<%
Function UBBCode(strContent)
DisSM=1
DisUBB=0
DisIMG=0
AutoURL=1
AutoKEY=0 
	If isEmpty(strContent) Or isNull(strContent) Then
        Exit Function
	Else
		Dim re, strMatchs, strMatch, rndID
		Set re=new RegExp
		re.IgnoreCase =True
		re.Global=True
		'strContent=Filter_Script(strContent)

		IF AutoURL=1 Then
			re.Pattern="([^=\]][\s]*?|^)(http|https|rstp|ftp|mms|ed2k)://([^\s&<\[)]*)"
			strContent=re.Replace(strContent,"$1<a href=""$2://$3"" target=""_blank"">$2://$3</a>")
			're.Pattern="(^|\s)(www\.\S+)"
			'strContent=re.Replace(strContent,"$1<a href=""http://$2"" target=""_blank"">$2</a>")
		End IF

		IF Not DisUBB=1 Then
			IF Not DisIMG=1 Then
				re.Pattern="(\[img\])(.[^\]]*)(\[\/img\])"
				strContent=re.Replace(strContent,"<img src=""$2"" border=""0"" onload=""javascript:DrawImage(this);"" width=500px  alt=""按此在新窗口打开图片"" onmouseover=""this.style.cursor='pointer';"" onclick=""window.open(this.src);"" />")
				re.Pattern="(\[swf\])(.[^\]]*)(\[\/swf\])"
				strContent= re.Replace(strContent,"<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=""470"" height=""380""><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/x-shockwave-flash"" width=""470"" height=""380""></embed></object>")
				re.Pattern="(\[wmv\])(.[^\]]*)(\[\/wmv\])"
				strContent= re.Replace(strContent,"<object classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" width=""470"" height=""380""><param name=""ShowStatusBar"" value=""-1""><param name=""AutoStart"" value=""False""><param name=""Filename"" value=""$2""></object>")
				re.Pattern="(\[wma\])(.[^\]]*)(\[\/wma\])"
				strContent= re.Replace(strContent,"<object classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95""  id=""MediaPlayer"" width=""470"" height=""380""><param name=""ShowStatusBar"" value=""-1""><param name=""AutoStart"" value=""False""><param name=""Filename"" value=""$2""></object>")
				re.Pattern="(\[mid\])(.[^\]]*)(\[\/mid\])"
				strContent= re.Replace(strContent,"<embed src=""$2"" height=""45"" width=""314"" autostart=""0""></embed>")
				re.Pattern="(\[ra\])(.[^\]]*)(\[\/ra\])"
				strContent= re.Replace(strContent,"<object classid=""clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" id=""RAOCX"" width=""450"" height=""60""><param name=""_ExtentX"" value=""6694""><param name=""_ExtentY"" value=""1588""><param name=""AUTOSTART"" value=""0""><param name=""SHUFFLE"" value=""0""><param name=""PREFETCH"" value=""0""><param name=""NOLABELS"" value=""0""><param name=""SRC"" value=""$2""><param name=""CONTROLS"" value=""StatusBar,ControlPanel""><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""><embed src=""$2"" width=""253"" autostart=""true"" height=""60""></embed></object>")
				re.Pattern="(\[rm\])(.[^\]]*)(\[\/rm\])"
				strContent= re.Replace(strContent,"<object classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" height=""350"" id=""Player"" width=""450"" viewastext><param name=""_ExtentX"" value=""12726""><param name=""_ExtentY"" value=""8520""><param name=""AUTOSTART"" value=""0""><param name=""SHUFFLE"" value=""0""><param name=""PREFETCH"" value=""0""><param name=""NOLABELS"" value=""0""><param name=""CONTROLS"" value=""ImageWindow""><param name=""CONSOLE"" value=""_master""><param name=""LOOP"" value=""0""><param name=""NUMLOOP"" value=""0""><param name=""CENTER"" value=""0""><param name=""MAINTAINASPECT"" value=""$2""><param name=""BACKGROUNDCOLOR"" value=""#000000""></object><br><object classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" height=""32"" id=""Player"" width=""450"" VIEWASTEXT><param name=""_ExtentX"" value=""18256""><param name=""_ExtentY"" value=""794""><param name=""AUTOSTART"" value=""-1""><param name=""SHUFFLE"" value=""0""><param name=""PREFETCH"" value=""0""><param name=""NOLABELS"" value=""0""><param name=""CONTROLS"" value=""controlpanel""><param name=""CONSOLE"" value=""_master""><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=""$2""></object>")
				re.Pattern="(\[qt\])(.[^\]]*)(\[\/qt\])"
				strContent= re.Replace(strContent,"<embed src=""$2"" width=""470"" height=""380"" autoplay=""false"" Loop=""false"" controller=""true"" playeveryframe=""false"" cache=""false"" scale=""TOFIT"" bgcolor=""#000000"" kioskmode=""false"" targetcache=""false"" pluginspage=""http://www.apple.com/quicktime/"">")
			End IF

			re.Pattern = "\[url=(.[^\]]*)\](.[^\[]*)\[\/url]"
			strContent = re.Replace(strContent,"<a target=""_blank"" href=""$1"">$2</a>")
			re.Pattern = "\[url](.[^\[]*)\[\/url]"
			strContent = re.Replace(strContent,"<a target=""_blank"" href=""$1"">$1</a>")
			re.Pattern = "\[email=(.[^\]]*)\](.[^\[]*)\[\/email]"
			strContent = re.Replace(strContent,"<a href=""$1"">$2</a>")
			re.Pattern = "\[email](.[^\[]*)\[\/email]"
			strContent = re.Replace(strContent,"<a href=""mailto:$1"">$1</a>")

			strContent = Replace(strContent,"[b]","<strong>")
			strContent = Replace(strContent,"[/b]","</strong>")
			strContent = Replace(strContent,"[i]","<i>")
			strContent = Replace(strContent,"[/i]","</i>")
			strContent = Replace(strContent,"[u]","<u>")
			strContent = Replace(strContent,"[/u]","</u>")
			strContent = Replace(strContent,"[fly]","<marquee width=""90%"" behavior=""alternate"" scrollamount=""3"">")
			strContent = Replace(strContent,"[/fly]","</marquee>")
			strContent = Replace(strContent,"[list]","<ul>")
			strContent = Replace(strContent,"[list=1]","<ol type=""1"">")
			strContent = Replace(strContent,"[list=a]","<ol type=""a"">")
			strContent = Replace(strContent,"[list=A]","<ol type=""A"">")
			strContent = Replace(strContent,"[*]","<li>")
			strContent = Replace(strContent,"[/list]","</ul></ol>")
			re.Pattern="\[font=([^<>\]]*?)\]"
			strContent=re.Replace(strContent,"<font face=""$1"">")
			strContent=Replace(strContent,"[/font]","</font>")
			re.Pattern="\[color=([^<>\]]*?)\]"
			strContent=re.Replace(strContent,"<font color=""$1"">")
			strContent=Replace(strContent,"[/color]","</font>")
			're.Pattern="\[face(^<>\]]*?)\]"
			re.Pattern="\[face(\d*?)\]"
		    strContent=re.Replace(strContent,"<img src=images\faces\$1.gif>")
			're.Pattern="\[script(\d*?)\]"
		    'strContent=re.Replace(strContent,"<img src=images\faces\$1.gif>")
			'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
			re.Pattern="\[align=([^<>\]]*?)\]"
			strContent=re.Replace(strContent,"<div align=""$1"">")
			strContent=Replace(strContent,"[/align]","</div>")
			re.Pattern="\[size=(\d*?)\]"
			strContent=re.Replace(strContent,"<font size=""$1"">")
			strContent=Replace(strContent,"[/size]","</font>")
		End IF

		re.Pattern = "\[down=(.[^\]]*)\](.[^\[]*)\[\/down]"
		strContent = re.Replace(strContent,"<img src=""images/download.gif"" align=""absmiddle"" /> <a href=""$1"" target=""_blank"">$2</a>")

		re.Pattern="\[code\](.*?)\[\/code\]"
		strContent= re.Replace(strContent,"<table border=""0"" width=""96%"" cellspacing=""0"" cellpadding=""1"" align=""center""><tr><td><b>程序代码：</b></td></tr><tr><td><div class=""code"">$1</div></td></tr></table>")

		re.Pattern="\[quote\](.*?)\[\/quote\]"
		strContent= re.Replace(strContent,"<table border=""0"" width=""96%"" cellspacing=""0"" cellpadding=""1"" align=""center""><tr><td><b>引用内容：</b></td></tr><tr><td><div class=""code"">$1</div></td></tr></table>")

		re.Pattern="\[html\](.*?)\[\/html\]"
		Set strMatchs=re.Execute(strContent)
		For Each strMatch in strMatchs
			RAndomize
			rndID="temp"&Int(100000 * Rnd)
			strContent=Replace(strContent,strMatch.Value,"<table border=""0"" width=""96%"" cellspacing=""0"" cellpadding=""0"" align=""center""><tr><td><b>HTML代码：</b></td></tr><tr><td><div class=""code""><TEXTAREA  rows=""8"" style=""width:100%"" id="""&rndID&""">"&HTMLDecode(strMatch.SubMatches(0)) & "</TEXTAREA><br><INPUT onclick=""runEx('"&rndID&"')""  type=""button"" value=""运行此代码""> [Ctrl+A 全部选择 提示：你可先修改部分代码，再按运行]</div></td></tr></table>",1,-1,1)
		Next
		Set strMatchs=nothing

		IF Not DisSM=1 Then
			dim log_Smilies,log_SmiliesContent
			For Each log_Smilies IN Arr_Smilies
				log_SmiliesContent=Split(log_Smilies,"|")
				strContent=Replace(strContent,log_SmiliesContent(2)," <img src=""images/smilies/"&log_SmiliesContent(1)&""" border=""0"" align=""absmiddle"" />")
			Next
		End IF

		IF AutoKEY=1 Then
			dim log_Keywords,log_KeywordsContent
			For Each log_Keywords IN Arr_Keywords
				log_KeywordsContent=Split(log_Keywords,"$|$")
				IF log_KeywordsContent(3)<>"None" Then
					strContent=Replace(strContent,log_KeywordsContent(1),"<a href="""&log_KeywordsContent(2)&""" target=""_blank""><img src=""images/keywords/"&log_KeywordsContent(3)&""" border=""0"" align=""absmiddle""> "&log_KeywordsContent(1)&"</a>")
				Else
					strContent=Replace(strContent,log_KeywordsContent(1),"<a href="""&log_KeywordsContent(2)&""" target=""_blank"">"&log_KeywordsContent(1)&"</a>")
				End IF
			Next
		End IF

		Set re=Nothing

		UBBCode=strContent
	End IF
End Function

Rem  过滤脚本
Function Filter_Script(strContent)
    If isEmpty(strContent) Or isNull(strContent) Then
        Exit Function
    Else
    	Dim re
		Set re=new RegExp
		re.IgnoreCase =True
		re.Global=True
    	're.Pattern="(&#)"
    	'strContent=re.Replace(strContent,"&amp;#")
    	re.Pattern="(var )"
    	strContent=re.Replace(strContent,"var..")
    	re.Pattern="(function )"
    	strContent=re.Replace(strContent,"function..")
    	re.Pattern="(meta )"
    	strContent=re.Replace(strContent,"meta..")
    	're.Pattern="(button )"
    	'strContent=re.Replace(strContent,"button..")
    	're.Pattern="(window)"
    	'strContent=re.Replace(strContent,"..window")
    	re.Pattern="(script)"
    	strContent=re.Replace(strContent,"script..")
    	re.Pattern="(js:)"
    	strContent=re.Replace(strContent,"..js:")
    	're.Pattern="(value)"
    	'strContent=re.Replace(strContent,"..value")
    	re.Pattern="(about:)"
    	strContent=re.Replace(strContent,"..about:" )
    	re.Pattern="(file:)"
    	strContent=re.Replace(strContent,"..file:")
    	re.Pattern="(Document.cookie)"
    	strContent=re.Replace(strContent,"..Document.cookie" )
    	re.Pattern="(vbs:)"
    	strContent=re.Replace(strContent,"..vbs:" )
    	re.Pattern="((ifr|fr)ame)"
    	strContent=re.Replace(strContent,"$2ame" &chr(30))
    	re.Pattern="(on(mouse|Exit|error|click|key|load))"
    	strContent=re.Replace(strContent,"on..$2")
    	Filter_Script=strContent
    End If
End Function
%>