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.
array The client IP addresses
getClientIp()
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,
);
}