<!-- #include file=../inc/Ubbcode_Setup.asp -->
<%
Dim MyHomeUrl,ConvertFlag
ConvertFlag = 1
MyHomeUrl = LCase(Request.Servervariables("SCRIPT_NAME"))
If Right(MyHomeUrl,23) = "/a/a2.asp" or Right(MyHomeUrl,26) = "/a/editannounce.asp" Then
	If Request.ServerVariables("SERVER_PORT") <> "80" Then MyHomeUrl = ":" & Request.ServerVariables("SERVER_PORT") & MyHomeUrl
	MyHomeUrl = Lcase("http://"&Request.ServerVariables("server_name") & MyHomeUrl)
	MyHomeUrl = Replace(MyHomeUrl,"a/a2.asp","")
	MyHomeUrl = Replace(MyHomeUrl,"a/editannounce.asp","")
Else
	MyHomeUrl = ""
End If

Function PrintTrueText(tempString)

	If tempString<>"" Then
		PrintTrueText=Replace(Replace(Replace(Replace(Replace(htmlEncode(tempString),VbCrLf & " ","<br>" & "&nbsp;"),VbCrLf,"<br>" & VbCrLf),"   "," &nbsp; "),"  "," &nbsp;"),chr(9)," &nbsp; &nbsp; &nbsp;")

		If Left(PrintTrueText,1) = chr(32) Then
			PrintTrueText = "&nbsp;" & Mid(PrintTrueText,2)
		End If
	Else
		PrintTrueText=""
	End If

End Function

Function clearUbbcode(str)

	Dim n,m,str2
	n = inStr(1,str,"[",0)
	if n > 0 Then
		m = inStr(n + 1,str,"]",0)
	Else
		m = 0
	End If
	str2 = str
	Do while n > 0 and n < m and m > 0
		str2 = Left(str2,n-1) & Mid(str2,m+1)
		n = inStr(1,str2,"[",0)
		if n > 0 Then
			m = inStr(n + 1,str2,"]",0)
		Else
			m = 0
		End If
	Loop
	clearUbbcode = str2

End Function

Function ClearTrTd(Str)

	Dim n,m,i,str2,T1,T2,T11
	T1 = "[table="
	T11 = "[table]"
	T2 = "[/table]"
	str2 = Str
	n = inStr(1,Lcase(Str),T1,0)
	i = inStr(1,Lcase(Str),T11,0)
	If n > i and i > 0 Then n = i
	If n = 0 Then n = i
	if n > 0 Then
		m = inStr(n + 1,Lcase(Str),T2,0)
	Else
		m = 0
	End If
	Dim SS,Max,TStr1,Tstr2
	SS = ""
	Max = m
	If n < 1 or n >= m Then
		str2 = Replace(str2, "[tr]", "")
		str2 = Replace(str2, "[TR]", "")
		str2 = Replace(str2, "[/tr]", "")
		str2 = Replace(str2, "[/TR]", "")
		str2 = Replace(str2, "[td]", "")
		str2 = Replace(str2, "[TD]", "")
		str2 = Replace(str2, "[/td]", "")
		str2 = Replace(str2, "[/TD]", "")
		ClearTrTd = Str2
		Exit Function
	End If

	dim re
	set re = New RegExp
	re.Global = True
	re.IgnoreCase = True
	Dim Tstr3

	Do while n > 0 and n < m
		TStr1 = Left(Str2,n-1)
		TStr1 = Replace(TStr1, "[tr]", "")
		TStr1 = Replace(TStr1, "[TR]", "")
		TStr1 = Replace(TStr1, "[/tr]", "")
		TStr1 = Replace(TStr1, "[/TR]", "")
		TStr1 = Replace(TStr1, "[td]", "")
		TStr1 = Replace(TStr1, "[TD]", "")
		TStr1 = Replace(TStr1, "[/td]", "")
		TStr1 = Replace(TStr1, "[/TD]", "")
		re.Pattern="\[table\]"
		TStr1 = re.Replace(TStr1,"")
		re.Pattern="\[table=([A-Za-z0-9\=\./\?%\-&_~`@$\(\)[,\':+!#]+)\]"
		TStr1 = re.Replace(TStr1,"")
		re.Pattern="\[\/table]"
		TStr1 = re.Replace(TStr1,"")

		TStr2 = Mid(Str2,n,m+8-n)
		Tstr3 = Left(Tstr2,7)
		Tstr2 = Mid(Tstr2,8,m-n-7)
		re.Pattern="\[table\]"
		TStr2 = re.Replace(TStr2,"")
		re.Pattern="\[table=([A-Za-z0-9\=\./\?%\-&_~`@$\(\)[,\':+!#]+)\]"
		TStr2 = re.Replace(TStr2,"")
		re.Pattern="\[\/table]"
		TStr2 = re.Replace(TStr2,"")
		SS = SS & TStr1 & UCase(Tstr3) & TStr2 & "[/TABLE]"
		str2 = Mid(str2,m+8)
		
		n = inStr(1,Lcase(Str2),T1,0)
		i = inStr(1,Lcase(Str2),T11,0)
		If n > i and i > 0 Then n = i
		If n = 0 Then n = i
		if n > 0 Then
			m = inStr(n + 1,Lcase(Str2),T2,0)
		Else
			m = 0
		End If
	Loop
	Str2 = Replace(Str2, "[tr]", "")
	Str2 = Replace(Str2, "[TR]", "")
	Str2 = Replace(Str2, "[/tr]", "")
	Str2 = Replace(Str2, "[/TR]", "")
	Str2 = Replace(Str2, "[td]", "")
	Str2 = Replace(Str2, "[TD]", "")
	Str2 = Replace(Str2, "[/td]", "")
	Str2 = Replace(Str2, "[/TD]", "")
	re.Pattern="\[table\]"
	Str2 = re.Replace(Str2,"")
	re.Pattern="\[table=([A-Za-z0-9\=\./\?%\-&_~`@$\(\)[,\':+!#]+)\]"
	Str2 = re.Replace(Str2,"")
	re.Pattern="\[\/table]"
	TStr1 = re.Replace(Str2,"")
	SS = SS & Str2
	ClearTrTd = SS
	Set Re = Nothing

End Function

