<!--#include file="Conn.asp"-->
<!--#include file="Inc/Cl_ClsSysTem.asp" -->
<%
Dim FoundErr, ErrMsg, sRssBody
Dim sqlInfo, TotalPut, i
Dim SystemTopDir, SystemDir
Dim sTitle, sDeScriptIon, sLogo
Dim ChannelID, sClassID, TopNum, sChannelName
ChannelID	= Cl.ChkClng(request("ChannelID"))
Cl.GetWeb_Setting()
Cl.GetWeb_CSetting(ChannelID)
SystemDir	= "http://"&Cl.ServerName & Cl.WebDir
sClassID	= Cl.ChkClng(request("ClassID"))
TopNum		= Cl.ChkClng(Request("Num"))
sTitle		= Cl.Web_Info(1)
sDeScriptIon= Replace(Cl.Web_Info(2),"|",",")
sLogo		= Replace(Cl.LoGo,"{%webdir%}",SystemDir)

RssBody
ShowRss

Sub ShowRss()
	Response.Expires=0
	Response.ContentType="application/xml"
	Response.Write "<?xml version=""1.0"" encoding=""GB2312""?>"
	Response.Write "<rss version=""2.0"">"
	Response.Write "<channel>"
	Response.Write "<title>" & Cl.NoHtml(sTitle) & "</title>"
	Response.Write "<description>" & sDeScriptIon & "</description> "
	Response.Write "<link>" & Cl.Web_Info(4) & "</link>"
	Response.Write "<generator>Rss Generator By Aspoo.Cn</generator>"
	Response.Write "<language>zh-cn</language>"
	Response.Write "<copyright>Copyright 2004-2005 Aspoo.Cn .All Rights Reserved</copyright>"
	Response.Write "<webMaster>" & Cl.Web_Info(8) & "</webMaster>"
	Response.Write "<docs>" & Cl.Web_Info(0) & "</docs>"
	Response.Write "<image>"
	Response.Write "	<title>" & Cl.Web_Info(1) & "</title> "
	Response.Write "	<url>" & sLogo & "</url> "
	Response.Write "	<link>" & Cl.Web_Info(4) & "</link> "
	Response.Write "	<description>" & sDeScriptIon & "</description> "
	Response.Write "</image>"
	Response.Write sRssBody
	Response.Write "</channel>"
	Response.Write "</rss>"
End Sub

