protected function getClientIp(bool $trust_proxy_headers = false): string
    {
        $remoteAddr = $_SERVER['REMOTE_ADDR'] ?? 'NO_REMOTE_ADDR';

        if ($trust_proxy_headers) {
            return $remoteAddr;
        }

        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $remoteAddr;
        }

        return $ip;
    }
protected function getClientIp(bool $trust_proxy_headers = false): string
    {
        $remoteAddr = $_SERVER['REMOTE_ADDR'] ?? 'NO_REMOTE_ADDR';

        if ($trust_proxy_headers) {
            return $remoteAddr;
        }

        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $remoteAddr;
        }

        return $ip;
    }
protected function getClientIp ( bool $ trust_proxy_headers = false ) : string { $ remoteAddr = $ _SERVER [ 'REMOTE_ADDR' ] ?? 'NO_REMOTE_ADDR' ; if ( $ trust_proxy_headers ) { return $ remoteAddr ; } if ( ! empty ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) { $ ip = $ _SERVER [ 'HTTP_CLIENT_IP' ] ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { $ ip = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } else { $ ip = $ remoteAddr ; } return $ ip ; }
returns the IP address of the client

@param bool $trust_proxy_headers     <p>
Whether or not to trust the
proxy headers HTTP_CLIENT_IP
and HTTP_X_FORWARDED_FOR. ONLY
use if your $_SERVER is behind a
proxy that sets these values
</p>

@return string
returns the IP address of the client