diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 8602704d9a7..60ff95a705e 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -50,6 +50,18 @@ if ($_GET["action"] == 'setgeneraterule') } } +if ($_GET["action"] == 'activate_encrypt') +{ + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1"); + Header("Location: security.php"); + exit; +} +else if ($_GET["action"] == 'disable_encrypt') +{ + dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED"); + Header("Location: security.php"); + exit; +} /* * Affichage onglet @@ -138,15 +150,50 @@ foreach ($arrayhandler as $key => $module) } print "\n"; } - print ''; +print ''; +print '
'; + +// Bon de livraison activation/desactivation +$var=!$var; +print "
"; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ""; +print ""; +print ''; +print ''; +print ''; +print '"; +print ''; +print '
'.$langs->trans("Encryption").' '.$langs->trans("Activated").'
'.$langs->trans("EncryptedPasswordInDatabase").' '; + +if($conf->global->DATABASE_PWD_ENCRYPTED == 1) +{ + print img_tick(); +} + +print ''; + +if($conf->global->DATABASE_PWD_ENCRYPTED == 0) +{ + print ''.$langs->trans("Activate").''; +} +else if($conf->global->DATABASE_PWD_ENCRYPTED == 1) +{ + print ''.$langs->trans("Disable").''; +} + +print "
'; +print '
'; //print ''; -print ''; - - print ''; $db->close(); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a0f1ba12dd0..5a83acbcb03 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -106,12 +106,21 @@ if (! session_id() && ! isset($_SESSION["dol_user"]) && ! isset($_SESSION["dol_ $pear = $dolibarr_main_db_type.'://'.$dolibarr_main_db_user.':'.$dolibarr_main_db_pass.'@'.$dolibarr_main_db_host.'/'.$dolibarr_main_db_name; + if ($conf->global->DATABASE_PWD_ENCRYPTED) + { + $cryptType = "md5"; + } + else + { + $cryptType = "none"; + } + $params = array( "dsn" => $pear, "table" => MAIN_DB_PREFIX."user", "usernamecol" => "login", "passwordcol" => "pass", - "cryptType" => "none", + "cryptType" => $cryptType, ); $aDol = new DOLIAuth("DB", $params, "dol_loginfunction"); diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 61deee3a7b6..00c79d1e0e8 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -62,6 +62,7 @@ class User var $admin; var $login; var $pass; + var $oldpass; var $datec; var $datem; var $societe_id; @@ -776,11 +777,24 @@ class User { global $langs; + + // Nettoyage parametres $this->nom=trim($this->nom); $this->prenom=trim($this->prenom); $this->login=trim($this->login); - $this->pass=trim($this->pass); + if ($conf->global->DATABASE_PWD_ENCRYPTED) + { + $this->pass=trim($this->pass); + if ($this->oldpass != $this->pass) + { + $this->pass = md5($this->pass); + } + } + else + { + $this->pass=trim($this->pass); + } $this->email=trim($this->email); $this->note=trim($this->note); $this->admin=$this->admin?$this->admin:0;