Sub RssBody()
	Dim sTemp
	if TopNum=0 then TopNum=20
	Select Case Cl.ChkClng(Cl.Channel_Setting(20))
	Case 0
		sTitle		= sTitle & "--频道列表"
		sRssBody	= GetChannelList : Exit Sub
	Case 1
		sChannelName = "Article"
		sqlInfo="I.Title,I.Prefixion,I.UpdateTime,I.Passed,I.IsHtml,I.HtmlFileUrl,I.Intro from Cl_Article I Inner Join Cl_Class C On I.ClassID=C.ClassID where I.Deleted=False and I.Passed=True and I.ChannelID=" & ChannelID & " "
	Case 2
		sChannelName = "Soft"
		sqlInfo="I.SoftName,I.Prefixion,I.UpdateTime,I.Passed,I.IsHtml,I.HtmlFileUrl,I.SoftIntro,I.SoftVersion from Cl_Soft I Inner Join Cl_Class C On I.ClassID=C.ClassID where I.Deleted=False and I.Passed=True and I.ChannelID=" & ChannelID & " "
	Case 3
		sChannelName = "Photo"
		sqlInfo="I.PhotoName,I.Prefixion,I.UpdateTime,I.Passed,I.IsHtml,I.HtmlFileUrl,I.PhotoIntro from Cl_Photo I Inner Join Cl_Class C On I.ClassID=C.ClassID where I.Deleted=False and I.Passed=True and I.ChannelID=" & ChannelID & " "
	Case 4
		sChannelName = "Movie"
		sqlInfo="I.MovieName,I.Prefixion,I.UpdateTime,I.Passed,I.IsHtml,I.HtmlFileUrl,I.MovieIntro from Cl_Movie I Inner Join Cl_Class C On I.ClassID=C.ClassID where I.Deleted=False and I.Passed=True and I.ChannelID=" & ChannelID & " "
	Case 5
		sChannelName = "Product"
		sqlInfo="I.ProductName,I.Prefixion,I.UpdateTime,I.Passed,I.IsHtml,I.HtmlFileUrl,I.ProductIntro from Cl_Product I Inner Join Cl_Class C On I.ClassID=C.ClassID where I.Deleted=False and I.Passed=True and I.ChannelID=" & ChannelID & " "
	Case 6
		sTitle		= sTitle & "--" & Cl.Channel_Setting(1) & "最新" & TopNum & Cl.Channel_Setting(3) & Cl.Channel_Setting(2)
		sRssBody	= GetGuestList : Exit Sub
	Case Else
		sRssBody	= "<item></item>" : Exit Sub
	End Select
	sqlInfo = "select top "&TopNum&" I."&sChannelName&"ID,I.ClassID,C.ClassName," & sqlInfo & " "
	sTitle	= sTitle & "--" & Cl.Channel_Setting(1)
	if sClassID>0 then
		set tClass=Cl.Execute("select ClassID,Child,ParentPath,arrChildID,ClassName from Cl_Class where ChannelID="&ChannelID&" and ClassID=" & sClassID)
		if not(tClass.bof and tClass.eof) then
			if tClass(1)>0 then
				sqlInfo = sqlInfo & " and I.ClassID in (" & tClass(3) & ")"
			else
				sqlInfo = sqlInfo & " and I.ClassID=" & sClassID
			end if
			sTitle	= sTitle & "(" & tClass(4) & ")"
		else
			sqlInfo = sqlInfo & " and I.ClassID=" & sClassID
		end if
		set tClass=Nothing
	end if
	sTitle	= sTitle & "最新" & TopNum & Cl.Channel_Setting(3) & Cl.Channel_Setting(2)
	sqlInfo = sqlInfo & " order by I.OnTop desc, I."&sChannelName&"ID desc"
	Set rsInfo= Cl.Execute(sqlInfo)
	If rsInfo.bof and  rsInfo.eof then
		sTemp = "<item></item>"
		rsInfo.close:set rsInfo=nothing
	Else
		sqlInfo		= rsInfo.GetRows(-1)
		rsInfo.close:set rsInfo=nothing
		for i=0 to Ubound(sqlInfo,2)
			sTemp = sTemp & "<item>"
			sTemp = sTemp & "<title><![CDATA["
			if sqlInfo(4,i)<>"" then
			sTemp = sTemp & "(" & sqlInfo(4,i) & ")" & sqlInfo(3,i)
			else
			sTemp = sTemp & sqlInfo(3,i)
			end if
			if Cl.ChkClng(Cl.Channel_Setting(20))=2 then sTemp = sTemp & sqlInfo(10,i) 
			sTemp = sTemp & "]]></title>"
			if sqlInfo(7,i)=True and Clng(Cl.Channel_Setting(10))=1 then
				sTemp = sTemp & "<link>" & SystemDir & sqlInfo(8,i) & "</link>"
			else
				sTemp = sTemp & "<link>" & SystemDir & Cl.Channel_Setting(4) & "/" & sChannelName & "Show.asp?" & sChannelName & "ID=" & sqlInfo(0,i) & "</link>"
			end if
			sTemp = sTemp & "<description><blockquote><![CDATA[" & sqlInfo(9,i) & "]]></blockquote></description>"
			sTemp = sTemp & "<pubDate><![CDATA[更新：" & sqlInfo(5,i) & "；注：点击标题查看全部内容]]></pubDate>"
			'sTemp = sTemp & "<author></author>"
			'sTemp = sTemp & "<category></category>"
			sTemp = sTemp & "</item>"
		Next
	End if
	sRssBody = sTemp
End Sub

