<?php
$lcheck = "b";
$z = "b";

if ($_GET['load'] == "rss") {
header("Content-type: text/xml");

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

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

echo "<title>".$sitename." - Latest ".ucfirst($cat)."</title><link>".$siteurl."</link><description>".$sitename." - ".$siteurl."</description><language>en-us</language><copyright>Copyright 2008-2010, ".$sitename.".</copyright><webMaster>".$email."</webMaster>";
 if ($cat == "media") {
 $sql = mysql_query("SELECT * FROM ".$pre."albums ORDER BY `id` DESC LIMIT ".$rlimit);
 } else {
 if ($cat == "posts") {
 $sql = mysql_query("SELECT * FROM ".$pre."posts WHERE type = 'post' ORDER BY `id` DESC LIMIT ".$rlimit);
 } else {
 if ($cat == "topics") {
 $sql = mysql_query("SELECT * FROM ".$pre."posts WHERE type = 'topic' OR type = 'Announcement' OR type = 'Sticky' ORDER BY `id` DESC LIMIT ".$rlimit);
 } else {
 $sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$cat."' AND ver = '0' AND save = '0' ORDER BY `date` DESC LIMIT ".$rlimit);
 }
 }
 }
 while($r = mysql_fetch_array($sql)) {
   $short = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE name = 'Short' AND cat = 'content' AND id2 = '".$r[id]."'"));
   $systems = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."systems WHERE id = '".$r[systems]."'"));
   
   if (($r[cat] == "posts") or ($r[cat] == "topics")) {
   echo "<item><title>".$sitename." - Post: ".$r[subject]."</title><link>".$siteurl."/".$f2part1.$r[tid].$f2part2;
   if (ucfirst($r[cat]) == "posts") {
   echo "#".$r[id];
   }
   echo "</link><description>".stripslashes(substr($r[message],0,100))."</description><pubDate>".date("D, d M Y h:i:s T", $r[date])."</pubDate></item>";
   } else {

echo "<item><title>".$sitename." - ".$r[name]." (".$systems[0].") - ".$r[cat]."</title><link>";
if (ucfirst($r[cat]) == "media") 	 {
echo $gpart1.$r[id].$gpart2;
} else 	 {
echo $part1.$r[id].$part2;
}
echo "</link>";
if (ucfirst($r[cat]) == "media") {
} else {
echo "<pubDate>".date("D, d M Y h:i:s T", $r[date])."</pubDate>";
}
if ($short[0]) {
echo "<description>".stripslashes(htmlspecialchars($short[0]))."</description><guid>".$siteurl."/".$part1.$r[id].fthrough($r[name], $r[cat]).$part2."</guid></item>";
} else {
echo "<description>".ucfirst($r[cat])." about ".$r[name]."</description><guid>".$siteurl."/".$part1.$r[id].fthrough($r[name], $r[cat]).$part2."</guid></item>";
}
}
}
echo "</channel></rss>";
}
?>