dolibarr  19.0.0-dev
explorer_withredoc.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
3  * Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  *
18  * @deprecated Old explorer. Not using Swagger. See instead explorer in htdocs/api/index.php.
19  */
20 
27 require_once '../../main.inc.php';
28 
29 // Enable and test if module Api is enabled
30 if (empty($conf->global->MAIN_MODULE_API)) {
31  $langs->load("admin");
32  dol_syslog("Call of Dolibarr API interfaces with module API REST are disabled");
33  print $langs->trans("WarningModuleNotActive", 'Api').'.<br><br>';
34  print $langs->trans("ToActivateModule");
35  //session_destroy();
36  exit(0);
37 }
38 
39 // Test if explorer is not disabled
40 if (!empty($conf->global->API_EXPLORER_DISABLED)) {
41  $langs->load("admin");
42  dol_syslog("Call Dolibarr API interfaces with module REST disabled");
43  print $langs->trans("WarningAPIExplorerDisabled").'.<br><br>';
44  //session_destroy();
45  exit(0);
46 }
47 
48 // Restrict API to some IPs
49 if (!empty($conf->global->API_RESTRICT_ON_IP)) {
50  $allowedip = explode(' ', $conf->global->API_RESTRICT_ON_IP);
51  $ipremote = getUserRemoteIP();
52  if (!in_array($ipremote, $allowedip)) {
53  dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP);
54  print 'APIs are not allowed from the IP '.$ipremote;
55  header('HTTP/1.1 503 API not allowed from your IP '.$ipremote);
56  //session_destroy();
57  exit(0);
58  }
59 }
60 
61 ?>
62 <!DOCTYPE html>
63 <html>
64  <head>
65  <title>ReDoc</title>
66  <!-- needed for adaptive design -->
67  <meta charset="utf-8"/>
68  <meta name="viewport" content="width=device-width, initial-scale=1">
69  <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
70 
71  <!--
72  ReDoc doesn't change outer page styles
73  -->
74  <style>
75  body {
76  margin: 0;
77  padding: 0;
78  }
79  </style>
80  </head>
81  <body>
82  <redoc spec-url='<?php echo DOL_MAIN_URL_ROOT.'/api/index.php/explorer/swagger.json?DOLAPIKEY='.GETPOST('DOLAPIKEY', 'aZ09'); ?>'></redoc>
83  <!--<redoc spec-url='https://demo.dolibarr.org/api/index.php/explorer/swagger.json'></redoc>-->
84  <!--<redoc spec-url='http://petstore.swagger.io/v2/swagger.json'></redoc>-->
85  <script src="https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js"> </script>
86  </body>
87 </html>
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:609
name
$conf db name
Definition: repair.php:123
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1741
getUserRemoteIP
getUserRemoteIP()
Return the IP of remote user.
Definition: functions.lib.php:3742