Neos\Flow\Http\Request::getClientIpAddress PHP 메소드

getClientIpAddress() 공개 메소드

Note that, depending on the actual source used, IP addresses can be spoofed and may not be reliable. Although several kinds of proxy headers are taken into account, certain combinations of ISPs and proxies might still produce wrong results. Don't rely on the client IP address as the only security measure!
public getClientIpAddress ( ) : string
리턴 string The client's IP address
    public function getClientIpAddress()
    {
        $serverFields = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED');
        foreach ($serverFields as $field) {
            if (empty($this->server[$field])) {
                continue;
            }
            $length = strpos($this->server[$field], ',');
            $ipAddress = trim($length === false ? $this->server[$field] : substr($this->server[$field], 0, $length));
            if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE) !== false) {
                return $ipAddress;
            }
        }
        return isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : null;
    }