Regular Expression For Profile Fields
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Regular Expression For Profile Fields
Last Update: 31 January 2012

A plugin to add a Regular Expression setting for a textbox Profile Fields.
The formatting check method used for this plugin uses XThreads Text Mask Filter method (I hope I don't misunderstand it Biggrin).

Please tell me if there is something wrong with the code. I'm still learning Smile


Attached File(s)
.7z  mn_pfregex.7z (Size: 1.51 KB / Downloads: 397)

(This post was last modified: 02-01-2012 02:41 AM by RateU.)
01-30-2012 06:57 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #2
RE: Regular Expression For Profile Fields
So basically, it will work like the MyCodes? More protection? Will try.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
01-30-2012 02:44 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #3
RE: Regular Expression For Profile Fields
For example, if you want your users fill a digit only in a profile fields, you can set the setting to ^\d+$
So, if they fill the profile fields with a non digit char, an error will be displayed.

01-31-2012 01:03 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Regular Expression For Profile Fields
Nice and logical - should be in stock Tongue

BTW, you might want to strip null chars when saving the expression, that is, replace

PHP Code:
$mn_pfaddsetting['mn_pfregex'] = $GLOBALS['db']->escape_string($GLOBALS['mybb']->input['mn_pfregex']);

with

PHP Code:
$mn_pfaddsetting['mn_pfregex'] = $GLOBALS['db']->escape_string(str_replace("\0", '', $GLOBALS['mybb']->input['mn_pfregex']));


IMO you shouldn't need to do this - blame PHP for that.  Reason being that it's possible to artificially terminate the expression early, although, really, it's not much of an issue since only admins can exploit it.


My Blog
01-31-2012 04:55 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #5
RE: Regular Expression For Profile Fields
Thanks for the fix, Yumi Smile
I've updated the plugin.

02-01-2012 02:42 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #6
RE: Regular Expression For Profile Fields
Alright, But i found a bug, if there are any required fields other than email and password, and you fill a incorrect input for the field that uses a regex, you get a normal error but the required field go away, the problem is, that when you try and insert a now-valid input for the regex field, you get a error saying ¨X field value is missing¨ (not exactly the same but..)
.

Registration is working fine.

Sorry if you don-t get me, danm keyboar...

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
02-01-2012 02:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #7
RE: Regular Expression For Profile Fields
Do you mean the textbox disappear from the registration page after filling it?
I'm sorry, but I can't reproduce it.

http://xtest.byethost7.com/member.php?action=register

02-02-2012 04:40 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #8
RE: Regular Expression For Profile Fields
No no, the registration page is working 100% right.

The problem is in the edit profile page.

If there are any profile fields that are required and don´t use some regex, such field disappear after you submit a invalid profile field that require a regex field.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
02-02-2012 03:33 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #9
RE: Regular Expression For Profile Fields
Still, I can't reproduce it:

   
The 'Location' is a required fields, no regex.
The 'Color' is a non required fields, regex.

(This post was last modified: 02-03-2012 03:04 AM by RateU.)
02-03-2012 02:39 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #10
RE: Regular Expression For Profile Fields
mmm, will check it in a clean board, my actual localhost is not so clean, maybe there is another plugin the one giving problems with this.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
02-03-2012 01:11 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: