<% Class admin_MakeHtml	
	Private Mesky
	Private Sub Class_Initialize()
		Set Mesky = New Cls_Main
		Server.ScriptTimeout = 999999999
		Call Mesky.LoadSetting
	End Sub
	Private Sub Class_Terminate()
		Set Mesky = Nothing	
	End Sub
	Public Sub AspInit()
		Response.Write "<HTML>" & vbCrLf
		Response.Write "<HEAD>" & vbCrLf
		Response.Write "<TITLE>下载管理</TITLE>" & vbCrLf
		Response.Write "<META http-equiv=Content-Type content=""text/html; charset=gb2312"">" & vbCrLf
		Response.Write "<LINK href=""admin.css"" type=text/css rel=stylesheet>" & vbCrLf
		Response.Write "</HEAD>" & vbCrLf
		Response.Write "<BODY leftmargin=""3"" topmargin=""3"">" & vbCrLf
			
			If Mesky.adminName = "" Then
				Mesky.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统，<a href=""../admin_login.asp"" target=_top>点此进入管理员登录界面</a>。"
				Call Mesky.SystemMsg
			ElseIf myPermission() = False Then
				Mesky.strMsg = "<li>非法操作：你没有权限进行此项操作，请联系管理员！"
				Call Mesky.SystemMsg
			Else
				Call Main
			End If
	
		Response.Write "</BODY>" & vbCrLf
		Response.Write "</HTML>" & vbCrLf
	
	End Sub
	Private Function myPermission()
		myPermission = False
		If Mesky.checkPermission(Mesky.adminName, "11") Then myPermission = True: Exit Function
	End Function
	Private Sub Main()
		Select Case Trim(Request("action"))
		Case "Down_Update"
			Call run_Down_Update
		Case "Down_New"
			Call run_Down_New
		Case "Down_Top"
			Call run_Down_Top
		Case "Down_Abc"
			Call run_Down_Abc
		Case "Down_List"
			Call run_Down_List
		Case "Down_Info"
			Call run_Down_Info
		Case "Down_Default"
			Call run_Down_Default
		Case "Down_Catalog"
			Call run_Down_Catalog
		Case "HtmlPage"
			Call run_HtmlPage
		Case "Cms_Update"
			Call run_Cms_Update
		Case "Cms_List"
			Call run_Cms_List
		Case "Cms_Info"
			Call run_Cms_Info
		Case "Cms_Default"
			Call run_Cms_Default
		Case "Cms_Catalog"
			Call run_Cms_Catalog
		Case Else
			Call makehtml
		End Select
	End Sub
	
	Private Sub makehtml()
		Dim i
		Response.Write "<table width=""100%""  border=""0"" cellpadding=""3"" cellspacing=""1"" bgcolor=""#FFFFFF"" class=""b1"">" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td align=""center"" class=""tdbg2"">下载系统网站页面生成操作</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg3"">　1、下载分类统计数据更新及生成XML数据 [<a href=""?action=Down_Update"">点击此处生成HTML</a>]</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg2"">　2、生成下载首页 [<a href=""?action=Down_Default"">点击此处生成HTML</a>]</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg3"">　3、生成下载分类页 [<a href=""?action=Down_Catalog"">点击此处生成HTML</a>]</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf
		
		Response.Write "<table width=""100%""  border=""0"" cellpadding=""3"" cellspacing=""1"" bgcolor=""#FFFFFF"" class=""b1"">" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td align=""center"" class=""tdbg2"">文章系统网站页面生成操作</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg3"">　1、文章分类统计数据更新及生成XML数据 [<a href=""?action=Cms_Update"">点击此处生成HTML</a>]</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg2"">　2、生成文章首页 [<a href=""?action=Cms_Default"">点击此处生成HTML</a>]</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg3"">　3、生成文章分类页 [<a href=""?action=Cms_Catalog"">点击此处生成HTML</a>]</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf	
	End Sub
	Private Sub run_Down_Update()
		Dim run
		run = Make_Down_update()
		Mesky.strMsg = "下载分类统计数据更新及生成XML数据 操作完成!"
		Call Mesky.SystemMsg
	End Sub	

	Private Sub run_Down_Default()
		Dim run
		run = Make_Down_Default()
		Mesky.strMsg = "生成下载首页-OK!"
		Call Mesky.SystemMsg
	End Sub
	
	Private Sub run_Down_Catalog()
		Dim run
		run = Make_Down_Catalog()
		Mesky.strMsg = "生成分类页-OK!"
		Call Mesky.SystemMsg
	End Sub
	
	Private Sub run_Cms_Update()
		Dim run
		run = Make_Cms_update()
		Mesky.strMsg = "文章分类统计数据更新及生成XML数据 操作完成!"
		Call Mesky.SystemMsg
	End Sub

	Private Sub run_Cms_Default()
		Dim run
		run = Make_Cms_Default()
		Mesky.strMsg = "生成文章首页-OK!"
		Call Mesky.SystemMsg
	End Sub
	
	Private Sub run_Cms_Catalog()
		Dim run
		run = Make_Cms_Catalog()
		Mesky.strMsg = "生成分类页-OK!"
		Call Mesky.SystemMsg
	End Sub
	Rem *************************************************下载首页****************************************************
	Public Function Make_Down_Default()
		Dim arrMainPage, tempStr
		arrMainPage = Split(Mesky.ReadStylePage("Style_Down_Main"), "<!--|||-->")
		tempStr = arrMainPage(0) & arrMainPage(1) & arrMainPage(2) & arrMainPage(3) & arrMainPage(4) & arrMainPage(5)
		tempStr = regExp_showDownRes(tempStr)
		tempStr = regExp_showDownResImages(tempStr)
		tempStr = regExp_showDownResStat(tempStr)
		tempStr = regExp_showNews(tempStr)
		tempStr = regExp_showSiteLinks(tempStr)
		tempStr = Replace(regExp_AdvshowDownRes(tempStr), "../", "")
		
		tempStr = regExp_showCmsRes(tempStr)
		tempStr = regExp_showCmsResImages(tempStr)
		tempStr = regExp_showCmsResStat(tempStr)
		tempStr = Replace(regExp_AdvshowCmsRes(tempStr), "../", "")
		
		tempStr = Replace(tempStr, "{$page_title}", Mesky.Setting(0) & " — 下载首页")
		Dim fso, fout
		Set fso = Server.CreateObject(Mesky.Setting(23))
		Set fout = fso.CreateTextFile(Server.MapPath(MyDbPath & Mesky.Setting(70)))
			fout.WriteLine Mesky.HtmlHead() & tempStr
	
		fout.Close: Set fout = Nothing
		Set fso = Nothing
		tempStr = Null
		arrMainPage = Null
	End Function
	
	Rem *************************************************文章首页****************************************************
	Public Function Make_Cms_Default()
		Dim arrMainPage, tempStr
		arrMainPage = Split(Mesky.ReadStylePage("Style_Cms_Main"), "<!--|||-->")
		tempStr = arrMainPage(0) & arrMainPage(1) & arrMainPage(2) & arrMainPage(3) & arrMainPage(4)
		tempStr = regExp_showCmsRes(tempStr)
		tempStr = regExp_showCmsResImages(tempStr)
		tempStr = regExp_showCmsResExcerptImages(tempStr)
		tempStr = regExp_showCmsResStat(tempStr)
		tempStr = regExp_showNews(tempStr)
		tempStr = regExp_showSiteLinks(tempStr)
		tempStr = Replace(regExp_AdvshowCmsRes(tempStr), "../", "")
		tempStr = regExp_showDownRes(tempStr)
		tempStr = regExp_showDownResImages(tempStr)		
		tempStr = regExp_showDownResStat(tempStr)
		tempStr = Replace(regExp_AdvshowDownRes(tempStr), "../", "")
		
		tempStr = Replace(tempStr, "{$page_title}", Mesky.Setting(0) & " — 文章首页")
		Dim fso, fout
		Set fso = Server.CreateObject(Mesky.Setting(23))
		Set fout = fso.CreateTextFile(Server.MapPath(MyDbPath & Mesky.Setting(95)))
	
			fout.WriteLine Mesky.HtmlHead() & tempStr
		
		fout.Close: Set fout = Nothing
		Set fso = Nothing
		tempStr = Null
		arrMainPage = Null
	End Function
	
	Rem ***************************************更新CMS分类数据生成分类XML********************************************
	Public Function Make_Cms_update()
		Dim Rs, sql, i, ResNum, xmlSQL, xmlFile
		Set Rs = Mesky.Execute("select rootID,catalogID,catalogName,depth,Child,orders,resNum from Mesky_Cms_Catalog")
		sql = Rs.GetRows(-1)
		Set Rs = Nothing
		
		For i = 0 To UBound(sql, 2)
			If sql(3, i) = 0 Then
				ResNum = Mesky.Execute("select Count(*) from Mesky_Cms_Resource where rootID=" & sql(0, i))(0)
				xmlSQL = "rootID=" & sql(0, i)
				xmlFile = "xml/rss_Cms_r" & sql(0, i) & ".xml"
			Else
				If sql(4, i) > 0 Then
					ResNum = Mesky.Execute("select Count(*) from Mesky_Cms_Resource where catalogID in (select catalogID from Mesky_Cms_Catalog where rootID=" & sql(0, i) & " and depth>" & sql(3, i) & " and orders>" & sql(5, i) & ")")(0)
					xmlSQL = "catalogID in (select catalogID from Mesky_Cms_Catalog where rootID=" & sql(0, i) & " and depth>" & sql(3, i) & " and orders>" & sql(5, i) & ")"
				Else
					ResNum = Mesky.Execute("select Count(*) from Mesky_Cms_Resource where catalogID=" & sql(1, i))(0)
					xmlSQL = "catalogID=" & sql(1, i)
				End If
				xmlFile = "xml/rss_Cms_s" & sql(1, i) & ".xml"
			End If
			Mesky.Execute ("update Mesky_Cms_Catalog set ResNum = " & ResNum & "  where catalogID=" & sql(1, i))
			Rs = Make_Cms_XML(xmlSQL, xmlFile, sql(2, i))
			Response.Write (sql(2, i) & "-OK!　")
			If i Mod 7 = 0 Then Response.Write ("<br>")
			Response.Flush
		Next
		Rs = Make_Cms_XML("", "xml/rss_Cms.xml", "全部文章更新")
	End Function
	Public Function Make_Cms_XML(xmlSQL, xmlFile, catalogName)
		Dim Rs, s
		s = s & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbCrLf
		s = s & "<rss version=""2.0"">" & vbCrLf
		s = s & "<channel>" & vbCrLf
		s = s & "       <title>" & Mesky.Setting(0) & " - " & catalogName & "</title>" & vbCrLf
		s = s & "       <link>" & Mesky.Setting(2) & "</link>" & vbCrLf
		s = s & "       <description>" & catalogName & "</description>" & vbCrLf
		s = s & "       <language>zh-cn</language>" & vbCrLf
		s = s & "       <generator>Www.Mesky.Cn</generator>" & vbCrLf
		s = s & "       <copyright>Copyright 2001-2004 www.mesky.cn, All Rights Reserved</copyright>" & vbCrLf
		s = s & "       <pubDate>" & Now() & "</pubDate>" & vbCrLf
		If xmlSQL = "" Then
		Set Rs = Mesky.Execute("select top 50 ID,rootID,catalogID,catalogName,title,content,DateAndTime,Writer from Mesky_Cms_Resource where isAuditing=1 order by DateAndTime Desc")
		Else
		Set Rs = Mesky.Execute("select top 50 ID,rootID,catalogID,catalogName,title,content,DateAndTime,Writer from Mesky_Cms_Resource where " & xmlSQL & " and isAuditing=1 order by DateAndTime Desc")
		End If
		If Not (Rs.EOF And Rs.BOF) Then
			Do While Not Rs.EOF
			s = s & "       <item>" & vbCrLf
			s = s & "           <title>[" & Rs(3) & "]" & Rs(4) & "</title>" & vbCrLf
			s = s & "           <link>" & Mesky.Setting(2) & "/" & Replace(Mesky.Setting(77), "{$id}", Rs(0)) & "</link>" & vbCrLf
			s = s & "           <author>" & Rs(7) & "</author>" & vbCrLf
			s = s & "           <guid></guid>" & vbCrLf
			s = s & "           <category>" & Rs(3) & "</category>" & vbCrLf
			s = s & "           <pubDate>" & Rs(6) & "</pubDate>" & vbCrLf
			s = s & "           <comments></comments>" & vbCrLf
			s = s & "           <description>" & Server.HTMLEncode(Rs(5)) & "</description>" & vbCrLf
			s = s & "       </item>" & vbCrLf
			Rs.MoveNext
			Loop
		Else
			s = s & "<item></item>" & vbCrLf
		End If
		Set Rs = Nothing
		s = s & "</channel>" & vbCrLf
		s = s & "</rss>" & vbCrLf
		Dim fso, fout
		Set fso = Server.CreateObject(Mesky.Setting(23))
		Set fout = fso.CreateTextFile(Server.MapPath(MyDbPath & xmlFile))
		fout.WriteLine s
		fout.Close: Set fout = Nothing
		Set fso = Nothing
		s = Null
	End Function
	
	Rem ***************************************更新分类数据生成分类XML********************************************
	Public Function Make_Down_update()
	
		Dim Rs, sql, i, ResNum, xmlSQL, xmlFile
		Set Rs = Mesky.Execute("select rootID,catalogID,catalogName,depth,Child,orders,resNum from Mesky_Down_Catalog")
		sql = Rs.GetRows(-1)
		Set Rs = Nothing
		
		For i = 0 To UBound(sql, 2)
			If sql(3, i) = 0 Then
				ResNum = Mesky.Execute("select Count(*) from Mesky_Down_Resource where rootID=" & sql(0, i))(0)
				xmlSQL = "rootID=" & sql(0, i)
				xmlFile = "xml/rss_Down_r" & sql(0, i) & ".xml"
			Else
				If sql(4, i) > 0 Then
					ResNum = Mesky.Execute("select Count(*) from Mesky_Down_Resource where catalogID in (select catalogID from Mesky_Down_Catalog where rootID=" & sql(0, i) & " and depth>" & sql(3, i) & " and orders>" & sql(5, i) & ")")(0)
					xmlSQL = "catalogID in (select catalogID from Mesky_Down_Catalog where rootID=" & sql(0, i) & " and depth>" & sql(3, i) & " and orders>" & sql(5, i) & ")"
				Else
					ResNum = Mesky.Execute("select Count(*) from Mesky_Down_Resource where catalogID=" & sql(1, i))(0)
					xmlSQL = "catalogID=" & sql(1, i)
				End If
				xmlFile = "xml/rss_Down_s" & sql(1, i) & ".xml"
			End If
			Mesky.Execute ("update Mesky_Down_Catalog set ResNum = " & ResNum & "  where catalogID=" & sql(1, i))
			Rs = Make_Down_XML(xmlSQL, xmlFile, sql(2, i))
			Response.Write (sql(2, i) & "-OK!　")
			If i Mod 7 = 0 Then Response.Write ("<br>")
			Response.Flush
		Next
		Rs = Make_Down_XML("", "xml/rss_Down.xml", "全部软件更新")
	End Function
	
	Public Function Make_Down_XML(xmlSQL, xmlFile, catalogName)
	
		Dim Rs, s
		s = s & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbCrLf
		s = s & "<rss version=""2.0"">" & vbCrLf
		s = s & "<channel>" & vbCrLf
		s = s & "       <title>" & Mesky.Setting(0) & " - " & catalogName & "</title>" & vbCrLf
		s = s & "       <link>" & Mesky.Setting(2) & "</link>" & vbCrLf
		s = s & "       <description>" & catalogName & "</description>" & vbCrLf
		s = s & "       <language>zh-cn</language>" & vbCrLf
		s = s & "       <generator>Www.Mesky.Cn</generator>" & vbCrLf
		s = s & "       <copyright>Copyright 2001-2004 www.mesky.cn, All Rights Reserved</copyright>" & vbCrLf
		s = s & "       <pubDate>" & Now() & "</pubDate>" & vbCrLf
		If xmlSQL = "" Then
		Set Rs = Mesky.Execute("select top 50 ID,rootID,catalogID,catalogName,ResName,ResVer,content,UpdateTime,authorEmail from Mesky_Down_Resource where isAuditing=1 order by UpdateTime Desc")
		Else
		Set Rs = Mesky.Execute("select top 50 ID,rootID,catalogID,catalogName,ResName,ResVer,content,UpdateTime,authorEmail from Mesky_Down_Resource where " & xmlSQL & " and isAuditing=1 order by UpdateTime Desc")
		End If
		If Not (Rs.EOF And Rs.BOF) Then
			Do While Not Rs.EOF
			s = s & "       <item>" & vbCrLf
			s = s & "           <title>[" & Rs(3) & "]" & Rs(4) & " " & Rs(5) & "</title>" & vbCrLf
			s = s & "           <link>" & Mesky.Setting(2) & "/" & Replace(Mesky.Setting(77), "{$id}", Rs(0)) & "</link>" & vbCrLf
			s = s & "           <author>" & Rs(8) & "</author>" & vbCrLf
			s = s & "           <guid></guid>" & vbCrLf
			s = s & "           <category>" & Rs(3) & "</category>" & vbCrLf
			s = s & "           <pubDate>" & Rs(7) & "</pubDate>" & vbCrLf
			s = s & "           <comments></comments>" & vbCrLf
			s = s & "           <description>" & Server.HTMLEncode(Rs(6)) & "</description>" & vbCrLf
			s = s & "       </item>" & vbCrLf
			Rs.MoveNext
			Loop
		Else
			s = s & "<item></item>" & vbCrLf
		End If
		Set Rs = Nothing
		s = s & "</channel>" & vbCrLf
		s = s & "</rss>" & vbCrLf
		Dim fso, fout
		Set fso = Server.CreateObject(Mesky.Setting(23))
		Set fout = fso.CreateTextFile(Server.MapPath(MyDbPath & xmlFile))
		fout.WriteLine s
		fout.Close: Set fout = Nothing
		Set fso = Nothing
		s = Null
	End Function
	
	Rem ***************************************更新分类数据生成分类XML********************************************
	Public Function Make_Down_Catalog()
	
		Dim arrPage, arrMainPage, tempStr
		arrPage = Split(Mesky.ReadStylePage("Style_Down_Catalog"), "<!--|||-->")
		arrMainPage = Split(Mesky.ReadStylePage("Style_Down_Main"), "<!--|||-->")
		tempStr = Replace(arrMainPage(0), "{$page_title}", Mesky.Setting(0) & " — 下载分类") & arrMainPage(1) & arrMainPage(2)
		tempStr = tempStr & Replace(arrPage(0), "{$site_nav}", Mesky.site_nav(0, "Mesky_Down_catalog", "下载分类", ""))
		tempStr = tempStr & Replace(arrPage(1), "{$showcatalog}", Mesky.showDownResCatalog()) & arrMainPage(4) & arrMainPage(5)
		
		Dim fso, fout
		Set fso = Server.CreateObject(Mesky.Setting(23))
		Set fout = fso.CreateTextFile(Server.MapPath(MyDbPath & Mesky.Setting(71)))
		fout.WriteLine Mesky.HtmlHead() & Replace(tempStr, "../", "")
		fout.Close: Set fout = Nothing
		tempStr = Null
		
		tempStr = "document.write(""<select name=\""catalog\"" id=\""catalog\"">"");"
		tempStr = tempStr & "document.write(""" & Mesky.HTMLToJS(Mesky.GetCatalogSelect(0,"Mesky_Down_Catalog")) & """);"
		tempStr = tempStr & "document.write(""</select>"");"
		Set fout = fso.CreateTextFile(Server.MapPath(MyDbPath & "js/down_select_catalog.js"))
		fout.WriteLine tempStr
		fout.Close: Set fout = Nothing
		Set fso = Nothing
		tempStr = Null
		Make_Down_Catalog = "生成下载分类网页-OK!"
	End Function
	Rem ***************************************更新分类数据生成分类XML********************************************
	Public Function Make_Cms_Catalog()
	
		Dim arrPage, arrMainPage, tempStr
		arrPage = Split(Mesky.ReadStylePage("Style_Cms_Catalog"), "<!--|||-->")
		arrMainPage = Split(Mesky.ReadStylePage("Style_Cms_Main"), "<!--|||-->")
		tempStr = Replace(arrMainPage(0), "{$page_title}", Mesky.Setting(0) & " — 文章分类") & arrMainPage(1) & arrMainPage(2)
		tempStr = tempStr & Replace(arrPage(0), "{$site_nav}", Mesky.site_nav(0, "Mesky_Cms_catalog", "文章分类", ""))
		tempStr = tempStr & Replace(arrPage(1), "{$showcatalog}", Mesky.showCmsResCatalog()) & arrMainPage(4)
		
		Dim fso, fout
		Set fso = Server.CreateObject(Mesky.Setting(23))
		Set fout = fso.CreateTextFile(Server.MapPath(MyDbPath & Mesky.Setting(96)))
		fout.WriteLine Mesky.HtmlHead() & Replace(tempStr, "../", "")
		fout.Close: Set fout = Nothing
		tempStr = Null
		
		tempStr = "document.write(""<select name=\""catalog\"" id=\""catalog\"">"");"
		tempStr = tempStr & "document.write(""" & Mesky.HTMLToJS(Mesky.GetCatalogSelect(0,"Mesky_Cms_Catalog")) & """);"
		tempStr = tempStr & "document.write(""</select>"");"
		Set fout = fso.CreateTextFile(Server.MapPath(MyDbPath & "js/cms_select_catalog.js"))
		fout.WriteLine tempStr
		fout.Close: Set fout = Nothing
		Set fso = Nothing
		tempStr = Null
		Make_Cms_Catalog = "生成下载分类网页-OK!"
	End Function
	
	Private Function regExp_showNews(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showNews:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = Mesky.showNews(arrRegExp(0), arrRegExp(1), arrRegExp(2), arrRegExp(3))
					str = Replace(str, "<!--showNews:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showNews = str
		str = Null
	End Function

	Private Function regExp_showDownRes(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showDownRes:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = Mesky.showDownRes(arrRegExp(0), arrRegExp(1), arrRegExp(2), arrRegExp(3), arrRegExp(4), arrRegExp(5))
					str = Replace(str, "<!--showDownRes:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showDownRes = str
		str = Null
	End Function
	Private Function regExp_showCmsRes(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showCmsRes:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = Mesky.showCmsRes(arrRegExp(0), arrRegExp(1), arrRegExp(2), arrRegExp(3), arrRegExp(4), arrRegExp(5))
					str = Replace(str, "<!--showCmsRes:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showCmsRes = str
		str = Null
	End Function
	Private Function regExp_AdvshowDownRes(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--AdvshowDownRes:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = Mesky.showDownResAdv(arrRegExp(0), arrRegExp(1), arrRegExp(2), arrRegExp(3), arrRegExp(4), arrRegExp(5), arrRegExp(6), arrRegExp(7))
					str = Replace(str, "<!--AdvshowDownRes:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_AdvshowDownRes = str
		str = Null
	End Function
	Private Function regExp_AdvshowCmsRes(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--AdvshowCmsRes:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = Mesky.showCmsResAdv(arrRegExp(0), arrRegExp(1), arrRegExp(2), arrRegExp(3), arrRegExp(4), arrRegExp(5), arrRegExp(6), arrRegExp(7))
					str = Replace(str, "<!--AdvshowCmsRes:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_AdvshowCmsRes = str
		str = Null
	End Function
	Private Function regExp_showDownResImages(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showDownResImages:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = Mesky.showDownResImages(arrRegExp(0), arrRegExp(1), arrRegExp(2), arrRegExp(3), arrRegExp(4), arrRegExp(5), arrRegExp(6))
					str = Replace(str, "<!--showDownResImages:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showDownResImages = str
		str = Null
	End Function
	Private Function regExp_showCmsResImages(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showCmsResImages:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = Mesky.showCmsResImages(arrRegExp(0), arrRegExp(1), arrRegExp(2), arrRegExp(3), arrRegExp(4), arrRegExp(5), arrRegExp(6))
					str = Replace(str, "<!--showCmsResImages:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showCmsResImages = str
		str = Null
	End Function
	Private Function regExp_showCmsResExcerptImages(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showCmsResExcerptImages:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = Mesky.showCmsResExcerptImages(arrRegExp(0), arrRegExp(1), arrRegExp(2), arrRegExp(3), arrRegExp(4), arrRegExp(5), arrRegExp(6), arrRegExp(7))
					str = Replace(str, "<!--showCmsResExcerptImages:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showCmsResExcerptImages = str
		str = Null
	End Function
	Private Function regExp_showDownResStat(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showDownResStat:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = showDownResStat(arrRegExp(0), arrRegExp(1), arrRegExp(2))
					str = Replace(str, "<!--showDownResStat:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showDownResStat = str
		str = Null
	End Function
	Private Function showDownResStat(strStat, strWhere, divisor)
		If strStat = "" Then strStat = "count(*)"
		If divisor = "" Or CLng(divisor) = 0 Then divisor = 1
		If strWhere = "" Then
			showDownResStat = Mesky.Execute("select " & strStat & " from Mesky_Down_Resource")(0) \ divisor
		Else
			showDownResStat = Mesky.Execute("select " & strStat & " from Mesky_Down_Resource where " & strWhere & "")(0) \ divisor
		End If
	End Function
	Private Function regExp_showCmsResStat(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showCmsResStat:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = showCmsResStat(arrRegExp(0), arrRegExp(1), arrRegExp(2))
					str = Replace(str, "<!--showCmsResStat:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showCmsResStat = str
		str = Null
	End Function
	Private Function showCmsResStat(strStat, strWhere, divisor)
		If strStat = "" Then strStat = "count(*)"
		If divisor = "" Or CLng(divisor) = 0 Then divisor = 1
		If strWhere = "" Then
			showCmsResStat = Mesky.Execute("select " & strStat & " from Mesky_Cms_Resource")(0) \ divisor
		Else
			showCmsResStat = Mesky.Execute("select " & strStat & " from Mesky_Cms_Resource where " & strWhere & "")(0) \ divisor
		End If
	End Function
	Private Function regExp_showSiteLinks(strContent)
		If strContent = "" Then
			Exit Function
		End If
		Dim regEx, Key, Matchs, arrRegExp, str, s
		str = strContent
		Set regEx = New RegExp
			regEx.IgnoreCase = True
			regEx.Global = True
			regEx.Pattern = "<!--showSiteLinks:([\S\s]*?)-->"
			Set Matchs = regEx.Execute(str)
			If Matchs.Count > 0 Then
				For Each Key In Matchs
					arrRegExp = Split(Key.SubMatches(0), "|")
					'Response.Write(Key.SubMatches(0)) & "<br>"
					s = showSiteLinks(arrRegExp(0), arrRegExp(1))
					str = Replace(str, "<!--showSiteLinks:" & Key.SubMatches(0) & "-->", s)
					s = Null
					arrRegExp = Null
				Next
				Key = Null
			End If
			Set Matchs = Nothing
		Set regEx = Nothing
		regExp_showSiteLinks = str
		str = Null
	End Function
	Public Function showSiteLinks(showType,showNum)
		dim tRs,s,link_i,link_ii
		link_i=0
		s = "<table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1""><tr align=""center"" bgcolor=""#F6F6F6""> "& vbcrlf
		if showType=1 then
			set tRs = Mesky.Execute("select top "&showNum&" * from Mesky_SiteLinks where LinkType=1 order by isHot Desc,orders asc,Hits Desc")
			If Not(tRs.eof and tRs.bof) then
				do while not tRs.eof
				s = s & "<td><a href="""&tRs("SiteURL")&""" target=_blank title="""&Trim(tRs("Description"))&"""><img src="""&tRs("SiteLogo")&""" width=""88"" height=""31"" border=""0""></a></td>"& vbcrlf
				link_i = link_i + 1
				if link_i mod 8 = 0 then  s = s & "</tr><tr align=""center"" bgcolor=""#F6F6F6"">"& vbcrlf
				tRs.movenext
				loop 
				If link_i mod 8 > 0 then 
					for link_ii = 1 to (8 - (link_i mod 8))
						s = s & "<td><img src=""../images/link.gif"" width=""88"" height=""31"" border=""0""></td>"& vbcrlf
					next
				End if
			End if
			Set tRs = Nothing 
		Else
			Set tRs = Mesky.Execute("select top "&showNum&" * from Mesky_SiteLinks where LinkType=0 order by isHot Desc,orders asc,Hits Desc")
			If Not(tRs.eof and tRs.bof) then
				do while not tRs.eof
					s = s & "<td><a href="""&tRs("SiteURL")&""" target=_blank title="""&Trim(tRs("Description"))&""">"&tRs("SiteName")&"</a></td>"& vbcrlf
					link_i = link_i + 1
					if link_i mod 8 = 0 then  s = s & "</tr><tr align=""center"" bgcolor=""#F6F6F6"">"& vbcrlf
				tRs.movenext
				loop 
				if link_i mod 8 > 0 then 
					for link_ii = 1 to (8 - (link_i mod 8))
						s = s & "<td>您的链接</td>"& vbcrlf
					next
				end if
			end if
			Set tRs = Nothing
		End if
		s = s & "</tr></table>"
		showSiteLinks = s
		s = Null
	End function
End Class %>