<!--#include file="main.asp"-->
<!--#include file="Inc/SendMail.asp"-->
<!--#include file="bbs/inc/md5.asp"-->
<%action=request("action")%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=citytitle%></title>
</head>

<body topmargin="0">
<%dlxf_TOP%>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor=#ffffff>
<%if action="passone" then
user=trim(request("user"))
qylx=request("qylx")
'------------------------------检查用户存在-----------------------------
set rs=server.createobject("adodb.recordset")
select case qylx
  case 0
    rs.open "select * from dlxf_yp where dlxf_user='"&user&"'",conn,1,1
    if rs.eof then
	response.write "<script>alert('此用户名不存在或已被关闭，请重新输入！');history.go(-1)</script>"
	response.end
	else
	mail=rs("dlxf_mail")
	dlxf_question=rs("dlxf_question")
	dlxf_answer=rs("dlxf_answer")
	end if
	rs.close
  case 1
    rs.open "select * from dlxf_job_qz where dlxf_user='"&user&"'",conn,1,1
    if rs.eof then
	response.write "<script>alert('此用户名不存在或已被关闭，请重新输入！');history.go(-1)</script>"
	response.end
	else
	mail=rs("dlxf_email")
	dlxf_question=rs("dlxf_question")
	dlxf_answer=rs("dlxf_answer")
	end if
    rs.close
end select
set rs=nothing
'-------------------------------邮件发送新密码--------------------------------------
if dlxf_citysendmail(6)=1 and dlxf_citysendmail(4)<>"0" then

Randomize timer
NewPass = left(Md5(cint(8999*Rnd+1000),32),10)

dlxf_citypassmail=replace(dlxf_citypassmail,"{$dlxf_name}",cityname)
dlxf_citypassmail=replace(dlxf_citypassmail,"{$dlxf_url}",cityurl)
dlxf_citypassmail=replace(dlxf_citypassmail,"{$dlxf_newpass} ",NewPass)

Topic=cityname&"用户找回密码邮件"

select case dlxf_citysendmail(4)
  case "Jmail"
     call Jmail(mail,Topic,dlxf_citypassmail)
  case "Cdonts"
     call Cdonts(mail,Topic,dlxf_citypassmail)
  case "AspEmail"
     call AspEmail(mail,Topic,dlxf_citypassmail)
end select

if sendmail="False" then
response.write"<script>alert('找回密码确认邮件发送出错，下面是产生错误的可能原因：\n\n·您没有填定您的联系邮箱有您填定的邮箱有错误，请重新输入\n\n·联系管理员查看邮件发送功能设置');history.go(-1)</script>"
response.end
elseif sendmail="OK" then
select case qylx
  case 0
    conn.execute("update dlxf_yp set dlxf_pass='"&Md5(NewPass,32)&"' where dlxf_user='"&user&"'")
  case 1
    conn.execute("update dlxf_job_qz set dlxf_pwd='"&Md5(NewPass,32)&"' where dlxf_user='"&user&"'")
end select
response.write"<script>alert('系统已自动发送一封邮件到您的邮箱，请立即查收');window.open('user_login.asp','_self')</script>"
response.end
else
response.write"<script>alert('出现未知错误，请联系管理员');history.go(-1)</script>"
response.end
end if
'-------------------------------直接写入新密码--------------------------------------
else

response.write "<form name=addform method=post action=?action=passsave><input name=user type=hidden value="&user&"><input name=qylx type=hidden value="&qylx&">"&_
 "<tr><td height=25 colspan=2>当前位置：<a href=index.asp>首页</a> >> <a href=LookupPass.asp>找回密码</a></td></tr>"&_
 "<tr bgcolor=#efefef><td colspan=2 height=25 style=""border-bottom:1px #999999 solid"">　　<strong>找回密码第二步 >> 填写密码问题或答案</strong></td></tr>"&_
 "<tr><td width=""26%"" align=right></td><td width=""74%"" height=350>密码提示问题：<input disabled name=dlxf_question type=text size=20 maxlength=30 class=input2 value="&dlxf_question&"><br><br>"&_
 "密码问题答案：<input name=dlxf_answer type=text size=20 maxlength=30 class=input2><br><br>"&_
 "输入您的新密码：<input name=dlxf_pass type=password size=19 maxlength=16 class=input2><br><br>　　　　　　　<input type=submit name=Submit value=""下一步"" class=input1></td></tr>"&_
 "</form>"
