<!--#include file="conn.asp"-->
<!--#include file="inc/bloginfo.asp"-->
<!--#include file="inc/syscode.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/md5.asp"-->
<%
response.Write "<title>"&sitetitle&"</title>"
dim show
dim action,show_getpassword
action=cint(request("action"))
call sysshow()
show_getpassword=show_getpassword&"当前位置：<a href='index.asp'>首页</a>→找回密码<hr noshade>"
select case action
	case 1
	call sub_getpassword_1()
	case 2
	call sub_getpassword_2()
	case 3
	call sub_getpassword_3()
	case else
	call sub_getpassword_0()
end select


show=replace(show,"$show_list$",show_getpassword)
response.Write show
call bottom()


dim pass_username,daan

sub sub_getpassword_0
	show_getpassword=show_getpassword&"<form name='form1' method='post' action='' onSubmit='return checkMe()'>"
	show_getpassword=show_getpassword&"<TABLE width='400' border=0 cellPadding=0 cellSpacing=0 borderColor=#111111 style='BORDER-COLLAPSE: collapse'>"
	show_getpassword=show_getpassword&"<tr><td height='18' class='bian'><strong>找回密码第一步:</strong></td> </tr><tr>"
	show_getpassword=show_getpassword&"<td height='200'><div align='center'>请输入用户名:"
	show_getpassword=show_getpassword&"<input name='uid' type='text' id='uid' size='23' maxlength='26'>"
	show_getpassword=show_getpassword&"<br><br><input name='Submit' type='submit' id='Submit' value='下一步'>"
	show_getpassword=show_getpassword&"<input name='action'  id='action' type='hidden' value='1'>"
	show_getpassword=show_getpassword&"</div></td></tr></table></form>"
end sub

sub sub_getpassword_1
	dim rs
	pass_username=replace(trim(request("uid")),"'","''")
	set rs=conn.execute ("select * from [user] where username='"&pass_username&"'")
	if rs.eof or err then
    	Response.Write"<script language=JavaScript>"
		Response.Write"alert(""该用户不存在！"");"
		Response.Write"window.history.go(-1);"
		Response.Write"</script>"
		response.End()
	end if
	show_getpassword=show_getpassword&"<form name='form1' method='post' action=''>"
	show_getpassword=show_getpassword&"<TABLE width='400' border=0 cellPadding=0 cellSpacing=0 borderColor=#111111 style='BORDER-COLLAPSE: collapse'>"
	show_getpassword=show_getpassword&"<tr><td height='18' class='bian'><strong>找回密码第二步:</strong></td> "
	show_getpassword=show_getpassword&"</tr><tr> <td height='200'><div align='center'>用户名:"
	show_getpassword=show_getpassword&"<input name='uid' type='text' id='uid' value='"&rs("username")&"' size='20' maxlength='26'>"
	show_getpassword=show_getpassword&"<br><br>密码提示问题:"
	show_getpassword=show_getpassword&"<input name='tishi' type='text' id='tishi' value='"&rs("Question")&"' size='30' maxlength='26'>"
	show_getpassword=show_getpassword&"<br><br>　　　　答案:"
	show_getpassword=show_getpassword&"<input name='daan' type='text' id='daan' size='30' maxlength='26'>"
	show_getpassword=show_getpassword&"<br><br><input name='Submit' type='submit' id='Submit' value='下一步'>"
	show_getpassword=show_getpassword&"<input name='action'  id='action' type='hidden' value='２'>"
	show_getpassword=show_getpassword&"</div></td></tr></table></form>"
	rs.close
	set rs=nothing
end sub

