Returns the client IP address.
@api
string The client IP address
public function getClientIp() {
if (self::$trustProxy) {
if ($this->server
->has('HTTP_CLIENT_IP')) {
return $this->server
->get('HTTP_CLIENT_IP');
}
elseif ($this->server
->has('HTTP_X_FORWARDED_FOR')) {
$clientIp = explode(',', $this->server
->get('HTTP_X_FORWARDED_FOR'));
foreach ($clientIp as $ipAddress) {
$cleanIpAddress = trim($ipAddress);
if (false !== filter_var($cleanIpAddress, FILTER_VALIDATE_IP)) {
return $cleanIpAddress;
}
}
return '';
}
}
return $this->server
->get('REMOTE_ADDR');
}