<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<!--#include file="md5.asp"-->
<%
if session("admin")="" then
  response.redirect "admin_login.asp"
end if

dim action,af(15)
action=request("action")

af(0)="00,分类管理"
af(1)="01,Flash添加"
af(2)="02,Flash管理"
af(3)="03,联盟作者管理"
af(4)="04,管理员管理"
af(5)="05,修改我的密码"  '
af(6)="06,友情链接管理"
af(7)="07,访客留言管理"
af(8)="08,网友点播管理"
af(9)="09,投票管理"
af(10)="10,评论管理"
af(11)="11,公告管理"
af(12)="12,配置修改"
af(13)="13,数据库备份"
af(14)="14,数据库恢复"
af(15)="15,执行SQL"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Flash系统-管理员管理</title>
<script language=javascript src="mouse_up.js"></script>
<link href="admin.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#FFFFCC" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#000000" vspace="0" hspace="0">
  <tr bgcolor="#EFEBEF"> 
    <td height="27"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="86%"><font color="#FF3000">.:: 您可以在这里进行[管理员管理]相关操作</font></td>
          <td width="14%" height="20" align="center"><a href="javascript:this.location.reload()"><img src="images/refresh.gif" alt="刷新" width="40" height="12" border="0"></a></td>
        </tr>
      </table></td>
  </tr>
  <tr > 
    <td height="1" bgcolor="#000000"></td>
  </tr>
</table>
<br>

<%
select case action
  case "edit"
   call adminedit()
  case "saveedit"
   call saveedit()
  case "myedit"
   call myedit()
  case "savemyedit"
   call savemyedit()
  case "del"
   call del()
  case "add"
   call add()
  case "addsave"
   call addsave()
  case else
   call main()
end select

conn.close
set conn=nothing

sub main()

'04 管理员管理
if not checkflag("04") then
  call mb("对不起，您没有管理员管理的权限！","",0)
end if
response.expires=0

set rs=conn.execute("select * from admin")
%>
<form name="form1" method="post" action="">
  <table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr bgcolor="#EFEBEF"> 
      <td height="23" colspan="7" align="center"><font color="#000000">系统管理员帐号列表</font> 
        　[<a href="?action=add">添加一个新帐号</a>]</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="46" height="23" align="center">ID</td>
      <td width="157" height="23" align="center">管理帐号</td>
      <td width="100" height="23" align="center">登陆次数</td>
      <td width="217" height="23" align="center">最后登陆</td>
      <td width="220" height="23" align="center">最后登陆IP</td>
      <td width="98" height="23" align="center">状态</td>
      <td width="107" height="23" align="center">操　作</td>
    </tr>
    <%
if rs.bof and rs.eof then
%>
    <tr bgcolor="#FFFFFF"> 
      <td height="23" colspan="7" align="center"><font color="#FF0000">还没有任何管理员帐号！</font>　　<a href="?action=add">请先添加</a></td>
    </tr>
    <%
else
do until rs.eof
%>
    <tr bgcolor="#FFFFFF"> 
      <td height="23">&nbsp;<%=rs("id")%></td>
      <td height="23">&nbsp;<a href="?action=edit&admin=<%=rs("admin")%>" title="编辑管理员：<%=rs("admin")%>"><%=rs("admin")%></a></td>
      <td height="23">&nbsp;<b><%=rs("logins")%></b></td>
      <td height="23">&nbsp;<b><%=rs("lastlogin")%></b></td>
      <td height="23">&nbsp;<b><%=rs("lastip")%></b></td>
      <td height="23" align="center"> 
        <%
	  if rs("islock") then
	    response.write "<font color=red>锁定</font>"
	  else
	    response.write "正常"
	  end if%>
      </td>
      <td height="23" align="center"><a href="?action=edit&admin=<%=rs("admin")%>" title="编辑管理员：<%=rs("admin")%>">编辑</a>　<a href="?action=del&id=<%=rs("id")%>" title="删除管理员：<%=rs("admin")%>" onclick="javascript:if(confirm('是否真的要删除管理员：<%=rs("admin")%>？\n\n系统提示：删除后不可恢复')){return true;}else{return false;}">删除</a></td>
    </tr>
    <%
rs.movenext
loop
end if
rs.close
set rs=nothing
%>
  </table>
  <br>
  <br>
</form>
<%end sub

sub adminedit()

'04 管理员管理
if not checkflag("04") then
  call mb("对不起，您没有管理员管理的权限！","",0)
end if

dim admin
admin=checkstr(request("admin"))
if admin="" then
  call mb("对不起，请指定要编辑的管理员帐号！","",0)
  response.end
end if

set rs=server.createobject("adodb.recordset")
sql="select * from admin where admin='"&admin&"'"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
  call mb("对不起，找不到您要编辑的管理员帐号信息！","",0)
  response.end
