Get more information about the IP with the highest number of connections
$top = 10;
Get details of IP
$get _location = true;
Reverse IP, used to get spiders, slow after opening
$reverse = FALSE;
$reverse = TRUE;
Ini_set (Extension_dir,dirname (__file__));
Ini_set (enable_dl,true);
if (!DL ("Php_curl.dll")) {
Exit (Can load curl.);
}
$content = ' netstat-an-p TCP ';
$regex = "/s TCPs d. D:(D) s (d. D. D):d s/sm";
$table = Array ();
1, the number of connections/2, the machine IP/3, the other IP
/**
* Port/IP is unique
*/
if (Preg_match_all ($regex, $content, $result)) {
foreach ($result [1] as $i = + $port) {
if (Isset ($table [$port:. $result [2][$i]])
$table [$port.:. $result [2][$i];
Else
$table [$port.:. $result [2][$i]] = 1;
}
$curl = Curl_init ();
curl_setopt ($curl, curlopt_timeout,5);
curl_setopt ($curl, Curlopt_header, 0);
curl_setopt ($curl, Curlopt_returntransfer, TRUE);
$i = 0;
$count = 0;
if (Asort ($table))
foreach ($table as $key = = $times) {
$ip = substr (Strstr ($key,:), 1);
$port = substr ($key, 0,strpos ($key,:));
$i;
echo "Number of connections:", $times,-, $key;
if (! $get _location | | $i
Continue
}
if ($port ==80) $count = $times;
if ($ip!==127.0.0.1 | | $ip!==0.0.0.0) {
$host = $reverse? GETHOSTBYADDR ($IP): $ip;
if ($host = = $ip) {
curl_setopt ($curl, Curlopt_url, "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=txt&ip=". $ip);
$location = curl_exec ($curl);
echo "(". Preg_replace (/(s|d|.) /,, $location). ")";
} else {
echo "(". $host. ")";
}
}
}
echo "", All:, $count;
}
?>
http://www.bkjia.com/PHPjc/478839.html www.bkjia.com true http://www.bkjia.com/PHPjc/478839.html techarticle ? PHP//Get the details of the highest number of connections $top = 10;//Get the details of the IP $get _location = true;//reverse IP, used to get the spider, the speed is slower after opening $reverse = FALSE;