diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php
index cc32a07d253..b11bbf4b3fc 100644
--- a/htdocs/admin/security.php
+++ b/htdocs/admin/security.php
@@ -33,6 +33,9 @@ $langs->load("admin");
if (!$user->admin) accessforbidden();
+// Do not allow change to clear model once passwords are crypted
+$allow_disable_encryption=false;
+
/*
* Actions
@@ -52,18 +55,35 @@ if ($_GET["action"] == 'setgeneraterule')
if ($_GET["action"] == 'activate_encrypt')
{
+ $db->begin();
+
dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1");
- $sql = "UPDATE ".MAIN_DB_PREFIX."user as u SET u.pass = MD5(u.pass)";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."user as u";
+ $sql.= " SET u.pass = MD5(u.pass)";
+ $sql.= " WHERE LENGTH(u.pass) < 32"; // Not a MD5 value
+
+ //print $sql;
$result = $db->query($sql);
- Header("Location: security.php");
- exit;
+ if ($result)
+ {
+ $db->commit();
+ Header("Location: security.php");
+ exit;
+ }
+ else
+ {
+ dolibarr_print_error($db,'');
+ }
}
else if ($_GET["action"] == 'disable_encrypt')
{
//On n'autorise pas l'annulation de l'encryption car les mots de passe ne peuvent pas être décodés
//Do not allow "disable encryption" as passwords cannot be decrypted
- //dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED");
- Header("Location: security.php");
+ if ($allow_disable_encryption)
+ {
+ dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED");
+ }
+ Header("Location: security.php");
exit;
}
@@ -165,35 +185,41 @@ print '
';
// Bon de livraison activation/desactivation
$var=false;
print "