4,19 → 4,12 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Config.php,v 1.137 2006/11/19 21:33:00 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
28,7 → 21,6 |
require_once 'PEAR/Registry.php'; |
require_once 'PEAR/Installer/Role.php'; |
require_once 'System.php'; |
require_once 'PEAR/Remote.php'; |
|
/** |
* Last created PEAR_Config instance. |
49,8 → 41,11 |
|
// default channel and preferred mirror is based on whether we are invoked through |
// the "pear" or the "pecl" command |
if (!defined('PEAR_RUNTYPE')) { |
define('PEAR_RUNTYPE', 'pear'); |
} |
|
if (!defined('PEAR_RUNTYPE') || PEAR_RUNTYPE == 'pear') { |
if (PEAR_RUNTYPE == 'pear') { |
define('PEAR_CONFIG_DEFAULT_CHANNEL', 'pear.php.net'); |
} else { |
define('PEAR_CONFIG_DEFAULT_CHANNEL', 'pecl.php.net'); |
84,14 → 79,20 |
if (getenv('PHP_PEAR_INSTALL_DIR')) { |
define('PEAR_CONFIG_DEFAULT_PHP_DIR', getenv('PHP_PEAR_INSTALL_DIR')); |
} else { |
if (file_exists($PEAR_INSTALL_DIR) && is_dir($PEAR_INSTALL_DIR)) { |
define('PEAR_CONFIG_DEFAULT_PHP_DIR', |
$PEAR_INSTALL_DIR); |
if (@file_exists($PEAR_INSTALL_DIR) && is_dir($PEAR_INSTALL_DIR)) { |
define('PEAR_CONFIG_DEFAULT_PHP_DIR', $PEAR_INSTALL_DIR); |
} else { |
define('PEAR_CONFIG_DEFAULT_PHP_DIR', $PEAR_INSTALL_DIR); |
} |
} |
|
// Default for metadata_dir |
if (getenv('PHP_PEAR_METADATA_DIR')) { |
define('PEAR_CONFIG_DEFAULT_METADATA_DIR', getenv('PHP_PEAR_METADATA_DIR')); |
} else { |
define('PEAR_CONFIG_DEFAULT_METADATA_DIR', ''); |
} |
|
// Default for ext_dir |
if (getenv('PHP_PEAR_EXTENSION_DIR')) { |
define('PEAR_CONFIG_DEFAULT_EXT_DIR', getenv('PHP_PEAR_EXTENSION_DIR')); |
131,6 → 132,34 |
$PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'data'); |
} |
|
// Default for cfg_dir |
if (getenv('PHP_PEAR_CFG_DIR')) { |
define('PEAR_CONFIG_DEFAULT_CFG_DIR', getenv('PHP_PEAR_CFG_DIR')); |
} else { |
define('PEAR_CONFIG_DEFAULT_CFG_DIR', |
$PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'cfg'); |
} |
|
// Default for www_dir |
if (getenv('PHP_PEAR_WWW_DIR')) { |
define('PEAR_CONFIG_DEFAULT_WWW_DIR', getenv('PHP_PEAR_WWW_DIR')); |
} else { |
define('PEAR_CONFIG_DEFAULT_WWW_DIR', |
$PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'www'); |
} |
|
// Default for man_dir |
if (getenv('PHP_PEAR_MAN_DIR')) { |
define('PEAR_CONFIG_DEFAULT_MAN_DIR', getenv('PHP_PEAR_MAN_DIR')); |
} else { |
if (defined('PHP_MANDIR')) { // Added in PHP5.3.7 |
define('PEAR_CONFIG_DEFAULT_MAN_DIR', PHP_MANDIR); |
} else { |
define('PEAR_CONFIG_DEFAULT_MAN_DIR', PHP_PREFIX . DIRECTORY_SEPARATOR . |
'local' . DIRECTORY_SEPARATOR .'man'); |
} |
} |
|
// Default for test_dir |
if (getenv('PHP_PEAR_TEST_DIR')) { |
define('PEAR_CONFIG_DEFAULT_TEST_DIR', getenv('PHP_PEAR_TEST_DIR')); |
233,16 → 262,14 |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
class PEAR_Config extends PEAR |
{ |
// {{{ properties |
|
/** |
* Array of config files used. |
* |
254,7 → 281,7 |
); |
|
var $layers = array(); |
|
|
/** |
* Configuration data, two-dimensional array where the first |
* dimension is the config layer ('user', 'system' and 'default'), |
272,7 → 299,7 |
'system' => array(), |
'default' => array(), |
); |
|
|
/** |
* Configuration values that can be set for a channel |
* |
281,9 → 308,9 |
* @access private |
*/ |
var $_channelConfigInfo = array( |
'php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', |
'test_dir', 'php_bin', 'username', 'password', 'verbose', |
'preferred_state', 'umask', 'preferred_mirror', |
'php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'cfg_dir', |
'test_dir', 'www_dir', 'php_bin', 'php_prefix', 'php_suffix', 'username', |
'password', 'verbose', 'preferred_state', 'umask', 'preferred_mirror', 'php_ini' |
); |
|
/** |
417,6 → 444,27 |
'prompt' => 'PEAR data directory', |
'group' => 'File Locations (Advanced)', |
), |
'cfg_dir' => array( |
'type' => 'directory', |
'default' => PEAR_CONFIG_DEFAULT_CFG_DIR, |
'doc' => 'directory where modifiable configuration files are installed', |
'prompt' => 'PEAR configuration file directory', |
'group' => 'File Locations (Advanced)', |
), |
'www_dir' => array( |
'type' => 'directory', |
'default' => PEAR_CONFIG_DEFAULT_WWW_DIR, |
'doc' => 'directory where www frontend files (html/js) are installed', |
'prompt' => 'PEAR www files directory', |
'group' => 'File Locations (Advanced)', |
), |
'man_dir' => array( |
'type' => 'directory', |
'default' => PEAR_CONFIG_DEFAULT_MAN_DIR, |
'doc' => 'directory where unix manual pages are installed', |
'prompt' => 'Systems manpage files directory', |
'group' => 'File Locations (Advanced)', |
), |
'test_dir' => array( |
'type' => 'directory', |
'default' => PEAR_CONFIG_DEFAULT_TEST_DIR, |
427,7 → 475,7 |
'cache_dir' => array( |
'type' => 'directory', |
'default' => PEAR_CONFIG_DEFAULT_CACHE_DIR, |
'doc' => 'directory which is used for XMLRPC cache', |
'doc' => 'directory which is used for web service cache', |
'prompt' => 'PEAR Installer cache directory', |
'group' => 'File Locations (Advanced)', |
), |
440,7 → 488,7 |
), |
'download_dir' => array( |
'type' => 'directory', |
'default' => PEAR_CONFIG_DEFAULT_CACHE_DIR, |
'default' => PEAR_CONFIG_DEFAULT_DOWNLOAD_DIR, |
'doc' => 'directory which is used for all downloaded files', |
'prompt' => 'PEAR Installer download directory', |
'group' => 'File Locations (Advanced)', |
452,6 → 500,20 |
'prompt' => 'PHP CLI/CGI binary', |
'group' => 'File Locations (Advanced)', |
), |
'php_prefix' => array( |
'type' => 'string', |
'default' => '', |
'doc' => '--program-prefix for php_bin\'s ./configure, used for pecl installs', |
'prompt' => '--program-prefix passed to PHP\'s ./configure', |
'group' => 'File Locations (Advanced)', |
), |
'php_suffix' => array( |
'type' => 'string', |
'default' => '', |
'doc' => '--program-suffix for php_bin\'s ./configure, used for pecl installs', |
'prompt' => '--program-suffix passed to PHP\'s ./configure', |
'group' => 'File Locations (Advanced)', |
), |
'php_ini' => array( |
'type' => 'file', |
'default' => '', |
459,6 → 521,13 |
'prompt' => 'php.ini location', |
'group' => 'File Locations (Advanced)', |
), |
'metadata_dir' => array( |
'type' => 'directory', |
'default' => PEAR_CONFIG_DEFAULT_METADATA_DIR, |
'doc' => 'directory where metadata files are installed (registry, filemap, channels, ...)', |
'prompt' => 'PEAR metadata directory', |
'group' => 'File Locations (Advanced)', |
), |
// Maintainers |
'username' => array( |
'type' => 'string', |
541,10 → 610,6 |
// __channels is reserved - used for channel-specific configuration |
); |
|
// }}} |
|
// {{{ PEAR_Config([file], [defaults_file]) |
|
/** |
* Constructor. |
* |
559,10 → 624,10 |
* |
* @see PEAR_Config::singleton |
*/ |
function PEAR_Config($user_file = '', $system_file = '', $ftp_file = false, |
function __construct($user_file = '', $system_file = '', $ftp_file = false, |
$strict = true) |
{ |
$this->PEAR(); |
parent::__construct(); |
PEAR_Installer_Role::initializeConfig($this); |
$sl = DIRECTORY_SEPARATOR; |
if (empty($user_file)) { |
572,16 → 637,18 |
$user_file = getenv('HOME') . $sl . '.pearrc'; |
} |
} |
|
if (empty($system_file)) { |
$system_file = PEAR_CONFIG_SYSCONFDIR . $sl; |
if (OS_WINDOWS) { |
$system_file = PEAR_CONFIG_SYSCONFDIR . $sl . 'pearsys.ini'; |
$system_file .= 'pearsys.ini'; |
} else { |
$system_file = PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.conf'; |
$system_file .= 'pear.conf'; |
} |
} |
|
$this->layers = array_keys($this->configuration); |
$this->files['user'] = $user_file; |
$this->files['user'] = $user_file; |
$this->files['system'] = $system_file; |
if ($user_file && file_exists($user_file)) { |
$this->pushErrorHandling(PEAR_ERROR_RETURN); |
592,7 → 659,7 |
} |
} |
|
if ($system_file && file_exists($system_file)) { |
if ($system_file && @file_exists($system_file)) { |
$this->mergeConfigFile($system_file, false, 'system', $strict); |
if ($this->_errorsFound > 0) { |
return; |
612,15 → 679,33 |
$this->configuration['default'][$key] = $info['default']; |
} |
|
$this->_registry['default'] = &new PEAR_Registry($this->configuration['default']['php_dir']); |
$this->_registry['default']->setConfig($this); |
$this->_registry['default'] = new PEAR_Registry( |
$this->configuration['default']['php_dir'], false, false, |
$this->configuration['default']['metadata_dir']); |
$this->_registry['default']->setConfig($this, false); |
$this->_regInitialized['default'] = false; |
//$GLOBALS['_PEAR_Config_instance'] = &$this; |
} |
|
// }}} |
// {{{ singleton([file], [defaults_file]) |
/** |
* Return the default locations of user and system configuration files |
*/ |
public static function getDefaultConfigFiles() |
{ |
$sl = DIRECTORY_SEPARATOR; |
if (OS_WINDOWS) { |
return array( |
'user' => PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.ini', |
'system' => PEAR_CONFIG_SYSCONFDIR . $sl . 'pearsys.ini' |
); |
} |
|
return array( |
'user' => getenv('HOME') . $sl . '.pearrc', |
'system' => PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.conf' |
); |
} |
|
/** |
* Static singleton method. If you want to keep only one instance |
* of this class in use, this method will give you a reference to |
632,17 → 717,15 |
* |
* @return object an existing or new PEAR_Config instance |
* |
* @access public |
* |
* @see PEAR_Config::PEAR_Config |
*/ |
function &singleton($user_file = '', $system_file = '', $strict = true) |
public static function &singleton($user_file = '', $system_file = '', $strict = true) |
{ |
if (is_object($GLOBALS['_PEAR_Config_instance'])) { |
return $GLOBALS['_PEAR_Config_instance']; |
} |
|
$t_conf = &new PEAR_Config($user_file, $system_file, false, $strict); |
$t_conf = new PEAR_Config($user_file, $system_file, false, $strict); |
if ($t_conf->_errorsFound > 0) { |
return $t_conf->lastError; |
} |
651,9 → 734,6 |
return $GLOBALS['_PEAR_Config_instance']; |
} |
|
// }}} |
// {{{ validConfiguration() |
|
/** |
* Determine whether any configuration files have been detected, and whether a |
* registry object can be retrieved from this configuration. |
665,12 → 745,10 |
if ($this->isDefinedLayer('user') || $this->isDefinedLayer('system')) { |
return true; |
} |
|
return false; |
} |
|
// }}} |
// {{{ readConfigFile([file], [layer]) |
|
/** |
* Reads configuration data from a file. All existing values in |
* the config layer are discarded and replaced with data from the |
691,26 → 769,26 |
} |
|
$data = $this->_readConfigDataFrom($file); |
|
if (PEAR::isError($data)) { |
if ($strict) { |
$this->_errorsFound++; |
$this->lastError = $data; |
|
return $data; |
} else { |
if (!$strict) { |
return true; |
} |
} else { |
$this->files[$layer] = $file; |
|
$this->_errorsFound++; |
$this->lastError = $data; |
|
return $data; |
} |
|
$this->files[$layer] = $file; |
$this->_decodeInput($data); |
$this->configuration[$layer] = $data; |
$this->_setupChannels(); |
if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) { |
$this->_registry[$layer] = &new PEAR_Registry($phpdir); |
$this->_registry[$layer]->setConfig($this); |
$this->_registry[$layer] = new PEAR_Registry( |
$phpdir, false, false, |
$this->get('metadata_dir', $layer, 'pear.php.net')); |
$this->_registry[$layer]->setConfig($this, false); |
$this->_regInitialized[$layer] = false; |
} else { |
unset($this->_registry[$layer]); |
718,8 → 796,6 |
return true; |
} |
|
// }}} |
|
/** |
* @param string url to the remote config file, like ftp://www.example.com/pear/config.ini |
* @return true|PEAR_Error |
735,61 → 811,64 |
require_once 'PEAR/FTP.php'; |
} |
} |
if (class_exists('PEAR_FTP')) { |
$this->_ftp = &new PEAR_FTP; |
$this->_ftp->pushErrorHandling(PEAR_ERROR_RETURN); |
$e = $this->_ftp->init($path); |
if (PEAR::isError($e)) { |
$this->_ftp->popErrorHandling(); |
return $e; |
} |
$tmp = System::mktemp('-d'); |
PEAR_Common::addTempFile($tmp); |
$e = $this->_ftp->get(basename($path), $tmp . DIRECTORY_SEPARATOR . |
'pear.ini', false, FTP_BINARY); |
if (PEAR::isError($e)) { |
$this->_ftp->popErrorHandling(); |
return $e; |
} |
PEAR_Common::addTempFile($tmp . DIRECTORY_SEPARATOR . 'pear.ini'); |
$this->_ftp->disconnect(); |
|
if (!class_exists('PEAR_FTP')) { |
return PEAR::raiseError('PEAR_RemoteInstaller must be installed to use remote config'); |
} |
|
$this->_ftp = new PEAR_FTP; |
$this->_ftp->pushErrorHandling(PEAR_ERROR_RETURN); |
$e = $this->_ftp->init($path); |
if (PEAR::isError($e)) { |
$this->_ftp->popErrorHandling(); |
$this->files['ftp'] = $tmp . DIRECTORY_SEPARATOR . 'pear.ini'; |
$e = $this->readConfigFile(null, 'ftp'); |
if (PEAR::isError($e)) { |
return $e; |
} |
$fail = array(); |
foreach ($this->configuration_info as $key => $val) { |
if (in_array($this->getGroup($key), |
array('File Locations', 'File Locations (Advanced)')) && |
$this->getType($key) == 'directory') { |
// any directory configs must be set for this to work |
if (!isset($this->configuration['ftp'][$key])) { |
$fail[] = $key; |
} |
return $e; |
} |
|
$tmp = System::mktemp('-d'); |
PEAR_Common::addTempFile($tmp); |
$e = $this->_ftp->get(basename($path), $tmp . DIRECTORY_SEPARATOR . |
'pear.ini', false, FTP_BINARY); |
if (PEAR::isError($e)) { |
$this->_ftp->popErrorHandling(); |
return $e; |
} |
|
PEAR_Common::addTempFile($tmp . DIRECTORY_SEPARATOR . 'pear.ini'); |
$this->_ftp->disconnect(); |
$this->_ftp->popErrorHandling(); |
$this->files['ftp'] = $tmp . DIRECTORY_SEPARATOR . 'pear.ini'; |
$e = $this->readConfigFile(null, 'ftp'); |
if (PEAR::isError($e)) { |
return $e; |
} |
|
$fail = array(); |
foreach ($this->configuration_info as $key => $val) { |
if (in_array($this->getGroup($key), |
array('File Locations', 'File Locations (Advanced)')) && |
$this->getType($key) == 'directory') { |
// any directory configs must be set for this to work |
if (!isset($this->configuration['ftp'][$key])) { |
$fail[] = $key; |
} |
} |
if (count($fail)) { |
$fail = '"' . implode('", "', $fail) . '"'; |
unset($this->files['ftp']); |
unset($this->configuration['ftp']); |
return PEAR::raiseError('ERROR: Ftp configuration file must set all ' . |
'directory configuration variables. These variables were not set: ' . |
$fail); |
} else { |
return true; |
} |
} else { |
return PEAR::raiseError('PEAR_RemoteInstaller must be installed to use remote config'); |
} |
|
if (!count($fail)) { |
return true; |
} |
|
$fail = '"' . implode('", "', $fail) . '"'; |
unset($this->files['ftp']); |
unset($this->configuration['ftp']); |
return PEAR::raiseError('ERROR: Ftp configuration file must set all ' . |
'directory configuration variables. These variables were not set: ' . |
$fail); |
} while (false); // poor man's catch |
unset($this->files['ftp']); |
return PEAR::raiseError('no remote host specified'); |
} |
|
// {{{ _setupChannels() |
|
/** |
* Reads the existing configurations and creates the _channels array from it |
*/ |
808,26 → 887,20 |
$this->setChannels($this->_channels); |
} |
|
// }}} |
// {{{ deleteChannel(channel) |
|
function deleteChannel($channel) |
{ |
$ch = strtolower($channel); |
foreach ($this->configuration as $layer => $data) { |
if (isset($data['__channels'])) { |
if (isset($data['__channels'][strtolower($channel)])) { |
unset($this->configuration[$layer]['__channels'][strtolower($channel)]); |
} |
if (isset($data['__channels']) && isset($data['__channels'][$ch])) { |
unset($this->configuration[$layer]['__channels'][$ch]); |
} |
} |
|
$this->_channels = array_flip($this->_channels); |
unset($this->_channels[strtolower($channel)]); |
unset($this->_channels[$ch]); |
$this->_channels = array_flip($this->_channels); |
} |
|
// }}} |
// {{{ mergeConfigFile(file, [override], [layer]) |
|
/** |
* Merges data into a config layer from a file. Does the same |
* thing as readConfigFile, except it does not replace all |
843,20 → 916,23 |
if (empty($this->files[$layer])) { |
return $this->raiseError("unknown config layer `$layer'"); |
} |
|
if ($file === null) { |
$file = $this->files[$layer]; |
} |
|
$data = $this->_readConfigDataFrom($file); |
if (PEAR::isError($data)) { |
if ($strict) { |
$this->_errorsFound++; |
$this->lastError = $data; |
|
return $data; |
} else { |
if (!$strict) { |
return true; |
} |
|
$this->_errorsFound++; |
$this->lastError = $data; |
|
return $data; |
} |
|
$this->_decodeInput($data); |
if ($override) { |
$this->configuration[$layer] = |
865,10 → 941,13 |
$this->configuration[$layer] = |
PEAR_Config::arrayMergeRecursive($data, $this->configuration[$layer]); |
} |
|
$this->_setupChannels(); |
if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) { |
$this->_registry[$layer] = &new PEAR_Registry($phpdir); |
$this->_registry[$layer]->setConfig($this); |
$this->_registry[$layer] = new PEAR_Registry( |
$phpdir, false, false, |
$this->get('metadata_dir', $layer, 'pear.php.net')); |
$this->_registry[$layer]->setConfig($this, false); |
$this->_regInitialized[$layer] = false; |
} else { |
unset($this->_registry[$layer]); |
876,15 → 955,12 |
return true; |
} |
|
// }}} |
// {{{ arrayMergeRecursive($arr2, $arr1) |
/** |
* @param array |
* @param array |
* @return array |
* @static |
*/ |
function arrayMergeRecursive($arr2, $arr1) |
public static function arrayMergeRecursive($arr2, $arr1) |
{ |
$ret = array(); |
foreach ($arr2 as $key => $data) { |
903,12 → 979,10 |
unset($arr1[$key]); |
} |
} |
|
return array_merge($ret, $arr1); |
} |
|
// }}} |
// {{{ writeConfigFile([file], [layer]) |
|
/** |
* Writes data into a config layer from a file. |
* |
930,12 → 1004,15 |
} |
return true; |
} |
|
if (empty($this->files[$layer])) { |
return $this->raiseError("unknown config file type `$layer'"); |
} |
|
if ($file === null) { |
$file = $this->files[$layer]; |
} |
|
$data = ($data === null) ? $this->configuration[$layer] : $data; |
$this->_encodeOutput($data); |
$opt = array('-p', dirname($file)); |
942,13 → 1019,16 |
if (!@System::mkDir($opt)) { |
return $this->raiseError("could not create directory: " . dirname($file)); |
} |
|
if (file_exists($file) && is_file($file) && !is_writeable($file)) { |
return $this->raiseError("no write access to $file!"); |
} |
|
$fp = @fopen($file, "w"); |
if (!$fp) { |
return $this->raiseError("PEAR_Config::writeConfigFile fopen('$file','w') failed ($php_errormsg)"); |
} |
|
$contents = "#PEAR_Config 0.9\n" . serialize($data); |
if (!@fwrite($fp, $contents)) { |
return $this->raiseError("PEAR_Config::writeConfigFile: fwrite failed ($php_errormsg)"); |
956,17 → 1036,12 |
return true; |
} |
|
// }}} |
// {{{ _readConfigDataFrom(file) |
|
/** |
* Reads configuration data from a file and returns the parsed data |
* in an array. |
* |
* @param string file to read from |
* |
* @return array configuration data or a PEAR error on failure |
* |
* @access private |
*/ |
function _readConfigDataFrom($file) |
975,19 → 1050,17 |
if (file_exists($file)) { |
$fp = @fopen($file, "r"); |
} |
|
if (!$fp) { |
return $this->raiseError("PEAR_Config::readConfigFile fopen('$file','r') failed"); |
} |
|
$size = filesize($file); |
$rt = get_magic_quotes_runtime(); |
set_magic_quotes_runtime(0); |
fclose($fp); |
$contents = file_get_contents($file); |
if (empty($contents)) { |
return $this->raiseError('Configuration file "' . $file . '" is empty'); |
} |
|
set_magic_quotes_runtime($rt); |
|
$version = false; |
if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, $matches)) { |
999,8 → 1072,8 |
$version = '0.1'; |
} |
} |
|
if ($version && version_compare("$version", '1', '<')) { |
|
// no '@', it is possible that unserialize |
// raises a notice but it seems to block IO to |
// STDOUT if a '@' is used and a notice is raise |
1019,116 → 1092,124 |
$error = "PEAR_Config: bad data in $file"; |
$err = $this->raiseError($error); |
return $err; |
} else { |
$data = array(); |
} |
|
$data = array(); |
} |
// add parsing of newer formats here... |
} else { |
$err = $this->raiseError("$file: unknown version `$version'"); |
return $err; |
return $err; |
} |
|
return $data; |
} |
|
// }}} |
// {{{ getConfFile(layer) |
/** |
* Gets the file used for storing the config for a layer |
* |
* @param string $layer 'user' or 'system' |
*/ |
|
function getConfFile($layer) |
{ |
return $this->files[$layer]; |
} |
|
// }}} |
|
/** |
* @param string Configuration class name, used for detecting duplicate calls |
* @param array information on a role as parsed from its xml file |
* @return true|PEAR_Error |
* @access private |
*/ |
function _addConfigVars($vars) |
function _addConfigVars($class, $vars) |
{ |
static $called = array(); |
if (isset($called[$class])) { |
return; |
} |
|
$called[$class] = 1; |
if (count($vars) > 3) { |
return $this->raiseError('Roles can only define 3 new config variables or less'); |
} |
|
foreach ($vars as $name => $var) { |
if (!is_array($var)) { |
return $this->raiseError('Configuration information must be an array'); |
} |
|
if (!isset($var['type'])) { |
return $this->raiseError('Configuration information must contain a type'); |
} else { |
if (!in_array($var['type'], |
array('string', 'mask', 'password', 'directory', 'file', 'set'))) { |
return $this->raiseError( |
'Configuration type must be one of directory, file, string, ' . |
'mask, set, or password'); |
} |
} elseif (!in_array($var['type'], |
array('string', 'mask', 'password', 'directory', 'file', 'set'))) { |
return $this->raiseError( |
'Configuration type must be one of directory, file, string, ' . |
'mask, set, or password'); |
} |
if (!isset($var['default'])) { |
return $this->raiseError( |
'Configuration information must contain a default value ("default" index)'); |
} else { |
if (is_array($var['default'])) { |
$real_default = ''; |
foreach ($var['default'] as $config_var => $val) { |
if (strpos($config_var, 'text') === 0) { |
$real_default .= $val; |
} elseif (strpos($config_var, 'constant') === 0) { |
if (defined($val)) { |
$real_default .= constant($val); |
} else { |
return $this->raiseError( |
'Unknown constant "' . $val . '" requested in ' . |
'default value for configuration variable "' . |
$name . '"'); |
} |
} elseif (isset($this->configuration_info[$config_var])) { |
$real_default .= |
$this->configuration_info[$config_var]['default']; |
} else { |
} |
|
if (is_array($var['default'])) { |
$real_default = ''; |
foreach ($var['default'] as $config_var => $val) { |
if (strpos($config_var, 'text') === 0) { |
$real_default .= $val; |
} elseif (strpos($config_var, 'constant') === 0) { |
if (!defined($val)) { |
return $this->raiseError( |
'Unknown request for "' . $config_var . '" value in ' . |
'Unknown constant "' . $val . '" requested in ' . |
'default value for configuration variable "' . |
$name . '"'); |
} |
|
$real_default .= constant($val); |
} elseif (isset($this->configuration_info[$config_var])) { |
$real_default .= |
$this->configuration_info[$config_var]['default']; |
} else { |
return $this->raiseError( |
'Unknown request for "' . $config_var . '" value in ' . |
'default value for configuration variable "' . |
$name . '"'); |
} |
$var['default'] = $real_default; |
} |
if ($var['type'] == 'integer') { |
$var['default'] = (integer) $var['default']; |
} |
$var['default'] = $real_default; |
} |
|
if ($var['type'] == 'integer') { |
$var['default'] = (integer) $var['default']; |
} |
|
if (!isset($var['doc'])) { |
return $this->raiseError( |
'Configuration information must contain a summary ("doc" index)'); |
} |
|
if (!isset($var['prompt'])) { |
return $this->raiseError( |
'Configuration information must contain a simple prompt ("prompt" index)'); |
} |
|
if (!isset($var['group'])) { |
return $this->raiseError( |
'Configuration information must contain a simple group ("group" index)'); |
} |
|
if (isset($this->configuration_info[$name])) { |
return $this->raiseError('Configuration variable "' . $name . |
'" already exists'); |
} |
|
$this->configuration_info[$name] = $var; |
// fix bug #7351: setting custom config variable in a channel fails |
$this->_channelConfigInfo[] = $name; |
} |
|
return true; |
} |
|
// {{{ _encodeOutput(&data) |
|
/** |
* Encodes/scrambles configuration data before writing to files. |
* Currently, 'password' values will be base64-encoded as to avoid |
1135,9 → 1216,7 |
* that people spot cleartext passwords by accident. |
* |
* @param array (reference) array to encode values in |
* |
* @return bool TRUE on success |
* |
* @access private |
*/ |
function _encodeOutput(&$data) |
1148,9 → 1227,11 |
$this->_encodeOutput($data['__channels'][$channel]); |
} |
} |
|
if (!isset($this->configuration_info[$key])) { |
continue; |
} |
|
$type = $this->configuration_info[$key]['type']; |
switch ($type) { |
// we base64-encode passwords so they are at least |
1165,19 → 1246,15 |
} |
} |
} |
|
return true; |
} |
|
// }}} |
// {{{ _decodeInput(&data) |
|
/** |
* Decodes/unscrambles configuration data after reading from files. |
* |
* @param array (reference) array to encode values in |
* |
* @return bool TRUE on success |
* |
* @access private |
* |
* @see PEAR_Config::_encodeOutput |
1187,6 → 1264,7 |
if (!is_array($data)) { |
return true; |
} |
|
foreach ($data as $key => $value) { |
if ($key == '__channels') { |
foreach ($data['__channels'] as $channel => $blah) { |
1193,9 → 1271,11 |
$this->_decodeInput($data['__channels'][$channel]); |
} |
} |
|
if (!isset($this->configuration_info[$key])) { |
continue; |
} |
|
$type = $this->configuration_info[$key]['type']; |
switch ($type) { |
case 'password': { |
1208,11 → 1288,10 |
} |
} |
} |
|
return true; |
} |
|
// }}} |
// {{{ getDefaultChannel([layer]) |
/** |
* Retrieve the default channel. |
* |
1234,27 → 1313,28 |
} elseif (isset($this->configuration[$layer]['default_channel'])) { |
$ret = $this->configuration[$layer]['default_channel']; |
} |
|
if ($ret == 'pear.php.net' && defined('PEAR_RUNTYPE') && PEAR_RUNTYPE == 'pecl') { |
$ret = 'pecl.php.net'; |
} |
|
if ($ret) { |
if ($ret != 'pear.php.net') { |
$this->_lazyChannelSetup(); |
} |
|
return $ret; |
} |
|
return PEAR_CONFIG_DEFAULT_CHANNEL; |
} |
|
// {{{ get(key, [layer]) |
/** |
* Returns a configuration value, prioritizing layers as per the |
* layers property. |
* |
* @param string config key |
* |
* @return mixed the config value, or NULL if not found |
* |
* @access public |
*/ |
function get($key, $layer = null, $channel = false) |
1262,12 → 1342,15 |
if (!isset($this->configuration_info[$key])) { |
return null; |
} |
|
if ($key == '__channels') { |
return null; |
} |
|
if ($key == 'default_channel') { |
return $this->getDefaultChannel($layer); |
} |
|
if (!$channel) { |
$channel = $this->getDefaultChannel(); |
} elseif ($channel != 'pear.php.net') { |
1274,7 → 1357,7 |
$this->_lazyChannelSetup(); |
} |
$channel = strtolower($channel); |
|
|
$test = (in_array($key, $this->_channelConfigInfo)) ? |
$this->_getChannelValue($key, $layer, $channel) : |
null; |
1288,6 → 1371,7 |
} |
return $test; |
} |
|
if ($layer === null) { |
foreach ($this->layers as $layer) { |
if (isset($this->configuration[$layer][$key])) { |
1299,13 → 1383,15 |
return $this->_prependPath($test, $this->_installRoot); |
} |
} |
|
if ($key == 'preferred_mirror') { |
$reg = &$this->getRegistry(); |
if (is_object($reg)) { |
$chan = &$reg->getChannel($channel); |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $channel; |
} |
|
if (!$chan->getMirror($test) && $chan->getName() != $test) { |
return $channel; // mirror does not exist |
} |
1323,33 → 1409,33 |
return $this->_prependPath($test, $this->_installRoot); |
} |
} |
|
if ($key == 'preferred_mirror') { |
$reg = &$this->getRegistry(); |
if (is_object($reg)) { |
$chan = &$reg->getChannel($channel); |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $channel; |
} |
|
if (!$chan->getMirror($test) && $chan->getName() != $test) { |
return $channel; // mirror does not exist |
} |
} |
} |
|
return $test; |
} |
|
return null; |
} |
|
// }}} |
// {{{ _getChannelValue(key, value, [layer]) |
/** |
* Returns a channel-specific configuration value, prioritizing layers as per the |
* layers property. |
* |
* @param string config key |
* |
* @return mixed the config value, or NULL if not found |
* |
* @access private |
*/ |
function _getChannelValue($key, $layer, $channel) |
1357,6 → 1443,7 |
if ($key == '__channels' || $channel == 'pear.php.net') { |
return null; |
} |
|
$ret = null; |
if ($layer === null) { |
foreach ($this->layers as $ilayer) { |
1368,33 → 1455,35 |
} elseif (isset($this->configuration[$layer]['__channels'][$channel][$key])) { |
$ret = $this->configuration[$layer]['__channels'][$channel][$key]; |
} |
if ($key == 'preferred_mirror') { |
if ($ret !== null) { |
$reg = &$this->getRegistry($layer); |
if (is_object($reg)) { |
$chan = &$reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $channel; |
} |
if (!$chan->getMirror($ret) && $chan->getName() != $ret) { |
return $channel; // mirror does not exist |
} |
|
if ($key != 'preferred_mirror') { |
return $ret; |
} |
|
|
if ($ret !== null) { |
$reg = &$this->getRegistry($layer); |
if (is_object($reg)) { |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $channel; |
} |
return $ret; |
|
if (!$chan->getMirror($ret) && $chan->getName() != $ret) { |
return $channel; // mirror does not exist |
} |
} |
if ($channel != $this->getDefaultChannel($layer)) { |
return $channel; // we must use the channel name as the preferred mirror |
// if the user has not chosen an alternate |
} else { |
return $this->getDefaultChannel($layer); |
} |
|
return $ret; |
} |
return $ret; |
} |
|
if ($channel != $this->getDefaultChannel($layer)) { |
return $channel; // we must use the channel name as the preferred mirror |
// if the user has not chosen an alternate |
} |
|
// }}} |
// {{{ set(key, value, [layer]) |
return $this->getDefaultChannel($layer); |
} |
|
/** |
* Set a config value in a specific layer (defaults to 'user'). |
1413,9 → 1502,11 |
if ($key == '__channels') { |
return false; |
} |
|
if (!isset($this->configuration[$layer])) { |
return false; |
} |
|
if ($key == 'default_channel') { |
// can only set this value globally |
$channel = 'pear.php.net'; |
1423,24 → 1514,29 |
$this->_lazyChannelSetup($layer); |
} |
} |
|
if ($key == 'preferred_mirror') { |
if ($channel == '__uri') { |
return false; // can't set the __uri pseudo-channel's mirror |
} |
|
$reg = &$this->getRegistry($layer); |
if (is_object($reg)) { |
$chan = &$reg->getChannel($channel ? $channel : 'pear.php.net'); |
$chan = $reg->getChannel($channel ? $channel : 'pear.php.net'); |
if (PEAR::isError($chan)) { |
return false; |
} |
|
if (!$chan->getMirror($value) && $chan->getName() != $value) { |
return false; // mirror does not exist |
} |
} |
} |
if (empty($this->configuration_info[$key])) { |
|
if (!isset($this->configuration_info[$key])) { |
return false; |
} |
|
extract($this->configuration_info[$key]); |
switch ($type) { |
case 'integer': |
1461,9 → 1557,11 |
break; |
} |
} |
|
if (!$channel) { |
$channel = $this->get('default_channel', null, 'pear.php.net'); |
} |
|
if (!in_array($channel, $this->_channels)) { |
$this->_lazyChannelSetup($layer); |
$reg = &$this->getRegistry($layer); |
1470,56 → 1568,63 |
if ($reg) { |
$channel = $reg->channelName($channel); |
} |
|
if (!in_array($channel, $this->_channels)) { |
return false; |
} |
} |
|
if ($channel != 'pear.php.net') { |
if (in_array($key, $this->_channelConfigInfo)) { |
$this->configuration[$layer]['__channels'][$channel][$key] = $value; |
return true; |
} else { |
return false; |
} |
} else { |
if ($key == 'default_channel') { |
if (!isset($reg)) { |
$reg = &$this->getRegistry($layer); |
if (!$reg) { |
$reg = &$this->getRegistry(); |
} |
|
return false; |
} |
|
if ($key == 'default_channel') { |
if (!isset($reg)) { |
$reg = &$this->getRegistry($layer); |
if (!$reg) { |
$reg = &$this->getRegistry(); |
} |
if ($reg) { |
$value = $reg->channelName($value); |
} |
if (!$value) { |
return false; |
} |
} |
|
if ($reg) { |
$value = $reg->channelName($value); |
} |
|
if (!$value) { |
return false; |
} |
} |
|
$this->configuration[$layer][$key] = $value; |
if ($key == 'php_dir' && !$this->_noRegistry) { |
if (!isset($this->_registry[$layer]) || |
$value != $this->_registry[$layer]->install_dir) { |
$this->_registry[$layer] = &new PEAR_Registry($value); |
$this->_registry[$layer] = new PEAR_Registry($value); |
$this->_regInitialized[$layer] = false; |
$this->_registry[$layer]->setConfig($this); |
$this->_registry[$layer]->setConfig($this, false); |
} |
} |
|
return true; |
} |
|
// }}} |
function _lazyChannelSetup($uselayer = false) |
{ |
if ($this->_noRegistry) { |
return; |
} |
|
$merge = false; |
foreach ($this->_registry as $layer => $p) { |
if ($uselayer && $uselayer != $layer) { |
continue; |
} |
|
if (!$this->_regInitialized[$layer]) { |
if ($layer == 'default' && isset($this->_registry['user']) || |
isset($this->_registry['system'])) { |
1526,10 → 1631,13 |
// only use the default registry if there are no alternatives |
continue; |
} |
|
if (!is_object($this->_registry[$layer])) { |
if ($phpdir = $this->get('php_dir', $layer, 'pear.php.net')) { |
$this->_registry[$layer] = &new PEAR_Registry($phpdir); |
$this->_registry[$layer]->setConfig($this); |
$this->_registry[$layer] = new PEAR_Registry( |
$phpdir, false, false, |
$this->get('metadata_dir', $layer, 'pear.php.net')); |
$this->_registry[$layer]->setConfig($this, false); |
$this->_regInitialized[$layer] = false; |
} else { |
unset($this->_registry[$layer]); |
1536,6 → 1644,7 |
return; |
} |
} |
|
$this->setChannels($this->_registry[$layer]->listChannels(), $merge); |
$this->_regInitialized[$layer] = true; |
$merge = true; |
1542,8 → 1651,7 |
} |
} |
} |
// {{{ setChannels() |
|
|
/** |
* Set the list of channels. |
* |
1557,16 → 1665,19 |
if (!is_array($channels)) { |
return false; |
} |
|
if ($merge) { |
$this->_channels = array_merge($this->_channels, $channels); |
} else { |
$this->_channels = $channels; |
} |
|
foreach ($channels as $channel) { |
$channel = strtolower($channel); |
if ($channel == 'pear.php.net') { |
continue; |
} |
|
foreach ($this->layers as $layer) { |
if (!isset($this->configuration[$layer]['__channels'])) { |
$this->configuration[$layer]['__channels'] = array(); |
1577,12 → 1688,10 |
} |
} |
} |
|
return true; |
} |
|
// }}} |
// {{{ getType(key) |
|
/** |
* Get the type of a config value. |
* |
1602,14 → 1711,10 |
return false; |
} |
|
// }}} |
// {{{ getDocs(key) |
|
/** |
* Get the documentation for a config value. |
* |
* @param string config key |
* |
* @return string documentation string |
* |
* @access public |
1620,16 → 1725,14 |
if (isset($this->configuration_info[$key])) { |
return $this->configuration_info[$key]['doc']; |
} |
|
return false; |
} |
// }}} |
// {{{ getPrompt(key) |
|
/** |
* Get the short documentation for a config value. |
* |
* @param string config key |
* |
* @return string short documentation string |
* |
* @access public |
1640,16 → 1743,14 |
if (isset($this->configuration_info[$key])) { |
return $this->configuration_info[$key]['prompt']; |
} |
|
return false; |
} |
// }}} |
// {{{ getGroup(key) |
|
/** |
* Get the parameter group for a config key. |
* |
* @param string config key |
* |
* @return string parameter group |
* |
* @access public |
1660,12 → 1761,10 |
if (isset($this->configuration_info[$key])) { |
return $this->configuration_info[$key]['group']; |
} |
|
return false; |
} |
|
// }}} |
// {{{ getGroups() |
|
/** |
* Get the list of parameter groups. |
* |
1680,17 → 1779,14 |
foreach ($this->configuration_info as $key => $info) { |
$tmp[$info['group']] = 1; |
} |
|
return array_keys($tmp); |
} |
|
// }}} |
// {{{ getGroupKeys() |
|
/** |
* Get the list of the parameters in a group. |
* |
* @param string $group parameter group |
* |
* @return array list of parameters in $group |
* |
* @access public |
1704,18 → 1800,15 |
$keys[] = $key; |
} |
} |
|
return $keys; |
} |
|
// }}} |
// {{{ getSetValues(key) |
|
/** |
* Get the list of allowed set values for a config value. Returns |
* NULL for config values that are not sets. |
* |
* @param string config key |
* |
* @return array enumerated array of set values, or NULL if the |
* config key is unknown or not a set |
* |
1733,14 → 1826,13 |
if (key($valid_set) === 0) { |
return $valid_set; |
} |
|
return array_keys($valid_set); |
} |
|
return null; |
} |
|
// }}} |
// {{{ getKeys() |
|
/** |
* Get all the current config keys. |
* |
1758,29 → 1850,30 |
$keys = array_merge($keys, $configs); |
} |
} |
|
unset($test['__channels']); |
$keys = array_merge($keys, $test); |
|
} |
return array_keys($keys); |
} |
|
// }}} |
// {{{ remove(key, [layer]) |
|
/** |
* Remove the a config key from a specific config layer. |
* |
* @param string config key |
* |
* @param string (optional) config layer |
* |
* @param string (optional) channel (defaults to default channel) |
* @return bool TRUE on success, FALSE on failure |
* |
* @access public |
*/ |
function remove($key, $layer = 'user') |
function remove($key, $layer = 'user', $channel = null) |
{ |
$channel = $this->getDefaultChannel(); |
if ($channel === null) { |
$channel = $this->getDefaultChannel(); |
} |
|
if ($channel !== 'pear.php.net') { |
if (isset($this->configuration[$layer]['__channels'][$channel][$key])) { |
unset($this->configuration[$layer]['__channels'][$channel][$key]); |
1787,23 → 1880,20 |
return true; |
} |
} |
|
if (isset($this->configuration[$layer][$key])) { |
unset($this->configuration[$layer][$key]); |
return true; |
} |
|
return false; |
} |
|
// }}} |
// {{{ removeLayer(layer) |
|
/** |
* Temporarily remove an entire config layer. USE WITH CARE! |
* |
* @param string config key |
* |
* @param string (optional) config layer |
* |
* @return bool TRUE on success, FALSE on failure |
* |
* @access public |
1814,17 → 1904,14 |
$this->configuration[$layer] = array(); |
return true; |
} |
|
return false; |
} |
|
// }}} |
// {{{ store([layer]) |
|
/** |
* Stores configuration data in a layer. |
* |
* @param string config layer to store |
* |
* @return bool TRUE on success, or PEAR error on failure |
* |
* @access public |
1834,29 → 1921,7 |
return $this->writeConfigFile(null, $layer, $data); |
} |
|
// }}} |
// {{{ toDefault(key) |
|
/** |
* Unset the user-defined value of a config key, reverting the |
* value to the system-defined one. |
* |
* @param string config key |
* |
* @return bool TRUE on success, FALSE on failure |
* |
* @access public |
*/ |
function toDefault($key) |
{ |
trigger_error("PEAR_Config::toDefault() deprecated, use PEAR_Config::remove() instead", E_USER_NOTICE); |
return $this->remove($key, 'user'); |
} |
|
// }}} |
// {{{ definedBy(key) |
|
/** |
* Tells what config layer that gets to define a key. |
* |
* @param string config key |
1881,6 → 1946,7 |
return $layer; |
} |
} |
|
if (isset($this->configuration[$layer][$key])) { |
if ($returnchannel) { |
return array('layer' => $layer, 'channel' => 'pear.php.net'); |
1888,37 → 1954,14 |
return $layer; |
} |
} |
|
return ''; |
} |
|
// }}} |
// {{{ isDefaulted(key) |
|
/** |
* Tells whether a config value has a system-defined value. |
* |
* @param string config key |
* |
* @return bool |
* |
* @access public |
* |
* @deprecated |
*/ |
function isDefaulted($key) |
{ |
trigger_error("PEAR_Config::isDefaulted() deprecated, use PEAR_Config::definedBy() instead", E_USER_NOTICE); |
return $this->definedBy($key) == 'system'; |
} |
|
// }}} |
// {{{ isDefined(key) |
|
/** |
* Tells whether a given key exists as a config value. |
* |
* @param string config key |
* |
* @return bool whether <config key> exists in this object |
* |
* @access public |
1930,17 → 1973,14 |
return true; |
} |
} |
|
return false; |
} |
|
// }}} |
// {{{ isDefinedLayer(key) |
|
/** |
* Tells whether a given config layer exists. |
* |
* @param string config layer |
* |
* @return bool whether <config layer> exists in this object |
* |
* @access public |
1950,9 → 1990,6 |
return isset($this->configuration[$layer]); |
} |
|
// }}} |
// {{{ getLayers() |
|
/** |
* Returns the layers defined (except the 'default' one) |
* |
1965,13 → 2002,10 |
return array_keys($cf); |
} |
|
// }}} |
// {{{ apiVersion() |
function apiVersion() |
{ |
return '1.1'; |
} |
// }}} |
|
/** |
* @return PEAR_Registry |
1978,11 → 2012,7 |
*/ |
function &getRegistry($use = null) |
{ |
if ($use === null) { |
$layer = 'user'; |
} else { |
$layer = $use; |
} |
$layer = $use === null ? 'user' : $use; |
if (isset($this->_registry[$layer])) { |
return $this->_registry[$layer]; |
} elseif ($use === null && isset($this->_registry['system'])) { |
1992,12 → 2022,13 |
} elseif ($use) { |
$a = false; |
return $a; |
} else { |
// only go here if null was passed in |
echo "CRITICAL ERROR: Registry could not be initialized from any value"; |
exit(1); |
} |
|
// only go here if null was passed in |
echo "CRITICAL ERROR: Registry could not be initialized from any value"; |
exit(1); |
} |
|
/** |
* This is to allow customization like the use of installroot |
* @param PEAR_Registry |
2008,13 → 2039,16 |
if ($this->_noRegistry) { |
return false; |
} |
|
if (!in_array($layer, array('user', 'system'))) { |
return false; |
} |
|
$this->_registry[$layer] = &$reg; |
if (is_object($reg)) { |
$this->_registry[$layer]->setConfig($this); |
$this->_registry[$layer]->setConfig($this, false); |
} |
|
return true; |
} |
|
2024,15 → 2058,6 |
} |
|
/** |
* @return PEAR_Remote |
*/ |
function &getRemote() |
{ |
$remote = &new PEAR_Remote($this); |
return $remote; |
} |
|
/** |
* @return PEAR_REST |
*/ |
function &getREST($version, $options = array()) |
2041,7 → 2066,8 |
if (!class_exists($class = 'PEAR_REST_' . $version)) { |
require_once 'PEAR/REST/' . $version . '.php'; |
} |
$remote = &new $class($this, $options); |
|
$remote = new $class($this, $options); |
return $remote; |
} |
|
2054,14 → 2080,12 |
{ |
if (isset($this->_ftp)) { |
return $this->_ftp; |
} else { |
$a = false; |
return $a; |
} |
|
$a = false; |
return $a; |
} |
|
// {{{ _prependPath($path, $prepend) |
|
function _prependPath($path, $prepend) |
{ |
if (strlen($prepend) > 0) { |
2078,7 → 2102,6 |
} |
return $path; |
} |
// }}} |
|
/** |
* @param string|false installation directory to prepend to all _dir variables, or false to |
2097,12 → 2120,12 |
continue; |
} |
$this->_registry[$layer] = |
&new PEAR_Registry($this->get('php_dir', $layer, 'pear.php.net')); |
$this->_registry[$layer]->setConfig($this); |
new PEAR_Registry( |
$this->get('php_dir', $layer, 'pear.php.net'), false, false, |
$this->get('metadata_dir', $layer, 'pear.php.net')); |
$this->_registry[$layer]->setConfig($this, false); |
$this->_regInitialized[$layer] = false; |
} |
} |
} |
} |
|
?> |