dolibarr 23.0.3
index.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 * Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2021 Alexis LAURIER <contact@alexislaurier.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
30use Luracast\Restler\Format\UploadFormat;
31
32// API endpoints return JSON (or XML). A stray PHP warning or notice in the
33// response body corrupts the parser on the caller side. Silence the display
34// of PHP messages here while keeping them in the server log so that the
35// problem is still observable to the operator (filefunc.inc.php only does
36// this when dolibarr_main_prod is set, which leaves development setups
37// emitting HTML into every API answer).
38@ini_set('display_errors', '0');
39@ini_set('log_errors', '1');
40
41if (!defined('NOCSRFCHECK')) {
42 define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
43}
44if (!defined('NOTOKENRENEWAL')) {
45 define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test
46}
47if (!defined('NOREQUIREMENU')) {
48 define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
49}
50if (!defined('NOREQUIREHTML')) {
51 define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
52}
53if (!defined('NOREQUIREAJAX')) {
54 define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
55}
56if (!defined("NOLOGIN")) {
57 define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
58}
59if (!defined("NOSESSION")) {
60 define("NOSESSION", '1');
61}
62if (!defined("NODEFAULTVALUES")) {
63 define("NODEFAULTVALUES", '1');
64}
65
66// Force entity if a value is provided into HTTP header. Otherwise, will use the entity of user of token used.
67if (!empty($_SERVER['HTTP_DOLAPIENTITY'])) {
68 define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']);
69}
70
71// Response for preflight requests (used by browser when into a CORS context)
72if (!empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'OPTIONS' && !empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
73 header('Access-Control-Allow-Origin: *');
74 header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
75 header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY, DOLAPIENTITY');
76 http_response_code(204);
77 exit;
78}
79
80// When we request url to get the json file, we accept Cross site so we can include the descriptor into an external tool.
81if (preg_match('/\/explorer\/swagger\.json/', $_SERVER["PHP_SELF"])) {
82 header('Access-Control-Allow-Origin: *');
83 header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
84 header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY, DOLAPIENTITY');
85}
86// When we request url to get an API, we accept Cross site so we can make js API call inside another website
87if (preg_match('/\/api\/index\.php/', $_SERVER["PHP_SELF"])) {
88 header('Access-Control-Allow-Origin: *');
89 header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
90 header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY, DOLAPIENTITY');
91}
92header('X-Frame-Options: SAMEORIGIN');
93
94
95$res = 0;
96if (!$res && file_exists("../main.inc.php")) {
97 $res = include '../main.inc.php';
98}
99if (!$res) {
100 die("Include of main fails");
101}
112require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php';
113
114call_user_func(
118 static function () {
119 $loader = Luracast\Restler\AutoLoader::instance();
120 spl_autoload_register($loader);
121 return $loader;
122 }
123);
124
125require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';
126require_once DOL_DOCUMENT_ROOT.'/api/class/api_access.class.php';
127require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
128
129
130// In API context, we force the protection to avoid forging of criteria including bind SQL injection
131$conf->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = 1;
132
133
134$url = $_SERVER['PHP_SELF'];
135if (preg_match('/api\/index\.php$/', $url)) { // sometimes $_SERVER['PHP_SELF'] is 'api\/index\.php' instead of 'api\/index\.php/explorer.php' or 'api\/index\.php/method'
136 $url = $_SERVER['PHP_SELF'].(empty($_SERVER['PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']);
137}
138// Fix for some NGINX setups (this should not be required even with NGINX, however setup of NGINX are often mysterious and this may help is such cases)
139if (getDolGlobalString('MAIN_NGINX_FIX')) {
140 $url = (isset($_SERVER['SCRIPT_URI']) && $_SERVER["SCRIPT_URI"] !== null) ? $_SERVER["SCRIPT_URI"] : $_SERVER['PHP_SELF'];
141}
142
143// Enable and test if module Api is enabled
144if (!isModEnabled('api')) {
145 $langs->load("admin");
146 dol_syslog("Call of Dolibarr API interfaces with module API REST are disabled");
147 print $langs->trans("WarningModuleNotActive", 'Api').'.<br><br>';
148 print $langs->trans("ToActivateModule");
149 //session_destroy();
150 exit(0);
151}
152
153// Test if explorer is not disabled
154if (preg_match('/api\/index\.php\/explorer/', $url) && getDolGlobalString('API_EXPLORER_DISABLED')) {
155 $langs->load("admin");
156 dol_syslog("Call Dolibarr API interfaces with module API REST disabled");
157 print $langs->trans("WarningAPIExplorerDisabled").'.<br><br>';
158 //session_destroy();
159 exit(0);
160}
161
162
163// This 2 lines are useful only if we want to exclude some Urls from the explorer
164//use Luracast\Restler\Explorer;
165//Explorer::$excludedPaths = array('/categories');
166
167
168// Analyze URLs
169// index.php/explorer do a redirect to index.php/explorer/
170// index.php/explorer/ called by swagger to build explorer page index.php/explorer/index.html
171// index.php/explorer/.../....png|.css|.js called by swagger for resources to build explorer page
172// index.php/explorer/resources.json called by swagger to get list of all services
173// index.php/explorer/resources.json/xxx called by swagger to get detail of services xxx
174// index.php/xxx called by any REST client to run API
175
176
177$reg = array();
178preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg);
179// .../index.php/categories?sortfield=t.rowid&sortorder=ASC
180
181
182$hookmanager->initHooks(array('api'));
183
184// When in production mode, a file api/temp/routes.php is created with the API available of current call.
185// But, if we set $refreshcache to false, so it may have only one API in the routes.php file if we make a call for one API without
186// using the explorer. And when we make another call for another API, the API is not into the api/temp/routes.php and a 404 is returned.
187// So we force refresh to each call.
188$refreshcache = (getDolGlobalString('API_PRODUCTION_DO_NOT_ALWAYS_REFRESH_CACHE') ? false : true);
189if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) {
190 $refreshcache = true;
191 if (!is_writable($conf->api->dir_temp)) {
192 dol_syslog("ErrorFailedToWriteInApiTempDirectory ".$conf->api->dir_temp, LOG_ERR);
193 print 'Erreur temp dir api/temp not writable';
194 header('HTTP/1.1 500 temp dir api/temp not writable');
195 exit(0);
196 }
197}
198
199$api = new DolibarrApi($db, '', $refreshcache);
200//var_dump($api->r->apiVersionMap);
201
202// If MAIN_API_DEBUG is set to 1, we save logs into file "dolibarr_api.log"
203if (getDolGlobalString('MAIN_API_DEBUG')) {
204 $r = $api->r;
205 $r->onCall(function () use ($r) {
206 // Don't log Luracast Restler Explorer resources calls
207 //if (!preg_match('/^explorer/', $r->url)) {
208 // 'method' => $api->r->requestMethod,
209 // 'url' => $api->r->url,
210 // 'route' => $api->r->apiMethodInfo->className.'::'.$api->r->apiMethodInfo->methodName,
211 // 'version' => $api->r->getRequestedApiVersion(),
212 // 'data' => $api->r->getRequestData(),
213 //dol_syslog("Debug API input ".var_export($r, true), LOG_DEBUG, 0, '_api');
214 dol_syslog("Debug API url ".var_export($r->url, true), LOG_DEBUG, 0, '_api');
215 dol_syslog("Debug API input ".var_export($r->getRequestData(), true), LOG_DEBUG, 0, '_api');
216 //}
217 });
218}
219
220
221// Enable the Restler API Explorer.
222// See https://github.com/Luracast/Restler-API-Explorer for more info.
223$api->r->addAPIClass('Luracast\\Restler\\Explorer');
224
225$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat'); // 'YamlFormat'
226$api->r->addAuthenticationClass('DolibarrApiAccess', '');
227
228// Define accepted mime types
229UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream');
230
231
232// Restrict API to some IPs
233if (getDolGlobalString('API_RESTRICT_ON_IP')) {
234 $allowedip = explode(' ', getDolGlobalString('API_RESTRICT_ON_IP'));
235 $ipremote = getUserRemoteIP();
236 if (!in_array($ipremote, $allowedip)) {
237 dol_syslog('Remote ip is '.$ipremote.', not into list ' . getDolGlobalString('API_RESTRICT_ON_IP'));
238 print 'APIs are not allowed from the IP '.$ipremote;
239 header('HTTP/1.1 503 API not allowed from your IP '.$ipremote);
240 //session_destroy();
241 exit(0);
242 }
243}
244
245
246// Call Explorer file for all APIs definitions (this part is slow)
247if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) {
248 // Scan all API files to load them
249
250 $listofapis = array();
251
252 $modulesdir = dolGetModulesDirs();
253 foreach ($modulesdir as $dir) {
254 // Search available module
255 dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files");
256
257 $handle = @opendir(dol_osencode($dir));
258 if (is_resource($handle)) {
259 while (($file = readdir($handle)) !== false) {
260 $regmod = array();
261 if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) {
262 $module = strtolower($regmod[1]);
263 $moduledirforclass = getModuleDirForApiClass($module);
264 $modulenameforenabled = $module;
265 if ($module == 'propale') {
266 $modulenameforenabled = 'propal';
267 } elseif ($module == 'supplierproposal') {
268 $modulenameforenabled = 'supplier_proposal';
269 } elseif ($module == 'ficheinter') {
270 $modulenameforenabled = 'intervention';
271 } elseif ($module == 'product' && !isModEnabled('product') && isModEnabled('service')) {
272 $modulenameforenabled = 'service';
273 }
274
275 dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass);
276
277 // Defined if module is enabled
278 $enabled = true;
279 if (!isModEnabled($modulenameforenabled)) {
280 $enabled = false;
281 }
282
283 if ($enabled) {
284 // If exists, load the API class for enable module
285 // Search files named api_<object>.class.php into /htdocs/<module>/class directory
286 // @todo : use getElementProperties() function ?
287 $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/');
288
289 $handle_part = @opendir(dol_osencode($dir_part));
290 if (is_resource($handle_part)) {
291 while (($file_searched = readdir($handle_part)) !== false) {
292 if ($file_searched == 'api_access.class.php') {
293 continue;
294 }
295
296 //$conf->global->API_DISABLE_LOGIN_API = 1;
297 if ($file_searched == 'api_login.class.php' && getDolGlobalString('API_DISABLE_LOGIN_API')) {
298 continue;
299 }
300
301 //dol_syslog("We scan to search api file with into ".$dir_part.$file_searched);
302
303 $regapi = array();
304 if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) {
305 $classname = ucwords($regapi[1]);
306 $classname = str_replace('_', '', $classname);
307 require_once $dir_part.$file_searched;
308 if (class_exists($classname.'Api')) {
309 //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched);
310 $listofapis[strtolower($classname.'Api')] = $classname.'Api';
311 } elseif (class_exists($classname)) {
312 //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
313 $listofapis[strtolower($classname)] = $classname;
314 } else {
315 dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
316 }
317 }
318 }
319 }
320 }
321 }
322 }
323 }
324 }
325
326 // Sort the classes before adding them to Restler.
327 // The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted.
328 asort($listofapis);
329 foreach ($listofapis as $apiname => $classname) {
330 $api->r->addAPIClass($classname, $apiname);
331 }
332 //var_dump($api->r);
333}
334
335// Call one APIs or one definition of an API
336$regbis = array();
337if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) {
338 $moduleobject = $reg[1];
339 if ($moduleobject == 'explorer') { // If we call page to explore details of a service
340 $moduleobject = $regbis[2];
341 }
342
343 $moduleobject = strtolower($moduleobject);
344 $moduledirforclass = getModuleDirForApiClass($moduleobject);
345
346 // Load a dedicated API file
347 dol_syslog("Load a dedicated API file moduleobject=".$moduleobject." moduledirforclass=".$moduledirforclass);
348
349 $tmpmodule = $moduleobject;
350 if ($tmpmodule != 'api') {
351 $tmpmodule = preg_replace('/api$/i', '', $tmpmodule);
352 }
353 $classfile = str_replace('_', '', $tmpmodule);
354
355 // Special cases that does not match name rules conventions
356 if ($moduleobject == 'supplierproposals') {
357 $classfile = 'supplier_proposals';
358 }
359 if ($moduleobject == 'supplierorders') {
360 $classfile = 'supplier_orders';
361 }
362 if ($moduleobject == 'supplierinvoices') {
363 $classfile = 'supplier_invoices';
364 }
365 if ($moduleobject == 'ficheinter') {
366 $classfile = 'interventions';
367 }
368 if ($moduleobject == 'interventions') {
369 $classfile = 'interventions';
370 }
371
372 $dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php', 0, 2);
373
374 $classname = ucwords($moduleobject);
375
376 // Test rules on endpoints. For example:
377 // $conf->global->API_ENDPOINT_RULES = 'endpoint1:1,endpoint2:1,...'
378 if (getDolGlobalString('API_ENDPOINT_RULES')) {
379 $listofendpoints = explode(',', getDolGlobalString('API_ENDPOINT_RULES'));
380 $endpointisallowed = false;
381
382 foreach ($listofendpoints as $endpointrule) {
383 $tmparray = explode(':', $endpointrule);
384 if (($classfile == $tmparray[0] || $classfile.'api' == $tmparray[0]) && $tmparray[1] == 1) {
385 $endpointisallowed = true;
386 break;
387 }
388 }
389
390 if (! $endpointisallowed) {
391 dol_syslog('The API with endpoint /'.$classfile.' is forbidden by config API_ENDPOINT_RULES', LOG_WARNING);
392 print 'The API with endpoint /'.$classfile.' is forbidden by config API_ENDPOINT_RULES';
393 header('HTTP/1.1 501 API is forbidden by API_ENDPOINT_RULES');
394 //session_destroy();
395 exit(0);
396 }
397 }
398
399 $parameters = array('url' => $url, 'ip' => getUserRemoteIP(), 'moduleobject' => $moduleobject, 'classfile' => $classfile, 'classname' => $classname);
400 $object = $api;
401 $action = $api->r->requestMethod;
402 // Note that $action and $object may be modified by some hooks
403 $reshook = $hookmanager->executeHooks('beforeApiCall', $parameters, $object, $action);
404 if ($reshook < 0) {
405 dol_syslog('beforeapicall Failed to call hook '.$hookmanager->error, LOG_ERR);
406 }
407
408 dol_syslog('Search api file /'.$moduledirforclass.'/class/api_'.$classfile.'.class.php => dir_part_file='.$dir_part_file.', classname='.$classname);
409
410 $res = false;
411 if ($dir_part_file) {
412 $res = include_once $dir_part_file;
413 }
414 if (!$res) {
415 dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING);
416 print 'API not found (failed to include API file)';
417 header('HTTP/1.1 501 API not found (failed to include API file)');
418 //session_destroy();
419 exit(0);
420 }
421
422 if (class_exists($classname)) {
423 $api->r->addAPIClass($classname);
424 }
425}
426
427
428//var_dump($api->r->apiVersionMap);
429//exit;
430
431// We do not want that restler outputs data if we use native compression (default behaviour) but we want to have it returned into a string.
432// If API_DISABLE_COMPRESSION is set, returnResponse is false => It use default handling so output result directly.
433$usecompression = (!getDolGlobalString('API_DISABLE_COMPRESSION') && !empty($_SERVER['HTTP_ACCEPT_ENCODING']));
434$foundonealgorithm = 0;
435if ($usecompression) {
436 if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress')) {
437 $foundonealgorithm++;
438 }
439 if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) {
440 $foundonealgorithm++;
441 }
442 if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) {
443 $foundonealgorithm++;
444 }
445 if (!$foundonealgorithm) {
446 $usecompression = false;
447 }
448}
449
450
451if (getDolGlobalString('MAIN_API_DEBUG')) {
452 dol_syslog('We found some compression algorithm: '.$foundonealgorithm.' -> usecompression='.(int) $usecompression, LOG_DEBUG, 0, '_api');
453}
454
455
456Luracast\Restler\Defaults::$returnResponse = $usecompression;
457
458// Call API (we suppose we found it).
459// The handle will use the file api/temp/routes.php to get data to run the API. If the file exists and the entry for API is not found, it will return 404.
460$responsedata = $api->r->handle();
461
462if (Luracast\Restler\Defaults::$returnResponse) {
463 // We try to compress the data received data
464 if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress') && defined('BROTLI_TEXT')) {
465 header('Content-Encoding: br');
466 $result = brotli_compress($responsedata, 11, constant('BROTLI_TEXT'));
467 } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) {
468 header('Content-Encoding: bz');
469 $result = bzcompress($responsedata, 9);
470 } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) {
471 header('Content-Encoding: gzip');
472 $result = gzencode($responsedata, 9);
473 } else {
474 header('Content-Encoding: text/html');
475 print "No compression method found. Try to disable compression by adding API_DISABLE_COMPRESSION=1";
476 exit(0);
477 }
478
479 // Restler did not output data yet, we return it now
480 echo $result;
481}
482
483if ((getDolGlobalInt("API_ENABLE_COUNT_CALLS") || !empty($dolibarr_api_count_always_enabled)) && $api->r->responseCode == 200) {
484 $error = 0;
485 $db->begin();
486 $userid = DolibarrApiAccess::$user->id;
487
488 $sql = "SELECT up.value";
489 $sql .= " FROM ".MAIN_DB_PREFIX."user_param as up";
490 $sql .= " WHERE up.param = 'API_COUNT_CALL'";
491 $sql .= " AND up.fk_user = ".((int) $userid);
492 $sql .= " AND up.entity = ".((int) $conf->entity);
493
494 $result = $db->query($sql);
495 if ($result) {
496 $updateapi = false;
497 $nbrows = $db->num_rows($result);
498 if ($nbrows == 0) {
499 $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."user_param";
500 $sql2 .= " (fk_user, entity, param, value)";
501 $sql2 .= " VALUES (".((int) $userid).", ".((int) $conf->entity).", 'API_COUNT_CALL', 1)";
502 } else {
503 $updateapi = true;
504 $sql2 = "UPDATE ".MAIN_DB_PREFIX."user_param as up";
505 $sql2 .= " SET up.value = up.value + 1";
506 $sql2 .= " WHERE up.param = 'API_COUNT_CALL'";
507 $sql2 .= " AND up.fk_user = ".((int) $userid);
508 $sql2 .= " AND up.entity = ".((int) $conf->entity);
509 }
510
511 $result2 = $db->query($sql2);
512 if (!$result2) {
513 $modeapicall = $updateapi ? 'updating' : 'inserting';
514 dol_syslog('Error while '.$modeapicall. ' API_COUNT_CALL for user '.$userid, LOG_ERR);
515 $error++;
516 }
517 } else {
518 dol_syslog('Error on select API_COUNT_CALL for user '.$userid, LOG_ERR);
519 $error++;
520 }
521
522 if ($error) {
523 $db->rollback();
524 } else {
525 $db->commit();
526 }
527}
528
529// Call API termination method
530$apiMethodInfo = &$api->r->apiMethodInfo;
531$terminateCall = '_terminate_' . $apiMethodInfo->methodName . '_' . $api->r->responseFormat->getExtension();
532if (method_exists($apiMethodInfo->className, $terminateCall)) {
533 // Now flush output buffers so that response data is sent to the client even if we still have action to do in a termination method.
534 ob_end_flush();
535
536 // If you're using PHP-FPM, this function will allow you to send the response and then continue processing
537 if (function_exists('fastcgi_finish_request')) {
538 fastcgi_finish_request();
539 }
540
541 // Call a termination method. Warning: This method can do I/O, sync but must not make output.
542 call_user_func(array(Luracast\Restler\Scope::get($apiMethodInfo->className), $terminateCall), $responsedata);
543}
544
545//session_destroy();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class for API REST v1.
Definition api.class.php:33
getModuleDirForApiClass($moduleobject)
Get name of directory where the api_...class.php file is stored.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.