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 Space in Username (https://vborg.vbsupport.ru/showthread.php?t=307349)

d1jsp 01-22-2014 06:06 PM

Disallow Space in Username
 
Hello folks,

I have googled this already before coming here, and my research has not been successful. I know how to accomplish this through modifying the code, but I want to minimize modifying vbulletin standard code to keep the files scalable with updates.

I use the Username Regular Expression :
^[A-Z0-9]

Which the help function suggests disallows spaces. However, users are still popping up with spaces in their usernames.

noppid 01-22-2014 06:13 PM

Use a different test. http://php.net/manual/en/function.strpos.php

kh99 01-22-2014 06:19 PM

Quote:

Originally Posted by d1jsp (Post 2476027)
I use the Username Regular Expression :
^[A-Z0-9]

I think the expression should be
Code:

^[A-Z0-9]+$
If you leave off the +$ then it's only saying that the name has to start with a letter or number. But you should be aware that if you use that expression, then names can only contain letters or numbers (and no other symbols), so you would need to add any other symbols you want to allow.

Of course, none of this will affect any existing names.

d1jsp 01-22-2014 06:28 PM

Quote:

Originally Posted by kh99 (Post 2476030)
I think the expression should be
Code:

^[A-Z0-9]+$
If you leave off the +$ then it's only saying that the name has to start with a letter or number. But if you use the expression I posted, then names can only contain letters or numbers (and no other symbols). Of course, none of this will affect any existing names.

This may be the problem; I will let you know.

I appreciate the response.

noppid 01-22-2014 06:36 PM

You both forgot lower case letters and a few other characters. Just saying.

kh99 01-22-2014 06:47 PM

Quote:

Originally Posted by noppid (Post 2476036)
You both forgot lower case letters and a few other characters. Just saying.

The code where that option is used looks like this:
PHP Code:

if (!preg_match('#' str_replace('#''\#'$this->registry->options['usernameregex']) . '#siU'$username))
{
    
$this->error('usernametaken'htmlspecialchars_uni($username), $this->registry->session->vars['sessionurl']);
    return 
false;



The 'i' in the siU at the end means ignore case, so that expression will allow lower case. I did mention that no other characters would be allowed, but I added to that post in case it wasn't clear what I meant.

JαρŘα?σoζ 01-30-2014 04:55 AM

So if I put this code "^[A-Z0-9]+$" to Username Regular Expression in vBulletin Options, that should be worked? So user cannnot make username that has space in it. Am I right?

tbworld 01-30-2014 05:35 AM

Quote:

Originally Posted by kh99 (Post 2476039)
The 'i' in the siU at the end means ignore case, so that expression will allow lower case.

I guess I can shorten my regex then. :)

Thanks for pointing out that code @Kh99. I had no idea they appended to the regular expression. I learn at least 10 things every day around here.

kh99 01-30-2014 09:19 AM

Quote:

Originally Posted by JαρŘα?σoζ (Post 2477888)
So if I put this code "^[A-Z0-9]+$" to Username Regular Expression in vBulletin Options, that should be worked? So user cannnot make username that has space in it. Am I right?

Yes. A user should then only be able to create a user name with letters and numbers only.


All times are GMT. The time now is 01:50 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.01035 seconds
  • Memory Usage 1,736KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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