PJBlog评论留言增加邮箱网址 记住访客信息


为了增强博客的交互性 本来想换z-blog 试了下 动态转静态。。收录就要从零开始了
为了我那可怜的收录,决定到处找,到pj论坛 到pj博客上看,看怎么修改源码
搞了一个下午。终于搞成现在这个效果了 虽然效果还不是很好。但勉强够用了
下面列出修改方法。方便想增加交互性的pj用户 呵呵。希望你们不要走弯路。

首先:评论留言增加邮箱网址及博主回复通知评论留言人

注意:此功能基于留言评论邮件通知博主(增加后台开关),否则发送不了邮件。

打开class/cls_article.asp,找到:

  1.            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
修改为:
  1.            SQL="Select comm_ID,comm_Content,comm_Author,comm_PostTime,comm_DisSM,comm_DisUBB,comm_DisIMG,comm_AutoURL,comm_PostIP,comm_AutoKEY,email,siteurl 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
找到
  1. <%=blog_CommAuthor%></strong></a> <span class="commentinfo">
,按回车,在下面插入以下代码.
  1. <%
     
  2. if trim(commArr(10,Pcount))<>"" then
     
  3.         response.write " <a href=mailto:"&trim(commArr(10,Pcount))&" target=_blank><img src=images/email1.gif border=0></a>"
     
  4. else
     
  5.         response.write " <img src=images/noemail1.gif>"
     
  6. end if
     

  7.  
  8. if trim(commArr(11,Pcount))<>"" and trim(commArr(11,Pcount))<>"http://" then
     
  9.         response.write " <a href="&trim(commArr(11,Pcount))&" target=_blank><img src=images/url1.gif border=0></a>"
     
  10. else
     
  11.         response.write " <img src=images/nourl1.gif>"
     
  12. end if
     
  13. %>
找到
  1.           <%if memName=empty or blog_validate=true then%><tr><td align="right" width="70"><strong>验证码:</strong></td><td align="left" style="padding:3px;"><input name="validate" type="text" size="4" class="userpass" maxlength="4"/> <%=getcode()%></td></tr><%end if%>
在其上插入一行,加入以下代码
  1.       <%if memName=empty then%><tr><td align="right" width="70"><strong>邮 箱:</strong></td><td align="left" style="padding:3px;"><input name="email" type="text" size="18" class="userpass" maxlength="24"/> 请填写您的邮箱.</td></tr><%end if%>
     
  2.       <%if memName=empty then%><tr><td align="right" width="70"><strong>网 址:</strong></td><td align="left" style="padding:3px;"><input name="siteurl" type="text" class="userpass" value="http://" size="18" maxlength="24"/> 请填写您的网址.</td></tr><%end if%>
3.打开PJBLOG根目录下的blogcomm.asp,找到
  1.   password=trim(CheckStr(request.form("password")))
在其下插入如下代码
  1. dim email,siteurl
     
  2.   email=trim(CheckStr(request.form("email")))
     
  3.   siteurl=trim(CheckStr(request.form("siteurl")))
找到
  1.   IF (memName=empty or blog_validate=true) and cstr(lcase(Session("GetCode")))<>cstr(lcase(validate)) then
     
  2.           ReInfo(0)="评论发表错误信息"
     
  3.           ReInfo(1)="<b>验证码有误,请返回重新输入</b>
     
  4. <a href=""javascript:history.go(-1);"">请返回重新输入</a>"
     
  5.           ReInfo(2)="ErrorIcon"
     
  6.           postcomm=ReInfo
     
  7.       exit function
     
  8.   end if
