评论留言加上邮箱和网址

作者:戒聊
发布网站:www.muzili.com
类型:本站原创

1.下载压缩包,解压后上传至PJBLOG所在目录,执行升级数据库.
2.打开class下的cls_article.asp,找到
       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

修改为:
       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


找到
<%=blog_CommAuthor%></strong></a> <span class="commentinfo">
,按回车,在下面插入以下代码.
<%
if trim(commArr(10,Pcount))<>"" then
    response.write " <a href=mailto:"&trim(commArr(10,Pcount))&" target=_blank><img src=images/email1.gif border=0></a>"
else
    response.write " <img src=images/noemail1.gif>"
end if

if trim(commArr(11,Pcount))<>"" and trim(commArr(11,Pcount))<>"http://" then
    response.write " <a href="&trim(commArr(11,Pcount))&" target=_blank><img src=images/url1.gif border=0></a>"
else
    response.write " <img src=images/nourl1.gif>"
end if
%>



找到
      <%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%>

在其上插入一行,加入以下代码
      <%if memName=empty then%><tr><td align="right" width="70"><strong>邮 箱:</strong></td><td align="left" style="padding:3px;"><input name="myblogemail" type="text" size="18" class="userpass" maxlength="24"/> 请填写您的邮箱.</td></tr><%end if%>
      <%if memName=empty then%><tr><td align="right" width="70"><strong>网 址:</strong></td><td align="left" style="padding:3px;"><input name="myblogsiteurl" type="text" class="userpass" value="http://" size="18" maxlength="24"/> 请填写您的网址.</td></tr><%end if%>


3.打开PJBLOG根目录下的blogcomm.asp,找到
  password=trim(CheckStr(request.form("myblogpassword")))

在其下插入如下代码
dim email,siteurl
  email=trim(CheckStr(request.form("myblogemail")))
  siteurl=trim(CheckStr(request.form("myblogsiteurl")))


找到
  IF (memName=empty or blog_validate=true) and cstr(lcase(Session("GetCode")))<>cstr(lcase(validate)) then
      ReInfo(0)="评论发表错误信息"
      ReInfo(1)="<b>验证码有误,请返回重新输入</b><br/><a href=""javascript:history.go(-1);"">请返回重新输入</a>"
      ReInfo(2)="ErrorIcon"
      postcomm=ReInfo
      exit function
  end if


在其上插入如下代码
    if memName=empty and email<>"" and IsValidEmail(email)=false then
            ReInfo(0)="评论发表错误信息"
            ReInfo(1)="<b>邮箱格式错误</b><br/><a href=""javascript:history.go(-1);"">请返回重新输入</a>"
            ReInfo(2)="ErrorIcon"
            postcomm=ReInfo
            exit function
    end if

    if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
            ReInfo(0)="评论发表错误信息"
            ReInfo(1)="<b>网址格式错误</b><br/><a href=""javascript:history.go(-1);"">请返回重新输入</a>"
            ReInfo(2)="ErrorIcon"
            postcomm=ReInfo
            exit function
    end if


找到
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))


修改为:
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,在最后一个之前插入如下代码.
Function IsRightUrl(UrlStrng)  '网址判断
  Dim regEx, retVal
  Set regEx = New RegExp
  regEx.Pattern = "^https?:\/\/[\u4E00-\u9FA5a-zA-Z\.\/0-9]{3,}[\u4E00-\u9FA5a-zA-Z\/0-9]{2,}$"
  regEx.IgnoreCase = False
  retVal = regEx.Test(UrlStrng)


  If retVal Then
    IsRightUrl = true
  Else
    IsRightUrl = false
  End If
End Function

Public function IsValidEmail(email)  '邮箱判断
    dim names, name, i, c
    IsValidEmail = true
    names = Split(email, "@")
    if UBound(names) <> 1 then
       IsValidEmail = false
       exit function
    end if
    for each name in names
       if Len(name) <= 0 then
         IsValidEmail = false
         exit function
       end if
       for i = 1 to Len(name)
         c = Lcase(Mid(name, i, 1))
         if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
           IsValidEmail = false
           exit function
         end if
       next
       if Left(name, 1) = "." or Right(name, 1) = "." then
          IsValidEmail = false
          exit function
       end if
    next
    if InStr(names(1), ".") <= 0 then
       IsValidEmail = false
       exit function
    end if
    i = Len(names(1)) - InStrRev(names(1), ".")
    if i <> 2 and i <> 3 then
       IsValidEmail = false
       exit function
    end if
    if InStr(email, "..") > 0 then
       IsValidEmail = false
    end if
end function


以下第4和第5点只针对留言插件.
4.打开Plugins/GuestBook/bookaction.asp,找到
  post_Message=request.form("Message")
