-2

I'm working on a small php script and i'd like to add ping feature to the script. I really don't know how to do it but , i like to have the same result as this : http://www.ipfingerprints.com/ping.php

Yassin Sterno
  • 41
  • 2
  • 4

4 Answers4

0

Depending on the permissions in php, you might be able to

<?php system("ping -c 3 localhost"); ?>

Be very careful accepting hostnames from web forms - if a user requests that you ping the server "; rm -rf /", you will lose all your data!

AMADANON Inc.
  • 5,753
  • 21
  • 31
0

it is very simple

<?php

if (!$socket = @fsockopen("YOUR.IP.HERE", 80, $errno, $errstr, 30))
{
  echo "<font color='red'><strong>Offline!</strong></font>";
}
   else 
    {
  echo "<font color='green'><strong>Online!/strong></font>";

  fclose($socket);
}

?>
MineScript
  • 291
  • 1
  • 4
0

Or use this code " exec('ping -c '.$pingTimes.'.$ipAdress); " at PHP

Yiğit Ağca
  • 11
  • 1
  • 4
0

If you want to have real ping (send ICMP packets) you can take a look at this Native-PHP ICMP ping implementation, but I didn't test it.

jcubic
  • 61,973
  • 54
  • 229
  • 402