29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34 $langs->load(
"admin");
40 $action =
GETPOST(
'action',
'aZ09');
43 if ($action ==
'setproductionmode') {
44 $status =
GETPOST(
'status',
'alpha');
50 $result =
dol_mkdir($conf->api->dir_temp);
52 setEventMessages($langs->trans(
"ErrorFailedToCreateDir", $conf->api->dir_temp),
null,
'errors');
59 setEventMessages($langs->trans(
"ErrorFailedToDeleteFile", $conf->api->dir_temp.
'/routes.php'),
null,
'errors');
65 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
74 if ($action ==
'setdisablecompression') {
75 $status =
GETPOST(
'status',
'alpha');
77 if (
dolibarr_set_const($db,
'API_DISABLE_COMPRESSION', $status,
'chaine', 0,
'', 0) > 0) {
78 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
85 if ($action ==
'save') {
99 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
100 print
load_fiche_titre($langs->trans(
"ApiSetup"), $linkback,
'title_setup');
102 print
'<span class="opacitymedium">'.$langs->trans(
"ApiDesc").
"</span><br>\n";
105 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
106 print
'<input type="hidden" name="token" value="'.newToken().
'">';
107 print
'<input type="hidden" name="action" value="save">';
109 print
'<table class="noborder centpercent">';
111 print
'<tr class="liste_titre">';
112 print
"<td>".$langs->trans(
"Parameter").
"</td>";
113 print
'<td>'.$langs->trans(
"Value").
"</td>";
114 print
"<td> </td>";
117 print
'<tr class="oddeven">';
118 print
'<td>'.$langs->trans(
"ApiProductionMode").
'</td>';
119 $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ?
false:
true);
120 if ($production_mode) {
121 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setproductionmode&token='.
newToken().
'&status=0">';
122 print
img_picto($langs->trans(
"Activated"),
'switch_on');
125 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setproductionmode&token='.
newToken().
'&status=1">';
126 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
129 print
'<td> </td>';
132 print
'<tr class="oddeven">';
133 print
'<td>'.$langs->trans(
"API_DISABLE_COMPRESSION").
'</td>';
134 $disable_compression = (empty($conf->global->API_DISABLE_COMPRESSION) ?
false:
true);
135 if ($disable_compression) {
136 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setdisablecompression&token='.
newToken().
'&status=0">';
137 print
img_picto($langs->trans(
"Activated"),
'switch_on');
140 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setdisablecompression&token='.
newToken().
'&status=1">';
141 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
144 print
'<td> </td>';
147 print
'<tr class="oddeven">';
148 print
'<td>'.$langs->trans(
"RESTRICT_ON_IP");
149 print
' '.$langs->trans(
"Example").
': '.$langs->trans(
"IPListExample");
151 print
'<td><input type="text" name="API_RESTRICT_ON_IP" value="'.dol_escape_htmltag(
getDolGlobalString(
'API_RESTRICT_ON_IP')).
'"></td>';
153 print
'<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'"></td>';
164 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
165 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
171 $url = $urlwithroot.
'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]';
172 $message .=
'<span class="opacitymedium">'.$langs->trans(
"UrlToGetKeyToUseAPIs").
':</span><br>';
173 $message .=
'<div class="urllink soixantepercent">'.img_picto(
'',
'globe').
' <input type="text" class="quatrevingtpercent" id="urltogettoken" value="'.$url.
'"></div>';
180 print
'<span class="opacitymedium">'.$langs->trans(
"ApiExporerIs").
':</span><br>';
181 if (
dol_is_dir(DOL_DOCUMENT_ROOT.
'/includes/restler/framework/Luracast/Restler/explorer')) {
182 $url = DOL_MAIN_URL_ROOT.
'/api/index.php/explorer';
183 print
'<div class="urllink soixantepercent">'.img_picto(
'',
'globe').
' <a href="'.$url.
'" target="_blank" rel="noopener noreferrer">'.$url.
"</a></div><br>\n";
184 print
'<div class="opacitymediumxxx"><br><span class="opacitymedium">'.$langs->trans(
"SwaggerDescriptionFile").
':</span><br>';
185 $urlswagger = DOL_MAIN_URL_ROOT.
'/api/index.php/explorer/swagger.json?DOLAPIKEY=youruserapikey';
187 print
'<div class="urllink soixantepercent">'.img_picto(
'',
'globe').
' <a href="'.$urlswagger.
'" target="_blank" rel="noopener noreferrer">'.$urlswagger.
"</a></div><br>\n";
190 $langs->load(
"errors");
191 print
info_admin($langs->trans(
"ErrorNotAvailableWithThisDistribution"), 0, 0,
'error');
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_dir($folder)
Test if filename is a directory.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.