end if
%>
<form action="?action=saveedit" method="post" name="adminedit" id="adminedit">
  <table border="0" cellspacing="1" cellpadding="4" bgcolor="#CCCCCC" align="center" width="500">
    <tr align="center" bgcolor="#EFEBEF" > 
      <td colspan="2"><font color="#000000">编 辑 管 理 员</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="116" height="22" align="right">登陆帐号：</td>
      <td width="365"> 
        <input name="admind" type="text" disabled class="input" id="admind" value="<%=rs("admin")%>">
        * </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="right">登陆密码：</td>
      <td> 
        <input name="password" type="password" class="input" id="password" value="<%=rs("password")%>">
        *!-如果不想修改请保持原样-&gt;</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="right">管理权限：</td>
      <td><table border=0 cellspacing=0 cellpadding=0><tr>
        <%dim i,j,temp
	  j=1
	  for i=0 to ubound(af)
	    temp=split(af(i),",")
		response.write "<td height=20 width='33%'><input type='checkbox' value='"&temp(0)&"' name='flag'"
		if instr(rs("flag"),temp(0))>0 then
		  response.write " checked"
		end if
		response.write ">"&temp(1)&"</td>"
		if j mod 3=0 then response.write "</tr><tr>"
		j=j+1
	  next
	 %>
	 </tr></table>
        <input name="chkall" type="checkbox" id="chkall3" onclick="CheckAll(this.form)" value=""> 
        &nbsp;<font color="#FF0000">全　　选</font> </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="right">帐号状态：</td>
      <td>&nbsp; 
        <input type="radio" name="islock" value="true" <%if rs("islock") then response.write " checked"%>>
        锁定　
        <input type="radio" name="islock" value="false" <%if not rs("islock") then response.write " checked"%>>
        正常</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td colspan="2" align="center"> 
        <input name="Submit" type="submit" class="button" value=" 确 定 编 辑"> 
        <input type="hidden" name="action" value="saveedit"> <input name="admin" type="hidden" id="admin" value="<%=rs("admin")%>"> 
      </td>
    </tr>
  </table>
</form>
<%
rs.close
set rs=nothing
end sub

sub myedit()

'05 修改我的密码
if not checkflag("05") then
  call mb("对不起，您没有修改密码的权限！","",0)
end if

dim admin
admin=checkstr(request("admin"))
if admin="" then
  call mb("对不起，请指定要编辑的管理员帐号！","",0)
  response.end
end if

set rs=server.createobject("adodb.recordset")
sql="select * from admin where admin='"&admin&"'"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
  call mb("对不起，找不到您要编辑的管理员帐号信息！","",0)
  response.end
end if
%>
<form action="?action=savemyedit" method="post" name="myedit" id="myedit">
  <table border="0" cellspacing="1" cellpadding="4" bgcolor="#CCCCCC" align="center" width="500">
    <tr align="center" bgcolor="#EFEBEF" > 
      <td colspan="2"><font color="#000000">修 改 我 的 登 陆 密 码</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="116" height="22" align="right">登陆帐号：</td>
      <td width="365"> 
        <input name="admind" type="text" disabled class="input" id="admind" value="<%=rs("admin")%>">
        * </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="right">登陆密码：</td>
      <td> 
        <input name="password" type="password" class="input" id="password" value="<%=rs("password")%>">
        *!-如果不想修改请保持原样-&gt;</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="right">管理权限：</td>
      <td> <table border=0 cellspacing=0 cellpadding=0><tr>
        <%dim i,j,temp
	  j=1
	  for i=0 to ubound(af)
	    temp=split(af(i),",")
		response.write "<td height=20 width='33%'><input type='checkbox' value='"&temp(0)&"' name='flag'"
		if instr(rs("flag"),temp(0))>0 then
		  response.write " checked"
		end if
		response.write " disabled>"&temp(1)&"</td>"
		if j mod 3=0 then response.write "</tr><tr>"
		j=j+1
	  next
	 %>
	 </tr></table>
        <input name="chkall" type="checkbox" id="chkall" onclick="CheckAll(this.form)" value="" disabled> 
        &nbsp;<font color="#FF0000">全　　选</font> </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="right">帐号状态：</td>
      <td>&nbsp; 
        <input type="radio" name="islock" value="true" <%if rs("islock") then response.write " checked"%> disabled>
        锁定　
        <input type="radio" name="islock" value="false" <%if not rs("islock") then response.write " checked"%> disabled>
        正常</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td colspan="2" align="center"> 
        <input name="Submit" type="submit" class="button" value=" 确 定 编 辑"> 
        <input type="hidden" name="action" value="saveedit"> <input name="admin" type="hidden" id="admin" value="<%=rs("admin")%>"> 
      </td>
    </tr>
  </table>
