remove duplicated config code from bootstrap and just include config.php
parent
53ce8c008a
commit
2c02a479d6
|
@ -120,29 +120,17 @@ 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@');
|
||||||
|
|
||||||
# Process name, value pairs from the main config file first
|
require_once "../../../includes/config.php";
|
||||||
$configvals = api_process_configfile(Configure::read('ZM_CONFIG'));
|
global $configvals;
|
||||||
|
|
||||||
# Search for user created config files. If one or more are found then
|
# Now that our array our finalized, and the config has been defined.
|
||||||
# update our config value array with those values
|
# Add them to the cakephp Config
|
||||||
$configSubFolder = Configure::read('ZM_CONFIG_SUBDIR');
|
|
||||||
if ( is_dir($configSubFolder) ) {
|
|
||||||
if ( is_readable($configSubFolder) ) {
|
|
||||||
foreach ( glob("$configSubFolder/*.conf") as $filename ) {
|
|
||||||
$configvals = array_replace($configvals, api_process_configfile($filename) );
|
|
||||||
}
|
|
||||||
} 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) {
|
foreach( $configvals as $key => $value) {
|
||||||
define( $key, $value );
|
|
||||||
Configure::write( $key, $value );
|
Configure::write( $key, $value );
|
||||||
}
|
}
|
||||||
|
if ( 0 ) {
|
||||||
|
// No longer needed, but I want to keep the code for reference
|
||||||
|
//
|
||||||
// For Human-readability, use ZM_SERVER_HOST or ZM_SERVER_NAME in zm.conf, and convert it here to a ZM_SERVER_ID
|
// For Human-readability, use ZM_SERVER_HOST or ZM_SERVER_NAME in zm.conf, and convert it here to a ZM_SERVER_ID
|
||||||
if ( ! defined('ZM_SERVER_ID') ) {
|
if ( ! defined('ZM_SERVER_ID') ) {
|
||||||
App::uses('ClassRegistry', 'Utility');
|
App::uses('ClassRegistry', 'Utility');
|
||||||
|
@ -163,26 +151,4 @@ if ( ! defined('ZM_SERVER_ID') ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function api_process_configfile($configFile) {
|
|
||||||
if ( is_readable( $configFile ) ) {
|
|
||||||
$configvals = array();
|
|
||||||
|
|
||||||
$cfg = fopen( $configFile, 'r') or die('Could not open config file.');
|
|
||||||
while ( !feof($cfg) ) {
|
|
||||||
$str = fgets( $cfg, 256 );
|
|
||||||
if ( preg_match( '/^\s*$/', $str ))
|
|
||||||
continue;
|
|
||||||
elseif ( preg_match( '/^\s*#/', $str ))
|
|
||||||
continue;
|
|
||||||
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches ))
|
|
||||||
$configvals[$matches[1]] = $matches[2];
|
|
||||||
}
|
|
||||||
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