php-bittorrent
PHP classes for encoding/decoding data to/from the BitTorrent format, creating torrent files and running your own tracker.
Credits: Christer Edvartsen Download: here PHP_BitTorrent PHP_BitTorrent is a library that provides PHP classes that can be used to encode/decode to/from the BitTorrent format. It also provides tracker classes that can be used to run your own BitTorrent tracker. The package is not a complete tracker system like for instance btit. Requirements PHP_BitTorrent requires PHP 5.3.x or above. Installation PHP_BitTorrent should be installed using PEAR. The PEAR channel (pear.starzinger.net) that is used to distribute PHP_BitTorrent needs to be registered with the local PEAR environment. Code:
christer@aurora:~$ sudo pear channel-discover pear.starzinger.net Adding Channel "pear.starzinger.net" succeeded Discovery of channel "pear.starzinger.net" succeeded Code:
christer@aurora:~$ sudo pear install stz/PHP_BitTorrent-alpha downloading PHP_BitTorrent-0.0.1.tgz ... Starting to download PHP_BitTorrent-0.0.1.tgz (8,037 bytes) .....done: 8,037 bytes install ok: channel://pear.starzinger.net/PHP_BitTorrent-0.0.1 Encode PHP variables Code:
'bar', 'bar' => 'foo')); // string(22) "d3:foo3:bar3:bar3:fooe" Decode BitTorrent encoded data Code:
int(1) [1]=> int(2) [2]=> int(3) } var_dump(PHP_BitTorrent_Decoder::decodeDictionary('d3:foo3:bar3:bar3:fooe'); // array(2) { ["foo"]=> string(3) "bar" ["bar"]=> string(3) "foo" } Decode torrent files The decoder class also has a method for decoding a torrent file (which is an encoded dictionary): Code:
The PHP_BitTorrent_Torrent class represents a torrent file and can be used to create torrent files. Code:
setAnnounce('http://tracker/announce.php') ->setComment('Some comment') ->loadFromPath('/path/to/files') ->save('/save/path/file.torrent'); Code:
loadFromTorrentFile('/path/to/file.torrent') ->setAnnounce('http://tracker/announce.php') // Override announce in original file ->setComment('Some comment') // Override commend in original file ->save('/save/path/file.torrent'); // Save to a new file |
All times are GMT +2. The time now is 10:55. |
Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.