<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Stats Scanned</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/sortabletable.js"></script>
<link type="text/css" rel="StyleSheet" href="css/sortabletable.css" />
<style type="text/css">
body {
font-family: Verdana, Helvetica, Arial, Sans-Serif;
font: Message-Box;
}
code {
font-size: 1em;
}
</style>
</head>
<body>
<?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.*, l.lab from arp_table a, lab l, subnets s where (a.os like 'Window%') and (a.subnet = s.subnet) and (s.lab=l.serial) and (lab<6) and not (os starts with 'Network Gear') and (a.ip_address<>'0.0.0.0') and (last_seen>'$fromdate') order by l.lab, a.iaso, a.ipnum;";
$sth = ibase_query($dbh, $stmt);
$message = '';
echo '<table class="sort-table" id="table-1" cellspacing="0">';
echo '<thead><tr>';
echo '<td>Lab</td>';
echo '<td>IASO</td>';
echo '<td>IP</td>';
echo '<td>Status</td>';
echo '<td>Building</td>';
echo '<td>Room</td>';
echo '<td>Barcode</td>';
echo '<td>OS</td>';
echo '</tr></thead>';
echo '<tbody>';
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 ($row->IASO<>'') {
$stmt2 = "SELECT DISPLAY_NAME, PHONE FROM OWNER WHERE (SERIAL='$row->IASO');";
$sth2 = ibase_query($dbh, $stmt2);
$iaso = ibase_fetch_object($sth2);
}
if ($rec[0]=='Full Access') { echo '<tr bgcolor="#18ff00">'; }
else if ($rec[0]=='') { echo '<tr bgcolor="#fE9999">'; }
else { echo '<tr bgcolor="FE2929">'; }
echo '<td>' . $row->LAB . '</td><td>' . $iaso->DISPLAY_NAME . ' </td><td>';
if ($rec[0]=='') {
echo '<a href="https://iat-db.wes.army.mil/right.php?SERIAL=' . $row->MD5 . '" target = "_blank">' . $row->IP_ADDRESS . '</a></td><td>Not Scanned';
} else {
echo '<a href="https://iat-db.wes.army.mil/right.php?SERIAL=' . $row->MD5 . '" target = "_blank">' . $row->IP_ADDRESS . '</td><td>' . $rec[0] . ' ' ;
}
echo '<td>' . $row->BUILDING . '</td>';
echo '<td>' . $row->ROOM . '</td>';
echo '<td>' . $row->BARCODE . '</td>';
echo '<td>' . $row->OS . '</td>';
echo '</tr>';
// echo $MACADDRESS . '<br>';
}
{
$fname = 'notscannedlist.txt';
$message .= $row->IP_ADDRESS . "\n";
$file = fopen ( "/home/stats/$fname", "w" );
$data = "$message \n";
$fout = fwrite ( $file, $data );
clearstatcache();
}
/* recipients */
$to = "<hide@address.com>"; // note the comma
/* 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 '<tbody>';
echo '</table>';
?>
<script type="text/javascript">
var st1 = new SortableTable(document.getElementById("table-1"),
["Lab", "IASO", "IP", "Status", "Building","Room","Barcode","OS"]);
</script>
<?
echo $message;
//mail($to, $subject, $message, $headers);
fclose ( $file );
odbtp_close();
?>