Function GetChannelList()
	Dim sTemp,SQL,Rs,i
	Set Rs=Cl.Execute("Select ChannelID,ChannelName,ChannelItemName,ChannelItemUnit,ChannelDir From Cl_Channel Where ChannelID>0 and ChannelType<=1 Order By OrderID")
	if Rs.Bof and Rs.Eof then
		sTemp = sTemp & "<item></item>"
		Rs.Close : Set Rs = Nothing
	Else
		SQL = Rs.GetRows(-1)
		Rs.Close : Set Rs = Nothing
		For i = 0 to UBound(SQL,2)
			sTemp = sTemp & "<item>"
			sTemp = sTemp & "<title><![CDATA[" & SQL(1,i) & "--频道列表]]></title>"
			sTemp = sTemp & "<link>" & SystemDir & SQL(4,i) & "</link>"
			sTemp = sTemp & "<description><blockquote><![CDATA[<font color=#0000ff><b>" & SQL(1,i) & "最新20" & SQL(3,i) & SQL(2,i) & "</b></font>：<a href=""" & SystemDir & "RssFeed.Asp?ChannelID=" & SQL(0,i) & """>" & SystemDir & "RssFeed.Asp?ChannelID=" & SQL(0,i) & "</a><br /><br />" & GetClassList(SQL(0,i),SQL(2,i),SQL(3,i)) & "]]></blockquote></description>"
			sTemp = sTemp & "<pubDate><![CDATA[" & Now() & "]]></pubDate>"
			sTemp = sTemp & "</item>"
		Next
	End if
	GetChannelList = sTemp
End Function

Function GetClassList(sChannelID,ItemName,ItemUnit)
	sChannelID = Cl.ChkClng(sChannelID)
	Dim sTemp,SQL,Rs,i,tDepth,n
	Set Rs=Cl.Execute("Select ClassID,ClassName,Depth,NextID From Cl_Class where IsOuter=0 and  ChannelID="&sChannelID&" order by RootID,OrderID")
	if Rs.Bof and Rs.Eof then
		GetClassList = ""
		Rs.Close : Set Rs = Nothing : Exit Function
	Else
		SQL = Rs.GetRows(-1)
		Rs.Close : Set Rs = Nothing
		dim arrShowLine(10)
		for i=0 to ubound(arrShowLine)
			arrShowLine(i)=False
		next
		For i=0 to Ubound(SQL,2)
			tDepth=SQL(2,i)
			if SQL(3,i)>0 then
				arrShowLine(tDepth)=True
			else
				arrShowLine(tDepth)=False
			end if
			if tDepth>0 then
				for n=1 to tDepth
					sTemp=sTemp & "&nbsp;&nbsp;"
					if n=tDepth then
						if SQL(3,i)>0 then
							sTemp=sTemp & "├&nbsp;"
						else
							sTemp=sTemp & "└&nbsp;"
						end if
					else
						if arrShowLine(n)=True then
							sTemp=sTemp & "│"
						else
							sTemp=sTemp & "&nbsp;"
						end if
					end if
				next
			end if
			sTemp = sTemp & "<b>" & SQL(1,i) & "最新" & TopNum & ItemUnit & ItemName & "</b>：<a href=""" & SystemDir & "RssFeed.Asp?ChannelID=" & sChannelID & "&ClassID=" & SQL(0,i) & """>" & SystemDir & "RssFeed.Asp?ChannelID=" & sChannelID & "&ClassID=" & SQL(0,i) & "</a><br />"
		Next
	End if
	GetClassList = sTemp
End Function

Function GetGuestList()
	Dim sTemp
	sqlInfo = "Select GuestId,GuestName,GuestTitle,GuestContent,GuestDatetime,GuestReply,GuestReplyAdmin From Cl_Guest where GuestIsPassed=True order by GuestId desc"
	Set rsInfo= Cl.Execute(sqlInfo)
	If rsInfo.bof and  rsInfo.eof then
		sTemp = "<item></item>"
		rsInfo.close:set rsInfo=nothing
	Else
		sqlInfo		= rsInfo.GetRows(-1)
		rsInfo.close:set rsInfo=nothing
		'GuestId,GuestTitle,GuestContent,GuestDatetime,GuestReply,GuestReplyAdmin
		for i=0 to Ubound(sqlInfo,2)
			sTemp = sTemp & "<item>"
			sTemp = sTemp & "<title><![CDATA[" & sqlInfo(2,i) & "]]></title>"
			sTemp = sTemp & "<link>" & SystemDir & "GuestBook/Index.Asp</link>"
			sTemp = sTemp & "<description><blockquote><![CDATA[" & sqlInfo(3,i) & "]]></blockquote></description>"
			sTemp = sTemp & "<pubDate><![CDATA[更新：" & sqlInfo(4,i) & "；注：点击标题查看全部内容]]></pubDate>"
			sTemp = sTemp & "<author>" & sqlInfo(1,i) & "</author>"
			'sTemp = sTemp & "<category></category>"
			sTemp = sTemp & "</item>"
		Next
	End if
	GetGuestList = sTemp
End Function
%>