RevCMS Character Fix

Blasteh

Lord Farquaad
Apr 3, 2013
1,151
513
Hello,
Recently users have been registering with a lightning bolt, skulls, etc. I tried to fix it, but for some reason, they still can.

Here's my class.users.php code:
HTML:
    /*-------------------------------Checking of submitted data-------------------------------------*/
    
final public function validName($username)
{
    if(strlen($username) <= 25 && preg_match("/^[a-zA-Z0-9]+$/", $username))
    {         
        return true;     
    }             

    return false;
}
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Problem is fixed by not using a CMS made in 2010

On Topic:
Code:
final public function validName($username)    
    {
        if(strlen($username) <= 25 && ctype_alnum($username))        
         {
            if(preg_match("/^[a-zA-Z0-9]+$/", $username) == 1) {
             return true;
            }          
         }                
       
         return false;    
    }
ctype_alnum is a function in php that will test if the string contains only letters and numbers. The preg_match is another check for validation to be 100% sure :)
 
Last edited by a moderator:

Blasteh

Lord Farquaad
Apr 3, 2013
1,151
513
If you're simply not going to help, this is really a basic question tbh and I see no ignorance involved in this post; so if you are going to not help then don't bother replying.

On Topic:
Code:
final public function validName($username)    
    {
        if(strlen($username) <= 25 && ctype_alnum($username))        
         {
            if(preg_match("/^[a-zA-Z0-9]+$/", $username) == 1) {
             return true;
            }          
         }                
       
         return false;    
    }
ctype_alnum is a function in php that will test if the string contains only letters and numbers. The preg_match is another check for validation to be 100% sure :)
That doesn't seem to fix the problem, I can still register with a skull, lightning bolt, etc.
 

zakiy

Member
Dec 5, 2011
44
4
Try adding this to your register page.
<script>
$('input').on('keypress', function (e) {
if (/^[a-zA-Z0-9\.\b]+$/.test(String.fromCharCode(e.keyCode))) {
return;
} else {
e.preventDefault();
}
});
</script>

then to disable copy and paste add this
<script>
window.onload = function() {
var myInput = document.getElementById('username');
myInput.onpaste = function(e) {
e.preventDefault();
}
}
</script>

REMEMBER: Put these before <body>
 

Blasteh

Lord Farquaad
Apr 3, 2013
1,151
513
Try adding this to your register page.
<script>
$('input').on('keypress', function (e) {
if (/^[a-zA-Z0-9\.\b]+$/.test(String.fromCharCode(e.keyCode))) {
return;
} else {
e.preventDefault();
}
});
</script>

then to disable copy and paste add this
<script>
window.onload = function() {
var myInput = document.getElementById('username');
myInput.onpaste = function(e) {
e.preventDefault();
}
}
</script>

REMEMBER: Put these before <body>
Doesn't work.
 
So I'd just do this, is that what you're saying?
You must be registered for see images attach
 

Users who are viewing this thread

Top