]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/lib.php
implement warming in new cli tool
[nominatim.git] / lib / lib.php
index 74abe6a28cc03cb778463cb96d789d8267a99870..5d4038d6db9eb3570dfee4ba9c614046fd55e01f 100644 (file)
@@ -5,6 +5,11 @@ require('Symfony/Component/Dotenv/autoload.php');
 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']);
 
     $dotenv = new \Symfony\Component\Dotenv\Dotenv();
     $dotenv->load(CONST_DataDir.'/settings/env.defaults');
@@ -134,6 +139,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;