예제 #1
0
파일: Ip.class.php 프로젝트: wAmpIre/netmon
 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;
 }