home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Mirror.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  3.3 KB  |  100 lines

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 5                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at the following url:           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Alexander Merz <alexmerz@php.net>                            |
  17. // |                                                                      |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: Mirror.php,v 1.3 2004/01/08 17:33:13 sniper Exp $
  21.  
  22. require_once "PEAR/Command/Common.php";
  23. require_once "PEAR/Command.php";
  24. require_once "PEAR/Remote.php";
  25. require_once "PEAR.php";
  26.  
  27. /**
  28.  * PEAR commands for providing file mirrors
  29.  *
  30.  */
  31. class PEAR_Command_Mirror extends PEAR_Command_Common
  32. {
  33.     // {{{ properties
  34.  
  35.     var $commands = array(
  36.         'download-all' => array(
  37.             'summary' => 'Downloads each avaible Package from master_server',
  38.             'function' => 'doDownloadAll',
  39.             'shortcut' => 'da',
  40.             'options' => array(),
  41.             'doc' => '
  42.         Request a list of avaible Packages from the Package-Server
  43.         (master_server) and downloads them to current working dir'
  44.             ),
  45.         );
  46.  
  47.     // }}}
  48.  
  49.     // {{{ constructor
  50.  
  51.     /**
  52.      * PEAR_Command_Mirror constructor.
  53.      *
  54.      * @access public
  55.      * @param object PEAR_Frontend a reference to an frontend
  56.      * @param object PEAR_Config a reference to the configuration data
  57.      */
  58.     function PEAR_Command_Mirror(&$ui, &$config)
  59.     {
  60.         parent::PEAR_Command_Common($ui, $config);
  61.     }
  62.  
  63.     // }}}
  64.  
  65.     // {{{ doDownloadAll()
  66.     /**
  67.     * retrieves a list of avaible Packages from master server
  68.     * and downloads them
  69.     *
  70.     * @access public
  71.     * @param string $command the command
  72.     * @param array $options the command options before the command
  73.     * @param array $params the stuff after the command name
  74.     * @return bool true if succesful
  75.     * @throw PEAR_Error 
  76.     */
  77.     function doDownloadAll($command, $options, $params)
  78.     {
  79.     $this->config->set("php_dir", "."); 
  80.     $remote = &new PEAR_Remote($this->config);
  81.     $remoteInfo = $remote->call("package.listAll");
  82.     if(PEAR::isError($remoteInfo)) {
  83.         return $remoteInfo;
  84.     }
  85.     $cmd = &PEAR_Command::factory("download", $this->config);
  86.     if(PEAR::isError($cmd)) {
  87.         return $cmd;
  88.     }    
  89.     foreach($remoteInfo as $pkgn=>$pkg) {   
  90.         // error handling not neccesary, because
  91.         // already done by the download command
  92.         $cmd->run("download", array(), array($pkgn));       
  93.       } 
  94.  
  95.         return true;
  96.     }
  97.  
  98.     // }}}
  99. }
  100.