|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
<!--#include file="check.asp"-->
<!-- #include file="../inc/conn.asp" -->
<!-- #include file="../inc/md5.asp" -->
<!--#include file="../inc/asppage.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>admin</title>
<link href="css.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function del(id)
{
var ok;
ok=confirm("删除后不可恢复!您确定要删除此管理员吗?");
if (ok==true)
{
window.location="admin.asp?action=del&id="+id;
}
else
{}
}
</script>
</head>
<body topmargin="10" background="images/bg1024.gif">
<%
checkAdmin
action=RequestSafeStr("action")
Select Case action
Case "add"
Call add()
Case "save"
Call save()
Case "edit"
Call edit()
Case "editsave"
Call editSave()
Case "del"
Call del()
Case "stop"
Call stops()
Case else
Call show()
End Select
%>
<%
Sub save()
user=RequestFormStr("user")
role=RequestFormNum("role")
password=RequestFormStr("password")
If user="" Then
Call MessageBox("请输入用户名!","")
Response.End
End If
If password="" Then
Call MessageBox("请输入密码!","")
Response.End
End If
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from [admin]"
rs.open sql,conn,1,3
rs.addnew
rs("user")=user
rs("role")=role
rs("password")=md5(password)
rs.update
rs.close
Call MessageBox("添加管理员成功!","admin.asp")
End Sub
Sub editSave()
intId=RequestFormNum("id")
If intId<>0 then
strUser=RequestFormStr("user")
intRole=RequestFormNum("role")
strPasswordOld=RequestFormStr("passwordOld")
StrPasswordNew=RequestFormStr("passwordNew")
If strUser="" Then
Call MessageBox("请输入用户名!","")
Response.End
End If
If strPasswordNew="" Then
strPassword=strPasswordOld
Else
strPassword=md5(strPasswordNew)
End If
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from [admin] Where id="& intId &""
rs.open sql,conn,2,3
If Not rs.eof then
rs("user")=strUser
rs("role")=intRole
rs("password")=strPassword
rs.update
End If
rs.close
Call MessageBox("修改成功!","admin.asp")
End If
End Sub
'del
Sub del()
intId=RequestQueryNum("id")
If id<>0 Then
conn.Execute("delete From [admin] Where id="& intId &"")
Call MessageBox("删除成功!","admin.asp")
End If
End Sub
'stop
Sub stops()
id=RequestQueryNum("id")
intisOk=RequestQueryNum("isOk")
If id<>0 Then
Set rs=conn.Execute("Select user From admin Where id="& id &"")
If Not rs.eof Then
If rs("user")<>session("user") then
conn.Execute("Update admin set [isOk]="& intisOk &",isOktime=Now() Where id="& id &"")
If intisOk=1 Then
strMsg="停用成功!"
Else
strMsg="启用成功!"
End If
Call MessageBox(strMsg,"admin.asp")
Else
Call MessageBox("不能停用自己的帐号!","")
Response.End
End If
End If
End If
End Sub
Sub show()
cid=RequestQueryNum("cid")
If cid<>0 Then
sql="Select * From [admin] Where categoryid="& cid &" order by isOk desc,id desc"
Else
sql="Select * From [admin] order by id desc"
End If
Set mypage=new xdownpage '创建对象
mypage.getconn=conn '得到数据库连接
mypage.getsql=sql
mypage.pagesize=20 '设置每一页的记录条数据为5条
set rs=mypage.getrs() '返回Recordset
%>
<table width="98%" align=center cellpadding="2" cellspacing="1">
<tr><td>
<a href="admin.asp?action=add"><strong>添加管理员</strong></a>
</td></tr></table>
<table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<th height="25" colspan="6">管理员管理</th>
</tr>
<tr>
<td class=Forumrow width="30">编号</td>
<td class=Forumrow>管理员</td>
<td class=Forumrow>状态</td>
<td class=Forumrow>权力组</td>
<td class=Forumrow width="150">添加日期</td>
<td class=Forumrow align="center" width="150">操作</td>
</tr>
<%
for i=1 to mypage.pagesize
If rs.eof Then
Exit for
End If
role=rs("role")
If role=1 Then
strRole="系统管理员"
ElseIf role=2 Then
strRole="网站管理员"
Else
strRole="编辑员"
End If
If rs("isOk") = 1 Then
strStat="<span class=red>停用</span>"
Else
strStat="正常"
End If
%>
<tr>
<td class=Forumrow><%=rs("id")%></td>
<td class=Forumrow><%=rs("user")%></td>
<td class=Forumrow><%=strStat%></td>
<td class=Forumrow><%=strRole%></td>
<td class=Forumrow ><%=rs("posttime")%></td>
<td class=Forumrow align="center" >
<%If rs("isOk")=0 then%>
<a href="?action=stop&id=<%=rs("id")%>&isOk=1">停用</a>
<%else%>
<a href="?action=stop&id=<%=rs("id")%>&isOk=0" class="red">取消停用</a>
<%End If%>
<a href="?action=edit&id=<%=rs("id")%>">修改</a>
<a href="javascript:del(<%=rs("id")%>)">删除</a></td>
</tr>
<%
rs.MoveNext
Next
%>
<tr align="center" ><td colspan="6" class=Forumrow><%mypage.showpage() %></td></tr>
</table>
<%
End Sub
Sub add()
%>
<table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
<form name="add" method="post" action="admin.asp">
<input type="hidden" name="action" value="save">
<tr>
<th height="25" colspan="2">添加管理员</th>
</tr>
<tr>
<td width="15%" height="25" align="right" class=Forumrow>管理员名称:</td>
<td align="left" class=Forumrow>
<input name="user" type="text" value="" size="25" maxlength="20" style="width:200"> <span class="red">*</span></td>
</tr>
<tr>
<td width="15%" height="25" align="right" class=Forumrow>密码:</td>
<td align="left" class=Forumrow>
<input name="password" type="password" value="" size="25" maxlength="20" style="width:200"> <span class="red">*</span></td>
</tr>
<tr>
<td width="15%" height="25" align="right" class=Forumrow>权力组:</td>
<td align="left" class=Forumrow>
<select name="role">
<option value="3">编辑员</option>
<option value="1">系统管理员</option>
</select>
</td>
</tr>
<tr>
<td class=Forumrow></td>
<td height="30" class=Forumrow>
<input type="submit" name="Submit" value="添 加" class="input1">
<input type="reset" name="Submit" class="input1"></td>
</tr>
</form>
</table>
<%
End Sub
Sub edit()
id=RequestQueryNum("id")
Set rs=conn.Execute("Select * From admin Where id="& id &"")
If Not rs.eof Then
intRole=rs("role")
%>
<table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
<form name="add" method="post" action="admin.asp">
<input type="hidden" name="action" value="editsave">
<input type="hidden" name="id" value="<%=id%>">
<tr>
<th height="25" colspan="2">修改管理员</th>
</tr>
<tr>
<td width="15%" height="25" align="right" class=Forumrow>管理员名称:</td>
<td align="left" class=Forumrow>
<input name="user" type="text" value="<%=rs("user")%>" size="25" maxlength="20" style="width:200"> <span class="red">*</span></td>
</tr>
<tr>
<td width="15%" height="25" align="right" class=Forumrow>密码:</td>
<td align="left" class=Forumrow> <input name="passwordOld" type="hidden" value="<%=rs("password")%>" >
<input name="passwordNew" type="password" value="" size="25" maxlength="20" style="width:200"> <span class="red">*</span></td>
</tr>
<tr>
<td width="15%" height="25" align="right" class=Forumrow>权力组:</td>
<td align="left" class=Forumrow>
<select name="role">
<option value="3" <%Call setSelected(3,intRole) %>>编辑</option>
<option value="1" <%Call setSelected(1,intRole) %>>系统管理员</option>
</select>
</td>
</tr>
<tr>
<td class=Forumrow></td>
<td height="30" class=Forumrow>
<input type="submit" name="Submit" value="修改" class="input1">
<input type="reset" name="Submit" class="input1"></td>
</tr>
</form>
</table>
<%
End If
End Sub
%>
</body>
</html>
这页其他功能都完好的,多少删除管理的功能不行,删除不了数据库里的帐号,各位大大有空帮忙看下是什么情况,那错了呀。谢谢哦 |
|