欢迎光临
我们一直在努力

UBB代码~(整理)-ASP教程,脚本编码

建站超值云服务器,限时71元/月

在论坛中,我常常要使用到特殊的显示效果,而要得到这些效果,我们通常都是使用ubb 函数来处理,下面是我整理的ubb代码~,有待完善~

[code]

———————————————————-

——————–ubbcode function———————-

———————————————————-

function ubbcode(byval strvalue)

忽略错误

on error resume next

定义变量

dim regexp

dim strnewvalue

set regexp = new regexp

regexp.ignorecase = true

regexp.global = true

strvalue = ucase(htmlencode(strvalue))

if strvalue <> "" then

regexp.pattern = "(\[url\])(.[^\[]*)(\[\/url\])"

strnewvalue = regexp.replace(strvalue,"<a href=http://$2 target=_blank>$2</a>")

regexp.pattern = "(\[url\])(http:\/\/.[^\[]*)(\[\/url\])"

strnewvalue = regexp.replace(strvalue,"<a href=$2 target=_blank>$2</a>")

regexp.pattern = "(\[url=(http:\/\/.[^\[]*)\])(.[^\[]*)(\[\/url\])"

strnewvalue = regexp.replace(strvalue,"<a href=$2 target=_blank>$3</a>")

regexp.pattern = "(\[url=(.[^\[]*)\])(.[^\[]*)(\[\/url\])"

strnewvalue = regexp.replace(strvalue,"<a href=http://$2 target=_blank>$3</a>")

regexp.pattern = "(\[img\])(.[^\[]*)(\[\/img\])"

strnewvalue = regexp.replace(strnewvalue,"<img src=$2 border=0>")

regexp.pattern = "(\[img=(http:\/\/.[^\[]*)\])(\[\/img\])"

strnewvalue = regexp.replace(strnewvalue,"<img src=$2 border=0>")

regexp.pattern = "(\[img=(.[^\[]*)\])(\[\/img\])"

strnewvalue = regexp.replace(strnewvalue,"<img src=http://$2 border=0>")

regexp.pattern = "(\[size=([0-9]*)\])(.[^\[]*)(\[\/size\])"

strnewvalue = regexp.replace(strnewvalue,"<font size=$2>$3</font>")

regexp.pattern = "(\[b\])(.[^\[]*)(\[\/b\])"

strnewvalue = regexp.replace(strnewvalue,"<b>$2</b>")

regexp.pattern = "(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/red\])"

strnewvalue = regexp.replace(strnewvalue,"<font color=$2>$3</font>")

regexp.pattern = "(\[red\])(.[^\[]*)(\[\/red\])"

strnewvalue = regexp.replace(strnewvalue,"<font color=#ff0000>$2</font>")

regexp.pattern = "(\[green\])(.[^\[]*)(\[\/green\])"

strnewvalue = regexp.replace(strnewvalue,"<font color=#009900>$2</font>")

regexp.pattern = "(\[blue\])(.[^\[]*)(\[\/blue\])"

strnewvalue = regexp.replace(strnewvalue,"<font color=#000099>$2</font>")

regexp.pattern = "(\[gray\])(.[^\[]*)(\[\/gray\])"

strnewvalue = regexp.replace(strnewvalue,"<font color=#999999>$2</font>")

regexp.pattern = "(\[s\])(.[^\[]*)(\[\/s\])"

strnewvalue = regexp.replace(strnewvalue,"<font style=text-decoration:line-through>$2</font>")

regexp.pattern = "(\[i\])(.[^\[]*)(\[\/i\])"

strnewvalue = regexp.replace(strnewvalue,"<i>$2</i>")

regexp.pattern = "(\[u\])(.[^\[]*)(\[\/u\])"

strnewvalue = regexp.replace(strnewvalue,"<u>$2</u>")

regexp.pattern = "(\[align=(.[^\[]*)\])(.[^\[]*)(\[\/align\])"

strnewvalue = regexp.replace(strnewvalue,"<div align=$2>$3</div>")

regexp.pattern = "(\[center\])(.[^\[]*)(\[\/center\])"

strnewvalue = regexp.replace(strnewvalue,"<center>$2</center>")

regexp.pattern = "(\[email\])(.[^\[]*)(\[\/email\])"

strnewvalue = regexp.replace(strnewvalue,"<a href=mailto:$2>$2</a>")

regexp.pattern = "(\[email=(.[^\[]*)\])(.[^\[]*)(\[\/email\])"

strnewvalue = regexp.replace(strnewvalue,"<a href=mailto:$2>$3</a>")

regexp.pattern = "(\[fly\])(.[^\[]*)(\[\/fly\])"

strnewvalue = regexp.replace(strnewvalue,"<marquee scrollamout=3 behavior=alternate width=98%>$2</marquee>")

regexp.pattern = "(\[move\])(.[^\[]*)(\[\/move\])"

strnewvalue = regexp.replace(strnewvalue,"<marquee scrollamout=3>$2</marquee>")

regexp.pattern = "(\[mp=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/mp\])"

strnewvalue = regexp.replace(strnewvalue,"<object align=middle classid=clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=object id=mediaplayer width=$2 height=$3><param name=showstatusbar value=-1><param name=filename value=$4><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplaer/en/nsmp2inf.cab#version=5,1,52,701 filename=mp src=$4 width=$2 height=$3></embed></object>")

regexp.pattern = "(\[flash\])(.[^\[]*)(\[\/flash\])"

strnewvalue = regexp.replace(strnewvalue,"<object codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,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/shockwave/download/index.cgi?p1_prod_version=shockwaveflash type=application/s-shockwave-flash width=500 height=400>$2</embed></object>")

regexp.pattern = "(\[qt=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/qt\])"

strnewvalue = regexp.replace(strnewvalue,"<embed src=$4 width=$2 height=$3 autoplay=true loop=false controller=true playeveryframe=false cache=false scale=tofit bgcolor=#000000 kioskmode=false targetcache=false pluginspage=http://www.apple.com/quicktime/>")

regexp.pattern = "(\[rm=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/rm\])"

strnewvalue = regexp.replace(strnewvalue,"<object classid=clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa class=object id=raocx width=$2 height=$3><param name=src value=$4><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=$3><param name=src value=$4><param name=autostart value=-1><param name=controls value=controlpanel><param name=console value=clip1></object>")

end if

ubbcode = lcase(strnewvalue)

输出错误

if err.number>0 then

response.write err.description

response.end

end if

end function

———————————————————-

——————-htmlencode function——————–

———————————————————-

function htmlencode(byval strvalue)

忽略错误

on error resume next

定义变量

dim strnewvalue

if strvalue <> "" then

strvalue = server.htmlencode(strvalue)

strnewvalue = replace(strvalue,"<","&lt;")

strnewvalue = replace(strnewvalue,">","&gt;")

strnewvalue = replace(strnewvalue,"","&#39;")

strnewvalue = replace(strnewvalue,"""","&quot;")

strnewvalue = replace(strnewvalue,vbcrlf,"<br>")

strnewvalue = replace(strnewvalue," ","&nbsp;")

end if

htmlencode = strnewvalue

输出错误

if err.number>0 then

response.write err.description

response.end

end if

end function

[code]

使用的时候,在你的textarea中输入ubb代码,那么,在处理页面直接使用

content = ubbcode(request.form("content"))就可以咯~

关于ubb的书写,可以在网上搜索,我就不说咯!

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » UBB代码~(整理)-ASP教程,脚本编码
分享到: 更多 (0)

相关推荐

  • 暂无文章