<?php
error_reporting(0);
/** me@dwisiswanto.my.id **/
# usage; this.php domain/ip
function ping($host){
$starttime = microtime(true);
$exec = fsockopen($host, 80, $errno, $errstr, 5); // 80 = port; 5 = max. execution time
$stoptime = microtime(true);
$status = 0;
if (!$exec) {
$status = "Request timed out.";
} else {
$status = ($stoptime - $starttime) * 1000;
$status = "Reply from " . $host . ": bytes=32 time=" . floor($status) . "ms TTL=53";
}
fclose($exec);
return $status;
}
if (preg_match(\'/^[a-z]{2,6}+\\.[-a-z0-9]+\\.[a-z]{2,6}$|^[-a-z0-9]+\\.[a-z]{2,6}$/\', strtolower($argv[1]))) {
echo "\\nPinging " . gethostbyaddr(gethostbyname($argv[1])) . " [" . gethostbyname($argv[1]) . "] with 32 bytes of data:\\n";
while (true) {
echo ping(gethostbyname($argv[1])) . "\\n";
sleep(1);
}
} elseif (preg_match(\'/^[0-9]{1,3}+\\.[0-9]{1,3}+\\.[0-9]{1,3}+\\.[0-9]{1,3}$/\', strtolower($argv[1]))) {
echo "\\nPinging " . $argv[1] . " with 32 bytes of data:\\n";
while (true) {
echo ping($argv[1]) . "\\n";
sleep(1);
}
} else {
echo "Ping request could not find host " . $argv[1] . ". Please check the name and try again.";
}
?>