pax_global_header00006660000000000000000000000064115336700070014514gustar00rootroot0000000000000052 comment=863151f3a81c16c842c94209e3416d6bcb4cee93 php-config-1.10.12/000077500000000000000000000000001153367000700137105ustar00rootroot00000000000000php-config-1.10.12/Config-1.10.12/000077500000000000000000000000001153367000700157135ustar00rootroot00000000000000php-config-1.10.12/Config-1.10.12/Config.php000066400000000000000000000207351153367000700176400ustar00rootroot00000000000000 | // +----------------------------------------------------------------------+ // // $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 * @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 * @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 ?> php-config-1.10.12/Config-1.10.12/Config/000077500000000000000000000000001153367000700171205ustar00rootroot00000000000000php-config-1.10.12/Config-1.10.12/Config/Container.php000066400000000000000000000644651153367000700215720ustar00rootroot00000000000000 | // +---------------------------------------------------------------------+ // // $Id: Container.php 306597 2010-12-24 05:11:09Z aharvey $ require_once 'Config.php'; /** * Interface for Config containers * * @author Bertrand Mansion * @package Config */ class Config_Container { /** * Container object type * Ex: section, directive, comment, blank * @var string */ var $type; /** * Container object name * @var string */ var $name = ''; /** * Container object content * @var string */ var $content = ''; /** * Container object children * @var array */ var $children = array(); /** * Reference to container object's parent * @var object */ var $parent; /** * Array of attributes for this item * @var array */ var $attributes; /** * Unique id to differenciate nodes * * This is used to compare nodes * Will not be needed anymore when this class will use ZendEngine 2 * * @var int */ var $_id; /** * Constructor * * @param string $type Type of container object * @param string $name Name of container object * @param string $content Content of container object * @param array $attributes Array of attributes for container object */ function Config_Container($type = 'section', $name = '', $content = '', $attributes = null) { $this->type = $type; $this->name = $name; $this->content = $content; $this->attributes = $attributes; $this->parent = null; if (version_compare(PHP_VERSION, '5.0.0', 'gt')) { $this->_id = uniqid($name.$type, true); } else { $this->_id = uniqid(substr($name.$type, 0, 114), true); } } // end constructor /** * Create a child for this item. * @param string $type type of item: directive, section, comment, blank... * @param mixed $item item name * @param string $content item content * @param array $attributes item attributes * @param string $where choose a position 'bottom', 'top', 'after', 'before' * @param object $target needed if you choose 'before' or 'after' for where * @return object reference to new item or Pear_Error */ function &createItem($type, $name, $content, $attributes = null, $where = 'bottom', $target = null) { $item = new Config_Container($type, $name, $content, $attributes); $result =& $this->addItem($item, $where, $target); return $result; } // end func &createItem /** * Adds an item to this item. * @param object $item a container object * @param string $where choose a position 'bottom', 'top', 'after', 'before' * @param object $target needed if you choose 'before' or 'after' in $where * @return mixed reference to added container on success, Pear_Error on error */ function &addItem(&$item, $where = 'bottom', $target = null) { if ($this->type != 'section') { return PEAR::raiseError('Config_Container::addItem must be called on a section type object.', null, PEAR_ERROR_RETURN); } if (is_null($target)) { $target =& $this; } if (strtolower(get_class($target)) != 'config_container') { return PEAR::raiseError('Target must be a Config_Container object in Config_Container::addItem.', null, PEAR_ERROR_RETURN); } switch ($where) { case 'before': $index = $target->getItemIndex(); break; case 'after': $index = $target->getItemIndex()+1; break; case 'top': $index = 0; break; case 'bottom': $index = -1; break; default: return PEAR::raiseError('Use only top, bottom, before or after in Config_Container::addItem.', null, PEAR_ERROR_RETURN); } if (isset($index) && $index >= 0) { array_splice($this->children, $index, 0, 'tmp'); } else { $index = count($this->children); } $this->children[$index] =& $item; $this->children[$index]->parent =& $this; return $item; } // end func addItem /** * Adds a comment to this item. * This is a helper method that calls createItem * * @param string $content Object content * @param string $where Position : 'top', 'bottom', 'before', 'after' * @param object $target Needed when $where is 'before' or 'after' * @return object reference to new item or Pear_Error */ function &createComment($content = '', $where = 'bottom', $target = null) { return $this->createItem('comment', null, $content, null, $where, $target); } // end func &createComment /** * Adds a blank line to this item. * This is a helper method that calls createItem * * @return object reference to new item or Pear_Error */ function &createBlank($where = 'bottom', $target = null) { return $this->createItem('blank', null, null, null, $where, $target); } // end func &createBlank /** * Adds a directive to this item. * This is a helper method that calls createItem * * @param string $name Name of new directive * @param string $content Content of new directive * @param mixed $attributes Directive attributes * @param string $where Position : 'top', 'bottom', 'before', 'after' * @param object $target Needed when $where is 'before' or 'after' * @return object reference to new item or Pear_Error */ function &createDirective($name, $content, $attributes = null, $where = 'bottom', $target = null) { return $this->createItem('directive', $name, $content, $attributes, $where, $target); } // end func &createDirective /** * Adds a section to this item. * * This is a helper method that calls createItem * If the section already exists, it won't create a new one. * It will return reference to existing item. * * @param string $name Name of new section * @param array $attributes Section attributes * @param string $where Position : 'top', 'bottom', 'before', 'after' * @param object $target Needed when $where is 'before' or 'after' * @return object reference to new item or Pear_Error */ function &createSection($name, $attributes = null, $where = 'bottom', $target = null) { return $this->createItem('section', $name, null, $attributes, $where, $target); } // end func &createSection /** * Tries to find the specified item(s) and returns the objects. * * Examples: * $directives =& $obj->getItem('directive'); * $directive_bar_4 =& $obj->getItem('directive', 'bar', null, 4); * $section_foo =& $obj->getItem('section', 'foo'); * * This method can only be called on an object of type 'section'. * Note that root is a section. * This method is not recursive and tries to keep the current structure. * For a deeper search, use searchPath() * * @param string $type Type of item: directive, section, comment, blank... * @param mixed $name Item name * @param mixed $content Find item with this content * @param array $attributes Find item with attribute set to the given value * @param int $index Index of the item in the returned object list. If it is not set, will try to return the last item with this name. * @return mixed reference to item found or false when not found * @see &searchPath() */ function &getItem($type = null, $name = null, $content = null, $attributes = null, $index = -1) { if ($this->type != 'section') { return PEAR::raiseError('Config_Container::getItem must be called on a section type object.', null, PEAR_ERROR_RETURN); } if (!is_null($type)) { $testFields[] = 'type'; } if (!is_null($name)) { $testFields[] = 'name'; } if (!is_null($content)) { $testFields[] = 'content'; } if (!is_null($attributes) && is_array($attributes)) { $testFields[] = 'attributes'; } $itemsArr = array(); $fieldsToMatch = count($testFields); for ($i = 0, $count = count($this->children); $i < $count; $i++) { $match = 0; reset($testFields); foreach ($testFields as $field) { if ($field != 'attributes') { if ($this->children[$i]->$field == ${$field}) { $match++; } } else { // Look for attributes in array $attrToMatch = count($attributes); $attrMatch = 0; foreach ($attributes as $key => $value) { if (isset($this->children[$i]->attributes[$key]) && $this->children[$i]->attributes[$key] == $value) { $attrMatch++; } } if ($attrMatch == $attrToMatch) { $match++; } } } if ($match == $fieldsToMatch) { $itemsArr[] =& $this->children[$i]; } } if ($index >= 0) { if (isset($itemsArr[$index])) { return $itemsArr[$index]; } else { $return = false; return $return; } } else { if ($count = count($itemsArr)) { return $itemsArr[$count-1]; } else { $return = false; return $return; } } } // end func &getItem /** * Finds a node using XPATH like format. * * The search format is an array: * array(item1, item2, item3, ...) * * Each item can be defined as the following: * item = 'string' : will match the container named 'string' * item = array('string', array('name' => 'xyz')) * will match the container name 'string' whose attribute name is equal to "xyz" * For example : * * @param mixed Search path and attributes * * @return mixed Config_Container object, array of Config_Container objects or false on failure. * @access public */ function &searchPath($args) { if ($this->type != 'section') { return PEAR::raiseError('Config_Container::searchPath must be called on a section type object.', null, PEAR_ERROR_RETURN); } $arg = array_shift($args); if (is_array($arg)) { $name = $arg[0]; $attributes = $arg[1]; } else { $name = $arg; $attributes = null; } // find all the matches for first.. $match =& $this->getItem(null, $name, null, $attributes); if (!$match) { $return = false; return $return; } if (!empty($args)) { return $match->searchPath($args); } return $match; } // end func &searchPath /** * Return a child directive's content. * * This method can use two different search approach, depending on * the parameter it is given. If the parameter is an array, it will use * the {@link Config_Container::searchPath()} method. If it is a string, * it will use the {@link Config_Container::getItem()} method. * * Example: * * require_once 'Config.php'; * $ini = new Config(); * $conf =& $ini->parseConfig('/path/to/config.ini', 'inicommented'); * * // Will return the value found at : * // [Database] * // host=localhost * echo $conf->directiveContent(array('Database', 'host'))); * * // Will return the value found at : * // date="dec-2004" * echo $conf->directiveContent('date'); * * * * @param mixed Search path and attributes or a directive name * @param int Index of the item in the returned directive list. * Eventually used if args is a string. * * @return mixed Content of directive or false if not found. * @access public */ function directiveContent($args, $index = -1) { if (is_array($args)) { $item =& $this->searchPath($args); } else { $item =& $this->getItem('directive', $args, null, null, $index); } if ($item) { return $item->getContent(); } return false; } // end func getDirectiveContent /** * Returns how many children this container has * * @param string $type type of children counted * @param string $name name of children counted * @return int number of children found */ function countChildren($type = null, $name = null) { if (is_null($type) && is_null($name)) { return count($this->children); } $count = 0; if (isset($name) && isset($type)) { for ($i = 0, $children = count($this->children); $i < $children; $i++) { if ($this->children[$i]->name === $name && $this->children[$i]->type == $type) { $count++; } } return $count; } if (isset($type)) { for ($i = 0, $children = count($this->children); $i < $children; $i++) { if ($this->children[$i]->type == $type) { $count++; } } return $count; } if (isset($name)) { // Some directives can have the same name for ($i = 0, $children = count($this->children); $i < $children; $i++) { if ($this->children[$i]->name === $name) { $count++; } } return $count; } } // end func &countChildren /** * Deletes an item (section, directive, comment...) from the current object * TODO: recursive remove in sub-sections * @return mixed true if object was removed, false if not, or PEAR_Error if root */ function removeItem() { if ($this->isRoot()) { return PEAR::raiseError('Cannot remove root item in Config_Container::removeItem.', null, PEAR_ERROR_RETURN); } $index = $this->getItemIndex(); if (!is_null($index)) { array_splice($this->parent->children, $index, 1); return true; } return false; } // end func removeItem /** * Returns the item index in its parent children array. * @return int returns int or null if root object */ function getItemIndex() { if (is_object($this->parent)) { // This will be optimized with Zend Engine 2 $pchildren =& $this->parent->children; for ($i = 0, $count = count($pchildren); $i < $count; $i++) { if ($pchildren[$i]->_id == $this->_id) { return $i; } } } return; } // end func getItemIndex /** * Returns the item rank in its parent children array * according to other items with same type and name. * @param bool count items differently by type * @return int returns int or null if root object */ function getItemPosition($byType = true) { if (is_object($this->parent)) { $pchildren =& $this->parent->children; for ($i = 0, $count = count($pchildren); $i < $count; $i++) { if ($pchildren[$i]->name == $this->name) { if ($byType == true) { if ($pchildren[$i]->type == $this->type) { $obj[] =& $pchildren[$i]; } } else { $obj[] =& $pchildren[$i]; } } } for ($i = 0, $count = count($obj); $i < $count; $i++) { if ($obj[$i]->_id == $this->_id) { return $i; } } } return; } // end func getItemPosition /** * Returns the item parent object. * @return object returns reference to parent object or null if root object */ function &getParent() { return $this->parent; } // end func &getParent /** * Returns the item parent object. * @return mixed returns reference to child object or false if child does not exist */ function &getChild($index = 0) { if (!empty($this->children[$index])) { return $this->children[$index]; } else { return false; } } // end func &getChild /** * Set this item's name. * @return void */ function setName($name) { $this->name = $name; } // end func setName /** * Get this item's name. * @return string item's name */ function getName() { return $this->name; } // end func getName /** * Set this item's content. * @return void */ function setContent($content) { $this->content = $content; } // end func setContent /** * Get this item's content. * @return string item's content */ function getContent() { return $this->content; } // end func getContent /** * Set this item's type. * @return void */ function setType($type) { $this->type = $type; } // end func setType /** * Get this item's type. * @return string item's type */ function getType() { return $this->type; } // end func getType /** * Set this item's attributes. * @param array $attributes Array of attributes * @return void */ function setAttributes($attributes) { $this->attributes = $attributes; } // end func setAttributes /** * Set this item's attributes. * @param array $attributes Array of attributes * @return void */ function updateAttributes($attributes) { if (is_array($attributes)) { foreach ($attributes as $key => $value) { $this->attributes[$key] = $value; } } } // end func updateAttributes /** * Get this item's attributes. * @return array item's attributes */ function getAttributes() { return $this->attributes; } // end func getAttributes /** * Get one attribute value of this item * @param string $attribute Attribute key * @return mixed item's attribute value */ function getAttribute($attribute) { if (isset($this->attributes[$attribute])) { return $this->attributes[$attribute]; } return null; } // end func getAttribute /** * Set a children directive content. * This is an helper method calling getItem and addItem or setContent for you. * If the directive does not exist, it will be created at the bottom. * * @param string $name Name of the directive to look for * @param mixed $content New content * @param int $index Index of the directive to set, * in case there are more than one directive * with the same name * @return object newly set directive */ function &setDirective($name, $content, $index = -1) { $item =& $this->getItem('directive', $name, null, null, $index); if ($item === false || PEAR::isError($item)) { // Directive does not exist, will create one unset($item); return $this->createDirective($name, $content, null); } else { // Change existing directive value $item->setContent($content); return $item; } } // end func setDirective /** * Is this item root, in a config container object * @return bool true if item is root */ function isRoot() { if (is_null($this->parent)) { return true; } return false; } // end func isRoot /** * Call the toString methods in the container plugin * @param string $configType Type of configuration used to generate the string * @param array $options Specify special options used by the parser * @return mixed true on success or PEAR_ERROR */ function toString($configType, $options = array()) { $configType = strtolower($configType); if (!isset($GLOBALS['CONFIG_TYPES'][$configType])) { return PEAR::raiseError("Configuration type '$configType' is not registered in Config_Container::toString.", null, PEAR_ERROR_RETURN); } $includeFile = $GLOBALS['CONFIG_TYPES'][$configType][0]; $className = $GLOBALS['CONFIG_TYPES'][$configType][1]; include_once($includeFile); $renderer = new $className($options); return $renderer->toString($this); } // end func toString /** * Returns a key/value pair array of the container and its children. * * Format : section[directive][index] = value * If the container has attributes, it will use '@' and '#' * index is here because multiple directives can have the same name. * * @param bool $useAttr Whether to return the attributes too * @return array */ function toArray($useAttr = true) { $array[$this->name] = array(); switch ($this->type) { case 'directive': if ($useAttr && count($this->attributes) > 0) { $array[$this->name]['#'] = $this->content; $array[$this->name]['@'] = $this->attributes; } else { $array[$this->name] = $this->content; } break; case 'section': if ($useAttr && count($this->attributes) > 0) { $array[$this->name]['@'] = $this->attributes; } if ($count = count($this->children)) { for ($i = 0; $i < $count; $i++) { $newArr = $this->children[$i]->toArray($useAttr); if (!is_null($newArr)) { foreach ($newArr as $key => $value) { if (isset($array[$this->name][$key])) { // duplicate name/type if (!is_array($array[$this->name][$key]) || !isset($array[$this->name][$key][0])) { $old = $array[$this->name][$key]; unset($array[$this->name][$key]); $array[$this->name][$key][0] = $old; } $array[$this->name][$key][] = $value; } else { $array[$this->name][$key] = $value; } } } } } break; default: return null; } return $array; } // end func toArray /** * Writes the configuration to a file * * @param mixed $datasrc Info on datasource such as path to the configuraton file or dsn... * @param string $configType Type of configuration * @param array $options Options for writer * @access public * @return mixed true on success or PEAR_ERROR */ function writeDatasrc($datasrc, $configType, $options = array()) { $configType = strtolower($configType); if (!isset($GLOBALS['CONFIG_TYPES'][$configType])) { return PEAR::raiseError("Configuration type '$configType' is not registered in Config_Container::writeDatasrc.", null, PEAR_ERROR_RETURN); } $includeFile = $GLOBALS['CONFIG_TYPES'][$configType][0]; $className = $GLOBALS['CONFIG_TYPES'][$configType][1]; include_once($includeFile); $writeMethodName = (version_compare(phpversion(), '5', '<')) ? 'writedatasrc' : 'writeDatasrc'; if (in_array($writeMethodName, get_class_methods($className))) { $writer = new $className($options); return $writer->writeDatasrc($datasrc, $this); } // Default behaviour $fp = @fopen($datasrc, 'w'); if ($fp) { $string = $this->toString($configType, $options); $len = strlen($string); @flock($fp, LOCK_EX); @fwrite($fp, $string, $len); @flock($fp, LOCK_UN); @fclose($fp); return true; } else { return PEAR::raiseError('Cannot open datasource for writing.', 1, PEAR_ERROR_RETURN); } } // end func writeDatasrc } // end class Config_Container ?> php-config-1.10.12/Config-1.10.12/Config/Container/000077500000000000000000000000001153367000700210425ustar00rootroot00000000000000php-config-1.10.12/Config-1.10.12/Config/Container/Apache.php000066400000000000000000000144721153367000700227440ustar00rootroot00000000000000 | // +----------------------------------------------------------------------+ // // $Id: Apache.php 203595 2005-12-24 02:34:39Z aashley $ /** * Simple config parser for apache httpd.conf files * A more complex version could handle directives as * associative arrays. * * @author Bertrand Mansion * @package Config */ class Config_Container_Apache { /** * This class options * Not used at the moment * * @var array */ var $options = array(); /** * Constructor * * @access public * @param string $options (optional)Options to be used by renderer */ function Config_Container_Apache($options = array()) { $this->options = $options; } // end constructor /** * Parses the data of the given configuration file * * @access public * @param string $datasrc path to the configuration file * @param object $obj reference to a config object * @return mixed returns a PEAR_ERROR, if error occurs or true if ok */ function &parseDatasrc($datasrc, &$obj) { $return = true; if (!is_readable($datasrc)) { return PEAR::raiseError("Datasource file cannot be read.", null, PEAR_ERROR_RETURN); } $lines = file($datasrc); $n = 0; $lastline = ''; $sections[0] =& $obj->container; foreach ($lines as $line) { $n++; if (!preg_match('/^\s*#/', $line) && preg_match('/^\s*(.*)\s+\\\$/', $line, $match)) { // directive on more than one line $lastline .= $match[1].' '; continue; } if ($lastline != '') { $line = $lastline.trim($line); $lastline = ''; } if (preg_match('/^\s*#+\s*(.*?)\s*$/', $line, $match)) { // a comment $currentSection =& $sections[count($sections)-1]; $currentSection->createComment($match[1]); } elseif (trim($line) == '') { // a blank line $currentSection =& $sections[count($sections)-1]; $currentSection->createBlank(); } elseif (preg_match('/^\s*(\w+)(?:\s+(.*?)|)\s*$/', $line, $match)) { // a directive $currentSection =& $sections[count($sections)-1]; $currentSection->createDirective($match[1], $match[2]); } elseif (preg_match('/^\s*<(\w+)(?:\s+([^>]*)|\s*)>\s*$/', $line, $match)) { // a section opening if (!isset($match[2])) $match[2] = ''; $currentSection =& $sections[count($sections)-1]; $attributes = explode(' ', $match[2]); $sections[] =& $currentSection->createSection($match[1], $attributes); } elseif (preg_match('/^\s*<\/(\w+)\s*>\s*$/', $line, $match)) { // a section closing $currentSection =& $sections[count($sections)-1]; if ($currentSection->name != $match[1]) { return PEAR::raiseError("Section not closed in '$datasrc' at line $n.", null, PEAR_ERROR_RETURN); } array_pop($sections); } else { return PEAR::raiseError("Syntax error in '$datasrc' at line $n.", null, PEAR_ERROR_RETURN); } } return $return; } // end func parseDatasrc /** * Returns a formatted string of the object * @param object $obj Container object to be output as string * @access public * @return string */ function toString(&$obj) { static $deep = -1; $ident = ''; if (!$obj->isRoot()) { // no indent for root $deep++; $ident = str_repeat(' ', $deep); } if (!isset($string)) { $string = ''; } switch ($obj->type) { case 'blank': $string = "\n"; break; case 'comment': $string = $ident.'# '.$obj->content."\n"; break; case 'directive': $string = $ident.$obj->name.' '.$obj->content."\n"; break; case 'section': if (!$obj->isRoot()) { $string = $ident.'<'.$obj->name; if (is_array($obj->attributes) && count($obj->attributes) > 0) { foreach ($obj->attributes as $attr => $val) { $string .= ' '.$val; } } $string .= ">\n"; } if (count($obj->children) > 0) { for ($i = 0; $i < count($obj->children); $i++) { $string .= $this->toString($obj->getChild($i)); } } if (!$obj->isRoot()) { // object is not root $string .= $ident.'name.">\n"; } break; default: $string = ''; } if (!$obj->isRoot()) { $deep--; } return $string; } // end func toString } // end class Config_Container_Apache ?> php-config-1.10.12/Config-1.10.12/Config/Container/GenericConf.php000066400000000000000000000117511153367000700237420ustar00rootroot00000000000000 | // +----------------------------------------------------------------------+ // // $Id: GenericConf.php 306537 2010-12-21 08:09:34Z cweiske $ /** * Config parser for generic .conf files like * htdig.conf... * * @author Bertrand Mansion * @package Config */ class Config_Container_GenericConf { /** * This class options: * Ex: $options['comment'] = '#'; * Ex: $options['equals'] = ':'; * Ex: $options['newline'] = '\\'; * * @var array */ var $options = array(); /** * Constructor * * @access public * @param string $options (optional)Options to be used by renderer */ function Config_Container_GenericConf($options = array()) { if (empty($options['comment'])) { $options['comment'] = '#'; } if (empty($options['equals'])) { $options['equals'] = ':'; } if (empty($options['newline'])) { $options['newline'] = '\\'; } $this->options = $options; } // end constructor /** * Parses the data of the given configuration file * * @access public * @param string $datasrc path to the configuration file * @param object $obj reference to a config object * @return mixed returns a PEAR_ERROR, if error occurs or true if ok */ function &parseDatasrc($datasrc, &$obj) { $return = true; if (!is_readable($datasrc)) { return PEAR::raiseError("Datasource file cannot be read.", null, PEAR_ERROR_RETURN); } $lines = file($datasrc); $n = 0; $lastline = ''; $currentSection =& $obj->container; foreach ($lines as $line) { $n++; if (!preg_match('/^\s*'.$this->options['comment'].'/', $line) && preg_match('/^\s*(.*)'.$this->options['newline'].'\s*$/', $line, $match)) { // directive on more than one line $lastline .= $match[1]; continue; } if ($lastline != '') { $line = $lastline.trim($line); $lastline = ''; } if (preg_match('/^\s*'.$this->options['comment'].'+\s*(.*?)\s*$/', $line, $match)) { // a comment $currentSection->createComment($match[1]); } elseif (preg_match('/^\s*$/', $line)) { // a blank line $currentSection->createBlank(); } elseif (preg_match('/^\s*([\w-]+)\s*'.$this->options['equals'].'\s*((.*?)|)\s*$/', $line, $match)) { // a directive $currentSection->createDirective($match[1], $match[2]); } else { return PEAR::raiseError("Syntax error in '$datasrc' at line $n.", null, PEAR_ERROR_RETURN); } } return $return; } // end func parseDatasrc /** * Returns a formatted string of the object * @param object $obj Container object to be output as string * @access public * @return string */ function toString(&$obj) { $string = ''; switch ($obj->type) { case 'blank': $string = "\n"; break; case 'comment': $string = $this->options['comment'].$obj->content."\n"; break; case 'directive': $string = $obj->name.$this->options['equals'].$obj->content."\n"; break; case 'section': // How to deal with sections ??? if (count($obj->children) > 0) { for ($i = 0; $i < count($obj->children); $i++) { $string .= $this->toString($obj->getChild($i)); } } break; default: $string = ''; } return $string; } // end func toString } // end class Config_Container_GenericConf ?> php-config-1.10.12/Config-1.10.12/Config/Container/IniCommented.php000066400000000000000000000343431153367000700241350ustar00rootroot00000000000000 | // +----------------------------------------------------------------------+ // // $Id: IniCommented.php 306554 2010-12-21 20:04:20Z cweiske $ /** * Config parser for PHP .ini files with comments * * @author Bertrand Mansion * @package Config */ class Config_Container_IniCommented { /** * Options for this class: * - linebreak - Character to use as new line break when serializing * * @var array */ var $options = array( 'linebreak' => "\n" ); /** * Constructor * * @access public * @param string $options (optional)Options to be used by renderer */ function Config_Container_IniCommented($options = array()) { $this->options = array_merge($this->options, $options); } // end constructor /** * Parses the data of the given configuration file * * @access public * @param string $datasrc path to the configuration file * @param object $obj reference to a config object * @return mixed returns a PEAR_ERROR, if error occurs or true if ok */ function &parseDatasrc($datasrc, &$obj) { $return = true; if (!file_exists($datasrc)) { return PEAR::raiseError( 'Datasource file does not exist.', null, PEAR_ERROR_RETURN ); } $lines = file($datasrc); if ($lines === false) { return PEAR::raiseError( 'File could not be read', null, PEAR_ERROR_RETURN ); } $n = 0; $lastline = ''; $currentSection =& $obj->container; foreach ($lines as $line) { $n++; if (preg_match('/^\s*;(.*?)\s*$/', $line, $match)) { // a comment $currentSection->createComment($match[1]); } elseif (preg_match('/^\s*$/', $line)) { // a blank line $currentSection->createBlank(); } elseif (preg_match('/^\s*([a-zA-Z0-9_\-\.\s:]*)\s*=\s*(.*)\s*$/', $line, $match)) { // a directive $values = $this->_quoteAndCommaParser($match[2]); if (PEAR::isError($values)) { return PEAR::raiseError($values); } if (count($values)) { foreach($values as $value) { if ($value[0] == 'normal') { $currentSection->createDirective(trim($match[1]), $value[1]); } if ($value[0] == 'comment') { $currentSection->createComment(substr($value[1], 1)); } } } } elseif (preg_match('/^\s*\[\s*(.*)\s*\]\s*$/', $line, $match)) { // a section $currentSection =& $obj->container->createSection($match[1]); } else { return PEAR::raiseError("Syntax error in '$datasrc' at line $n.", null, PEAR_ERROR_RETURN); } } return $return; } // end func parseDatasrc /** * Quote and Comma Parser for INI files * * This function allows complex values such as: * * * mydirective = "Item, number \"1\"", Item 2 ; "This" is really, really tricky * * @param string $text value of a directive to parse for quotes/multiple values * @return array The array returned contains multiple values, if any (unquoted literals * to be used as is), and a comment, if any. The format of the array is: * *
     * array(array('normal', 'first value'),
     *       array('normal', 'next value'),...
     *       array('comment', '; comment with leading ;'))
     * 
