newb Posted January 24, 2012 Share Posted January 24, 2012 how can i output the remote user's ping to my server on my website through php? Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/ Share on other sites More sharing options...
joel24 Posted January 25, 2012 Share Posted January 25, 2012 google. have a look at this or... alternate Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1310839 Share on other sites More sharing options...
newb Posted January 25, 2012 Author Share Posted January 25, 2012 google. have a look at this or... alternate no good. i need something that will show the user his own ping relative to the host server (like using the ping cmd from the command prompt), not the server's ping itself.. Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1310889 Share on other sites More sharing options...
Pikachu2000 Posted January 25, 2012 Share Posted January 25, 2012 You can't do that with php. Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1310896 Share on other sites More sharing options...
newb Posted January 25, 2012 Author Share Posted January 25, 2012 You can't do that with php. bah...can you do it with javascript or something? Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1310904 Share on other sites More sharing options...
Pikachu2000 Posted January 25, 2012 Share Posted January 25, 2012 You're probably looking at a Java applet, or something similar that the user would have to explicitly allow to run to get that functionality. Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1310907 Share on other sites More sharing options...
newb Posted January 25, 2012 Author Share Posted January 25, 2012 do u know a website that does this already? maybe i can use curl to fetch results from it or something.. Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1311206 Share on other sites More sharing options...
newb Posted January 25, 2012 Author Share Posted January 25, 2012 no way to get client ping? Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1311207 Share on other sites More sharing options...
newb Posted January 25, 2012 Author Share Posted January 25, 2012 here is the fix... $cmd = "/bin/ping -c 5 ".$_SERVER['REMOTE_ADDR']; $ping = shell_exec($cmd); if(strlen($ping) < 5) { echo "? ms"; } else { preg_match("/rtt min\/avg\/max\/mdev = (.*)\/(.*)\/(.*)\/(.*) ms/", $ping, $matches); $urping = number_format($matches[1],0)." ms"; } Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1311209 Share on other sites More sharing options...
Pikachu2000 Posted January 25, 2012 Share Posted January 25, 2012 You said you wanted to get the ping response from the client to the server. That's a ping from the server to the client, which you specifically said you didn't want. It's probably the best you'll be able to get without the user installing anything, though. Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1311255 Share on other sites More sharing options...
newb Posted January 25, 2012 Author Share Posted January 25, 2012 yeah...this doesnt work sometimes like if the client IP is blocking pings w/ a firewall...oh well..i dont know any other solutions =/ Link to comment https://forums.phpfreaks.com/topic/255708-output-ping-of-the-server/#findComment-1311270 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.