diff options
author | David M <davidmj@users.sourceforge.net> | 2007-03-31 15:16:18 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2007-03-31 15:16:18 +0000 |
commit | c6b0b621651e52bccc778cd9d1e8cf8cf02bc2de (patch) | |
tree | 7946a24f4150fff6e56c62cf203ab9a8d7ecaa45 /phpBB/includes/functions_user.php | |
parent | 21ff4e419030d7114f599ea2a13882497644285a (diff) | |
download | forums-c6b0b621651e52bccc778cd9d1e8cf8cf02bc2de.tar forums-c6b0b621651e52bccc778cd9d1e8cf8cf02bc2de.tar.gz forums-c6b0b621651e52bccc778cd9d1e8cf8cf02bc2de.tar.bz2 forums-c6b0b621651e52bccc778cd9d1e8cf8cf02bc2de.tar.xz forums-c6b0b621651e52bccc778cd9d1e8cf8cf02bc2de.zip |
allow password complexity to work using mbstring if PCRE does not support unicode properties
git-svn-id: file:///svn/phpbb/trunk@7249 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 1670a90a5f..1f17274250 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1254,6 +1254,8 @@ function validate_password($password) return false; } + $pcre = $mbstring = false; + // generic UTF-8 character types supported? if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) { @@ -1261,6 +1263,16 @@ function validate_password($password) $low = '\p{Ll}'; $num = '\p{N}'; $sym = '[^\p{Lu}\p{Ll}\p{N}]'; + $pcre = true; + } + else if (function_exists('mb_ereg_match')) + { + mb_regex_encoding('UTF-8'); + $upp = '[[:upper:]]'; + $low = '[[:lower:]]'; + $num = '[[:digit:]]'; + $sym = '[^[:upper:][:lower:][:digit:]]'; + $mbstring = true; } else { @@ -1268,6 +1280,7 @@ function validate_password($password) $low = '[a-z]'; $num = '[0-9]'; $sym = '[^A-Za-z0-9]'; + $pcre = true; } $chars = array(); @@ -1293,11 +1306,24 @@ function validate_password($password) break; } - foreach ($chars as $char) + if ($pcre) { - if (!preg_match('#' . $char . '#u', $password)) + foreach ($chars as $char) { - return 'INVALID_CHARS'; + if (!preg_match('#' . $char . '#u', $password)) + { + return 'INVALID_CHARS'; + } + } + } + else if ($mbstring) + { + foreach ($chars as $char) + { + if (!mb_ereg_match($char, $password)) + { + return 'INVALID_CHARS'; + } } } |