100 || !is_numeric($limit)) $limit = 100;
if ($type == "")
{
header("Content-type: text/xml");
echo "\n";
echo "no group specified\n";
die();
}
if ($type != "g")
{
$result = mysql_query("select ID from feed where '".mysql_real_escape_string($type)."' REGEXP code");
$feedid = -1;
while ($row = mysql_fetch_assoc($result))
$feedid = $row["id"];
$result = mysql_query("select item.*, feed.* from item join ( select ID from item where feedID = '".mysql_real_escape_string($feedid)."' order by adddateunique desc limit ".$limit." ) x on x.ID = item.ID inner join feed on feed.ID = item.feedID inner join access on access.guid = '".mysql_real_escape_string($uid)."' order by item.id desc");
}
else
$result = mysql_query("select item.*, feed.* from item join ( select item.ID from item inner join access on access.guid = '".mysql_real_escape_string($uid)."' and item.feedid != coalesce(access.misc, -1) and role=2 where feedid in (select id from feed where name = 'gid') ORDER BY item.adddateunique DESC LIMIT ".$limit." ) x on x.ID = item.ID inner join feed on feed.ID = item.feedID order by item.ID desc");
if (!$result)
{
header("Content-type: text/xml");
echo "\n";
echo "general error";
die();
}
//
// build metadata about the item(s)
//
$xml = "";
while ($row = mysql_fetch_assoc($result))
{
//create the xml
$xml .= "\t- \n";
$xml .= "\t\t".htmlentities($row['title'])."\n";
$xml .= "\t\t".date('r', strtotime($row['adddate']))."\n";
$xml .= "\t\t".htmlentities($row['reqid'])."\n";
$xml .= "\t\t".htmlentities($row['code'])."\n";
$xml .= "\t\t".htmlentities($row['link'])."\n";
if ($row['description']!= "")
$xml .= "\t\t\n";
$xml .= "\t\t".htmlentities($row['guid'])."\n";
$xml .= "\t
\n";
}
//
// build the xml
//
$xmlstart = "
".mysql_real_escape_string(htmlentities($type))." feed
http://www.newznab.com
".mysql_real_escape_string(htmlentities($type))." feed
en-us\n";
$xmlend = "\n";
$ret = $xmlstart . $xml . $xmlend;
//
// output xml
//
header("Content-type: text/xml");
echo "\n";
echo $ret;