1<?php //; echo; echo "YOU NEED TO RUN THIS SCRIPT WITH PHP!"; echo; echo "Point your webbrowser to it or run: php -q go-pear.php"; echo; exit # -*- PHP -*- 2# 3# The PEAR installation wizard, both webbased or command line. 4# 5# Webbased installation: 6# 1) Download this file and save it as go-pear.php 7# 2) Put go-pear.php on your webserver, where you would put your website 8# 3) Open http://yourdomain.example.org/go-pear.php in your browser 9# 4) Follow the instructions, done! 10# 11# Command-line installation (for advanced users): 12# 1) Download this file and save it as go-pear.php 13# 2) Open a terminal/command prompt and type: php -q go-pear.php 14# 3) Follow the instructions, done! 15# 16# Notes: 17# * Get the latest go-pear version from http://pear.php.net/go-pear 18# * This installer requires PHP 4.3.0 or newer. 19# * On windows, the PHP CLI binary is php.exe, don't forget the -q option if using the CGI binary. 20# * The default for the command-line installation is a system-wide configuration file, For a local install use: php -q go-pear.php local 21 22/** 23 * go-pear is the online PEAR installer: just download it and run it 24 * (through a browser or command line), it will set up a minimal PEAR 25 * installation that will be ready for immediate use. 26 * 27 * @license http://www.php.net/license/2_02.txt PHP License 2.02 28 * @version CVS: $Id: go-pear 281637 2009-06-04 08:51:45Z clockwerx $ 29 * @link http://pear.php.net/package/pearweb_gopear 30 * @author Tomas V.V.Cox <cox@idecnet.com> 31 * @author Stig Bakken <ssb@php.net> 32 * @author Christian Dickmann <dickmann@php.net> 33 * @author Pierre-Alain Joye <pierre@php.net> 34 * @author Greg Beaver <cellog@php.net> 35 * @author Tias Guns <tias@ulyssis.org> 36 */ 37 38 39$sapi_name = php_sapi_name(); 40 41$safe_mode = (bool)ini_get('safe_mode'); 42if (!$safe_mode) { 43 set_time_limit(0); 44} 45 46@ob_end_clean(); 47ob_implicit_flush(true); 48define('WEBINSTALLER', ($sapi_name != 'cli' && !(substr($sapi_name,0,3)=='cgi' && !isset($_SERVER['GATEWAY_INTERFACE'])))); 49 50ini_set('track_errors', true); 51ini_set('html_errors', WEBINSTALLER); 52ini_set('magic_quotes_runtime', false); 53error_reporting( E_ALL & ~E_NOTICE); 54 55define('WINDOWS', (substr(PHP_OS, 0, 3) == 'WIN')); 56define('GO_PEAR_VER', '1.1.2'); 57 58define('WIN32GUI', !WEBINSTALLER && WINDOWS && $sapi_name=='cli' && which('cscript')); 59 60$destdir = getenv('DESTDIR'); 61 62/* 63 * See bug #23069 64 */ 65if ( WEBINSTALLER && WINDOWS ) { 66 $php_sapi_name = win32DetectPHPSAPI(); 67 if($php_sapi_name=='cgi'){ 68 $msg = nl2br(" 69Sorry! The PEAR installer actually does not work on Windows platform 70using CGI and Apache. Please install the module SAPI (see 71http://www.php.net/manual/en/install.apache.php for the instructions) or 72use the CLI (cli\php.exe) in the console. 73"); 74 displayHTML('error', $msg); 75 } 76} 77 78if (WEBINSTALLER && isset($_GET['action']) && $_GET['action'] == 'img' && isset($_GET['img'])) { 79 switch ($_GET['img']) 80 { 81 case 'note': 82 case 'pearlogo': 83 case 'smallpear': 84 showImage($_GET['img']); 85 exit; 86 default: 87 exit; 88 }; 89} 90 91// Check if PHP version is sufficient 92if (function_exists("version_compare") && version_compare(phpversion(), "4.3.0",'<')) { 93 die("Sorry! Your PHP version is too old. PEAR and this script requires at 94least PHP 4.3.0 for stable operation. 95 96It may be that you have a newer version of PHP installed in your web 97server, but an older version installed as the 'php' command. In this 98case, you need to rebuilt PHP from source. 99If your source is 4.3.x or newer, just make sure you don't run 100'configure' with --disable-cli, rebuilt and copy sapi/cli/php. 101 102Please upgrade PHP to a newer version, and try again. See you then. 103 104"); 105} 106 107$gopear_bundle_dir = dirname(__FILE__).'/go-pear-bundle'; 108 109$bootstrap_files = array( 110 'PEAR.php' => 'http://svn.php.net/viewvc/pear/pear-core/branches/PEAR_1_4/PEAR.php?view=co', 111 'Archive/Tar.php' => 'http://svn.php.net/viewvc/pear/packages/Archive_Tar/tags/RELEASE_1_3_2/Archive/Tar.php?view=co', 112 'Console/Getopt.php' => 'http://svn.php.net/viewvc/pear/pear-core/branches/PEAR_1_4/Console/Getopt.php?view=co', 113); 114 115$bootstrap_pkgs = array( // uses URL like http://pear.php.net/get/%s 116 'PEAR', 117 'Structures_Graph' 118); 119 120$installer_packages = array( 121 'PEAR-stable', 122 'Structures_Graph-stable', 123 'Archive_Tar-stable', 124 'Console_Getopt-stable', 125); 126 127$pfc_packages = array( 128 'PEAR_Frontend_Web-beta' => 'Webbased PEAR Installer', 129 'PEAR_Frontend_Gtk2' => 'Graphical PEAR installer based on PHP-Gtk2', 130 'MDB2' => 'database abstraction layer.', 131); 132 133$config_desc = array( 134 'prefix' => 'Installation prefix ($prefix)', 135 'temp_dir' => 'Temporary files directory', 136 'bin_dir' => 'Binaries directory', 137 'php_dir' => 'PHP code directory ($php_dir)', 138 'doc_dir' => 'Documentation base directory', 139 'data_dir' => 'Data base directory', 140 'test_dir' => 'Tests base directory', 141); 142 143if(!WEBINSTALLER && WINDOWS){ 144 $config_desc['php_bin'] = 'php.exe path'; 145} 146 147if (WEBINSTALLER) { 148 $config_desc['cache_dir'] = 'PEAR Installer cache directory'; 149 $config_desc['cache_ttl'] = 'Cache TimeToLive'; 150 $config_desc['webfrontend_file'] = 'Filename of WebFrontend'; 151 $config_desc['php_bin'] = "php.exe path, optional (CLI command tools)"; 152} 153 154if (my_env('HTTP_PROXY')) { 155 $http_proxy = my_env('HTTP_PROXY'); 156} elseif (my_env('http_proxy')) { 157 $http_proxy = my_env('http_proxy'); 158} else { 159 $http_proxy = ''; 160} 161 162register_shutdown_function('bail'); 163 164detect_install_dirs(); 165 166if (WEBINSTALLER) { 167 @session_start(); 168 169 // If welcome, just welcome 170 if (!isset($_GET['step'])) { 171 $_GET['step'] = 'Welcome'; 172 /* clean up old sessions datas */ 173 session_destroy(); 174 } 175 if ($_GET['step'] == 'Welcome') { 176 displayHTML('Welcome'); 177 exit(); 178 } 179 180 if (!isset($_SESSION['go-pear']) || isset($_GET['restart'])) { 181 $_SESSION['go-pear'] = array( 182 'http_proxy' => $http_proxy, 183 'config' => array( 184 'prefix' => dirname(__FILE__), 185 'bin_dir' => $bin_dir, 186 'php_bin' => $php_bin, 187 'php_dir' => '$prefix/PEAR', 188 'doc_dir' => $doc_dir, 189 'data_dir' => $data_dir, 190 'test_dir' => $test_dir, 191 'temp_dir' => '$prefix/temp', 192 'cache_dir' => '$php_dir/cache', 193 'cache_ttl' => 300, 194 'webfrontend_file' => '$prefix/index.php', 195 ), 196 'install_pfc' => true, 197 'install_optional_packages' => array(), 198 'DHTML' => true, 199 ); 200 } 201 202 // save submited values 203 if ($_GET['step'] == 'install') { 204 $_SESSION['go-pear']['http_proxy'] = strip_magic_quotes($_POST['proxy']['host']).':'.strip_magic_quotes($_POST['proxy']['port']); 205 if ($_SESSION['go-pear']['http_proxy'] == ':') { 206 $_SESSION['go-pear']['http_proxy'] = ''; 207 }; 208 209 $config_errors = array(); 210 foreach($_POST['config'] as $key => $value) { 211 $_POST['config'][$key] = strip_magic_quotes($value); 212 if ($key != 'cache_ttl' && $key != 'php_bin') { 213 if ( empty($_POST['config'][$key]) ) { 214 $config_errors[$key] = 'Please fill this path, you can use $prefix, $php_dir or a full path.'; 215 } 216 } 217 } 218 219 if( sizeof($config_errors)>0){ 220 $_GET['step'] = 'config'; 221 } 222 223 $_SESSION['go-pear']['config'] = $_POST['config']; 224 $_SESSION['go-pear']['install_pfc'] = (isset($_POST['install_pfc']) && $_POST['install_pfc'] == 'on'); 225 // webinstaller allows to choose pfc packages individually 226 foreach ($pfc_packages as $key => $value) { 227 $pos = array_search($key, $_SESSION['go-pear']['install_optional_packages']); 228 if (isset($_POST[$key]) && $_POST[$key] == 'on' && $pos === false) { 229 $_SESSION['go-pear']['install_optional_packages'][] = $key; 230 } 231 if (!isset($_POST[$key]) && $pos !== false) { 232 unset($_SESSION['go-pear']['install_optional_packages'][$pos]); 233 } 234 } 235 $_SESSION['go-pear']['DHTML'] = isset($_POST['BCmode']) ? false : true; 236 } 237 238 // export session values 239 $http_proxy = $_SESSION['go-pear']['http_proxy']; 240 $GLOBALS['config_vars'] = array_keys($config_desc); 241 array_unshift($GLOBALS['config_vars'], ''); 242 unset($GLOBALS['config_vars'][0]); // make indices run from 1... 243 foreach($_SESSION['go-pear']['config'] as $var => $value) { 244 $$var = $value; 245 } 246 $install_pfc = $_SESSION['go-pear']['install_pfc']; 247 $install_optional_packages = $_SESSION['go-pear']['install_optional_packages']; 248 249 if ($_GET['step'] == 'config') { 250 displayHTML('config'); 251 exit(); 252 } 253 // Anything past this step has something to do with the installation 254} 255/* 256if (!WEBINSTALLER) { 257 $tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r'); 258 259 if (!$tty) { 260 $tty = fopen('php://stdin', 'r'); 261 } 262 263 $local = isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local'; 264 if ($local) { 265 $local = " 266Running in local install mode 267"; 268 } elseif (WINDOWS) { 269 $local = " 270Use 'php " . $_SERVER['argv'][0] . " local' to install a local copy of PEAR. 271"; 272 } 273 print "Welcome to go-pear! 274 275Go-pear will install the 'pear' command and all the files needed by 276it. This command is your tool for PEAR installation and maintenance. 277$local 278Go-pear also lets you download and install the following optional PEAR 279packages: " . implode(', ', array_keys($pfc_packages)) . ". 280 281 282If you wish to abort, press Control-C now, or press Enter to continue: "; 283 284 fgets($tty, 1024); 285 286 print "\n"; 287 288 print "HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:"; 289 290 if (!empty($http_proxy)) { 291 print " [$http_proxy]"; 292 } 293 print ": "; 294 $tmp = trim(fgets($tty, 1024)); 295 if (!empty($tmp)) { 296 $http_proxy = $tmp; 297 } 298} 299*/ 300$origpwd = getcwd(); 301 302$config_vars = array_keys($config_desc); 303 304// make indices run from 1... 305array_unshift($config_vars, ""); 306unset($config_vars[0]); 307reset($config_vars); 308$desclen = max(array_map('strlen', $config_desc)); 309$descfmt = "%-{$desclen}s"; 310$first = key($config_vars); 311end($config_vars); 312$last = key($config_vars); 313 314$progress = 0; 315 316/* 317 * Checks PHP SAPI version under windows/CLI 318 */ 319if( WINDOWS && !WEBINSTALLER && $php_bin=='') { 320 print " 321We do not find any php.exe, please select the php.exe folder (CLI is 322recommanded, usually in c:\php\cli\php.exe) 323"; 324 $php_bin_set = false; 325} elseif ( WINDOWS && !WEBINSTALLER && strlen($php_bin) ) { 326 $php_bin_sapi = win32DetectPHPSAPI(); 327 $php_bin_set = true; 328 switch($php_bin_sapi){ 329 case 'cli': 330 break; 331 case 'cgi': 332 print " 333*NOTICE* 334We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI. PEAR commandline 335tool works well with it, if you have a CLI php.exe available, we 336recommand to use it. 337"; 338 break; 339 default: 340 print " 341*WARNING* 342We found php.exe under $php_bin, it uses an unknown SAPI. PEAR commandline 343tool has not been tested with it, if you have a CLI (or CGI) php.exe available, 344we strongly recommand to use it. 345 346"; 347 break; 348 } 349} 350/* 351while (!WEBINSTALLER) { 352 print " 353Below is a suggested file layout for your new PEAR installation. To 354change individual locations, type the number in front of the 355directory. Type 'all' to change all of them or simply press Enter to 356accept these locations. 357 358"; 359 360 foreach ($config_vars as $n => $var) { 361 printf("%2d. $descfmt : %s\n", $n, $config_desc[$var], $$var); 362 } 363 364 print "\n$first-$last, 'all' or Enter to continue: "; 365 $tmp = trim(fgets($tty, 1024)); 366 if ( empty($tmp) ) { 367 if( WINDOWS && !$php_bin_set ){ 368 echo "**ERROR** 369Please, enter the php.exe path. 370 371"; 372 } else { 373 break; 374 } 375 } 376 if (isset($config_vars[(int)$tmp])) { 377 $var = $config_vars[(int)$tmp]; 378 $desc = $config_desc[$var]; 379 $current = $$var; 380 381 if(WIN32GUI){ 382 $tmp = win32BrowseForFolder("$desc [$current] :"); 383 } else { 384 print "$desc [$current] : "; 385 $tmp = trim(fgets($tty, 1024)); 386 } 387 388 $old = $$var; 389 if(WINDOWS && $var=='php_bin' ){ 390 if(file_exists($tmp.DIRECTORY_SEPARATOR.'php.exe')){ 391 $tmp = $tmp.DIRECTORY_SEPARATOR.'php.exe'; 392 $php_bin_sapi = win32DetectPHPSAPI(); 393 if($php_bin_sapi=='cgi'){ 394 print " 395****************************************************************************** 396NOTICE! We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI. 397PEAR commandline tool works well with it. 398If you have a CLI php.exe available, we recommand to use it. 399 400"; 401 } elseif ($php_bin_sapi=='unknown') { 402 print " 403****************************************************************************** 404WARNING! We found php.exe under $php_bin, it uses an $php_bin_sapi SAPI. 405PEAR commandline tool has not been tested with it. 406If you have a CLI (or CGI) php.exe available, we strongly recommand to use it. 407 408"; 409 } 410 echo "php.exe (sapi: $php_bin_sapi) found.\n\n"; 411 $php_bin_set = true; 412 } else { 413 echo "**ERROR**: no php.exe found in this folder.\n"; 414 $tmp=''; 415 } 416 } 417 418 if (!empty($tmp) ) { 419 $$var = parse_dirname($tmp); 420 } 421 } elseif ($tmp == 'all') { 422 foreach ($config_vars as $n => $var) { 423 $desc = $config_desc[$var]; 424 $current = $$var; 425 print "$desc [$current] : "; 426 $tmp = trim(fgets($tty, 1024)); 427 if (!empty($tmp)) { 428 $$var = $tmp; 429 } 430 } 431 } 432} 433*/ 434#### 435# Installation stuff 436#### 437 438// expand all subvars in the config vars 439foreach ($config_vars as $n => $var) { 440 for ($m = 1; $m <= count($config_vars); $m++) { 441 $var2 = $config_vars[$m]; 442 $$var = str_replace('$'.$var2, $$var2, $$var); 443 } 444 $$var = parse_dirname($$var); 445} 446 447 // temp dir stuff (separate for windows bugs) 448 if (!empty($temp_dir)) { 449 $_found = temp_dir($temp_dir); 450 } else { 451 $_found = temp_dir(); 452 } 453 if (!$_found) { 454 if (!WEBINSTALLER) { 455 print " 456 457****************************************************************************** 458FATAL ERROR! We cannot initialize the temp directory. Please be sure to give 459full write access to this directory and the install directory. 460 461"; 462 if (!empty($temp_dir)) { 463 print "'$temp_dir' was given."; 464 } 465 exit(); 466 467 } else { // WEBINSTALLER 468 if (!is_dir($temp_dir)) { 469 $config_errors['temp_dir'] = 'FATAL ERROR! This directory does not exist and we can not create it. Create the directory manually or make sure we have full permission in its parent directory.'; 470 if (!WINDOWS) { 471 $config_errors['temp_dir'] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br /> 472<tt>mkdir '.dirname($temp_dir).' && chmod 0777 '.dirname($temp_dir).'</tt></p>'; 473 } 474 } else { // is_dir(temp_dir) 475 $config_errors['temp_dir'] = 'FATAL ERROR! This directory exists, but we have no write permission in it.'; 476 if (!WINDOWS) { 477 $config_errors['temp_dir'] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br /> 478<tt>chmod 0777 '.$temp_dir.'</tt></p>'; 479 } 480 } 481 } 482 } 483 if (@is_dir($ptmp)) { 484 chdir($ptmp); 485 } 486 487 // check every dir, existence and permissions 488 foreach ($config_vars as $var) { 489 if (!preg_match('/_dir$/', $var) || $var == 'temp_dir') { 490 continue; 491 } 492 493 $dir = ($destdir ? $destdir : '').$$var; 494 if (!@is_dir($dir)) { 495 if (!mkdir_p($dir)) { 496 if (!WEBINSTALLER) { 497 $root = WINDOWS ? 'administrator' : 'root'; 498 bail("Unable to create {$config_desc[$var]} $dir. 499Run this script as $root or pick another location.\n"); 500 } else { // WEBINSTALLER 501 $config_errors[$var] = 'ERROR! This directory does not exist and we can not create it. Create the directory manually or make sure we have full permission in its parent directory.'; 502 if (!WINDOWS) { 503 $config_errors[$var] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br /> 504<tt>mkdir '.dirname($dir).' && chmod 0777 '.dirname($dir).'</tt></p>'; 505 } 506 } 507 } 508 } 509 if (WEBINSTALLER && @is_dir($dir) && !is_writable($dir)) { 510 $config_errors[$var] = 'ERROR! This directory exists, but we have no write permission in it.'; 511 if (!WINDOWS) { 512 $config_errors[$var] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br /> 513<tt>chmod 0777 '.$dir.'</tt></p>'; 514 } 515 } 516 } 517 518 // check every file, existence and permissions 519 foreach ($config_vars as $var) { 520 if (!preg_match('/_file$/', $var)) { 521 continue; 522 } 523 524 $file = $$var; 525 $dir = dirname($file); 526 if (!file_exists($file) && !is_writable($dir)) { 527 if (!WEBINSTALLER) { 528 $root = WINDOWS ? 'administrator' : 'root'; 529 bail("Unable to create {$config_desc[$var]} $file. 530Run this script as $root or pick another location.\n"); 531 } else { // WEBINSTALLER 532 $config_errors[$var] = 'ERROR! This file does not exist and we can not create it. Make sure we have full permission in its parent directory.'; 533 if (!WINDOWS) { 534 $config_errors[$var] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br /> 535<tt>chmod 0777 '.$dir.'</tt></p>'; 536 } 537 } 538 } elseif (WEBINSTALLER && file_exists($file) && !is_writable($file)) { 539 $config_errors[$var] = 'ERROR! This file exists, but we have no write permission on it.'; 540 if (!WINDOWS) { 541 $config_errors[$var] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br /> 542<tt>chmod 0777 '.$file.'</tt></p>'; 543 } 544 } 545 } 546 547if (WEBINSTALLER) { 548 if ( isset($config_errors) && sizeof($config_errors) ) { 549 displayHTML('config'); 550 exit(); 551 } else { 552 if (isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'] == true && $_GET['step'] == 'install') { 553 $_GET['step'] = 'preinstall'; 554 } 555 if ($_GET['step'] != 'install' && $_GET['step'] != 'install-progress') { 556 displayHTML($_GET['step']); 557 exit; 558 } 559 if ($_GET['step'] == 'install-progress') { 560 displayHTMLHeader(); 561 echo "Starting installation ...<br/>"; 562 } 563 ob_start(); 564 } 565} 566/* 567if (!WEBINSTALLER) { 568 $msg = "The following PEAR packages are bundled with PHP: " . 569 implode(', ', array_keys($pfc_packages)); 570 print "\n" . wordwrap($msg, 75) . ".\n"; 571 print "Would you like to install these as well? [Y/n] : "; 572 $install_pfc = !stristr(fgets($tty, 1024), "n"); 573 $install_optional_packages = array(); 574 print "\n"; 575} 576*/ 577#### 578# Download 579#### 580 581dl('xml.so'); 582 583if (function_exists('set_include_path')) { 584 set_include_path($ptmp . PATH_SEPARATOR . "/opengrok/src/dports/devel/pear/pear-1.10.12/go-pear-bundle"); 585} else { 586 ini_set('include_path', $ptmp . PATH_SEPARATOR . "/opengrok/src/dports/devel/pear/pear-1.10.12/go-pear-bundle"); 587} 588/* 589if (!extension_loaded('zlib') && !WEBINSTALLER) { // In Web context we could be in multithread env which makes dl() end up with a fatal error. 590 if (WINDOWS) { 591 @dl('php_zlib.dll'); 592 } elseif (PHP_OS == 'HP-UX') { 593 @dl('zlib.sl'); 594 } elseif (PHP_OS == 'AIX') { 595 @dl('zlib.a'); 596 } else { 597 @dl('zlib.so'); 598 } 599} 600if (!extension_loaded('zlib')) { 601 $urltemplate = 'http://pear.php.net/get/%s?uncompress=yes'; 602 $have_gzip = null; 603} else { 604 $urltemplate = 'http://pear.php.net/get/%s'; 605 $have_gzip = true; 606} 607 608print "Loading zlib: ".($have_gzip ? 'ok' : 'failed')."\n"; 609 610if (!$have_gzip) { 611 print "Downloading uncompressed packages\n"; 612}; 613*/ 614if ($install_pfc) { 615 $to_install = array_merge($installer_packages, array_keys($pfc_packages)); 616} else { 617 $to_install = $installer_packages; 618/* 619 // webinstaller allows to choose pfc packages individually 620 foreach ($pfc_packages as $pkg => $desc) { 621 if (in_array($pkg, $install_optional_packages)) { 622 array_push($to_install, $pkg); 623 } 624 } 625*/ 626} 627 628// gopear_bundle usage 629$local_dir = array(); 630if (file_exists($gopear_bundle_dir) || is_dir($gopear_bundle_dir)) { 631 $dh = @opendir($gopear_bundle_dir); 632 633 while($file = @readdir($dh)) { 634 if ($file == '.' || $file == '..' || !is_file($gopear_bundle_dir.'/'.$file)) { 635 continue; 636 } 637 $_pos = strpos($file, '-'); 638 if ($_pos === false) { 639 $local_dir[$file] = $file; 640 } else { 641 $local_dir[substr($file, 0, $_pos)] = $file; 642 } 643 } 644 closedir($dh); 645 unset($dh, $file, $_pos); 646} 647 648print "\n".'Bootstrapping Installer...................'."\n"; 649displayHTMLProgress($progress = 5); 650 651// Bootstrap needed ? 652$nobootstrap = false; 653/* 654if (is_dir($php_dir)) { 655 $nobootstrap = true; 656 foreach ($bootstrap_files as $file => $url) { 657 $nobootstrap &= is_file($php_dir.'/'.$file); 658 } 659} 660*/ 661 662if ($nobootstrap) { 663 print('Using previously install ... '); 664 if (function_exists('set_include_path')) { 665 set_include_path($php_dir . PATH_SEPARATOR . "/opengrok/src/dports/devel/pear/pear-1.10.12/go-pear-bundle"); 666 } else { 667 ini_set('include_path', $php_dir . PATH_SEPARATOR . "/opengrok/src/dports/devel/pear/pear-1.10.12/go-pear-bundle"); 668 } 669 include_once 'PEAR.php'; 670 print "ok\n"; 671} else { 672 foreach($bootstrap_files as $name => $url) { 673 $file = basename($name); 674 $dir = dirname($name); 675 676 print 'Bootstrapping '.$name.'............'; 677 displayHTMLProgress($progress += round(14 / count($bootstrap_files))); 678 if ($dir != '' && $dir != '.') { 679 mkdir($dir, 0700); 680 } 681 682 if (in_array($file, $local_dir)) { 683 copy($gopear_bundle_dir.'/'.$file, $name); 684 echo '(local) '; 685 } else { 686 download_url($url, $name, $http_proxy); 687 echo '(remote) '; 688 } 689 include_once $name; 690 print "ok\n"; 691 } 692} 693unset($nobootstrap, $file, $url, $name, $dir); 694 695PEAR::setErrorHandling(PEAR_ERROR_DIE, "\n%s\n"); 696print "\n".'Extracting installer..................'."\n"; 697displayHTMLProgress($progress = 20); 698 699// Extract needed ? 700$noextract = false; 701/* 702if (is_dir($php_dir)) { 703 $noextract = @include_once 'PEAR/Registry.php'; 704 705 if ($noextract) { 706 $registry = new PEAR_Registry($php_dir); 707 foreach ($bootstrap_pkgs as $pkg) { 708 $noextract &= $registry->packageExists($pkg); 709 } 710 } 711} 712*/ 713 714if ($noextract) { 715 print('Using previously installed installer ... '); 716 print "ok\n"; 717} else { 718 $bootstrap_pkgs_tarballs = array(); 719 foreach ($bootstrap_pkgs as $pkg) { 720 $tarball = null; 721 if (isset($local_dir[$pkg])) { 722 echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.'); 723 copy($gopear_bundle_dir.'/'.$local_dir[$pkg], $local_dir[$pkg]); 724 $tarball = $local_dir[$pkg]; 725 } else { 726 print str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.'); 727 $url = sprintf($urltemplate, $pkg); 728 $pkg = str_replace('-stable', '', $pkg); 729 $tarball = download_url($url, null, $http_proxy); 730 } 731 displayHTMLProgress($progress += round(19 / count($bootstrap_pkgs))); 732 733 $fullpkg = substr($tarball, 0, strrpos($tarball, '.')); 734 $tar = new Archive_Tar($tarball, $have_gzip); 735 if (!$tar->extractModify($ptmp, $fullpkg)) { 736 bail("Extraction for $fullpkg failed!\n"); 737 } 738 $bootstrap_pkgs_tarballs[$pkg] = $tarball; 739 print "ok\n"; 740 } 741} 742unset($noextract, $registry, $pkg, $tarball, $url, $fullpkg, $tar); 743 744 745print "\n".'Preparing installer..................'."\n"; 746displayHTMLProgress($progress = 40); 747 748// Default for sig_bin 749putenv('PHP_PEAR_SIG_BIN=""'); 750// Default for sig_keydir 751putenv('PHP_PEAR_SIG_KEYDIR=""'); 752putenv('PHP_PEAR_DOWNLOAD_DIR=' . $temp_dir . '/download'); 753putenv('PHP_PEAR_TEMP_DIR=' . $temp_dir); 754 755include_once "PEAR/Config.php"; 756include_once "PEAR/Command.php"; 757include_once "PEAR/Registry.php"; 758 759$config = &PEAR_Config::singleton(($destdir ? $destdir : '').$prefix."/etc/pear.conf.sample", ''); 760 761$config->set('preferred_state', 'stable'); 762foreach ($config_vars as $var) { 763 if (isset($$var) && $$var != '') { 764 $config->set($var, $$var); 765 } 766} 767$config->set('download_dir', $temp_dir . '/download'); 768$config->set('temp_dir', $temp_dir); 769$config->set('http_proxy', $http_proxy); 770$config->store(); 771 772$registry = new PEAR_Registry(($destdir ? $destdir : '').$php_dir); 773PEAR_Command::setFrontendType('CLI'); 774 775PEAR::staticPushErrorHandling(PEAR_ERROR_DIE); //fail silently 776$ch_cmd = &PEAR_Command::factory('update-channels', $config); 777$ch_cmd->run('update-channels', $options, array()); 778PEAR::staticPopErrorHandling(); // reset error handling 779unset($ch_cmd); 780 781 782print "\n".'Installing selected packages..................'."\n"; 783displayHTMLProgress($progress = 45); 784 785$install = &PEAR_Command::factory('install', $config); 786foreach ($to_install as $pkg) { 787 $pkg_basename = substr($pkg, 0, strpos($pkg, '-')); 788 789 if (in_array($pkg, $installer_packages)) { 790 $options = array('nodeps' => true); 791 } else { 792 $options = array('onlyreqdeps' => true); 793 } 794 if ($destdir) { 795 $options['packagingroot'] = $destdir; 796 $options['force'] = true; 797 $options['nodeps'] = true; 798 } 799 if ($registry->packageExists($pkg) || $registry->packageExists($pkg_basename)) { 800 print(str_pad("Package: $pkg", max(50,9+strlen($pkg)+4), '.').' already installed ... ok'."\n"); 801 displayHTMLProgress($progress += round(50 / count($to_install))); 802 continue; 803 } 804 805 $pkg_basename = substr($pkg, 0, strpos($pkg, '-')); 806 if (in_array($pkg_basename, $bootstrap_pkgs)) { 807 print(str_pad("Installing bootstrap package: $pkg_basename", max(50,30+strlen($pkg_basename)+4), '.')."..."); 808 displayHTMLProgress($progress += round(25 / count($to_install))); 809 $install->run('install', $options, array($bootstrap_pkgs_tarballs[$pkg_basename])); 810 } elseif (isset($local_dir[$pkg_basename])) { 811 print(str_pad("Installing local package: $pkg", max(50,26+strlen($pkg)+4), '.')."..."); 812 displayHTMLProgress($progress += round(25 / count($to_install))); 813 $install->run('install', $options, array($gopear_bundle_dir.'/'.$local_dir[$pkg_basename])); 814 } else { // no local copy 815 print(str_pad("Downloading and installing package: $pkg", max(50,36+strlen($pkg)+4), '.')."..."); 816 displayHTMLProgress($progress += round(25 / count($to_install))); 817 $install->run('install', $options, array($pkg)); 818 } 819 displayHTMLProgress($progress += round(25 / count($to_install))); 820} 821unset($pkg, $pkg_basename, $options, $bootstrap_pkgs_tarballs); 822 823/* TODO: Memory exhaustion in webinstaller : / (8Mb) 824print "\n".'Making sure every package is at the latest version........'; 825$install->run('upgrade-all', array('soft' => true), array()); 826print "ok\n"; 827*/ 828unset($config, $registry, $install); 829displayHTMLProgress($progress = 99); 830 831 832// Base installation finished 833/* 834ini_restore("include_path"); 835 836if (!WEBINSTALLER) { 837 $sep = WINDOWS ? ';' : ':'; 838 $include_path = explode($sep, ini_get('include_path')); 839 if (WINDOWS) { 840 $found = false; 841 $t = strtolower($php_dir); 842 foreach($include_path as $path) { 843 if ($t==strtolower($path)) { 844 $found = true; 845 break; 846 } 847 } 848 } else { 849 $found = in_array($php_dir, $include_path); 850 } 851 if (!$found) { 852 print " 853****************************************************************************** 854WARNING! The include_path defined in the currently used php.ini does not 855contain the PEAR PHP directory you just specified: 856<$php_dir> 857If the specified directory is also not in the include_path used by 858your scripts, you will have problems getting any PEAR packages working. 859"; 860 861 if ( $php_ini = getPhpiniPath() ) { 862 print "\n\nWould you like to alter php.ini <$php_ini>? [Y/n] : "; 863 $alter_phpini = !stristr(fgets($tty, 1024), "n"); 864 if( $alter_phpini ) { 865 alterPhpIni($php_ini); 866 } else { 867 if (WINDOWS) { 868 print " 869Please look over your php.ini file to make sure 870$php_dir is in your include_path."; 871 } else { 872 print " 873I will add a workaround for this in the 'pear' command to make sure 874the installer works, but please look over your php.ini or Apache 875configuration to make sure $php_dir is in your include_path. 876"; 877 } 878 879 } 880 } 881 882 print " 883Current include path : ".ini_get('include_path')." 884Configured directory : $php_dir 885Currently used php.ini (guess) : $php_ini 886"; 887 888 print "Press Enter to continue: "; 889 fgets($tty, 1024); 890 } 891 892 $pear_cmd = $bin_dir . DIRECTORY_SEPARATOR . 'pear'; 893 $pear_cmd = WINDOWS ? strtolower($pear_cmd).'.bat' : $pear_cmd; 894 895 // check that the installed pear and the one in tha path are the same (if any) 896 $pear_old = which(WINDOWS ? 'pear.bat' : 'pear', $bin_dir); 897 if ($pear_old && ($pear_old != $pear_cmd)) { 898 // check if it is a link or symlink 899 $islink = WINDOWS ? false : is_link($pear_old) ; 900 if ($islink && readlink($pear_old) != $pear_cmd) { 901 print "\n** WARNING! The link $pear_old does not point to the " . 902 "installed $pear_cmd\n"; 903 } elseif (is_writable($pear_old) && !is_dir($pear_old)) { 904 rename($pear_old, "{$pear_old}_old"); 905 print "\n** WARNING! Backed up old pear to {$pear_old}_old\n"; 906 } else { 907 print "\n** WARNING! Old version found at $pear_old, please remove it or ". 908 "be sure to use the new $pear_cmd command\n"; 909 } 910 } 911 912 print "\nThe 'pear' command is now at your service at $pear_cmd\n"; 913 914 // Alert the user if the pear cmd is not in PATH 915 $old_dir = $pear_old ? dirname($pear_old) : false; 916 if (!which('pear', $old_dir)) { 917 print " 918** The 'pear' command is not currently in your PATH, so you need to 919** use '$pear_cmd' until you have added 920** '$bin_dir' to your PATH environment variable. 921 922"; 923 924 print "Run it without parameters to see the available actions, try 'pear list' 925to see what packages are installed, or 'pear help' for help. 926 927For more information about PEAR, see: 928 929 http://pear.php.net/faq.php 930 http://pear.php.net/manual/ 931 932Thanks for using go-pear! 933 934"; 935 } 936} 937 938if (WEBINSTALLER) { 939 print "\n".'Writing WebFrontend file ... '; 940 @unlink($webfrontend_file); //Delete old one 941 copy ( $doc_dir.DIRECTORY_SEPARATOR. 942 'PEAR_Frontend_Web'.DIRECTORY_SEPARATOR. 943 'docs'.DIRECTORY_SEPARATOR. 944 'index.php.txt', 945 $webfrontend_file 946 ); 947 print "ok\n"; 948 949 if ($_GET['step'] == 'install-progress') { 950 displayHTMLProgress($progress = 100); 951 ob_end_clean(); 952 displayHTMLInstallationSummary(); 953 displayHTMLFooter(); 954 } else { 955 $out = ob_get_contents(); 956 957 $out = explode("\n", $out); 958 foreach($out as $line => $value) { 959 if (preg_match('/ok$/', $value)) { 960 $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value); 961 }; 962 if (preg_match('/^install ok:/', $value)) { 963 $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value); 964 }; 965 if (preg_match('/^Warning:/', $value)) { 966 $value = '<span style="color: #ff0000">'.$value.'</span>'; 967 }; 968 $out[$line] = $value; 969 }; 970 $out = nl2br(implode("\n",$out)); 971 ob_end_clean(); 972 973 displayHTML('install', $out); 974 } 975 // Little hack, this will be fixed in PEAR later 976 if ( WINDOWS ) { 977 clearstatcache(); 978 @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear'); 979 } 980 exit; 981} 982 983// Little hack, this will be fixed in PEAR later 984if ( WINDOWS ) { 985 clearstatcache(); 986 @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear'); 987} 988 989if (WINDOWS && !WEBINSTALLER) { 990 win32CreateRegEnv(); 991} 992*/ 993// Set of functions following 994/** 995 * Parse the given dirname 996 * eg. expands '~' etc 997 * 998 * @param string $dir directory, from input 999 * @return string parsed directory 1000 */ 1001function parse_dirname($dir) 1002{ 1003 if (!isset($_ENV['HOME'])) { 1004 if (strpos($dir, '~') === 0) { 1005 if (WEBINSTALLER) { 1006 die('<p><em>Can\'t use the \'~\' symbol for homedir substitution, write the directory out in full.</em></p>'); 1007 } else { 1008 die('Can\'t use the \'~\' symbol for homedir substitution, write the directory out in full.'); 1009 } 1010 } 1011 return $dir; 1012 } 1013 1014 $home_root = $_ENV['HOME']; 1015 // first strip last slash, if available 1016 if (substr($home_root, -1) == DIRECTORY_SEPARATOR) { 1017 $home_root = substr($home_root, 0, -1); 1018 } 1019 if (strpos($dir, '~/') === 0) { 1020 // eg ~/ = /home/tias/ 1021 $dir = substr_replace($dir, $home_root, 0, 1); 1022 } elseif (strpos($dir, '~') === 0) { 1023 // eg ~tias/ = /home/tias/ 1024 // then delete user-dir 1025 $home_root = dirname($home_root) . DIRECTORY_SEPARATOR; 1026 $dir = substr_replace($dir, $home_root, 0, 1); 1027 } 1028 1029 return $dir; 1030} 1031 1032 1033// {{{ download_url() 1034 1035function download_url($url, $destfile = null, $proxy = null) 1036{ 1037 $use_suggested_filename = ($destfile === null); 1038 if ($use_suggested_filename) { 1039 $destfile = basename($url); 1040 } 1041 $tmp = parse_url($url); 1042 if (empty($tmp['port'])) { 1043 $tmp['port'] = 80; 1044 } 1045 if (empty($proxy)) { 1046 $fp = fsockopen($tmp['host'], $tmp['port'], $errno, $errstr); 1047 //print "\nconnecting to $tmp[host]:$tmp[port]\n"; 1048 } else { 1049 $tmp_proxy = parse_url($proxy); 1050 $phost = $tmp_proxy['host']; 1051 $pport = $tmp_proxy['port']; 1052 $fp = fsockopen($phost, $pport, $errno, $errstr); 1053 //print "\nconnecting to $phost:$pport\n"; 1054 } 1055 if (!$fp) { 1056 bail("download of $url failed: $errstr ($errno)\n"); 1057 // If valid URL but error, no CURL extentions installed 1058 } 1059 if (empty($proxy)) { 1060 $path = $tmp['path']; 1061 } else { 1062 $path = "http://$tmp[host]:$tmp[port]$tmp[path]"; 1063 } 1064 if (isset($tmp['query'])) { 1065 $path .= "?$tmp[query]"; 1066 } 1067 if (isset($tmp['fragment'])) { 1068 $path .= "#$tmp[fragment]"; 1069 } 1070 $request = "GET $path HTTP/1.0\r\nHost: $tmp[host]:$tmp[port]\r\n". 1071 "User-Agent: go-pear\r\n"; 1072 1073 if (!empty($proxy) && $tmp_proxy['user'] != '') { 1074 $request .= 'Proxy-Authorization: Basic ' . 1075 base64_encode($tmp_proxy['user'] . ':' . $tmp_proxy['pass']) . "\r\n"; 1076 } 1077 $request .= "\r\n"; 1078 fwrite($fp, $request); 1079 $cdh = "content-disposition:"; 1080 $cdhl = strlen($cdh); 1081 $content_length = 0; 1082 while ($line = fgets($fp, 2048)) { 1083 if (trim($line) == '') { 1084 break; 1085 } 1086 if (preg_match('/^Content-Length: (.*)$/i', $line, $matches)) { 1087 $content_length = trim($matches[1]); 1088 } 1089 if ($use_suggested_filename && !strncasecmp($line, $cdh, $cdhl)) { 1090 if (eregi('filename="([^"]+)"', $line, $matches)) { 1091 $destfile = basename($matches[1]); 1092 } 1093 } 1094 } 1095 1096 displayHTMLSetDownload($destfile); 1097 $wp = fopen($destfile, "wb"); 1098 if (!$wp) { 1099 bail("could not open $destfile for writing\n"); 1100 } 1101 $bytes_read = 0; 1102 $progress = 0; 1103 while ($data = fread($fp, 2048)) { 1104 fwrite($wp, $data); 1105 $bytes_read += strlen($data); 1106 if ($content_length != 0 && floor($bytes_read * 10 / $content_length) != $progress) { 1107 $progress = floor($bytes_read * 10 / $content_length); 1108 displayHTMLDownloadProgress($progress * 10); 1109 }; 1110 } 1111 displayHTMLDownloadProgress(100); 1112 fclose($fp); 1113 fclose($wp); 1114 1115 displayHTMLSetDownload(''); 1116 return $destfile; 1117} 1118 1119// }}} 1120// {{{ which() 1121 1122function which($program, $dont_search_in = false) 1123{ 1124 if (WINDOWS) { 1125 if ($_path=my_env('Path')) { 1126 $dirs = explode(';', $_path); 1127 } else { 1128 $dirs = explode(';', my_env('PATH')); 1129 } 1130 foreach ($dirs as $i => $dir) { 1131 $dirs[$i] = strtolower(realpath($dir)); 1132 } 1133 if ($dont_search_in) { 1134 $dont_search_in = strtolower(realpath($dont_search_in)); 1135 } 1136 if ($dont_search_in && 1137 ($key = array_search($dont_search_in, $dirs)) !== false) 1138 { 1139 unset($dirs[$key]); 1140 } 1141 1142 foreach ($dirs as $dir) { 1143 $dir = str_replace('\\\\', '\\', $dir); 1144 if (!strlen($dir)) { 1145 continue; 1146 } 1147 if ($dir[strlen($dir) - 1] != '\\') { 1148 $dir .= '\\'; 1149 } 1150 $tmp = $dir . $program; 1151 $info = pathinfo($tmp); 1152 if (in_array(strtolower($info['extension']), 1153 array('exe', 'com', 'bat', 'cmd'))) { 1154 if (file_exists($tmp)) { 1155 return strtolower($tmp); 1156 } 1157 } elseif (file_exists($ret = $tmp . '.exe') || 1158 file_exists($ret = $tmp . '.com') || 1159 file_exists($ret = $tmp . '.bat') || 1160 file_exists($ret = $tmp . '.cmd')) { 1161 return strtolower($ret); 1162 } 1163 } 1164 } else { 1165 $dirs = explode(':', my_env('PATH')); 1166 if ($dont_search_in && 1167 ($key = array_search($dont_search_in, $dirs)) !== false) 1168 { 1169 unset($dirs[$key]); 1170 } 1171 foreach ($dirs as $dir) { 1172 if (is_executable("$dir/$program")) { 1173 return "$dir/$program"; 1174 } 1175 } 1176 } 1177 return false; 1178} 1179 1180// }}} 1181// {{{ bail() 1182 1183function bail($msg = '') 1184{ 1185 global $ptmp, $origpwd; 1186 if ($ptmp && is_dir($ptmp)) { 1187 chdir($origpwd); 1188 rm_rf($ptmp); 1189 } 1190 if ($msg && WEBINSTALLER) { 1191 $msg = @ob_get_contents() ."\n\n". $msg; 1192 @ob_end_clean(); 1193 displayHTML('error', $msg); 1194 exit; 1195 }; 1196 if ($msg && !WEBINSTALLER) { 1197 die($msg); 1198 } 1199} 1200 1201// }}} 1202// {{{ mkdir_p() 1203 1204function mkdir_p($dir, $mode = 0777) 1205{ 1206 if (@is_dir($dir)) { 1207 return true; 1208 } 1209 1210 $parent = dirname($dir); 1211 $ok = true; 1212 if (!@is_dir($parent) && $parent != $dir) { 1213 $ok = mkdir_p(dirname($dir), $mode); 1214 } 1215 if ($ok) { 1216 $ok = @mkdir($dir, $mode); 1217 // This is handled in the caller function (eg. webfrontend or not) 1218 //if (!$ok) { 1219 // print "mkdir failed: <$dir>\n"; 1220 //} 1221 } 1222 return $ok; 1223} 1224 1225// }}} 1226// {{{ rm_rf() 1227 1228function rm_rf($path) 1229{ 1230 if (@is_dir($path) && is_writable($path)) { 1231 $dp = opendir($path); 1232 while ($ent = readdir($dp)) { 1233 if ($ent == '.' || $ent == '..') { 1234 continue; 1235 } 1236 $file = $path . DIRECTORY_SEPARATOR . $ent; 1237 if (@is_dir($file)) { 1238 rm_rf($file); 1239 } elseif (is_writable($file)) { 1240 unlink($file); 1241 } else { 1242 echo $file . "is not writable and cannot be removed. 1243Please fix the permission or select a new path.\n"; 1244 } 1245 } 1246 closedir($dp); 1247 return rmdir($path); 1248 } else { 1249 return @unlink($path); 1250 } 1251} 1252 1253// }}} 1254// {{{ tmpdir() 1255/* 1256 * Fixes for winXP/wrong tmp set by Urs Gehrig (urs@circle.ch) 1257 */ 1258function temp_dir($default=false) 1259{ 1260 global $ptmp, $prefix; 1261 1262 if ($default) { 1263 if (!@is_dir($default)) { 1264 if (!mkdir_p($default)) { 1265 return false; 1266 } 1267 } 1268 1269 /* try it really, is_writable is buggy with openbasedir */ 1270 $fh = @fopen(realpath($default) . "/test","wb"); 1271 if ($fh) { 1272 // desparately try to set temp dir any possible way, see bug #13167 1273 $ptmp = $_temp = $temp_dir = $default; 1274 putenv('TMPDIR='.$default); 1275 return true; 1276 } else { 1277 return false; 1278 } 1279 } 1280 1281 $_temp = false; 1282 if (WINDOWS){ 1283 if ( my_env('TEMP') ) { 1284 $_temp = my_env('TEMP'); 1285 } elseif ( my_env('TMP') ) { 1286 $_temp = my_env('TMP'); 1287 } elseif ( my_env('windir') ) { 1288 $_temp = my_env('windir') . '\temp'; 1289 } elseif ( my_env('SystemRoot') ) { 1290 $_temp = my_env('SystemRoot') . '\temp'; 1291 } 1292 1293 // handle ugly ENV var like \Temp instead of c:\Temp 1294 $dirs = explode("\\", realpath($_temp)); 1295 if(strpos($_temp, ":") != 1) { 1296 unset($_temp); 1297 $_dirs = array(); 1298 foreach($dirs as $val) { 1299 if((boolean)$val ) { 1300 $_dirs[] = str_replace("/", "", $val); 1301 } 1302 } 1303 unset($dirs); 1304 $dirs = $_dirs; 1305 array_unshift ($dirs, "c:" ); 1306 $_temp = $dirs[0]; 1307 for($i = 1;$i < count($dirs);$i++) { 1308 $_temp .= "//" . $dirs[$i]; 1309 } 1310 } 1311 $ptmp = $_temp; 1312 } else { 1313 $_temp = my_env('TMPDIR'); 1314 if (!$_temp) { 1315 if (is_writable('/tmp')) { 1316 $_temp = '/tmp'; 1317 } 1318 } 1319 } 1320 1321 // If for some reason the user has no rights to access to 1322 // the standard tempdir, we assume that he has the right 1323 // to access his prefix and choose $prefix/tmp as tempdir 1324 if (!$_temp || !is_writable($_temp)) { 1325 print "System's Tempdir failed, trying to use \$prefix/tmp ..."; 1326 $res = mkdir_p($prefix.'/tmp'); 1327 if (!$res) { 1328 bail('mkdir '.$prefix.'/tmp'.' ... failed'); 1329 } 1330 1331 $ptmp = $prefix . '/tmp'; 1332 $_temp = tempnam($prefix.'/tmp', 'gope'); 1333 1334 rm_rf($_temp); 1335 mkdir_p($_temp, 0700); 1336 $ok = @chdir($ptmp); 1337 1338 if (!$ok) { // This should not happen, really ;) 1339 bail('chdir '.$ptmp.' ... failed'); 1340 } 1341 1342 print "ok\n"; 1343 1344 // Adjust TEMPDIR envvars 1345 if (!isset($_ENV)) { 1346 $_ENV = array(); 1347 } 1348 $_ENV['TMPDIR'] = $_ENV['TEMP'] = $prefix.'/tmp'; 1349 } else { 1350 $_temp = tempnam($_temp.'/tmp', 'gope'); 1351 } 1352 $temp_dir = $ptmp = $_temp; 1353 return true; 1354} 1355 1356// }}} 1357// {{{ my_env() 1358/* 1359(cox) In my system PHP 4.2.1 (both cgi & cli) $_ENV is empty 1360 but getenv() does work fine 1361*/ 1362function my_env($var) 1363{ 1364 if (is_array($_ENV) && isset($_ENV[$var])) { 1365 return $_ENV[$var]; 1366 } 1367 return getenv($var); 1368} 1369 1370// }}} 1371// {{{ detect_install_dirs() 1372 1373function detect_install_dirs($_prefix = null) { 1374 global $temp_dir, $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir; 1375 if (WINDOWS) { 1376 if ($_prefix === null) { 1377 $prefix = getcwd(); 1378 } else { 1379 $prefix = $_prefix; 1380 } 1381 1382 if (!@is_dir($prefix)) { 1383 if (@is_dir('c:\php5')) { 1384 $prefix = 'c:\php5'; 1385 } elseif (@is_dir('c:\php4')) { 1386 $prefix = 'c:\php4'; 1387 } elseif (@is_dir('c:\php')) { 1388 $prefix = 'c:\php'; 1389 } 1390 } 1391 1392 $bin_dir = '$prefix'; 1393 $php_dir = '$prefix\pear'; 1394 $doc_dir = '$php_dir\docs'; 1395 $data_dir = '$php_dir\data'; 1396 $test_dir = '$php_dir\tests'; 1397 $temp_dir = '$prefix\temp'; 1398 1399 /* 1400 * Detects php.exe 1401 */ 1402 if( $t=getenv('PHP_PEAR_PHP_BIN') ){ 1403 $php_bin = $t; 1404 } elseif ($t=getenv('PHP_BIN') ) { 1405 $php_bin = $t; 1406 } elseif ( $t=which('php') ) { 1407 $php_bin = $t; 1408 } elseif ( is_file($prefix.'\cli\php.exe') ) { 1409 $php_bin = $prefix.'\cli\php.exe'; 1410 } elseif ( is_file($prefix.'\php.exe') ) { 1411 $php_bin = $prefix.'\php.exe'; 1412 } 1413 if( $php_bin && !is_file($php_bin) ){ 1414 $php_bin = ''; 1415 } else { 1416 if(!ereg(":",$php_bin)){ 1417 $php_bin = getcwd().DIRECTORY_SEPARATOR.$php_bin; 1418 } 1419 } 1420 if (!is_file($php_bin)) { 1421 if (is_file('c:/php/cli/php.exe')) { 1422 $php_bin = 'c:/php/cli/php.exe'; 1423 } elseif (is_file('c:/php5/php.exe')) { 1424 $php_bin = 'c:/php5/php.exe'; 1425 } elseif (is_file('c:/php4/cli/php.exe')) { 1426 $php_bin = 'c:/php4/cli/php.exe'; 1427 } 1428 } 1429 } else { 1430 if ($_prefix === null) { 1431 $prefix = '/usr/local'; 1432 } else { 1433 $prefix = $_prefix; 1434 } 1435 $bin_dir = '$prefix/bin'; 1436 $php_dir = '$prefix/share/pear'; 1437 $doc_dir = '$prefix/share/doc/pear'; 1438 $data_dir = '$php_dir/data'; 1439 $test_dir = '$php_dir/tests'; 1440 $temp_dir = '/tmp/pear'; 1441/* 1442 // check if the user has installed PHP with PHP or GNU layout 1443 if (@is_dir("$prefix/lib/php/.registry")) { 1444 $php_dir = '$prefix/lib/php'; 1445 } elseif (@is_dir("$prefix/share/pear/lib/.registry")) { 1446 $php_dir = '$prefix/share/pear/lib'; 1447 $doc_dir = '$prefix/share/pear/docs'; 1448 $data_dir = '$prefix/share/pear/data'; 1449 $test_dir = '$prefix/share/pear/tests'; 1450 } elseif (@is_dir("$prefix/share/php/.registry")) { 1451 $php_dir = '$prefix/share/php'; 1452 } 1453*/ 1454 } 1455} 1456 1457// }}} 1458// {{{ displayHTMLHeader 1459 1460function displayHTMLHeader() 1461{ 1462?> 1463<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 1464<html> 1465<head> 1466 <title>PEAR :: Installer :: Go-PEAR</title> 1467 <style type="text/css"> 1468 <!-- 1469 a { 1470 color:#000000; 1471 text-decoration: none; 1472 } 1473 a:visited { 1474 color:#000000; 1475 text-decoration: none; 1476 } 1477 a:active { 1478 color:#000000; 1479 text-decoration: none; 1480 } 1481 a:hover { 1482 color:#000000; 1483 text-decoration: underline; 1484 } 1485 1486 a.green { 1487 color:#006600; 1488 text-decoration: none; 1489 } 1490 a.green:visited { 1491 color:#006600; 1492 text-decoration: none; 1493 } 1494 a.green:active { 1495 color:#006600; 1496 text-decoration: none; 1497 } 1498 a.green:hover { 1499 color:#006600; 1500 text-decoration: underline; 1501 } 1502 1503 body, td, th { 1504 font-family: verdana,arial,helvetica,sans-serif; 1505 font-size: 90%; 1506 } 1507 1508 p { 1509 font-family: verdana,arial,helvetica,sans-serif; 1510 } 1511 1512 th.pack { 1513 color: #FFFFFF; 1514 background: #009933; 1515 text-align: right; 1516 } 1517 1518 td.package_info_title { 1519 color: #006600; 1520 font-weight: bold; 1521 } 1522 1523 th.others { 1524 color: #006600; 1525 text-align: left; 1526 } 1527 1528 em { 1529 font-weight: bold; 1530 font-style: italic; 1531 } 1532 1533 .green { 1534 color: #006600; 1535 } 1536 .red { 1537 color: #ff0000; 1538 } 1539 .grey { 1540 color: #a9a9a9; 1541 } 1542 1543 span.headline { 1544 font-family: verdana,arial,helvetica,sans-serif; 1545 font-size: 125%; 1546 font-weight: bold; 1547 color: #ffffff; 1548 } 1549 1550 span.title { 1551 font-family: verdana,arial,helvetica,sans-serif; 1552 font-size: 110%; 1553 font-weight: bold; 1554 color: #006600; 1555 } 1556 1557 .newsDate { 1558 font-size: 85%; 1559 font-style: italic; 1560 color: #66cc66; 1561 } 1562 1563 .compact { 1564 font-family: arial, helvetica, sans-serif; 1565 font-size: 90%; 1566 } 1567 1568 .menuWhite { 1569 font-family: verdana,arial,helvetica,sans-serif; 1570 font-size: 75%; 1571 color: #ffffff; 1572 } 1573 .menuBlack { 1574 font-family: verdana,arial,helvetica,sans-serif; 1575 text-decoration: none; 1576 font-weight: bold; 1577 font-size: 75%; 1578 color: #000000; 1579 } 1580 1581 .sidebar { 1582 font-size: 85%; 1583 } 1584 1585 code, pre, tt { 1586 font-family: Courier, "Courier New", monospace; 1587 font-size: 90%; 1588 } 1589 1590 pre.php { 1591 border-color: black; 1592 border-style: dashed; 1593 border-width: 1px; 1594 background-color: #eeeeee; 1595 padding: 5px; 1596 } 1597 1598 h1 { 1599 font-family: verdana,arial,helvetica,sans-serif; 1600 font-size: 140%; 1601 font-weight: bold; 1602 color: #006600; 1603 } 1604 1605 h2 { 1606 font-family: verdana,arial,helvetica,sans-serif; 1607 font-size: 125%; 1608 font-weight: bold; 1609 color: #006600; 1610 } 1611 1612 h3 { 1613 font-family: verdana,arial,helvetica,sans-serif; 1614 font-size: 110%; 1615 font-weight: bold; 1616 color: #006600; 1617 } 1618 1619 small { 1620 font-family: verdana,arial,helvetica,sans-serif; 1621 font-size: 75%; 1622 } 1623 1624 a.small { 1625 font-family: verdana,arial,helvetica,sans-serif; 1626 font-size: 75%; 1627 text-decoration: none; 1628 } 1629 1630 .tableTitle { 1631 font-family: verdana,arial,helvetica,sans-serif; 1632 font-weight: bold; 1633 } 1634 1635 .tableExtras { 1636 font-family: verdana,arial,helvetica,sans-serif; 1637 font-size: 85%; 1638 color: #FFFFFF; 1639 } 1640 1641 input { 1642 font-family: verdana,arial,helvetica,sans-serif; 1643 } 1644 1645 textarea { 1646 font-family: verdana,arial,helvetica,sans-serif; 1647 } 1648 1649 input.small, select.small { 1650 font-family: verdana,arial,helvetica,sans-serif; 1651 font-size: 75%; 1652 } 1653 1654 textarea.small { 1655 font-family: verdana,arial,helvetica,sans-serif; 1656 font-size: 75%; 1657 } 1658 1659 form { 1660 margin-bottom : 0; 1661 } 1662 hr { 1663 text-align: left; 1664 width: 80%; 1665 } 1666 --> 1667 </style> 1668 <meta name="description" content="This is the Web Interface of the PEAR Installer" /> 1669</head> 1670 1671<body topmargin="0" leftmargin="0" 1672 marginheight="0" marginwidth="0" 1673 bgcolor="#ffffff" 1674 text="#000000" 1675 link="#006600" 1676 alink="#cccc00" 1677 vlink="#003300" 1678> 1679<?php 1680} 1681 1682// }}} 1683// {{{ displayHTML 1684 1685function displayHTML($page = 'Welcome', $data = array()) 1686{ 1687 global $pfc_packages; 1688 1689 displayHTMLHeader(); 1690 1691?> 1692<a name="TOP" /></a> 1693<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%"> 1694 <tr bgcolor="#339900"> 1695 <td align="left" width="120"> 1696 <img src="<?php echo basename(__FILE__); ?>?action=img&img=pearlogo" width="104" height="50" vspace="2" hspace="5" alt="PEAR"> 1697 </td> 1698 <td align="left" valign="middle" width="20"> 1699 1700 </td> 1701 <td align="left" valign="middle"> 1702 <span class="Headline">Go-PEAR Installer</span> 1703 </td> 1704 </tr> 1705 1706 <tr bgcolor="#003300"><td colspan="3"></td></tr> 1707 1708 <tr bgcolor="#006600"> 1709 <td align="right" valign="top" colspan="3"> 1710 <span style="color: #ffffff">Version <?php echo GO_PEAR_VER; ?></span> <br /> 1711 </td> 1712 </tr> 1713 1714 <tr bgcolor="#003300"><td colspan="3"></td></tr> 1715</table> 1716 1717 1718<table cellpadding="0" cellspacing="0" width="100%"> 1719 <tr valign="top"> 1720 <td bgcolor="#f0f0f0" width="100"> 1721 <table width="200" border="0" cellpadding="4" cellspacing="0"> 1722 <tr valign="top"> 1723 <td style="font-size: 90%" align="left" width="200"> 1724 <p><br /> 1725 <?php 1726 $menus = array('Welcome' => 'Welcome to Go-PEAR', 1727 'config' => 'Configuration', 1728 'preinstall' => 'Installation', 1729 'install' => 'Completed'); 1730 $after_current = false; 1731 1732 // Menu robustness (a bit low, but better then never) 1733 if ($page == 'error') { 1734 $_GET['last'] = $_GET['step']; 1735 $after_current = true; 1736 } elseif (!array_key_exists($page, $menus)) { 1737 $page = 'Welcome'; 1738 } 1739 1740 foreach ($menus as $menu => $descr) { 1741 print('<img src="'.basename(__FILE__).'?action=img&img=smallpear" alt="" />'); 1742 1743 if (!$after_current) { 1744 $class = ''; 1745 if ($page == $menu) { 1746 $class = 'green'; 1747 } 1748 if (!isSet($_GET['last'])) { $_GET['last'] = $page; } 1749 print('<a href="'.basename(__FILE__).'?step='.$menu.'&last='.$_GET['last'].'" class="'.$class.'">'.$descr.'</a><br />'); 1750 1751 if ($_GET['last'] == $menu) { 1752 $after_current = true; 1753 } 1754 } else { 1755 print('<span class="grey">'.$descr.'</span><br />'); 1756 } 1757 } 1758 ?> 1759 1760 </td> 1761 </tr> 1762 </table> 1763 </td> 1764 <td bgcolor="#cccccc" width="1" background="/gifs/checkerboard.gif"></td> 1765 <td> 1766 <table width="100%" cellpadding="10" cellspacing="0"> 1767 <tr> 1768 <td valign="top"> 1769 1770<table border="0"> 1771<tr> 1772 <td width="20"> 1773 </td> 1774 <td> 1775<?php 1776 if ($page == 'error') { 1777?> 1778 <span class="title">Error</span><br/> 1779 <br/> 1780<?php 1781 $value = $data; 1782 if (preg_match('/ok$/', $value)) { 1783 $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value); 1784 } 1785 if (preg_match('/failed$/', $value)) { 1786 $value = preg_replace('/(failed)$/', '<span class="red">\1</span>', $value); 1787 } 1788 if (preg_match('/^install ok:/', $value)) { 1789 $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value); 1790 } 1791 if (preg_match('/^Warning:/', $value)) { 1792 $value = '<span style="color: #ff0000">'.$value.'</span>'; 1793 } 1794 1795 echo nl2br($value); 1796 } elseif ($page == 'Welcome') { 1797?> 1798 <span class="title">Welcome to go-pear <?php echo GO_PEAR_VER; ?>!</span><br/> 1799 <p> 1800 Go-pear will install Pear, its Web Frontend and all the needed files. This<br/> 1801 frontend is your tool for PEAR installation and maintenance. 1802 </p> 1803 <p> 1804 Go-pear also lets you download and install the following optional PEAR<br/> 1805 packages: <?php echo implode(', ', array_keys($GLOBALS['pfc_packages'])); ?>. 1806 </p> 1807 1808 <a href="<?php echo basename(__FILE__); ?>?step=config&restart=1" class="green">Next >></a> 1809<?php 1810 } elseif ($page == 'config') { 1811 if (!empty($GLOBALS['http_proxy'])) { 1812 $tmp_proxy = parse_url($GLOBALS['http_proxy']); 1813 1814 $proxy_host = $tmp_proxy['scheme'] . '://'; 1815 if ($tmp_proxy['user'] != '') { 1816 $proxy_host .= $tmp_proxy['user']; 1817 if ($tmp_proxy['pass'] != '') { 1818 $proxy_host .= ':' . $tmp_proxy['pass']; 1819 } 1820 $proxy_host .= '@'; 1821 } 1822 $proxy_host .= $tmp_proxy['host']; 1823 $proxy_port = $tmp_proxy['port']; 1824 } else { 1825 $proxy_host = $proxy_port = ''; 1826 } 1827?> 1828 <form action="<?php echo basename(__FILE__);?>?step=install" method="post"> 1829 <!-- Packages stuff --> 1830 <span class="title">Packages</span> 1831 <p> 1832 The following PEAR packages will be installed. You can select some optional<br /> 1833 packages to be installed by go-pear too:<br /> 1834 </p> 1835 <table border="0"> 1836 <tr> 1837 <th> </th><th>Package</th><th width="65%">Description</th> 1838 </tr><tr> 1839 <td>(required)</td><td>PEAR core</td><td>PEAR Base System</td> 1840 </tr> 1841 1842 <?php 1843 // automatically install frontend 1844 $frontend = 'PEAR_Frontend_Web-beta'; 1845 print('<tr><td>(required)<input type="hidden" name="'.$frontend.'" value="on" /></td><td>'.$frontend.'</td><td>'.$GLOBALS['pfc_packages'][$frontend].'</td></tr>'); 1846 unset($GLOBALS['pfc_packages'][$frontend]); 1847 1848 foreach ($GLOBALS['pfc_packages'] as $var => $descr) { 1849 $checked = ''; 1850 if (in_array($var, $GLOBALS['install_optional_packages'])) { $checked = ' checked'; } 1851 printf('<tr><td align="center"><input type="checkbox" name="%s"%s></td><td>%s</td><td>%s</td></tr>', 1852 $var, 1853 $checked, 1854 $var, 1855 $descr); 1856 } 1857 ?> 1858 </table> 1859 <hr /> 1860 1861 <!-- Configuration stuff --> 1862 <span class="title">Configuration</span> 1863 <p> 1864 Below is a suggested file layout for your new PEAR installation. 1865 </p> 1866 1867 <!-- 1868 <p> 1869 <table border="0"> 1870 <tr> 1871 <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" /></td> 1872 <td> 1873 <span class="green"> 1874 <b>Note:</b> Make sure that PHP has the permission to access the specified<br/> 1875 directories. 1876 </span> 1877 </td> 1878 </tr> 1879 </table> 1880 </p> 1881 --> 1882 1883 <table border="0" width="80%"> 1884<?php 1885 foreach ($GLOBALS['config_vars'] as $n => $var) { 1886 $error_class = ''; 1887 if (is_array($GLOBALS['config_errors']) && array_key_exists($var, $GLOBALS['config_errors'])) { 1888 // www_error for this var 1889 $error_class = ' class="red"'; 1890 } 1891 1892 printf('<tr><td>%d. %s</td><td><input type="text" name="config[%s]" value="%s"%s></td></tr>', 1893 $n, 1894 $GLOBALS['config_desc'][$var], 1895 $var, 1896 $_SESSION['go-pear']['config'][$var], 1897 $error_class); 1898 1899 // prefix dir, check perm (uses GLOBALS: resolved subvars) 1900 if ($n == 1 && is_dir($GLOBALS[$var]) && !is_writable($GLOBALS[$var])) { 1901 $error = '<em>WARNING!</em> No permission to create subdirectories in this prefix dir. Unless you fix this, the default configuration will not work.'; 1902 if (!WINDOWS) { 1903 $error .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br /> 1904<tt>chmod 0777 '.$GLOBALS[$var].'</tt></p>'; 1905 } 1906 print('<tr><td colspan="2" class="green">'.$error.'</td></tr>'); 1907 } 1908 1909 1910 if (is_array($GLOBALS['config_errors']) && array_key_exists($var, $GLOBALS['config_errors'])) { 1911 // www_error for this var 1912 print('<tr><td colspan="2" class="red">'.$GLOBALS['config_errors'][$var].'</td></tr>'); 1913 } 1914 } 1915?> 1916 </table> 1917 </p> 1918 <hr /> 1919 1920 <!-- Optional stuff --> 1921 <span class="title">Optional:</span> 1922 1923 <ul> 1924 <p> 1925 <li />HTTP proxy (host:port) 1926 <input type="text" name="proxy[host]" value="<?php echo $proxy_host;?>"> : <input type="text" name="proxy[port]" value="<?php echo $proxy_port;?>" size="6"> 1927 </p> 1928 1929 <p> 1930 <li />Compatibility-Mode for old non-DOM Browsers <input type="checkbox" name="BCmode" id="BCmode" checked> 1931 <script type="text/javascript"> 1932 <!-- 1933 if (document.getElementById('BCmode')) { 1934 document.getElementById('BCmode').checked = 0; 1935 }; 1936 // --> 1937 </script> 1938 </p> 1939 </ul> 1940 1941<?php 1942 if (WINDOWS && phpversion() == '4.1.1') { 1943?> 1944 <p> 1945 <table border="0"> 1946 <tr> 1947 <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" alt="" /></td> 1948 <td> 1949 <span style="color: #ff0000"> 1950 <b>Warning:</b> Your PHP version (4.1.1) might be imcompatible with go-pear due to a bug<br/> 1951 in your PHP binary. If the installation crashes you might want to update your PHP version.</br> 1952 </span> 1953 </td> 1954 </tr> 1955 </table> 1956 </p> 1957<?php 1958 } 1959?> 1960 <hr /> 1961 <!-- Closing note --> 1962 <p> 1963 <table border="0"> 1964 <tr> 1965 <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" alt="" /></td> 1966 <td> 1967 <span class="green"> 1968 <b>Note:</b> Installation might take some time, because go-pear has to<br/> 1969 download all needed files from pear.php.net. Just be patient and wait for<br/> 1970 the next page to load.<br/> 1971 </span> 1972 </td> 1973 </tr> 1974 </table> 1975 </p> 1976 1977 <input type="submit" value="Install" onClick="javascript: submitButton.value='Downloading and installing ... please wait ...'" name="submitButton"> 1978 </form> 1979 1980<?php 1981 } elseif ($page == 'install') { 1982?> 1983 <span class="title">Installation Complete - Summary</span><br/> 1984<?php 1985 displayHTMLInstallationSummary($data); 1986 } elseif ($page == 'preinstall') { 1987?> 1988 <p> 1989 <span class="title">Installation in progress ...</span></br > 1990 <i>(If the page stops loading before the end of the installation, then just reload it)</i></p> 1991 <script type="text/javascript"> 1992 <!-- 1993 1994 var progress; 1995 var downloadprogress; 1996 progress = 0; 1997 downloadprogress = 0; 1998 1999 function setprogress(value) 2000 { 2001 progress = value; 2002 2003 prog = document.getElementById('installation_progress'); 2004 prog.innerHTML = progress + " %"; 2005 progress2 = progress / 10; 2006 progress2 = Math.floor(progress2); 2007 for (i=0; i < 10; i++) 2008 document.getElementById('progress_cell_'+i).style.backgroundColor = "#cccccc"; 2009 switch(progress2) 2010 { 2011 case 10: 2012 document.getElementById('progress_cell_9').style.backgroundColor = "#006600"; 2013 case 9: 2014 document.getElementById('progress_cell_8').style.backgroundColor = "#006600"; 2015 case 8: 2016 document.getElementById('progress_cell_7').style.backgroundColor = "#006600"; 2017 case 7: 2018 document.getElementById('progress_cell_6').style.backgroundColor = "#006600"; 2019 case 6: 2020 document.getElementById('progress_cell_5').style.backgroundColor = "#006600"; 2021 case 5: 2022 document.getElementById('progress_cell_4').style.backgroundColor = "#006600"; 2023 case 4: 2024 document.getElementById('progress_cell_3').style.backgroundColor = "#006600"; 2025 case 3: 2026 document.getElementById('progress_cell_2').style.backgroundColor = "#006600"; 2027 case 2: 2028 document.getElementById('progress_cell_1').style.backgroundColor = "#006600"; 2029 case 1: 2030 document.getElementById('progress_cell_0').style.backgroundColor = "#006600"; 2031 }; 2032 } 2033 2034 function addprogress(value) 2035 { 2036 progress += value; 2037 setprogress(progress); 2038 } 2039 2040 function setdownloadfile(value) 2041 { 2042 setdownloadprogress(0); 2043 2044 prog = document.getElementById('download_file'); 2045 prog.innerHTML = 'Downloading '+value+' ...'; 2046 }; 2047 2048 function unsetdownloadfile() 2049 { 2050 setdownloadprogress(0); 2051 2052 prog = document.getElementById('download_file'); 2053 prog.innerHTML = ''; 2054 }; 2055 2056 function setdownloadprogress(value) 2057 { 2058 downloadprogress = value; 2059 2060 prog = document.getElementById('download_progress'); 2061 prog.innerHTML = downloadprogress + " %"; 2062 progress2 = downloadprogress / 10; 2063 progress2 = Math.floor(progress2); 2064 for (i=0; i < 10; i++) 2065 document.getElementById('download_progress_cell_'+i).style.backgroundColor = "#cccccc"; 2066 switch(progress2) 2067 { 2068 case 10: 2069 document.getElementById('download_progress_cell_9').style.backgroundColor = "#006600"; 2070 case 9: 2071 document.getElementById('download_progress_cell_8').style.backgroundColor = "#006600"; 2072 case 8: 2073 document.getElementById('download_progress_cell_7').style.backgroundColor = "#006600"; 2074 case 7: 2075 document.getElementById('download_progress_cell_6').style.backgroundColor = "#006600"; 2076 case 6: 2077 document.getElementById('download_progress_cell_5').style.backgroundColor = "#006600"; 2078 case 5: 2079 document.getElementById('download_progress_cell_4').style.backgroundColor = "#006600"; 2080 case 4: 2081 document.getElementById('download_progress_cell_3').style.backgroundColor = "#006600"; 2082 case 3: 2083 document.getElementById('download_progress_cell_2').style.backgroundColor = "#006600"; 2084 case 2: 2085 document.getElementById('download_progress_cell_1').style.backgroundColor = "#006600"; 2086 case 1: 2087 document.getElementById('download_progress_cell_0').style.backgroundColor = "#006600"; 2088 }; 2089 }; 2090 2091 // --> 2092 </script> 2093 <table style="border-width: 1px; border-color: #000000" cellspacing="0" cellpadding="0"> 2094 <tr> 2095 <td> 2096 <table border="0"> 2097 <tr> 2098 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_0"> </td> 2099 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_1"> </td> 2100 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_2"> </td> 2101 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_3"> </td> 2102 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_4"> </td> 2103 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_5"> </td> 2104 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_6"> </td> 2105 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_7"> </td> 2106 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_8"> </td> 2107 <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_9"> </td> 2108 <td bgcolor="#ffffff" width="10" height="20"> </td> 2109 <td bgcolor="#ffffff" height="20" id="installation_progress" class="green">0 %</td> 2110 </tr> 2111 </table> 2112 <br /> 2113 <table border="0"> 2114 <tr> 2115 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_0"> </td> 2116 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_1"> </td> 2117 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_2"> </td> 2118 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_3"> </td> 2119 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_4"> </td> 2120 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_5"> </td> 2121 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_6"> </td> 2122 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_7"> </td> 2123 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_8"> </td> 2124 <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_9"> </td> 2125 <td bgcolor="#ffffff" width="10" height="20"> </td> 2126 <td bgcolor="#ffffff" height="20" id="download_progress" class="green">0 %</td> 2127 <td bgcolor="#ffffff" width="10" height="20"> </td> 2128 <td bgcolor="#ffffff" height="20" id="download_file" class="green"></td> 2129 </tr> 2130 </table> 2131 <br /> 2132 <iframe src="<?php echo basename(__FILE__); ?>?step=install-progress&<?php echo SID;?>" width="700" height="700" frameborder="0" marginheight="0" marginwidth="0"></iframe> 2133 </td> 2134 </tr> 2135 </table> 2136<?php 2137 } 2138?> 2139 </td> 2140</tr> 2141</table> 2142 2143 2144</td> 2145 </tr> 2146 </table> 2147 </td> 2148 2149 </tr> 2150</table> 2151<?php 2152 displayHTMLFooter(); 2153} 2154 2155// }}} 2156// {{{ displayHTMLFooter 2157 2158function displayHTMLFooter() 2159{ 2160 ?> 2161 </body> 2162 </html> 2163 <?php 2164}; 2165 2166// }}} 2167// {{{ displayHTMLInstallationSummary 2168 2169function displayHTMLInstallationSummary($data = '') 2170{ 2171 $next = NULL; 2172 $file = $GLOBALS['webfrontend_file']; 2173 $doc_root = strip_magic_quotes($_SERVER['DOCUMENT_ROOT']); 2174 $file_dir = dirname(__FILE__); 2175 if ( WINDOWS ) { 2176 $file = str_replace('/', '\\', strtolower($file)); 2177 $doc_root = str_replace('/', '\\', strtolower($doc_root)); 2178 $file_dir = str_replace('/', '\\', strtolower($file_dir)); 2179 } 2180 2181 if ($doc_root && substr($file, 0, strlen($doc_root)) == $doc_root) { 2182 $next = substr($file, strlen($doc_root)); 2183 // need leading / (file - docroot = path from docroot) 2184 if (substr($next, 0, 1) != '/') { 2185 $next = '/'.$next; 2186 } 2187 } else if ($file_dir && substr($file, 0, strlen($file_dir)) == $file_dir) { 2188 $next = substr($file, strlen($file_dir)); 2189 // strip leading / (file - file_dir = path from go-pear file) 2190 if (substr($next, 0, 1) == '/') { 2191 $next = substr($next, 1, strlen($next)); 2192 } 2193 } 2194 2195 if ($data) { 2196 echo "<br/>".$data; 2197 } 2198?> 2199 <p> 2200 <span class="title">Installation Completed !</span> 2201 </p> 2202 2203 <table border="0"> 2204 <tr> 2205 <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" alt="" /></td> 2206 <td> 2207 <span class="green"> 2208 <b>Note:</b> To use PEAR without any problems you need to add your<br/> 2209 PEAR Installation path (<?php echo $GLOBALS['php_dir']; ?>)<br /> 2210 to your <a href="http://www.php.net/manual/en/configuration.directives.php#ini.include_path">include_path</a>.<br/> 2211 <br/> 2212 Using a .htaccess file or directly edit httpd.conf would be working solutions<br/> 2213 for Apache running servers, too.<br/> 2214 </span> 2215 </td> 2216 </tr> 2217 </table> 2218 <br/> 2219 For more information about PEAR, see:<br/> 2220 <a href="http://pear.php.net/faq.php" target="_new" class="green">PEAR FAQ</a><br/> 2221 <a href="http://pear.php.net/manual/" target="_new" class="green">PEAR Manual</a><br/> 2222 <br/> 2223 Thanks for using go-pear!<br/> 2224 <br/> 2225<?php 2226 if ($next === NULL) { 2227?> 2228 <table border="0"> 2229 <tr> 2230 <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" alt="" /></td> 2231 <td> 2232 <span style="color: #ff0000"> 2233 <b>Warning:</b> Can not determine the URL of the freshly installed Web Frontend<br /> 2234 (file: <?php echo $file ?>).<br /> 2235 Please access it manually ! 2236 </span> 2237 </td> 2238 </tr> 2239 </table> 2240<?php 2241 } else { 2242 if ($_GET['step'] == 'install-progress') { 2243?> 2244 <a href="<?php echo $next;?>" class="green" target="_parent">Start Web Frontend of the PEAR Installer >></a> 2245<?php 2246 } else { 2247?> 2248 <a href="<?php echo $next;?>" class="green">Start Web Frontend of the PEAR Installer >></a> 2249<?php 2250 } 2251 } 2252} 2253 2254// }}} 2255// {{{ strip_magic_quotes 2256 2257function strip_magic_quotes($value) 2258{ 2259 if (ini_get('magic_quotes_gpc')) { 2260 return stripslashes($value); 2261 } 2262 return $value; 2263}; 2264 2265// }}} 2266// {{{ showImage 2267 2268function showImage($img) 2269{ 2270 $images = array( 2271 'smallpear' => array( 2272 'type' => 'gif', 2273 'data' => 'R0lGODlhEQATAMQAAAAAACqUACiTAC2WAC+YAzKZBTSaBsHgszOZADCYADmcB4TCZp3Ohtfrzd/v1+by4PD47DaaAz+fDUijF2WyOlCoHvT58VqtJPn893y+S/v9+f7//f3+/Pz9+////////ywAAAAAEQATAAAFkqAnjiR5NGXqcdpCoapnMVRdWbEHUROVVROYalHJTCaVAKWTcjAUGckgQY04SJAFMhJJIL5e4a5I6X6/gwlkRIwOzucAY9SYZBRvOCKheIwYFxR5enxCLhVeemAHbBQVg4SMIoCCinsKVyIOdlKKAhQcJFpGiWgFQiIYPxeJCQEEcykcDIgDAwYUkjEWB70NGykhADs=', 2274 ), 2275 'pearlogo' => array( 2276 'type' => 'gif', 2277 'data' => 'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEekFluvKmu3PvX68ujz4XvBS8LgrNXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/ICCOZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1AuiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoSDxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIWWQPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFEAWCTxse+ABD4SClWA0zovAjcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSKkbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmEvDTEETAVJ6bEpypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQs+cEHgIiHVH5EAFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzcYpdiNgddc0E8cKBAu/FElBwagMb88ZZKDRAkWJtkWhHh3wwUbKHQJN3wQAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MDVKwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBET9lFjggKhDYZAELZJYEBI2BDB3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BPPZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmRa7XDjKZXhBdAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYiWHb+WQBgaIJqqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAWdgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFANRgqcJoEDRARLREtxOQpsPO906ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgUA3Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH7nARBArqwi0gkFJBrZiXBQRbHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GGKW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oHs1CAgMoBxzRqvzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQGHcs/RRdiUDPHA33oADEAIAOw==', 2278 ), 2279 'note' => array( 2280 'type' => 'png', 2281 'data' => 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAAAAADFHGIkAAAAAmJLR0QAAKqNIzIAAAEESURBVHjaZZIhksMwDEV9voWFSwsLA0MLDf8VdARBUUNBQ1FBHcErZ5M0baXJjOPnb0vfLuMMn3H+lWMgBKL89A1Eq9Q9IrwB+gIOsnMPBR8giMclguQfBGS8x5xIoPQxnxqb4LL/eQ4l2AVNONP2ZshLCqJ3qqzWtT5pNgNnLU4OcNbuiqaLmFmHGhJ0TCMC99+f2wphlhaOYjuQVc0IIzLH2BRWfQoWsNSjct8AVop4rF3belTuVAb3MRj6kLrcTwtIy+g03V1vC57t1XrMzqfP5pln5yLTkk7+5UhstvOni1X3ixLEdf2c36+W0Q7kOb48hnSRLI/XdNPfX4kpMkgP5R+elfdkDPprQgAAAEN0RVh0U29mdHdhcmUAQCgjKUltYWdlTWFnaWNrIDQuMi44IDk5LzA4LzAxIGNyaXN0eUBteXN0aWMuZXMuZHVwb250LmNvbZG6IbgAAAAqdEVYdFNpZ25hdHVyZQAzYmQ3NDdjNWU0NTgwNzAwNmIwOTBkZDNlN2EyNmM0NBTTk/oAAAAOdEVYdFBhZ2UAMjR4MjQrMCswclsJMQAAAABJRU5ErkJggg==', 2282 ), 2283 ); 2284 2285 Header('Content-Type: image/'.$images[$img]['type']); 2286 echo base64_decode($images[$img]['data']); 2287}; 2288 2289// }}} 2290// {{{ displayHTMLProgress 2291 2292function displayHTMLProgress($progress) 2293{ 2294 if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) { 2295 return; 2296 }; 2297 $msg = ob_get_contents(); 2298 ob_end_clean(); 2299 2300 $msg = explode("\n", $msg); 2301 foreach($msg as $key => $value) { 2302 if (preg_match('/ok$/', $value)) { 2303 $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value); 2304 }; 2305 if (preg_match('/failed$/', $value)) { 2306 $value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value); 2307 }; 2308 if (preg_match('/^install ok:/', $value)) { 2309 //$value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value).'<br />'; 2310 //$msg = array($value); // if install succeeded: don't show the irritatingly verbose pear installer 2311 $msg = array('<span class="green">ok</span><br />'); 2312 break; 2313 }; 2314 if (preg_match('/^Warning:/', $value)) { 2315 $value = '<span style="color: #ff0000">'.$value.'</span>'; 2316 }; 2317 $msg[$key] = $value; 2318 }; 2319 $msg = implode('<br />', $msg); 2320 2321 $msg.='<script type="text/javascript"> parent.setprogress('.((int) $progress).'); </script>'; 2322 2323 echo $msg; 2324 ob_start(); 2325}; 2326 2327// }}} 2328// {{{ displayHTMLDownloadProgress 2329 2330function displayHTMLDownloadProgress($progress) 2331{ 2332 if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) { 2333 return; 2334 }; 2335 $msg = ob_get_contents(); 2336 ob_end_clean(); 2337 2338 echo '<script type="text/javascript"> parent.setdownloadprogress('.((int) $progress).'); </script>'; 2339 2340 ob_start(); 2341 echo $msg; 2342}; 2343 2344// }}} 2345// {{{ displayHTMLSetDownload 2346 2347function displayHTMLSetDownload($file) 2348{ 2349 if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) { 2350 return; 2351 }; 2352 $msg = ob_get_contents(); 2353 ob_end_clean(); 2354 2355 if ($file != null && $file != '') { 2356 echo '<script type="text/javascript"> parent.setdownloadfile("'.$file.'"); </script>'; 2357 } else { 2358 echo '<script type="text/javascript"> parent.unsetdownloadfile(); </script>'; 2359 } 2360 2361 ob_start(); 2362 echo $msg; 2363}; 2364 2365// }}} 2366// {{{ win32BrowseForFolder 2367 2368/* 2369 * Create a vbs script to browse the getfolder dialog, called 2370 * by cscript, if it's available. 2371 * $label is the label text in the header of the dialog box 2372 * 2373 * TODO: 2374 * - Do not show Control panel 2375 * - Replace WSH with calls to w32 as soon as callbacks work 2376 * @Author Pierrre-Alain Joye 2377 */ 2378function win32BrowseForFolder($label) 2379{ 2380 global $ptmp; 2381 static $wshSaved=false; 2382 static $cscript=''; 2383$wsh_browserfolder = 'Option Explicit 2384Dim ArgObj, var1, var2, sa, sFld 2385Set ArgObj = WScript.Arguments 2386Const BIF_EDITBOX = &H10 2387Const BIF_NEWDIALOGSTYLE = &H40 2388Const BIF_RETURNONLYFSDIRS = &H0001 2389Const BIF_DONTGOBELOWDOMAIN = &H0002 2390Const BIF_STATUSTEXT = &H0004 2391Const BIF_RETURNFSANCESTORS = &H0008 2392Const BIF_VALIDATE = &H0020 2393Const BIF_BROWSEFORCOMPUTER = &H1000 2394Const BIF_BROWSEFORPRINTER = &H2000 2395Const BIF_BROWSEINCLUDEFILES = &H4000 2396Const OFN_LONGNAMES = &H200000 2397Const OFN_NOLONGNAMES = &H40000 2398Const ssfDRIVES = &H11 2399Const ssfNETWORK = &H12 2400Set sa = CreateObject("Shell.Application") 2401var1=ArgObj(0) 2402Set sFld = sa.BrowseForFolder(0, var1, BIF_EDITBOX + BIF_VALIDATE + BIF_BROWSEINCLUDEFILES + BIF_RETURNFSANCESTORS+BIF_NEWDIALOGSTYLE , ssfDRIVES ) 2403if not sFld is nothing Then 2404 if not left(sFld.items.item.path,1)=":" Then 2405 WScript.Echo sFld.items.item.path 2406 Else 2407 WScript.Echo "invalid" 2408 End If 2409Else 2410 WScript.Echo "cancel" 2411End If 2412'; 2413 if( !$wshSaved){ 2414 $cscript = $ptmp.DIRECTORY_SEPARATOR."bf.vbs"; 2415 $fh = fopen($cscript,"wb+"); 2416 fwrite($fh,$wsh_browserfolder,strlen($wsh_browserfolder)); 2417 fclose($fh); 2418 $wshSaved = true; 2419 } 2420 exec('cscript '.$cscript.' "'.$label.'" //noLogo',$arPath); 2421 if($arPath[0]=='' || $arPath[0]=='cancel'){ 2422 return ''; 2423 } elseif ($arPath[0]=='invalid') { 2424 echo "Invalid Path.\n"; 2425 return ''; 2426 } 2427 return $arPath[0]; 2428} 2429 2430// }}} 2431// {{{ win32CreateRegEnv 2432 2433/* 2434 * Generates a registry addOn for Win32 platform 2435 * This addon set PEAR environment variables 2436 * @Author Pierrre-Alain Joye 2437 */ 2438function win32CreateRegEnv() 2439{ 2440 global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir, $temp_dir; 2441 $nl = "\r\n"; 2442 $reg ='REGEDIT4'.$nl. 2443 '[HKEY_CURRENT_USER\Environment]'.$nl. 2444 '"PHP_PEAR_SYSCONF_DIR"="'.addslashes($prefix).'"'.$nl. 2445 '"PHP_PEAR_INSTALL_DIR"="'.addslashes($php_dir).'"'.$nl. 2446 '"PHP_PEAR_DOC_DIR"="'.addslashes($doc_dir).'"'.$nl. 2447 '"PHP_PEAR_BIN_DIR"="'.addslashes($bin_dir).'"'.$nl. 2448 '"PHP_PEAR_DATA_DIR"="'.addslashes($data_dir).'"'.$nl. 2449 '"PHP_PEAR_PHP_BIN"="'.addslashes($php_bin).'"'.$nl. 2450 '"PHP_PEAR_TEST_DIR"="'.addslashes($test_dir).'"'.$nl; 2451 2452 $fh = fopen($prefix.DIRECTORY_SEPARATOR.'PEAR_ENV.reg','wb'); 2453 if($fh){ 2454 fwrite($fh, $reg ,strlen($reg)); 2455 fclose($fh); 2456 echo " 2457 2458* WINDOWS ENVIRONMENT VARIABLES * 2459For convenience, a REG file is available under $prefix\\PEAR_ENV.reg . 2460This file creates ENV variables for the current user. 2461 2462Double-click this file to add it to the current user registry. 2463 2464"; 2465 } 2466} 2467 2468// }}} 2469// {{{ win32DetectPHPSAPI 2470 2471/* 2472 * Try to detect the kind of SAPI used by the 2473 * the given php.exe. 2474 * @Author Pierrre-Alain Joye 2475 */ 2476function win32DetectPHPSAPI() 2477{ 2478 global $php_bin,$php_sapi_name; 2479 if (WEBINSTALLER) { 2480 return $php_sapi_name; 2481 } 2482 if($php_bin!=''){ 2483 exec($php_bin.' -v', $res); 2484 if(is_array($res)) { 2485 if( isset($res[0]) && strpos($res[0],"(cli)")) { 2486 return 'cli'; 2487 } 2488 if( isset($res[0]) && strpos($res[0],"cgi")) { 2489 return 'cgi'; 2490 } else { 2491 return 'unknown'; 2492 } 2493 } 2494 } 2495 return 'unknown'; 2496} 2497 2498// }}} 2499// {{{ getPhpiniPath 2500 2501/* 2502 * Get the php.ini file used with the current 2503 * process or with the given php.exe 2504 * 2505 * Horrible hack, but well ;) 2506 * 2507 * Not used yet, will add the support later 2508 * @Author Pierre-Alain Joye <paj@pearfr.org> 2509 */ 2510function getPhpiniPath() 2511{ 2512 $pathIni = get_cfg_var('cfg_file_path'); 2513 if( $pathIni && is_file($pathIni) ){ 2514 return $pathIni; 2515 } 2516 2517 // Oh well, we can keep this too :) 2518 // I dunno if get_cfg_var() is safe on every OS 2519 if (WINDOWS) { 2520 // on Windows, we can be pretty sure that there is a php.ini 2521 // file somewhere 2522 do { 2523 $php_ini = PHP_CONFIG_FILE_PATH . DIRECTORY_SEPARATOR . 'php.ini'; 2524 if ( @file_exists($php_ini) ) break; 2525 $php_ini = 'c:\winnt\php.ini'; 2526 if ( @file_exists($php_ini) ) break; 2527 $php_ini = 'c:\windows\php.ini'; 2528 } while (false); 2529 } else { 2530 $php_ini = PHP_CONFIG_FILE_PATH . DIRECTORY_SEPARATOR . 'php.ini'; 2531 } 2532 2533 if( @is_file($php_ini) ){ 2534 return $php_ini; 2535 } 2536 2537 // We re running in hackz&troubles :) 2538 ob_implicit_flush(false); 2539 ob_start(); 2540 phpinfo(INFO_GENERAL); 2541 $strInfo = ob_get_contents (); 2542 ob_end_clean(); 2543 ob_implicit_flush(true); 2544 2545 if ( php_sapi_name() != 'cli' ) { 2546 $strInfo = strip_tags($strInfo,'<td>'); 2547 $arrayInfo = explode("</td>", $strInfo ); 2548 $cli = false; 2549 } else { 2550 $arrayInfo = explode("\n",$strInfo); 2551 $cli = true; 2552 } 2553 2554 foreach($arrayInfo as $val){ 2555 if ( strpos($val,"php.ini") ) { 2556 if($cli){ 2557 list(,$pathIni) = explode('=>',$val); 2558 } else { 2559 $pathIni = strip_tags(trim($val) ); 2560 } 2561 $pathIni = trim($pathIni); 2562 if(is_file($pathIni)){ 2563 return $pathIni; 2564 } 2565 } 2566 } 2567 2568 return false; 2569} 2570 2571// }}} 2572// {{{ alterPhpIni 2573 2574/* 2575 * Not optimized, but seems to work, if some nice 2576 * peardev will test it? :) 2577 * 2578 * @Author Pierre-Alain Joye <paj@pearfr.org> 2579 */ 2580function alterPhpIni($pathIni='') 2581{ 2582 global $php_dir, $prefix; 2583 2584 $iniSep = WINDOWS?';':':'; 2585 2586 if( $pathIni=='' ){ 2587 $pathIni = getphpinipath(); 2588 } 2589 2590 $arrayIni = file($pathIni); 2591 $i=0; 2592 $found=0; 2593 2594 // Looks for each active include_path directives 2595 foreach ( $arrayIni as $iniLine ) { 2596 $iniLine = trim($iniLine); 2597 $iniLine = str_replace(array("\n","\r"),array(),$iniLine); 2598 if( preg_match("/^include_path/",$iniLine) ){ 2599 $foundAt[] = $i; 2600 $found++; 2601 } 2602 $i++; 2603 } 2604 2605 if ( $found ) { 2606 $includeLine = $arrayIni[$foundAt[0]]; 2607 list(,$currentPath)=explode('=',$includeLine); 2608 2609 $currentPath = trim($currentPath); 2610 if(substr($currentPath,0,1)=='"'){ 2611 $currentPath = substr($currentPath,1,strlen($currentPath)-2); 2612 } 2613 2614 $arrayPath = explode($iniSep, $currentPath); 2615 if( $arrayPath[0]=='.' ){ 2616 $newPath[0] = '.'; 2617 $newPath[1] = $php_dir; 2618 array_shift($arrayPath); 2619 } else { 2620 $newPath[0] = $php_dir; 2621 } 2622 2623 foreach( $arrayPath as $path ){ 2624 $newPath[]= $path; 2625 } 2626 } else { 2627 $newPath[0] = '.'; 2628 $newPath[1] = $php_dir; 2629 2630 } 2631 $nl = WINDOWS?"\r\n":"\n"; 2632 $includepath = 'include_path="'.implode($iniSep,$newPath).'"'; 2633 $newInclude = "$nl$nl;***** Added by go-pear$nl". 2634 $includepath. 2635 $nl.";*****". 2636 $nl.$nl; 2637 2638 $arrayIni[$foundAt[0]] = $newInclude; 2639 2640 for( $i=1; $i<$found; $i++){ 2641 $arrayIni[$foundAt[$i]]=';'.trim($arrayIni[$foundAt[$i]]); 2642 } 2643 2644 $newIni = implode("",$arrayIni); 2645 if ( !($fh = @fopen($pathIni, "wb+")) ){ 2646 $prefixIni = $prefix.DIRECTORY_SEPARATOR."php.ini-gopear"; 2647 $fh = fopen($prefixIni, "wb+"); 2648 if ( !$fh ) { 2649 echo 2650" 2651****************************************************************************** 2652WARNING! I cannot write to $pathIni nor in $prefix/php.ini-gopear. Please 2653modify manually your php.ini by adding: 2654 2655$includepath 2656 2657"; 2658 return false; 2659 } else { 2660 fwrite($fh, $newIni, strlen($newIni)); 2661 fclose($fh); 2662 echo 2663" 2664****************************************************************************** 2665WARNING! I cannot write to $pathIni, but I succesfully created a php.ini 2666under <$prefix/php.ini-gopear>. Please replace the file <$pathIni> with 2667<$prefixIni> or modify your php.ini by adding: 2668 2669$includepath 2670 2671"; 2672 2673 } 2674 } else { 2675 fwrite($fh, $newIni, strlen($newIni)); 2676 fclose($fh); 2677 echo " 2678php.ini <$pathIni> include_path updated. 2679"; 2680 } 2681 return true; 2682} 2683 2684?> 2685