Function UBB_Code(Str)

	Dim USC,LoopN
	USC = Str
	USC = PrintTrueText(USC)
	USC = Replace(USC,VbCrLf,chr(3))
	dim re
	set re = New RegExp
	re.Global = True
	re.IgnoreCase = True

	re.Pattern="(javascript|jscript|js|about|file|vbscript|vbs)(:)"
	USC=re.Replace(USC,"$1&#58;")
	're.Pattern="(value)"
	'USC=re.Replace(USC,"&#118;alue")
	re.Pattern="(document)(.)(cookie)"
	USC=re.Replace(USC,"$1&#46;$3")
	re.Pattern="(on(mouse|exit|error|click|key))"
	USC=re.Replace(USC,"&#111;n$2")

	USC = ClearTrTd(USC)
    If DEF_EnableImagesUBB = 1 then
		re.Pattern="(\[\/IMGA\])"
		USC=re.Replace(USC,"[/IMGA]" & VbCrLf)
		re.Pattern="\[IMGA=*([0-9]*),(absmiddle|left|right|top|middle|bottom|absbottom|baseline|texttop)\](/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)\[\/IMGA]"
		USC=re.Replace(USC,"<IMG onmouseover=""javascript:if(this.width>520)this.width=520;"" style=""CURSOR: hand"" onclick=javascript:window.open(this.src); src=""$3$4"" onload=""javascript:if(this.width>520)this.width=520;"" align=$2 border=$1>")
		're.Pattern="\[IMGA\](/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)\[\/IMGA]"
		re.Pattern="\[IMGA\](/|../|http://|https://|ftp://)(.[^\[]*)\[\/IMGA]"
		USC=re.Replace(USC,"<IMG onmouseover=""javascript:if(this.width>520)this.width=520;"" style=""CURSOR: hand"" onclick=javascript:window.open(this.src); src=""$1$2"" onload=""javascript:if(this.width>520)this.width=520;"" align=absmiddle border=0>")
	   	USC = Replace(USC,VbCrLf,"")

		re.Pattern="(\[\/IMG\])"
		USC=re.Replace(USC,"[/IMG]" & VbCrLf)
		re.Pattern="\[IMG=*([0-9]*),(absmiddle|left|right|top|middle|bottom|absbottom|baseline|texttop)\](/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)\[\/IMG]"
		USC=re.Replace(USC,"<IMG onmouseover=""javascript:if(this.width>520)this.width=520;"" src=""$3$4"" onload=""javascript:if(this.width>520)this.width=520;"" align=$2 border=$1>")
		're.Pattern="\[IMG\](/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)\[\/IMG]"
		re.Pattern="\[IMG\](/|../|http://|https://|ftp://)(.[^\[]*)\[\/IMG]"
		USC=re.Replace(USC,"<IMG onmouseover=""javascript:if(this.width>520)this.width=520;"" src=""$1$2"" onload=""javascript:if(this.width>520)this.width=520;"" align=absmiddle border=0>")
	   	USC = Replace(USC,VbCrLf,"")
    End If

	re.Pattern="(\[\/URL\])"
	USC=re.Replace(USC,"[/URL]" & VbCrLf)
	re.Pattern="(\[URL\])(.*)(\[\/URL\])"
	USC= re.Replace(USC,"<A HREF=""$2"" TARGET=_blank>$2</A>")
   	USC = Replace(USC,VbCrLf,"")
   	
	re.Pattern="(\[\/bgcolor\])"
	USC=re.Replace(USC,"[/bgcolor]" & VbCrLf)
   	re.Pattern="\[bgcolor=*(#*[a-z0-9]*),*(#*[a-z0-9]*)\](.*)\[\/bgcolor\]"
   	USC=re.Replace(USC,"<font style=""BACKGROUND-COLOR: $1"" color=$2>$3</font>")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/color\])"
	USC=re.Replace(USC,"[/color]" & VbCrLf)
   	re.Pattern="\[color=*(#*[a-z0-9]*)\](.*)\[\/color\]"
   	USC=re.Replace(USC,"<font color=""$1"">$2</font>")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[EMAIL\])(\S+\@.[^\[]*)(\[\/EMAIL\])"
	USC= re.Replace(USC,"<A HREF=""mailto:$2"">$2</A>")
	
	re.Pattern="(\[\/EMAIL\])"
	USC=re.Replace(USC,"[/EMAIL]" & VbCrLf)
	re.Pattern="(\[EMAIL=(\S+\@.[^\[]*)\])(.*)(\[\/EMAIL\])"
	USC= re.Replace(USC,"<A HREF=""mailto:$2"">$3</A>")
   	USC = Replace(USC,VbCrLf,"")

    If DEF_EnableFlashUBB = 1 and ConvertFlag = 1 then
    	If CheckSupervisorUserName = 1 Then
	    	re.Pattern="\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
			USC=re.Replace(USC,"<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]"
			USC=re.Replace(USC,"<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/>")
		Else
	    	re.Pattern="\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
			USC= re.Replace(USC,"<a href=""$3"" TARGET=_blank><IMG SRC=../images/FileType/mp3.gif border=0 align=absmiddle height=16 width=16>[点击打开Shockwave文件，注意此文件可能含有不安全内容]</a>")
			re.Pattern="\[QT=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/QT]"
			USC= re.Replace(USC,"<a href=""$3"" TARGET=_blank><IMG SRC=../images/FileType/mp3.gif border=0 align=absmiddle height=16 width=16>[点击打开QuickTime文件，注意此文件可能含有不安全内容]</a>")
		End If
		If CheckSupervisorUserName = 1 Then
			re.Pattern="\[MP=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/MP]"
			USC=re.Replace(USC,"<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><PARAM NAME=AUTOSTART VALUE=0></object>")
		Else
			re.Pattern="\[MP=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/MP]"
			USC= re.Replace(USC,"<a href=""$3"" TARGET=_blank><IMG SRC=../images/FileType/mp3.gif border=0 align=absmiddle height=16 width=16>[点击打开媒体文件,注意此文件可能含有不安全内容]</a>")
		End If
		If CheckSupervisorUserName = 1 Then
			re.Pattern="\[RM=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/RM]"
			USC=re.Replace(USC,"<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=""" & second(DEF_Now) & "$3""><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=0></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=0><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=""" & second(DEF_Now) & "$3""></OBJECT>")
		Else
			re.Pattern="\[RM=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/RM]"
			USC= re.Replace(USC,"<a href=""$3"" TARGET=_blank><IMG SRC=../images/FileType/mp3.gif border=0 align=absmiddle height=16 width=16>[点击打开Real文件,注意此文件可能含有不安全内容]</a>")
		End If
		
		re.Pattern="(\[FLASH\])(http://|ftp://|../)(.[^\[]*)(.swf)(\[\/FLASH\])"
		If CheckSupervisorUserName = 1 Then
			USC= re.Replace(USC,"<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=500 height=400><PARAM NAME=movie VALUE=""$2$3$4""><PARAM NAME=quality VALUE=high><embed src=""http://$3$4"" quality=high pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type='application/x-shockwave-flash' width=500 height=400>$2$3$4</embed></OBJECT>")
		Else
			USC= re.Replace(USC,"<a href=""$2$3$4"" TARGET=_blank><IMG SRC=../images/FileType/swf.gif border=0 align=absmiddle height=16 width=16>[全屏欣赏,注意Flash可能含有不安全内容]</a>")
		End If

		re.Pattern="(\[FLASH=*([0-9]*),*([0-9]*)\])(http://|ftp://|../)(.[^\[]*)(.swf)(\[\/FLASH\])"
		If CheckSupervisorUserName = 1 Then
			USC= re.Replace(USC,"<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=$2 height=$3><PARAM NAME=movie VALUE=""$4$5$6""><PARAM NAME=quality VALUE=high><embed src=""$4$5$6"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=$2 height=$3>$4$5$6</embed></OBJECT>")
		Else
			USC= re.Replace(USC,"<a href=""$4$5$6"" TARGET=_blank><IMG SRC=../images/FileType/swf.gif border=0 align=absmiddle height=16 width=16>[全屏欣赏,注意Flash可能含有不安全内容]</a>")
		End If

		If ConvertFlag = 1 Then
			re.Pattern="(\[sound\])(.[^\[]*)(\[\/sound\])" 
			USC=re.Replace(USC,"<a href=""$2"" target=_blank><IMG SRC=../images/FileType/mid.gif border=0 alt='背景音乐' height=16 width=16></a><bgsound src=""$2"" loop=""-1"">")
		End If
   	End If
   	If DEF_UBBiconNumber > 0 then
		For LoopN = 1 to DEF_UBBiconNumber
			If ConvertFlag = 1 Then
   				USC=replace(USC,"[EM" & Right(("0" & LoopN),2) & "]","<img src=""../images/UBBicon/em" & Right("0" & LoopN,2) & ".GIF"" width=20 height=20 align=absmiddle border=0>",1,DEF_MaxUBBNumber,0)
   				USC=replace(USC,"[em" & Right(("0" & LoopN),2) & "]","<img src=""../images/UBBicon/em" & Right("0" & LoopN,2) & ".GIF"" width=20 height=20 align=absmiddle border=0>",1,DEF_MaxUBBNumber,0)
   			Else
   				USC=replace(USC,"[EM" & Right(("0" & LoopN),2) & "]","<img src=""../images/UBBicon/em" & Right("0" & LoopN,2) & ".GIF"">",1,DEF_MaxUBBNumber,0)
   				USC=replace(USC,"[em" & Right(("0" & LoopN),2) & "]","<img src=""../images/UBBicon/em" & Right("0" & LoopN,2) & ".GIF"">",1,DEF_MaxUBBNumber,0)
   			End If
   		Next
   	End If

	re.Pattern="(\[\/FIELDSET\])"
	USC=re.Replace(USC,"[/FIELDSET]" & VbCrLf)
   	re.Pattern="\[FIELDSET=(.*)\](.*)\[\/FIELDSET\]"
   	USC=re.Replace(USC,"<FIELDSET><LEGEND>$1</LEGEND>$2</FIELDSET>")
   	USC = Replace(USC,VbCrLf,"")

	If ConvertFlag = 1 Then
		re.Pattern="(\[\/face\])"
		USC=re.Replace(USC,"[/face]" & VbCrLf)
	   	re.Pattern="\[face=(.[^\[]*)\](.*)\[\/face\]"
	   	USC=re.Replace(USC,"<font face=""$1"">$2</font>")
	   	USC = Replace(USC,VbCrLf,"")
	End If

	If ConvertFlag = 1 Then
		re.Pattern="(\[\/GLOW\])"
		USC=re.Replace(USC,"[/GLOW]" & VbCrLf)
		re.Pattern="\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.*)\[\/GLOW]"
		USC=re.Replace(USC,"<table glow width=$1><tr><td style=""filter:glow(color=$2, strength=$3)"">$4</td></tr></table glow>")
	   	USC = Replace(USC,VbCrLf,"")
	
		re.Pattern="(\[\/SHADOW\])"
		USC=re.Replace(USC,"[/SHADOW]" & VbCrLf)
	    re.Pattern="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.*)\[\/SHADOW]"
	    USC=re.Replace(USC,"<table shadow width=$1><tr><td style=""filter:shadow(color=$2, strength=$3)"">$4</td></tr></table shadow>")
	   	USC = Replace(USC,VbCrLf,"")
	End If

	re.Pattern="(\[\/FLY\])"
	USC=re.Replace(USC,"[/FLY]" & VbCrLf)
	re.Pattern="\[FLY\](.*)\[\/FLY]"
	USC=re.Replace(USC,"<MARQUEE>$1</MARQUEE>")
	USC = Replace(USC,VbCrLf,"")

	USC = Replace(USC,"[b]","<b>")
	USC = Replace(USC,"[B]","<b>")
	USC = Replace(USC,"[/b]","</b>")
	USC = Replace(USC,"[/B]","</b>")
	
	USC = Replace(USC,"[u]","<u>")
	USC = Replace(USC,"[U]","<u>")
	USC = Replace(USC,"[/u]","</u>")
	USC = Replace(USC,"[/U]","</u>")
	
	USC = Replace(USC,"[i]","<i>")
	USC = Replace(USC,"[I]","<i>")
	USC = Replace(USC,"[/i]","</i>")
	USC = Replace(USC,"[/I]","</i>")

	re.Pattern="(\[\/align\])"
	USC=re.Replace(USC,"[/align]" & VbCrLf)
   	re.Pattern="\[align=(center|left|right|justify)\](.*)\[\/align]"
	USC=re.Replace(USC,"<p align=$1>$2</p>")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/size\])"
	USC=re.Replace(USC,"[/size]" & VbCrLf)
	re.Pattern="\[size=*([0-9]*)\](.*)\[\/size]"
	USC=re.Replace(USC,"<font size=$1>$2</font>")
   	USC = Replace(USC,VbCrLf,"")
	
	USC = Replace(USC,"[sup]","<sup>")
	USC = Replace(USC,"[SUP]","<sup>")
	USC = Replace(USC,"[/sup]","</sup>")
	USC = Replace(USC,"[/SUP]","</sup>")
	
	USC = Replace(USC,"[sub]","<sub>")
	USC = Replace(USC,"[SUB]","<sub>")
	USC = Replace(USC,"[/sub]","</sub>")
	USC = Replace(USC,"[/SUB]","</sub>")
	
	USC = Replace(USC,"[strike]","<STRIKE>")
	USC = Replace(USC,"[STRIKE]","<STRIKE>")
	USC = Replace(USC,"[/strike]","</STRIKE>")
	USC = Replace(USC,"[/STRIKE]","</STRIKE>")
	
	USC = Replace(USC,"[ul]","<UL>")
	USC = Replace(USC,"[UL]","<UL>")
	USC = Replace(USC,"[/ul]","</UL>")
	USC = Replace(USC,"[/UL]","</UL>")
	
	USC = Replace(USC,"[ol]","<OL>")
	USC = Replace(USC,"[OL]","<OL>")
	USC = Replace(USC,"[/ol]","</OL>")
	USC = Replace(USC,"[/OL]","</OL>")
	
	USC = Replace(USC,"[*]","<LI>")
	USC = Replace(USC,"[/*]","</LI>")
	If ConvertFlag = 1 Then
		re.Pattern="(\[\/CODE\])"
		USC=re.Replace(USC,"[/CODE]" & VbCrLf)
		re.Pattern="\[CODE\](.*)\[\/CODE]"
		USC=re.Replace(USC,"<table code width=100% bgcolor=" & DEF_BBS_LightestColor & " cellpadding=5 cellspacing=2 class=TBBG9><tr><td bgcolor=" & DEF_BBS_LightColor & " class=TBBG1>$1</td></tr></table code>")
		USC = Replace(USC,VbCrLf,"")

		re.Pattern="(\[\/QUOTE\])"
		USC=re.Replace(USC,"[/QUOTE]" & VbCrLf)
		re.Pattern="\[QUOTE\](.*)\[\/QUOTE]"
		USC=re.Replace(USC,"<table width=100% bgcolor=" & DEF_BBS_DarkColor & " cellpadding=5 cellspacing=1 class=TBone><tr><td bgcolor=" & DEF_BBS_LightestColor & " class=TBBG9>$1</td></tr></table>")
		USC = Replace(USC,VbCrLf,"")

		re.Pattern="(\[\/LIGHT\])"
		USC=re.Replace(USC,"[/LIGHT]" & VbCrLf)
		re.Pattern="\[LIGHT\](.*)\[\/LIGHT]"
		USC=re.Replace(USC,"<span style=""behavior:url(../inc/font.htc)"">$1</span>")
		USC = Replace(USC,VbCrLf,"")
	End If

	re.Pattern="(\[\/URL\])"
	USC=re.Replace(USC,"[/URL]" & VbCrLf)
	re.Pattern="(\[URL=(.[^\[]*)\])(.*)(\[\/URL\])"
	USC= re.Replace(USC,"<A HREF=""$2"" TARGET=_blank>$3</A>")
   	USC = Replace(USC,VbCrLf,"")

	If ConvertFlag = 1 Then
		re.Pattern="(\[\/nulltable\])"
		USC=re.Replace(USC,"[/nulltable]" & VbCrLf)
		re.Pattern="\[nulltable\](.*)\[\/nulltable]"
		USC=re.Replace(USC,"<table border=0 width=100% cellspacing=0 cellpadding=0>$1</table>")
		USC=re.Replace(USC,"[/nulltable]" & VbCrLf)
		re.Pattern="(\[nulltable=(.[^\[]*)\])(.*)(\[\/nulltable\])"
		USC= re.Replace(USC,"<table border=0 width=100% cellspacing=0 cellpadding=0 background=""$2"">$3</table>")
		USC = Replace(USC,VbCrLf,"")
	

		re.Pattern="(\[\/nulltr\])"
		USC=re.Replace(USC,"[/nulltr]" & VbCrLf)
		re.Pattern="\[nulltr\](.*)\[\/nulltr]"
		USC=re.Replace(USC,"<tr>$1</tr>")
		USC = Replace(USC,VbCrLf,"")

		re.Pattern="(\[\/nulltd\])"
		USC=re.Replace(USC,"[/nulltd]" & VbCrLf)
		re.Pattern="\[nulltd\](.*)\[\/nulltd]"
		USC=re.Replace(USC,"<td>$1</td>")
		USC = Replace(USC,VbCrLf,"")
	End If

	re.Pattern="(\[\/table\])"
	USC=re.Replace(USC,"[/table]" & VbCrLf)
	re.Pattern="\[table\](.*)\[\/table]"
	'USC=re.Replace(USC,"<table border=1 bordercolor=gray cellspacing=0 cellpadding=3>$1</table>")
	USC=re.Replace(USC,"<table border=0 cellspacing=0 cellpadding=3>$1</table>")
	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/table\])"
	USC=re.Replace(USC,"[/table]" & VbCrLf)
	re.Pattern="\[table=*(#*[a-z0-9]*),*([0-9]*),*([0-9]*),*([0-9%|\""&quot;]*),(left|center|right),*(#*[a-z0-9]*),*([0-9]*)\](.*)\[\/table]"
	USC=re.Replace(USC,"<table borderColor=$1 cellSpacing=$2 cellPadding=$3 width=$4 align=$5 bgColor=$6 border=$7>$8</table>")
	
	re.Pattern="\[table=*(#*[a-z0-9]*),*([0-9]*),*([0-9]*),*([0-9%|\""&quot;]*),(left|center|right),*(#*[a-z0-9]*),*([0-9]*),(.[^\[]*)\](.*)\[\/table]"
	USC=re.Replace(USC,"<table borderColor=$1 cellSpacing=$2 cellPadding=$3 width=$4 align=$5 bgColor=$6 background=""$8"" border=$7>$9</table>")
	
   	USC = Replace(USC,VbCrLf,"")
   	
	re.Pattern="(\[\/table\])"
	USC=re.Replace(USC,"[/table]" & VbCrLf)
	re.Pattern="\[table=*(#*[a-z0-9]*),*([0-9]*),*([0-9]*),*([0-9%|\""&quot;]*),*(#*[a-z0-9]*),*([0-9]*)\](.*)\[\/table]"
	USC=re.Replace(USC,"<table borderColor=$1 cellSpacing=$2 cellPadding=$3 width=$4 bgColor=$5 border=$6>$7</table>")
	
	re.Pattern="\[table=*(#*[a-z0-9]*),*([0-9]*),*([0-9]*),*([0-9%|\""&quot;]*),*(#*[a-z0-9]*),*([0-9]*),(.[^\[]*)\](.*)\[\/table]"
	USC=re.Replace(USC,"<table borderColor=$1 cellSpacing=$2 cellPadding=$3 width=$4 bgColor=$5 background=""$7"" border=$6>$8</table>")
	
   	USC = Replace(USC,VbCrLf,"")
	
	USC = Replace(USC,"[pre]","<PRE>")
	USC = Replace(USC,"[PRE]","<PRE>")
	USC = Replace(USC,"[/pre]","</PRE>")
	USC = Replace(USC,"[/PRE]","</PRE>")

	USC = Replace(USC,"[tr]","<TR>")
	USC = Replace(USC,"[TR]","<TR>")
	USC = Replace(USC,"[/tr]","</TR>")
	USC = Replace(USC,"[/TR]","</TR>")

	USC = Replace(USC,"[td]","<TD>")
	USC = Replace(USC,"[TD]","<TD>")
	USC = Replace(USC,"[/td]","</TD>")
	USC = Replace(USC,"[/TD]","</TD>")

	USC = Replace(USC,"[pp]","<p>")
	USC = Replace(USC,"[/pp]","</p>")
	USC = Replace(USC,"[PP]","<p>")
	USC = Replace(USC,"[/PP]","</p>")
	USC = Replace(USC,chr(3),VbCrLf)
	USC = Replace(USC,"[HR]","<HR>")
   	
   	USC=replace(USC,"[HIDDEN]","[HIDDEN]" & VbCrLf,1,1,0)
   	USC=replace(USC,"[/HIDDEN]",VbCrLf & "[/HIDDEN]" & VbCrLf,1,1,0)

	re.Pattern = "^((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)"
	USC = re.Replace(USC,"<a target=_blank href=""$1"">$1</a>")
	re.Pattern = "((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!]+)$"
	USC = re.Replace(USC,"<a target=_blank href=""$1"">$1</a>")
	re.Pattern = "([^>="",])((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!]+)"
	USC = re.Replace(USC,"$1<a target=_blank href=""$2"">$2</a>")

	If MyHomeUrl <> "" Then
		re.Pattern="(" & MyHomeUrl & ")"
		USC=re.Replace(USC,"../")
	End If

	If CheckSupervisorUserName = 0 Then
		UBB_Code = UBB_FiltrateBadWords(USC)
	Else
		UBB_Code = USC
	End If
	Set Re = Nothing

End Function

Function ResumeUBBCode(Tstr)

	Dim str
	str = Tstr
	Str = Replace(str,"&nbsp;"," ")
	Str = Replace(str,VbCrLf,"")
	Str = Replace(str,"<br>" & VbCrLf,VbCrLf)
	Str = Replace(str,"<BR>" & VbCrLf,VbCrLf)
	Str = Replace(str,"<br>",VbCrLf)
	Str = Replace(str,"<BR>",VbCrLf)
	ResumeUBBCode = Str

End Function

Function Html2UBBCode(str)

	Dim USC,LoopN
	USC = str

	USC = ResumeUBBCode(USC)

	USC = Replace(USC,VbCrLf,chr(3))
	dim re
	set re = New RegExp
	re.Global = True
	re.IgnoreCase = True

	re.Pattern="\<IMG "
	USC=re.Replace(USC,VbCrLf & "<IMG ")
	If DEF_UBBiconNumber > 0 then
		re.Pattern="\<IMG src=\""(\../images/UBBicon/em|" & MyHomeUrl & "images/UBBicon/em|" & MyHomeUrl & "images/UBBicon/em|" & MyHomeUrl & "images/UBBicon/em)([0-9]+).gif([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)>"
		USC=re.Replace(USC,"[EM$2]")
	End If
	're.Pattern="\<IMG onmouseover=""javascript:if\(this.width>520\)this.width=520;"" style=""CURSOR: hand"" onclick=javascript:window.open\(this.src\); src=""(/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)"" onload=""javascript:if\(this.width>520\)this.width=520;"" align=(absmiddle|left|right|top|middle|bottom|absbottom|baseline|texttop) border=*([0-9]*)>"
	'USC=re.Replace(USC,"[IMGA=$4,$3]$1$2[/IMGA]")
	re.Pattern="\<IMG (.*)style=""CURSOR: hand"" (.*)src=""(/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)"" onload=""javascript:if\(this.width>520\)this.width=520;"" align=(absmiddle|left|right|top|middle|bottom|absbottom|baseline|texttop) border=*([0-9]*)>"
	USC=re.Replace(USC,"[IMGA=$6,$5]$3$4[/IMGA]")
    	re.Pattern="\<IMG onmouseover=""javascript:if\(this.width>520\)this.width=520;"" src=""(/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)"" onload=""javascript:if\(this.width>520\)this.width=520;"" align=(absmiddle|left|right|top|middle|bottom|absbottom|baseline|texttop) border=*([0-9]*)>"
	USC=re.Replace(USC,"[IMG=$4,$3]$1$2[/IMG]")
	USC = Replace(USC,"if(this.width>","if(this.width")
	'(.[^\[]*)
	're.Pattern="\<IMG (.*)src=\""(/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)(.[A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]*)>"
	're.Pattern="\<IMG (.*)src=\""(/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)(.[^\[>]*)>"
	re.Pattern="\<IMG (.*)src=\""(/|../|http://|https://|ftp://)(.[^\[\ \"">]*)(.[^\[>]*)>"
	USC=re.Replace(USC,"[IMGA]$2$3[/IMGA]")
	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/FIELDSET\])"
	USC=re.Replace(USC,"[/FIELDSET]" & VbCrLf)
   	re.Pattern="\<FIELDSET><LEGEND>(.*)</LEGEND>(.*)</FIELDSET>"
   	USC = re.Replace(USC,"[FIELDSET=$1]$2[/FIELDSET]")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\<\/table>)"
	USC=re.Replace(USC,"</table>" & VbCrLf)

	re.Pattern="<table borderColor=*(#*[a-z0-9]*) cellSpacing=*([0-9]*) cellPadding=*([0-9]*) width=*([0-9%]*) align=(left|center|right) bgColor=*(#*[a-z0-9]*) border=*([0-9]*)>(.*)</table>"
	USC= re.Replace(USC,"[TABLE=$1,$2,$3,$4,$5,$6,$7]$8[/TABLE]")

	re.Pattern="<table borderColor=*(#*[a-z0-9]*) cellSpacing=*([0-9]*) cellPadding=*([0-9]*) width=""*([0-9%]*)"" align=(left|center|right) bgColor=*(#*[a-z0-9]*) border=*([0-9]*)>(.*)</table>"
	USC= re.Replace(USC,"[TABLE=$1,$2,$3,$4,$5,$6,$7]$8[/TABLE]")


	re.Pattern="<table borderColor=*(#*[a-z0-9]*) cellSpacing=*([0-9]*) cellPadding=*([0-9]*) width=*([0-9%]*) align=(left|center|right) bgColor=*(#*[a-z0-9]*) background=(.[^\[\ ]*) border=*([0-9]*)>(.*)</table>"
	USC= re.Replace(USC,"[TABLE=$1,$2,$3,$4,$5,$6,$8,$7]$9[/TABLE]")

	re.Pattern="<table borderColor=*(#*[a-z0-9]*) cellSpacing=*([0-9]*) cellPadding=*([0-9]*) width=""*([0-9%]*)"" align=(left|center|right) bgColor=*(#*[a-z0-9]*) background=(.[^\[\ ]*) border=*([0-9]*)>(.*)</table>"
	USC= re.Replace(USC,"[TABLE=$1,$2,$3,$4,$5,$6,$8,$7]$9[/TABLE]")


	re.Pattern="<table borderColor=*(#*[a-z0-9]*) cellSpacing=*([0-9]*) cellPadding=*([0-9]*) width=*([0-9%]*) bgColor=*(#*[a-z0-9]*) background=(.[^\[\ ]*) border=*([0-9]*)>(.*)</table>"
	USC= re.Replace(USC,"[TABLE=$1,$2,$3,$4,$5,$7,$6]$8[/TABLE]")

	re.Pattern="<table borderColor=*(#*[a-z0-9]*) cellSpacing=*([0-9]*) cellPadding=*([0-9]*) width=""*([0-9%]*)"" bgColor=*(#*[a-z0-9]*) background=(.[^\[\ ]*) border=*([0-9]*)>(.*)</table>"
	USC= re.Replace(USC,"[TABLE=$1,$2,$3,$4,$5,$7,$6]$8[/TABLE]")
	

	re.Pattern="<table borderColor=*(#*[a-z0-9]*) cellSpacing=*([0-9]*) cellPadding=*([0-9]*) width=*([0-9%]*) bgColor=*(#*[a-z0-9]*) border=*([0-9]*)>(.*)</table>"
	USC= re.Replace(USC,"[TABLE=$1,$2,$3,$4,$5,$6]$7[/TABLE]")

	re.Pattern="<table borderColor=*(#*[a-z0-9]*) cellSpacing=*([0-9]*) cellPadding=*([0-9]*) width=""*([0-9%]*)"" bgColor=*(#*[a-z0-9]*) border=*([0-9]*)>(.*)</table>"
	USC= re.Replace(USC,"[TABLE=$1,$2,$3,$4,$5,$6]$7[/TABLE]")

	re.Pattern="\<table (.[^\[>]*)\>(.*)</table>"
	USC= re.Replace(USC,"[TABLE]$2[/TABLE]")
	
	re.Pattern="\<table\>(.*)\<\/table>"
	USC=re.Replace(USC,"[TABLE]$1[/TABLE]")

   	USC = Replace(USC,VbCrLf,"")

	re.Pattern = "\<tr ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[TR]")
	USC = Replace(USC,"<TR>","[TR]")
	USC = Replace(USC,"<tr>","[TR]")
	USC = Replace(USC,"</TR>","[/TR]")
	USC = Replace(USC,"</tr>","[/TR]")

	re.Pattern = "\<td ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[TD]")
	USC = Replace(USC,"<TD>","[TD]")
	USC = Replace(USC,"<td>","[TD]")
	USC = Replace(USC,"</TD>","[/TD]")
	USC = Replace(USC,"</td>","[/TD]")

	re.Pattern = "\<sup ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[SUP]")
	USC = Replace(USC,"<sup>","[SUP]")
	USC = Replace(USC,"<SUP>","[SUP]")
	USC = Replace(USC,"</SUP>","[/SUP]")
	USC = Replace(USC,"</sup>","[/SUP]")
	
	re.Pattern = "\<sub ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[SUB]")
	USC = Replace(USC,"<SUB>","[SUB]")
	USC = Replace(USC,"<sub>","[SUB]")
	USC = Replace(USC,"</SUB>","[/SUB]")
	USC = Replace(USC,"</sub>","[/SUB]")
	
	re.Pattern = "\<ul ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[UL]")
	USC = Replace(USC,"<UL>","[UL]")
	USC = Replace(USC,"<ul>","[UL]")
	USC = Replace(USC,"</ul>","[/UL]")
	USC = Replace(USC,"</UL>","[/UL]")
	
	re.Pattern = "\<ol ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[OL]")
	USC = Replace(USC,"<OL>","[OL]")
	USC = Replace(USC,"<ol>","[OL]")
	USC = Replace(USC,"</ol>","[/OL]")
	USC = Replace(USC,"</OL>","[/OL]")

	re.Pattern = "\<li ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[*]")
	USC = Replace(USC,"<LI>","[*]")
	USC = Replace(USC,"<li>","[*]")
	USC = Replace(USC,"</LI>","[/*]")
	USC = Replace(USC,"</li>","[/*]")

	re.Pattern="\</font>"
	USC=re.Replace(USC,"</font>" & VbCrLf)
	re.Pattern="\<font size=*([0-9]*)>(.*)\<\/font\>"
	USC= re.Replace(USC,"[SIZE=$1]$2[/SIZE]")
   	USC = Replace(USC,VbCrLf,"")
	re.Pattern="\<font "
	USC=re.Replace(USC,VbCrLf & "<font ")
	'//re.Pattern="\<font face=(.*)>(.*)\<\/font\>"
	'//USC= re.Replace(USC,"[FACE=$1]$2[/FACE]")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="\<\/font>"
	USC=re.Replace(USC,"</font>" & VbCrLf)
	re.Pattern="\<font color=*(#*[a-z0-9]*)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]*)>(.*)\<\/font\>"
	USC= re.Replace(USC,"[COLOR=$1]$3[/COLOR]")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="\<\/font>"
	USC=re.Replace(USC,"</font>" & VbCrLf)
	re.Pattern="\<font style=""BACKGROUND-COLOR: *(#*[a-z0-9]*)"" color=*(#*[a-z0-9]*)>(.*)(\<\/font\>)"
	USC= re.Replace(USC,"[BGCOLOR=$1,$2]$3[/BGCOLOR]")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern = "(\<i ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>)"
	USC = re.Replace(USC,"[I]")
	USC = Replace(USC,"<i>","[I]")
	USC = Replace(USC,"<I>","[I]")
	USC = Replace(USC,"</i>","[/I]")
	USC = Replace(USC,"</I>","[/I]")

	re.Pattern = "(\<u ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>)"
	USC = re.Replace(USC,"[U]")
	USC = Replace(USC,"<u>","[U]")
	USC = Replace(USC,"<U>","[U]")
	USC = Replace(USC,"</u>","[/U]")
	USC = Replace(USC,"</U>","[/U]")

	re.Pattern = "(\<b ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>)"
	USC = re.Replace(USC,"[B]")
	USC = Replace(USC,"<b>","[B]")
	USC = Replace(USC,"<B>","[B]")
	USC = Replace(USC,"</b>","[/B]")
	USC = Replace(USC,"</B>","[/B]")

	USC = Replace(USC,"</MARQUEE>","[/FLY]")
	USC = Replace(USC,"</marquee>","[/FLY]")
	USC = Replace(USC,"<MARQUEE>","[FLY]")
	USC = Replace(USC,"<marquee>","[FLY]")

	re.Pattern="(\<\/A>)"
	USC=re.Replace(USC,"</A>" & VbCrLf)
	re.Pattern="\<A ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]?)HREF=""mailto:(.*)""([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]?)>(.*)\<\/A\>"
	USC= re.Replace(USC,"[EMAIL=$2]$4[/EMAIL]")
	re.Pattern="\<A (.*)(HREF|name)=\""(.[^\""[]*)\""([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]*)>(.*)\<\/A\>"
	USC= re.Replace(USC,"[URL=$3]$5[/URL]")
   	USC = Replace(USC,VbCrLf,"")

	USC = Replace(USC,"</div>","</P>")
	USC = Replace(USC,"</DIV>","</P>")
	USC = Replace(USC,"<div ","<P ")
	USC = Replace(USC,"<DIV ","<P ")

	re.Pattern="\<p align="
	USC=re.Replace(USC,VbCrLf & "<p align=")
	re.Pattern="\<p ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]?)align=(center|left|right|justify)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]?)>(.*)\<\/P\>"
	USC= re.Replace(USC,"[ALIGN=$2]$4[/ALIGN]")
   	USC = Replace(USC,VbCrLf,"")

	USC = Replace(USC,VbCrLf,"")
	USC = Replace(USC,chr(3),VbCrLf)

	re.Pattern = "\<p ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[PP]")
	'USC = Replace(USC,"<p>","[PP]")
	'USC = Replace(USC,"<P>","[PP]")
	'USC = Replace(USC,"</p>","[/PP]")
	'USC = Replace(USC,"</P>","[/PP]")
	USC = Replace(USC,"<p>","")
	USC = Replace(USC,"<P>","")
	USC = Replace(USC,"</p>",VbCrLf & VbCrLf)
	USC = Replace(USC,"</P>",VbCrLf & VbCrLf)

	re.Pattern = "\<hr ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[HR]")
	USC = Replace(USC,"<hr>","[HR]")
	USC = Replace(USC,"<HR>","[HR]")

	re.Pattern = "\<dir ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[UL]")
	USC = Replace(USC,"<DIR>","[UL]")
	USC = Replace(USC,"<dir>","[UL]")
	USC = Replace(USC,"</DIR>","[/UL]")
	USC = Replace(USC,"</dir>","[/UL]")

	USC = Replace(USC,"</PRE>","[/PRE]")
	USC = Replace(USC,"</pre>","[/PRE]")
	USC = Replace(USC,"<PRE>","[PRE]")
	USC = Replace(USC,"<pre>","[PRE]")

	re.Pattern = "\<strong ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[B]")
	USC = Replace(USC,"<STRONG>","[B]")
	USC = Replace(USC,"<strong>","[B]")
	USC = Replace(USC,"</STRONG>","[/B]")
	USC = Replace(USC,"</strong>","[/B]")

	re.Pattern = "\<em ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[I]")
	USC = Replace(USC,"<EM>","[I]")
	USC = Replace(USC,"<em>","[I]")
	USC = Replace(USC,"</EM>","[/I]")
	USC = Replace(USC,"</em>","[/I]")

	re.Pattern = "\<STRIKE ([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#\ \""]+)\>"
	USC = re.Replace(USC,"[STRIKE]")
	USC = Replace(USC,"<STRIKE>","[STRIKE]")
	USC = Replace(USC,"<strike>","[STRIKE]")
	USC = Replace(USC,"</STRIKE>","[/STRIKE]")
	USC = Replace(USC,"</strike>","[/STRIKE]")

	re.Pattern = "(\<script>)"
	USC = re.Replace(USC,"<script>")
	re.Pattern = "(\<script )"
	USC = re.Replace(USC,"<script>")
	re.Pattern = "(\</script>)"
	USC = re.Replace(USC,"</script>")
	USC = KillHTMLLabel(KillHTMLScript(USC))
	If CheckSupervisorUserName = 0 Then
		Html2UBBCode = UBB_FiltrateBadWords(USC)
	Else
		Html2UBBCode = USC
	End If
	Set Re = Nothing

