} } //Stupid Recent Snatches On User Page if ($CategoryID == '1' && $Image != '') { $RecentSnatches = $Cache->get_value("recent_snatches_{$UserID}"); if (!empty($RecentSnatches)) { $Snatch = array('ID' => $GroupID, 'Name' => $Name, 'Artist' => $Artists, 'WikiImage' => $Image); if (!in_array($Snatch, $RecentSnatches)) { if (count($RecentSnatches) === 5) { array_pop($RecentSnatches); } array_unshift($RecentSnatches, $Snatch); } elseif (!is_array($RecentSnatches)) { $RecentSnatches = array($Snatch); } $Cache->cache_value("recent_snatches_{$UserID}", $RecentSnatches, 0); } } $DB->query("\n\tINSERT IGNORE INTO users_downloads (UserID, TorrentID, Time)\n\tVALUES ('{$UserID}', '{$TorrentID}', '" . sqltime() . "')"); $DB->query("\n\tSELECT File\n\tFROM torrents_files\n\tWHERE TorrentID = '{$TorrentID}'"); Torrents::set_snatch_update_time($UserID, Torrents::SNATCHED_UPDATE_AFTERDL); list($Contents) = $DB->next_record(MYSQLI_NUM, false); $FileName = TorrentsDL::construct_file_name($Info['PlainArtists'], $Name, $Year, $Media, $Format, $Encoding, false, $DownloadAlt); if ($DownloadAlt) { header('Content-Type: text/plain; charset=utf-8'); } elseif (!$DownloadAlt || $Failed) { header('Content-Type: application/x-bittorrent; charset=utf-8'); } header('Content-disposition: attachment; filename="' . $FileName . '"'); echo TorrentsDL::get_file($Contents, ANNOUNCE_URL . "/{$TorrentPass}/announce"); define('SKIP_NO_CACHE_HEADERS', 1);
$SQL = "\n\t\t\t\t\tJOIN xbt_snatched AS x ON t.ID = x.fid\n\t\t\t\tWHERE x.uid = '{$UserID}'"; $Month = "FROM_UNIXTIME(x.tstamp)"; break; case 'seeding': if (!check_paranoia('seeding', $User['Paranoia'], $UserClass, $UserID)) { error(403); } $SQL = "\n\t\t\t\t\tJOIN xbt_files_users AS xfu ON t.ID = xfu.fid\n\t\t\t\tWHERE xfu.uid = '{$UserID}'\n\t\t\t\t\tAND xfu.remaining = 0"; $Month = "FROM_UNIXTIME(xfu.mtime)"; break; default: error(0); } } $DownloadsQ = $DB->query("\n\tSELECT\n\t\tt.ID AS TorrentID,\n\t\tDATE_FORMAT({$Month}, '%Y - %m') AS Month,\n\t\tt.GroupID,\n\t\tt.Media,\n\t\tt.Format,\n\t\tt.Encoding,\n\t\tIF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year,\n\t\ttg.Name,\n\t\tt.Size\n\tFROM torrents AS t\n\t\tJOIN torrents_group AS tg ON t.GroupID = tg.ID\n\t{$SQL}\n\tGROUP 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); } continue;
$SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5.5'"; break; case '45': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5'"; break; case '46': $SQL .= "t.Format = 'AAC' AND t.Encoding = '192'"; break; default: error(0); } $SQL .= " THEN {$Priority} "; } $SQL .= "\n\t\tELSE 100\n\tEND AS Rank,\n\tt.GroupID,\n\tt.ID AS TorrentID,\n\tt.Media,\n\tt.Format,\n\tt.Encoding,\n\tIF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year,\n\ttg.Name,\n\tt.Size\nFROM torrents AS t\n\tINNER JOIN collages_torrents AS c ON t.GroupID = c.GroupID AND c.CollageID = '{$CollageID}'\n\tINNER JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1'\nORDER BY t.GroupID ASC, Rank DESC, t.{$Preference}"; $DownloadsQ = $DB->query($SQL); $Collector = new TorrentsDL($DownloadsQ, $CollageName); while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) { $Artists = Artists::get_artists($GroupIDs); $TorrentFilesQ = $DB->query("\n\t\tSELECT TorrentID, File\n\t\tFROM torrents_files\n\t\tWHERE TorrentID IN (" . implode(',', array_keys($GroupIDs)) . ')', false); if (is_int($TorrentFilesQ)) { // Query failed. Let's not create a broken zip archive foreach ($GroupIDs as $GroupID) { $Download =& $Downloads[$GroupID]; $Download['Artist'] = Artists::display_artists($Artists[$GroupID], false, true, false); $Collector->fail_file($Download); } continue; } while (list($TorrentID, $TorrentFile) = $DB->next_record(MYSQLI_NUM, false)) { $GroupID = $GroupIDs[$TorrentID]; $Download =& $Downloads[$GroupID];