diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index dc3e2a0c13c..d6a8281ce72 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008-2011 Regis Houssin + * Copyright (C) 2008-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -145,7 +145,7 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod function dol_loginfunction($langs,$conf,$mysoc) { global $dolibarr_main_demo,$db; - global $smartphone; + global $smartphone,$mc; $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); $langs->setDefaultLang($langcode); @@ -214,12 +214,12 @@ function dol_loginfunction($langs,$conf,$mysoc) } // Entity cookie - if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) + if (! empty($conf->multicompany->enabled)) { $lastuser = ''; $lastentity = $_POST['entity']; - if (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE)) + if (! empty($conf->global->MULTICOMPANY_COOKIE_ENABLED)) { $prefix=dol_getprefix(); $entityCookieName = 'DOLENTITYID_'.$prefix; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0f28ce7722d..c92c8b2b4b9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Philippe Grand * Copyright (C) 2008 Matteli * Copyright (C) 2011 Juanjo Menent @@ -576,7 +576,7 @@ if (! defined('NOLOGIN')) $prefix=dol_getprefix(); $entityCookieName = 'DOLENTITYID_'.$prefix; // TTL : is defined in the config page multicompany - $ttl = (! empty($conf->global->MULTICOMPANY_COOKIE_TTL) ? $conf->global->MULTICOMPANY_COOKIE_TTL : time()+60*60*8 ); + $ttl = (! empty($conf->global->MULTICOMPANY_COOKIE_TTL) ? dol_now()+$conf->global->MULTICOMPANY_COOKIE_TTL : dol_now()+60*60*8 ); // Cryptkey : will be created randomly in the config page multicompany $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 6d4a338cbc8..31c0b410609 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Simon Tosser * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010 Juanjo Menent @@ -137,20 +137,6 @@ if (! defined('NOREQUIREDB')) { $conf->entity = GETPOST("entity",'int'); } - else if (! empty($conf->file->cookie_cryptkey)) - { - $prefix=dol_getprefix(); - $entityCookieName = 'DOLENTITYID_'.$prefix; - if (! empty($_COOKIE[$entityCookieName])) // Just for view specific login page - { - include_once(DOL_DOCUMENT_ROOT."/core/class/cookie.class.php"); - $lastuser = ''; $lastentity = ''; - $entityCookie = new DolCookie($conf->file->cookie_cryptkey); - $cookieValue = $entityCookie->_getCookie($entityCookieName); - list($lastuser, $lastentity) = explode('|', $cookieValue); - $conf->entity = $lastentity; - } - } //print "Will work with data into entity instance number '".$conf->entity."'";