<!--#include file="setup.asp"-->
<%
Response.Buffer = True
Set NC_Admin = New Check
NC_Admin.AdminChk = "32"
NC_Admin.Check
DownsysClass.admin_header
If Not(DownsysClass.IsObjectFSO(DownsysClass.Script_FSO) And CInt(DownsysClass.Setting(5)) = 0 ) Then
	NC_Admin.Error_Msg ("<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)或你后台没有选择为html方式</font></b>")
	DownsysClass.admin_footer
	Response.End
End If
	Dim stype, i, DownloadClass_Ads, ii 
	Dim Style_CSS, HtmlTempStr, NowStats, HtmlTitle
	Dim SoftTypeSrt, SoftSize, SoftTime, SoftName, SortName
	Dim CurrentPage,totalnumber, maxperpage, tempPcount, bookmark
	Dim CreateHtml, FSO, Fout,j,jj
	On Error Resume Next
	Server.ScriptTimeOut = 99999
	DownsysClass.LoadTemplates ("")
	Set DownloadClass_Ads = New Adcolumn_Cls
	If ( CInt(DownsysClass.mainset(33)) Mod CInt(DownsysClass.mainset(34)) ) = 0 Then
		jj= CInt(DownsysClass.mainset(33)) \ CInt(DownsysClass.mainset(34))
	Else 
		jj= CInt(DownsysClass.mainset(33)) \ CInt(DownsysClass.mainset(34)) + 1
	End if
 	For j= 1 to jj
  	CurrentPage=j
	Style_CSS = Replace(Replace(DownsysClass.Style_CSS, "{$SetupDir}", DownsysClass.SetupDir), "{$PicUrl}", DownsysClass.TempDir)
	HtmlTempStr = DownsysClass.mainhtml(0) & DownsysClass.mainhtml(1) & DownsysClass.mainhtml(2) & DownsysClass.mainhtml(3)
	HtmlTempStr = Replace(HtmlTempStr, "{$NavMenu}", DownsysClass.SortingMenu)
	HtmlTempStr = Replace(HtmlTempStr, "{$Style_CSS}", Style_CSS)
	NowStats = "热门软件"
	HtmlTitle = "热门软件"
	Set Rs = Server.CreateObject("adodb.recordset")
	maxperpage = CInt(DownsysClass.mainset(34))
	SQL = "select top " & CInt(DownsysClass.mainset(33)) & " * from NC_SoftInfo where isLock=0 order by hits desc, SoftTime desc,SoftID desc"
	Rs.Open SQL, Conn, 1, 1
	If Not (Rs.EOF And Rs.bof) Then
		totalnumber = Rs.recordcount
		If (totalnumber Mod maxperpage) = 0 Then
			tempPcount = totalnumber \ maxperpage
		Else
			tempPcount = totalnumber \ maxperpage + 1
		End If
		Rs.MoveFiRst
		If CurrentPage > tempPcount Then CurrentPage = tempPcount
		If CurrentPage < 1 Then CurrentPage = 1
		Rs.Move (CurrentPage - 1) * maxperpage
		bookmark = Rs.bookmark
		i = 0
		HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(14)
		Do While Not Rs.EOF And i < CLng(maxperpage)
			HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(15)
			If Rs("SoftSize") > 1024 Then
				SoftSize = Round(Rs("SoftSize") / 1024, 2) & " MB"
			Else
				SoftSize = Rs("SoftSize") & " KB "
			End If
			If Rs("SoftTime") >= Date Then
				SoftTime = "<font color=red>" & FormatDateTime(Rs("SoftTime"), 2) & "</font>"
			Else
				SoftTime = FormatDateTime(Rs("SoftTime"), 2)
			End If
			If CInt(DownsysClass.Setting(5)) = 0 Then
				SoftName = "<a href='" & DownsysClass.SetupDir & "Software/Catalog" & Rs("sortid") & "/" & Rs("softid") & ".html'>" & Rs("SoftName") &"&nbsp;"& Rs("SoftVer") & "</a>"
				SortName = "<a href='" & DownsysClass.SetupDir & "Sorting/Catalog" & Rs("sortid") & "/Sorting_Indate_Desc_1.html'>" & Rs("SortName") & "</a>"
			Else
				SoftName = "<a href='" & DownsysClass.SetupDir & "Software.Asp?id=" & Rs("softid") & "'>" & Rs("SoftName") &"&nbsp;"& Rs("SoftVer") & "</a>"
				SortName = "<a href='" & DownsysClass.SetupDir & "Sorting.Asp?sortid=" & Rs("sortid") & "'>" & Rs("SortName") & "</a>"
			End If
			HtmlTempStr = Replace(HtmlTempStr, "{$Grades}", Rs("Grades"))
			HtmlTempStr = Replace(HtmlTempStr, "{$SoftSize}", SoftSize)
			HtmlTempStr = Replace(HtmlTempStr, "{$SoftName}", SoftName)
			HtmlTempStr = Replace(HtmlTempStr, "{$SoftTime}", SoftTime)
			HtmlTempStr = Replace(HtmlTempStr, "{$SortName}", SortName)
			HtmlTempStr = Replace(HtmlTempStr, "{$Hits}", Rs("Hits"))
			Rs.movenext
			i = i + 1
			If i >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close
	Set Rs = Nothing
	HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(16)
	HtmlTempStr = Replace(HtmlTempStr, "{$ShowPage}", GetShowPage(maxperpage, totalnumber, CurrentPage))
	HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(4)
	If CInt(DownsysClass.Setting(5)) = 0 Then
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(9))
	Else
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(10))
	End If
	HtmlTempStr = Replace(HtmlTempStr, "{$NowStats}", NowStats)
	HtmlTempStr = Replace(HtmlTempStr, "{$Title}", HtmlTitle)
	HtmlTempStr = Replace(HtmlTempStr, "{$Width}", DownsysClass.mainset(0))
	If CInt(DownsysClass.Setting(5)) = 1 Then
		HtmlTempStr = Replace(HtmlTempStr, "{$FootMeun}", DownsysClass.mainset(11))
	Else 
		HtmlTempStr = Replace(HtmlTempStr, "{$FootMeun}", DownsysClass.mainset(44))
	End If
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(0)}", DownloadClass_Ads.RunScriptAds(7))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(7))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(7, 2))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(3)}", DownloadClass_Ads.AdsColumn(7, 3))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(6)}", DownloadClass_Ads.AdsColumn(7, 7))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(7))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(7))

	Set FSO = Server.CreateObject("ADODB.STREAM")
	CreateHtml = Server.MapPath(DownsysClass.SetupDir & "Software/Hotsoft_" & CurrentPage & ".html")
	With FSO
		.Open
		.Charset = "GB2312"
		.WriteText HtmlTempStr
		.SaveToFile CreateHtml,2
		.Close
	End With
	Set FSO = Nothing	
	Next
	NC_Admin.Succeed_Msg ("生成热门软件成功!")
	Set DownloadClass_Ads = Nothing