在其上插入如下代码
  1.         if memName=empty and email<>"" and IsValidEmail(email)=false then
     
  2.                         ReInfo(0)="评论发表错误信息"
     
  3.                         ReInfo(1)="<b>邮箱格式错误</b>
     
  4. <a href=""javascript:history.go(-1);"">请返回重新输入</a>"
     
  5.                         ReInfo(2)="ErrorIcon"
     
  6.                         postcomm=ReInfo
     
  7.                         exit function
     
  8.         end if
     

  9.  
  10.         if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
     
  11.                         ReInfo(0)="评论发表错误信息"
     
  12.                         ReInfo(1)="<b>网址格式错误</b>
     
  13. <a href=""javascript:history.go(-1);"">请返回重新输入</a>"
     
  14.                         ReInfo(2)="ErrorIcon"
     
  15.                         postcomm=ReInfo
     
  16.                         exit function
     
  17.         end if
找到
  1. 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))
修改为:
  1. 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("email",email),Array("siteurl",siteurl))
打开common下的function.asp,在最后一个
  1. %>
之前插入如下代码.
  1. Function IsRightUrl(UrlStrng)  '网址判断
     
  2.   Dim regEx, retVal
     
  3.   Set regEx = New RegExp
     
  4.   regEx.Pattern = "^https?:\/\/[\u4E00-\u9FA5a-zA-Z\.\/0-9]{3,}[\u4E00-\u9FA5a-zA-Z\/0-9]{2,}$"
     
  5.   regEx.IgnoreCase = False
     
  6.   retVal = regEx.Test(UrlStrng)
     

  7.  

  8.  
  9.   If retVal Then
     
  10.     IsRightUrl = true
     
  11.   Else
     
  12.     IsRightUrl = false
     
  13.   End If
     
  14. End Function
     

  15.  
  16. Public function IsValidEmail(email)  '邮箱判断
     
  17.         dim names, name, i, c
     
  18.         IsValidEmail = true
     
  19.         names = Split(email, "@")
     
  20.         if UBound(names) <> 1 then
     
  21.            IsValidEmail = false
     
  22.            exit function
     
  23.         end if
     
  24.         for each name in names
     
  25.            if Len(name) <= 0 then
     
  26.                  IsValidEmail = false
     
  27.              exit function
     
  28.            end if
     
  29.            for i = 1 to Len(name)
     
  30.                  c = Lcase(Mid(name, i, 1))
     
  31.              if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
     
  32.                IsValidEmail = false
     
  33.                    exit function
     
  34.              end if
     
  35.            next
     
  36.            if Left(name, 1) = "." or Right(name, 1) = "." then
     
  37.                   IsValidEmail = false
     
  38.               exit function
     
  39.            end if
     
  40.         next
     
  41.         if InStr(names(1), ".") <= 0 then
     
  42.            IsValidEmail = false
     
  43.            exit function
     
  44.         end if
     
  45.         i = Len(names(1)) - InStrRev(names(1), ".")
     
  46.         if i <> 2 and i <> 3 then
     
  47.            IsValidEmail = false
     
  48.            exit function
     
  49.         end if
     
  50.         if InStr(email, "..") > 0 then
     
  51.            IsValidEmail = false
     
  52.         end if
     
  53. end function
以下第4和第5点只针对留言插件.
4.打开Plugins/GuestBook/bookaction.asp,找到
  1.   post_Message=request.form("Message")
在其下插入
  1. dim email,siteurl
     
  2.   email=trim(CheckStr(request.form("email")))
     
  3.   siteurl=trim(CheckStr(request.form("siteurl")))
找到
  1.   if filterSpam(post_Message,"../../spam.xml") and stat_Admin=0 then
     
  2.       showmsg "留言发表错误信息","<b>留言中包含被屏蔽的字符</b>
     
  3. <a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
     
  4.       exit function
     
  5.   end if
在其上插入一行,加以下代码
  1.         if memName=empty and email<>"" and IsValidEmail(email)=false then
     
  2.                 showmsg "留言发表错误信息","<b>邮箱格式错误</b>
     
  3. <a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
     
  4.                 exit function
     
  5.         end if
     

  6.  
  7.         if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
     
  8.                   showmsg "留言发表错误信息","<b>网址格式错误</b>
     
  9. <a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
     
  10.                   exit function
     
  11.         end if
