%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true
Const PurviewLevel=2 '操作权限
Const CheckChannelID=2 '所属频道,0为不检测所属频道
%>
<%
dim strFileName,ComeUrl
strFileName="Admin_Comment.asp"
ComeUrl=trim(request("ComeUrl"))
if ComeUrl="" then
ComeUrl=Request.ServerVariables("HTTP_REFERER")
end if
const MaxPerPage=20
dim totalPut,CurrentPage,TotalPages,i,j
dim Title
dim Action,FoundErr,Errmsg
Action=Trim(request("Action"))
Title=Trim(request("Title"))
if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
dim sql,rs
%>
文章评论管理
文 章 评 论 管 理
管理导航:
<%
if Action="Modify" then
call Modify()
elseif Action="SaveModify" then
call SaveModify()
elseif Action="Del" then
call DelComment()
elseif Action="Del2" then
call DelComment2()
elseif Action="Reply" then
call Reply()
elseif Action="SaveReply" then
call SaveReply()
else
call main()
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
sub main()
sql="select A.ArticleID, A.ClassID, A.Title as ArticleTitle, A.IncludePic, C.CommentID,C.UserName,C.IP,C.Title as CommentTitle, C.Content,C.WriteTime,C.ReplyName,C.ReplyContent,C.ReplyTime from Comment C Left Join Article A On C.ArticleID=A.ArticleID "
if Title<>"" then
sql=sql & " where C.Title like '%" & Title & "%' "
end if
sql=sql & " order by A.ArticleID desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
%>
<%
if currentPage=1 then
showContent
showpage strFileName,totalput,MaxPerPage,true,false,"篇评论"
else
if (currentPage-1)*MaxPerPage
<%
rs.close
set rs=nothing
end sub
sub showContent
dim i
i=0
dim PrevID
PrevID=rs("ArticleID")
do while not rs.eof
if rs("ArticleID")<>PrevID then response.write " "
if i=0 or rs("ArticleID")<>PrevID then
%>
|
<%
if rs("IncludePic")=true then
response.write "[图文]"
end if
response.write "" & rs("ArticleTitle") & ""
%>
<%
end if
i=i+1
if i>=MaxPerPage then exit do
PrevID=rs("ArticleID")
rs.movenext
loop
%>
选中本页显示的所有评论
<%
end sub
sub Modify()
dim CommentID
CommentID=trim(Request("CommentID"))
if CommentID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定评论ID
"
Exit sub
else
CommentID=Clng(CommentID)
end if
sql="Select * from Comment where CommentID=" & CommentID
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open sql,conn,1,1
if rs.Bof or rs.EOF then
FoundErr=True
ErrMsg=ErrMsg & "
找不到指定的评论!
"
else
%>
<%
end if
rs.close
set rs=nothing
end sub
sub Reply()
dim CommentID
CommentID=trim(Request("CommentID"))
if CommentID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定评论ID
"
Exit sub
else
CommentID=Clng(CommentID)
end if
sql="select A.ArticleID, A.ClassID, A.Title as ArticleTitle, A.IncludePic, C.CommentID,C.UserName,C.IP,C.Title as CommentTitle, C.Content,C.WriteTime,C.ReplyContent from Comment C Left Join Article A On C.ArticleID=A.ArticleID where C.CommentID=" & CommentID
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open sql,conn,1,1
if rs.Bof or rs.EOF then
FoundErr=True
ErrMsg=ErrMsg & "
找不到指定的评论!
"
else
%>
<%
end if
rs.close
set rs=nothing
end sub
%>
<%
sub DelComment()
dim CommentID,i
CommentID=trim(Request("CommentID"))
if CommentID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定评论ID
"
Exit sub
end if
if instr(CommentID,",")>0 then
dim idarr
idArr=split(CommentID)
for i = 0 to ubound(idArr)
conn.execute "delete from Comment where Commentid=" & Clng(idArr(i))
next
else
conn.execute "delete from Comment where Commentid=" & Clng(CommentID)
end if
call CloseConn()
response.redirect ComeUrl
End sub
sub DelComment2()
dim ArticleID
ArticleID=trim(request("ArticleID"))
if ArticleID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定评论ID
"
Exit sub
else
ArticleID=Clng(ArticleID)
end if
conn.execute "delete from Comment where ArticleID=" & ArticleID
call CloseConn()
response.redirect ComeUrl
End sub
sub SaveModify()
dim CommentID,UserName,IP,Title,Content,WriteTime
CommentID=trim(Request("CommentID"))
UserName=trim(request.form("UserName"))
IP=trim(request.form("IP"))
Title=trim(Request.form("Title"))
Content=trim(Request.form("Content"))
WriteTime=trim(request.form("WriteTime"))
if CommentID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定评论ID
"
Exit sub
else
CommentID=Clng(CommentID)
end if
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "
请输入评论人用户名
"
end if
if IP="" then
FoundErr=True
ErrMsg=ErrMsg & "
请输入评论人IP
"
end if
if WriteTime="" then
FoundErr=True
ErrMsg=ErrMsg & "
请输入发表评论时间
"
end if
if Title="" then
FoundErr=True
ErrMsg=ErrMsg & "
请输入评论标题
"
end if
if Content="" then
FoundErr=True
ErrMsg=ErrMsg & "
请输入评论内容
"
end if
if FoundErr=True then
exit sub
end if
sql="Select * from Comment where CommentID=" & CommentID
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open sql,conn,1,3
if rs.Bof or rs.EOF then
FoundErr=True
ErrMsg=ErrMsg & "
找不到指定的评论!
"
else
rs("UserName")=UserName
rs("IP")=IP
rs("WriteTime")=WriteTime
rs("Title")=dvhtmlencode(Title)
rs("Content")=dvhtmlencode(Content)
rs.update
end if
rs.Close
set rs=Nothing
call CloseConn()
response.redirect ComeUrl
end sub
sub SaveReply()
dim CommentID,ReplyName,ReplyContent,ReplyTime
CommentID=trim(Request("CommentID"))
ReplyContent=trim(request("ReplyContent"))
if CommentID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定评论ID
"
Exit sub
else
CommentID=Clng(CommentID)
end if
if ReplyContent="" then
FoundErr=True
ErrMsg=ErrMsg & "
请输入回复内容
"
end if
if FoundErr=True then
exit sub
end if
sql="Select * from Comment where CommentID=" & CommentID
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open sql,conn,1,3
if rs.Bof or rs.EOF then
FoundErr=True
ErrMsg=ErrMsg & "
找不到指定的评论!
"
else
rs("ReplyName")=AdminName
rs("ReplyTime")=now()
rs("ReplyContent")=dvhtmlencode(ReplyContent)
rs.update
end if
rs.Close
set rs=Nothing
call CloseConn()
response.redirect ComeUrl
end sub
%>