public function Request::getClientIps

Returns the client IP addresses.

The most trusted IP address is first, and the less trusted one last. The "real" client IP address is the last one, but this is also the less trusted one.

Use this method carefully; you should use getClientIp() instead.

Return value

array The client IP addresses

See also

getClientIp()

1 call to Request::getClientIps()
Request::getClientIp in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php
Returns the client IP address.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php, line 692

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public function getClientIps() {
  $ip = $this->server
    ->get('REMOTE_ADDR');
  if (!self::$trustedProxies) {
    return array(
      $ip,
    );
  }
  if (!self::$trustedHeaders[self::HEADER_CLIENT_IP] || !$this->headers
    ->has(self::$trustedHeaders[self::HEADER_CLIENT_IP])) {
    return array(
      $ip,
    );
  }
  $clientIps = array_map('trim', explode(',', $this->headers
    ->get(self::$trustedHeaders[self::HEADER_CLIENT_IP])));
  $clientIps[] = $ip;
  $trustedProxies = !self::$trustedProxies ? array(
    $ip,
  ) : self::$trustedProxies;
  $ip = $clientIps[0];
  foreach ($clientIps as $key => $clientIp) {
    if (IpUtils::checkIp($clientIp, $trustedProxies)) {
      unset($clientIps[$key]);
      continue;
    }
  }
  return $clientIps ? array_reverse($clientIps) : array(
    $ip,
  );
}