31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/api.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
57$action =
GETPOST(
'action',
'aZ09');
60if ($action ==
'setproductionmode') {
61 $status =
GETPOST(
'status',
'alpha');
76 setEventMessages($langs->trans(
"ErrorFailedToDeleteFile",
$conf->api->dir_temp.
'/routes.php'),
null,
'errors');
82 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
91if ($action ==
'setdisablecompression') {
98if ($action ==
'setenablecount' && !empty($dolibarr_api_count_always_enabled)) {
104if ($action ==
'save') {
118llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-api page-admin-index');
120$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
128print
'<span class="opacitymedium">'.$langs->trans(
"ApiDesc").
"</span><br>\n";
131print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
132print
'<input type="hidden" name="token" value="'.newToken().
'">';
133print
'<input type="hidden" name="action" value="save">';
135print
'<table class="noborder centpercent">';
137print
'<tr class="liste_titre">';
138print
"<td>".$langs->trans(
"Parameter").
"</td>";
139print
'<td>'.$langs->trans(
"Value").
"</td>";
140print
"<td> </td>";
143print
'<tr class="oddeven">';
144print
'<td>'.$langs->trans(
"ApiProductionMode").
'</td>';
146if ($production_mode) {
147 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setproductionmode&token='.newToken().
'&status=0">';
148 print
img_picto($langs->trans(
"Activated"),
'switch_on');
151 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setproductionmode&token='.newToken().
'&status=1">';
152 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
155print
'<td> </td>';
158print
'<tr class="oddeven">';
159print
'<td>'.$langs->trans(
"API_DISABLE_COMPRESSION").
'</td>';
161if ($disable_compression) {
162 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setdisablecompression&token='.newToken().
'&status=0">';
163 print
img_picto($langs->trans(
"Activated"),
'switch_on');
166 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setdisablecompression&token='.newToken().
'&status=1">';
167 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
170print
'<td> </td>';
173print
'<tr class="oddeven">';
174print
'<td>'.$langs->trans(
"API_ENABLE_COUNT_CALLS").
'</td>';
176if (!empty($dolibarr_api_count_always_enabled)) {
178 print
img_picto($langs->trans(
"AlwaysEnabled"),
'switch_on',
'class="opacitymedium"');
182 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setenablecount&token='.newToken().
'&status=0">';
183 print
img_picto($langs->trans(
"Activated"),
'switch_on');
186 print
'<td><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setenablecount&token='.newToken().
'&status=1">';
187 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
191print
'<td> </td>';
194print
'<tr class="oddeven">';
195print
'<td>'.$form->textwithpicto($langs->trans(
"RESTRICT_ON_IP"), $langs->trans(
"RESTRICT_ON_IPHelp").
'<br>'.$langs->trans(
"Example").
': '.$langs->trans(
"IPListExample"));
197print
'<td><input type="text" name="API_RESTRICT_ON_IP" value="'.dol_escape_htmltag(
getDolGlobalString(
'API_RESTRICT_ON_IP')).
'" spellcheck="false"></td>';
199print
'<input type="submit" class="button button-save smallpaddingimp" name="save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'"></td>';
211$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
217$url = $urlwithroot.
'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]';
218$message .=
'<span class="opacitymedium">'.$langs->trans(
"UrlToGetKeyToUseAPIs").
':</span><br>';
219$message .=
'<div class="urllink soixantepercent">'.img_picto(
'',
'globe').
' <input type="text" class="quatrevingtpercent" id="urltogettoken" value="'.$url.
'" spellcheck="false"></div>';
221print ajax_autoselect(
"urltogettoken");
226print
'<span class="opacitymedium">'.$langs->trans(
"ApiExporerIs").
':</span><br>';
227if (
dol_is_dir(DOL_DOCUMENT_ROOT.
'/includes/restler/framework/Luracast/Restler/explorer')) {
228 $url = DOL_MAIN_URL_ROOT.
'/api/index.php/explorer';
229 print
'<div class="urllink soixantepercent">'.img_picto(
'',
'globe').
' <a href="'.$url.
'" target="_blank" rel="noopener noreferrer">'.$url.
"</a></div><br>\n";
231 print
'<div class="opacitymediumxxx"><br><span class="opacitymedium">'.$langs->trans(
"SwaggerDescriptionFile").
':</span><br>';
232 $urlswagger = DOL_MAIN_URL_ROOT.
'/api/index.php/explorer/swagger.json?DOLAPIKEY=youruserapikey';
234 print
'<div class="urllink soixantepercent">'.img_picto(
'',
'globe').
' <input type="text" class="quatrevingtpercent" id="urltogetapidesc" value="'.$urlswagger.
'" spellcheck="false"></div>';
236 print ajax_autoselect(
"urltogetapidesc");
238 $langs->load(
"errors");
239 print
info_admin($langs->trans(
"ErrorNotAvailableWithThisDistribution"), 0, 0,
'error');
global $dolibarr_main_url_root
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).
api_admin_prepare_head()
Return array head with list of tabs to view object information.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.