<?php
 
defined('IN_HS') or exit('Access Denied');
sajax_init();
sajax_export("savename","savedel","savecontents","checkonline","chkcopy");
sajax_handle_client_request();
function chkcopy($idserver,$iduser)
{
global $MOD;
if(!$idserver) return "<span style='font-size:14px;color:red;font-weight:bold'>未读取到分区ID！</span>";
if(!$iduser) return "<span style='font-size:14px;color:red;font-weight:bold'>未读取到角色信息！</span>";
if(!$MOD['ccitems']) return "<span style='font-size:14px;color:red;font-weight:bold'>猪！<a href='?mod=game&file=setting' style='color:red;TEXT-DECORATION: underline'>先在游戏模块中设置要检查的道具ID</a></span>";
$gamels = cache_read("gamelist_".$idserver.".php");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
if(!$mysqlco) return "<span style='font-size:14px;color:red;font-weight:bold'>连接分区失败，请检查服务器分区设置情况！</span>";
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$datafso);
$sqldb->query("SET NAMES DEFAULT");
$its = $sqldb->get_one("SELECT Items FROM user WHERE ID='$iduser'");
$items = explode(',',$its['Items']);
$ccitems = explode(',',$MOD['ccitems']);
$citem = '';
foreach($items as $key =>$item)
{
foreach($ccitems as $ccitem)
{
if($item == $ccitem)
{
$i= $key -1;
if(strlen($items[$i]) >6 &&strpos($citem,$item)===FALSE)
{
$hbitems = $items[$i].",".$item.",";
$ri = $sqldb->get_one("SELECT count(*) as inum FROM user WHERE Items LIKE '%$hbitems%'");
$rb = $sqldb->get_one("SELECT count(*) as bnum FROM t_bank WHERE Items LIKE '%$hbitems%'");
$inum = ($ri['inum']) ?$ri['inum'] : 0;
$bnum = ($rb['bnum']) ?$rb['bnum'] : 0;
$totnums = $inum+$bnum;
if($totnums >1)
{
$citem .= "共".$totnums."个".$hbitems." 其中<a href='?words=".$hbitems."&action=sfso&mod=game&file=searchitem&idserver=".$idserver."' target='_blank' style='color:red;TEXT-DECORATION: underline'>".$inum."个在角色背包</a>，<a href='?words=".$hbitems."&action=sban&mod=game&file=searchitem&idserver=".$idserver."' target='_blank' style='color:red;TEXT-DECORATION: underline'>".$bnum."个在角色仓库</a><br>";
}
}
}
}
}
if($citem)
{
return "<span style='font-size:14px;color:darkgreen;font-weight:bold'>查出可疑道具(请点击下面的红色的链接进行管理)：</span><br>".$citem;
}else{
return "<span style='font-size:14px;color:darkgreen;font-weight:bold'>该角色身上未查到复制道具！</span>";
}
}
function savecontents($iduser,$idserver,$Level,$EXP,$PK,$Credit,$Faction,$MetierLevel,$Gold,$Con,$Str,$Int,$Dex,$Hit,$AP,$SP,$OnlineTime,$Skills,$Task)
{
global $db;
if(!$idserver) return "未读取到分区ID！";
if(!$iduser) return "未读取到角色信息！";
$Skills = $_COOKIE['cookskills'];
$Task = $_COOKIE['cooktask'];
$Items = $_COOKIE['cookitems'];
if(!$Items) return "你禁用了Cookie或将Items设为了空。这样是不允许的！";
$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($PK != '0'||$PK)
{
$PK = $PK*60000;
}else{
$PK = 0;
}
if($OnlineTime != '0'||$OnlineTime)
{
$OnlineTime = $OnlineTime*60;
}else{
$OnlineTime = 0;
}
$sqldb->query("UPDATE user SET `Level`='$Level',`EXP`='$EXP',`PK`='$PK',`Credit`='$Credit',`Faction`='$Faction',`MetierLevel`='$MetierLevel',`Gold`='$Gold',`Con`='$Con',`Str`='$Str',`Int`='$Int',`Dex`='$Dex',`Hit`='$Hit',`AP`='$AP',`SP`='$SP',`OnlineTime`='$OnlineTime',`Skills`='$Skills',`Task`='$Task',`Items`='$Items' WHERE ID='$iduser'");
if($sqldb->affected_rows())
{
return "true";
}else{
return "更新失败，或者原数据未作任何改变！请刷新页面或重试！";
}
}
function checkonline($idserver,$iduser)
{
global $db;
if(!$idserver) return "未读取到分区ID！";
if(!$iduser) return "未读取到角色信息！";
$gamels = cache_read("gamelist_".$idserver.".php");
@extract($gamels,EXTR_OVERWRITE);
$mysqlco = @mysql_connect($serverip.':'.$port,$loginname,$loginpass,$datalog);
if(!$mysqlco) return "连接分区失败，请检查服务器分区设置情况！";
$sqldb = new db_mysql;
$sqldb->connect($serverip.':'.$port,$loginname,$loginpass,$datalog);
$sqldb->query("SET NAMES DEFAULT");
$rl = $sqldb->get_one("SELECT LogTime FROM t_log_user_history WHERE type='15' AND `longParam1`='1' AND userID='$iduser' ORDER BY OperateID DESC limit 0,1");
$truetime = $rl['LogTime'];
$ro = $sqldb->get_one("SELECT LogTime FROM t_log_user_history WHERE type='15' AND `longParam1`='2' AND userID='$iduser' ORDER BY OperateID DESC limit 0,1");
$outtime = $ro['LogTime'];
$sumdo = strtotime($truetime);
$sumdt = strtotime($outtime);
if ($sumdo >$sumdt)
{
return "该角色在线，修改可会失败！";
}else{
return "该角色不在线，可以进行修改！";
}
}
function savename($iduser,$idserver,$oldname,$newname)
{
global $db;
if(!$iduser) return "未读取到角色ID！";
if(!$idserver) return "未读取到分区ID！";
if(!$oldname) return "信息读取错误！";
if(!$newname) 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");
$che = $sqldb->get_one("SELECT ID FROM user WHERE Name='$newname'");
if ($che) return "这个名字已被其它玩家使用了，请换一个！";
$sqldb->query("UPDATE user SET Name='$newname',UniqueName='$newname' WHERE ID='$iduser'");
return "true";
}
function savedel($iduser,$idserver)
{
global $db,$PHP_TIME;
if(!$iduser) 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");
$r = $sqldb->get_one("SELECT AccountID,deleted FROM user WHERE ID='$iduser'");
$deleted = $r['deleted'];
if($deleted != "0")
{
$ndeleted = "0";
$AccountID = $r['AccountID'];
$rs = $sqldb->get_one("SELECT count(*) as num FROM user WHERE AccountID='$AccountID' AND deleted='$ndeleted'");
if ($rs['num'] >2) return "toomuck";
$sqldb->query("UPDATE user SET deleted='$ndeleted',DeleteDate=Null WHERE ID='$iduser'");
}else{
$ndeleted = "2";
$ndeltime = date("Y-m-d H:i:s",$PHP_TIME);
$sqldb->query("UPDATE user SET deleted='$ndeleted',DeleteDate='$ndeltime' WHERE ID='$iduser'");
}
if($ndeleted != "0")
{
return '<input style="color:#f00;" name="button" type="button" class="btn" onClick="savedel('.$iduser.','.$idserver.')" value="已删除">';
}else{
return '<input style="color:green" name="button" type="button" class="btn" onClick="savedel('.$iduser.','.$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,$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 .= $Name ?" and Name like '%$Name%'": '';
$condition .= $deleted ?" and deleted= '$deleted'": '';
$condition .= $AccountID ?" and AccountID= '$AccountID'": '';
$condition .= $ID ?" and ID= '$ID'": '';
$ordertype = $ordertype ?$ordertype : 'ID';
$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 $ordertype DESC LIMIT $offset,$pagesize");
while($r = $sqldb->fetch_array($result))
{
$r['CreateDate'] = date('Y年m月d日H点',strtotime($r['CreateDate']));
$r['DeleteDate'] = date('Y年m月d日H点',strtotime($r['DeleteDate']));
$r['LastUpdateDate'] = date('Y年m月d日H点',strtotime($r['LastUpdateDate']));
$r['OnlineTime'] = floor($r['OnlineTime']/60);
$r['PK'] = ceil($r['PK']/60000);
$members[] = $r;
}
include admintpl('fsolist');
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;
case 'senditem':
$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 username like '%$username%'": '';
$condition .= $deleted ?" and deleted= '$deleted'": '';
$condition .= $AccountID ?" and AccountID= '$AccountID'": '';
$ordertype = $ordertype ?$ordertype : 'ID';
$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 $ordertype DESC LIMIT $offset,$pagesize");
while($r = $sqldb->fetch_array($result))
{
$members[] = $r;
}
include admintpl('senditem');
break;
}
?>