@@ -50,8 +50,9 @@ public function __construct()
50
50
'X-Longitude ' => $ _SERVER ['GEOIP_LONGITUDE ' ]
51
51
];
52
52
}
53
- $ clientIpAddress = $ this ->getClientIP ();
54
- $ this ->headers ['X-Forwarded-For ' ] = $ clientIpAddress ;
53
+ if (!is_null ($ clientIpAddress = $ this ->getClientIP ())) {
54
+ $ this ->headers ['X-Forwarded-For ' ] = $ clientIpAddress ;
55
+ }
55
56
$ this ->encryption = DI ::container ()->get (EncryptionProvider::class);
56
57
$ this ->secureStorage = DI ::container ()->get (SecureCookieProvider::class);
57
58
$ this ->secureStorage ->setEncryptionProvider ($ this ->encryption );
@@ -109,20 +110,24 @@ public function setEncryptionProvider(EncryptionInterface $encryptionProvider):
109
110
return $ this ;
110
111
}
111
112
112
- /**
113
+ /**
113
114
* looks for a user's IP address
114
115
*
115
- * @return string
116
+ * @return string|null
116
117
*/
117
- public function getClientIP (){
118
- if (array_key_exists ('HTTP_X_FORWARDED_FOR ' , $ _SERVER )){
119
- return $ _SERVER ["HTTP_X_FORWARDED_FOR " ];
120
- }else if (array_key_exists ('REMOTE_ADDR ' , $ _SERVER )) {
118
+ public function getClientIP ()
119
+ {
120
+ if (array_key_exists ('HTTP_X_REAL_IP ' , $ _SERVER )) {
121
+ return $ _SERVER ["HTTP_X_REAL_IP " ];
122
+ } else if (array_key_exists ('HTTP_X_FORWARDED_FOR ' , $ _SERVER )) {
123
+ return $ _SERVER ["HTTP_X_FORWARDED_FOR " ];
124
+ } else if (array_key_exists ('REMOTE_ADDR ' , $ _SERVER )) {
121
125
return $ _SERVER ["REMOTE_ADDR " ];
122
- }else if (array_key_exists ('HTTP_CLIENT_IP ' , $ _SERVER )) {
126
+ } else if (array_key_exists ('HTTP_CLIENT_IP ' , $ _SERVER )) {
123
127
return $ _SERVER ["HTTP_CLIENT_IP " ];
124
- }
125
- return '' ;
128
+ }
129
+
130
+ return null ;
126
131
}
127
132
128
133
/**
0 commit comments