<%
Dim ArticleTitle,ArticleWhather,ArticleZy,ArticleFoot
Function UBBCode(strContent)
	If isEmpty(strContent) Or isNull(strContent) Then
        Exit Function
	Else
		strContent=CblogObj.CheckLinkStr(strContent)
		strContent=Replace(strContent,"[#seperator#]","")
		Dim re, strMatches, strMatch, tmpStr1, tmpStr2, tmpStr3, tmpStr4, RNDStr
		strContent = Replace(strContent, CHR(13)&chr(10), chr(13))
		strContent = Replace(strContent, CHR(10)&chr(13), chr(13))
		strContent = Replace(strContent, CHR(13), "<br/>")
		Set re=new RegExp
		re.IgnoreCase =True
		re.Global=True
		re.Pattern="\[code\](<br/>)+"
		strContent=re.Replace(strContent,"[code]")
		re.Pattern="\[quote\](<br/>)+"
		strContent=re.Replace(strContent,"[quote]")
		re.Pattern="([^=\]][\s]*?|^)(https?|ftp|gopher|news|telnet|mms|rtsp)://([a-z0-9/\-_+=.~!%@?#%&;:$\\()|]+)"
		StrContent=re.Replace(StrContent,"$1[url]$2://$3[/url]")
		re.Pattern="\[img\](.*?)\[\/img\]"
		Set strMatches=re.Execute(strContent)
		For Each strMatch In strMatches
			tmpStr1=CblogObj.CheckLinkStr(strMatch.SubMatches(0))
			IF Isonmousewheel Then
				strContent=Replace(strContent,strMatch.Value,"<div style=""width: 100%;float: left;overflow-x : auto;""><img onmousewheel=""return bbimg(this)"" onload=""return imgzoom(this,600)"" src="""&tmpStr1&""" border=""0""  alt=""按此在新窗口打开图片"" onclick=""window.open(this.src);"" /></div>")
			Else
				strContent=Replace(strContent,strMatch.Value,"<div style=""width: 100%;float: left;overflow-x : auto;""><img src="""&tmpStr1&""" border=""0""  alt=""按此在新窗口打开图片"" onclick=""window.open(this.src);"" /></div>")
			End IF
		Next
		Set strMatches=Nothing
		re.Pattern="\[img=(left|right|center|absmiddle)\](.*?)\[\/img\]"
		Set strMatches=re.Execute(strContent)
		For Each strMatch In strMatches
			tmpStr1=strMatch.SubMatches(0)
			tmpStr2=CblogObj.CheckLinkStr(strMatch.SubMatches(1))
			IF Isonmousewheel Then
				strContent=Replace(strContent,strMatch.Value,"<div style=""width: 100%;float: left;overflow-x : auto;""><img onmousewheel=""return bbimg(this)"" onload=""return imgzoom(this,600)"" src="""&tmpStr1&""" border=""0""  alt=""按此在新窗口打开图片"" onclick=""window.open(this.src);"" /></div>")
			Else
				strContent=Replace(strContent,strMatch.Value,"<div style=""width: 100%;float: left;overflow-x : auto;""><img src="""&tmpStr1&""" border=""0""  alt=""按此在新窗口打开图片"" onclick=""window.open(this.src);"" /></div>")
			End IF
		Next
		Set strMatches=Nothing
		strContent=replace(strContent,"[swf]","[swf=550,400]")
		strContent=replace(strContent,"[wmv]","[wmv=550,400]")
		strContent=replace(strContent,"[wma]","[wma=450,70]")
		strContent=replace(strContent,"[rm]","[rm=550,400]")
		strContent=replace(strContent,"[ra]","[ra=450,60]")
		re.Pattern="\[(swf|wma|wmv|rm|ra|qt)=(\d*?|),(\d*?|)\](.*?)\[\/(swf|wma|wmv|rm|ra|qt)\]"
		Set strMatches=re.Execute(strContent)
		For Each strMatch in strMatches
			RNDStr=Int(7999 * Rnd + 2000)
			tmpStr1=CblogObj.CheckLinkStr(strMatch.SubMatches(3))
			strContent= Replace(strContent,strMatch.Value,"<div class=""code_head""><input id=""VOBJ_"&RNDStr&""" type=""hidden"" value=""-1"" /><a href=""javascript:UBBShowObj('"&strMatch.SubMatches(0)&"','OBJ_"&RNDStr&"','"&strMatch.SubMatches(3)&"','"&strMatch.SubMatches(1)&"','"&strMatch.SubMatches(2)&"');""><img src="""&CityBlogDir&"img/ubbcode/bb_wmv.gif"" alt=""显示影音文件"" align=""absmiddle"" border=""0"" /> 点击显示/隐藏影音文件</a></div><div id=""OBJ_"&RNDStr&""" class=""code_main"">影音源文件地址：<a href="""&strMatch.SubMatches(3)&""" target=""_blank"">"&strMatch.SubMatches(3)&"</a></div>")
		Next
		Set strMatches=Nothing
		re.Pattern = "\[url=(.[^\]]*)\](.*?)\[\/url]"
		Set strMatches=re.Execute(strContent)
		For Each strMatch In strMatches
			tmpStr1=CblogObj.CheckLinkStr(strMatch.SubMatches(0))
			tmpStr2=strMatch.SubMatches(1)
			strContent=Replace(strContent,strMatch.Value,"<a target=""_blank"" rel=""nofollow"" href="""&tmpStr1&""">"&tmpStr2&"</a>")
		Next
		Set strMatches=Nothing
		re.Pattern = "\[url](.*?)\[\/url]"
		Set strMatches=re.Execute(strContent)
		For Each strMatch In strMatches
			tmpStr1=CblogObj.CheckLinkStr(strMatch.SubMatches(0))
			tmpStr2=CutURL(tmpStr1)
			strContent=Replace(strContent,strMatch.Value,"<a target=""_blank"" rel=""nofollow"" href="""&tmpStr1&""">"&tmpStr2&"</a>")
		Next
		Set strMatches=Nothing
		
		re.Pattern = "#chr39##chr39#(.*?)<br/>"
		Set strMatches=re.Execute(strContent)
		For Each strMatch In strMatches
			tmpStr1=CblogObj.CheckLinkStr(strMatch.SubMatches(0))
			strContent=Replace(strContent,strMatch.Value,"<p style=""text-indent: 2em;"">"&tmpStr1&"</p>")
		Next
		Set strMatches=Nothing

		re.Pattern = "\[email=(.[^\]]*)\](.*?)\[\/email]"
		strContent = re.Replace(strContent,"<a href=""mailto:$1"">$2</a>")
		re.Pattern = "\[email](.*?)\[\/email]"
		strContent = re.Replace(strContent,"<a href=""mailto:$1"">$1</a>")
		strContent = Replace(strContent,"[list]","<ul>")
		strContent = Replace(strContent,"[list=1]","<ol type=""1"">")
		strContent = Replace(strContent,"[list=a]","<ol type=""a"">")
		strContent = Replace(strContent,"[list=A]","<ol type=""A"">")
		strContent = Replace(strContent,"[*]","<li>")
		strContent = Replace(strContent,"[/list]","</ul></ol>")
		re.Pattern="\[fly\](.*?)\[\/fly]"
		strContent=re.Replace(strContent,"<marquee onmouseover=""this.stop()"" onmouseout=""this.start()"" direction=""up"" scrollamount=""1"" scrolldelay=""100"" height=""80"" width=""95%""><font color=""Green""><font size=""3""><strong>$1</strong></font></font></marquee>")	
		re.Pattern="\[font=([^<>\]]*?)\](.*?)\[\/font]"
		strContent=re.Replace(strContent,"<font face=""$1"">$2</font>")
		re.Pattern="\[color=([^<>\]]*?)\](.*?)\[\/color]"
		strContent=re.Replace(strContent,"<font color=""$1"">$2</font>")
		re.Pattern="\[align=([^<>\]]*?)\](.*?)\[\/align]"
		strContent=re.Replace(strContent,"<div align=""$1"">$2</div>")
		re.Pattern="\[size=(\d*?)\](.*?)\[\/size]"
		strContent=re.Replace(strContent,"<font size=""$1"">$2</font>")
		re.Pattern="\[b\](.*?)\[\/b]"
		strContent=re.Replace(strContent,"<strong>$1</strong>")	
		re.Pattern="\[i\](.*?)\[\/i]"
		strContent=re.Replace(strContent,"<em>$1</em>")	
		re.Pattern="\[u\](.*?)\[\/u]"
		strContent=re.Replace(strContent,"<u>$1</u>")
		re.Pattern="\[sub\](.*?)\[\/sub]"
		strContent=re.Replace(strContent,"<sub>$1</sub>")	
		re.Pattern="\[sup\](.*?)\[\/sup]"
		strContent=re.Replace(strContent,"<sup>$1</sup>")
		re.Pattern="\[code\](.*?)\[\/code\]"
		Set strMatches=re.Execute(strContent)
		For Each strMatch In strMatches
			tmpStr1=Replace(strMatch.SubMatches(0),"<i>&#106","j")
			tmpStr1=Replace(tmpStr1,"</i>","")
			tmpStr1=Replace(tmpStr1, "<br/>", Chr(13))
			tmpStr1=Replace(tmpStr1, "<p style=""text-indent: 2em;"">", Chr(13))
			tmpStr1=Replace(tmpStr1, "</p>", Chr(13))
			tmpStr1=Replace(tmpStr1, "<p>", Chr(13))
			tmpStr1=Replace(tmpStr1, "&amp;", "&")
			strContent= Replace(strContent,strMatch.Value,"<textarea name=""textarea"" cols=""0"" rows=""20"" style=""width:90%"" class=""code"">以下是代码片段,您可以CTRL+A,然后复制。"& Chr(13)&Chr(13) & tmpStr1&"</textarea>")
		Next
		Set strMatches=Nothing
		re.Pattern="\[quote\](.*?)\[\/quote\]"
		strContent= re.Replace(strContent,"<div class=""quote"">$1</div>")
		re.Pattern = "\[down=(.[^\]]*)\](.*?)\[\/down]"
		strContent = re.Replace(strContent,"<img src="""&CityBlogDir&"img/ubbcode/bb_down.gif"" align=""absmiddle"" /> <a href=""$1"" target=""_blank"">$2</a>")
		re.Pattern = "\[download=(.[^\]]*)\](.*?)\[\/download]" 
		strContent = re.Replace(strContent,"<img src="""&CityBlogDir&"img/ubbcode/bb_down.gif"" align=""absmiddle"" /> <a href=""$1"" target=""_blank"">$2</a>")
		Dim log_SmiliesListNums,log_SmiliesListNumI
		log_SmiliesListNums=Ubound(CblogObj.Cahe("_blog_Smilies"),2)
		For log_SmiliesListNumI=0 To log_SmiliesListNums
			strContent=Replace(strContent,CblogObj.Cahe("_blog_Smilies")(2,log_SmiliesListNumI)," <img src="""&CityBlogDir&"img/smilies/"&CblogObj.Cahe("_blog_Smilies")(1,log_SmiliesListNumI)&""" border=""0"" align=""absmiddle"" />")
		Next
		Set re=Nothing
		UBBCode=Replace(strContent,"#chr39#"," ")
        UBBCode=Replace(UBBCode,"</p><br/>","</p>")

	




	End IF
End Function
Function CutURL(URLStr)
	Dim URLLen
	URLLen=Len(URLStr)
	If URLLen>65 Then
		CutURL=Left(URLStr,URLLen*0.5)&" ... "&Right(URLStr,URLLen*0.3)
	Else
		CutURL=URLStr
	End If
End Function
%>