<!--#include file="conn/hl_conn.asp"-->
<!--#include file="Inc/hl_function.asp"-->
<!--#include file="Inc/md5.asp"-->
<!--#include file="inc/upiconfig.asp"--><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=SiteName & " >> 会员中心 >> 找回密码"%></title>
</head>


<style type="text/css">
<!--
body {
	background-color: #4296CE;
	font-size: 12px;

}
td,th{font-size:12px}
-->
</style>
<body bgcolor="#4296CE" leftMargin=0 topMargin=0 marginwidth="0" marginheight="0" class="td">
<TABLE width="628" border="0" cellPadding="0" cellSpacing="0">
  <TBODY>
    <TR>
      <TD class=s vAlign=top align=right width=459 
          background=img/leftmanu_top1.gif height=30>&nbsp;</TD>
      <TD class=s vAlign=top width=141 
          background=img/top_nav_bg2.gif>&nbsp;</TD>
      <TD width=28><IMG height=30 src="img/top_nav_5.gif" 
            width=28></TD>
    </TR>
  </TBODY>
</TABLE>
<table width="628" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table width="623" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
      <tr>
        <td height="35"  align="middle"  style="BACKGROUND-POSITION: left top; BACKGROUND-REPEAT: no-repeat">
		<img height="35" src="img/txzqhmm.gif" width="544" /></td>
      </tr>
      <tr>
        <td  style="BACKGROUND-POSITION: left top; BACKGROUND-REPEAT: no-repeat" align="middle"></td>
      </tr>
    </table>
        <table width="623" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr>
            <td valign="top" height="80">
<%
Dim sUserName, rsGetPassword
Dim Answer, Password, PwdConfirm, CheckCode
Dim Interface_Action,AdminName,NewPassword,OldPassword
sUserName = Replace(Trim(Request("UserName")),"'","")
sUserName = ReplaceBadChar(sUserName)
sUserEmail= Replace(Trim(Request("UserEmail")),"'","")
sUserEmail = ReplaceBadChar(sUserEmail)
Answer = Trim(Request("Answer"))
Password = Trim(Request("Password"))
PwdConfirm = Trim(Request("PwdConfirm"))
Select Case Action
Case "step2"
    Call Step2
Case "step3"
    Call Step3
Case "step4"
    Call Step4
Case Else
    Call Step1
End Select
If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
End If
%></td>
          </tr>
        </table>
        <table width="623" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr>
            <td>&nbsp;</td>
          </tr>
      </table></td>
  </tr>
</table>
<table width="628" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="img/user_index_bottom.jpg" width="630" height="10" /></td>
  </tr>
</table>

<table width="756" border="0" align="center" cellpadding="0" cellspacing="0" class="user_border">
  <tr>
    <td valign="top"></td>
  </tr>
</table>
</body>
</html>
<%
Call CloseConn

Sub Step1()
    Response.Write "<br>" & vbCrLf
    Response.Write "<table border=""1"" align=""center"" cellpadding=""2"" cellspacing=""0"" bordercolor=""#0E7FC5"" style=""BORDER-COLLAPSE: collapse"" width=""544"">"
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height='15' colspan='2'>找回密码 &gt;&gt; 第一步：输入用户名</td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height='100' colspan='2' align='center'>" & vbCrLf
    Response.Write "      <form name='form1' method='post' action=''>" & vbCrLf
    Response.Write "        <strong> 请输入你的用户名：</strong>" & vbCrLf
    Response.Write "        <input name='UserName' type='text' id='UserName' size='20' maxlength='20'><br><br>" & vbCrLf
    Response.Write "        <strong>&nbsp;&nbsp;请输入你的邮箱：</strong>" & vbCrLf
    Response.Write "        <input name='UserEmail' type='text' id='UserEmail' size='20' maxlength='20'><br><br>" & vbCrLf
    Response.Write "        <input name='Action' type='hidden' id='Action' value='step2'>" & vbCrLf
    Response.Write "        <input name='Next' type='submit' id='Next' style='cursor:hand;' value='下一步'>" & vbCrLf
    Response.Write "        <input name='Cancel' type='button' id='Cancel' style='cursor:hand;' onclick='window.location.href=""../index.asp""' value=' 取消 '>" & vbCrLf
    Response.Write "      </form>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
End Sub

