class FEED {
function open_feed() {
header("Content-type: application/xml; charset=UTF-8");
echo "\n","\n\t\n";
}
function close_feed() {
echo "\t\n";
}
function channel($Title, $Description, $Section = '') {
$Site = site_url();
echo "\t\t
$Title :: ". SITE_NAME. "\n";
echo "\t\t$Site$Section\n";
echo "\t\t$Description\n";
echo "\t\ten-us\n";
echo "\t\t". date('r'). "\n";
echo "\t\thttp://blogs.law.harvard.edu/tech/rss\n";
echo "\t\tGazelle Feed Class\n\n";
}
function item($Title, $Description, $Page, $Creator, $Comments = '', $Category = '', $Date = '') { //Escape with CDATA, otherwise the feed breaks.
if ($Date == '') {
$Date = date('r');
} else {
$Date = date('r', strtotime($Date));
}
$Site = site_url();
$Item = "\t\t- \n";
$Item .= "\t\t\t\n";
$Item .= "\t\t\t\n";
$Item .= "\t\t\t$Date\n";
$Item .= "\t\t\t$Site$Page\n";
$Item .= "\t\t\t$Site$Page\n";
if ($Comments != '') {
$Item .= "\t\t\t$Site$Comments\n";
}
if ($Category != '') {
$Item .= "\t\t\t\n";
}
$Item .= "\t\t\t$Creator\n\t\t
\n";
return $Item;
}
function retrieve($CacheKey, $AuthKey, $PassKey) {
global $Cache;
$Entries = $Cache->get_value($CacheKey);
if (!$Entries) {
require(SERVER_ROOT.'/classes/mysql.class.php');
$DB = NEW DB_MYSQL; //Load the database wrapper
$DB->query("
SELECT * FROM (
SELECT t.*,
(SELECT Name from artists_group ag WHERE ag.ArtistID=ta.ArtistID) AS ArtistName,
tg.Name AS GroupName,
tg.WikiBody AS WikiBody
FROM `torrents` t
LEFT JOIN torrents_artists ta ON t.GroupID=ta.GroupID
LEFT JOIN torrents_group tg ON tg.ID=ta.GroupID
ORDER BY id DESC
LIMIT 20
) sub
ORDER BY id ASC");
while ($torrent = $DB->next_record()) {
$Title = $torrent['ArtistName'].' - '.$torrent['GroupName'].' - '.$torrent['Recorded'].' | '.$torrent['Codec'].' / '.$torrent['Media'].' / '.$torrent['Container'].' / '.$torrent['Resolution'].' / '.$torrent['AudioFormat'];
$Item = self::item($Title, Text::strip_bbcode($torrent['WikiBody']), 'torrents.php?action=download&authkey=[[AUTHKEY]]&torrent_pass=[[PASSKEY]]&id='.$torrent['ID'], $torrent['UserID'], 'torrents.php?id='.$torrent['GroupID']);
self::populate('torrents_all', $Item);
echo str_replace(array('[[PASSKEY]]', '[[AUTHKEY]]'), array(display_str($PassKey), display_str($AuthKey)), $Item);
}
} else {
foreach ($Entries as $Item) {
echo str_replace(array('[[PASSKEY]]', '[[AUTHKEY]]'), array(display_str($PassKey), display_str($AuthKey)), $Item);
}
}
}
function populate($CacheKey, $Item) {
global $Cache;
$Entries = $Cache->get_value($CacheKey, true);
if (!$Entries) {
$Entries = [];
} else {
if (count($Entries) >= 50) {
array_pop($Entries);
}
}
array_unshift($Entries, $Item);
$Cache->cache_value($CacheKey, $Entries, 0); //inf cache
}
}