应海枫(jogocun)的要求,放出这次整合版中回复评论的修改方法。不过声明在先,放出此方法的唯一原因是为了与PJ Fans共同讨论技术问题,因此不建议动手能力较弱的博主们将此方法部署到自己的Blog上。本人也不会对因为使用本方法造成的任何损失负上法律和道义上的责任。如果你非常喜欢并迫切需要回复评论此功能,强烈建议安装由丹MM放出的元旦整合版。
最近有很多朋友都试用了本修改方法,并提出了很多之前我没有考虑到的一些问题,在此表示感谢。但是也不得不提醒各位,本贴的内容要求具有较高的动手修改代码和分析代码的能力,所以建议对ASP不熟悉的朋友还是尽量地使用由丹MM整合的版本。当然,今后发现的一些问题,我也会尽量利用空闲时间做出更新,但由于工作关系,有时不可能做出及时回复,还望见谅。
PS:需要其他帮助的朋友请不要加我的QQ了,因为我不经常上的。有问题可在论坛里PM我,我能解决的会在第一时间做出响应的。
2007-1-29
修正可多次回复的Bug
修正可回复自己评论的Bug
放出已经修改好的文件下载
2007-1-19
经过
Wady提醒又修改了几处错漏。
2007-1-13
刚刚发现之前写掉了一处修改的地方,赶紧加上。
数据库修改
blog_Comment表
增加字段:comm_parentID(数字型)被回复的评论ID、comm_hasReply(布尔型)是否有回复
文件修改
/blogcomm.asp
找到以下内容,并增加红色部分:
'====================== 评论发表函数 ===========================================================
function postcomm
dim username,post_logID,post_From,post_FromURL,post_disImg,post_DisSM,post_DisURL,post_DisKEY,post_DisUBB,post_Message,validate,china
,parentID,hasReply
dim password
dim ReInfo,LastMSG,FlowControl
ReInfo=Array("错误信息","","MessageIcon")
username=trim(CheckStr(request.form("username")))
password=trim(CheckStr(request.form("password")))
post_logID=CheckStr(request.form("logID"))
validate=trim(request.form("validate"))
post_Message=CheckStr(request.form("Message"))
parentID=cint(request.form("parentID"))
hasReply=cbool(request.form("hasReply"))
FlowControl=false
找到以下内容,并增加红色部分:
'插入数据
Dim AddComm
AddComm=array(array("blog_ID",post_logID),array("comm_Content",post_Message),array("comm_Author",username),array("comm_DisSM",post_DisSM),array("comm_DisUBB",post_DisUBB),array("comm_DisIMG",post_disImg),array("comm_AutoURL",post_DisURL),Array("comm_PostIP",getIP),Array("comm_AutoKEY",post_DisKEY)
,Array("comm_parentID",parentID),Array("comm_hasReply ",false))
DBQuest "blog_Comment",AddComm,"insert"
'Conn.ExeCute("INSERT INTO blog_Comment(blog_ID,comm_Content,comm_Author,comm_DisSM,comm_DisUBB,comm_DisIMG,comm_AutoURL,comm_PostIP,comm_AutoKEY) VALUES ("&post_logID&",'"&post_Message&"','"&username&"',"&post_DisSM&","&post_DisUBB&","&post_disImg&","&post_DisURL&",'"&getIP()&"',"&post_DisKEY&")")
if hasReply then
Conn.ExeCute("update blog_Comment set comm_hasReply=true where comm_ID="&parentID)
end if
/class/cls_article.asp
在文件末尾添加下列代码:
'*******************************************
' 显示日志回复评论内容
'*******************************************
Sub ShowReplyComm(commID)
dim blog_Comment,Pcount,comm_Num,blog_CommID,blog_CommAuthor,blog_CommContent,Url_Add,commArr
Set blog_Comment=Server.CreateObject("Adodb.RecordSet")
Pcount=0
SQL="SELECT comm_ID,comm_Content,comm_Author,comm_PostTime,comm_DisSM,comm_DisUBB,comm_DisIMG,comm_AutoURL,comm_PostIP,comm_AutoKEY FROM blog_Comment WHERE comm_parentID="&commID
blog_Comment.Open SQL,Conn,1,1
SQLQueryNums=SQLQueryNums+1
IF blog_Comment.EOF AND blog_Comment.BOF Then
else
commArr=blog_Comment.GetRows(blog_Comment.RecordCount)
blog_Comment.close
set blog_Comment = nothing
blog_CommID=commArr(0,Pcount)
blog_CommAuthor=commArr(2,Pcount)
blog_CommContent=commArr(1,Pcount)
%>
<div class="comment">
<div class="commenttop"><a name="comm_<%=blog_CommID%>" href="javascript:addQuote('<%=blog_CommAuthor%>','commcontent_<%=blog_CommID%>')"><img border="0" src="images/<%if memName=blog_CommAuthor then response.write ("icon_quote_author.gif") else response.write ("icon_quote.gif") end if%>" alt="" style="margin:0px 4px -3px 0px"/></a><a href="member.asp?action=view&memName=<%=Server.URLEncode(blog_CommAuthor)%>"><strong><%=blog_CommAuthor%></strong></a> <span class="commentinfo">[<%=DateToStr(commArr(3,Pcount),"Y-m-d H:I A")%> <%if stat_Admin then response.write (" | "&commArr(8,Pcount)) end if%><%if stat_Admin=true or (stat_CommentDel=true and memName=blog_CommAuthor) then response.write (" | <a href=""blogcomm.asp?action=del&commID="&blog_CommID&""" onclick=""if (!window.confirm('是否删除该评论?')) {return false}""><img src=""images/del1.gif"" alt=""删除该评论"" border=""0""/></a>") end if%>]</span></div>
<div class="commentcontent" id="commcontent_<%=blog_CommID%>"><%=UBBCode(HtmlEncode(blog_CommContent),commArr(4,Pcount),blog_commUBB,blog_commIMG,commArr(7,Pcount),commArr(9,Pcount))%></div>
</div>
<%end if
end sub%>
找到以下内容,并增加红色部分:
blog_CommID=commArr(0,Pcount)
blog_CommAuthor=commArr(2,Pcount)
blog_CommContent=commArr(1,Pcount)
comm_hasReply=cbool(commArr(10,Pcount))
找到以下内容,并增加红色部分:
dim blog_Comment,Pcount,comm_Num,blog_CommID,blog_CommAuthor,blog_CommContent,Url_Add,commArr,commArrLen
,comm_hasReply
Set blog_Comment=Server.CreateObject("Adodb.RecordSet")
Pcount=0
SQL="SELECT comm_ID,comm_Content,comm_Author,comm_PostTime,comm_DisSM,comm_DisUBB,comm_DisIMG,comm_AutoURL,comm_PostIP,comm_AutoKEY
,comm_hasReply FROM blog_Comment WHERE blog_ID="&LogID&"
and comm_parentID=0 UNION ALL SELECT 0,tb_Intro,tb_Title,tb_PostTime,tb_URL,tb_Site,tb_ID,0,'127.0.0.1',0
,0 FROM blog_Trackback WHERE blog_ID="&LogID&" ORDER BY comm_PostTime "&comDesc
找到以下内容,并增加红色部分:
<div class="commenttop"><a name="comm_<%=blog_CommID%>" href="javascript:addQuote('<%=blog_CommAuthor%>','commcontent_<%=blog_CommID%>')"><img border="0" src="images/<%if memName=blog_CommAuthor then response.write ("icon_quote_author.gif") else response.write ("icon_quote.gif") end if%>" alt="" style="margin:0px 4px -3px 0px"/></a><a href="member.asp?action=view&memName=<%=Server.URLEncode(blog_CommAuthor)%>"><strong><%=blog_CommAuthor%></strong></a> <span class="commentinfo">[<%=DateToStr(commArr(3,Pcount),"Y-m-d H:I A")%> <%if stat_Admin then response.write (" | "&commArr(8,Pcount)) end if%><%if stat_Admin=true or (stat_CommentDel=true and memName=blog_CommAuthor) then response.write (" | <a href=""blogcomm.asp?action=del&commID="&blog_CommID&""" onclick=""if (!window.confirm('是否删除该评论?')) {return false}""><img src=""images/del1.gif"" alt=""删除该评论"" border=""0""/></a>") end if%>]
<%if stat_Admin and not comm_hasReply and blog_CommAuthor<>memName then response.write ("<a href=""javascript:replyComment('"&blog_CommAuthor&"','"&blog_CommID&"');"" title=""回复本条评论"">[回复]</a>") end if%></span></div>
<div class="commentcontent" id="commcontent_<%=blog_CommID%>">
<%=UBBCode(HtmlEncode(blog_CommContent),commArr(4,Pcount),blog_commUBB,blog_commIMG,commArr(7,Pcount),commArr(9,Pcount))%>
<%
if comm_hasReply then
ShowReplyComm(blog_CommID)
end if
%>
</div>
找到以下内容,并增加红色部分:
<tr>
<td colspan="2" align="center" style="padding:3px;">
<input name="logID" type="hidden" value="<%=LogID%>"/>
<input name="action" type="hidden" value="post"/>
<input name="parentID" type="hidden" value="0"/>
<input name="hasReply" type="hidden" value="false"/>
<input name="submit2" type="submit" class="userbutton" value="发表评论" accesskey="S"/>
<input name="button" type="reset" class="userbutton" value="重写" onclick="resetReply()"/></td>
</tr>
/common/common.js
在文件末尾添加下列代码:
function replyComment(author,commID) {
document.getElementById("MsgHead").innerHTML="回复 "+ author + " 的评论";
if (document.getElementById("editMask") != undefined) {
showUBB('Message');
}
document.getElementById("hasReply").value="true";
document.getElementById("parentID").value=commID;
document.getElementById("Message").focus();
}
function resetReply() {
document.getElementById("MsgHead").innerHTML="发表评论";
document.getElementById("hasReply").value="false";
document.getElementById("parentID").value="0";
}
[
本帖最后由 小骏 于 2007-1-29 11:44 编辑 ]