if($user->isAway()) $stats['away']++;
else $stats['here']++;
if($user->getModes()->hasMode('o')) $stats['opers']++;
- if($user->getIP()->isLocalAddress()) $stats['local']++;
+ if($user->getIP()->isLocalAddress(true)) $stats['local']++;
if($user->getIP()->isIPv6()) $stats['ipv6']++;
else $stats['ipv4']++;
}
private static $pattern_IPv4 = '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(|\/[0-9]{1,2})$/';
private $ip6 = array();
private $addr_is_ipv6 = false;
+ private $is_server_addr = false;
public function __construct($initial_value) {
for($i = 0; $i < 8; $i++) {
return $this->addr_is_ipv6;
}
- public function isLocalAddress() {
+ public function setServerAddr($serverAddr) {
+ $this->is_server_addr = $serverAddr;
+ }
+
+ public function isServerAddr() {
+ return $this->is_server_addr;
+ }
+
+ public function isLocalAddress($serverAddr = false) {
/* checks if address is out of:
* 127.0.0.1/32
* 10.0.0.0/8
* 172.16.0.0/12
* ::1/128
* fc00::/7
+ *
+ * if $serverAddr is true also return true for server IP's
*/
if($this->addr_is_ipv6) {
if(
)
return true;
}
+ if($serverAddr && $this->is_server_addr)
+ return true;
return false;
}
$modes = implode(" ",array_slice($args, 5, count($args)-8));
$modes = new P10_UserModeSet($modes);
$ip = new IPAddr($args[count($args)-3]);
+ if($host == $server->getName())
+ $ip->setServerAddr(true);
$realname = $args[count($args)-1];
$user = new P10_User($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes);
if($this->eventHandler)