<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<%
Dim DownloadClass
Set DownloadClass = New Create_SoftInfo_Cls
DownloadClass.CreateSoftInfo
Set DownloadClass = Nothing
CloseConn

Class Create_SoftInfo_Cls
	Private Rs, SQL
	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
	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 CreateSoftInfo()
		If Not IsNumeric(Request("id")) And Request("id") <> "" Then
			Response.Write "Sorry！错误的系统参数!ID必须是数字"
			Response.End
		End If
		If Request("id") = 0 Or Request("id") = "" Then
			Response.Write "Sorry！错误的系统参数,请选择正确的连接方式。"
			Response.End
		Else
			softid = CLng(Request("id"))
		End If
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select * from NC_SoftInfo where isLock=0 and softid = " & softid
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			Response.Write "Sorry！还没有找到任何软件！"
			Exit Sub
		Else
			MemberSoft = ""
			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(10))
		HtmlTempStr = Replace(HtmlTempStr, "{$FootMeun}", DownsysClass.mainset(11))
		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
		Response.Write HtmlTempStr
	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
					HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Sorting.asp?sortid=" & Rs(0) & "'>" & Rs(1) & "</a>→"
					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 Rs1 = Server.CreateObject("ADODB.Recordset")
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Set Rss = Server.CreateObject("ADODB.Recordset")
		SQL = "select isMember from NC_SoftInfo where isLock=0 and softid = " & softid
		Rs1.Open SQL, Conn, 1, 1
 		If Rs1.bof And Rs1.EOF Then
				HtmlString = "还没有添加下载地址!"
 		Else
	 		If CInt(Rs1("isMember")) = 0 Then		
				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='"& Trim(Rs("downsite"))&"'>" & 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 & ""(rs.fields.item("downsite")) & "'>"& Trim(Rss("ServerName")) & "</a><BR>"
								Rss.movenext
							Loop
						End If
						Rss.Close
					End If
					Rs.movenext
				Loop
				End If
		Else 
	   		If DownsysClass.memberName = Empty Then
	   			HtmlString = DownsysClass.TempSet(3)
	   		Else 
				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 &""(rs.fields.item("downsite")) & "'>" & 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 & ""(rs.fields.item("downsite")) & "'>" & 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
	    		End if
			End If 
		End if
		Rs1.Close
		Set Rs1 = 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 from NC_SoftInfo where SoftName like '%" & Left((Keys), 4) & "%' and  SoftID <> " & keyid
		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 from NC_Article where title like '%" & Left((Keys), 4) & "%' "
		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
%>