1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00

Merge branch 'patch-1' of https://github.com/horst-n/processwire-1 into horst-n-patch-1

This commit is contained in:
Ryan Cramer
2016-10-05 10:41:04 -04:00

View File

@@ -651,7 +651,11 @@ class Session extends Wire implements \IteratorAggregate {
*/
public function getIP($int = false, $useClient = false) {
if($useClient) {
if('cli' == php_sapi_name()) {
// when accessing via CLI Interface, $_SERVER['REMOTE_ADDR'] isn't set and trying to get it, throws a php-notice
$ip = '127.0.0.1';
} else if($useClient) {
if(!empty($_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP'];
else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(!empty($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];