<!-- #include file="../include/skin.asp" -->
<!-- #include file="../include/jk_md5.asp" -->
<!-- #include file="../include/jk_email.asp" -->
<!-- #include file="../include/jk_sendmail.asp" -->
<!-- #include file="../include/jk_val_code.asp" -->
<%

tit="取回密码"

call web_head(0,0,2,0,0)
%>
<table border=0 width='70%'>
<tr><td align=center>
  <table cellspacing=1 cellpadding=4 class=table>
  <tr><td class=td>&nbsp;<%response.write img_skin("m_user")&tit%></td></tr>
  <tr class=tr><td align=center height=300>
<%
select case action
case "chk"
  call getpass_chk()
case else
  call getpass_main()
end select
%>
  </td></tr>
  </table>
</td></tr>
</table>
<%
response.write ukong

call web_end(0,0)

sub getpass_chk()
  dim found_err,username,passwd,email,uid,upower,newpass,sbody,sendmail
  username=trim(request.form("username"))
  passwd=joekoe_cms.code_form(request.form("passwd"))
  email=trim(request.form("email"))
  found_err=""
  if symbol_name(username)=false then
    found_err=found_err&"+您输入的 <font class=red>用户名称</font> 为空或不符合相关规则！<br>"
  end if
  if symbol_name(passwd)=false then
    found_err=found_err&"+您输入的 <font class=red>密码钥匙</font> 为空或不符合相关规则！<br>"
  end if
  if email_ok(email,50)=false then
    found_err=found_err&"+您输入的 <font class=red>E-mail</font> 为空或不符合邮件规则！<br>"
  end if
  if val_chk("getpass")=false then
    found_err=found_err&"+您提交的 <font class=red2>验证码</font> 为空或有错误，请勿非法提交！<br>"
  end if
  if found_err<>"" then
    response.write found_error(found_err,280)
    exit sub
  end if
  sql="select top 1 id,power,popedom from user_data where hidden=1 and username='"&username&"' and passwd='"&jk_md5(passwd,"short")&"' and email='"&email&"'"
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    found_err=found_err&"+您输入的取回密码信息有错误或用户不存在！<br>"
    response.write found_error(found_err,260)
    exit sub
  end if
  uid=rs("id")
  upower=rs("power")
  login_popedom=rs("popedom")
  rs.close
  if format_power(upower,2)=1 then
    found_err=found_err&"+<font class=blue>管理员不可以取回密码！请与网站管理者联系取回。</font><br>"
  end if
  if popedom_p(41)=1 then
    found_err=found_err&"+用户(<font class=blue>"&username&"</font>)已被<font class=red>锁定</font>！不可以取回密码。<br>"
  end if
  if found_err<>"" then
    response.write found_error(found_err,300)
    exit sub
  end if
  newpass=joekoe_cms.rand_num(8)
  sbody=vbcrlf&"您于 "&joekoe_cms.time_type("",2)&" 使用了系统的密码取回功能！" & _
	vbcrlf& _
	vbcrlf&"系统生成的随机登陆密码为："&newpass& _
	vbcrlf& _
	vbcrlf&"请尽快登陆本站并修改一个安全的密码！" & _
	vbcrlf& _
	vbcrlf& joekoe_cms.web_url &"login.asp"
  sendmail=send_mail(username,email,tit,sbody)
  response.write vbcrlf&"<p class=htd><font class=red>成功取回密码！</font><br><br>"
  if sendmail then
    response.write vbcrlf&"系统已将新的密码发送到您的邮箱（"&email&"）中！"
  else
    response.write vbcrlf&"系统配置不正常，注册邮件没有能正确发送！<br>新的随机密码为："&newpass
  end if
  response.write vbcrlf&"<br><br>请及时 <a href='login.asp'>登陆</a> 并修改一个安全的密码。</p>"
  call joekoe_cms.exec("update user_data set password='"&jk_md5(newpass,"short")&"' where id="&uid,0)
  call val_chk_end("getpass")
end sub

sub getpass_main()
%>
<table border=0 cellspacing=1 cellpadding=2>
<form action='?action=chk' method=post onsubmit="javascript:frm_submitonce(this);">
<input type=hidden name=chk value='yes'>
<%response.write val_code_num("getpass",1)%>
<tr>
<td>用户名称：</td>
<td><input type=text name=username size=20 value=''></td>
</tr>
<tr><td height=10></td></tr>
<tr>
<td>密码钥匙：</td>
<td><input type=password name=passwd size=20 maxlength=20></td>
</tr>
<tr><td></td><td class=gray>您在注册时填写的密码钥匙</td></tr>
<tr>
<td>电子邮件：</td>
<td><input type=text name=email size=20 maxlength=50></td>
</tr>
<tr><td></td><td class=gray>您在注册时填写的电子邮箱</td></tr>
<tr><td colspan=2 align=center height=40><input type=submit class=btn value='取 得 密 码'>　　<input type=reset class=btn value='重新填写'></td></tr>
<tr>
<td colspan=2 align=center class=htd><font class=gray>数据验证无误后将随机生成密码；<br>并发送到您的电子邮箱里。</font></td>
</tr>
</form>
</table>
<%
end sub
%>