<?php
$now = date("m/j/y h:i:s",time());
include "connect.php";
include ('tcpPortScanner.inc');
$now = date("j/m/y h:i:s",time());
$stmt = "Select * FROM arp_table where (last_port_scan is null) and (serial>180) and (serial < 280);";
print '<body bgcolor="#FFFFCC">';
echo $now . "<BR>";
$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) {
if ($portNumber != 80) {
$stmt2 = "insert into ports (PORT_NUMBER, MACHINE, FOUND_DATE, LAST_CHECKED) values ('$portNumber', '$row->SERIAL', '$now', '$now');";
$sth2 = ibase_query($dbh, $stmt2);
echo "$portNumber ($service)<br/>";
}
}
$stmt3 = "update arp_table set LAST_PORT_SCAN = '$now' where serial = '$row->SERIAL';";
$sth3 = ibase_query($dbh, $stmt3);
}
}
ibase_free_result($sth);
ibase_close($dbh);
?>