Sub Step2()
    
    Set rsGetPassword = server.CreateObject("adodb.recordset")
    rsGetPassword.open "select UserName,userQuestion,userAnswer,UserPassword from hl_User where UserName='" & sUserName & "' and useremail='"&sUserEmail&"'", Conn, 1, 1
    If rsGetPassword.bof And rsGetPassword.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>对不起，你输入的资料不匹配！</li>"
        rsGetPassword.Close
        Set rsGetPassword = Nothing
		 Call ShowErr(ErrMsg)
        Exit Sub
    End If

    Response.Write "<script language=javascript>" & vbCrLf
    Response.Write "<!--" & vbCrLf
    Response.Write "function refreshimg(){document.all.checkcode.src='../inc/checkcode.asp';}" & vbCrLf
    Response.Write "//-->" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<br>" & vbCrLf
    Response.Write "<table border=""1"" align=""center"" cellpadding=""2"" cellspacing=""0"" bordercolor=""#0E7FC5"" style=""BORDER-COLLAPSE: collapse"" width=""544"">"

    'Response.Write "<table align='center' width='300' border='0' cellpadding='4' cellspacing='0' class='border'>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height='15' colspan='2'>找回密码 &gt;&gt; 第二步：回答问题</td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height='100' colspan='2' align='center'>" & vbCrLf
    Response.Write "      <form name='form1' method='post' action=''>" & vbCrLf
    Response.Write "        <table width='100%' border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "          <tr>" & vbCrLf
    Response.Write "            <td width='44%' align='right'><strong>密码提示问题：</strong></td>" & vbCrLf
    Response.Write "            <td width='56%'>" & rsGetPassword("userQuestion") & "</td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "          <tr>" & vbCrLf
    Response.Write "            <td align='right'><strong>你的答案：</strong></td>" & vbCrLf
    Response.Write "            <td><input name='Answer' type='text' size='20' maxlength='20'></td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "          <tr>" & vbCrLf
    Response.Write "            <td align='right'><strong>验证码：</strong></td>" & vbCrLf
    Response.Write "            <td><input name='CheckCode' type='text' size='6' maxlength='6'> <a href='javascript:refreshimg()' title='看不清楚，换个图片'><img id='checkcode' src='inc/checkcode.asp' style='border: 1px solid #ffffff'></a></td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "        </table>" & vbCrLf
    Response.Write "        <br>" & vbCrLf
    Response.Write "        <input name='UserName' type='hidden' id='UserName' value='" & rsGetPassword("UserName") & "'>" & vbCrLf
    Response.Write "        <input name='Action' type='hidden' id='Action' value='step3'>" & vbCrLf
    Response.Write "        <input name='PrevStep' type='button' id='PrevStep' value='上一步' style='cursor:hand;' onclick='history.go(-1)'>&nbsp;" & vbCrLf
    Response.Write "        <input name='NextStep' type='submit' id='NextStep' style='cursor:hand;' value='下一步'>&nbsp;" & vbCrLf
    Response.Write "        <input name='Cancel' type='button' id='Cancel' style='cursor:hand;' onclick='window.location.href=""../index.asp""' value=' 取消 '>" & vbCrLf
    Response.Write "      </form>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf

    rsGetPassword.Close
    Set rsGetPassword = Nothing
End Sub

