Feb 13

如何给你的PJ博客加评论的回复功能 晴

碟舞飞扬 , 12:45 , Web开发 , 评论(0) , 引用(0) , 阅读(3734) , Via 本站原创 | |
一.打开class\cls_article.asp
1.找到
引用
Sub ShowComm(LogID,comDesc,DisComment)

在下面插入:
引用
dim action,commID,CommReplyContent

2.搜索
引用
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 blog_ID="&LogID&" UNION ALL Select 0,tb_Intro,tb_Title,tb_PostTime,tb_URL,tb_Site,tb_ID,0,'127.0.0.1',0 FROM blog_Trackback Where blog_ID="&LogID&" orDER BY comm_PostTime "&comDesc

替换为
引用
if action="Reply" then
                commID=request("commID")
           SQL="Select comm_ID,comm_Content,comm_Author,comm_PostTime,comm_DisSM,comm_DisUBB,comm_DisIMG,comm_AutoURL,comm_PostIP,comm_AutoKEY,comm_Reply,comm_Replytime FROM blog_Comment Where comm_ID="&commID&" UNION ALL Select 0,tb_Intro,tb_Title,tb_PostTime,tb_URL,tb_Site,tb_ID,0,'127.0.0.1',0,0,0 FROM blog_Trackback Where blog_ID="&LogID&" orDER BY comm_PostTime "&comDesc
                else
           SQL="Select comm_ID,comm_Content,comm_Author,comm_PostTime,comm_DisSM,comm_DisUBB,comm_DisIMG,comm_AutoURL,comm_PostIP,comm_AutoKEY,comm_Reply,comm_Replytime FROM blog_Comment Where blog_ID="&LogID&" UNION ALL Select 0,tb_Intro,tb_Title,tb_PostTime,tb_URL,tb_Site,tb_ID,0,'127.0.0.1',0,0,0 FROM blog_Trackback Where blog_ID="&LogID&" orDER BY comm_PostTime "&comDesc
           end if

3.找到
引用
<a href=""blogcomm.asp?action=del&commID="&blog_CommID&""" onclick=""if (!window.confirm('是否删除该评论?')) {return false}"">

在它之前插入
引用
<a href=""article.asp?action=Reply&commID="&blog_CommID&"&ID="&LogID&"#comm_"&blog_CommID&"""><img src=""Plugins/guestbook/reply.gif"" alt=""回复"" border=""0"" style=""margin-bottom:-3px""/></a>

4.找到
引用
<div id="MsgHead">发表评论</div>

将 发表评论 替换为
引用
<%
          if action="Reply" then
                  response.write "回复评论"
          else
                  response.write "发表评论"
          end if
%>

5.找到
引用
<input name="action" type="hidden" value="post"/>

替换为
引用
<%
          if action="Reply" then
%>
              <input name="action" type="hidden" value="Reply"/>
              <input name="commID" type="hidden" value="<%=blog_CommID%>"/>
<%
          else
%>
              <input name="action" type="hidden" value="post"/>
<%
          end if
%>

6.找到
引用
<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>

在下面插入
引用
<%if len(commArr(10,Pcount))>0 then %>
<div class="commenttop"><img src="images/reply.gif" alt="" border="0" style="margin:0px 3px -3px 0px"/><b><%=blog_master%>回复</b>  <span class="commentinfo">[<%=DateToStr(commArr(11,Pcount),"Y-m-d H:I A")%>]</span></div>
<div class="commentcontent"><%=UBBCode(HtmlEncode(commArr(10,Pcount)),0,0,0,1,1)%></div>
<%end if%>

7.找到
引用
blog_CommContent=commArr(1,Pcount)

在下面插入(注意:如果出错了请将里面的10修改为12)
引用
dim CommReplyConten
CommReplyContent=commArr(10,Pcount)

8.找到
引用
UBB_Tools_Items=UBB_Tools_Items&"||image,link,mail,quote,smiley"

在下面插入
引用
if action="Reply" then
              UBB_Msg_Value=UBBFilter(UnCheckStr(CommReplyContent))
           end if

二.打开blogcomm.asp
1.在最下面的一个
引用
%>

