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

Source for file WebInstaller.php

Documentation is available at WebInstaller.php

  1. <?php
  2. /*
  3.   +----------------------------------------------------------------------+
  4.   | PHP Version 4                                                        |
  5.   +----------------------------------------------------------------------+
  6.   | Copyright (c) 1997-2003 The PHP Group                                |
  7.   +----------------------------------------------------------------------+
  8.   | This source file is subject to version 2.02 of the PHP license,      |
  9.   | that is bundled with this package in the file LICENSE, and is        |
  10.   | available at through the world-wide-web at                           |
  11.   | http://www.php.net/license/2_02.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: Christian Dickmann <dickmann@php.net>                        |
  17.   |         Pierre-Alain Joye <pajoye@php.net>                           |
  18.   +----------------------------------------------------------------------+
  19.  
  20.   $Id: WebInstaller.php,v 1.29 2004/05/25 20:59:36 pajoye Exp $
  21. */
  22. define('PEAR_Frontend_Web',1);
  23.  
  24. if (!isset($_SESSION['_PEAR_Frontend_Web_js'])) {
  25.     $_SESSION['_PEAR_Frontend_Web_js'= false;
  26. }
  27. if (isset($_GET['enableJS']&& $_GET['enableJS'== 1{
  28.     $_SESSION['_PEAR_Frontend_Web_js'= true;
  29. }
  30. define('USE_DHTML_PROGRESS'(@$useDHTML && $_SESSION['_PEAR_Frontend_Web_js']));
  31. if (!isset($pear_user_config)) {
  32.      $pear_user_config dirname(__FILE__)."/pear.conf";
  33. }
  34.  
  35. // Include needed files
  36. require_once 'PEAR.php';
  37. require_once 'PEAR/Registry.php';
  38. require_once 'PEAR/Config.php';
  39. require_once 'PEAR/Command.php';
  40.  
  41. // Init PEAR Installer Code and WebFrontend
  42. $config  $GLOBALS['_PEAR_Frontend_Web_config'&PEAR_Config::singleton($pear_user_config'');
  43. PEAR_Command::setFrontendType("Web");
  44.  
  45. $ui &PEAR_Command::getFrontendObject();
  46.  
  47. PEAR::setErrorHandling(PEAR_ERROR_CALLBACKarray($ui"displayFatalError"));
  48.  
  49. // Cient requests an Image/Stylesheet/Javascript
  50. if (isset($_GET["css"])) {
  51.     $ui->outputFrontendFile($_GET["css"]'css');
  52. }
  53. if (isset($_GET["js"])) {
  54.     $ui->outputFrontendFile($_GET["js"]'js');
  55. }
  56. if (isset($_GET["img"])) {
  57.     $ui->outputFrontendFile($_GET["img"]'image');
  58. }
  59.  
  60. $verbose $config->get("verbose");
  61. $cmdopts = array();
  62. $opts    = array();
  63. $params  = array();
  64.  
  65. $URL 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  66. $dir substr(dirname(__FILE__)0-strlen('PEAR/PEAR'))// strip PEAR/PEAR
  67.  
  68. $_ENV['TMPDIR'$_ENV['TEMP'$dir.'tmp';
  69.  
  70. if (false && !file_exists($pear_user_config)) {
  71.     // I think PEAR_Frontend_Web is running for the first time!
  72.     // Install it properly ...
  73.  
  74.     // First of all set some config-vars:
  75.     $cmd = PEAR_Command::factory('config-set'$config);
  76.     $ok $cmd->run('config-set'array()array('php_dir',  $dir.'PEAR'));
  77.     $ok $cmd->run('config-set'array()array('doc_dir',  $dir.'docs'));
  78.     $ok $cmd->run('config-set'array()array('ext_dir',  $dir.'ext'));
  79.     $ok $cmd->run('config-set'array()array('bin_dir',  $dir.'bin'));
  80.     $ok $cmd->run('config-set'array()array('data_dir'$dir.'data'));
  81.     $ok $cmd->run('config-set'array()array('test_dir'$dir.'test'));
  82.     $ok $cmd->run('config-set'array()array('cache_dir'$dir.'cache'));
  83.     $ok $cmd->run('config-set'array()array('cache_ttl'300));
  84.  
  85.     // Register packages
  86.     $packages = array(
  87.                                 'Archive_Tar',
  88.                                 'Console_Getopt',
  89.                                 'HTML_Template_IT',
  90.                                 'Net_UserAgent_Detect',
  91.                                 'Pager',
  92.                                 'PEAR',
  93.                                 'PEAR_Frontend_Web',
  94.                                 'XML_RPC'
  95.                         );
  96.     $reg = new PEAR_Registry($dir.'PEAR');
  97.     if (!file_exists($dir.'PEAR/.registry')) {
  98.         PEAR::raiseError('Directory "'.$dir.'PEAR/.registry" does not exist. please check your installation');
  99.     }
  100.  
  101.     foreach($packages as $pkg{
  102.         $info $reg->packageInfo($pkg);
  103.         foreach($info['filelist'as $fileName => $fileInfo{
  104.             if($fileInfo['role'== "php"{
  105.                 $info['filelist'][$fileName]['installed_as'=
  106.                     str_replace('{dir}',$dir$fileInfo['installed_as']);
  107.             }
  108.         }
  109.         $reg->updatePackage($pkg$infofalse);
  110.     }
  111. }
  112.  
  113. // Handle some diffrent Commands
  114. if (isset($_GET["command"])) {
  115.     switch ($_GET["command"]{
  116.         case 'install':
  117.         case 'uninstall':
  118.         case 'upgrade':
  119.             if (USE_DHTML_PROGRESS && isset($_GET['dhtml'])) {
  120.                 PEAR::setErrorHandling(PEAR_ERROR_CALLBACKarray($ui"displayErrorImg"));
  121.             }
  122.  
  123.             $command $_GET["command"];
  124.             $params = array($_GET["pkg"]);
  125.             $cmd = PEAR_Command::factory($command$config);
  126.             $ok $cmd->run($command$opts$params);
  127.  
  128.             // success
  129.             if (USE_DHTML_PROGRESS && isset($_GET['dhtml'])) {
  130.                 echo '<script language="javascript">';
  131.                 if ($_GET["command"== "uninstall"{
  132.                     printf(' parent.deleteVersion(\'%s\'); ',  $_GET["pkg"]);
  133.                     printf(' parent.displayInstall(\'%s\'); '$_GET["pkg"]);
  134.                     printf(' parent.hideDelete(\'%s\'); ',     $_GET["pkg"]);
  135.                 else {
  136.                     printf(' parent.newestVersion(\'%s\'); ',  $_GET["pkg"]);
  137.                     printf(' parent.hideInstall(\'%s\'); ',    $_GET["pkg"]);
  138.                     printf(' parent.displayDelete(\'%s\'); ',  $_GET["pkg"]);
  139.                 }
  140.                 echo '</script>';
  141.                 $html sprintf('<img src="%s?img=install_ok" border="0">'$_SERVER['PHP_SELF']);
  142.                 echo $js.$html;
  143.                 exit;
  144.             }
  145.  
  146.             if (isset($_GET['redirect']&& $_GET['redirect'== 'info'{
  147.                 $URL .= '?command=remote-info&pkg='.$_GET["pkg"];
  148.             elseif (isset($_GET['redirect']&& $_GET['redirect'== 'search'{
  149.                 $URL .= '?command=search&userDialogResult=get&0='.$_GET["0"].'&1='.$_GET["1"];
  150.             else {
  151.                 $URL .= '?command=list-all&pageID='.$_GET['pageID'].'#'.$_GET["pkg"];
  152.             }
  153.             Header("Location: ".$URL);
  154.             exit;
  155.         case 'remote-info':
  156.             $command $_GET["command"];
  157.             $params = array($_GET["pkg"]);
  158.             $cmd = PEAR_Command::factory($command$config);
  159.             $ok $cmd->run($command$opts$params);
  160.  
  161.             exit;
  162.         case 'search':
  163.             list($name$description$ui->userDialog('search',
  164.                 array('Package Name''Package Info')// Prompts
  165.                 array()array()// Types, Defaults
  166.                 'Package Search''pkgsearch' // Title, Icon
  167.                 );
  168.  
  169.             $command $_GET["command"];
  170.             $params = array($name$description);
  171.             $cmd = PEAR_Command::factory($command$config);
  172.             $ok $cmd->run($command$opts$params);
  173.  
  174.             exit;
  175.         case 'config-show':
  176.             $command $_GET["command"];
  177.             $cmd = PEAR_Command::factory($command$config);
  178.             $res $cmd->run($command$opts$params);
  179.             foreach($GLOBALS['_PEAR_Frontend_Web_Config'as $var => $value{
  180.                 $command 'config-set';
  181.                 $params = array($var$value);
  182.                 $cmd = PEAR_Command::factory($command$config);
  183.                 $res $cmd->run($command$opts$params);
  184.             }
  185.  
  186.             $URL .= '?command=config-show';
  187.             header("Location: ".$URL);
  188.             exit;
  189.         case 'list-all':
  190.             $command $_GET["command"];
  191.             $params = array();
  192.             if (isset($_GET["mode"]))
  193.                 $opts['mode'$_GET["mode"];
  194.             $cmd = PEAR_Command::factory($command$config);
  195.             $ok $cmd->run($command$opts$params);
  196.  
  197.             exit;
  198.         case 'show-last-error':
  199.             $GLOBALS['_PEAR_Frontend_Web_log'$_SESSION['_PEAR_Frontend_Web_LastError_log'];
  200.             $ui->displayError($_SESSION['_PEAR_Frontend_Web_LastError']'Error''error'true);
  201.             exit;
  202.         default:
  203.             $command $_GET["command"];
  204.             $cmd = PEAR_Command::factory($command$config);
  205.             $res $cmd->run($command$opts$params);
  206.  
  207.             $URL .= '?command='.$_GET["command"];
  208.             header("Location: ".$URL);
  209.             exit;
  210.     }
  211. }
  212.  
  213. $ui->displayStart();
  214. ?>

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