Sub Step3()
    If Answer = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>请输入提示问题的答案！</li>"
        Exit Sub
    End If
	CheckCode = LCase(ReplaceBadChar(Trim(Request("CheckCode"))))
    If CheckCode = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>验证码不能为空！</li>"
    End If
    If Trim(Session("CheckCode")) = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>你登录时间过长，请重新返回登录页面进行登录。</li>"
    End If
	   If CheckCode <> Session("CheckCode") Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>您输入的确认码和系统产生的不一致，请重新输入。</li>"
    End If
    If FoundErr = True Then
	 Call ShowErr(ErrMsg)
        Exit Sub
    End If
	'sUserName = ReplaceBadChar(sUserName)
	    Set rsGetPassword = server.CreateObject("adodb.recordset")
    rsGetPassword.open "select UserName,userQuestion,userAnswer,UserPassword from hl_User where UserName='" & sUserName & "'", Conn, 1, 1
    If rsGetPassword.bof And rsGetPassword.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>对不起，用户名不存在！可能已经被管理员删除了。</li>"
    End If
	Answer=Md5(Answer,32)
	If Len(rsGetPassword("userAnswer"))=16 Then Answer=Mid(Answer,9,16)
	If Answer<>rsGetPassword("userAnswer") Then
	FoundErr = True
        ErrMsg = ErrMsg & "<br><li>您输入的答案不正确。</li>"
		Call ShowErr(ErrMsg)
	Exit Sub
	end if
    Response.Write "<br>" & vbCrLf
	Response.Write "<table border=""1"" align=""center"" cellpadding=""2"" cellspacing=""0"" bordercolor=""#0E7FC5"" style=""BORDER-COLLAPSE: collapse"" width=""544"">"
    'Response.Write "<table align='center' width='300' border='0' cellpadding='4' cellspacing='0' class='border'>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height='15' colspan='2' class='title'>找回密码 &gt;&gt; 第三步：设置新密码</td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height='100' colspan='2' align='center'>" & vbCrLf
    Response.Write "      <form name='form1' method='post' action=''>" & vbCrLf
    Response.Write "        <table width='100%' border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "          <tr>" & vbCrLf
    Response.Write "            <td width='44%' align='right'><strong>密码提示问题：</strong></td>" & vbCrLf
    Response.Write "            <td width='56%'>" & rsGetPassword("userQuestion") & "</td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "          <tr>" & vbCrLf
    Response.Write "            <td align='right'><strong>你的答案：</strong></td>" & vbCrLf
    Response.Write "            <td>" & Answer & " <input name='Answer' type='hidden' id='Answer' value='" & Answer & "'></td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "          <tr>" & vbCrLf
    Response.Write "            <td align='right'><strong>新密码：</strong></td>" & vbCrLf
    Response.Write "            <td><input name='Password' type='password' id='Password' size='20' maxlength='20'></td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "          <tr>" & vbCrLf
    Response.Write "            <td align='right'><strong>确认新密码：</strong></td>" & vbCrLf
    Response.Write "            <td><input name='PwdConfirm' type='password' id='PwdConfirm' size='20' maxlength='20'></td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "        </table>" & vbCrLf
    Response.Write "        <br>" & vbCrLf
    Response.Write "        <input name='UserName' type='hidden' id='UserName' value='" & rsGetPassword("Username") & "'>" & vbCrLf
    Response.Write "        <input name='Action' type='hidden' id='Action' value='step4'>" & vbCrLf
    Response.Write "        <input name='PrevStep' type='button' id='PrevStep' value='上一步' style='cursor:hand;' onclick='history.go(-1)'>&nbsp;" & vbCrLf
    Response.Write "        <input name='Next' type='submit' id='Next' style='cursor:hand;' value='下一步'>&nbsp;" & vbCrLf
    Response.Write "        <input name='Cancel' type='button' id='Cancel' style='cursor:hand;' onclick='window.location.href=""../index.asp""' value=' 取消 '>" & vbCrLf
    Response.Write "      </form>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf

    'rsGetPassword.Close
    'Set rsGetPassword = Nothing
End Sub

