vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Disallow Special Chars in Username (https://vborg.vbsupport.ru/showthread.php?t=38725)

Neo 05-17-2002 03:38 AM

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:

Logician 05-17-2002 07:54 AM

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

Logician 05-17-2002 08:05 AM

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; 



Neo 05-18-2002 03:22 AM

thank you this really take some of my stress of coding off :)

Joshua Clinard 05-19-2002 02:20 AM

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.

Eggie 08-30-2005 01:23 PM

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.

Logician 08-30-2005 01:30 PM

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 


Eggie 08-31-2005 09:37 AM

great! and this will provent usernames from having a space also?

paul41598 08-31-2005 05:55 PM

Quote:

Originally Posted by Eggie
great! and this will provent usernames from having a space also?

thanks!

Andreas 08-31-2005 06:02 PM

Maybe easier:

PHP Code:

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




All times are GMT. The time now is 06:21 AM.

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.02421 seconds
  • Memory Usage 1,740KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete