mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
functions.inc.php:
- validate_password(): use Config::read and Lang::read instead of $CONF and $PALANG git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1439 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
parent
be84a8b8fc
commit
74deef8221
@ -1003,25 +1003,25 @@ function generate_password () {
|
||||
* @return array of error messages, or empty array if the password is ok
|
||||
*/
|
||||
function validate_password($password) {
|
||||
global $CONF;
|
||||
global $PALANG;
|
||||
$val_conf = Config::read('password_validation');
|
||||
$result = array();
|
||||
|
||||
if (isset($CONF['min_password_length'])) { # used up to 2.3.x - check it for backward compatibility
|
||||
$minlen = (int) $CONF['min_password_length'];
|
||||
$CONF['password_validation']['/.{' . $minlen . '}/'] = "password_too_short $minlen";
|
||||
$minlen = (int) Config::read('min_password_length'); # used up to 2.3.x - check it for backward compatibility
|
||||
if ($minlen > 0) {
|
||||
$val_conf['/.{' . $minlen . '}/'] = "password_too_short $minlen";
|
||||
}
|
||||
|
||||
foreach ($CONF['password_validation'] as $regex => $message) {
|
||||
foreach ($val_conf as $regex => $message) {
|
||||
if (!preg_match($regex, $password)) {
|
||||
$msgparts = preg_split("/ /", $message, 2);
|
||||
if (count($msgparts) == 1) {
|
||||
$result[] = $PALANG[$msgparts[0]];
|
||||
$result[] = Lang::read($msgparts[0]);
|
||||
} else {
|
||||
$result[] = sprintf($PALANG[$msgparts[0]], $msgparts[1]);
|
||||
$result[] = sprintf(Lang::read($msgparts[0]), $msgparts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user