<?
if(!$db){
        include("$DOCUMENT_ROOT/s/mysql.php");$db= new mysql;
        if(!$db->init()) die(" Can't connect to DataBase");        
}
$sql="select * from tbl_article where (category_id1 in ('2','7','9') or category_id2 in ('2','7','9'))
	and state='published' order by ptime desc limit 20";
$result=$db->select($sql);
$output="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">
   <channel>
	<title>Perspektif Online - Wimar Witoelar</title>
	<link>http://www.perspektif.net</link>
	<description>Indonesia's Opinion Portal, hosted by Wimar Witoelar</description>
	<copyright>Copyright 2005 InterMatrix Communications</copyright>
	<webMaster>webmaster@perspektif.net</webMaster>
	<lastBuildDate>".date("D, d M Y H:i:s")." GMT</lastBuildDate>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>

	<image>
	<url>http://www.perspektif.net/i/template/perspektif/wimarwave.gif</url>
	<title>Wimar Witoelar</title>
	<link>http://www.perspektif.net</link>
	</image>
";

while(list($key,$val)=each($result)){
	$id		= $val[id];
	$title		= stripslashes($val[title]);$title=trim($title);
	$category_id1	= $val[category_id1];
	$category	= $db->convert_value(array("table"=>"category","cs"=>"category","cd"=>"id","vd"=>"$category_id1"));
	//count_comment
	$count_comment	= $db->count_comment($id);
	$summary	= stripslashes($val[summary]);$summary=trim($summary);
	$ptime		= $val[ptime];	

	$ptime_d=substr($ptime,8,2);
	$ptime_m=substr($ptime,5,2);
	$ptime_y=substr($ptime,0,4);
	$ptime_h=substr($ptime,11,2);
	$ptime_i=substr($ptime,14,2);
	$ptime_s=substr($ptime,17,2);
	$ptime_new=date("D, d M Y H:i:s",mktime($ptime_h,$ptime_i,$ptime_s,$ptime_m,$ptime_d,$ptime_y));

	$output .="
	<item>
		<title>$title</title>
		<link>http://www.perspektif.net$category/article.php?article_id=$id</link>
		<comments>http://www.perspektif.net$category/article.php?article_id=$id#comments</comments>
		<description>$summary</description>
		<pubDate>$ptime_new GMT</pubDate>
	</item>
	";
	#Tue, 03 Jun 2005 09:39:21 GMT
}
$output .="
   </channel>
</rss>";
header("Content-type: text/xml");
echo $output;
?>