Sub Step4()
    If Password = "" Or strLength(Password) > 12 Or strLength(Password) < 6 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>请输入密码(不能大于12小于6)</li>"
    Else
        If InStr(Password, "=") > 0 Or InStr(Password, "%") > 0 Or InStr(Password, Chr(32)) > 0 Or InStr(Password, "?") > 0 Or InStr(Password, "&") > 0 Or InStr(Password, ";") > 0 Or InStr(Password, ",") > 0 Or InStr(Password, "'") > 0 Or InStr(Password, ",") > 0 Or InStr(Password, Chr(34)) > 0 Or InStr(Password, Chr(9)) > 0 Or InStr(Password, "") > 0 Or InStr(Password, "$") > 0 Then
            ErrMsg = ErrMsg + "<br><li>密码中含有非法字符</li>"
            FoundErr = True
        End If
    End If
    If PwdConfirm = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>请输入确认密码(不能大于12小于6)</li>"
    Else
        If Password <> PwdConfirm Then
            FoundErr = True
            ErrMsg = ErrMsg & "<br><li>密码和确认密码不一致</li>"
        End If
    End If
    If FoundErr = True Then Exit Sub

    '加入对整合接口的支持
    
    If FoundErr = True Then Exit Sub
    '完毕

  '  sUserName = ReplaceBadChar(sUserName)
    Set rsGetPassword = server.CreateObject("adodb.recordset")
    rsGetPassword.open "select UserName,userQuestion,userAnswer,UserPassword from hl_User where UserName='" & sUserName & "'", Conn, 1, 3
    If rsGetPassword.bof And rsGetPassword.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>对不起，用户名不存在！可能已经被管理员删除了。</li>"
    Else
        If (rsGetPassword("useranswer") <> MD5(Answer, 32)) and (rsGetPassword("useranswer") <> MD5(Answer, 16)) Then
       '     FoundErr = True
       '     ErrMsg = ErrMsg & "<br><li>对不起，你的答案不对！</li>"
        End If
    End If
    If FoundErr = True Then
        rsGetPassword.Close
        Set rsGetPassword = Nothing
        Exit Sub
    End If
	
	 OldPassword=rsGetPassword("UserPassword")
	 NewPassword=MD5(Password, 16)
	'与其它数据库的用户数据同步开始
     AdminName=rsGetPassword("username")
     password_bak=password
     password=NewPassword
     Interface_Action="ModifyPsw"
     ComeUrl="User_ModifPWD.asp"
     Call Interface
	'与其它数据库的用户数据同步结束
	
	password=password_bak
    rsGetPassword("UserPassword") = NewPassword
    rsGetPassword.Update
    Response.Cookies("hl_user")("password")=NewPassword
    Response.Write "<br>" & vbCrLf
    Response.Write "<table align='center' width='300' border='0' cellpadding='4' cellspacing='0' class='border'>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height='15' colspan='2' class='title'>找回密码 &gt;&gt; 第四步：成功设置新密码</td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height='100' colspan='2' align='center' class='tdbg'>" & vbCrLf
    Response.Write "      <table width='90%' border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='80' align='right'><strong>用户名：</strong></td>" & vbCrLf
    Response.Write "          <td>" & sUserName & "</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='80' align='right'><strong>新密码：</strong></td>" & vbCrLf
    Response.Write "          <td><strong>" & Password & "</strong></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>" & vbCrLf
    Response.Write "      <br>" & vbCrLf
    Response.Write "      <font color='#FF0000'>请记住您的新密码并使用新密码<a href='../index.asp'>登录</a>！</font><br><br>" & vbCrLf
    Response.Write "      <a href='../index.asp'>【返回首页】</a>&nbsp;&nbsp;" & vbCrLf
    Response.Write "      <a href='javascript:window.close();'>【关闭窗口】</a>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    rsGetPassword.Close
    Set rsGetPassword = Nothing
End Sub

Sub Interface()            
            Md5Info=MD5(AdminName & SecurityKey, 32)
            Response.Write "<html>" & vbCrLf
            Response.Write "<head>" & vbCrLf
            Response.Write "<meta http-equiv=""refresh"" content=""" & RefreshTime & ";URL="""&ComeUrl&""" />"&vbCrLf
            Response.Write "<title>正在更新通行证资料</title>" & vbCrLf
            Response.Write "</head>" & vbCrLf
            Response.Write "<body>" & vbCrLf
            Response.Write "<span class='style15'>正在更新通行证资料，请稍等...</span>" & vbCrLf
            Response.Write "<div align='center'><img src='img/interface.gif' width='500' height='20' /></div>"
            If IsNull(SecurityKey) = False And SecurityKey <> "" And IsNull(arrUpiUrls) = False And arrUpiUrls <> "" Then
            HLUpi = Split(arrUpiUrls, "|")
			RegSiteId=split(RegSiteIds,",")   
            For iNums = 0 To UBound(HLUpi)
			Response.Write "<iframe id='ModifyInfo' width='100%' height='0' frameborder='0' src=""" & HLUpi(iNums) & "?action="&Interface_Action&"&Md5Info=" & Md5Info & "&name=" & AdminName & "&pass=" & password & "&oldpass=" & OldPassword & """></iframe>"& vbCrLf			
			Next
            End If
            Response.Write "</body>" & vbCrLf
            Response.Write "</html>" & vbCrLf
End Sub

Sub ShowErr(ErrMsg)
	dim strErr
	strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
	strErr=strErr & "</head><body>" & vbcrlf
	strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
	strErr=strErr & "  <tr align='center'><td height='22' class='title'><strong>错误信息</strong></td></tr>" & vbcrlf
	strErr=strErr & "  <tr><td height='100'  valign='top'><b>产生错误的可能原因：</b><br>" & ErrMsg &"</td></tr>" & vbcrlf
	strErr=strErr & "  <tr align='center'><td class='tdbg'><input type=button name='button' value='返回' onClick='javascript:history.go(-1);'></td></tr>" & vbcrlf
	strErr=strErr & "</table>" & vbcrlf
	strErr=strErr & "</body></html>" & vbcrlf
	response.write strErr
end sub
%>