Jump to content

can someone help me improve my code about ip scanner?


phpkiller

Recommended Posts

Hi, i'm a new guy here, please guide me if i'm doing wrong..

 

mmm...actually i plan to build an ip scanner using php, so, this is my source code,  this looks messy, can someone give me the idea how to make thing easy? I try to grab the information and put it in array but it looks complicated.

 

FYI, i'm a quite new to php.

 

<html><head><title>Network Status</title></head>

<body>

<p align=center>

<?php

 

function check($ip) {

unset($return);

unset($value);

 

system('ping -c 1 '.$ip,$return);

$row=sizeof($return);

 

echo "return value is ".$return;

echo "<br>";

echo "row value is ".$row;

 

$value=explode(" ", $return[4]);

$x=sizeof($value);

 

for ($y=0;$y<$x;$y++)  {

        if($value[$y]=="0%" && $value[$y+1]=="packet" && $value[$y+2]=="loss,")  {

    echo "<table><td bgcolor='green'>";

    echo $ip;

      echo (" is UP<br>");

    echo "</td></table>";

    }

            else  {

    echo "<table><td bgcolor='red'>";

                    echo "$ip is down";

    echo "</td></table>";

            }

    } echo "<br>";

}

 

//echo 'Please Enter new Network Prefix to Monitor, (i.e. 10.10.0): ';

//echo "<INPUT TYPE=TEXT NAME=netPre>";

//echo '<INPUT TYPE=SUBMIT VALUE="Submit">';

 

 

//echo '<br>Current Network Prefix: <br>';

//echo "<br>";

 

for ($end=50;$end<55;$end++){

$ip="10.100.100.".$end;

echo "now the ip is: ";

echo $ip."<br>";

check($ip);

}

 

?>

</p>

</body>

</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.