vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Prevent use of symbols in usernames (https://vborg.vbsupport.ru/showthread.php?t=33086)

Joshua Clinard 12-09-2001 08:18 PM

I don't want people to be able to sign up with symbols in their usernames, like the forwards slash, and the paranthases, and so on. The only symbol I want people to be able to use in thier username is the underscore. No periods, commas, or other symbols or punctuation marks. Is there a way to prevent this?

Scott MacVicar 12-09-2001 10:09 PM

open register.php

look for

PHP Code:

  if (strlen($username)<$minuserlength) {
    eval(
"standarderror(\"".gettemplate("error_usernametooshort")."\");");
    exit;
  } elseif (
strlen($username)>$maxuserlength) {
    eval(
"standarderror(\"".gettemplate("error_usernametoolong")."\");");
    exit;
  } 

below it add
PHP Code:

  if(!preg_match("/^[a-zA-Z_0-9]+$/"$username)) {
    eval(
"standarderror(\"Invalid Characters you can only use a-z, 1-9 or an underscore in your username.\");");
    exit;
  } 


Joshua Clinard 12-10-2001 12:31 AM

Thanks. I'm just curious, but has this been tested?

Scott MacVicar 12-10-2001 12:08 PM

Yeah it will work, it allow characters for a-z A-Z underscore and numbers in the range 0-9.

Hence the

a-zA-Z_0-9

but i believe that

PHP Code:

if (!preg_match("/^\w+$/"$username)) {
  eval(
"standarderror(\"Invalid Characters you can only use a-z, 1-9 or an underscore in your username.\");");
  exit;


as \w represents word in perl thought it depends on locale settings

Joshua Clinard 12-16-2001 07:48 PM

I didn't realize that this hack was also going to prevent the use of spaces. I don't want it to do that. Is there anyway to fix that? If I just typed in a space after the _ would that do it? By the way, I don't get what you were trying to say in your last post! Can you tell me what that means?

Joshua Clinard 12-18-2001 03:50 PM

Can someone please help? I want to get this fixed.

StarBuG 01-08-2002 03:07 PM

ever tried to use the html code for space in that definition?
"& n b s p ;" or "& # 1 6 0 ;" (without the spaces and "!)

like

PHP Code:

if(!preg_match("/^[a-zA-Z_0-9& n b s p ;]+$/"$username)) {
    eval(
"standarderror(\"Invalid Characters you can only use a-z, 1-9 or an underscore in your username.\");");
    exit;
  } 

(also without spaces of course)

don?t know if it works but it is woth a try ;)

Greetings

StarBuG

Joshua Clinard 01-10-2002 03:03 PM

The answer is to add a space after 9 in this code
PHP Code:

[a-zA-Z_0-

This has been tested. Thanks to Hoojx for help with this.

Scott MacVicar 01-10-2002 03:25 PM

this works as well

PHP Code:

if (!preg_match("/^w+$/"$username)) {
  eval(
"standarderror(\"Invalid Characters you can only use a-z, 1-9 or an underscore in your username.\");");
  exit;



Sion 06-27-2002 10:15 AM

How can I allow a dash (-) aswell? Coz when I added it it didn't seem to work!

--Sion

Logician 06-27-2002 10:38 AM

use in this format:

[a-zA-Z_0-9\- ]

Sion 07-01-2002 01:05 PM

How can I prevent ppl signing up with - and _ at the beginning/end of their usernames, so that they're valid for email addresses (ie. username@mydomain.com)

Thanks!

Joshua Clinard 08-30-2002 04:05 PM

Glad someone else got some use out of this mod. I thought I was the only one using it.

N9ne 08-30-2002 04:55 PM

Maybe it should be released..

stan111 02-01-2007 05:04 AM

how come i can't find any of those code under register.php

Princeton 02-01-2007 01:31 PM

you brought up an old thread .... check the date :D


All times are GMT. The time now is 04:46 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.01066 seconds
  • Memory Usage 1,749KB
  • 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
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)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