<!--#include file=conn.asp-->

<!--#include file=../inc/md5.asp-->

<%
if request("jleadd")="ok" then
username=replace(trim(request("username")),"'","‘")
password=replace(trim(request("password")),"'","‘")
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select username,password from [admin] where username='"&username&"'" 
rs.open sql,conn,1,3
if not rs.eof or not rs.bof then
response.write "<li>错误，管理员已经存在！"
response.end
else
rs.addnew
rs("username")=username
rs("password")=md5(password)
rs.update
end if
rs.close
set rs=nothing
closedb
response.write "<li>恭喜你，添加管理员成功！"
response.write "<meta http-equiv=refresh content=""1;URL=admin_administrator.asp"">"
response.end
end if
%>

<link href="inc_style.css" rel="stylesheet" type="text/css">
<body topmargin="0" leftmargin="0">

<div align="center">
<%if request.cookies("adminjle")("max")<>1 then
dim UserName
UserName=request.cookies("adminjle")("username")
jle=request("jle")
password2=trim(request("password2"))
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select * from admin where UserName='"&UserName&"'"
rs.open sql,conn,1,3
if jle="editchk1" then
if password2="" then
response.write"<SCRIPT language=JavaScript>alert('请填写新的密码');javascript:history.go(-1)</SCRIPT>"
response.end 
end if
rs("password")=md5(password2)
rs.update
response.write"<SCRIPT language=JavaScript>alert('密码修改成功');</SCRIPT>"
response.write "<meta http-equiv=refresh content=""1;URL=index.asp"">"
response.end
end if
%>
<div align="center">
<table width="98%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolorlight="#c5cfe0" bordercolordark="#FFFFFF" bgcolor="#C5D5E4"  style="font-size:12px; letter-spacing:1px;">
        <tr align="center" bgcolor="#FFFFFF" height="20"> 
<td align="center" height="29" class="tdbar"><b>修改<%=rs("username")%>（二级管理员）密码</b></td>
</tr>
<tr>
<td height="75" bgcolor="#EAF0FC">
<form method="POST" action="?jle=editchk1" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<p align="center" style="line-height: 200%; ">
新密码：<input name="password2" size="20" maxlength="20" type="password"></p>
<p align="center" style="line-height: 200%; ">
<input type="submit" value="确定修改" name="editchk"></p>
</form>
</td>
</tr>
</table>
</div>
<%
else
%>
<div align="center">
<form method="POST" action="?jleadd=ok">
<center>
<table width="98%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolorlight="#c5cfe0" bordercolordark="#FFFFFF" bgcolor="#C5D5E4"  style="font-size:12px; letter-spacing:1px;">
        <tr align="center" bgcolor="#FFFFFF" height="20"> 
<td align="center" height="29"  class="tdbar">
<p align="center"><b>增加管理员</b></td>
</tr>
<tr>
<td height="21" align="center" bgcolor="#EAF0FC" style="BORDER-BOTTOM: medium none">用户名：<input name="username" size="20" maxlength="20"></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#EAF0FC" style="BORDER-TOP: medium none; BORDER-BOTTOM: medium none">密&nbsp; 码：<input name="password" size="20" maxlength="20"></td>
</tr>
<tr>
<td height="25" bgcolor="#E4EDFC" style="BORDER-TOP: medium none">
<p align="center">
<input type="submit" value="确定添加" name="B1"></td>
</tr>
</table>
</center>
</form>
</div>
<div align="center">
<%
dim username2,password2,max
username2=trim(request("username2"))
password2=trim(request("password2"))
max=request("R1")
jle=request("jle")
id=request("id")
if jle="editchk" then
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select * from [admin] where id="&cstr(id)
rs.open sql,conn,1,3
if password2="" then
response.write"<SCRIPT language=JavaScript>alert('请填写新的密码');javascript:history.go(-1)</SCRIPT>"
response.end 
end if
rs("username")=username2
rs("password")=md5(password2)
rs("max")=max
rs.update
response.write"<SCRIPT language=JavaScript>alert('修改成功');</SCRIPT>"
response.write "<meta http-equiv=refresh content=""1;URL=admin_administrator.asp"">"
response.end
end if
if jle="del" then
call del()
else
 if jle="edit" then
 call edit()
 else
%>
</div>
<div align="center">
<center>
<table width="98%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolorlight="#c5cfe0" bordercolordark="#FFFFFF" bgcolor="#C5D5E4"  style="font-size:12px; letter-spacing:1px;">
      <tr align="center" bgcolor="#FFFFFF" height="20"> 
<td align="center" height="29"  class="tdbar"><font color="#990000">编号</font></td>
<td width="221" height="24" align="center"  class="tdbar"><font color="#990000">管理帐号</font></td>
<td width="65" height="24" align="center"  class="tdbar"><font color="#990000">操作</font></td>
<td width="65" height="24" align="center"  class="tdbar"><font color="#990000">修改</font></td>
</tr>
<%
dim rs,sql,i,id,jle
i=1
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select id,username from [admin]" 
rs.open sql,conn,1,1
do while not rs.eof
%>
<tr>
<td width="46" height="24" align="center" bgcolor="#EAF0FC"><%=i%></td>
<td width="221" height="24" align="center" bgcolor="#EAF0FC"><%=rs("username")%></td>
<td width="65" height="24" align="center" bgcolor="#EAF0FC"><a href="?jle=del&id=<%=rs("id")%>">删除</a></td>
<td width="65" height="24" align="center" bgcolor="#EAF0FC">
<a href="?jle=edit&id=<%=rs("id")%>">修改</a></td>
</tr>
<%
i=i+1
rs.movenext
loop
rs.close
set rs=nothing
sub del()
id=request("id")
set rs = Server.CreateObject("ADODB.RecordSet")
sql="delete from [admin] where id="&cstr(id)
rs.open sql,conn,1,3
response.write "<font size=2>帐号删除成功!</font><br>"
response.end
end sub
%>
</table>
<%sub edit()
id=request("id")
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select * from [admin] where id="&cstr(id)
rs.open sql,conn,1,3
%>
<table border="0" width="90%" cellspacing="0" style="border-collapse: collapse" bordercolor="#cac8c9" height="102" cellpadding="0" class="table">
<tr>
<td align="center" height="25" bgcolor="#FEEEBC" class="tdbar" bordercolor="#A7D0F5"><b>修改管理员信息</b></td>
</tr>
<tr>
<td height="75" bgcolor="#EAF0FC">
<form method="POST" action="?jle=editchk&id=<%=id%>" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<p align="center" style="line-height: 200%; margin-top: 0; margin-bottom: 0">用户名：<input name="username2" size="20" maxlength="20" value="<%=rs("username")%>"></p>
<p align="center" style="line-height: 200%; margin-top: 0; margin-bottom: 0">
密&nbsp; 码：<input name="password2" size="20" maxlength="20" type="password"></p>
<p align="center" style="line-height: 200%; margin-top: 0; margin-bottom: 0">
<input type="radio" value="1"<%if rs("max")=1 then %> checked <%end if%> name="R1">特级管理员　<input type="radio" value="0" <%if rs("max")=0 then %> checked <%end if%> name="R1">二级管理员</p>
<p align="center" style="line-height: 200%; margin-top: 0; margin-bottom: 0">
<input type="submit" value="确定修改" name="editchk"></p>
</form>
</td>
</tr>
</table>
<%
end sub
end if
end if
set rs=nothing
closedb%>
</center>
</div>
<%end if%>