hola, tengo el codigo para hacer ping a un rango ip que se determine, pero siempre devuelve UP siendo que hay IP q no deberian responder
Alguno me podria indicar donde estoy fallando?
Gracias
<?php
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
error_reporting(0);
?>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$oct1 = $_POST['1oct'];
$oct11 = $_POST['1oct'];
if($_POST['1rang'] == "on")
$oct11 = $_POST['1oct2'];
$oct2 = $_POST['2oct'];
$oct21 = $_POST['2oct'];
if($_POST['2rang'] == "on")
$oct21 = $_POST['2oct2'];
$oct3 = $_POST['3oct'];
$oct31 = $_POST['3oct'];
if($_POST['3rang'] == "on")
$oct31 = $_POST['3oct2'];
$oct4 = (int)$_POST['4oct'];
$oct41 = (int)$_POST['4oct'];
if($_POST['4rang'] == "on")
$oct41 = (int)$_POST['4oct2'];
// echo $oct11;
// echo $oct21;
// echo $oct31;
// echo $oct41;
// echo "\n";
for ($i = $oct1; $i <= $oct11; $i++)
{
for ($j = $oct2; $j <= $oct21; $j++)
{
for ($k = $oct3; $k <= $oct31; $k++)
{
for ($l = $oct4; $l <= $oct41; $l++)
{
//echo "a";
$ip = strval($i) . "." . strval($j) . "." . strval($k) . "." . strval($l).
$output = shell_exec("ping -n 2 -l 8 -w 1000 $ip");
if (strpos ($output, "recibidos = 0") or strpos ($output, "inaccesible"))
{
$estado='Down';
}
else
{
$estado='Up';
}
echo strval($i) . "." . strval($j) . "." . strval($k) . "." . strval($l) ." ". $estado. "<br />";
}
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title></title>
<style type="text/css"></style>
<link rel="stylesheet" href="estilos" type="text/css">
</head>
<body>
<h1>Escaneo rango I</h1>
<form method="post" action="index5.php" name="form1">
<table>
<tr>
<td>ip inicial</td>
<td><input value="" maxlength="3" size="3" name="1oct"></td>
<td><input value="" maxlength="3" size="3" name="2oct"></td>
<td><input value="" maxlength="3" size="3" name="3oct"></td>
<td><input value="" maxlength="3" size="3" name="4oct"></td></tr>
<tr>
<td>ip final</td>
<td><input value="" maxlength="3" size="3" name="1oct2">
<td><input value="" maxlength="3" size="3" name="2oct2">
<td><input value="" maxlength="3" size="3" name="3oct2">
<td><input value="" maxlength="3" size="3" name="4oct2">
<tr>
<td>rango</td>
<td><input name="1rang" type="checkbox"></td>
<td><input name="2rang" type="checkbox"></td>
<td><input name="3rang" type="checkbox"></td>
<td><input name="4rang" type="checkbox"></td></tr>
<table>
<input name="scan" value="scan" type="submit"><br>
</form>
<br>
<br>
</body>
</html>