<!-- #include file="common.asp"-->
<!-- #include file="admcomm.asp"-->
<!-- #include file="md5.asp"-->
<!-- #include file="isadm.asp" -->
<%
	Dim zsb_auth, hasAuth
	hasAuth = False
	zsb_auth = Split( Trim( session("zsb_auth") ), ",", -1, 1 )
	For Each auth In zsb_auth
		If ( auth = "account" ) Then
				hasAuth = True
			Exit For
		End If
	Next
	
	'对帐户管理功能，因其需要设置用户功能操作权限，所以即使没有设置此功能操作权限
	'只要他是超级用户，就允许他操作此功能
	If hasAuth = false and session("zsb_admtp")="normaladm" Then
		Response.Write("<script language=javascript>alert('对不起，你没有权限，请联系超级管理员！');history.back(-1);</script>")
	End If
%>
<%
  if Trim(Request("op"))="ModS" then
    set rs=Server.CreateObject("ADODB.Recordset")
    sqlstr="select * from Admin Where ID=" & Trim(Request("ID"))
    rs.open sqlstr,conn,1,3
    if not rs.eof then
	    rs("AdmID")=Trim(Request.Form("AID"))
		If rs("AdmPS") <> Trim(Request.Form("APS")) Then
			rs("AdmPS")=md5(Trim(Request.Form("APS")))
		End If
		if Request.Form("ATP")=1 then
		  rs("AdmTP")=True
		  rs("Authorization")="config,news,account,modguest,repguest,delguest,settop,clearword,batchadm,ipdenylist,denyip,auditing"
		else
		  rs("AdmTP")=False
		end if
	  rs.Update
	end if 
	rs.close
	set rs=nothing   

  elseif Trim(Request("op"))="Add" then
  	If Trim(Request.Form("AID"))="" or Trim(Request.Form("APS"))="" Then
		Response.Write("<script language=javascript>alert('请输入帐号和密码！');history.back(-1);</script>")
	End If

    set rs=Server.CreateObject("ADODB.Recordset")
    sqlstr="select * from Admin Where AdmID='" & Trim(Request.Form("AID")) & "'"
    rs.open sqlstr,conn,1,3
    if not rs.eof then
	 	Response.Write("<script language=javascript>alert('该管理员已经存在！');history.back(-1);</script>")
	else
		rs.AddNew
		rs("AdmID")=Trim(Request.Form("AID"))
		rs("AdmPS")=md5(Trim(Request.Form("APS")))
		if Request.Form("ATP")=1 then
		  	rs("AdmTP")=True
		  	rs("Authorization")="config,news,account,modguest,repguest,delguest,settop,clearword,batchadm,ipdenylist,denyip,auditing"
		else
		  	rs("AdmTP")=False
			rs("Authorization")=",,,,,," 
		end if
		rs.Update
	end if 
	rs.close
	set rs=nothing 
	  
  elseif Trim(Request("op"))="Del" then
    SQLDel="Delete from Admin Where ID=" & Trim(Request("ID"))
	conn.Execute(SQLDel)
  end if
%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=<%=Char_Set%>">
	<title>管理员账号管理</title>
	<link href="commcss.css" rel="stylesheet" type="text/css">
	<link href="<%=GBCss%>/common.css" rel="stylesheet" type="text/css">
</head>

<body>
<div style="background-color:#fff;">
<%Call AdmPageTop()%>
<% if Trim(Request("op"))="Mod" then %>
<%
    set rs=Server.CreateObject("ADODB.Recordset")
    sqlstr="select * from Admin Where ID=" & Trim(Request("ID"))
    rs.open sqlstr,conn,1,3
    if not rs.eof then
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(<%=GBSkin%>/guest_bg.gif);">
  <tr align="center">
    <td height="10" colspan="2">&nbsp;</td>
  </tr>
  <tr align="center">
    <td height="30" colspan="2" style="background-image:url(<% =GBSkin %>/guest_top.gif) ">修改管理帐号</td>
  </tr>
  <form name="form1" method="post" action="Aid_mang.asp?op=ModS&pn=<%=Request("pn")%>&ID=<% =Trim(rs("ID")) %>">
  <tr>
    <td width="40%" height="30" align="right">管理员帐号：</td>
    <td height="30">
      <input name="AID" type="text" class="input_common" style="width: 140px; height:18px;" id="AID" value="<% =Trim(rs("AdmID")) %>">
    </td>
  </tr>
  <tr>
    <td height="30" align="right">管理员密码：</td>
    <td height="30"><input name="APS" type="password" class="input_common" style="width: 140px; height:18px;"  id="APS" value="<% =Trim(rs("AdmPS")) %>"></td>
  </tr>
  <tr>
    <td height="30" align="right">管理员类型：</td>
    <td height="30"><select name="ATP" id="ATP">
	<% if rs("AdmTP")=True then %><option value="1" selected>超级管理员</option>
	<option value="0">普通管理员</option>
	<% else %>
      <option value="0" selected>普通管理员</option>
      <option value="1">超级管理员</option><% end if %>
    </select></td>
  </tr>
  <tr align="center">
    <td height="30" colspan="2">
	<input type="button" onClick="javascript:location.href='manage.asp?pn=<%=Trim(Request("pn"))%>';" value="返&nbsp;&nbsp;&nbsp;&nbsp;回" class="button_common" style="width:80px; height:18px;">
	<input type="reset" class="button_common" style="width:80px; height:18px;"  name="Submit" value="重&nbsp;&nbsp;&nbsp;&nbsp;置">
    <input type="submit" class="button_common" style="width:80px; height:18px;"  name="Submit" value="提&nbsp;&nbsp;&nbsp;&nbsp;交"></td>
    </tr>
  <tr align="center">
    <td height="20" colspan="2">&nbsp;</td>
  </tr>
  </form>
	<tr align="center">
    <td height="10" colspan="2" style="background-image:url(<%=GBSkin%>/guest_top.gif);">&nbsp;</td>
  </tr>
