修正关键字替换显示错误的BUG并增加关键字前的标示图片
作者:小戒 日期:2008-08-28
话外音:一般在编辑代码时,请尽量不要用记事本。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
%>
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=""/>
<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>
<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"> </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>
<tr align="center">
<td width="16" nowrap="nowrap" class="TDHead"> </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
RedirectUrl("ConContent.asp?Fmenu=smilies&Smenu=KeyWord")
Else
到
复制内容到剪贴板
程序代码
程序代码 Keywords(2)
session(CookieName&"_ShowMsg") = True
session(CookieName&"_MsgText") = session(CookieName&"_MsgText")&"关键字保存成功!"
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 | 查看次数: -
现在好了。。。。。方法能提供吗? 我不会加在左边 我想加在文章左边
小戒 于 [2008-08-29 02:17 PM] 回复
打开STATIC.HTM,找到:
在下面插入:
然后在你的CSS文件中插入:
复制内容到剪贴板
程序代码
程序代码 <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>
<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;}
#aditem_paper01{clear: left;float: left;height: auto;width: auto;}
视觉工人博客用了这个修改方法后也解决了问题!谢谢!!
http://www.wjzxy.cn/blog
http://www.wjzxy.cn/blog
解决了!谢谢!!
还有我想问你一下,你的广告挡住了文章文字,你为什么不修复呢。我只会把广告放在文章的上面或者下面 ,不会放在文章左边,不知道能不能把方法做个文章出来
小戒 于 [2008-08-29 00:51 AM] 回复
呃。。。不好意思。我用的IE6,一直是正常状态,最近才有朋友说用FIREFOX和IE7,问题严重。现在如何了?谢谢。
已经解决 谢谢了 哈哈
不错,但是好多字都被你的广告盖住了看不见啊。。。。还有为什么我升级到157以后发表的文章页面的GG广告全部都不显示了,,,而157以前版本发布的文章却显示,,,,但是看你的好像每这个问题,,能指点一二吗?
小戒 于 [2008-08-28 09:09 PM] 回复
后台更新缓存,重新生成一下。
发表评论
上一篇
下一篇

文章来自:
Tags:
回复

后祝中秋节快乐,全家幸福安康平安!