dolibarr  7.0.0-beta
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 Regis Houssin <regis.houssin@capnetworks.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 $langs->load("admin");
33 
34 if (! $user->admin)
36 
37 $action=GETPOST('action','aZ09');
38 
39 //Activate ProfId
40 if ($action == 'setproductionmode')
41 {
42  $status = GETPOST('status','alpha');
43 
44  if (dolibarr_set_const($db, 'API_PRODUCTION_MODE', $status, 'chaine', 0, '', $conf->entity) > 0)
45  {
46  $error=0;
47 
48  if ($status == 1)
49  {
50  $result = dol_mkdir($conf->api->dir_temp);
51  if ($result < 0)
52  {
53  setEventMessages($langs->trans("ErrorFailedToCreateDir", $conf->api->dir_temp), null, 'errors');
54  $error++;
55  }
56  }
57  else
58  {
59  // Delete the cache file otherwise it does not update
60  $result = dol_delete_file($conf->api->dir_temp.'/routes.php');
61  if ($result < 0)
62  {
63  setEventMessages($langs->trans("ErrorFailedToDeleteFile", $conf->api->dir_temp.'/routes.php'), null, 'errors');
64  $error++;
65  }
66  }
67 
68  if (!$error)
69  {
70  header("Location: ".$_SERVER["PHP_SELF"]);
71  exit;
72  }
73  }
74  else
75  {
76  dol_print_error($db);
77  }
78 }
79 
80 dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge
81 
82 
83 /*
84  * View
85  */
86 
87 llxHeader();
88 
89 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
90 print load_fiche_titre($langs->trans("ApiSetup"),$linkback,'title_setup');
91 
92 print $langs->trans("ApiDesc")."<br>\n";
93 print "<br>\n";
94 
95 //print '<form name="apisetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
96 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
97 print '<table class="noborder" width="100%">';
98 
99 print '<tr class="liste_titre">';
100 print "<td>".$langs->trans("Parameter")."</td>";
101 print '<td align="center">'.$langs->trans("Value")."</td>";
102 print "<td>&nbsp;</td>";
103 print "</tr>";
104 
105 print '<tr class="impair">';
106 print '<td>'.$langs->trans("ApiProductionMode").'</td>';
107 $production_mode=(empty($conf->global->API_PRODUCTION_MODE)?false:true);
108 if ($production_mode)
109 {
110  print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=0">';
111  print img_picto($langs->trans("Activated"),'switch_on');
112  print '</a></td>';
113 }
114 else
115 {
116  print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=1">';
117  print img_picto($langs->trans("Disabled"),'switch_off');
118  print '</a></td>';
119 }
120 print '<td>&nbsp;</td>';
121 print '</tr>';
122 
123 print '</table>';
124 print '<br><br>';
125 
126 // Define $urlwithroot
127 $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
128 $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
129 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
130 
131 // Show message
132 $message='';
133 $url=$urlwithroot.'/api/index.php/login?login=<strong>auserlogin</strong>&password=<strong>thepassword</strong>[&reset=1]';
134 $message.=$langs->trans("UrlToGetKeyToUseAPIs").':<br>';
135 $message.=img_picto('','object_globe.png').' '.$url;
136 print $message;
137 print '<br>';
138 print '<br>';
139 
140 // Explorer
141 print '<u>'.$langs->trans("ApiExporerIs").':</u><br>';
142 if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer'))
143 {
144  $url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer';
145  print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
146 }
147 else
148 {
149  print $langs->trans("NotAvailableWithThisDistribution");
150 }
151 
152 llxFooter();
153 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
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:485
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:414
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:37
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
print
Draft customers invoices.
Definition: index.php:91
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null)
Remove a file or several files with a mask.
Definition: files.lib.php:1103