示例#1
0
 /**
  * Constructor.
  *
  * @param string file to read user-defined options from
  * @param string file to read system-wide defaults from
  * @param bool   determines whether a registry object "follows"
  *               the value of php_dir (is automatically created
  *               and moved when php_dir is changed)
  * @param bool   if true, fails if configuration files cannot be loaded
  *
  * @access public
  *
  * @see PEAR_Config::singleton
  */
 function PEAR_Config($user_file = '', $system_file = '', $ftp_file = false, $strict = true)
 {
     $this->PEAR();
     PEAR_Installer_Role::initializeConfig($this);
     $sl = DIRECTORY_SEPARATOR;
     if (empty($user_file)) {
         if (OS_WINDOWS) {
             $user_file = PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.ini';
         } else {
             $user_file = getenv('HOME') . $sl . '.pearrc';
         }
     }
     if (empty($system_file)) {
         $system_file = PEAR_CONFIG_SYSCONFDIR . $sl;
         if (OS_WINDOWS) {
             $system_file .= 'pearsys.ini';
         } else {
             $system_file .= 'pear.conf';
         }
     }
     $this->layers = array_keys($this->configuration);
     $this->files['user'] = $user_file;
     $this->files['system'] = $system_file;
     if ($user_file && file_exists($user_file)) {
         $this->pushErrorHandling(PEAR_ERROR_RETURN);
         $this->readConfigFile($user_file, 'user', $strict);
         $this->popErrorHandling();
         if ($this->_errorsFound > 0) {
             return;
         }
     }
     if ($system_file && @file_exists($system_file)) {
         $this->mergeConfigFile($system_file, false, 'system', $strict);
         if ($this->_errorsFound > 0) {
             return;
         }
     }
     if (!$ftp_file) {
         $ftp_file = $this->get('remote_config');
     }
     if ($ftp_file && defined('PEAR_REMOTEINSTALL_OK')) {
         $this->readFTPConfigFile($ftp_file);
     }
     foreach ($this->configuration_info as $key => $info) {
         $this->configuration['default'][$key] = $info['default'];
     }
     $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;
 }
示例#2
0
 /**
  * Constructor.
  *
  * @param string file to read user-defined options from
  * @param string file to read system-wide defaults from
  * @param bool   determines whether a registry object "follows"
  *               the value of php_dir (is automatically created
  *               and moved when php_dir is changed)
  *
  * @access public
  *
  * @see PEAR_Config::singleton
  */
 function PEAR_Config($user_file = '', $system_file = '', $ftp_file = false)
 {
     $this->PEAR();
     PEAR_Installer_Role::initializeConfig($this);
     $sl = DIRECTORY_SEPARATOR;
     if (empty($user_file)) {
         if (OS_WINDOWS) {
             $user_file = PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.ini';
         } else {
             $user_file = getenv('HOME') . $sl . '.pearrc';
         }
     }
     if (empty($system_file)) {
         if (OS_WINDOWS) {
             $system_file = PEAR_CONFIG_SYSCONFDIR . $sl . 'pearsys.ini';
         } else {
             $system_file = PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.conf';
         }
     }
     $this->layers = array_keys($this->configuration);
     $this->files['user'] = $user_file;
     $this->files['system'] = $system_file;
     if ($user_file && @file_exists($user_file)) {
         $this->readConfigFile($user_file);
     }
     if ($system_file && @file_exists($system_file)) {
         $this->mergeConfigFile($system_file, false, 'system');
     }
     if (!$ftp_file) {
         $ftp_file = $this->get('remote_config');
     }
     if ($ftp_file) {
         $this->readFTPConfigFile($ftp_file);
     }
     foreach ($this->configuration_info as $key => $info) {
         $this->configuration['default'][$key] = $info['default'];
     }
     $this->_registry['default'] =& new PEAR_Registry($this->configuration['default']['php_dir']);
     $this->_registry['default']->setConfig($this);
     $this->_regInitialized['default'] = false;
     //$GLOBALS['_PEAR_Config_instance'] = &$this;
 }