Ban Error Fix

HabboME

Member
Oct 14, 2011
84
20
Here is a fix for the ban error that is suppose to show when a user tries to log in.

Below is how to fix it.

Find in class.users.php

PHP:
    final public function isBanned($value)
    {
        global $engine;
        if($engine->num_rows("SELECT * FROM bans WHERE value = '" . $value . "' LIMIT 1") > 0)
        {
            return true;
        }
           
        return false;
    }

Replace With

PHP:
    final public function isBanned($value)
    {
        global $engine;
           
        if ($engine->num_rows("SELECT * FROM bans WHERE value = '" . $value . "' AND expire >= '" . time() . "' ") > 0)
        {
            return true;
        }
 
        return false;   
    }

Find in class.users.php

PHP:
    if($this->isBanned($template->form->log_username) == false || $this->isBanned($_SERVER['REMOTE_ADDR']) == false)
    {
        if($this->userValidation($template->form->log_username, $core->hashed($template->form->log_password)))
        {
            $this->turnOn($template->form->log_username);
            $this->updateUser($_SESSION['user']['id'], 'ip_last', $_SERVER['REMOTE_ADDR']);
            $template->form->unsetData();
            header('Location: ' . $_CONFIG['hotel']['url'] . '/me');
            exit;
        }
        else
        {
            $template->form->error = 'Details do not match';
            return;
        }
    }
    else
    {
        $template->form->error = 'Sorry, it appears this user is banned<br />';
        $template->form->error .= 'Reason: ' . $this->getReason($template->form->log_username);
        return;
    }

Replace With

PHP:
if($this->isBanned($_SERVER['REMOTE_ADDR']) == false)
    {
        if($this->isBanned($template->form->log_username) == false)
        {
            if($this->userValidation($template->form->log_username, $core->hashed($template->form->log_password)))
            {
                $this->turnOn($template->form->log_username);
                $this->updateUser($_SESSION['user']['id'], 'ip_last', $_SERVER['REMOTE_ADDR']);
                $template->form->unsetData();
                header('Location: ' . $_CONFIG['hotel']['url'] . '/me');
                exit;
            }
            else
            {
                $template->form->error = 'Details do not match';
                return;
            }
        }
        else
        {
            $template->form->error = 'Sorry, it appears this user is banned<br />';
            $template->form->error .= 'Reason: ' . $this->getReason($template->form->log_username);
            return;
        }
    }
    else
    {
        $template->form->error = 'Sorry, it appears this IP is banned.<br />';
        $template->form->error .= 'Reason: ' . $this->getReason($_SERVER['REMOTE_ADDR']);
        return;
    }
 

presto5

Member
Jul 26, 2011
66
1
Already fixed this on my own I wasn't sure if I should release but anyway nice post. Should help a lot of people.
 

Users who are viewing this thread

Top