<%@LANGUAGE="VBSCRIPT" %>
<!--#include file = "tuzh_pri.asp"-->
<!--#include file="../connadmin.asp"-->
<!--#include file = "../md5.asp"-->

<script language="javascript">
<!--
function checkdel(username){
	if (confirm("您确定要删除 "+user+" 这个超级用户吗？")){
		window.open("chpass.asp?act=del&username="+user,"_self");
	}
	else{
		//Do Nothing;
	}
}
-->
</script><%
doact=request("act")
user=trim(request.form("user"))
pass=trim(request.form("pass"))
user2=trim(request.form("user2"))
pass2=trim(request.form("pass2"))
pass3=trim(request.form("pass3"))
if doact="add" then
if user="" or pass="" then
  response.write("<center><font color=red>用户名或密码不能为空！</font></center>")
else
  set rs=conn.execute("select * from admin where user='"&user&"'") 
  if rs.eof then
  strCommand = "INSERT INTO admin (user,pass) VALUES ('"&user&"','"&md5(pass)&"')"
  conn.Execute strCommand 
  response.write("<center><font color=red>添加新帐户成功！</font></center>")
  else
  response.write("<center><font color=red>错误!此用户名已存在,请重新操作</font></center>")
  end if 
  rs.close
end if
end if

if doact="modi" then
set rs=conn.execute("select * from admin where user='"&user2&"' and pass='"&md5(pass2)&"'") 
  if not rs.eof then
  conn.Execute("UPDATE admin SET pass='"&md5(pass3)&"' WHERE user='"&user2&"'")
  response.write("<center><font color=red>修改成功！</font></center>")

  else
  response.write("<center><font color=red>错误!此用户名不存在!或你的旧密码输入错误</font></center>")
  end if
end if

if doact="del" then
delusername = trim(Request.QueryString("user"))
conn.Execute("DELETE FROM admin WHERE user='"&user&"'")
end if
%>
<html>
<head>
<LINK href="../img/css.css" type=text/css rel=stylesheet>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type=text/css>
body  {
SCROLLBAR-FACE-COLOR: #9CC5D7;
SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; 
SCROLLBAR-SHADOW-COLOR: #006699; 
SCROLLBAR-3DLIGHT-COLOR: #006699; 
SCROLLBAR-ARROW-COLOR: #330000; 
SCROLLBAR-TRACK-COLOR: #E2F3F1; 
SCROLLBAR-DARKSHADOW-COLOR: #ffffff;}
</style>
</head>

<body><center>
  <table class="border" width="98%" border="0" align="center" cellpadding="1" cellspacing="0">
    <tr> 
      <td height="534" align="center" valign="top" class="bg_low"> 
        <table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td align="center" valign="middle" class="bgtop"><font color="#FFFFFF"><b>管理员账户管理</b></font> 
            </td>
          </tr>
        </table>
        <center>
          <br>
          <table width="400" border="5" cellpadding="0" cellspacing="0" bordercolor="#ABCEDD">
<% 
set rs=conn.execute("select * from admin") 
do while not rs.eof
%>
            <tr> 
              <td width="170"> &nbsp;&nbsp;&nbsp; 用户:&nbsp;<%=rs("user")%>&nbsp; 
                <br> 
              </td>
              <td width="216"><input onClick=checkdel("<%=trim(rs("user"))%>") type=button class="button2" value=" 删 除 " name="button"></td>
            </tr>
<%rs.movenext     
loop  
rs.close
set rs=nothing
%>
          </table>
          <p>&nbsp;</p><table width="400" border="5" cellpadding="0" cellspacing="0" bordercolor="#ABCEDD">
            <tr> 
              <td align="center">
<form name="form1" method="post" action="chpass.asp?act=add">
                  <p> 添加用户<br>
                    用户 
                    <input name="user" type="text" id="user">
                    <br>
                    密码 
                    <input name="pass" type="text" id="pass">
                    <br>
                    <input type="submit" name="Submit" value="提交">
                    <input type="reset" name="Submit2" value="重置">
                  </p>
                </form></td>
            </tr>
          </table>
          <p>&nbsp;</p><table width="400" border="5" cellpadding="0" cellspacing="0" bordercolor="#ABCEDD">
            <tr> 
              <td align="center">
<form name="form2" method="post" action="chpass.asp?act=modi">
                  <p> 修改用户<br>
                    用户名 
                    <input name="user2" type="text" id="user2">
                    <br>
                    旧密码 
                    <input name="pass2" type="text" id="pass2">
                    <br>
                    新密码 
                    <input name="pass3" type="text" id="pass3">
                    <br>
                    <input type="submit" name="Submit3" value="提交">
                    <input name="reset" type="reset" id="reset" value="重置">
                  </p>
                </form></td>
            </tr>
          </table>
          <br>
        </center>
        
      </td>
    </tr>
  </table>
  <br>
</center>
</body>
</html>
<%conn.close
set conn=nothing%>
