From fd3c47112670104ad7b863c28595a275eeba846b Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 21 Sep 2007 12:33:14 +0000 Subject: [PATCH] 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 --- functions.inc.php | 159 +++++++++++++++++++++++----------------------- 1 file changed, 78 insertions(+), 81 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index a2132c6e..1539255e 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -964,37 +964,35 @@ function pacrypt ($pw, $pw_db="") $password = ""; $salt = ""; - if ($CONF['encrypt'] == 'md5crypt') - { + if ($CONF['encrypt'] == 'md5crypt') { $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); } - if ($CONF['encrypt'] == 'system') - { - if (ereg ("\$1\$", $pw_db)) - { + if($CONF['encrypt'] == 'md5') { + $password = md5($pw); + } + + if ($CONF['encrypt'] == 'system') { + if (ereg ("\$1\$", $pw_db)) { $split_salt = preg_split ('/\$/', $pw_db); $salt = $split_salt[2]; } - else - { - if (strlen($pw_db) == 0) - { + else { + if (strlen($pw_db) == 0) { $salt = substr (md5 (mt_rand ()), 0, 2); } - else - { + else { $salt = substr ($pw_db, 0, 2); } } $password = crypt ($pw, $salt); } - if ($CONF['encrypt'] == 'cleartext') - { + if ($CONF['encrypt'] == 'cleartext') { $password = $pw; } $password = escape_string ($password); @@ -1646,7 +1644,7 @@ function gen_show_status ($show_alias) { global $CONF, $table_alias; $stat_string = ""; - + $stat_goto = ""; $stat_result = db_query ("SELECT goto FROM $table_alias WHERE address='$show_alias'"); if ($stat_result['rows'] > 0) @@ -1658,94 +1656,94 @@ function gen_show_status ($show_alias) // UNDELIVERABLE CHECK if ( $CONF['show_undeliverable'] == 'YES' ) { - $gotos=array(); - $gotos=explode(',',$stat_goto); - $undel_string=""; - - //make sure this alias goes somewhere known - $stat_ok = 1; - while ( ($g=array_pop($gotos)) && $stat_ok ) - { - $stat_result = db_query ("SELECT address FROM $table_alias WHERE address = '$g'"); - if ($stat_result['rows'] == 0) - { - $stat_ok = 0; - } - if ( $stat_ok == 0 ) - { - $stat_domain = substr($g,strpos($g,"@")+1); - $stat_vacdomain = substr($stat_domain,strpos($stat_domain,"@")+1); - if ( $stat_vacdomain == $CONF['vacation_domain'] ) + $gotos=array(); + $gotos=explode(',',$stat_goto); + $undel_string=""; + + //make sure this alias goes somewhere known + $stat_ok = 1; + while ( ($g=array_pop($gotos)) && $stat_ok ) + { + $stat_result = db_query ("SELECT address FROM $table_alias WHERE address = '$g'"); + if ($stat_result['rows'] == 0) { - $stat_ok = 1; - break; + $stat_ok = 0; } - for ($i=0; $i < sizeof($CONF['show_undeliverable_exceptions']);$i++) + if ( $stat_ok == 0 ) { - if ( $stat_domain == $CONF['show_undeliverable_exceptions'][$i] ) - { - $stat_ok = 1; - break; - } + $stat_domain = substr($g,strpos($g,"@")+1); + $stat_vacdomain = substr($stat_domain,strpos($stat_domain,"@")+1); + if ( $stat_vacdomain == $CONF['vacation_domain'] ) + { + $stat_ok = 1; + break; + } + for ($i=0; $i < sizeof($CONF['show_undeliverable_exceptions']);$i++) + { + if ( $stat_domain == $CONF['show_undeliverable_exceptions'][$i] ) + { + $stat_ok = 1; + break; + } + } } - } - } // while - if ( $stat_ok == 0 ) - { - $stat_string .= "" . $CONF['show_status_text'] . " "; - } - else - { - $stat_string .= $CONF['show_status_text'] . " "; - } + } // while + if ( $stat_ok == 0 ) + { + $stat_string .= "" . $CONF['show_status_text'] . " "; + } + else + { + $stat_string .= $CONF['show_status_text'] . " "; + } } else { - $stat_string .= $CONF['show_status_text'] . " "; + $stat_string .= $CONF['show_status_text'] . " "; } // POP/IMAP CHECK if ( $CONF['show_popimap'] == 'YES' ) { - //if the address passed in appears in its own goto field, its POP/IMAP - if (preg_match ('/^' . $show_alias . '$/', $stat_goto) || - preg_match ('/.*,' . $show_alias . ',.*$/', $stat_goto) || - preg_match ('/,' . $show_alias . '$/', $stat_goto) ) - { + //if the address passed in appears in its own goto field, its POP/IMAP + if (preg_match ('/^' . $show_alias . '$/', $stat_goto) || + preg_match ('/.*,' . $show_alias . ',.*$/', $stat_goto) || + preg_match ('/,' . $show_alias . '$/', $stat_goto) ) + { $stat_string .= "" . $CONF['show_status_text'] . " "; - } - else - { + "'>" . $CONF['show_status_text'] . " "; + } + else + { $stat_string .= $CONF['show_status_text'] . " "; - } + } } // CUSTOM DESTINATION CHECK if ( $CONF['show_custom_count'] > 0 ) { - for ($i = 0; $i < sizeof ($CONF['show_custom_domains']); $i++) - { - if (preg_match ('/^.*' . $CONF['show_custom_domains'][$i] . '.*$/', $stat_goto)) - { - $stat_string .= "" . $CONF['show_status_text'] . " "; - } - else - { - $stat_string .= $CONF['show_status_text'] . " "; - } - } + for ($i = 0; $i < sizeof ($CONF['show_custom_domains']); $i++) + { + if (preg_match ('/^.*' . $CONF['show_custom_domains'][$i] . '.*$/', $stat_goto)) + { + $stat_string .= "" . $CONF['show_status_text'] . " "; + } + else + { + $stat_string .= $CONF['show_status_text'] . " "; + } + } } else { - $stat_string .= "; "; + $stat_string .= "; "; } -// $stat_string .= "    " . -// "    "; + // $stat_string .= "    " . + // "    "; return $stat_string; } @@ -1758,4 +1756,3 @@ $table_log = table_by_key ('log'); $table_mailbox = table_by_key ('mailbox'); $table_vacation = table_by_key ('vacation'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ -?>