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

$link = db_connect();
$result = mysql_query("SELECT * FROM sbed_accommodation ORDER BY id ASC");
$now = time();

if (@mysql_num_rows($result)){
	while ($row = mysql_fetch_array($result)){
		$row['showfrom'] = $now;
		$row['acctypefull'] = ($row['acctype'] == "sc") ? "Self-catering" : "Bed and Breakfast";
		$row['uri'] = ($row['acctype'] == "sc") ? "bed_and_breakfast.php?accommodation=" : "self_catering.php?accommodation=";
		$news[] = $row;
	}

	$last_updated = $now;

}
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?> Accommodation Updates</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>Stay in Beds</name>
		<email>info@stayinbeds.co.uk</email>
	</author>

	<?php
	foreach ($news as $n){
	?>
		<entry>
			<title><?=$n['name']?></title>
			<link href="http://www.stayinbeds.co.uk/<?=$n['uri'].$n['id']?>"/>
			<id><?=$n['id']?></id>
			<updated><?=date("Y-m-d\TH-i-m\Z",$n['showfrom'])?></updated>
			<summary><?=$n['acctypefull']?> Accommodation in <?=$n['town']?> at <?=$n['name']?></summary>
			<content><?=$n['info']?></content>
		</entry>
	<?php
	}
	?>


</feed>

