<!--#include file="inc_const.asp"-->
<%set cschat=server.createobject("ffcschat.cssbchat")

cschat.FilterStr=application(ConstStr & "_usernamefilter")
username=cschat.trdb(request("username"))

if username="" then
  response.redirect("showerr.asp?errtext=没有输入用户名！")
  set cschat=nothing
  response.end
end if
Set Conn=Server.CreateObject("ADODB.Connection")
conn.open Application(ConstStr & "_connstr")
Dim myMail
function cdontsck()
  on error resume next
  err.clear
  Set myMail = Server.CreateObject("CDONTS.NewMail")
  if err then
    err.clear
    cdontsck=false
  else
    cdontsck=true
  end if
end function
%>
<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'><META content="text/html; charset=gb2312" http-equiv=content-type>
<link rel="stylesheet" type="text/css" href="chat.css">
<style>p{color:#990000;text-align:left;margin-left:10px;margin-right:20px;margin-top:10px;margin-bottom:0px}</style>
<body style="background-color:EAF2FF;color:112233;scrollbar-Base-Color: #b0d8ff;SCROLLBAR-DARKSHADOW-COLOR:#b0d8ff;SCROLLBAR-arrow-COLOR:#336699;SCROLLBAR-TRACK-COLOR: EAF2FF;SCROLLBAR-3DLIGHT-COLOR: #b0d8ff;SCROLLBAR-SHADOW-COLOR: #336699;SCROLLBAR-HIGHLIGHT-COLOR: #b0d8ff;" leftmargin=3 topmargin=3 >
  <table cellspacing=0 cellpadding=0 align=center width=90% height=100%>
  <tr><td valign=center>
  <table width=400 cellspacing=0 cellpadding=0 style="border:'1px solid navy'">
  <tr><td class=navy2>你想找回用户〖<%=username%>〗的密码</td>
  <form action=findpass.asp method=post><input type=hidden name=username value=<%=username%>><tr><td><p>
<%set Rs=conn.execute("select * from user where username='"&username&"'")
if Rs.eof or Rs.bof then
  response.write "用户尚为注册！"
elseif request("cmdYes")="提交" then
  answer=cschat.trdb(request("answer"))
  if answer<>"" and trim(answer)=trim(rs("answer")) then
    randomize
    pass=""&int(Rnd*1000000+100)
    conn.Execute("UPDATE user SET passwd='"&cschat.trpass(pass)&"' WHERE username='"&username&"'")
    response.write "成功:密码被系统重新设置为<u><big><big>"&pass&"</big></big></u>！"
  else
    response.write "你给出了错误的答案，找回密码失败！"
  end if
elseif request("cmdYes")="1.产生临时密码" then
  randomize
  pass=""&int(Rnd*1000000+100)
  conn.Execute("UPDATE user SET temppass='"&pass&"' WHERE username='"&username&"'")
  if cdontsck() then
    room_array=split(Application(ConstStr & "_room_list"),"$>")
    room_name=room_array(1)
    myMail.From = rs("email")
    myMail.To = rs("email")
    myMail.Subject = "找回密码"
    myMail.Body = room_name&":用户"&username&" 系统为你设置临时密码为："&pass
    myMail.Send
    Set myMail = Nothing%>
   系统产生临时密码并发到邮箱：<u><%=rs("email")%></u>。<br>请接收邮件然后进行下一步。
   <p><center><input class=navy1 type=submit name=cmdYes value="2.修改用户密码" ></form>
  <%else
    response.write "服务器没有安装CDONTS邮件组件！<br>无法利用email地址找回密码！"
  end if%>
<%elseif request("cmdYes")="2.修改用户密码" then%>
  <p><center>临时密码：<input type=password name=temppass size=10 maxlength=10>
  <p><center>修改密码：<input type=password name=spass size=10 maxlength=15>
  <p><center><input class=navy1 type=submit name=cmdYes value=修改 >
  <input class=navy1 type=reset name=cmdcancel value=重置 ></center></form>
<%elseif request("cmdYes")="修改" then
  temppass=request("temppass")
  if temppass<>"" and temppass=trim(rs("temppass")) then
    spass=request("spass")
    if spass<>"" and spass<>username then
      conn.Execute("UPDATE user SET temppass=' ',passwd='"&cschat.trpass(spass)&"' WHERE username='"&username&"'")
      errtext="你成功地修改了密码！"
    else
      errtext="你想把密码修改为空或者与用户名相同！"
    end if
  else
    conn.Execute("UPDATE user SET temppass=' ' WHERE username='"&username&"'")
    errtext="临时密码验证失败,临时密码被清除！"
  end if
  response.write errtext
else
  if (trim(rs("remand"))<>"" and trim(rs("answer"))<>"") or trim(rs("email"))<>"" then
    if (trim(rs("remand"))<>"" and trim(rs("answer"))<>"") then %>
      <tr><td class=navy1>密码提问：<%=Rs("remand")%><tr><td><p>密码回答：<input type=text name=answer size=25 maxlength=250><p>
      <center><input class=navy1 type=submit name=cmdYes value=提交 >
      <input class=navy1 type=reset name=cmdcancel value=重置 ></center>
    <%end if%>
    <%if trim(rs("email"))<>"" then%><br><p><tr><td class=navy1>利用EMAIL地址找回密码<tr><td><p><center><input class=navy1 type=submit name=cmdYes value="1.产生临时密码" >
      <%if trim(rs("temppass"))<>"" then%><p><center><input class=navy1 type=submit name=cmdYes value="2.修改用户密码" ><p>(临时密码已经产生，你可以重新产生或者直接进行第二步：修改用户密码。)<%end if%>
    <%end if%></center></form>
  <%else
    response.write "你既没有设置密码提问和密码回答，<br>也没有设置Email地址。<br>不能找回密码！"
  end if
end if%>
</p></td></tr>
</table><br>[<a href='help.asp?id=1'>帮助</a>] [<a href='javascript:history.go(-1)'>后退</a>] [<a href='.'>登录页面</a>]</table></body></html>
<%rs.close
set rs=nothing
conn.close
set conn=nothing
set cschat=nothing%>

























