<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

Dim Ubb
Set Ubb = New AsaiMHUbbCode

Class AsaiMHUbbCode
	Private IsOpenHTML,IsOpenUBB
	Private re,xml,isxhtml,MaxLoopcount
	Private m_strBasePath,SettingArray,m_strPicPath
	Private m_strTitle
	Private m_strImgzoom,m_intResize
	Public  showxhtml
	Private sub Class_Initialize()
		On Error Resume Next
		'是否开放HTML代码
		IsOpenHTML = 0 
		IsOpenUBB = 0
		'UBB代码勘套循环的最多次数，避免死循环加入此变量
		MaxLoopcount =100
		set re = New RegExp
		re.IgnoreCase = True
		re.Global = True
		set xml = server.Createobject("msxml2.DOMDocument"& MsxmlVersion)
		'SettingArray = Array(0,0,0,0,0,0,0,0,0,0,0,550,0,0,1)
		SettingArray = Array(0,0,0,0,0,0,0,0,0,0,0,650,0,0,1)
		'-- 图片路径
		m_strPicPath = Cls.Web_Dir & "Images/Pic/"
		m_strBasePath = Cls.Web_Dir
		m_strTitle = ""
		showxhtml = False
	End sub
	
	Private sub Class_Terminate()
		set re = Nothing
		set xml = Nothing
		set ubb = Nothing
	End sub

	Public Property Let setUbbcode( setValue )
			SettingArray = SplitArray(setValue, "|",4)
	End Property
	
	Public Property Let Title( TitleValue )
			m_strTitle = TitleValue
	End Property
	
	Public Function FilterEm(s)
		if Cls.Is_Null(s)="" then
		  FilterEm=""
		  exit function
		End If
		re.Pattern="\[em(b|c|q)?(\d+)\]"
		s=re.Replace(s, "<image src="""&Cls.Web_Dir&"Images/Em/Em$1/$2.gif"" border="""">&nbsp;")
		FilterEm=s
	End Function

	Public Function HtmlCode(ByVal strContent)
	    If IsOpenUBB = 1 Then
		   IsOpenHtml = 1
		   HtmlCode = UbbCode(strContent)
		End If
		Dim re
		Set re = New RegExp
		re.IgnoreCase = True
		re.Global = True
		strContent=FilterEm(strContent)
		'不健康字符过滤
		strContent = Cls.Code_Health(strContent)
		'过滤危险脚本
		re.Pattern = "(<s+cript(.[^>]*)>)"
		strContent = re.Replace(strContent, "&lt;&#83cript$2&gt;")
		re.Pattern = "(<\/s+cript>)"
		strContent = re.Replace(strContent, "&lt;/&#83cript&gt;")
		re.Pattern = "(<iframe(.[^>]*)>)"
		strContent = re.Replace(strContent, "&lt;iframe$2&gt;")
		re.Pattern = "(<\/iframe>)"
		strContent = re.Replace(strContent, "&lt;/iframe&gt;")
		re.Pattern = "(<body(.[^>]*)>)"
		strContent = re.Replace(strContent, "<body>")
		re.Pattern = "(<\!(.[^>]*)>)"
		strContent = re.Replace(strContent, "&lt;$2&gt;")
		re.Pattern = "(<\!)"
		strContent = re.Replace(strContent, "&lt;!")
		re.Pattern = "(-->)"
		strContent = re.Replace(strContent, "--&gt;")
		re.Pattern = "(javascript:)"
		strContent = re.Replace(strContent, "<i>javascript</i>:")
		Set re = Nothing
		strContent = Replace(strContent, "{", "&#123;")
		strContent = Replace(strContent, "}", "&#125;")
		strContent = Replace(strContent, "$", "&#36;")
		strContent = Replace(strContent, "{$download_dir}", Cls.Web_Dir&Cls.Web_Upload)
		strContent = Replace(strContent, "{$web_dir}", Cls.Web_Dir)
		HtmlCode = Cls.ReWord(strContent)
	End Function
	
	Public Function UBBCode(ByVal strContent)
        	If Cls.Is_Null(strContent) = "" then exit function
		m_intResize = Cls.ChkNumeric(SettingArray(11))
		If m_intResize < 10 Then
			m_strImgzoom = "return imgresize(this);"
		Else
			m_strImgzoom = "return imgzoom(this," & m_intResize & ");"
		End If
		're.Pattern="([\f\n\r\t\v])"
		'strContent=re.Replace(strContent,"")
		'不健康字符过滤
		strContent = Cls.Code_Health(strContent)
		'Html标签替换
		If IsOpenHTML=0 Then
			strContent=Replace(strContent,"<","&lt;")
			strContent=Replace(strContent,">","&gt;")
			strContent=Replace(strContent, vbNewLine,"&#13;&#10;<br />")
			strContent=Replace(strContent, "  ", "&nbsp;&nbsp;")
		End If
		'载入EM图片
		strContent=FilterEm(strContent)
		'断行
		re.Pattern="(<p>&nbsp;<\/p>)"
		strContent=re.Replace(strContent, "")
		re.Pattern="(\[ChannelDir\])"		
		strContent=re.Replace(strContent, m_strBasePath)
		re.Pattern="(<s+cript(.[^>]*)>)"
		strContent=re.Replace(strContent,"&lt;&#83cript$2&gt;")
		re.Pattern="(<\/s+cript>)"
		re.Pattern = "(<iframe(.[^>]*)>)"
		strContent = re.Replace(strContent, "&lt;iframe$2&gt;")
		re.Pattern = "(<\/iframe>)"
		strContent = re.Replace(strContent, "&lt;/iframe&gt;")
		strContent=re.Replace(strContent,"&lt;/&#83cript&gt;")
		
		'  斜体设置
		
	'	re.Pattern="(on(load|click|dbclick|mouseover|mouseout|mousedown|mouseup|mousewheel|keydown|submit|change|focus))"
	
	'	strContent=re.Replace(strContent,"<i>$1</i>")	
		'-- 是否禁用URL标签
		If SettingArray(1) = "0" And SettingArray(0) = "0" Then
			strContent=ProcessUbbCode_S1(strContent,"url","<a href=""$1"" target=""_blank"">$1</a>")
			strContent=ProcessUbbCode_UF(strContent,"url","<a href=""$1"" target=""_blank"">$2</a>","0")
		Else
			strContent=ProcessUbbCode_S1(strContent,"url","$1")
			strContent=ProcessUbbCode_UF(strContent,"url","$2","0")
		End If
		'-- 是否禁用IMG标签
		If SettingArray(2) = "0" And SettingArray(0) = "0" Then
			re.Pattern="(\[img\])(.[^\[]*)(\[\/img\])"
			strContent=re.Replace(strContent,"<img src=""$2"" border=0 onload="""&m_strImgzoom&""" onclick=""zoom(this, '$2', '"&Cls.Web_Dir&"images/viewpic')"" style=""cursor: pointer;"" />")
		Else
			re.Pattern="(\[img\])(.[^\[]*)(\[\/img\])"
			strContent=re.Replace(strContent,"$2")
		End If
		'暂不需此功能
		'strContent=checkimg(bbimg(strContent))
		If SettingArray(5) = "0" And SettingArray(0) = "0" Then
			strContent=ProcessUbbCode_S1(strContent,"email","<a href=""mailto:$1"">$1</a>")
			strContent=ProcessUbbCode_UF(strContent,"email","<a href=""mailto:$1"" target=""_blank"">$2</a>","0")
		Else
			strContent=ProcessUbbCode_S1(strContent,"email","$1")
			strContent=ProcessUbbCode_UF(strContent,"email","$2","0")
		End If
		'--是否禁用DOWN标签
		If SettingArray(7) = "0" And SettingArray(0) = "0" Then
			strContent=ProcessUbbCode_S1(strContent,"down","<a href=""$1"" target=""_blank""><img src=""" & m_strPicPath & "download.gif"" alt="""" border=""0"" style=""margin:0px 2px -4px 0px""/>点击下载此文件</a>")
			strContent=ProcessUbbCode_UF(strContent,"down","<a href=""$1"" target=""_blank""><img src=""" & m_strPicPath & "download.gif"" alt="""" border=""0"" style=""margin:0px 2px -4px 0px""/>$2</a>","0")
		Else
			strContent=ProcessUbbCode_S1(strContent,"down","$1")
			strContent=ProcessUbbCode_UF(strContent,"down","$2","0")
		End If
		If SettingArray(8) = "0" And SettingArray(0) = "0" Then
			strContent=ProcessUbbCode_S1(strContent,"ed2k","<a href=""$1"" target=""_blank""><img src=""" & m_strPicPath & "ed2k.gif"" alt="""" border=""0"" style=""margin:0px 2px -4px 0px""/>$1</a>")
			strContent=ProcessUbbCode_UF(strContent,"ed2k","<a href=""$1"" target=""_blank""><img src=""" & m_strPicPath & "ed2k.gif"" alt="""" border=""0"" style=""margin:0px 2px -4px 0px""/>$2</a>","0")
		Else
			strContent=ProcessUbbCode_S1(strContent,"ed2k","$1")
			strContent=ProcessUbbCode_UF(strContent,"ed2k","$2","0")
		End If
		If  SettingArray(0) = "0" Then
			strContent=ProcessUbbCode_S1(strContent,"code","<div class=""UBBContainer""><div class=""UBBTitle""><img src=""" & m_strPicPath & "code.gif"" style=""margin:0px 2px -3px 0px"" alt=""以下内容为程序代码""/> 以下内容为程序代码</div><div class=""UBBContent"">$1</div></div>")
			strContent=ProcessUbbCode_Q(strContent,"quote","<div class=""UBBContainer""><div class=""UBBTitle""><img src=""" & m_strPicPath & "quote.gif"" style=""margin:0px 2px -3px 0px"" alt=""引用内容""/> 引用内容</div><div class=""UBBContent"">$1</div></div>")
			strContent=ProcessUbbCode_UF(strContent,"color","<font color=""$1"">$2</font>","1")
			strContent=ProcessUbbCode_S1(strContent,"center","<div align=""center"">$1</div>")
			strContent=ProcessUbbCode_S1(strContent,"fly","<marquee width=""90%"" behavior=""alternate"" scrollamount=""3"">$1</marquee>")
			strContent=ProcessUbbCode_S1(strContent,"move","<marquee scrollamount=""3"">$1</marquee>")
			strContent=ProcessUbbCode_iS1(strContent,"shadow","<div style=""width:$1px;filter:shadow(color=$2, strength=$3)"">$4</div>")
			strContent=ProcessUbbCode_iS1(strContent,"glow","<div style=""width:$1px;filter:glow(color=$2, strength=$3)"">$4</div>")
			strContent=ProcessUbbCode_UF(strContent,"size","<font size=""$1"">$2</font>","1")
			strContent=ProcessUbbCode_S1(strContent,"i","<i>$1</i>")
			strContent=ProcessUbbCode_S1(strContent,"b","<b>$1</b>")
			strContent=ProcessUbbCode_S1(strContent,"u","<u>$1</u>")
			'strContent=ProcessUbbCode_Align(strContent)
			re.Pattern="\[align=(\w{4,6})\]([^\r]*?)\[\/align\]"
			strContent=re.Replace(strContent,"<div align=""$1"">$2</div>")
			re.Pattern="\[(list)\]"
			strContent=re.Replace(strContent,"<ul>")
			re.Pattern="\[list=(.[^\]]*)\]"
			strContent=re.Replace(strContent,"<ul style=""list-style-type:$1"">")
			re.Pattern="\[\*\](.[^\[]*)(\n|)"
			strContent=re.Replace(strContent,"<li>$1</li>")
			re.Pattern="\[(\/list)\]"
			strContent=re.Replace(strContent,"</ul>")		
		End If
		If  SettingArray(6) = "0" Then
			strContent=ProcessUbbCode_C(strContent,"html")
		End If
		If SettingArray(3) = "0" And SettingArray(0) = "0" Then
			re.Pattern = "(\[flash\])(.[^\[]*)(\[\/flash\])"
			strContent = re.Replace(strContent, "<object codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"" classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" width=""500"" height=""450""><param name=""movie"" value=""$2"" /><param name=""quality"" value=""high"" /><param name=""AllowScriptAccess"" value=""never"" /><embed src=""$2"" quality=""high"" pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""500"" height=""450""></embed></object>")
			re.Pattern = "(\[flash=*([0-9]*),*([0-9]*)\])(.[^\[]*)(\[\/flash\])"
			strContent = re.Replace(strContent, "<object codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"" classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" width=""$2"" height=""$3""><param name=""movie"" value=""$4"" /><param name=""quality"" value=""high"" /><param name=""AllowScriptAccess"" value=""never"" /><embed src=""$4"" quality=""high"" pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""$2"" height=""$3""></embed></object>")
		ElseIf SettingArray(0) = "1" Then
			re.Pattern = "(\[flash\])(.[^\[]*)(\[\/flash\])"
			strContent = re.Replace(strContent, "$2")
			re.Pattern = "(\[flash=*([0-9]*),*([0-9]*)\])(.[^\[]*)(\[\/flash\])"
			strContent = re.Replace(strContent, "$4")
		End If
		
		If SettingArray(4) = "0" And SettingArray(0) = "0" Then
			'-----------多媒体标签----------------
			re.Pattern = "\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
			strContent = re.Replace(strContent, "<embed src=""$3"" pluginspage=""http://www.macromedia.com/shockwave/download/"" width=""$1"" height=""$2""></embed>")
			re.Pattern = "\[QT=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/QT]"
			strContent = re.Replace(strContent, "<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/""></embed>")
			re.Pattern = "\[MP=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/MP]"
			strContent = re.Replace(strContent, "<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>")
			re.Pattern = "(\[rm\])(.[^\[]*)(\[\/rm\])"
			strContent = re.Replace(strContent, "<object classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" class=""OBJECT"" id=""RAOCX"" width=""400"" height=""400""><param name=""src"" value=""$2""/><param name=""console"" value=""Clip1""/><param name=""controls"" value=""imagewindow""/><param name=""autostart"" value=""true""/></object><br/><object classid=""CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" height=""32"" id=""video2"" width=""400""><param name=src value=""$2""/><param name=""autostart"" value=""-1""/><param name=""controls"" value=""controlpanel""/><param name=""console"" value=""Clip1""/></object>")
			re.Pattern = "\[rm=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/rm]"
			strContent = re.Replace(strContent, "<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=""Clip1""/><param name=""controls"" value=""imagewindow""/><param name=""autostart"" value=""true""/></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=""Clip1""/></object>")
			re.Pattern = "(\[wmv\])(.[^\[]*)(\[\/wmv\])"
			strContent = re.Replace(strContent, "<object classid=""clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"" codebase=""http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902"" type=""application/x-oleobject"" standby=""Loading..."" width=""400"" height=""300"">"&_
			"<param name=""FileName"" VALUE=""$2"" /><param name=""ShowStatusBar"" value=""-1"" /><param name=""AutoStart"" value=""true"" /><param name=""volume"" value=""90""/><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""$2"" autostart=""true"" width=""400"" height=""300"" /></object>")
			re.Pattern = "\[wmv=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/wmv]"
			strContent = re.Replace(strContent, "<object classid=""clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"" codebase=""http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902"" type=""application/x-oleobject"" standby=""Loading..."" width=""$1"" height=""$2"">"&_
			"<param name=""FileName"" VALUE=""$3"" /><param name=""ShowStatusBar"" value=""-1"" /><param name=""AutoStart"" value=""true"" /><param name=""volume"" value=""90""/><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""$3"" autostart=""true"" width=""$1"" height=""$2"" /></object>")
			re.Pattern = "(\[wma\])(.[^\[]*)(\[\/wma\])"
			strContent = re.Replace(strContent, "<object classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" id=""MediaPlayer"" width=""450"" height=""65""><param name=""FileName"" VALUE=""$2"" /><param name=""howStatusBar"" value=""-1""/><param name=""AutoStart"" value=""true""/><param name=""Filename"" value=""$2""/><param name=""volume"" value=""90""/><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""$2"" autostart=""true"" width=""450"" height=""70"" /></object>")
			re.Pattern = "\[wma=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/wma]"
			strContent = re.Replace(strContent, "<object classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" id=""MediaPlayer"" width=""$1"" height=""$2""><param name=""Filename"" value=""$3""/><param name=""howStatusBar"" value=""-1""/><param name=""AutoStart"" value=""true""/><param name=""volume"" value=""90""/><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""$3"" autostart=""true"" width=""$1"" height=""$2"" /></object>")
			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=""true""/><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=""450"" autostart=""true"" height=""60""></embed></object>")
			re.Pattern = "\[ra=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/ra]"
			strContent = re.Replace(strContent, "<object classid=""clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" id=""RAOCX"" width=""$1"" height=""$2""><param name=""_ExtentX"" value=""6694""/><param name=""_ExtentY"" value=""1588""/><param name=""AUTOSTART"" value=""true""/><param name=""SHUFFLE"" value=""0""/><param name=""PREFETCH"" value=""0""/>"&_
			"<param name=""NOLABELS"" value=""0""/><param name=""SRC"" value=""$3""/><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=""$3"" width=""$1"" autostart=""true"" height=""$2""></embed></object>")
			re.Pattern="(\[mid\])(.[^\]]*)\[\/mid\]"
			strContent= re.Replace(strContent,"<embed src=""$2"" height=""45"" width=""314"" autostart=""0""></embed>")
		ElseIf SettingArray(4) = "2" And SettingArray(0) = "0" Then
			strContent=ProcessUbbCode_MP(strContent)
			re.Pattern="(\[mid\])(.[^\]]*)\[\/mid\]"
			strContent= re.Replace(strContent,"<embed src=""$2"" height=""45"" width=""314"" autostart=""0""></embed>")
		End If
		If SettingArray(9) = "0" Then
			'自动识别网址
			re.Pattern="(^|[^<=""'])((http|https|ftp|rtsp|mms|ed2k):(\/\/|\\\\)(([\w\/\\\+\-~`@:%\/\|])+\.)+([\w\/\\\.\=\?\+\-~`@\':!%#\/\|]|(&amp;)|&)+)"
			strContent=re.Replace(strContent,"$1<a target=""_blank"" href=""$2"">$2</a>")
			
			'自动识别www等开头的网址
			're.Pattern="(^|[^\/\\\w\=])((www|Bbs)\.(\w)+\.([\w\/\\\.\=\?\+\-~`@\'!%#]|(&amp;))+)"
			'strContent=re.Replace(strContent,"$1<a target=""_blank"" href=""http://$2"">$2</a>")			
		End If
		'替换UPLOAD标签
		If SettingArray(10) = "0" Then
			strContent=ProcessUbbCode_U(strContent,1)
		End If
		'替换UBB断行
		re.Pattern="(\[br ?\/?\])"
		strContent=re.Replace(strContent, "<br/>")
		strContent = Replace(strContent, "{$download_dir}", Cls.Web_Dir &Cls.Web_Upload)
		strContent = Replace(strContent, "{$web_dir}", Cls.Web_Dir)
		If int(Format_Mid_Num(11)) = 1 Then
		If xml.loadxml("<div>" & replace(strContent,"&","&amp;") &"</div>") Then
			isxhtml=True
			if showxhtml And Login_modep = 1 then strContent=strContent&"<p style=""color:green"" align=""right"">[此文符合XHML规范，内容为纯文本或UBB(UBB解释文件版本：AsaiMH-UBB 7.8)]</p>"
		Else
			isxhtml=false
			if showxhtml And Login_modep = 1 then strContent=strContent&"<p style=""color:red"" align=""right"">[此文不符合XHML规范(UBB解释文件版本：AsaiMH-UBB 7.8)]</p>"			
		End If
		End If
		UBBCode = Cls.ReWord(strContent)
	End Function
	
	Function CheckImg(textstr)
		Dim node,srctext,newnode
		If xml.loadxml("<div>" & replace(textstr,"&","&amp;") &"</div>")Then
			For Each Node in xml.documentElement.getElementsByTagName("img")
				'-- 是否开启滚轮改变图片大小的功能，如果不需要可以屏蔽
				'-- Node.attributes.setNamedItem(xml.createNode(2,"onmousewheel","")).text="return bbimg(this);"
				Node.attributes.setNamedItem(xml.createNode(2,"border","")).text=0
				Node.attributes.setNamedItem(xml.createNode(2,"onload","")).text=m_strImgzoom
				Node.attributes.setNamedItem(xml.createNode(2,"style","")).text="cursor: pointer;"
				Node.attributes.setNamedItem(xml.createNode(2,"onclick","")).text="javascript:window.open(this.src);"
				'--删除相关节点
				If m_strTitle <> "" Then
					Node.attributes.setNamedItem(xml.createNode(2,"alt","")).text=m_strTitle
				End If
				Node.attributes.removeNamedItem("title")
				Node.attributes.removeNamedItem("twffan")
				If Not Node.parentNode is Nothing Then
					If Node.parentNode.nodename = "a" Then
							Node.attributes.removeNamedItem("onclick")
							Node.attributes.setNamedItem(xml.createNode(2,"target","")).text="_blank"
					End If
				End If
			Next
			checkimg=xmldecode(Mid(xml.documentElement.xml,6,Len (xml.documentElement.xml)-11))
		Else
			checkimg=textstr
		End If
	End Function
	
	Private Function bbimg(strText)
		Dim s
		s=strText
		re.Pattern="<img(\w*) style\s*=""*([^>|""]*)""([^>]*)>"
		s=re.Replace(s,"<img$1$3>")
		re.Pattern="<img(.[^>]*)>"
		s=re.Replace(s, "<img$1/>")
		re.Pattern="(\/\/>)"
		s=re.Replace(s, "/>")
		re.Pattern="<img(.[^>]*)([/| ])>"
		s=re.Replace(s,"<img$1/>")
		re.Pattern="<img(.[^>]*)/>"
		s=re.Replace(s,"<img$1 onload="""&m_strImgzoom&""" onclick=""javascript:window.open(this.src);"" style=""cursor: pointer;""/>")
		bbimg=s
	End Function
	
	Private Function ProcessUbbCode_MP(strContent)
		re.Pattern="\[(flash|wma|wmv|rm|ra|qt)(=\d*?|)(,\d*?|)\]([^<>]*?)\[\/(flash|wma|wmv|rm|ra|qt)\]"
		Set strMatchs=re.Execute(strContent)
		Dim strMatch,strMatchs
		Dim strType,strWidth,strHeight,strSRC,TitleText,rndID
		For Each strMatch in strMatchs
			RAndomize
			strType=strMatch.SubMatches(0)
			If strType="flash" Then
				TitleText="<img src=""" & m_strPicPath & "flash.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>Flash动画"
			ElseIf strType="wma" Then
				TitleText="<img src=""" & m_strPicPath & "music.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放音频文件"
			ElseIf strType="wmv" Then
				TitleText="<img src=""" & m_strPicPath & "mediaplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放视频文件"		 
			ElseIf strType="rm" Then
				TitleText="<img src=""" & m_strPicPath & "realplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放real视频流文件"		 
			ElseIf strType="ra" Then
				TitleText="<img src=""" & m_strPicPath & "realplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放real音频流文件"		 
			ElseIf strType="qt" Then
				TitleText="<img src=""" & m_strPicPath & "mediaplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放mov视频文件"		 
			End If
			strWidth=strMatch.SubMatches(1)
			strHeight=strMatch.SubMatches(2)
			If (len(strWidth)=0) Then 
				strWidth="400"
			Else
				strWidth=right(strWidth,(len(strWidth)-1))
			End If
			If (len(strHeight)=0) Then
				strHeight="300"
			Else
				strHeight=right(strHeight,(len(strHeight)-1))
			End If
			strSRC=strMatch.SubMatches(3)
			rndID="temp"&Int(100000 * Rnd)
			strContent= Replace(strContent,strMatch.Value,"<div class=""UBBContainer""><div class=""UBBTitle"">"&TitleText&"</div><div class=""UBBContent""><a id="""+rndID+"_href"" href=""javascript:MediaShow('"+strType+"','"+rndID+"','"+strSRC+"','"+strWidth+"','"+strHeight+"','"+m_strPicPath+"')""><img name="""+rndID+"_img"" src=""" & m_strPicPath & "mm_snd.gif"" style=""margin:0px 3px -2px 0px"" border=""0"" alt=""""/><span id="""+rndID+"_text"">在线播放</span></a><div id="""+rndID+"""></div></div></div>")
		Next
		Set strMatchs=nothing
		ProcessUbbCode_MP = strContent
	End Function

	Private Function ProcessUbbCode_Q(strText,uCodeC,tCode)
		Dim s
		Dim Test
		Dim LoopCount
		LoopCount=0
		s=strText
		re.Pattern="\["&uCodeC&"\]"
		Test=re.Test(s)
		If Test Then
			re.Pattern="\[\/"&uCodeC&"\]"
			Test=re.Test(s)
			If Test Then
				re.Pattern="\["&uCodeC&"\]"
				s=re.replace(s, chr(1) & "QUOTE" & chr(2))
				re.Pattern="\[\/"&uCodeC&"\]"
				s=re.replace(s, chr(1) & "/"&uCodeC&"" & chr(2))
				Do
					re.Pattern="\x01"&uCodeC&"\x02\x01\/"&uCodeC&"\x02"
					s=re.Replace(s,"")
					re.Pattern="\x01"&uCodeC&"\x02(.[^\x01]*)\x01\/"&uCodeC&"\x02"
					s=re.Replace(s,tCode)
					Test=re.Test(s)
					LoopCount=LoopCount+1
					If LoopCount>MaxLoopCount Then Exit Do
				Loop While(Test)
				re.Pattern="\x02"
				s=re.replace(s, "]")
				re.Pattern="\x01"
				s=re.replace(s, "[")
			End If
		End If
		ProcessUbbCode_Q=s
	End Function

	Private Function ProcessUbbCode_U(strText,Flag)	'(内容，是否开放图片标签)
		Dim s
		s=strText
		re.Pattern="\[UPLOAD=(gif|jpg|jpeg|bmp|png|swf|swi)\]"
		s=re.replace(s, chr(1) & "UPLOAD=$1" & chr(2))
		re.Pattern="\[\/UPLOAD\]"
		s=re.replace(s, chr(1) & "/UPLOAD" & chr(2))
		re.Pattern="\x01UPLOAD=(gif|jpg|jpeg|bmp|png)\x02\x01\/UPLOAD\x02"
		s=re.Replace(s,"")
		re.Pattern="\x01UPLOAD=(gif|jpg|jpeg|bmp|png)\x02(.[^\x01]*)\x01\/UPLOAD\x02"
		If Flag = 1 Then
			s= re.Replace(s,"<br /><IMG SRC="""&Cls.Web_Dir&"Images/FileType/$1.gif"" border=0 align=absmiddle> 相关图片如下：<br /><IMG SRC=""$2"" border=0 onload="""&m_strImgzoom&""" onclick=""zoom(this, '$2', '"&Cls.Web_Dir&"images/viewpic')"" style=""cursor: pointer;""/><br />")
		Else
			s= re.Replace(s,"<br /><IMG SRC="""&Cls.Web_Dir&"Images/FileType/$1.gif"" border=0 align=absmiddle><A HREF=""$2"" TARGET=_blank>$2</A><br /><IMG SRC=""$2"" border=0 onload="""&m_strImgzoom&""" onclick=""zoom(this, '$2')"" style=""cursor: pointer;""/><br />")
		End If
		re.Pattern="\x01UPLOAD=(swf|swi)\x02(.[^\x01]*)\x01\/UPLOAD\x02"
		If Flag = 1 Then
			s= re.Replace(s,"<br /><IMG SRC="""&Cls.Web_Dir&"Images/FileType/swf.gif"" border=0 align=absmiddle><A HREF=""$2"" TARGET=_blank>点击浏览该FLASH文件</A>：<br /><embed src=""$2"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=500 height=300></embed><br />")
		Else
			s= re.Replace(s,"<br /><IMG SRC="""&Cls.Web_Dir&"Images/FileType/swf.gif"" border=0 align=absmiddle><A HREF=""$2"" TARGET=_blank>$2</A><br />")
		End If
		re.Pattern="\x02"
		s=re.replace(s, "]")
		re.Pattern="\x01"
		s=re.replace(s, "[")
		re.Pattern="\[UPLOAD=(.[^\[]*)\]"
		s=re.replace(s, chr(1) & "UPLOAD=$1" & chr(2))
		re.Pattern="\[\/UPLOAD\]"
		s=re.replace(s, chr(1) & "/UPLOAD" & chr(2))
		re.Pattern="\x01UPLOAD=(.[^\x01]*)\x02\x01\/UPLOAD\x02"
		s=re.Replace(s,"")
		re.Pattern="\x01UPLOAD=(.[^\x01]*)\x02(.[^\x01]*)\x01\/UPLOAD\x02"
		if Is_LoginTrue then
			s= re.Replace(s,"<br /><IMG SRC="""&Cls.Web_Dir&"Images/FileType/$1.gif"" border=0> <a href=""$2"" target=_blank>点击下载</a><br />")
		else
			s= re.Replace(s,"<br /><IMG SRC="""&Cls.Web_Dir&"Images/FileType/$1.gif"" border=0> <a href='"&Cls.Web_Dir&"User/Login.asp?old_url=back' title='对不起，您需要登陆才能下载本附件！'>点击下载</a><br />")
		End If
		's= re.Replace(s,"<br /><IMG SRC="""&Cls.Web_Dir&"Images/FileType/$1.gif"" border=0> <a href=""$2"" target=_blank>点击浏览该文件</a><br /><IMG src=""$2"" border=0 ><br />")
		re.Pattern="\x02"
		s=re.replace(s, "]")
		re.Pattern="\x01"
		s=re.replace(s, "[")
		ProcessUbbCode_U=s
	End Function

	Private Function ProcessUbbCode_S1(strText,uCodeC,tCode)
		Dim s
		s=strText
		re.Pattern="\["&uCodeC&"\][\s\n]*\[\/"&uCodeC&"\]"
		s=re.Replace(s,"")
		re.Pattern="\[\/"&uCodeC&"\]"
		s=re.Replace(s, Chr(1)&"/"&uCodeC&"]")
		re.Pattern="\["&uCodeC&"\]([^\x01]*)\x01\/"&uCodeC&"\]"
		s=re.Replace(s,tCode)
		re.Pattern="\x01\/"&uCodeC&"\]"
		s=re.Replace(s,"[/"&uCodeC&"]")
		ProcessUbbCode_S1=s
	End Function

	Private Function ProcessUbbCode_UF(strText,uCodeC,tCode,Flag)
		Dim s
		Dim LoopCount
		LoopCount=0
		s=strText
		'===============修正字体及字体大小开始
		re.Pattern="\[FACE=(.[^\[]*)\]"
		s=re.replace(s, chr(1) & "FACE=$1" & chr(2))
		re.Pattern="\[\/FACE\]"
		s=re.replace(s, chr(1) & "/FACE" & chr(2))
		re.Pattern="\x01FACE=(.[^\x01]*)\x02\x01\/FACE\x02"
		s=re.Replace(s,"")
		re.Pattern="\x01FACE=(.[^\x01]*)\x02(.[^\x01]*)\x01\/FACE\x02"
		s=re.Replace(s,"<font face=$1>$2</font>")
		re.Pattern="\x02"
		s=re.replace(s, "]")
		re.Pattern="\x01"
		s=re.replace(s, "[")
		re.Pattern="\[SIZE=([1-7])\]"
		s=re.replace(s, chr(1) & "SIZE=$1" & chr(2))
		re.Pattern="\[\/SIZE\]"
		s=re.replace(s, chr(1) & "/SIZE" & chr(2))
		re.Pattern="\x01SIZE=([1-7])\x02\x01\/SIZE\x02"
		s=re.Replace(s,"")
		re.Pattern="\x01SIZE=([1-7])\x02(.[^\x01]*)\x01\/SIZE\x02"
		s=re.Replace(s,"<font size=$1>$2</font>")
		re.Pattern="\x02"
		s=re.replace(s, "]")
		re.Pattern="\x01"
		s=re.replace(s, "[")
		'===============修正字体及字体大小结束
		re.Pattern="\["&uCodeC&"=([^\]]*)\][\s\n ]*\[\/"&uCodeC&"\]"
		s=re.Replace(s,"")
		re.Pattern="\[\/"&uCodeC&"\]"
		s=re.Replace(s, chr(1)&"/"&uCodeC&"]")
		re.Pattern="\["&uCodeC&"=([^\]]*)\]([^\x01]*)\x01\/"&uCodeC&"\]"
		If Flag="1" Then 
			Do While Re.Test(s)
				s=re.Replace(s,tCode)
				LoopCount=LoopCount+1
				If LoopCount>MaxLoopCount Then Exit Do
			Loop
		ElseIf Flag="0" Then
			s=re.Replace(s,tCode)
		Else
			re.Pattern="\["&uCodeC&"=(["&Flag&"]*)\]([^\x01]*)\x01\/"&uCodeC&"\]"
			Do While Re.Test(s)
				s=re.Replace(s,tCode)
				LoopCount=LoopCount+1
				If LoopCount>MaxLoopCount Then Exit Do
			Loop
		End If
		re.Pattern="\x01\/"&uCodeC&"\]"
		s=re.Replace(s,"[/"&uCodeC&"]")
		ProcessUbbCode_UF=s
	End Function

	Private Function ProcessUbbCode_iS1(strText,uCodeC,tCode)
		Dim s
		s=strText
		re.Pattern="\["&uCodeC&"=[^\]]*\][\s\n]\[\/"&uCodeC&"\]"
		s=re.Replace(s,"")
		re.Pattern="\[\/"&uCodeC&"\]"
		s=re.Replace(s, chr(1)&"/"&uCodeC&"]")
		re.Pattern="\["&uCodeC&"=([0-9]+),(#?[\w]+),([0-9]+)\]([^\x01]*)\x01\/"&uCodeC&"\]"
		s=re.Replace(s,tCode)
		re.Pattern="\x01\/"&uCodeC&"\]"
		s=re.Replace(s, "[/"&uCodeC&"]")
		ProcessUbbCode_iS1=s
	End Function
		
	Private Function ProcessUbbCode_Align(strText)
		Dim s
		s=strText
		're.Pattern="\[align=(center|left|right)\][\s\n]*\[\/align\]"
		's=re.Replace(s,"")
		re.Pattern="\[\/align\]"
		s=re.Replace(s,chr(1)&"/align]")
		re.Pattern="\[align=(center|left|right)\]([^\x01]*)\x01\/align\]"
		s=re.Replace(s,"<div align=""$1"">$2</div>")
		re.Pattern="\x01\/align\]"
		s=re.Replace(s,"[/align]")
		ProcessUbbCode_Align=s
	End Function
			
	Private Function ProcessUbbCode_C(strText,uCodeC)
		Dim s,matches,match,CodeStr,rndID
		s=strText
		re.Pattern="\["&uCodeC&"\][\s\n]*\[\/"&uCodeC&"\]"
		s=re.Replace(s,"")
		re.Pattern="\[\/"&uCodeC&"\]"
		s=re.Replace(s,Chr(1)&"/"&uCodeC&"]")
		re.Pattern="\["&uCodeC&"\]([^\x01]*)\x01\/"&uCodeC&"\]"
		Set matches = re.Execute(s)
		re.Global=False
		For Each match In matches
			RAndomize
			rndID="CodeText"&Int(100000 * Rnd)
			CodeStr=match.SubMatches(0)
			CodeStr = Replace(CodeStr,"&nbsp;",Chr(32),1,-1,1)
			CodeStr = Replace(CodeStr,"<p>","",1,-1,1)
			CodeStr = Replace(CodeStr,"</p>","&#13;&#10;",1,-1,1)
			CodeStr = Replace(CodeStr,"[br]","&#13;&#10;",1,-1,1)
			CodeStr = Replace(CodeStr,"<br />","",1,-1,1)
			CodeStr = Replace(CodeStr,"<br/>","",1,-1,1)
			CodeStr = Replace(CodeStr,"<br />","",1,-1,1)
			CodeStr = Replace(CodeStr,vbNewLine,"&#13;&#10;",1,-1,1)
			CodeStr = "<div class=""UBBContainer""><div class=""UBBTitle""><img src=""" & m_strPicPath & "html.gif"" style=""margin:0px 2px -3px 0px""> 以下是程序代码</div><div class=""UBBContent""><textarea rows=""8"" id="""&rndID&""" class=""UBBText"">"&CodeStr& "</textarea><br/><input onclick=""runEx('"&rndID&"')""  type=""button"" value=""运行此代码""/> <input onclick=""doCopy('"&rndID&"')""  type=""button"" value=""复制此代码""/><br/> [Ctrl+A 全部选择 提示：你可先修改部分代码，再按运行]</div></div>"
			s = re.Replace(s,CodeStr)
		Next
		re.Global=true
		Set matches=Nothing
		re.Pattern="\x01\/"&uCodeC&"\]"
		s=re.Replace(s,"[/"&uCodeC&"]")
		ProcessUbbCode_C=s
	End Function
	
	Public Function SplitArray(expression,delimiter,start)
		Dim TempArray()
		Dim m_arrTemp,i,n
		If Len(expression) = 0 Then
		   'SplitArray = Array(0,0,0,1,1,1,1,1,1,1,0,550,0,0,1)
			SplitArray = Array(0,0,0,1,1,1,1,1,1,1,0,650,0,0,1)
			Exit Function
		End If
		m_arrTemp = Split(expression, delimiter)
		If start < 1 Then
			SplitArray = m_arrTemp
			Exit Function
		End If
		n = 0
		For i = start To UBound(m_arrTemp)
			ReDim Preserve TempArray(n)
			TempArray(n) = m_arrTemp(i)
			n = n + 1
		Next
		SplitArray = TempArray
	End Function
End Class
%>
