2013-01-24 16:42:34 +04:00
|
|
|
<?php
|
2018-05-05 00:37:48 +03:00
|
|
|
|
2020-12-15 12:09:55 +03:00
|
|
|
require_once(CONST_LibDir.'/init-website.php');
|
|
|
|
require_once(CONST_LibDir.'/ParameterParser.php');
|
|
|
|
require_once(CONST_LibDir.'/Status.php');
|
2013-01-24 16:42:34 +04:00
|
|
|
|
2018-05-05 00:37:48 +03:00
|
|
|
$oParams = new Nominatim\ParameterParser();
|
|
|
|
$sOutputFormat = $oParams->getSet('format', array('text', 'json'), 'text');
|
2016-09-14 04:16:46 +03:00
|
|
|
|
2020-12-15 17:36:13 +03:00
|
|
|
$oDB = new Nominatim\DB(CONST_Database_DSN);
|
2013-01-24 16:42:34 +04:00
|
|
|
|
2018-05-05 00:37:48 +03:00
|
|
|
if ($sOutputFormat == 'json') {
|
|
|
|
header('content-type: application/json; charset=UTF-8');
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
2014-01-23 20:06:43 +04:00
|
|
|
|
2018-05-05 00:37:48 +03:00
|
|
|
|
|
|
|
try {
|
2019-02-24 18:14:36 +03:00
|
|
|
$oStatus = new Nominatim\Status($oDB);
|
2018-05-05 00:37:48 +03:00
|
|
|
$oStatus->status();
|
|
|
|
} catch (Exception $oErr) {
|
|
|
|
if ($sOutputFormat == 'json') {
|
|
|
|
$aResponse = array(
|
2018-05-08 01:37:41 +03:00
|
|
|
'status' => $oErr->getCode(),
|
|
|
|
'message' => $oErr->getMessage()
|
|
|
|
);
|
2018-05-05 00:37:48 +03:00
|
|
|
javascript_renderData($aResponse);
|
|
|
|
} else {
|
|
|
|
header('HTTP/1.0 500 Internal Server Error');
|
|
|
|
echo 'ERROR: '.$oErr->getMessage();
|
|
|
|
}
|
|
|
|
exit;
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
2018-05-05 00:37:48 +03:00
|
|
|
|
|
|
|
|
|
|
|
if ($sOutputFormat == 'json') {
|
|
|
|
$epoch = $oStatus->dataDate();
|
|
|
|
$aResponse = array(
|
2018-05-08 01:37:41 +03:00
|
|
|
'status' => 0,
|
|
|
|
'message' => 'OK',
|
2021-03-01 18:47:19 +03:00
|
|
|
'data_updated' => (new DateTime('@'.$epoch))->format(DateTime::RFC3339),
|
|
|
|
'software_version' => CONST_NominatimVersion
|
2018-05-08 01:37:41 +03:00
|
|
|
);
|
2021-03-02 00:17:16 +03:00
|
|
|
$sDatabaseVersion = $oStatus->databaseVersion();
|
|
|
|
if ($sDatabaseVersion) {
|
|
|
|
$aResponse['database_version'] = $sDatabaseVersion;
|
|
|
|
}
|
2018-05-05 00:37:48 +03:00
|
|
|
javascript_renderData($aResponse);
|
|
|
|
} else {
|
|
|
|
echo 'OK';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
2014-01-23 20:48:20 +04:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
exit;
|