<?

include_once($_SERVER['DOCUMENT_ROOT']."/inc_session_start.php");
include_once($_SERVER['DOCUMENT_ROOT']."/inc_common.php");
include_once($_SERVER['DOCUMENT_ROOT']."/db.php");

header("Content-Type: application/rss+xml; charset=UTF-8");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

// grab all the info we'll need for the rss feed and build an array
$sql = "select newsID, newsTitle, newsText, newsDate from musicNews order by newsDate desc limit 0,50";
$result = mysql_query($sql);
$arNewsItems = array();
while ($arThisRow = mysql_fetch_array($result)){
	$strText = strCleanForRSS($arThisRow['newsText']);
	if (strLen($strText) > 750){
		$strText = substr($strText,0,765);
		$strText = substr($strText,0,strrpos($strText," "));
		$strText .= "...";
	}
	$arNewsItems[] = array(
		$arThisRow['newsID'],
		$arThisRow['newsTitle'],
		$strText,
		date('D, d M Y H:i:s',$arThisRow['newsDate'])." EST"
	);
}


print '<?xml version="1.0" encoding="UTF-8"?>'."\n";
print '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
print '<channel>'."\n";
print '<title>Music News - Moshable.com</title>'."\n";
print '<link>http://www.moshable.com/</link>'."\n";
print '<description>Music Industry News from Moshable.com</description>'."\n";
print '<language>en-us</language>'."\n";
print '<copyright>Copyright '.date('Y').' Moshable.com</copyright>'."\n";
print '<atom:link href="http://www.moshable.com/music-news.xml" rel="self" type="application/rss+xml" />'."\n";
print '<lastBuildDate>'.$arNewsItems[0][3].'</lastBuildDate>'."\n";
print '<image>'."\n";
print '<title>Music News - Moshable.com</title>'."\n";
print '<url>http://www.moshable.com/images/rss-header.gif</url>'."\n";
print '<link>http://www.moshable.com/</link>'."\n";
print '<width>144</width>'."\n";
print '<height>20</height>'."\n";
print '</image>'."\n\n";

foreach ($arNewsItems as $arThisItem){
	$strArticleURL = cleanForSubDomain($arThisItem[1]);
	$strArticleURL .= "_".str_pad($arThisItem[0],5,"0",STR_PAD_LEFT).".html";

	print '<item>'."\n";
	print '<title>'.$arThisItem[1].'</title>'."\n";
	print '<link>http://www.moshable.com/music-news/'.$strArticleURL.'</link>'."\n";
	print '<description>'.$arThisItem[2].'</description>'."\n";
	print '<author>news@moshable.com (Moshable.com Music News)</author>'."\n";
	print '<pubDate>'.$arThisItem[3].'</pubDate>'."\n";
	print '<guid isPermaLink="true">http://www.moshable.com/music-news.php?newsID='.$arThisItem[0].'</guid>'."\n";
	print '</item>'."\n\n";
}

print '</channel>'."\n";
print '</rss>'."\n";

?>