address = $address; $this->netbits = $netbits; } //-------------- // Return the IP address function address() { return ($this->address); } //-------------- // Return the netbits function netbits() { return ($this->netbits); } //-------------- // Return the netmask function netmask() { return (long2ip(ip2long("255.255.255.255") << (32-$this->netbits))); } //-------------- // Return the network that the address sits in function network() { return (long2ip((ip2long($this->address)) & (ip2long($this->netmask())))); } //-------------- // Return the broadcast that the address sits in function broadcast() { return (long2ip(ip2long($this->network()) | (~(ip2long($this->netmask()))))); } //-------------- // Return the inverse mask of the netmask function inverse() { return (long2ip(~(ip2long("255.255.255.255") << (32-$this->netbits)))); } } $adres=$_GET['adres']; $maska=$_GET['maska']; $ip_addr = $adres; $subnet_mask = (long2ip(ip2long("255.255.255.255")<< (32-$maska))); $ip = ip2long($ip_addr); $nm = ip2long($subnet_mask); $nw = ($ip & $nm); $bc = $nw | (~$nm); $ip = new ipv4($adres,$maska); echo "Adres IP: ".$ip->address(); echo "
Maska w bitach: ".$ip->netbits(); echo "
Maska: ".$ip->netmask(); echo "
Adres sieci: ".$ip->network(); echo "
Adres rozgłoszeniowy: ".$ip->broadcast(); echo "
Pierwszy host: ".long2ip($nw + 1); echo "
Ostatni host: ".long2ip($bc - 1); echo "

"; ?> Powrót