<?php
include("../includes/config.php");
include("../includes/functions.php");

$link = db_connect();
$result = mysql_query("SELECT *,UNIX_TIMESTAMP(showfrom) AS showfrom FROM ".$tables['news']." ORDER BY showfrom DESC");
$now = time();

if (@mysql_num_rows($result)){
	while ($row = mysql_fetch_array($result)){
		$news[] = $row;
		if (!$last_updated) $last_updated = $row['showfrom'];
	}
}
mysql_close($link);

header('Content-type: application/xml');
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Enviromat News</title>
		<link>http://www.enviromat.co.uk</link>
		<description>Enviromat News and Updates</description>
		<lastBuildDate><?=date("D, d M Y H:i:s",$last_updated)." GMT"?></lastBuildDate>
		<?php
		foreach ($news as $n){
		?>
		<item>
			<title><?=$n['title']?></title>
			<link>http://www.enviromat.co.uk/news.php?article=<?=$n['id']?></link>
			<pubDate><?=date("D, d M Y H:i:s",$n['showfrom'])." GMT"?></pubDate>
			<description><?=strip_tags($n['body'])?> Enviromat article from http://www.enviromat.co.uk.</description>
			<guid>http://www.enviromat.co.uk/news.php?article=<?=$n['id']?></guid>
		</item>
		<?php
		}
		?>
	<atom:link href="http://www.enviromat.co.uk/rss/rss.xml" rel="self" type="application/rss+xml" />
	</channel>
</rss>

