Code:
<?php
$ip = $_SERVER['127.0.0.1'];
exec("ping -n 4 $ip 2>&1", $output, $retval);
if ($retval != 0) {
echo "no!";
}
else
{
echo "yes!"; }
?>
The result is: NO!
why???
|
Go4Expert Member
|
|
| 8Oct2008,14:46 | #1 |
|
I would like to make a simple monitoring. I make this:
Code:
<?php
$ip = $_SERVER['127.0.0.1'];
exec("ping -n 4 $ip 2>&1", $output, $retval);
if ($retval != 0) {
echo "no!";
}
else
{
echo "yes!"; }
?>
The result is: NO! why??? |
|
Go4Expert Member
|
|
| 8Oct2008,18:43 | #2 |
|
I change this code and I put this:
Code:
IP: 10.110.206.123 (
<?php
$ping_ex = exec("ping -n 1 10.140.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\">";
}
?> )
But... the result is YES in two cases. Why??? Last edited by guif; 8Oct2008 at 18:50.. |
|
Go4Expert Member
|
|
| 9Oct2008,16:40 | #3 |
|
yeah!
finally I put this code: 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\">";
}
?>
I would like to insert a button: Code:
<input type="submit" onClick="para();"> Is it possible?? |
|
Go4Expert Founder
|
![]() |
| 9Oct2008,16:59 | #4 |
|
Moved to PHP forum for better response.
|
|
Go4Expert Member
|
|
| 16Aug2012,11:47 | #5 |
|
So, can this code be used for performing DOS attacks on sites??
|