note 101739 added to function.exec
| From: | vaflancher at gmail dot com | Date: | Sat, 08 Jan 2011 08:59:09 +0000 |
| Subject: | note 101739 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175527@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=NULL) {
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/101739
Del: integrated -- https://master.php.net/note/delete/101739/integrated
Del: useless -- https://master.php.net/note/delete/101739/useless
Del: bad code -- https://master.php.net/note/delete/101739/bad+code
Del: spam -- https://master.php.net/note/delete/101739/spam
Del: non-english -- https://master.php.net/note/delete/101739/non-english
Del: in docs -- https://master.php.net/note/delete/101739/in+docs
Del: other reasons-- https://master.php.net/note/delete/101739
Reject -- https://master.php.net/note/reject/101739
Search -- https://master.php.net/manage/user-notes.php