<?php
$fromdate = $_POST['fromdate'];
$iponly = $_POST['IPONLY'];
include "connect.php";
if (!extension_loaded('odbtp')) {
dl('php_odbtp.so');
}
$con = odbtp_connect($StatsScannerAddress,'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\\Program Files\\Stat\\Scanner\\STAT Scanner Output DB.mdb' ) or die;
odbtp_set_attr( ODB_ATTR_FULLCOLINFO, TRUE );
$now = date("j/m/y h:i:s",time());
if ($fromdate == '') {
$fromdate = date("m/j/y h:i:s",time()-(7*60*60*24));
}
$stmt = "Select a.ip_address, a.mac_address, l.lab, a.last_seen from arp_table a, lab l, subnets s where (a.subnet = s.subnet) and (s.lab=l.serial) and (lab<6) and (a.ip_address<>'0.0.0.0') and (last_seen>'$fromdate') order by l.lab;";
$sth = ibase_query($dbh, $stmt);
$message = '';
while ($row = ibase_fetch_object($sth)) {
$TEMP = strtoupper($row->MAC_ADDRESS);
$MACADDRESS = '';
for ($k=0; $k<6; $k++) {
$MACADDRESS .= $TEMP[($k * 2)];
$MACADDRESS .= $TEMP[($k * 2)+1];
if ($k<>5) {
$MACADDRESS .= ':';
}
}
$myquery = "select [SCAN Summary TABLE].Access from [MACHINE TABLE], [SCAN Summary TABLE] where ([SCAN Summary TABLE].[MACHINE ID]=[MACHINE TABLE].[MACHINE ID]) and ([MACHINE TABLE].[MAC ADDRESS]='" . $MACADDRESS . "');";
//echo $myquery;
$good=0;
if ($qry = odbtp_query($myquery)) {
$rec = odbtp_fetch_array($qry);
$good=1;
// echo $row->IP_ADDRESS . ' ' . $rec[0] .'<BR>';
}
if ($rec[0]=='') {
echo $row->IP_ADDRESS . '<BR>';
} else {
// echo $row->IP_ADDRESS . ' ' . $rec[0] .'<BR>';
}
// echo $MACADDRESS . '<br>';
}
/* recipients */
$to = "<hide@address.com>"; //
/* subject */
$subject = "New Machines on network since " . $fromdate;
/* message */
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers .= "From: Information Assurance <" . $fromemailaddress . ">\r\n";
#$headers .= "Bcc: hide@address.com\r\n";
/* and now mail it */
echo $message;
//mail($to, $subject, $message, $headers);
odbtp_close();
?>