<?php header('Content-type: text/xml');

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;

$orderBy 		= '`dateStart` ASC, title ASC';
$query 			= "SELECT id AS event_id,
						  title,
						  description FROM `{$CONFIG['MODULES'][$moduleName]['TABLES']['EVENTS']}`
					   WHERE dateEnd > NOW()
						 AND approved = 'Y'
						 AND ( pgType = 'event' OR pgType = 'notice' )
					   ORDER BY {$orderBy}
					   LIMIT {$limit}
				   ";

?>
<rss version="2.0">
<channel>
<title><?php echo $CONFIG['SITE']['name']; ?></title>
<description><![CDATA[<?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 $result['title']; ?>]]></title>
		<description><![CDATA[<?php echo $result['description'];?>]]></description>
		<link><?php echo $CONFIG['URL']['root']; ?>events/event.php?id=<?php echo $result['event_id'];?></link>
		<guid><?php echo $CONFIG['URL']['root']; ?>events/event.php?id=<?php echo $result['event_id'];?></guid>
		<pubDate><?php echo date( 'r' , strtotime($result['date'])); ?></pubDate>
	 </item>
<? } ?>

</channel>
</rss>