DownsysClass.admin_footer
NothingObject
CloseConn

Private Function GetShowPage(maxperpage, totalnumber, CurrentPage)
	Dim n
	Dim HtmlString
	If totalnumber Mod maxperpage = 0 Then
		n = totalnumber \ maxperpage
	Else
		n = totalnumber \ maxperpage + 1
	End If
	HtmlString = HtmlString & "<table cellspacing=1 width='100%' border=0><form method=Post onChange=""submit()""><tr><td align=center> " & vbCrLf
	HtmlString = HtmlString & "<font color='red'>热门软件</font> " & vbCrLf
	If CurrentPage < 2 Then
		HtmlString = HtmlString & "" & totalnumber & "个&nbsp;&nbsp;首 页&nbsp;&nbsp;上一页&nbsp;&nbsp;"
	Else
		HtmlString = HtmlString & "" & totalnumber & "个&nbsp;&nbsp;<a href=Hotsoft_1.html>首 页</a>&nbsp;&nbsp;"
		HtmlString = HtmlString & "<a href=Hotsoft_" & CurrentPage - 1 & ".html>上一页</a>&nbsp;&nbsp;"	
	End If
	If n - CurrentPage < 1 Then
		HtmlString = HtmlString & "下一页&nbsp;&nbsp;尾 页 " & vbCrLf
	Else
		HtmlString = HtmlString & "<a href=Hotsoft_" & (CurrentPage + 1) & ".html>下一页</a>"
		HtmlString = HtmlString & "&nbsp;&nbsp;<a href=Hotsoft_" & n & ".html>尾 页</a>" & vbCrLf
	End If
	HtmlString = HtmlString & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页"
	HtmlString = HtmlString & "&nbsp;<b>" & maxperpage & "</b>个/页" & vbCrLf
	HtmlString = HtmlString & "&nbsp;转到："
	HtmlString = HtmlString & "<select name='page' size='1' style=""font-size: 9pt"" onChange='javascript:window.open(this.options[this.selectedIndex].value,""_top"")'>" & vbCrLf
	For ii = 1 To n
		HtmlString = HtmlString & "&nbsp;<option value='Hotsoft_" & ii & ".html' "
		If CurrentPage = CInt(ii) Then
			HtmlString = HtmlString & "selected "
		End If
		HtmlString = HtmlString & ">第" & ii & "页</option>"
	Next
	HtmlString = HtmlString & "&nbsp;</select> " & vbCrLf
	HtmlString = HtmlString & "</td></tr></FORM></table>" & vbCrLf
	GetShowPage = HtmlString
End Function
%>
