📄 comment.asp
字号:
<!--#include file="Inc/conn.asp"-->
<!--#include file="inc/ubbcode.asp"-->
<!--#include file="Inc/function.asp"-->
<%
dim ArticleID,Action,ErrMsg,FoundErr
dim Commented,CommentedID,arrCommentedID,i
Action=trim(request("Action"))
ArticleID=trim(request("ArticleID"))
Commented=False
CommentedID=session("CommentedID")
if ArticleId="" then
founderr=true
errmsg=errmsg+"<li>请指定要评论的文章ID</li>"
else
ArticleID=Clng(ArticleID)
end if
if CommentedID<>"" then
if instr(CommentedID,"|")>0 then
arrCommentedID=split(CommentedID,"|")
for i=0 to ubound(arrCommentedID)
if Clng(arrCommentedID(i))=ArticleID then
Commented=True
exit for
end if
next
else
if CommentedID=ArticleID then
Commented=True
end if
end if
end if
if Commented=True then
FoundErr=True
ErrMsg=ErrMsg & "<li>你已经对该篇文章发表过评论了!请勿连续对同一篇文章发表评论。</li>"
end if
if FoundErr<>True then
if Action="Save" then
call SaveComment()
else
call main()
end if
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
sub main()
%>
<html>
<head>
<title>发表评论</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="STYLE.CSS" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function Check()
{
if (document.form1.Title.value=="")
{
alert("请输入评论标题!");
document.form1.Title.focus();
return false;
}
if (document.form1.Content.value=="")
{
alert("请输入评论内容!");
document.form1.Content.focus();
return false;
}
return true;
}
</script>
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<form name="form1" method="post" action="Comment.asp" onSubmit="return Check();">
<p> </p><table width="500" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
<tr align="center" class="title">
<td height="25" colspan="2"><strong><font color="#FFFFFF">发 表 评 论</font></strong></td>
</tr>
<tr class="tdbg">
<td align="right">评论标题:</td>
<td> <input name="Title" type="text" id="Title" size="60" maxlength="60">
<font color="#FF0000">*</font></td>
</tr>
<tr class="tdbg">
<td align="right">评论内容:</td>
<td> <textarea name="Content" cols="50" rows="10" id="Content"></textarea></td>
</tr>
<tr align="center" bgcolor="#DAE8CA" class="tdbg">
<td colspan="2"><input name="Action" type="hidden" id="Action" value="Save">
<input name="ArticleID" type="hidden" id="ArticleID" value="<%=ArticleID%>">
<input type="submit" name="Submit" value=" 发 表 "></td>
</tr>
</table>
</form>
</body>
</html>
<%
end sub
sub SaveComment()
dim ClassID,tClass,Title,Content
Title=trim(request.form("title"))
Content=trim(request.Form("Content"))
if Title="" then
founderr=true
errmsg=errmsg & "<br><li>请输入评论标题</li>"
end if
if Content="" then
founderr=true
errmsg=errmsg & "<br><li>请输入评论内容</li>"
end if
set tClass=conn.execute("select ClassID from Article where ArticleID=" & ArticleID)
if tClass.bof and tClass.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>找不到要评论的文章,可能已经被删除!</li>"
else
ClassID=tClass(0)
end if
set tClass=nothing
if founderr=true then
exit sub
end if
Title=DvHtmlEncode(Title)
Content=DvHtmlEncode(Content)
sql="Insert Into Comment (ClassID,ArticleID,UserName,IP,Title,Content) values (" & ClassID & "," & ArticleID & ",'" & Request.Cookies("asp163")("UserName") & "','" & Request.ServerVariables("REMOTE_ADDR") & "','" & Title & "','" & Content & "')"
conn.execute sql
if CommentedID="" then
session("CommentedID")=ArticleID
else
session("CommentedID")=CommentedID & "|" & ArticleID
end if
call WriteSuccessMsg("发表评论成功!")
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -