<%
Option Explicit
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<!--#include file="inc/config.asp" -->
<!--#include file="inc/conn.asp" -->
<!--#include file="inc/function.asp" -->
<!--#include file="inc/md5.asp" -->
<!--#include file="inc/sql_filter.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>找回密码</title>
<link href="style/global.css" rel="stylesheet" type="text/css" />
<link href="member/style/member.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style3{ color:#F00;}
.msg{ line-height:20px; padding:5px; color:#930;}
</style>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript">
// JavaScript Document
function check(obj){
	if(obj.UserName.value==""){
		alert("用户名不能为空!");
		obj.UserName.focus();
		obj.UserName.select();
		return false;
	}
	if(obj.ForAsk.value==""){
		alert("请填写密码问题!");
		obj.ForAsk.focus();
		obj.ForAsk.select();
		return false;
	}
	if(obj.ForAnswer.value==""){
		alert("请填写密码答案!");
		obj.ForAnswer.focus();
		obj.ForAnswer.select();
		return false;
	}
	if(obj.CheckCode.value==""){
		alert("验证码不能为空!");
		obj.CheckCode.focus();
		obj.CheckCode.select();
		return false;
	}
	return true;
}
function checkemail(semail){
	var pattern = /^([\.a-zA-Z0-9_-]){3,}@([\.a-zA-Z0-9_-]){2,}(\.([a-zA-Z0-9]){2,4}){1,2}$/; 
	return pattern.test(semail);
}
</script>
</head>
<body>
<!--#include file="templet/head.htm" -->
<%
dim act
act=request.QueryString("act")
if(act="do") then
	if(isSelfRefer()) then
	else
		call alertstr("禁止外部提交",2)
	end if
	dim rs,UserName,ForAsk,ForAnswer,CheckCode,UIP,IsRight,GenMsg,NewPassWd
	dim m_ask,m_answer
	UserName=replaceBadChar(request.Form("UserName"))	
	ForAsk=replaceBadChar(request.Form("ForAsk"))
	ForAnswer=replaceBadChar(request.Form("ForAnswer"))
	CheckCode=request.Form("CheckCode")
	if CheckCode <> CStr(Session("GetCode"))  then 
		call alertstr("错误：\n验证码错误",1)
	end if
	if CheckCode= "" then
		call alertstr("错误：\n验证码错误",1)
	elseif Session("GetCode") = "9999" then
		Session("GetCode")=""
	elseif Session("GetCode") = "" then
		call alertstr("错误：\n验证码错误",1)
	elseif cstr(Session("GetCode"))<>cstr(Trim(CheckCode)) then
		call alertstr("错误：\n您输入的确认码和系统产生的不一致，请重新输入。\n返回后请刷新登录页面后重新输入正确的信息",2)		
	end if
	Session("GetCode")=""
	UIP=GetIp()	
	NewPassWd=Md5("123456",32)
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from t_member where UserId='"&UserName&"'",conn,3,1
	if not rs.eof then
		m_ask=rs("PassAsk")
		m_answer=rs("PassAnswer")
		if(m_ask=ForAsk and m_answer=ForAnswer) then
			IsRight=true
			conn.execute("update t_member set UserPass='"&NewPassWd&"' where UserId='"&UserName&"'")
			GenMsg="您的密码已重置为：123456，请使用该密码登录并尽快修改您的密码"
		else
			IsRight=false
			GenMsg="您的密码问题或答案错误！"
		end if
	else
		IsRight=false
		GenMsg="没有找到此用户"		
	end if
	rs.close
	set rs=nothing
	response.Write("<p align=""center"" class=""msg"">"&GenMsg&"</p>")
else
%>
<form id="form1" name="form1" method="post" action="?act=do" onsubmit="return check(this)">
  <table width="960" align="center" cellpadding="0" cellspacing="1" bgcolor="#fff0cf" class="tableborder">
    <tr align="middle">
      <th colspan="2" class="pad_10">找回密码</th>
    </tr>
    <tr>
      <td height="22" colspan="2" bgcolor="#FFFFFF" class="pformleft">&nbsp;</td>
    </tr>
    <tr>
      <td width="46%" bgcolor="#FFFFFF" class="pad_5"><strong>用户名</strong>：</td>
      <td width="54%" bgcolor="#FFFFFF" class="pformleft"><input name="UserName" id="UserName" size="30" maxlength="20" />
        (<span class="style3">*</span>)<span id="userMsg"></span></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="pad_5"><strong>密码问题</strong>：</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="ForAsk" id="ForAsk" size="30" />
      (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="pad_5"><strong>问题答案</strong>：</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="ForAnswer" id="ForAnswer" size="30" />
      (<span class="style3">*</span>)</td>
    </tr>
	<tr>
      <td width="46%" bgcolor="#FFFFFF" class="pad_5"><strong>请输入验证码</strong>：</td>
    <td width="54%" bgcolor="#FFFFFF" class="pformleft">
          <input size="5" name="CheckCode" />          
          <% = GetCode() %>
          (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#FFFFFF" class="row4"><div align="center">
        <input type="submit" name="Submit" value="确定" />
        <input type="reset" name="Submit2" value="重 写" />
      </div></td>
    </tr>
  </table>
</form>
<%
	end if
%>
<!--#include file="templet/root.htm" -->
</body>
</html>
<%
call connclose()
%>