</form>
<%
rs.close
set rs=nothing
end sub

sub saveedit()

'04 管理员管理
if not checkflag("04") then
  call mb("对不起，您没有管理员管理的权限！","",0)
end if

 dim admin,password,flag,islock
 admin=checkstr(trim(request("admin")))
 password=checkstr(trim(request("password")))
 flag=request("flag")
 islock=request("islock")

 set rs=server.createobject("adodb.recordset")
 sql="select * from admin where admin='"&admin&"'"
 rs.open sql,conn,1,3
 
 if rs.bof and rs.eof then
   call mb("对不起，没有找到相关管理员帐号的资料！","",0)
 else
   if rs("password")<>password then '修改了密码
     rs("password")=md5(password,"long")
   end if
   rs("flag")=flag
   rs("islock")=islock
   rs.update
   call mb("恭喜您，成功的编辑了管理员："&admin&"的信息！","admin_admin.asp",1)
  end if
  rs.close
  set rs=nothing

end sub
 
sub savemyedit()

'05 修改我的密码
if not checkflag("05") then
  call mb("对不起，您没有修改密码的权限！","",0)
end if


 dim admin,password
 admin=checkstr(trim(request("admin")))
 password=checkstr(trim(request("password")))

 set rs=server.createobject("adodb.recordset")
 sql="select * from admin where admin='"&admin&"'"
 rs.open sql,conn,1,3
 
 if rs.bof and rs.eof then
   call mb("对不起，没有找到相关管理员帐号的资料！","",0)
 else
   if rs("password")<>password then '修改了密码
     rs("password")=md5(password,"long")
   end if
  
   rs.update
   call mb("恭喜您，修改登陆密码成功！","admin_admin.asp?action=myedit&admin="&session("admin"),1)
  end if
  rs.close
  set rs=nothing

end sub

sub add()

'04 管理员管理
if not checkflag("04") then
  call mb("对不起，您没有管理员管理的权限！","",0)
end if 

%>
<form action="?action=addsave" method="post" name="add" id="add">
  <table border="0" cellspacing="1" cellpadding="4" bgcolor="#CCCCCC" align="center" width="500">
    <tr align="center" bgcolor="#EFEBEF" > 
      <td height="23" colspan="2"><font color="#000000">添 加 管 理 员</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="93" height="22" align="right">登陆帐号：</td>
      <td width="288"> 
        <input type="text" name="admin" class="input">
        * </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="right">登陆密码：</td>
      <td> 
        <input type="password" name="password" class="input">
        * </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="right">管理权限：</td>
      <td><table border=0 cellspacing=0 cellpadding=0><tr>
        <%dim i,j,temp
	  j=1
	  for i=0 to ubound(af)
	    temp=split(af(i),",")
		response.write "<td height=20 width='33%'><input type='checkbox' value='"&temp(0)&"' name='flag'>"&temp(1)&"</td>"
		if j mod 3=0 then response.write "</tr><tr>"
		j=j+1
	  next
	 %>
	 </tr></table>
        <input name="chkall" type="checkbox" id="chkall" onclick="CheckAll(this.form)" value="">
        &nbsp;<font color="#FF0000">全　　选</font> </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td colspan="2" align="center"> 
        <input name="Submit2" type="submit" class="button" value="确 定 添 加">
      </td>
    </tr>
  </table>
</form>
<%
end sub

sub addsave()

'04 管理员管理
if not checkflag("04") then
  call mb("对不起，您没有管理员管理的权限！","",0)
end if

 dim admin,password,flag
 admin=checkstr(trim(request("admin")))
 password=checkstr(trim(request("password")))
 flag=request("flag")
 
 set rs=server.createobject("adodb.recordset")
 sql="select * from admin where admin='"&admin&"'"
 rs.open sql,conn,1,3
 
 if rs.bof and rs.eof then
   rs.addnew()
   rs("admin")=admin
   rs("password")=md5(password,"long")
   rs("flag")=flag
   rs.update
   call mb("添加管理员成功！","admin_admin.asp",1)
 else
   call mb("此管理帐号已经存在了！","",0)
 end if
 rs.close
 set rs=nothing
end sub

sub del()

'04 管理员管理
if not checkflag("04") then
  call mb("对不起，您没有管理员管理的权限！","",0)
end if

 dim id
 id=request("id")
 if not isinteger(id) then 
   call mb("系统提示：请正确指定要删除管理员帐号！","",0)
 end if
 
 '删除管理员帐号
 sql="delete from admin where id="&id
 conn.execute(sql)
 
 
 call mb("系统提示：删除管理员帐号成功！","admin_admin.asp",1)
end sub
%>
<script language=javascript>
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       
	 e.checked = form.chkall.checked; 
   }
  }
-->
</script>
</body>
</html>
