concrete/src/Permission/IPService.php
public function failedLoginsThresholdReached(AddressInterface $ip = null, $ignoreConfig = false)
    {
        $result = false;
        if ($ignoreConfig || $this->config->get('concrete.security.ban.ip.enabled')) {
            if ($ip === null) {
                $ip = $this->getRequestIPAddress();
            }
            if (!$this->isWhitelisted($ip)) {
                $thresholdSeconds = (int) $this->config->get('concrete.security.ban.ip.time');
                $thresholdTimestamp = new DateTime("-{$thresholdSeconds} seconds");
                $rs = $this->connection->executeQuery(
                    '
                        SELECT
                            ' . $this->connection->getDatabasePlatform()->getCountExpression('lcirID') . ' AS n
                        FROM
                            FailedLoginAttempts
                        WHERE
                            flaIp = ?
                            AND flaTimestamp > ?
                    ',
                    [$ip->getComparableString(), $thresholdTimestamp->format($this->connection->getDatabasePlatform()->getDateTimeFormatString())]
                );
                $count = $rs->fetchColumn();
                $rs->closeCursor();
                $thresholdAttempts = (int) $this->config->get('concrete.security.ban.ip.attempts');
                if ($count !== false && (int) $count >= $thresholdAttempts) {
                    $result = true;
                }
            }
        }

        return $result;
    }
public function failedLoginsThresholdReached(AddressInterface $ip = null, $ignoreConfig = false)
    {
        $result = false;
        if ($ignoreConfig || $this->config->get('concrete.security.ban.ip.enabled')) {
            if ($ip === null) {
                $ip = $this->getRequestIPAddress();
            }
            if (!$this->isWhitelisted($ip)) {
                $thresholdSeconds = (int) $this->config->get('concrete.security.ban.ip.time');
                $thresholdTimestamp = new DateTime("-{$thresholdSeconds} seconds");
                $rs = $this->connection->executeQuery(
                    '
                        SELECT
                            ' . $this->connection->getDatabasePlatform()->getCountExpression('lcirID') . ' AS n
                        FROM
                            FailedLoginAttempts
                        WHERE
                            flaIp = ?
                            AND flaTimestamp > ?
                    ',
                    [$ip->getComparableString(), $thresholdTimestamp->format($this->connection->getDatabasePlatform()->getDateTimeFormatString())]
                );
                $count = $rs->fetchColumn();
                $rs->closeCursor();
                $thresholdAttempts = (int) $this->config->get('concrete.security.ban.ip.attempts');
                if ($count !== false && (int) $count >= $thresholdAttempts) {
                    $result = true;
                }
            }
        }

        return $result;
    }
public function failedLoginsThresholdReached ( AddressInterface $ ip = null , $ ignoreConfig = false ) { $ result = false ; if ( $ ignoreConfig || $ this -> config -> get ( 'concrete.security.ban.ip.enabled' ) ) { if ( $ ip === null ) { $ ip = $ this -> getRequestIPAddress ( ) ; } if ( ! $ this -> isWhitelisted ( $ ip ) ) { $ thresholdSeconds = ( int ) $ this -> config -> get ( 'concrete.security.ban.ip.time' ) ; $ thresholdTimestamp = new DateTime ( "-{$thresholdSeconds} seconds" ) ; $ rs = $ this -> connection -> executeQuery ( '
                        SELECT
                            ' . $ this -> connection -> getDatabasePlatform ( ) -> getCountExpression ( 'lcirID' ) . ' AS n
                        FROM
                            FailedLoginAttempts
                        WHERE
                            flaIp = ?
                            AND flaTimestamp > ?
                    ' , [ $ ip -> getComparableString ( ) , $ thresholdTimestamp -> format ( $ this -> connection -> getDatabasePlatform ( ) -> getDateTimeFormatString ( ) ) ] ) ; $ count = $ rs -> fetchColumn ( ) ; $ rs -> closeCursor ( ) ; $ thresholdAttempts = ( int ) $ this -> config -> get ( 'concrete.security.ban.ip.attempts' ) ; if ( $ count !== false && ( int ) $ count >= $ thresholdAttempts ) { $ result = true ; } } } return $ result ; }
Check if the current IP address has reached the failed login attempts threshold.

@param AddressInterface $ip the IP address to log (if null, we'll use the current IP address)
@param bool $ignoreConfig if set to true, we'll check the IP even if the IP ban system is disabled in the configuration

@return bool
Check if the current IP address has reached the failed login attempts threshold .