note 101738 added to function.exec
| From: | vaflancher at gmail dot com | Date: | Sat, 08 Jan 2011 08:58:00 +0000 |
| Subject: | note 101738 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175526@lists.php.net to get a copy of this message | ||
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();
?>
----
Server IP: 212.93.96.97
Probable Submitter: 85.254.25.168
----
Manual Page -- http://www.php.net/manual/en/function.exec.php
Edit -- https://master.php.net/note/edit/101738
Del: integrated -- https://master.php.net/note/delete/101738/integrated
Del: useless -- https://master.php.net/note/delete/101738/useless
Del: bad code -- https://master.php.net/note/delete/101738/bad+code
Del: spam -- https://master.php.net/note/delete/101738/spam
Del: non-english -- https://master.php.net/note/delete/101738/non-english
Del: in docs -- https://master.php.net/note/delete/101738/in+docs
Del: other reasons-- https://master.php.net/note/delete/101738
Reject -- https://master.php.net/note/reject/101738
Search -- https://master.php.net/manage/user-notes.php