找到
  1. Conn.ExeCute("Insert INTO blog_book(book_Messager,book_face,book_IP,book_Content,book_HiddenReply,email,siteurl) VALUES ('"&username&"','"&face&"','"&getIP()&"','"&post_Message&"',"&hiddenreply&")")
修改为:
  1. Conn.ExeCute("Insert INTO blog_book(book_Messager,book_face,book_IP,book_Content,book_HiddenReply,email,siteurl) VALUES ('"&username&"','"&face&"','"&getIP()&"','"&post_Message&"',"&hiddenreply&",'"&email&"','"&siteurl&"')")
5.打开Plugins/GuestBook/guestbook.asp,找到
  1.                         <a href="member.asp?action=view&memName=<%=Server.URLEncode(GuestDB("book_Messager"))%>"><b><%=GuestDB("book_Messager")%></b></a> <span class="commentinfo">
按回车,插入以下代码:
  1. <%
     
  2. if trim(GuestDB("email"))<>"" then
     
  3.         response.write " <a href=mailto:"&trim(GuestDB("email"))&" target=_blank><img src=images/email1.gif border=0></a>"
     
  4. else
     
  5.         response.write " <img src=images/noemail1.gif>"
     
  6. end if
     
  7. if trim(GuestDB("siteurl"))<>"" and trim(GuestDB("siteurl"))<>"http://" then
     
  8.         response.write " <a href="&trim(GuestDB("siteurl"))&" target=_blank><img src=images/url1.gif border=0></a>"
     
  9. else
     
  10.         response.write " <img src=images/nourl1.gif>"
     
  11. end if
     
  12. %>
找到
  1.                     <tr><td align="right" width="70"><strong>验证码:</strong></td><td align="left" style="padding:3px;"><input name="validate" type="text" size="4" class="userpass" maxlength="4"/> <%=getcode()%></td></tr>
在上面插入以下代码
  1.                           <%if memName=empty then%><tr><td align="right" width="70"><strong>邮 箱:</strong></td><td align="left" style="padding:3px;"><input name="email" type="text" size="18" class="userpass" maxlength="24"/> 请填写您的邮箱.</td></tr><%end if%>
     
  2.                           <%if memName=empty then%><tr><td align="right" width="70"><strong>网 址:</strong></td><td align="left" style="padding:3px;"><input name="siteurl" type="text" class="userpass" value="http://" size="18" maxlength="24"/> 请填写您的网址.</td></tr><%end if%>
此默认为EMAIL和网址为选填,如果要为必填,请将上面的
  1. if memName=empty and email<>"" and IsValidEmail(email)=false then
修改为
  1. if memName=empty and IsValidEmail(email)=false then
  1. if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
修改为
  1. if memName=empty and IsRightUrl(siteurl)=false then
题外话:以上修改默认为EMAIL和网址为选填,如果要为必填(可防止垃圾广告),请将上面的
  1. if memName=empty and email<>"" and IsValidEmail(email)=false then
修改为
  1. if memName=empty and IsValidEmail(email)=false then
  1. if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
修改为
  1. if memName=empty and IsRightUrl(siteurl)=false then

如果之前没加过评论留言加网址和邮箱功能,请下载附件,升级数据库,否则请跳过。

点击下载附件

OK,全文结束。如果是全静态,修改完成后到后台重新生成。

然后:单击自动输入验证码

