<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #INCLUDE FILE = "conn.asp" -->
<!-- #INCLUDE FILE = "MD5.asp" -->
<!-- #INCLUDE FILE = "session.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>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
.style2 {font-size: 12px}
-->
</style>
</head>
<%
dim act,username,oldpass,newpass,newpassconfirm
act=request.QueryString("act")
if(act<>"" and act="mod") then
	username=session("TotStat_Name")
	oldpass=md5(request.Form("oldpass"),32)
	newpass=md5(request.Form("newpass"),32)
	newpassconfirm=md5(request.Form("newpassconfirm"),32)
	if(newpassconfirm<>newpass) then
		response.Write("两次输入的密码不同")
		response.Write("<br><a href=""javascript:history.back();"">返回</a>")
		response.End()
	end if	
	Set rs=Server.CreateObject("ADODB.Recordset")
	rs.open "select * from t_admin where adminname='"&username&"' and adminpass='"&oldpass&"'",conn,3,3
	if not rs.eof then
		rs("adminpass")=newpass
		rs.update
		rs.close
		set rs=nothing
		session("admin")=empty
		response.Write("<script>alert(""成功修改密码!系统将返回至登录页面"");location.href='login.asp';</script>")		
	else
		response.Write("你的旧密码不正确!")
		response.Write("<br><a href=""javascript:history.back();"">返回</a>")
		rs.close
	set rs=nothing
		response.End()
	end if	
else
%>
<body>
<script language="javascript">
function check(obj){
	with(obj){
		if(username.value==""){
			alert("用户名不能为空!");
			username.focus();
			username.select();
			return false;
		}
		if(oldpass.value==""){
			alert("原有密码不能为空!");
			oldpass.focus();
			oldpass.select();
			return false;
		}
		if(newpass.value==""){
			alert("请确定您的新密码!");
			newpass.focus();
			newpass.select();
			return false;
		}
		if(newpassconfirm.value==""){
			alert("请确认您的密码!");
			newpassconfirm.focus();
			newpassconfirm.select();
			return false;
		}
		if(newpass.value!=newpassconfirm.value){
			alert("两次输入的密码不同!");
			newpass.focus();
			newpass.select();
			return false;
		}
		return true;
	}
}
</script>
<form id="form1" name="form1" method="post" action="?act=mod" onsubmit="return check(this)">
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#E7E7E7">
    <tr>
      <td height="22" colspan="2" bgcolor="#006699"><div align="center" class="style1">修改密码</div></td>
    </tr>
    <tr>
      <td width="300" height="30" bgcolor="#FFFFFF"><div align="right">用户名：</div></td>
      <td width="300" bgcolor="#FFFFFF"><input name="username" type="text" id="username" size="20" value="<%=session("TotStat_Name")%>" readonly="true" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF"><div align="right">旧密码：</div></td>
      <td height="30" bgcolor="#FFFFFF"><input name="oldpass" type="password" id="oldpass" size="20" /></td>
    </tr>
	<tr>
      <td bgcolor="#FFFFFF"><div align="right">新密码：</div></td>
      <td height="30" bgcolor="#FFFFFF"><input name="newpass" type="password" id="newpass" size="20" /></td>
    </tr>
	<tr>
      <td bgcolor="#FFFFFF"><div align="right">确认密码：</div></td>
      <td height="30" bgcolor="#FFFFFF"><input name="newpassconfirm" type="password" id="newpassconfirm" size="20" /></td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#FFFFFF"><div align="center">
        <input type="submit" name="Submit" value="修改" />&nbsp;&nbsp;
        <input type="reset" name="Submit2" value="取消" />
      </div></td>
    </tr>
  </table>
  <p align="center" class="style2">注：此处修改的密码，是统计系统独立管理员的登录密码，CMS后台总管理员还是可以查看系统统计情况。</p>
</form>
<%
end if
%>
</body>
</html>
<%
call connclose()
%>