论坛UBB代码 推荐
<%
dim param,smiles 'param是ubb标签完全可用的标记 param=full 则完全可用,否则不支持一些占位大的标签 smiles是禁止笑脸转换
function ubbcode(content)
dim n,i
'on error resume next
set re=new regexp
re.ignorecase=true
re.global=true
re.pattern="\[code\](\r\n)?([\s\s]+?)\[\/code\]"
set matches = re.execute(content)
dim code()
n=0
if re.test(content) then codeb=true
if codeb then
for each match in matches
redim preserve code(n)
code(n) =match.value
n=n+1
next
for i=0 to ubound(code)
if code(i)="" then exit for
content=replace(content,code(i),"{code"&i&"}")
next
end if
if param="full" then
re.pattern="\[html\](\r\n)?([\s\s]+?)\[\/html\]"
set matches = re.execute(content)
dim html()
n=0
if re.test(content) then htmlb=true
if htmlb then
for each match in matches
redim preserve html(n)
html(n) =match.value
n=n+1
next
for i=0 to ubound(html)
if html(i)="" then exit for
content=replace(content,html(i),"{html"&i&"}")
next
end if
end if
content=gmt(content) 'ubb
if codeb then
for i=0 to ubound(code)
if code(i)="" then exit for
tcode=server.htmlencode(code(i))
content=replace(content,"{code"&i&"}",tcode)
next
end if
'-----处理[code] 中的[html]
re.pattern="\[html\](\r\n)?([\s\s]+?)\[\/html\]"
set matches = re.execute(content) ' execute search.
dim html2()
n=0
if re.test(content) then html2b=true
if html2b then
for each match in matches ' iterate matches collection.
redim preserve html2(n)
html2(n) =match.value
n=n+1
next
for i=0 to ubound(html2)
if html2(i)="" then exit for
content=replace(content,html2(i),"{html2"&i&"}")
next
end if
if param="full" then
if htmlb then
for i=0 to ubound(html)
if html(i)="" then exit for
thtml=server.htmlencode(html(i))
content=replace(content,"{html"&i&"}",thtml)
next
end if
end if
re.pattern="(\[code\])(\r\n)?([\s\s]+?)(\[\/code\])"
content=re.replace(content,"<pre class=codesamp>$3</pre>")
if param="full" then
re.pattern="(\[html\])(\r\n)?([\s\s]+?)(\[\/html\])"
content=re.replace(content,"<span><textarea cols=95 rows=12>$3</textarea><br><input onclick=runcode() type=button value=运行代码> <input onclick=copycode() type=button value=复制代码>[ctrl+a 全部选择 提示:你可先修改部分代码,再按运行]</span>")
end if
if html2b then
for i=0 to ubound(html2)
if html2(i)="" then exit for
thtml2=html2(i)
content=replace(content,"{html2"&i&"}",thtml2)
next
end if
ubbcode=content
end function
function gmt(strcontent)
strcontent=htmlfilter(strcontent)
dim re
set re=new regexp
re.ignorecase =true
re.global=true
if param="full" then
if not smiles then '笑脸转换
re.pattern="(\[em(\d{1,2})\])"
strcontent=re.replace(strcontent,"<img src=images/em$2.gif border=0 align=middle>")
're.pattern=":\)"
'strcontent=re.replace(strcontent,"<img src=images/smile.gif border=0 align=middle>")
're.pattern=":\("
'strcontent=re.replace(strcontent,"<img src=images/frown.gif border=0 align=middle>")
're.pattern=":o"
'strcontent=re.replace(strcontent,"<img src=images/redface.gif border=0 align=middle>")
're.pattern=":d"
'strcontent=re.replace(strcontent,"<img src=images/biggrin.gif border=0 align=middle>")
're.pattern=";\)"
'strcontent=re.replace(strcontent,"<img src=images/wink.gif border=0 align=middle>")
're.pattern=":p"
'strcontent=re.replace(strcontent,"<img src=images/tongue.gif border=0 align=middle>")
're.pattern=":cool:"
'strcontent=re.replace(strcontent,"<img src=images/cool.gif border=0 align=middle>")
're.pattern=":rolleyes:"
'strcontent=re.replace(strcontent,"<img src=images/rolleyes.gif border=0 align=middle>")
're.pattern=":mad:"
'strcontent=re.replace(strcontent,"<img src=images/mad.gif border=0 align=middle>")
're.pattern=":eek:"
'strcontent=re.replace(strcontent,"<img src=images/eek.gif border=0 align=middle>")
're.pattern=":confused:"
'strcontent=re.replace(strcontent,"<img src=images/confused.gif border=0 align=middle>")
're.pattern=":cry:"
'strcontent=re.replace(strcontent,"<img src=images/cry.gif border=0 align=middle>")
end if
re.pattern="(\[img\])(.*?)(\[\/img\])"
strcontent=re.replace(strcontent,"<a href=$2 target=_blank><img src=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>document.body.clientwidth-300) {this.height=(document.body.clientwidth-300)*this.height/this.width;this.width=document.body.clientwidth-300}"" galleryimg=no></a>")
're.pattern="\[dir=*([0-9]*),*([0-9]*)\](.*?)\[\/dir]"
'strcontent=re.replace(strcontent,"<object classid=clsid:166b1bca-3f9c-11cf-8075-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=7,0,2,0 width=$1 height=$2><param name=src value=$3><embed src=$3 pluginspage=http://www.macromedia.com/shockwave/download/ width=$1 height=$2></embed></object>")
'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=(\d+),(\d+)\](.*?)\[\/mp]"
strcontent=re.replace(strcontent,"<object align=middle classid=clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=object id=mediaplayer width=$1 height=$2 ><param name=showstatusbar value=-1><param name=playcount value=10><param name=filename value=""$3""><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"" playcount=10 width=$1 height=$2></embed></object>")
'mp3
re.pattern="\[mp3](.*?)\[\/mp3]"
strcontent=re.replace(strcontent,"<object align=middle classid=clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=object id=mediaplayer width=300 height=180 ><param name=showstatusbar value=-1><param name=playcount value=10><param name=filename value=""$1""><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701 flename=mp src=""$1"" playcount=10 width=300 height=180></embed></object>")
re.pattern="\[rm=(\d+),(\d+)\](.*?)\[\/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,"<object codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 width=500 height=400><param name=movie value=""$2""><param name=quality value=high><embed src=""$2"" quality=high pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=500 height=400>$2</embed></object>")
re.pattern="(\[flash=(\d+),(\d+)\])(.*?)(\[\/flash\])"
strcontent= re.replace(strcontent,"<object codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 width=$2 height=$3><param name=movie value=""$4""><param name=quality value=high><param name=menu value=false><embed src=""$4"" quality=high menu=false pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=$2 height=$3>$4</embed></object>")
'循环转换quote
re.pattern="(\[quote\])(.*?)(\[\/quote\])"
while re.test(strcontent)
strcontent=re.replace(strcontent,"<blockquote>引用:<hr class=bordercolor><span>$2</span><hr class=bordercolor></blockquote>")
wend
re.pattern="(\[w\])(.*?)(\[\/w\])"
strcontent=re.replace(strcontent,"<iframe frameborder=1 align=center width=100% height=400 scrolling=yes src=$2></iframe><br>页面:<a href=$2 target=_blank>点这儿参观</a>")
end if '大空间标签
re.pattern="(\[attachment=(.*?)\])(.*?)(\[\/attachment\])"
strcontent= re.replace(strcontent,"<p><img src=images/attachment.gif> <a href=""$2"" target=_blank title=""提示:"&chr(13)&"您可以单击右键另存为把该文件下载到本地机器"">$3</a><p>")
re.pattern="(\[url\])(.*?)(\[\/url\])"
strcontent= re.replace(strcontent,"<a href=""$2"" target=_blank>$2</a>")
re.pattern="(\[url=(http|https|ftp|rtsp|mms)(:\/\/)(.*?)\])(.*?)(\[\/url\])"
strcontent= re.replace(strcontent,"<a href=""$2$3$4"" target=_blank>$5</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 = "(^|\s|<br>|<p>)(http|https|ftp|rtsp|mms)(:\/\/)(\s+)"
strcontent = re.replace(strcontent,"$1<a target=_blank href=$2$3$4>$4</a>")
re.pattern = "(^|\s|<br>|<p>)(www.)(\s+)"
strcontent = re.replace(strcontent,"$1<a target=_blank href=http://$2$3>$2$3</a>")
'文本效果
re.pattern="(\[list\])(.+?)(\[\/list\])"
strcontent=re.replace(strcontent,"<ul type=square>$2</ul>")
re.pattern="(\[list=)(a|1)(\])(.+?)(\[\/list\])"
strcontent=re.replace(strcontent,"<ol type=$2>$4</ol>")
re.pattern="(\[\*\])"
strcontent=re.replace(strcontent,"<li>")
re.pattern="(\[color=(.*?)\])(.*?)(\[\/color\])"
strcontent=re.replace(strcontent,"<font color=$2>$3</font>")
re.pattern="(\[#(.{6}?)\])(.*?)(\[\/#\])"
strcontent=re.replace(strcontent,"<font color=#$2>$3</font>")
re.pattern="(\[font=(.*?)\])(.*?)(\[\/font\])"
strcontent=re.replace(strcontent,"<font face=$2>$3</font>")
re.pattern="(\[align=(left|center|right)\])(.*?)(\[\/align\])"
strcontent=re.replace(strcontent,"<div align=$2>$3</div>")
re.pattern="(\[fly\])(.*?)(\[\/fly\])"
strcontent=re.replace(strcontent,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
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>")
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="(\[sup\])(.*?)(\[\/sup\])"
strcontent=re.replace(strcontent,"<sup>$2</sup>")
re.pattern="(\[sub\])(.*?)(\[\/sub\])"
strcontent=re.replace(strcontent,"<sub>$2</sub>")
re.pattern="\[size=([+|-]?[0-7])\](.*?)(\[\/size\])"
strcontent=re.replace(strcontent,"<font size=$1>$2</font>")
re.pattern="(\[center\])(.*?)(\[\/center\])"
strcontent=re.replace(strcontent,"<center>$2</center>")
set re=nothing
gmt=strcontent
end function
rem 过滤html代码
function htmlfilter(fstring)
if not isnull(fstring) then
fstring=server.htmlencode(fstring)
fstring = replace(fstring, chr(9), " ") 'tab
' fstring = replace(fstring, chr(34), """) '"
' fstring = replace(fstring, chr(39), "'") ''
fstring = replace(fstring, chr(13), "") '回车是一个13+10
fstring = replace(fstring, chr(10) & chr(10), " <p>") '
fstring = replace(fstring, chr(10), " <br>")
' fstring = replace(fstring, chr(32), " ") ' 空格
htmlfilter = fstring
end if
end function
%>
<%
function isemail(strng)
isemail = false
dim regex, match ' create variables.
set regex = new regexp ' create a regular expression object (stupid, huh?)
regex.pattern = "^\w+((-\w+)|(\.\w+))*\@[a-za-z0-9]+((\.|-)[a-za-z0-9]+)*\.[a-za-z0-9]+$" ' sets pattern.
regex.ignorecase = true ' set case insensitivity.
set match = regex.execute(strng) ' execute search.
if match.count then isemail= true
end function
%>
上一篇: OL7.6上RPM方式安装Oracle 19c的教程
下一篇: asp 正则 过滤重复字符串的代码