<%
'=================================================================================
'                             +-生成某个类的RSS-XML-+
'函数：CreateRss(classid)
'功能：生成某个类的RSS-XM
'参数：
'classid   		---栏目ID
'=================================================================================
sub CreateRss(classid)
	dim TempArr,ListName,listUrl,rssArr,urlType
	Set rs = Server.CreateObject("adodb.recordset")
	sql="select title,savedir,flag from catalogs where id="&classid
	rs.open sql,conn,3,1
	if not rs.eof then		
		ListName=rs("title")
		listUrl=rs("savedir")
		if(rs("flag")=true) then
			urlType="/index.htm"
		else
			urlType="/index_1.htm"
		end if
	else
		response.Write("暂时没有数据!<input type='button' value='继续发布 →' onclick="&Chr(34)&"javascript:location.href='send_rss.asp'"&Chr(34)&">")
		response.End()
	end if
	rs.close()
	set rs=nothing
	'读取信息
	Set rs = Server.CreateObject("adodb.recordset")
	rs.open "select top "&RssMaxNum&" title,pagepath,id,moditime,content from news where checked=1 and classid="&classid&" order by id desc",conn,3,1
	if not rs.eof then
		TempArr=rs.GetRows()
	else
		response.Write("暂时没有数据!<input type='button' value='继续发布 →' onclick="&Chr(34)&"javascript:location.href='send_rss.asp'"&Chr(34)&">")
		response.End()
	end if
	rs.close
	set rs=nothing
	
	Set fs=Server.CreateObject("Scripting.FileSystemObject")	
	rssArr="<?xml version = '1.0' encoding = 'GBK'?>"&Chr(13)
	rssArr=rssArr&"<rss version=""2.0"">"&Chr(13)
   	rssArr=rssArr&"<channel>"&Chr(13)
      	rssArr=rssArr&"<pubDate>"&now&"</pubDate>"&Chr(13)
      	rssArr=rssArr&"<docs>"&SiteUrl&listUrl&"</docs>"&Chr(13)
      	rssArr=rssArr&"<title>"&ListName&"</title>"&Chr(13)
      	rssArr=rssArr&"<link>"&SiteUrl&listUrl&urlType&"</link>"&Chr(13)
      	rssArr=rssArr&"<language>cn</language>"&Chr(13)
      	rssArr=rssArr&"<dc_date>"&now&"</dc_date>"&Chr(13)
      	rssArr=rssArr&"<dc_language>cn</dc_language>"&Chr(13)
	'生成每页的HTML文件
		
	for i=0 to ubound(TempArr,2)
		rssArr=rssArr&"<item>"&Chr(13)
         	rssArr=rssArr&"<title>"&TempArr(0,i)&"</title>"&Chr(13)
         	rssArr=rssArr&"<link>"&SiteUrl&"/"&TempArr(1,i)&"</link>"&Chr(13)
         	rssArr=rssArr&"<description>"&left(RemoveHTML(TempArr(4,i)),80)&"...</description>"&Chr(13)
         	rssArr=rssArr&"<pubDate>"&TempArr(3,i)&"</pubDate>"&Chr(13)
      		rssArr=rssArr&"</item>"&Chr(13)
	next
	rssArr=rssArr&"   </channel>"&Chr(10)
	rssArr=rssArr&"</rss>"&Chr(10)

	'写入文件内容
	
	Set file_w = fs.CreateTextFile(server.mappath("../rss/rss_"&classid&".xml"),true)		
	file_w.WriteLine(rssArr)
	if err.number>0 then
		response.Write(err.description)
		end if
	file_w.close
	set file_w=nothing
	response.Write("文件成功保存到："&server.mappath("../rss/rss_"&classid&".xml")&"<br>")'打印保存路径
	response.Write("OK")
	set fs=nothing
end sub 
%>