<!-- #include file="conn.asp" -->
<!-- #include file="cls_main.asp" -->
<!-- #include file="cls_Mesky_showPage.asp" -->
<!-- #include file="cls_regExp.asp" -->
<% dim obj,Mesky
set obj = New ViewDownList
	obj.AspInit()
set obj = nothing

class ViewDownList
	Private strSQL,q
	Private Sub Class_Initialize()
		Set Mesky = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set Mesky = Nothing
	End Sub
	Public Sub AspInit()
		Call Mesky.LoadSetting()
		Dim rootID,catalogID,catalogName,depth
		Dim Rs
		if Request.QueryString("rootID") = "" and Request.QueryString("catalogID") = "" then
			Mesky.strMsg ="非法操作!参数未指定."
			Call Mesky.SystemMsg()
			Exit sub
		ElseIF Request.QueryString("rootID") <> "" and Request.QueryString("catalogID") = "" then
			strSQL = "rootID=" & clng(Trim(Request.QueryString("rootID")))
			q = "&"&strSQL
			set Rs = Mesky.Execute("select catalogID,catalogName,rootID,depth,Child,orders,ResNum from Mesky_Down_Catalog where "&strSQL&" and depth=0")
			if not (Rs.eof and Rs.bof) then
				catalogID = Rs (0)
				catalogName = Rs(1)
				rootID = Rs(2)
				depth = Rs(3)
				call Show_Down_List(Rs(2), Rs (0), Rs(1), Rs(3), Rs(4), Rs(5), Rs(6))
			else
				Mesky.strMsg = "指定的分类不存在！"
				call Mesky.SystemMsg()
				exit sub
			end if
			set Rs = Nothing
		ElseIF Request.QueryString("rootID") = "" and Request.QueryString("catalogID") <> "" then
			strSQL = "catalogID=" & clng(Trim(Request.QueryString("catalogID")))
			q = "&"&strSQL	
			set Rs = Mesky.Execute("select catalogID,catalogName,rootID,depth,Child,orders,ResNum from Mesky_Down_Catalog where "&strSQL)
			if not (Rs.eof and Rs.bof) then
				catalogID = Rs (0)
				catalogName = Rs(1)
				rootID = Rs(2)
				depth = Rs(3)
				If Rs(4)>0 Then
					strSQL = "catalogID in (select catalogID from Mesky_Down_Catalog where rootID="&Rs(2)&" and depth>"&Rs(3)&" and orders>"&Rs(5)&")"
				End If
				call Show_Down_List(Rs(2), Rs (0), Rs(1), Rs(3), Rs(4), Rs(5), Rs(6))
			else
				Mesky.strMsg = "指定的分类不存在！"
				call Mesky.SystemMsg()
				exit sub
			end if
			set Rs = nothing
		End IF
		
	End Sub
	Public Sub Show_Down_List(rootID, catalogID, catalogName, depth, child, orders, ResNum)
	
		Dim arrPage, arrMainPage, Rs, strSQL, sFileName, sXml
		If depth = 0 Then
			strSQL = "rootID=" & rootID
			'q = " & " & strSQL
			sFileName = Replace(Mesky.Setting(72), "{$id}", rootID & "&Page={$pages}")
			sXml = "xml/rss_Down_r" & rootID & ".xml"
		Else
			strSQL = "catalogID=" & catalogID
			'q = " & " & strSQL
			If child > 0 Then
				strSQL = "catalogID in (select catalogID from Mesky_Down_Catalog where rootID=" & rootID & " and depth>" & depth & " and orders>" & orders & ")"
			End If
			sFileName = Replace(Mesky.Setting(73), "{$id}", catalogID& "&Page={$pages}")
			sXml = "xml/rss_Down_r" & catalogID & ".xml"
		End If
		
		Dim showPageRs, sql, i, sColumn, currentPage, Pages, tempStr, s
		Dim fso, fout
		
		arrPage = Split(Mesky.ReadStylePage("Style_Down_List"), "<!--|||-->")
		arrMainPage = Split(Mesky.ReadStylePage("Style_Down_Main"), "<!--|||-->")
		'currentPage = 1
		If ResNum = 0 Then  '没有记录时
			Pages = 1
			tempStr = Replace(arrMainPage(0), "{$page_title}", Mesky.Setting(0) & " - " & catalogName) & arrMainPage(1) & arrMainPage(2)
			tempStr = tempStr & Replace(Replace(arrPage(0), "{$site_nav}", Mesky.site_nav(catalogID, "Mesky_Down_catalog", "资源列表", "")), "{$rssurl}", sXml)
			tempStr = tempStr & Replace(Replace(Replace(arrPage(1), "{$strsql}", strSQL), "{$showpage}", ""), "{$catalog_nav}", Mesky.catalog_nav(rootID, catalogID, depth, "Mesky_Down_catalog"))
			tempStr = tempStr & arrPage(2) & Replace(arrPage(4), "{$showpage}", "")
			tempStr = tempStr & arrMainPage(4) & arrMainPage(5) '结束
			
			Response.Write tempStr
	
			tempStr = Null
		Else
			
			If ResNum Mod Mesky.Setting(83) = 0 Then
				Pages = CLng(ResNum / Mesky.Setting(83) * -1) * -1
			Else
				Pages = CLng(ResNum / Mesky.Setting(83) * -1) * -1 + 1
			End If
		
			sColumn = "ID,rootID,catalogID,catalogName,ResName,ResVer,FontColor,FontType,ResLanguage,ResSize,ResType,ResLicence,ResRank,System,DateAndTime,UpdateTime,HitsTotal,isHot,isTop,isBest,Excerpt,SmallImg"
			Set showPageRs = New cls_Mesky_showPage
			
				If Trim(Request.QueryString("Page")) = "" then
					currentPage = 1
				Else
					currentPage = Trim(Request.QueryString("Page"))
				End if
				
				If IsSqlDataBase = 1 Then
					showPageRs.DbType = "MSSQL_SP"
				Else
					showPageRs.DbType = "AC"
				End If
				showPageRs.RecType = 2
				showPageRs.RecSql = Int(ResNum)
				showPageRs.RecTerm = 2
				showPageRs.CookieName = "View_down_reslist" & catalogID
				showPageRs.Order = 1
				showPageRs.PageSize = Int(Mesky.Setting(83))
				showPageRs.currentPage = Int(currentPage)
				showPageRs.sql = sColumn & "$Mesky_Down_Resource$" & strSQL & " and isAuditing=1$isTop Desc,UpdateTime Desc$UpdateTime"
	
				Dim iRecCount, sqlRs
				iRecCount = showPageRs.RecCount()
				
				tempStr = Replace(arrMainPage(0), "{$page_title}", Mesky.Setting(0) & " - " & catalogName) & arrMainPage(1) & arrMainPage(2)
				tempStr = tempStr & Replace(Replace(arrPage(0), "{$site_nav}", Mesky.site_nav(catalogID, "Mesky_Down_catalog", "资源列表", "")), "{$rssurl}", sXml)
				tempStr = tempStr & Replace(Replace(Replace(arrPage(1), "{$strsql}", strSQL), "{$showpage}", showPageRs.showPage("../" & sFileName)), "{$catalog_nav}", Mesky.catalog_nav(rootID, catalogID, depth, "Mesky_Down_catalog"))
				tempStr = regExp_showDownRes(tempStr)
				
				If iRecCount < 1 Then
					s = "<tr> <td colspan=""5"">Sorry！没有找到任何记录。</td></tr>"
				Else
					
					Rs = showPageRs.ResultSet()
					For i = 0 To UBound(Rs, 2)
						s = arrPage(3)
						If Rs(18, i) Then
							s = Replace(s, "{$dot_images}", "<img src=""../images/isTop.gif"" align=""absmiddle"">")
						ElseIf Rs(17, i) Then
							s = Replace(s, "{$dot_images}", "<img src=""../images/isHot.gif"" align=""absmiddle"">")
						ElseIf Rs(19, i) Then
							s = Replace(s, "{$dot_images}", "<img src=""../images/isBest.gif"" align=""absmiddle"">")
						Else
							s = Replace(s, "{$dot_images}", "<img src=""../images/isList.gif"" align=""absmiddle"">")
						End If
							
						s = Replace(s, "{$softurl}", Replace(Mesky.Setting(77), "{$id}", Rs(0, i)))
						s = Replace(s, "{$softname}", Rs(4, i))
						s = Replace(s, "{$softver}", Rs(5, i))
						s = Replace(s, "{$updatetime}", Mesky.FormatMyDate(Rs(15, i), "{Y}-{m}-{d}"))
						s = Replace(s, "{$softrank}", Rs(12, i))
						s = Replace(s, "{$hitstotal}", Rs(16, i))
						If Rs(9, i) > 1024 Then
							s = Replace(s, "{$softsize}", Round(Rs(9, i) / 1024, 2) & " MB")
						Else
							s = Replace(s, "{$softsize}", Rs(9, i) & " KB")
						End If
						s = Replace(s, "{$excerpt}", Rs(20, i))
						s = Replace(s, "{$softtype}", Rs(10, i))
						s = Replace(s, "{$softlicence}", Rs(11, i))
						s = Replace(s, "{$system}", Rs(13, i))
						s = Replace(s, "{$smallimg}", "../" & Rs(21, i))
						tempStr = tempStr & s
						s = Null
					Next
					Rs = Null

				End If
				
				tempStr = tempStr & Replace(arrPage(4), "{$showpage}", showPageRs.showPage("../" & sFileName)) & arrMainPage(4) & arrMainPage(5)
				
				tempStr = regExp_showDownResImages(tempStr)
				
				Response.Write Replace(Mesky.HtmlHead() & tempStr,"../","")
				tempStr = Null
			Set showPageRs = Nothing
		End If
	End Sub
End Class
%>