@@ -225,47 +225,47 @@ |
||
| 225 | 225 | return php_sapi_name(); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - /** |
|
| 229 | - * Returns the client IP address which originated this request. |
|
| 230 | - * Lifted and modified from SilverStripe 3's SS_HTTPRequest. |
|
| 231 | - * |
|
| 232 | - * @return string |
|
| 233 | - */ |
|
| 234 | - public function getIP() : string |
|
| 228 | + /** |
|
| 229 | + * Returns the client IP address which originated this request. |
|
| 230 | + * Lifted and modified from SilverStripe 3's SS_HTTPRequest. |
|
| 231 | + * |
|
| 232 | + * @return string |
|
| 233 | + */ |
|
| 234 | + public function getIP() : string |
|
| 235 | 235 | { |
| 236 | - $headerOverrideIP = null; |
|
| 236 | + $headerOverrideIP = null; |
|
| 237 | 237 | |
| 238 | - if (defined('TRUSTED_PROXY')) { |
|
| 239 | - $headers = (defined('SS_TRUSTED_PROXY_IP_HEADER')) ? |
|
| 238 | + if (defined('TRUSTED_PROXY')) { |
|
| 239 | + $headers = (defined('SS_TRUSTED_PROXY_IP_HEADER')) ? |
|
| 240 | 240 | [SS_TRUSTED_PROXY_IP_HEADER] : |
| 241 | 241 | null; |
| 242 | 242 | |
| 243 | - if(!$headers) { |
|
| 244 | - // Backwards compatible defaults |
|
| 245 | - $headers = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR']; |
|
| 246 | - } |
|
| 243 | + if(!$headers) { |
|
| 244 | + // Backwards compatible defaults |
|
| 245 | + $headers = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR']; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - foreach($headers as $header) { |
|
| 249 | - if(!empty($_SERVER[$header])) { |
|
| 250 | - $headerOverrideIP = $_SERVER[$header]; |
|
| 248 | + foreach($headers as $header) { |
|
| 249 | + if(!empty($_SERVER[$header])) { |
|
| 250 | + $headerOverrideIP = $_SERVER[$header]; |
|
| 251 | 251 | |
| 252 | - break; |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 252 | + break; |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | 257 | $proxy = Injector::inst()->create(TrustedProxyMiddleware::class); |
| 258 | 258 | |
| 259 | - if ($headerOverrideIP) { |
|
| 260 | - return $proxy->getIPFromHeaderValue($headerOverrideIP); |
|
| 261 | - } |
|
| 259 | + if ($headerOverrideIP) { |
|
| 260 | + return $proxy->getIPFromHeaderValue($headerOverrideIP); |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | 263 | if (isset($_SERVER['REMOTE_ADDR'])) { |
| 264 | - return $_SERVER['REMOTE_ADDR']; |
|
| 265 | - } |
|
| 264 | + return $_SERVER['REMOTE_ADDR']; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | 267 | return ''; |
| 268 | - } |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * Returns a default set of additional data specific to the user's part in |