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

📄 usermanage.asp

📁 一个网络相册
💻 ASP
字号:
<% option explicit %>
<!--#include file="../function1/DBOpen.asp"-->
<!--#include file="../function/md5.asp"-->
<%
  if session("purview")<>"99999" then
      response.write "错误!!您没有权限或者连接超时,请重新登陆." %>
<a href="../login.asp?id=0" target="_top">登陆</a> 
<% response.end 
end if  
dim isedit '是否在编辑状态
dim color  '表格颜色
dim userid,curpage,i,purview
dim sql,rs,rsc
userid=request("userid")
color=1
isedit=false
if request("action")="edit" then
    isedit=true
end if
if request("action")="modify" then   '*****************修改用户*****************
    if trim(request("userpassword"))="" then
	    response.write "错误!密码不能为空! <a href=usermanage.asp>返回</a>"
        response.end
    end if
	sql="update users set name='" & cstr(trim(request("username"))) & "',pwd='" & md5(cstr(trim(request("userpassword")))) & "',purview='" & cstr(request("purview")) & "' where userid=" & cstr(request("userid"))
	conn.execute sql
	if err.number <> 0 then
	    response.write "数据库操作出错:" + err.description
	else %>
<script language=vbscript>
			msgbox "操作成功!用户 <%=trim(request("username"))%> 的信息已经更新!"
		</script>
<%end if
end if
if request("action")="add" then   '*******************添加新用户****************
    if trim(request("username"))="" or trim(request("userpassword"))="" then
	    response.write "错误!用户名或密码不能为空! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
        response.end
    end if
	set rs=server.createobject("adodb.recordset")   '检查用户是否重名
    rs.open "select * from users where name='" & cstr(trim(request("username"))) & "'",conn,1,1
    if err.number <> 0 then
	          response.write "数据库出错"
    else  if not rs.bof and not rs.eof then
	          response.write "错误!该用户名已存在! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
              response.end
          end if
    end if
	rs.close
	set rs=nothing
	sql="insert into users(name,pwd,purview,lock) values('" & cstr(trim(request("username"))) & "','" & md5(cstr(trim(request("userpassword")))) & "',11111,1)"
	conn.execute sql
	if err.number <> 0 then
	    response.write "数据库操作出错:" + err.description
	else %>
<script language=vbscript>
			msgbox "操作成功!新用户 <%=trim(request("username"))%> 的信息添加成功!"
		</script>
<%end if
end if
if request("action")="del" then   '*******************删除用户******************
	sql="delete from users where userid=" + cstr(userid)
	conn.execute sql
	if err.number <> 0 then
		response.write "数据库操作错误:" + err.description
		err.clear
	else %>
<script language=vbscript>
		msgbox "操作成功!用户 <%=trim(request("username"))%> 的信息已删除!"
		</script>
<%  end if
end if
if request("action")="lock" then   '*******************锁定用户******************
	sql="update users set lock=2 where userid=" & cstr(request("userid"))
	conn.execute sql
	if err.number <> 0 then
	    response.write "数据库操作出错:" + err.description
	else %>
<script language=vbscript>
			msgbox "操作成功!用户 <%=trim(request("username"))%> 已锁定!"
		</script>
<%  end if
end if
if request("action")="unlock" then   '*******************用户解锁******************
	sql="update users set lock=1 where userid=" & cstr(request("userid"))
	conn.execute sql
	if err.number <> 0 then
	    response.write "数据库操作出错:" + err.description
	else %>
<script language=vbscript>
			msgbox "操作成功!用户 <%=trim(request("username"))%> 已解锁!"
		</script>
