PJBLOG去掉最新評論及留言中ubb代碼的方法[本站原創]

在你的最新評論和留言中突然冒出來UBB代碼,不爽吧?
下面是修改方法:

一、打開plugins\guestbook\install.xml,如果沒裝留言插件,此步路過。
找到
NewMessage=NewMessage&"<a class=""sideA"" href=""LoadMod.asp?plugins=GuestBookForPJBlog#book_"&Message_Item(0)&""" title="""&Message_Item(1)&" 于 "&Message_Item(2)&" 发表留言"&CHR(10)&CCEncode(CutStr(Message_Item(3,25))&""">"&CCEncode(CutStr(Message_Item(3),25))&"</a>"


修改成:
NewMessage=NewMessage&"<a class=""sideA"" href=""LoadMod.asp?plugins=GuestBookForPJBlog#book_"&Message_Item(0)&""" title="""&Message_Item(1)&" 于 "&Message_Item(2)&" 发表留言"&CHR(10)&CCEncode(CutStr(UBBCode(Message_Item(3),1,0,0,0,0),25))&""">"&CCEncode(CutStr(UBBCode(Message_Item(3),1,0,0,0,0),25))&"</a>"


二、打開common\cache.asp
找到:
NewComment=NewComment&"<a class=""sideA"" href=""default.asp?id="&blog_Comment(1,i)&"#comm_"&blog_Comment(0,i)&""" title="""&blog_Comment(2,i)&" 于 "&blog_Comment(4,i)&" 发表评论"&CHR(10)&CCEncode(CutStr(DelQuote(blog_Comment(3,i)),100))&""">"&CCEncode(CutStr(DelQuote(blog_Comment(3,i)),25))&"</a>"


修改成:
NewComment=NewComment&"<a class=""sideA"" href=""default.asp?id="&blog_Comment(1,i)&"#comm_"&blog_Comment(0,i)&""" title="""&blog_Comment(2,i)&" 于 "&blog_Comment(4,i)&" 发表评论"&CHR(10)&CCEncode(CutStr(UBBCode(DelUbb(blog_Comment(3,i)),1,0,0,0,0),100))&""">"&CCEncode(CutStr(UBBCode(DelUbb(blog_Comment(3,i)),1,0,0,0,0),25))&"</a>"



二、打開common\ubbcode.asp
找到:(注意%>)
End Function
%>


在上面插入以下代碼(太多了,不想看,所以直接在後面加了代碼。在原代碼中修改也能出來。)
        IF DisSM=1 Then
            For Each log_Smilies IN Arr_Smilies
                log_SmiliesContent=Split(log_Smilies,"|")
                strContent=Replace(strContent,log_SmiliesContent(2),"")
            Next
        End IF
        UBBCode=strContent

        
三、打开common\function.asp
在最后的上面插入以下代码


'*************************************
'删除标签
'*************************************
Function DelUbb(strContent)
    If IsNull(strContent) Then Exit Function
    Dim re
    Set re=new RegExp
    re.IgnoreCase =True
    re.Global=True
    re.Pattern="\[quote\](.[^\]]*?)\[\/quote\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[quote=(.[^\]]*)\](.[^\]]*?)\[\/quote\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="(\[img\])(.[^\]]*)\[\/img\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[img=(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[img=(\d*|),(\d*|)\](.[^\]]*)\[\/img\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[img=(\d*|),(\d*|),(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])"
    strContent= re.Replace(strContent,"")
    re.Pattern="(\[mid\])(.[^\]]*)\[\/mid\]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[url=(.[^\]]*)\](.[^\[]*)\[\/url]"
    strContent= re.Replace(strContent,"$2")
    re.Pattern = "\[url](.[^\[]*)\[\/url]"
    strContent= re.Replace(strContent,"$1")
    re.Pattern = "\[ed2k=([^\r]*?)\]([^\r]*?)\[\/ed2k]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[ed2k]([^\r]*?)\[\/ed2k]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[email=(.[^\]]*)\](.[^\[]*)\[\/email]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[email](.[^\[]*)\[\/email]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[align=(\w{4,6})\]([^\r]*?)\[\/align\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[color=(#\w{3,10}|\w{3,10})\]([^\r]*?)\[\/color\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[size=(\d{1,2})\]([^\r]*?)\[\/size\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[font=([^\r]*?)\]([^\r]*?)\[\/font\]"
    strContent=re.Replace(strContent,"$2")
    re.Pattern="\[b\]([^\r]*?)\[\/b\]"
    strContent=re.Replace(strContent,"$1")
    re.Pattern="\[i\]([^\r]*?)\[\/i\]"
    strContent=re.Replace(strContent,"$1")
    re.Pattern="\[u\]([^\r]*?)\[\/u\]"
    strContent=re.Replace(strContent,"$1")
    re.Pattern="\[s\]([^\r]*?)\[\/s\]"
    strContent=re.Replace(strContent,"$1")
    re.Pattern="\[sup\]([^\r]*?)\[\/sup\]"
    strContent=re.Replace(strContent,"$1")
    re.Pattern="\[sub\]([^\r]*?)\[\/sub\]"
    strContent=re.Replace(strContent,"$1")
    re.Pattern="\[fly\]([^\r]*?)\[\/fly\]"
    strContent=re.Replace(strContent,"$1")
    re.Pattern = "\[down=(.[^\]]*)\](.[^\[]*)\[\/down]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[down\](.[^\[]*)\[\/down]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[mDown=(.[^\]]*)\](.[^\[]*)\[\/mDown]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[mDown\](.[^\[]*)\[\/mDown]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[code\](.*?)\[\/code\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[hidden\](.*?)\[\/hidden\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[hidden=(.[^\]]*)\](.*?)\[\/hidden\]"
    strContent= re.Replace(strContent,"")
    re.Pattern="\[html\](.*?)\[\/html\]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[reply=(.[^\]]*),(.[^\]]*)\](.*?)\[\/reply\]"
    strContent= re.Replace(strContent,"")
    re.Pattern = "\[reply=(.[^\]]*)\](.*?)\[\/reply\]"
    strContent= re.Replace(strContent,"")
    Set re=Nothing
    DelUbb=strContent
End Function


OK了。備份文件,上傳到服務器,後台,修複插件。

[本日志由 小戒 于 2009-02-28 06:50 PM 编辑]
上一篇: 网站开发之按钮onclick大全
下一篇: 评论留言加上邮箱和网址
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: PJBLOG 原创
相关日志:
评论: 2 | 引用: 0 | 查看次数: -
tkdhaoren
回复回复tkdhaoren[2009-07-03 09:13 AM | | | del]
用一下
纯属路过
回复回复纯属路过[2009-05-24 04:01 PM | | | del]
纯属路过,呵呵!
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 支持Gravatar头像.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.