<!-- #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 ViewDownNew
	obj.AspInit()
set obj = nothing

class ViewDownNew
	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 arrTop1, arrTop2
		arrTop1 = "HitsTotal,HitsMonth,HitsWeek,HitsToday"
		arrTop2 = "全部下载排行榜,本月下载排行榜,本周下载排行榜,本日下载排行榜"
		arrTop1 = Split(arrTop1, ",")
		arrTop2 = Split(arrTop2, ",")
		
		IF Request.QueryString("s") <>"" then 
			sID = Clng(Mesky.checkStr(Trim(Request.QueryString("s"))))-1
			Call show_Down_Top(sID, arrTop1(sID),arrTop2(sID))
		Else
			Call show_Down_Top(0, arrTop1(sID),arrTop2(sID))
		End If		
	End Sub
	Public Sub show_Down_Top(sID, topC, topN)
	
		Dim arrPage, arrMainPage, sFileName, sXml, x, selectType, strSQL
		Dim arrTop1, arrTop2
		arrTop1 = "HitsTotal,HitsMonth,HitsWeek,HitsToday"
		arrTop2 = "全部下载排行榜,本月下载排行榜,本周下载排行榜,本日下载排行榜"
		arrTop1 = Split(arrTop1, ",")
		arrTop2 = Split(arrTop2, ",")
		For x = 0 To UBound(arrTop1)
			If x = 0 Then
				selectType = selectType & "<a href=""../" & Replace(Replace(Mesky.Setting(76), "{$s}", x + 1), "{$pages}", "1") & """>" & arrTop2(x) & "</a>"
			Else
				selectType = selectType & " | <a href=""../" & Replace(Replace(Mesky.Setting(76), "{$s}", x + 1), "{$pages}", "1") & """>" & arrTop2(x) & "</a>"
			End If
		Next
		arrPage = Split(Mesky.ReadStylePage("Style_Down_Top"), "<!--|||-->")
		arrMainPage = Split(Mesky.ReadStylePage("Style_Down_Main"), "<!--|||-->")
		
		Dim Rs, showPageRs, sql, i, sColumn, currentPage, Pages, tempStr, s, n
		Dim fso, fout	
		
		Set showPageRs = New cls_Mesky_showPage
		
		If Mesky.Setting(86) Mod Mesky.Setting(87) = 0 Then
			Pages = CLng(Mesky.Setting(86) / Mesky.Setting(87) * -1) * -1
		Else
			Pages = CLng(Mesky.Setting(86) / Mesky.Setting(87) * -1) * -1 + 1
		End If
		
		If Trim(Request.QueryString("Page")) = "" then
			currentPage = 1
		Else
			currentPage = Trim(Request.QueryString("Page"))
		End if
		
			sColumn = "ID,rootID,catalogID,catalogName,ResName,ResVer,UpdateTime,ResRank," & topC & ",ResSize,isHot,isTop,isBest,excerpt"
			showPageRs.DbType = "AC"
			showPageRs.RecType = 3
			showPageRs.RecSql = Mesky.Setting(86)
			showPageRs.RecTerm = 2
			showPageRs.CookieName = "View_New_reslist" & sID
			showPageRs.Order = 1
			showPageRs.PageSize = Int(Mesky.Setting(87))
			showPageRs.currentPage = Int(currentPage)
			showPageRs.sql = sColumn & "$Mesky_Down_Resource$isAuditing=1$" & topC & " desc$" & topC & ""
			Dim iRecCount, sqlRs
			iRecCount = showPageRs.RecCount()
			
			sFileName = "../" & Replace(Mesky.Setting(76), "{$s}", sID+1 & "&Page={$pages}")
			tempStr = Replace(arrMainPage(0), "{$page_title}", Mesky.Setting(0) & " — " & topN) & arrMainPage(1) & arrMainPage(2)
			tempStr = tempStr & Replace(Replace(arrPage(0), "{$site_nav}", Mesky.site_nav(0, "Mesky_Down_catalog", topN, "")), "{$select_toptype}", selectType)
			tempStr = tempStr & Replace(Replace(arrPage(1), "{$strsql}", strSQL), "{$showpage}", showPageRs.showPage(sFileName))
			tempStr = regExp_showDownRes(tempStr)
			
			If iRecCount < 1 Then
			
				s = "<tr> <td colspan=""5"">Sorry！没有找到任何记录。</td></tr>"
				tempStr = tempStr & s
				s = Null
			Else
				Rs = showPageRs.ResultSet()
				For i = 0 To UBound(Rs, 2)
					s = arrPage(2)
					If currentPage = 1 Then
						n = " 第" & i + 1 & "名 "
					Else
						n = " 第" & ((currentPage - 1) * Int(Mesky.Setting(87)) + i + 1) & "名 "
					End If
					If Rs(11, i) Then
						s = Replace(s, "{$dot_images}", "<img src=""../images/isTop.gif"" align=""absmiddle"">" & n)
					ElseIf Rs(10, i) Then
						s = Replace(s, "{$dot_images}", "<img src=""../images/isHot.gif"" align=""absmiddle"">" & n)
					ElseIf Rs(12, i) Then
						s = Replace(s, "{$dot_images}", "<img src=""../images/isBest.gif"" align=""absmiddle"">" & n)
					Else
						s = Replace(s, "{$dot_images}", "<img src=""../images/isList.gif"" align=""absmiddle"">" & n)
					End If
	
					s = Replace(s, "{$catalogurl}", "../" & Replace(Replace(Mesky.Setting(73), "{$id}", Rs(2, i)), "{$pages}", "1"))
					s = Replace(s, "{$catalogname}", Rs(3, i))
					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(6, i), "{Y}-{m}-{d}"))
					s = Replace(s, "{$softrank}", Rs(7, i))
					s = Replace(s, "{$hitstotal}", Rs(8, 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(13, i))
					tempStr = tempStr & s
					s = Null
				Next
				Rs = Null
			End If			
			i = Null
			s = Null
			tempStr = tempStr & Replace(arrPage(3), "{$showpage}", showPageRs.showPage(sFileName)) & arrMainPage(5)
			Response.Write Replace(tempStr,"../","")
			tempstr = Null
			Set showPageRs = Nothing
	End Sub
End Class
%>