]> git.openstreetmap.org Git - nominatim.git/blob - website/status.php
details page: differentiate between spheric distance and distance in meters
[nominatim.git] / website / status.php
1 <?php
2
3 require_once(CONST_BasePath.'/lib/init-website.php');
4 require_once(CONST_BasePath.'/lib/ParameterParser.php');
5 require_once(CONST_BasePath.'/lib/Status.php');
6
7 $oParams = new Nominatim\ParameterParser();
8 $sOutputFormat = $oParams->getSet('format', array('text', 'json'), 'text');
9
10 $oDB = new Nominatim\DB();
11
12 if ($sOutputFormat == 'json') {
13     header('content-type: application/json; charset=UTF-8');
14 }
15
16
17 try {
18     $oStatus = new Nominatim\Status($oDB);
19     $oStatus->status();
20 } catch (Exception $oErr) {
21     if ($sOutputFormat == 'json') {
22         $aResponse = array(
23                       'status' => $oErr->getCode(),
24                       'message' => $oErr->getMessage()
25                      );
26         javascript_renderData($aResponse);
27     } else {
28         header('HTTP/1.0 500 Internal Server Error');
29         echo 'ERROR: '.$oErr->getMessage();
30     }
31     exit;
32 }
33
34
35 if ($sOutputFormat == 'json') {
36     $epoch = $oStatus->dataDate();
37     $aResponse = array(
38                   'status' => 0,
39                   'message' => 'OK',
40                   'data_updated' => (new DateTime('@'.$epoch))->format(DateTime::RFC3339)
41                  );
42     javascript_renderData($aResponse);
43 } else {
44     echo 'OK';
45 }
46
47 exit;