View Single Post
  #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: 20,911
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