<?php
/*
* This is a php frontend for mod_log_sql. It interfaces
* with the table structure as defined in a MySql database and has been
* tested only with version 1.16 of mod_log_sql.
*
* contact hide@address.com
*
*/
require('db-connect-apache.php');
require('apache-common.php');
require('header.php');
?>
<center>
<table border="1" cellpadding="2" cellspacing=0>
<tr>
<td><b>Log Database</b></td>
<td><b>Total<br>
Connections/
<br>(after filters)</b></td>
<td><b>Todays<br>Connections</b></td>
<td><b>Yesterdays<br>Connections</b></td>
<td><b>4xx<br>
errors</b></td>
<td><b>Total<br>
Bytes (~)</b></td>
<td><b>Last<br>
request</b></td>
<td><b>Virus</b></td>
</tr>
<?php
while(list($key, $foo)=each($validTables))
{
$tempQuery = "select count(*),sum(bytes_sent),max(time_stamp) from ".mysql_Escape_string($foo);
$tempResults = mysql_query($tempQuery);
$counter = mysql_fetch_row($tempResults);
$tempQuery = "select count(*) from ".mysql_Escape_string($foo).sensibleFilter(1).customFilter(1);
$tempResults = mysql_query($tempQuery);
$filterCounter = mysql_fetch_row($tempResults);
$tempQuery = "select count(*) from ".mysql_Escape_string($foo)." ".betweenToday(1);
$tempResults = mysql_query($tempQuery);
$todays = mysql_fetch_row($tempResults);
$tempQuery = "select count(*) from ".mysql_Escape_string($foo)." ".betweenYesterday(1);
$tempResults = mysql_query($tempQuery);
$yesterdays = mysql_fetch_row($tempResults);
$tempQuery = "select count(*) from ".mysql_Escape_string($foo)." where status >= 400 and status < 500 ";
$tempResults = mysql_query($tempQuery);
$errors = mysql_fetch_row($tempResults);
$tempQuery = "select count(*) from ".mysql_Escape_string($foo)." where request_uri like '%default.ida%' or request_uri like '%system32/cmd.exe%'";
$tempResults = mysql_query($tempQuery);
$virus = mysql_fetch_row($tempResults);
if(is_null($counter[2])){
$lastRequest = "N/A";
} else{
$lastRequest = date("d M y h:i:s a", $counter[2]);
}
$grandTotal += $counter[1];
$totalConnections += $counter[0];
$filterTotal += $filterCounter[0];
$todaysTotal += $todays[0];
$yesterdaysTotal += $yesterdays[0];
$totalVirus += $virus[0];
$totalVirusPercent = round(($totalVirus/$totalConnections)*100,2) or $totalVirusPercent = 0;
$percent = round(($virus[0]/$counter[0])*100,2) or $percent = 0;
print '<tr><td><a href="apache.php?dbs='.$foo.'">'.$foo.'</a></td>
<td align=center>'.$counter[0].' /
'.$filterCounter[0].'</td>
<td align=center>'.$todays[0].'</td>
<td align=center>'.$yesterdays[0].'</td>
<td align=center>'.$errors[0].'</td>
<td align=center>'.getBytes($counter[1]).'</td>
<td align=center>'.$lastRequest.'</td>
<td align=center>'.$virus[0].' ('.$percent.'%)</td>
</tr>
';
}
print "<tr><td align=right><b>Totals</b></td><td align=center>".$totalConnections." / ".$filterTotal."</td>
<td align=center>".$todaysTotal."</td><td align=center>".$yesterdaysTotal."</td><td> </td>
<td align=center>".getBytes($grandTotal)."</td><td> </td><td>".$totalVirus."(".$totalVirusPercent."%)</td></tr>";
?>
</table>
</center>
<?php require("footer.php") ?>