Jump to content

Recommended Posts

I change this code and I put this:

 

IP: 10.140.206.123 (
<?php
$ping_ex = exec("ping -n 1 10.110.206.123", $ping_result, $pr);
if (count($ping_result) > 1){
echo "<img src=\"on.png\">";
} else{
echo "<img src=\"off.png\">";
}
?> )


IP: 127.0.0.1 (
<?php
$ping_ex = exec("ping -n 1 127.0.0.1", $ping_result, $pr);
if (count($ping_result) > 1){
echo "<img src=\"on.png\">";
} else{
echo "<img src=\"off.png\">";
}
?> )

 

In the first case the resulst are NO and the second case are YES.

But... the result is YES in two cases. Why???

Link to comment
https://forums.phpfreaks.com/topic/127515-make-ping-with-php/#findComment-659871
Share on other sites

yeah!

finally I put this code:

 

<?php
$str = exec("ping -n 1 -w 1 100.100.100.100", $input, $result);
if ($result == 0){
echo "<img src=\"on.png\">";
}else{
echo "<img src=\"off.png\">";
}
?>

 

It's run correctly, but i would like to insert this code into a javascript function because I insert many times this PHP and the page is very hard to load.

I would like to insert a button:

 

<input type="submit" onClick="para();">

 

and when I press this button, the javascript runs.

Is it possible??

Link to comment
https://forums.phpfreaks.com/topic/127515-make-ping-with-php/#findComment-660771
Share on other sites

I took this snippet out of my ELC(External Link Checker), http://links.lamezz.com Type in the IP address to ping.

 

<?php
   $url = "127.0.0.1";
    $churl = @fopen($url,'r');
    if (!$churl && !empty($url)){
     echo "<br><center>The URL does not exist, or the server is down.</center>";
    }else{
     echo "<br><center>The URL does exist!</center>";
    }
?>

Link to comment
https://forums.phpfreaks.com/topic/127515-make-ping-with-php/#findComment-661860
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.