<!--#include file="setup.asp"-->
<%
Response.Buffer = True
Set NC_Admin = New Check
NC_Admin.AdminChk = "35"
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
HotArticleList
DownsysClass.admin_footer
NothingObject
CloseConn

Private Function GetShowPage(maxperpage, totalnumber, CurrentPage)
	Dim ii
	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=HotArticle_1.Html>首 页</a>&nbsp;&nbsp;"
		HtmlString = HtmlString & "<a href=HotArticle_" & CurrentPage - 1 & ".Html>上一页</a>&nbsp;&nbsp;"
	End If
	If n - CurrentPage < 1 Then
		HtmlString = HtmlString & "下一页&nbsp;&nbsp;尾 页 " & vbCrLf
	Else
		HtmlString = HtmlString & "<a href=HotArticle_" & (CurrentPage + 1) & ".Html>下一页</a>"
		HtmlString = HtmlString & "&nbsp;&nbsp;<a href=HotArticle_" & 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='HotArticle_" & 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

Public Sub HotArticleList()
	Dim i
	Dim stype, DownloadClass_Ads
	Dim Style_CSS, HtmlTempStr, ArticleTypeSrt
	Dim NowStats, HtmlTitle
	Dim InfoTime, title, ClassName
	Dim totalnumber, maxperpage, CurrentPage, tempPcount, bookmark
	Dim CreateHtml, FSO, Fout,j,jj
	DownsysClass.LoadTemplates ("article")
	Set DownloadClass_Ads = New Adcolumn_Cls
	If ( CInt(DownsysClass.TempSet(13)) MOD CInt(DownsysClass.TempSet(14)) )= 0 Then
		jj = CInt(DownsysClass.TempSet(13)) \ CInt(DownsysClass.TempSet(14))
	Else 
		jj = CInt(DownsysClass.TempSet(13)) \ CInt(DownsysClass.TempSet(14))+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.ClassMenu)
	HtmlTempStr = Replace(HtmlTempStr, "{$Style_CSS}", Style_CSS)
	NowStats = "热门文章"
	HtmlTitle = "热门文章"
	Set Rs = Server.CreateObject("adodb.recordset")
	maxperpage = CInt(DownsysClass.TempSet(14))
	SQL = "select top " & CInt(DownsysClass.TempSet(13)) & " * from NC_Article where isLock=0 order by hits desc, InfoTime desc,ID 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.temphtml(9)
		Do While Not Rs.EOF And i < CLng(maxperpage)
			HtmlTempStr = HtmlTempStr & DownsysClass.temphtml(10)
			If Rs("InfoTime") >= Date Then
				InfoTime = "<FONT color=red>" & FormatDateTime(Rs("InfoTime"), 2) & "</FONT >"
			Else
				InfoTime = FormatDateTime(Rs("InfoTime"), 2)
			End If
			Title = "<a href='" & DownsysClass.SetupDir & "Article.Asp?id=" & Rs("ID") & "' title='" & Rs("Title") & "'>" & Rs("Title") & "</a>"
			ClassName = "<a href='" & DownsysClass.SetupDir & "Listing.Asp?classid=" & Rs("classid") & "'>" & Rs("ClassName") & "</a>"
			HtmlTempStr = Replace(HtmlTempStr, "{$Topic}", Title)
			HtmlTempStr = Replace(HtmlTempStr, "{$InfoTime}", InfoTime)
			HtmlTempStr = Replace(HtmlTempStr, "{$ClassName}", ClassName)
			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.temphtml(11)
	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 & "Article/HotArticle_" & 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
End Sub

%>
