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

Source for file torrentinfo.php

Documentation is available at torrentinfo.php

  1. <?php
  2.  
  3.     /**
  4.     * File_Bittorrent Example
  5.     * Get Info from a .torrent file
  6.     *
  7.     * Usage:
  8.     *   # php torrentinfo.php -t file.torrent
  9.     *
  10.     * @author Markus Tacker <m@tacker.org>
  11.     * @version $Id: torrentinfo.php 10 2005-02-04 12:05:14Z m $
  12.     */
  13.  
  14.     // Includes
  15.     require_once 'File/Bittorrent/Decode.php';
  16.     require_once 'Console/Getargs.php';
  17.  
  18.     // Get filename from command line
  19.     $args_config = array(
  20.         'torrent' => array(
  21.             'short' => 't',
  22.             'min' => 1,
  23.             'max' => 1,
  24.             'desc' => 'Filename of the torrent'
  25.         ),
  26.     );
  27.     $args =Console_Getargs::factory($args_config);
  28.     if (PEAR::isError($argsor !($torrent $args->getValue('torrent'))) {
  29.         echo Console_Getargs::getHelp($args_config)."\n";
  30.         exit;
  31.     }
  32.  
  33.     if (!is_readable($torrent)) {
  34.         echo 'ERROR: "' $torrent "\" is not readable.\n";
  35.         exit;
  36.     }
  37.  
  38.     $File_Bittorrent_Decode = new File_Bittorrent_Decode;
  39.     $info $File_Bittorrent_Decode->decodeFile($torrent);
  40.  
  41.     foreach ($info as $key => $val{
  42.         echo str_pad($key ': '20' 'STR_PAD_LEFT);
  43.         switch($key{
  44.         case 'files':
  45.             echo "\n";
  46.             foreach ($val as $file{
  47.                 echo str_repeat(' '20'- ' $file['filename'"\n";
  48.             }
  49.             break;
  50.         case 'announce_list':
  51.             echo "\n";
  52.             foreach ($val as $url{
  53.                 echo str_repeat(' '20'- ' $url "\n";
  54.             }
  55.             break;
  56.         default:
  57.             echo $val "\n";
  58.         }
  59.     }
  60.  
  61. ?>

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