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

📄 sysuser.asp

📁 简单明晰的asp后台代码 新闻 产品
💻 ASP
字号:
<!--#include file = "../inc/dbclass.inc.asp"-->
<!--#include file = "../inc/syslogincheck.inc.asp" -->
<!--#include file="../inc/md5.asp" -->

<%
' =============================================================
' made by xiasp & 智多网络 http://www.cq18.com/ qq群:12403617
' =============================================================
%>

<%
dim action, operate, h_level, duserid
action = getsafestr(trim(request("action")))
operate = getsafestr(trim(request("operate")))
h_level = session("sys_level")

if action = "del" then	'删除管理用户
	if h_level <> 3 then
		call alertmsg("您的权限不够进行此操作!")
	else
		duserid = trim(request.querystring("d_userid"))
		oconn.execute("delete from admin where a_userid='"&duserid&"'")
	end if
end if

if action = "modify" then	'读取已有用户的资料,这里主要是作为修改密码之用。
	dim ars, asql, muserid, mlevel ,moduserid
	moduserid = trim(request.querystring("m_userid"))
	set ars = server.createobject( "adodb.recordset" )
	asql = "select * from  admin where a_userid ='"&moduserid&"'"
	ars.open asql,oconn,1,1
		if ars.recordcount = 1 then
			muserid = ars("a_userid")
			mlevel = ars("a_level")
			operate = "modify"
		else
			operate = "addnew"
		end if
	ars.close
	set ars = nothing
end if

if action = "ok" then
	if h_level <> 3 then
		call alertmsg("您的权限不够进行此操作!")
	else
		call operateuser()
	end if
end if

sub operateuser()
	dim auserid, apasswd, arepasswd, alevel
	auserid = getsafestr(trim(request.form("muserid")))
	apasswd = getsafestr(trim(request.form("mpasswd")))
	arepasswd = getsafestr(trim(request.form("mrepasswd")))
	alevel = getsafeint(trim(request.form("mlevel")),0)
	 
	if auserid <> "" and apasswd <> "" and arepasswd <>"" and alevel > 0 then 
		if apasswd = arepasswd then
			ssql="select * from  admin where a_userid ='"&auserid&"'"
			ors.open ssql,oconn,1,3
			if not ors.eof then
				if operate ="modify" then 	'修改管理用户
					ors("a_pwd") = md5(apasswd)
					ors("a_level") = alevel
					ors.update
					call alertmsg("用户修改成功!")
				else
					call alertmsg("该用户已经存在,请重新建立用户!!")
				end if
			else	'添加管理用户
				ors.addnew
				ors("a_userid") = auserid
				ors("a_pwd") = md5(apasswd)
				ors("a_level") = alevel
				ors("a_addtime") = now()
				ors.update
				call alertmsg("添加用户成功!")
			end if
			ors.close
			set ors = nothing
		else
			call alertmsg("您两次输入的密码不一致!")
		end if
	else
		call alertmsg("请正确输入新用户名和密码!")
	end if
end sub
  
call header("系统用户管理")
call content()
call footer()

' 开始写入内容
sub content()
%>

<!--#include file="admin_index_top.asp" -->
<br>

<script language="javascript">
<!--
function checkdel(username){
	if (confirm("您确定要删除 "+username+" 这个超级用户吗?")){
		window.open("sysuser.asp?action=del&d_userid="+username,"_blank");
	}
	else{
		//do nothing;
	}
}

function checkmod(username){
	window.open("sysuser.asp?action=modify&m_userid="+username,"_blank");
}

