/**************************
* int_oct($ip)
* Convert INTeger rep of IP to octal (dotted quad)
*/
function int_oct($ip) {
/* Set variable to float */
settype($ip, float);
/* FIX for silly PHP integer syndrome */
$fix = 0;
if($ip > 2147483647) $fix = 16777216;
if(is_numeric($ip)) {
return(sprintf("%u.%u.%u.%u",
$ip / 16777216,
(($ip % 16777216) + $fix) / 65536,
(($ip % 65536) + $fix / 256) / 256,
($ip % 256) + $fix / 256 / 256
)
);
}
else {
return('');
}
}
or
function iplongtostring($ip)
{
$ip=floatval($ip); // otherwise it is capped at 127.255.255.255
$a=($ip>>24)&255;
$b=($ip>>16)&255;
$c=($ip>>8)&255;
$d=$ip&255;
return "$a.$b.$c.$d";
}