Gazelle/sections/feeds/index.php

198 lines
7.0 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
// Main feeds page
// The feeds don't use script_start.php, their code resides entirely in feeds.php in the document root
2013-02-22 08:00:24 +00:00
// Bear this in mind when you try to use script_start functions.
2011-03-28 14:21:28 +00:00
if (
2013-08-28 23:08:41 +00:00
empty($_GET['feed'])
|| empty($_GET['authkey'])
|| empty($_GET['auth'])
|| empty($_GET['passkey'])
|| empty($_GET['user'])
|| !is_number($_GET['user'])
|| strlen($_GET['authkey']) != 32
|| strlen($_GET['passkey']) != 32
|| strlen($_GET['auth']) != 32
2011-03-28 14:21:28 +00:00
) {
$Feed->open_feed();
$Feed->channel('Blocked', 'RSS feed.');
$Feed->close_feed();
die();
}
$User = (int)$_GET['user'];
2013-04-19 08:00:55 +00:00
if (!$Enabled = $Cache->get_value('enabled_'.$User)) {
2013-05-27 08:00:58 +00:00
require(SERVER_ROOT.'/classes/mysql.class.php');
2011-03-28 14:21:28 +00:00
$DB=NEW DB_MYSQL; //Load the database wrapper
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT Enabled
FROM users_main
WHERE ID = '$User'");
2011-03-28 14:21:28 +00:00
list($Enabled) = $DB->next_record();
2013-07-04 08:00:56 +00:00
$Cache->cache_value("enabled_$User", $Enabled, 0);
2011-03-28 14:21:28 +00:00
}
if (md5($User.RSS_HASH.$_GET['passkey']) != $_GET['auth'] || $Enabled != 1) {
$Feed->open_feed();
$Feed->channel('Blocked', 'RSS feed.');
$Feed->close_feed();
die();
}
$Feed->open_feed();
2013-04-19 08:00:55 +00:00
switch ($_GET['feed']) {
2013-02-22 08:00:24 +00:00
case 'feed_news':
2011-03-28 14:21:28 +00:00
$Feed->channel('News', 'RSS feed for site news.');
if (!$News = $Cache->get_value('news')) {
2013-05-27 08:00:58 +00:00
require(SERVER_ROOT.'/classes/mysql.class.php'); //Require the database wrapper
2011-03-28 14:21:28 +00:00
$DB=NEW DB_MYSQL; //Load the database wrapper
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT
ID,
Title,
Body,
Time
2011-03-28 14:21:28 +00:00
FROM news
ORDER BY Time DESC
LIMIT 10");
2013-07-04 08:00:56 +00:00
$News = $DB->to_array(false, MYSQLI_NUM, false);
$Cache->cache_value('news', $News, 1209600);
2011-03-28 14:21:28 +00:00
}
$Count = 0;
foreach ($News as $NewsItem) {
list($NewsID,$Title,$Body,$NewsTime) = $NewsItem;
if (strtotime($NewsTime) >= time()) {
continue;
}
2013-12-12 08:01:01 +00:00
echo $Feed->item($Title, Text::strip_bbcode($Body), "index.php#news$NewsID", SITE_NAME.' Staff', '', '', $NewsTime);
2011-03-28 14:21:28 +00:00
if (++$Count > 4) {
break;
}
}
break;
2013-02-22 08:00:24 +00:00
case 'feed_blog':
2011-03-28 14:21:28 +00:00
$Feed->channel('Blog', 'RSS feed for site blog.');
if (!$Blog = $Cache->get_value('blog')) {
2013-05-27 08:00:58 +00:00
require(SERVER_ROOT.'/classes/mysql.class.php'); //Require the database wrapper
2013-05-04 08:00:48 +00:00
$DB = NEW DB_MYSQL; //Load the database wrapper
$DB->query("
SELECT
b.ID,
um.Username,
b.Title,
b.Body,
b.Time,
b.ThreadID
FROM blog AS b
2013-07-04 08:00:56 +00:00
LEFT JOIN users_main AS um ON b.UserID = um.ID
2011-03-28 14:21:28 +00:00
ORDER BY Time DESC
LIMIT 20");
$Blog = $DB->to_array();
2013-07-04 08:00:56 +00:00
$Cache->cache_value('Blog', $Blog, 1209600);
2011-03-28 14:21:28 +00:00
}
foreach ($Blog as $BlogItem) {
list($BlogID, $Author, $Title, $Body, $BlogTime, $ThreadID) = $BlogItem;
2013-05-04 08:00:48 +00:00
if ($ThreadID) {
2013-12-12 08:01:01 +00:00
echo $Feed->item($Title, Text::strip_bbcode($Body), 'forums.php?action=viewthread&amp;threadid='.$ThreadID, SITE_NAME.' Staff', '', '', $BlogTime);
2012-08-30 08:00:17 +00:00
} else {
2013-12-12 08:01:01 +00:00
echo $Feed->item($Title, Text::strip_bbcode($Body), "blog.php#blog$BlogID", SITE_NAME.' Staff', '', '', $BlogTime);
2012-08-30 08:00:17 +00:00
}
2011-03-28 14:21:28 +00:00
}
break;
2013-06-16 08:01:11 +00:00
case 'feed_changelog':
$Feed->channel('Gazelle Change Log', 'RSS feed for Gazelle\'s changelog.');
if (!$Changelog = $Cache->get_value('changelog')) {
require(SERVER_ROOT.'/classes/mysql.class.php');
require(SERVER_ROOT.'/classes/misc.class.php');
$DB = NEW DB_MYSQL;
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT Message, Author, Date(Time)
FROM changelog
ORDER BY Time DESC
LIMIT 20");
2013-06-16 08:01:11 +00:00
$Changelog = $DB->to_array();
$Cache->cache_value('changelog', $Changelog, 86400);
}
foreach ($Changelog as $Change) {
list($Message, $Author, $Date) = $Change;
2013-07-04 08:00:56 +00:00
echo $Feed->item("$Date by $Author", $Message, 'tools.php?action=change_log', SITE_NAME.' Staff', '', '', $Date);
2013-06-16 08:01:11 +00:00
}
break;
2013-02-22 08:00:24 +00:00
case 'torrents_all':
2011-03-28 14:21:28 +00:00
$Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_all', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_music':
2011-03-28 14:21:28 +00:00
$Feed->channel('Music Torrents', 'RSS feed for all new music torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_music', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_apps':
2011-03-28 14:21:28 +00:00
$Feed->channel('Application Torrents', 'RSS feed for all new application torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_apps', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_ebooks':
2011-03-28 14:21:28 +00:00
$Feed->channel('E-Book Torrents', 'RSS feed for all new e-book torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_ebooks', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_abooks':
2011-03-28 14:21:28 +00:00
$Feed->channel('Audiobook Torrents', 'RSS feed for all new audiobook torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_abooks', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_evids':
2011-03-28 14:21:28 +00:00
$Feed->channel('E-Learning Video Torrents', 'RSS feed for all new e-learning video torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_evids', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_comedy':
2011-03-28 14:21:28 +00:00
$Feed->channel('Comedy Torrents', 'RSS feed for all new comedy torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_comedy', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_comics':
2011-03-28 14:21:28 +00:00
$Feed->channel('Comic Torrents', 'RSS feed for all new comic torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_comics', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_mp3':
2011-03-28 14:21:28 +00:00
$Feed->channel('MP3 Torrents', 'RSS feed for all new mp3 torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_mp3', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_flac':
2011-03-28 14:21:28 +00:00
$Feed->channel('FLAC Torrents', 'RSS feed for all new FLAC torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_flac', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_vinyl':
2011-03-28 14:21:28 +00:00
$Feed->channel('Vinyl Sourced Torrents', 'RSS feed for all new vinyl sourced torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_vinyl', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_lossless':
2011-03-28 14:21:28 +00:00
$Feed->channel('Lossless Torrents', 'RSS feed for all new lossless uploads.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_lossless', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
case 'torrents_lossless24':
2011-03-28 14:21:28 +00:00
$Feed->channel('24bit Lossless Torrents', 'RSS feed for all new 24bit uploads.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_lossless24', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
break;
default:
// Personalized torrents
2013-05-04 08:00:48 +00:00
if (empty($_GET['name']) && substr($_GET['feed'], 0, 16) == 'torrents_notify_') {
2011-03-28 14:21:28 +00:00
// All personalized torrent notifications
$Feed->channel('Personalized torrent notifications', 'RSS feed for personalized torrent notifications.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve($_GET['feed'], $_GET['authkey'], $_GET['passkey']);
2013-05-04 08:00:48 +00:00
} elseif (!empty($_GET['name']) && substr($_GET['feed'], 0, 16) == 'torrents_notify_') {
2011-03-28 14:21:28 +00:00
// Specific personalized torrent notification channel
$Feed->channel(display_str($_GET['name']), 'Personal RSS feed: '.display_str($_GET['name']));
2013-07-04 08:00:56 +00:00
$Feed->retrieve($_GET['feed'], $_GET['authkey'], $_GET['passkey']);
2013-05-04 08:00:48 +00:00
} elseif (!empty($_GET['name']) && substr($_GET['feed'], 0, 21) == 'torrents_bookmarks_t_') {
2012-02-08 08:00:20 +00:00
// Bookmarks
$Feed->channel('Bookmarked torrent notifications', 'RSS feed for bookmarked torrents.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve($_GET['feed'], $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
} else {
$Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.');
2013-07-04 08:00:56 +00:00
$Feed->retrieve('torrents_all', $_GET['authkey'], $_GET['passkey']);
2011-03-28 14:21:28 +00:00
}
}
$Feed->close_feed();
?>