<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/function.asp"-->
<%
If isjmail=0 Then
Response.Write("<script>alert('对不起，网站暂时不支持找回密码功能！');location.href='login.asp';</script>")
Response.End()
End If
If Request("act")=1 Then
  Call Cw_yzm()'验证码
  e_email=Trim(Request.Form("email"))
  e_user=Trim(Request.Form("user"))
  e_rnd=Cw_rnd(19)
  e_code=Cw_rnd(50)
  Set rs=Server.CreateObject("adodb.recordset")
  sql="select * from cw_user where [user]='"&e_user&"' and ismail=1"
  rs.Open sql,conn,1,3
  If Not rs.Eof Then   
     email=rs("email")  	 
	 If email=e_email then	   
	   rs("repass")=e_rnd
	   rs.Update
	   e_tit=cf_name&"-密码找回"
	   e_con="亲爱的"&cf_name&"用户："&e_user&"<br />您正在使用密码找回功能，您的验证码是："&e_rnd&"（不区分大小写）"	   
	   jm=Cw_jmail(cf_smtp,cf_email,cf_name,cf_jmailUser,cf_jmailPass,e_email,e_tit,e_con)
	   If jm=0 Then Response.Write("<script>alert('验证码己发送到邮箱，请进入邮箱查看！');location.href='cw_repass.asp?act=2&u="&e_user&"&code="&e_code&"';</script>")
	   If jm=1 Then Response.Write("<script>alert('验证码发送失败，暂不支持找回密码！');history.back();</script>")
	   If jm=2 Then Response.Write("<script>alert('验证码发送失败，暂不支持找回密码！');history.back();</script>")
	 Else
	   Response.Write("<script>alert('该帐号不支持找回密码！'); history.back();</script>")
	   Response.End()
	 End If
  Else	 
	 Response.Write("<script>alert('该帐号不支持找回密码！'); history.back();</script>")
	 Response.End()
  End If
  rs.Close
  set rs=nothing
  Response.End()
End If
If Request("act")=3 Then
  Set ru=Server.CreateObject("adodb.recordset")
  ruq="select * from cw_user where [user]='"&Request("u")&"'"
  ru.Open ruq,conn,1,3
  If Not ru.Eof Then
    repass=ru("repass")
	yzm=Trim(Request("yzm"))
	If repass<>yzm Then
	   Response.Write("<script>alert('验证码错误！');history.back();</script>")
	   Response.End()
	Else
	   ru("pass")=md5(Trim(Request("pass")))
	   ru("repass")=""
	   ru.Update
	   Response.Write("<script>alert('密码重置成功！');location.href='login.asp';</script>")
	   Response.End()
	End If
  Else
    Response.Write("<script>alert('非法操作，你己被记录！');location.href='../';</script>")
  End If
  ru.Close
  Set ru=Nothing
End If
%>
<!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>帐号密码找回 - <%=cf_name%></title>
<link rel="stylesheet" type="text/css" href="images/style.css" />
<script type="text/javascript" src="images/us.js"></script>
</head>

<body>
<!--#include file="top.asp"-->
<div class="reg">
   <div class="reg_left"><br /><br /><br />
      <%If Request("act")="" then%>
      <form action="cw_repass.asp?act=1" method="post" onsubmit="return Check_repass(this)">
      <div class="reg_box"><span>登录帐号：</span><input name="user" type="text" id="user" tabindex="1" value="6-12位用户名" maxlength="20" onfocus="this.className='login_input2';if(this.value=='6-12位用户名'){this.value=''};" onblur="this.className='login_input';if(this.value==''){this.value='6-12位用户名'};" class="login_input" /><label id="f_user"></label></div>  

	  <div class="reg_box"><span>联系邮箱：</span><input name="email" type="text" id="email" tabindex="5" value="example@163.com" maxlength="20" onfocus="this.className='login_input2';if(this.value=='example@163.com'){this.value=''};" onblur="this.className='login_input';if(this.value==''){this.value='example@163.com'};" class="login_input" /><label id="f_email"></label></div>
	  
	  <div class="reg_box2"><span>验 证 码：</span><input name="yzm" type="text" id="yzm" tabindex="7" value="" maxlength="5"  onfocus="this.className='login_input4';" onblur="this.className='login_input3';" class="login_input3" />&nbsp;&nbsp;<img src="../inc/code.asp" width="80" height="25" alt="看不清单击刷新" onclick="this.src='../inc/code.asp?' + Math.random();" style="cursor:pointer" align="absmiddle"/>
	    <label id="f_yzm"></label></div>
	  <div class="login_box"><input type="submit" name="sub" value="下一步，邮箱找回密码！" class="reg_btn" /></div>
	  </form>
	  <%
	  End If
	  If Request("act")=2 Then
	  %>
	  <form action="cw_repass.asp?act=3" method="post" onsubmit="return Check_repass2(this)">
      <div class="reg_box"><span>新 密 码：</span>
        <input name="pass" type="password" id="pass" tabindex="1" maxlength="20" onfocus="this.className='login_input2';" onblur="this.className='login_input';" class="login_input" />
        <label id="f_p1"></label></div>  

	  <div class="reg_box"><span>确认密码：</span><input name="pass2" type="password" id="pass2" tabindex="5" maxlength="20" onfocus="this.className='login_input2';" onblur="this.className='login_input';" class="login_input" />
	    <label id="f_p2"></label></div>
	  
	  <div class="reg_box2"><span>验 证 码：</span><input name="yzm" type="text" id="yzm" tabindex="7" value="邮箱收到的验证码" maxlength="21"  onfocus="this.className='login_input2';if(this.value=='邮箱收到的验证码'){this.value='';}" onblur="this.className='login_input';if(this.value==''){this.value='邮箱收到的验证码';}" class="login_input" />
	    <label id="f_yzm"></label><input type="hidden" name="u" value="<%=Request("u")%>" /></div>
	  <div class="login_box"><input type="submit" name="sub" value="下一步，重置密码" class="reg_btn" />

	  </div>
	  </form>
	  <%
	  End If
	  %>
   </div>
   <div class="reg_right">      
      <div class="login_bg">
	       <p><b>忘记了登录密码？</b><br />找回密码的前提是你注册的用户名己经成功<br />通过了该帐号绑定的对应邮箱的验证！<br /><a href="login.asp"><img src="images/login_s.png" /></a></p>
	  </div>
   </div>
   <div class="clear"></div>
</div>
<!--#include file="foot.asp"-->
</body>
</html>
