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
|
|
|
|
2013-02-21 08:00:30 +00:00
|
|
|
require(SERVER_ROOT.'/classes/class_bencode.php');
|
2011-03-28 14:21:28 +00:00
|
|
|
require(SERVER_ROOT.'/classes/class_torrent.php');
|
|
|
|
|
|
|
|
if (empty($_GET['type'])) {
|
|
|
|
error(0);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
switch ($_GET['type']) {
|
|
|
|
case 'uploads':
|
2012-10-21 08:00:14 +00:00
|
|
|
if (!check_paranoia('uploads', $User['Paranoia'], $UserClass, $UserID)) {
|
|
|
|
error(403);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
$SQL = "WHERE t.UserID='$UserID'";
|
|
|
|
$Month = "t.Time";
|
|
|
|
break;
|
|
|
|
case 'snatches':
|
2012-10-21 08:00:14 +00:00
|
|
|
if (!check_paranoia('snatched', $User['Paranoia'], $UserClass, $UserID)) {
|
|
|
|
error(403);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
$SQL = "JOIN xbt_snatched AS x ON t.ID=x.fid WHERE x.uid='$UserID'";
|
|
|
|
$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);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
$SQL = "JOIN xbt_files_users AS xfu ON t.ID = xfu.fid WHERE xfu.uid='$UserID' AND xfu.remaining = 0";
|
|
|
|
$Month = "FROM_UNIXTIME(xfu.mtime)";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-21 08:00:30 +00:00
|
|
|
$DownloadsQ = $DB->query("SELECT
|
|
|
|
t.ID AS TorrentID,
|
2012-10-21 08:00:14 +00:00
|
|
|
DATE_FORMAT(".$Month.",'%Y - %m') AS Month,
|
2011-03-28 14:21:28 +00:00
|
|
|
t.GroupID,
|
|
|
|
t.Media,
|
|
|
|
t.Format,
|
|
|
|
t.Encoding,
|
2013-02-21 08:00:30 +00:00
|
|
|
IF(t.RemasterYear=0,tg.Year,t.RemasterYear) AS Year,
|
2011-03-28 14:21:28 +00:00
|
|
|
tg.Name,
|
2012-10-21 08:00:14 +00:00
|
|
|
t.Size
|
2013-02-21 08:00:30 +00:00
|
|
|
FROM torrents as t
|
2011-03-28 14:21:28 +00:00
|
|
|
JOIN torrents_group AS tg ON t.GroupID=tg.ID
|
2011-05-12 10:24:03 +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);
|
|
|
|
$TorrentFilesQ = $DB->query("SELECT TorrentID, File FROM torrents_files WHERE TorrentID IN (".implode(',', $TorrentIDs).")", false);
|
|
|
|
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);
|
|
|
|
if (Misc::is_new_torrent($TorrentFile)) {
|
|
|
|
$TorEnc = BEncTorrent::add_announce_url($TorrentFile, ANNOUNCE_URL."/$LoggedUser[torrent_pass]/announce");
|
|
|
|
} else {
|
|
|
|
$Contents = unserialize(base64_decode($TorrentFile));
|
|
|
|
$Tor = new TORRENT($Contents, true);
|
|
|
|
$Tor->set_announce_url(ANNOUNCE_URL."/$LoggedUser[torrent_pass]/announce");
|
|
|
|
unset($Tor->Val['announce-list']);
|
|
|
|
$TorEnc = $Tor->enc();
|
2012-10-21 08:00:14 +00:00
|
|
|
}
|
2013-02-21 08:00:30 +00:00
|
|
|
$Collector->add_file($TorEnc, $Download, $Download['Month']);
|
|
|
|
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
|
|
|
|
|
|
|
define('IE_WORKAROUND_NO_CACHE_HEADERS', 1);
|