Example #1
0
 /**
  * Check if the requester's IP is in any known IP address range and cache the
  * result
  *
  * @return bool
  */
 protected function getIpInRange()
 {
     if ($this->ipInRange !== null) {
         return $this->ipInRange;
     }
     $this->ipInRange = false;
     $remoteAddress = new \Zend\Http\PhpEnvironment\RemoteAddress();
     $remoteIp = $remoteAddress->getIpAddress();
     // Iterate all permissions with ipRanges. We'll accept any range for now.
     foreach ($this->permissions as $permission) {
         if (empty($permission['ipRange'])) {
             continue;
         }
         $ranges = [];
         foreach ($permission['ipRange']->toArray() as $range) {
             list($ip) = explode('#', $range, 2);
             $ranges = array_merge($ranges, array_map('trim', explode(',', $ip)));
         }
         if ($this->ipAddressUtils->isInRange($remoteIp, $ranges)) {
             $this->ipInRange = true;
             break;
         }
     }
     return $this->ipInRange;
 }
Example #2
0
 /**
  * Check if the requester's IP is in any known IP address range and cache the
  * result
  *
  * @return bool
  */
 protected function getIpInRange()
 {
     if ($this->ipInRange !== null) {
         return $this->ipInRange;
     }
     $this->ipInRange = false;
     $remoteAddress = new \Zend\Http\PhpEnvironment\RemoteAddress();
     $remoteIp = $remoteAddress->getIpAddress();
     // Iterate all permissions with ipRanges. We'll accept any range for now.
     foreach ($this->permissions as $permission) {
         if (empty($permission['ipRange'])) {
             continue;
         }
         if ($this->ipAddressUtils->isInRange($remoteIp, (array) $permission['ipRange'])) {
             $this->ipInRange = true;
             break;
         }
     }
     return $this->ipInRange;
 }