?? ubbcode.asp
字號:
<%
dim tt1,tt2
tt1="<font style='font-size:9pt;line-height:15pt'><hr color=#CDCFCE size=1><font color=#808080>"
tt2="</font><hr color=#CDCFCE size=1>"
function html_encode(byval str)
if isnull(str) then
html_encode=""
else
str=replace(str,"&","&")
str=replace(str,chr(32)," ")
str=replace(str,chr(39),"'")
str=replace(str,chr(36),"$")
str=replace(str,chr(34),""")
str=replace(str,"<","<")
str=replace(str,">",">")
str = Replace(str, chr(13), "")
str = Replace(str, chr(10) &chr(10), "</p><p> ")
html_encode = Replace(str, chr(10), "<br> ")
end if
end function
function ubb_base(byval str)
dim regEx
set regEx=new regExp
regEx.IgnoreCase=true
regEx.Global=true
if isnull(str) or str="" then
ubb_base=""
exit function
end if
str=me.html_encode(str)
regEx.pattern="((javascript:)|(jscript:)|(object)|(js:)|(location.)|(vbscript:)|(vbs:)|(\.value)|(about:)|(file:)|(document.cookie)|(on(mouse|exit|error|click|key|load)))"
str=regEx.replace(str,"<I>$1</I>")
regEx.pattern="\[UPLOAD=(gif|jpg|jpeg|bmp|png)\](.[^\[]*)(gif|jpg|jpeg|bmp)\[\/UPLOAD\]"
str=regEx.replace(str,"<br><IMG SRC=""pic/$1.gif"" border=0> 此主題相關圖片如下:<br><SPAN style='CURSOR: hand'><IMG SRC=""upload/$2$1"" border=0 alt=按此在新窗口瀏覽圖片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333"" onclick=""window.open(this.src,null,'')""></span>")
regEx.pattern="\[IMG\](http|https|ftp):\/\/(.[^\[]*)\[\/IMG\]"
str=regEx.replace(str,"<img src=$1://$2 border=0 style='cursor:hand' onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333"" 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]*)]"
str=regEx.replace(str,"<img src=images/emote/em$1.gif>")
regEx.pattern="\[((/?b)|(/?i)|(/?u)|(/?sub)|(/?sup))\]"
str=regEx.replace(str,"<$1>")
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><b>此主題相關媒體如下:<a href=""$3"" TARGET=_blank>(點這里下載)</a></b><br><object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=$1 height=$2 >" & vbcrlf & "<PARAM NAME=AUTOSTART VALUE=1><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,"<b>此主題相關媒體如下:<a href=""$3"" TARGET=_blank>(點這里下載)</a></b><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=true>" & 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=1>" & 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,"<b>此主題相關的FLASH文件如下:</b><a href=""$3"" TARGET=_blank><IMG SRC=pic/swf.gif border=0 alt=點擊開新窗口欣賞該FLASH動畫! height=16 width=16>[全屏欣賞]</a><br><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=$1 height=$2><PARAM NAME=movie VALUE=""$3""><PARAM NAME=quality VALUE=high><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>$3</embed></OBJECT>")
regEx.Pattern="\[Ra\](.[^\[]*)\[\/Ra]"
str=regEx.replace(str,"<b>此主題相關的 RealPlayer 音樂如下:[ <a href=$1>下載</a> ]</b><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,"<img align=absmiddle src=pic/url.gif border=0><a target=_blank href=$1>$1</a>")
regEx.Pattern = "((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@':;#+!]+)$"
str=regEx.Replace(str,"<img align=absmiddle src=pic/url.gif border=0><a target=_blank href=$1>$1</a>")
regEx.Pattern="([^>=""])((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@':;+!]+)"
str=regEx.Replace(str,"$1<img align=absmiddle src=pic/url.gif border=0><a target=_blank href=$2>$2</a>")
regEx.Pattern="(^.*)(\[smark=*([0-9]*)\])(.[^\[]*)(\[\/s\])(.*)"
dim needmark,usermark
needmark=regEx.Replace(str,"$3")
if IsNumeric(needmark) then needmark=int(needmark) else needmark=0
if isnull(lguserid) or lguserid="" then
usermark=0
else
usermark=conn.execute("select top 1 mark from [user] where userid="&lguserid&"")("mark")
end if
if lguserid=topicuserid or usermark>=needmark then
str=regEx.Replace(str,"$1"&tt1&"此內容需要積分 <b>"&needmark&"</b> 以上的用戶以及作者才能瀏覽:</font><BR>$4"&tt2&"$6")
else
str=regEx.Replace(str,"$1"&tt1&"此內容需要積分 <b>"&needmark&"</b> 以上的用戶以及作者才能瀏覽:</font><BR>"&tt2&"$6")
end if
regEx.Pattern="(^.*)(\[slogin\])(.[^\[]*)(\[\/s\])(.*)"
if isnull(lguserid) or lguserid="" then
str=regEx.Replace(str,"$1"&tt1&"此帖內容<b>必須<a href=login.asp>登陸</a></b>后才能瀏覽:</font><BR>"&tt2&"$5")
else
str=regEx.Replace(str,"$1"&tt1&"此帖內容<b>必須登陸</b>后才能瀏覽:</font><BR>$3"&tt2&"$5")
end if
regEx.Pattern="(^.*)(\[showdate=(.[^\[]*)\])(.[^\[]*)(\[\/s\])(.*)"
dim showdate
showdate=regEx.replace(str,"$3")
if isdate(showdate) then
showdate=datediff("d",cdate(showdate),cdate(now()))
else
showdate=-1
end if
if int(showdate)>=0 or lguserid=topicuserid then
str=regEx.Replace(str,"$1"&tt1&"此內容只有 <b>$3</b> 這天以后才能瀏覽:</font><BR>$4"&tt2&"$6")
else
str=regEx.Replace(str,"$1"&tt1&"此內容只有 <b>$3</b> 這天以后才能瀏覽:</font><BR>"&tt2&"$6")
end if
regEx.Pattern="(^.*)(\[showtograde=*([0-9]*)\])(.[^\[]*)(\[\/s\])(.*)"
dim needgrade,usergrade
needgrade=regEx.Replace(str,"$3")
if IsNumeric(needgrade) then
needgrade=int(needgrade)
else
needgrade=0
end if
if isnull(lguserid) or lguserid="" then
usergrade=0
else
usergrade=conn.execute("select top 1 grade from [user] where userid="&lguserid&"")("grade")
end if
if lguserid=topicuserid or usergrade>=needgrade then
str=regEx.Replace(str,"$1"&tt1&"此內容需要等級為 <b>"&needgrade&"</b> 或更高的等級以及作者才能瀏覽:</font><BR>$4"&tt2&"$6")
else
str=regEx.Replace(str,"$1"&tt1&"此內容需要等級為 <b>"&needgrade&"</b> 或更高的等級以及作者才能瀏覽:</font><BR>"&tt2&"$6")
end if
regEx.Pattern="(^.*)(\[showtoname=(.[^\[]*)\])(.[^\[]*)(\[\/s\])(.*)"
dim showtoname,cansee,n
showtoname=regEx.replace(str,"$3")
showtoname=split(showtoname,",")
cansee=false
for n=0 to ubound(showtoname)
if lgname=showtoname(n) then:cansee=true:exit for
next
if cansee=true or lguserid=topicuserid then
str=regEx.Replace(str,"$1"&tt1&"此內容只有作者和 <b>$3</b> 能瀏覽:</font><BR>$4"&tt2&"$6")
else
str=regEx.Replace(str,"$1"&tt1&"此內容只有作者和 <b>$3</b> 能瀏覽:</font><BR>"&tt2&"$6")
end if
regEx.Pattern="(^.*)(\[showtoreply\])(.[^\[]*)(\[\/s\])(.*)"
dim canread,ubbrs
canread=false
if isnull(lguserid) or lguserid="" then
canread=false
else
set ubbrs=conn.execute("select top 1 id from bbs"&totable&" where bid="&id&" and userid="&lguserid&"")
if not ubbrs.eof or lguserid=topicuserid then canread=true
set ubbrs=nothing
end if
if canread=true then
str=regEx.Replace(str,"$1"&tt1&"此內容只有作者和已經回復此帖的瀏覽者能瀏覽:</font><BR>$3"&tt2&"$5")
else
str=regEx.Replace(str,"$1"&tt1&"此內容只有作者和已經回復此帖的瀏覽者能瀏覽:</font><BR>"&tt2&"$5")
end if
ubb_base=str
set regEx=nothing
end function
function ubbhtml(byval str)
dim ary_string,i,n,n_pos
ary_string=split(str,"[code]")
n=ubound(ary_string)
if n<1 then
ubbhtml=me.ubb_base(str)
exit function
end if
ary_string(0)=me.ubb_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>" & ubb_base(right(ary_string(i),len(ary_string(i))-n_pos-6))
else
ary_string(i)="[code]" & me.ubb_base(ary_string(i))
end if
next
ubbhtml=join(ary_string,"")
end function
function ubb(byval str)
if isnull(str) or str="" then
ubb=""
exit function
end if
dim ary_string,i,n,n_pos
ubb=me.ubbhtml(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();
}
</script>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -