📄 user_comment.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="user_chkpass.asp"-->
<!--#include file="inc/usercode.asp"-->
<!--#include file="inc/function.asp"-->
<SCRIPT language=javascript>
function del_space(s)
{
for(i=0;i<s.length;++i)
{
if(s.charAt(i)!=" ")
break;
}
for(j=s.length-1;j>=0;--j)
{
if(s.charAt(j)!=" ")
break;
}
return s.substring(i,++j);
}
function VerifySubmit()
{
topic = del_space(document.form2.topic.value);
if (topic.length == 0)
{
alert("您忘了填写题目!");
return false;
}
submits();
if (document.form2.edit.value == "")
{
alert("请输入内容!");
return false;
}
return true;
}
</SCRIPT>
<%
if CheckUserLogined()=False then
response.Redirect "user_login.asp"
end if
const MaxPerPage=20
dim strFileName
dim totalPut,CurrentPage,TotalPages
dim rs, sql
dim ID,UserSearch,Keyword,strField
dim Action,FoundErr,ErrMsg
dim tmpDays,usersql
dim mainid
keyword=trim(request("keyword"))
if keyword<>"" then
keyword=ReplaceBadChar(keyword)
end if
strField=trim(request("Field"))
UserSearch=trim(request("UserSearch"))
Action=trim(request("Action"))
ID=trim(Request("ID"))
mainid=trim(Request("mainID"))
ComeUrl=Request.ServerVariables("HTTP_REFERER")
if UserSearch="" then
UserSearch=0
else
UserSearch=Clng(UserSearch)
end if
strFileName="user_comment.asp?UserSearch=" & UserSearch
if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
%>
<html>
<head>
<title>用户评论管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="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.checked = form.chkAll.checked;
}
}
</SCRIPT>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<br>
<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>
<form name="form1" action="user_comment.asp" method="get">
<tr class="tdbg">
<td width="100" height="30"><strong>快速查找评论:</strong></td>
<td width="687" height="30"><select size=1 name="UserSearch" onChange="javascript:submit()">
<option value="0">列出所有评论</option>
<%if userlevel=9 then%><option value="1">我文章里的评论</option><%end if%>
<option value="10" selected> </option>
</select>
<a href="user_comment.asp">评论管理首页</a> </td>
</tr>
</form>
</table>
<br>
<%
if Action="Modify" then
call Modify()
elseif Action="SaveModify" then
call SaveModify()
elseif Action="Del" then
call Delcomment()
else
call main()
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
sub main()
dim strGuide
strGuide="<table width='98%' align='center'><tr><td align='left'>您现在的位置:<a href='User_comment.asp'>用户评论管理</a> >> "
select case UserSearch
case 0
if userlevel=9 then
sql="select * from [comment] order by ID desc"
else
sql="select * from [comment] where mainuser='"&username&"' order by ID desc"
end if
strGuide=strGuide & "所有评论"
case 1
sql="select * from [comment] where mainuser='"&username&"' order by id desc"
strGuide=strGuide & "我文章里的评论"
case 10
if Keyword="" then
if userlevel=9 then
sql="select * from [comment] order by id desc"
else
sql="select * from [comment] where mainuser='"&username&"' order by id desc"
end if
strGuide=strGuide & "所有评论"
else
select case strField
case "ID"
if IsNumeric(Keyword)=False then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>ID必须是整数!</li>"
else
if userlevel=9 then
sql="select * from [comment] where ID =" & Clng(Keyword)&" and mainuser='"&username&"'"
else
sql="select * from [comment] where ID =" & Clng(Keyword)
end if
strGuide=strGuide & "评论ID等于<font color=red> " & Clng(Keyword) & " </font>的用户"
end if
case "topic"
if userlevel=9 then
sql="select * from [comment] where commenttopic like '%" & Keyword & "%' order by ID desc"
else
sql="select * from [comment] where commenttopic like '%" & Keyword & "%' and mainuser='"&username&"' order by ID desc"
end if
strGuide=strGuide & "标题中含有“ <font color=red>" & Keyword & "</font> ”的评论"
end select
end if
case else
FoundErr=True
ErrMsg=ErrMsg & "<br><li>错误的参数!</li>"&sql
end select
strGuide=strGuide & "</td><td align='right'>"
if FoundErr=True then exit sub
Set rs=Server.CreateObject("Adodb.RecordSet")
'response.Write userlevel
'response.Write(sql)
rs.Open sql,Conn,1,1
if rs.eof and rs.bof then
strGuide=strGuide & "共找到 <font color=red>0</font> 个评论</td></tr></table>"
response.write strGuide
else
totalPut=rs.recordcount
strGuide=strGuide & "共找到 <font color=red>" & totalPut & "</font> 个评论</td></tr></table>"
response.write strGuide
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个评论"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个评论"
else
currentPage=1
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个评论"
end if
end if
end if
rs.Close
set rs=Nothing
call ShowSearch()
end sub
sub showContent()
dim i
i=0
%>
<table width='100%' border="0" cellpadding="0" cellspacing="0">
<tr>
<form name="myform" method="Post" action="user_comment.asp" onsubmit="return confirm('确定要执行选定的操作吗?');">
<td>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
<tr class="title">
<td width="34" align="center"><font color="#FFFFFF">选中</font></td>
<td width="34" align="center"><font color="#FFFFFF">ID</font></td>
<td width="138" height="22" align="center"><span class="style1">发表人</span> </td>
<td width="320" height="22" align="center"><font color="#FFFFFF">评论标题</font></td>
<td width="154" align="center"><font color="#FFFFFF">发表时间</font></td>
<td width="87" height="22" align="center"><font color="#FFFFFF">
操作</font></td>
</tr>
<%do while not rs.EOF %>
<tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'">
<td width="34" align="center"><input name='ID' type='checkbox' onclick="unselectall()" id="ID" value='<%=cstr(rs("ID"))%>'>
<input name='mainID' type="hidden" id="mainID" value='<%=trim(rs("mainID"))%>'></td>
<td width="34" align="center"><%=rs("ID")%></td>
<td width="138" align="center" <%if userlevel=9 then%>title="IP:<%=rs("addip")%>"<%end if%>><%=rs("comment_user")%>
</td>
<td align="center"> <a href=more.asp?name=<%=rs("mainuser")%>&id=<%=rs("mainid")%> target=_blank><%=rs("commenttopic")%> </a> </td>
<td align="center"> <%
if rs("addtime")<>"" then
response.write rs("addtime")
else
response.write " "
end if
%> </td>
<td width="100" align="center"><%
response.write "<a href='User_comment.asp?Action=Modify&ID=" & rs("ID") & "&re=true'>回复</a> "
response.write "<a href='User_comment.asp?Action=Modify&ID=" & rs("ID") & "'>修改</a> "
response.write "<a href='User_comment.asp?Action=Del&ID=" & rs("ID") & "&mainid="&rs("mainid")&"' onClick='return confirm(""确定要删除此评论吗?"");'>删除</a>"
%> </td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="200" height="30"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
选中本页显示的所有评论</td>
<td> <strong>操作:</strong>
<input name="Action" type="radio" value="Del" checked onClick="document.myform.UserLevel.disabled=true">删除
<input type="submit" name="Submit" value=" 执 行 "></td>
</tr>
</table>
</td>
</form></tr></table>
<%
end sub
sub ShowSearch()
%>
<form name="form2" method="post" action="user_comment.asp">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
<tr class="tdbg">
<td width="120"><strong>评论高级查询:</strong></td>
<td width="300">
<select name="Field" id="Field">
<option value="ID">评论ID</option>
<option value="topic" selected>评论标题</option>
</select>
<input name="Keyword" type="text" id="Keyword" size="20" maxlength="30">
<input type="submit" name="Submit2" value=" 查 询 ">
<input name="UserSearch" type="hidden" id="UserSearch" value="10">
</td>
<td>若为空,则查询所有评论</td>
</tr>
</table>
</form>
<%
end sub
sub Modify()
dim ID
dim rsblog,sqlblog
dim restr
ID=trim(request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>参数不足!</li>"
exit sub
else
ID=Clng(ID)
end if
Set rsblog=Server.CreateObject("Adodb.RecordSet")
if userlevel=9 then
sqlblog="select * from [comment] where ID=" & ID
else
sqlblog="select * from [comment] where ID=" & ID&" and mainuser='"&username&"'"
end if
rsblog.Open sqlblog,Conn,1,1
if rsblog.bof and rsblog.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>找不到指定的评论!</li>"
rsUser.close
set rsUser=nothing
exit sub
end if
if request("re")="true" then
restr="<table align=center bgcolor=#f3f3f3 border=1 bordercolor=#cccccc cellPadding=2 cellSpacing=0 style='BORDER-COLLAPSE: collapse' width='90%'>"
restr=restr&"<tbody><tr><td><p><strong>以下为blog主人的回复:</strong></p><p> </p></td></tr></tbody></table>"
end if
%>
<form action="user_comment.asp?action=SaveModify" method="post" name="form2" onSubmit="return VerifySubmit()">
<table width="98%" border="0" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
<tr align="center">
<td height=25 colspan=5 class="topbg"><strong>修 改 评 论</strong>
<tr>
<td width="11%" class="tdbg" height=23>评论标题:</td>
<td width="89%" colspan="4" class="tdbg"><input name="topic" type=text class="cont" id="topic" value="<%=rsblog("commenttopic")%>" size="50" maxlength="30">
<font color="#FF0000"> *</font></td>
</tr>
<tr>
<td height=23 colspan="5" class="tdbg"><INPUT type="hidden" name="edit" id="edit"value="<%
if rsblog("comment")<>"" then
response.Write Server.HtmlEncode(rsblog("comment")+restr)
else
response.Write " "
end if
%>"">
<!--#include file="edit.asp"-->
</td>
</tr>
<tr>
<td height=25 colspan="5" class="tdbg"> <INPUT type="hidden" name="id" value="<%=rsblog("id")%>">
<input type="submit" name="Submit2" value="提交修改">
<input type="reset" name="Submit" value="清除重写"> </td>
</tr>
</table>
</form>
<%
rsblog.close
set rsblog=nothing
end sub
sub SaveModify()
dim id,rsblogchk
id=clng(trim(request("id")))
'call chkenaddlog()
if userlevel=9 then
sql="select * from comment where id="&id
else
sql="select * from comment where id="&id&" and mainuser='"&username&"'"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
rs("commenttopic")=trim(request("topic"))
rs("comment")=request("edit")
rs.update
rs.close
set rs=nothing
call CloseConn()
Response.Write"<script language=JavaScript>"
Response.Write"alert(""修改评论成功!"");"
Response.Write"window.location='user_comment.asp'"
Response.Write"</script>"
'response.redirect "user_comment.asp"
end sub
sub Delcomment()
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请指定要删除的评论</li>"
exit sub
end if
if instr(ID,",")>0 then
ID=replace(ID," ","")
if userlevel=9 then
sql="delete from [comment] where ID in (" & ID & ")"
else
sql="delete from [comment] where ID in (" & ID & ")"&" and mainuser='"&username&"'"
end if
dim n,i,u '回复数-1
n=split(id,",")
u=split(mainid,",")
for i=0 to ubound(n)
conn.execute("update [blog] set commentnum=commentnum-1 where id="&trim(u(i)))
next
else
if userlevel=9 then
sql="delete from [comment] where ID=" & Clng(ID)
else
sql="delete from [comment] where ID=" & Clng(ID)&" and mainuser='"&username&"'"
end if
if instr(mainid,",")=0 then
conn.execute("update [blog] set commentnum=commentnum-1 where id="&mainid)
end if
end if
Conn.Execute sql
call CloseConn()
response.redirect ComeUrl
end sub
sub WriteErrMsg()
dim strErr
strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strErr=strErr & "<link href='style.css' rel='stylesheet' type='text/css'></head><body><br><br>" & vbcrlf
strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
strErr=strErr & " <tr align='center' class='title'><td height='22'><strong>错误信息</strong></td></tr>" & vbcrlf
strErr=strErr & " <tr class='tdbg'><td height='100' valign='top'><b>产生错误的可能原因:</b>" & errmsg &"</td></tr>" & vbcrlf
strErr=strErr & " <tr align='center' class='tdbg'><td><a href='javascript:history.go(-1)'><< 返回上一页</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></html>" & vbcrlf
response.write strErr
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -