query("SELECT t.ID, DATE_FORMAT(".$Month.",'%Y - %m') AS Month, t.GroupID, t.Media, t.Format, t.Encoding, IF(t.RemasterYear=0,tg.Year,t.RemasterYear), tg.Name, t.Size FROM torrents as t JOIN torrents_group AS tg ON t.GroupID=tg.ID ".$SQL." GROUP BY t.ID"); $Downloads = $DB->to_array(0, MYSQLI_NUM, false); $Artists = Artists::get_artists($DB->collect('GroupID')); if (!empty($Downloads)) { $DB->query("SELECT TorrentID, File FROM torrents_files WHERE TorrentID IN (".implode(',', array_keys($Downloads)).")"); $TorrentFiles = $DB->to_array(0, MYSQLI_NUM, false); } list($UserID, $Username) = array_values(Users::user_info($UserID)); $Zip = new ZIP($Username.'\'s '.ucfirst($_GET['type'])); foreach ($Downloads as $Download) { list($TorrentID, $Month, $GroupID, $Media, $Format, $Encoding, $Year, $Album, $Size) = $Download; if (!isset($TorrentFiles[$TorrentID])) { continue; } $Artist = Artists::display_artists($Artists[$GroupID],false,true,false); $Contents = unserialize(base64_decode($TorrentFiles[$TorrentID][1])); $Tor = new TORRENT($Contents, true); $Tor->set_announce_url(ANNOUNCE_URL.'/'.$LoggedUser['torrent_pass'].'/announce'); unset($Tor->Val['announce-list']); $TorrentName = ''; $TorrentInfo = ''; $TorrentName = $Artist; $TorrentName .= $Album; if ($Year > 0) { $TorrentName .= ' - '.$Year; } if ($Media != '') { $TorrentInfo .= $Media; } if ($Format != '') { if ($TorrentInfo != '') { $TorrentInfo .= ' - '; } $TorrentInfo .= $Format; } if ($Encoding!='') { if ($TorrentInfo != '') { $TorrentInfo .= ' - '; } $TorrentInfo .= $Encoding; } if ($TorrentInfo != '') { $TorrentName .= ' ('.$TorrentInfo.')'; } if (!$TorrentName) { $TorrentName = "No Name"; } $FileName = Misc::file_string($TorrentName); if ($Browser == 'Internet Explorer') { $FileName = urlencode($FileName); } $FileName .= '.torrent'; $Zip->add_file($Tor->enc(), Misc::file_string($Month).'/'.$FileName); } $Zip->close_stream(); define('IE_WORKAROUND_NO_CACHE_HEADERS', 1);