Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Restrict usernames to alphanumeric and underscore Details »»
Restrict usernames to alphanumeric and underscore
Version: 1.00, by Reynaldovb Reynaldovb is offline
Developer Last Online: Aug 2014 Show Printable Version Email this Page

Version: 3.0.3 Rating:
Released: 12-30-2004 Last Update: Never Installs: 28
 
No support by the author.

In response to
http://www.vbulletin.com/forum/showt...614#post772614

User memobug wanted (and myself too) to have a way to restrict usernames to alphanumeric chars and underscore. To me it has been a headache with a lot of users because their password didn't work, just to find after investigation that their usernames had an space and they were writing it without it. I hope this helps others as it has helped me.

Here are the instructions to do it.

1) Go to your Admin Control Panel, Phrases Manager and create a new phrase named "username_invalidchars" in the "Front-end error messages" section.

For the text use something like "Username has invalid characters. Only characters allowed are letters, numbers and underscore."



2.- Open /forums/register.php

Somewhere around line 187 you will find the following
PHP Code:
$errors = array(); 
Add the following just below that
PHP Code:
//--------------------------------------------------
    // check username does not contain UNWANTED characters
    
if (preg_match('/[^a-zA-Z0-9\_]+/'$_POST['username']))
    {
        
//eval(print_standard_error('error_username_semicolon'));
        
eval('$errors[11] = "' fetch_phrase('username_invalidchars'PHRASETYPEID_ERROR) . '";');
    }
//------------------------------------------------- 

That's it, enjoy it.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 01-17-2005, 12:07 PM
shawno shawno is offline
 
Join Date: Jul 2004
Location: London
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reynaldovb,

Thank you
Thank you
Thank you

To be suprised I am not sure why this isn't a default item within vB. The amount of work generated by users saying "my log in doesn't work" all because of spaces and symbols is incredible.

Shawno
Reply With Quote
  #13  
Old 01-18-2005, 02:23 AM
T3MEDIA T3MEDIA is offline
 
Join Date: Dec 2004
Posts: 944
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do I put \- at then end to add the "-" symbol? I dont mind having that as well.
Reply With Quote
  #14  
Old 01-18-2005, 04:58 AM
Reynaldovb Reynaldovb is offline
 
Join Date: Dec 2004
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

T3Media:

Yes, it would be something like this:
PHP Code:
if (preg_match('/[^a-zA-Z0-9\_\-]+/'$_POST['username'])) 
Reply With Quote
  #15  
Old 01-20-2005, 12:29 PM
T3MEDIA T3MEDIA is offline
 
Join Date: Dec 2004
Posts: 944
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Respect due. Thanks. Just needed to verify.
Reply With Quote
  #16  
Old 01-23-2005, 01:30 PM
Mechanical Mind's Avatar
Mechanical Mind Mechanical Mind is offline
 
Join Date: Sep 2004
Location: USA
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

* clicks install *

I haven't had a problem with user names like >>..@---@..<< yet !!!

However, I don't want to have such problems!!!

Thank you. I'm going to test this out. And I only have 85 members, so I will email a few of them to notify them that an underscore has been added to their names. (I will add them manually)
Reply With Quote
  #17  
Old 01-23-2005, 03:32 PM
Mechanical Mind's Avatar
Mechanical Mind Mechanical Mind is offline
 
Join Date: Sep 2004
Location: USA
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does anybody which part in CSS to modify the error message color. The error message color on my forum is so light, that it can barely be seen.

Thanks.

UPDATE..........

I found it. Page Background, Font Color
Reply With Quote
  #18  
Old 02-07-2005, 07:28 AM
PIKenPIK PIKenPIK is offline
 
Join Date: Feb 2005
Location: Netherlands
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i've installed V3.0.6

following code in register.php

PHP Code:
    $errors = array();

    
// check username does not contain semi-colons
    
if (preg_match('/(?<!&#[0-9]{3}|&#[0-9]{4}|&#[0-9]{5});/'$_POST['username']))
    {
        
//eval(print_standard_error('error_username_semicolon'));
        
eval('$errors[10] = "' fetch_phrase('username_semicolon'PHRASETYPEID_ERROR) . '";');
    } 
Is that the same or what?
Reply With Quote
  #19  
Old 02-07-2005, 10:08 AM
Lizard King Lizard King is offline
 
Join Date: Jan 2005
Location: Mersin
Posts: 907
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if (preg_match('/[^a-zA-Z0-9\_\ \]+/'$_POST['username'])) 
Is this the correct code if I want to allow space in user names ?
I am using one
Reply With Quote
  #20  
Old 02-07-2005, 04:11 PM
Reynaldovb Reynaldovb is offline
 
Join Date: Dec 2004
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lizard King:
No, I think the correct way to do it would be something like this:
PHP Code:
if (preg_match('/[^a-zA-Z0-9\_\s]+/'$_POST['username'])) 
Reply With Quote
  #21  
Old 02-19-2005, 01:17 PM
clearchannel clearchannel is offline
 
Join Date: Nov 2001
Location: Ft Lauderdale, Florida
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would like to install this hack in vB 3.06. I would also like to allow spaces in usernames. Which of the above code would be correct to use in 3.06?

Thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:46 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04558 seconds
  • Memory Usage 2,316KB
  • Queries Executed 27 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete