Skip to content

Commit

Permalink
get correct client IP from X-forwarded-for header
Browse files Browse the repository at this point in the history
  • Loading branch information
pulzarraider committed Nov 22, 2011
1 parent cd7fa42 commit a931e21
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -453,7 +453,8 @@ public function getClientIp($proxy = false)
if ($this->server->has('HTTP_CLIENT_IP')) {
return $this->server->get('HTTP_CLIENT_IP');
} elseif (self::$trustProxy && $this->server->has('HTTP_X_FORWARDED_FOR')) {
return $this->server->get('HTTP_X_FORWARDED_FOR');
$clientIp = explode(',', $this->server->get('HTTP_X_FORWARDED_FOR'), 2);
return isset($clientIp[0]) ? trim($clientIp[0]) : '';
}
}

Expand Down

0 comments on commit a931e21

Please sign in to comment.