<?php /** * Simple tracker server implementation for system test. * Being run with PHP's built-in web server (or Apache). * @package StealThisTracker * @author StealThisShow <*****@*****.**> * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause * @see SeedServerTest */ // No tolerance for errors - it's a test. set_error_handler(function ($errno, $errstr, $errfile = null, $errline = null) { throw new Exception("Error {$errno}: {$errstr} in {$errfile}:{$errline}"); }); require dirname(__FILE__) . '/../../vendor/autoload.php'; use StealThisShow\StealThisTracker\Persistence\Pdo; use StealThisShow\StealThisTracker\Core; $persistence = new Pdo('sqlite:' . sys_get_temp_dir() . '/sqlite_test.db'); $core = new Core($persistence); $core->setInterval(60)->setIp($_SERVER['REMOTE_ADDR']); echo $core->announce($_GET);
* * @package StealThisTracker * @author StealThisShow <*****@*****.**> * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause */ use StealThisShow\StealThisTracker\Core; use StealThisShow\StealThisTracker\Torrent; use StealThisShow\StealThisTracker\Persistence\Pdo; use StealThisShow\StealThisTracker\File\File; // ----------------------------------------------------------- // This is how to create a .torrent file from a physical file. // ----------------------------------------------------------- // Composer autoloader require dirname(__FILE__) . '/../vendor/autoload.php'; // Persistence object implementing PersistenceInterface. // We use Pdo here. $persistence = new Pdo('sqlite:sqlite_example.db'); // Core class managing creating the file. $core = new Core($persistence); // The torrent file $file = new File('/path/to/file.ext'); // The first parameters is the file. $torrent = new Torrent($file); $torrent->setAnnounceList(array('http://announce'))->setSizePiece(262144); // Setting appropriate HTTP header and sending back the .torrrent file. // This is VERY inefficient to do! SAVE the .torrent file on your server and // serve the saved copy! header('Content-Type: application/x-bittorrent'); header('Content-Disposition: attachment; filename="test.torrent"'); // Outputs torrent content echo (string) $core->addTorrent($torrent);
<?php /** * Scrape example * * @package StealThisTracker * @author StealThisShow <*****@*****.**> * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause */ use StealThisShow\StealThisTracker\Core; use StealThisShow\StealThisTracker\Persistence\Pdo; // --------------------------------------- // This is how to set up a scrape URL. // --------------------------------------- // Composer autoloader require dirname(__FILE__) . '/../vendor/autoload.php'; // Persistence object implementing PersistenceInterface. // We use Pdo here. $persistence = new Pdo('sqlite:sqlite_example.db'); // Core class managing the scrapes. $core = new Core($persistence); // We simply send back the results of the scrape method to the client. echo (string) $core->scrape($_GET);