📄 go-pear.php
字号:
$_ENV = array(); }; $_ENV['TMPDIR'] = $_ENV['TEMP'] = $prefix.'/tmp';}while (!WEBINSTALLER) { print "Below is a suggested file layout for your new PEAR installation. Tochange individual locations, type the number in front of thedirectory. Type 'all' to change all of them or simply press Enter toaccept these locations."; if( WINDOWS && $php_bin=='' ){ } foreach ($config_vars as $n => $var) { printf("%2d. $descfmt : %s\n", $n, $config_desc[$var], $$var); } print "\n$first-$last, 'all' or Enter to continue: "; $tmp = trim(fgets($tty, 1024)); if ( empty($tmp) ) { if( WINDOWS && !$php_bin_set ){ echo "**ERROR**Please, enter the php.exe path."; } else { break; } } if (isset($config_vars[(int)$tmp])) { $var = $config_vars[(int)$tmp]; $desc = $config_desc[$var]; $current = $$var; if(WIN32GUI){ $tmp = win32BrowseForFolder("$desc [$current] :"); } else { print "$desc [$current] : "; $tmp = trim(fgets($tty, 1024)); } $old = $$var; if(WINDOWS && $var=='php_bin' ){ if(file_exists($tmp.DIRECTORY_SEPARATOR.'php.exe')){ $tmp = $tmp.DIRECTORY_SEPARATOR.'php.exe'; $php_bin_sapi = win32DetectPHPSAPI(); if($php_bin_sapi=='cgi'){ print "******************************************************************************NOTICE! We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI.PEAR commandline tool works well with it.If you have a CLI php.exe available, we recommand to use it."; } elseif ($php_bin_sapi=='unknown') { print "******************************************************************************WARNING! We found php.exe under $php_bin, it uses an $php_bin_sapi SAPI.PEAR commandline tool has not been tested with it.If you have a CLI (or CGI) php.exe available, we strongly recommand to use it."; } echo "php.exe (sapi: $php_bin_sapi) found.\n\n"; $php_bin_set = true; } else { echo "**ERROR**: no php.exe found in this folder.\n"; $tmp=''; } } if (!empty($tmp) ) { $$var = $tmp; } } elseif ($tmp == 'all') { foreach ($config_vars as $n => $var) { $desc = $config_desc[$var]; $current = $$var; print "$desc [$current] : "; $tmp = trim(fgets($tty, 1024)); if (!empty($tmp)) { $$var = $tmp; } } }}foreach ($config_vars as $n => $var) { foreach ($config_vars as $m => $var2) { $$var = str_replace('$'.$var2, $$var2, $$var); }}foreach ($config_vars as $var) { $dir = $$var; if (!preg_match('/_dir$/', $var)) { continue; }; if (!@is_dir($dir)) { if (!mkdir_p($dir)) { $root = WINDOWS ? 'administrator' : 'root'; bail("Unable to create {$config_desc[$var]} $dir.Run this script as $root or pick another location.\n"); } }}if (!WEBINSTALLER) { $msg = "The following PEAR packages are bundled with PHP: " . implode(', ', $pfc_packages); print "\n" . wordwrap($msg, 75) . ".\n"; print "Would you like to install these as well? [Y/n] : "; $install_pfc = !stristr(fgets($tty, 1024), "n"); print "\n";}##### Download####ini_set("include_path", $ptmp);if (!extension_loaded('zlib') && !WEBINSTALLER) { // In Web context we could be in multithread env which makes dl() end up with a fatal error. if (WINDOWS) { @dl('php_zlib.dll'); } elseif (PHP_OS == 'HP-UX') { @dl('zlib.sl'); } elseif (PHP_OS == 'AIX') { @dl('zlib.a'); } else { @dl('zlib.so'); }}if (!extension_loaded('zlib')) { $urltemplate = 'http://pear.php.net/get/%s?uncompress=yes'; $have_gzip = false;} else { $urltemplate = 'http://pear.php.net/get/%s'; $have_gzip = true;}print "Loading zlib: ".($have_gzip ? 'ok' : 'failed')."\n";if (!$have_gzip) { print "Downloading uncompressed packages\n";};if ($install_pfc) { $to_install = array_merge($installer_packages, $pfc_packages);} else { $to_install = $installer_packages;}displayHTMLProgress($progress = 5);if (file_exists(dirname(__FILE__).'/go-pear-bundle') || is_dir(dirname(__FILE__).'/go-pear-bundle')) { $dh = @opendir(dirname(__FILE__).'/go-pear-bundle');}$local_dir = array();if ($dh) { while($file = @readdir($dh)) { if ($file == '.' || $file == '..' || !is_file(dirname(__FILE__).'/go-pear-bundle/'.$file)) { continue; }; $local_dir[] = $file; };}foreach ($installer_packages as $pkg) { foreach($local_dir as $file) { if (substr($file, 0, strlen($pkg)) == $pkg) { echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.'); copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file); $tarball[$pkg] = $file; echo "ok\n"; displayHTMLProgress($progress += round(65 / count($to_install))); continue 2; }; }; $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.'); print $msg; $url = sprintf($urltemplate, $pkg); $tarball[$pkg] = download_url($url, null, $http_proxy); print "ok\n"; displayHTMLProgress($progress += round(65 / count($to_install)));}print 'Bootstrapping: PEAR...................';$r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['PEAR'], 5), 0, -4));$url = "http://cvs.php.net/co.php/php-src/pear/PEAR.php?p=1&r=$r";if (in_array('Getopt.php', $local_dir)) { copy(dirname(__FILE__).'/go-pear-bundle/PEAR.php', 'PEAR.php'); echo "(local) ";} else { download_url($url, 'PEAR.php', $http_proxy); echo "(remote) ";}include_once 'PEAR.php';print "ok\n";print 'Bootstrapping: Archive_Tar............';$r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Archive_Tar'], 12), 0, -4));$url = "http://cvs.php.net/co.php/pear/Archive_Tar/Archive/Tar.php?p=1&r=$r";mkdir('Archive', 0700);if (in_array('Getopt.php', $local_dir)) { copy(dirname(__FILE__).'/go-pear-bundle/Tar.php', 'Archive/Tar.php'); echo "(local) ";} else { download_url($url, 'Archive/Tar.php', $http_proxy); echo "(remote) ";}print "ok\n";print 'Bootstrapping: Console_Getopt.........';$r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Console_Getopt'], 15), 0, -4));$url = "http://cvs.php.net/co.php/php-src/pear/Console/Getopt.php?p=1&r=$r";mkdir('Console', 0700);if (in_array('Getopt.php', $local_dir)) { copy(dirname(__FILE__).'/go-pear-bundle/Getopt.php', 'Console/Getopt.php'); echo "(local) ";} else { download_url($url, 'Console/Getopt.php', $http_proxy); echo "(remote) ";}print "ok\n";if ($install_pfc) { foreach ($pfc_packages as $pkg) { foreach($local_dir as $file) { if (substr($file, 0, strlen($pkg)) == $pkg) { echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.'); copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file); $tarball[$pkg] = $file; echo "ok\n"; displayHTMLProgress($progress += round(65 / count($to_install))); continue 2; }; }; $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.'); print $msg; $url = sprintf($urltemplate, $pkg); $tarball[$pkg] = download_url($url, null, $http_proxy); print "ok\n"; displayHTMLProgress($progress += round(65 / count($to_install))); }}displayHTMLProgress($progress = 70);PEAR::setErrorHandling(PEAR_ERROR_DIE, "\n%s\n");print 'Extracting installer..................';$dot = strrpos($tarball['PEAR'], '.');$pkg = substr($tarball['PEAR'], 0, $dot);$ext = substr($tarball['PEAR'], $dot+1);include_once 'Archive/Tar.php';$tar = &new Archive_Tar($tarball['PEAR'], $have_gzip);if (!$tar->extractModify($ptmp, $pkg)) { bail("failed!\n");}print "ok\n";$tarball['PEAR'] = 'package.xml'; // :-)include_once "PEAR.php";include_once "PEAR/Config.php";include_once "PEAR/Command.php";include_once "PEAR/Registry.php";if (WEBINSTALLER) { $config = &PEAR_Config::singleton($prefix."/pear.conf", '');} else { $config = &PEAR_Config::singleton();};$config->set('preferred_state', 'stable');foreach ($config_vars as $var) { $config->set($var, $$var);}$config->store();$registry = new PEAR_Registry($php_dir);PEAR_Command::setFrontendType('CLI');$install = &PEAR_Command::factory('install', $config);$install_options = array( 'nodeps' => true, 'force' => true, );foreach ($tarball as $pkg => $src) { $options = $install_options; if ($registry->packageExists($pkg)) { $options['upgrade'] = true; } $install->run('install', $options, array($src)); displayHTMLProgress($progress += round(29 / count($tarball)));}displayHTMLProgress($progress = 99);// Base installation finishedini_restore("include_path");if (!WEBINSTALLER) { $sep = WINDOWS ? ';' : ':'; $include_path = explode($sep, ini_get('include_path')); if (WINDOWS) { $found = false; $t = strtolower($php_dir); foreach($include_path as $path) { if ($t==strtolower($path)) { $found = true; break; } } } else { $found = in_array($php_dir, $include_path); } if (!$found) { print "******************************************************************************WARNING! The include_path defined in the currently used php.ini does notcontain the PEAR PHP directory you just specified:<$php_dir>If the specified directory is also not in the include_path used byyour scripts, you will have problems getting any PEAR packages working."; if ( $php_ini = getPhpiniPath() ) { print "\n\nWould you like to alter php.ini <$php_ini>? [Y/n] : "; $alter_phpini = !stristr(fgets($tty, 1024), "n"); if( $alter_phpini ) { alterPhpIni($php_ini); } else { if (WINDOWS) { print "Please look over your php.ini file to make sure$php_dir is in your include_path."; } else { print "I will add a workaround for this in the 'pear' command to make surethe installer works, but please look over your php.ini or Apacheconfiguration to make sure $php_dir is in your include_path."; } } } print "Current include path : ".ini_get('include_path')."Configured directory : $php_dirCurrently used php.ini (guess) : $php_ini"; print "Press Enter to continue: "; fgets($tty, 1024); } $pear_cmd = $bin_dir . DIRECTORY_SEPARATOR . 'pear'; $pear_cmd .= WINDOWS?'.bat':''; // check that the installed pear and the one in tha path are the same (if any) $pear_old = which('pear', $bin_dir); if ($pear_old && $pear_old != $pear_cmd) { // check if it is a link or symlink $islink = WINDOWS ? is_link($pear_old) : false; if ($islink && readlink($pear_old) != $pear_cmd) { print "\n** WARNING! The link $pear_old does not point to the " . "installed $pear_cmd\n"; } elseif (is_writable($pear_old)) { rename($pear_old, "{$pear_old}_old"); print "\n** WARNING! Backed up old pear to {$pear_old}_old\n"; } else { print "\n** WARNING! Old version found at $pear_old, please remove it or ". "be sure to use the new $pear_cmd command\n"; } } print "\nThe 'pear' command is now at your service at $pear_cmd\n"; // Alert the user if the pear cmd is not in PATH $old_dir = $pear_old ? dirname($pear_old) : false; if (!which('pear', $old_dir)) { print "** The 'pear' command is not currently in your PATH, so you need to** use '$pear_cmd' until you have added** '$bin_dir' to your PATH environment variable."; print "Run it without parameters to see the available actions, try 'pear list'to see what packages are installed, or 'pear help' for help.For more information about PEAR, see: http://pear.php.net/faq.php http://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1 http://pear.php.net/manual/Thanks for using go-pear!"; }}if (WEBINSTALLER) { print "Writing WebFrontend file ... "; @unlink($webfrontend_file); //Delete old one copy ( $doc_dir.DIRECTORY_SEPARATOR. 'PEAR_Frontend_Web'.DIRECTORY_SEPARATOR. 'docs'.DIRECTORY_SEPARATOR. 'example.php', $webfrontend_file ); if ($_GET['step'] == 'install-progress') { displayHTMLProgress($progress = 100); ob_end_clean(); displayHTMLInstallationSummary(); displayHTMLFooter(); } else { $out = ob_get_contents(); $out = explode("\n", $out); foreach($out as $line => $value) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -