通行证: 用户 密码 域名空间  下载中心 社区论坛 信息公告 my小屋
联系我们
设为首页
加入收藏

 

qq,asp,php,jsp,xml,sql,.net,编程 程序 网页图象 建站经验 私服
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿
论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图
专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版
社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务
当前位置:首页>>网页设计>>dreamweaver>>正文 新版上线![旧版]
注:打开慢时请稍等

ubb 转换函数演示

http://www.iyit.net  日期:2006-5-27 9:52:20  来源:网络转载    点击:
参加讨论

    ubb代码对于经常上论坛的朋友来说是最熟悉不过了。
经典论坛的ubb转换我觉得是处理的非常好的,研究了一下它的转换结果[因为没有源码:)],做了下面的演示。转换结果基本上觉得象了。

    主要是针对[code][html]这两个标签的处理,其他的ubb标签还是一般的处理方法。

    下面是分别用javascript和vbscript实现的演示。自己做论坛的朋友,如果想实现类似经典论坛的运行代码框可以看看这种转换。

欢迎大家输入尽量多格式的ubb进行测试,多多指出错误。

javascript:

<style>
.codesamp {
 padding-right: 0.5em; margin-top: 1em; padding-left: 0.5em; font-size: 8p; margin-bottom: 1em; padding-bottom: 0.5em; margin-left: 0pt; padding-top: 0.5em; font-family: "courier new"; background-color: #eeeeee;width: 480px;overflow:hidden;border: 1px solid #888888;
}
textarea {
border-width: 1; border-color: #000000;font-size: 12px;font-family: "tahoma", "ms shell dlg";
}
</style>

<textarea name=phx cols=65 rows=12>
[i][b][color=blue]blue[/color][/b][/i]

[html][color=red]te
st[/color][/html]

[html][code]te
st[/code][/html]

[code][html]te
st[/html][/code]</textarea>
<br><button onclick=show.innerhtml=ubbcode(phx.value,"html")>转换</button><br>
<div id=show style="border:1 solid skyblue;width=500;font-size: 12px;font-family:
'tahoma', 'ms shell dlg';
"></div>


<script>
stricons = "1"  //允许笑脸转换
strsmile="1"   //同上
imgname="em"
picurl="pic/"

function ubbcode(content,html){
st=new date().gettime()
content=content.replace(/\[(\/)?phx_code\]/ig,"{$1phx_code}");
content=content.replace(/\[(\/)?phx_html\]/ig,"{$1phx_html}");
content="[phx_code]"+content+"[/phx_code]";         
content=content.replace(/(\[code\]([\s\s]+?)\[\/code\])/ig,"[/phx_code]$1[phx_code]");
content=content.replace(/\[phx_code\]([\s\s]*?)\[\/phx_code\]/ig,function($1,$2){if(html=="html"){return(htmlcode($2));}else{return(trans($2));}});
content=content.replace(/\[code\](\r\n)?([\s\s]+?)\[\/code\]/ig,function($1,$2,$3){return("<pre class=codesamp>"+dvbbshtmlan($3)+"</pre>")});
content=content.replace(/\{(\/)?phx_code\}/ig,"[$1phx_code]");
content=content.replace(/\{(\/)?phx_html\}/ig,"[$1phx_html]");
alert('共耗时 '+eval(new date().gettime()-st)+' ms');
return(content);
}

function htmlcode(content){  
content="[phx_html]"+content+"[/phx_html]";   
content=content.replace(/(\[html\]([\s\s]+?)\[\/html\])/ig,"[/phx_html]$1[phx_html]");
content=content.replace(/\[phx_html\]([\s\s]*?)\[\/phx_html\]/ig,function($1,$2){return(trans($2))});
content=content.replace(/\[html\]([\s\s]+?)\[\/html\]/ig,function($1,$2){return("<span><textarea cols=95 rows=12>"+hencode($2)+"</textarea><br><input onclick=runcode() type=button value=运行代码>[ctrl+a 全部选择 提示:你可先修改部分代码,再按运行]</span>")});
return(content);
}

