mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
use explicit DSN for website scripts
Website scripts have no access to the dotenv variables, so use the DSN constant instead when connecting to the database.
This commit is contained in:
@@ -9,7 +9,7 @@ $oParams = new Nominatim\ParameterParser();
|
||||
$sOutputFormat = $oParams->getSet('format', array('json'), 'json');
|
||||
set_exception_handler_by_format($sOutputFormat);
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB = new Nominatim\DB(CONST_Database_DSN);
|
||||
$oDB->connect();
|
||||
|
||||
$sSQL = 'select placex.place_id, country_code,';
|
||||
|
||||
@@ -25,7 +25,7 @@ $bIncludeHierarchy = $oParams->getBool('hierarchy', false);
|
||||
$bGroupHierarchy = $oParams->getBool('group_hierarchy', false);
|
||||
$bIncludePolygonAsGeoJSON = $oParams->getBool('polygon_geojson', false);
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB = new Nominatim\DB(CONST_Database_DSN);
|
||||
$oDB->connect();
|
||||
|
||||
$sLanguagePrefArraySQL = $oDB->getArraySQL($oDB->getDBQuotedList($aLangPrefOrder));
|
||||
|
||||
@@ -15,7 +15,7 @@ set_exception_handler_by_format($sOutputFormat);
|
||||
// Preferred language
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB = new Nominatim\DB(CONST_Database_DSN);
|
||||
$oDB->connect();
|
||||
|
||||
$hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
|
||||
@@ -13,7 +13,7 @@ $iDays = $oParams->getInt('days', false);
|
||||
$bReduced = $oParams->getBool('reduced', false);
|
||||
$sClass = $oParams->getString('class', false);
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB = new Nominatim\DB(CONST_Database_DSN);
|
||||
$oDB->connect();
|
||||
|
||||
$iTotalBroken = (int) $oDB->getOne('SELECT count(*) FROM import_polygon_error');
|
||||
|
||||
@@ -16,7 +16,7 @@ set_exception_handler_by_format($sOutputFormat);
|
||||
// Preferred language
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB = new Nominatim\DB(CONST_Database_DSN);
|
||||
$oDB->connect();
|
||||
|
||||
$hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
|
||||
@@ -6,7 +6,7 @@ require_once(CONST_LibDir.'/Geocode.php');
|
||||
require_once(CONST_LibDir.'/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB = new Nominatim\DB(CONST_Database_DSN);
|
||||
$oDB->connect();
|
||||
$oParams = new Nominatim\ParameterParser();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ require_once(CONST_LibDir.'/Status.php');
|
||||
$oParams = new Nominatim\ParameterParser();
|
||||
$sOutputFormat = $oParams->getSet('format', array('text', 'json'), 'text');
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB = new Nominatim\DB(CONST_Database_DSN);
|
||||
|
||||
if ($sOutputFormat == 'json') {
|
||||
header('content-type: application/json; charset=UTF-8');
|
||||
|
||||
Reference in New Issue
Block a user