修正关键字替换显示错误的BUG并增加关键字前的标示图片

特别提醒,之所以不弄补丁,是因为此方法修改后,如果日志比较多的话,全静态下生成日志时可能会非常缓慢,所以请做选择性修改。可能是由于此方法不对,望高人指出。

话外音:一般在编辑代码时,请尽量不要用记事本。Dreamweaver或者Editplus是很不错的选择。

本BLOG上通过。

修改方法:
1、打开COMMON\UBBCODE.ASP,找到:
        '-----------关键词识别----------------

从此行到本文档最后的代码,全部替换为:
        '-----------关键词识别----------------
        If AutoKEY = 1 Then
            Dim log_Keywords, log_KeywordsContent
            For Each log_Keywords IN Arr_Keywords
                log_KeywordsContent = Split(log_Keywords, "$|$")
                strContent = startReplace(strContent,log_KeywordsContent(1),log_KeywordsContent(2),log_KeywordsContent(3))
            Next
        End If
        Set re = Nothing
        UBBCode = strContent
    End If
End Function

Function AddToDic(reg,key,Index,str,dic)
    Set reg=new RegExp
    reg.Global=True
    reg.IgnoreCase=True
    Dim pattern,matches,m,ky
    pattern="<a(.*?)>(.*?)</a>|\<[^>]*\>"
    reg.Pattern=pattern
    Set matches=reg.Execute(str)
    For Each m In matches
        dic.Add "key"&Index,m.value    
        str=replace(str,m.value,"$key"&Index&"$")
        Index=Index+1
    Next
    Set matches=Nothing
End Function

Function startReplace(str,KeywordsContent,KeywordsUrl,KeywordsImg)
    Dim TempStr:TempStr=str
    Dim dic'字典
    Set dic=server.CreateObject("scripting.dictionary")
    Dim Index:Index=0
    Dim reg
    Set reg=new RegExp
    reg.Global=True
    reg.IgnoreCase=True
    Dim pattern,matches,m,ky
    ky=KeywordsContent
    AddToDic reg,ky,Index,TempStr,dic
    If KeywordsImg<>"" Then
        TempStr=replace(TempStr,ky,"<a href='"&KeywordsUrl&"'>"&ky&"</a>")
    Else
        TempStr=replace(TempStr,ky,"<img src='"&KeywordsImg&"'><a href='"&KeywordsUrl&"'>"&ky&"</a>")
    End If
    AddToDic reg,ky,Index,TempStr,dic
    Set reg=Nothing
    Dim i
    For i=0 To Index-1
        TempStr=replace(TempStr,"$key"&i&"$",dic.Item("key"&i))
    Next
    Set dic=Nothing
    startReplace=TempStr
End Function

%>


在后台生成时可能会出现超时的错误,打开const.asp,找到
Server.ScriptTimeOut = 90

把90适当地改成更大值,比如900甚至9000。
注意:此时在出错后,不要关闭后台,先更新缓存,否则前台会打不开。

增加关键字标示图片:
打开control\c_smilies.asp,找到如下代码
           <form action="ConContent.asp" method="post" style="margin:0px">
           <input type="hidden" name="action" value="smilies"/>
           <input type="hidden" name="whatdo" value="KeyWord"/>
           <input type="hidden" name="DelID" value=""/>

到:
     <div class="SubButton" style="text-align:left;">
                   <select name="doModule">
                     <option value="SaveAll">保存所有关键字</option>
                     <option value="DelSelect">删除所选关键字</option>

之间的代码,全部替换为:
<table border="0" cellpadding="2" cellspacing="1" class="TablePanel">
                <tr align="center">
                  <td width="16" nowrap="nowrap" class="TDHead">&nbsp;</td>
                  <td width="120" nowrap="nowrap" class="TDHead">关键字</td>
                  <td width="220" nowrap="nowrap" class="TDHead">关键字链接地址</td>
                  <td width="220" nowrap="nowrap" class="TDHead">关键字前图片地址</td>
                </tr>
               <%
        Dim bKeyWord
        Set bKeyWord = conn.Execute("select * from blog_Keywords order by key_ID desc")
        Do Until bKeyWord.EOF
        
        %>
                <tr align="center">
                  <td><input name="SelectKeyWordID" type="checkbox" value="<%=bKeyWord("key_ID")%>"/></td>
                  <td><input name="KeyWordID" type="hidden" value="<%=bKeyWord("key_ID")%>"/><input name="KeyWord" type="text" size="18" class="text" value="<%=bKeyWord("key_Text")%>"/></td>
                  <td><input name="KeyWordURL" type="text" size="34" class="text" value="<%=bKeyWord("key_URL")%>"/></td>
                  <td><input name="key_Image" type="text" class="text" id="key_Image" value="<%=bKeyWord("key_Image")%>" size="34"/></td>
                </tr>
               <%
        bKeyWord.movenext
        Loop
        
        %>
               <tr align="center" bgcolor="#D5DAE0">
                <td colspan="4" class="TDHead" align="left" style="border-top:1px solid #9EA9C5"><a name="AddLink"></a><img src="images/add.gif" style="margin:0px 2px -3px 2px"/>添加新关键字</td>
               </tr>    
                <tr align="center">
                  <td></td>
                  <td><input name="KeyWordID" type="hidden" value="-1"/><input name="KeyWord" type="text" size="18" class="text"/></td>
                  <td><input name="KeyWordURL" type="text" size="34" class="text"/></td>
                  <td><input name="key_Image" type="text" class="text" id="key_Image" size="34"/></td>
                </tr>
             </table>



打开control\action.asp,找到
            session(CookieName&"_MsgText") = session(CookieName&"_MsgText")&(UBound(KeyWordID) + 1)&"关键字被删除!"
            RedirectUrl("ConContent.asp?Fmenu=smilies&Smenu=KeyWord")
        Else


            Keywords(2)
            session(CookieName&"_ShowMsg") = True
            session(CookieName&"_MsgText") = session(CookieName&"_MsgText")&"关键字保存成功!"

之间的代码,全部替换为:

            Dim key_Image
            KeyWordID = Split(Request.Form("KeyWordID"), ", ")
            KeyWord = Split(Request.Form("KeyWord"), ", ")
            KeyWordURL = Split(Request.Form("KeyWordURL"), ", ")
            key_Image = Split(Request.Form("key_Image"), ", ")
            For i = 0 To UBound(KeyWordID)
                If Int(KeyWordID(i))<> -1 Then
                    conn.Execute("update blog_Keywords set key_Text='"&CheckStr(KeyWord(i))&"',key_URL='"&CheckStr(KeyWordURL(i))&"',key_Image='"&CheckStr(key_Image(i))&"' where key_ID="&KeyWordID(i))
                Else
                    If Len(Trim(CheckStr(KeyWord(i))))>0 Then
                        conn.Execute("insert into blog_Keywords (key_Text,key_URL,key_Image) values ('"&CheckStr(KeyWord(i))&"','"&CheckStr(KeyWordURL(i))&"','"&CheckStr(key_Image(i))&"')")
                        session(CookieName&"_MsgText") = "新关键字添加成功! "
                    End If
                End If
            Next


结束。请注意备份。

评论: 7 | 引用: 0 | 查看次数: -
mini
回复回复mini[2008-09-13 06:34 PM | | | del]
想问一下,像这样修改后,对于我已经用标签代替关键字的,有什么区别呢? 我不太明白。。

后祝中秋节快乐,全家幸福安康平安!
回复来自 小戒 的评论 小戒 于 2008-09-14 09:31 AM 回复
谢谢,中秋快乐。不好意思,我没明白你说的用标签代替关键字是什么意思。
残阳博客
回复回复残阳博客[2008-08-29 09:20 AM | | | del]
现在好了。。。。。方法能提供吗? 我不会加在左边  我想加在文章左边
回复来自 小戒 的评论 小戒 于 2008-08-29 02:17 PM 回复
打开STATIC.HTM,找到:
                <div id="logPanel" class="Content-body">

在下面插入:
<div id="paper02"></div>
<div id="aditem_paper01">
<script type="text/javascript"><!--
google_ad_client = "pub-6347887448711969";
/* muzili.com文章页 */
google_ad_slot = "1157673251";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>


然后在你的CSS文件中插入:
#paper02{clear: left;float: left;height: 10px;width: 1px;}
#aditem_paper01{clear: left;float: left;height: auto;width: auto;}
瑾煜
回复回复瑾煜[2008-08-29 04:10 AM | | | del]
视觉工人博客用了这个修改方法后也解决了问题!谢谢!!
http://www.wjzxy.cn/blog
瑾煜
回复回复瑾煜[2008-08-29 03:55 AM | | | del]
解决了!谢谢!!
残阳博客
回复回复残阳博客[2008-08-28 09:59 PM | | | del]
还有我想问你一下,你的广告挡住了文章文字,你为什么不修复呢。我只会把广告放在文章的上面或者下面 ,不会放在文章左边,不知道能不能把方法做个文章出来
回复来自 小戒 的评论 小戒 于 2008-08-29 00:51 AM 回复
呃。。。不好意思。我用的IE6,一直是正常状态,最近才有朋友说用FIREFOX和IE7,问题严重。现在如何了?谢谢。
残阳博客
回复回复残阳博客[2008-08-28 09:57 PM | | | del]
已经解决 谢谢了  哈哈
残阳博客
回复回复残阳博客[2008-08-28 08:39 PM | | | del]
不错,但是好多字都被你的广告盖住了看不见啊。。。。还有为什么我升级到157以后发表的文章页面的GG广告全部都不显示了,,,而157以前版本发布的文章却显示,,,,但是看你的好像每这个问题,,能指点一二吗?
回复来自 小戒 的评论 小戒 于 2008-08-28 09:09 PM 回复
后台更新缓存,重新生成一下。
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 支持Gravatar头像.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.