Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2002, 03:38 AM
Neo's Avatar
Neo Neo is offline
 
Join Date: Oct 2001
Location: Anywhere
Posts: 1,817
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Disallow Special Chars in Username

THis would be great to have ( to lazy to make it ) but I have some poeple come on my site and register names like

~~~Mary~~~

and that for some odd reason makes me mad... so it would like a hack that only allows letters and numbers at registration.

thanks for your time

- Dan :ninja:
Reply With Quote
  #2  
Old 05-17-2002, 07:54 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In register.php find:

if (strlen($username)<$minuserlength) {

before that add:

------ cut -----------
// enter not allowed chars here seperated with a space:
$illegaluserchars=', . ~ ;';

$dontlethimuse=explode(" ",$illegaluserchars);

while (list($key,$val)=each($dontlethimuse))
{
if (strpos($username,$val))
{
eval("standarderror(\"".gettemplate("error_notallo wedusername")."\");");exit;
}
}
------ cut -----------

Create a template named "error_notallowedusername" and specify your error message that will be posted if someone enters an invalid char.

This is not tested so it may require some polishing and debugging, but needless to say, you can handle it perfectly. Also dont forget to add another if clause if you want to ban space or ' char..Enjoy..

Regards,
Logician
Reply With Quote
  #3  
Old 05-17-2002, 08:05 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ops I've just noticed that you ONLY want numbers or letters in the username. So this is easier to apply:

PHP Code:
if (!preg_match("/^[a-zA-Z0-9]+$/",$username)) 

eval(
"standarderror(\"".gettemplate("error_notallowedusername")."\");");exit; 

Reply With Quote
  #4  
Old 05-18-2002, 03:22 AM
Neo's Avatar
Neo Neo is offline
 
Join Date: Oct 2001
Location: Anywhere
Posts: 1,817
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you this really take some of my stress of coding off
Reply With Quote
  #5  
Old 05-19-2002, 02:20 AM
Joshua Clinard Joshua Clinard is offline
 
Join Date: Nov 2001
Posts: 101
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I use the code in this post on my board.

The update in this post did not work at all for me, but I posted a fix for the problem I was having.

You can change the text to say anything you want.
Reply With Quote
  #6  
Old 08-30-2005, 01:23 PM
Eggie Eggie is offline
 
Join Date: Jun 2005
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry to bring back a REALLY OLD thread. but after endless searching, this was the only post regarding this I could find.

Will this code also work with vB 3.0.8 If not, could you please provide me with a code that would.
Reply With Quote
  #7  
Old 08-30-2005, 01:30 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Eggie
sorry to bring back a REALLY OLD thread. but after endless searching, this was the only post regarding this I could find.

Will this code also work with vB 3.0.8 If not, could you please provide me with a code that would.
For vb 3.0.x, edit register.php, find:

PHP Code:
// strip 'blank' ascii chars if admin wants to do so 
BEFORE that line add (as a new line, NOT on the LEFT of it!):

PHP Code:
// Logician Hack Start
// enter not allowed chars here seperated with a space:
$illegaluserchars=', . ~ ;';

$dontlethimuse explode(" ",$illegaluserchars);

while (list(
$key,$val)=each($dontlethimuse))
{
    if (
strpos($_POST['username'],$val))
   {
    
$errors[11] = "You can not use ..... characters in username!";
   }
}
// Logician Hack End 
Reply With Quote
  #8  
Old 08-31-2005, 09:37 AM
Eggie Eggie is offline
 
Join Date: Jun 2005
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

great! and this will provent usernames from having a space also?
Reply With Quote
  #9  
Old 08-31-2005, 05:55 PM
paul41598's Avatar
paul41598 paul41598 is offline
 
Join Date: Jun 2004
Location: MI
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Eggie
great! and this will provent usernames from having a space also?
thanks!
Reply With Quote
  #10  
Old 08-31-2005, 06:02 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe easier:

PHP Code:
if (preg_match('/[,|\.|~|;]/'$_POST['username'])
{
    
$errors[11] = "You can not use ..... characters in username!";

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 07:57 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06785 seconds
  • Memory Usage 2,257KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete