3  * SPDX-License-Identifier: GPL-2.0-only
 
   5  * This file is part of Nominatim. (https://nominatim.org)
 
   7  * Copyright (C) 2022 by the Nominatim developer community.
 
   8  * For a full list of authors see the git log.
 
  11 require_once(CONST_LibDir.'/init-website.php');
 
  12 require_once(CONST_LibDir.'/ParameterParser.php');
 
  13 require_once(CONST_LibDir.'/Status.php');
 
  15 $oParams = new Nominatim\ParameterParser();
 
  16 $sOutputFormat = $oParams->getSet('format', array('text', 'json'), 'text');
 
  18 $oDB = new Nominatim\DB(CONST_Database_DSN);
 
  20 if ($sOutputFormat == 'json') {
 
  21     header('content-type: application/json; charset=UTF-8');
 
  26     $oStatus = new Nominatim\Status($oDB);
 
  29     if ($sOutputFormat == 'json') {
 
  30         $epoch = $oStatus->dataDate();
 
  34                       'data_updated' => (new DateTime('@'.$epoch))->format(DateTime::RFC3339),
 
  35                       'software_version' => CONST_NominatimVersion
 
  37         $sDatabaseVersion = $oStatus->databaseVersion();
 
  38         if ($sDatabaseVersion) {
 
  39             $aResponse['database_version'] = $sDatabaseVersion;
 
  41         javascript_renderData($aResponse);
 
  45 } catch (Exception $oErr) {
 
  46     if ($sOutputFormat == 'json') {
 
  48                       'status' => $oErr->getCode(),
 
  49                       'message' => $oErr->getMessage()
 
  51         javascript_renderData($aResponse);
 
  53         header('HTTP/1.0 500 Internal Server Error');
 
  54         echo 'ERROR: '.$oErr->getMessage();