Auth_phpBB: Case of Letters in 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
Dr DBW



Joined: 22 Sep 2005
Posts: 24
Location: Melbourne, Victoria

PostPosted: Sun Feb 21, 2010 4:09 pm    Post subject: Auth_phpBB: Case of Letters in Usernames Reply with quote
It appears that something has changed with how usernames are handled by this extension.

I did have, I think it was, v2.6 installed. Have just upgrading to phpBB3, so also upgraded Auth_phpBB to the latest v3.0.3

Now a mess is made of usernames.

Before I could log into the wiki using Dr_DBW Now it logs me in as Dr_dbw That is now a new username, totally different to before. Anything done before as Dr_DBW is no longer linked to the user that I now log in as, Dr_dbw. Plus it means that all the permissions etc within MediaWiki that are associated with the first username no longer exists with the second.

Is there a way to return it to handle usernames as it did before?

Thank you.
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Tue Feb 23, 2010 12:09 pm    Post subject: Reply with quote
Take a look at the getCanonicalName function. When it finds a match on the username it does this.

Code:
return ucfirst($faryMySQLResult['username_clean']);


this uppercases the first letter of the clean username from the database.
Back to top
View user's profile Send private message
Dr DBW



Joined: 22 Sep 2005
Posts: 24
Location: Melbourne, Victoria

PostPosted: Tue Feb 23, 2010 1:46 pm    Post subject: Reply with quote
Thanks.

But that means it only upper cases the first letter, keeping the rest of the casing of the username intact.

So in my case, if removed that command, that would then mean that the username would become dr_dbw which is still not correct. Plus, that function is also present in the older script, so this is not what has changed the behaviour of something in how it is handling my usernames.

Been trying to compare the coding between the two versions of the script. Main difference to me appears to be the use of username versus username_clean This code also appears to be missing from the newer one:
Code:
          // Check MySQLVersion
            if ($GLOBALS['gstrMySQLVersion'] >= 4.1) {

              // Check Database for username. We will return the correct casing of the name.
              $fstrMySQLQuery = 'SELECT `username`
                                 FROM `' . $GLOBALS['wgPHPBB_UserTB'] . '`
                                 WHERE `username` = CONVERT( _utf8 \'' . $username . '\' USING latin1 )
                                   COLLATE latin1_swedish_ci
                                   LIMIT 1';
            } else {

              // Check Database for username. We will return the correct casing of the name.
              $fstrMySQLQuery = 'SELECT `username`
                                 FROM `' . $GLOBALS['wgPHPBB_UserTB'] . '`
                                 WHERE `username` = \'' . $username . '\'
                                   LIMIT 1';
            }

From my limited coding knowledge, that appears to may be what was maintaining the correct capitalising. And that is now missing from the current coding.
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Fri Feb 26, 2010 1:29 am    Post subject: Reply with quote
MW or PHPBB3 requires the updated mysql database so I removed the check.

the username_clean is used because phpBB3 supports utf8. Which really only matters on non-english forums. You are welcome to change the function to use just username.
Back to top
View user's profile Send private message
Dr DBW



Joined: 22 Sep 2005
Posts: 24
Location: Melbourne, Victoria

PostPosted: Sun Feb 28, 2010 3:39 pm    Post subject: Reply with quote
So, what is the difference between what is contained in username versus username_clean?
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Tue Mar 02, 2010 11:36 am    Post subject: Reply with quote
username_clean is case folded.

Without case folding.
MyName == MyName
myname != MyName

With case folding.
MyName == MyName
myname == MyName

What I have learned from helping my non-english users, is that in Cyrillic and Asian languages there is no upper and lower case concept and without UTF8 case folding. (Which phpbb3 does) it would become hard to look for usernames like below.

SELECT username WHERE username = "مرحبا!"
SELECT username WHERE username = "喂"
Back to top
View user's profile Send private message
Dr DBW



Joined: 22 Sep 2005
Posts: 24
Location: Melbourne, Victoria

PostPosted: Wed Mar 03, 2010 1:31 pm    Post subject: Reply with quote
Thank you for the reply.

Still doesn't help my issue though. Have tried changing to just username, but that script no longer works. Tried going back to the old version of the script, does not work with the phpBB3 installation.

So I now have a major problem, I cannot (or any of my users) log into the wiki now with the correct username.
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Fri Mar 05, 2010 11:18 am    Post subject: Reply with quote
When you look in the MW user table does it have an entry for both Dr_DBW and Dr_dbw ?
Back to top
View user's profile Send private message
Dr DBW



Joined: 22 Sep 2005
Posts: 24
Location: Melbourne, Victoria

PostPosted: Sun Mar 07, 2010 2:31 pm    Post subject: Reply with quote
Yes, they are both there, it created Dr_dbw when I logged in using the new script.
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Mon Mar 08, 2010 1:36 am    Post subject: Reply with quote
Yes that is because to MW

"Dr_dbw" != "Dr_DBW"

which is why I set it to use the case folded "dr_dbw".

So I go back to my suggestion to change the getCanonicalName function to return just the username and not username_clean field. Also remove ucfirst().
Back to top
View user's profile Send private message
Dr DBW



Joined: 22 Sep 2005
Posts: 24
Location: Melbourne, Victoria

PostPosted: Mon Mar 08, 2010 2:51 pm    Post subject: Reply with quote
Yes, I realised that, since it created a new user account for the username., as that is what is causing the problem.

I think I may have it sorted now, change the function code to:
Code:
        public function getCanonicalName( $username )
        {
            // Connect to the database.
            $fresMySQLConnection = $this->connect();

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

            // Check Database for username. We will return the correct casing of the name.
            $fstrMySQLQuery = sprintf("SELECT `username`
                               FROM `%s`
                               WHERE `username_clean` = '%s'
                               LIMIT 1",
                               $this->_UserTB,
                               mysql_real_escape_string($username, $fresMySQLConnection));

            // Query Database.
            $fresMySQLResult = mysql_query($fstrMySQLQuery, $fresMySQLConnection)
                or die($this->mySQLError('Unable to view external table'));

            while($faryMySQLResult = mysql_fetch_assoc($fresMySQLResult))
            {
                return $faryMySQLResult['username'];
            }

            // At this point the username is invalid and should return just as it was passed.            return $username;
        }

Through a lot of trial and error (as I said, not a real coding person), got something that works.

Thank you for the assistance. Very Happy

Cool
Back to top
View user's profile Send private message
Dr DBW



Joined: 22 Sep 2005
Posts: 24
Location: Melbourne, Victoria

PostPosted: Mon Apr 12, 2010 2:45 pm    Post subject: Reply with quote
OK, there was a problem with that last section of code. If the user had an uppercase first letter in their username on phpBB3, then it worked fine. However, those with lowercase first letters failed to be able to log in. Appears that need to maintain the uppercasing of the first letter, this line:
Code:
                return ucfirst($faryMySQLResult['username']);
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Tue Apr 13, 2010 12:31 pm    Post subject: Reply with quote
You are experiencing a lot of the same things I experienced that led me to the decision to use the case folded username_clean field.

What might be worthwhile is to add a new table that links the username_clean field to the username casing in phpBB and use getCanonicalName to read from there for the correct casing from phpBB3. Although that could have untold consequences.
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