X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/25bdd7c6d99f99e5fe01c86477be1dcabc35ec98..36447c488a78017dc533f7ed42bc8cf20c72556d:/lib/lib.php diff --git a/lib/lib.php b/lib/lib.php index 9861cdd0..7760f695 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -1,21 +1,44 @@ load($sProjectDir.'/.env'); +function getSettingConfig($sConfName, $sSystemConfig) +{ + $sValue = $_SERVER['NOMINATIM_'.$sConfName]; + + if (!$sValue) { + return CONST_DataDir.'/settings/'.$sSystemConfig; } - $dotenv->load(CONST_DataDir.'/settings/env.defaults'); + + return $sValue; } function fail($sError, $sUserError = false) @@ -107,6 +130,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;