* @author Greg Beaver * @access private */ function _quoteAndCommaParser($text) { $text = trim($text); if ($text == '') { $emptyNode = array(); $emptyNode[0][0] = 'normal'; $emptyNode[0][1] = ''; return $emptyNode; } // tokens $tokens['normal'] = array('"', ';', ','); $tokens['quote'] = array('"', '\\'); $tokens['escape'] = false; // cycle $tokens['after_quote'] = array(',', ';'); // events $events['normal'] = array('"' => 'quote', ';' => 'comment', ',' => 'normal'); $events['quote'] = array('"' => 'after_quote', '\\' => 'escape'); $events['after_quote'] = array(',' => 'normal', ';' => 'comment'); // state stack $stack = array(); // return information $return = array(); $returnpos = 0; $returntype = 'normal'; // initialize array_push($stack, 'normal'); $pos = 0; // position in $text do { $char = $text{$pos}; $state = $this->_getQACEvent($stack); if ($tokens[$state]) { if (in_array($char, $tokens[$state])) { switch($events[$state][$char]) { case 'quote' : if ($state == 'normal' && isset($return[$returnpos]) && !empty($return[$returnpos][1])) { return PEAR::raiseError( 'invalid ini syntax, quotes cannot follow' . " text '$text'", null, PEAR_ERROR_RETURN ); } if ($returnpos >= 0 && isset($return[$returnpos])) { // trim any unnecessary whitespace in earlier entries $return[$returnpos][1] = trim($return[$returnpos][1]); } else { $returnpos++; } $return[$returnpos] = array('normal', ''); array_push($stack, 'quote'); continue 2; break; case 'comment' : // comments go to the end of the line, so we are done $return[++$returnpos] = array('comment', substr($text, $pos)); return $return; break; case 'after_quote' : array_push($stack, 'after_quote'); break; case 'escape' : // don't save the first slash array_push($stack, 'escape'); continue 2; break; case 'normal' : // start a new segment if ($state == 'normal') { $returnpos++; continue 2; } else { while ($state != 'normal') { array_pop($stack); $state = $this->_getQACEvent($stack); } $returnpos++; } break; default : PEAR::raiseError( "::_quoteAndCommaParser oops, state missing", null, PEAR_ERROR_DIE ); break; } } else { if ($state != 'after_quote') { if (!isset($return[$returnpos])) { $return[$returnpos] = array('normal', ''); } // add this character to the current ini segment if // non-empty, or if in a quote if ($state == 'quote') { $return[$returnpos][1] .= $char; } elseif (!empty($return[$returnpos][1]) || (empty($return[$returnpos][1]) && trim($char) != '')) { if (!isset($return[$returnpos])) { $return[$returnpos] = array('normal', ''); } $return[$returnpos][1] .= $char; if (strcasecmp('true', $return[$returnpos][1]) == 0) { $return[$returnpos][1] = '1'; } elseif (strcasecmp('false', $return[$returnpos][1]) == 0) { $return[$returnpos][1] = ''; } } } else { if (trim($char) != '') { return PEAR::raiseError( 'invalid ini syntax, text after a quote' . " not allowed '$text'", null, PEAR_ERROR_RETURN ); } } } } else { // no tokens, so add this one and cycle to previous state $return[$returnpos][1] .= $char; array_pop($stack); } } while (++$pos < strlen($text)); return $return; } // end func _quoteAndCommaParser /** * Retrieve the state off of a state stack for the Quote and Comma Parser * @param array $stack The parser state stack * @author Greg Beaver * @access private */ function _getQACEvent($stack) { return array_pop($stack); } // end func _getQACEvent /** * Returns a formatted string of the object * @param object $obj Container object to be output as string * @access public * @return string */ function toString(&$obj) { static $childrenCount, $commaString; if (!isset($string)) { $string = ''; } switch ($obj->type) { case 'blank': $string = $this->options['linebreak']; break; case 'comment': $string = ';'.$obj->content . $this->options['linebreak']; break; case 'directive': $count = $obj->parent->countChildren('directive', $obj->name); $content = $obj->content; if ($content === false) { $content = '0'; } elseif ($content === true) { $content = '1'; } elseif (strlen(trim($content)) < strlen($content) || strpos($content, ',') !== false || strpos($content, ';') !== false || strpos($content, '=') !== false || strpos($content, '"') !== false || strpos($content, '%') !== false || strpos($content, '~') !== false || strpos($content, '!') !== false || strpos($content, '|') !== false || strpos($content, '&') !== false || strpos($content, '(') !== false || strpos($content, ')') !== false || $content === 'none') { $content = '"'.addslashes($content).'"'; } if ($count > 1) { // multiple values for a directive are separated by a comma if (isset($childrenCount[$obj->name])) { $childrenCount[$obj->name]++; } else { $childrenCount[$obj->name] = 0; $commaString[$obj->name] = $obj->name.' = '; } if ($childrenCount[$obj->name] == $count-1) { // Clean the static for future calls to toString $string .= $commaString[$obj->name] . $content . $this->options['linebreak']; unset($childrenCount[$obj->name]); unset($commaString[$obj->name]); } else { $commaString[$obj->name] .= $content.', '; } } else { $string = $obj->name.' = '.$content . $this->options['linebreak']; } break; case 'section': if (!$obj->isRoot()) { $string = '[' . $obj->name . ']' . $this->options['linebreak']; } if (count($obj->children) > 0) { for ($i = 0; $i < count($obj->children); $i++) { $string .= $this->toString($obj->getChild($i)); } } break; default: $string = ''; } return $string; } // end func toString } // end class Config_Container_IniCommented ?> php-config-1.10.12/Config-1.10.12/Config/Container/IniFile.php000066400000000000000000000156441153367000700231040ustar00rootroot00000000000000 * @license http://www.php.net/license PHP License * @link http://pear.php.net/package/Config */ /** * Config parser for PHP .ini files * Faster because it uses parse_ini_file() but get rid of comments, * quotes, types and converts On, Off, True, False, Yes, No to 0 and 1. * * Empty lines and comments are not preserved. * * @category Configuration * @package Config * @author Bertrand Mansion * @license http://www.php.net/license PHP License * @link http://pear.php.net/package/Config */ class Config_Container_IniFile { /** * This class options * Not used at the moment * * @var array */ var $options = array(); /** * Constructor * * @param string $options (optional)Options to be used by renderer * * @access public */ function Config_Container_IniFile($options = array()) { $this->options = $options; } // end constructor /** * Parses the data of the given configuration file * * @param string $datasrc path to the configuration file * @param object &$obj reference to a config object * * @return mixed Returns a PEAR_ERROR, if error occurs or true if ok * * @access public */ function &parseDatasrc($datasrc, &$obj) { $return = true; if (!file_exists($datasrc)) { return PEAR::raiseError( "Datasource file does not exist.", null, PEAR_ERROR_RETURN ); } $currentSection =& $obj->container; $confArray = parse_ini_file($datasrc, true); if (!$confArray) { return PEAR::raiseError( "File '$datasrc' does not contain configuration data.", null, PEAR_ERROR_RETURN ); } foreach ($confArray as $key => $value) { if (is_array($value)) { $currentSection =& $obj->container->createSection($key); foreach ($value as $directive => $content) { // try to split the value if comma found if (!is_array($content) && strpos($content, '"') === false) { $values = preg_split('/\s*,\s+/', $content); if (count($values) > 1) { foreach ($values as $k => $v) { $currentSection->createDirective($directive, $v); } } else { $currentSection->createDirective($directive, $content); } } else { $currentSection->createDirective($directive, $content); } } } else { $currentSection->createDirective($key, $value); } } return $return; } // end func parseDatasrc /** * Returns a formatted string of the object * * @param object &$obj Container object to be output as string * * @return string * * @access public */ function toString(&$obj) { static $childrenCount, $commaString; if (!isset($string)) { $string = ''; } switch ($obj->type) { case 'blank': $string = "\n"; break; case 'comment': $string = ';'.$obj->content."\n"; break; case 'directive': $count = $obj->parent->countChildren('directive', $obj->name); $content = $obj->content; if (!is_array($content)) { $content = $this->contentToString($content); if ($count > 1) { // multiple values for a directive are separated by a comma if (isset($childrenCount[$obj->name])) { $childrenCount[$obj->name]++; } else { $childrenCount[$obj->name] = 0; $commaString[$obj->name] = $obj->name.'='; } if ($childrenCount[$obj->name] == $count-1) { // Clean the static for future calls to toString $string .= $commaString[$obj->name].$content."\n"; unset($childrenCount[$obj->name]); unset($commaString[$obj->name]); } else { $commaString[$obj->name] .= $content.', '; } } else { $string = $obj->name.'='.$content."\n"; } } else { //array $string = ''; $n = 0; foreach ($content as $contentKey => $contentValue) { if (is_integer($contentKey) && $contentKey == $n) { $stringKey = ''; ++$n; } else { $stringKey = $contentKey; } $string .= $obj->name . '[' . $stringKey . ']=' . $this->contentToString($contentValue) . "\n"; } } break; case 'section': if (!$obj->isRoot()) { $string = '['.$obj->name."]\n"; } if (count($obj->children) > 0) { for ($i = 0; $i < count($obj->children); $i++) { $string .= $this->toString($obj->getChild($i)); } } break; default: $string = ''; } return $string; } // end func toString /** * Converts a given content variable to a string that can * be used as value in a ini file * * @param mixed $content Value * * @return string $content String to be used as ini value */ function contentToString($content) { if ($content === false) { $content = '0'; } else if ($content === true) { $content = '1'; } else if (strlen(trim($content)) < strlen($content) || strpos($content, ',') !== false || strpos($content, ';') !== false || strpos($content, '=') !== false || strpos($content, '"') !== false || strpos($content, '%') !== false || strpos($content, '~') !== false || strpos($content, '!') !== false || strpos($content, '|') !== false || strpos($content, '&') !== false || strpos($content, '(') !== false || strpos($content, ')') !== false || $content === 'none' ) { $content = '"'.addslashes($content).'"'; } return $content; } } // end class Config_Container_IniFile ?> php-config-1.10.12/Config-1.10.12/Config/Container/PHPArray.php000066400000000000000000000234761153367000700232150ustar00rootroot00000000000000 | // +----------------------------------------------------------------------+ // // $Id: PHPArray.php 306488 2010-12-20 08:45:09Z cweiske $ /** * Config parser for common PHP configuration array * such as found in the horde project. * * Options expected is: * 'name' => 'conf' * Name of the configuration array. * Default is $conf[]. * 'useAttr' => true * Whether we render attributes * * @author Bertrand Mansion * @package Config */ class Config_Container_PHPArray { /** * This class options: * - name of the config array to parse/output * Ex: $options['name'] = 'myconf'; * - Whether to add attributes to the array * Ex: $options['useAttr'] = false; * - Whether to treat numbered arrays as duplicates of their parent directive * or as individual directives * Ex: $options['duplicateDirectives'] = false; * * @var array */ var $options = array('name' => 'conf', 'useAttr' => true, 'duplicateDirectives' => true); /** * Constructor * * @access public * @param string $options Options to be used by renderer */ function Config_Container_PHPArray($options = array()) { foreach ($options as $key => $value) { $this->options[$key] = $value; } } // end constructor /** * Parses the data of the given configuration file * * @access public * @param string $datasrc path to the configuration file * @param object $obj reference to a config object * @return mixed returns a PEAR_ERROR, if error occurs or true if ok */ function &parseDatasrc($datasrc, &$obj) { $return = true; if (empty($datasrc)) { return PEAR::raiseError("Datasource file path is empty.", null, PEAR_ERROR_RETURN); } if (is_array($datasrc)) { $this->_parseArray($datasrc, $obj->container); } else { if (!file_exists($datasrc)) { return PEAR::raiseError("Datasource file does not exist.", null, PEAR_ERROR_RETURN); } else { include($datasrc); if (!isset(${$this->options['name']}) || !is_array(${$this->options['name']})) { return PEAR::raiseError("File '$datasrc' does not contain a required '".$this->options['name']."' array.", null, PEAR_ERROR_RETURN); } } $this->_parseArray(${$this->options['name']}, $obj->container); } return $return; } // end func parseDatasrc /** * Parses the PHP array recursively * @param array $array array values from the config file * @param object $container reference to the container object * @access private * @return void */ function _parseArray($array, &$container) { foreach ($array as $key => $value) { switch ((string)$key) { case '@': $container->setAttributes($value); break; case '#': $container->setType('directive'); $container->setContent($value); break; default: if (is_array($value)) { if ($this->options['duplicateDirectives'] == true //speed (first/one key is numeric) && is_integer(key($value)) //accuracy (all keys are numeric) && 1 == count(array_unique(array_map('is_numeric', array_keys($value)))) ) { foreach ($value as $nestedValue) { if (is_array($nestedValue)) { $section =& $container->createSection($key); $this->_parseArray($nestedValue, $section); } else { $container->createDirective($key, $nestedValue); } } } else { $section =& $container->createSection($key); $this->_parseArray($value, $section); } } else { $container->createDirective($key, $value); } } } } // end func _parseArray /** * Returns a formatted string of the object * @param object $obj Container object to be output as string * @access public * @return string */ function toString(&$obj) { if (!isset($string)) { $string = ''; } switch ($obj->type) { case 'blank': $string .= "\n"; break; case 'comment': $string .= '// '.$obj->content."\n"; break; case 'directive': $attrString = ''; $parentString = $this->_getParentString($obj); $attributes = $obj->getAttributes(); if ($this->options['useAttr'] && is_array($attributes) && count($attributes) > 0) { // Directive with attributes '@' and value '#' $string .= $parentString."['#']"; foreach ($attributes as $attr => $val) { $attrString .= $parentString."['@']" ."['".$attr."'] = '".addcslashes($val, "\\'")."';\n"; } } else { $string .= $parentString; } $string .= ' = '; if (is_string($obj->content)) { $string .= "'".addcslashes($obj->content, "\\'")."'"; } elseif (is_int($obj->content) || is_float($obj->content)) { $string .= $obj->content; } elseif (is_bool($obj->content)) { $string .= ($obj->content) ? 'true' : 'false'; } elseif ($obj->content === null) { $string .= 'null'; } $string .= ";\n"; $string .= $attrString; break; case 'section': $attrString = ''; $attributes = $obj->getAttributes(); if ($this->options['useAttr'] && is_array($attributes) && count($attributes) > 0) { $parentString = $this->_getParentString($obj); foreach ($attributes as $attr => $val) { $attrString .= $parentString."['@']" ."['".$attr."'] = '".addcslashes($val, "\\'")."';\n"; } } $string .= $attrString; if ($count = count($obj->children)) { for ($i = 0; $i < $count; $i++) { $string .= $this->toString($obj->getChild($i)); } } break; default: $string = ''; } return $string; } // end func toString /** * Returns a formatted string of the object parents * @access private * @return string */ function _getParentString(&$obj) { $string = ''; if (!$obj->isRoot()) { $string = is_int($obj->name) ? "[".$obj->name."]" : "['".$obj->name."']"; $string = $this->_getParentString($obj->parent).$string; $count = $obj->parent->countChildren(null, $obj->name); if ($count > 1) { $string .= '['.$obj->getItemPosition(false).']'; } } else { if (empty($this->options['name'])) { $string .= '$'.$obj->name; } else { $string .= '$'.$this->options['name']; } } return $string; } // end func _getParentString /** * Writes the configuration to a file * * @param mixed datasrc info on datasource such as path to the configuraton file * @param string configType (optional)type of configuration * @access public * @return string */ function writeDatasrc($datasrc, &$obj) { $fp = @fopen($datasrc, 'w'); if ($fp) { $string = "toString($obj) ."?>"; // php-config-1.10.12/Config-1.10.12/Config/Container/PHPConstants.php000066400000000000000000000143551153367000700241070ustar00rootroot00000000000000 * @license http://www.php.net/license PHP License * @version SVN: $Id: PHPConstants.php 306571 2010-12-22 06:50:39Z cweiske $ * @link http://pear.php.net/package/Config */ require_once 'Config/Container.php'; /** * Config parser for PHP constant files * * @category Configuration * @package Config * @author Phillip Oertel * @license http://www.php.net/license PHP License * @link http://pear.php.net/package/Config */ class Config_Container_PHPConstants extends Config_Container { /** * Valid config options: * - "lowercase" - boolean - config names are lowercased when reading them * * @var array */ var $options = array( 'lowercase' => false ); /** * Constructor * * @param string $options (optional)Options to be used by renderer * * @access public */ function Config_Container_PHPConstants($options = array()) { $this->options = array_merge($this->options, $options); } // end constructor /** * Parses the data of the given configuration file * * @param string $datasrc Path to the configuration file * @param object &$obj Reference to a config object * * @return mixed PEAR_ERROR, if error occurs or true if ok * * @access public */ function &parseDatasrc($datasrc, &$obj) { $return = true; if (!file_exists($datasrc)) { return PEAR::raiseError( 'Datasource file does not exist.', null, PEAR_ERROR_RETURN ); } $fileContent = file_get_contents($datasrc, true); if (!$fileContent) { return PEAR::raiseError( "File '$datasrc' could not be read.", null, PEAR_ERROR_RETURN ); } $rows = explode("\n", $fileContent); for ($i=0, $max=count($rows); $i<$max; $i++) { $line = $rows[$i]; //blanks? // sections if (preg_match("/^\/\/\s*$/", $line)) { preg_match("/^\/\/\s*(.+)$/", $rows[$i+1], $matches); $obj->container->createSection(trim($matches[1])); $i += 2; continue; } // comments if (preg_match("/^\/\/\s*(.+)$/", $line, $matches) || preg_match("/^#\s*(.+)$/", $line, $matches) ) { $obj->container->createComment(trim($matches[1])); continue; } // directives $regex = "/^\s*define\s*\('([A-Z1-9_]+)',\s*'*(.[^\']*)'*\)/"; preg_match($regex, $line, $matches); if (!empty($matches)) { $name = trim($matches[1]); if ($this->options['lowercase']) { $name = strtolower($name); } $obj->container->createDirective( $name, trim($matches[2]) ); } } return $return; } // end func parseDatasrc /** * Returns a formatted string of the object * * @param object &$obj Container object to be output as string * * @return string * * @access public */ function toString(&$obj) { $string = ''; switch ($obj->type) { case 'blank': $string = "\n"; break; case 'comment': $string = '// '.$obj->content."\n"; break; case 'directive': $content = $obj->content; // don't quote numeric values, true/false and constants if (is_bool($content)) { $content = var_export($content, true); } else if (!is_numeric($content) && !in_array($content, array('false', 'true')) && !preg_match('/^[A-Z_]+$/', $content) ) { $content = "'" . str_replace("'", '\\\'', $content) . "'"; } $string = 'define(' . '\'' . strtoupper($obj->name) . '\'' . ', ' . $content . ');' . chr(10); break; case 'section': if (!$obj->isRoot()) { $string = chr(10); $string .= '//'.chr(10); $string .= '// '.$obj->name.chr(10); $string .= '//'.chr(10); } if (count($obj->children) > 0) { for ($i = 0, $max = count($obj->children); $i < $max; $i++) { $string .= $this->toString($obj->getChild($i)); } } break; default: $string = ''; } return $string; } // end func toString /** * Writes the configuration to a file * * @param mixed $datasrc Info on datasource such as path to the file * @param string &$obj Configuration object to write * * @return mixed PEAR_Error on failure or boolean true if all went well * * @access public */ function writeDatasrc($datasrc, &$obj) { $fp = @fopen($datasrc, 'w'); if (!$fp) { return PEAR::raiseError( 'Cannot open datasource for writing.', 1, PEAR_ERROR_RETURN ); } $string = "toString($obj); $string .= "\n?>"; // php-config-1.10.12/Config-1.10.12/Config/Container/XML.php000066400000000000000000000217161153367000700222220ustar00rootroot00000000000000 | // +----------------------------------------------------------------------+ // // $Id: XML.php 203592 2005-12-24 02:24:30Z aashley $ require_once('XML/Parser.php'); require_once('XML/Util.php'); /** * Config parser for XML Files * * @author Bertrand Mansion * @package Config */ class Config_Container_XML extends XML_Parser { /** * Deep level used for indentation * * @var int * @access private */ var $_deep = -1; /** * This class options: * version (1.0) : XML version * encoding (ISO-8859-1) : XML content encoding * name : like in phparray, name of your config global entity * indent : char used for indentation * linebreak : char used for linebreak * addDecl : whether to add the xml declaration at beginning or not * useAttr : whether to use the attributes * isFile : whether the given content is a file or an XML string * useCData : whether to surround data with * * @var array */ var $options = array('version' => '1.0', 'encoding' => 'ISO-8859-1', 'name' => '', 'indent' => ' ', 'linebreak' => "\n", 'addDecl' => true, 'useAttr' => true, 'isFile' => true, 'useCData' => false); /** * Container objects * * @var array */ var $containers = array(); /** * Constructor * * @access public * @param string $options Options to be used by renderer * version : (1.0) XML version * encoding : (ISO-8859-1) XML content encoding * name : like in phparray, name of your config global entity * indent : char used for indentation * linebreak : char used for linebreak * addDecl : whether to add the xml declaration at beginning or not * useAttr : whether to use the attributes * isFile : whether the given content is a file or an XML string */ function Config_Container_XML($options = array()) { foreach ($options as $key => $value) { $this->options[$key] = $value; } } // end constructor /** * Parses the data of the given configuration file * * @access public * @param string $datasrc path to the configuration file * @param object $obj reference to a config object * @return mixed returns a PEAR_ERROR, if error occurs or true if ok */ function &parseDatasrc($datasrc, &$obj) { $err = true; $this->folding = false; $this->cdata = null; $this->XML_Parser($this->options['encoding'], 'event'); $this->containers[0] =& $obj->container; if (is_string($datasrc)) { if ($this->options['isFile']) { $err = $this->setInputFile($datasrc); if (PEAR::isError($err)) { return $err; } $err = $this->parse(); } else { $err = $this->parseString($datasrc, true); } } else { $this->setInput($datasrc); $err = $this->parse(); } return $err; } // end func parseDatasrc /** * Handler for the xml-data * * @param mixed $xp ignored * @param string $elem name of the element * @param array $attribs attributes for the generated node * * @access private */ function startHandler($xp, $elem, &$attribs) { $container =& new Config_Container('section', $elem, null, $attribs); $this->containers[] =& $container; return null; } // end func startHandler /** * Handler for the xml-data * * @param mixed $xp ignored * @param string $elem name of the element * * @access private */ function endHandler($xp, $elem) { $count = count($this->containers); $container =& $this->containers[$count-1]; $currentSection =& $this->containers[$count-2]; if (count($container->children) == 0) { $container->setType('directive'); $container->setContent(trim($this->cdata)); } $currentSection->addItem($container); array_pop($this->containers); $this->cdata = null; return null; } // end func endHandler /* * The xml character data handler * * @param mixed $xp ignored * @param string $data PCDATA between tags * * @access private */ function cdataHandler($xp, $cdata) { $this->cdata .= $cdata; } // end func cdataHandler /** * Returns a formatted string of the object * @param object $obj Container object to be output as string * @access public * @return string */ function toString(&$obj) { $indent = ''; if (!$obj->isRoot()) { // no indent for root $this->_deep++; $indent = str_repeat($this->options['indent'], $this->_deep); } else { // Initialize string with xml declaration $string = ''; if ($this->options['addDecl']) { $string .= XML_Util::getXMLDeclaration($this->options['version'], $this->options['encoding']); $string .= $this->options['linebreak']; } if (!empty($this->options['name'])) { $string .= '<'.$this->options['name'].'>'.$this->options['linebreak']; $this->_deep++; $indent = str_repeat($this->options['indent'], $this->_deep); } } if (!isset($string)) { $string = ''; } switch ($obj->type) { case 'directive': $attributes = ($this->options['useAttr']) ? $obj->attributes : array(); $string .= $indent.XML_Util::createTag($obj->name, $attributes, $obj->content, null, ($this->options['useCData'] ? XML_UTIL_CDATA_SECTION : XML_UTIL_REPLACE_ENTITIES)); $string .= $this->options['linebreak']; break; case 'comment': $string .= $indent.''; $string .= $this->options['linebreak']; break; case 'section': if (!$obj->isRoot()) { $string = $indent.'<'.$obj->name; $string .= ($this->options['useAttr']) ? XML_Util::attributesToString($obj->attributes) : ''; } if ($children = count($obj->children)) { if (!$obj->isRoot()) { $string .= '>'.$this->options['linebreak']; } for ($i = 0; $i < $children; $i++) { $string .= $this->toString($obj->getChild($i)); } } if (!$obj->isRoot()) { if ($children) { $string .= $indent.'name.'>'.$this->options['linebreak']; } else { $string .= '/>'.$this->options['linebreak']; } } else { if (!empty($this->options['name'])) { $string .= 'options['name'].'>'.$this->options['linebreak']; } } break; default: $string = ''; } if (!$obj->isRoot()) { $this->_deep--; } return $string; } // end func toString } // end class Config_Container_XML ?> php-config-1.10.12/Config-1.10.12/docs/000077500000000000000000000000001153367000700166435ustar00rootroot00000000000000php-config-1.10.12/Config-1.10.12/docs/Apache.php000066400000000000000000000031371153367000700205410ustar00rootroot00000000000000 * @package Config */ // $Id: Apache.php 120908 2003-03-22 17:44:12Z mansion $ require_once('Config.php'); $datasrc = '/path/to/httpd.conf'; $conf = new Config(); $content =& $conf->parseConfig($datasrc, 'apache'); if (PEAR::isError($content)) { die($content->getMessage()); } // adding a new virtual-host $content->createBlank(); $content->createComment('My virtual host'); $content->createBlank(); $vhost =& $content->createSection('VirtualHost', array('127.0.0.1:82')); $vhost->createDirective('DocumentRoot', '/usr/share/www'); $vhost->createDirective('ServerName', 'www.mamasam.com'); $location =& $vhost->createSection('Location', array('/admin')); $location->createDirective('AuthType', 'basic'); $location->createDirective('Require', 'group admin'); // adding some directives Listen if ($listen =& $content->getItem('directive', 'Listen')) { $res =& $content->createDirective('Listen', '82', null, 'after', $listen); } else { $listen =& $content->createDirective('Listen', '81', null, 'bottom'); if (PEAR::isError($listen)) { die($listen->getMessage()); } $content->createDirective('Listen', '82', null, 'after', $listen); } echo '
'.htmlspecialchars($content->toString('apache')).'
'; // Writing the files /* if (!PEAR::isError($write = $conf->writeConfig('/tmp/httpd.conf', 'apache'))) { echo 'done writing config
'; } else { die($write->getMessage()); } if ($vhost->writeDatasrc('/tmp/vhost.conf', 'apache')) { echo 'done writing vhost
'; } */ ?>php-config-1.10.12/Config-1.10.12/docs/IniCommented.php000066400000000000000000000012601153367000700217260ustar00rootroot00000000000000 * @package Config */ // $Id: IniCommented.php 203590 2005-12-24 02:16:58Z aashley $ require_once('Config.php'); $datasrc = '/usr/local/php5/lib/php.ini'; $phpIni = new Config(); $root =& $phpIni->parseConfig($datasrc, 'inicommented'); if (PEAR::isError($root)) { die($root->getMessage()); } // Convert your ini file to a php array config echo '
'.$root->toString('phparray', array('name' => 'php_ini')).'
'; ?> php-config-1.10.12/Config-1.10.12/docs/IniFromScratch.php000066400000000000000000000047601153367000700222360ustar00rootroot00000000000000 * @package Config */ // $Id: IniFromScratch.php 120857 2003-03-21 18:04:21Z mansion $ require_once('Config.php'); // Creates a PHPArray config with attributes, from scratch $dsn = array('type' => 'mysql', 'host' => 'localhost', 'user' => 'mamasam', 'pass' => 'foobar'); $c = new Config_Container('section', 'root'); $c->createComment('DB Config'); $db =& $c->createSection('DB', $dsn); $fields =& $db->createSection('fields'); $fields->createDirective('username', 'USERNAME', array('type' => 'varchar', 'size' => 32)); $fields->createDirective('password', 'PASSWD', array('type' => 'varchar', 'size' => 32)); $c->createBlank(); $c->createComment('Support config'); $c->createDirective('support', 'See my wishlist...'); echo '
'. $c->toString('phparray') .'
'; unset($c); // Parses and writes an existing php array $conf $conf['storage']['driver'] = 'sql'; $conf['storage']['params']['phptype'] = 'mysql'; $conf['storage']['params']['hostspec'] = 'localhost'; $conf['storage']['params']['username'] = 'mamasam'; $conf['storage']['params']['password'] = 'foobar'; $conf['menu']['apps'] = array('imp', 'turba'); $conf['stdcontent']['para'][0] = 'This is really cool !'; $conf['stdcontent']['para'][1] = 'It just rocks...'; $c = new Config(); $root =& $c->parseConfig($conf, 'phparray'); $storage =& $root->getItem('section', 'storage'); $storage->removeItem(); $root->addItem($storage); echo '
'. $root->toString('phparray', array('name' => 'test')) .'
'; if ($c->writeConfig('/tmp/Config_Test.php', 'phparray', array('name' => 'test')) === true) { echo 'Config written into /tmp/Config_Test.php'; } // Making a php ini file with $storage only $ini = new Config(); $iniRoot =& $ini->getRoot(); $iniRoot->addItem($storage); $comment =& new Config_Container('comment', null, 'This is the php ini version of storage'); $iniRoot->addItem($comment, 'top'); $iniRoot->createBlank('after', $comment); echo '
'. $iniRoot->toString('inicommented') .'
'; // Gonna make an array with it echo '
'; var_dump($iniRoot->toArray()); echo '
'; // Now, I'll parse you php.ini file and make it a php array $phpIni = new Config(); $phpIni->parseConfig('/usr/local/lib/php.ini', 'inifile'); $root =& $phpIni->getRoot(); echo '
'.$root->toString('phparray', array('name' => 'php_ini')).'
'; ?>php-config-1.10.12/Config-1.10.12/test/000077500000000000000000000000001153367000700166725ustar00rootroot00000000000000php-config-1.10.12/Config-1.10.12/test/bug10010.phpt000066400000000000000000000021531153367000700207270ustar00rootroot00000000000000--TEST-- regression test for bug #10010 --FILE-- 'bar', 'aMonths' => array( 1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December',) ); $c = new Config(); $root = & $c->parseConfig($aTrans, 'phparray', array('duplicateDirectives' => false)); $filename = './bug10010-output.php'; $result = $c->writeConfig($filename, 'phparray', array('name' => 'words')); include($filename); print_r($words) ?> --CLEAN-- --EXPECT-- Array ( [foo] => bar [aMonths] => Array ( [1] => January [2] => February [3] => March [4] => April [5] => May [6] => June [7] => July [8] => August [9] => September [10] => October [11] => November [12] => December ) ) php-config-1.10.12/Config-1.10.12/test/bug10185.phpt000066400000000000000000000027341153367000700207510ustar00rootroot00000000000000--TEST-- regression test for bug #10185 --FILE-- s %b" common'.PHP_EOL; $conf .= ''.PHP_EOL; $conf .= ' CustomLog "/foo/bar/access.log" common'.PHP_EOL; $conf .= ''.PHP_EOL; $conf .= ''.PHP_EOL; $conf .= ' CustomLog "\foo\bar\access.log" common'.PHP_EOL; $conf .= ''.PHP_EOL; $conf .= ''.PHP_EOL; $conf .= ' CustomLog "\\\foo\\\bar\\\access.log" common'.PHP_EOL; $conf .= ''.PHP_EOL; file_put_contents('bug10185.httpd.conf.old', $conf); $conf1 = new Config; $root1 =& $conf1->parseConfig('bug10185.httpd.conf.old', 'apache'); $conf1->writeConfig('bug10185.httpd.conf.new.php', 'phparray', array('name' => 'test')); $conf2 = new Config; $root2 =& $conf2->parseConfig('bug10185.httpd.conf.new.php', 'phparray', array('name' => 'test')); $conf2->writeConfig('bug10185.httpd.conf.new', 'apache'); readfile('bug10185.httpd.conf.new'); ?> --CLEAN-- --EXPECT-- LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog "/foo/bar/access.log" common CustomLog "\foo\bar\access.log" common CustomLog "\\foo\\bar\\access.log" common php-config-1.10.12/Config-1.10.12/test/bug11435-inicommented.phpt000066400000000000000000000013021153367000700234070ustar00rootroot00000000000000--TEST-- regression test for bug #11435 - IniCommented --FILE-- parseConfig($datasrc, 'IniCommented'); $root =& $config->getRoot(); print $root->toString('IniCommented'); ?> --EXPECT-- [characters] comma = "string," semi-colon = "string;" equal-sign = "string=" double-quote = "string\"" single-quote = string' percent = "string%" tilde = "string~" exclamation-mark = "string!" pipe = "string|" ampersand = "string&" open-bracket = "string(" close-bracket = "string)" [emptystrings] string1 = string2 = NULL string3 = string4 = "none" php-config-1.10.12/Config-1.10.12/test/bug11435-inifile.phpt000066400000000000000000000013521153367000700223600ustar00rootroot00000000000000--TEST-- regression test for bug #11435 - IniFile --SKIPIF-- --FILE-- parseConfig($datasrc, 'IniFile'); $root =& $config->getRoot(); print $root->toString('IniFile'); ?> --EXPECT-- [characters] comma = , semi-colon = ; equal-sign = = double-quote = " single-quote = ' percent = % tilde = ~ exclamation-mark = ! pipe = | ampersand = & open-bracket = ( close-bracket = ) [emptystrings] string1 = string2 = NULL string3 = "" string4 = none php-config-1.10.12/Config-1.10.12/test/bug11435.ini000066400000000000000000000005431153367000700205500ustar00rootroot00000000000000[characters] comma = "string," semi-colon = "string;" equal-sign = "string=" double-quote = "string\"" single-quote = "string'" percent = "string%" tilde = "string~" exclamation-mark = "string!" pipe = "string|" ampersand = "string&" open-bracket = "string(" close-bracket = "string)" [emptystrings] string1 = string2 = NULL string3 = "" string4 = none php-config-1.10.12/Config-1.10.12/test/bug11807.phpt000066400000000000000000000013441153367000700207470ustar00rootroot00000000000000--TEST-- regression test for bug #11807: serializing null values in php arrays --FILE-- "id", "null" => null, "false" => false, "zero" => 0, "empty_string" => '' ); $root = $config->parseConfig( $data, 'phparray', array('name' => 'conf') ); $config->writeConfig( $path, 'phparray', array('name' => 'conf') ); print file_get_contents($path); ?> --CLEAN-- --EXPECT-- php-config-1.10.12/Config-1.10.12/test/bug11827.ini000066400000000000000000000000641153367000700205530ustar00rootroot00000000000000[section] directive[] = value1 directive[] = value2 php-config-1.10.12/Config-1.10.12/test/bug11827.phpt000066400000000000000000000005531153367000700207520ustar00rootroot00000000000000--TEST-- regression test for bug #11827 --FILE-- parseConfig($datasrc, 'inifile'); var_dump($root->children[0]->children[0]->content); ?> --EXPECT-- array(2) { [0]=> string(6) "value1" [1]=> string(6) "value2" } php-config-1.10.12/Config-1.10.12/test/bug12291.ini000066400000000000000000000001421153367000700205440ustar00rootroot00000000000000keyword:foo,bar,\ baz keyword_with_space:foo, \ bar, baz keyword_with_two_spaces:foo, \ bar, baz php-config-1.10.12/Config-1.10.12/test/bug12291.phpt000066400000000000000000000014511153367000700207440ustar00rootroot00000000000000--TEST-- regression test for bug #12291: do not require space before newline --FILE-- parseConfig($datasrc, 'genericconf'); var_dump($root->toArray()); ?> --EXPECT-- array(1) { ["root"]=> array(3) { ["keyword"]=> string(11) "foo,bar,baz" ["keyword_with_space"]=> string(13) "foo, bar, baz" ["keyword_with_two_spaces"]=> string(14) "foo, bar, baz" } } php-config-1.10.12/Config-1.10.12/test/bug12387.ini000066400000000000000000000000171153367000700205530ustar00rootroot00000000000000hy-phen: value php-config-1.10.12/Config-1.10.12/test/bug12387.phpt000066400000000000000000000005661153367000700207600ustar00rootroot00000000000000--TEST-- Test for request #12387: Allow hyphens in the key --FILE-- parseConfig($datasrc, 'genericconf'); var_dump($root->toArray()); ?> --EXPECT-- array(1) { ["root"]=> array(1) { ["hy-phen"]=> string(5) "value" } } php-config-1.10.12/Config-1.10.12/test/bug12388.ini000066400000000000000000000001211153367000700205500ustar00rootroot00000000000000nospace: value space_before: value space_after : value two_spaces_after :value php-config-1.10.12/Config-1.10.12/test/bug12388.phpt000066400000000000000000000010021153367000700207430ustar00rootroot00000000000000--TEST-- Test for request #12388: Allow spaces after the key --FILE-- parseConfig($datasrc, 'genericconf'); var_dump($root->toArray()); ?> --EXPECT-- array(1) { ["root"]=> array(4) { ["nospace"]=> string(5) "value" ["space_before"]=> string(5) "value" ["space_after"]=> string(5) "value" ["two_spaces_after"]=> string(5) "value" } } php-config-1.10.12/Config-1.10.12/test/bug13791.phpt000066400000000000000000000005611153367000700207530ustar00rootroot00000000000000--TEST-- Test for bug #13791: quote strings in constants container to get valid PHP code --FILE-- getRoot()->createDirective('WITH_QUOTES', 'double: " single:\' end'); echo $config->getRoot()->toString('phpconstants'); ?> --EXPECT-- define('WITH_QUOTES', 'double: " single:\' end');php-config-1.10.12/Config-1.10.12/test/bug16590-2.phpt000066400000000000000000000026021153367000700211100ustar00rootroot00000000000000--TEST-- regression test for bug #16590, named arrays with number as first key --FILE-- array( '203' => 'mysql', 'host' => 'localhost', ), 'ok' => array( 0 => 'foo', 1 => 'bar', ), 'ok2' => array( '0' => 'foo2', '1' => 'bar2', ) ); print_r($conf); $arr_read = $config->parseConfig( $conf, 'phparray', array('duplicateDirectives' => true) ); $arr_read = $arr_read->toArray(); print_r($arr_read['root']); ?> --EXPECT-- Array ( [DB] => Array ( [203] => mysql [host] => localhost ) [ok] => Array ( [0] => foo [1] => bar ) [ok2] => Array ( [0] => foo2 [1] => bar2 ) ) Array ( [DB] => Array ( [203] => mysql [host] => localhost ) [ok] => Array ( [0] => foo [1] => bar ) [ok2] => Array ( [0] => foo2 [1] => bar2 ) ) php-config-1.10.12/Config-1.10.12/test/bug16590.phpt000066400000000000000000000011071153367000700207500ustar00rootroot00000000000000--TEST-- regression test for bug #16590, named arrays with number as first key --FILE-- 'mysql', 'host' => 'localhost', ); print_r($conf); $c = new Config(); $arr_read = $c->parseConfig($conf, 'phparray'); //var_dump($arr_read); $arr_read = $arr_read->toArray(); print_r($arr_read['root']); ?> --EXPECT-- Array ( [203] => mysql [host] => localhost ) Array ( [203] => mysql [host] => localhost )php-config-1.10.12/Config-1.10.12/test/bug16656.ini000066400000000000000000000000201153367000700205500ustar00rootroot00000000000000foo=bar bar=baz php-config-1.10.12/Config-1.10.12/test/bug16656.phpt000066400000000000000000000017341153367000700207610ustar00rootroot00000000000000--TEST-- Test for request #11827: newline option for inicommented container --FILE-- parseConfig( $datasrc, 'inicommented' ); //windows - \r\n echo make_visible( $root->toString( 'inicommented', array('linebreak' => "\r\n") ) ) . "\n"; //mac - \r echo make_visible( $root->toString( 'inicommented', array('linebreak' => "\r") ) ) . "\n"; //unix - \n echo make_visible( $root->toString( 'inicommented', array('linebreak' => "\n") ) ) . "\n"; //default - \n echo make_visible( $root->toString('inicommented') ) . "\n"; ?> --EXPECT-- foo = bar\r\nbar = baz\r\n foo = bar\rbar = baz\r foo = bar\nbar = baz\n foo = bar\nbar = baz\n php-config-1.10.12/Config-1.10.12/test/bug16724-config.php000066400000000000000000000001061153367000700220240ustar00rootroot00000000000000php-config-1.10.12/Config-1.10.12/test/bug16724.phpt000066400000000000000000000015001153367000700207440ustar00rootroot00000000000000--TEST-- Test for request #16724: lowercase constant names option --FILE-- parseConfig( $datasrc, 'phpconstants', array('lowercase' => true) ); print_r($root->toArray()); echo $root->toString('phpconstants'); //not lowercasing should still work $config = new Config(); $root = $config->parseConfig( $datasrc, 'phpconstants' ); print_r($root->toArray()); ?> --EXPECT-- Array ( [root] => Array ( [my_config_option] => foo [host12_3] => foo ) ) define('MY_CONFIG_OPTION', 'foo'); define('HOST12_3', 'foo'); Array ( [root] => Array ( [MY_CONFIG_OPTION] => foo [HOST12_3] => foo ) ) php-config-1.10.12/Config-1.10.12/test/bug18124.phpt000066400000000000000000000005351153367000700207470ustar00rootroot00000000000000--TEST-- regression test for bug #11827, saving array back into ini --FILE-- parseConfig($datasrc, 'inifile'); echo $root->toString('inifile'); ?> --EXPECT-- [section] directive[]=value1 directive[]=value2 php-config-1.10.12/Config-1.10.12/test/bug2742.ini000066400000000000000000000000121153367000700204600ustar00rootroot00000000000000var = 1234php-config-1.10.12/Config-1.10.12/test/bug2742.phpt000066400000000000000000000007211153367000700206630ustar00rootroot00000000000000--TEST-- test for bug 2742 --FILE-- parseConfig($datasrc, 'inicommented'); if ($phpt->assertNoErrors('problem!')) { $phpt->assertEquals('$php_ini[\'var\'] = \'1234\';', $root->toString('phparray', array('name' => 'php_ini')), 'convert var = 1234 to array'); } echo 'tests done'; ?> --EXPECT-- tests done php-config-1.10.12/Config-1.10.12/test/bug2780.phpt000066400000000000000000000006071153367000700206700ustar00rootroot00000000000000--TEST-- bug 2780 regression --FILE-- addItem($c2); // Convert your ini file to a php array config echo $c1->toString('phparray', array('name' => 'php_ini')); ?> --EXPECT-- php-config-1.10.12/Config-1.10.12/test/bug3051.phpt000066400000000000000000000006531153367000700206610ustar00rootroot00000000000000--TEST-- test for bug 3051 --FILE-- parseConfig(dirname(__FILE__) . '/bug3051.xml', 'xml'); $root =& $root->getChild(0); for ($i=0; $i < $root->countChildren('directive', 'item'); $i++) { $item = $root->getItem('directive', 'item', null, null, $i); print $item->getAttribute('name')."\n"; } ?> --EXPECT-- item1 item2 php-config-1.10.12/Config-1.10.12/test/bug3051.xml000066400000000000000000000001011153367000700204720ustar00rootroot00000000000000 php-config-1.10.12/Config-1.10.12/test/bug3137.phpt000066400000000000000000000015001153367000700206560ustar00rootroot00000000000000--TEST-- regression test for bug #3137 --FILE-- parseConfig($array, "phparray"); if (PEAR::isError($root)) { die('Error while reading configuration: ' . $root->getMessage() . "\r\n"); } $result = $root->createComment("Comment", "before", $root->children[0]); if (PEAR::isError($result)) { die('Error while reading configuration: ' . $result->getMessage() . "\r\n"); } $exp = '// Comment $conf[0] = \'foo\'; $conf[1] = \'bar\'; $conf[2] = \'too\'; '; //print_r($root->toString('phparray')); if ($phpt->assertNoErrors('problem!')) { $phpt->assertEquals($root->toString('phparray'), $exp, 'uh oh'); } echo 'tests done'; ?> --EXPECT-- tests done php-config-1.10.12/Config-1.10.12/test/bug3298.phpt000066400000000000000000000013061153367000700206720ustar00rootroot00000000000000--TEST-- bug 3298 regression test --FILE-- parseConfig($datasrc, 'XML'); $configArray = $root->toArray('PHParray'); $config2 = new Config(); $root2 = $config2->parseConfig(current($configArray), 'PHParray'); if ($root2->writeDatasrc('new_config.xml', 'XML')) { $file = file_get_contents("new_config.xml"); } else { echo "error updating XML"; } if ($phpt->assertNoErrors('problem!')) { $phpt->assertEquals( file_get_contents($datasrc), $file, "XML doesn't match"); } echo 'tests done'; ?> --CLEAN-- --EXPECT-- tests done php-config-1.10.12/Config-1.10.12/test/bug3298.xml000066400000000000000000000013351153367000700205210ustar00rootroot00000000000000 clients intern true intern true
intern true intern true
php-config-1.10.12/Config-1.10.12/test/bug3398.ini000066400000000000000000000002701153367000700204760ustar00rootroot00000000000000[Preset] presets=common [common] sntpTZ=type=4,"value=CST6DST5,M4.1.0/02:00:00,M10.5.0/02:00:00",name=sntpTZ, label=TimeZone, form=text, "select=array (value => %value, size => 37);" php-config-1.10.12/Config-1.10.12/test/bug3398.phpt000066400000000000000000000015161153367000700206760ustar00rootroot00000000000000--TEST-- regression test for bug #3398 --FILE-- parseConfig($datasrc, 'inicommented'); if (PEAR::isError($root)) { die('Error while reading configuration: ' . $root->getMessage() . "\r\n"); } $exp = array( 'root' => array ( 'Preset' => array ('presets' => 'common'), 'common' => array ( 'sntpTZ' => array( 0 => 'type=4', 1 => 'value=CST6DST5,M4.1.0/02:00:00,M10.5.0/02:00:00', 2 => 'name=sntpTZ', 3 => 'label=TimeZone', 4 => 'form=text', 5 => 'select=array (value => %value, size => 37);') ) )); //print_r($root->toArray()); if ($phpt->assertNoErrors('problem!')) { $phpt->assertEquals($root->toArray(), $exp, 'uh oh'); } echo 'tests done'; ?> --EXPECT-- tests done php-config-1.10.12/Config-1.10.12/test/bug3590-input.php000066400000000000000000000003531153367000700216370ustar00rootroot00000000000000 'croooow', 'password' => 'coolrobot', 'host' => 'localhost', 'database' => 'deep13' ); $conf['emergencyemails'] = array( 'joel@example.org', 'cambot@example.org' ); ?> php-config-1.10.12/Config-1.10.12/test/bug3590.phpt000066400000000000000000000014661153367000700206740ustar00rootroot00000000000000--TEST-- regression test for bug #3590 --FILE-- parseConfig($datasrc, "phparray"); if (PEAR::isError($root)) { die('Error while reading configuration: ' . $root->getMessage() . "\r\n"); } $exp = '$conf[\'mysql\'][\'user\'] = \'croooow\'; $conf[\'mysql\'][\'password\'] = \'coolrobot\'; $conf[\'mysql\'][\'host\'] = \'localhost\'; $conf[\'mysql\'][\'database\'] = \'deep13\'; $conf[\'emergencyemails\'][0] = \'joel@example.org\'; $conf[\'emergencyemails\'][1] = \'cambot@example.org\'; '; if ($phpt->assertNoErrors('problem!')) { $phpt->assertEquals($root->toString('phparray'), $exp, 'uh oh'); } echo 'tests done'; ?> --EXPECT-- tests done php-config-1.10.12/Config-1.10.12/test/bug4623.conf000066400000000000000000000003731153367000700206400ustar00rootroot00000000000000 ServerName www.foo.com Limit GET TESTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT blah php-config-1.10.12/Config-1.10.12/test/bug4623.phpt000066400000000000000000000010431153367000700206610ustar00rootroot00000000000000--TEST-- regression test for bug #3590 --FILE-- parseConfig($datasrc, "Apache"); if (PEAR::isError($root)) { die('Error while reading configuration: ' . $root->getMessage() . "\r\n"); } $exp = $root->toString('Apache'); if ($phpt->assertNoErrors('problem!')) { $phpt->assertEquals($root->toString('Apache'), $exp, 'uh oh'); } echo 'tests done'; ?> --EXPECT-- tests done php-config-1.10.12/Config-1.10.12/test/bug6441.ini000066400000000000000000000001501153367000700204630ustar00rootroot00000000000000val1 = true val2 = false val3 = True val4 = False val5 = TRUE val6 = FALSE val7 = "true" val8 = "false" php-config-1.10.12/Config-1.10.12/test/bug6441.phpt000066400000000000000000000011621153367000700206630ustar00rootroot00000000000000--TEST-- regression test for bug #6441 --FILE-- parseConfig($datasrc, 'inicommented'); $temp = $conf_obj->toArray(); $conf = $temp['root']; var_dump($conf); ?> --EXPECT-- array(8) { ["val1"]=> string(1) "1" ["val2"]=> string(0) "" ["val3"]=> string(1) "1" ["val4"]=> string(0) "" ["val5"]=> string(1) "1" ["val6"]=> string(0) "" ["val7"]=> string(4) "true" ["val8"]=> string(5) "false" } php-config-1.10.12/Config-1.10.12/test/bug7544-inicommented.phpt000066400000000000000000000007001153367000700233360ustar00rootroot00000000000000--TEST-- regression test for bug #7544 - IniCommented --FILE-- parseConfig($datasrc, 'IniCommented'); $root =& $config->getRoot(); print $root->toString('phparray'); ?> --EXPECT-- $conf['test']['myattrib1'] = 'wee'; $conf['test']['myattrib2'] = ''; // comment // after blank line php-config-1.10.12/Config-1.10.12/test/bug7544-inifile.phpt000066400000000000000000000006261153367000700223110ustar00rootroot00000000000000--TEST-- regression test for bug #7544 - IniFile --FILE-- parseConfig($datasrc, 'IniFile'); $root =& $config->getRoot(); print $root->toString('phparray'); ?> --EXPECT-- $conf['test']['myattrib1'] = 'wee'; $conf['test']['myattrib2'] = ''; php-config-1.10.12/Config-1.10.12/test/bug7544.ini000066400000000000000000000000741153367000700204750ustar00rootroot00000000000000[test] myattrib1=wee myattrib2= ;comment ;after blank line php-config-1.10.12/Config-1.10.12/test/bug7652.phpt000066400000000000000000000011241153367000700206660ustar00rootroot00000000000000--TEST-- regression test for bug #7652 --FILE-- parseConfig($datasrc, 'xml'); $root =& $config->getRoot(); print $root->toString('phparray'); ?> --EXPECT-- $conf['root']['tag1'][0]['#'] = ''; $conf['root']['tag1'][0]['@']['attrib'] = 'val'; $conf['root']['tag1'][1]['@']['attrib'] = 'val2'; $conf['root']['tag1'][1]['tag2'] = 'hello world'; $conf['root']['tag1'][2]['#'] = ''; $conf['root']['tag1'][2]['@']['attrib'] = 'val23'; php-config-1.10.12/Config-1.10.12/test/bug7652.xml000066400000000000000000000002551153367000700205170ustar00rootroot00000000000000 hello world php-config-1.10.12/Config-1.10.12/test/bug8357-inicommented.phpt000066400000000000000000000006601153367000700233460ustar00rootroot00000000000000--TEST-- regression test for bug #8357 - IniCommented --FILE-- parseConfig($datasrc, 'IniCommented'); $root =& $config->getRoot(); print $root->toString('phparray'); ?> --EXPECT-- $conf['meta']['robots'] = 'index, follow'; $conf['meta']['keywords'] = 'key, words'; php-config-1.10.12/Config-1.10.12/test/bug8357-inifile.phpt000066400000000000000000000007541153367000700223160ustar00rootroot00000000000000--TEST-- regression test for bug #8357 - IniFile --FILE-- parseConfig($datasrc, 'IniFile'); $root =& $config->getRoot(); print $root->toString('phparray'); ?> --EXPECT-- $conf['meta']['robots'][0] = 'index'; $conf['meta']['robots'][1] = 'follow'; $conf['meta']['keywords'][0] = 'key'; $conf['meta']['keywords'][1] = 'words'; php-config-1.10.12/Config-1.10.12/test/bug8357.ini000066400000000000000000000001001153367000700204660ustar00rootroot00000000000000[meta] robots = "index, follow" keywords = "key, words" php-config-1.10.12/Config-1.10.12/test/phpt_test.php.inc000066400000000000000000000311061153367000700221660ustar00rootroot00000000000000_diffonly = $diffonly; $this->_errors = array(); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array(&$this, 'pearerrorCallback')); PEAR_ErrorStack::setDefaultCallback(array(&$this, 'pearerrorstackCallback')); } function pearerrorCallback($err) { PEAR_ErrorStack::staticPush('PEAR_Error', -1, 'error', array('obj' => $err), $err->getMessage()); } function pearerrorstackCallback($err) { $this->_errors[] = $err; } function assertPEARError($err, $message) { if (is_a($err, 'PEAR_Error')) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Not a PEAR_Error\n"; return false; } function assertNoErrors($message, $trace = null) { if (count($this->_errors) == 0) { return true; } if ($trace === null) { $trace = debug_backtrace(); } $this->_failTest($trace, $message); foreach ($this->_errors as $err) { if ($err['package'] == 'PEAR_Error') { echo "Unexpected PEAR_Error:\n"; echo 'message "' . $err['message'] . "\"\n"; } else { echo "Unexpected PEAR_ErrorStack error:\n"; echo 'package "' . $err['package'] . "\"\n"; echo 'message "' . $err['message'] . "\"\n"; } } $this->_errors = array(); return false; } function assertErrors($errors, $message, $trace = null) { if (!count($this->_errors)) { if ($trace === null) { $trace = debug_backtrace(); } $this->_failTest($trace, $message); echo "No errors caught, but errors were expected\n"; return false; } if (!isset($errors[0])) { $errors = array($errors); } $failed = false; foreach ($errors as $err) { $found = false; foreach ($this->_errors as $i => $caughterror) { if ($caughterror['package'] == $err['package']) { if ($caughterror['message'] == $err['message']) { $found = true; break; } } } if ($found) { unset($this->_errors[$i]); continue; } if (!$failed) { if ($trace === null) { $trace = debug_backtrace(); } $failed = true; $this->_failTest($trace, $message); } echo "Unthrown error:\n"; if ($err['package'] == 'PEAR_Error') { echo "PEAR_Error:\n"; } else { echo "error package: \"$err[package]\"\n"; } echo "message: \"$err[message]\"\n"; } if (count($this->_errors)) { if (!$failed) { if ($trace === null) { $trace = debug_backtrace(); } $failed = true; $this->_failTest($trace, $message); } foreach ($this->_errors as $err) { echo "Unexpected error:\n"; if ($err['package'] == 'PEAR_Error') { echo "PEAR_Error:\n"; } else { echo "error package: \"$err[package]\"\n"; } echo "message: \"$err[message]\"\n"; } } $this->_errors = array(); return !$failed; } function assertTrue($test, $message) { $this->assertNoErrors($message, debug_backtrace()); if ($test === true) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpected non-true value: \n"; var_export($test); echo "\n'$message'\n"; return false; } function assertIsa($control, $test, $message) { $this->assertNoErrors($message, debug_backtrace()); if (is_a($test, $control)) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpected non-$control object: \n"; var_export($test); echo "\n'$message'\n"; return false; } function assertNull($test, $message) { $this->assertNoErrors($message, debug_backtrace()); if ($test === null) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpected non-null value: \n"; var_export($test); echo "\n'$message'\n"; return false; } function assertNotNull($test, $message) { $this->assertNoErrors($message, debug_backtrace()); if ($test !== null) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpected null: \n"; var_export($test); echo "\n'$message'\n"; return false; } function assertSame($test, $test1, $message) { $this->assertNoErrors($message, debug_backtrace()); if ($test === $test1) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpectedly two vars are not the same thing: \n"; echo "\n'$message'\n"; return false; } function assertNotSame($test, $test1, $message) { $this->assertNoErrors($message, debug_backtrace()); if ($test !== $test1) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpectedly two vars are the same thing: \n"; echo "\n'$message'\n"; return false; } function assertFalse($test, $message) { $this->assertNoErrors($message, debug_backtrace()); if ($test === false) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpected non-false value: \n"; var_export($test); echo "\n'$message'\n"; return false; } function assertNotTrue($test, $message) { $this->assertNoErrors($message, debug_backtrace()); if (!$test) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpected loose true value: \n"; var_export($test); echo "\n'$message'\n"; return false; } function assertNotFalse($test, $message) { $this->assertNoErrors($message, debug_backtrace()); if ($test) { return true; } $this->_failTest(debug_backtrace(), $message); echo "Unexpected loose false value: \n"; var_export($test); echo "\n'$message'\n"; return false; } function assertEquals($control, $test, $message) { $this->assertNoErrors($message, debug_backtrace()); if (str_replace(array("\r", "\n"), array('', ''), var_export($control, true)) != str_replace(array("\r", "\n"), array('', ''), var_export($test, true))) { $this->_failTest(debug_backtrace(), $message); if (class_exists('Text_Diff')) { echo "Diff of expecting/received:\n"; $diff = &new Text_Diff( explode("\n", var_export($control, true)), explode("\n", var_export($test, true))); // Output the diff in unified format. $renderer = &new Text_Diff_Renderer_unified(); echo $renderer->render($diff); if ($this->_diffonly) { return false; } } echo "Expecting:\n"; var_export($control); echo "\nReceived:\n"; var_export($test); return false; } return true; } function assertFileExists($fname, $message) { $this->assertNoErrors($message, debug_backtrace()); if (!@file_exists($fname)) { $this->_failTest(debug_backtrace(), $message); echo "File '$fname' does not exist, and should\n"; return false; } return true; } function assertFileNotExists($fname, $message) { $this->assertNoErrors($message, debug_backtrace()); if (@file_exists($fname)) { $this->_failTest(debug_backtrace(), $message); echo "File '$fname' exists, and should not\n"; return false; } return true; } function assertRegEquals($dump, &$reg, $message) { $actualdump = var_export(trim($this->dumpReg($reg)), true); $testdump = var_export(trim($dump), true); return $this->assertEquals($testdump, $actualdump, $message); } function assertPackageInfoEquals($control, $test, $message) { $this->assertNoErrors($message, debug_backtrace()); if (isset($control[0])) { if (!isset($test[0]) || (count($control) != count($test))) { echo "Invalid packageInfo\n"; $ret = $this->assertEquals($control, $test, $message); } $ret = true; foreach ($control as $i => $packageinfo) { $ret = $ret && $this->assertPackageInfoEquals($packageinfo, $test[$i], $message . $i); } return $ret; } if (isset($control['_lastmodified'])) { if (!isset($test['_lastmodified'])) { echo "_lastmodified is not set in packageInfo() output\n"; $this->_failTest(debug_backtrace(), $message); return false; } } $savecontrol = $control; $savetest = $test; unset($control['_lastmodified']); unset($test['_lastmodified']); if (var_export($control, true) != var_export($test, true)) { $this->_failTest(debug_backtrace(), $message); if (class_exists('Text_Diff')) { echo "Diff of expecting/received:\n"; $diff = &new Text_Diff( explode("\n", var_export($control, true)), explode("\n", var_export($test, true))); // Output the diff in unified format. $renderer = &new Text_Diff_Renderer_unified(); echo $renderer->render($diff); if ($this->_diffonly) { return false; } } echo "Expecting:\n"; var_export($savecontrol); echo "\nReceived:\n"; var_export($savetest); return false; } return true; } function dumpReg(&$reg) { ob_start(); print "dumping registry...\n"; $infos = $reg->packageInfo(null, null, null); foreach ($infos as $channel => $info) { echo "channel $channel:\n"; foreach ($info as $pkg) { print $pkg["name"] . ":"; unset($pkg["name"]); foreach ($pkg as $k => $v) { if ($k == '_lastmodified') { print " _lastmodified is set"; continue; } if (is_array($v) && $k == 'filelist') { print " $k=array("; $i = 0; foreach ($v as $k2 => $v2) { if ($i++ > 0) print ","; print "{$k2}["; $j = 0; foreach ($v2 as $k3 => $v3) { if ($j++ > 0) print ","; print "$k3=$v3"; } print "]"; } print ")"; } else { print " $k=\"$v\""; } } print "\n"; } } print "dump done\n"; $ret = ob_get_contents(); ob_end_clean(); return $ret; } function _failTest($trace, $message) { echo 'Test Failure: "' . $message . "\"\n in " . $trace[0]['file'] . ' line ' . $trace[0]['line'] . "\n"; } function showAll() { $this->_diffonly = false; } } ?>php-config-1.10.12/Config-1.10.12/test/setup.php.inc000066400000000000000000000003641153367000700213160ustar00rootroot00000000000000php-config-1.10.12/package.xml000066400000000000000000000632641153367000700160400ustar00rootroot00000000000000 Config pear.php.net Your configuration's swiss-army knife. The Config package provides methods for configuration manipulation. * Creates configurations from scratch * Parses and outputs different formats (XML, PHP, INI, Apache...) * Edits existing configurations * Converts configurations to other formats * Allows manipulation of sections, comments, directives... * Parses configurations into a tree structure * Provides XPath like access to directives Bertrand Mansion mansion bmansion@mamasam.com no Ryan King ryansking ryansking@php.net no Adam Ashley aashley aashley@php.net yes Adam Harvey aharvey aharvey@php.net yes 2010-12-24 1.10.12 1.10.8 stable stable PHP License I believe we'll call this the "all hail Christian Weiske" release, since he's been a very busy bee. Bugs fixed: * Fixed Bug #11435: Fix IniCommented parsing of ~ ! | & ( ). (aashley) * Fixed Bug #11807: Config can create invalid php for unknown values. (cweiske) * Fixed Bug #11827: notice when using arrays (directive[]=value) in inifiles. (cweiske) * Fixed Bug #12291: PEAR GenericConf newline shouldn't need a space. (cweiske) * Fixed Bug #12387: GenericConf doesn't allow for hyphens on left-hand-side of a directive. (cweiske) * Fixed Bug #12388: GenericConf doesn't allow whitepace to left of directive delimiter. (cweiske) * Fixed Bug #13116: Syntax Strict notice for references on constructors. (fjfnaranjo) * Fixed Bug #15964: errors in test suite. (cweiske) * Fixed Bug #16590: parseConfig phparray ignores named arrays that use numbers as name. (cweiske) * Fixed Bug #18124: Saving arrays back to ini file fails. (cweiske) Feature requests implemented: * Request #13791: Options for the PHPConstants container. (cweiske) * Request #16656: New 'linebreak' option for IniCommented container. (cweiske) * Request #16724: PHPConstants container should have option lowercase. (cweiske) 4.3.0 1.4.0b1 XML_Parser pear.php.net XML_Util pear.php.net 2010-12-24 1.10.12 1.10.8 stable stable PHP License I believe we'll call this the "all hail Christian Weiske" release, since he's been a very busy bee. Bugs fixed: * Fixed Bug #11435: Fix IniCommented parsing of ~ ! | & ( ). (aashley) * Fixed Bug #11807: Config can create invalid php for unknown values. (cweiske) * Fixed Bug #11827: notice when using arrays (directive[]=value) in inifiles. (cweiske) * Fixed Bug #12291: PEAR GenericConf newline shouldn't need a space. (cweiske) * Fixed Bug #12387: GenericConf doesn't allow for hyphens on left-hand-side of a directive. (cweiske) * Fixed Bug #12388: GenericConf doesn't allow whitepace to left of directive delimiter. (cweiske) * Fixed Bug #13116: Syntax Strict notice for references on constructors. (fjfnaranjo) * Fixed Bug #15964: errors in test suite. (cweiske) * Fixed Bug #16590: parseConfig phparray ignores named arrays that use numbers as name. (cweiske) * Fixed Bug #18124: Saving arrays back to ini file fails. (cweiske) Feature requests implemented: * Request #13791: Options for the PHPConstants container. (cweiske) * Request #16656: New 'linebreak' option for IniCommented container. (cweiske) * Request #16724: PHPConstants container should have option lowercase. (cweiske) 2007-06-12 1.10.11 1.10.8 stable stable PHP License * Fixed Bug #11184: Knock on problems from fix for Bug #10185. Thanks to Thomas Despoix and Carsten Wiedmann for helping me understand it properly. 2007-03-26 1.10.10 1.10.8 stable stable PHP License * Fix Bug #10010: numeric index lost when parsing subarrays * Fix Bug #10185: problem with addslashs in container "PHPArray" / method "toString" 2006-12-22 1.10.9 1.10.8 stable stable PHP License * Fixed Bug #9632: PHPConstants container not registered. Thanks to Clemens Lang <neverpanic at gmail dot com> 2006-11-10 1.10.8 1.10.8 stable stable PHP License * Fixed Bug #7097: writeConfig incorrect when root has attributes 2006-10-20 1.10.8RC1 1.10.8 beta stable PHP License * Fixed Bug #7097: writeConfig incorrect when root has attributes This fix has the potential to break other things as it is a big change to the PHPArray backend. Please test. 1.10.7 1.10.7 stable stable 2006-08-11 PHP License Changelog: * Fixed Bug #7544: Empty attributes in IniCommented are being discarded (Luis Correa d'Almeida) * Fixed Bug #7652: wrong xml to phparray convert. Caused by counting position of directives and sections seperately. While when converting to some containers we want to count them together. * Add tests to confirm behaviour of Bug #8357. Do not believe it is fixable without removing features. 1.10.6 1.10.6 stable stable 2006-02-14 PHP License Changelog: * More PHP 4.4 and 5.1 return by reference fixes * Fixed bug #4477 fatal error when key of array is longer than 114 chars under PHP4.x * Fixed bug #6385 Allow colon in directive name in IniCommented to match IniFile. * Fixed bug #6441 true and false literals should be parsed appropriately. Booleans are now parsed the same as in parse_ini_file() 1.10.5 1.10.5 stable stable 2006-01-03 PHP License Changelog: * Make what we add quotes around consistent between IniFile and IniCommented. * Fixed bug #3137 Adding a comment caused problems outputing in phparray format. * Fixed bug #3590 Handling phparray formats with implicit numeric keys. * Fixed bug #4623 Rendering to Apache format a second time looses section attributes. * Fixed bug #5598 Allow '=' in values and output it correctly in IniFile format. * Fixed bugs #5033, #5835, #6294 Return only variables by reference as required by PHP 4.4 and 5.1. * Partial Fix for #6385 Allow colon in directive name in IniCommented to match IniFile. 1.10.4 1.10.4 stable stable 2005-02-10 PHP License Changelog: * Fixed bug #3298 which wouldn't parse arrays with numerical indexes correctly. *Fixed bug #2742 which didn't trim variable names in Inicommented file *changed XML_Parser and XML_Util dependencies to optional, since they're only needed when parsing XML files (bug #2738) *added a new container for editing files of php constants, courtesy of philip ortel [me@phillipoertel.com] (beta) 1.10.3 1.10.3 stable stable 2004-10-13 PHP License Changelog: *Fixed bug #2179 which prevented URL's containting ~ in ini files to be parsed correctly *Fixed bug #2439 which caused Config_Containter::countChildren() to return a PEAR_ERROR object when called on a non-section Config_Container object. This change brings the object's behavior inline with the documentation. Beware, if your code relies on the previous behavior, this change may break your code. 1.10.2 1.10.2 stable stable 2004-06-14 PHP License * Fixed bug #1633 related to case-sensitivity of method names in PHP4. causing PHPArray container not to work correctly. See also #1556. Patch provided by m at tacker dotorg. 1.10.1 1.10.1 stable stable 2004-06-04 PHP License * Fixed problems with PHP5 case sensitivity on class and method names. * Added possibility to actually replace the root container by using method Config::setRoot() with a container of type 'section' and name 'root'. * XML parser now makes use of the encoding specified in the options array. * Fixed a warning with array_splice() on an unset $children. 1.10 1.10 stable stable 2003-11-29 PHP License * Added 'isFile' option to XML container * Fix a bug when a directive has no content in XML configurations * Fix slowdown caused by uniqid() on Linux * Fix regular expression for directives in .ini files (Emil Biserov) * Fix bug #132 concerning % in .ini files (Wagner netsols.de) * Fix possible warning if text is empty in .ini commented (Dean Urmson) * Small speed optimizations 1.9 1.9 stable stable 2003-09-21 PHP License * Added a new boolean option/parameter in XML, PHPArray and toArray() to set whether attributes should be rendered. * Added comments rendering in XML. * Fix typo in PHPArray when setting the configuration array name (Laurent Laville) 1.8.1 1.8.1 stable stable 2003-09-07 PHP License * Fix a bug in XML container related to cdata handler read by chunk, reported by Stephan Wentz 1.8 1.8 stable stable 2003-08-16 PHP License * Fix a bug in setRoot() for the XML generator * Added new method searchPath() to Config_Container (taken from Alan Knowles for XML_Tree) * Added float detection in Config_Container_PHPArray (Sylvinus Prodi) * Uses XML_Util in xml container for special entities translation, customizable linebreaks, indents, xml declaration 1.7 1.7 stable stable 2003-06-16 PHP License * Added new method registerConfigType() (Greg Beaver) * Root containers are not named 'root' anymore (Bertrand Mansion) * IniCommented handles comma, quotes, slashes (Greg Beaver) * IniFile and IniCommented take care of slashes (Greg Beaver) * Method _parseArray() in PHPArray refactored and much faster (Bertrand Mansion) * Fix bugs with certain type of arrays with PHPArray (Bertrand Mansion) * PHPArray now returns values between single quotes (Jean-Marc Fontaine) 1.6 1.6 stable stable 2003-05-20 PHP License * Fix bug #23690 in toArray reported by Rob Halff 1.5 1.5 stable stable 2003-04-14 PHP License * Added an id private property for each node * Fix a bug in toArray when items are duplicates 1.4 1.4 stable stable 2003-04-02 PHP License * Fix setDirective method in Container * Fix warnings in foreach loop when attributes are not set * Added phpdoc comments 1.3 1.3 stable stable 2003-03-26 PHP License * Fixed missing quote in xml generation (Nicolas Guennoc) * Fixed warning in xml container when no attributes (Nicolas Guennoc) * Added methods getAttribute and updateAttributes to container. * Added possibility to get item by looking at its attributes in getItem() * PHPArray container automatically generates array name when not specified in options * XML Container can accept a name too that will generate the global root entity if needed 1.2 1.2 stable stable 2003-03-24 PHP License First stable release. * Added an XML container (uses XML_Parser), * Possibility to convert from one format to another, * Fixes in toArray(), * Added attributes to containers, * New methods for item manipulation. 1.1 1.1 beta beta 2002-10-08 PHP License Fix bug in toArray(). Thanks to Mark Polsen for noticing it. 1.0 1.0 stable stable 2006-10-20 PHP License Complete rewrite : API has changed. The class now uses a tree structure of container objects. As a consequence, backward compatibility is not provided !!! Look at the Apache.php and IniCommented.php scripts in 'docs' for usage examples. Some containers are still missing : XML and DB. 0.3.1 0.3.1 stable stable 2006-10-20 PHP License Documentation is in README.Config. 0.3.1 - E_ALL fixes 0.3 0.3 stable stable 2006-10-20 PHP License - some fixes - add WDDX-Container for config data in WDDX-files - add phpIniFile, does the same like IniFile but based on the PHP build-in function parse_ini_file() 0.2.2 0.2.2 stable stable 2006-10-20 PHP License - Only the first char of ->feature['cc'] is taken as a comment deliminator - quoting supports both methods: [bla] foo = "'bar'" bar = '"foo"' - Value parser only parser until first comment-char or the end of the string, therefore spaces surrounded by nonspaces don't have to be quoted. 0.2.1 0.2.1 stable stable 2006-10-20 PHP License - Bug fixed, when $feature in ParseInput was not set - some e_warnings fixed (thanks to Markus Fischer for the reports)