<!-- #Include File="../Include/Skin.asp" -->
<!-- #Include File="../Include/Inc_md5.asp" -->
<!-- #Include File="../Include/Inc_sendmail.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

tit="取回密码"
call DoWebHead(0,0)
select case action
case "chk"
  call getpass_chk()
case else
  call getpass_main()
end select
call DoWebEnd()
sub getpass_chk()
  dim found_err,username,passwd,email,uid,upower,newpass,sbody,sendmail,sTmp,ulock
  username=trim(request.form("username"))
  passwd=Cls.Code_Var(request.form("passwd"))
  email=trim(request.form("email"))
  found_err=""
  if ChkName(username)=false then
    found_err=found_err&"+您输入的 <font class=red>用户名称</font> 为空或不符合相关规则！<br />"
  End If
  if ChkName(passwd)=false then
    found_err=found_err&"+您输入的 <font class=red>密码钥匙</font> 为空或不符合相关规则！<br />"
  End If
  if Cls.Is_Email(email,50)=false then
    found_err=found_err&"+您输入的 <font class=red>E-mail</font> 为空或不符合邮件规则！<br />"
  End If
  if Not Cls.CodeIsTrue() then
    found_err=found_err&"+您提交的 <font class=red2>验证码</font> 为空或有错误，请勿非法提交！<br />"
  End If
  if found_err<>"" then
       Cls.ReadPage "common"
	   Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
	   Cls.HtmlRcod "tit",tit
	   Cls.OutPage
    exit sub
  End If
  sql="select top 1 id,power,islock from AsaiMHUserData where hidden=1 and username='"&username&"' and passwd='"&AsaiMHMd5(passwd,"short")&"' and email='"&email&"'"
  set rs=Cls.exec(sql,1)
  if rs.eof then
    rs.close
    found_err=found_err&"+您输入的取回密码信息有错误或用户不存在！<br />"
       Cls.ReadPage "common"
	   Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
	   Cls.HtmlRcod "tit",tit
	   Cls.OutPage
    exit sub
  End If
  uid=rs("id")
  upower=rs("power")
  ulock=rs("islock")
  rs.close
  if format_power(upower,2)=1 then
    found_err=found_err&"+<font class=blue>管理员不可以取回密码！请与网站管理者联系取回。</font><br />"
  End If
  if ulock=true then
    found_err=found_err&"+用户(<font class=blue>"&username&"</font>)已被<font class=red>锁定</font>！不可以取回密码。<br />"
  End If
  if found_err<>"" then
       Cls.ReadPage "common"
	   Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
	   Cls.HtmlRcod "tit",tit
	   Cls.OutPage
    exit sub
  End If
  newpass=Cls.rand_num(8)
  sbody=vbcrlf&"您于 "&Cls.time_type("",2)&" 使用了系统的密码取回功能！" & _
	vbcrlf& _
	vbcrlf&"系统生成的随机登陆密码为："&newpass& _
	vbcrlf& _
	vbcrlf&"请尽快登陆本站并修改一个安全的密码！" & _
	vbcrlf& _
	vbcrlf& Cls.web_urls &"login.asp"
  sendmail=send_mail(username,email,tit,sbody)
    sTmp="<table border=0 align=center><tr><td><p class=htd><font class=red>成功取回密码！</font><br /><br />"
  if sendmail then
    sTmp=sTmp&"系统已将新的密码发送到您的邮箱（"&email&"）中！"
  else
    sTmp=sTmp&"系统配置不正常，注册邮件没有能正确发送！<br />新的随机密码为："&newpass
  End If
  sTmp=sTmp&"<br /><br />请及时 <a href='login.asp'>登陆</a> 并修改一个安全的密码。</p></td></tr></table>"
  Cls.ReadPage "common"
	Cls.HtmlRcod "tit",tit
	Cls.HtmlRcod "msg",sTmp
	Cls.OutPage
  call Cls.exec("update AsaiMHUserData set password='"&AsaiMHMd5(newpass,"short")&"' where id="&uid,0)
End Sub
sub getpass_main()
    Cls.ReadPage "getpass_main"
	Cls.HtmlRcod "GetCode",Cls.GetCode()
	Cls.HtmlRcod "tit",tit
    Cls.HtmlRcod "m_help2",img_skin("m_help2")
	Cls.OutPage
End Sub
%>
