src/Service/Config/Config.php
protected function isAllowedIp($whitelist)
    {
        $server = $this->pool->getServer();

        if (empty($server[static::REMOTE_ADDRESS]) === true) {
            $remote = '';
        } else {
            $remote = $server[static::REMOTE_ADDRESS];
        }

        $whitelist = explode(',', $whitelist);
        if (php_sapi_name() === 'cli' || in_array($remote, $whitelist) === true) {
            // Either the IP is matched, or we are in CLI
            return true;
        }

        // Check the wildcards.
        foreach ($whitelist as $ip) {
            $ip = trim($ip);
            $wildcardPos = strpos($ip, '*');
            // Check if the ip has a wildcard.
            if ($wildcardPos !== false && substr($remote, 0, $wildcardPos) . '*' === $ip) {
                return true;
            }
        }

        return false;
    }
protected function isAllowedIp($whitelist)
    {
        $server = $this->pool->getServer();

        if (empty($server[static::REMOTE_ADDRESS]) === true) {
            $remote = '';
        } else {
            $remote = $server[static::REMOTE_ADDRESS];
        }

        $whitelist = explode(',', $whitelist);
        if (php_sapi_name() === 'cli' || in_array($remote, $whitelist) === true) {
            // Either the IP is matched, or we are in CLI
            return true;
        }

        // Check the wildcards.
        foreach ($whitelist as $ip) {
            $ip = trim($ip);
            $wildcardPos = strpos($ip, '*');
            // Check if the ip has a wildcard.
            if ($wildcardPos !== false && substr($remote, 0, $wildcardPos) . '*' === $ip) {
                return true;
            }
        }

        return false;
    }
protected function isAllowedIp ( $ whitelist ) { $ server = $ this -> pool -> getServer ( ) ; if ( empty ( $ server [ static :: REMOTE_ADDRESS ] ) === true ) { $ remote = '' ; } else { $ remote = $ server [ static :: REMOTE_ADDRESS ] ; } $ whitelist = explode ( ',' , $ whitelist ) ; if ( php_sapi_name ( ) === 'cli' || in_array ( $ remote , $ whitelist ) === true ) { // Either the IP is matched, or we are in CLI return true ; } // Check the wildcards. foreach ( $ whitelist as $ ip ) { $ ip = trim ( $ ip ) ; $ wildcardPos = strpos ( $ ip , '*' ) ; // Check if the ip has a wildcard. if ( $ wildcardPos !== false && substr ( $ remote , 0 , $ wildcardPos ) . '*' === $ ip ) { return true ; } } return false ; }
Checks if the current client ip is allowed.

@author Chin Leung
@see https://stackoverflow.com/questions/35559119/php-ip-address-whitelist-with-wildcards

@param string $whitelist
The ip whitelist.

@return bool
Whether the current client ip is allowed or not.
Checks if the current client ip is allowed .