<?php header('Content-type: text/xml');
$ROOT=(dirname(__FILE__))."/../";   
include "$ROOT/common/includes/database.inc";
?>
<rss version="2.0">
<channel>
<title>Ecco Pacific Ltd :: News</title>
<description>New Zealand Wholesaler</description>
<link>http://www.ecco.co.nz/</link>
<copyright>Ecco Pacific Ltd</copyright>

<?php
$articles=mysql_query(" select id,title,category,synopsis,UNIX_TIMESTAMP(pub_date) AS pub_date from news ORDER BY pub_date DESC, category  LIMIT 0,15");
if(!$articles) {
	write_log(mysql_errno(). ": ".mysql_error());
	echo "Maintenance in progress, please try later... (1)";
	exit;
}

if(mysql_num_rows($articles)>0) {
	$article=mysql_fetch_array($articles);

do {
    $item= '<item>'."\n";
    $item.='    <title>'.htmlentities(strip_tags($article['title'])).'</title>'."\n";
    $item.='    <guid isPermaLink="true">http://'.$_SERVER['SERVER_NAME'].'/news/'.date('Y_m_d',$article['pub_date']).'/'.str_replace(" ", "_",htmlentities(strip_tags($article['title']))).'.html</guid>'."\n";
    $item.='    <description>'.htmlentities(strip_tags($article['synopsis'],'ENT_QUOTES')).'</description>'."\n";
    $item.='    <link>http://'.$_SERVER['SERVER_NAME'].'/news/'.date('Y_m_d',$article['pub_date']).'/'.str_replace(" ", "_",htmlentities(strip_tags($article['title']))).'.html</link>'."\n";
    $item.='    <category>'.htmlentities(strip_tags($article['category'])).'</category>'."\n";
    $item.='    <pubDate>'.date('r', $article['pub_date']).'</pubDate>'."\n";
    $item.='</item>'."\n";
     echo $item;
	}while($article=mysql_fetch_array($articles));
}
?>
</channel>
</rss>         

