mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 17:28:55 +00:00
bb28f7cdd5
(cherry picked from commit 0ccb312)
81 lines
1.9 KiB
PHP
81 lines
1.9 KiB
PHP
<?php
|
|
require_once('config.php');
|
|
|
|
$type = isset($_GET["t"]) ? $_GET["t"] : "tv";
|
|
$reqid = isset($_GET["reqid"]) ? explode(",",$_GET["reqid"]) : [];
|
|
$uid = isset($_GET["newznabID"]) ? $_GET["newznabID"] : "";
|
|
|
|
//
|
|
// query can include multiple comma sep reqids
|
|
//
|
|
$reqstr = "(";
|
|
foreach ($reqid as $req)
|
|
$reqstr.= " reqid = '".mysql_real_escape_string($req)."' or ";
|
|
$reqstr.= " 1=2) ";
|
|
|
|
if ($type != "g")
|
|
{
|
|
$result = mysql_query("select ID from feed where '".mysql_real_escape_string($type)."' REGEXP code and status = 1");
|
|
$feedid = -1;
|
|
while ($row = mysql_fetch_assoc($result))
|
|
$feedid = $row["id"];
|
|
|
|
$result = mysql_query("select * from item inner join feed on feed.ID = item.feedID inner join access on access.guid = '".mysql_real_escape_string($uid)."' where ".$reqstr." and item.feedid = '".mysql_real_escape_string($feedid)."'");
|
|
}
|
|
else
|
|
$result = mysql_query("select * from item inner join feed on feed.ID = item.feedID inner join access on access.guid = '".mysql_real_escape_string($uid)."' and role=2 where feed.name = 'gid' and ".$reqstr);
|
|
|
|
|
|
//
|
|
// build metadata about the item(s)
|
|
//
|
|
$ret = "<items>";
|
|
while ($row = mysql_fetch_assoc($result))
|
|
$ret.="<item reqid=\"".$row["reqid"]."\" link=\"".cleanXML($row["link"])."\" date=\"".$row["pubdate"]."\" title=\"".cleanXML($row["title"])."\" />\n";
|
|
$ret.="</items>";
|
|
|
|
//
|
|
// output xml
|
|
//
|
|
header("Content-type: text/xml");
|
|
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
|
echo $ret;
|
|
die();
|
|
|
|
|
|
function cleanXML($strin)
|
|
{
|
|
$strout = null;
|
|
|
|
for ($i = 0; $i < strlen($strin); $i++)
|
|
{
|
|
$ord = ord($strin[$i]);
|
|
|
|
if (($ord > 0 && $ord < 32) || ($ord >= 127))
|
|
{
|
|
$strout .= "&#{$ord};";
|
|
}
|
|
else
|
|
{
|
|
switch ($strin[$i])
|
|
{
|
|
case '<':
|
|
$strout .= '<';
|
|
break;
|
|
case '>':
|
|
$strout .= '>';
|
|
break;
|
|
case '&':
|
|
$strout .= '&';
|
|
break;
|
|
case '"':
|
|
$strout .= '"';
|
|
break;
|
|
default:
|
|
$strout .= $strin[$i];
|
|
}
|
|
}
|
|
}
|
|
|
|
return $strout;
|
|
} |