dolibarr 20.0.0
api_status.class.php
1<?php
2/*
3 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
4 * Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';
21require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
22
23
30class Status extends DolibarrApi
31{
35 public function __construct()
36 {
37 global $db;
38 $this->db = $db;
39 }
40
46 public function index()
47 {
48 global $dolibarr_main_prod;
49
50 $response = array(
51 'success' => array(
52 'code' => 200,
53 'dolibarr_version' => DOL_VERSION,
54 'access_locked' => getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED', '0'),
55 ),
56 );
57
58 if (empty($dolibarr_main_prod)) {
59 $response['success']['environment'] = 'non-production';
60 $response['success']['timestamp_now_utc'] = dol_now();
61 $response['success']['timestamp_php_tz'] = date_default_timezone_get();
62 $response['success']['date_tz'] = dol_print_date(dol_now('gmt'), 'standard');
63 }
64
65 return $response;
66 }
67}
Class for API REST v1.
Definition api.class.php:30
__construct()
Constructor of the class.
index()
Get status (Dolibarr version)
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.