ZF-7092: Add a method to retrieve the remote IP
Description
Having a method in the HTTP request object to get the client's IP would be really useful. Proposed method:
public function getClientIp()
{
if (!empty($this->getServer('HTTP_CLIENT_IP'))) {
$ip = $this->getServer('HTTP_CLIENT_IP');
} else if (!empty($this->getServer('HTTP_X_FORWARDED_FOR'))) {
$ip = $this->getServer('HTTP_X_FORWARDED_FOR');
} else {
$ip = $this->getServer('REMOTE_ADDR');
}
return $ip;
}
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2009-06-23T04:41:13.000+0000
Assigning back to Jurrien, as he knows the implementation desired. :) Please don't forget to write tests for the functionality. :)
Posted by Jurrien Stutterheim (norm2782) on 2009-06-23T20:42:02.000+0000
Resolved in r16267. Merged to release-1.8 in r16268
Posted by Kazusuke Sasezaki (sasezaki) on 2009-06-24T08:52:27.000+0000
Is not under "IP address spoofing"?
please check.Similar issue - cakephp's https://trac.cakephp.org/ticket/5842
Posted by Jurrien Stutterheim (norm2782) on 2009-06-24T14:18:09.000+0000
Opened a new issue for that: http://framework.zend.com/issues/browse/ZF-7117