sub sub_getpassword_2
	dim tishi,rs
	pass_username=replace(trim(request("uid")),"'","''")
	daan=replace(trim(request("daan")),"'","''")
	set rs=conn.execute("select * from [user] where username='"&pass_username&"' and answer='"&daan&"'")
	if rs.eof or err then
    	Response.Write"<script language=JavaScript>"
		Response.Write"alert(""密码提示问题回答错误！"");"
		Response.Write"window.history.go(-1);"
		Response.Write"</script>"
		response.End()
	end if
	show_getpassword=show_getpassword&"<TABLE width='400' border=0 cellPadding=0 cellSpacing=0  align='center' style='BORDER-COLLAPSE: collapse'>"& vbcrlf
	show_getpassword=show_getpassword&"<tr><td height='18' class='bian'><strong>完成,请重新设定密码:</strong></td></tr><tr>"& vbcrlf
	show_getpassword=show_getpassword&"<td><table width='100%' border='0' cellpadding='0' cellspacing='0'>"& vbcrlf
	show_getpassword=show_getpassword&"<tr><td><FORM action='' method='post' name='regform' onSubmit='return VerifySubmit()'>"& vbcrlf
	show_getpassword=show_getpassword&"<br><br><table width='60%' border='0' align='center' cellpadding='0' cellspacing='0'>"& vbcrlf
	show_getpassword=show_getpassword&"<tr><td><table  border='0' cellspacing='0' cellpadding='5'>"& vbcrlf
	show_getpassword=show_getpassword&"<tr> <td width='37%'><div align='right'>"& vbcrlf
	show_getpassword=show_getpassword&"<p>新密码：</p></div></td><td colspan='2'><input name='new_pass' type='password' id='new_pass'></td>"& vbcrlf
	show_getpassword=show_getpassword&"</tr><tr><td><div align='right'>重复新密码：</div></td>"& vbcrlf
	show_getpassword=show_getpassword&"<td colspan='2'><input name='new_pass2' type='password' id='new_pass2'></td>"& vbcrlf
	show_getpassword=show_getpassword&"</tr><tr><td><div align='right'> </div></td>"& vbcrlf
	show_getpassword=show_getpassword&"<td width='17%'><input type='submit' name='Submit' value='确定'></td>"& vbcrlf
	show_getpassword=show_getpassword&"<td width='46%'><input type='reset' name='Submit2' value='取消'></td>"& vbcrlf
	show_getpassword=show_getpassword&"</tr></table><input name='action'  id='action' type='hidden' value='3'><input name='uid'  id='uid' type='hidden' value='"&pass_username&"'><input name='daan'  id='daan' type='hidden' value='"&daan&"'></td></tr></table></form><br><div align='center'> </div></td>"& vbcrlf
	show_getpassword=show_getpassword&"</tr></table></td></tr></table>"& vbcrlf
	rs.close
	set rs=nothing
end sub

sub sub_getpassword_3()
	dim password
	pass_username=replace(trim(request("uid")),"'","''")
	daan=replace(trim(request("daan")),"'","''")
	password=md5(trim(request("new_pass")))
	conn.execute("update [user] set userpassword='"&password&"' where username='"&pass_username&"' and answer='"&daan&"'" )
	Response.Write"<script language=JavaScript>"
	Response.Write"alert(""密码修改成功！"");"
	Response.Write"window.location.href='index.asp';"
	Response.Write"</script>"
end sub

%>
<script language=Javascript>
<!--
function checkMe(){
	if (form1.uid.value==""){
		alert("用户名不能为空!");
		return false;
	}
}
//-->
</script>
<script language=Javascript>
function VerifySubmit()
{
	    	 
	  
	 new_pass = del_space(document.all("new_pass").value);
     if (new_pass.length == 0)
     {
        alert("请输入新密码！");
	return false;
     }

	new_pass = del_space(document.all("new_pass").value);
     if (new_pass.length < 6)
     {
        alert("密码应大于6个字符！");
	return false;
     }

	new_pass2 = del_space(document.all("new_pass2").value);
     if (new_pass2!=new_pass)
     {
        alert("两次密码输入不一样!");
		return false;
     }
	 
	return true;
}
//-->
</SCRIPT>