<?xml version="1.0" encoding="ISO-8859-1"?>
<keywords>
<!-- Start Keywords -->
<key>
<phrase>xml</phrase>
<url>http://some/site.xml</url>
</key>
<key>
<phrase>html</phrase>
<url>http://some/site.html</url>
</key>
<b><font color="red"><key>
<phrase>css</phrase>
<url>http://some/site.css</url>
</key></font id="red"></b>
</keywords>function FormatStr(fString)
on Error resume next fString = ChkKeys(fString)Function ChkKeys(fString)
dim strKeys,strReplace,keywords,keyreplace,objRegex
'file check
if ShowKeyWords = False then
ChkKeys = fString
Exit Function
end if
if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
end if
strKeys = Application(strCookieURL & "STRKEYWORDS")
strReplace = Application(strCookieURL & "STRKEYREPLACE")
if fString = "" or IsNull(fString) then fString = " "
keywords = split(strKeys, ",")
keyreplace = split(strReplace, ",")
set objRegex = new RegExp
objRegex.ignorecase = true
objRegex.global = true
for i = 0 to ubound(keywords)
strPattern = "^(" & keywords(i) & ")(\s)"
strReplace = keyreplace(i) & "$2"
objRegex.pattern= strPattern
fString = objRegex.replace(fString,strReplace)
strPattern = "(" & keywords(i) & ")$"
strReplace = keyreplace(i)
objRegex.pattern= strPattern
fString = objRegex.replace(fString,strReplace)
fString = Replace(fString, " " & keywords(i) & " ", " " & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ",", " " & keyreplace(i) & ",", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ".", " " & keyreplace(i) & ".", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ":", " " & keyreplace(i) & ":", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ";", " " & keyreplace(i) & ";", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "!", " " & keyreplace(i) & "!", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "?", " " & keyreplace(i) & "?", 1, -1, 1)
fString = Replace(fString, "-" & keywords(i) & "-", "-" & keyreplace(i) & "-", 1, -1, 1)
fString = Replace(fString, "-" & keywords(i) & " ", "-" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "-", " " & keyreplace(i) & "-", 1, -1, 1)
fString = Replace(fString, "_" & keywords(i) & "_", "_" & keyreplace(i) & "_", 1, -1, 1)
fString = Replace(fString, "_" & keywords(i) & " ", "_" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "_", " " & keyreplace(i) & "_", 1, -1, 1)
fString = Replace(fString, "'" & keywords(i) & "'", "'" & keyreplace(i) & "'", 1, -1, 1)
fString = Replace(fString, "'" & keywords(i) & " ", "'" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "'", " " & keyreplace(i) & "'", 1, -1, 1)
fString = Replace(fString, """" & keywords(i) & """", """" & keyreplace(i) & """", 1, -1, 1)
fString = Replace(fString, """" & keywords(i) & " ", """" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & """", " " & keyreplace(i) & """", 1, -1, 1)
fString = Replace(fString, "(" & keywords(i) & ")", "(" & keyreplace(i) & ")", 1, -1, 1)
fString = Replace(fString, "(" & keywords(i) & " ", "(" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ")", " " & keyreplace(i) & ")", 1, -1, 1)
fString = Replace(fString, "[" & keywords(i) & "]", "[" & keyreplace(i) & "]", 1, -1, 1)
fString = Replace(fString, "[" & keywords(i) & " ", "[" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "]", " " & keyreplace(i) & "]", 1, -1, 1)
'This line needs repeated parsing misses every other word when a word is repeated
fString = Replace(fString, " " & keywords(i) & " ", " " & keyreplace(i) & " ", 1, -1, 1)
'scenario - first word in line
fString = Replace(fString, chr(13) & chr(10) & keywords(i) & " ", chr(13) & chr(10) & keyreplace(i) & " ", 1, -1, 1)
'scenario - last word in line
fString = Replace(fString, " " & keywords(i) & chr(13) & chr(10), " " & keyreplace(i) & chr(13) & chr(10), 1, -1, 1)
'scenarion - first and only word in line
fString = Replace(fString, chr(13) & chr(10) & keywords(i) & chr(13) & chr(10), chr(13) & chr(10) & keyreplace(i) & chr(13) & chr(10), 1, -1, 1)
'scenario - first word in line followed by a character
fString = Replace(fString, chr(10) & keywords(i) & ".", chr(10) & keyreplace(i) & ".", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ",", chr(10) & keyreplace(i) & ",", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & "?", chr(10) & keyreplace(i) & "?", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & "!", chr(10) & keyreplace(i) & "!", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ":", chr(10) & keyreplace(i) & ":", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ";", chr(10) & keyreplace(i) & ";", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & """", chr(10) & keyreplace(i) & """", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & "'", chr(10) & keyreplace(i) & "'", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ")", chr(10) & keyreplace(i) & ")", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & "]", chr(10) & keyreplace(i) & "]", 1, -1, 1)
next
set objRegex = nothing
ChkKeys = fString
End Function
Sub LoadKeywordApps()
dim strPath,xmlDoc,strErr,NumOfKeys,strKeys,strReplace,iKey
strPath = "<b><font color="green">Absolute address of your Xml file</font id="green"></b>"
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDOc.setProperty "ServerHTTPRequest", true
xmlDoc.load(strPath)
if xmlDoc.parseError.errorCode <> 0 Then
strErr = "<div><b>" & vbNewLine & _
"<ul>" & vbNewLine & _
"<li>ERROR!</li>" & vbNewLine & _
"<li>XML File " & strFileName & " - Failed to validate.</li>" & vbNewLine & _
"<li>" & xmlDoc.parseError.reason & "</li>" & vbNewLine & _
"<li>Error code: " & xmlDoc.parseError.errorCode & "</li>" & vbNewLine & _
"<li>Line: " & xmlDoc.parseError.line & "</li>" & vbNewLine & _
"<li>Character: " & xmlDoc.parseError.linepos & "</li>" & vbNewLine & _
"<li>Source: " & Chr(34) & xmlDoc.parseError.srcText & Chr(34) & "</li>" & vbNewLine & _
"<li>" & Now & "</li>" & vbNewLine & _
"</ul>" & vbNewLine & _
"</b></div>" & vbNewLine
Response.Write strErr
Response.End
end if
set xmlKeyList = xmlDoc.getElementsByTagName("key")
NumOfKeys = ((xmlKeyList.length) - 1) '0 based
strKeys = ""
strReplace = ""
for iKey = 0 to cLng(NumOfKeys)
if strKeys = "" then
strKeys = xmlKeyList.item(iKey).childNodes(0).text
strReplace = "<a <b><font color="red">id=""keywords""</font id="red"></b> href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
else
strKeys = strKeys & "," & xmlKeyList.item(iKey).childNodes(0).text
strReplace = strReplace & ", <a <b><font color="red">id=""keywords""</font id="red"></b> href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
end if
next
set xmlDoc = nothing
Application.Lock
Application(strCookieURL & "STRKEYWORDS") = strKeys
Application(strCookieURL & "STRKEYREPLACE") = strReplace
Application.UnLock
End Sub
Dim ShowKeyWords : ShowKeyWords = True%>
<!--#INCLUDE FILE="config.asp"-->
<%
<font color="red">Dim ShowKeyWords : ShowKeyWords = True</font id="red">
".spnSearchHighlight {background-color:" & strSearchHiLiteColor & "}" & vbNewLine & _"#keywords{color:yellow;font-weight:bold;background-color:yellow;)" & vbNewLine & _
I tried it again but this time I added a <% above the code and the %> below the code.What code did you add that too?<
Originally posted by leatherlipsNothing jumps out as being wrong... but something is causing the XML parser some heartburn. I wonder if its a problem with the version of the XML parser you're using.<
Here is my xml file:
http://www.mangionemagic.com/forumfortesting/autolinkterms.xml
I only added a few keywords while testing.
xmlDoc.async="false"xmlDoc.setProperty "ServerHTTPRequest", true 'if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
'end ifOriginally posted by bobby131313No
Do the 2 variables need to be dimmed in config.asp?
Application.Lock
Application(strCookieURL & "STRKEYWORDS") = ""
Application(strCookieURL & "STRKEYREPLACE") = ""
Application.UnLockleatherlips, this is the solution ms support gives for that error.cripto9t,
After this line in LoadKeywordApps()
xmlDoc.async="false"
Add this line
xmlDoc.setProperty "ServerHTTPRequest", true
Hope that helps
strReplace = "<span class=""keywords""><a href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"strReplace = strReplace & ", <span class=""keywords""><a href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"Originally posted by bobby131313Yea I added ten keywords to a description and it worked allright. Maybe a parsing error because it looks like it just quit right there and jumped to the next cell.
I would rather have it not work on default.asp at all.
Now I just started over from scratch and that error is not happening now. So I guess it was my error somehow.![]()
for iKey = 0 to cLng(NumOfKeys)
if strKeys = "" then
strKeys = xmlKeyList.item(iKey).childNodes(0).text
strReplace = "<a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
else
strKeys = strKeys & "," & xmlKeyList.item(iKey).childNodes(0).text
strReplace = strReplace & ", <a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
end if
next
#keywords {color: #336633; text-decoration:underline; font-weight:bold}
#keywords:hover {color: #FF0000}
Function ChkKeys(fString)
dim strKeys,strReplace,keywords,keyreplaceFunction ChkKeys(fString)
dim strFiles,iCnt,strKeys,strReplace,keywords,keyreplace
strFiles = array("admin_","default","forum","profile","active","register","members","search","faq")
for iCnt = 0 to Ubound(strFiles)
if Instr(lcase(strScriptName),strFiles(iCnt)) > 0 then
ChkKeys = fString
Exit Function
end if
next
".keywords a {color:yellow;font-weight:bold;background-color:yellow;)" & vbNewLine & _
"#keywords {color:yellow;font-weight:bold;background-color:yellow;}" & vbNewLine & _
Originally posted by bobby131313Aaah yea that would help to
Also need to change...Code:to...".keywords a {color:yellow;font-weight:bold;background-color:yellow;)" & vbNewLine & _Code:"#keywords {color:yellow;font-weight:bold;background-color:yellow;}" & vbNewLine & _
Are your topics still being blocked?Yeah, yours are working?<
strScriptName = request.servervariables("script_name") fString = Replace(fString,keywords(i),keyreplace(i), 1, -1, 1) fString = Replace(fString, " " & keywords(i) & " ", " " & keyreplace(i) & " ", 1, -1, 1) Add this line right after that
"#keywords a {color:yellow;font-weight:bold;background-color:yellow;)" & vbNewLine & _
function FormatStr(fString)
on Error resume next
fString = ChkKeys(fString)Dim ShowKeyWords : ShowKeyWords = True%>
<!--#INCLUDE FILE="config.asp"-->
<%
Dim ShowKeyWords : ShowKeyWords = TrueAlso, I'm wonder if the target frame could be set in the xml file when you specify the url for the phrase?Thats a good idea and I think I have a good idea on how to do it
Originally posted by leatherlips
I tried removing the part in red from both lines that have it but they still open in a new window:
strReplace = "<a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
Am I removing the correct section of code?
'if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
'end ifOriginally posted by weeweeslapYou typed the wrong phrase.
hmm I logge din and made some sample posts and see the results, neither worked and I didn't do any tricks!
for iKey = 0 to cLng(NumOfKeys)
if strKeys = "" then
strKeys = xmlKeyList.item(iKey).childNodes(0).text
strDiv = xmlKeyList.item(iKey).childNodes(1).text
if left(strDiv,4)<> "http" and left(strDiv,3) <> "ftp" then
strReplace = "<a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""_self"">"
else
strReplace = "<a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""_blank"">"
end if
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
else
strKeys = strKeys & "," & xmlKeyList.item(iKey).childNodes(0).text
strDiv = xmlKeyList.item(iKey).childNodes(1).text
strDiz = xmlKeyList.item(iKey).childNodes(0).text
if left(strDiv,4)= "http" or left(strDiv,3) = "ftp" then
strReplace = strReplace & ", <a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""_blank"">"
else
strReplace = strReplace & ", <a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""_self"">"
end if
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
end if
next
I noticed that it changes the capitalization to whatever capitalization you have set in the XML file.Thats the way it works. I may be able to solve that using regular expressions. Most of the sites I visit use all caps for the keywords. Thats probably why I never thought this would be an issue.
"#autokeywords{color:#333399;font-weight:normal;text-decoration:none;border-bottom:1px dashed;}" & vbNewLine & _
"#autokeywords:hover{color:red;font-weight:normal;text-decoration:none;border-bottom:1px dashed;}" & vbNewLine & _Originally posted by leatherlips The only thing left IMO is to maintain the case of the letters if possible.
Originally posted by leatherlips
Each time you upate your xml file or even change the target of the keyword links in the inc_func_common.asp file you must first uncomment the lines you mentioned, save the file and then uncomment the lines and then save again:Code:'if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
'end if
Originally posted by CarefreeI'm not sure, but I just checked my page on my MacBook using Safari and Firefox and the links were all correctly taking on the id.
I have the same issue with first/last occasionally not following set behaviour. Not sure what's causing it. I'm going to experiment & see if I can fix it, though.
Originally posted by cripto9tGood call! 18 was the magic number!
Maybe there's just not enough room.
Leatherlips, for the bottom border try setting the line-height up. I added a border to mine and like yours some worked and some didn't,
especially when they were on consecutive lines. Mine started working at 18px.
line-height:18px;
Function ChkKeys(fString)
dim strFiles,iCnt,strKeys,strReplace,strClose,keywords,keyreplace,objRegex
if ShowKeyWords = False then
ChkKeys = fString
Exit Function
end if
if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
end if
strKeys = Application(strCookieURL & "STRKEYWORDS")
strReplace = Application(strCookieURL & "STRKEYREPLACE")
strClose = "</a>"
if fString = "" or IsNull(fString) then fString = " "
keywords = split(strKeys, ",")
keyreplace = split(strReplace, ",")
set objRegex = new RegExp
objRegex.ignorecase = true
objRegex.global = true
for i = 0 to Ubound(keywords)
strPattern = "^(" & keywords(i) & ")(\s)"
strReplace = keyreplace(i) & "$1" & strClose & "$2"
objRegex.pattern= strPattern
fString = objRegex.replace(fString,strReplace)
strPattern = "(" & keywords(i) & ")$"
strReplace = keyreplace(i) & "$1" & strClose
objRegex.pattern= strPattern
fString = objRegex.replace(fString,strReplace)
strPattern = "(""|'|\(|\[|{)(" & keywords(i) & ")(}|\]|\)|'|"")"
strReplace = "$1" & keyreplace(i) & "$2" & strClose & "$3"
objRegex.pattern= strPattern
fString = objRegex.replace(fString,strReplace)
strPattern = "(\s)(" & keywords(i) & ")(\s|\.|,|;|'|\?|!|\)|\]|}|"")"
strReplace = "$1" & keyreplace(i) & "$2" & strClose & "$3"
objRegex.pattern= strPattern
fString = objRegex.replace(fString,strReplace)
next
ChkKeys = fString
End Function
Sub LoadKeywordApps()
dim strPath,xmlDoc,strErr,xmlKeyList,NumOfKeys,strKeys,strReplace,iKey
strPath = "C:\Inetpub\wwwroot\pool\key_db.xml"
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDOc.setProperty "ServerHTTPRequest", true
xmlDoc.load(strPath)
if xmlDoc.parseError.errorCode <> 0 Then
strErr = "<div><b>" & vbNewLine & _
"<ul>" & vbNewLine & _
"<li>ERROR!</li>" & vbNewLine & _
"<li>XML File " & strFileName & " - Failed to validate.</li>" & vbNewLine & _
"<li>" & xmlDoc.parseError.reason & "</li>" & vbNewLine & _
"<li>Error code: " & xmlDoc.parseError.errorCode & "</li>" & vbNewLine & _
"<li>Line: " & xmlDoc.parseError.line & "</li>" & vbNewLine & _
"<li>Character: " & xmlDoc.parseError.linepos & "</li>" & vbNewLine & _
"<li>Source: " & Chr(34) & xmlDoc.parseError.srcText & Chr(34) & "</li>" & vbNewLine & _
"<li>" & Now & "</li>" & vbNewLine & _
"</ul>" & vbNewLine & _
"</b></div>" & vbNewLine
Response.Write strErr
Response.End
end if
set xmlKeyList = xmlDoc.getElementsByTagName("key")
NumOfKeys = ((xmlKeyList.length) - 1) '0 based
strKeys = ""
strReplace = ""
for iKey = 0 to cLng(NumOfKeys)
if strKeys = "" then
strKeys = xmlKeyList.item(iKey).childNodes(0).text
strReplace = "<a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
else
strKeys = strKeys & "," & xmlKeyList.item(iKey).childNodes(0).text
strReplace = strReplace & ", <a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
end if
next
set xmlKeyList = nothing
set xmlDoc = nothing
Application.Lock
Application(strCookieURL & "STRKEYWORDS") = strKeys
Application(strCookieURL & "STRKEYREPLACE") = strReplace
Application.UnLock
End Subfor iKey = 0 to cLng(NumOfKeys)
if strKeys = "" then
strKeys = xmlKeyList.item(iKey).childNodes(0).text
strDiv = xmlKeyList.item(iKey).childNodes(1).text
if left(strDiv,4)<> "http" and left(strDiv,3) <> "ftp" then
strReplace = "<a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""_self"">"
else
strReplace = "<a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""_blank"">"
end if
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
else
strKeys = strKeys & "," & xmlKeyList.item(iKey).childNodes(0).text
strDiv = xmlKeyList.item(iKey).childNodes(1).text
strDiz = xmlKeyList.item(iKey).childNodes(0).text
if left(strDiv,4)= "http" or left(strDiv,3) = "ftp" then
strReplace = strReplace & ", <a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""_blank"">"
else
strReplace = strReplace & ", <a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""_self"">"
end if
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
end if
nextstrReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"Originally posted by leatherlips
Each time you upate your xml file or even change the target of the keyword links in the inc_func_common.asp file you must first uncomment the lines you mentioned, save the file and then uncomment the lines and then save again:Code:'if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
'end if
The reason for this suggestion, I made my xml file changes uploaded the file. Then went through the comment process and the changes installed on the keywords.. I am sure it is possible with some if'thens etc..Andy, assuming you have admin status, try this
Code:if mLev < 3 then
if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
end if
else
LoadKeywordApps
end if
if mLev < 3 then
if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
end if
else
LoadKeywordApps
end iffunction FormatStr2(fString)
on Error resume next
fString = Replace(fString, CHR(13), "")
'fString = Replace(fString, CHR(10) & CHR(10), "<br /><br />")
fString = Replace(fString, CHR(10), "<br />")
if strBadWordFilter = 1 or strBadWordFilter = "1" then
fString = ChkBadWords(fString)
end if
if strAllowForumCode = "1" then
fString = ReplaceURLs(fString)
fString = ReplaceCodeTags(fString)
if strIMGInPosts = "1" then
fString = ReplaceImageTags(fString)
end if
end if
fString = ChkURLs(fString, "http://", 1)
fString = ChkURLs(fString, "https://", 2)
fString = ChkURLs(fString, "www.", 3)
fString = ChkMail(fString)
fString = ChkURLs(fString, "ftp://", 5)
fString = ChkURLs(fString, "file:///", 6)
if strIcons = "1" then
fString = smile(fString)
end if
if strAllowForumCode = "1" then
fString = extratags(fString)
end if
FormatStr2 = fString
on Error goto 0
end function Response.Write "</span id=""msg""></font></td>" & vbNewLine & _
" </tr>" & vbNewLine
if CanShowSignature = 1 and Reply_Sig = 1 and Reply_MemberSig <> "" then
Response.Write " <tr>" & vbNewLine & _
" <td valign=""bottom""><hr noshade size=""" & strFooterFontSize & """><font color=""" & strForumFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><span class=""spnMessageText"">" & formatStr2(Reply_MemberSig) & "</span></font></td>" & vbNewLine & _
" </tr>" & vbNewLine
end ifResponse.Write "</span id=""msg""></font></td>" & vbNewLine & _
" </tr>" & vbNewLine
if CanShowSignature = 1 and Topic_Sig = 1 and Topic_MemberSig <> "" then
Response.Write " <tr>" & vbNewLine & _
" <td valign=""bottom""><hr noshade size=""" & strFooterFontSize & """><font color=""" & strForumFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><span class=""spnMessageText"">" & formatStr2(Topic_MemberSig) & "</span></font></td>" & vbNewLine & _
" </tr>" & vbNewLine
end if'if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
'end ifif mLev < 3 then
if trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" then
LoadKeywordApps
end if
else
LoadKeywordApps
end ifOriginally posted by bobby131313On my forum, a user initiated link does override the auto link. I didn't do anything different that what was provided in this thread.<
Awesome crypto, thanks!
I think the only thing left is the conflict of a user initiated link and a keyword link. Obviously I would like a user initiated link to override an automated link.
That doesn't sound to my amateur mind like it would be easy though.![]()
Notes:
1. In "config.asp":
After this line (appx 473):
strShowQuickReply = Application(strCookieURL & "STRSHOWQUICKREPLY")
Insert the following:
' ## Keywords Below
IKey = Application(strCookieURL & "IKey")
KeyReplace = Application(strCookieURL & "KeyReplace")
KeyWords = Application(strCookieURL & "KeyWords")
NumOfKeys = Application(strCookieURL & "NumOfKeys")
ObjRegex = Application(strCookieURL & "ObjRegex")
ShowKeyWords = Application(strCookieURL & "ShowKeyWords")
strErr = Application(strCookieURL & "strErr")
strKeys = Application(strCookieURL & "strKeys")
strPath = Application(strCookieURL & "strPath")
strReplace = Application(strCookieURL & "strReplace")
XMLDoc = Application(strCookieURL & "XMLDoc")
' ## Keywords Above
After this line (appx 163):
Dim SubCount, MySubCount
Insert the following:
' ## Keywords Below
Dim IKey, KeyReplace, Keywords, NumOfKeys, objRegex, ShowKeyWords
Dim strErr, strKeys, strPath, strReplace, xmlDoc
' ## Keywords Above
2. In "topic.asp" (and in any other file you wish the keyword links to function):
Before this line (appx 95):
'## Forum_SQL - Get original topic and check for the Category, Forum or Topic Status and existence
Insert the following:
' ## Keywords Below
ShowKeyWords = True
' ## Keywords Above
3. In "inc_func_common.asp":
After these lines (appx 1560-1562):
Sub WriteFooterShort() %>
<!--#INCLUDE FILE="inc_footer_short.asp"-->
<% end sub
Insert the following:
' ## Keywords Below
Function ChkKeys(fString)
If ShowKeyWords = FALSE Then
ChkKeys = fString
Exit Function
End If
If mLev < 3 Then
If trim(Application(strCookieURL & "STRKEYWORDS")) = "" or trim(Application(strCookieURL & "STRKEYREPLACE")) = "" Then
LoadKeywordApps
End If
Else
LoadKeywordApps
End If
If fString = "" or IsNull(fString) Then
fString = " "
End If
keywords = split(strKeys, ",")
keyreplace = split(strReplace, ",")
Set objRegex = new RegExp
objRegex.ignorecase = TRUE
objRegex.global = TRUE
For i = 0 to ubound(keywords)
strPattern = "^(" & keywords(i) & ")(\s)"
strReplace = keyreplace(i) & "$2"
objRegex.pattern= strPattern
fString = objRegex.replace(fString,strReplace)
strPattern = "(" & keywords(i) & ")$"
strReplace = keyreplace(i)
objRegex.pattern= strPattern
fString = objRegex.replace(fString,strReplace)
fString = Replace(fString, " " & keywords(i) & " ", " " & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ",", " " & keyreplace(i) & ",", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ".", " " & keyreplace(i) & ".", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ":", " " & keyreplace(i) & ":", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ";", " " & keyreplace(i) & ";", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "!", " " & keyreplace(i) & "!", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "?", " " & keyreplace(i) & "?", 1, -1, 1)
fString = Replace(fString, "-" & keywords(i) & "-", "-" & keyreplace(i) & "-", 1, -1, 1)
fString = Replace(fString, "-" & keywords(i) & " ", "-" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "-", " " & keyreplace(i) & "-", 1, -1, 1)
fString = Replace(fString, "_" & keywords(i) & "_", "_" & keyreplace(i) & "_", 1, -1, 1)
fString = Replace(fString, "_" & keywords(i) & " ", "_" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "_", " " & keyreplace(i) & "_", 1, -1, 1)
fString = Replace(fString, "'" & keywords(i) & "'", "'" & keyreplace(i) & "'", 1, -1, 1)
fString = Replace(fString, "'" & keywords(i) & " ", "'" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "'", " " & keyreplace(i) & "'", 1, -1, 1)
fString = Replace(fString, """" & keywords(i) & """", """" & keyreplace(i) & """", 1, -1, 1)
fString = Replace(fString, """" & keywords(i) & " ", """" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & """", " " & keyreplace(i) & """", 1, -1, 1)
fString = Replace(fString, "(" & keywords(i) & ")", "(" & keyreplace(i) & ")", 1, -1, 1)
fString = Replace(fString, "(" & keywords(i) & " ", "(" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & ")", " " & keyreplace(i) & ")", 1, -1, 1)
fString = Replace(fString, "[" & keywords(i) & "]", "[" & keyreplace(i) & "]", 1, -1, 1)
fString = Replace(fString, "[" & keywords(i) & " ", "[" & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & "]", " " & keyreplace(i) & "]", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & " ", " " & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, chr(13) & chr(10) & keywords(i) & " ", chr(13) & chr(10) & keyreplace(i) & " ", 1, -1, 1)
fString = Replace(fString, " " & keywords(i) & chr(13) & chr(10), " " & keyreplace(i) & chr(13) & chr(10), 1, -1, 1)
fString = Replace(fString, chr(13) & chr(10) & keywords(i) & chr(13) & chr(10), chr(13) & chr(10) & keyreplace(i) & chr(13) & chr(10), 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ".", chr(10) & keyreplace(i) & ".", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ",", chr(10) & keyreplace(i) & ",", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & "?", chr(10) & keyreplace(i) & "?", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & "!", chr(10) & keyreplace(i) & "!", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ":", chr(10) & keyreplace(i) & ":", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ";", chr(10) & keyreplace(i) & ";", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & """", chr(10) & keyreplace(i) & """", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & "'", chr(10) & keyreplace(i) & "'", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & ")", chr(10) & keyreplace(i) & ")", 1, -1, 1)
fString = Replace(fString, chr(10) & keywords(i) & "]", chr(10) & keyreplace(i) & "]", 1, -1, 1)
Next
Set objRegex = Nothing
ChkKeys = fString
End Function
Sub LoadKeywordApps()
strPath = strForumURL & "keywords.xml"
Set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="False"
xmlDOc.setProperty "ServerHTTPRequest", True
xmlDoc.load(strPath)
If xmlDoc.parseError.errorCode <> 0 Then
strErr = "<div><b>" & vbNewLine & _
"<ul>" & vbNewLine & _
"<li>ERROR!</li>" & vbNewLine & _
"<li>XML File " & strFileName & " - Failed to validate.</li>" & vbNewLine & _
"<li>" & xmlDoc.parseError.reason & "</li>" & vbNewLine & _
"<li>Error code: " & xmlDoc.parseError.errorCode & "</li>" & vbNewLine & _
"<li>Line: " & xmlDoc.parseError.line & "</li>" & vbNewLine & _
"<li>Character: " & xmlDoc.parseError.linepos & "</li>" & vbNewLine & _
"<li>Source: " & Chr(34) & xmlDoc.parseError.srcText & Chr(34) & "</li>" & vbNewLine & _
"<li>" & Now & "</li>" & vbNewLine & _
"</ul>" & vbNewLine & _
"</b></div>" & vbNewLine
Response.Write strErr
Response.End
End If
Set xmlKeyList = xmlDoc.getElementsByTagName("key")
NumOfKeys = ((xmlKeyList.length) - 1)
strKeys = ""
strReplace = ""
For iKey = 0 to cLng(NumOfKeys)
If strKeys = "" Then
strKeys = xmlKeyList.item(iKey).childNodes(0).text
strReplace = "<a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
Else
strKeys = strKeys & "," & xmlKeyList.item(iKey).childNodes(0).text
strReplace = strReplace & ", <a id=""keywords"" href=""" & xmlKeyList.item(iKey).childNodes(1).text & """ target=""blank"">"
strReplace = strReplace & xmlKeyList.item(iKey).childNodes(0).text & "</a>"
End If
Next
Set xmlKeyList = Nothing
Set xmlDoc = Nothing
Application.Lock
Application(strCookieURL & "STRKEYWORDS") = strKeys
Application(strCookieURL & "STRKEYREPLACE") = strReplace
Application.UnLock
End Sub
' ## Keywords Above
Next, within "FormatStr" function:
After this line (appx 117):
on Error resume next
Insert the following:
' ## Keywords Below
If fString <> "Reply_MemberSig" and fString <> "Topic_MemberSig" Then
fString = ChkKeys(fString)
End If
' ## Keywords Above
4. keywords.xml file (You'll have to create this yourself, the file name must match the one above in green save to forum root directory):
NOTES:
a. Pattern is critical, nothing extra can be inserted.
b. If the URL is not within your forum, use the entire path (including http://),
if it is within your forum, just the internal address is sufficient (eg. topic.asp?topic_id=300)
c. If a phrase is repeated within a longer phrase (eg. "murder" and "mass murder"), then list the
longer phrase keyword first or the shorter recognized keyword will point both to the first URL.
<?xml version="1.0" encoding="ISO-8859-1"?>
<keywords>
<key>
<phrase>xml</phrase>
<url>http://some/site.xml</url>
</key>
<key>
<phrase>html</phrase>
<url>http://some/site.html</url>
</key>
<key>
<phrase>css</phrase>
<url>http://some/site.css</url>
</key>
</keywords>
Styling (optional): To add a style to the keyword links, make the following changes.
In "inc_header.asp", look for this line (appx 269):
".spnSearchHighlight {background-color:" & strSearchHiLiteColor & "}" & vbNewLine & _
After that, insert these:
"#keywords {color:" & strLinkColor & "; font-weight:normal; text-decoration:none; border-bottom-style:1px dashed; line-height:18px;}" & vbNewLine & _
"#keywords:hover {color:" & strHoverFontColor & "; font-weight:normal; text-decoration:none; border-bottom-style:1px dashed; line-height:18px;}" & vbNewLine & _