ubbcode函数
程序员文章站
2022-07-02 07:53:19
复制代码 代码如下:<% public function ubbcode(strcontent) ...
复制代码 代码如下:
<%
public function ubbcode(strcontent)
dim re
set re = new regexp
re.ignorecase = true
re.global = true
'过滤危险脚本
re.pattern = "(</script>)"
strcontent = re.replace(strcontent, "</script>")
re.pattern = "(script:)"
strcontent = re.replace(strcontent, "s cript:")
re.pattern = "(script)"
strcontent = re.replace(strcontent, "s cript")
re.pattern = "(js:)"
strcontent = re.replace(strcontent, "js:")
re.pattern = "(value)"
strcontent = re.replace(strcontent, "value")
re.pattern = "(about:)"
strcontent = re.replace(strcontent, "about:")
re.pattern = "(file:)"
strcontent = re.replace(strcontent, "file:")
re.pattern = "(document.cookie)"
strcontent = re.replace(strcontent, "documents.cookie")
re.pattern = "(vbs:)"
strcontent = re.replace(strcontent, "v bs:")
re.pattern = "(on(mouse|exit|error|click|key))"
strcontent = re.replace(strcontent, "on$2")
re.pattern = "<img.[^>]*src(=| )(.[^>]*)>"
'strcontent = re.replace(strcontent,"<img src=$2 onclick=""javascript:window.open(this.src);"" style=""cursor: pointer"" border=""0"">")
strcontent = re.replace(strcontent,"<img src=$2 border=""0"">")
're.pattern="<img(.[^>]*)>"
'strcontent = re.replace(strcontent,"<img$1 onload=""return imgzoom(this,550)"">")
re.pattern = "(\[i\])(.[^\[]*)(\[\/i\])"
strcontent = re.replace(strcontent, "<i>$2</i>")
re.pattern = "(\[u\])(.[^\[]*)(\[\/u\])"
strcontent = re.replace(strcontent, "<u>$2</u>")
re.pattern = "(\[b\])(.[^\[]*)(\[\/b\])"
strcontent = re.replace(strcontent, "<b>$2</b>")
re.pattern = "(\[fly\])(.*)(\[\/fly\])"
strcontent = re.replace(strcontent, "<marquee>$2</marquee>")
re.pattern = "\[size=([1-9])\](.[^\[]*)\[\/size\]"
strcontent = re.replace(strcontent, "<font size=$1>$2</font>")
re.pattern = "(\[center\])(.[^\[]*)(\[\/center\])"
strcontent = re.replace(strcontent, "<center>$2</center>")
re.pattern = "\[dir=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/dir]"
strcontent = re.replace(strcontent, "<embed src=$3 pluginspage=http://www.macromedia.com/shockwave/download/ width=$1 height=$2></embed>")
re.pattern = "\[qt=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/qt]"
strcontent = re.replace(strcontent, "<embed src=$3 width=$1 height=$2 autoplay=true loop=false controller=true playeveryframe=false cache=false scale=tofit bgcolor=#000000 kioskmode=false targetcache=false pluginspage=http://www.apple.com/quicktime/>")
re.pattern = "\[mp=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/mp]"
strcontent = re.replace(strcontent, "<embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701 flename=mp src=$3 width=$1 height=$2></embed>")
re.pattern = "\[rm=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/rm]"
strcontent = re.replace(strcontent, "<object classid=clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa class=object id=raocx width=$1 height=$2><param name=src value=$3><param name=console value=clip1><param name=controls value=imagewindow><param name=autostart value=true></object><br><object classid=clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa height=32 id=video2 width=$1><param name=src value=$3><param name=autostart value=-1><param name=controls value=controlpanel><param name=console value=clip1></object>")
re.pattern = "(\[flash\])(.[^\[]*)(\[\/flash\])"
'strcontent = re.replace(strcontent, "<embed src=""$2"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width=500 height=400>$2</embed>")
strcontent = re.replace(strcontent, "")
re.pattern = "(\[flash=*([0-9]*),*([0-9]*)\])(.[^\[]*)(\[\/flash\])"
strcontent = re.replace(strcontent, "<embed src=""$4"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width=$2 height=$3>$4</embed>")
strcontent = re.replace(strcontent, "")
re.pattern = "\[upload=(gif|jpg|jpeg|bmp|png)\](.[^\[]*)(gif|jpg|jpeg|bmp|png)\[\/upload\]"
strcontent = re.replace(strcontent, "<br><a href=""$2$1"" target=_blank><img src=""$2$1"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
re.pattern = "(\[upload=(.[^\[]*)\])(.[^\[]*)(\[\/upload\])"
strcontent = re.replace(strcontent, "<br><a href=""$3"">点击浏览该文件</a>")
re.pattern = "(\[url\])(.[^\[]*)(\[\/url\])"
strcontent = re.replace(strcontent, "<a href=""$2"" target=_blank>$2</a>")
re.pattern = "(\[url=(.[^\[]*)\])(.[^\[]*)(\[\/url\])"
strcontent = re.replace(strcontent, "<a href=""$2"" target=_blank>$3</a>")
re.pattern = "(\[email\])(.[^\[]*)(\[\/email\])"
strcontent = re.replace(strcontent, "<a href=""mailto:$2"">$2</a>")
re.pattern = "(\[email=(.[^\[]*)\])(.[^\[]*)(\[\/email\])"
strcontent = re.replace(strcontent, "<a href=""mailto:$2"" target=_blank>$3</a>")
re.pattern = "(\[html\])(.[^\[]*)(\[\/html\])"
strcontent = re.replace(strcontent, "<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#f6f6f6'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
re.pattern = "(\[code\])(.[^\[]*)(\[\/code\])"
strcontent = re.replace(strcontent, "<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#f6f6f6'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
re.pattern = "(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])"
strcontent = re.replace(strcontent, "<font color=$2>$3</font>")
re.pattern = "(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])"
strcontent = re.replace(strcontent, "<font face=$2>$3</font>")
re.pattern = "\[align=(center|left|right)\](.*)\[\/align\]"
strcontent = re.replace(strcontent, "<div align=$1>$2</div>")
re.pattern = "(\[quote\])(.*)(\[\/quote\])"
strcontent = re.replace(strcontent, "<table cellpadding=0 cellspacing=0 border=1 width=94% bordercolor=#000000 bgcolor=#f2f8ff align=center ><tr><td ><table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor='#f6f6f6'>$2</table></table><br>")
re.pattern = "(\[move\])(.*)(\[\/move\])"
strcontent = re.replace(strcontent, "<marquee scrollamount=3>$2</marquee>")
re.pattern = "\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/glow]"
strcontent = re.replace(strcontent, "<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
re.pattern = "\[shadow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/shadow]"
strcontent = re.replace(strcontent, "<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
set re = nothing
strcontent = replace(strcontent, "{", "{")
strcontent = replace(strcontent, "}", "}")
strcontent = replace(strcontent, "$", "$")
ubbcode = strcontent
end function
%>
上一篇: SQLServer之创建分区视图
下一篇: Go语言变量