⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 go-pear.php

📁 php5.0原代码
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php //; echo; echo "YOU NEED TO RUN THIS SCRIPT WITH PHP NOW!"; echo; echo "Try this: lynx -source http://pear.php.net/go-pear | php -q"; echo; exit # -*- PHP -*-# +----------------------------------------------------------------------+# | PHP Version 4                                                        |# +----------------------------------------------------------------------+# | Copyright (c) 1997-2002 The PHP Group                                |# +----------------------------------------------------------------------+# | This source file is subject to version 2.02 of the PHP license,      |# | that is bundled with this package in the file LICENSE, and is        |# | available at through the world-wide-web at                           |# | http://www.php.net/license/2_02.txt.                                 |# | If you did not receive a copy of the PHP license and are unable to   |# | obtain it through the world-wide-web, please send a note to          |# | license@php.net so we can mail you a copy immediately.               |# +----------------------------------------------------------------------+# | Authors: Tomas V.V.Cox <cox@idecnet.com>                             |# |          Stig S鎡her Bakken <stig@php.net>                           |# |			 Christian Dickmann <dickmann@php.net>						 |# |			 Pierre-Alain Joye <pajoye@pearfr.org>						 |# +----------------------------------------------------------------------+# $Id: go-pear,v 1.57 2004/02/15 00:49:10 pajoye Exp $## Automatically download all the files needed to run the "pear" command# (the PEAR package installer).  Requires PHP 4.1.0 or newer.## Installation: Linux## This script can either be directly launched or passed via lynx like this.##  $ lynx -source http://pear.php.net/go-pear | php## The above assumes your php binary is named php and that it's# executable through your PATH:## Installation: Windows## On Windows, go-pear uses stdin for user input, so you must download# go-pear first and then run it:## Note: In PHP 4.2.0-4.2.3, the PHP CLI binary is named php-cli.exe while since# PHP 4.3.0, it's simply named php.exe in the cli/ folder of your PHP directory.# The CGI is also named php.exe but it sits directly in your PHP directory.##  > cli/php -r "readfile('http://pear.php.net/go-pear');" > go-pear#  > cli/php go-pear## Installation: Notes## - If using the CGI version of PHP, append the -q option to suppress#   headers in the output.# - Once the go-pear script is initiated, you will see instructions on#   how to continue installing PEAR.  The first thing you should see is:##   Welcome to go-pear!## Installation: Web browser## You can now use go-pear via a webbrowser, thanks to Christian Dickmann. It is# still beta codes, but feel free to test it:# 1.: Download the go-pear script by using the "Save target as ..." function# of your browser here.## 2.: Place the go-pear file somewhere under the document root of your webserver.# The easiest way is to create a new directory for pear and to put the file in there.# Be sure your web server is setup to recognize PHP, and that you use an appropriate# extension.  For example, you might name this file gopear.php## 3.: Access go-pear through your webserver and follow the instructions. Please# make sure that PHP has write access to the dir you want to install PEAR into.# For example: http://localhost/pear/gopear.php## 4.: After running go-pear you get a link to the Web Frontend of the PEAR installer.# I suggest bookmarking this link.## 5.: Protect the Web Frontend directory and the go-pear script with a password.# Use .htaccess on Apache webservers for example.##$sapi_name = php_sapi_name();set_time_limit(0);@ob_end_clean();ob_implicit_flush(true);define('WEBINSTALLER', (php_sapi_name() != 'cli' && !( substr(php_sapi_name(),0,3)=='cgi' && !isset($_SERVER['GATEWAY_INTERFACE']))));ini_set('track_errors', true);ini_set('html_errors', WEBINSTALLER);ini_set('magic_quotes_runtime', false);error_reporting( E_ALL & ~E_NOTICE);define('WINDOWS', (substr(PHP_OS, 0, 3) == 'WIN'));define('GO_PEAR_VER', '0.2.2');define('WIN32GUI', !WEBINSTALLER && WINDOWS && php_sapi_name()== 'cli' && which('cscript'));/** * See bug #23069 */if ( WEBINSTALLER && WINDOWS ) {    $php_sapi_name = win32DetectPHPSAPI();    if($php_sapi_name=='cgi'){    $msg = nl2br("Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for theinstructions) or use the CLI (cli\php.exe) in the console.");        displayHTML('error', $msg);    }}if (WEBINSTALLER && isset($_GET['action']) && $_GET['action'] == 'img' && isset($_GET['img'])) {	switch ($_GET['img'])	{		case 'note':		case 'pearlogo':		case 'smallpear':			showImage($_GET['img']);			exit;		default:			exit;	};}// Check if PHP version is sufficientif (function_exists("version_compare") && version_compare(phpversion(), "4.2.0",'<')) {    die("Sorry!  Your PHP version is too old.  PEAR and this script requires atleast PHP 4.2.0 for stable operation.It may be that you have a newer version of PHP installed in your webserver, but an older version installed as the 'php' command.  In thiscase, you need to rebuilt PHP from source.If your source is 4.2.x, you need to run 'configure' with the--enable-cli option, rebuild and copy sapi/cli/php somewhere.If your source is 4.3.x or newer, just make sure you don't run'configure' with --disable-cli, rebuilt and copy sapi/cli/php.Please upgrade PHP to a newer version, and try again.  See you then.");}$installer_packages = array(    'PEAR',    'Archive_Tar',    'Console_Getopt',    'XML_RPC'    );if (WEBINSTALLER) {	$installer_packages[] = 'Pager';	$installer_packages[] = 'HTML_Template_IT';	$installer_packages[] = 'Net_UserAgent_Detect';	$installer_packages[] = 'PEAR_Frontend_Web';}$version_n = explode(".",phpversion());if ($version_n[0]=="4") {    $pfc_packages = array(        'DB',        'Net_Socket',        'Net_SMTP',        'Mail',        'XML_Parser',        'PHPUnit-0.6.2'        );} else {    $pfc_packages = array(        'DB',        'Net_Socket',        'Net_SMTP',        'Mail',        'XML_Parser',        'PHPUnit'        );}$config_desc = array(    'prefix' => 'Installation prefix',    'bin_dir' => 'Binaries directory',    'php_dir' => 'PHP code directory ($php_dir)',    'doc_dir' => 'Documentation base directory',    'data_dir' => 'Data base directory',    'test_dir' => 'Tests base directory',);if(!WEBINSTALLER && WINDOWS){    $config_desc['php_bin'] = 'php.exe path';}if (WEBINSTALLER) {	$config_desc['cache_dir'] = 'PEAR Installer cache directory';	$config_desc['cache_ttl'] = 'Cache TimeToLive';	$config_desc['webfrontend_file'] = 'Filename of WebFrontend';    $config_desc['php_bin'] = "php.exe path, optional (CLI command tools)";}if (my_env('HTTP_PROXY')) {	$http_proxy = my_env('HTTP_PROXY');} elseif (my_env('http_proxy')) {	$http_proxy = my_env('http_proxy');} else {	$http_proxy = '';}register_shutdown_function('bail');detect_install_dirs();if (WEBINSTALLER) {	@session_start();    /*        See bug #23069    */    if ( WINDOWS ) {        $php_sapi_name = win32DetectPHPSAPI();        if($php_sapi_name=='cgi'){            $msg = "    Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.    Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for the    instructions) or use the CLI (cli\php.exe) in the console.    ";            displayHTML('error', $msg);            exit();        }    }	if (!isset($_SESSION['go-pear']) || isset($_GET['restart'])) {		$sep = WINDOWS ? "\\" : '/';		$_SESSION['go-pear'] = array(			'http_proxy' => $http_proxy,			'config' => array(				'prefix' => dirname(__FILE__),				'bin_dir' => $bin_dir,                'php_bin' => $php_bin,				'php_dir' => '$prefix'.$sep.'PEAR',				'doc_dir' => $doc_dir,				'data_dir' => $data_dir,				'test_dir' => $test_dir,				'cache_dir' => '$php_dir'.$sep.'cache',				'cache_ttl' => 300,				'webfrontend_file' => '$prefix'.$sep.'index.php',				),			'install_pfc' => true,            'DHTML' => true,			);	}	if (!isset($_GET['step'])) {		$_GET['step'] = 'Welcome';        /* clean up old sessions datas */        session_destroy();	}	if ($_GET['step'] == 'install') {		$_SESSION['go-pear']['http_proxy'] = strip_magic_quotes($_POST['proxy']['host']).':'.strip_magic_quotes($_POST['proxy']['port']);		if ($_SESSION['go-pear']['http_proxy'] == ':') {			$_SESSION['go-pear']['http_proxy'] = '';		};        $www_errors = array();		foreach($_POST['config'] as $key => $value) {			$_POST['config'][$key] = strip_magic_quotes($value);            if($key!='cache_ttl'){                if( ereg(' ', $_POST['config'][$key]) ) {                    $www_errors[$key] = 'Spaces are not allowed in pathes. Please choose another path.';                } elseif ( empty($_POST['config'][$key]) ) {                    $www_errors[$key] = 'Please fill this path, you can use $prefix, $php_dir or a full path.';                }            }        }        if( sizeof($www_errors)>0){            $_GET['step'] = 'config';        }		$_SESSION['go-pear']['config'] = $_POST['config'];		$_SESSION['go-pear']['install_pfc'] = (isset($_POST['install_pfc']) && $_POST['install_pfc'] == 'on');        $_SESSION['go-pear']['DHTML'] = !($_POST['BCmode'] == "on");	}	$http_proxy = $_SESSION['go-pear']['http_proxy'];	foreach($_SESSION['go-pear']['config'] as $var => $value) {		$$var = $value;	}	$install_pfc = $_SESSION['go-pear']['install_pfc'];}if (!WEBINSTALLER) {	$tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r');	if (!$tty) {	    $tty = fopen('php://stdin', 'r');	}	print "Welcome to go-pear!Go-pear will install the 'pear' command and all the files needed byit.  This command is your tool for PEAR installation and maintenance.Go-pear also lets you download and install the PEAR packages bundledwith PHP: " . implode(', ', $pfc_packages) . ".If you wish to abort, press Control-C now, or press Enter to continue: ";	fgets($tty, 1024);	print "\n";        print "HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:";	if (!empty($http_proxy)) {	    print " [$http_proxy]";	}	print ": ";	$tmp = trim(fgets($tty, 1024));	if (!empty($tmp)) {	    $http_proxy = $tmp;	}}$origpwd = getcwd();$config_vars = array_keys($config_desc);// make indices run from 1...array_unshift($config_vars, "");unset($config_vars[0]);reset($config_vars);$desclen = max(array_map('strlen', $config_desc));$descfmt = "%-{$desclen}s";$first = key($config_vars);end($config_vars);$last = key($config_vars);if (WEBINSTALLER) {    if ( isset($www_errors) && sizeof($www_errors) ) {        displayHTML('config');        exit();    } else {        if (isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'] == true && $_GET['step'] == 'install') {            $_GET['step'] = 'preinstall';        }        if ($_GET['step'] != 'install' && $_GET['step'] != 'install-progress') {            displayHTML($_GET['step']);            exit;        }        if ($_GET['step'] == 'install-progress') {            displayHTMLHeader();            echo "Starting installation ...<br/>";        }        ob_start();    }}$progress = 0;/* * Checks PHP SAPI version under windows/CLI */if( WINDOWS && !WEBINSTALLER && $php_bin=='') {    print "We do not find any php.exe, please select the php.exe folder (CLI isrecommanded, usually in c:\php\cli\php.exe)";    $php_bin_set = false;} elseif ( WINDOWS && !WEBINSTALLER && strlen($php_bin) ) {    $php_bin_sapi = win32DetectPHPSAPI();    $php_bin_set = true;    switch($php_bin_sapi){        case 'cli':        break;        case 'cgi':            print "*NOTICE*We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI. PEAR commandlinetool works well with it, if you have a CLI php.exe available, werecommand to use it.";        break;        default:            print "*WARNING*We found php.exe under $php_bin, it uses an unknown SAPI. PEAR commandlinetool has not been tested with it, if you have a CLI (or CGI) php.exe available,we strongly recommand to use it.";        break;    }}##### Temp stuff####$foo = tmp_dir();$ptmp = tempnam($foo, 'gope');if (WINDOWS) {    $ptmp = str_replace($foo,'',$ptmp);    $foo=str_replace("\\\\",'/',$foo);    $s = substr($ptmp,0,1);    if($s=="\\" || $s=='/' ){        $ptmp = $foo.'/'.substr($ptmp,1);    } else {        $ptmp = $foo.'/'.$ptmp;    }}rm_rf($ptmp);mkdir_p($ptmp, 0700);$ok = @chdir($ptmp);// If for some reason the user has no rights to access to// the standard tempdir, we assume that he has the right// to access his prefix and choose $prefix/tmp as tempdirif (!$ok) {	print "System's Tempdir failed, trying to use \$prefix/tmp ...";	$res = mkdir_p($prefix.'/tmp');	if (!$res) {		bail('mkdir '.$prefix.'/tmp'.' ... failed');	}	$ptmp = tempnam($prefix.'/tmp', 'gope');	rm_rf($ptmp);	mkdir_p($ptmp, 0700);	$ok = @chdir($ptmp);	if (!$ok) { // This should not happen, really ;)		bail('chdir '.$ptmp.' ... failed');	}	print "ok\n";	// Adjust TEMPDIR envvars	if (!isset($_ENV)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -