X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/15a1666f8a1e19c338015fccd502be6cfd5c24df..0947b618085f7d46515a3ec06cab5ed818e8635f:/lib/lib.php?ds=sidebyside diff --git a/lib/lib.php b/lib/lib.php index 753159d2..9f266aeb 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -18,9 +18,35 @@ function loadSettings($sProjectDir) $dotenv->load(CONST_DataDir.'/settings/env.defaults'); } -function getSetting($sConfName) +function getSetting($sConfName, $sDefault = null) { - return $_ENV['NOMINATIM_'.$sConfName]; + $sValue = $_ENV['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 = $_ENV['NOMINATIM_'.$sConfName]; + + if (!$sValue) { + return CONST_DataDir.'/settings/'.$sSystemConfig; + } + + return $sValue; } function fail($sError, $sUserError = false)