root/trunk2/infohash.php
| Revision 77, 3.0 KB (checked in by m, 17 months ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | <?php |
| 2 | |
| 3 | // +----------------------------------------------------------------------+ |
| 4 | // | Decode and Encode data in Bittorrent format | |
| 5 | // +----------------------------------------------------------------------+ |
| 6 | // | Copyright (C) 2004-2005 Markus Tacker <m@tacker.org> | |
| 7 | // +----------------------------------------------------------------------+ |
| 8 | // | This library is free software; you can redistribute it and/or | |
| 9 | // | modify it under the terms of the GNU Lesser General Public | |
| 10 | // | License as published by the Free Software Foundation; either | |
| 11 | // | version 2.1 of the License, or (at your option) any later version. | |
| 12 | // | | |
| 13 | // | This library is distributed in the hope that it will be useful, | |
| 14 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 | // | Lesser General Public License for more details. | |
| 17 | // | | |
| 18 | // | You should have received a copy of the GNU Lesser General Public | |
| 19 | // | License along with this library; if not, write to the | |
| 20 | // | Free Software Foundation, Inc. | |
| 21 | // | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 22 | // +----------------------------------------------------------------------+ |
| 23 | |
| 24 | /** |
| 25 | * Info-Hash Test |
| 26 | * Compares the info_hash compution of this package to the original program implementation |
| 27 | * |
| 28 | * Usage: |
| 29 | * # php infohash.php -t file.torrent |
| 30 | * |
| 31 | * @author Markus Tacker <m@tacker.org> |
| 32 | * @version $Id$ |
| 33 | */ |
| 34 | |
| 35 | error_reporting(E_ALL); |
| 36 | |
| 37 | // Includes |
| 38 | require_once 'File/Bittorrent2/Decode.php'; |
| 39 | require_once 'Console/Getargs.php'; |
| 40 | |
| 41 | // Get filename from command line |
| 42 | $args_config = array( |
| 43 | 'torrent' => array( |
| 44 | 'short' => 't', |
| 45 | 'min' => 1, |
| 46 | 'max' => 1, |
| 47 | 'desc' => 'Filename of the torrent' |
| 48 | ), |
| 49 | ); |
| 50 | $args =& Console_Getargs::factory($args_config); |
| 51 | if (PEAR::isError($args) or !($torrent = $args->getValue('torrent'))) { |
| 52 | echo Console_Getargs::getHelp($args_config)."\n"; |
| 53 | exit; |
| 54 | } |
| 55 | |
| 56 | if (!is_readable($torrent)) { |
| 57 | echo 'ERROR: "' . $torrent . "\" is not readable.\n"; |
| 58 | exit; |
| 59 | } |
| 60 | |
| 61 | $File_Bittorrent2_Decode = new File_Bittorrent2_Decode; |
| 62 | $File_Bittorrent2_Decode->decodeFile($torrent); |
| 63 | |
| 64 | echo "\nInfo Hash\n"; |
| 65 | echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; |
| 66 | echo "This: " . $File_Bittorrent2_Decode->getInfoHash() . "\n"; |
| 67 | |
| 68 | exec('torrentinfo-console ' . escapeshellarg($torrent), $bt); |
| 69 | echo "torrentinfo-console: " . substr($bt[3], strpos($bt[3], ':') + 2) . "\n"; |
| 70 | |
| 71 | ?> |
Note: See TracBrowser
for help on using the browser.