主题:论坛UBB代码问题
下面这段UBB使用的时候URL和IMG代码会出错.
比如我用 (url)www.xxx.com(/url) 括号是中括号,发一个链接,在帖子中看到的效果却是我的网站地址+这个链接....例如本机测试就会变成http://127.0.0.1/www.xxx.com,使得这链接不能访问了.....图片也是,也会加上网站地址...所以都显示一把叉....请问怎么修改才能正确显示?
<%
function ChkBadWords(fString)
bwords = split(BadWords, "|")
for i = 0 to ubound(bwords)
fString = Replace(fString, bwords(i), string(len(bwords(i)),"*"), 1,-1,1)
next
ChkBadWords = fString
end function
function HTMLEncode(fString)
fString = replace(fString, "&amp;amp;", "&amp;amp;#38;")
fString = replace(fString, ">", "&amp;amp;gt;")
fString = replace(fString, "<", "&amp;amp;lt;")
fString = replace(fString, "@#$%3v42q", "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) &amp;amp; CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode = fString
end function
function doCode(fString, fOTag, fCTag, fROTag, fRCTag)
fOTagPos = Instr(1, fString, fOTag, 1)
fCTagPos = Instr(1, fString, fCTag, 1)
while (fCTagPos > 0 and fOTagPos > 0)
fString = replace(fString, fOTag, fROTag, 1, 1, 1)
fString = replace(fString, fCTag, fRCTag, 1, 1, 1)
fOTagPos = Instr(1, fString, fOTag, 1)
fCTagPos = Instr(1, fString, fCTag, 1)
wend
doCode = fString
end function
function UBBCode(strContent)
if strAllowHTML <> 1 then
strContent = HTMLEncode(strContent)
end if
dim re
set re = New RegExp
re.Global = True
re.IgnoreCase = True
re.Pattern="(javascript)"
strContent=re.Replace(strContent,"&amp;amp;#106avascript")
re.Pattern="(jscript:)"
strContent=re.Replace(strContent,"&amp;amp;#106script:")
re.Pattern="(js:)"
strContent=re.Replace(strContent,"&amp;amp;#106s:")
re.Pattern="(value)"
strContent=re.Replace(strContent,"&amp;amp;#118alue")
re.Pattern="(about:)"
strContent=re.Replace(strContent,"about&amp;amp;#58")
re.Pattern="(file:)"
strContent=re.Replace(strContent,"file&amp;amp;#58")
re.Pattern="(document.cookie)"
strContent=re.Replace(strContent,"documents&amp;amp;#46cookie")
re.Pattern="(vbscript:)"
strContent=re.Replace(strContent,"&amp;amp;#118bscript:")
re.Pattern="(vbs:)"
strContent=re.Replace(strContent,"&amp;amp;#118bs:")
re.Pattern="(on(mouse|exit|error|click|key))"
strContent=re.Replace(strContent,"&amp;amp;#111n$2")
re.Pattern = "\[url](.[^\[]*)\[\/url]"
strContent = re.Replace(strContent,"<a target=_blank href=$1>$1</a>")
re.Pattern = "\[mail](.[^\[]*)\[\/mail]"
strContent = re.Replace(strContent,"<a href=mailto:$1>$1</a>")
re.Pattern = "\[IMG](.[^\[]*)\[\/IMG]"
strContent = re.Replace(strContent,"<a href=""$1"" target=blank><IMG SRC=""$1"" border=0 onload=""javascript:if(this.width>750)this.width=750""></a>")
strContent = doCode(strContent, "[list]", "[/list]", "<ul>", "</ul>")
strContent = doCode(strContent, "[list=1]", "[/list]", "<ol type=1>", "</ol id=1>")
strContent = doCode(strContent, "[list=a]", "[/list]", "<ol type=a>", "</ol id=a>")
strContent = doCode(strContent, "[*]", "[/*]", "<li>", "</li>")
strContent = ChkBadWords(strContent)
UBBCode = strContent
end function
%>
比如我用 (url)www.xxx.com(/url) 括号是中括号,发一个链接,在帖子中看到的效果却是我的网站地址+这个链接....例如本机测试就会变成http://127.0.0.1/www.xxx.com,使得这链接不能访问了.....图片也是,也会加上网站地址...所以都显示一把叉....请问怎么修改才能正确显示?
<%
function ChkBadWords(fString)
bwords = split(BadWords, "|")
for i = 0 to ubound(bwords)
fString = Replace(fString, bwords(i), string(len(bwords(i)),"*"), 1,-1,1)
next
ChkBadWords = fString
end function
function HTMLEncode(fString)
fString = replace(fString, "&amp;amp;", "&amp;amp;#38;")
fString = replace(fString, ">", "&amp;amp;gt;")
fString = replace(fString, "<", "&amp;amp;lt;")
fString = replace(fString, "@#$%3v42q", "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) &amp;amp; CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode = fString
end function
function doCode(fString, fOTag, fCTag, fROTag, fRCTag)
fOTagPos = Instr(1, fString, fOTag, 1)
fCTagPos = Instr(1, fString, fCTag, 1)
while (fCTagPos > 0 and fOTagPos > 0)
fString = replace(fString, fOTag, fROTag, 1, 1, 1)
fString = replace(fString, fCTag, fRCTag, 1, 1, 1)
fOTagPos = Instr(1, fString, fOTag, 1)
fCTagPos = Instr(1, fString, fCTag, 1)
wend
doCode = fString
end function
function UBBCode(strContent)
if strAllowHTML <> 1 then
strContent = HTMLEncode(strContent)
end if
dim re
set re = New RegExp
re.Global = True
re.IgnoreCase = True
re.Pattern="(javascript)"
strContent=re.Replace(strContent,"&amp;amp;#106avascript")
re.Pattern="(jscript:)"
strContent=re.Replace(strContent,"&amp;amp;#106script:")
re.Pattern="(js:)"
strContent=re.Replace(strContent,"&amp;amp;#106s:")
re.Pattern="(value)"
strContent=re.Replace(strContent,"&amp;amp;#118alue")
re.Pattern="(about:)"
strContent=re.Replace(strContent,"about&amp;amp;#58")
re.Pattern="(file:)"
strContent=re.Replace(strContent,"file&amp;amp;#58")
re.Pattern="(document.cookie)"
strContent=re.Replace(strContent,"documents&amp;amp;#46cookie")
re.Pattern="(vbscript:)"
strContent=re.Replace(strContent,"&amp;amp;#118bscript:")
re.Pattern="(vbs:)"
strContent=re.Replace(strContent,"&amp;amp;#118bs:")
re.Pattern="(on(mouse|exit|error|click|key))"
strContent=re.Replace(strContent,"&amp;amp;#111n$2")
re.Pattern = "\[url](.[^\[]*)\[\/url]"
strContent = re.Replace(strContent,"<a target=_blank href=$1>$1</a>")
re.Pattern = "\[mail](.[^\[]*)\[\/mail]"
strContent = re.Replace(strContent,"<a href=mailto:$1>$1</a>")
re.Pattern = "\[IMG](.[^\[]*)\[\/IMG]"
strContent = re.Replace(strContent,"<a href=""$1"" target=blank><IMG SRC=""$1"" border=0 onload=""javascript:if(this.width>750)this.width=750""></a>")
strContent = doCode(strContent, "[list]", "[/list]", "<ul>", "</ul>")
strContent = doCode(strContent, "[list=1]", "[/list]", "<ol type=1>", "</ol id=1>")
strContent = doCode(strContent, "[list=a]", "[/list]", "<ol type=a>", "</ol id=a>")
strContent = doCode(strContent, "[*]", "[/*]", "<li>", "</li>")
strContent = ChkBadWords(strContent)
UBBCode = strContent
end function
%>