📄 ubbcode2.asp
字号:
<%
function ubbb2_base(byval str)
dim regEx
set regEx=new regExp
regEx.IgnoreCase=true
regEx.Global=true
if isnull(str) or str="" then
ubbb2_base=""
exit function
end if
regEx.Pattern="((ifr|fr)ame)"
str=regEx.Replace(str,"<I>$2ame</I>")
'regEx.pattern="<IMG.[^>]*SRC(=| )(.[^>]*)>"
'str=regEx.replace(str,"<img src=$2 border=0 alt=点此浏览本图大图 name=""carpic"" onload=""initimg(this,600,868)"" onclick=""window.open(this.src,null,'')"">")
regEx.pattern="\[UPLOAD=(gif|jpg|jpeg|bmp|png)\](.[^\[]*)(gif|jpg|jpeg|bmp)\[\/UPLOAD\]"
str=regEx.replace(str,"<br><SPAN style='CURSOR: hand'><IMG SRC=""upload/$2$1"" border=0 alt=点此浏览本图大图 name=""carpic"" onload=""initimg(this,600,868)"" onclick=""window.open(this.src,null,'')""></span>")
regEx.pattern="\[IMG\](http|https|ftp):\/\/(.[^\[]*)\[\/IMG\]"
str=regEx.replace(str,"<img src=$1://$2 border=0 alt=点此浏览本图大图 name=""carpic"" onload=""initimg(this,600,868)"" onclick=""window.open(this.src,null,'')"">")
regEx.pattern="(\[sound\])(.[^\[]*)(\[\/sound\])"
str=regEx.Replace(str,"<a href=""$2"" target=_blank><IMG SRC=pic/mid.gif border=0 alt='背景音乐'></a><bgsound src=""$2"" loop=""-1"">")
regEx.pattern="\[em([0-9]{1,2})]"
str=regEx.replace(str,"<img src=emot/em$1.gif>")
regEx.pattern="\[((/?b)|(/?u)|(/?sub)|(/?sup))\]"
str=regEx.replace(str,"<$1>")
regEx.pattern="\[i\]((.|\n)+?)\[/i\]"
str=regEx.replace(str,"<i>$1</i>")
regEx.pattern="\[color=((#.{6})|.{3,6})\]((.|\n)*?)\[/color\]"
str=regEx.replace(str,"<font color=#$1>$3</font>")
regEx.pattern="\[url=(.{5,}?)\](.+?)\[/url\]"
str=regEx.replace(str,"<a href=""$1"" target='_blank'>$2</a>")
regEx.Pattern="(\[url\])(http:\/\/\S+?)(\[\/url\])"
str=regEx.replace(str,"<a href=""$2"" target='_blank'>$2</a>")
regEx.pattern="\[EMAIL\]([^\s@]+@[^\.]+\..+?)\[\/EMAIL\]"
str=regEx.replace(str,"<a href=""mailto:$1"" target='_blank'>$1</a>")
regEx.pattern="\[EMAIL=([^\s@]+@[^\.]+?\..+?)\](.+?)\[\/EMAIL\]"
str=regEx.replace(str,"<a href=""mailto:$1"" target='_blank'>$2</a>")
regEx.Pattern="\[MP=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/MP]"
str=regEx.Replace(str,"<br><object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=$1 height=$2 >" & vbcrlf & "<PARAM NAME=AUTOSTART VALUE=0><param name=ShowStatusBar value=-1>" & vbcrlf & "<param name=Filename value=$3>" & vbcrlf & "<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>" & vbcrlf & "</embed>" & vbcrlf & "</object>")
regEx.Pattern="\[RM=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/RM]"
str=regEx.Replace(str,"<br><OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=$1 height=$2>" & vbcrlf & "<PARAM NAME=SRC VALUE=$3>" & vbcrlf & "<PARAM NAME=CONSOLE VALUE=Clip1>" & vbcrlf & "<PARAM NAME=CONTROLS VALUE=imagewindow>" & vbcrlf & "<PARAM NAME=AUTOSTART VALUE=false>" & vbcrlf & "</OBJECT>" & vbcrlf & "<br>" & vbcrlf & "<OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=$1>" & vbcrlf & "<PARAM NAME=SRC VALUE=$3>" & vbcrlf & "<PARAM NAME=AUTOSTART VALUE=0>" & vbcrlf & "<PARAM NAME=CONTROLS VALUE=controlpanel>" & vbcrlf & "<PARAM NAME=CONSOLE VALUE=Clip1>" & vbcrlf & "</OBJECT>")
regEx.Pattern="\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
str=regEx.Replace(str,"<OBJECT CLASSID=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 CODEBASE=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 WIDTH=$1 HEIGHT=$2>" & vbcrlf & "<PARAM NAME=movie VALUE=$3>" & vbcrlf & "<PARAM NAME=quality VALUE=high>" & vbcrlf & "<EMBED SRC=$3 QUALITY=high PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash TYPE=application/x-shockwave-flash WIDTH=$1 HEIGHT=$2>" & vbcrlf & "</EMBED>" & vbcrlf & "</OBJECT>")
regEx.Pattern="\[Ra\](.[^\[]*)\[\/Ra]"
str=regEx.replace(str,"[ <a href=$1>下载</a> ]<br><object classid=clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=280 height=70><param name=_ExtentX value=7938><param name=_ExtentY value=2646><param name=AUTOSTART value=0><param name=SHUFFLE value=0><param name=PREFETCH value=0><param name=NOLABELS value=0><param name=LOOP value=0><param name=NUMLOOP value=0><param name=CENTER value=0><param name=MAINTAINASPECT value=0><param name=BACKGROUNDCOLOR value=#000000><PARAM NAME=SRC VALUE=$1></object>")
regEx.pattern="\[align=(center|left|right)\](.*)\[\/align\]"
str=regEx.replace(str,"<div align=$1>$2</div>")
regEx.pattern="\[right\]((.|\n)+?)\[/right\]"
str=regEx.replace(str,"<div align=right>$1<//div>")
regEx.pattern="(\[quote\])((.|\n)+?)(\[\/quote\])"
str=regEx.replace(str,"<FIELDSET style='PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px;'><LEGEND>引用回复</LEGEND><BR>$2<BR></FIELDSET>")
regEx.pattern="\[SIZE=([1-4])\]((.|\n)+?)\[\/SIZE\]"
str=regEx.replace(str,"<font size=$1>$2</font>")
regEx.Pattern="(\[UPLOAD=(.[^\[]*)\])(.[^\[]*)(\[\/UPLOAD\])"
str=regEx.Replace(str,"<IMG SRC=""pic/$2.gif"" border=0> <a target=_blank href=upload/$3>点击浏览该文件</a>")
regEx.Pattern="\[fly\](.+?)\[\/fly\]"
str=regEx.replace(str,"<marquee width=90% behavior=alternate scrollamount=3>$1</marquee>")
regEx.Pattern="\[move\](.+?)\[\/move\]"
str=regEx.replace(str,"<MARQUEE scrollamount=3>$1</marquee>")
regEx.Pattern="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]"
str=regEx.replace(str,"<table width=$1 ><tr><td style=""filter:shadow(color=$2, stregExngth=$3)"">$4</td></tr></table>")
regEx.Pattern="\[light\](.[^\[]*)\[\/light]"
str=regEx.replace(str,"<span style=""behavior:url(inc/font.htc)"">$1</span>")
regEx.Pattern = "^((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@':;#+!]+)"
str=regEx.Replace(str,"<a target=_blank href=$1>$1</a>")
regEx.Pattern = "((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@':;#+!]+)$"
str=regEx.Replace(str,"<a target=_blank href=$1>$1</a>")
regEx.Pattern="([^>=""])((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@':;+!]+)"
str=regEx.Replace(str,"$1<a target=_blank href=$2>$2</a>")
ubbb2_base=str
set regEx=nothing
end function
function ubbb2html(byval str)
dim ary_string,i,n,n_pos
ary_string=split(str,"[code]")
n=ubound(ary_string)
if n<1 then
ubbb2html=me.ubbb2_base(str)
exit function
end if
ary_string(0)=me.ubbb2_base(ary_string(0))
for i=1 to n
n_pos=instr(ary_string(i),"[/code]")
if n_pos>0 then
ary_string(i)="<form><textarea style='font-family: 宋体; font-size: 9pt;width:90%' name='dbg' rows='10'>" & text_encode(left(ary_string(i),n_pos-1)) & "</textarea><p style='margin:5px'><input type='button' class='button' value='运行此代码' style='width:80px' onclick='runit(this.form.dbg)'> <input type='button' class='button' value='复制到剪贴板' style='width:90px' onclick='copyit(this.form.dbg)'> <input type='button' class='button' value='代码另存为' style='width:80px' onclick='saveAs(this.form.dbg)'></p> </form>" & ubbb2_base(right(ary_string(i),len(ary_string(i))-n_pos-6))
else
ary_string(i)="[code]" & me.ubbb2_base(ary_string(i))
end if
next
ubbb2html=join(ary_string,"")
end function
function ubbb2(byval str)
if isnull(str) or str="" then
ubbb2=""
exit function
end if
dim ary_string,i,n,n_pos
ubbb2=me.ubbb2html(str)
end function
function text_encode(byval str)
if isnull(str) then
text_encode=""
else
str=replace(str,"&","&")
str=replace(str,"<","<")
text_encode=replace(str,">",">")
end if
end function
%><script>
function copyit(obj){
obj.select();
js=obj.createTextRange();
js.execCommand("Copy");
}
function saveAs(obj){
var winname=window.open('','test','top=10000');
winname.document.open("text/html", "replace");
winname.document.write(obj.value);
winname.document.execCommand('saveas','','code.html');
winname.close();
}
function runit(obj)
{
var winname=window.open("","test","");
winname.document.open("text/html", "replace");
winname.document.write(obj.value);
winname.document.close();
}
function initimg(parpic,maxwidth,maxheight)
{
var scale=maxwidth/maxheight;
var realscale=parpic.width/parpic.height;
if((parpic.width>maxwidth)||(parpic.height>maxheight))
{
if(realscale>scale)
{
parpic.width=maxwidth;
}
else
{
parpic.height=maxheight;
}
}
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -