Location: PHPKode > projects > Network Asset Management Archive > nama/scanlist.php
<?php
$now = date("m/j/y h:i:s",time());
include "connect.php";
print '<body bgcolor="#FFFFCC">';
$now = date("j/m/y h:i:s",time());
$LABlist = $_POST['LABlist'];
$SUBNET = $_POST['SUBNET'];
$OSlist = $_POST['OSlist'];
$SUBMIT = $_POST['Submit'];
if ($SUBMIT=='No Network Gear') {
     $stmt = "Select IP_ADDRESS FROM arp_table a, subnets b where (not (os starts with 'Network Gear')) and (a.subnet = b.subnet) ";
} else {
     $stmt = "Select IP_ADDRESS FROM arp_table a, subnets b where (a.subnet = b.subnet) ";
}
if (sizeof($LABlist) != 0) {
	$hadlab = true;
	if (sizeof($LABlist) == 1) {
	$stmt = $stmt . " and ((LAB = '$LABlist[0]')";
	}
	else {
		$stmt = $stmt . " and ((LAB in (";
		for ($i=0; $i < sizeof($LABlist); $i++) {
		    $stmt = $stmt . $LABlist[$i];
		    if ($i < sizeof($LABlist)-1) {
			$stmt = $stmt . ","; 
		    }
		    else {
			$stmt = $stmt . "))";
		    }
		}
	}
}
if (sizeof($SUBNET) != 0) {
	$hadlab = true;
	if (sizeof($SUBNET) == 1) {
		if (sizeof($LABlist) == 0) {
		     $stmt = $stmt . " and (SUBNET = '$SUBNET[0]')";
		}
		else {
		     $stmt = $stmt . " or (SUBNET = '$SUBNET[0]')";
		}
	}
	else {
		if (sizeof($LABlist) == 0) {
			$stmt = $stmt . " and (SUBNET in ('";
		}
		else {
			$stmt = $stmt . " or (SUBNET in ('";
		}
		for ($i=0; $i < sizeof($SUBNET); $i++) {
		    $stmt = $stmt . $SUBNET[$i];
		    if ($i < sizeof($SUBNET)-1) {
			$stmt = $stmt . "','"; 
		    }
		    else {
			$stmt = $stmt . "'))";
		    }
		}
	}
}
if (sizeof($LABlist) != 0) {
        $stmt = $stmt . ")";
}
if (sizeof($OSlist) != 0) {
	$hadlab = true;
	if (sizeof($OSlist) == 1) {
	$stmt = $stmt . " and (OS = '$OSlist[0]')";
	}
	else {
		$stmt = $stmt . " and (OS in ('";
		for ($i=0; $i < sizeof($OSlist); $i++) {
		    $stmt = $stmt . $OSlist[$i];
		    if ($i < sizeof($OSlist)-1) {
			$stmt = $stmt . "','"; 
		    }
		    else {
			$stmt = $stmt . "'))";
		    }
		}
	}
}
$stmt = $stmt . " order by IPNUM";
//echo $stmt;
//echo "<BR>";
include ('tcpPortScanner.inc');

$sth = ibase_query($dbh, $stmt);
while ($row = ibase_fetch_object($sth)) {
		   echo $row->IP_ADDRESS . "<BR>";

$tcpScanner = new tcpPortScanner($row->IP_ADDRESS);
   $ports = $tcpScanner-> doScan();
   if (count($ports) == 0) {
       echo "no open tcp ports detected.<br/>";
   } else {
       echo "open tcp ports:<br/>";
       foreach ($ports as $portNumber => $service) {
           echo "$portNumber ($service)<br/>";
       }
   }

}
?>

Return current item: Network Asset Management Archive