@@ -218,46 +218,46 @@ |
||
218 | 218 | return php_sapi_name(); |
219 | 219 | } |
220 | 220 | |
221 | - /** |
|
222 | - * Returns the client IP address which originated this request. |
|
223 | - * Lifted and modified from SilverStripe 3's SS_HTTPRequest. |
|
224 | - * |
|
225 | - * @return string |
|
226 | - */ |
|
227 | - public function getIP() |
|
221 | + /** |
|
222 | + * Returns the client IP address which originated this request. |
|
223 | + * Lifted and modified from SilverStripe 3's SS_HTTPRequest. |
|
224 | + * |
|
225 | + * @return string |
|
226 | + */ |
|
227 | + public function getIP() |
|
228 | 228 | { |
229 | - $headerOverrideIP = null; |
|
229 | + $headerOverrideIP = null; |
|
230 | 230 | |
231 | - if (defined('TRUSTED_PROXY')) { |
|
232 | - $headers = (defined('SS_TRUSTED_PROXY_IP_HEADER')) ? |
|
231 | + if (defined('TRUSTED_PROXY')) { |
|
232 | + $headers = (defined('SS_TRUSTED_PROXY_IP_HEADER')) ? |
|
233 | 233 | array(SS_TRUSTED_PROXY_IP_HEADER) : |
234 | 234 | null; |
235 | 235 | |
236 | - if(!$headers) { |
|
237 | - // Backwards compatible defaults |
|
238 | - $headers = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR']; |
|
239 | - } |
|
236 | + if(!$headers) { |
|
237 | + // Backwards compatible defaults |
|
238 | + $headers = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR']; |
|
239 | + } |
|
240 | 240 | |
241 | - foreach($headers as $header) { |
|
242 | - if(!empty($_SERVER[$header])) { |
|
243 | - $headerOverrideIP = $_SERVER[$header]; |
|
241 | + foreach($headers as $header) { |
|
242 | + if(!empty($_SERVER[$header])) { |
|
243 | + $headerOverrideIP = $_SERVER[$header]; |
|
244 | 244 | |
245 | - break; |
|
246 | - } |
|
247 | - } |
|
248 | - } |
|
245 | + break; |
|
246 | + } |
|
247 | + } |
|
248 | + } |
|
249 | 249 | |
250 | 250 | $proxy = Injector::inst()->create(TrustedProxyMiddleware::class); |
251 | 251 | |
252 | - if ($headerOverrideIP) { |
|
253 | - return $proxy->getIPFromHeaderValue($headerOverrideIP); |
|
254 | - } |
|
252 | + if ($headerOverrideIP) { |
|
253 | + return $proxy->getIPFromHeaderValue($headerOverrideIP); |
|
254 | + } |
|
255 | 255 | |
256 | 256 | if (isset($_SERVER['REMOTE_ADDR'])) { |
257 | - return $_SERVER['REMOTE_ADDR']; |
|
258 | - } |
|
257 | + return $_SERVER['REMOTE_ADDR']; |
|
258 | + } |
|
259 | 259 | |
260 | 260 | return ''; |
261 | - } |
|
261 | + } |
|
262 | 262 | |
263 | 263 | } |