<?php
session_start();
include_once("inc/conn.php");
include_once("inc/function.php");
?>
<!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" />
<script type="text/javascript" src="inc/reg.js"></script>
</head>
<?php include_once("top.php");?>
<DIV class="wrapper">
	<DIV class="page_content">
		<DIV class="webgame-activities-title">
			<H3>找回密码</H3>
		</DIV>
			<div class="main_users">
				 <div class="main_txzreg">
				 	<?
					if($_GET["act"]=="forget"){
						if(strtolower($_SESSION["yan"])!=strtolower($_POST["tbSafeCode"])){
							echo "<script language=javascript>alert('验证码错误');history.go(-1);</script>";
							exit;
						}
						
						$tbUserSecQues=str_check($_POST["tbUserSecQues"]);
						$tbUserSecAns=str_check($_POST["tbUserSecAns"]);
						if($_POST["r"]==1){
						$tbUserAccount=intval($_POST["tbUserAccount"]);
						$query_f=$db->query("Select * from {$web_dbtop}users where id=$tbUserAccount");
						}else{
						$tbUserAccount=str_check($_POST["tbUserAccount"]);
						$query_f=$db->query("Select * from {$web_dbtop}users where email='$tbUserAccount'");
						}
						if($rs_f=$db->fetch_array($query_f)){
							if($rs_f["secques"]==$tbUserSecQues and $rs_f["secans"]==$tbUserSecAns){
								$newpassword=random(6);
								$db->query("update {$web_dbtop}users set password='".md5($newpassword)."' where id=".$rs_f["id"]);
								echo "<div align=\"center\" style=\"margin-top:50px;font-size: 14px;color: #FF6600;\">安全问题回答正确。<br>您的新密码是：$newpassword</div>";
							}else{
								echo "<div align=\"center\" style=\"margin-top:50px;font-size: 14px;color: #FF6600;\">对不您的安全答案不正确！</div>";
							}
						}else{
							echo "<div align=\"center\" style=\"margin-top:50px;font-size: 14px;color: #FF6600;\">对不起没有该用户！</div>";
						}
					}else{
					?>
					<FORM action="?act=forget" method="post" onsubmit="return Chkforpwd()">
					<table width="580" border="0" align="center" cellpadding="0" cellspacing="0" class="table_setpw">
						<tr>
							<th width="80">帐户类型：</th>
							<td width="500"><INPUT id=rID type=radio CHECKED value=1 name=r> ID <INPUT id=rMail type=radio value=0 name=r>E-mail</td>
						</tr>
						<tr>
							<th>通行证：</th>
							<td><INPUT class="inpA" maxLength=50 name="tbUserAccount" id="tbUserAccount"> <span id="sUserAccount"></span></td>
						</tr>
						<tr>
							<th>安全提问：</th>
							<td><SELECT class=bk name="tbUserSecQues" id="tbUserSecQues">
                      <OPTION value="" selected>请选择机密问题</OPTION>
                      <OPTION value=你父亲的姓名是什么?>你父亲的姓名是什么?</OPTION>
                      <OPTION value=你母亲的姓名是什么?>你母亲的姓名是什么?</OPTION>
                      <OPTION value=你的出生地?>你的出生地?</OPTION>
                      <OPTION value=你的宠物的名子?>你的宠物的名子?</OPTION>
                      <OPTION value=你的职业是什么?>你的职业是什么?</OPTION>
                      <OPTION value=你配偶的职业是什么?>你配偶的职业是什么?</OPTION>
                    </SELECT>
					<span id="sUserSecQues"></span></td>
						</tr>
						<tr>
							<th>安全提问：</th>
							<td><INPUT class="inpA" maxLength=50 name="tbUserSecAns" id="tbUserSecAns"> <span id="sUserSecAns"></span></td>
						</tr>
						<tr>
							<th>验证码：</th>
							<td><input name="tbSafeCode" type="text" id="tbSafeCode" class="inp_yzm" />
							&nbsp; <img id="vdimgck" width="60" height="24" src="inc/code.php" alt="看不清？点击更换" align="absmiddle" style="cursor:pointer" onclick="this.src=this.src+'?'" /></td>
						</tr>
						<tr>
							<th>&nbsp;</th>
							<td> <button class="btn" id="btnSignCheck" type="submit">下一步</button>&nbsp;</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>