<?php
+require('Symfony/Component/Dotenv/autoload.php');
+
+function loadSettings($sProjectDir)
+{
+ if (!$sProjectDir) {
+ $sProjectDir = getcwd();
+ }
+
+ @define('CONST_InstallDir', $sProjectDir);
+
+ $dotenv = new \Symfony\Component\Dotenv\Dotenv();
+
+ if (file_exists($sProjectDir.'/.env')) {
+ $dotenv->load($sProjectDir.'/.env');
+ }
+ $dotenv->load(CONST_DataDir.'/settings/env.defaults');
+}
+
+function getSetting($sConfName, $sDefault = null)
+{
+ $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)
{
if (!$sUserError) $sUserError = $sError;
if ($a['importance'] != $b['importance'])
return ($a['importance'] > $b['importance']?-1:1);
- return ($a['foundorder'] < $b['foundorder']?-1:1);
+ return $a['foundorder'] <=> $b['foundorder'];
}