<?php

	session_start();
	header('content-type: text/xml');

	$date = date("Y-m-d", time());

	include ('../databaseinformation.php');
	
	echo "<?xml version='1.0' encoding='UTF-8'?>\n";
	echo "<rss version='2.00'>\n";
	echo "<channel>\n";
	
	echo "<title>Fine Art News on FineArtAmerica.com</title>\n";
	echo "<link>http://www.fineartamerica.com</link>\n";
	echo "<description>Fine Art News on FineArtAmerica.com</description>\n";
	
	echo "<image>\n";
	echo "<title>Fine Art America</title>\n";
	echo "<url>http://fineartamerica.com/assets/images/LogoFineArtAmerica2008.jpg</url>\n";
	echo "<link>http://www.fineartamerica.com</link>\n";
	echo "</image>\n";
	
	
	$query = "SELECT * FROM pressreleases WHERE domainid = '{$_SESSION[domain][aliasid]}' ORDER BY timestamp DESC LIMIT 15";
	$result = mysql_query($query);
	
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
	
		$row[presstitle] = ucwords(strtolower($row[presstitle]));
		$row[presstitle] = htmlentities($row[presstitle],ENT_NOQUOTES,'UTF-8');
		$row[presstitle] = str_replace("?", "'", $row[presstitle]);
		$row[presstitle] = str_replace("?", "-", $row[presstitle]);
		$row[presstitle] = str_replace("?", "\"", $row[presstitle]);
		$row[presstitle] = str_replace("?", "\"", $row[presstitle]);		
		$row[presstitle] = str_replace("&","", $row[presstitle]);
		$row[presstitle] = str_replace(";","", $row[presstitle]);
		$row[presstitle] = str_replace("?","", $row[presstitle]);

				
		$row[pressdescription] = $row[presscity].", ".$row[pressstate]." - ".htmlentities($row[pressdescription],ENT_NOQUOTES,'UTF-8');
		$row[pressdescription] = str_replace("?", "'", $row[pressdescription]);
		$row[pressdescription] = str_replace("?", "-", $row[pressdescription]);
		$row[pressdescription] = str_replace("?", "\"", $row[pressdescription]);
		$row[pressdescription] = str_replace("?", "\"", $row[pressdescription]);		
		$row[pressdescription] = str_replace("&","",$row[pressdescription]);
		$row[pressdescription] = str_replace(";","",$row[pressdescription]);
		$row[pressdescription] = str_replace("?","",$row[pressdescription]);
		$row[pressdescription] = stripslashes($row[pressdescription]);

		$row[pressdescription] = substr($row[pressdescription],0,250)."...";
		
		$row[timestamp] = date("D, d M Y H:i:s", $row[timestamp])." GMT";

		//echo "<p style='font: 8pt arial;'>$row[pressdescription]</p>";
		
		echo "<item>\n";
		echo "<title>$row[presstitle]</title>\n";
		echo "<pubDate>$row[timestamp]</pubDate>\n";
		echo "<link>http://fineartamerica.com/pressreleases/$row[presspagename]</link>\n";
		echo "<description>$row[pressdescription]</description>\n";
		echo "</item>\n";
		
	}
	

	
	echo "</channel>\n";
	echo "</rss>\n";
?>
