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