Jacky小站

开不开心自己说了算~~~~~~~

« 半夜起来听Michael的歌再次动手做了张皮~~~~~~~ »

回复评论修改方法放出

  应海枫(jogocun)的要求,放出这次整合版中回复评论的修改方法。不过声明在先,放出此方法的唯一原因是为了与PJ Fans共同讨论技术问题,因此不建议动手能力较弱的博主们将此方法部署到自己的Blog上。本人也不会对因为使用本方法造成的任何损失负上法律和道义上的责任。如果你非常喜欢并迫切需要回复评论此功能,强烈建议安装由丹MM放出的元旦整合版。

  最近有很多朋友都试用了本修改方法,并提出了很多之前我没有考虑到的一些问题,在此表示感谢。但是也不得不提醒各位,本贴的内容要求具有较高的动手修改代码和分析代码的能力,所以建议对ASP不熟悉的朋友还是尽量地使用由丹MM整合的版本。当然,今后发现的一些问题,我也会尽量利用空闲时间做出更新,但由于工作关系,有时不可能做出及时回复,还望见谅。

  PS:需要其他帮助的朋友请不要加我的QQ了,因为我不经常上的。有问题可在论坛里PM我,我能解决的会在第一时间做出响应的。

  修改好后的文件下载:
  放在根目录下:
  下载文件 下载此文件
  放在class目录下:
  下载文件 下载此文件
  放在common目录下:
  下载文件 下载此文件

  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)
%>
<%=blog_CommAuthor%> [<%=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 (" | ") end if%>]
<%=UBBCode(HtmlEncode(blog_CommContent),commArr(4,Pcount),blog_commUBB,blog_commIMG,commArr(7,Pcount),commArr(9,Pcount))%>
<%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

找到以下内容,并增加红色部分:
<%=blog_CommAuthor%> [<%=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 (" | ") end if%>]<%if stat_Admin and not comm_hasReply and blog_CommAuthor<>memName then response.write ("[回复]") end if%>

<%=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
%>


找到以下内容,并增加红色部分:







/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";
}
  • 相关文章:
  • quote 1.jogocun
  • 非常感谢小骏推出的方法。
    不过我用的是wbc的ajac评论,出差完毕回去认真测试下了。[wink]
  • 2007-1-14 0:04:14 回复该留言

日历

饭  否

搜索



最新评论及回复

最近发表

Google广告

Powered By Z-Blog 1.8 Arwen Build 81206

Copyright 2007 JackyTsu.com. 鄂ICP备06020224号