diff --git a/web/api/app/Config/bootstrap.php.in b/web/api/app/Config/bootstrap.php.in index f1c6d85d4..275c55bbb 100644 --- a/web/api/app/Config/bootstrap.php.in +++ b/web/api/app/Config/bootstrap.php.in @@ -120,29 +120,17 @@ Configure::write('ZM_CONFIG_SUBDIR', '@ZM_CONFIG_SUBDIR@'); Configure::write('ZM_VERSION', '@VERSION@'); Configure::write('ZM_API_VERSION', '@API_VERSION@'); -# Process name, value pairs from the main config file first -$configvals = api_process_configfile(Configure::read('ZM_CONFIG')); +require_once "../../../includes/config.php"; +global $configvals; -# Search for user created config files. If one or more are found then -# update our config value array with those values -$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 +# Now that our array our finalized, and the config has been defined. +# Add them to the cakephp Config foreach( $configvals as $key => $value) { - define( $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 if ( ! defined('ZM_SERVER_ID') ) { 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 ); - } } -