<?php
 
defined('IN_HS') or exit('Access Denied');
sajax_init();
sajax_export("savepass","savemoney","savecontents","checkonline");
sajax_handle_client_request();
function savepass($accountid,$idserver,$newpass)
{
global $db;
if(!$accountid) return "未读取到仓库ID！";
if(!$idserver) return "未读取到分区ID！";
$gamels = cache_read("gamelist_".$idserver.".php");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
if(!$mysqlco) return "连接分区失败，请检查服务器分区设置情况！";
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
$sqldb->query("SET NAMES DEFAULT");
//if ($newpass) $newpass = hsmd5($newpass);
if ($newpass) $newpass = substr(md5($newpass),0,16);
$sqldb->query("UPDATE t_bank SET Password='$newpass' WHERE AccountID='$accountid'");
if($sqldb->affected_rows())
{
return "true";
}else{
return "更新失败，或者密码未作改变！";
}
}
function savemoney($accountid,$idserver,$newmoney)
{
global $db;
if(!$accountid) return "未读取到仓库ID！";
if(!$idserver) return "未读取到分区ID！";
$gamels = cache_read("gamelist_".$idserver.".php");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
if(!$mysqlco) return "连接分区失败，请检查服务器分区设置情况！";
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
$sqldb->query("SET NAMES DEFAULT");
if ($newpass == '') $newpass = 0;
$sqldb->query("UPDATE t_bank SET BankMoney='$newmoney' WHERE AccountID='$accountid'");
if($sqldb->affected_rows())
{
return "true";
}else{
return "更新失败，或者仓库存款未作改变！";
}
}
function savecontents($iduser,$idserver,$Items)
{
global $db;
if(!$idserver) return "未读取到分区ID！";
if(!$iduser) return "未读取到角色信息！";
if($Items == '') return "请将仓库道具填写完整，不要留空！";
$gamels = cache_read("gamelist_".$idserver.".php");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
if(!$mysqlco) return "连接分区失败，请检查服务器分区设置情况！";
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
$sqldb->query("SET NAMES DEFAULT");
$sqldb->query("UPDATE t_bank SET `Items`='$Items' WHERE AccountID='$iduser'");
if($sqldb->affected_rows())
{
return "true";
}else{
return "更新失败，或者原数据未作任何改变！请刷新页面或重试！";
}
}
function checkonline($idserver,$AccountID)
{
global $db;
if(!$idserver) return "未读取到分区ID！";
if(!$AccountID) 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");
$accinfo = $sqldb->get_one("SELECT latest_login_date FROM user WHERE idx='$AccountID' ORDER BY idx DESC limit 0,1");
$truetime = $accinfo['latest_login_date'];
$leavel = $sqldb->get_one("SELECT leave_time FROM consume WHERE AccountID='$AccountID' ORDER BY idx DESC limit 0,1");
$outtime = $leavel['leave_time'];
$sumdo = strtotime($truetime);
$sumdt = strtotime($outtime);
if ($sumdo >$sumdt)
{
return "该帐号下有角色在线，修改后可能会被在线角色覆盖！";
}else{
return "该帐号下没有角色在线，可以进行修改！";
}
}
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,$datafso);
if(!$mysqlco) showmessage("连接分区失败，请检查服务器分区设置情况！");
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
$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 u.username like '%$username%'": '';
$condition .= $AccountID ?" and AccountID= '$AccountID'": '';
$ordertype = $ordertype ?$ordertype : 'AccountID';
$r = $sqldb->get_one("SELECT count(*) as num FROM t_bank t,".$dataacc.".user u WHERE t.AccountID=u.idx $condition");
$sumnums = $r['num'];
$pages = phppages($r['num'],$page,$pagesize);
$members = array();
$result = $sqldb->query("SELECT t.*,u.username FROM t_bank t,".$dataacc.".user u WHERE t.AccountID=u.idx $condition ORDER BY $ordertype DESC LIMIT $offset,$pagesize");
while($r = $sqldb->fetch_array($result))
{
$members[] = $r;
}
include admintpl('banklist');
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;
}
?>