/usr/share/php/Config.php is in php-config 1.10.12-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | <?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
// $Id: Config.php 306597 2010-12-24 05:11:09Z aharvey $
require_once('PEAR.php');
require_once('Config/Container.php');
$GLOBALS['CONFIG_TYPES'] =
array(
'apache' => array('Config/Container/Apache.php', 'Config_Container_Apache'),
'genericconf' => array('Config/Container/GenericConf.php', 'Config_Container_GenericConf'),
'inifile' => array('Config/Container/IniFile.php', 'Config_Container_IniFile'),
'inicommented' => array('Config/Container/IniCommented.php', 'Config_Container_IniCommented'),
'phparray' => array('Config/Container/PHPArray.php', 'Config_Container_PHPArray'),
'phpconstants' => array('Config/Container/PHPConstants.php', 'Config_Container_PHPConstants'),
'xml' => array('Config/Container/XML.php', 'Config_Container_XML')
);
/**
* Config
*
* This class allows for parsing and editing of configuration datasources.
* Do not use this class only to read datasources because of the overhead
* it creates to keep track of the configuration structure.
*
* @author Bertrand Mansion <bmansion@mamasam.com>
* @package Config
*/
class Config {
/**
* Datasource
* Can be a file url, a dsn, an object...
* @var mixed
*/
var $datasrc;
/**
* Type of datasource for config
* Ex: IniCommented, Apache...
* @var string
*/
var $configType = '';
/**
* Options for parser
* @var string
*/
var $parserOptions = array();
/**
* Container object
* @var object
*/
var $container;
/**
* Constructor
* Creates a root container
*
* @access public
*/
function Config()
{
$this->container = new Config_Container('section', 'root');
} // end constructor
/**
* Returns true if container is registered
*
* @param string $configType Type of config
* @access public
* @return bool
*/
function isConfigTypeRegistered($configType)
{
return isset($GLOBALS['CONFIG_TYPES'][strtolower($configType)]);
} // end func isConfigTypeRegistered
/**
* Register a new container
*
* @param string $configType Type of config
* @param array|false $configInfo Array of format:
* array('path/to/Name.php',
* 'Config_Container_Class_Name').
*
* If left false, defaults to:
* array('Config/Container/$configType.php',
* 'Config_Container_$configType')
* @access public
* @static
* @author Greg Beaver <cellog@users.sourceforge.net>
* @return true|PEAR_Error true on success
*/
function registerConfigType($configType, $configInfo = false)
{
if (Config::isConfigTypeRegistered($configType)) {
$info = $GLOBALS['CONFIG_TYPES'][strtolower($configType)];
if ($info[0] == $configInfo[0] &&
$info[1] == $configInfo[1]) {
return true;
} else {
return PEAR::raiseError("Config::registerConfigType registration of existing $configType failed.", null, PEAR_ERROR_RETURN);
}
}
if (!is_array($configInfo)) {
// make the normal assumption, that this is a standard config container added in at runtime
$configInfo = array('Config/Container/' . $configType . '.php',
'Config_Container_'. $configType);
}
$file_exists = @include_once($configInfo[0]);
if ($file_exists) {
if (!class_exists($configInfo[1])) {
return PEAR::raiseError("Config::registerConfigType class '$configInfo[1]' not found in $configInfo[0]", null, PEAR_ERROR_RETURN);
}
} else {
return PEAR::raiseError("Config::registerConfigType file $configInfo[0] not found", null, PEAR_ERROR_RETURN);
}
$GLOBALS['CONFIG_TYPES'][strtolower($configType)] = $configInfo;
return true;
} // end func registerConfigType
/**
* Returns the root container for this config object
*
* @access public
* @return object reference to config's root container object
*/
function &getRoot()
{
return $this->container;
} // end func getRoot
/**
* Sets the content of the root Config_container object.
*
* This method will replace the current child of the root
* Config_Container object by the given object.
*
* @param object $rootContainer container to be used as the first child to root
* @access public
* @return mixed true on success or PEAR_Error
*/
function setRoot(&$rootContainer)
{
if (is_object($rootContainer) && strtolower(get_class($rootContainer)) === 'config_container') {
if ($rootContainer->getName() === 'root' && $rootContainer->getType() === 'section') {
$this->container =& $rootContainer;
} else {
$this->container = new Config_Container('section', 'root');
$this->container->addItem($rootContainer);
}
return true;
} else {
return PEAR::raiseError("Config::setRoot only accepts object of Config_Container type.", null, PEAR_ERROR_RETURN);
}
} // end func setRoot
/**
* Parses the datasource contents
*
* This method will parse the datasource given and fill the root
* Config_Container object with other Config_Container objects.
*
* @param mixed $datasrc Datasource to parse
* @param string $configType Type of configuration
* @param array $options Options for the parser
* @access public
* @return mixed PEAR_Error on error or Config_Container object
*/
function &parseConfig($datasrc, $configType, $options = array())
{
$configType = strtolower($configType);
if (!$this->isConfigTypeRegistered($configType)) {
return PEAR::raiseError("Configuration type '$configType' is not registered in Config::parseConfig.", null, PEAR_ERROR_RETURN);
}
$includeFile = $GLOBALS['CONFIG_TYPES'][$configType][0];
$className = $GLOBALS['CONFIG_TYPES'][$configType][1];
include_once($includeFile);
$parser = new $className($options);
$error = $parser->parseDatasrc($datasrc, $this);
if ($error !== true) {
return $error;
}
$this->parserOptions = $parser->options;
$this->datasrc = $datasrc;
$this->configType = $configType;
return $this->container;
} // end func &parseConfig
/**
* Writes the container contents to the datasource.
*
* @param mixed $datasrc Datasource to write to
* @param string $configType Type of configuration
* @param array $options Options for config container
* @access public
* @return mixed PEAR_Error on error or true if ok
*/
function writeConfig($datasrc = null, $configType = null, $options = array())
{
if (empty($datasrc)) {
$datasrc = $this->datasrc;
}
if (empty($configType)) {
$configType = $this->configType;
}
if (empty($options)) {
$options = $this->parserOptions;
}
return $this->container->writeDatasrc($datasrc, $configType, $options);
} // end func writeConfig
} // end class Config
?>
|