<!--#include file="config.asp"-->
<%
Dim Rs,SQL,foundstr,Page_Strings
Dim classid,ChildStr,stype,strTitle
Dim HtmlContent,ListContent
Dim ListStyle,i,CreateHtml,ChannelRootDir
CreateHtml = 1
ChannelRootDir = Newasp.InstallDir & Newasp.ChannelDir
classid = Newasp.CheckNumeric(Request("classid"))
stype = Newasp.CheckNumeric(Request("type"))
Newasp.LoadTemplates 9999, 7, 0
LoadXsltPage("../skin/downtop.xslt")
HtmlContent = Page_Strings(0).text
Call DownTopList
HtmlContent = HtmlContent & Page_Strings(4).text
HtmlContent = Replace(HtmlContent,"{$InstallDir}", Newasp.InstallDir)
HtmlContent = Replace(HtmlContent, "{$ChannelID}", 0)
HtmlContent = Replace(HtmlContent,"{$PageTitle}","今日下载排行")
HtmlContent = Replace(HtmlContent, "{$ChannelRootDir}", "")
HtmlContent = Replace(HtmlContent, "{$SoftIndex}", Newasp.ModuleName)
HtmlContent = ReadClassMenu(HtmlContent)
HtmlContent = ReadClassMenubar(HtmlContent)
Newasp.HTMLValue = HtmlContent
HtmlContent = Newasp.HTMLValue
Response.Write HtmlContent
Public Sub DownTopList()
	Dim sTitle, sTopic, softname, ListStyle, TitleWord,HtmlFileName
	Dim LinksUrl, SoftTime, sClassName, SoftImage, SoftVer,SoftIntro
	Dim findword,strTitle
	If classid > 0 Then
		SQL = "SELECT ClassName,ChildStr FROM [xp90com_Classify] WHERE ChannelID=" & ChannelID & " And ClassID=" & CLng(classid)
		Set Rs = Newasp.Execute(SQL)
		If Rs.BOF And Rs.EOF Then
			Rs.Close: Set Rs = Nothing
			Exit Sub
		Else
			strTitle = Rs("ClassName")
			ChildStr = Rs("ChildStr")
		End If
		Rs.Close:Set Rs = Nothing
		findword = "And A.ClassID in (" & ChildStr & ") And Datediff(d,HitsTime,getdate())=0 ORDER BY A.DayHits DESC ,A.SoftID DESC"
	Else
		strTitle = "全部软件列表"
		findword = "And Datediff(d,HitsTime,getdate())=0 ORDER BY A.DayHits DESC ,A.SoftID DESC"
	End If
	If stype = 1 Then
		findword = Replace(findword, "And Datediff(d,HitsTime,getdate())=0", "")
		findword = Replace(findword, "A.DayHits", "A.AllHits")
	End If
	If ChannelID > 0 Then
		SQL = "SELECT TOP 100 A.SoftID,A.ClassID,A.ChannelID,A.SoftName,A.SoftVer,A.content,A.Related,A.Languages,A.SoftType,A.RunSystem,A.impower,A.SoftSize,A.star,A.SoftTime,A.username,A.Allhits,A.DayHits,A.HtmlFileDate,C.ClassName,C.HtmlFileDir,C.UseHtml FROM [xp90com_SoftLists] A INNER JOIN [xp90com_Classify] C On A.ClassID=C.ClassID WHERE A.ChannelID=" & ChannelID & " And A.isAccept > 0 " & findword
	Else
		SQL = "SELECT TOP 100 A.SoftID,A.ClassID,A.ChannelID,A.SoftName,A.SoftVer,A.content,A.Related,A.Languages,A.SoftType,A.RunSystem,A.impower,A.SoftSize,A.star,A.SoftTime,A.username,A.Allhits,A.DayHits,A.HtmlFileDate,C.ClassName,C.HtmlFileDir,C.UseHtml FROM [xp90com_SoftLists] A INNER JOIN [xp90com_Classify] C On A.ClassID=C.ClassID WHERE A.isAccept > 0 " & findword
	End If
	Set Rs = Newasp.Execute(SQL)
	If Rs.BOF And Rs.EOF Then
	Else
		i = 1
		HtmlContent = HtmlContent & Page_Strings(1).text
		Do While Not Rs.EOF
			ListContent = ListContent & Page_Strings(2).text
			If (i Mod 2) = 0 Then
				ListStyle = 1
			Else
				ListStyle = 2
			End If
			TitleWord = Rs("SoftName") & " " & Rs("SoftVer")
			sTitle = TitleWord
			If CInt(CreateHtml) <> 0 Then
				HtmlFileName = Newasp.ReadFileName(Rs("HtmlFileDate"), Rs("SoftID"), Newasp.HtmlExtName, Newasp.HtmlPrefix, Newasp.HtmlForm, "")
				LinksUrl = ShowChannelPath(Newasp.ChannelPath, Rs("HtmlFileDir")) & Newasp.ShowDatePath(Rs("HtmlFileDate"), Newasp.HtmlPath) & HtmlFileName
				sClassName = ChannelRootDir & Rs("HtmlFileDir")
			Else
				LinksUrl = ChannelRootDir & "show.asp?id=" & Rs("SoftID")
				sClassName = ChannelRootDir & "list.asp?classid=" & Rs("ClassID")
			End If
			sClassName = "<a href=""" & sClassName & """ title=""" & Rs("ClassName") & """ target=""_blank"">" & Rs("ClassName") & "</a>"
			softname = "<a href='" & LinksUrl & "' title='" & Rs("SoftName") & Rs("SoftVer") & "' class=""toplist"" target=""_blank"">" & sTitle & "</a>"
			SoftTime = Newasp.ShowDateTime(Rs("SoftTime"), 2)
			ListContent = Replace(ListContent, "{$ClassifyName}", sClassName)
			ListContent = Replace(ListContent, "{$SoftName}", softname)
			ListContent = Replace(ListContent, "{$Topic}", sTitle)
			ListContent = Replace(ListContent, "{$LinksUrl}", LinksUrl)
			ListContent = Replace(ListContent, "{$Star}", Rs("star"))
			ListContent = Replace(ListContent, "{$SoftHits}", Rs("AllHits"))
			ListContent = Replace(ListContent, "{$DayHits}", Rs("DayHits"))
			ListContent = Replace(ListContent, "{$UserName}", Rs("username"))
			ListContent = Replace(ListContent, "{$SoftDateTime}", SoftTime)
			ListContent = Replace(ListContent, "{$ListStyle}", ListStyle)
			ListContent = Replace(ListContent, "{$SoftSize}",ReadSoftsize(Rs("SoftSize")))
			ListContent = Replace(ListContent, "{$Impower}", Rs("impower"))
			ListContent = Replace(ListContent, "{$Language}", Rs("Languages"))
			ListContent = Replace(ListContent, "{$SoftType}", Rs("SoftType"))
			ListContent = Replace(ListContent, "{$SoftID}", Rs("SoftID"))
			ListContent = Replace(ListContent, "{$Order}", Newasp.Supplemental(i,3))
			Rs.MoveNext
			i = i + 1
		Loop
	End If
	Rs.Close: Set Rs = Nothing
	HtmlContent = HtmlContent &  ListContent & Page_Strings(3).text
End Sub
'页面加载
Public Sub LoadXsltPage(ByVal StyleFile)
	Dim XslDoc,Page_File
	Page_File = Server.MapPath(StyleFile)
	Set XslDoc=Server.CreateObject("Msxml2.FreeThreadedDOMDocument")
	If Not XslDoc.Load(Page_File) Then
		Response.Write "模板不存在"
		Response.End
		Exit Sub
	Else
		Set Page_Strings = XslDoc.DocumentElement.selectNodes("xsl:variable")
	End If
	Set XslDoc = Nothing
End Sub
'================================================
'函数名：ReadSoftsize
'作  用：读取软件的大小
'================================================
Function ReadSoftsize(ByVal para)
	On Error Resume Next
	Dim parasize
	parasize = Clng(para)
	If parasize = 0 Then
		ReadSoftsize = "未知"
		Exit Function
	End If
	If parasize > 1024*1024 Then
		ReadSoftsize = Round(parasize / (1024*1024), 2) & " GB"
		Exit Function
	ElseIf parasize > 1024 Then
		ReadSoftsize = Round(parasize / 1024, 2) & " MB"
		Exit Function
	Else
		ReadSoftsize = parasize & " KB"
		Exit Function
	End If
	ReadSoftsize = "未知"
End Function
%>
