|
@ -28,7 +28,7 @@ function getIPInfo($ip) { |
|
|
$info['loc'] = $rawIspInfo['loc']; |
|
|
$info['loc'] = $rawIspInfo['loc']; |
|
|
$info['isp'] = getIsp($rawIspInfo); |
|
|
$info['isp'] = getIsp($rawIspInfo); |
|
|
} |
|
|
} |
|
|
$info['cidr'] = $detail['beginIP'] . ' - ' . $detail['endIP']; |
|
|
$info['scope'] = tryCIDR($detail['beginIP'], $detail['endIP']); |
|
|
$info['detail'] = $detail['dataA'] . $detail['dataB']; |
|
|
$info['detail'] = $detail['dataA'] . $detail['dataB']; |
|
|
|
|
|
|
|
|
if ($_GET['cli'] == "true") { // 使用命令行模式 |
|
|
if ($_GET['cli'] == "true") { // 使用命令行模式 |
|
@ -40,7 +40,7 @@ function getIPInfo($ip) { |
|
|
$cli .= "Timezone: ".$info['timezone'] . PHP_EOL; |
|
|
$cli .= "Timezone: ".$info['timezone'] . PHP_EOL; |
|
|
$cli .= "Location: ".$info['loc'] . PHP_EOL; |
|
|
$cli .= "Location: ".$info['loc'] . PHP_EOL; |
|
|
$cli .= "ISP: ".$info['isp'] . PHP_EOL; |
|
|
$cli .= "ISP: ".$info['isp'] . PHP_EOL; |
|
|
$cli .= "CIDR: ".$info['cidr'].PHP_EOL; |
|
|
$cli .= "Scope: ".$info['scope'] . PHP_EOL; |
|
|
$cli .= "Detail: ".$info['detail'] . PHP_EOL; |
|
|
$cli .= "Detail: ".$info['detail'] . PHP_EOL; |
|
|
return $cli; |
|
|
return $cli; |
|
|
} |
|
|
} |
|
@ -113,4 +113,13 @@ function getAS($rawIspInfo) { // 提取AS信息 |
|
|
return trim($as['0']); |
|
|
return trim($as['0']); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function tryCIDR($beginIP, $endIP) { |
|
|
|
|
|
$tmp = ip2long($endIP) - ip2long($beginIP) + 1; |
|
|
|
|
|
if (pow(2, intval(log($tmp, 2))) == $tmp) { |
|
|
|
|
|
return $beginIP . '/' . (32 - log($tmp, 2)); |
|
|
|
|
|
} else { |
|
|
|
|
|
return $beginIP . ' - ' . $endIP; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
?> |
|
|
?> |
|
|