include 'config.php';
if(isset($_POST['sub'])) {
$name=$_POST['name'];
$pwd=trim($_POST['pwd']);
if ($pwd == '') {
exit('玩家后台的授权密码不能为空');
}
mysql_query("set names 'utf8'"); //数据库输出编码
mysql_select_db($YZF_CONFIG['dbgame'].$qu,$con);
$result = mysql_query("SELECT * FROM actors WHERE actorname LIKE '{$name}' or accountname LIKE '{$name}' limit 1");
if($result&&mysql_num_rows($result)>0){
$row = mysql_fetch_array($result);
}
$uid =$row['actorid'];
$actorname =$row['actorname'];
$pwd=md5($uid.$pwd.$key);
$fp = fopen($vipfile, "a+");
if (filesize($vipfile) > 0) {
$str = fread($fp, filesize($vipfile));
fclose($fp);
$vipjson = json_decode($str, true);
if ($vipjson == null) {
$vipjson = array();
}
} else {
$vipjson = array();
}
if (!$vipjson[$uid]) {
echo "";
exit;
} elseif ($vipjson[$uid]['pwd'] != $pwd) {
echo "";
exit;
}
if ($vipjson[$uid]['qu'] != $qu) {
echo "";
exit;
}
$viplevel = intval($vipjson[$uid]['level']);
if($viplevel==1){
$_SESSION["vip"] = $viplevel;
$_SESSION["actorname"] = $actorname;
$_SESSION["name"] = $name;
$_SESSION["pwd"] = $pwd;
$_SESSION['expiretime'] = time();
mysql_close($con);;
header("Location:player.php");
}elseif($viplevel==2){
$_SESSION["vip"] = $viplevel;
$_SESSION["actorname"] = $actorname;
$_SESSION["name"] = $name;
$_SESSION["pwd"] = $pwd;
$_SESSION['expiretime'] = time();
mysql_close($con);;
header("Location:playermail.php");
}
echo "";
exit;
}