3 require_once(CONST_LibDir.'/init-website.php');
4 require_once(CONST_LibDir.'/ParameterParser.php');
5 require_once(CONST_LibDir.'/Status.php');
7 $oParams = new Nominatim\ParameterParser();
8 $sOutputFormat = $oParams->getSet('format', array('text', 'json'), 'text');
10 $oDB = new Nominatim\DB(CONST_Database_DSN);
12 if ($sOutputFormat == 'json') {
13 header('content-type: application/json; charset=UTF-8');
18 $oStatus = new Nominatim\Status($oDB);
21 if ($sOutputFormat == 'json') {
22 $epoch = $oStatus->dataDate();
26 'data_updated' => (new DateTime('@'.$epoch))->format(DateTime::RFC3339),
27 'software_version' => CONST_NominatimVersion
29 $sDatabaseVersion = $oStatus->databaseVersion();
30 if ($sDatabaseVersion) {
31 $aResponse['database_version'] = $sDatabaseVersion;
33 javascript_renderData($aResponse);
37 } catch (Exception $oErr) {
38 if ($sOutputFormat == 'json') {
40 'status' => $oErr->getCode(),
41 'message' => $oErr->getMessage()
43 javascript_renderData($aResponse);
45 header('HTTP/1.0 500 Internal Server Error');
46 echo 'ERROR: '.$oErr->getMessage();