function isvalid()
{
	if (document.addsysuser.muserid.value=="")
	{
		alert("请输入新用户名!");
		document.addsysuser.muserid.focus();
		return false;
	}
	if (document.addsysuser.mpasswd.value=="")
	{
		alert("请输入新用户的密码");
		document.addsysuser.mpasswd.focus();
		return false;
	}
	
	if (document.addsysuser.mrepasswd.value=="")
	{
		alert("请再次输入新用户的密码");
		document.addsysuser.mrepasswd.focus();
		return false;
	}
	
	if (document.addsysuser.mrepasswd.value != document.addsysuser.mpasswd.value)
	{
		alert("两次输入的密码不一致!");
		document.addsysuser.mrepasswd.focus();
		return false;
	}
	return true;
}
-->
</script>
<table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="25"><b>
    <% = homepage_title%> - <font color="#ff0000">系统用户管理</font></b></td>
  </tr>
  <tr>
    <td><table width="82%" border="0" cellspacing="0" cellpadding="0">
      <tr valign="top">
        <td>
          <table width="100%" cellspacing="0" cellpadding="0" height="100%" border="0">
            <tr>
              <td height="351" valign="top"><form name="addsysuser" method="post" action="sysuser.asp?action=ok" onsubmit="return isvalid();">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                      <tr>
                        <td width="100" height="30"><b>添加超级用户</b></td>
                        <td>用&nbsp;户&nbsp;名:
                            <input name="muserid" type="text" class="button1" value="<%=muserid%>" size=25 maxlength="30">
                        </td>
                      </tr>
                      <tr>
                        <td height="30">&nbsp;</td>
                        <td>用户级别:
                          <select name="mlevel" id="mlevel">
                            <option value="1" <%if mlevel =1 then response.write "selected"%>>信息编辑员</option>
                            <option value="2" <%if mlevel =2 then response.write "selected"%>>信息审核员</option>
                            <option value="3" <%if mlevel =3 then response.write "selected"%>>系统管理员</option>
                          </select></td>
                      </tr>
                      <tr>
                        <td height="30">&nbsp; </td>
                        <td>密&nbsp;&nbsp;&nbsp;&nbsp;码:
                          <input name="mpasswd" type="password" class="button1" size=25 maxlength="30">
						</td>
                      </tr>
                      <tr>
                        <td height="30">&nbsp; </td>
                        <td>确认密码:
                            <input name="mrepasswd" type="password" class="button1" size=25 maxlength="30">
                        </td>
                      </tr>
                      <tr>
                        <td height="30">&nbsp; </td>
                        <td>
                          <input type="hidden" name="operate" value="<%=operate%>">
                          <input type="submit" name="submit2" value=" 提 交 " class="button2">
                          <input type="reset" name="submit22" value=" 重 写 " class="button2">
                        </td>
                      </tr>
                    </table>
                  </form>
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                    <tr>
                      <td width="100" valign="top"><b>超级用户管理</b></td>
                      <td valign="top">
						<%
						dim num, alevel, alevelname, ars, asql
						set ars = server.createobject( "adodb.recordset" )
						asql="select * from admin order by a_id desc" 
						ars.open asql,oconn,1,1
						num = ars.recordcount
						%>
                        <table border="0" width="100%" cellpadding="0" align="center" cellspacing="0">
                          <tr>
                            <td colspan="5">
                              <div align="left">共有<font color="#ff0033"><%=num%></font>位超级用户</div></td>
                          </tr>
						<%
							do while not ars.eof
								alevel = ars("a_level")
								if alevel = 3 then alevelname = "系统管理员"
								if alevel = 2 then alevelname = "信息审核员"
								if alevel = 1 then alevelname = "信息编辑员"
							
						%>
                          <tr>
                            <td width="45"><input onclick = checkdel("<%=trim(ars("a_userid"))%>") type=button class="button2" value="删除" name="button"></td>
                            <td align="left" colspan="4" height=24>
                              <input type="text" size=15 name="viewsysuser" value="<%=trim(ars("a_userid"))%>" readonly class="button1">
                              <input name="button2" type=button class="button2" id="button2" onclick = checkmod("<%=trim(ars("a_userid"))%>") value="修改">                              &nbsp;<%=alevelname%></td>
                          </tr>
						<%
							ars.movenext
							loop
							ars.close
							set ars = nothing
						%>
                      </table></td>
                    </tr>
                </table>
                <br>
                </td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<%
end sub
%>
                                                                                              
                                                                                                    

⌨️ 快捷键说明

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