分享
 
 
 

UBB(vb.net完整版)(我的小毛驴)(2004年)

王朝vb·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

最近一段时间我用vb.net做论坛,在网上找了一下,虽然有关于ubb(vb.net)的转换代码,可是都不全面,我在这里补充了一下,拿出来和大家共享。

有什么问题到我个人的论坛

www.hushiyu.com来交流,随时欢迎。

Public Class ubbs

function ubb(vstr as string)

'替换HTML标记及换行处理

vstr = replace(vstr, ">", ">")

vstr = replace(vstr, "<", "<")

vstr = Replace(vstr, CHR(32), " ")

vstr = Replace(vstr, CHR(9), " ")

vstr = Replace(vstr, CHR(34), """)

vstr = Replace(vstr, CHR(39), "'")

vstr = Replace(vstr, CHR(13), "")

vstr = Replace(vstr, CHR(10), "<BR> ")

vstr = Replace(vstr, "[enter]", "<BR> ")

dim xface as integer

if xface=1 then

'表情转换,数值型变量xface=1时,允许转换

vstr = replace(vstr,":)","<img src=""em/em1.gif"">")

vstr = replace(vstr,":(","<img src=""em/em2.gif"">")

vstr = replace(vstr,":o","<img src=""em/em3.gif"">")

vstr = replace(vstr,":D","<img src=""em/em4.gif"">")

vstr = replace(vstr,";)","<img src=""em/em5.gif"">")

vstr = replace(vstr,":p","<img src=""em/em6.gif"">")

vstr = replace(vstr,":cool:","<img src=""em/em7.gif"">")

vstr = replace(vstr,":mad:","<img src=""em/em8.gif"">")

vstr = replace(vstr,":eek:","<img src=""em/em9.gif"">")

vstr = replace(vstr,":?:","<img src=""em/em0.gif"">")

end if

dim objregex as RegEx

'屏蔽JS等等

objregex = new regex("javascript")

vstr = objregex.replace(vstr,"javascript")

objregex = new regex("jscript:")

vstr = objregex.replace(vstr,"jscript:")

objregex = new regex("js:")

vstr = objregex.replace(vstr,"js:")

objregex = new regex("value")

vstr = objregex.replace(vstr,"value")

objregex = new regex("about:")

vstr = objregex.replace(vstr,"about:")

objregex = new regex("file:")

vstr = objregex.replace(vstr,"file:")

objregex = new regex("document.cookie")

vstr = objregex.replace(vstr,"documents.cookie")

objregex = new regex("vbscript:")

vstr = objregex.replace(vstr,"vbscript:")

objregex = new regex("vbs:")

vstr = objregex.replace(vstr,"vbs:")

objregex = new regex("(on(mouse|exit|error|click|key))")

vstr = objregex.replace(vstr,"on$2")

objregex = new regex("script")

vstr = objregex.replace(vstr,"script")

'UBB转换

'url

objregex = new regex("(\[URL=(.[^\[]*)\])(.*?)(\[\/URL\])")

vstr = objregex.replace(vstr,"<A HREF=""$2"" TARGET=_blank>$3</A>")

'EMAIL

objregex = new regex("\[EMAIL\](.[^\[]*)\[\/EMAIL\]")

vstr = objregex.replace(vstr,"<a href=""mailto:$1"" TARGET=""_blank"">$1</a>")

'IMG

objregex = new regex("\[IMG\](http|https|ftp):\/\/(.[^\[]*)\[\/IMG\]")

vstr = objregex.replace(vstr,"<br><a onfocus=this.blur() href=""$1://$2"" target=_blank><IMG SRC=""$1://$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")

'自动识别URL

objregex = new regex("\[url=(http:\/\/.[^\[]*)\](.[^\[]*)(\[\/url\])")

vstr = objregex.replace(vstr,"<a href=""$1"" target=""_blank"">$2</a>")

objregex = new regex("^(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)")

vstr = objregex.replace(vstr,"<a href=""$1"" target=""_blank"">$1</a>")

objregex = new regex("(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$")

vstr = objregex.replace(vstr,"<a target=_blank href=$1>$1</a>")

objregex = new regex("[^>=""](http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)")

vstr = objregex.replace(vstr,"<a target=_blank href=$1>$1</a>")

'COLOR

objregex = new regex("\[color=(.[^\[]*)\](.[^\[]*)\[\/color\]")

vstr = objregex.replace(vstr,"<font color=""$1"">$2</font>")

'u

objregex = new regex("\[U\](.*)\[\/U\]")

vstr = objregex.replace(vstr,"<U>$1</U>")

'B

objregex = new regex("\[B\](.*)\[\/B\]")

vstr = objregex.replace(vstr,"<B>$1</B>")

'I

objregex = new regex("\[I\](.*)\[\/I\]")

vstr = objregex.replace(vstr,"<I>$1</I>")

'FLY

objregex = new regex("\[fly\](.*)\[\/fly\]")

vstr = objregex.replace(vstr,"<marquee width=""80%"" behavior=""alternate"" scrollamount=""3"">$1</marquee>")

'SHADOW

objregex = new regex("\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]")

vstr = objregex.replace(vstr,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")

'GLOW

objregex = new regex("\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/glow]")

vstr = objregex.replace(vstr,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")

'center

objregex = new regex("(\[center\])(.*?)(\[\/center\])")

vstr = objregex.replace(vstr,"<center>$2</center>")

'CODE

objregex = new regex("\[code\](.*)\[\/code\]")

vstr = objregex.replace(vstr,"<table width=""80%"" border=""0"" cellpadding=""2"" cellspacing=""0"" bgcolor=""#99FFCC"" style=""border:1px solid #000000;font-size:9pt;font-family:tahoma""><tr><td>$1</td></tr></table>")

'FLASH

objregex = new regex("(\[falsh\])(.*?)(\[\/falsh\])")

vstr = objregex.replace(vstr,"<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>")

objregex = new regex("(\[falsh=*([0-9]*),*([0-9]*)\])(.*?)(\[\/falsh\])")

vstr = objregex.replace(vstr,"<a href=""$4"" TARGET=_blank><IMG SRC=pic/swf.gif border=0 alt=点击开新窗口欣赏该FLASH动画!> [全屏欣赏]</a><br><br><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>")

'dir

objregex = new regex("\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]")

vstr = objregex.replace(vstr,"<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>")

'rm

objregex = new regex("\[rm=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/rm]")

vstr = objregex.replace(vstr,"<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>")

'mp

objregex = new regex("\[mp=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/mp]")

vstr = objregex.replace(vstr,"<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=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 width=$1 height=$2></embed></object>")

'qt

objregex = new regex("\[qt=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/qt]")

vstr = objregex.replace(vstr,"<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/>")

'QUOTE

objregex = new regex("(\[QUOTE\])(.*)(\[\/QUOTE\])")

vstr = objregex.replace(vstr,"<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 >$2</table></table><br>")

'move

objregex = new regex("(\[move\])(.*)(\[\/move\])")

vstr = objregex.replace(vstr,"<MARQUEE scrollamount=3>$2</marquee>")

'size

objregex = new regex("(\[size=1\])(.[^\[]*)(\[\/size\])")

vstr = objregex.replace(vstr,"<font size=1>$2</font>")

objregex = new regex("(\[size=2\])(.[^\[]*)(\[\/size\])")

vstr = objregex.replace(vstr,"<font size=2>$2</font>")

objregex = new regex("(\[size=3\])(.[^\[]*)(\[\/size\])")

vstr = objregex.replace(vstr,"<font size=3>$2</font>")

objregex = new regex("(\[size=4\])(.[^\[]*)(\[\/size\])")

vstr = objregex.replace(vstr,"<font size=4>$2</font>")

'face

objregex = new regex("(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])")

vstr = objregex.replace(vstr,"<font face=$2>$3</font>")

'em

objregex = new regex("(\[em(.[^\[]*)\])")

vstr = objregex.replace(vstr,"<img src=pic\em$2.gif border=0 align=middle>")

'完成,还可以自己扩展

ubb = vstr

end function

End Class

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有