很不错的一个UBB代码
程序员文章站
2022-10-31 14:00:40
<%function htmlencode(byval strvalue) '忽略错误 on error ...
<%
function htmlencode(byval strvalue)
'忽略错误
on error resume next
'定义变量
dim strnewvalue
if strvalue <> "" then
strnewvalue = replace(strvalue,"<","<")
strnewvalue = replace(strnewvalue,">",">")
strnewvalue = replace(strnewvalue,"'","'")
strnewvalue = replace(strnewvalue,"""",""")
strnewvalue = replace(strnewvalue,vbcrlf,"<br>")
strnewvalue = replace(strnewvalue," "," ")
end if
htmlencode = strnewvalue
'输出错误
if err.number>0 then
response.write err.description
response.end
end if
end function
function ubbcode(strvalue)
dim regexp
'strvalue=htmlencode(strvalue)
set regexp=new regexp
regexp.ignorecase =true
regexp.global=true
if strvalue <> "" then
regexp.pattern="(\[img\])(.[^\[]*)(\[\/img\])"
strvalue=regexp.replace(strvalue,"<a href=""$2"" target=_blank><img src=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
regexp.pattern="(\[flash\])(.[^\[]*)(\[\/flash\])"
strvalue=regexp.replace(strvalue,"<object codebase="",0,2,0"" classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 width=500 height=400 id=shockwaveflash1><param name=movie value=""$2""><param name=quality value=high><embed src=""$2"" quality=high pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash"" type=""appl ... 00 height=400></embed></object>")
regexp.pattern="(\[zip\])(.[^\[]*)(\[\/zip\])"
strvalue=regexp.replace(strvalue,"<br><a href=""$2"">点击下载该文件</a>")
regexp.pattern="(\[rar\])(.[^\[]*)(\[\/rar\])"
strvalue=regexp.replace(strvalue,"<br><a href=""$2"">点击下载该文件</a>")
'regexp.pattern="(\[upload=(.[^\[]*)\])(.[^\[]*)(\[\/upload\])"
'strvalue=regexp.replace(strvalue,"<br><img src=""$2.gif"" border=0> <a href=""$3"" target=_blank>点击查看或下载该文件</a>")
'strvalue=regexp.replace(strvalue,"<br><img src=""$2.gif"" border=0>此主题相关图片如下:<br><a href=""$3"" target=_blank><img src=""$3"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
regexp.pattern="(\[url\])(http:\/\/.[^\[]*)(\[\/url\])"
strvalue=regexp.replace(strvalue,"<a href=""$2"" target=_blank>$2</a>")
regexp.pattern="(\[url\])(.[^\[]*)(\[\/url\])"
strvalue=regexp.replace(strvalue,"<a href=""http://$2"" target= ... t;/a>")
regexp.pattern="(\*)\])(.[^\[]*)(\[\/url\])"
strvalue=regexp.replace(strvalue,"<a href=""$2"" target=_blank>$3</a>")
regexp.pattern="(\[url=(.[^\[]*)\])(.[^\[]*)(\[\/url\])"
strvalue=regexp.replace(strvalue,"<a href=""[url]http://$2"" target=_blank>$3</a>")
regexp.pattern="(\[email\])(\s+\@.[^\[]*)(\[\/email\])"
strvalue=regexp.replace(strvalue,"<a href=""mailto:$2"">$2</a>")
regexp.pattern="(\[email=(\s+\@.[^\[]*)\])(.[^\[]*)(\[\/email\])"
strvalue=regexp.replace(strvalue,"<a href=""mailto:$2"" target=_blank>$3</a>")
regexp.pattern = "^(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "[^>=""](http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "^(ftp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "(ftp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "[^>=""](ftp://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "^(rtsp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "(rtsp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "[^>=""](rtsp://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "^(mms://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "(mms://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "[^>=""](mms://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern="(\[html\])(.[^\[]*)(\[\/html\])"
strvalue=regexp.replace(strvalue,"<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#ffffff'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
regexp.pattern="(\[code\])(.[^\[]*)(\[\/code\])"
strvalue=regexp.replace(strvalue,"<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#ffffff'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
regexp.pattern="(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])"
strvalue=regexp.replace(strvalue,"<font color=$2>$3</font>")
regexp.pattern="(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])"
strvalue=regexp.replace(strvalue,"<font face=$2>$3</font>")
regexp.pattern="(\[align=(.[^\[]*)\])(.*)(\[\/align\])"
strvalue=regexp.replace(strvalue,"<div align=$2>$3</div>")
regexp.pattern="(\[quote\])(.*)(\[\/quote\])"
strvalue=regexp.replace(strvalue,"<table cellpadding=0 cellspacing=0 border=0 width=94% bgcolor=#000000 align=center><tr><td><table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor='#ffffff'>$2</table></table><br>")
regexp.pattern="(\[fly\])(.*)(\[\/fly\])"
strvalue=regexp.replace(strvalue,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
regexp.pattern="(\[move\])(.*)(\[\/move\])"
strvalue=regexp.replace(strvalue,"<marquee scrollamount=3>$2</marquee>")
regexp.pattern="\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/glow]"
strvalue=regexp.replace(strvalue,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
regexp.pattern="\[shadow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/shadow]"
strvalue=regexp.replace(strvalue,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
regexp.pattern="(\[i\])(.[^\[]*)(\[\/i\])"
strvalue=regexp.replace(strvalue,"<i>$2</i>")
regexp.pattern="(\[u\])(.[^\[]*)(\[\/u\])"
strvalue=regexp.replace(strvalue,"<u>$2</u>")
regexp.pattern="(\[b\])(.[^\[]*)(\[\/b\])"
strvalue=regexp.replace(strvalue,"<b>$2</b>")
regexp.pattern="(\[fly\])(.[^\[]*)(\[\/fly\])"
strvalue=regexp.replace(strvalue,"<marquee>$2</marquee>")
regexp.pattern="(\[size=1\])(.[^\[]*)(\[\/size\])"
strvalue=regexp.replace(strvalue,"<font size=1>$2</font>")
regexp.pattern="(\[size=2\])(.[^\[]*)(\[\/size\])"
strvalue=regexp.replace(strvalue,"<font size=2>$2</font>")
regexp.pattern="(\[size=3\])(.[^\[]*)(\[\/size\])"
strvalue=regexp.replace(strvalue,"<font size=3>$2</font>")
regexp.pattern="(\[size=4\])(.[^\[]*)(\[\/size\])"
strvalue=regexp.replace(strvalue,"<font size=4>$2</font>")
regexp.pattern="(\[center\])(.[^\[]*)(\[\/center\])"
strvalue=regexp.replace(strvalue,"<center>$2</center>")
end if
set regexp=nothing
ubbcode=strvalue
'输出错误
if err.number>0 then
response.write err.description
response.end
end if
end function
%>
function htmlencode(byval strvalue)
'忽略错误
on error resume next
'定义变量
dim strnewvalue
if strvalue <> "" then
strnewvalue = replace(strvalue,"<","<")
strnewvalue = replace(strnewvalue,">",">")
strnewvalue = replace(strnewvalue,"'","'")
strnewvalue = replace(strnewvalue,"""",""")
strnewvalue = replace(strnewvalue,vbcrlf,"<br>")
strnewvalue = replace(strnewvalue," "," ")
end if
htmlencode = strnewvalue
'输出错误
if err.number>0 then
response.write err.description
response.end
end if
end function
function ubbcode(strvalue)
dim regexp
'strvalue=htmlencode(strvalue)
set regexp=new regexp
regexp.ignorecase =true
regexp.global=true
if strvalue <> "" then
regexp.pattern="(\[img\])(.[^\[]*)(\[\/img\])"
strvalue=regexp.replace(strvalue,"<a href=""$2"" target=_blank><img src=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
regexp.pattern="(\[flash\])(.[^\[]*)(\[\/flash\])"
strvalue=regexp.replace(strvalue,"<object codebase="",0,2,0"" classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 width=500 height=400 id=shockwaveflash1><param name=movie value=""$2""><param name=quality value=high><embed src=""$2"" quality=high pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash"" type=""appl ... 00 height=400></embed></object>")
regexp.pattern="(\[zip\])(.[^\[]*)(\[\/zip\])"
strvalue=regexp.replace(strvalue,"<br><a href=""$2"">点击下载该文件</a>")
regexp.pattern="(\[rar\])(.[^\[]*)(\[\/rar\])"
strvalue=regexp.replace(strvalue,"<br><a href=""$2"">点击下载该文件</a>")
'regexp.pattern="(\[upload=(.[^\[]*)\])(.[^\[]*)(\[\/upload\])"
'strvalue=regexp.replace(strvalue,"<br><img src=""$2.gif"" border=0> <a href=""$3"" target=_blank>点击查看或下载该文件</a>")
'strvalue=regexp.replace(strvalue,"<br><img src=""$2.gif"" border=0>此主题相关图片如下:<br><a href=""$3"" target=_blank><img src=""$3"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
regexp.pattern="(\[url\])(http:\/\/.[^\[]*)(\[\/url\])"
strvalue=regexp.replace(strvalue,"<a href=""$2"" target=_blank>$2</a>")
regexp.pattern="(\[url\])(.[^\[]*)(\[\/url\])"
strvalue=regexp.replace(strvalue,"<a href=""http://$2"" target= ... t;/a>")
regexp.pattern="(\*)\])(.[^\[]*)(\[\/url\])"
strvalue=regexp.replace(strvalue,"<a href=""$2"" target=_blank>$3</a>")
regexp.pattern="(\[url=(.[^\[]*)\])(.[^\[]*)(\[\/url\])"
strvalue=regexp.replace(strvalue,"<a href=""[url]http://$2"" target=_blank>$3</a>")
regexp.pattern="(\[email\])(\s+\@.[^\[]*)(\[\/email\])"
strvalue=regexp.replace(strvalue,"<a href=""mailto:$2"">$2</a>")
regexp.pattern="(\[email=(\s+\@.[^\[]*)\])(.[^\[]*)(\[\/email\])"
strvalue=regexp.replace(strvalue,"<a href=""mailto:$2"" target=_blank>$3</a>")
regexp.pattern = "^(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "[^>=""](http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "^(ftp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "(ftp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "[^>=""](ftp://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "^(rtsp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "(rtsp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "[^>=""](rtsp://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "^(mms://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "(mms://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern = "[^>=""](mms://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>")
regexp.pattern="(\[html\])(.[^\[]*)(\[\/html\])"
strvalue=regexp.replace(strvalue,"<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#ffffff'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
regexp.pattern="(\[code\])(.[^\[]*)(\[\/code\])"
strvalue=regexp.replace(strvalue,"<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#ffffff'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
regexp.pattern="(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])"
strvalue=regexp.replace(strvalue,"<font color=$2>$3</font>")
regexp.pattern="(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])"
strvalue=regexp.replace(strvalue,"<font face=$2>$3</font>")
regexp.pattern="(\[align=(.[^\[]*)\])(.*)(\[\/align\])"
strvalue=regexp.replace(strvalue,"<div align=$2>$3</div>")
regexp.pattern="(\[quote\])(.*)(\[\/quote\])"
strvalue=regexp.replace(strvalue,"<table cellpadding=0 cellspacing=0 border=0 width=94% bgcolor=#000000 align=center><tr><td><table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor='#ffffff'>$2</table></table><br>")
regexp.pattern="(\[fly\])(.*)(\[\/fly\])"
strvalue=regexp.replace(strvalue,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
regexp.pattern="(\[move\])(.*)(\[\/move\])"
strvalue=regexp.replace(strvalue,"<marquee scrollamount=3>$2</marquee>")
regexp.pattern="\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/glow]"
strvalue=regexp.replace(strvalue,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
regexp.pattern="\[shadow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/shadow]"
strvalue=regexp.replace(strvalue,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
regexp.pattern="(\[i\])(.[^\[]*)(\[\/i\])"
strvalue=regexp.replace(strvalue,"<i>$2</i>")
regexp.pattern="(\[u\])(.[^\[]*)(\[\/u\])"
strvalue=regexp.replace(strvalue,"<u>$2</u>")
regexp.pattern="(\[b\])(.[^\[]*)(\[\/b\])"
strvalue=regexp.replace(strvalue,"<b>$2</b>")
regexp.pattern="(\[fly\])(.[^\[]*)(\[\/fly\])"
strvalue=regexp.replace(strvalue,"<marquee>$2</marquee>")
regexp.pattern="(\[size=1\])(.[^\[]*)(\[\/size\])"
strvalue=regexp.replace(strvalue,"<font size=1>$2</font>")
regexp.pattern="(\[size=2\])(.[^\[]*)(\[\/size\])"
strvalue=regexp.replace(strvalue,"<font size=2>$2</font>")
regexp.pattern="(\[size=3\])(.[^\[]*)(\[\/size\])"
strvalue=regexp.replace(strvalue,"<font size=3>$2</font>")
regexp.pattern="(\[size=4\])(.[^\[]*)(\[\/size\])"
strvalue=regexp.replace(strvalue,"<font size=4>$2</font>")
regexp.pattern="(\[center\])(.[^\[]*)(\[\/center\])"
strvalue=regexp.replace(strvalue,"<center>$2</center>")
end if
set regexp=nothing
ubbcode=strvalue
'输出错误
if err.number>0 then
response.write err.description
response.end
end if
end function
%>
调用:<%=ubbcode(content)%>
上一篇: 简单过滤一下广告的代码
下一篇: ASP小偷(远程数据获取)程序入门教程
推荐阅读
-
仅用500行Python代码实现一个英文解析器的教程
-
一个优秀的SEO人员必知的网站代码优化
-
mybatis generator对于同一个表生成多次代码的问题
-
php压缩多个CSS为一个css的代码并缓存
-
在第一个input框内输入内容.textarea自动得到第一个文件框的值的javascript代码
-
Android 启动另一个App/apk中的Activity实现代码
-
HTML5 Canvas旋转动画的2个代码例子(一个旋转的太极图效果)
-
video.js 一个页面同时播放多个视频的实例代码
-
Python随机生成一个6位的验证码代码分享
-
sql语句查询之一个学生在某一年的所有成绩与查询某一个班的高等数学的成绩(代码实例)