LoginAttempts::RecordLoginAttempt PHP Method

RecordLoginAttempt() public static method

Insert IP record to the database which has a failed login attempt.
public static RecordLoginAttempt ( ) : void
return void
    public static function RecordLoginAttempt()
    {
        global $g_ado_db;
        $now = time();
        $userIp = getenv('REMOTE_ADDR');
        $queryStr = "INSERT INTO FailedLoginAttempts (ip_address,time_of_attempt) VALUES('" . $userIp . "','" . $now . "')";
        $g_ado_db->Execute($queryStr);
    }

Usage Example

Example #1
0
        // fix uri
        $_SERVER['REQUEST_URI'] = $this->getRequest()->getRequestUri();
        // reset view
        $this->view->legacy = NULL;
        $this->_helper->layout->enableLayout();
        // redirect/forward
        if (!empty($_POST['_next']) && $_POST['_next'] == 'post') {
            // forward POST request
            $this->_forward($this->_getParam('action'), $this->_getParam('controller'), 'admin');
        } else {
            // redirect GET request
            setcookie("TOL_Language", $f_login_language);
            if (array_key_exists(SecurityToken::SECURITY_TOKEN, $_GET)) {
                $_SERVER['REQUEST_URI'] .= sprintf('&%s=%s', SecurityToken::SECURITY_TOKEN, SecurityToken::GetToken());
            }
            $this->_redirect($_SERVER['REQUEST_URI'], array('prependBase' => false));
        }
        return;
    }
}
//
// Invalid logins start here.
//
// Record the attempt
LoginAttempts::RecordLoginAttempt();
// CAPTCHA invalid -> captcha login page
if ($validateCaptcha && !PhpCaptcha::Validate($f_captcha_code, true)) {
    return 'captcha';
}
// Everything else
return 'userpass';