<? 

// Replace the auto header
header('Content-type: text/xml'); 

// You gotta have this file to connect to the database
// and provide all the default RSS values
@include('init_rss.php');


echo '<?xml version="1.0"?>';

?>
<rss version="2.0">
<channel>
	<title>-- WARM ELECTRONIC RECORDINGS -- NEWS</title>
	<link>http://www.thewarmsupercomputer.com/index_testor.php</link>
	<description>The only place to go on the internet for news on YOUR BAND.</description>
	<?
	
	// PRETEND THAT THE FEED IS PUBLISHED DAILY
	$pub_date = date("D, d M Y H:i:s T", (time() - (24 * 60 * 60)));
	echo '<pubDate>'.$pub_date.'</pubDate>';
	
	
	// DISCOVER THE LAST PUBLISH DATE...
	$the_q = "SELECT id,date_posted FROM hero_news WHERE status = 2 AND archive_status = 0 ORDER BY date_posted DESC LIMIT 2";
	$the_r = mysql_query($the_q);
	$last_build_date = date("D, d M Y H:i:s T",  mysql_result($the_r,0,'date_posted')   );
	
	echo '<lastBuildDate>'.$last_build_date.'</lastBuildDate>';
	
	
	echo '<language>'.$rss_lang.'</language>';
	echo '<copyright>'.$rss_copyright.'</copyright>';
	echo '<managingEditor>'.$rss_managing_editor.'</managingEditor>';
	echo '<webMaster>'.$rss_webmaster.'</webMaster>';
	echo '<generator>'.$rss_generator.'</generator>';
	
	if (isset($rss_category)) {
		echo '<category>'.$rss_category.'</category>';
	}
	if (isset($rss_time_to_live)) {
		echo '<ttl>'.$rss_time_to_live.'</ttl>';
	}
	
	
	
	$the_q = "SELECT * FROM hero_news WHERE status = 2 AND archive_status = 0 ORDER BY date DESC LIMIT 5";
	$the_r = mysql_query($the_q);
	$the_total = @mysql_num_rows($the_r);
	
	// run loop
	for ($i=0; $i < $the_total; $i++) {
	
		// POPULATE VARIABLES
		$cur = mysql_fetch_array($the_r);
		
		// id
		$cur_id = $cur['id'];
		
		// date
		$cur_date = date("D, d M Y H:i:s T",$cur["date"]);
		
		// headline
		$cur_headline = htmlentities(strip_tags(stripslashes($cur["headline"])));
		
		// body
		$cur_body = stripslashes($cur['body']);
		
		
		
		
		echo "<item>";
		
		echo '<title>'.$cur_headline.'</title>';
		echo '<link>http://www.thewarmsupercomputer.com/news/news_story.php?id='.$cur_id.'</link>';
		
		echo '<description>'.@strip_tags(deliver_sentence($cur_body)).'</description>';
			 
		echo '<pubDate>'.$cur_date.'</pubDate>';
			 
		echo '<source url="http://www.thewarmsupercomputer.com/rss_feeds/news.xml">YOUR BAND - NEWS</source>';
		
		echo "</item>";
	
	}// end for
	
	?>
</channel>
</rss>
