<%
Class Create_SoftInfo_Cls
	Private Rs, SQL, Rss, SQLS, total, CreateHtml, FSO, objFSO, NewFolderPath
	Private DownloadClass_Ads
	Private HtmlTemplate
	Private SoftName
	Private SoftReadme
	Private SoftTime
	Private SoftSize
	Private MemberSoft
	Private isCommend
	Private MoneyNum
	Private AllHits
	Private Grades
	Private impower
	Private RunSystem
	Private SoftImg
	Private sortid
	Private SortName
	Private depth
	Private ParentID
	Private strParent
	Private PreviewImg
	Private PreviewPic
	Private strDecode
	Private Homepage
	Private SoftType
	Private Language
	Private Contact
	Private softid
	Private HtmlTempStr
	Private NowStats
	Private HtmlTitle
	Private TempTopStr
	Private TempFootStr
	Private Style_CSS
	Private datDate
	Private startime
	Private i
	Private j, k
	Private Rs1
	Private p
	Private d
	Private maxperpage
	Private SoftTotal
	Private TotalPage
	Private SoftNumber
	Private totalnumber
	Private action
	Private Re
	Private Sub Class_Initialize()
	    On Error Resume Next
		Set Rs = Server.CreateObject("ADODB.Recordset")
		DownsysClass.LoadTemplates ("softinfo")
		Set DownloadClass_Ads = New Adcolumn_Cls
	End Sub

	Private Sub Class_Terminate()
		If IsObject(Conn) Then
			Conn.Close
			Set Conn = Nothing
		End If
		If IsObject(DownloadClass_Ads) Then
			Set DownloadClass_Ads = Nothing
		End If
	End Sub
	'*************************************************************
	'函数作用：生成全部软件
	'*************************************************************
	Public Sub CreateSoftInfos()
		DownsysClass.admin_header
		Server.ScriptTimeout = 99999
		Set NC_Admin = New Check
		NC_Admin.AdminChk = "32"
		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
		Response.Write "<table width=""400"" border=""0"" cellspacing=""1"" cellpadding=""1"">" & vbCrLf
		Response.Write "<tr> " & vbCrLf
		Response.Write "<td align=center> <span id=txt2 name=txt2 style=""font-size:9pt"">正在生成文件请耐心等待……</span>   <span id=txt3 name=txt3 style=""font-size:9pt""></span></td></tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf
		Response.Flush
		Set Rss = Server.CreateObject("adodb.recordset")
		SQLs = "select softid from [NC_SoftInfo] where isLock=0"
		Rss.Open SQLs, Conn, 1, 1
		total = Rss.recordcount
		If total = 0 Then
			NC_Admin.Error_Msg ("<script>txt2.innerHTML="""";txt3.innerHTML="""";</script> 没有你选择范围内文章信息页可生成！")
			DownsysClass.admin_footer
			Response.End
		End If
		Rss.MoveFiRst
		k = 1
		Do While Not Rss.EOF
			softid = Rss("softid")
			CreateSoftInfo(softid) '生成软件信息html页
			Response.Write "<script>txt2.innerHTML=""生成进度:" & FormatNumber(k / total * 100, 2, -1) & "%"";" & vbCrLf
			Response.Write "txt3.innerHTML=""共有 <B><font color=RED>" & total & "</font></B> 个 　正在生成第 " & k & " 个"";</script>" & vbCrLf
			Response.Flush
			Rss.movenext
			DownsysClass.SqlQueryNum = DownsysClass.SqlQueryNum + 1
			k = k + 1
		Loop
		Rss.Close
		Set Rss = Nothing
		Response.Write "<script>txt2.innerHTML="""";txt3.innerHTML="""";</script>"
		NC_Admin.Succeed_Msg ("共有 <B><font color=RED>" & total & "</font></B> 个软件信息页面生成完毕！")
		DownsysClass.admin_footer
	End Sub
	'*************************************************************
	'函数作用：生成软件
	'*************************************************************
	Public Sub CreateSoftInfo(softid)
		On Error Resume Next
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select * from NC_SoftInfo where softid = " & softid
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			Response.Write "Sorry！还没有找到任何软件！"
			Exit Sub
		Else
			If CInt(Rs("isMember")) = 0 Then
				MemberSoft = ""
			Else
				MemberSoft = DownsysClass.TempSet(3)
			End If
			SoftName = Trim(Rs("SoftName")) & " " & Trim(Rs("SoftVer"))
			If Rs("SoftSize") > 1024 Then
				SoftSize = Round(Rs("SoftSize") / 1024, 2) & " MB"
			Else
				SoftSize = Rs("SoftSize") & " KB"
			End If
			If Rs("MoneyNum") = 0 Or Len(Rs("MoneyNum")) = 0 Then
				MoneyNum = ""
			Else
				MoneyNum = Rs("MoneyNum")
			End If
			sortid = Rs("sortid")
			SoftReadme = Rs("content")
			Set Re = New RegExp
			Re.IgnoreCase =true
			Re.Global=True
			If CInt(DownsysClass.Setting(44)) = 1 Then
				Re.Pattern="\[br\]"
				SoftReadme = Re.Replace(SoftReadme,"<BR>")
				Re.Pattern="\[align=right\]"
				SoftReadme = Re.Replace(SoftReadme,"<div align=right>")
				Re.Pattern="\[\/align\]"
				SoftReadme = Re.Replace(SoftReadme,"</div>")
			Else
				Re.Pattern="\[br\]"
				SoftReadme = Re.Replace(SoftReadme,"")
				Re.Pattern="\[align=right\](.*)\[\/align\]"
				SoftReadme = Re.Replace(SoftReadme,"")
			End If
			Set Re = Nothing
			SoftTime = Rs("SoftTime")
			AllHits = Rs("Hits")
			Grades = Rs("Grades")
			impower = Rs("impower")
			RunSystem = Rs("RunSystem")
			SoftType = Trim(Rs("softType"))
			Language = Trim(Rs("Language"))
			If Not IsNull(Trim(Rs("softimg"))) And Trim(Rs("softimg")) <> "" Then
				SoftImg = "<img src='" & Rs("softimg") & "' width='" & DownsysClass.TempSet(13) & "' height='" & DownsysClass.TempSet(14) & "' border='0'>"
			Else
				SoftImg = DownloadClass_Ads.AdsColumn(3, 7)
			End If
			If Not IsNull(Trim(Rs("PreviewImg"))) And Trim(Rs("PreviewImg")) <> "" Then
				PreviewImg = "<a href='" & DownsysClass.SetupDir & "PreviewImg.asp?SoftID=" & softid & "' target='_blank'><img src='" & DownsysClass.SetupDir & "images/screen.gif' border='0' align='absmiddle' alt='点击查看大图：<br> <img src="& Trim(Rs("PreviewImg")) &" border=1 width=180 height=120>'>"
				PreviewPic = "<img src='"& Trim(Rs("PreviewImg")) &"' border='0'>"
			Else
				PreviewImg = "没有预览图片"
				PreviewPic = "没有预览图片"
			End If
			If Not IsNull(Trim(Rs("Decode"))) And Trim(Rs("Decode")) <> "" Then
				strDecode = "<font color=red>" & Trim(Rs("Decode")) & "</font>"
			Else
				strDecode = "默认密码:<font color=red>" & DownsysClass.Setting(37) & "</font>"
			End If
			If Len(Rs("Contact")) = 0 Then
				Contact = DownsysClass.TempSet(16)
			Else
				Contact = DownsysClass.TempSet(17)
				Contact = Replace(Contact, "{$SoftName}", Trim(Rs("SoftName")))
				Contact = Replace(Contact, "{$ContactSite}", Trim(Rs("Contact")))
			End If
			If Len(Rs("Homepage")) = 0 Then
				Homepage = DownsysClass.TempSet(4)
			Else
				Homepage = DownsysClass.TempSet(15)
				Homepage = Replace(Homepage, "{$PageUrl}", Trim(Rs("Homepage")))
			End If
		End If
		Rs.Close
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select sortid,rootid,sortname,depth,ParentID,strParent from [NC_SoftSort] where sortid = " & sortid
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			Response.Write "Sorry！没有找到任何软件信息。或者您选择了错误的系统参数!"
			Response.End
		Else
			SortName = Rs("sortname")
			sortid = Rs("sortid")
			depth = Rs("depth")
			ParentID = Rs("ParentID")
			strParent = Rs("strParent")
		End If
		Rs.Close
		NowStats = NowStation(sortid, SortName, ParentID, strParent) & "→" & SoftName
		HtmlTitle = SoftName
		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(4)) = 0 Then
			TempFootStr = DownsysClass.mainhtml(4)
		Else
			TempFootStr = DownsysClass.temphtml(4)
		End If
		Style_CSS = Replace(Replace(DownsysClass.Style_CSS, "{$SetupDir}", DownsysClass.SetupDir), "{$PicUrl}", DownsysClass.TempDir)
		HtmlTempStr = TempTopStr & DownsysClass.temphtml(1) & DownsysClass.temphtml(2) & DownsysClass.temphtml(3) & TempFootStr
		HtmlTempStr = Replace(HtmlTempStr, "{$NavMenu}", DownsysClass.SortingMenu)
		HtmlTempStr = Replace(HtmlTempStr, "{$Width}", DownsysClass.mainset(0))
		HtmlTempStr = Replace(HtmlTempStr, "{$Style_CSS}", Style_CSS)
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(9))
		HtmlTempStr = Replace(HtmlTempStr, "{$FootMeun}", DownsysClass.mainset(44))
		HtmlTempStr = Replace(HtmlTempStr, "{$NowStats}", NowStats)
		HtmlTempStr = Replace(HtmlTempStr, "{$Title}", HtmlTitle)
		HtmlTempStr = Replace(HtmlTempStr, "{$SoftName}", SoftName)
		HtmlTempStr = Replace(HtmlTempStr, "{$SoftID}", softid)
		HtmlTempStr = Replace(HtmlTempStr, "{$SortID}", sortid)
		HtmlTempStr = Replace(HtmlTempStr, "{$SortName}", SortName)
		HtmlTempStr = Replace(HtmlTempStr, "{$SoftReadme}", SoftReadme)
		HtmlTempStr = Replace(HtmlTempStr, "{$SoftTime}", SoftTime)
		HtmlTempStr = Replace(HtmlTempStr, "{$SoftSize}", SoftSize)
		HtmlTempStr = Replace(HtmlTempStr, "{$Hits}", AllHits)
		HtmlTempStr = Replace(HtmlTempStr, "{$RunSystem}", RunSystem)
		HtmlTempStr = Replace(HtmlTempStr, "{$Impower}", impower)
		HtmlTempStr = Replace(HtmlTempStr, "{$Grades}", Grades)
		HtmlTempStr = Replace(HtmlTempStr, "{$SoftPic}", SoftImg)
		HtmlTempStr = Replace(HtmlTempStr, "{$MoneyNum}", MoneyNum)
		HtmlTempStr = Replace(HtmlTempStr, "{$MemberSoft}", MemberSoft)
		HtmlTempStr = Replace(HtmlTempStr, "{$Commend}", isCommend)
		HtmlTempStr = Replace(HtmlTempStr, "{$Decode}", strDecode)
		HtmlTempStr = Replace(HtmlTempStr, "{$PreviewImg}", PreviewImg)
		HtmlTempStr = Replace(HtmlTempStr, "{$PreviewPic}", PreviewPic)
		HtmlTempStr = Replace(HtmlTempStr, "{$SoftType}", SoftType)
		HtmlTempStr = Replace(HtmlTempStr, "{$Language}", Language)
		HtmlTempStr = Replace(HtmlTempStr, "{$Contact}", Contact)
		HtmlTempStr = Replace(HtmlTempStr, "{$HomePage}", Homepage)
		HtmlTempStr = Replace(HtmlTempStr, "{$DownLoadUrl}", DownLoadUrl(softid))
		HtmlTempStr = Replace(HtmlTempStr, "{$EssayInfo}", SoftEssayInfo(softid))
		HtmlTempStr = Replace(HtmlTempStr, "{$KeySoft}", GetKeySoftware(SoftName, softid))
		HtmlTempStr = Replace(HtmlTempStr, "{$KeyArticle}", GetKeyArticle(SoftName))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(0)}", DownloadClass_Ads.RunScriptAds(3))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(3))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(3, 2))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(3)}", DownloadClass_Ads.AdsColumn(3, 3))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(6)}", DownloadClass_Ads.AdsColumn(3, 7))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(7)}", DownloadClass_Ads.AdsColumn(3, 8))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(8)}", DownloadClass_Ads.AdsColumn(3, 9))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(9)}", DownloadClass_Ads.AdsColumn(3, 10))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(3))
		HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(3))
		Set Rs = Nothing
		NewFolderPath = Server.MapPath(DownsysClass.SetupDir & "Software/Catalog" & sortid)
		Set objFSO = Server.CreateObject(DownsysClass.Script_FSO)
		If Not objFSO.FolderExists(NewFolderPath) Then
			objFSO.CreateFolder (NewFolderPath)
		End If
		objFSO.Close
		Set objFSO = Nothing
		Set FSO = Server.CreateObject("ADODB.STREAM")
		CreateHtml = Server.MapPath(DownsysClass.SetupDir & "Software/Catalog" & sortid & "/" & softid & ".html")
		With FSO
			.Open
			.Charset = "GB2312"
			.WriteText HtmlTempStr
			.SaveToFile CreateHtml,2
			.Close
		End With
		Set FSO = Nothing
    End Sub
	'*************************************************************
	'函数作用：删除软件
	'*************************************************************
	Public Sub DelSoftInfo(softid)
		Dim FilePath
		Set NC_Admin = New Check
		NC_Admin.Check
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select * from NC_SoftInfo where softid = " & softid
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			Response.Write "Sorry！还没有找到任何软件！"
			Exit Sub
		Else
			sortid = Rs("sortid")
		End If
		If CInt(DownsysClass.Setting(5)) = 0 Then
			FilePath = Server.MapPath(DownsysClass.SetupDir & "Software/Catalog" & sortid & "/" & softid & ".html")
			Set FSO = Server.CreateObject(DownsysClass.Script_FSO)
			If FSO.FileExists(FilePath) Then
				FSO.DeleteFile FilePath
			End If
			Set FSO = Nothing
		End If
	End Sub
	'*************************************************************
	'函数作用：当前位置
	'*************************************************************
	Private Function NowStation(sortid, SortName, ParentID, strParent)
		Dim Rs
		Dim SQL
		Dim HtmlString
		Set Rs = Server.CreateObject("adodb.recordset")
		If ParentID <> 0 And Len(strParent) <> 0 Then
			SQL = "select sortid,sortname from [NC_SoftSort] where sortid in(" & strParent & ")"
			Rs.Open SQL, Conn, 1, 1
			If Not (Rs.EOF And Rs.bof) Then
				Do While Not Rs.EOF
					If CInt(DownsysClass.Setting(5)) = 0 Then
						HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting/Catalog" & Rs(0) & "/Sorting_Indate_Desc_1.html'>" & Rs(1) & "</a>→"
					Else
						HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting.asp?sortid=" & Rs(0) & "'>" & Rs(1) & "</a>→"
					End If
					Rs.movenext
				Loop
			End If
			Rs.Close
			Set Rs = Nothing
		End If
		If CInt(DownsysClass.Setting(5)) = 0 Then
			HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting/Catalog" & sortid & "/Sorting_Indate_Desc_1.html'>" & SortName & "</a>"
		Else
			HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting.asp?sortid=" & sortid & "'>" & SortName & "</a>"
		End If
		NowStation = HtmlString
	End Function
	'*************************************************************
	'函数作用：下载服务器
	'*************************************************************
	Private Function DownLoadUrl(softid)
		Dim Rs, Rss
		Dim SQL
		Dim HtmlString
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Set Rss = Server.CreateObject("ADODB.Recordset")
		SQL = "select  * from  NC_SoftSite where SoftID=" & softid
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			HtmlString = "还没有添加下载地址!"
		Else
			Do While Not Rs.EOF
				If Rs("serverid") = 0 Then
					HtmlString = HtmlString & "&nbsp;&nbsp;<img src='" & DownsysClass.SetupDir & "images/download.gif' border=0> <a href='" & DownsysClass.SetupDir & "down.asp?id=" & Rs("id") & "&downid=" & Rs("serverid") & "'>" & Trim(Rs("SiteName")) & "</a><BR>"
				Else
					SQL = "select  * from NC_ServerSite where depth = 1 And rootid = " & Rs("serverid") & " order by orders"
					Rss.Open SQL, Conn, 1, 1
					If Rss.bof And Rss.EOF Then
						HtmlString = HtmlString & "还没有添加下载服务器!"
					Else
						Do While Not Rss.EOF
							HtmlString = HtmlString & "&nbsp;&nbsp;<img src='" & DownsysClass.SetupDir & "images/download.gif' border=0> <a href='" & DownsysClass.SetupDir & "down.asp?id=" & Rs("id") & "&downid=" & Rss("serverid") & "'>" & Trim(Rss("ServerName")) & "</a><BR>"
							Rss.movenext
						Loop
					End If
					Rss.Close
				End If
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rss = Nothing
		Set Rs = Nothing
		DownLoadUrl = HtmlString
	End Function
	'*************************************************************
	'函数作用：软件评论信息
	'*************************************************************
	Private Function SoftEssayInfo(softid)
		Dim Rss
		Dim SQL
		Dim HtmlString
		Set Rss = Server.CreateObject("ADODB.Recordset")
		SQL = "select top " & CInt(DownsysClass.TempSet(5)) & " * from NC_SoftEssay where softid=" & softid & " order by ID desc"
		Rss.Open SQL, Conn, 1, 1
		If Rss.bof And Rss.EOF Then
			HtmlString = ""
		Else
			Do While Not Rss.EOF
				HtmlString = HtmlString & "用户名：" & Rss("username") & " 　参与时间：" & Rss("postime") & "<BR>"
				HtmlString = HtmlString & "　 · " & DownsysClass.gotTopic(Rss("content"), CInt(DownsysClass.TempSet(6))) & "<BR>"
				Rss.movenext
			Loop
		End If
		Rss.Close
		Set Rss = Nothing
		SoftEssayInfo = HtmlString
	End Function
	'*************************************************************
	'函数作用：相关软件
	'*************************************************************
	Private Function GetKeySoftware(Keys, keyid)
		Dim Rss, SQL, HtmlString, SoftName, SoftTime
		Set Rss = Server.CreateObject("adodb.recordset")
		SQL = "select top " & CInt(DownsysClass.TempSet(8)) & " SoftID,sortid,SoftName,SoftVer,Hits,SoftTime,islock from NC_SoftInfo where SoftName like '%" & Left((Keys), 4) & "%' and  SoftID <> " & keyid & " and islock = 0 "
		Rss.Open SQL, Conn, 1, 1
		If Not (Rss.EOF And Rss.bof) Then
			Do While Not Rss.EOF
				HtmlString = HtmlString & DownsysClass.TempSet(10)
				If CInt(DownsysClass.Setting(5)) = 0 Then
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software/Catalog" & Rss(1) & "/" & Rss(0) & ".html'>" & DownsysClass.gotTopic(Rss(2) & " " & Rss(3), CInt(DownsysClass.TempSet(9))) & "</A>"
				Else
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software.asp?id=" & Rss(0) & "'>" & DownsysClass.gotTopic(Rss(2) & " " & Rss(3), CInt(DownsysClass.TempSet(9))) & "</A>"
				End If
				'SoftTime = Month(Rss("SoftTime")) & "/" & Day(Rss("SoftTime"))
				'HtmlString = Replace(HtmlString, "{$SoftHits}", Rss("Hits"))
				'HtmlString = Replace(HtmlString, "{$SoftTime}", SoftTime)
				HtmlString = Replace(HtmlString, "{$SoftName}", SoftName)
				Rss.movenext
			Loop
		End If
		Rss.Close
		 Set Rss = Nothing
		GetKeySoftware = HtmlString
	End Function
	'*************************************************************
	'函数作用：相关文章
	'*************************************************************
	Private Function GetKeyArticle(Keys)
		Dim Rss, SQL, HtmlString, Topic, InfoTime
		Set Rss = Server.CreateObject("adodb.recordset")
		SQL = "select top " & CInt(DownsysClass.TempSet(8)) & " id,classid,title,Hits,InfoTime,islock from NC_Article where title like '%" & Left((Keys), 4) & "%' and islock = 0"
		Rss.Open SQL, Conn, 1, 1
		If Not (Rss.EOF And Rss.bof) Then
			Do While Not Rss.EOF
				HtmlString = HtmlString & DownsysClass.TempSet(11)
				If CInt(DownsysClass.Setting(5)) = 0 Then
					Topic = "<A HREF='" & DownsysClass.SetupDir & "Article/Catalog" & Rss("classid") & "/" & Rss("id") & ".html' >" & DownsysClass.gotTopic(Rss("title"), CInt(DownsysClass.TempSet(9))) & "</A>"
				Else
					Topic = "<A HREF='" & DownsysClass.SetupDir & "Article.asp?id=" & Rss("id") & "' >" & DownsysClass.gotTopic(Rss("title"), CInt(DownsysClass.tempset(9))) & "</A>"
				End If
				'InfoTime = Month(Rss("InfoTime")) & "/" & Day(Rss("InfoTime"))
				'HtmlString = Replace(HtmlString, "{$Hits}", Rss("Hits"))
				'HtmlString = Replace(HtmlString, "{$InfoTime}", InfoTime)
				HtmlString = Replace(HtmlString, "{$Topic}", Topic)
				Rss.movenext
			Loop
		End If
		Rss.Close
		Set Rss = Nothing
		GetKeyArticle = HtmlString
	End Function

End Class
%>