File_Bittorrent
[ class tree: File_Bittorrent ] [ index: File_Bittorrent ] [ all elements ]

Source for file scrape.php

Documentation is available at scrape.php

  1. <?php
  2.  
  3.     /**
  4.     * Fetch the statistics for a torrent
  5.     *
  6.     * Usage:
  7.     *   # php scrape.php -t file
  8.     *
  9.     * @author Markus Tacker <m@tacker.org>
  10.     * @version $Id: scrape.php 35 2005-07-21 10:58:19Z m $
  11.     */
  12.  
  13.     // Includes
  14.     require_once 'File/Bittorrent/Decode.php';
  15.     require_once 'Console/Getargs.php';
  16.  
  17.     // Get filename from command line
  18.     $args_config = array(
  19.         'torrent' => array(
  20.             'short' => 't',
  21.             'min' => 1,
  22.             'max' => 1,
  23.             'desc' => 'Filename of the torrent'
  24.         ),
  25.     );
  26.     $args =Console_Getargs::factory($args_config);
  27.     if (PEAR::isError($argsor !($torrent $args->getValue('torrent'))) {
  28.         echo Console_Getargs::getHelp($args_config)."\n";
  29.         exit;
  30.     }
  31.  
  32.     if (!is_readable($torrent)) {
  33.         echo 'ERROR: "' $torrent "\" is not readable.\n";
  34.         exit;
  35.     }
  36.  
  37.     // Decode the torrent
  38.     $File_Bittorrent_Decode = new File_Bittorrent_Decode;
  39.     $File_Bittorrent_Decode->decodeFile($torrent);
  40.  
  41.     echo "\nStatistics\n";
  42.     echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
  43.     echo 'Tracker:            ' $File_Bittorrent_Decode->announce . "\n";
  44.     echo 'info hash:          ' $File_Bittorrent_Decode->info_hash . "\n";
  45.     foreach ($File_Bittorrent_Decode->getStats(as $key => $val{
  46.         echo str_pad($key ':'20$val "\n";
  47.     }
  48.  
  49. ?>

Documentation generated on Mon, 11 Mar 2019 14:18:19 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.