<?php

include_once ('config.php');
if (! isset($CONFIG) ) {
	die('CONFIG Array not found - Check siteConfig.php is in the root directory.');
}

include_once $CONFIG['PATHS']['lib'] . 'magicQuotes.php';
include_once $CONFIG['PATHS']['lib'] . 'dbconnect.php';
include_once $CONFIG['PATHS']['lib'] . 'functions.php';
include_once $CONFIG['PATHS']['classes'] . 'User.php';
include_once $CONFIG['PATHS']['classes'] . 'Object.php';

$oUser	= new User($CONFIG['TABLES']['user'], $CONFIG['SESSION']['name'], $CONFIG['COOKIE']);


$orderBy 		= '`date` DESC, title ASC';

$limit  =15;

$query 			= "SELECT
					offer_id,
					title,
					description,
					price_text,
					date
				   FROM `{$CONFIG['MODULES'][$moduleName]['TABLES']['offers']}`
				   WHERE CURDATE() < expiry_date
				   ORDER BY {$orderBy} LIMIT {$limit}
				  ";

header('Content-type: text/xml;  charset=UTF-8');
?>
<rss version="2.0">
<channel>
<title><?php echo $CONFIG['SITE']['name']; ?></title>
<description><?php echo $CONFIG['SITE']['description']; ?></description>
<link><?php echo $CONFIG['URL']['root']; ?></link>
<copyright>Your copyright information</copyright>

<?
$doGet=mysql_query($query);

while($result = mysql_fetch_array($doGet)){
?>
	 <item>
		<title><![CDATA[<?php echo htmlentities(strip_tags($result['title'])); ?>]]></title>
		<description><![CDATA[<?php echo $result['description']. '<br />' . $result['price_text']; ?>]]></description>
		<link><?php echo $CONFIG['URL']['root']; ?>offers/offer_details.php?id=<?php echo $result['offer_id'];?></link>
		<guid><?php echo $CONFIG['URL']['root']; ?>offers/offer_details.php?id=<?php echo $result['offer_id'];?></guid>
		<pubDate><?php echo date( "r" , strtotime($result['date'])); ?></pubDate>
	 </item>
<? } ?>

</channel>
</rss>
