From 12ba217de0ad812c46e25ffef0ad253fc2211dcf Mon Sep 17 00:00:00 2001 From: pliablepixels Date: Sat, 13 Jun 2015 16:32:37 +0000 Subject: [PATCH] Added API version in addition to ZM version, also added loadConfig code that was there in the angular-ui branch but not merged to master --- web/api/app/Config/bootstrap.php.in | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/web/api/app/Config/bootstrap.php.in b/web/api/app/Config/bootstrap.php.in index e4102d62b..cff9a29dd 100644 --- a/web/api/app/Config/bootstrap.php.in +++ b/web/api/app/Config/bootstrap.php.in @@ -107,3 +107,37 @@ CakeLog::config('error', array( 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), 'file' => 'error', )); + +Configure::write('ZM_CONFIG', '@ZM_CONFIG@'); +Configure::write('ZM_VERSION', '@VERSION@'); +Configure::write('ZM_API_VERSION', '@API_VERSION@'); + +loadConfigFile(); + +function loadConfigFile() { + $configFile = Configure::read('ZM_CONFIG'); + $localConfigFile = basename($configFile); + if ( file_exists( $localConfigFile ) && filesize( $localConfigFile ) > 0 ) + { + if ( php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']) ) + print( "Warning, overriding installed $localConfigFile file with local copy\n" ); + else + error_log( "Warning, overriding installed $localConfigFile file with local copy" ); + $configFile = $localConfigFile; + } + + $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 )) + Configure::write("$matches[1]", "$matches[2]"); + } + fclose( $cfg ); +} + +