src/Whip.php
public function getIpAddress($source = null)
    {
        $source = $this->getRequestAdapter($this->coalesceSources($source));
        $remoteAddr = $source->getRemoteAddr();
        $requestHeaders = $source->getHeaders();

        foreach (self::$headers as $key => $headers) {
            if (!$this->isMethodUsable($key, $remoteAddr)) {
                continue;
            }

            if ($ipAddress = $this->extractAddressFromHeaders($requestHeaders, $headers)) {
                return $ipAddress;
            }
        }

        if ($remoteAddr && ($this->enabled & self::REMOTE_ADDR)) {
            return $remoteAddr;
        }

        return false;
    }
public function getIpAddress($source = null)
    {
        $source = $this->getRequestAdapter($this->coalesceSources($source));
        $remoteAddr = $source->getRemoteAddr();
        $requestHeaders = $source->getHeaders();

        foreach (self::$headers as $key => $headers) {
            if (!$this->isMethodUsable($key, $remoteAddr)) {
                continue;
            }

            if ($ipAddress = $this->extractAddressFromHeaders($requestHeaders, $headers)) {
                return $ipAddress;
            }
        }

        if ($remoteAddr && ($this->enabled & self::REMOTE_ADDR)) {
            return $remoteAddr;
        }

        return false;
    }
public function getIpAddress ( $ source = null ) { $ source = $ this -> getRequestAdapter ( $ this -> coalesceSources ( $ source ) ) ; $ remoteAddr = $ source -> getRemoteAddr ( ) ; $ requestHeaders = $ source -> getHeaders ( ) ; foreach ( self :: $ headers as $ key => $ headers ) { if ( ! $ this -> isMethodUsable ( $ key , $ remoteAddr ) ) { continue ; } if ( $ ipAddress = $ this -> extractAddressFromHeaders ( $ requestHeaders , $ headers ) ) { return $ ipAddress ; } } if ( $ remoteAddr && ( $ this -> enabled & self :: REMOTE_ADDR ) ) { return $ remoteAddr ; } return false ; }
Returns the IP address of the client using the given methods.
@param mixed $source (optional) The source data. If omitted, the class
will use the value passed to Whip::setSource or fallback to
$_SERVER.
@return string Returns the IP address as a string or false if no
IP address could be found.
Returns the IP address of the client using the given methods .