之前插入如下代码
引用
function replyMsg
  dim post_Message,MsgID,ReInfo,post_logID
  ReInfo=Array("错误信息","","MessageIcon")
  MsgID = CheckStr(Request.form("commID"))
  post_Message=CheckStr(request.form("Message"))
  post_logID=CheckStr(request.form("logID"))
           if not (memName<>empty and stat_Admin) then
                         ReInfo(0)="评论回复错误信息"
                         ReInfo(1)="你没有权限回复留言<a href=""javascript:history.go(-1)"">单击返回</a>"
                         ReInfo(2)="ErrorIcon"
           end if
           If MsgID=Empty then
                         ReInfo(0)="评论回复错误信息"
                         ReInfo(1)="非法操作<a href=""javascript:history.go(-1)"">单击返回</a>"
                         ReInfo(2)="ErrorIcon"
           end if
           If IsInteger(MsgID)=0 then
                         ReInfo(0)="评论回复错误信息"
                         ReInfo(1)="非法操作<a href=""javascript:history.go(-1)"">单击返回</a>"
                         ReInfo(2)="ErrorIcon"
           end if
      Conn.ExeCute("update blog_Comment set Comm_reply='"&post_Message&"',Comm_replytime='"&now&"' where comm_ID=" & MsgID)
         ReInfo(0)="评论回复成功"
         ReInfo(1)="<b>你成功地对该评论进行了回复</b><br/><a href=""article.asp?id="&post_logID&""">单击返回该日志</a>"
         ReInfo(2)="MessageIcon"
replyMsg=ReInfo
end function

2.找到
引用
<%
else
response.write ("非法操作!!")

在上面插入如下代码
引用
<%
elseif Request("action")="Reply" then
PostBComm=replyMsg
%>
   <div style="text-align:center;">
    <div id="MsgContent" style="width:300px">
      <div id="MsgHead"><%=PostBComm(0)%></div>
      <div id="MsgBody">
                 <div class="<%=PostBComm(2)%>"></div>
         <div class="MessageText"><%=PostBComm(1)%></div>
          </div>
        </div>
  </div>

三.打开ConContent.asp
1.找到
引用
conn.execute("Update blog_Comment SET comm_Content='"&checkStr(Request.form("message_"&doCommID(i)))&"' Where comm_ID="&doCommID(i))

替换为
引用
conn.execute("Update blog_Comment SET comm_Content='"&checkStr(Request.form("message_"&doCommID(i)))&"',comm_Reply='"&checkStr(Request.form("reply_"&doCommID(i)))&"',Comm_replytime='"&now&"' Where comm_ID="&doCommID(i))

2.找到第二处的(有两处)
引用
<div class="content"><textarea name="message_<%=commArr(0,Pcount)%>" onFocus="focusMe(this)" onBlur="blurMe(this)" onMouseOver="overMe(this)" onMouseOut="outMe(this)"><%=UnCheckStr(commArr(1,Pcount))%></textarea></div>

在下面插入
引用
<div class="reply"><h5>回复内容:<%if len(trim(commArr(7,Pcount)))<1 or IsNull(commArr(7,Pcount)) then response.write "<span class=""tip"">(无回复留言)</span>"%></h5><textarea name="reply_<%=commArr(0,Pcount)%>" onFocus="focusMe(this)" onBlur="blurMe(this)" onMouseOver="overMe(this)" onMouseOut="outMe(this)" onChange="checkMe(this)"><%=UnCheckStr(commArr(7,Pcount))%></textarea></div>

3.找到
引用
SQL="Select comm_ID,comm_Content,comm_Author,comm_PostTime,comm_PostIP,blog_ID,T.log_Title from blog_Comment C,blog_Content T Where C.blog_ID=T.log_ID orDER BY C.comm_PostTime desc"

修改为:
引用
SQL="Select comm_ID,comm_Content,comm_Author,comm_PostTime,comm_PostIP,blog_ID,T.log_Title,comm_Reply from blog_Comment C,blog_Content T Where C.blog_ID=T.log_ID orDER BY C.comm_PostTime desc"


四.下载附件,上传Update.ASP到博客目录执行升级数据库.然后到后台重建数据缓存.你就可以实现这个效果了!
文件内容如下:
引用
<!--#include file="const.asp" -->
<!--#include file="conn.asp" -->
<!--#include file="common/function.asp" -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
body{
font-size:12px;
font-family:verdana;
}
</style>
<h3>PJBlog 公告等升级程序</h3><br/>
<b>开始执行升级 SQL 语句</b><br/>
- 说明: <span style="color:#004000"><b>绿色文字</b></span> 代表已经升级过的字段,<span style="color:#0000a0"><b>蓝色字代</b></span> 表正在执行的语句
<br/>
<br/>
<div style="border:1px solid #4b372e;background:#fefded;padding:6px;line-height:160%;">
<%
   SQL="Alter TABLE `blog_Comment` ADD `Comm_reply` memo"
   UpdateSQL SQL
   SQL="Alter TABLE `blog_Comment` ADD `Comm_replytime` date"
   UpdateSQL SQL
   Conn.ExeCute("update blog_Comment set Comm_replytime='"&now&"'")
  %>
  </div>
  <%
Conn.Close
Set Conn=Nothing

function UpdateSQL(SQLString)
On Error Resume Next
  Conn.execute SQLString
if err then
   response.write "<span style=""color:#004000""><b></b> "&err.description&"</span><br/>"
  else
   response.write "<span style=""color:#0000a0""><b>执行:</b> "&SQLString&"</span><br/>"
end if
end function
%>
<div style="border:1px solid #4b372e;background:#fefded;padding:6px;line-height:160%;margin-top:2px">
升级完成为了保证你的系统安全,请删除升级文件。<br/>升级后到后台 <b>"站点基本设置-初试化数据"</b> 执行 <b>"重建数据缓存"</b>
</div>
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]