/** * Get list of files for a torrent * @return array */ public function getFiles($url) { $url = "uploads/torrents/" . $url; if (!file_exists($url)) { return false; } // Loading BitTorrent class require_once "../lib/bittorrent/Autoload.php"; // Open a new torrent instance $torrent = new PHP_BitTorrent_Torrent(); // Load torrent $torrent->loadFromTorrentFile($url); // Get filelist $fileList = $torrent->getFileList(); // If it returns only one file, build array like multi-file. if (is_string($fileList)) { return array(array("length" => $torrent->getSize(), "path" => array($fileList))); } else { return $fileList; } }