48 $runtimeRoot = str_replace(
'\\',
'/', rtrim(dirname(
$pearDir),
'/\\'));
49 $runtimeRootWin = str_replace(
'/',
'\\', $runtimeRoot);
50 $appRootWin = str_replace(
'/',
'\\', dirname(
$pearDir, 5));
51 $registryDir =
$pearDir .
'/.registry';
53 if (!is_dir($registryDir)) {
57 foreach (glob($registryDir .
'/*.reg') as $registryFile) {
58 $content = @file_get_contents($registryFile);
59 if ($content ===
false) {
63 $relocated = preg_replace_callback(
64 '/(s:)\d+(:")([A-Za-z]:\\\\[^"]*|core\\\\libs\\\\php\\\\pear(?:\\\\[^"]*)?)(")/',
65 function ($match) use ($runtimeRoot, $runtimeRootWin, $appRootWin) {
68 if (stripos($path, $runtimeRootWin) === 0 ||
69 stripos($path, $runtimeRoot) === 0) {
75 if (preg_match(
'#^core\\\\libs\\\\php\\\\pear(?:\\\\[^"]*)?$#i', $path)) {
76 $path = $appRootWin .
'\\' . $path;
77 return $match[1] . strlen($path) . $match[2] . $path . $match[4];
81 if (preg_match(
'#^[A-Za-z]:\\\\[^\r\n"]*?\\\\pear$#i', $path)) {
82 return $match[1] . strlen($runtimeRootWin) . $match[2] .
83 $runtimeRootWin . $match[4];
87 '#^[A-Za-z]:\\\\[^\r\n"]*?\\\\pear\\\\(pear|tests|docs|data|cfg|scripts|doc)(.*)$#i',
91 $path = $runtimeRootWin .
'\\' . $layout[1] . $layout[2];
92 return $match[1] . strlen($path) . $match[2] . $path . $match[4];
96 '#^[A-Za-z]:\\\\[^\r\n"]*?\\\\pear\\\\([^"\\\\]+)$#i',
100 $path = $runtimeRootWin .
'\\' . $file[1];
101 return $match[1] . strlen($path) . $match[2] . $path . $match[4];
109 if ($relocated !==
null && $relocated !== $content) {
110 @file_put_contents($registryFile, $relocated);
117@ini_set(
'allow_url_fopen',
true);
119ob_implicit_flush(
true);
120@ini_set(
'track_errors',
true);
121@ini_set(
'html_errors',
false);
123set_error_handler(
'error_handler');
127require_once
'PEAR.php';
128require_once
'PEAR/Frontend.php';
129require_once
'PEAR/Config.php';
130require_once
'PEAR/Command.php';
131require_once
'Console/Getopt.php';
137$argv = Console_Getopt::readPHPArgv();
139if (php_sapi_name() !=
'cli' && isset(
$argv[1]) &&
$argv[1] ==
'--') {
156 foreach (
$opts as $opt) {
157 if ($opt[0] ==
'G') {
163$pear_user_config =
'';
169foreach (
$opts as $opt) {
172 $pear_user_config = $opt[1];
186 if ($pear_user_config !==
false) {
187 $_file .= $pear_user_config;
193 $_file =
'The default config file';
196 $ui->outputData(
"ERROR: $_file is not a valid config file or is corrupted.");
210 if (!
$config->isDefinedLayer(
'user') && !
$config->isDefinedLayer(
'system')) {
212 foreach (
$opts as $opt) {
213 if ($opt[0] ==
'd' || $opt[0] ==
'D') {
220 $parent = dirname(__FILE__);
221 if (strpos($parent,
'scripts')) {
222 $grandparent = dirname($parent);
223 $packagexml = $grandparent . DIRECTORY_SEPARATOR .
'package2.xml';
224 $pearbase = $grandparent;
226 $packagexml = $parent . DIRECTORY_SEPARATOR .
'package2.xml';
229 if (file_exists($packagexml)) {
234 $config->set(
'php_dir', $pearbase . DIRECTORY_SEPARATOR .
'php');
235 $config->set(
'data_dir', $pearbase . DIRECTORY_SEPARATOR .
'data');
236 $config->set(
'doc_dir', $pearbase . DIRECTORY_SEPARATOR .
'docs');
237 $config->set(
'test_dir', $pearbase . DIRECTORY_SEPARATOR .
'tests');
240 $pearbase . DIRECTORY_SEPARATOR .
'extensions'
242 $config->set(
'bin_dir', $pearbase);
243 $config->mergeConfigFile($pearbase .
'pear.ini',
false);
245 $config->set(
'auto_discover', 1);
250foreach (
$opts as $opt) {
251 $param = !empty($opt[1]) ? $opt[1] :
true;
254 if ($param ===
true) {
256 'Invalid usage of "-d" option, expected -d config_value=value, ' .
257 'received "-d"' .
"\n"
260 $possible = explode(
'=', $param);
261 if (count($possible) != 2) {
263 'Invalid usage of "-d" option, expected ' .
264 '-d config_value=value, received "' . $param .
'"' .
"\n"
267 list($key, $value) = explode(
'=', $param);
268 $config->set($key, $value,
'user');
271 if ($param ===
true) {
273 'Invalid usage of "-d" option, expected ' .
274 '-d config_value=value, received "-d"' .
"\n"
277 $possible = explode(
'=', $param);
278 if (count($possible) != 2) {
280 'Invalid usage of "-d" option, expected ' .
281 '-d config_value=value, received "' . $param .
'"' .
"\n"
284 list($key, $value) = explode(
'=', $param);
285 $config->set($key, $value,
'system');
294 $config->remove($param,
'user');
303 usage(
null,
'version');
328 if (!
$config->validConfiguration()) {
330 "CRITICAL ERROR: no existing valid configuration files found in " .
331 "files '$pear_user_config' or '$pear_system_config', " .
332 "please copy an existing configuration file to one of these " .
333 "locations, or use the -c and -s options to create one"
521 if ((!defined(
'PHP_VERSION_ID') || PHP_VERSION_ID < 80400) && ($errno & E_STRICT)) {
524 if ($errno & E_DEPRECATED) {
527 if (!(error_reporting() & $errno) &&
529 $GLOBALS[
'config']->
get(
'verbose') < 4
534 E_DEPRECATED =>
'Deprecated Warning',
536 E_WARNING =>
"Warning",
537 E_PARSE =>
"Parsing Error",
538 E_NOTICE =>
"Notice",
539 E_CORE_ERROR =>
"Core Error",
540 E_CORE_WARNING =>
"Core Warning",
541 E_COMPILE_ERROR =>
"Compile Error",
542 E_COMPILE_WARNING =>
"Compile Warning",
544 E_USER_WARNING =>
"User Warning",
545 E_USER_NOTICE =>
"User Notice"
547 if (!defined(
'PHP_VERSION_ID') || PHP_VERSION_ID < 80400) {
548 $errortype[E_STRICT] =
'Strict Warning';
550 $prefix = $errortype[$errno];
555 $file = basename($file);
557 print
"\n$prefix: $errmsg in $file on line $line\n";