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

$link = db_connect();
$result = mysql_query("SELECT *,UNIX_TIMESTAMP(showfrom) as showfrom FROM ".$tables['news']." WHERE (TO_DAYS(showfrom) <= TO_DAYS(CURRENT_DATE) AND TO_DAYS(showto) >= TO_DAYS(CURRENT_DATE)) ORDER BY showfrom DESC");


if (@mysql_num_rows($result)){
	while ($row = mysql_fetch_array($result)){
		$news[] = $row;
	}

	$last_updated = $news[0]['showfrom'];

}
mysql_close($link);

header('Content-type: application/atom+xml');
echo '<?xml version="1.0" encoding="utf-8"?>';
?>

<feed xmlns="http://www.w3.org/2005/Atom">
<title><?=$site_title?> News Feed</title>
	<link rel="self" type="application/atom+xml" href="<?=$_SERVER['SCRIPT_URI']?>" />
	<id>http://<?=$_SERVER['HTTP_HOST']?>/</id>
	<updated><?=date("Y-m-d\TH-i-m\Z",$last_updated)?></updated>
	<author>
		<name><?=$site_title?></name>
		<email><?=$primary_email?></email>
	</author>

	<?php
	foreach ($news as $n){
	?>
		<entry>
			<title><?=$n['title']?></title>
			<link href="http://dev.fyicenter.com/faq/"/>
			<id><?=$n['id']?></id>
			<updated><?=date("Y-m-d\TH-i-m\Z",$n['showfrom'])?></updated>
			<summary><?=quick_prepare($n['intro'])?></summary>
			<content>
				<?=prepare($n['body'])?>
			</content>
		</entry>
	<?php
	}
	?>


</feed>
