<? header('Content-type: text/xml; charset=utf-8'); ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Assemblist RSS Feed</title>
<description>The freshest images at Assemblist</description>
<link>http://assemblist.com/</link>
<atom:link href="http://assemblist.com/rss/feed.php" rel="self" type="application/rss+xml" />

<? require_once '../includes/mysql.php';
$db = &new MySQL($host, $dbUser, $dbPass, $dbName);

function shorten($string, $length) {
	$suffix = '...';
	$short_desc = trim(str_replace(array("\r","\n", "\t"), ' ', strip_tags($string)));
	$desc = trim(substr($short_desc, 0, $length));
	$lastchar = substr($desc, -1, 1);
	if ($lastchar == '.' || $lastchar == '!' || $lastchar == '?' || !$desc || strlen($desc) < $length) $suffix='';
	$desc .= $suffix;
	return $desc;
}

/* Superseded by wp-include/formatting.php
function remove_html($string) {
	$replacing    = array('<',     '>',     '"',      '&',    '\'',     '&amp;ndash;', '&amp;lsquo;', '&amp;rsquo;', '&amp;amp;', '&amp;oslash;');
	$replace_with = array('&#60;', '&#62;', '&quot;', '&amp;', '&#39;', '&#8211;',     '&#8216;',     '&#8217;',     '&#38;',     '&#248;');
	$string = str_replace($replacing,$replace_with,$string);
	return $string;
}
*/

$sql = "SELECT * FROM posts WHERE status = 1 ORDER BY post_id DESC LIMIT 50";
$queryResource = mysql_query($sql);

require 'formatting.php';

while ($item = mysql_fetch_array($queryResource, MYSQL_ASSOC)) {

	$post_id = $item['post_id'];
	$image = $item['image'];
	$description = $item['description'];
	$member_id = $item['member_id'];
	$date = $item['date'];
	$category_id = $item['category_id'];
	$url = $item['url'];
	$total_bumps = $item['bumps'];
	
	$title = htmlentities($item['title'], ENT_COMPAT, 'utf-8');
	
	$title = ent2ncr($title);
	$description = ent2ncr($description);
	$description = utf8_encode($description);
	
	$href = $item['link'].'/';
				
	if(empty($item['link'])) $href = "/?post_id=".$post_id;
	
 	// output to client
	
?>

<item>
  	<title></title>
  	<link>http://www.assemblist.com/<? echo $href; ?></link>
	<guid>http://www.assemblist.com/<? echo $href; ?></guid>
  	<pubDate><? echo date("D, j M Y H:i:s T", strtotime($item['date'])) ?></pubDate>
  	<description><![CDATA[<img src='http://www.assemblist.com/graphics/image_files/post_<? echo $item['image'] ?>' alt='' /><br /><br /><? echo $description ?>]]></description>
</item>

<? } ?>

</channel>
</rss>