<%  end if
end if
%>
<html>
<head> 
<title>用户管理</title>
<script language=javascript>
function SureDel(id)
{
    if ( confirm("您确定要删除该用户吗?"))
        {
            window.location.href = "usermanage.asp?action=del&userid=" + id
        }
}
function lock(id)
{
    if ( confirm("您确定要锁定该用户吗?"))
        {
            window.location.href = "usermanage.asp?action=lock&userid=" + id
        }
}
function unlock(id)
{
            window.location.href = "usermanage.asp?action=unlock&userid=" + id
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE>
TABLE {FONT-SIZE: 12px;COLOR: #000000; FONT-FAMILY: 宋体;LINE-HEIGHT: 180%}
.Shadow_white {FONT-SIZE: 14pt; FILTER: dropshadow(color:black, offx=1, offy=1, positive=1); WIDTH: 70%; COLOR: #000000; FONT-FAMILY: 宋体; POSITION: relative}
.Shadow_white2 {FONT-SIZE: 10pt; FILTER: dropshadow(color:black, offx=1, offy=1, positive=1); WIDTH: 70%; COLOR: #000000; FONT-FAMILY: 宋体; POSITION: relative}
A:link {COLOR: #000000; TEXT-DECORATION: none}
A:active {COLOR: #000000; TEXT-DECORATION: none}
A:visited {COLOR: #000000; TEXT-DECORATION: none}
A:hover {COLOR: #ff0000; TEXT-DECORATION: underline}
.style2 {color: #FFFFFF}
</STYLE></head>
<body> 
<table border="0" width="95%" bgcolor="#000000" cellpadding="0" cellspacing="1" align="center">
  <tr bgcolor="#0033FF"> 
    <td height="27" colspan="9"> 
      <div align="center"></div>
      <div align="center"></div>
      <div align="center" class="style2">用户管理</div>
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td width="16%"> 
      <div align="center">用户ID</div>
    </td>
    <td width="16%" align="center">名字</td>
    <td width="16%" align="center">权限</td>
    <td width="6%" bgcolor="#FFFFFF"><div align="center">状态</div></td>
    <td width="16%"> 
      <div align="center">操作</div>
    </td>
  </tr>
  <%
  set rs=server.createobject("adodb.recordset")
  rs.open "select * from users where userid<>1",conn,1,1
     if not rs.eof and not rs.bof then
              if request("page")="" then
  	               curpage = 1
               else
	               curpage = cint(request("page"))
               end if
               rs.pagesize=10
               rs.absolutepage = curpage
               for i = 1 to rs.pagesize
                   %>			   
  <tr bgcolor="#FFFFFF"> 
    <td width="16%" height="21"> 
      <div align="center"><a href='userinfo.asp?user=<%=cstr(rs("name"))%>' title='查看用户详细信息' target=_blank><%=rs("name")%></a></div>
    </td>
    <td width="16%" align="center"><a href='userinfo.asp?user=<%=cstr(rs("name"))%>' title='查看用户详细信息' target=_blank><%=rs("turename")%></a></td>
    <td width="16%" align="center"><a href='userinfo.asp?user=<%=cstr(rs("name"))%>' title='查看用户详细信息' target=_blank>
	      <% if rs("purview")="11111" then
							        response.write "普通用户"
								else if rs("purview")="99999" then
								         response.write "超级用户"
                                     end if
								end if %>
</a></td>
    <td width="6%"><div align="center">
      <% if rs("lock")="1" then
							        response.write "<b>正常</b>"
								else if rs("lock")="2" then
								         response.write "<b>锁定</b>"
                                     end if
								end if %>
    </div></td>
    <td width="16%" height="21"> 
      <div align="center"> 
        <% if trim(rs("name"))=trim(session("name")) then 
	                             response.write "----"
							 else
							     response.write "<a href='usermanage.asp?userid=" & cstr(rs("userid")) & "&action=edit'>编辑</a>&nbsp;&nbsp;"
							     response.write "<a href='javascript:SureDel(" & cstr(rs("userid")) & ")'>删除</a>&nbsp;&nbsp;"
                                 if rs("lock")="1" then
							                response.write "<a href='javascript:lock(" & cstr(rs("userid")) & ")'>锁定"
								        else if rs("lock")="2" then
								            response.write "<a href='javascript:unlock(" & cstr(rs("userid")) & ")'>解锁"
                                             end if
								 end if 
							 end if %>
      </div>
    </td>
  </tr>
  <% rs.movenext
      if rs.eof then
	      i = i + 1
	      exit for
      end if
               next 
	end if
			   %>
  <tr bgcolor="#FFFFFF">
    <td height="27" colspan="9" ><div align="center">
      <% 
		response.write "<div align=center>"
		response.write "第<font color=red>" + cstr(curpage) + "</font>页/总<font color=red>" + cstr(rs.pagecount) + "</font>页 "
		response.write "本页<font color=red>" + cstr(i-1) + "</font>条/总<font color=red>" + cstr(rs.recordcount) + "</font>条 "
		if curpage = 1 then 
			response.write "首页 前页 "
		else
			response.write "<a href='usermanage.asp?page=1'>首页</a> <a href='usermanage.asp?page=" & cstr(curpage-1) & "'>前页</a> "
		end if
		if  curpage = rs.pagecount then
			response.write "后页 末页"
		else
			response.write "<a href='usermanage.asp?page=" + cstr(curpage+1) + "'>后页</a> <a href='usermanage.asp?page=" + cstr(rs.pagecount) + "'>末页</a>"
		end if
'rs.close
set rs=nothing
 %>
    </div></td>
  </tr>
</table>
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#abb8d6" style="border: 1px solid #000000">
  <tr> 
    <td height="40"> 
      <div align="center"> 
        <% if isedit then
	       set rs=server.createobject("adodb.recordset")
		   rs.open "select * from users where userid=" & cstr(request("userid")),conn,1,1
	       response.write "编 辑 用 户<br>"
	   else
	       response.write "添 加 新 用 户<br>"
	   end if %>
      </div>
    </td>
  </tr>
  <tr> 
    <td> 
      <form action="usermanage.asp" method="post">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
          <tr> 
            <td height="40"> 
              <div align="center"> 
                <input type="Hidden" name="action" value='<% If isedit then%>modify<% Else  %>add<% End If %>'>
                <%If isedit then%>
                <input type="Hidden" name="userid" value='<%=cstr(request("userid"))%>'>
                <%End If%>
                用户账号: 
                <input type="text" name="username" class=input maxlength=14 size="16" value='<% if isedit then
		                                                         response.write trim(rs("name"))
															 end if %>'
															  <% if isedit then
															        response.write " readonly"
																 end if %>>
                用户密码: 
                <input type="password" name="userpassword"  class=input maxlength=12 size="16" value=''>
               用户权限:  
               <select name="purview" id="purview">
			   <%
               Response.Write"<option value='99999'"
               if isedit then
			   purview=rs("purview")
                   if purview="99999" then Response.Write" selected" 
               end if
               Response.Write">超极管理员</option>"
               Response.Write"<option value='11111'"
               if isedit then
                   if purview="11111" then Response.Write" selected" 
               end if
               Response.Write">普通用户</option>"
               %>
                </select>
              </div>
            </td>
          </tr>
          <tr>
            <td height="40"><div align="center">
      <input type=submit value="确 定" class=button name="submit">
   
    <input type="reset" name="Submit" value="重 设">
            </div></td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
</table>
<p align="center">&nbsp; </p>
<p>&nbsp;</p>
</body>
</html>
<!--#include file="../function/DBclose.asp"-->

⌨️ 快捷键说明

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