📄 user.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#Include file = "BBSConfig.asp"-->
<!--#include file="Session.asp"-->
<!--#include file="md5.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户组管理</title>
<link href="Style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_callJS(jsStr) { //V2.3
return eval(jsStr)
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0">
<%
Sub errorMsg(theError)
response.write"<script language=javascript>alert('"& theError &"');history.back();</script>"
response.End
End Sub
'---------------------------------------
action = trim(request.QueryString("action"))
SELECT CASE action
Case "add"
Call add()
Case "SaveNew"
Call SaveNew()
Case "Edit"
Call Edit()
Case "SaveEdit"
Call SaveEdit()
Case "Del"
Call Del()
Case "show"
Call show()
Case "private"
Call pm()
Case else
Call search()
End SELECT
'=============================
Sub Del()
userid = trim(request.QueryString("userid"))
if Not(IsNumeric(userid)) then ErrorMsg "参数错误!~"
if trim(request.Form("Submit")) = "确定删除" then
set rs = server.CreateObject("adodb.recordset")
rs.open "select username,usergroup from JBB_user where userID="&userid,conn,1,3
if not rs.eof then
if rs(1) = 1 then
Conn.ExeCute("delete From JBB_admin where adminname='"& rtrim(rs(0)) &"'")
elseif rs(1) = 2 or rs(1) = 3 then
Conn.ExeCute("delete From JBB_Mod where Mod_nameID="& userid)
End if
rs.delete
End if
rs.close
set rs = Nothing
conn.execute("update JBB_thread set postuserid=0,postusername='游客' where postuserid="&userid)
conn.execute("update JBB_post set user_id=0,user_name='游客' where user_id="&userid)
response.Write("<br><br> 删除完毕!~")
Application.Lock
Application(JBBMasterCookies&"Home_userInfo") = ""
Application.UnLock
else
%>
<br>
<table width="450" height="47" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<form name="form2" method="post" action="?action=Del&userid=<%=userid%>">
<tr>
<td bgcolor="#EFEFE7">
<div align="center"><strong>确认删除</strong></div></td>
</tr>
<tr>
<td height="50" bgcolor="#FFFFFF">
<div align="center"><font color="#FF0000">您确定删除此用户吗?删除后该用户所发的帖子都将作为是游客发的</font></div></td>
</tr>
<tr>
<td bgcolor="#EFEFE7">
<div align="center">
<input name="Submit" type="submit" class="form1" id="Submit" value="确定删除">
<input name="Submit6" type="button" class="form1" onClick="MM_callJS('history.back()')" value="返回">
</div></td>
</tr>
</form>
</table>
<br>
如果你想先删除该会员所发的信息, 请点 <a href="thread.asp?action=Del&userid=<%=userid%>">这里</a>.<br>
<br>
<%
End if
End Sub
'==========================
Sub search()
%>
<br>
<form name="form1" method="get" action="">
<table width="368" height="49" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td><a href="?action=show">[列出所有用户]</a></td>
</tr>
</table>
<table width="368" height="49" border="0" align="center" cellpadding="8" cellspacing="1" bgcolor="#CCCCCC">
<tr bgcolor="#EFEFE7">
<td colspan="2"><strong>查找用户</strong><font color="#000000"><strong>
<input name="action" type="hidden" id="action" value="show">
</strong></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="96">在用户组:</td>
<td width="237">
<select name="groupID" id="groupID">
<option value="1">管理员</option>
<option value="2">超级版主</option>
<option value="3">版主</option>
<option value="4">贵宾</option>
<option value="5" selected>普通会员</option>
<option value="0">所有用户组</option>
</select></td>
</tr>
<tr bgcolor="#FFFFFF">
<td>按用户名:<br>
(为空查找全部)</td>
<td>
<input name="username" type="text" id="username">
</td>
</tr>
</table>
<br><center>
<input type="submit" class="form1" value="开始查找">
<input name="Submit3" type="reset" class="form1" value="重置">
</center>
<br> </form>
<%
End Sub
'===================================
Sub show()
groupid = replace(Trim(Request.QueryString("groupid")),"'","")
username = replace(Trim(Request.QueryString("username")),"'","")
set rs = server.CreateObject("adodb.recordset")
if Isnumeric(groupid) and groupid <> "0" and username = "" then
sql = "select userid,username,regtime,usergroup,threadcount,replycount,regip from JBB_User where usergroup ="&groupid &" order By userid desc"
elseif groupid = "0" and username <> "" then
sql = "select userid,username,regtime,usergroup,threadcount,replycount,regip from JBB_User where username like '%"& username &"%' order By userid desc"
elseif Isnumeric(groupid) and username <> "" then
sql = "select userid,username,regtime,usergroup,threadcount,replycount,regip from JBB_User where username like '%"& username &"%' and usergroup ="&groupid &" order By userid desc"
else
sql = "select userid,username,regtime,usergroup,threadcount,replycount,regip from JBB_User order By userid desc"
end if
rs.open sql,conn,1,1
if rs.eof Or rs.Bof then
rs.close
set rs = Nothing
ErrorMsg "暂时没有符合条件的用户"
else
page = trim(request.QueryString("page"))
if Not(IsNumeric(page)) or page = "0" then page = 1
rs.pageSize = 20
pageCount = rs.pageCount
if len(page) > 4 then page = pageCount
if Cint(page) > Cint(pageCount) then page = pageCount
rs.absolutepage = page
%>
<br>
<table border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
<tr bgcolor="#EFEFE7">
<td><font color="#000000"><strong>用户名</strong></font></td>
<td><font color="#000000"> 操作</font></td>
<td><font color="#000000"> <strong>注册日期</strong></font></td>
<td><strong><font color="#000000">注册IP</font></strong></td>
<td><font color="#000000"><strong>发帖数量</strong></font></td>
</tr>
<%
for i = 1 to rs.pagesize
if rs.eof then exit for
%>
<tr bgcolor="#FFFFFF">
<td>
<%
response.Write replace(rtrim(rs("username")),username,"<font color=red>"&username&"</font>")
if Cstr(rs("usergroup")) = 2 then
response.Write("<br>(<font color=red>超级版主</font>)")
End if
%>
</td>
<td>[<a href="user.asp?action=Del&userid=<%=rs("userid")%>">删除</a>]
[<a href="user.asp?action=Edit&userid=<%=rs("userid")%>">编辑</a>]
<%
if rs("usergroup") = 2 then
set rsmod = Conn.exeCute("select Mod_id From JBB_Mod where Mod_nameID="&rs("userid"))
if Not(rsmod.Eof and rsmod.Bof) then
response.Write("<br>[<a href=Boards.asp?action=EditMod&Mod_ID="& rsmod(0) &"&Mod_Name="& rtrim(rs("username")) &">编辑管理权限</a>]")
End if
set rsmod = Nothing
End if
%> </td>
<td><%=rs("regtime")%></td>
<td><%=rs("regIP")%></td>
<td>
<div align="center"><%= rs("threadcount")+rs("replycount")%></div></td>
</tr>
<%
rs.MoveNext
Next
%>
</table>
<br>
<table width="560" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td width="237">
<%
if pagecount < 1 then pagecount = 1
response.Write " 页次:"& PAGECOUNT &"/" & page &"页 每页"& rs.pageSize &" 用户数"&rs.recordCount&" "
%>
</td>
<td width="307" height="30">分页:
<%
beginpage = 1
endpage = CInt(pagecount)
page = CInt(page)
if pagecount >= 9 then
if page >= 5 then
beginpage = page - 4
if page <= (pagecount - 4) then
endpage = page + 4
else
endpage = pagecount
beginpage = pagecount - 4
end if
else
beginpage = 1
endpage = 9
end if
end if
if beginpage>1 then response.write " <a title=""第一页"" href=""user.asp?action=show&username="&username&"&groupID="&groupID&"""><font face=webdings>9</font></a>"
for j = beginpage to endpage
if j = page then
response.write" <b>" & j & "</b> "
else
response.write"<a href=""user.asp?action=show&page=" & j &"&username="&username&"&groupID="&groupID&"""> " & j & " </a>"
end if
next
if endpage < pagecount then response.write " <a title=""最末页"" href=""user.asp?action=show&page="& pagecount &"&username="&username&"&groupID="&groupID&"""><font face=webdings>:</font></a>"
%>
</td>
</tr>
</table>
<br>
<%
rs.close
set rs = Nothing
End if
End Sub
'=============================
Sub SaveNew()
username = replace(Trim(Request.Form("username")),"'","")
if username = "" then ErrorMsg "用户名不可为空!~"
set rs = server.CreateObject("adodb.recordset")
rs.open "select userid From JBB_user where username = '"& username &"'",conn,1,1
if Not rs.eof then
rs.close
set rs = Nothing
ErrorMsg "论坛中已有名为 "& username &" 的用户了,请重新输入一个用户名!"
End if
rs.close
set rs = Nothing
userpass = replace(Trim(Request.Form("userpass")),"'","")
if userpass = "" then ErrorMsg "请输入用户密码!~"
usergroup = Trim(Request.Form("usergroup"))
birthday = Trim(Request.Form("birthday"))
if birthday <> "" and Not(IsDate(birthday)) then ErrorMsg "生日日期格式不对~"
set rs = server.CreateObject("adodb.recordset")
rs.open "select * From JBB_user",conn,1,3
rs.addnew
rs("username") = username
rs("userpass") = md5(userpass)
rs("usertitle") = replace(Trim(Request.Form("usertitle")),"'","")
rs("usergroup") = usergroup
rs("email") = replace(Trim(Request.Form("email")),"'","")
rs("showemail") = Trim(Request.Form("showemail"))
rs("styleid") = Trim(Request.Form("styleid"))
rs("homepage") = replace(Trim(Request.Form("homepage")),"'","")
rs("oicq") = replace(Trim(Request.Form("oicq")),"'","")
rs("MSN") = replace(Trim(Request.Form("MSN")),"'","")
if birthday <> "" then
rs("birthday") = birthday
End if
rs("usersex") = Trim(Request.Form("usersex"))
rs("useradd") = replace(Trim(Request.Form("useradd")),"'","")
rs("signature") = replace(rTrim(Request.Form("signature")),"'","")
rs("regtime") = Now()
rs.update
rs.close
set rs = Nothing
if usergroup = 1 then
Conn.ExeCute("insert into JBB_admin(adminname,adminpass) values('"& username &"','"& md5(userpass) &"')")
elseif usergroup = 2 then
set rs = Conn.ExeCute("select userid From JBB_user where username = '" & username &"'")
if not rs.eof then
userid = rs(0)
End if
set rs = nothing
Conn.ExeCute("insert into JBB_Mod(Mod_BoardID,Mod_nameID,Mod_super) values("& 0 &","& userid &","& 1 &")")
End if
response.Write("<br><br> 成功添加用户:"&username)
Application.Lock
Application(JBBMasterCookies&"Home_userInfo") = ""
Application.UnLock
End Sub
'=============================
Sub add()
%>
<br>
<form name="form3" method="post" action="?action=SaveNew">
<table width="560" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
<tr bgcolor="#EFEFE7">
<td colspan="2"><strong>添加用户</strong></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="175">用户名</td>
<td width="362">
<input name="username" type="text" id="username"></td>
</tr>
<tr bgcolor="#F5F5F5">
<td>密 码</td>
<td>
<input name="userpass" type="text" id="userpass"></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -