<!--#include file="setup.asp" -->
<%
Dim DownloadClass_Ads
Dim NowStats
Dim HtmlTitle
Dim Style_CSS
Dim HtmlTempStr


NC_Admin.AdminChk = "36"
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_CreateCatalog
DownsysClass.admin_footer
NothingObject
CloseConn

Public Sub Init_CreateCatalog()
	Dim FSO,Fout,CreateHtml
	On Error Resume Next
	Server.ScriptTimeOut = 99999
	DownsysClass.LoadTemplates ("")
	Set DownloadClass_Ads = New Adcolumn_Cls
	NowStats = "软件分类"
	HtmlTitle = "软件分类"
	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) & DownsysClass.mainhtml(5) & DownsysClass.mainhtml(4)
	HtmlTempStr = Replace(HtmlTempStr, "{$NavMenu}", DownsysClass.SortingMenu)
	HtmlTempStr = Replace(HtmlTempStr, "{$Width}", DownsysClass.mainset(0))
	HtmlTempStr = Replace(HtmlTempStr, "{$Style_CSS}", Style_CSS)
	If CInt(DownsysClass.Setting(5)) = 0 Then
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(9))
	Else
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(10))
	End If
	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, "{$NowStats}", NowStats)
	HtmlTempStr = Replace(HtmlTempStr, "{$Title}", HtmlTitle)
	HtmlTempStr = Replace(HtmlTempStr, "{$Catalog}", CatalogInfo)
	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 & "Sorting/Index.html")
	With FSO
		.Open
		.Charset = "GB2312"
		.WriteText HtmlTempStr
		.SaveToFile CreateHtml,2
		.Close
	End With
	Set FSO = Nothing
	NC_Admin.Succeed_Msg ("生成总分类的HTML页完成!")