改进步骤: 1、在common/ajax.js的最后面添加如下代码:

  1. function get(url,obj1,obj2)  
     
  2. {  
     
  3.         
     
  4.        var xmlhttp = CreateXMLHTTP();  
     
  5.      if(!xmlhttp)  
     
  6.        {  
     
  7.           alert("你的浏览器不支持XMLHTTP!!");  
     
  8.             return;  
     
  9.         }  
     
  10.       xmlhttp.onreadystatechange=requestdata;  
     
  11.         xmlhttp.open("GET",url,true);  
     
  12.       xmlhttp.send(null);  
     
  13.         function requestdata()  
     
  14.      {  
     
  15.             
     
  16.                fopen(obj1);  
     
  17.                echo(obj1,"<img src='images/loading.gif'>");  
     
  18.              if(xmlhttp.readyState==4)  
     
  19.               {  
     
  20.                   if(xmlhttp.status==200)  
     
  21.                     {  
     
  22.                       if(obj1!=obj2){fclose(obj1);};  
     
  23.                      $(obj2).value = xmlhttp.responseText;  
     
  24.                         
     
  25.                    }  
     
  26.               }  
     
  27.             
     
  28.        }  
     
  29. }  

2、在根目录下的Action.asp中找到

  1. If request.QueryString("action") = "checkAlias" then  

替换为

  1. '-------------- [code] -----------------  
     
  2. If request.QueryString("action") = "code" Then  
     
  3.     If ChkPost() Then  
     
  4.       Dim code  
     
  5.        code = Session("GetCode")  
     
  6.       Response.Write code  
     
  7.     End If  
     
  8. '-------------- [Alias] -----------------  
     
  9. ElseIf request.QueryString("action") = "checkAlias" then  

3、更改模板文件:在template/static.htm中找到

  1. <input name="validate" type="text" size="4" class="userpass" maxlength="4" onfocus="this.select()"/>  
     
  2.                  <img id="vcodeImg" src="about:blank" onerror="this.onerror=null;this.src='common/getcode.asp?s='+Math.random();" alt="验证码" title="看不清楚?点击刷新验证码!" style="margin-right:40px;cursor:pointer;width:40px;height:18px;margin-bottom:-4px;margin-top:3px;" onclick="src='common/getcode.asp?s='+Math.random()"/>  

替换为

  1. <input id="validate" name="validate" type="text" size="4" class="userpass" maxlength="4" onfocus="this.select()" onclick="get('action.asp?action=code','c','validate')" />   
     
  2.                   <img id="vcodeImg" src="about:blank" onerror="this.onerror=null;this.src='common/getcode.asp?s='+Math.random();" alt="验证码" title="看不清楚?点击刷新验证码!" style="margin-right:40px;cursor:pointer;width:40px;height:18px;margin-bottom:-4px;margin-top:3px;" onclick="src='common/getcode.asp?s='+Math.random()"/><span id="c">提示:单击验证码</span>  

如果你使用的是动态或者半静态模式,那么你需要在class/cls_article.asp中将上面的代码替换为

  1. <input id="validate" name="validate" type="text" size="4" class="userpass" maxlength="4" onfocus="this.select()" onclick="get('action.asp?action=code','c','validate')" /> <%=getcode()%><span id="c">提示:单击验证码</span>  

至此,修改完毕了。

最后:记住访客信息

在blogcomm.asp 中 Response.Cookies(CookieName)("memLastpost") = Now() 一句下方增加:

    '将评论者资料写入cookies
    Response.Cookies("VisitorName")=username
    Response.Cookies("VisitorEmail")=email
    Response.Cookies("VisitorWeb")=tsiteurl

在class/cls_article.asp 中 昵称/电邮/网址三个表单项文本框代码中把原默认value代码替换为:

  value="<%response.write (request.cookies("VisitorName"))%>"/>
  value="<%response.write (request.cookies("VisitorEmail"))%>"/>
  value="<%response.write (request.cookies("VisitorWeb"))%>"/> 
目前本博客已经升级了这两个代码模块。

您只要评论之后,系统就会通过cookies记住您在本站评论时留下的昵称、Email和网址了。

下次想要说些什么,直接输入您想说的就OK了。

 按上面的步骤做就可以了 做之前做好备份哦。。呵呵! 危险 勿进~~

