*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Stig Bakken <ssb@php.net>
- * @author Tomas V.V.Cox <cox@idecnet.com>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: pearcmd.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
+ * @category pear
+ * @package PEAR
+ * @author Stig Bakken <ssb@php.net>
+ * @author Tomas V.V.Cox <cox@idecnet.com>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
*/
-ob_end_clean();
+@ob_end_clean();
if (!defined('PEAR_RUNTYPE')) {
// this is defined in peclcmd.php as 'pecl'
define('PEAR_RUNTYPE', 'pear');
/**
* @nodep Gtk
*/
-if ('@include_path@' != '@'.'include_path'.'@') {
- ini_set('include_path', '@include_path@');
+//the space is needed for windows include paths with trailing backslash
+// http://pear.php.net/bugs/bug.php?id=19482
+if ('@include_path@ ' != '@'.'include_path'.'@ ') {
+ ini_set('include_path', trim('@include_path@ '). PATH_SEPARATOR . get_include_path());
$raw = false;
} else {
// this is a raw, uninstalled pear, either a cvs checkout, or php distro
$raw = true;
}
@ini_set('allow_url_fopen', true);
-if (!ini_get('safe_mode')) {
- @set_time_limit(0);
-}
+@set_time_limit(0);
ob_implicit_flush(true);
@ini_set('track_errors', true);
@ini_set('html_errors', false);
-@ini_set('magic_quotes_runtime', false);
$_PEAR_PHPDIR = '#$%^&*';
set_error_handler('error_handler');
// remove this next part when we stop supporting that crap-ass PHP 4.2
if (!isset($_SERVER['argv']) && !isset($argv) && !isset($HTTP_SERVER_VARS['argv'])) {
- echo 'ERROR: either use the CLI php executable, or set register_argc_argv=On in php.ini';
+ echo 'ERROR: either use the CLI php executable, ' .
+ 'or set register_argc_argv=On in php.ini';
exit(1);
}
$fetype = 'CLI';
if ($progname == 'gpear' || $progname == 'pear-gtk') {
- $fetype = 'Gtk';
+ $fetype = 'Gtk2';
} else {
foreach ($opts as $opt) {
if ($opt[0] == 'G') {
- $fetype = 'Gtk';
+ $fetype = 'Gtk2';
}
}
}
-//Check if Gtk and PHP >= 5.1.0
-if ($fetype == 'Gtk' && version_compare(phpversion(), '5.1.0', '>=')) {
- $fetype = 'Gtk2';
-}
$pear_user_config = '';
$pear_system_config = '';
foreach ($opts as $opt) {
switch ($opt[0]) {
- case 'c':
- $pear_user_config = $opt[1];
- break;
- case 'C':
- $pear_system_config = $opt[1];
- break;
+ case 'c':
+ $pear_user_config = $opt[1];
+ break;
+ case 'C':
+ $pear_system_config = $opt[1];
+ break;
}
}
if (PEAR::isError($config)) {
$_file = '';
if ($pear_user_config !== false) {
- $_file .= $pear_user_config;
+ $_file .= $pear_user_config;
}
if ($pear_system_config !== false) {
- $_file .= '/' . $pear_system_config;
+ $_file .= '/' . $pear_system_config;
}
if ($_file == '/') {
$_file = 'The default config file';
$_PEAR_PHPDIR = $config->get('php_dir');
$ui->setConfig($config);
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
-if (ini_get('safe_mode')) {
- $ui->outputData('WARNING: running in safe mode requires that all files created ' .
- 'be the same uid as the current script. PHP reports this script is uid: ' .
- @getmyuid() . ', and current user is: ' . @get_current_user());
-}
$verbose = $config->get("verbose");
$cmdopts = array();
$found = false;
foreach ($opts as $opt) {
if ($opt[0] == 'd' || $opt[0] == 'D') {
- $found = true; // the user knows what they are doing, and are setting config values
+ // the user knows what they are doing, and are setting config values
+ $found = true;
}
}
if (!$found) {
// no prior runs, try to install PEAR
- if (strpos(dirname(__FILE__), 'scripts')) {
- $packagexml = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'package2.xml';
- $pearbase = dirname(dirname(__FILE__));
+ $parent = dirname(__FILE__);
+ if (strpos($parent, 'scripts')) {
+ $grandparent = dirname($parent);
+ $packagexml = $grandparent . DIRECTORY_SEPARATOR . 'package2.xml';
+ $pearbase = $grandparent;
} else {
- $packagexml = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'package2.xml';
- $pearbase = dirname(__FILE__);
+ $packagexml = $parent . DIRECTORY_SEPARATOR . 'package2.xml';
+ $pearbase = $parent;
}
if (file_exists($packagexml)) {
$options[1] = array(
$config->set('data_dir', $pearbase . DIRECTORY_SEPARATOR . 'data');
$config->set('doc_dir', $pearbase . DIRECTORY_SEPARATOR . 'docs');
$config->set('test_dir', $pearbase . DIRECTORY_SEPARATOR . 'tests');
- $config->set('ext_dir', $pearbase . DIRECTORY_SEPARATOR . 'extensions');
+ $config->set(
+ 'ext_dir',
+ $pearbase . DIRECTORY_SEPARATOR . 'extensions'
+ );
$config->set('bin_dir', $pearbase);
$config->mergeConfigFile($pearbase . 'pear.ini', false);
$config->store();
foreach ($opts as $opt) {
$param = !empty($opt[1]) ? $opt[1] : true;
switch ($opt[0]) {
- case 'd':
- if ($param === true) {
- die('Invalid usage of "-d" option, expected -d config_value=value, ' .
- 'received "-d"' . "\n");
- }
- $possible = explode('=', $param);
- if (count($possible) != 2) {
- die('Invalid usage of "-d" option, expected -d config_value=value, received "' .
- $param . '"' . "\n");
- }
- list($key, $value) = explode('=', $param);
- $config->set($key, $value, 'user');
- break;
- case 'D':
- if ($param === true) {
- die('Invalid usage of "-d" option, expected -d config_value=value, ' .
- 'received "-d"' . "\n");
- }
- $possible = explode('=', $param);
- if (count($possible) != 2) {
- die('Invalid usage of "-d" option, expected -d config_value=value, received "' .
- $param . '"' . "\n");
- }
- list($key, $value) = explode('=', $param);
- $config->set($key, $value, 'system');
- break;
- case 's':
- $store_user_config = true;
- break;
- case 'S':
- $store_system_config = true;
- break;
- case 'u':
- $config->remove($param, 'user');
- break;
- case 'v':
- $config->set('verbose', $config->get('verbose') + 1);
- break;
- case 'q':
- $config->set('verbose', $config->get('verbose') - 1);
- break;
- case 'V':
- usage(null, 'version');
- case 'c':
- case 'C':
- break;
- default:
- // all non pear params goes to the command
- $cmdopts[$opt[0]] = $param;
- break;
+ case 'd':
+ if ($param === true) {
+ die(
+ 'Invalid usage of "-d" option, expected -d config_value=value, ' .
+ 'received "-d"' . "\n"
+ );
+ }
+ $possible = explode('=', $param);
+ if (count($possible) != 2) {
+ die(
+ 'Invalid usage of "-d" option, expected ' .
+ '-d config_value=value, received "' . $param . '"' . "\n"
+ );
+ }
+ list($key, $value) = explode('=', $param);
+ $config->set($key, $value, 'user');
+ break;
+ case 'D':
+ if ($param === true) {
+ die(
+ 'Invalid usage of "-d" option, expected ' .
+ '-d config_value=value, received "-d"' . "\n"
+ );
+ }
+ $possible = explode('=', $param);
+ if (count($possible) != 2) {
+ die(
+ 'Invalid usage of "-d" option, expected ' .
+ '-d config_value=value, received "' . $param . '"' . "\n"
+ );
+ }
+ list($key, $value) = explode('=', $param);
+ $config->set($key, $value, 'system');
+ break;
+ case 's':
+ $store_user_config = true;
+ break;
+ case 'S':
+ $store_system_config = true;
+ break;
+ case 'u':
+ $config->remove($param, 'user');
+ break;
+ case 'v':
+ $config->set('verbose', $config->get('verbose') + 1);
+ break;
+ case 'q':
+ $config->set('verbose', $config->get('verbose') - 1);
+ break;
+ case 'V':
+ usage(null, 'version');
+ case 'c':
+ case 'C':
+ break;
+ default:
+ // all non pear params goes to the command
+ $cmdopts[$opt[0]] = $param;
+ break;
}
}
exit;
}
-if ($fetype == 'Gtk' || $fetype == 'Gtk2') {
+if ($fetype == 'Gtk2') {
if (!$config->validConfiguration()) {
- PEAR::raiseError('CRITICAL ERROR: no existing valid configuration files found in files ' .
- "'$pear_user_config' or '$pear_system_config', please copy an existing configuration" .
- 'file to one of these locations, or use the -c and -s options to create one');
+ PEAR::raiseError(
+ "CRITICAL ERROR: no existing valid configuration files found in " .
+ "files '$pear_user_config' or '$pear_system_config', " .
+ "please copy an existing configuration file to one of these " .
+ "locations, or use the -c and -s options to create one"
+ );
}
Gtk::main();
-} else do {
- if ($command == 'help') {
- usage(null, @$options[1][1]);
- }
-
- if (!$config->validConfiguration()) {
- PEAR::raiseError('CRITICAL ERROR: no existing valid configuration files found in files ' .
- "'$pear_user_config' or '$pear_system_config', please copy an existing configuration" .
- 'file to one of these locations, or use the -c and -s options to create one');
- }
+} else {
+ do {
+ if ($command == 'help') {
+ usage(null, isset($options[1][1]) ? $options[1][1] : null);
+ }
- PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
- $cmd = PEAR_Command::factory($command, $config);
- PEAR::popErrorHandling();
- if (PEAR::isError($cmd)) {
- usage(null, @$options[1][0]);
- }
+ if (!$config->validConfiguration()) {
+ PEAR::raiseError(
+ "CRITICAL ERROR: no existing valid configuration files found " .
+ "in files '$pear_user_config' or '$pear_system_config', " .
+ "please copy an existing configuration file to one of " .
+ "these locations, or use the -c and -s options to create one"
+ );
+ }
- $short_args = $long_args = null;
- PEAR_Command::getGetoptArgs($command, $short_args, $long_args);
- array_shift($options[1]);
- $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args);
+ PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
+ $cmd = PEAR_Command::factory($command, $config);
+ PEAR::popErrorHandling();
+ if (PEAR::isError($cmd)) {
+ usage(null, isset($options[1][0]) ? $options[1][0] : null);
+ }
- if (PEAR::isError($tmp)) {
- break;
- }
+ $short_args = $long_args = null;
+ PEAR_Command::getGetoptArgs($command, $short_args, $long_args);
+ array_shift($options[1]);
+ $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args);
- list($tmpopt, $params) = $tmp;
- $opts = array();
- foreach ($tmpopt as $foo => $tmp2) {
- list($opt, $value) = $tmp2;
- if ($value === null) {
- $value = true; // options without args
+ if (PEAR::isError($tmp)) {
+ break;
}
- if (strlen($opt) == 1) {
- $cmdoptions = $cmd->getOptions($command);
- foreach ($cmdoptions as $o => $d) {
- if (isset($d['shortopt']) && $d['shortopt'] == $opt) {
- $opts[$o] = $value;
- }
+ list($tmpopt, $params) = $tmp;
+ $opts = array();
+ foreach ($tmpopt as $foo => $tmp2) {
+ list($opt, $value) = $tmp2;
+ if ($value === null) {
+ $value = true; // options without args
}
- } else {
- if (substr($opt, 0, 2) == '--') {
- $opts[substr($opt, 2)] = $value;
+
+ if (strlen($opt) == 1) {
+ $cmdoptions = $cmd->getOptions($command);
+ foreach ($cmdoptions as $o => $d) {
+ if (isset($d['shortopt']) && $d['shortopt'] == $opt) {
+ $opts[$o] = $value;
+ }
+ }
+ } else {
+ if (substr($opt, 0, 2) == '--') {
+ $opts[substr($opt, 2)] = $value;
+ }
}
}
- }
- $ok = $cmd->run($command, $opts, $params);
- if ($ok === false) {
- PEAR::raiseError("unknown command `$command'");
- }
+ $ok = $cmd->run($command, $opts, $params);
+ if ($ok === false) {
+ PEAR::raiseError("unknown command `$command'");
+ }
- if (PEAR::isError($ok)) {
- PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
- PEAR::raiseError($ok);
- }
-} while (false);
+ if (PEAR::isError($ok)) {
+ PEAR::setErrorHandling(
+ PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")
+ );
+ PEAR::raiseError($ok);
+ }
+ } while (false);
+}
// {{{ usage()
+/**
+ * Display usage information
+ *
+ * @param mixed $error Optional error message
+ * @param mixed $helpsubject Optional subject/command to display help for
+ *
+ * @return void
+ */
function usage($error = null, $helpsubject = null)
{
global $progname, $all_commands;
"Usage: $progname [options] command [command-options] <parameters>\n".
"Type \"$progname help options\" to list all options.\n".
"Type \"$progname help shortcuts\" to list all command shortcuts.\n".
- "Type \"$progname help <command>\" to get the help for the specified command.";
+ "Type \"$progname help version\" or ".
+ "\"$progname version\" to list version information.\n".
+ "Type \"$progname help <command>\" to get the help ".
+ "for the specified command.";
}
fputs($stdout, "$put\n");
fclose($stdout);
exit(1);
}
+/**
+ * Return help string for specified command
+ *
+ * @param string $command Command to return help for
+ *
+ * @return void
+ */
function cmdHelp($command)
{
global $progname, $all_commands, $config;
// }}}
-function error_handler($errno, $errmsg, $file, $line, $vars) {
- if ((defined('E_STRICT') && $errno & E_STRICT) || (defined('E_DEPRECATED') &&
- $errno & E_DEPRECATED) || !error_reporting()) {
- if (defined('E_STRICT') && $errno & E_STRICT) {
+/**
+ * error_handler
+ *
+ * @param mixed $errno Error number
+ * @param mixed $errmsg Message
+ * @param mixed $file Filename
+ * @param mixed $line Line number
+ * @param mixed $vars Variables
+ *
+ * @access public
+ * @return boolean
+ */
+function error_handler($errno, $errmsg, $file, $line, $vars)
+{
+ if ($errno & E_STRICT
+ || $errno & E_DEPRECATED
+ || !error_reporting()
+ ) {
+ if ($errno & E_STRICT) {
return; // E_STRICT
}
- if (defined('E_DEPRECATED') && $errno & E_DEPRECATED) {
+ if ($errno & E_DEPRECATED) {
return; // E_DEPRECATED
}
- if ($GLOBALS['config']->get('verbose') < 4) {
+ if (!error_reporting() && isset($GLOBALS['config']) && $GLOBALS['config']->get('verbose') < 4) {
return false; // @silenced error, show all if debug is high enough
}
}
$errortype = array (
+ E_DEPRECATED => 'Deprecated Warning',
E_ERROR => "Error",
E_WARNING => "Warning",
E_PARSE => "Parsing Error",
+ E_STRICT => 'Strict Warning',
E_NOTICE => "Notice",
E_CORE_ERROR => "Core Error",
E_CORE_WARNING => "Core Warning",
* mode: php
* End:
*/
-// vim600:syn=php
\ No newline at end of file
+// vim600:syn=php