mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Add checks to see if REMOTE_ADDR is set before making use of it.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60578 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
48b60fa710
commit
128e5e4a05
@ -207,14 +207,16 @@ class Session {
|
||||
public static function load_config() {
|
||||
foreach(self::$session_ips as $sessionIP => $timeout) {
|
||||
if(preg_match('/^([0-9.]+)\s?-\s?([0-9.]+)$/', $sessionIP, $ips)) {
|
||||
$startIP = ip2long($ips[1]);
|
||||
$endIP = ip2long($ips[2]);
|
||||
$clientIP = ip2long($_SERVER['REMOTE_ADDR']);
|
||||
$minIP = min($startIP, $endIP);
|
||||
$maxIP = max($startIP, $endIP);
|
||||
|
||||
if($minIP <= $clientIP && $clientIP <= $maxIP) {
|
||||
return self::set_timeout($timeout);
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) {
|
||||
$startIP = ip2long($ips[1]);
|
||||
$endIP = ip2long($ips[2]);
|
||||
$clientIP = ip2long($_SERVER['REMOTE_ADDR']);
|
||||
$minIP = min($startIP, $endIP);
|
||||
$maxIP = max($startIP, $endIP);
|
||||
|
||||
if($minIP <= $clientIP && $clientIP <= $maxIP) {
|
||||
return self::set_timeout($timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO - Net masks or something
|
||||
|
@ -349,7 +349,7 @@ class HTTPRequest extends Object implements ArrayAccess {
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
//to check ip is pass from proxy
|
||||
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else {
|
||||
} elseif(isset($_SERVER['REMOTE_ADDR'])) {
|
||||
return $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user