Skip to content
Snippets Groups Projects
Commit c812c328 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Bad init of conf->entity

parent d3255c19
No related branches found
No related tags found
No related merge requests found
......@@ -39,19 +39,17 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Include Dolibarr environment
require_once($path."../../htdocs/master.inc.php");
// After this $db is an opened handler to database. We close it at end of file.
// After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
require_once(DOL_DOCUMENT_ROOT."/cron/functions_cron.lib.php");
// Load main language strings
$langs->load("main");
// Global variables
$version='$Revision$';
$error=0;
// -------------------- START OF YOUR CODE HERE --------------------
//$langs->setDefaultLang('en_US'); // To change default language of $langs
$langs->load("main"); // To load language file for default language
@set_time_limit(0);
print "***** ".$script_file." (".$version.") *****\n";
......
......@@ -225,22 +225,23 @@ if (! defined('NOREQUIREUSER'))
*/
if (! defined('NOREQUIREDB'))
{
if (session_id() && isset($_SESSION["dol_entity"])) // Entity inside an opened session
// By default conf->entity is 1, but we change this if we ask another value.
if (session_id() && ! empty($_SESSION["dol_entity"])) // Entity inside an opened session
{
$conf->entity = $_SESSION["dol_entity"];
}
elseif (isset($_ENV["dol_entity"])) // Entity inside a CLI script
elseif (! empty($_ENV["dol_entity"])) // Entity inside a CLI script
{
$conf->entity = $_ENV["dol_entity"];
}
elseif (isset($_POST["loginfunction"]) && isset($_POST["entity"])) // Just after a login page
elseif (isset($_POST["loginfunction"]) && ! empty($_POST["entity"])) // Just after a login page
{
$conf->entity = $_POST["entity"];
}
else
{
$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
if (isset($_COOKIE[$entityCookieName]) && ! empty($conf->file->cookie_cryptkey)) // Just for view specific login page
if (! empty($_COOKIE[$entityCookieName]) && ! empty($conf->file->cookie_cryptkey)) // Just for view specific login page
{
include_once(DOL_DOCUMENT_ROOT."/core/cookie.class.php");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment