mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 01:34:31 +02:00
Add new removeAllFor($namespace) method to Session, and improve the multi-IP option in the getIP() method
This commit is contained in:
@@ -617,6 +617,18 @@ class Session extends Wire implements \IteratorAggregate {
|
|||||||
return $this->remove($ns, $key);
|
return $this->remove($ns, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all session variables in given namespace
|
||||||
|
*
|
||||||
|
* @param string|object $ns
|
||||||
|
* @return $this
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function removeAllFor($ns) {
|
||||||
|
$this->remove($ns, true);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a namespace object or string, return the namespace string
|
* Given a namespace object or string, return the namespace string
|
||||||
*
|
*
|
||||||
@@ -715,9 +727,22 @@ class Session extends Wire implements \IteratorAggregate {
|
|||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanitize by converting to and from integer
|
if($useClient === 2 && strpos($ip, ',') !== false) {
|
||||||
$ip = ip2long($ip);
|
// return multiple IPs
|
||||||
|
$ips = explode(',', $ip);
|
||||||
|
foreach($ips as $key => $ip) {
|
||||||
|
$ip = ip2long(trim($ip));
|
||||||
if(!$int) $ip = long2ip($ip);
|
if(!$int) $ip = long2ip($ip);
|
||||||
|
$ips[$key] = $ip;
|
||||||
|
}
|
||||||
|
$ip = implode(',', $ips);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// sanitize by converting to and from integer
|
||||||
|
$ip = ip2long(trim($ip));
|
||||||
|
if(!$int) $ip = long2ip($ip);
|
||||||
|
}
|
||||||
|
|
||||||
return $ip;
|
return $ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user