function hencode(fstring){  //简单模拟server.htmlencode   asp中不用这个
 fstring = fstring.replace(/&/ig,"&amp;")
 fstring = fstring.replace(/>/ig,"&gt;") //>
 fstring = fstring.replace(/</ig,"&lt;") //<
return fstring;
}

function dvbbshtmlan(fstring){

if(fstring=="")return("");

fstring=hencode(fstring)

 fstring = fstring.replace(/\t/ig,"&nbsp;&nbsp;&nbsp;") //tab
 fstring = fstring.replace(/"/ig,"&quot;")    //"
 fstring = fstring.replace(/'/ig,"&#39;")    //'
 fstring = fstring.replace(/\r/ig,"")     //回车是一个13+10
 fstring = fstring.replace(/\n\n/ig,"<p>")    // 
 fstring = fstring.replace(/\n/ig,"<br>")    //换行
 fstring = fstring.replace(/\x20/ig,"&nbsp;")   //空格 


return(fstring);
}

function trans(strcontent){
var re;
strcontent=dvbbshtmlan(strcontent);
 
 re=/\[img\](.+?)\[\/img\]/ig;
 strcontent=strcontent.replace(re,"<a href=$1 target=_blank><img src=$1 border=0 alt=按此在新窗口浏览图片 onload=\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\" galleryimg=no></a>");
 re=/\[dir=*([0-9]*),*([0-9]*)\](.*?)\[\/dir]/ig
 strcontent=strcontent.replace(re,"<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=/\[qt=*([0-9]*),*([0-9]*)\](.*?)\[\/qt]/ig
 strcontent=strcontent.replace(re,"<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=/\[mp=*([0-9]*),*([0-9]*)\](.*?)\[\/mp]/ig
 strcontent=strcontent.replace(re,"<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>")
 re=/\[rm=*([0-9]*),*([0-9]*)\](.*?)\[\/rm]/ig
 strcontent=strcontent.replace(re,"<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=/(\[flash\])(.*?)(\[\/flash\])/ig
 strcontent= strcontent.replace(re,"<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=/(\[flash=*([0-9]*),*([0-9]*)\])(.*?)(\[\/flash\])/ig
 strcontent= strcontent.replace(re,"<a href=$4 target=_blank><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709520919961.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>")

 re=/(\[upload=gif\])(.*?)(\[\/upload\])/ig
 strcontent= strcontent.replace(re,"<br><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521026190.gif" border=0>此主题相关图片如下:<br><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>")
 re=/(\[upload=jpg\])(.*?)(\[\/upload\])/ig
 strcontent= strcontent.replace(re,"<br><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521066480.gif" border=0>此主题相关图片如下:<br><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>")
 re=/(\[upload=bmp\])(.*?)(\[\/upload\])/ig
 strcontent= strcontent.replace(re,"<br><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521018172.gif" border=0>此主题相关图片如下:<br><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>")

 re=/(\[upload=(.[^\[]*)\])(.*?)(\[\/upload\])/ig
 strcontent= strcontent.replace(re,"<br><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521061925.gif" border=0> <a href=$3>点击浏览该文件</a>")

 re=/(\[url\])(.*?)(\[\/url\])/ig
 strcontent= strcontent.replace(re,"<a href=$2 target=_blank>$2</a>")
 re=/(\[url=(.[^\[]*)\])(.*?)(\[\/url\])/ig
 strcontent= strcontent.replace(re,"<a href=$2 target=_blank>$3</a>")

 re=/(\[email\])(.*?)(\[\/email\])/ig
 strcontent= strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521056342.gif"><a href=\"$2mailto:$2\">$2</a>")
 re=/(\[email=(.[^\[]*)\])(.*?)(\[\/email\])/ig
 strcontent= strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521056342.gif"><a href=\"mailto:$2\" target=_blank>$3</a>")

 re =/^(http:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/(http:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)$/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/[^>=""](http:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/^(ftp:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/(ftp:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)$/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/[^>=""](ftp:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/^(rtsp:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/(rtsp:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)$/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/[^>=""](rtsp:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/^(mms:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/(mms:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)$/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re =/[^>=""](mms:\/\/[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strcontent = strcontent.replace(re,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")

 if(stricons == "1"){                       //笑脸转换
 re=/(\[em(.*?)\])/ig
 strcontent=strcontent.replace(re,"<img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521448617.gif" border=0 align=middle>")
 }

 if(strsmile == "1"){                       //笑脸转换
 re=/(\[s(\d{1,2})\])/ig
 strcontent=strcontent.replace(re,"<img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521587415.gif" border=0 align=middle>")
 }

 re=/(\[color=(.[^\[]*)\])(.*?)(\[\/color\])/ig
 strcontent=strcontent.replace(re,"<font color=$2>$3</font>")
 re=/(\[face=(.[^\[]*)\])(.*?)(\[\/face\])/ig
 strcontent=strcontent.replace(re,"<font face=$2>$3</font>")
 re=/(\[align=(.[^\[]*)\])(.*?)(\[\/align\])/ig
 strcontent=strcontent.replace(re,"<div align=$2>$3</div>")
//循环转换quote
 re=/(\[quote\])(.*?)(\[\/quote\])/ig
 while(strcontent.indexof("[quote]")>0 && strcontent.indexof("[/quote] ")>0){
 strcontent=strcontent.replace(re,"<blockquote>引用:<hr><span>$2</span><hr></blockquote>")
 }
 re=/(\[fly\])(.*?)(\[\/fly\])/ig
 strcontent=strcontent.replace(re,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
 re=/(\[move\])(.*?)(\[\/move\])/ig
 strcontent=strcontent.replace(re,"<marquee scrollamount=3>$2</marquee>") 
 re=/\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.*?)\[\/glow]/ig
 strcontent=strcontent.replace(re,"<table width=$1 style=\"filter:glow(color=$2, strength=$3)\">$4</table>")
 re=/\[shadow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.*?)\[\/shadow]/ig
 strcontent=strcontent.replace(re,"<table width=$1 style=\"filter:shadow(color=$2, strength=$3)\">$4</table>")

 re=/(\[i\])(.*?)(\[\/i\])/ig
 strcontent=strcontent.replace(re,"<i>$2</i>")
 re=/(\[u\])(.*?)(\[\/u\])/ig
 strcontent=strcontent.replace(re,"<u>$2</u>")
 re=/(\[b\])(.*?)(\[\/b\])/ig
 strcontent=strcontent.replace(re,"<b>$2</b>")

 re=/(\[size=1\])(.*?)(\[\/size\])/ig
 strcontent=strcontent.replace(re,"<font size=1>$2</font>")
 re=/(\[size=2\])(.*?)(\[\/size\])/ig
 strcontent=strcontent.replace(re,"<font size=2>$2</font>")
 re=/(\[size=3\])(.*?)(\[\/size\])/ig
 strcontent=strcontent.replace(re,"<font size=5>$2</font>")
 re=/(\[size=4\])(.*?)(\[\/size\])/ig
 strcontent=strcontent.replace(re,"<font size=6>$2</font>")
 
 re=/\[size=([+|-]?[0-7])\](.*?)(\[\/size\])/ig
 strcontent=strcontent.replace(re,"<font size=$1>$2</font>")
 
 re=/(\[list\])(.+?)(\[\/list\])/ig;
    strcontent=strcontent.replace(re,"<ul type=square>$2<\/ul>");
    re=/(\[list=)(a|1)(\])(.+?)(\[\/list\])/ig;
    strcontent=strcontent.replace(re,"<ol type=$2>$4<\/ol>");
    re=/(\[\*\])/ig;
    strcontent=strcontent.replace(re,"<li>");

 re=/(\[center\])(.*?)(\[\/center\])/ig
 strcontent=strcontent.replace(re,"<center>$2</center>")

 re=/(\[table=(#*[a-z0-9]*),(#*[a-z0-9]*),(#*[a-z0-9]*)\])(.*?)(\[\/table\])/ig
 strcontent=strcontent.replace(re,"<table border=0 cellpadding=5 cellspacing=1 bgcolor=$2><tr><td bgcolor=$3><font color=$4>$5</font></td></tr></table>")

return(strcontent);
}
</script>

vbscript:

<style>
.codesamp {
 padding-right: 0.5em; margin-top: 1em; padding-left: 0.5em; font-size: 8p; margin-bottom: 1em; padding-bottom: 0.5em; margin-left: 0pt; padding-top: 0.5em; font-family: "courier new"; background-color: #eeeeee;width: 480px;overflow:hidden;border: 1px solid #888888;
}
textarea {
border-width: 1; border-color: #000000;font-size: 12px;font-family: "tahoma", "ms shell dlg";
}
</style>

<textarea name=phx cols=65 rows=12>
[i][b][color=blue]blue[/color][/b][/i]

[html][color=red]te
st[/color][/html]

[html][code]te
st[/code][/html]

[code][html]te
st[/html][/code]</textarea>
<br><button onclick=show.innerhtml=ubbcode(phx.value)>转换</button><br>
<div id=show style="border:1 solid skyblue;width=500;font-size: 12px;font-family:
'tahoma', 'ms shell dlg';
"></div>


<script language=vbs>
stricons = "1"  '允许笑脸转换
strsmile="1"   '同上
imgname="em"
picurl="pic/"

function ubbcode(content)
'on error resume next
st=timer
set re=new regexp
re.global=true

re.pattern="\[code\](\r\n)?([\s\s]+?)\[\/code\]"
set matches = re.execute(content)   ' execute search.
dim code()
n=0
if re.test(content) then codeb=true
if codeb then
  for each match in matches      ' iterate matches collection.
   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


re.pattern="\[html\](\r\n)?([\s\s]+?)\[\/html\]"
set matches = re.execute(content)   ' execute search.
dim html()
n=0
if re.test(content) then htmlb=true
if htmlb then
  for each match in matches      ' iterate matches collection.
   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

content=gmt(content)    'ubb


if codeb then
for i=0 to ubound(code)
if code(i)="" then exit for
tcode=hencode(code(i))
content=replace(content,"{code"&i&"}",tcode)
next
end if
'-----
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 htmlb then
for i=0 to ubound(html)
if html(i)="" then exit for
thtml=hencode(html(i))
content=replace(content,"{html"&i&"}",thtml)
next
end if

re.pattern="(\[code\])(\r\n)?([\s\s]+?)(\[\/code\])"
content=re.replace(content,"<pre class=codesamp>$3</pre>")

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=运行代码>[ctrl+a 全部选择 提示:你可先修改部分代码,再按运行]</span>")

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
msgbox "转换共耗时 "&formatnumber((timer-st)*1000,2)&" ms"
end function

 

function hencode(fstring)  '简单模拟server.htmlencode   asp中不用这个
 fstring = replace(fstring,"&","&amp;")
 fstring = replace(fstring,">","&gt;") 
 fstring = replace(fstring,"<","&lt;") 
hencode=fstring
end function

function dvbbshtmlan(fstring)

if not isnull(fstring) then
 
fstring=hencode(fstring)
 fstring = replace(fstring, chr(9), "&nbsp;&nbsp;&nbsp;") 'tab
 fstring = replace(fstring, chr(34), "&quot;")   '"
 fstring = replace(fstring, chr(39), "&#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), "&nbsp;")   ' 空格
 
 dvbbshtmlan = fstring
end if
end function

function gmt(strcontent)

strcontent=dvbbshtmlan(strcontent)
 
 dim re
 set re=new regexp
 re.ignorecase =true
 re.global=true

 re.pattern="(\[img\])(.*?)(\[\/img\])"
 strcontent=re.replace(strcontent,"<a href=$2 target=_blank><img src=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333"" galleryimg=no></a>")

 if not usersign or (usersign and userimgcode=1) then
 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=*([0-9]*),*([0-9]*)\](.*?)\[\/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=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>")
 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>")
 end if

 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=*([0-9]*),*([0-9]*)\])(.*?)(\[\/flash\])"
 strcontent= re.replace(strcontent,"<a href=""$4"" target=_blank><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709520919961.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>")

 re.pattern="(\[upload=gif\])(.*?)(\[\/upload\])"
 strcontent= re.replace(strcontent,"<br><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521630189.gif"" border=0>此主题相关图片如下:<br><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>")
 re.pattern="(\[upload=jpg\])(.*?)(\[\/upload\])"
 strcontent= re.replace(strcontent,"<br><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521611915.gif"" border=0>此主题相关图片如下:<br><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>")
 re.pattern="(\[upload=bmp\])(.*?)(\[\/upload\])"
 strcontent= re.replace(strcontent,"<br><img src="http://www.iyit.net/files/beyondpic/2006-5/27/065270952169480.gif"" border=0>此主题相关图片如下:<br><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>")

 re.pattern="(\[upload=(.[^\[]*)\])(.*?)(\[\/upload\])"
 strcontent= re.replace(strcontent,"<br><img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521622137.gif"" border=0> <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,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521056342.gif"><a href=""$2mailto:$2"">$2</a>")
 re.pattern="(\[email=(.[^\[]*)\])(.*?)(\[\/email\])"
 strcontent= re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521056342.gif"><a href=""mailto:$2"" target=_blank>$3</a>")

 re.pattern = "^(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "(<br>|<p>)(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)(<br>|<p>)"
 strcontent = re.replace(strcontent,"$1<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$2>$2</a>$3")
 re.pattern = "^(ftp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "(ftp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "[^>=""](ftp://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "^(rtsp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "(rtsp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "[^>=""](rtsp://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "^(mms://[a-za-z0-9\./=\?%\-&_~`@':+!]+)"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "(mms://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")
 re.pattern = "[^>=""](mms://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strcontent = re.replace(strcontent,"<img align=absmiddle src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521173535.gif"><a target=_blank href=$1>$1</a>")

 if stricons = "1" then                       '笑脸转换
 re.pattern="(\["&imgname&"(.*?)\])"
 strcontent=re.replace(strcontent,"<img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521990049.gif" border=0 align=middle>")
 end if

 if strsmile = "1" then                       '笑脸转换
 re.pattern="(\[s(\d{1,2})\])"
 strcontent=re.replace(strcontent,"<img src="http://www.iyit.net/files/beyondpic/2006-5/27/0652709521587415.gif" border=0 align=middle>")
 end if


 re.pattern="(\[color=(.[^\[]*)\])(.*?)(\[\/color\])"
 strcontent=re.replace(strcontent,"<font color=$2 style=""font-size:"&fontsize&"pt;line-height:"&fontheight&"pt"">$3</font>")
 re.pattern="(\[face=(.[^\[]*)\])(.*?)(\[\/face\])"
 strcontent=re.replace(strcontent,"<font face=$2 style=""font-size:"&fontsize&"pt;line-height:"&fontheight&"pt"">$3</font>")
 re.pattern="(\[align=(.[^\[]*)\])(.*?)(\[\/align\])"
 strcontent=re.replace(strcontent,"<div align=$2>$3</div>")
'循环转换quote
 re.pattern="(\[quote\])(.*?)(\[\/quote\])"
 while (instr(strcontent,"[quote]")>0 and instr(strcontent,"[/quote]")>0)
 strcontent=re.replace(strcontent,"<blockquote>引用:<hr><span>$2</span><hr></blockquote>")
 wend
 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="(\[size=1\])(.*?)(\[\/size\])"
 strcontent=re.replace(strcontent,"<font size=1 style=""line-height:"&fontheight&"pt"">$2</font>")
 re.pattern="(\[size=2\])(.*?)(\[\/size\])"
 strcontent=re.replace(strcontent,"<font size=2 style=""line-height:"&fontheight&"pt"">$2</font>")
 re.pattern="(\[size=3\])(.*?)(\[\/size\])"
 strcontent=re.replace(strcontent,"<font size=5 style=""line-height:"&fontheight&"pt"">$2</font>")
 re.pattern="(\[size=4\])(.*?)(\[\/size\])"
 strcontent=re.replace(strcontent,"<font size=6 style=""line-height:"&fontheight&"pt"">$2</font>")
 
 re.pattern="\[size=([+|-]?[0-7])\](.*?)(\[\/size\])"
 strcontent=re.replace(strcontent,"<font size=$1 style=""line-height:"&fontheight&"pt"">$2</font>")

 re.pattern="(\[center\])(.*?)(\[\/center\])"
 strcontent=re.replace(strcontent,"<center>$2</center>")

 re.pattern="(\[table=(#*[a-z0-9]*),(#*[a-z0-9]*),(#*[a-z0-9]*)\])(.*?)(\[\/table\])"
 strcontent=re.replace(strcontent,"<table border=0 cellpadding=5 cellspacing=1 bgcolor=$2><tr><td bgcolor=$3><font color=$4>$5</font></td></tr></table>")

'[html/] start
 're.pattern="(\[html\])(.*?)(\[\/html\])"
 'strcontent=re.replace(strcontent,"<span><textarea cols=95 rows=12>$2</textarea><br><input onclick=runcode() type=button value=运行代码>[ctrl+a 全部选择 提示:你可先修改部分代码,再按运行]</span>")
       

'[html/] end  
 


 set re=nothing
 gmt=strcontent
end function

</script>

 

 



编辑:黑鹰 [
发送给好友] [打印本页] [关闭窗口] [返回顶部]
上一篇:用js封装的时间设置器
下一篇:用 onerror 获取错误信息
转载请注明来源:www.iyit.net
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

 相关文章
最新更新 热点排行 推荐新闻
dreamwavermx与asp.net(十四)
dreamwavermx与asp.net(十三)
dreamwavermx与asp.net(十一)
dreamwavermx与asp.net(十)
dreamwavermx与asp.net(九)
dreamwavermx与asp.net(十四)
dreamwavermx与asp.net(十三)
dreamwavermx与asp.net(十一)
dreamwavermx与asp.net(十)
dreamwavermx与asp.net(九)
dreamwavermx与asp.net(八)
dreamwavermx与asp.net(七)
dreamwavermx与asp.net(六)
dreamwavermx与asp.net(五)
dreamwavermx与asp.net(四)
表格边框魔鬼教程
驯服不听话的网页表格
dreamweaver的行为事件
dreamweaver制作网页幻灯片效果
去除dw mx 2004表格宽度辅助
优秀公益广告作品欣赏(8)
java数据类型转换
windows xp专业版iis连接数的更改
新开放qq免费挂级网站
优秀公益广告作品欣赏(7)
免费在qq上看在线电影电视听音乐
office2007简体中文版浮出水面 美图抢
qq珊瑚虫外挂4.0版本发布!
web服务器配置全攻略(三)
免费把qq炫铃设为本机qq的系统提示音
msn8.0下载
asp 五大高效提速技巧
如何在win20003中更好的玩游戏
qq收费头像免费使用的方法 
微软将在华推分期付款,充值卡pc 可低价
 amd处理器am2测试 风扇竟运行7分钟
exeplorer.exe错误的问题的总结、解决
asp.net 2.0 中的异步页功能应用
硬盘坏道修复及数据恢复宝典
免费登录搜索引擎入口大全
 友情链接
设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接
copyrights © 2004-2006 iyit.net all rights reserved.
网站合作、广告联系qq:147007642、466949678
易特网络技术 点击这里给我发消息