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

Class Create_Article_Cls
	Private Rs, SQL
	Private ArticleID, classid, rootid, depth, ClassName, ParentID, strParent, Child
	Private DownloadClass_Ads, Source, Writer, AllHits, Topic, Content
	Private action
	Private Rs1, i, j
	Private ArticleTypeSrt
	Private NowStats
	Private HtmlTitle
	Private Style_CSS
	Private HtmlTempStr
	Private Title, InfoTime
	Private stype, ArtType, ii
	Private TempString
	Private HtmlTemplate

	Private Sub Class_Initialize()
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Set DownloadClass_Ads = New Adcolumn_Cls
		DownsysClass.LoadTemplates ("article")
	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 GetArticle()
		If Not IsNumeric(Request("id")) And Request("id") <> "" Then
			Response.Write "错误的系统参数!ID必须是数字"
			Response.End
		End If
		If Request("id") = "0" Or Request("id") = "" Then
			Response.Write "<BR><BR><BR>Sorry！错误的系统参数,请选择正确的连接方式。"
			Response.End
		Else
			ArticleID = CLng(Request("id"))
		End If
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select * from NC_Article where isLock=0 and id = " & ArticleID
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			Response.Write "<p align=center>还没有找到相关文章！</p>"
			Exit Sub
		Else
			Topic = Rs("Title")
			Content = Rs("Content")
			InfoTime = Rs("InfoTime")
			Writer = Rs("Writer")
			Source = Rs("Source")
			AllHits = Rs("Hits")
			classid = Rs("classid")
		End If
		Rs.Close
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select classid,rootid,ClassName,depth,ParentID,strParent from [NC_Class] where classid = " & classid
		Rs.Open SQL, Conn, 1, 1
		If Rs.bof And Rs.EOF Then
			Response.Write "Sorry！没有找到任何软件信息。或者您选择了错误的系统参数!"
			Exit Sub
		Else
			ClassName = Rs("ClassName")
			classid = Rs("classid")
			depth = Rs("depth")
			ParentID = Rs("ParentID")
			strParent = Rs("strParent")
		End If
		Rs.Close
		Dim temphtml, NowStats, HtmlTitle, ArticleIndex
		Dim TempTopStr, TempFootStr, Style_CSS
		ArticleIndex = "<A HREF='" & DownsysClass.SetupDir & "Article_Index.Asp'>" & DownsysClass.TempSet(7) & "</A>→"
		NowStats = ArticleIndex & NowStation(classid, ClassName, ParentID, strParent) & "→" & Topic
		HtmlTitle = Topic
		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(3)) = 0 Then
			TempFootStr = DownsysClass.mainhtml(4)
		Else
			TempFootStr = DownsysClass.temphtml(3)
		End If
		temphtml = TempTopStr & DownsysClass.temphtml(1) & DownsysClass.temphtml(2) & DownsysClass.temphtml(3) & TempFootStr
		temphtml = Replace(temphtml, "{$TopMeun}", DownsysClass.mainset(10))
		temphtml = Replace(temphtml, "{$Width}", DownsysClass.mainset(0))
		temphtml = Replace(temphtml, "{$FootMeun}", DownsysClass.mainset(11))
		temphtml = Replace(temphtml, "{$NavMenu}", DownsysClass.ClassMenu)
		temphtml = Replace(temphtml, "{$Style_CSS}", DownsysClass.Style_CSS)
		temphtml = Replace(temphtml, "{$NowStats}", NowStats)
		temphtml = Replace(temphtml, "{$Title}", HtmlTitle)
		temphtml = Replace(temphtml, "{$ClassID}", classid)
		temphtml = Replace(temphtml, "{$ArticleID}", articleid)
		temphtml = Replace(temphtml, "{$Topic}", Topic)
		temphtml = Replace(temphtml, "{$Content}", Content)
		temphtml = Replace(temphtml, "{$InfoTime}", InfoTime)
		temphtml = Replace(temphtml, "{$AllHits}", AllHits)
		temphtml = Replace(temphtml, "{$Writer}", Writer)
		temphtml = Replace(temphtml, "{$Source}", Source)
		'temphtml = Replace(temphtml, "{$HotArticle}", GetHotArticle)
		temphtml = Replace(temphtml, "{$KeyArticle}", GetKeyArticle(Topic, articleid))
		temphtml = Replace(temphtml, "{$KeySoft}", GetKeySoftware(Topic))
		temphtml = Replace(temphtml, "{$FormerArticle}", FormerArticle(articleid))
		temphtml = Replace(temphtml, "{$NextArticle}", NextArticle(articleid))
		temphtml = Replace(temphtml, "{$Adcolumn(0)}", DownloadClass_Ads.RunScriptAds(6))
		temphtml = Replace(temphtml, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(6))
		temphtml = Replace(temphtml, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(6, 2))
		temphtml = Replace(temphtml, "{$Adcolumn(3)}", DownloadClass_Ads.AdsColumn1(6, 3))
		temphtml = Replace(temphtml, "{$Adcolumn(6)}", DownloadClass_Ads.AdsColumn(6, 7))
		temphtml = Replace(temphtml, "{$Adcolumn(7)}", DownloadClass_Ads.AdsColumn(6, 8))
		temphtml = Replace(temphtml, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(6))
		temphtml = Replace(temphtml, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(6))
		HtmlTemplate = temphtml
		Set Rs = Nothing
		Response.Write HtmlTemplate
	End Sub
	'*************************************************************
	'函数作用：当前位置
	'*************************************************************
	Private Function NowStation(classid, ClassName, ParentID, strParent)
		Dim Rs, SQL, HtmlString
		Set Rs = Server.CreateObject("adodb.recordset")
		If ParentID <> 0 And Len(strParent) <> 0 Then
			SQL = "select classid,ClassName from [NC_Class] where classid 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 & "Listing/Catalog" & Rs(0) & "/Listing_indate_Desc_1.html'>" & Rs(1) & "</a>→"
					Else
						HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Listing.Asp?classid=" & 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 & "Listing/Catalog" & classid & "/Listing_indate_Desc_1.html'>" & ClassName & "</a>"
		Else
			HtmlString = HtmlString & "<a href='" & DownsysClass.SetupDir & "Listing.Asp?classid=" & classid & "'>" & ClassName & "</a>"
		End If
		NowStation = HtmlString
	End Function
	'*************************************************************
	'函数作用：相关文章
	'*************************************************************
	Private Function GetKeyArticle(Keys, keyid)
		Dim Rss, SQL, HtmlString, Topic, InfoTime
		Set Rss = Server.CreateObject("adodb.recordset")
		SQL = "select top " & CInt(DownsysClass.TempSet(0)) & " id,classid,title,Hits,InfoTime from NC_Article where title like '%" & Left((Keys), 4) & "%' and  ID <> " & keyid
		Rss.Open SQL, Conn, 1, 1
		If Not (Rss.EOF And Rss.bof) Then
			Do While Not Rss.EOF
				HtmlString = HtmlString & DownsysClass.TempSet(2)
				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(1))) & "</A>"
				Else
					Topic = "<A HREF='" & DownsysClass.SetupDir & "Article.asp?id=" & Rss("id") & "'>" & DownsysClass.gotTopic(Rss("Title"), CInt(DownsysClass.TempSet(1))) & "</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

	Private Function FormerArticle(articleid)
		Dim Rss, SQL, HtmlString
		Set Rss = Server.CreateObject("adodb.recordset")
		SQL = "select id,classid,title from NC_Article where id = " & articleid - 1
		Rss.Open SQL, Conn, 1, 1
		If Rss.EOF And Rss.bof Then
			HtmlString = DownsysClass.TempSet(3)
		Else
			If CInt(DownsysClass.Setting(5)) = 0 Then
				HtmlString = "<a href=" & DownsysClass.SetupDir & "Article/Catalog" & Rss("classid") & "/" & Rss("id") & ".html>" & Rss("title") & "</a>"
			Else
				HtmlString = "<a href=" & DownsysClass.SetupDir & "Article.Asp?id=" & Rss("id") & ">" & Rss("title") & "</a>"
			End If
		End If
		Rss.Close
		Set Rss = Nothing
		FormerArticle = HtmlString
	End Function

	Private Function NextArticle(articleid)
		Dim Rss, SQL, HtmlString
		Set Rss = Server.CreateObject("adodb.recordset")
		SQL = "select id,classid,title from NC_Article where id = " & articleid + 1
		Rss.Open SQL, Conn, 1, 1
		If Rss.EOF And Rss.bof Then
			HtmlString = DownsysClass.TempSet(3)
		Else
			If CInt(DownsysClass.Setting(5)) = 0 Then
				HtmlString = "<a href=" & DownsysClass.SetupDir & "Article/Catalog" & Rss("classid") & "/" & Rss("id") & ".html>" & Rss("title") & "</a>"
			Else
				HtmlString = "<a href=" & DownsysClass.SetupDir & "Article.Asp?id=" & Rss("id") & ">" & Rss("title") & "</a>"
			End If
		End If
		Rss.Close
		Set Rss = Nothing
		NextArticle = HtmlString
	End Function


	'*************************************************************
	'函数作用：相关软件
	'*************************************************************
	Private Function GetKeySoftware(Keys)
		Dim Rss, SQL, HtmlString, SoftName, SoftTime
		Set Rss = Server.CreateObject("adodb.recordset")
		SQL = "select top " & CInt(DownsysClass.TempSet(0)) & " SoftID,sortid,SoftName,SoftVer from NC_SoftInfo where SoftName 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(6)
				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(1))) & "</A>"
				Else
					SoftName = "<A HREF='" & DownsysClass.SetupDir & "Software.asp?id=" & Rss(0) & "'>" & DownsysClass.gotTopic(Rss(2) & " " & Rss(3), CInt(DownsysClass.TempSet(1))) & "</A>"
				End If
				HtmlString = Replace(HtmlString,"{$SoftName}",SoftName)
				Rss.movenext
			Loop
		End If
		Rss.Close
		Set Rss = Nothing
		GetKeySoftware = HtmlString
	End Function
	'*************************************************************

	'*************************************************************
	'函数作用：热门文章
	'*************************************************************
	Private Function GetHotArticle()
		Dim Rs, SQL, HtmlString, HotTopic, ClassName, InfoTime
		Set Rs = Server.CreateObject("adodb.recordset")
		SQL = "select Top " & CInt(DownsysClass.TempSet(4)) & " id,classid,Title, ClassName,InfoTime,Hits from NC_Article where isLock = 0 order by Hits 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 >"
				Else
					InfoTime = "<FONT color=#999999>" & Month(Rs("InfoTime")) & "/" & Day(Rs("InfoTime")) & "</FONT >"
				End If
				If CInt(DownsysClass.Setting(5)) = 0 Then
					HotTopic = "<A HREF='" & DownsysClass.SetupDir & "Article/Catalog" & Rs(1) & "/" & Rs(0) & ".html' title='" & Rs(2) & "' class='TableLink'>" & DownsysClass.gotTopic(Rs(2), CInt(DownsysClass.TempSet(5))) & "</A>"
				Else
					HotTopic = "<A HREF='" & DownsysClass.SetupDir & "Article.asp?id=" & Rs(0) & "' title='" & Rs(2) & "' class='TableLink'>" & DownsysClass.gotTopic(Rs(2), CInt(DownsysClass.TempSet(5))) & "</A>"
				End If
				HtmlString = HtmlString & DownsysClass.TempSet(6)
				HtmlString = Replace(HtmlString, "{$HotTopic}", HotTopic)
				HtmlString = Replace(HtmlString, "{$InfoTime}", InfoTime)
				HtmlString = Replace(HtmlString, "{$ArticleHits}", Rs("Hits"))
				Rs.movenext
			Loop
		End If
		Rs.Close
		Set Rs = Nothing
		GetHotArticle = HtmlString
	End Function

End Class
%>
