aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_user.php
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2006-11-12 15:17:46 +0000
committerDavid M <davidmj@users.sourceforge.net>2006-11-12 15:17:46 +0000
commitb0217ddc11799f81c8cf42961f6e0db54ce2e38e (patch)
treea3c79604787560feb5358e658ba21598dd99d2f2 /phpBB/includes/functions_user.php
parent90b16076d34cf1475d8210701737b4df371f42eb (diff)
downloadforums-b0217ddc11799f81c8cf42961f6e0db54ce2e38e.tar
forums-b0217ddc11799f81c8cf42961f6e0db54ce2e38e.tar.gz
forums-b0217ddc11799f81c8cf42961f6e0db54ce2e38e.tar.bz2
forums-b0217ddc11799f81c8cf42961f6e0db54ce2e38e.tar.xz
forums-b0217ddc11799f81c8cf42961f6e0db54ce2e38e.zip
banned usernames are now cached and normalized
git-svn-id: file:///svn/phpbb/trunk@6571 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r--phpBB/includes/functions_user.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 56b92f850b..a1bdec1695 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1120,9 +1120,11 @@ function validate_match($string, $optional = false, $match)
*/
function validate_username($username)
{
- global $config, $db, $user;
+ global $config, $db, $user, $cache;
+
+ $clean_username = utf8_clean_string($username);
- if (utf8_clean_string($user->data['username']) == utf8_clean_string($username))
+ if (utf8_clean_string($user->data['username']) == $clean_username)
{
return false;
}
@@ -1134,7 +1136,7 @@ function validate_username($username)
$sql = 'SELECT username
FROM ' . USERS_TABLE . "
- WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
+ WHERE username_clean = '" . $db->sql_escape($clean_username) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -1156,19 +1158,17 @@ function validate_username($username)
return 'USERNAME_TAKEN';
}
- $sql = 'SELECT disallow_username
- FROM ' . DISALLOW_TABLE;
- $result = $db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ $bad_usernames = array();
+ $cache->obtain_disallowed_usernames($bad_usernames);
+
+ foreach ($bad_usernames as $bad_username)
{
- if (preg_match('#^' . str_replace('%', '.*?', preg_quote($row['disallow_username'], '$#')) . '#i', $username))
+ if (preg_match('#^' . $bad_username . '#', $clean_username))
{
- $db->sql_freeresult($result);
return 'USERNAME_DISALLOWED';
}
}
- $db->sql_freeresult($result);
$sql = 'SELECT word
FROM ' . WORDS_TABLE;