note 101738 deleted from function.exec by danbrown
| From: | danbrown@php.net | Date: | Sat, 08 Jan 2011 16:55:58 +0000 |
| Subject: | note 101738 deleted from function.exec by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175534@lists.php.net to get a copy of this message | ||
Note Submitter: vaflancher at gmail dot com
----
Here is I written a function, that shows the ping on the OS Windows and Linux, helps me a lot, shows
players theirs ping to the server (the site is where the server).
<?php
function GetPing($ip) {
if(empty($ip)) {$ip = $_SERVER['REMOTE_ADDR'];}
if(getenv("OS")=="Windows_NT") {
$exec = exec("ping -n 3 -l 64 ".$ip);
return end(explode(" ", $exec ));
}
else {
$exec = exec("ping -c 3 -s 64 -t 64 ".$ip);
$array = explode("/", end(explode("=", $exec )) );
return ceil($array[1]) . 'ms';
}
}
echo GetPing();
?>