End Function

Function KillHTMLScript(str)

	Dim n,m,str2
	str2 = str
	n = inStr(str2,"<script>")
	if n > 0 Then
		m = inStr(n + 1,str2,"</script>",0)
	Else
		m = 0
	End If
	Do while n > 0 and n < m and m > 0
		str2 = Left(str2,n-1) & Mid(str2,m+9)
		n = inStr(str2,"<script>")
		if n > 0 Then
			m = inStr(n + 1,str2,"</script>",0)
		Else
			m = 0
		End If
	Loop
	KillHTMLScript = str2

End Function

Function UBB_FiltrateBadWords(tempStr)

	Dim re
	Set re = New RegExp
	re.Global = True
	re.IgnoreCase = True

	Dim Str
	Str = tempStr
	Dim FiltrateBadWordString_Temp,i,Temp_N
	FiltrateBadWordString_Temp = split(FiltrateBadWordString, "|")
	Temp_N = ubound(FiltrateBadWordString_Temp)
	For i = 0 to Temp_N
		'Str = Replace(Str, FiltrateBadWordString_Temp(i), string(len(FiltrateBadWordString_Temp(i)),"*"), 1,-1,0)
		re.Pattern="(" & FiltrateBadWordString_Temp(i) & ")"
		Str=re.Replace(Str,string(len(FiltrateBadWordString_Temp(i)),"*"))
	Next
	Set Re = Nothing
	UBB_FiltrateBadWords = Str

