Location: PHPKode > projects > Network Asset Management Archive > nama/redcounts3.php
<?php
$now = date("m/j/y h:i:s",time());
include "connect.php";

$now = date("j/m/y h:i:s",time());
echo '<body bgcolor="#F9F3E0">';
$tablerow = "style='border-color:#DBB748; border-width:1px; border-right: 2px solid #DBB748; border-collapse: collapse; border-style:solid;'";
$stmt2 = "Select count(a.ip_address) as counttotal, l.lab FROM  ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE  (L.LIASO = O.SERIAL) AND (S.LAB = L.SERIAL) AND (S.SUBNET = A.SUBNET) and (a.ip_address<>'0.0.0.0') group by l.lab";
#echo $stmt2 . '<br>';
?>
<table style='border-color:#DBB748; border-width:3px; border-right: 3px solid #DBB748; border-collapse: collapse; border-style:solid;' width="700" border="2">
<?
$sth2 = ibase_query($dbh, $stmt2);
$i = 0;
$totalmachines=0;
$totalreds=0;
$totalnorton=0;
$totalcac=0;
$totalupdate=0;
$totalwin=0;
$totalvirus=0;
echo "<tr BGCOLOR='#DBB748' ALIGN=left><th>Lab</th><th>Machines</th><th>Norton AV</th><th>Update Server</th><th>CAC</th><th>Virus</th></tr>";
while ($row2 = ibase_fetch_object($sth2)) {
$stmt = "Select count(a.ip_address) as countred, l.lab FROM ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE (L.LIASO = O.SERIAL) AND (S.LAB = L.SERIAL) AND (S.SUBNET = A.SUBNET) and (L.LAB ='" . $row2->LAB . "') and ((owner is null) or (a.iaso is null) or (building is null) or (room is null) or (barcode is null) or (os is null)) and (a.ip_address<>'0.0.0.0') group by l.lab";
#echo $stmt2;
$stmt3 = "Select count(a.ip_address) as counttotal, l.lab FROM  ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE  (L.LIASO = O.SERIAL) AND (S.LAB = L.SERIAL) and (L.LAB ='" . $row2->LAB . "') AND (S.SUBNET = A.SUBNET) and (s.lab<16) and (av_server is not null) and (a.ip_address<>'0.0.0.0') group by l.lab";
#echo $stmt3;
$stmtu = "Select count(a.ip_address) as counttotal, l.lab FROM  ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE  (L.LIASO = O.SERIAL) AND (S.LAB = L.SERIAL) and (L.LAB ='" . $row2->LAB . "') AND (S.SUBNET = A.SUBNET) and (s.lab<16) and (update_server is not null) and (a.ip_address<>'0.0.0.0') group by l.lab";
$stmtc = "Select count(a.ip_address) as counttotal, l.lab FROM  ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE  (L.LIASO = O.SERIAL) AND (S.LAB = L.SERIAL) and (L.LAB ='" . $row2->LAB . "') AND (S.SUBNET = A.SUBNET) and (s.lab<16) and (cac_type is not null) and (a.ip_address<>'0.0.0.0') group by l.lab";
$stmtw = "Select count(a.ip_address) as counttotal, l.lab FROM  ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE  (L.LIASO = O.SERIAL) AND (S.LAB = L.SERIAL) and (L.LAB ='" . $row2->LAB . "') AND (S.SUBNET = A.SUBNET) and (s.lab<16) and ((os is null) or (os starts with 'Windows')) and (a.ip_address<>'0.0.0.0') group by l.lab";
$stmtv = "Select count(a.ip_address) as counttotal, l.lab FROM  ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE  (L.LIASO = O.SERIAL) AND (S.LAB = L.SERIAL) and (L.LAB ='" . $row2->LAB . "') AND (S.SUBNET = A.SUBNET) and (s.lab<16) and (VIRUS_FOUND=1) and (a.ip_address<>'0.0.0.0') group by l.lab";
$sth = ibase_query($dbh, $stmt);
$sth3 = ibase_query($dbh, $stmt3);
$sthu = ibase_query($dbh, $stmtu);
$sthc = ibase_query($dbh, $stmtc);
$sthw = ibase_query($dbh, $stmtw);
$sthv = ibase_query($dbh, $stmtv);
$row = ibase_fetch_object($sth);
$row3 = ibase_fetch_object($sth3);
$rowu = ibase_fetch_object($sthu);
$rowc = ibase_fetch_object($sthc);
$roww = ibase_fetch_object($sthw);
$rowv = ibase_fetch_object($sthv);
$totalmachines=$totalmachines + $row2->COUNTTOTAL;
$totalreds=$totalreds + $row->COUNTRED;
$totalnorton = $totalnorton + $row3->COUNTTOTAL;
$totalupdate = $totalupdate + $rowu->COUNTTOTAL;
$totalcac = $totalcac + $rowc->COUNTTOTAL;
$totalwin = $totalwin + $roww->COUNTTOTAL;
$totalvirus = $totalvirus + $rowv->COUNTTOTAL;
if ($i%2) {
   echo "<tr BGCOLOR='#F5EACB'>";
} else {
   echo "<tr>";
}
echo '<td ' . $tablerow . '>' . $row2->LAB  . '</td>' ;
//echo '<td>' . ($row2->COUNTTOTAL - $row->COUNTRED) . '</td>';
if ($row->COUNTRED != '') { 
echo '<td ' . $tablerow . '>' . ($row2->COUNTTOTAL - $row->COUNTRED) . ' / ' . $row2->COUNTTOTAL . ' = ' . (100-round(($row->COUNTRED/$row2->COUNTTOTAL)*100,1)) . '%</td>';
} else {
    echo '<td ' . $tablerow . '>' . $row2->COUNTTOTAL . ' / ' . $row2->COUNTTOTAL . ' = 100%';
}
//echo '<td>' . round((($row2->COUNTTOTAL - $row->COUNTRED) / $row2->COUNTTOTAL * 100),2) . '</td>';
//echo '<td>' . round(($row->COUNTRED / $row2->COUNTTOTAL * 100),2) . '</td>';
if ($row3->COUNTTOTAL != '') { 
    echo '<td ' . $tablerow . '>' . $row3->COUNTTOTAL . ' / ' . $roww->COUNTTOTAL . ' = ' . round(($row3->COUNTTOTAL/$roww->COUNTTOTAL)*100,1) . '%</td>';
} else {
    echo '<td ' . $tablerow . '>0 / ' . $roww->COUNTTOTAL  . ' = 0%</td>';
}
if ($rowu->COUNTTOTAL != '') { 
    echo '<td ' . $tablerow . '>' . $rowu->COUNTTOTAL . ' / ' . $roww->COUNTTOTAL . ' = ' . round(($rowu->COUNTTOTAL/$roww->COUNTTOTAL)*100,1) . '%</td>';
} else {
    echo '<td ' . $tablerow . '>0 / ' . $roww->COUNTTOTAL  . ' = 0%</td>';
}
if ($rowc->COUNTTOTAL != '') { 
    echo '<td ' . $tablerow . '>' . $rowc->COUNTTOTAL . '</td>';
} else {
    echo '<td ' . $tablerow . '>0</td>';
}
if ($rowv->COUNTTOTAL != '') { 
    echo '<td ' . $tablerow . '>' . $rowv->COUNTTOTAL . '</td>';
} else {
    echo '<td ' . $tablerow . '>0</td>';
}
echo '</tr>';
$i = $i + 1;
}
echo '<tr bgcolor="#EBD89B">';
echo '<td ' . $tablerow . '><b>Total</b></td>' ;
echo '<td ' . $tablerow . '>';
echo ($totalmachines - $totalreds) . ' / ' . $totalmachines  . ' = ' . (100-round(($totalreds/$totalmachines)*100,1))  . '%</td>';
//echo '<td>' . $totalreds . '</td>';
//echo '<td>' . round((($totalmachines - $totalreds) / $totalmachines * 100),2) . '</td>';
//echo '<td>' . round(($totalreds / $totalmachines * 100),2) . '</td>';
echo '<td ' . $tablerow . '>' . $totalnorton . ' / ' . $totalwin .  ' = ' . round(($totalnorton/$totalwin)*100,1) . '%</td>';
echo '<td ' . $tablerow . '>' . $totalupdate . ' / ' . $totalwin .  ' = ' . round(($totalupdate/$totalwin)*100,1) . '%</td>';
echo '<td ' . $tablerow . '>' . $totalcac . '</td>';
echo '<td ' . $tablerow . '>' . $totalvirus . '</td>';
echo '</tr>';
echo "</table>";
?>

Return current item: Network Asset Management Archive