在其下插入
dim email,siteurl
  email=trim(CheckStr(request.form("myblogemail")))
  siteurl=trim(CheckStr(request.form("myblogsiteurl")))


找到
  if filterSpam(post_Message,"../../spam.xml") and stat_Admin=0 then
      showmsg "留言发表错误信息","<b>留言中包含被屏蔽的字符</b><br/><a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
      exit function
  end if


在其上插入一行,加以下代码
    if memName=empty and email<>"" and IsValidEmail(email)=false then
        showmsg "留言发表错误信息","<b>邮箱格式错误</b><br/><a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
        exit function
    end if

    if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
          showmsg "留言发表错误信息","<b>网址格式错误</b><br/><a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
          exit function
    end if


找到
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&")")


修改为:
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,找到
                    <a href="member.asp?action=view&memName=<%=Server.URLEncode(GuestDB("book_Messager"))%>"><b><%=GuestDB("book_Messager")%></b></a> <span class="commentinfo">
按回车,插入以下代码:
<%
if trim(GuestDB("email"))<>"" then
    response.write " <a href=mailto:"&trim(GuestDB("email"))&" target=_blank><img src=images/email1.gif border=0></a>"
else
    response.write " <img src=images/noemail1.gif>"
end if
if trim(GuestDB("siteurl"))<>"" and trim(GuestDB("siteurl"))<>"http://" then
    response.write " <a href="&trim(GuestDB("siteurl"))&" target=_blank><img src=images/url1.gif border=0></a>"
else
    response.write " <img src=images/nourl1.gif>"
end if
%>


找到
                <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>

在上面插入以下代码
              <%if memName=empty then%><tr><td align="right" width="70"><strong>邮 箱:</strong></td><td align="left" style="padding:3px;"><input name="myblogemail" type="text" size="18" class="userpass" maxlength="24"/> 请填写您的邮箱.</td></tr><%end if%>
              <%if memName=empty then%><tr><td align="right" width="70"><strong>网 址:</strong></td><td align="left" style="padding:3px;"><input name="myblogsiteurl" type="text" class="userpass" value="http://" size="18" maxlength="24"/> 请填写您的网址.</td></tr><%end if%>


此默认为EMAIL和网址为选填,如果要为必填,请将上面的
if memName=empty and email<>"" and IsValidEmail(email)=false then
修改为
if memName=empty and IsValidEmail(email)=false then
if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
修改为
if memName=empty and IsRightUrl(siteurl)=false then


下载文件 点击下载附件
OK,全文结束.

[本日志由 小戒 于 2008-05-27 05:25 AM 编辑]
上一篇: PJBLOG去掉最新評論及留言中ubb代碼的方法[本站原創]
下一篇: 留言评论邮件通知博主For pjblog2.6|2.7
文章来自:
引用通告: 查看所有引用 | 我要引用此文章
Tags: 评论 留言 PJBLOG
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
yong
回复回复yong[2008-11-14 02:57 PM | | | del]
谢谢,我想加上QQ怎么改
夢醒時分
回复回复夢醒時分[2008-03-21 03:36 AM | | | del]
测试看下效果
恋爱中的鱼
回复回复恋爱中的鱼[2008-03-04 05:14 PM | | | del]
我试下看看!
protect
回复回复protect[2008-02-22 08:01 AM | | | del]
你这个方法修改是必填吗?评论会出错。

Server ?ԏ󼯦ont> ?펳 'ASP 0178 : 80070005'

Server.CreateObject ?Îʴ펳

/common/function.asp??А 8

?첩ȨϞʱ???ԠServer.CreateObject ?ĵ???ܡ??ܾ??ԏ󵄷Îʡ?
Ollie
回复回复Ollie[2008-02-09 10:20 PM | | | del]
新版本pj blogcomm.asp代码部分修改了 行不通了哦
回复来自 小戒 的评论 小戒 于 09/02/2008 23:30:20 回复
没测试过新版本。呵呵。
tizza
回复回复tizza[2007-12-16 12:26 AM | | | del]
prefect! 支持
nextway.cn
回复回复nextway.cn[2007-12-10 07:41 PM | | | del]
你的皮肤在1024x768下严重错位。
www.nextway.cn
jogocun
回复回复jogocun[2007-12-08 07:53 PM | | | del]
这样不错了,可以把信箱和主页文字去掉保留图片即可了~

不写邮箱和网址会提示...格式错误啊~
jogocun
回复回复jogocun[2007-12-08 06:35 PM | | | del]
邮箱和网址不要是必须项的为好啊~
要不会给访客带来麻烦,有心的人自然会写这些~
jogocun
回复回复jogocun[2007-12-08 06:33 PM | | | del]
可以把邮箱和网址以带链接的图片显示出来,效果更佳~
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 支持Gravatar头像.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.