X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/0947b618085f7d46515a3ec06cab5ed818e8635f..a759c5b75b66894b1902327097185840a2557f86:/lib/lib.php?ds=sidebyside diff --git a/lib/lib.php b/lib/lib.php index 9f266aeb..a02fefd0 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -1,26 +1,19 @@ load($sProjectDir.'/.env'); - } - $dotenv->load(CONST_DataDir.'/settings/env.defaults'); + // 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']); + defined('CONST_Default_ModulePath') or define('CONST_Default_ModulePath', $_SERVER['NOMINATIM_DATABASE_MODULE_SRC_PATH']); } function getSetting($sConfName, $sDefault = null) { - $sValue = $_ENV['NOMINATIM_'.$sConfName]; + $sValue = $_SERVER['NOMINATIM_'.$sConfName]; if ($sDefault !== null && !$sValue) { return $sDefault; @@ -40,7 +33,7 @@ function getSettingBool($sConfName) function getSettingConfig($sConfName, $sSystemConfig) { - $sValue = $_ENV['NOMINATIM_'.$sConfName]; + $sValue = $_SERVER['NOMINATIM_'.$sConfName]; if (!$sValue) { return CONST_DataDir.'/settings/'.$sSystemConfig; @@ -138,6 +131,24 @@ function addQuotes($s) return "'".$s."'"; } +function fwriteConstDef($rFile, $sConstName, $value) +{ + $sEscapedValue; + + if (is_bool($value)) { + $sEscapedValue = $value ? 'true' : 'false'; + } elseif (is_numeric($value)) { + $sEscapedValue = strval($value); + } elseif (!$value) { + $sEscapedValue = 'false'; + } else { + $sEscapedValue = addQuotes(str_replace("'", "\\'", (string)$value)); + } + + fwrite($rFile, "@define('CONST_$sConstName', $sEscapedValue);\n"); +} + + function parseLatLon($sQuery) { $sFound = null;