From e86917a1484ccd0fe8e86f3be6669c6d1339b79f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 May 2009 00:19:06 +0000 Subject: [PATCH] Renamed conf->cookie_cryptkey into conf->file->cookie_cryptkey. The goal is to have all parameters defined inside file conf.php to be in $conf->file->xxx. Excep for database that are stored in $conf->db (historic reasons). This make code easier to understand and to know origine of a value (file or database). --- htdocs/lib/security.lib.php | 10 +++++----- htdocs/main.inc.php | 4 ++-- htdocs/master.inc.php | 31 +++++++++++++++---------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php index 8907cb23d09..050b4eed19e 100644 --- a/htdocs/lib/security.lib.php +++ b/htdocs/lib/security.lib.php @@ -128,21 +128,21 @@ function dol_loginfunction($langs,$conf,$mysoc) $demologin=$tab[0]; $demopassword=$tab[1]; } - + if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) { $lastuser = ''; $lastentity = ''; - + if (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE)) { $entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]); if (isset($_COOKIE[$entityCookieName])) { include_once(DOL_DOCUMENT_ROOT . "/core/cookie.class.php"); - - $cryptkey = ( isset($conf->cookie->cryptkey) ? $conf->cookie->cryptkey : '' ); - + + $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); + $entityCookie = new DolCookie($cryptkey); $cookieValue = $entityCookie->_getCookie($entityCookieName); list($lastuser, $lastentity) = split('\|', $cookieValue); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2133c80a7b0..6464811aca3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -450,8 +450,8 @@ if (! isset($_SESSION["dol_login"])) // TTL : sera defini dans la page de config multicompany $ttl = (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE_TTL) ? $conf->global->MAIN_MULTICOMPANY_COOKIE_TTL : time()+60*60*8 ); // Cryptkey : sera cree aleatoirement dans la page de config multicompany - $cryptkey = ( isset($conf->cookie->cryptkey) ? $conf->cookie->cryptkey : '' ); - + $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); + $entityCookie = new DolCookie($cryptkey); $entityCookie->_setCookie($entityCookieName, $entity, $ttl); } diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 61e8128187c..377e99fadea 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -137,10 +137,7 @@ $conf->file->main_force_https = empty($dolibarr_main_force_https)?'':$dolibarr_m if (empty($force_charset_do_notuse)) $force_charset_do_notuse='UTF-8'; $conf->file->character_set_client=strtoupper($force_charset_do_notuse); // Cookie cryptkey -if (isset($dolibarr_main_cookie_cryptkey)) -{ - $conf->cookie->cryptkey = $dolibarr_main_cookie_cryptkey; -} +$conf->file->cookie_cryptkey = empty($dolibarr_main_cookie_cryptkey)?'':$dolibarr_main_cookie_cryptkey; // Define array of document root directories $conf->file->dol_document_root=array(DOL_DOCUMENT_ROOT); @@ -210,8 +207,6 @@ if (! defined('NOREQUIREUSER')) */ if (! defined('NOREQUIREDB')) { - $entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]); - if (session_id() && isset($_SESSION["dol_entity"])) // Entity inside an opened session { $conf->entity = $_SESSION["dol_entity"]; @@ -224,18 +219,22 @@ if (! defined('NOREQUIREDB')) { $conf->entity = $_POST["entity"]; } - elseif (isset($_COOKIE[$entityCookieName])) // Just for view specific login page + else { - include_once(DOL_DOCUMENT_ROOT."/core/cookie.class.php"); - - $lastuser = ''; - $lastentity = ''; - $cryptkey = ( isset($conf->cookie->cryptkey) ? $conf->cookie->cryptkey : '' ); + $entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]); + if (isset($_COOKIE[$entityCookieName])) // Just for view specific login page + { + include_once(DOL_DOCUMENT_ROOT."/core/cookie.class.php"); - $entityCookie = new DolCookie($conf->cookie->cryptkey); - $cookieValue = $entityCookie->_getCookie($entityCookieName); - list($lastuser, $lastentity) = split('\|', $cookieValue); - $conf->entity = $lastentity; + $lastuser = ''; + $lastentity = ''; + $cryptkey = ( ! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); + + $entityCookie = new DolCookie($conf->file->cookie_cryptkey); + $cookieValue = $entityCookie->_getCookie($entityCookieName); + list($lastuser, $lastentity) = split('\|', $cookieValue); + $conf->entity = $lastentity; + } } $conf->setValues($db);