2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
if (!empty($_GET['userid']) && is_number($_GET['userid'])) {
|
|
|
|
$UserID = $_GET['userid'];
|
|
|
|
} else {
|
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
|
2012-10-21 08:00:14 +00:00
|
|
|
if (!check_perms('zip_downloader')) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(403);
|
|
|
|
}
|
|
|
|
|
2012-10-11 08:00:15 +00:00
|
|
|
$User = Users::user_info($UserID);
|
|
|
|
$Perms = Permissions::get_permissions($User['PermissionID']);
|
2011-05-12 10:24:03 +00:00
|
|
|
$UserClass = $Perms['Class'];
|
2013-02-21 08:00:30 +00:00
|
|
|
list($UserID, $Username) = array_values($User);
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
if (empty($_GET['type'])) {
|
|
|
|
error(0);
|
|
|
|
} else {
|
2013-05-16 16:15:57 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
switch ($_GET['type']) {
|
|
|
|
case 'uploads':
|
2012-10-21 08:00:14 +00:00
|
|
|
if (!check_paranoia('uploads', $User['Paranoia'], $UserClass, $UserID)) {
|
|
|
|
error(403);
|
|
|
|
}
|
2013-11-19 08:00:48 +00:00
|
|
|
$SQL = "WHERE t.UserID = '$UserID'";
|
2011-03-28 14:21:28 +00:00
|
|
|
$Month = "t.Time";
|
|
|
|
break;
|
|
|
|
case 'snatches':
|
2012-10-21 08:00:14 +00:00
|
|
|
if (!check_paranoia('snatched', $User['Paranoia'], $UserClass, $UserID)) {
|
|
|
|
error(403);
|
|
|
|
}
|
2013-11-19 08:00:48 +00:00
|
|
|
$SQL = "
|
|
|
|
JOIN xbt_snatched AS x ON t.ID = x.fid
|
|
|
|
WHERE x.uid = '$UserID'";
|
2011-03-28 14:21:28 +00:00
|
|
|
$Month = "FROM_UNIXTIME(x.tstamp)";
|
|
|
|
break;
|
|
|
|
case 'seeding':
|
2012-10-21 08:00:14 +00:00
|
|
|
if (!check_paranoia('seeding', $User['Paranoia'], $UserClass, $UserID)) {
|
|
|
|
error(403);
|
|
|
|
}
|
2013-11-19 08:00:48 +00:00
|
|
|
$SQL = "
|
|
|
|
JOIN xbt_files_users AS xfu ON t.ID = xfu.fid
|
|
|
|
WHERE xfu.uid = '$UserID'
|
|
|
|
AND xfu.remaining = 0";
|
2011-03-28 14:21:28 +00:00
|
|
|
$Month = "FROM_UNIXTIME(xfu.mtime)";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-16 16:15:57 +00:00
|
|
|
$DownloadsQ = $DB->query("
|
|
|
|
SELECT
|
|
|
|
t.ID AS TorrentID,
|
2013-11-19 08:00:48 +00:00
|
|
|
DATE_FORMAT($Month, '%Y - %m') AS Month,
|
2013-05-16 16:15:57 +00:00
|
|
|
t.GroupID,
|
|
|
|
t.Media,
|
|
|
|
t.Format,
|
|
|
|
t.Encoding,
|
2013-11-19 08:00:48 +00:00
|
|
|
IF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year,
|
2013-05-16 16:15:57 +00:00
|
|
|
tg.Name,
|
|
|
|
t.Size
|
2013-11-17 08:00:47 +00:00
|
|
|
FROM torrents AS t
|
2013-11-19 08:00:48 +00:00
|
|
|
JOIN torrents_group AS tg ON t.GroupID = tg.ID
|
2013-05-16 16:15:57 +00:00
|
|
|
$SQL
|
2013-02-21 08:00:30 +00:00
|
|
|
GROUP BY TorrentID");
|
|
|
|
|
|
|
|
$Collector = new TorrentsDL($DownloadsQ, "$Username's ".ucfirst($_GET['type']));
|
|
|
|
|
|
|
|
while (list($Downloads, $GroupIDs) = $Collector->get_downloads('TorrentID')) {
|
|
|
|
$Artists = Artists::get_artists($GroupIDs);
|
|
|
|
$TorrentIDs = array_keys($GroupIDs);
|
2013-05-16 16:15:57 +00:00
|
|
|
$TorrentFilesQ = $DB->query('
|
|
|
|
SELECT TorrentID, File
|
|
|
|
FROM torrents_files
|
|
|
|
WHERE TorrentID IN ('.implode(',', $TorrentIDs).')', false);
|
2013-02-21 08:00:30 +00:00
|
|
|
if (is_int($TorrentFilesQ)) {
|
|
|
|
// Query failed. Let's not create a broken zip archive
|
|
|
|
foreach ($TorrentIDs as $TorrentID) {
|
|
|
|
$Download =& $Downloads[$TorrentID];
|
|
|
|
$Download['Artist'] = Artists::display_artists($Artists[$Download['GroupID']], false, true, false);
|
|
|
|
$Collector->fail_file($Download);
|
2012-10-21 08:00:14 +00:00
|
|
|
}
|
2013-02-21 08:00:30 +00:00
|
|
|
continue;
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-02-21 08:00:30 +00:00
|
|
|
while (list($TorrentID, $TorrentFile) = $DB->next_record(MYSQLI_NUM, false)) {
|
|
|
|
$Download =& $Downloads[$TorrentID];
|
|
|
|
$Download['Artist'] = Artists::display_artists($Artists[$Download['GroupID']], false, true, false);
|
2013-02-25 21:16:55 +00:00
|
|
|
$Collector->add_file($TorrentFile, $Download, $Download['Month']);
|
2013-02-21 08:00:30 +00:00
|
|
|
unset($Download);
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
2013-02-21 08:00:30 +00:00
|
|
|
$Collector->finalize(false);
|
2012-08-25 08:00:15 +00:00
|
|
|
|
2013-08-22 08:00:54 +00:00
|
|
|
define('SKIP_NO_CACHE_HEADERS', 1);
|