End Sub
Private Function CatalogInfo()
	Dim Rs
	Dim Rs_c
	Dim HtmlString
	Dim TotalNumber
	Dim TotalNum
	Dim i
	Set Rs = CreateObject("adodb.recordset")
	Set Rs_c = CreateObject("adodb.recordset")
	HtmlString = HtmlString & "<TABLE width=""99%"" bgcolor=""#CECECE"" cellSpacing=1 cellPadding=5 align=center border=0>" & vbCrLf
	HtmlString = HtmlString & " <TR>" & vbCrLf
	HtmlString = HtmlString & "    <TD colspan=""2"" align=center class=Border1>∷软件分类∷</TD>" & vbCrLf
	HtmlString = HtmlString & "    </TR>"
	Rs.Open "select * from NC_softSort Where depth = 0 order by sortid asc", conn, 1, 1
	If Not (Rs.bof And Rs.EOF) Then
		Do While Not Rs.EOF
			HtmlString = HtmlString & " <TR>" & vbCrLf
			HtmlString = HtmlString & "    <TD width=""15%"" align=center class=Border1>"
			If CInt(DownsysClass.Setting(5)) = 0 Then
				HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting/Catalog" & Rs("sortid") & "/Sorting_Indate_Desc_1.html' title='" & Rs("readme") & "<BR>共有软件：" & Rs("SoftNum") & " 个'>" & Rs("sortName") & "</a> "
			Else
				HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting.Asp?sortid=" & Rs("sortid") & "' title='" & Rs("readme") & "<BR>共有软件：" & Rs("SoftNum") & " 个'>" & Rs("sortName") & "</a> "
			End If
			HtmlString = HtmlString & "</TD>    <TD width=""85%"" class=Border2>" & vbCrLf
			Rs_c.Open "select * from NC_softSort where depth <> 0 and rootid=" & Rs("rootid") & " order by sortid asc", conn, 1, 1
			If Rs_c.bof And Rs_c.EOF Then
				HtmlString = HtmlString & "没有添加分类"
			Else
				TotalNumber = Rs_c.recordcount
				i = 1
				Do While Not Rs_c.EOF
					If CInt(DownsysClass.Setting(5)) = 0 Then
						HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting/Catalog" & Rs_c("sortid") & "/Sorting_Indate_Desc_1.html' title='" & Rs_c("readme") & "<BR>共有软件：" & Rs_c("SoftNum") & " 个'>" & Rs_c("sortName") & "</a> &nbsp; " & vbCrLf
					Else
						HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting.Asp?sortid=" & Rs_c("sortid") & "' title='" & Rs_c("readme") & "<BR>共有软件：" & Rs_c("SoftNum") & " 个'>" & Rs_c("sortName") & "</a> &nbsp; " & vbCrLf
					End If
					If (i Mod CInt(DownsysClass.mainset(28))) = 0 And i <> TotalNumber Then
						HtmlString = HtmlString & " <br>"
					End If
					i = i + 1
					Rs_c.movenext
				Loop
			End If
			Rs_c.Close
			HtmlString = HtmlString & "  </TD>" & vbCrLf
			HtmlString = HtmlString & " </TR>" & vbCrLf
			Rs.movenext
		Loop
	End If
	Rs.Close
	HtmlString = HtmlString & " <TR>" & vbCrLf
	HtmlString = HtmlString & "    <TD colspan=""2"" align=center class=Border1>∷文章分类∷</TD>" & vbCrLf
	HtmlString = HtmlString & "    </TR>"
	Rs.Open "select * from NC_class Where depth = 0 order by classid asc", conn, 1, 1
	If Not (Rs.bof And Rs.EOF) Then
		Do While Not Rs.EOF
			HtmlString = HtmlString & " <TR>" & vbCrLf
			HtmlString = HtmlString & "    <TD align=center class=Border1>"
			If CInt(DownsysClass.Setting(5)) = 0 Then
				HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Listing/Catalog" & Rs("classid") & "/Listing_Indate_Desc_1.html' title='" & Rs("readme") & "<BR>共有文章：" & Rs("ArticleNum") & " 篇'>" & Rs("className") & "</a> "
			Else
				HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Listing.Asp?classid=" & Rs("classid") & "' title='" & Rs("readme") & "<BR>共有文章：" & Rs("ArticleNum") & " 篇'>" & Rs("className") & "</a> "
			End If
			HtmlString = HtmlString & "</TD>    <TD class=Border2>" & vbCrLf
			Rs_c.Open "select * from NC_class where depth <> 0 and rootid = " & Rs("rootid") & " order by classid asc", conn, 1, 1
			If Rs_c.bof And Rs_c.EOF Then
				HtmlString = HtmlString & "没有添加分类"
			Else
				TotalNum = Rs_c.recordcount
				i = 1
				Do While Not Rs_c.EOF
					If CInt(DownsysClass.Setting(5)) = 0 Then
						HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Listing/Catalog" & Rs_c("classid") & "/Listing_Indate_Desc_1.html' title='" & Rs_c("readme") & "<BR>共有文章：" & Rs_c("ArticleNum") & " 篇'>" & Rs_c("className") & "</a> &nbsp; " & vbCrLf
					Else
						HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Listing.Asp?classid=" & Rs_c("classid") & "' title='" & Rs_c("readme") & "<BR>共有文章：" & Rs_c("ArticleNum") & " 篇'>" & Rs_c("className") & "</a> &nbsp; " & vbCrLf
					End If
					If (i Mod CInt(DownsysClass.mainset(28))) = 0 And i <> TotalNum Then
						HtmlString = HtmlString & "<br>"
					End If
					i = i + 1
					Rs_c.movenext
				Loop
			End If
			Rs_c.Close
			HtmlString = HtmlString & "</TD>" & vbCrLf
			HtmlString = HtmlString & " </TR>" & vbCrLf
			Rs.movenext
		Loop
	End If
	Rs.Close
	HtmlString = HtmlString & "</TABLE>" & vbCrLf
	HtmlString = HtmlString & "<BR style=""OVERFLOW: hidden; LINE-HEIGHT: 3px"">" & vbCrLf
	Set Rs_c = Nothing
	Set Rs = Nothing
	CatalogInfo = HtmlString
End Function
%>
