<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="md5.asp"-->
<%
sql="select * from [admin]"
set rs=Server.CreateObject("Adodb.Recordset")
rs.open sql,conn,1,1
If rs.Bof Then 
   Response.Write("<script language=javascript>alert('非法操作。请返回！！！');history.back()</script>")
   Response.End
End If
If Request.QueryString("style")="del" Then
   conn.execute("delete * from admin where ID=" & Request.QueryString("id"))
   Response.Write("<script language=javascript>window.location.replace('usermana.asp');</script>")
End If
If Request.QueryString("style")="add" Then
    sql="select * from [admin] where admin='"&Request.Form("user")&"'"
    set rs=Server.CreateObject("Adodb.Recordset")
	rs.open sql,conn,1,1
	If not rs.Bof Then 
	   Response.Write("<script language=javascript>alert('已经有此用户。请返回！！！');history.back()</script>")
	   Response.End
	End If                   '判断一下。是否已经有此用户。如果有的话程序返回
   conn.execute("insert into admin (admin,password,flag) values ('"&Request.Form("user")&"','"&md5(Request.Form("pass"))&"',"&Request.Form("flag")&")")
   Response.Write("<script language=javascript>window.location.replace('usermana.asp');</script>")
   ConnClose()
   Response.end
End If
                             '填加一个用户
If Request.QueryString("style")="edit" Then
   conn.execute("update admin set password='"&md5(Request.Form("password"))&"' where admin='"&Request.Form("admin")&"'")
   conn.execute("update admin set flag="&cint(request("flag"))&" where admin='"&Request.Form("admin")&"'")
   Response.Write("<script language=javascript>window.location.replace('usermana.asp');</script>")
   ConnClose()
   Response.end
End If                      '修改用户的密码
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="images/bbs.css" rel="stylesheet" type="text/css">
<script language=javascript>
function xxg()
{
  if (form2.user.value=="")
   {
     alert("姓名？？？");
	 return false;
	 }
  if (form2.pass.value=="")
   {
    alert("密码？？？");
     return false;
	 }
	 return true
	 }
</script>
</head>
<body>
<%
if session("flag")>0 then
   Response.Write("<br><br><br><center>对不起。你没有权限进入此页面！！！</center>")
   Response.end 
end if
%>
<table width="458" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr align="center"> 
    <td width="7%" height="25">ID</td>
    <td width="26%" height="25">姓名</td>
    <td width="23%">密码</td>
    <td width="19%">权限</td>
    <td width="25%" height="25">操作</td>
  </tr>
</table>
  
  <% 
		rs.pagesize=8
		currentpage=Clng(request("page"))
		if currentpage<1 then currentpage=1
		if currentpage>rs.pagecount then currentpage=rs.pagecount
		rs.absolutepage=currentpage

Do While Not rs.Eof %>
<table width="462" align="center">
  <%
if session("flag")=0 then
%>
  <form action="usermana.asp?style=edit" method="post">
    <tr> 
      <td width="29" height="25" align="center"><%=rs("ID")%></td>
      <td width="114" height="25"> <input name="admin" type="text" id="admin" value="<%=rs("admin")%>" size="15" readonly="true"> 
      </td>
      <td width="101" height="25"> <input name="password" type="password" id="password" value="<%=rs("password")%>" size="13"></td>
      <td width="82"><select name="flag" id="flag">
          <option value="1" <%if rs("flag")=1 then%>selected<%end if%>>用户</option>
          <option value="0" <%if rs("flag")=0 then%>selected<%end if%>>管理员</option>
        </select></td>
      <td width="112" height="25" align="center"><input name="submit" type="submit" id="submit" value="修改">
        <a href="usermana.asp?id=<%=rs("ID")%>&style=del" class="black">删除</a></td>
    </tr>
  </form>
</table>
<%
  end if
i=i+1
rs.MoveNext
If i>=rs.pagesize Then Exit Do
Loop  %>
</table>
<form name="form1" method="post" action="usermana.asp">
  <table width="438" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
      <td><div align="center">共有用户:<font color=red><%=rs.recordcount-1%></font> &nbsp;&nbsp;<a href=usermana.asp class="black">首页</a>&nbsp; <a href=usermana.asp?page=<%=currentpage-1%> class="black"> 
          上一页</a> &nbsp; <a href=usermana.asp?page=<%=currentpage+1%> class="black">下一页</a>
           &nbsp; <a href=usermana.asp?page=<%=rs.pagecount%> class="black">尾页</a>&nbsp; 
          <input name="search" type="hidden" id="search" value="<%=search%>">
          <input name="key" type="hidden" id="key" value="<%=key%>">
        </div></td>
    </tr>
  </table>
</form>
<form name="form2" method="post" action="usermana.asp?style=add" onsubmit="return xxg()">
  <table width="438" height="101" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
      <td colspan="3" align="center">填加用户</td>
    </tr>
    <tr> 
      <td width="67" align="center">姓名</td>
      <td width="154"><input name="user" type="text" id="user"></td>
      <td width="217">密码 <input name="pass" type="password" id="pass"></td>
    </tr>
    <tr> 
      <td align="center">&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr> 
      <td align="center">权限</td>
      <td> <input name="flag" type="radio" value="1" checked>
        用户 
        <input type="radio" name="flag" value="0">
        管理员</td>
      <td> 
        <input type="submit" name="Submit2" value="提交"></td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td colspan="2">&nbsp; </td>
    </tr>
  </table>
</form>
</body>
</html>
<%
rsclose()
ConnClose() %>