/** * Read menu file. Parse xml and initializate menu. * * @param menu string Configuration file * @param cacheFile string Name of file where parsed config will be stored for faster loading * @return void */ public function parseFile(RM_Account_iUser $obUser) { PROFILER_IN('Menu'); $cacheFile = $this->_filepath . '.' . L(NULL) . '.cached'; if ($this->_cache_enabled and file_exists($cacheFile) and filemtime($cacheFile) > filemtime($this->_filepath)) { $this->_rootArray = unserialize(file_get_contents($cacheFile)); } else { # # Initializing PEAR config engine... # $old = error_reporting(); error_reporting($old & ~E_STRICT); require_once 'Config.php'; $conf = new Config(); $this->_root = $conf->parseConfig($this->_filepath, 'XML'); if (PEAR::isError($this->_root)) { error_reporting($old); throw new Exception(__METHOD__ . '(): Error while reading menu configuration: ' . $this->_root->getMessage()); } $this->_rootArray = $this->_root->toArray(); if ($this->_cache_enabled) { file_put_contents($cacheFile, serialize($this->_rootArray)); } } $arr = array_shift($this->_rootArray); $arr = $arr['menu']; $this->_menuData['index'] = array(); // index for branches $this->_menuData['default'] = array(); // default selected block of menu $this->_menuData['tree'] = $this->formMenuArray($obUser, $arr['node']); $this->_menuData['branches'] = array(); // tmp array, dont cached PROFILER_OUT('Menu'); }
function __construct($filename = null, $type = 'xml') { $this->type = $type; $conf = new Config(); if (!is_null($filename)) { //$filename = "notthere.conf"; $this->rootObj = @$conf->parseConfig($filename, $type); if (PEAR::isError($this->rootObj)) { print "message: " . $this->rootObj->getMessage() . "\n"; print "code: " . $this->rootObj->getCode() . "\n\n"; print "Backtrace:\n"; foreach ($this->rootObj->getBacktrace() as $caller) { print_r($caller); print $caller['class'] . $caller['type']; print $caller['function'] . "() "; print "line " . $caller['line'] . "\n"; } die; } //print get_class( $this->rootObj )."\\\\ \n";; } else { $this->rootObj = new Config_Container('section', 'config'); $conf->setroot($this->rootObj); } }
/** * The progress bar's UI extended model class constructor * * @param string $file file name of model properties * @param string $type type of external ressource (phpArray, iniFile, XML ...) * * @since 1.0 * @access public * @throws HTML_PROGRESS_ERROR_INVALID_INPUT */ function HTML_Progress_Model($file, $type) { $this->_package = 'HTML_Progress'; if (!file_exists($file)) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1)); } $conf = new Config(); if (!$conf->isConfigTypeRegistered($type)) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2)); } $data = $conf->parseConfig($file, $type); $structure = $data->toArray(false); $this->_progress =& $structure['root']; if (is_array($this->_progress['cell']['font-family'])) { $this->_progress['cell']['font-family'] = implode(",", $this->_progress['cell']['font-family']); } if (is_array($this->_progress['string']['font-family'])) { $this->_progress['string']['font-family'] = implode(",", $this->_progress['string']['font-family']); } $this->_orientation = $this->_progress['orientation']['shape']; $this->_fillWay = $this->_progress['orientation']['fillway']; if (isset($this->_progress['script']['file'])) { $this->_script = $this->_progress['script']['file']; } else { $this->_script = null; } if (isset($this->_progress['cell']['count'])) { $this->_cellCount = $this->_progress['cell']['count']; } else { $this->_cellCount = 10; } $this->_updateProgressSize(); }
public function __construct() { $this->config['app'] = Config::parseConfig('app'); define('TEMPLATE_PATH', APP_PATH . 'app/views/' . $this->config['app']->template . '/'); define('APP_URL', $this->config['app']->url . (empty($this->config['app']->index) ? '' : $this->config['app']->index . '/')); define('ASSET_URL', $this->config['app']->url . 'app/views/' . $this->config['app']->template . '/'); define('CONTENT_URL', $this->config['app']->url . 'contents/'); }
/** * Control the main setup process * * @param array $data */ function perform($data) { // include PEAR Config class include_once SF_BASE_DIR . 'modules/common/PEAR/Config.php'; $c = new Config(); $root =& $c->parseConfig($data, 'PHPArray'); // save the modified config array $c->writeConfig(SF_BASE_DIR . 'modules/common/config/config.php', 'PHPArray', array('name' => 'this->B->sys')); }
/** * Control the main setup process * * @param array $data * $data['data'] Data (array or ...) to store * $data['file'] File to store * $data['var_name'] Name of the data array or ... * $data['type'] Data type */ function perform($data = FALSE) { // include PEAR Config class include_once SF_BASE_DIR . 'modules/common/PEAR/Config.php'; $c = new Config(); $root =& $c->parseConfig($data['data'], $data['type']); // save the modified config array $c->writeConfig($data['file'], $data['type'], array('name' => $data['var_name'])); }
/** * Read the configuration file, parse its XML contents, and return the * result as an array. * * @param string configFile The name of the configuration file. * @return mixed The parsed configuration file as an array or PEAR_Error * if the configuration file could not be read. */ function loadConfiguration($configFile) { $config = new Config(); $root =& $config->parseConfig($configFile, 'xml'); if (PEAR::isError($root)) { return $root; } $root =& $root->toArray(); return $root['root']; }
function __construct($filename = null, $type = 'xml') { $this->type = $type; $conf = new Config(); if (!is_null($filename)) { $this->rootObj = $conf->parseConfig($filename, $type); } else { $this->rootObj = new Config_Container('section', 'config'); $conf->setroot($this->rootObj); } }
function readConfigFile($site_name, $type = "xml") { global $PattenConfigDir; $config = new Config(); $root =& $config->parseConfig($PattenConfigDir . $site_name . '.' . $type, $type); if (PEAR::isError($root)) { die($root->getMessage()); } $data = $root->toArray(); return $data; }
public static function setDbConfig(Config $config = null) { if (empty($config)) { if (empty(self::$dbConfig)) { self::$dbConfig = Config::parseConfig(DEFAULT_CONFIG_PATH, CONFIG_PATH); } } else { self::$dbConfig($config); } return self::$dbConfig; }
function configureTestFromArray($aConfigurationEntries, $configFilename) { $config = new Config(); $configContainer =& $config->parseConfig(CONFIG_TEMPLATE, 'inifile'); foreach ($aConfigurationEntries as $configurationEntry) { $aConfigurationEntry = explode("=", $configurationEntry); list($configurationKey, $configurationValue) = $aConfigurationEntry; list($sectionName, $variableName) = explode('.', $configurationKey); $section =& $configContainer->getItem('section', $sectionName); $section->setDirective($variableName, $configurationValue); } $config->writeConfig($configFilename, 'inifile'); }
function loadValuesFromPath($path) { if (!is_file($path)) { return array(); } $config = new Config(); $configContainer = $config->parseConfig($path, $this->configType, $this->options); if ($configContainer instanceof PEAR_Error) { return array(); } $rootConfig = $configContainer->toArray(); return $rootConfig["root"]; }
/** * Control the main setup process * * @param array $data * $data['data'] Data (array or ...) to store * $data['file'] File to store * $data['var_name'] Name of the data array or ... * $data['type'] Data type * $data['reload'] Reload page if true * * @param array $data */ function perform(&$data) { // include PEAR Config class include_once SF_BASE_DIR . 'modules/common/PEAR/Config.php'; $c = new Config(); $root =& $c->parseConfig($data['data'], $data['type']); // save the modified config array $c->writeConfig($data['file'], $data['type'], array('name' => $data['var_name'])); if ($data['reload'] == TRUE) { // reload page @header('Location: ' . SF_BASE_LOCATION . '/' . SF_CONTROLLER . '?' . SF_ADMIN_CODE . '=1'); exit; } return SF_IS_VALID_ACTION; }
function prepareScanningData() { $old = error_reporting(); error_reporting($old & ~E_STRICT); require_once 'Config.php'; $conf = new Config(); $root = $conf->parseConfig(dirname(__FILE__) . '/scan-data.xml', 'XML'); if (PEAR::isError($root)) { error_reporting($old); throw new Exception(__METHOD__ . '(): Error while reading menu configuration: ' . $root->getMessage()); } $rootArray = $root->toArray(); $arr = $rootArray['root']['root']; M('Db')->execBatch($arr['init']); foreach ($arr['test'] as $test) { $userId = $test["@"]['id']; addReceipt($userId, $test['receipt']); } M('Db')->execBatch($arr['post_init']); return $userId; }
/** * Loads the directories from an ini file. * If you don't specify the config file, it will be determined * automatically. * * @access public * @param string $strFile The file to load the data from (ini file) * @return mixed True on success, PEAR_Error on failure */ function loadFromFile($strFile = null) { $strFile = $this->getDefaultConfigFile(); if (!file_exists($strFile)) { //Not existing config file isn't an error return true; } $conf = new Config(); $root =& $conf->parseConfig($strFile, 'inifile'); if (PEAR::isError($root)) { return $root; } $arSettings = $root->toArray(); if (!isset($arSettings['root']['paths'])) { return true; } foreach ($arSettings['root']['paths'] as $strId => $strValue) { if ($strValue != '') { $this->arCache[$strId] = $strValue; } } return true; }
/** * test to ensure that special characters * are written and read correctly * IniCommented config class should quote all special chars * except backslash and single quote * * note: parse_ini_file() will break array on double quote * */ function test_iniFile() { $min = 32; $max = 126; for ($i = $min; $i <= $max; $i++) { if ($i == 34 || $i == 36) { // '"' (any version) and '$' (5.3) break the test continue; } $aIni = array(); $aIni['test1'][$i] = 'test' . chr($i); $aIni['test2'][$i] = chr($i) . 'test'; $aIni['test3'][$i] = 'te' . chr($i) . 'st'; $ini = MAX_PATH . '/var/test_' . $i . '.ini'; $oConfig = new Config(); $oConfig->parseConfig($aIni, 'phpArray'); $this->assertTrue($oConfig->writeConfig($ini, 'IniCommented')); $aResult = @parse_ini_file($ini, true); $this->assertEqual($aResult['test1'][$i], $aIni['test1'][$i], 'ERROR:' . $i); $this->assertEqual($aResult['test2'][$i], $aIni['test2'][$i], 'ERROR:' . $i); $this->assertEqual($aResult['test3'][$i], $aIni['test3'][$i], 'ERROR:' . $i); @unlink($ini); } }
/** * A method to write the configuration file for plugin. Also creates "fake" * configuration files when required by multi-host installations. * * @static * @param array $aConfig The configuration array to save as a configuration file. * @param string $module The plugin module name (i.e. /plugins/module directory). * @param string $package An optional plugin package name (i.e. /plugins/module/package * directory). If not given, writes the module level * configuration file path. * @param string $name An optional plugin name (i.e. /plugins/module/package/plugin.plugin.php). * If not given, writes the package level configuration file, or * the module level configuration file, depending on the $package * parameter. * @return boolean True on success, false otherwise. */ function writePluginConfig($aConfig, $module, $package = null, $name = null) { $conf = $GLOBALS['_MAX']['CONF']; // Prepare the config file for writing, using the delivery engine // host as the hostname for the "real" config file $url = @parse_url('http://' . $conf['webpath']['delivery']); if (!isset($url['host'])) { return false; } $deliveryHost = $url['host']; $configFileName = MAX_Plugin::getConfigFileName($module, $package, $name, false, $deliveryHost); if (!file_exists($configFileName)) { MAX_Plugin::copyDefaultConfig($module, $package, $name); } // Create a new config class, parse the config array, and write to disk $oConfig = new Config(); $oConfig->parseConfig($aConfig, 'phpArray'); $result = $oConfig->writeConfig($configFileName, 'inifile'); if ($result == false || PEAR::isError($result)) { return false; } // Check the other possible host names, and write out the fake // configuration files if different $url = @parse_url('http://' . $conf['webpath']['admin']); if (isset($url['host'])) { $adminHost = $url['host']; if ($adminHost != $deliveryHost) { // Create fake file for this host $configFileName = MAX_Plugin::getConfigFileName($module, $package, $name, false, $adminHost); $aConfig = array('realConfig' => $deliveryHost); $oConfig = new Config(); $oConfig->parseConfig($aConfig, 'phpArray'); if (!$oConfig->writeConfig($configFileName, 'inifile')) { return false; } } } $url = @parse_url('http://' . $conf['webpath']['deliverySSL']); if (isset($url['host'])) { $deliverySslHost = $url['host']; if ($deliverySslHost != $deliveryHost) { // Create fake file for this host $configFileName = MAX_Plugin::getConfigFileName($module, $package, $name, false, $deliverySslHost); $aConfig = array('realConfig' => $deliveryHost); $oConfig = new Config(); $oConfig->parseConfig($aConfig, 'phpArray'); if (!$oConfig->writeConfig($configFileName, 'inifile')) { return false; } } } return true; }
<?php ini_set("include_path", ini_get("include_path") . ";.;../../../WEBSERVER/pear"); $host = "127.0.0.1"; $timeout = 0.5; // ********* // leggo configurazione da file XML (richiede il modulo CONFIG di PEAR) require_once "Config.php"; $conf = new Config(); $root =& $conf->parseConfig('../config/config.xml', 'XML'); if (PEAR::isError($root)) { die('Error reading XML config file: ' . $root->getMessage()); } $settings = $root->toArray(); // ********* // porta per mysql $mysqlport = $settings['root']['conf']['DB']['dbport']; // leggo keyforum.conf per rilevare le porte richieste $filename = "../../WEBSERVER/Apache/conf/keyforum.conf"; $handle = fopen($filename, "r"); while (!feof($handle)) { $buffer = fgets($handle); if (preg_match("/\\blisten\\b/i", $buffer)) { $portlist .= trim(str_replace("\n", "", preg_replace("/\\blisten\\b/i", "", $buffer))) . ","; } } fclose($handle); // altre porte (keyforum com = 40569 , keyforum shell = 40565") require "otherport.php"; $portlist = $portlist . $mysqlport . $otherport; $ports = explode(',', $portlist);
/** * 画面IDをセットする * 画面IDに紐付く画面タイトルとモジュール名とアクション名をsmartyにセットする * @access public * @param string $id 画面ID */ public function setScreenId($id) { /* Decoratorテンプレートをセットする */ $this->setDecoratorDirectory(MO_TEMPLATE_DIR); $this->setDecoratorTemplate(MO_TEMPLATE_FILE); // スクリーンタイトルを取得する $title = ''; $screenName = ''; $screenNameList = MO_CONFIG_DIR . '/' . S4_SCREEN_NAME_LIST; $moduleName = ''; $actionName = ''; if (file_exists($screenNameList)) { $config = new Config(); $container = $config->parseConfig($screenNameList, 'inifile'); $child = $container->searchPath(array('ScreenName')); $screenList = $child->toArray(); if (isset($screenList['ScreenName'][$id])) { list($screenName, $moduleName, $actionName) = explode(',', $screenList['ScreenName'][$id]); } // タイトルバーに画面タイトルをセットする $title = $screenName; } // 画面タイトルを設定する $this->setAttribute('title', $title); $this->setAttribute('screen_name', $screenName); }
$dest_dir = './uploads/'; $dest_name = $file->moveTo($dest_dir); if (PEAR::isError($dest_name)) { $std->Error($dest_name->getMessage()); } $real = $file->getProp('real'); // echo "Uploaded $real as $dest_name in $dest_dir\n"; } elseif ($file->isMissing()) { echo "" . $lang['reg_nofile'] . ""; } elseif ($file->isError()) { echo $file->errorMsg() . "\n"; } //print_r($file->getProp()); //echo '</pre>'; // leggo il file $root =& $xmldata->parseConfig('uploads/' . $file->getProp('name'), 'XML'); if (PEAR::isError($root)) { $std->Error('Error reading XML config file: ' . $root->getMessage()); } $userdata = $root->toArray(); $userkey = $userdata['root']['USERDATA']['KEY']; $usernick = $userdata['root']['USERDATA']['NICK']; $userpwd = $userdata['root']['USERDATA']['PWD']; $usertpp = $userdata['root']['USERDATA']['TPP']; $userppp = $userdata['root']['USERDATA']['PPP']; $userlang = $userdata['root']['USERDATA']['LANG']; } ?> <tr><td>
public function GetSettings($file) { $config = new Config(); /** @var $current Config_Container */ $current = $config->parseConfig($file, 'PHPArray'); $currentValues = $current->getItem("section", Configuration::SETTINGS)->toArray(); return $currentValues[Configuration::SETTINGS]; }
<?php /** * Config.php example with Apache container * @author Bertrand Mansion <*****@*****.**> * @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)) {
/** * Sets the look-and-feel model that renders the progress bar. * * @param string $file file name of model properties * @param string $type type of external ressource (phpArray, iniFile, XML ...) * * @return void * @since 1.0 * @access public * @throws HTML_PROGRESS_ERROR_INVALID_INPUT * @see setUI() */ function setModel($file, $type) { if (!file_exists($file)) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1)); } include_once 'Config.php'; $conf = new Config(); if (!$conf->isConfigTypeRegistered($type)) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2)); } $data = $conf->parseConfig($file, $type); $structure = $data->toArray(false); $progress = $structure['root']; $ui = new HTML_Progress_UI(); if (isset($progress['core']['speed'])) { $this->setAnimSpeed(intval($progress['core']['speed'])); } if (isset($progress['core']['indeterminate'])) { $mode = strtolower(trim($progress['core']['indeterminate'])) == 'true'; $this->setIndeterminate($mode); } if (isset($progress['core']['increment'])) { $this->setIncrement(intval($progress['core']['increment'])); } if (isset($progress['core']['javascript']) && file_exists($progress['core']['javascript'])) { $ui->setScript($progress['core']['javascript']); } if (isset($progress['orientation']['shape'])) { $ui->setOrientation(intval($progress['orientation']['shape'])); } if (isset($progress['orientation']['fillway'])) { $ui->setFillWay($progress['orientation']['fillway']); } if (isset($progress['cell']['count'])) { $ui->setCellCount(intval($progress['cell']['count'])); } if (isset($progress['cell']['font-family'])) { if (is_array($progress['cell']['font-family'])) { $progress['cell']['font-family'] = implode(",", $progress['cell']['font-family']); } } if (isset($progress['cell'])) { $ui->setCellAttributes($progress['cell']); } if (isset($progress['border'])) { $this->setBorderPainted(true); $ui->setBorderAttributes($progress['border']); } if (isset($progress['string']['font-family'])) { if (is_array($progress['string']['font-family'])) { $progress['string']['font-family'] = implode(",", $progress['string']['font-family']); } } if (isset($progress['string'])) { $this->setStringPainted(true); $ui->setStringAttributes($progress['string']); } if (isset($progress['progress'])) { $ui->setProgressAttributes($progress['progress']); } $this->_UI = $ui; }
<?php require_once 'ez_sql.php'; require "functions.php"; include "core.php"; include "testa.php"; // lingua $lang += load_lang('lang_mngws', $blanguage); //inizializzo il db //classe PEAR per file config (XML) require_once "Config.php"; $xmldata = new Config(); $root =& $xmldata->parseConfig('http://' . $_SERVER['HTTP_HOST'] . '/config/config.xml', 'XML'); if (PEAR::isError($root)) { die($lang['mngws_error1'] . $root->getMessage()); } $settings = $root->toArray(); // dati del db $_ENV['sql_host'] = $settings['root']['conf']['DB']['host']; $_ENV['sql_user'] = $settings['root']['conf']['DB']['dbuser']; $_ENV['sql_passwd'] = $settings['root']['conf']['DB']['dbpassword']; $_ENV['sql_dbname'] = $settings['root']['conf']['DB']['dbname']; $_ENV['sql_dbport'] = $settings['root']['conf']['DB']['dbport']; if (!$_ENV['sql_dbport']) { $_ENV['sql_dbport'] = "3306"; } $db = new db($_ENV['sql_user'], $_ENV['sql_passwd'], $_ENV['sql_dbname'], $_ENV['sql_host'] . ":" . $_ENV['sql_dbport']); if (!$_REQUEST['ws']) { $data = $db->get_results("SELECT DISTINCT SUBKEY FROM config WHERE MAIN_GROUP='WEBSERVER'"); layoutws($data); die;
/** * Copy the modified config values from the config.ini to the appropriate setting in the database */ function moveConfigSettingsToDB() { require_once 'Config.php'; // Get config settings from config.ini $oKTConfig = KTConfig::getSingleton(); $configPath = $oKTConfig->getConfigFilename(); $c = new Config(); $root =& $c->parseConfig($configPath, "IniCommented"); if (PEAR::isError($root)) { return $root; } $confRoot = $root->toArray(); $conf = $confRoot['root']; // Get the default settings from the database $query = "SELECT id, s.group_name, s.item, s.value, s.default_value\n FROM config_settings s\n ORDER BY group_name, item"; $settings = DBUtil::getResultArray($query); if (PEAR::isError($settings)) { return $settings; } // update the settings in the database if not set to default or equal to the default value foreach ($settings as $item) { if (!isset($conf[$item['group_name']][$item['item']])) { continue; // Don't overwrite the default with a null value } $confValue = $conf[$item['group_name']][$item['item']]; if ($confValue == 'default') { continue; // skip over if its set to default } if ($confValue == $item['value']) { continue; // skip over if it already has the same value } if ($confValue == $item['default_value']) { if ($item['value'] == 'default' || $item['value'] == $item['default_value']) { continue; // skip over if it has the same value as the default value } // Set the value to default $confValue = 'default'; } // Update the setting $res = DBUtil::autoUpdate('config_settings', array('value' => $confValue), $item['id']); if (PEAR::isError($res)) { return $res; } } return true; }
$conf['storage']['params']['username'] = '******'; $conf['storage']['params']['password'] = '******'; $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 '<pre>' . $root->toString('phparray', array('name' => 'test')) . '</pre>'; 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 '<pre>' . $iniRoot->toString('inicommented') . '</pre>'; // Gonna make an array with it echo '<pre>'; var_dump($iniRoot->toArray()); echo '</pre>'; // 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 '<pre>' . $root->toString('phparray', array('name' => 'php_ini')) . '</pre>';
public function Register($configFile, $configId, $overwrite = false) { if (!file_exists($configFile)) { echo "Missing config file: {$configFile}. If there is a .dist config file in this location, please copy it as {$configFile}"; throw new Exception("Missing config file: {$configFile}"); } $config = new Config(); $container = $config->parseConfig($configFile, 'PHPArray'); $this->AddConfig($configId, $container, $overwrite); }
public function __construct() { $this->config['db'] = Config::parseConfig('db', true); }
/** * Load a config file * Used for the unit tests * * @param unknown_type $filename * @param unknown_type $bDefault * @return unknown */ function loadFile($filename, $bDefault = false) { $c = new Config(); $root =& $c->parseConfig($filename, "IniCommented"); if (PEAR::isError($root)) { return $root; } $this->aFileRoot[$filename] =& $root; $conf =& $root->toArray(); foreach ($conf["root"] as $seck => $secv) { $aSectionFile[$seck] = $filename; if (is_array($secv)) { foreach ($secv as $k => $v) { $this->setns($seck, $k, $v); } } else { $this->setns(null, $seck, $secv); } } $this->conf = kt_array_merge($this->conf, $conf["root"]); }
<?php /** * Config.php example with IniCommented container * This container is for PHP .ini files, when you want * to keep your comments. If you don't use comments, you'd rather * use the IniFile.php container. * @author Bertrand Mansion <*****@*****.**> * @package Config */ // $Id: IniCommented.php,v 1.3 2003/03/21 18:01:09 mansion Exp $ 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 '<pre>' . $root->toString('phparray', array('name' => 'php_ini')) . '</pre>';