本文整理汇总了PHP中mergeConfigFiles函数的典型用法代码示例。如果您正苦于以下问题:PHP mergeConfigFiles函数的具体用法?PHP mergeConfigFiles怎么用?PHP mergeConfigFiles使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mergeConfigFiles函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mergeConfigFiles
function mergeConfigFiles($realConfig, $fakeConfig)
{
foreach ($fakeConfig as $key => $value) {
if (is_array($value)) {
if (!isset($realConfig[$key])) {
$realConfig[$key] = array();
}
$realConfig[$key] = mergeConfigFiles($realConfig[$key], $value);
} else {
if (isset($realConfig[$key]) && is_array($realConfig[$key])) {
$realConfig[$key][0] = $value;
} else {
if (isset($realConfig) && !is_array($realConfig)) {
$temp = $realConfig;
$realConfig = array();
$realConfig[0] = $temp;
}
$realConfig[$key] = $value;
}
}
}
unset($realConfig['realConfig']);
return $realConfig;
}
示例2: parseIniFile
/**
* The general (non-delivery engine) function to parse the configuration .ini file
*
* @param string $configPath The directory to load the config file from.
* Default is Max's /var directory.
* @param string $configFile The configuration file name (eg. "geotargeting").
* Default is no name (ie. the main Max
* configuration file).
* @param boolean $sections Process sections, as per parse_ini_file().
* @param string $type The config file type value (eg. ".php"). Allows BC
* support for old ".ini" files.
*
* @return mixed The array resulting from the call to parse_ini_file(), with
* the appropriate .php file for the installation.
*/
function parseIniFile($configPath = null, $configFile = null, $sections = true, $type = '.php')
{
// Set up the configuration .ini file path location
if (is_null($configPath)) {
$configPath = MAX_PATH . '/var';
}
// Set up the configuration .ini file type name
if (!is_null($configFile)) {
$configFile = '.' . $configFile;
}
// Is this a web, or a cli call?
if (is_null($configFile) && !isset($_SERVER['SERVER_NAME'])) {
if (!isset($GLOBALS['argv'][1]) && !file_exists($configPath . '/default' . $configFile . '.conf' . $type)) {
echo MAX_PRODUCT_NAME . " was called via the command line, but had no host as a parameter.\n";
exit(1);
}
$host = trim($GLOBALS['argv'][1]);
} else {
$host = OX_getHostName();
}
// Is the system running the test environment?
if (is_null($configFile) && defined('TEST_ENVIRONMENT_RUNNING')) {
// Does the test environment config exist?
$testFilePath = $configPath . '/test.conf' . $type;
if (file_exists($testFilePath)) {
return @parse_ini_file($testFilePath, $sections);
} else {
// Define a value so that we know the testing environment is not
// configured, so that the TestRenner class knows not to run any
// tests, and return an empty config
define('TEST_ENVIRONMENT_NO_CONFIG', true);
return array();
}
}
// Is the .ini file for the hostname being used directly accessible?
if (file_exists($configPath . '/' . $host . $configFile . '.conf' . $type)) {
// Parse the configuration file
$conf = @parse_ini_file($configPath . '/' . $host . $configFile . '.conf' . $type, $sections);
// Is this a real config file?
if (!isset($conf['realConfig'])) {
// Yes, return the parsed configuration file
return $conf;
}
// Parse and return the real configuration .ini file
if (file_exists($configPath . '/' . $conf['realConfig'] . $configFile . '.conf' . $type)) {
$realConfig = @parse_ini_file(MAX_PATH . '/var/' . $conf['realConfig'] . '.conf' . $type, true);
$mergedConf = mergeConfigFiles($realConfig, $conf);
// if not multiple levels of configs
if (!isset($mergedConf['realConfig'])) {
return $mergedConf;
}
}
} elseif ($configFile === '.plugin') {
// For plugins, if no configuration file is found, return the sane default values
$pluginType = basename($configPath);
$defaultConfig = MAX_PATH . '/plugins/' . $pluginType . '/default.plugin.conf' . $type;
if (file_exists($defaultConfig)) {
return parse_ini_file($defaultConfig, $sections);
} else {
echo MAX_PRODUCT_NAME . " could not read the default configuration file for the {$pluginType} plugin";
exit(1);
}
}
// Check for a default.conf.php file...
if (file_exists($configPath . '/default' . $configFile . '.conf' . $type)) {
// Parse the configuration file
$conf = @parse_ini_file($configPath . '/default' . $configFile . '.conf' . $type, $sections);
// Is this a real config file?
if (!isset($conf['realConfig'])) {
// Yes, return the parsed configuration file
return $conf;
}
// Parse and return the real configuration .ini file
if (file_exists($configPath . '/' . $conf['realConfig'] . $configFile . '.conf' . $type)) {
$realConfig = @parse_ini_file(MAX_PATH . '/var/' . $conf['realConfig'] . '.conf' . $type, true);
$mergedConf = mergeConfigFiles($realConfig, $conf);
// if not multiple levels of configs
if (!isset($mergedConf['realConfig'])) {
return $mergedConf;
}
}
}
// Got all this way, and no configuration file yet found - maybe
// the user is upgrading from an old version where the config
// files have a .ini prefix instead of .php...
//.........这里部分代码省略.........