Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2015, 05:36 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 113,273
Abronsyth is on a distinguished road
Default Disable certain characters in usernames

Resolved

Hello!

So despite the very obvious warning I put on my registration page I still have users registering with special characters in their usernames, which makes it so that their profiles become unviewable and makes for some issues.

Is there a way to disable it so that if they attempt to register with a special character in the username it won't register them, but instead gives the warning "Sorry, please only use letters, numbers, or spaces in your username."
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 02-18-2016 at 06:39 PM.
Reply With Quote
  #2  
Old 02-18-2016, 11:35 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 113,273
Abronsyth is on a distinguished road
Default

OK, so there's this chunk of code;
Code:
      if($username == "SYSTEM"){
         $this->seterror("Cannot use SYSTEM as username.");
         return FALSE;
      }
But I'm wondering if I could do something like this to make it so the only characters that can be entered are alphanumeric and spaces? So if a user tries something like; "user_name" then they'll get the error; "Sorry, you cannot use special characters in your username."

Some folks use this sort of code;
PHP Code:
if(preg_match('/^[a-zA-Z0-9 ]+$/'$username)) {

Do y'all think I'd be able to incorporate that somehow..?
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 02-18-2016 at 11:44 AM.
Reply With Quote
  #3  
Old 02-18-2016, 04:36 PM
pachoofoosh's Avatar
pachoofoosh pachoofoosh is offline
Artist
 
Join Date: Dec 2012
Location: New York
Posts: 98
Gender: Unknown/Other
Credits: 15,419
pachoofoosh is on a distinguished road
Default

To check that usernames only have letters, numbers, and spaces, find the usernamevalidate() function in classes/class_registervalidator.php and replace the function with this:
PHP Code:
protected function usernamevalidate($username ""){
      
// The username validator, note its a bit complicate here due to the different mechanism of username check for register and other validators
      
$lang Registry::get("lang");
      if(!
$this->emptyvalidate($username)){
         
$this->seterror("The field Username is Empty.");
         return 
FALSE;
      }
      if(
preg_match('#^[A-Z0-9 ]+$#i'$username) == FALSE){
         
$this->seterror("Usernames can only contain letters, numbers, and spaces.");
         return 
FALSE;
      }
      
$username = (empty($username))?$this->value['username']:$username;      
      
$userexist $this->datavalidate("users", array("username"), "username = '{$username}'");
      if(
$userexist == TRUE){
         
$this->seterror($lang->user);
         return 
FALSE;
      }
      else return 
TRUE;
  } 
__________________
The calzones... betrayed me?
Reply With Quote
  #4  
Old 02-18-2016, 06:38 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 113,273
Abronsyth is on a distinguished road
Default

Awesome, thank you!

Also- Pachooooo! <3
__________________
My Mods Site (1.3.4, 2020 Mods)
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 -5. The time now is 04:10 PM.

Currently Active Users: 597 (0 members and 597 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636