diff --git a/libs/ping.php b/libs/ping.php index 9b40268..ea18709 100644 --- a/libs/ping.php +++ b/libs/ping.php @@ -5,11 +5,15 @@ $datas = array(); + if (count($Config->get('ping:hosts')) > 0) $hosts = $Config->get('ping:hosts'); else $hosts = array('google.com', 'wikipedia.org'); +array_push($hosts, $_SERVER["REMOTE_ADDR"]); +$hosts = array_reverse($hosts, true); + foreach ($hosts as $host) { exec('/bin/ping -qc 1 '.$host.' | awk -F/ \'/^(rtt|round-trip)/ { print $5 }\'', $result); @@ -18,7 +22,7 @@ { $result[0] = 0; } - + $datas[] = array( 'host' => $host, 'ping' => $result[0], @@ -27,4 +31,6 @@ unset($result); } -echo json_encode($datas); \ No newline at end of file +$datas[0]["host"] = "Station ({$_SERVER["REMOTE_ADDR"]})"; + +echo json_encode($datas);