<%
Option Explicit
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<!--#include file="inc/config.asp" -->
<!--#include file="inc/conn.asp" -->
<!--#include file="inc/function.asp" -->
<!--#include file="inc/md5.asp" -->
<!--#include file="inc/sql_filter.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改密码</title>
<link href="style/global.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style3{ color:#F00;}
.msg{ line-height:20px; padding:5px; color:#930;}
</style>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript">
// JavaScript Document
function check(obj){
	if(obj.OldPass.value==""){
		alert("请输入您的旧密码!");
		obj.OldPass.focus();
		obj.OldPass.select();
		return false;
	}
	if(obj.NewPass.value==""){
		alert("请填写您的新密码!");
		obj.NewPass.focus();
		obj.NewPass.select();
		return false;
	}
	if(obj.ConfirmPass.value!=obj.NewPass.value){
		alert("确认密码不一致!");
		obj.ConfirmPass.focus();
		obj.ConfirmPass.select();
		return false;
	}
	if(obj.CheckCode.value==""){
		alert("验证码不能为空!");
		obj.CheckCode.focus();
		obj.CheckCode.select();
		return false;
	}
	return true;
}
function checkemail(semail){
	var pattern = /^([\.a-zA-Z0-9_-]){3,}@([\.a-zA-Z0-9_-]){2,}(\.([a-zA-Z0-9]){2,4}){1,2}$/; 
	return pattern.test(semail);
}
</script>
</head>
<body>

<%
dim act,username,showhead
showhead=request.QueryString("showhead")
if(showhead<>"") then
	showhead=Cint(showhead)
else
	showhead=0
end if
if(showhead=1) then
%>
<!--#include file="head.asp" -->
<%
end if
act=request.QueryString("act")
if(act="do") then
	if(isSelfRefer()) then
	else
		call alertstr("禁止外部提交",2)
	end if
	dim rs,OldPass,NewPass,ConfirmPass,CheckCode,UIP,IsRight,GenMsg,NewPassWd
	dim m_pass,m_answer
	username=replaceBadChar(request.Form("username"))
	OldPass=request.Form("OldPass")	
	NewPass=request.Form("NewPass")
	ConfirmPass=request.Form("ConfirmPass")
	CheckCode=request.Form("CheckCode")
	if CheckCode <> CStr(Session("GetCode"))  then 
		call alertstr("错误：\n验证码错误",1)
	end if
	if CheckCode= "" then
		call alertstr("错误：\n验证码错误",1)
	elseif Session("GetCode") = "9999" then
		Session("GetCode")=""
	elseif Session("GetCode") = "" then
		call alertstr("错误：\n验证码错误",1)
	elseif cstr(Session("GetCode"))<>cstr(Trim(CheckCode)) then
		call alertstr("错误：\n您输入的确认码和系统产生的不一致，请重新输入。\n返回后请刷新登录页面后重新输入正确的信息",2)		
	end if
	Session("GetCode")=""
	UIP=GetIp()	
	NewPassWd=Md5(NewPass,32)
	OldPass=Md5(OldPass,32)
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from t_member where UserId='"&username&"'",conn,3,1
	if not rs.eof then
		m_pass=rs("UserPass")
		if(m_pass=OldPass) then
			IsRight=true
			conn.execute("update t_member set UserPass='"&NewPassWd&"' where UserId='"&username&"'")
			GenMsg="成功修改密码"
		else
			IsRight=false
			GenMsg="旧密码错误！"
		end if
	else
		IsRight=false
		GenMsg="没有找到此用户"		
	end if
	rs.close
	set rs=nothing
	response.Write("<p align=""center"" class=""msg"">"&GenMsg&"</p>")
else
	username=request.QueryString("username")
	if(username<>"") then
		username=replaceBadChar(username)
%>
<form id="form1" name="form1" method="post" action="?act=do" onsubmit="return check(this)">
  <table width="960" align="center" cellpadding="0" cellspacing="1" bgcolor="#fff0cf" class="tableborder">
    <tr align="middle">
      <th colspan="2" class="pad_10">修改密码</th>
    </tr>
    <tr>
      <td height="22" colspan="2" bgcolor="#FFFFFF" class="pformleft">&nbsp;</td>
    </tr>
    <tr>
      <td width="46%" height="35" bgcolor="#FFFFFF" class="pad_5"><strong>您的旧密码</strong>：</td>
      <td width="54%" bgcolor="#FFFFFF" class="pformleft"><input name="OldPass" type="password" id="OldPass" size="30" maxlength="20" />
        (<span class="style3">*</span>)<span id="userMsg"></span></td>
    </tr>
    <tr>
      <td height="35" bgcolor="#FFFFFF" class="pad_5"><strong>输入新密码</strong>：</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="NewPass" type="password" id="NewPass" size="30" />
      (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td height="35" bgcolor="#FFFFFF" class="pad_5"><strong>新密码确认</strong>：</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="ConfirmPass" type="password" id="ConfirmPass" size="30" />
      (<span class="style3">*</span>)</td>
    </tr>
	<tr>
      <td width="46%" height="35" bgcolor="#FFFFFF" class="pad_5"><strong>请输入验证码</strong>：</td>
    <td width="54%" bgcolor="#FFFFFF" class="pformleft">
        <input size="5" name="CheckCode" />          
          <% = GetCode() %>
          (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td height="45" colspan="2" bgcolor="#FFFFFF" class="row4"><div align="center">
        <input type="hidden" name="username" value="<%=username%>" />
        <input type="submit" name="Submit" value="确定" />
        <input type="reset" name="Submit2" value="重 写" />
      </div></td>
    </tr>
  </table>
</form>
<%
	else
		response.Write("<p align=""center"">请先登录</p>")
	end if
end if
%>
</body>
</html>
<%
call connclose()
%>