dolibarr  9.0.0
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.org>
4  * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2012-2018 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31 
32 // Load translation files required by the page
33 $langs->load("admin");
34 
35 if (! $user->admin)
37 
38 $action=GETPOST('action','aZ09');
39 
40 //Activate ProfId
41 if ($action == 'setproductionmode')
42 {
43  $status = GETPOST('status','alpha');
44 
45  if (dolibarr_set_const($db, 'API_PRODUCTION_MODE', $status, 'chaine', 0, '', 0) > 0)
46  {
47  $error=0;
48 
49  if ($status == 1)
50  {
51  $result = dol_mkdir($conf->api->dir_temp);
52  if ($result < 0)
53  {
54  setEventMessages($langs->trans("ErrorFailedToCreateDir", $conf->api->dir_temp), null, 'errors');
55  $error++;
56  }
57  }
58  else
59  {
60  // Delete the cache file otherwise it does not update
61  $result = dol_delete_file($conf->api->dir_temp.'/routes.php');
62  if ($result < 0)
63  {
64  setEventMessages($langs->trans("ErrorFailedToDeleteFile", $conf->api->dir_temp.'/routes.php'), null, 'errors');
65  $error++;
66  }
67  }
68 
69  if (!$error)
70  {
71  header("Location: ".$_SERVER["PHP_SELF"]);
72  exit;
73  }
74  }
75  else
76  {
77  dol_print_error($db);
78  }
79 }
80 
81 dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge
82 
83 
84 /*
85  * View
86  */
87 
88 llxHeader();
89 
90 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
91 print load_fiche_titre($langs->trans("ApiSetup"),$linkback,'title_setup');
92 
93 print $langs->trans("ApiDesc")."<br>\n";
94 print "<br>\n";
95 
96 //print '<form name="apisetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
97 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
98 print '<table class="noborder" width="100%">';
99 
100 print '<tr class="liste_titre">';
101 print "<td>".$langs->trans("Parameter")."</td>";
102 print '<td align="center">'.$langs->trans("Value")."</td>";
103 print "<td>&nbsp;</td>";
104 print "</tr>";
105 
106 print '<tr class="impair">';
107 print '<td>'.$langs->trans("ApiProductionMode").'</td>';
108 $production_mode=(empty($conf->global->API_PRODUCTION_MODE)?false:true);
109 if ($production_mode)
110 {
111  print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=0">';
112  print img_picto($langs->trans("Activated"),'switch_on');
113  print '</a></td>';
114 }
115 else
116 {
117  print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=1">';
118  print img_picto($langs->trans("Disabled"),'switch_off');
119  print '</a></td>';
120 }
121 print '<td>&nbsp;</td>';
122 print '</tr>';
123 
124 print '</table>';
125 print '<br><br>';
126 
127 // Define $urlwithroot
128 $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
129 $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
130 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
131 
132 // Show message
133 $message='';
134 $url=$urlwithroot.'/api/index.php/login?login=<strong>auserlogin</strong>&password=<strong>thepassword</strong>[&reset=1]';
135 $message.=$langs->trans("UrlToGetKeyToUseAPIs").':<br>';
136 $message.=img_picto('','object_globe.png').' '.$url;
137 print $message;
138 print '<br>';
139 print '<br>';
140 
141 // Explorer
142 print '<u>'.$langs->trans("ApiExporerIs").':</u><br>';
143 if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer'))
144 {
145  $url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer';
146  print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
147 }
148 else
149 {
150  print $langs->trans("NotAvailableWithThisDistribution");
151 }
152 
153 llxFooter();
154 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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).
Definition: admin.lib.php:510
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:438
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
llxHeader()
Header empty.
Definition: index.php:36
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
Definition: files.lib.php:1139
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)