Display Lag time between user and your server.
Place this snippet in your index.php and when the user loads your site, it'll tell them their ping time from them to the server.
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 "<center><font color=white face=Verdana size=1>your lag to this server " . GetPing() . "<br>";
Re: Display Lag time between user and your server.
very nice tutorial shared ohnoyekoms :)