public function ipIsInNetwork($network = false) { $network = $network ? $network : $this->getNetwork(); if ($network instanceof Network) { $ip = inet_pton($this->getIp()); $binaryip = Ip::inet_to_bits($ip, $network->getIpv()); $net = $network->getIp(); $maskbits = $network->getNetmask(); //list($net,$maskbits)=explode('/',$cidrnet); $net = inet_pton($net); $binarynet = Ip::inet_to_bits($net, $network->getIpv()); $ip_net_bits = substr($binaryip, 0, $maskbits); $net_bits = substr($binarynet, 0, $maskbits); if ($ip_net_bits !== $net_bits) { return false; } else { return true; } } return false; }