<!--#include file="../conn/conn.asp"-->
<!--#include file="../conn/nosql.asp"-->
<!--#include file="../conn/config.asp"-->
<!--#include file="../conn/md5.asp"-->

<%if Not ChkPosturl then response.redirect ("login.asp")
if session("adminname")="" then
  response.Write "<script language='javascript'>alert('网络超时或您还没有登陆！');window.location.href='login.asp';</script>"
  response.End
end if
  action=request.QueryString("action")
  adminname=nosql(trim(request("admin")))
  adminpass=nosql(trim(request("password")))
if action= "edit" then
if isChkInteger(request.QueryString("id")) then
id=request("id")
else
Response.Redirect ("../index.asp")
end if
  set rs=server.CreateObject("adodb.recordset")
  rs.Open "select * from mini_admin where id="&id,conn,1,3
  rs("adminname")=adminname
    if trim(request("password"))<>"" then
    rs("adminpass")=md5(trim(request("password")))
    end if
  rs("adminflag")=int(request("flag"))
  rs.Update
  rs.Close
  set rs=nothing
    response.write "<script language='javascript'>"
    response.write "alert('操作成功，正在返回！');"
    response.write"this.location.href='mini_manageadmin.asp';</SCRIPT>"
    response.End
end if
'//添加新数据
if action= "add" then
  set rs=server.CreateObject("adodb.recordset")
  rs.open "select * from mini_admin",conn,1,3
  rs.addnew
  rs("adminname")=trim(request("admin2"))
  rs("adminpass")=md5(trim(request("password2")))
  rs("adminflag")=int(request("flag2"))
  rs.update
  rs.close
  set rs=nothing
    response.write "<script language='javascript'>"
    response.write "alert('添加成功，正在返回！');"
    response.write"this.location.href='mini_manageadmin.asp';</SCRIPT>"
    response.End
end if
'//删除数据
if action= "del" then
if isChkInteger(request.QueryString("id")) then
id=request("id")
else
Response.Redirect ("../index.asp")
end if
  conn.execute ("delete from mini_admin where id="&id)
  response.Redirect "mini_manageadmin.asp"
end if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../css.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/right_top2.gif">
  <tr>
    <td width="1%">&nbsp;</td>
    <td width="99%"><table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="30%" style="font-size:14px;color:#ffffff">&nbsp;<strong><font color="#000000">后台用户管理</font></strong></td>
          <td width="70%" align="right">&nbsp;</td>
        </tr>
    </table></td>
  </tr>
</table>
<br>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#9DB2D4">
  <%set rs=server.CreateObject("adodb.recordset")
        rs.Open "select * from mini_admin order by id",conn,1,1
        do while not rs.EOF
		%>
  <form name="form1" method="post" action="?action=edit&id=<%=int(rs("id"))%>">
    <tr bgcolor="#F0F3F8">
      <td colspan="2" bgcolor="#F0F3F8">&nbsp;&nbsp;管理员
          <input name="admin" type="text" class="wenbenkuang" size="16" value="<%=trim(rs("adminname"))%>">
     &nbsp;&nbsp;密 码
            <input name="password" type="text" size="16" class="wenbenkuang">
&nbsp;&nbsp;权 限
      <%select case rs("adminflag")
                case "1"
                response.Write "<input type=radio name=flag value=1 checked>管理&nbsp;<input name=flag type=radio value=2 >查看"
                case "2"
                response.Write "<input type=radio name=flag value=1>管理&nbsp;<input name=flag type=radio value=2 checked>查看"
                end select%>&nbsp;&nbsp;<input type="submit" name="Submit" value="修 改" class="go-wenbenkuang">&nbsp;&nbsp;<a href="?id=<%=int(rs("id"))%>&action=del" onClick="return confirm('您确定要删除此用户吗？')"><font color=red>删除该管理员</font></a>
      <div align="center"> </div>        <div align="center">        </div>        <div align="center"> </div></td>
    </tr>

  </form>
  <%rs.movenext
        loop
        rs.close
        set rs=nothing
        %>
</table>
<br>
<br>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#9DB2D4">
  <form name="form1" method="post" action="?action=add">
    <tr bgcolor="#F0F3F8">
      <td colspan="2" bgcolor="#F0F3F8"> &nbsp;&nbsp;管理员
          <input name="admin2" type="text" size="16" class="wenbenkuang">
        &nbsp;&nbsp;密 码
        <input name="password2" type="text" size="16" class="wenbenkuang">
        &nbsp;&nbsp;权 限
        <input type="radio" name="flag2" value="1">
        管理
        <input name="flag2" type="radio" value="2" checked>
        查看
       &nbsp;&nbsp;<input type="submit" name="Submit2" value="添 加" class="go-wenbenkuang"></td>
    </tr>
  </form>
</table>
</body>
</html>
<script language=javascript>
function mm()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script>
<script language=javascript>
function mm1()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script>