IHDHIC: Universal ip to dec to hex et vice versa converter
= $min) && ($ip_long <= $max))
{
return false;
}
}
return true;
}
if($submit){
$ip=gethostbyname($ip);
echo "
";
if($ip){
$encedip=dechex(ip2long($ip));
$idec=ip2long($ip);
$iname=@gethostbyaddr($ip);
echo "
IP: $ip
is hex: $encedip
";
printf("is dec: %u
",$idec,$idec);
echo "(reverse) hostname: $iname
";
if(validip($ip)){
echo "---------- $ip is a public IP address*
";
}else{
echo "---------- $ip is a reserved IP address*
";
}
echo "
";
}
if($hex){
$nip=long2ip(hexdec($hex));
$hname=@gethostbyaddr($nip);
$hdec=hexdec($hex);
echo "
HEX: $hex
is ip: $nip
";
printf("is dec: %u
",$hdec,$hdec);
echo "(reverse) hostname: $hname
";
if(validip($nip)){
echo "---------- $nip is a public IP address*
";
}else{
echo "---------- $nip is a reserved IP address*
";
}
echo "
";
}
if($dec){
$dip=long2ip($dec);
$dhex=dechex(ip2long($dip));
$dname=@gethostbyaddr($dip);
echo "
DEC: $dec
is ip: $dip
is hex: $dhex
(reverse) hostname: $dname
";
if(validip($dip)){
echo "---------- $dip is a public IP address*
";
}else{
echo "---------- $dip is a reserved IP address*
";
}
echo "
";
}
echo "
\n";
echo "(* reserved addresses according to: http://www.iana.org/assignments/ipv4-address-space)\n";
echo "
\n";
}
?>
source of this file