<!--#include file=conn.asp-->
<!--#include file=config.asp-->
<!--#include file=const.asp-->
<!--#include file=char.asp-->
<!--#include file=md5.asp-->
<!--#include file="inc/upiconfig.asp"-->
<%
If HLIntegration = True Then 
ComeURl=Request.ServerVariables("HTTP_REFERER")
Response.Redirect HL_Url&Manage_Url&"User_ModifyPWD.asp?ComeUrl="&ComeUrl
End If
 '=========================================================
' File: modifypsw.asp
' Version:3.0
' Date: 2005-11-6
' Script Written by xmrxw
'=========================================================
' Copyright (C) 2004,2005 Xmrxw.Com All rights reserved.
' Web: http://www.xmrxw.com,http://www.xmzxw.com
' Email: info@mssky.com,super@mssky.com
' QQ：10689579　Msn：zdlmicr@hotmail.com
'=========================================================

response.buffer=true
stats="修改密码"
call nav()

if not founduser then
	Errmsg=Errmsg+"<br>"+"<li>您还没有登陆，请登陆后进行修改。"
	founderr=true
end if

if founderr then
  	errmsg=errmsg+"<br>"+"<li>您没有<a href=login.asp target=_blank>登录</a>。"
	call head_var("","")
	call Mslove_error()
else
	call head_var(membername & "的帐号","mycount.asp")
	if request("action")="updat" then
		call updatep()
		if founderr then
			call Mslove_error()
		else
			sucmsg="<li>修改密码成功！"
			call Mslove_suc()
		end if
	else
		call userinfo()
	end if
end if
call activeonline()
call footer()

sub userinfo()
set rs=server.createobject("adodb.recordset")
sql="Select * from [Ms_User] where userid="&userid
rs.open sql,conn,1,1
if rs.eof and rs.bof then
	errmsg=errmsg+"<br>"+"<li>该用户名不存在。"
	founderr=true
	exit sub
else
%>
<table cellpadding=3 cellspacing=1 align=center class=tableborder1>
<tr>
<th width=12% height=25 id=tabletitlelink><a href=mycount.asp>我的帐号</a></th>
<th width=11%  id=tabletitlelink><a href=mymodify.asp>基本资料</a></th>
<th width=11%  id=tabletitlelink><a href=modifypsw.asp>密码修改</a></th>
<th width=11%  id=tabletitlelink><a href=modifyfd.asp>交友资料</a></th>
<th width=11%  id=tabletitlelink><a href=modifyadd.asp>联系资料</a></th>
<th width=11%  id=tabletitlelink><a href=usersms.asp>短信服务</a></th>
<th width=11%  id=tabletitlelink><a href=friendlist.asp>我的好友</a></th>
<th width=11%  id=tabletitlelink><a href=favlist.asp>我的收藏</a></th>
<th width=11%  id=tabletitlelink><a href=userphoto.asp>我的相册</a></th>
</tr>
</table>
<form action="modifypsw.asp?action=updat" method=POST name="theForm">
<table cellpadding=3 cellspacing=1 align=center class=tableborder1>
<tr> 
      <th colspan="2" width="100%">用户密码资料
      </th>
    </tr>
<tr>    
        <td width="40%" class=tablebody1><B>旧密码确认</B>：<BR>如要修改请输入旧密码进入确认</td>   
        <td width="60%" class=tablebody1>    
          <input class=2 type="password" name="oldpassword" size=30 maxlength=20>   
        </td>   
      </tr>  
    <tr>    
        <td width="40%" class=tablebody1><B>新密码确认</B>：<BR>如要修改请直接输入新密码进入更新</td>   
        <td width="60%" class=tablebody1>    
          <input class=2 type="password" name="password" size=30 maxlength=20>   
        </td>   
      </tr>   
      <tr>    
        <td width="40%" class=tablebody1><B>密码问题</B>：<BR>请填写做为密码答案依据</td>   
        <td width="60%" class=tablebody1>    
          <input class=2 type=text name="quesion" size=30 value="<%=htmlencode(rs("Userquesion"))%>">
        </td>   
      </tr>  
      <tr>    
        <td width="40%" class=tablebody1><B>问题答案</B>：<BR>请认真填写以便您日后取回密码<BR>答案采用了MD5加密，只供取回密码使用，如要修改可直接填写。</td>   
        <td width="60%" class=tablebody1>    
          <input class=2 type=text name="answer" size=30 value="<%=htmlencode(rs("Useranswer"))%>">
          <input type=hidden name="oldanswer" value="<%=htmlencode(rs("Useranswer"))%>">
        </td>   
      </tr>
    <tr align="center"> 
      <td colspan="2" width="100%"  class=tablebody2>
            <input class=2 type=Submit value="更 新" name="Submit"> &nbsp; <input class=2 type="reset" name="Submit2" value="清 除">
      </td>
    </tr>

    </table></form>
   
</body>
</html> 
<%
end if
rs.close
set rs=nothing
end sub

sub updatep()
dim password
dim oldpassword
dim quesion
dim answer
oldpassword=checkstr(trim(request("oldpassword")))
if len(oldpassword)>20 or len(oldpassword)<6 then
errmsg=errmsg+"<br>"+"<li>请输入您的旧密码,才能完成修改（长度不大于20个字符）。"
founderr=true
end if
if len(checkstr(trim(request("password"))))>20 or len(checkstr(trim(request("password"))))<6 then
errmsg=errmsg+"<br>"+"<li>请输入您的新密码,才能完成修改（长度不大于20个字符）。"
founderr=true
else
password=md5(checkstr(trim(request("password"))),16)
end if

if request("quesion")="" or strLength(request("quesion"))>50 then
  	errmsg=errmsg+"<br>"+"<li>请输入密码提示问题（长度不大于50个字符）。"
	founderr=true
else
	quesion=checkStr(trim(request("quesion")))
end if
if request("answer")="" or strLength(request("answer"))>50 then
  	errmsg=errmsg+"<br>"+"<li>请输入密码提示问题答案（长度不大于50个字符）。"
	founderr=true
else
	answer=md5(checkStr(trim(request("answer"))),16)
end if

set rs=server.createobject("adodb.recordset")
sql="Select UserPassword from [Ms_User] where userid="&userid
set rs=conn.execute(sql)
if rs.eof and rs.bof then
	errmsg=errmsg+"<br>"+"<li>该用户名不存在。"
	founderr=true
elseif md5(trim(request("oldpassword")),16)<>trim(rs("UserPassword")) then
	  	errmsg=errmsg+"<br>"+"<li>输入的旧密码错误，请重新输入。"
		founderr=true
end if
rs.close

if founderr=true then exit sub
set rs=server.createobject("adodb.recordset")
sql="Select UserPassword,UserQuesion,UserAnswer from [Ms_User] where userid="&userid
rs.open sql,conn,1,3
if rs.eof and rs.bof then
	errmsg=errmsg+"<br>"+"<li>该用户名不存在。"
	founderr=true
	exit sub
else
	rs("UserPassword")=password
	
	rs("UserQuesion")=quesion
	rs("UserAnswer")=answer
	rs.Update
	Response.Cookies(Forum_sn)("password") = password
	Response.Cookies(Forum_sn).path=cookiepath
end if
rs.close
set rs=nothing
end sub
%>   