<?php
include ("config.php");
header("Content-type: text/xml");

if ($_GET['lim'] == "") {
$rlimit = "10";
} else {
$rlimit = $_GET['lim'];
}

echo "<?xml version=\"1.0\" encoding=\"US-ASCII\"?><rss version=\"2.0\"><channel>";

echo "<title>".$sitename." - Forum Posts</title><link>".$siteurl."/forums.html</link><description>".$sitename." - ".$siteurl."</description><language>en-us</language><copyright>Copyright 2006, ".$sitename.".</copyright><webMaster>webmaster@politialyard.com</webMaster><image><title>".$sitename." Forums</title><width>144</width><height>35</height><link>".$siteurl."/forums.html</link><url>".$siteurl."/py.png</url></image>";
$sql = mysql_query("SELECT * FROM posts ORDER BY `id` DESC LIMIT ".$rlimit);
while($r = mysql_fetch_array($sql)) {
$forum = mysql_fetch_row(mysql_query("SELECT name FROM forums WHERE id = '".$r[fid]."'"));

echo "<item><title>".stripslashes($r[subject])." - ".$forum[0];

    $link = str_replace(" ", "-", html_entity_decode(stripslashes($r[subject])));
    $url3 = str_replace("?", "", $link);
    $url3 = str_replace("!", "", $url3);
    $url3 = str_replace(":", "", $url3);
    $url3 = str_replace("'", "", $url3);
    $url3 = str_replace("`", "", $url3);
    $url3 = str_replace("’", "", $url3);
    $url3 = str_replace("(", "", $url3);
    $url3 = str_replace(")", "", $url3);
    $url3 = str_replace("/", "-", $url3);
	$url3 = str_replace(",", "", $url3);
	$url3 = str_replace(".", "", $url3);
	$url3 = str_replace('"', '', $url3);
	$url3 = str_replace("%22", "", $url3);
	$url3 = str_replace("$", "", $url3);
	$url3 = str_replace(";", "", $url3);
	$url3 = str_replace("&quot", "", $url3);
	$url3 = str_replace("--", "-", $url3);
	$url3 = $siteurl."/topic".$r[tid]."-".$url3.".html";
	$url3 = str_replace("--", "", $url3);
	$url3 = str_replace("-
.", ".", $url3);

$ex = explode("[/quote]<br />", $r[message]);
if ($ex[1]) {
$message = stripslashes(htmlspecialchars(substr($ex[1],0,300)));
} else {
$message = stripslashes(htmlspecialchars(substr($r[message],0,300)));
}

echo "</title><link>".$url3."</link><pubDate>".date("D, d M Y h:i:s T", $r[date])."</pubDate><guid>".$url3."</guid><description>".$message."</description></item>";
}
echo "</channel></rss>";
?>