<?php
define('CURSCRIPT','rss');
require_once './engine/common.inc.php';
if(!in_array($rssid,array(1,2,3))){
	showmsg("订阅信息不存在");
}
header("Content-type: application/xml");
$siteurl=site(1);
echo 	"<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n".
	"<rss version=\"2.0\">\n".
	"  <channel>\n".
		"    <title>$sitename</title>\n".
		"    <link>index.php</link>\n".
		"    <description>$sitename $sitekeywords</description>\n".
	"    <copyright>Copyright(C) $sitename</copyright>\n".
	"    <generator>gatewei web engine by Peng Jingkang</generator>\n".
	"    <lastBuildDate>".gmdate('r', $timestamp+3600*8)."</lastBuildDate>\n".
	"    <image>\n".
	"      <url>$siteurl/templates/default/images/sitelogo.gif</url>\n".
	"      <title>$sitename</title>\n".
	"    </image>\n";
if($rssid==1){
	$q = $db->query("SELECT * FROM g_articles ORDER BY ord DESC LIMIT 0 , 20");
	while($rssarticle=$db->fetch_array($q)){
			echo 	"<item>\n".
			"<title>".$rssarticle['articletitle']."</title>\n".
			"<link>viewarticle.php?aid=".$rssarticle['aid']."</link>\n".
			"<category>".$articlecategory[$rssarticle['categoryid']]['categorytitle']."</category>\n".
			"<description xmlns:cf=\"http://www.microsoft.com/schemas/rss/core/2005\" cf:type=\"html\">&lt;b&gt;发布人:".$rssarticle['useraccount']."&lt;/b&gt;&lt;br&gt;".$rssarticle['articletitle']."</description>\n".
			"<pubDate>".gmdate('r',$rssarticle['subtime'])."</pubDate>\n".
			"<guid>viewarticle.php?aid=".$rssarticle['aid']."</guid>\n</item>\n";
		}
}elseif($rssid==2){
	$q = $db->query("SELECT * FROM g_products ORDER BY ord DESC LIMIT 0 , 20");
	while($rssproduct=$db->fetch_array($q)){
			echo 	"<item>\n".
			"<title>".$rssproduct['producttitle']."</title>\n".
			"<link>viewproduct.php?productid=".$rssproduct['productid']."</link>\n".
			"<category>".$productcategory[$rssproduct['categoryid']]['categorytitle']."</category>\n".
			"<description>发布人:".$rssproduct['useraccount']."<BR />".$rssproduct['productintro']."</description>\n".
			"<pubDate>".gmdate('r',$rssproduct['subtime'])."</pubDate>\n".
			"<guid>viewproduct.php?productid=".$rssproduct['productid']."</guid>\n</item>\n";
		}
}elseif($rssid==3){
	$q = $db->query("SELECT * FROM g_threads ORDER BY ord DESC LIMIT 0 , 20");
	while($rssthread=$db->fetch_array($q)){
			echo 	"<item>\n".
			"<title>".$rssthread['title']."</title>\n".
			"<link>viewthread.php?tid=".$rssthread['tid']."</link>\n".
			"<category>".$articlecategory[$rssthread['forid']]['forumtitle']."</category>\n".
			"<description>发布人:".$rssthread['useraccount']."<BR />".$rssthread['title']."</description>\n".
			"<pubDate>".gmdate('r',$rssthread['subtime'])."</pubDate>\n".
			"<guid>viewarticle.php?aid=".$rssthread['tid']."</guid>\n</item>\n";
		}
}
 
  echo "</channel>\n".
"</rss>";
?>