No Special Characters in Usernames
Author Message
This is a fairly useless plugin.  It just disallows usernames which have characters other than a-z, 0-9 and _ in them (can allow more characters by changing the setting under "User Registration and Profile Options").
I recall someone requesting this, which is why I made it.

Otherwise, just posting it here to increase my post count.
(This post was last modified: 11-05-2015 06:42 PM by ZiNgA BuRgA.)
Find all posts by this user
Quote this message in a reply
Download: stduname.php (4.22 KB)
Plugin Version: 1.4
Last Updated: 11-05-2015, 06:42 PM

Downloads: 1,749
MyBB Compatibility: 1.2.x, 1.4.x, 1.6.x, 1.8.x
Uploader: ZiNgA BuRgA
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #11
RE: No Special Characters in Usernames
(07-03-2010 07:44 PM)ZiNgA BuRgA Wrote:  - checks username in AJAX registration
- added setting under User Registration and Profile Options, where you can enter in additional characters you want to allow

With this setting, this plugin is really useful and give us more flexibility. Thank you very much, Yumi.

07-04-2010 01:28 PM
Find all posts by this user Quote this message in a reply
katib Offline
Junior Member
**
Posts: 20
Joined: Dec 2010
Post: #12
RE: No Special Characters in Usernames
Sure! it is a useful Plugin
However, I wonder if it is possible to disallow some characters using regex!!
I would like to disallow all latin charaters [a-z] [A-Z] so only arabic characters are allowed
Back in the time when I was using phpbb3, this was acheived by :

Code:
$regex = '[\p{Arabic}0-9-[\]_+ ]*\p{Arabic}+[\p{Arabic}0-9-[\]_+ ]*';

This also ensures that choosen username contains at least on alphabet, and not only numerics

(This post was last modified: 12-06-2010 10:04 AM by katib.)
12-06-2010 10:00 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #13
RE: No Special Characters in Usernames
Do a search for preg_match and edit it with whatever regex you want.

My Blog
12-06-2010 10:11 AM
Find all posts by this user Quote this message in a reply
katib Offline
Junior Member
**
Posts: 20
Joined: Dec 2010
Post: #14
RE: No Special Characters in Usernames
Thanks for prompt reply
I found:

Code:
	return !preg_match('#[^0-9a-zA-Z'.strtr($mybb->settings['stduname_allowedchars'], array('\\' => '\\\\', '[' => '\\[', ']' => '\\]', '-' => '\\-')).']#', $name);

So is it simply a matter of replacing 0-9a-zA-Z by p{Arabic}0-9
?

12-06-2010 10:39 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #15
RE: No Special Characters in Usernames
No, you need to replace [^0-9a-zA-Z'.strtr($mybb->settings['stduname_allowedchars'], array('\\' => '\\\\', '[' => '\\[', ']' => '\\]', '-' => '\\-')).'] with whatever you wish

My Blog
(This post was last modified: 12-06-2010 11:26 AM by ZiNgA BuRgA.)
12-06-2010 11:26 AM
Find all posts by this user Quote this message in a reply
katib Offline
Junior Member
**
Posts: 20
Joined: Dec 2010
Post: #16
RE: No Special Characters in Usernames
Unfortunately, it didnot work
Basically, I need to ensure two things:
1- That username contains arabic characters only: p{Arabic}
I mean I want to disallow all latin characters: a-zA-Z
2- That username contains AT LEAST one alphabet, so username with numerics only like 555586 are disallowed
12-06-2010 11:37 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #17
RE: No Special Characters in Usernames
That's because there's no such pattern as "{Arabic}": http://www.php.net/manual/en/reference.p...http://www.php.net/manual/en/reference.pcre.pattern.

Unfortunately, it's up to you to supply the correct regex - I just pointed out where to edit.  I have no idea what arabic characters are like, so you're going to have to research that one unfortunately.

My Blog
12-07-2010 08:20 AM
Find all posts by this user Quote this message in a reply
katib Offline
Junior Member
**
Posts: 20
Joined: Dec 2010
Post: #18
RE: No Special Characters in Usernames
It deos exist: http://alex-csed.blogspot.com/2010/03/tu...http://alex-csed.blogspot.com/2010/03/tutorial-validating-users-arabic-

Code:
 /\p{Arabic}/u 

However I am a totla newbie at php, so dont know how to implement it

12-07-2010 08:49 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #19
RE: No Special Characters in Usernames
That's interesting - I wonder why I couldn't find that in the official docs. (I blame the documentation >_>)
Take a look at the regex used inside preg_match.  The page you linked seems to suggest that the "u" modifier is required.  I'm using "#" as a delimiter instead of "/", so you need to stick the "u" after the second "#".  See if that helps.

My Blog
12-07-2010 08:58 AM
Find all posts by this user Quote this message in a reply
Speeder Offline
Junior Member
**
Posts: 1
Joined: Feb 2011
Post: #20
RE: No Special Characters in Usernames
Hi! I found a bug in this plugin.

If I don´t allow spaces in usernames, but a user register with spaces in the end of username, the plugin allow the use of that username.

Example: Disallow spaces in usernames. Then, register for example with this username u1 and put 1 or more spaces at the end of the username. Bingo! It´s allowed.
05-05-2011 05:11 AM
Find all posts by this user Quote this message in a reply


Forum Jump: