⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adminadmin.asp

📁 零度白茶影视系统好东西要大家分享
💻 ASP
字号:
<%@language=vbscript codepage=936 %>
<!--#include file="../inc/conn.asp"-->
<!--#include file="AdminChkPurview.asp"-->
<!--#include file="../inc/md5.asp"-->
<%
dim rs, sql, strPurview,iCount
dim Action
Action=Trim(request("Action"))
%>
<html>
<head>
<title>管理员管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../inc/Admin_Style.css" rel="stylesheet" type="text/css">
<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;
    }
}

function CheckModifyPurview()
{
  if (document.form1.Purview[1].checked==true){
	GetClassPurview();
  }
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr> 
    <td height="22" colspan="2" align="center" class="title"><strong>管 理 员 管 理</strong></td>
  </tr>
  <tr class="tdbg"> 
    <td width="70" height="30"><strong>管理导航:</strong></td>
    <td height="30"><a href="AdminAdmin.asp">管理员管理首页</a>&nbsp;|&nbsp;<a href="AdminAdmin.asp?Action=Add">新增管理员</a></td>
  </tr>
</table>
<%
if Action="Add" then
	call AddAdmin()
elseif Action="SaveAdd" then
	call SaveAdd()
elseif Action="ModifyPwd" then
	call ModifyPwd()
elseif Action="SaveModifyPwd" then
	call SaveModifyPwd()
elseif Action="Del" then
	call DelAdmin()
else
	call main()
end if


sub main()
	If Not IsObject(Conn) Then ConnectionDatabase 'shiyu
	Set rs=Server.CreateObject("Adodb.RecordSet")
	sql="select * from admin order by id"
	rs.Open sql,conn,1,1
	iCount=rs.recordcount
%>
<table width='100%' border="0" cellpadding="0" cellspacing="0">
  <tr>
  <form name="myform" method="Post" action="AdminAdmin.asp" onSubmit="return confirm('确定要删除选中的管理员吗?');">
   <td>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
  <tr align="center" class="title">
    <td  width="30"><strong>选中</strong></td>
    <td  width="30" height="22"><strong> 序号</strong></td>
    <td height="22"><strong> 用 户 名</strong></td>
    <td  width="100" height="22"><strong> 权 限</strong></td>
    <td width="100"><strong>最后登录IP</strong></td>
    <td width="120"><strong>最后登录时间</strong></td>
    <td  width="60"><strong>登录次数</strong></td>
    <td  width="150" height="22"><strong> 操 作</strong></td>
  </tr>
  <%do while not rs.EOF %>
  <tr align="center" class="tdbg" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#cccccc'" style="padding: 0px 2px;"> 
    <td width="30">
	  <input name="ID" type="checkbox" id="ID" value="<%=rs("ID")%>" <%if rs("UserName")=AdminName then response.write " disabled"%> onClick="unselectall()" style="border: 0px;background-color: #eeeeee;">
	</td>
    <td width="30"><%=rs("ID")%></td>
    <td>
	  <%
	    if rs("username")=AdminName then
		  response.write "<font color=#FF6600><b>" & rs("UserName") & "</b></font>"
	    else
		response.write rs("UserName")
	    end if
	   %>
	</td>
    <td width="100"> 
	  <%
		  select case rs("purview")
		    case 1
              strPurview="<font color=#0066CC>超级管理员</font>"
            case 2
              strpurview="普通管理员"
		  end select
		  response.write(strPurview)
       %>
    </td>
    <td width="100">
	  <%
	    if rs("LastLoginIP")<>"" then
		  response.write rs("LastLoginIP")
	    else
		response.write "&nbsp;"
  	    end if
	  %>
	</td>
    <td width="120">
	  <%
	    if rs("LastLoginTime")<>"" then
		  response.write rs("LastLoginTime")
   	    else
		response.write "&nbsp;"
	    end if
	  %> 
	</td>
    <td width="60">
	  <%
  	    if rs("LoginTimes")<>"" then
		  response.write rs("LoginTimes")
	    else
		response.write "0"
	    end if
	  %> 
	</td>
    <td width="150">
	  <%
  	    response.write "<a href='AdminAdmin.asp?Action=ModifyPwd&ID=" & rs("ID") & "'>修改密码</a>&nbsp;&nbsp;"
	    if iCount>1 and rs("UserName")<>AdminName then
		response.write "<a href='AdminAdmin.asp?Action=Del&ID=" & rs("ID") & "' onClick=""return confirm('确定要删除此管理员吗?');"">删除</a>"
	    else
		response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
	    end if
	  %> 
    </td>
  </tr>
  <%
	rs.MoveNext
loop
  %>
</table>  
<table cellpadding="0" cellspacing="1" border="0" width="100%" class="border" align=center>
	<tr valign="middle" class="tdbg">
      <td width="200">
	    <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox" style="border: 0px;background-color: #eeeeee;">
              选中本页显示的所有管理员</td>
      <td>
	    <input name="Action" type="hidden" id="Action" value="Del">
        <input name="Submit" type="submit" id="Submit" value="&nbsp;删除选中的管理员&nbsp;" style="cursor: hand;background-color: #cccccc;">
	  </td>
  </tr>
</table>
</td>
</form>
</tr>
</table>
<%

end sub

sub AddAdmin()
%>
<table cellpadding="0" cellspacing="1" border="0" width="100%" class="border" align=center>
<form method="post" action="AdminAdmin.asp" name="form1" onSubmit="javascript:return CheckAdd();">
	<tr>
	  <td colspan="3" align="center" class="title"><strong>新 增 管 理 员</strong></div></td>
    </tr>
    <tr class="tdbg"> 
      <td width="35%" class="tdbg"><strong> 用 户 名:</strong></td>
      <td width="65%" class="tdbg"><input name="username" type="text"> &nbsp;</td>
    </tr>
    <tr class="tdbg"> 
      <td width="35%" class="tdbg"><strong> 初始密码: </strong></td>
      <td width="65%" class="tdbg"><font size="2"> 
        <input type="password" name="Password">
      </font></td>
    </tr>
    <tr class="tdbg"> 
      <td width="35%" class="tdbg"><strong> 确认密码:</strong></td>
      <td width="65%" class="tdbg"><font size="2"> 
        <input type="password" name="PwdConfirm">
      </font></td>
    </tr>
    <tr class="tdbg"> 
      <td width="35%" class="tdbg"><strong>权限设置: </strong></td>
      <td width="65%" class="tdbg"><table width="100%" border="0" cellspacing="1" cellpadding="2">
        <tr>
          <td width="100"><input name="Purview" type="radio" value="1" checked style="border: 0px;background-color: #eeeeee;">
超级管理员</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td width="100"><input type="radio" name="Purview" value="2" style="border: 0px;background-color: #eeeeee;">
普通管理员</td>
          <td>&nbsp;</td>
        </tr>
      </table>
</td>
    </tr>
    <tr> 
      <td height="40" colspan="2" align="center" class="tdbg">
	    <input name="Action" type="hidden" id="Action" value="SaveAdd"> 
        <input  type="submit" name="Submit" value=" 添&nbsp;&nbsp;加 " style="cursor: hand;background-color: #cccccc;">&nbsp; 
		<input name="Cancel" type="button" id="Cancel" value=" 取&nbsp;&nbsp;消 " onClick="window.location.href='AdminAdmin.asp'" style="cursor: hand;background-color: #cccccc;"></td>
    </tr>
  </form>
</table>
<%
end sub
sub ModifyPwd()
	dim UserID
	UserID=trim(Request("ID"))
	if UserID="" then
		response.write "<br><li>请指定要修改的管理员ID</li>"
		exit sub
	else
		UserID=Clng(UserID)
	end if
	sql="Select * from Admin where ID=" & UserID
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,3
	if rs.Bof and rs.EOF then
		response.write "<br><li>不存在此用户!</li>"
	else
%>
<table cellpadding="0" cellspacing="1" border="0" width="100%" class="border" align=center>
<form method="post" action="AdminAdmin.asp" name="form1" onSubmit="javascript:return CheckModifyPwd();">
	<tr>
	  <td colspan="3" align="center" class="title"><strong>修 改 管 理 员 密 码</strong></font></div></td>
    </tr>
    <tr> 
      <td width="16%" class="tdbg"><strong>用 户 名:</strong></td>
      <td width="84%" class="tdbg"><%=rs("UserName")%> <input name="ID" type="hidden" value="<%=rs("ID")%>"></td>
    </tr>
    <tr> 
      <td width="16%" class="tdbg"><strong>新 密 码:</strong></td>
      <td width="84%" class="tdbg"><input type="password" name="Password"></td>
    </tr>
    <tr> 
      <td width="16%" class="tdbg"><strong>确认密码:</strong></td>
      <td width="84%" class="tdbg"><input type="password" name="PwdConfirm"></td>
    </tr>
    <tr> 
      <td colspan="2" align="center" class="tdbg">
	    <input name="Action" type="hidden" id="Action" value="SaveModifyPwd"> 
        <input  type="submit" name="Submit" value="&nbsp;保存修改结果&nbsp;" style="cursor: hand;background-color: #cccccc;">&nbsp;
        <input name="Cancel" type="button" id="Cancel" value=" 取&nbsp;&nbsp;消 " onClick="window.location.href='AdminAdmin.asp'" style="cursor: hand;background-color: #cccccc;">
	  </td>
    </tr>
</form>
</table>
<%
	end if
	rs.close
	set rs=nothing
end sub
sub SaveAdd()
	dim username, password,PwdConfirm, purview
	username=trim(Request("username"))
	password=trim(Request("Password"))
	PwdConfirm=trim(request("PwdConfirm"))
	purview=trim(Request("purview"))
	if username="" then
		response.write "<br><li>用户名不能为空!</li>"
	end if
	if password="" then
		response.write "<br><li>初始密码不能为空!</li>"
	end if
	if PwdConfirm<>Password then
		response.write "<br><li>确认密码必须与初始密码相同!</li>"
	end if
	if purview="" then
		response.write "<br><li>用户权限不能为空!</li>"
	else
		purview=CInt(purview)
	end if
	sql="Select * from Admin where username='"&username&"'"
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,3
	if not (rs.bof and rs.EOF) then
		response.write "<br><li>数据库中已经存在此管理员!</li>"
		rs.close
		set rs=nothing
		exit sub
	end if
   	rs.addnew
 	rs("username")=username
   	rs("password")=md5(password)
    rs("purview")=purview
	rs.update
    rs.Close
	set rs=Nothing
	Call main()
end sub

sub SaveModifyPwd()
	dim UserID, UserName,password,PwdConfirm
	UserID=trim(Request("ID"))
	password=trim(Request("Password"))
	PwdConfirm=trim(request("PwdConfirm"))
	if UserID="" then
		response.write "<br><li>请指定要修改的管理员ID</li>"
	else
		UserID=Clng(UserID)
	end if
	if password="" then
		response.write "<br><li>新密码不能为空!</li>"
	end if
	if PwdConfirm<>Password then
		response.write "<br><li>确认密码必须与新密码相同!</li>"
	end if
	
	sql="Select * from Admin where ID=" & UserID
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,3
	if rs.Bof and rs.EOF then
		response.write "<br><li>不存在此管理员!</li>"
		rs.close
		set rs=nothing
		exit sub
	end if
	rs("password")=md5(password)
 	rs.update
	rs.Close
   	set rs=Nothing
    call main()
end sub

sub DelAdmin()
	dim UserID
	UserID=trim(Request("ID"))
	if UserID="" then
		response.write "<br><li>请指定要删除的管理员ID</li>"
		exit sub
	end if
	if instr(UserID,",")>0 then
		UserID=replace(UserID," ","")
		sql="Select * from Admin where ID in (" & UserID & ")"
	else
		UserID=clng(UserID)
		sql="select * from Admin where ID=" & UserID
	end if
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,3
	do while not rs.eof
		rs.delete
		rs.update
		rs.movenext
	loop
	rs.close
	set rs=nothing
	call main()
end sub

%>
 <!--#include file="AdminFooder.asp"-->
</body>
</html>

⌨️ 快捷键说明

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