Merge pull request #1951 from connortechnology/fix_api_conf_d
updates bootstrap.php.in to match config.php's conf.d loading
This commit is contained in:
commit
e247efcd42
|
@ -113,37 +113,52 @@ CakeLog::config('custom_path', array(
|
||||||
));
|
));
|
||||||
|
|
||||||
Configure::write('ZM_CONFIG', '@ZM_CONFIG@');
|
Configure::write('ZM_CONFIG', '@ZM_CONFIG@');
|
||||||
|
Configure::write('ZM_CONFIG_SUBDIR', '@ZM_CONFIG_SUBDIR@');
|
||||||
Configure::write('ZM_VERSION', '@VERSION@');
|
Configure::write('ZM_VERSION', '@VERSION@');
|
||||||
Configure::write('ZM_API_VERSION', '@API_VERSION@');
|
Configure::write('ZM_API_VERSION', '@API_VERSION@');
|
||||||
|
|
||||||
loadConfigFile();
|
# Process name, value pairs from the main config file first
|
||||||
|
$configvals = process_configfile(Configure::read('ZM_CONFIG'));
|
||||||
|
|
||||||
function loadConfigFile() {
|
# Search for user created config files. If one or more are found then
|
||||||
$configFile = Configure::read('ZM_CONFIG');
|
# update our config value array with those values
|
||||||
$localConfigFile = basename($configFile);
|
$configSubFolder = Configure::read('ZM_CONFIG_SUBDIR');
|
||||||
if ( file_exists( $localConfigFile ) && filesize( $localConfigFile ) > 0 )
|
if ( is_dir($configSubFolder) ) {
|
||||||
{
|
if ( is_readable($configSubFolder) ) {
|
||||||
if ( php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']) )
|
foreach ( glob("$configSubFolder/*.conf") as $filename ) {
|
||||||
print( "Warning, overriding installed $localConfigFile file with local copy\n" );
|
$configvals = array_replace($configvals, process_configfile($filename) );
|
||||||
else
|
|
||||||
error_log( "Warning, overriding installed $localConfigFile file with local copy" );
|
|
||||||
$configFile = $localConfigFile;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
error_log( "WARNING: ZoneMinder configuration subfolder found but is not readable. Check folder permissions on $configSubFolder." );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Now that our array our finalized, define each key => value
|
||||||
|
# pair in the array as a constant
|
||||||
|
foreach( $configvals as $key => $value) {
|
||||||
|
define( $key, $value );
|
||||||
|
Configure::write( $key, $value );
|
||||||
|
}
|
||||||
|
|
||||||
|
function process_configfile($configFile) {
|
||||||
|
if ( is_readable( $configFile ) ) {
|
||||||
|
$configvals = array();
|
||||||
|
|
||||||
$cfg = fopen( $configFile, "r") or die("Could not open config file.");
|
$cfg = fopen( $configFile, "r") or die("Could not open config file.");
|
||||||
while ( !feof($cfg) )
|
while ( !feof($cfg) ) {
|
||||||
{
|
|
||||||
$str = fgets( $cfg, 256 );
|
$str = fgets( $cfg, 256 );
|
||||||
if ( preg_match( '/^\s*$/', $str ))
|
if ( preg_match( '/^\s*$/', $str ))
|
||||||
continue;
|
continue;
|
||||||
elseif ( preg_match( '/^\s*#/', $str ))
|
elseif ( preg_match( '/^\s*#/', $str ))
|
||||||
continue;
|
continue;
|
||||||
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches )) {
|
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches ))
|
||||||
Configure::write( $matches[1], $matches[2] );
|
$configvals[$matches[1]] = $matches[2];
|
||||||
define( $matches[1], $matches[2] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fclose( $cfg );
|
fclose( $cfg );
|
||||||
|
return( $configvals );
|
||||||
|
} else {
|
||||||
|
error_log( "WARNING: ZoneMinder configuration file found but is not readable. Check file permissions on $configFile." );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue