Re[2]: [PEAR-DEV] Re: go-pear. Was:Re[2]: [PEAR-DEV] XML_RPC

From: Date: Thu, 09 Dec 2004 12:29:00 +0000
Subject: Re[2]: [PEAR-DEV] Re: go-pear. Was:Re[2]: [PEAR-DEV] XML_RPC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-34952@lists.php.net to get a copy of this message
Hello Pierre-Alain, From Thursday, December 9, 2004, 2:12:21 PM, you wrote: >> Even if you place an '@'... (which I have missed in my patch), PAJ> btw, where is your patch? can you please attach it again using a PAJ> .txt extension only? Well, I see that none of my patches got here. =/ Now I can send you only cummulative. To see what had been changed follow this thread. Is it possible to add .patch into the list of allowed extensions? >> think about the error message the user will get (I'm using PHP >> 4.3.9) >> >> <?php >> $host = 'zzzz'; >> $fp = @fsockopen($host, 80, $errno, $errstr); >> if (!$fp) { >> print("\nconnect to '$host' failed: $errstr ($errno)\n"); >> } >> ?> >> >> >connect to 'zzzz' failed: The operation completed successfully. >> >(0) >> Rather confusing if you ask me. PAJ> Makes me think about MS style messages :-). PAJ> Failed to see where it comes from (the completed part). Did you get that message? >> >connect to 'zzzz' failed: The operation completed successfully. If it so then disable @ and read PHP warning to see where does it come from. That's gethostbyaddr() that failed and not fsockopen() fsockopen() returns "i'm ok" t --

--- go-pear_old.php 2004-09-21 14:08:44.000000000 +0200 +++ go-pear.php 2004-12-07 18:39:52.000000000 +0200 @@ -20,7 +20,7 @@ # $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. +# (the PEAR package installer). Requires PHP 4.2.0 or newer. # # Installation: Linux # @@ -86,7 +86,8 @@ 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('PHP5', (substr(phpversion(), 0, 1) == '5')); +define('GO_PEAR_VER', '0.2.3'); define('WIN32GUI', !WEBINSTALLER && WINDOWS && php_sapi_name()== 'cli' && which('cscript')); @@ -151,8 +152,8 @@ $installer_packages[] = 'Net_UserAgent_Detect'; $installer_packages[] = 'PEAR_Frontend_Web'; } -$version_n = explode(".",phpversion()); -if ($version_n[0]=="4") { + +if (!PHP5) { $pfc_packages = array( 'DB', 'Net_Socket', @@ -174,7 +175,7 @@ $config_desc = array( 'prefix' => 'Installation prefix', 'bin_dir' => 'Binaries directory', - 'php_dir' => 'PHP code directory ($php_dir)', + 'pear_dir' => 'PEAR code directory ($pear_dir)', 'doc_dir' => 'Documentation base directory', 'data_dir' => 'Data base directory', 'test_dir' => 'Tests base directory', @@ -220,26 +221,27 @@ } } - 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, + 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, + 'pear_dir' => '$prefix'.$sep.'PEAR', + 'doc_dir' => $doc_dir, + 'data_dir' => $data_dir, + 'test_dir' => $test_dir, + 'cache_dir' => '$pear_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 */ @@ -258,7 +260,7 @@ 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.'; + $www_errors[$key] = 'Please fill this path, you can use $prefix, $pear_dir or a full path.'; } } } @@ -535,12 +537,15 @@ } 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"; + $msg = (!PHP5) + ? "The following PEAR packages are bundled with PHP: " + . implode(', ', $pfc_packages) + : "The following PEAR packages are common ones, and can be installed from PEAR website by go-pear too : " + . 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"; } #### @@ -710,7 +715,7 @@ $config->store(); -$registry = new PEAR_Registry($php_dir); +$registry = new PEAR_Registry($pear_dir); PEAR_Command::setFrontendType('CLI'); $install = &PEAR_Command::factory('install', $config); $install_options = array( @@ -739,7 +744,7 @@ $include_path = explode($sep, ini_get('include_path')); if (WINDOWS) { $found = false; - $t = strtolower($php_dir); + $t = strtolower($pear_dir); foreach($include_path as $path) { if ($t==strtolower($path)) { $found = true; @@ -747,14 +752,14 @@ } } } else { - $found = in_array($php_dir, $include_path); + $found = in_array($pear_dir, $include_path); } if (!$found) { print " ****************************************************************************** WARNING! The include_path defined in the currently used php.ini does not contain the PEAR PHP directory you just specified: -<$php_dir> +<$pear_dir> If the specified directory is also not in the include_path used by your scripts, you will have problems getting any PEAR packages working. "; @@ -768,12 +773,12 @@ if (WINDOWS) { print " Please look over your php.ini file to make sure -$php_dir is in your include_path."; +$pear_dir is in your include_path."; } else { print " I will add a workaround for this in the 'pear' command to make sure the installer works, but please look over your php.ini or Apache -configuration to make sure $php_dir is in your include_path. +configuration to make sure $pear_dir is in your include_path. "; } @@ -782,7 +787,7 @@ print " Current include path : ".ini_get('include_path')." -Configured directory : $php_dir +Configured directory : $pear_dir Currently used php.ini (guess) : $php_ini "; @@ -880,7 +885,7 @@ exit; } -// Little hack, this will be fixed in PEAR later +// Little hack, this will be fixed in PEAR later FIXME! if ( WINDOWS ) { clearstatcache(); @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear'); @@ -889,6 +894,13 @@ if (WINDOWS && !WEBINSTALLER) { win32CreateRegEnv(); } + + + + + + +//[***************************************************************************] // Set of functions following // {{{ download_url() @@ -903,18 +915,22 @@ if (empty($tmp['port'])) { $tmp['port'] = 80; } - if (empty($proxy)) { - $fp = fsockopen($tmp['host'], $tmp['port'], $errno, $errstr); - //print "\nconnecting to $tmp[host]:$tmp[port]\n"; - } else { - $tmp_proxy = parse_url($proxy); - $phost = $tmp_proxy['host']; - $pport = $tmp_proxy['port']; - $fp = fsockopen($phost, $pport, $errno, $errstr); - //print "\nconnecting to $phost:$pport\n"; + + $tmp_proxy = (empty($proxy))?parse_url($proxy):null; + $host = (empty($proxy))?$tmp['host']:$tmp_proxy['host']; + $port = (empty($proxy))?$tmp['port']:$tmp_proxy['port'];; + + //print "\nconnecting to $host:$port\n"; + if (strspn($host, '.0123456789') != strlen($host)) { + $tmp_host = gethostbyname($host); + if (strcmp($tmp_host, $host) == 0) { + bail("\nunable to lookup hostname '$host'\n"); + } } + $fp = fsockopen($host, $port, $errno, $errstr); + if (!$fp) { - bail("download of $url failed: $errstr ($errno)\n"); + bail("\ndownload of $url failed: $errstr ($errno)\n"); } if (empty($proxy)) { $path = $tmp['path']; @@ -949,7 +965,7 @@ $content_length = trim($matches[1]); }; if ($use_suggested_filename && !strncasecmp($line, $cdh, $cdhl)) { - if (eregi('filename="([^"]+)"', $line, $matches)) { + if (eregi("filename=\"([^\"]+)", $line, $matches)) { $destfile = basename($matches[1]); } } @@ -1151,7 +1167,7 @@ // {{{ detect_install_dirs() function detect_install_dirs($_prefix = null) { - global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir; + global $prefix, $bin_dir, $pear_dir, $php_bin, $doc_dir, $data_dir, $test_dir; if (WINDOWS) { if ($_prefix === null) { $prefix = getcwd(); @@ -1168,28 +1184,35 @@ } $bin_dir = '$prefix'; - $php_dir = '$prefix\pear'; - $doc_dir = '$php_dir\docs'; - $data_dir = '$php_dir\data'; - $test_dir = '$php_dir\tests'; + $pear_dir = '$prefix\pear'; + $doc_dir = '$pear_dir\docs'; + $data_dir = '$pear_dir\data'; + $test_dir = '$pear_dir\tests'; /* * Detects php.exe + * TODO: an ability to detect current php.exe path */ - if( $t=getenv('PHP_PEAR_PHP_BIN') ){ - $php_bin = $t; - } elseif ($t=getenv('PHP_BIN') ) { - $php_bin = $t; - } elseif ( $t=which('php') ) { - $php_bin = $t; - } elseif ( is_file($prefix.'\cli\php.exe') ) { + if (is_file($prefix.'\cli\php.exe')) { $php_bin = $prefix.'\cli\php.exe'; - } elseif ( is_file($prefix.'\php.exe') ) { + } elseif (is_file($prefix.'\php.exe')) { $php_bin = $prefix.'\php.exe'; - } - if( $php_bin && !is_file($php_bin) ){ - $php_bin = ''; + } elseif (is_file($prefix.'\php-cli.exe')) { + $php_bin = $prefix.'\php-cli.exe'; + } elseif (is_file($t=getenv('PHP_PEAR_PHP_BIN'))){ + $php_bin = $t; + } elseif (is_file($t=getenv('PHP_BIN'))) { + $php_bin = $t; + } elseif (is_file($t=which('php'))) { + $php_bin = $t; } else { - if(!ereg(":",$php_bin)){ + $php_bin = ''; + } + + if (is_file($php_bin)) { + // superfluous - will never be executed or will never be right + // if all of above returning full paths fail | + // note, that $prefix is always autodetected here + if (!ereg(":",$php_bin)) { $php_bin = getcwd().DIRECTORY_SEPARATOR.$php_bin; } } @@ -1207,20 +1230,20 @@ $prefix = $_prefix; } $bin_dir = '$prefix/bin'; - $php_dir = '$prefix/share/pear'; - $doc_dir = '$php_dir/docs'; - $data_dir = '$php_dir/data'; - $test_dir = '$php_dir/tests'; + $pear_dir = '$prefix/share/pear'; + $doc_dir = '$pear_dir/docs'; + $data_dir = '$pear_dir/data'; + $test_dir = '$pear_dir/tests'; // check if the user has installed PHP with PHP or GNU layout if (@is_dir("$prefix/lib/php/.registry")) { - $php_dir = '$prefix/lib/php'; + $pear_dir = '$prefix/lib/php'; } elseif (@is_dir("$prefix/share/pear/lib/.registry")) { - $php_dir = '$prefix/share/pear/lib'; + $pear_dir = '$prefix/share/pear/lib'; $doc_dir = '$prefix/share/pear/docs'; $data_dir = '$prefix/share/pear/data'; $test_dir = '$prefix/share/pear/tests'; } elseif (@is_dir("$prefix/share/php/.registry")) { - $php_dir = '$prefix/share/php'; + $pear_dir = '$prefix/share/php'; } } } @@ -1860,7 +1883,7 @@ <TD> <span class="green"> <b>Note:</b> To use PEAR without any problems you need to add your<br/> - PEAR Installation path (<?php echo $GLOBALS['php_dir']; ?>)<br> + PEAR Installation path (<?php echo $GLOBALS['pear_dir']; ?>)<br> to your <a href="http://www.php.net/manual/en/configuration.directives.php#ini.include_path">include_path</a>.<br/> <br/> Using a .htaccess file or directly edit httpd.conf would be working solutions<br/> @@ -2083,12 +2106,12 @@ * @Author Pierrre-Alain Joye */ function win32CreateRegEnv(){ - global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir; + global $prefix, $bin_dir, $pear_dir, $php_bin, $doc_dir, $data_dir, $test_dir; $nl = "\r\n"; $reg ='REGEDIT4'.$nl. '[HKEY_CURRENT_USER\Environment]'.$nl. '"PHP_PEAR_SYSCONF_DIR"="'.addslashes($prefix).'"'.$nl. - '"PHP_PEAR_INSTALL_DIR"="'.addslashes($php_dir).'"'.$nl. + '"PHP_PEAR_INSTALL_DIR"="'.addslashes($pear_dir).'"'.$nl. '"PHP_PEAR_DOC_DIR"="'.addslashes($doc_dir).'"'.$nl. '"PHP_PEAR_BIN_DIR"="'.addslashes($bin_dir).'"'.$nl. '"PHP_PEAR_DATA_DIR"="'.addslashes($data_dir).'"'.$nl. @@ -2221,7 +2244,7 @@ */ function alterPhpIni($pathIni='') { - global $php_dir, $prefix; + global $pear_dir, $prefix; $iniSep = WINDOWS?';':':'; @@ -2256,10 +2279,10 @@ $arrayPath = explode($iniSep, $currentPath); if( $arrayPath[0]=='.' ){ $newPath[0] = '.'; - $newPath[1] = $php_dir; + $newPath[1] = $pear_dir; array_shift($arrayPath); } else { - $newPath[0] = $php_dir; + $newPath[0] = $pear_dir; } foreach( $arrayPath as $path ){ @@ -2267,7 +2290,7 @@ } } else { $newPath[0] = '.'; - $newPath[1] = $php_dir; + $newPath[1] = $pear_dir; } $nl = WINDOWS?"\r\n":"\n";
« previous php.pear.dev (#34952) next »