日期:2014-05-17 浏览次数:20483 次
<?php function iptolong($ip){ $key = explode('.', $ip); if(count($key) >= 4){ $long = intval($key[0]) * 16777216 + intval($key[1]) * 65536 + intval($key[2]) * 256 + intval($key[3]); } return $long; } function longtoip($long){ $long = floor($long); $p4 = $long - floor($long / 256) * 256; $long = ($long - $p4) / 256; $p3 = $long - floor($long / 256) * 256; $long = ($long - $p3) / 256; $p2 = $long - floor($long / 256) * 256; $long = ($long - $p2) / 256; $p1 = $long; $ip = $p1.'.'.$p2.'.'.$p3.'.'.$p4; return $ip; } ?>