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 = "";
$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 .= "<span style='background-color:" . $CONF['show_undeliverable_color'] .
"'>" . $CONF['show_status_text'] . "</span>&nbsp;";
}
else
{
$stat_string .= $CONF['show_status_text'] . "&nbsp;";
}
} // while
if ( $stat_ok == 0 )
{
$stat_string .= "<span style='background-color:" . $CONF['show_undeliverable_color'] .
"'>" . $CONF['show_status_text'] . "</span>&nbsp;";
}
else
{
$stat_string .= $CONF['show_status_text'] . "&nbsp;";
}
}
else
{
$stat_string .= $CONF['show_status_text'] . "&nbsp;";
$stat_string .= $CONF['show_status_text'] . "&nbsp;";
}
// 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 .= "<span style='background-color:" . $CONF['show_popimap_color'] .
"'>" . $CONF['show_status_text'] . "</span>&nbsp;";
}
else
{
"'>" . $CONF['show_status_text'] . "</span>&nbsp;";
}
else
{
$stat_string .= $CONF['show_status_text'] . "&nbsp;";
}
}
}
// 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 .= "<span style='background-color:" . $CONF['show_custom_colors'][$i] .
"'>" . $CONF['show_status_text'] . "</span>&nbsp;";
}
else
{
$stat_string .= $CONF['show_status_text'] . "&nbsp;";
}
}
for ($i = 0; $i < sizeof ($CONF['show_custom_domains']); $i++)
{
if (preg_match ('/^.*' . $CONF['show_custom_domains'][$i] . '.*$/', $stat_goto))
{
$stat_string .= "<span style='background-color:" . $CONF['show_custom_colors'][$i] .
"'>" . $CONF['show_status_text'] . "</span>&nbsp;";
}
else
{
$stat_string .= $CONF['show_status_text'] . "&nbsp;";
}
}
}
else
{
$stat_string .= ";&nbsp;";
$stat_string .= ";&nbsp;";
}
// $stat_string .= "<span style='background-color:green'> &nbsp; </span> &nbsp;" .
// "<span style='background-color:blue'> &nbsp; </span> &nbsp;";
// $stat_string .= "<span style='background-color:green'> &nbsp; </span> &nbsp;" .
// "<span style='background-color:blue'> &nbsp; </span> &nbsp;";
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: */
?>

Loading…
Cancel
Save