<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<%
Dim Rs, SQL, i
Dim stype, DownloadClass_Ads
Dim Style_CSS, HtmlTempStr, ArticleTypeSrt
Dim NowStats, HtmlTitle
Dim InfoTime, title, ClassName
Dim totalnumber, maxperpage, CurrentPage, tempPcount, bookmark
Set DownloadClass_Ads = New Adcolumn_Cls
HotArticleList

Public Sub HotArticleList()
	If Not IsEmpty(Request.Querystring("page")) Then
		CurrentPage = CInt(Request.Querystring("page"))
	Else
		CurrentPage = 1
	End If
	DownsysClass.LoadTemplates ("article")
	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}", GetAspShowPage(maxperpage, totalnumber, CurrentPage))
	HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(4)
	HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(10))
	HtmlTempStr = Replace(HtmlTempStr, "{$NowStats}", NowStats)
	HtmlTempStr = Replace(HtmlTempStr, "{$Title}", HtmlTitle)
	HtmlTempStr = Replace(HtmlTempStr, "{$Width}", DownsysClass.mainset(0))
	HtmlTempStr = Replace(HtmlTempStr, "{$FootMeun}", DownsysClass.mainset(11))
	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))
	Response.Write HtmlTempStr
End Sub

Private Function GetAspShowPage(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=?page=1>首 页</a>&nbsp;&nbsp;"
		HtmlString = HtmlString & "<a href=?page=" & CurrentPage - 1 & ">上一页</a>&nbsp;&nbsp;"
	End If
	If n - CurrentPage < 1 Then
		HtmlString = HtmlString & "下一页&nbsp;&nbsp;尾 页 " & vbCrLf
	Else
		HtmlString = HtmlString & "<a href=?page=" & (CurrentPage + 1) & ">下一页</a>"
		HtmlString = HtmlString & "&nbsp;&nbsp;<a href=?page=" & n & ">尾 页</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='?page=" & ii & "' "
		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
	GetAspShowPage = HtmlString
End Function
%>
