Auth_phpBB: Fix for non-latin usernames

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php|uber.leet Forum Index // General
View previous topic :: View next topic  
Author Message
ipse



Joined: 26 Jan 2008
Posts: 4

PostPosted: Sat Jan 26, 2008 3:59 pm    Post subject: Auth_phpBB: Fix for non-latin usernames Reply with quote
I have users with non-latin usernames (in cyrillic) in my setup and without this fix they're not able to login:

Code:
--- Auth_phpBB.php   2008-01-27 02:44:40.000000000 +0300
+++ Auth_phpBB.php   2008-01-27 02:45:52.000000000 +0300
@@ -497,7 +497,7 @@
             $username = $this->utf8($username); // Convert to UTF8
 
           // Check Database for username. We will return the correct casing of the name.
-          $fstrMySQLQuery = 'SELECT `username_clean`
+          $fstrMySQLQuery = 'SELECT `username_clean`, `username`
                              FROM `' . $this->_UserTB . '`
                              WHERE `username_clean` = \'' . $username . '\'
                                LIMIT 1';
@@ -508,7 +508,7 @@
 
             while($faryMySQLResult = mysql_fetch_assoc($fresMySQLResult))
             {
-                return ucfirst($faryMySQLResult['username_clean']);
+                return ucfirst($faryMySQLResult['username']);
             }
 
             // At this point the username is invalid and should return just as it was passed.
@@ -880,7 +880,7 @@
             $username = $this->utf8($username); // Convert to UTF8
 
           // Check Database for username.
-          $fstrMySQLQuery = 'SELECT `username_clean`
+          $fstrMySQLQuery = 'SELECT `username_clean`, `username`
                              FROM `' . $this->_UserTB . '`
                              WHERE `username_clean` = \'' . $username . '\'
                                LIMIT 1';
@@ -895,11 +895,11 @@
                 // If debug is on print the username entered by the user and the one from the datebase to the screen.
                 if ($this->_debug)
                 {
-                    print $username . ' : ' . $faryMySQLResult['username_clean']; // Debug
+                    print $username . ' : ' . $faryMySQLResult['username']; // Debug
                 }
 
                 // Double check match.
-                if ($username == $faryMySQLResult['username_clean'])
+                if ($username == $faryMySQLResult['username'])
                 {
                     return true; // Pass
                 }


What this fix does is that it lookup username in DB as 'username_clean', but return value of 'username' to MW. Afaik this follow the way original phpBB code works.

Updated: Original patch was reversed. Fixed this.
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Mon Jan 28, 2008 2:23 pm    Post subject: Reply with quote
In my test environment I used हिन्दी to test non-English user names.

Code:
$username = $this->utf8($username); // Convert to UTF8


This line uses phpbb3's case folding code to force the name to lowercase.

In phpBB3. Name, NAME, NaMe, nAmE are all the same. They all get forced into username_clean as "name". Which has a unique index on it.

In MW, Name, NAME, NaMe, (nAmE = NAmE), are all different. MW forces the 1st letter to cap so the change in the last example.

So looking at the two I choose to enforce the more restrictive of the two systems. PhpBB3's. So the user names MW uses are a derivative of that rule. As MW forces upper casing on the 1st letter.

So the user name rule becomes.

Code:
$username = ucfirst(utf8($username));


This does cause some weird things. Like MrSmith on phpbb3 becomes Mrsmith in the wiki. My tests with हिन्दी worked so I assumed it ok.

To anyone who knows what हिन्दी mean I am sorry I do not, I just lifted it off a website.
Back to top
View user's profile Send private message
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php|uber.leet Forum Index // General All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

alexisBlue v1.2 // Theme Created By: Andrew Charron and Web Hosting Bluebook
Powered by phpBB © 2001, 2002 phpBB Group