<?php
session_start();
include_once("inc/conn.php");
include_once("inc/function.php");
login_check();
$query=$db->query("Select * from {$web_dbtop}users where id =".intval($_COOKIE["usersid"])." and password='".str_check($_COOKIE["password"])."'");
	if($rs=$db->fetch_array($query)){
			$editid=$rs["editid"];
		}
	if($editid==0){
		echo "<script language=javascript>alert('对不起，您没有被授权使用该功能！');history.go(-1);</script>";
		exit;
	}
	if($_GET["act"]=="editid"){
		if(!is_numeric($_POST["tbeidtid"])){
			echo "<script language=javascript>alert('对不起，输入id格式不正确，只能是数字！');history.go(-1);</script>";
			exit;
		}
		if(!$_POST["tbeidtid"]){
			echo "<script language=javascript>alert('对不起，请输入修改的id！');history.go(-1);</script>";
			exit;
		}
		if(strlen($_POST["tbeidtid"])>10){
			echo "<script language=javascript>alert('对不起，长度请不要超过10位数！');history.go(-1);</script>";
			exit;
		}
		if(strtolower($_SESSION["yan"])!=strtolower($_POST["tbSafeCode"])){
			echo "<script language=javascript>alert('验证码错误!');history.go(-1);</script>";
			exit;
		}
		$query=$db->query("Select * from {$web_dbtop}users where id =".intval($_POST["tbeidtid"])."");
		if($rs=$db->fetch_array($query)){
			echo "<script language=javascript>alert('该ID已经被使用,请重新选择！');history.go(-1);</script>";
			exit;
		}
		ck_secans(str_check($_POST["tbUserSecAns"]));
		$query=$db->query("Select * from {$web_dbtop}editid where id =1");
		if($rs=$db->fetch_array($query)){
			$blid=explode("\r",$rs["content"]);
			$count = count($blid)-1;
			for($i=0;$i<=$count;$i++){
				if(stristr($blid[$i],"-")){
					$blidx=explode("-",str_replace("\n","",$blid[$i]));
					if($blidx[0]<=intval($_POST["tbeidtid"]) && $blidx[1]>=intval($_POST["tbeidtid"])){
						echo "<script language=javascript>alert('该ID已经被使用,请重新选择！');history.go(-1);</script>";
						exit;
					}
				}else{
					if(intval($_POST["tbeidtid"])==intval(str_replace("\n","",$blid[$i]))){
						echo "<script language=javascript>alert('该ID已经被使用,请重新选择！');history.go(-1);</script>";
						exit;
					}
				}
			}
		}
		
		$db->query("update {$web_dbtop}users set id=".intval($_POST["tbeidtid"]).",editid=0 where id =".intval($_COOKIE["usersid"])." and password='".str_check($_COOKIE["password"])."'");
		$db->query("update {$web_dbtop}users set tjid=".intval($_POST["tbeidtid"])." where tjid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}adip set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}adlogusers set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}advice set usersid=".intval($_POST["tbeidtid"])." where usersid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}backlog set usersid=".intval($_POST["tbeidtid"])." where usersid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}bbs_posts set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}bbs_reply set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}business set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}card set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}exchange set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game_log set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game11_auto set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game11_auto_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game11_users_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game11_kg_users_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game16_auto set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game16_auto_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game16_users_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game16_kg_users_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game28_auto set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game28_auto_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game28_users_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game28_kg_users_tz set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game_log set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}game_experience set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}gamebox_log set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}gamedodge set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}msg set usersid=".intval($_POST["tbeidtid"])." where usersid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}userslog set usersid=".intval($_POST["tbeidtid"])." where usersid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}webip set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		$db->query("update {$web_dbtop}tjlog set uid=".intval($_POST["tbeidtid"])." where uid =".intval($_COOKIE["usersid"]));
		setcookie("usersid",intval($_POST["tbeidtid"]));
		echo "<script language=javascript>alert('帐号ID修改成功！');location.href='index.php';</script>";
		exit;
	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>修改靓号-<?=$web_name;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<?=$web_keywords;?>" />
<meta name="description" content="<?=$web_description;?>" />
<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<link href="style/default.css" rel="stylesheet" type="text/css" />
</head>
<?php include_once("top.php");?>
<script language="javascript">
qiehuan(6);
document.getElementById("qh_con6").getElementsByTagName('li')[2].className="current";
</script>
<DIV class="wrapper">
	<DIV class="page_content">
		<DIV class="webgame-activities-title">
			<H3>修改靓号</H3>
		</DIV>
		<div class="main_users">
			<div class="main_txzreg">
				<p class="tit_reg"><img src="images/icon_tit01.gif" />&nbsp;&nbsp;请注意靓号位数为10位请不要超过，只能填写数字。</p>
				 <form action="?act=editid" method="post">
					<table width="750" border="0" cellspacing="0" cellpadding="0" class="table_reg">  
					<?
					$query=$db->query("Select * From {$web_dbtop}users where id=".intval($_COOKIE["usersid"])." and password='".str_check($_COOKIE["password"])."'");
					if($rs=$db->fetch_array($query)){
					?>           
						<tr>
						<th width="150">帐号ID：</th>
							<td width="300"><input name="tbeidtid" class="inpA" type="text" id="tbeidtid" /></td>
							<td width="300">只能填写数字,位数为10位请不要超过</td>
						</tr>
						<tr>
						<th>密码保护问题：</th>
							<td width="300"><?=$rs["secques"];?></td>
							<td width="300"></td>
						</tr>
						<tr>
						<th>密码保护答案：</th>
							<td width="300"><input class="inpA" id="tbUserSecAns" type="text" value="" name="tbUserSecAns" /></td>
							<td width="300"></td>
						</tr>
						<tr>
							<th>验证码：</th>
							<td><input name="tbSafeCode" type="text" id="tbSafeCode" style='text-transform:uppercase;' class="inp_yzm"/>&nbsp; <img id="regSafeCode" onClick="$('regSafeCode').src='inc/code.php';" src="inc/code.php" alt="看不清？点击更换" style="cursor:pointer"  width="60" height="26" /> <a href="javascript:showCode();">看不清楚？换个图片</a></td>
							<td></td>
						</tr>
						<tr>
							<th>&nbsp;</th>
							<td class="btn_reg"><input name="" type="image" src="images/ljtj.gif"></td>
						</tr>
					<?
					}
					?>
					</table>
				</form>
			</div>
		</div>
		<div class="area960-b h5px"></div>
		<DIV class=cl></DIV>
	</div>
	<!--Flink End-->
	<div class="blank10"></div>
	<!--Footer Start-->
<?php include_once("footer.php");?>
</DIV>