<?
//changing this from whatever it was to UTF-8
header('Content-type: text/xml; charset=utf-8');
//add the library code to make the necessary conversions
include_once("named2hex.inc.php");
//make sure that everything done to strings from now on respects UTF-8
mb_internal_encoding("UTF-8");

//PHP Connect Code for Inpress Website

	$user = "admin";
	$pass = "bzimmo";
	$db = "trace";
	$connection = mysql_pconnect( "localhost", $user, $pass );
	if ( ! $connection)
	die( "Couldn't connect to MySQL" );
	mysql_select_db( $db, $connection )
	or die ("Couldn't open $db: ".mysql_error() );
	
?>
<rss version="2.0">
<channel>
<title>Art Loss Review</title>
<description>Protection and retrieval of Art and Antiques</description>
<link>http://www.artlossreview.com/</link>
<copyright>2006 Art Loss Review</copyright>

<?
$sql = "SELECT id,date,title,story FROM news ORDER by date DESC LIMIT 0,20";
$sql_result = mysql_query($sql); 

if (mysql_num_rows($sql_result) ==0)
{
	die (mysql_error());
}
else {

        while ($row = mysql_fetch_array($sql_result)){
        $id = strip_tags($row['id']);
        $date = $row['date'];
        //apply the conversion to both the title and story
        $title = utf8_encode(named2hex(strip_tags($row['title'])));
        $story = utf8_encode(named2hex(strip_tags($row['story'])));
        //changed this, it was kind of dumb to have the same variable set twice
        //all the second request was doing was truncating the text to 200 chars
        $story = substr($story,0,200);
        
// output to client
//removed htmlentities code below
	
?>

	<item>
	<title><?echo $title;?></title>
	<description><?echo $story;?></description>
	<link>http://www.artlossreview.com/news/index.php?id=<?echo $id;?></link> 
	<pubDate><?echo date('D, d M Y H:i:s T',strtotime($date)) ;?></pubDate>
	</item>

<? } }?>

</channel>
</rss>