Tags: pjblog  评论留言  邮箱网址  访客信息  
引用通告: 点击获取引用地址
相关文章:
评论: 26 | 引用: 0 | 浏览:
一米 [2009-11-14 12:51:39] [回复该留言]
好长的代码啊,我先试试。不过最好将它放在密码下面,感觉更好。
[reply=老七,2009-11-14 01:35 PM]真的嘛?[/reply]
小白 [2009-11-15 3:29:56] [回复该留言]
代码的确长
TONY [2009-11-15 5:02:44] [回复该留言]
呵呵 回访!我也弄上这个功能使用一下
先看看 [2009-11-15 5:45:41] [回复该留言]
代码挺多的,能把邮箱网址放在昵称下面吗
[reply=老七,2009-11-15 06:17 AM]好的[/reply]
开心凡人 [2009-11-15 5:51:47] [回复该留言]
好多要改的地方啊
不死鸟 [2009-11-15 6:11:14] [回复该留言]
代码,菜鸟一个。不过,你反其道而行,别人都把评论放在email, web下面,有点不习惯,呵呵
北北 [2009-11-15 6:49:18] [回复该留言]
高手[face41]
本来开始我也想用PJBLOG了,可是我的ASP主机快到期了,正好又买了新的PHP主机,所以就用WP了。

还有自动添加验证码不错哦。
北北 [2009-11-15 6:50:52] [回复该留言]
不过这样你的网站会有点卡啊。
[reply=老七,2009-11-15 07:03 AM]额。不是吧。[/reply]
在路上 [2009-11-15 6:58:59] [回复该留言]
厉害!牛人一个!
hslx111 [2009-11-15 7:02:50] [回复该留言]
为什么我发评论说该用户已存在,发表评论失败...
[reply=老七,2009-11-15 07:07 AM]能说清楚点嘛 我好解决?[/reply]
javik [2009-11-15 8:21:19] [回复该留言]
我来了哦 !
idying.cn [2009-11-15 11:41:24] [回复该留言]
code.google.com/p/pjblog/source/detail?r=254
你可以查考这里哦。
彭涛雅阁 [2009-11-16 0:10:54] [回复该留言]
这样就舒服多了 ~~~~赞一个
彭涛雅阁 [2009-11-16 0:14:22] [回复该留言]
不过有一点貌似做的不好呀
那个昵称的超链接应该链接到网站上去,不是用户信息……
老七 ,这个还得改~~~
TONY [2009-11-16 3:54:38] [回复该留言]
汗 没弄成功
[reply=老七,2009-11-16 03:56 AM]怎么?[/reply]
TONY [2009-11-16 4:02:53] [回复该留言]
数据库升级了,可能是修改文件的时候有错误吧!能不能直接把你修改的文件给我发过来!我很懒!dashan714@126.com
TONY [2009-11-16 5:25:22] [回复该留言]
晕 不知道为什么又出错!不弄了……
集团电话 [2009-11-16 7:46:18] [回复该留言]
妈妈呀,貌似好麻烦呀
星光居士 [2009-11-16 9:07:43] [回复该留言]
好啊好啊,马上试试!
某曦 [2009-11-16 9:33:31] [回复该留言]
终于有访问记录功能了
摩凝 [2009-11-16 13:37:26] [回复该留言]
PJ的用户体验的确很差!
左岸读书 [2009-11-18 12:07:30] [回复该留言]
pj就是要不断的改造~
海天无影 [2009-11-21 2:01:45] [回复该留言]
你说的是哪个记住我啊?
海天无影 [2009-11-21 7:53:14] [回复该留言]
我们的版本可能不一样,因为最后一个正式版我没升级
我是照的戒聊的老版改的 和新版本不一样
但你这个可能就COOKIE不行 因为貌似浏览器不关 在其他页面 还是有的啊~
彩票论坛 [2010-1-21 15:19:51] [回复该留言]
好东西。。
木本无心 [2010-6-1 10:28:35] [回复该留言]
测试下!
昵 称:
邮 箱:
网 站:
内 容:
   
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。