<?php
 
defined('IN_HS') or exit('Access Denied');
sajax_init();
sajax_export("savepass","savepriv","savelock");
sajax_handle_client_request();
function savepass($idx,$idserver,$npass)
{
global $db;
if(!$idx) return "未读取角色ID！";
if(!$idserver) return "未读取到分区ID！";
if(!$npass) return "请输入新密码";
$gamels = cache_read("gamelist_".$idserver.".php");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$dataacc);
if(!$mysqlco) return "连接分区失败，请检查服务器分区设置情况！";
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$dataacc);
$sqldb->query("SET NAMES DEFAULT");
$npass = hsmd5($npass);
$sqldb->query("UPDATE user SET password='$npass' WHERE idx='$idx'");
return "true";
}
function savepriv($idx,$idserver)
{
global $db;
if(!$idx) return "未读取角色ID！";
if(!$idserver) return "未读取到分区ID！";
$gamels = cache_read("gamelist_".$idserver.".php");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$dataacc);
if(!$mysqlco) return "连接分区失败，请检查服务器分区设置情况！";
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$dataacc);
$sqldb->query("SET NAMES DEFAULT");
$priv = $sqldb->get_one("SELECT user_priv FROM user WHERE idx='$idx'");
$priv = $priv['user_priv'];
if($priv == "65535")
{
$npriv = "1";
}else{
$npriv = "65535";
}
$sqldb->query("UPDATE user SET user_priv='$npriv' WHERE idx='$idx'");
if($npriv == "65535")
{
return '<input style="color:#900;font-weight:bold" name="button" type="button" class="btn" onClick="savepriv('.$idx.','.$idserver.')" value="GM帐号">';
}else{
return '<input name="button" type="button" class="btn" onClick="savepriv('.$idx.','.$idserver.')" value="普通帐号">';
}
}
function savelock($idx,$idserver)
{
global $db;
if(!$idx) return "未读取到角色ID！";
if(!$idserver) return "未读取到分区ID！";
$gamels = cache_read("gamelist_".$idserver.".php");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$dataacc);
if(!$mysqlco) return "连接分区失败，请检查服务器分区设置情况！";
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$dataacc);
$sqldb->query("SET NAMES DEFAULT");
$deleted = $sqldb->get_one("SELECT deleted FROM user WHERE idx='$idx'");
$deleted = $deleted['deleted'];
if($deleted == "1")
{
$ndeleted = "0";
}else{
$ndeleted = "1";
}
$sqldb->query("UPDATE user SET deleted='$ndeleted' WHERE idx='$idx'");
if($ndeleted == "1")
{
return '<input style="color:#f00;" name="button" type="button" class="btn" onClick="savelock('.$idx.','.$idserver.')" value="冻结中">';
}else{
return '<input style="color:green" name="button" type="button" class="btn" onClick="savelock('.$idx.','.$idserver.')" value=" 正常 ">';
}
}
switch($action)
{
case 'manage':
$idserver=intval($idserver);
if(!idserver) showmessage("非法操作！");
$gamels = $db->get_one("SELECT * FROM ".TABLE_GAMESERVER." WHERE id='$idserver'");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$dataacc);
if(!$mysqlco) showmessage("连接分区失败，请检查服务器分区设置情况！");
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$dataacc);
$sqldb->query("SET NAMES DEFAULT");
$page = isset($page) ?intval($page) : 1;
$pagesize = $HS['pagesize'] ?$HS['pagesize'] : 30;
$offset = ($page-1)*$pagesize;
$condition = '';
$condition .= $username ?" and username like '%$username%'": '';
$condition .= $user_priv ?" and user_priv= '$user_priv'": '';
$condition .= $deleted ?" and deleted= '$deleted'": '';
$condition .= $idx ?" and idx= '$idx'": '';
$r = $sqldb->get_one("SELECT count(*) as num FROM user WHERE 1 $condition");
$sumnums = $r['num'];
$pages = phppages($r['num'],$page,$pagesize);
$members = array();
$result = $sqldb->query("SELECT * FROM user WHERE 1 $condition ORDER BY idx DESC LIMIT $offset,$pagesize");
while($r = $sqldb->fetch_array($result))
{
$r['latest_login_date'] = date("m月d日H点i分",strtotime($r['latest_login_date']));
$members[] = $r;
}
include admintpl('acclist');
break;
case 'select':
$gamelist = array();
$result = $db->query("SELECT * FROM ".TABLE_GAMESERVER." ORDER BY id");
while($r = $db->fetch_array($result))
{
$gamelist[] = $r;
}
include admintpl('select');
break;
}
?>