mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 01:04:16 +02:00
Merge branch 'patch-1' of https://github.com/horst-n/processwire-1 into horst-n-patch-1
This commit is contained in:
@@ -651,7 +651,11 @@ class Session extends Wire implements \IteratorAggregate {
|
|||||||
*/
|
*/
|
||||||
public function getIP($int = false, $useClient = false) {
|
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'];
|
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['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
else if(!empty($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
|
else if(!empty($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
Reference in New Issue
Block a user