diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index c5edbc74d66..2f3c0b9236b 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -32,6 +32,7 @@ if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
+if (!defined("NOSESSION")) define("NOSESSION", '1');
// Force entity if a value is provided into HTTP header. Otherwise, will use the entity of user of token used.
@@ -72,7 +73,8 @@ if (empty($conf->global->MAIN_MODULE_API))
dol_syslog("Call Dolibarr API interfaces with module REST disabled");
print $langs->trans("WarningModuleNotActive", 'Api').'.
';
print $langs->trans("ToActivateModule");
- exit;
+ //session_destroy();
+ exit(0);
}
// Test if explorer is not disabled
@@ -81,7 +83,8 @@ if (preg_match('/api\/index\.php\/explorer/', $url) && !empty($conf->global->API
$langs->load("admin");
dol_syslog("Call Dolibarr API interfaces with module REST disabled");
print $langs->trans("WarningAPIExplorerDisabled").'.
';
- exit;
+ //session_destroy();
+ exit(0);
}
@@ -138,7 +141,7 @@ if (!empty($conf->global->API_RESTRICT_ON_IP))
dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP);
print 'APIs are not allowed from the IP '.$ipremote;
header('HTTP/1.1 503 API not allowed from your IP '.$ipremote);
- //print $conf->global->API_RESTRICT_ON_IP;
+ //session_destroy();
exit(0);
}
}
@@ -275,6 +278,7 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING);
print 'API not found (failed to include API file)';
header('HTTP/1.1 501 API not found (failed to include API file)');
+ //session_destroy();
exit(0);
}
@@ -282,9 +286,16 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
$api->r->addAPIClass($classname);
}
+
//var_dump($api->r->apiVersionMap);
//exit;
// Call API (we suppose we found it).
// 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.
+
+//Luracast\Restler\Defaults::$returnResponse = true;
+//print $api->r->handle();
+
$api->r->handle();
+
+//session_destroy();
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index cf53d994ece..396e377e7b5 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -217,13 +217,6 @@ session_name($sessionname);
if (!defined('NOSESSION'))
{
session_start();
- /*if (ini_get('register_globals')) // Deprecated in 5.3 and removed in 5.4. To solve bug in using $_SESSION
- {
- foreach ($_SESSION as $key=>$value)
- {
- if (isset($GLOBALS[$key])) unset($GLOBALS[$key]);
- }
- }*/
}
// Init the 5 global objects, this include will make the 'new Xxx()' and set properties for: $conf, $db, $langs, $user, $mysoc