functions.inc.php: enable md5 password hashing (thanks to Levente Farkas (lfarkas) on the forum)

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@64 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
David Goodwin 17 years ago
parent 91589bf6d6
commit fd3c471126

@ -964,37 +964,35 @@ function pacrypt ($pw, $pw_db="")
$password = ""; $password = "";
$salt = ""; $salt = "";
if ($CONF['encrypt'] == 'md5crypt') if ($CONF['encrypt'] == 'md5crypt') {
{
$split_salt = preg_split ('/\$/', $pw_db); $split_salt = preg_split ('/\$/', $pw_db);
if (isset ($split_salt[2])) $salt = $split_salt[2]; if (isset ($split_salt[2])) {
$salt = $split_salt[2];
}
$password = md5crypt ($pw, $salt); $password = md5crypt ($pw, $salt);
} }
if ($CONF['encrypt'] == 'system') if($CONF['encrypt'] == 'md5') {
{ $password = md5($pw);
if (ereg ("\$1\$", $pw_db)) }
{
if ($CONF['encrypt'] == 'system') {
if (ereg ("\$1\$", $pw_db)) {
$split_salt = preg_split ('/\$/', $pw_db); $split_salt = preg_split ('/\$/', $pw_db);
$salt = $split_salt[2]; $salt = $split_salt[2];
} }
else else {
{ if (strlen($pw_db) == 0) {
if (strlen($pw_db) == 0)
{
$salt = substr (md5 (mt_rand ()), 0, 2); $salt = substr (md5 (mt_rand ()), 0, 2);
} }
else else {
{
$salt = substr ($pw_db, 0, 2); $salt = substr ($pw_db, 0, 2);
} }
} }
$password = crypt ($pw, $salt); $password = crypt ($pw, $salt);
} }
if ($CONF['encrypt'] == 'cleartext') if ($CONF['encrypt'] == 'cleartext') {
{
$password = $pw; $password = $pw;
} }
$password = escape_string ($password); $password = escape_string ($password);
@ -1758,4 +1756,3 @@ $table_log = table_by_key ('log');
$table_mailbox = table_by_key ('mailbox'); $table_mailbox = table_by_key ('mailbox');
$table_vacation = table_by_key ('vacation'); $table_vacation = table_by_key ('vacation');
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
?>

Loading…
Cancel
Save