</table>
<%
  end if
  rs.close
  set rs=nothing
%>
<% end if %>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(<% =GBSkin %>/guest_bg.gif) ">
  <tr>
    <td height="10" colspan="5"></td>
  </tr>
  <tr align="center">
    <td height="30" colspan="5" style="background-image:url(<% =GBSkin %>/guest_top.gif) ">管理员列表</td>
  </tr>
  <tr align="center">
    <td height="30">编号</td>
    <td>管理用户名</td>
    <td>管理密码</td>
    <td>管理类型</td>
    <td>操作</td>
  </tr>
<%
  set rs=Server.CreateObject("ADODB.Recordset")
  sqlstr="select * from Admin"
  rs.open sqlstr,conn,1,3
  if not rs.eof then
		i=0
    While Not rs.EOF
%>
  <tr align="center" style="<%If (i MOD 2)=0 Then%>background-color:#fff;<%End If%>border:#ccc 1px solid;">
    <td height="30"><% =rs("ID") %></td>
    <td height="30"><% =rs("AdmID") %></td>
    <td height="30"><% '=rs("AdmPS") %>**********</td>
    <td height="30"><% if rs("AdmTP")=True then %>超级管理员<% else %>普通管理员<% end if %></td>
    <td height="30"><a href="Aid_mang.asp?op=Mod&pn=<%=Request("pn")%>&ID=<% =rs("ID") %>">修改</a>&nbsp;<a href="Aid_mang.asp?op=Del&pn=<%=Request("pn")%>&ID=<% =rs("ID") %>">删除</a>&nbsp;<a href="authsetting.asp?pn=<%=Request("pn")%>&id=<% =rs("ID") %>">设置管理权限</a></td>
  </tr>
<%
	  rs.movenext
		i=i+1
	wend
  end if
  rs.close
  set rs=nothing
%>
  <tr align="center">
    <td height="10" colspan="5" style="background-image:url(<%=GBSkin%>/guest_top.gif);">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(<% =GBSkin %>/guest_bg.gif) ">
  <tr align="center">
    <td height="10" colspan="2">&nbsp;</td>
  </tr>
  <tr align="center">
    <td height="27" colspan="2" style="background-image:url(<% =GBSkin %>/guest_top.gif) ">增加管理帐号</td>
  </tr>
  <form name="form1" method="post" action="Aid_mang.asp?pn=<%=Request("pn")%>&op=Add">
  <tr>
    <td width="40%" height="30" align="right">管理员帐号：</td>
    <td height="30">
      <input name="AID" class="input_common" style="width: 140px; height:18px;"  type="text" id="AID">
    </td>
  </tr>
  <tr>
    <td height="30" align="right">管理员密码：</td>
    <td height="30"><input name="APS" class="input_common" style="width: 140px; height:18px;"  type="password" id="APS"></td>
  </tr>
  <tr>
    <td height="30" align="right">管理员类型：</td>
    <td height="30"><select name="ATP" id="ATP">
      <option value="0" selected>普通管理员</option>
      <option value="1">超级管理员</option>
    </select></td>
  </tr>
  <tr align="center">
    <td height="30" colspan="2">
	<input type="button" onClick="javascript:location.href='manage.asp?pn=<%=Trim(Request("pn"))%>';" value="返&nbsp;&nbsp;&nbsp;&nbsp;回" class="button_common" style="width:80px; height:18px;">
	<input type="reset" class="button_common" style="width:80px; height:18px;"  name="Submit" value="重&nbsp;&nbsp;&nbsp;&nbsp;置">
    <input type="submit" class="button_common" style="width:80px; height:18px;"  name="Submit" value="提&nbsp;&nbsp;&nbsp;&nbsp;交"></td>
    </tr></form>
	<tr align="center">
    <td height="10" colspan="2" style="background-image:url(<%=GBSkin%>/guest_top.gif);">&nbsp;</td>
  </tr>
</table>
<%Call CopyRight()%>
</div>
</body>
</html>