<? header('Content-type: text/xml'); ?>

<rss version="2.0">
<channel>
<title>United North America</title>
<description>A United North America - Amalgamation of Canada and the United States of America</description>
<link>http://www.unitednorthamerica.org/</link>
<copyright>Copyright 2007 United North America</copyright>

<?
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'conn.php');

global $HTTP_POST_FILES;
$q= "SELECT topic_title,topic_id,topic_first_post_id,topic_time FROM phpbb_topics WHERE topic_news = 1 ORDER BY topic_id DESC LIMIT 0,5";

$doGet=mysql_query($q);
while($result = mysql_fetch_array($doGet)){

	$post_id = $result['topic_first_post_id'];
	$subquery = "SELECT post_text FROM phpbb_posts_text WHERE post_id = $post_id";
	$subresult = mysql_query($subquery)
	or die("Query failed at data retrieval stage."); 
	$subdata = mysql_fetch_assoc($subresult);

	$post_text = $subdata['post_text'];
	
	$pos = strrpos_string($post_text,"</span>");
	
	$post_text = str_replace("”", "\"",str_replace("“", "\"",str_replace("—", " ",str_replace("–", " ",str_replace("’", "'",preg_replace('/\s\s+/', ' ',trim(substr($post_text,$pos))))))));

?>
     <item>
        <title><?=strip_tags($result['topic_title']); ?></title>
        <description><?=trim(strtrim(strip_tags($post_text,'ENT_QUOTES'),150,10));?></description>
        <link>http://www.unitednorthamerica.org/viewtopic.php?t=<?=$result['topic_id'];?></link>
	<guid isPermaLink="true">http://www.unitednorthamerica.org/viewtopic.php?t=<?=$result['topic_id'];?></guid>
        <pubDate> <?=strftime( "%a, %d %b %Y %T %Z" , $result['topic_time']);?></pubDate>
     </item>  
<? } 
?> 
</channel>
</rss>
