<!-- #include file=../inc/Ubbcode_Setup.jsp -->
<!--#include file="../plug-ins/qqubb.js"-->
<%
Dim MyHomeUrl,ConvertFlag
ConvertFlag = 1
MyHomeUrl = LCase(Request.Servervariables("SCRIPT_NAME"))
If Right(MyHomeUrl,23) = "/a/announce2.jsp" or Right(MyHomeUrl,26) = "/a/editannounce.jsp" 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/announce2.jsp","")
	MyHomeUrl = Replace(MyHomeUrl,"a/editannounce.jsp","")
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 Ubbcode3(str)
	str=Replace(str,"[HIDDEN]","以下为被隐藏的内容 [HR]")		
	str=Replace(str,"[/HIDDEN]"," [HR]")		
	ubbcode3=UBB_Code(Str)
End function


function UBB_Code(str)

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

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

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

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

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

	re.Pattern="(\[EMAIL\])(\S+\@.[^\[]*)(\[\/EMAIL\])"
	UBBStrCnt= re.Replace(UBBStrCnt,"<A HREF=""mailto:$2"">$2</A>")
	re.Pattern="\[QQ@*([0-9]*)\]"
	UBBStrCnt=re.Replace(UBBStrCnt,"&nbsp;<span onclick=""ShowQQ('$1')"" style=""cursor: hand""><img src=""../plug-ins/Img/$1.gif"" border=""0"" alt=""点击看我超酷表演""></span>&nbsp;")
	re.Pattern="(\[\/EMAIL\])"
	UBBStrCnt=re.Replace(UBBStrCnt,"[/EMAIL]" & VbCrLf)
	re.Pattern="(\[EMAIL=(\S+\@.[^\[]*)\])(.*)(\[\/EMAIL\])"
	UBBStrCnt= re.Replace(UBBStrCnt,"<A HREF=""mailto:$2"">$3</A>")
   	UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")

    If DEF_EnableFlashUBB = 1 and ConvertFlag = 1 then
    	re.Pattern="\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
		UBBStrCnt=re.Replace(UBBStrCnt,"<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]"
		UBBStrCnt=re.Replace(UBBStrCnt,"<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]"
			UBBStrCnt=re.Replace(UBBStrCnt,"<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=1></object>")
		
		re.Pattern="\[RM=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/RM]"
		UBBStrCnt=re.Replace(UBBStrCnt,"<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=1></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=""" & second(DEF_Now) & "$3""></OBJECT>")
		
		re.Pattern="(\[FLASH\])(http://|ftp://|../)(.[^\[]*)(.swf)(\[\/FLASH\])"

			UBBStrCnt= re.Replace(UBBStrCnt,"<a href=""$2$3$4"" TARGET=_blank><IMG SRC=../images/FileType/swf.gif border=0 align=absmiddle 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=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>")

	
		re.Pattern="(\[FLASH=*([0-9]*),*([0-9]*)\])(http://|ftp://|../)(.[^\[]*)(.swf)(\[\/FLASH\])"

			UBBStrCnt= re.Replace(UBBStrCnt,"<a href=""$4$5$6"" TARGET=_blank><IMG SRC=../images/FileType/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=$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>")
		

		If ConvertFlag = 1 Then
			re.Pattern="(\[sound\])(.[^\[]*)(\[\/sound\])" 
			UBBStrCnt=re.Replace(UBBStrCnt,"<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
   				UBBStrCnt=replace(UBBStrCnt,"[EM" & Right(("0" & LoopN),2) & "]","<img src=""../images/UBBicon/em" & Right("0" & LoopN,2) & ".GIF"" align=absmiddle border=0>",1,DEF_MaxUBBNumber,0)
   				UBBStrCnt=replace(UBBStrCnt,"[em" & Right(("0" & LoopN),2) & "]","<img src=""../images/UBBicon/em" & Right("0" & LoopN,2) & ".GIF"" align=absmiddle border=0>",1,DEF_MaxUBBNumber,0)
   			Else
   				UBBStrCnt=replace(UBBStrCnt,"[EM" & Right(("0" & LoopN),2) & "]","<img src=""../images/UBBicon/em" & Right("0" & LoopN,2) & ".GIF"">",1,DEF_MaxUBBNumber,0)
   				UBBStrCnt=replace(UBBStrCnt,"[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\])"
	UBBStrCnt=re.Replace(UBBStrCnt,"[/FIELDSET]" & VbCrLf)
   	re.Pattern="\[FIELDSET=(.*)\](.*)\[\/FIELDSET\]"
   	UBBStrCnt=re.Replace(UBBStrCnt,"<FIELDSET><LEGEND>$1</LEGEND>$2</FIELDSET>")
   	UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")

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

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

	re.Pattern="(\[\/FLY\])"
	UBBStrCnt=re.Replace(UBBStrCnt,"[/FLY]" & VbCrLf)
	re.Pattern="\[FLY\](.*)\[\/FLY]"
	UBBStrCnt=re.Replace(UBBStrCnt,"<MARQUEE>$1</MARQUEE>")
	UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")
	
	 re.Pattern="(\[\/HIDDEN\])"
     UBBStrCnt=re.Replace(UBBStrCnt,"[/HIDDEN]" & VbCrLf)
     re.Pattern="\[HIDDEN\](.*)\[\/HIDDEN]"
     UBBStrCnt=re.Replace(UBBStrCnt,"-----------------------------------------------------<br><font color=blue class=BlueFont>回复此帖才能查看内容</font><br>-----------------------------------------------------")
     UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")

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

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

	re.Pattern="(\[\/size\])"
	UBBStrCnt=re.Replace(UBBStrCnt,"[/size]" & VbCrLf)
	re.Pattern="\[size=*([0-9]*)\](.*)\[\/size]"
	UBBStrCnt=re.Replace(UBBStrCnt,"<font size=$1>$2</font>")
   	UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")
	
	UBBStrCnt = Replace(UBBStrCnt,"[sup]","<sup>")
	UBBStrCnt = Replace(UBBStrCnt,"[SUP]","<sup>")
	UBBStrCnt = Replace(UBBStrCnt,"[/sup]","</sup>")
	UBBStrCnt = Replace(UBBStrCnt,"[/SUP]","</sup>")
	
	UBBStrCnt = Replace(UBBStrCnt,"[sub]","<sub>")
	UBBStrCnt = Replace(UBBStrCnt,"[SUB]","<sub>")
	UBBStrCnt = Replace(UBBStrCnt,"[/sub]","</sub>")
	UBBStrCnt = Replace(UBBStrCnt,"[/SUB]","</sub>")
	
	UBBStrCnt = Replace(UBBStrCnt,"[strike]","<STRIKE>")
	UBBStrCnt = Replace(UBBStrCnt,"[STRIKE]","<STRIKE>")
	UBBStrCnt = Replace(UBBStrCnt,"[/strike]","</STRIKE>")
	UBBStrCnt = Replace(UBBStrCnt,"[/STRIKE]","</STRIKE>")
	
	UBBStrCnt = Replace(UBBStrCnt,"[ul]","<UL>")
	UBBStrCnt = Replace(UBBStrCnt,"[UL]","<UL>")
	UBBStrCnt = Replace(UBBStrCnt,"[/ul]","</UL>")
	UBBStrCnt = Replace(UBBStrCnt,"[/UL]","</UL>")
	
	UBBStrCnt = Replace(UBBStrCnt,"[ol]","<OL>")
	UBBStrCnt = Replace(UBBStrCnt,"[OL]","<OL>")
	UBBStrCnt = Replace(UBBStrCnt,"[/ol]","</OL>")
	UBBStrCnt = Replace(UBBStrCnt,"[/OL]","</OL>")
	
	UBBStrCnt = Replace(UBBStrCnt,"[*]","<LI>")
	UBBStrCnt = Replace(UBBStrCnt,"[/*]","</LI>")
	If ConvertFlag = 1 Then
		re.Pattern="(\[\/CODE\])"
		UBBStrCnt=re.Replace(UBBStrCnt,"[/CODE]" & VbCrLf)
		re.Pattern="\[CODE\](.*)\[\/CODE]"
		UBBStrCnt=re.Replace(UBBStrCnt,"<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>")
		UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")

		re.Pattern="(\[\/QUOTE\])"
		UBBStrCnt=re.Replace(UBBStrCnt,"[/QUOTE]" & VbCrLf)
		re.Pattern="\[QUOTE\](.*)\[\/QUOTE]"
		UBBStrCnt=re.Replace(UBBStrCnt,"<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>")
		UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")

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

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

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

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

	If ConvertFlag = 1 Then
		re.Pattern="(\[\/nulltable\])"
		UBBStrCnt=re.Replace(UBBStrCnt,"[/nulltable]" & VbCrLf)
		re.Pattern="\[nulltable\](.*)\[\/nulltable]"
		UBBStrCnt=re.Replace(UBBStrCnt,"<table border=0 cellspacing=0 cellpadding=0>$1</table>")
		UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")

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

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

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

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

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

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

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

	If CheckSupervisorUserName = 0 Then
		UBB_Code = UBB_FiltrateBadWords(UBBStrCnt)
	Else
		UBB_Code = UBBStrCnt
	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 UBBStrCnt,LoopN
	UBBStrCnt = str

	UBBStrCnt = ResumeUBBCode(UBBStrCnt)

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

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

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

	re.Pattern="(\<\/table>)"
	UBBStrCnt=re.Replace(UBBStrCnt,"</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>"
	UBBStrCnt= re.Replace(UBBStrCnt,"[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>"
	UBBStrCnt= re.Replace(UBBStrCnt,"[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%]*) bgColor=*(#*[a-z0-9]*) border=*([0-9]*)>(.*)</table>"
	UBBStrCnt= re.Replace(UBBStrCnt,"[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>"
	UBBStrCnt= re.Replace(UBBStrCnt,"[TABLE=$1,$2,$3,$4,$5,$6]$7[/TABLE]")

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

   	UBBStrCnt = Replace(UBBStrCnt,VbCrLf,"")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	re.Pattern = "(\<script>)"
	UBBStrCnt = re.Replace(UBBStrCnt,"<script>")
	re.Pattern = "(\<script )"
	UBBStrCnt = re.Replace(UBBStrCnt,"<script>")
	re.Pattern = "(\</script>)"
	UBBStrCnt = re.Replace(UBBStrCnt,"</script>")
	UBBStrCnt = KillHTMLLabel(KillHTMLScript(UBBStrCnt))
	If CheckSupervisorUserName = 0 Then
		Html2UBBCode = UBB_FiltrateBadWords(UBBStrCnt)
	Else
		Html2UBBCode = UBBStrCnt
	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 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)
    next
    UBB_FiltrateBadWords = Str

end function

function UBB_Code_UnderWrite(str)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

End Function%>