end if
'======================================
elseif action="passsave" then
user=request("user")
dlxf_answer=Md5(request("dlxf_answer"),32)
dlxf_Newpass=request("dlxf_pass")
qylx=int(request("qylx"))
if dlxf_answer="" or user="" or dlxf_Newpass="" or qylx="" then
response.write"<script>alert('请填写问题答案及您的新密码！');history.go(-1)</script>"
response.end
end if
if len(dlxf_Newpass)<4 or len(dlxf_Newpass)>16 then
response.write"<script>alert('新密码输入错误，请重新输入一个 4-16 位的新密码！');history.go(-1)</script>"
response.end
end if
'------------------------------检查用户存在-----------------------------
set rs=server.createobject("adodb.recordset")
select case qylx
  case 0
    rs.open "select * from dlxf_yp where dlxf_user='"&user&"' and dlxf_answer='"&dlxf_answer&"'",conn,1,1
    if rs.eof then
	response.write "<script>alert('对不起您的密码提示问题答案输入错误，请重新输入！');history.go(-1)</script>"
	response.end
	else
    conn.execute("update dlxf_yp set dlxf_pass='"&Md5(dlxf_Newpass,32)&"' where dlxf_user='"&user&"'")
	response.write"<script>alert('密码修改成功，请重新登录！');window.open('user_login.asp','_self')</script>"
    response.end
	end if
	rs.close
  case 1
    rs.open "select * from dlxf_job_qz where dlxf_user='"&user&"' and dlxf_answer='"&dlxf_answer&"'",conn,1,1
    if rs.eof then
	response.write "<script>alert('对不起您的密码提示问题答案输入错误，请重新输入！');history.go(-1)</script>"
	response.end
	else
    conn.execute("update dlxf_job_qz set dlxf_pwd='"&Md5(dlxf_Newpass,32)&"' where dlxf_user='"&user&"'")
	response.write"<script>alert('密码修改成功，请重新登录！');window.open('user_login.asp','_self')</script>"
    response.end
	end if
    rs.close
end select
set rs=nothing
'======================================
else%>
<script language="JavaScript">
<!--
function checkdata() {
if( isNumberString(addform.user.value,"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_")!=1 || addform.user.value.length<2 || addform.user.value.length>16) {
alert("\用户注册出错，下面是产生错误的可能原因：\n\n·用户名必须是2-16位的数字、英文或下划线")
return false;
}
return true;
}
function isNumberString (InString,RefString)
{
if(InString.length==0) return (false);
for (Count=0; Count < InString.length; Count++)  {
	TempChar= InString.substring (Count, Count+1);
	if (RefString.indexOf (TempChar, 0)==-1)  
	return (false);
}
return (true);
}
// -->
</script>
<form name="addform" method="post" action="?action=passone" onSubmit="return checkdata()">
  <tr>
	<td height="25" colspan=2>当前位置：<a href=index.asp>首页</a> >> <a href=LookupPass.asp>找回密码</a></td>
  </tr>
  <tr bgcolor="#efefef">
    <td colspan=2 height="25" style="border-bottom:1px #999999 solid">　　<strong>找回密码第一步 >> 填写用户名</strong></td>
  </tr>
  <tr>
    <td width="26%" align="right"></td>
	<td width="74%" height="350">用 户 名：<input name="user" type="text" size="20" maxlength="16" class=input2>　2-16个<font color=red>英文、数字或下划线</font><br><br>用户类型：<select name="qylx">
<option value=0>企业用户</option>
<option value=1>个人用户</option>
</select><br><br>　　　　　<input type="submit" name="Submit" value="下一步" class=input1></td>
  </tr>
</form>
<%end if%>
</table>
<!--====== bottom ========-->
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor=#ffffff>
<tr><td height=10></td></tr>
<tr><td height=2 bgcolor=#4795EC></td></tr>
  <tr>
    <td align="center" height=80><%=citybottom%></td>
  </tr>
</table>
</body>
</html>