End Function

Function UBB_Code_UnderWrite(str)

	Dim USC,LoopN
	USC = str
	USC = PrintTrueText(USC)
	USC = Replace(USC,VbCrLf,chr(3))
	Dim re
	Set re = New RegExp
	re.Global = True
	re.IgnoreCase = True

	re.Pattern="(javascript|jscript|js|about|file|vbscript|vbs)(:)"
	USC=re.Replace(USC,"$1&#58;")
	're.Pattern="(value)"
	'USC=re.Replace(USC,"&#118;alue")
	re.Pattern="(document)(.)(cookie)"
	USC=re.Replace(USC,"$1&#46;$3")
	re.Pattern="(on(mouse|exit|error|click|key))"
	USC=re.Replace(USC,"&#111;n$2")

	USC = Replace(USC,"[imga]","[img]")
	USC = Replace(USC,"[/imga]","[/img]")
	USC = Replace(USC,"[IMGA]","[IMG]")
	USC = Replace(USC,"[/IMGA]","[/IMG]")
    If DEF_UbbUnderwriteImages = 1 then
		re.Pattern="(\[\/IMG\])"
		USC=re.Replace(USC,"[/IMG]" & VbCrLf)
		re.Pattern="\[IMG=*([0-9]*),(absmiddle|left|right|top|middle|bottom|absbottom|baseline|texttop)\](/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)\[\/IMG]"
		USC=re.Replace(USC,"<IMG onmouseover=""javascript:if(this.width>520)this.width=520;"" src=""$3$4"" onload=""javascript:if(this.width>520)this.width=520;"" align=$2 border=$1>")
		re.Pattern="\[IMG\](/|../|http://|https://|ftp://)([A-Za-z0-9\./=\?%\-&_~`@$\(\)[\]\':+!#]+)\[\/IMG]"
		USC=re.Replace(USC,"<IMG onmouseover=""javascript:if(this.width>520)this.width=520;"" src=""$1$2"" onload=""javascript:if(this.width>520)this.width=520;"" align=absmiddle border=0>")
	   	USC = Replace(USC,VbCrLf,"")
    End If

	re.Pattern="(\[\/URL\])"
	USC=re.Replace(USC,"[/URL]" & VbCrLf)
	re.Pattern="(\[URL\])(.*)(\[\/URL\])"
	USC= re.Replace(USC,"<A HREF=""$2"" TARGET=_blank>$2</A>")
   	USC = Replace(USC,VbCrLf,"")
   	
	re.Pattern="(\[\/bgcolor\])"
	USC=re.Replace(USC,"[/bgcolor]" & VbCrLf)
   	re.Pattern="\[bgcolor=*(#*[a-z0-9]*),*(#*[a-z0-9]*)\](.*)\[\/bgcolor\]"
   	USC=re.Replace(USC,"<font style=""BACKGROUND-COLOR: $1"" color=$2>$3</font>")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/color\])"
	USC=re.Replace(USC,"[/color]" & VbCrLf)
   	re.Pattern="\[color=*(#*[a-z0-9]*)\](.*)\[\/color\]"
   	USC=re.Replace(USC,"<font color=""$1"">$2</font>")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[EMAIL\])(\S+\@.[^\[]*)(\[\/EMAIL\])"
	USC= re.Replace(USC,"<A HREF=""mailto:$2"">$2</A>")
	
	re.Pattern="(\[\/EMAIL\])"
	USC=re.Replace(USC,"[/EMAIL]" & VbCrLf)
	re.Pattern="(\[EMAIL=(\S+\@.[^\[]*)\])(.*)(\[\/EMAIL\])"
	USC= re.Replace(USC,"<A HREF=""mailto:$2"">$3</A>")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/face\])"
	USC=re.Replace(USC,"[/face]" & VbCrLf)
	re.Pattern="\[face=(.[^\[]*)\](.*)\[\/face\]"
	USC=re.Replace(USC,"<font face=$1>$2</font>")
	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/GLOW\])"
	USC=re.Replace(USC,"[/GLOW]" & VbCrLf)
	re.Pattern="\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.*)\[\/GLOW]"
	USC=re.Replace(USC,"<table glow width=$1><tr><td style=""filter:glow(color=$2, strength=$3)"">$4</td></tr></table glow>")
	USC = Replace(USC,VbCrLf,"")
	
	re.Pattern="(\[\/SHADOW\])"
	USC=re.Replace(USC,"[/SHADOW]" & VbCrLf)
	re.Pattern="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.*)\[\/SHADOW]"
	USC=re.Replace(USC,"<table shadow width=$1><tr><td style=""filter:shadow(color=$2, strength=$3)"">$4</td></tr></table shadow>")
	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/FLY\])"
	USC=re.Replace(USC,"[/FLY]" & VbCrLf)
	re.Pattern="\[FLY\](.*)\[\/FLY]"
	USC=re.Replace(USC,"<MARQUEE>$1</MARQUEE>")
	USC = Replace(USC,VbCrLf,"")

	USC = Replace(USC,"[b]","<b>")
	USC = Replace(USC,"[B]","<b>")
	USC = Replace(USC,"[/b]","</b>")
	USC = Replace(USC,"[/B]","</b>")
	
	USC = Replace(USC,"[u]","<u>")
	USC = Replace(USC,"[U]","<u>")
	USC = Replace(USC,"[/u]","</u>")
	USC = Replace(USC,"[/U]","</u>")
	
	USC = Replace(USC,"[i]","<i>")
	USC = Replace(USC,"[I]","<i>")
	USC = Replace(USC,"[/i]","</i>")
	USC = Replace(USC,"[/I]","</i>")

	re.Pattern="(\[\/align\])"
	USC=re.Replace(USC,"[/align]" & VbCrLf)
   	re.Pattern="\[align=(center|left|right|justify)\](.*)\[\/align]"
	USC=re.Replace(USC,"<p align=$1>$2</p>")
   	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/size\])"
	USC=re.Replace(USC,"[/size]" & VbCrLf)
	re.Pattern="\[size=*([0-9]*)\](.*)\[\/size]"
	USC=re.Replace(USC,"<font size=$1>$2</font>")
   	USC = Replace(USC,VbCrLf,"")
	
	USC = Replace(USC,"[sup]","<sup>")
	USC = Replace(USC,"[SUP]","<sup>")
	USC = Replace(USC,"[/sup]","</sup>")
	USC = Replace(USC,"[/SUP]","</sup>")
	
	USC = Replace(USC,"[sub]","<sub>")
	USC = Replace(USC,"[SUB]","<sub>")
	USC = Replace(USC,"[/sub]","</sub>")
	USC = Replace(USC,"[/SUB]","</sub>")
	
	USC = Replace(USC,"[strike]","<STRIKE>")
	USC = Replace(USC,"[STRIKE]","<STRIKE>")
	USC = Replace(USC,"[/strike]","</STRIKE>")
	USC = Replace(USC,"[/STRIKE]","</STRIKE>")

	USC = Replace(USC,"[ul]","<UL>")
	USC = Replace(USC,"[UL]","<UL>")
	USC = Replace(USC,"[/ul]","</UL>")
	USC = Replace(USC,"[/UL]","</UL>")

	USC = Replace(USC,"[ol]","<OL>")
	USC = Replace(USC,"[OL]","<OL>")
	USC = Replace(USC,"[/ol]","</OL>")
	USC = Replace(USC,"[/OL]","</OL>")

	USC = Replace(USC,"[*]","<LI>")
	USC = Replace(USC,"[/*]","</LI>")

	re.Pattern="(\[\/LIGHT\])"
	USC=re.Replace(USC,"[/LIGHT]" & VbCrLf)
	re.Pattern="\[LIGHT\](.*)\[\/LIGHT]"
	USC=re.Replace(USC,"<span style=""behavior:url(../inc/font.htc)"">$1</span>")
	USC = Replace(USC,VbCrLf,"")

	re.Pattern="(\[\/URL\])"
	USC=re.Replace(USC,"[/URL]" & VbCrLf)
	re.Pattern="(\[URL=(.[^\[]*)\])(.*)(\[\/URL\])"
	USC= re.Replace(USC,"<A HREF=""$2"" TARGET=_blank>$3</A>")
   	USC = Replace(USC,VbCrLf,"")

	If MyHomeUrl <> "" Then
		re.Pattern="(" & MyHomeUrl & ")"
		USC=re.Replace(USC,"../")
	End If

	USC = Replace(USC,"[pp]","<p>")
	USC = Replace(USC,"[/pp]","</p>")
	USC = Replace(USC,"[PP]","<p>")
	USC = Replace(USC,"[/PP]","</p>")
	USC = Replace(USC,chr(3),VbCrLf)

	If CheckSupervisorUserName = 0 Then
		UBB_Code_UnderWrite = UBB_FiltrateBadWords(USC)
	Else
		UBB_Code_UnderWrite = USC
	End If
	Set Re = Nothing

End Function%>