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

Public Sub Init_CreateLateNew()
	Dim stype, i, DownloadClass_Ads
	Dim Style_CSS, HtmlTempStr, NowStats, HtmlTitle
	Dim SoftTypeSrt, SoftSize, SoftTime, SoftName, SortName, isCommend,j
	Dim SoftType, NewFileName
	Dim FSO,Fout,CreateHtml
	On Error Resume Next
	Server.ScriptTimeOut = 99999
	SoftType = Split(DownsysClass.Setting(35), ",")
	Set DownloadClass_Ads = New Adcolumn_Cls
	DownsysClass.LoadTemplates ("")
	For j = -1 to UBound(SoftType)
		If j=-1 then
			stype = ""

		Else
			stype = Replace(Trim(SoftType(j)),"'", "''")
		End if
	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)
	Set Rs = Server.CreateObject("adodb.recordset")
	If stype <> "" Then
		SQL = "select top " & CInt(DownsysClass.mainset(29)) & " * from [NC_Softinfo] where isLock=0 and SoftType='" & stype & "' order by SoftTime desc,SoftID desc"
		SoftTypeSrt = stype
	Else
		SQL = "select top " & CInt(DownsysClass.mainset(29)) & " * from [NC_Softinfo] where isLock=0 order by SoftTime desc,SoftID desc"
		SoftTypeSrt = "最近更新软件"
	End If
	NowStats = SoftTypeSrt
	HtmlTitle = SoftTypeSrt
	HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(6)
	HtmlTempStr = Replace(HtmlTempStr, "{$NewAllName}", "Latenew.html")
	For i = 0 To UBound(SoftType)
		HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(7)
		NewFileName = "Latenew_" & i & ".html"
		If Trim(SoftType(i)) = stype Then HtmlTempStr = Replace(HtmlTempStr, "{$Selected}", "selected")
		HtmlTempStr = Replace(HtmlTempStr, "{$SoftTypeName}", Trim(SoftType(i)))
		HtmlTempStr = Replace(HtmlTempStr, "{$NewFileName}", NewFileName)
	Next

	HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(8)
	Rs.Open SQL, Conn, 1, 1
	If Rs.bof And Rs.EOF Then
		HtmlTempStr = HtmlTempStr & "<tr><td colspan=5 class=Border2>还没有找到任何软件！</td></tr>"
	Else
		Do While Not Rs.EOF
			HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(9)
			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(Rs("isCommend")) = 0 Then
				isCommend = ""
			Else
				isCommend = "<img src='" & DownsysClass.SetupDir & "images/jing.gif' align='absmiddle'>"
			End If
			If CInt(DownsysClass.Setting(5)) = 0 Then
				SoftName = "<a href='" & DownsysClass.SetupDir & "Software/Catalog" & Rs("sortid") & "/" & Rs("softid") & ".html'>" & Rs("SoftName") & Rs("SoftVer") & "</a> " & isCommend
				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") & Rs("SoftVer") & "</a> " & isCommend
				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)
			Rs.movenext
		Loop
	End If
	Rs.Close
	Set Rs = Nothing
	HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(10)
	HtmlTempStr = HtmlTempStr & DownsysClass.mainhtml(4)
	HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(9))
	HtmlTempStr = Replace(HtmlTempStr, "{$NowStats}", NowStats)
	HtmlTempStr = Replace(HtmlTempStr, "{$Title}", HtmlTitle)
	HtmlTempStr = Replace(HtmlTempStr, "{$Width}", DownsysClass.mainset(0))
	HtmlTempStr = Replace(HtmlTempStr, "{$FootMeun}", DownsysClass.mainset(44))
	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))

	If Not DownsysClass.IsObjectFSO(DownsysClass.Script_FSO) Then
		Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 最近更新软件HTML页文件没有生成</font></b>"
	Else	
		Set FSO = Server.CreateObject("ADODB.STREAM")
		If j=-1 then
			CreateHtml = Server.MapPath(DownsysClass.SetupDir & "Software/Latenew.Html")
		Else
			CreateHtml = Server.MapPath(DownsysClass.SetupDir & "Software/Latenew_" & j & ".Html")
		End if
			With FSO
				.Open
				.Charset = "GB2312"
				.WriteText HtmlTempStr
				.SaveToFile CreateHtml,2
				.Close
			End With
		Set FSO = Nothing
	End if
	Next
	NC_Admin.Succeed_Msg ("生成最近更新软件HTML页完成!")
	Set DownloadClass_Ads = Nothing
End sub
%>
