PDA

View Full Version : Display Lag time between user and your server.



ohnoyekoms
05-14-2012, 06:11 PM
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>";

CloudStrife7x
05-14-2012, 06:22 PM
very nice tutorial shared ohnoyekoms :)

thegutta
05-14-2012, 06:34 PM
very nice tutorial shared ohnoyekoms :)

+1 :-)