Vectorface\Whip\Whip::getIpAddress PHP Method

getIpAddress() public method

Returns the IP address of the client using the given methods.
public getIpAddress ( mixed $source = null ) : string
$source mixed (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.
    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;
            }
            return $this->extractAddressFromHeaders($requestHeaders, $headers);
        }
        return $this->enabled & self::REMOTE_ADDR ? $remoteAddr : false;
    }

Usage Example

コード例 #1
0
ファイル: IpListener.php プロジェクト: neeckeloo/recurly
 public function onResult(MvcEvent $event)
 {
     parent::onResult($event);
     if ($event->isError()) {
         if ($this->logger) {
             $this->logger->info(sprintf('Unauthorized ip address "%s" attempted to push Recurly notification.', $this->whip->getIpAddress()));
         }
         $event->getResponse()->setStatusCode(HttpResponse::STATUS_CODE_403);
     }
 }
All Usage Examples Of Vectorface\Whip\Whip::getIpAddress