<%
Class Create_SoftIndex_Cls
	Private ErrMsg
	Private SucMsg
	Private Founderr
	Private NC_Admin
	Private Sub Class_Initialize()
		Founderr = False
	End Sub

	Private Sub Class_Terminate()
		If IsObject(Conn) Then
			Conn.Close
			Set Conn = Nothing
		End If
		If IsObject(NC_Admin) Then
			Set NC_Admin = Nothing
		End If
		If IsObject(DownloadClass_Ads) Then
			Set DownloadClass_Ads = Nothing
		End If
	End Sub

	
	'*************************************************************
	'函数作用：下载排行 hitsID=0:下载总排行 hitsID=1:本日下载排行
	'*************************************************************
	Private Function DownLoadTop(HitsID)
		Dim Rs, SQL, HtmlString, OrderName, SoftName
		Select Case CInt(HitsID)
			Case 1
				OrderName = "DayHits"
			Case 2
				OrderName = "WeekHits"
			Case 3
				OrderName = "MonthHits"
			Case Else
				OrderName = "Hits"
		End Select
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.mainset(13)) & " softid,sortid,SoftName,SoftVer, " & OrderName & ", SoftTime from NC_SoftInfo where isLock = 0 order by " & OrderName & " desc, SoftTime desc, softid desc"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "还没有排行软件!"
		Else
			Do While Not Rs.EOF
				If CInt(DownsysClass.Setting(5)) = 0 Then
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='软件名称: " & Rs(2) & Rs(3) & "<BR>更新时间: " & Rs(5) & "<BR>下载次数: " & Rs(4) & "'>" & DownsysClass.gotTopic(Rs(2) & Rs(3), CInt(DownsysClass.mainset(14))) & "</A>"
				Else
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software.asp?id=" & Rs(0) & "' title='软件名称: " & Rs(2) & " " & Rs(3) & "<BR>更新时间: " & Rs(5) & "<BR>下载次数: " & Rs(4) & "'>" & DownsysClass.gotTopic(Rs(2) & " " & Rs(3), CInt(DownsysClass.mainset(14))) & "</A>"
				End If
				HtmlString = HtmlString & DownsysClass.mainset(15)
				HtmlString = Replace(HtmlString, "{$SoftTopName}", SoftName)
				HtmlString = Replace(HtmlString, "{$SoftHits}", Rs(4))
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rs = Nothing
		DownLoadTop = HtmlString
	End Function
	'*************************************************************
	'函数作用：热门文章 hitsID=0:总浏览排行文章 hitsID=1:本日浏览排行
	'*************************************************************
	Private Function ArticleHits(HitsID)
		Dim Rs, SQL, HtmlString, OrderName, ArticleTitle
		Select Case CInt(HitsID)
			Case 1
				OrderName = "DayHits"
			Case 2
				OrderName = "WeekHits"
			Case 3
				OrderName = "MonthHits"
			Case Else
				OrderName = "Hits"
		End Select
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.mainset(16)) & " id,classid,Title, " & OrderName & ", InfoTime from NC_Article where isLock = 0 order by " & OrderName & " desc, InfoTime desc, id desc"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "还没有排行文章!"
		Else
			Do While Not Rs.EOF
				If CInt(DownsysClass.Setting(5)) = 0 Then
					ArticleTitle = "<A HREF='" & DownsysClass.SetupDir & "Article/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='文章标题: " & Rs(2) & "<BR>更新时间: " & Rs(4) & "<BR>浏览次数: " & Rs(3) & "'>" & DownsysClass.gotTopic(Rs(2), CInt(DownsysClass.mainset(17))) & "</A>"
				Else
					ArticleTitle = "<A HREF='" & DownsysClass.SetupDir & "Article.asp?id=" & Rs(0) & "' title='文章标题: " & Rs(2) & "<BR>更新时间: " & Rs(4) & "<BR>浏览次数: " & Rs(3) & "'>" & DownsysClass.gotTopic(Rs(2), CInt(DownsysClass.mainset(17))) & "</A>"
				End If
				HtmlString = HtmlString & DownsysClass.mainset(18)
				HtmlString = Replace(HtmlString, "{$ArticleTitle}", ArticleTitle)
				HtmlString = Replace(HtmlString, "{$ArticleHits}", Rs(3))
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rs = Nothing
		ArticleHits = HtmlString
	End Function
	'*************************************************************
	'函数作用：最新加入文章
	'*************************************************************
	Private Function NewArticle()
		Dim Rs, SQL, HtmlString, ArticleTitle, ClassName, InfoTime, InfoDate
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.mainset(19)) & " id,classid,Title, ClassName,InfoTime,Hits from NC_Article where isLock = 0 order by InfoTime desc, id desc"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "还没有最新文章!"
		Else
			Do While Not Rs.EOF
				If Rs("InfoTime") >= Date Then
					InfoTime = "<FONT color=red>" & Month(Rs("InfoTime")) & "/" & Day(Rs("InfoTime")) & "</FONT >"
					InfoDate = "<FONT color=red>" & FormatDateTime(Rs("InfoTime"), 2) & "</FONT >"
				Else
					InfoTime = "<FONT color=#999999>" & Month(Rs("InfoTime")) & "/" & Day(Rs("InfoTime")) & "</FONT >"
					InfoDate = "<FONT color=#999999>" & FormatDateTime(Rs("InfoTime"), 2) & "</FONT >"
				End If
				If CInt(DownsysClass.Setting(5)) = 0 Then
					ArticleTitle = "<A HREF='" & DownsysClass.SetupDir & "Article/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='" & Rs(2) & "' class='TableLink'>" & DownsysClass.gotTopic(Rs(2), CInt(DownsysClass.mainset(20))) & "</A>"
					ClassName = "<A HREF='" & DownsysClass.SetupDir & "Listing/Catalog" & Rs(1) & "/Listing_Indate_Desc_1.html' title='" & Rs("ClassName") & "'>" & Rs("ClassName") & "</A>"
				Else
					ArticleTitle = "<A HREF='" & DownsysClass.SetupDir & "Article.asp?id=" & Rs(0) & "' title='" & Rs(2) & "' class='TableLink'>" & DownsysClass.gotTopic(Rs(2), CInt(DownsysClass.mainset(20))) & "</A>"
					ClassName = "<A HREF='" & DownsysClass.SetupDir & "Listing.asp?classid=" & Rs(1) & "' title='" & Rs("ClassName") & "'>" & Rs("ClassName") & "</A>"
				End If
				HtmlString = HtmlString & DownsysClass.mainset(21)
				HtmlString = Replace(HtmlString, "{$ArticleTitle}", ArticleTitle)
				HtmlString = Replace(HtmlString, "{$ClassName}", ClassName)
				HtmlString = Replace(HtmlString, "{$InfoTime}", InfoTime)
				HtmlString = Replace(HtmlString, "{$ArticleHits}", Rs("Hits"))
				HtmlString = Replace(HtmlString, "{$InfoDate}", InfoDate)
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rs = Nothing
		NewArticle = HtmlString
	End Function
	'*************************************************************
	'函数作用：推荐文章
	'*************************************************************
	Private Function BestArticle()
		Dim Rs, SQL, HtmlString, ArticleTitle, ClassName, InfoTime, InfoDate
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.mainset(19)) & " id,classid,Title, ClassName,InfoTime,Hits,isTop from NC_Article where isLock = 0 And isCommend = 1 order by isTop desc, InfoTime desc, id desc"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "还没有推荐文章!"
		Else
			Do While Not Rs.EOF
				If Rs("InfoTime") >= Date Then
					InfoTime = "<FONT color=red>" & Month(Rs("InfoTime")) & "/" & Day(Rs("InfoTime")) & "</FONT >"
					InfoDate = "<FONT color=red>" & FormatDateTime(Rs("InfoTime"), 2) & "</FONT >"
				Else
					InfoTime = "<FONT color=#999999>" & Month(Rs("InfoTime")) & "/" & Day(Rs("InfoTime")) & "</FONT >"
					InfoDate = "<FONT color=#999999>" & FormatDateTime(Rs("InfoTime"), 2) & "</FONT >"
				End If
				If CInt(DownsysClass.Setting(5)) = 0 Then
					ArticleTitle = "<A HREF='" & DownsysClass.SetupDir & "Article/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='" & Rs(2) & "' class='TableLink'>" & DownsysClass.gotTopic(Rs(2), CInt(DownsysClass.mainset(20))) & "</A>"
					ClassName = "<A HREF='" & DownsysClass.SetupDir & "Listing/Catalog" & Rs(1) & "/Listing_Indate_Desc_1.html' title='" & Rs("ClassName") & "'>" & Rs("ClassName") & "</A>"
				Else
					ArticleTitle = "<A HREF='" & DownsysClass.SetupDir & "Article.asp?id=" & Rs(0) & "' title='" & Rs(2) & "' class='TableLink'>" & DownsysClass.gotTopic(Rs(2), CInt(DownsysClass.mainset(20))) & "</A>"
					ClassName = "<A HREF='" & DownsysClass.SetupDir & "Listing.asp?classid=" & Rs(1) & "' title='" & Rs("ClassName") & "'>" & Rs("ClassName") & "</A>"
				End If
				HtmlString = HtmlString & DownsysClass.mainset(21)
				HtmlString = Replace(HtmlString, "{$ArticleTitle}", ArticleTitle)
				HtmlString = Replace(HtmlString, "{$ClassName}", ClassName)
				HtmlString = Replace(HtmlString, "{$InfoTime}", InfoTime)
				HtmlString = Replace(HtmlString, "{$ArticleHits}", Rs("Hits"))
				HtmlString = Replace(HtmlString, "{$InfoDate}", InfoDate)
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rs = Nothing
		BestArticle = HtmlString
	End Function
	'*************************************************************
	'函数作用：最近更新软件
	'*************************************************************
	Private Function DayNewSoft()
		Dim Rs, SQL, HtmlString, SoftName, SortName, SoftTime, SoftDate
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.mainset(22)) & " softid,sortid,SoftName, SoftVer,SortName,SoftTime,Hits from NC_SoftInfo where isLock = 0 order by SoftTime desc, softid desc"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "还没有更新软件!"
		Else
			Do While Not Rs.EOF
				If Rs("SoftTime") >= Date Then
					SoftTime = "<FONT color=red>" & Month(Rs("SoftTime")) & "/" & Day(Rs("SoftTime")) & "</FONT >"
					SoftDate = "<FONT color=red>" & FormatDateTime(Rs("SoftTime"), 2) & "</FONT >"
				Else
					SoftTime = "<FONT color=#999999>" & Month(Rs("SoftTime")) & "/" & Day(Rs("SoftTime")) & "</FONT >"
					SoftDate = "<FONT color=red>" & FormatDateTime(Rs("SoftTime"), 2) & "</FONT >"
				End If
				If CInt(DownsysClass.Setting(5)) = 0 Then
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='" & Rs("SoftName") & Rs("SoftVer") & "' class='TableLink'>" & DownsysClass.gotTopic(Rs("SoftName") & " " & Rs("SoftVer"), CInt(DownsysClass.mainset(23))) & "</A>"
					SortName = "<A HREF='" & DownsysClass.SetupDir & "Sorting/Catalog" & Rs(1) & "/Sorting_Indate_Desc_1.html' title='" & Rs("SortName") & "'>" & Rs("SortName") & "</A>"
				Else
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software.asp?id=" & Rs(0) & "' title='" & Rs("SoftName") & " " & Rs("SoftVer") & "' class='TableLink'>" & DownsysClass.gotTopic(Rs("SoftName") & " " & Rs("SoftVer"), CInt(DownsysClass.mainset(23))) & "</A>"
					SortName = "<A HREF='" & DownsysClass.SetupDir & "Sorting.asp?sortid=" & Rs(1) & "' title='" & Rs("SoftName") & " " & Rs("SoftVer") & "'>" & Rs("SortName") & "</A>"
				End If
				HtmlString = HtmlString & DownsysClass.mainset(24)
				HtmlString = Replace(HtmlString, "{$SoftName}", SoftName)
				HtmlString = Replace(HtmlString, "{$SortName}", SortName)
				HtmlString = Replace(HtmlString, "{$SoftTime}", SoftTime)
				HtmlString = Replace(HtmlString, "{$SoftHits}", Rs("Hits"))
				HtmlString = Replace(HtmlString, "{$SoftDate}", SoftDate)
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rs = Nothing
		DayNewSoft = HtmlString
	End Function
	'*************************************************************
	'函数作用：推荐软件
	'*************************************************************
	Private Function CommendSoft()
		Dim Rs, SQL, HtmlString, SoftName, SortName, SoftTime, SoftDate
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.mainset(22)) & " softid,sortid,SoftName, SoftVer,SortName,SoftTime,Hits,isTop from NC_SoftInfo where isLock = 0 And isCommend = 1 order by SoftTime desc, softid desc"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "还没有推荐软件!"
		Else
			Do While Not Rs.EOF
				If Rs("SoftTime") >= Date Then
					SoftTime = "<FONT color=red>" & Month(Rs("SoftTime")) & "/" & Day(Rs("SoftTime")) & "</FONT >"
					SoftDate = "<FONT color=red>" & FormatDateTime(Rs("SoftTime"), 2) & "</FONT >"
				Else
					SoftTime = "<FONT color=#999999>" & Month(Rs("SoftTime")) & "/" & Day(Rs("SoftTime")) & "</FONT >"
					SoftDate = "<FONT color=#999999>" & FormatDateTime(Rs("SoftTime"), 2) & "</FONT >"
				End If
				If CInt(DownsysClass.Setting(5)) = 0 Then
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='" & Rs("SoftName") & " " & Rs("SoftVer") & "' class='TableLink'>" & DownsysClass.gotTopic(Rs("SoftName") & " " & Rs("SoftVer"), CInt(DownsysClass.mainset(23))) & "</A>"
					SortName = "<A HREF='" & DownsysClass.SetupDir & "Sorting/Catalog" & Rs(1) & "/Sorting_Indate_Desc_1.html' title='" & Rs("SortName") & "'>" & Rs("SortName") & "</A>"
				Else
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software.asp?id=" & Rs(0) & "' title='" & Rs("SoftName") & " " & Rs("SoftVer") & "' class='TableLink'>" & DownsysClass.gotTopic(Rs("SoftName") & " " & Rs("SoftVer"), CInt(DownsysClass.mainset(23))) & "</A>"
					SortName = "<A HREF='" & DownsysClass.SetupDir & "Sorting.asp?sortid=" & Rs(1) & "' title='" & Rs("SoftName") & " " & Rs("SoftVer") & "'>" & Rs("SortName") & "</A>"
				End If
				If Rs("isTop") = 1 Then SoftName = "<FONT color=red>" & SoftName & "</Font>"
				HtmlString = HtmlString & DownsysClass.mainset(24)
				HtmlString = Replace(HtmlString, "{$SoftName}", SoftName)
				HtmlString = Replace(HtmlString, "{$SortName}", SortName)
				HtmlString = Replace(HtmlString, "{$SoftTime}", SoftTime)
				HtmlString = Replace(HtmlString, "{$SoftHits}", Rs("Hits"))
				HtmlString = Replace(HtmlString, "{$SoftDate}", SoftDate)
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rs = Nothing
		CommendSoft = HtmlString
	End Function
	'*************************************************************
	'函数作用：站内公告
	'*************************************************************
	Private Function WebMessage(statid)
		Dim Rs, SQL, HtmlString, MsgTitle, PostTime
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.mainset(25)) & " * from NC_Message where statid in (0, " & statid & ") order by isTop desc, Postime desc, id desc"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "没有公告!"
		Else
			Do While Not Rs.EOF
				If Rs("Postime") >= Date Then
					PostTime = "<FONT color=red>" & FormatDateTime(Rs("Postime"), 2) & "</FONT >"
				Else
					PostTime = "<FONT color=#999999>" & FormatDateTime(Rs("Postime"), 2) & "</FONT >"
				End If
				MsgTitle = "<A HREF=""javascript:openScript('" & DownsysClass.SetupDir & "message.asp?id=" & Rs("id") & "',400,300)"" title='" & Rs("title") & "'>" & DownsysClass.gotTopic(Rs("title"), CInt(DownsysClass.mainset(26))) & "</A>"
				HtmlString = HtmlString & DownsysClass.mainset(27)
				HtmlString = Replace(HtmlString, "{$MsgTitle}", MsgTitle)
				HtmlString = Replace(HtmlString, "{$PostTime}", PostTime)
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rs = Nothing
		WebMessage = HtmlString
	End Function
	'*************************************************************
	'函数作用：统计信息
	'*************************************************************
	Private Function Statistics()
		Dim Rs, SQL, HtmlString
		Dim AllSoft, DayUpdateSoft, AllDownNum, AllSoftSize
		Dim AllArticle, DayUpdateArt, AllArticleHits, AllUserNum
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "Select count(SoftID) from NC_SoftInfo"
		Rs.Open SQL, Conn, 1, 1
		AllSoft = Rs(0)
		If IsNull(AllSoft) Then AllSoft = 0
		Rs.Close

		If isSqlDataBase = 1 Then
			SQL = "Select count(SoftID) from NC_SoftInfo Where datediff(d,SoftTime,GetDate())=0"
		Else
			SQL = "Select count(SoftID) from NC_SoftInfo Where softTime>=Date()"
		End If
		Rs.Open SQL, Conn, 1, 1
		DayUpdateSoft = Rs(0)
		If IsNull(DayUpdateSoft) Then DayUpdateSoft = 0
		Rs.Close

		SQL = "Select sum(Hits) from NC_SoftInfo"
		Rs.Open SQL, Conn, 1, 1
		AllDownNum = Rs(0)
		If IsNull(AllDownNum) Then AllDownNum = 0
		Rs.Close

		SQL = "Select sum(SoftSize) from NC_SoftInfo"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			AllSoftSize = 0
		Else
			If IsNull(Rs(0)) Then
				AllSoftSize = 0
			Else
				AllSoftSize = Round(Rs(0) / 1024 / 1024, 3)
			End If
		End If
		Rs.Close

		SQL = "Select count(ID) from NC_Article"
		Rs.Open SQL, Conn, 1, 1
		AllArticle = Rs(0)
		If IsNull(AllArticle) Then AllArticle = 0
		Rs.Close

		If isSqlDataBase = 1 Then
			SQL = "Select count(ID) from NC_Article Where datediff(d,infoTime,GetDate())=0"
		Else
			SQL = "Select count(ID) from NC_Article Where infoTime >= Date()"
		End If
		Rs.Open SQL, Conn, 1, 1
		DayUpdateArt = Rs(0)
		If IsNull(DayUpdateArt) Then DayUpdateArt = 0
		Rs.Close

		SQL = "Select sum(Hits) from NC_Article"
		Rs.Open SQL, Conn, 1, 1
		AllArticleHits = Rs(0)
		If IsNull(AllArticleHits) Then AllArticleHits = 0
		Rs.Close

		SQL = "Select count(userid) from NC_User"
		Rs.Open SQL, Conn, 1, 1
		AllUserNum = Rs(0)
		If IsNull(AllUserNum) Then AllUserNum = 0
		Rs.Close
		HtmlString = DownsysClass.mainset(12)
		HtmlString = Replace(HtmlString, "{$AllSoft}", AllSoft)
		HtmlString = Replace(HtmlString, "{$DayUpdateSoft}", DayUpdateSoft)
		HtmlString = Replace(HtmlString, "{$AllDownNum}", AllDownNum)
		HtmlString = Replace(HtmlString, "{$AllSoftSize}", AllSoftSize)
		HtmlString = Replace(HtmlString, "{$AllArticle}", AllArticle)
		HtmlString = Replace(HtmlString, "{$DayUpdateArt}", DayUpdateArt)
		HtmlString = Replace(HtmlString, "{$AllArticleHits}", AllArticleHits)
		HtmlString = Replace(HtmlString, "{$AllUserNum}", AllUserNum)
		Set Rs = Nothing
		Statistics = HtmlString
	End Function
	'*************************************************************
	'函数作用：友情连接
	'*************************************************************
	Public Function FriendLink()
		If CInt(DownsysClass.Setting(17)) = 1 Then
			Dim Rs, SQL, i
			Set Rs = Server.CreateObject("adodb.recordset")
			FriendLink = FriendLink & "<table align=center width=98% >"
			i = CInt(DownsysClass.TempSet(10))
			SQL = "select Linkname,readme,lurl from NC_Link where islogo=0 and isLock=0 order by linkid"
			Set Rs = Conn.Execute(SQL)
			If Not Rs.EOF And Not Rs.bof Then
				Do While Not Rs.EOF
					If i > CInt(DownsysClass.TempSet(11)) Then
						FriendLink = FriendLink & "<tr><td width=""13%"">"
						i = 1
					Else
						FriendLink = FriendLink & "<td width=""13%"">"
					End If
					FriendLink = FriendLink & "<a href=" & Rs(2) & " target=_blank title=""" & Rs(1) & """>" & Rs(0) & "</a>"
					Rs.movenext
					FriendLink = FriendLink & "</td>"
					If i = CInt(DownsysClass.TempSet(11)) Then FriendLink = FriendLink & "</tr>"
					i = i + 1
				Loop
			End If
			Rs.Close
			i = CInt(DownsysClass.TempSet(10))
			SQL = "select Linkname,readme,lurl,logo from NC_Link where islogo=1 and isLock=0 order by linkid"
			Set Rs = Conn.Execute(SQL)
			If Not Rs.EOF And Not Rs.bof Then
				FriendLink = FriendLink & "<tr><td align=center colspan=8><hr align=center size=1 color=#CECECE></td></tr>"
				Do While Not Rs.EOF
					If i > CInt(DownsysClass.TempSet(11)) Then
						FriendLink = FriendLink & "<tr><td width=""13%"">"
						i = 1
					Else
						FriendLink = FriendLink & "<td width=""13%"">"
					End If
					FriendLink = FriendLink & "<a href=" & Rs(2) & " target=_blank><img src=""" & Rs(3) & """ border=0 alt=""" & Rs(0) & "：" & Rs(1) & """ height=31 width=88></a>"
					Rs.movenext
					FriendLink = FriendLink & "</td>"
					If i = CInt(DownsysClass.TempSet(11)) Then FriendLink = FriendLink & "</tr>"
					i = i + 1
				Loop
			End If
			Rs.Close
			 Set Rs = Nothing
			If IsNull(FriendLink) Or FriendLink = "" Then FriendLink = " "
			FriendLink = FriendLink & "</table>"
		End If
	End Function
	'*************************************************************
	'函数作用：软件类型
	'*************************************************************
	Private Function CreateSoftType()
		Dim Rs, SQL, SoftTime, Title, HtmlString, SoftName, SortName, i, TypeUrl, SoftDate
		Set Rs = Server.CreateObject("adodb.recordset")
		HtmlString = HtmlString & "<TABLE width=""100%"" cellSpacing=5 cellPadding=1 border=0>" & vbCrLf
		HtmlString = HtmlString & " <TR vAlign=top>" & vbCrLf
		Dim SoftType
		SoftType = Split(DownsysClass.Setting(35), ",")
		For i = 0 To UBound(SoftType)
			HtmlString = HtmlString & "    <TD vAlign=top width=""50%"">" & vbCrLf
			SQL = "SELECT top " & CInt(DownsysClass.TempSet(5)) & " SoftID,sortid,SoftName,SoftVer,SortName,SoftType,SoftTime,Hits FROM NC_SoftInfo where SoftType='" & Trim(SoftType(i)) & "' order by SoftTime desc,SoftID desc"
			Rs.Open SQL, Conn, 1, 1
			HtmlString = HtmlString & DownsysClass.TempSet(7)
			If CInt(DownsysClass.Setting(5)) = 0 Then
				TypeUrl = DownsysClass.SetupDir & "Software/Latenew_" & i & ".html"
			Else
				TypeUrl = DownsysClass.SetupDir & "Latenew.Asp?type=" & Trim(SoftType(i)) & ""
			End If
			HtmlString = Replace(HtmlString, "{$SoftTypeUrl}", TypeUrl)
			HtmlString = Replace(HtmlString, "{$TypeName}", Trim(SoftType(i)))
			If Rs.EOF And Rs.bof Then
				HtmlString = HtmlString & "<p align=center>还没有任何软件！</p>"
			Else
				Do While Not Rs.EOF
					HtmlString = HtmlString & DownsysClass.TempSet(8)
					If Rs("SoftTime") >= Date Then
						SoftTime = "<FONT color=red>" & Month(Rs("SoftTime")) & "/" & Day(Rs("SoftTime")) & "</FONT >"
						SoftDate = "<FONT color=red>" & FormatDateTime(Rs("SoftTime"), 2) & "</FONT >"
					Else
						SoftTime = "<FONT color=#999999>" & Month(Rs("SoftTime")) & "/" & Day(Rs("SoftTime")) & "</FONT >"
						SoftDate = "<FONT color=#999999>" & FormatDateTime(Rs("SoftTime"), 2) & "</FONT >"
					End If
					If CInt(DownsysClass.Setting(5)) = 0 Then
						SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software/Catalog" & Rs("sortid") & "/" & Rs("softid") & ".html' title='软件名称: " & Rs("SoftName") & Rs("SoftVer") & "<BR>更新时间: " & Rs("SoftTime") & "<BR>下载次数: " & Rs("Hits") & "' class='TableLink'>" & DownsysClass.gotTopic(Rs("SoftName") & " " &Rs("SoftVer"), CInt(DownsysClass.TempSet(6))) & "</A>"
						SortName = "<A HREF='" & DownsysClass.SetupDir & "Sorting/Catalog" & Rs("sortid") & "/Sorting_Indate_Desc_1.html' title='" & Rs("SortName") & "'>" & Rs("SortName") & "</A>"
					Else
						SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software.asp?id=" & Rs("softid") & "' title='软件名称:" & Rs("SoftName") & " " & Rs("SoftVer") & "<BR>更新时间: " & Rs("SoftTime") & "<BR>下载次数: " & Rs("Hits") & "' class='TableLink'>" & DownsysClass.gotTopic(Rs("SoftName") & " " & Rs("SoftVer"), CInt(DownsysClass.TempSet(6))) & "</A>"
						SortName = "<A HREF='" & DownsysClass.SetupDir & "Sorting.asp?sortid=" & Rs("sortid") & "' title='" & Rs("SoftName") & " " & Rs("SoftVer") & "'>" & Rs("SortName") & "</A>"
					End If
					HtmlString = Replace(HtmlString, "{$SoftName}", SoftName)
					HtmlString = Replace(HtmlString, "{$SortName}", SortName)
					HtmlString = Replace(HtmlString, "{$SoftTime}", SoftTime)
					HtmlString = Replace(HtmlString, "{$SoftDate}", SoftDate)
					Rs.movenext
				Loop
			End If
			HtmlString = HtmlString & DownsysClass.TempSet(9)
			Rs.Close

			HtmlString = HtmlString & "</TD>" & vbCrLf
			If DownsysClass.TempSet(12) = "" Then
				If (i Mod 2) = 1 Then HtmlString = HtmlString & "</tr><tr>"
			Else
				If (i Mod CInt(DownsysClass.TempSet(12))) = (CInt(DownsysClass.TempSet(12)) - 1) Then HtmlString = HtmlString & "</tr><tr>"
			End If
		Next
		HtmlString = HtmlString & " </TR>" & vbCrLf
		HtmlString = HtmlString & "</TABLE>" & vbCrLf
		Set Rs = Nothing
		CreateSoftType = HtmlString
	End Function
	'*************************************************************
	'函数作用：图片推荐
	'*************************************************************
	Private Function SoftImage()
		Dim Rs, SQL, HtmlString, SoftName, SoftImg, i
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.TempSet(0)) & " softid,sortid,SoftName,SoftVer,SoftImg from NC_SoftInfo where isLock = 0 And SoftImg <>'' order by SoftTime desc, softid desc"
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "<img src='" & DownsysClass.SetupDir & "images/NoPic.jpg' width='" & DownsysClass.TempSet(13) & "' height='" & DownsysClass.TempSet(14) & "' border='0'>"
		Else
			HtmlString = DownsysClass.TempSet(2)
			Do While Not Rs.EOF
				If CInt(DownsysClass.Setting(5)) = 0 Then
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='" & Rs(2) & Rs(3) & "'>" & DownsysClass.gotTopic(Rs(2) & " " & Rs(3), CInt(DownsysClass.TempSet(1))) & "</A>"
					SoftImg = "<A HREF='" & DownsysClass.SetupDir & "Software/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='" & Rs(2) & Rs(3) & "'><img src='" & Rs(4) & "' width='" & DownsysClass.TempSet(13) & "' height='" & DownsysClass.TempSet(14) & "' border='0'></A>"
				Else
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software.asp?id=" & Rs(0) & "' title='" & Rs(2) & " " & Rs(3) & "'>" & DownsysClass.gotTopic(Rs(2) & " " & Rs(3), CInt(DownsysClass.TempSet(1))) & "</A>"
					SoftImg = "<A HREF='" & DownsysClass.SetupDir & "Software.asp?id=" & Rs(0) & "' title='" & Rs(2) & " " & Rs(3) & "'><img src='" & Rs(4) & "' width='" & DownsysClass.TempSet(13) & "' height='" & DownsysClass.TempSet(14) & "' border='0'></A>"
				End If
				HtmlString = HtmlString & DownsysClass.TempSet(3)
				HtmlString = Replace(HtmlString, "{$SoftImage}", SoftImg)
				HtmlString = Replace(HtmlString, "{$SoftName}", SoftName)
				Rs.movenext
			Loop
			HtmlString = HtmlString & DownsysClass.TempSet(4)
		End If
		Rs.Close
		Set Rs = Nothing
		SoftImage = HtmlString
	End Function

	Private Function CreateHtmlFile()
		DownsysClass.LoadTemplates ("index")
		Dim DownloadClass_Ads
		Set DownloadClass_Ads = New Adcolumn_Cls
		Dim temphtml, NowStats, HtmlTitle
		Dim TempTopStr, TempFootStr
		NowStats = "首页"
		HtmlTitle = "首页"
		If Len(DownsysClass.temphtml(0)) < 50 Then
			TempTopStr = DownsysClass.mainhtml(0) & DownsysClass.mainhtml(1) & DownsysClass.mainhtml(2) & DownsysClass.mainhtml(3)
		Else
			TempTopStr = DownsysClass.temphtml(0)
		End If
		If Len(DownsysClass.temphtml(5)) = 0 Then
			TempFootStr = DownsysClass.mainhtml(4)
		Else
			TempFootStr = DownsysClass.temphtml(5)
		End If
		temphtml = TempTopStr & DownsysClass.temphtml(1) & DownsysClass.temphtml(2) & DownsysClass.temphtml(3) & DownsysClass.temphtml(4) & TempFootStr
		temphtml = Replace(temphtml, "{$NavMenu}", DownsysClass.SortingMenu)
		temphtml = Replace(temphtml, "{$Width}", DownsysClass.mainset(0))
		If CInt(DownsysClass.Setting(5)) = 0 Then
			temphtml = Replace(temphtml, "{$TopMeun}", DownsysClass.mainset(9))
		Else
			temphtml = Replace(temphtml, "{$TopMeun}", DownsysClass.mainset(10))
		End If
		If CInt(DownsysClass.Setting(5)) = 1 Then
			temphtml = Replace(temphtml, "{$FootMeun}", DownsysClass.mainset(11))
		Else 
			temphtml = Replace(temphtml, "{$FootMeun}", DownsysClass.mainset(44))
		End If
		temphtml = Replace(temphtml, "{$Style_CSS}", DownsysClass.Style_CSS)
		temphtml = Replace(temphtml, "{$NowStats}", NowStats)
		temphtml = Replace(temphtml, "{$Title}", HtmlTitle)
		temphtml = Replace(temphtml, "{$NewArticle}", NewArticle)
		temphtml = Replace(temphtml, "{$BestArticle}", BestArticle)
		temphtml = Replace(temphtml, "{$DayNewSoft}", DayNewSoft)
		temphtml = Replace(temphtml, "{$CommendSoft}", CommendSoft)
		temphtml = Replace(temphtml, "{$Message}", WebMessage(1))
		temphtml = Replace(temphtml, "{$Statistic}", Statistics)
		temphtml = Replace(temphtml, "{$SoftImage}", SoftImage)
		temphtml = Replace(temphtml, "{$SoftType}", CreateSoftType)
		temphtml = Replace(temphtml, "{$FriendLink}", FriendLink)
		temphtml = Replace(temphtml, "{$Adcolumn(0)}", DownloadClass_Ads.RunScriptAds(1))
		temphtml = Replace(temphtml, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(1))
		temphtml = Replace(temphtml, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(1, 2))
		temphtml = Replace(temphtml, "{$Adcolumn(3)}", DownloadClass_Ads.AdsColumn(1, 3))
		temphtml = Replace(temphtml, "{$Adcolumn(6)}", DownloadClass_Ads.AdsColumn(1, 7))
		temphtml = Replace(temphtml, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(1))
		temphtml = Replace(temphtml, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(1))
		Set DownloadClass_Ads = Nothing
		CreateHtmlFile = temphtml
	End Function
	Public Sub Init_IndexHtml()
		Response.Buffer = True
		Dim CreateHtml, FSO, Fout
		Set NC_Admin = New Check
		NC_Admin.AdminChk = "31"
		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
		Set FSO = Server.CreateObject("ADODB.STREAM")
		CreateHtml = Server.MapPath(DownsysClass.SetupDir & DownsysClass.Setting(6))
		With FSO
			.Open
			.Charset = "GB2312"
			.WriteText CreateHtmlFile
			.SaveToFile CreateHtml,2
			.Close
		End With
		Set FSO = Nothing
		NC_Admin.Succeed_Msg ("生成下载首页成功!")
		DownsysClass.admin_footer
	End Sub

	Public Sub IndexHtml()
		Response.Buffer = True
		If CInt(DownsysClass.Setting(5)) = 0 Then
			Response.redirect (DownsysClass.SetupDir & DownsysClass.Setting(6))
		Else
			Response.Write CreateHtmlFile
		End If
	End Sub

End Class
%>
