+function loadSettings($sProjectDir)
+{
+ @define('CONST_InstallDir', $sProjectDir);
+ // Temporary hack to set the direcory via environment instead of
+ // the installed scripts. Neither setting is part of the official
+ // set of settings.
+ defined('CONST_DataDir') or define('CONST_DataDir', $_SERVER['NOMINATIM_DATADIR']);
+ defined('CONST_BinDir') or define('CONST_BinDir', $_SERVER['NOMINATIM_BINDIR']);
+}
+
+function getSetting($sConfName, $sDefault = null)
+{
+ $sValue = $_SERVER['NOMINATIM_'.$sConfName];
+
+ if ($sDefault !== null && !$sValue) {
+ return $sDefault;
+ }
+
+ return $sValue;
+}
+
+function getSettingBool($sConfName)
+{
+ $sVal = strtolower(getSetting($sConfName));
+
+ return strcmp($sVal, 'yes') == 0
+ || strcmp($sVal, 'true') == 0
+ || strcmp($sVal, '1') == 0;
+}
+
+function getSettingConfig($sConfName, $sSystemConfig)
+{
+ $sValue = $_SERVER['NOMINATIM_'.$sConfName];
+
+ if (!$sValue) {
+ return CONST_DataDir.'/settings/'.$sSystemConfig;
+ }
+
+ return $sValue;
+}
+