* Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \defgroup api Module DolibarrApi * \brief API explorer using the swagger.json file * \file htdocs/api/admin/explorer_withredoc.php * * @deprecated Old explorer. Not using Swagger. See instead explorer in htdocs/api/index.php. */ require_once '../../main.inc.php'; /** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Translate $langs * @var User $user */ // Enable and test if module Api is enabled if (!isModEnabled('api')) { $langs->load("admin"); dol_syslog("Call of Dolibarr API interfaces with module API REST are disabled"); print $langs->trans("WarningModuleNotActive", 'Api').'.

'; print $langs->trans("ToActivateModule"); //session_destroy(); exit(0); } // Test if explorer is not disabled if (getDolGlobalString('API_EXPLORER_DISABLED')) { $langs->load("admin"); dol_syslog("Call Dolibarr API interfaces with module REST disabled"); print $langs->trans("WarningAPIExplorerDisabled").'.

'; //session_destroy(); exit(0); } // Restrict API to some IPs if (getDolGlobalString('API_RESTRICT_ON_IP')) { $allowedip = explode(' ', getDolGlobalString('API_RESTRICT_ON_IP')); $ipremote = getUserRemoteIP(); if (!in_array($ipremote, $allowedip)) { dol_syslog('Remote ip is '.$ipremote.', not into list ' . getDolGlobalString('API_RESTRICT_ON_IP')); print 'APIs are not allowed from the IP '.$ipremote; header('HTTP/1.1 503 API not allowed from your IP '.$ipremote); //session_destroy(); exit(0); } } ?> ReDoc '>