admin_admin.asp

来自「是个不错的文件代码,希望大家好好用,」· ASP 代码 · 共 533 行 · 第 1/2 页

ASP
533
字号
<!--#include file="inc/inc_sys.asp"-->
<%
dim rs, rst,sql,roleId
dim Action,iCount,adminname,strPara
strPara=LCase(Request.QueryString)
Action=Trim(request("Action"))
adminname=session("adminname")
CheckSafePath(0)
Set rst=Server.CreateObject("Adodb.Recordset")
Set rst=oblog.Execute("Select roleid,r_name From oblog_roles Order By roleid")
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>oBlog--后台管理</title>
<link rel="stylesheet" href="images/style.css" type="text/css" />
<script src="images/menu.js" type="text/javascript"></script>
</head>
<body>
<script language=javascript>
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled!=true)
       e.checked = form.chkAll.checked;
    }
}

function CheckAdd()
{
  if(document.form1.username.value=="")
    {
      alert("用户名不能为空!");
	  document.form1.username.focus();
      return false;
    }

  if(document.form1.Password.value=="")
    {
      alert("密码不能为空!");
	  document.form1.Password.focus();
      return false;
    }

  if((document.form1.Password.value)!=(document.form1.PwdConfirm.value))
    {
      alert("初始密码与确认密码不同!");
	  document.form1.PwdConfirm.select();
	  document.form1.PwdConfirm.focus();	
      return false;
    }
  if (document.form1.Purview[1].checked==true){
	GetClassPurview();
  }
}
function CheckModifyPwd()
{
  if(document.form1.Password.value=="")
    {
      alert("密码不能为空!");
	  document.form1.Password.focus();
      return false;
    }
  if((document.form1.Password.value)!=(document.form1.PwdConfirm.value))
    {
      alert("初始密码与确认密码不同!");
	  document.form1.PwdConfirm.select();
	  document.form1.PwdConfirm.focus();	
      return false;
    }
}

</script>
<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left">管 理 员 管 理</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
  <tr class="topbg">
    <td height="22" colspan="2" align="center"><strong>管 理 员 管 理</strong></td>
  </tr>
  <tr class="tdbg">
    <td width="70" height="30"><strong>管理导航:</strong></td>
    <td height="30"><a href="admin_admin.asp">管理员管理首页</a>&nbsp;|&nbsp;<a href="admin_admin.asp?Action=Add">新增管理员</a></td>
  </tr>
</table>
		</div>
	</div>
	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
</div>
<%
Select Case Lcase(Action)
	Case "add"
		call AddAdmin()
	Case "saveadd"
		If CheckSafePath(0) Then call SaveAdd()
	Case "edit"
		Call EditAdmin()
	Case "saveedit"
		Call SaveEdit
	Case "del"
		If CheckSafePath(0) Then call DelAdmin()
	Case Else
		call main()
end Select


Sub main()
	if not IsObject(conn) then link_database
	Set rs=Server.CreateObject("Adodb.RecordSet")
	sql="select * from oblog_admin order by roleid"
	rs.Open sql,conn,1,1
	iCount=rs.recordcount
%>
<style>

tr td {
padding:5px 0!important;
}

</style>

<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left">管 理 员 管 理</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
  <form name="myform" method="Post" action="admin_admin.asp" onSubmit="return confirm('确定要删除选中的管理员吗?');">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
          <tr align="center" class="title">
            <td width="32"><font style="color:#000;font-weight:600;">选中</font></td>
            <td width="40"><font style="color:#000;font-weight:600;">序号</font></td>
            <td width="180"><font style="color:#000;font-weight:600;">权限角色</font></td>
            <td width="100"><font style="color:#000;font-weight:600;">用 户 名</font></td>
            <td width="80"><font style="color:#000;font-weight:600;">绑定博客</font></td>
            <td width="100"><font style="color:#000;font-weight:600;">最后登录IP</font></td>
            <td><font style="color:#000;font-weight:600;">最后登录时间</font></td>
            <td width="60"><font style="color:#000;font-weight:600;">登录次数</font></td>
            <td width="32"><font style="color:#000;font-weight:600;">修改</font></td>
          </tr>
          <%do while not rs.EOF %>
          <tr align="center" class="tdbg" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#BFDFFF'">
            <td><input name="ID" type="checkbox" id="ID" value="<%=rs("ID")%>" <%if rs("UserName")=AdminName then response.write " disabled"%> onClick="unselectall()"></td>
            <td><%=rs("ID")%></td>
            <td><%
            	If Not IsNull(rs("roleid")) Then
	            	rst.Filter="roleid=" & rs("roleid")
	            	If Not rst.Eof Then
	            		Response.Write rst("r_name")
	            	Else
	            		Response.Write "系统管理员"
	            	End If
	            Else
	            	Response.Write "系统管理员"
	            End If
            	%></td>
            <td>
              <%
				if rs("username")=AdminName then
					response.write "<font color=red><b>" & rs("UserName") & "</b></font>"
				else
					response.write rs("UserName")
				end if
				%>
            </td>
            <td>
              <%
				if rs("userid")<>""  then
					response.write "<a href=""../go.asp?userid=" & rs("userid") & """ target=_blank>" & rs("userid") & "</a>"
				else
					response.write "&nbsp;"
				end if
				%>
            </td>
            <td>
              <%
				if rs("LastLoginIP")<>"" then
					response.write rs("LastLoginIP")
				else
					response.write "&nbsp;"
				end if
				%>
            </td>
            <td>
              <%
				if rs("LastLoginTime")<>"" then
					response.write rs("LastLoginTime")
				else
					response.write "&nbsp;"
				end if
				%>
            </td>
            <td>
			<%
			    If Not IsNull(rs("LoginTimes")) Then
					If rs("LoginTimes")<>"" Then
						response.write rs("LoginTimes")
					Else
						response.write 0
						oblog.execute ("update [oblog_admin]  set LoginTimes=0 where id="&uid)
					End If
				Else
					oblog.execute ("update [oblog_admin]  set LoginTimes=0")
				End if
				%>
            </td>
            <td>
            	<%If rs("roleid")>0 Then%>
            		<a href="admin_admin.asp?action=edit&id=<%=rs("id")%>">修改</a>
            	<%Else%>
            <s>修改</s>
            		<%End If%>
            	</td>
          </tr>
          <%
	rs.MoveNext
loop
  %>
          <tr class="title">
            <td colspan="9"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
              选中本页显示的所有管理员<input name="Action" type="hidden" id="Action" value="Del">
              <input name="Submit" type="submit" id="Submit" value="删除选中的管理员"></td>
          </tr>
        </table>
</form>
		</div>
	</div>
	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
</div>
<%
	rs.Close
	set rs=Nothing
end sub

sub AddAdmin()
%>
<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left">新 增 管 理 员</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
<form method="post" action="admin_admin.asp" name="form1" onSubmit="javascript:return CheckAdd();">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border" >
    <tr class="tdbg">

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?