/** * Convert a stored torrent into a binary file that can be loaded in a torrent client * * @param mixed $TorrentData bencoded torrent without announce URL (new format) or TORRENT object (old format) * @return bencoded string */ public static function get_file(&$TorrentData, $AnnounceURL) { if (Misc::is_new_torrent($TorrentData)) { return BencodeTorrent::add_announce_url($TorrentData, $AnnounceURL); } $Tor = new TORRENT(unserialize(base64_decode($TorrentData)), true); $Tor->set_announce_url($AnnounceURL); unset($Tor->Val['announce-list']); unset($Tor->Val['url-list']); unset($Tor->Val['libtorrent_resume']); return $Tor->enc(); }
if(!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'btjunkie.org')) { $DB->query("UPDATE users_main SET Cursed='1' WHERE ID='$UserID'"); $DB->query("UPDATE users_info SET AdminComment=CONCAT('".sqltime()." - Account cursed at $LoggedUser[BytesDownloaded] bytes downloaded for accessing the site from ".db_string($_SERVER['HTTP_REFERER'])." ', AdminComment) WHERE UserID='$LoggedUser[ID]'"); } $DB->query("INSERT INTO users_downloads (UserID, TorrentID, Time) VALUES ('$UserID', '$TorrentID', '".sqltime()."') ON DUPLICATE KEY UPDATE Time=VALUES(Time)"); $DB->query("SELECT File FROM torrents_files WHERE TorrentID='$TorrentID'"); list($Contents) = $DB->next_record(MYSQLI_NUM, array(0)); $Contents = unserialize(base64_decode($Contents)); $Tor = new TORRENT($Contents, true); // New TORRENT object // Set torrent announce URL $Tor->set_announce_url(ANNOUNCE_URL.'/'.$TorrentPass.'/announce'); // Remove multiple trackers from torrent unset($Tor->Val['announce-list']); // Remove web seeds (put here for old torrents not caught by previous commit unset($Tor->Val['url-list']); // Torrent name takes the format of Artist - Album - YYYY (Media - Format - Encoding) $TorrentName=''; $TorrentInfo=''; $TorrentName = $Artists; $TorrentName.=$Name; if ($Year>0) { $TorrentName.=' - '.$Year; }
$DB->query("SELECT DATE_FORMAT(t.Time,'%b \'%y') AS Month, t.GroupID, t.Media, t.Format, t.Encoding, IF(t.RemasterYear=0,tg.Year,t.RemasterYear), tg.Name, t.Size, f.File FROM torrents as t JOIN torrents_group AS tg ON t.GroupID=tg.ID LEFT JOIN torrents_files AS f ON t.ID=f.TorrentID ".$SQL); $Downloads = $DB->to_array(false,MYSQLI_NUM,false); $Artists = get_artists($DB->collect('GroupID')); list($UserID, $Username) = array_values(user_info($UserID)); $Zip = new ZIP($Username.'\'s '.ucfirst($_GET['type'])); foreach($Downloads as $Download) { list($Month, $GroupID, $Media, $Format, $Encoding, $Year, $Album, $Size, $Contents) = $Download; $Artist = display_artists($Artists[$GroupID],false); $Contents = unserialize(base64_decode($Contents)); $Tor = new TORRENT($Contents, true); $Tor->set_announce_url(ANNOUNCE_URL.'/'.$LoggedUser['torrent_pass'].'/announce'); unset($Tor->Val['announce-list']); $Zip->add_file($Tor->enc(), file_string($Month).'/'.file_string($Artist.$Album).' - '.file_string($Year).' ('.file_string($Media).' - '.file_string($Format).' - '.file_string($Encoding).').torrent'); } $Zip->close_stream();