gettext("Actions"),
'interface' => gettext("Interfaces"),
'proto' => gettext("Protocols"),
'srcip' => gettext("Source IPs"),
'dstip' => gettext("Destination IPs"),
'srcport' => gettext("Source Ports"),
'dstport' => gettext("Destination Ports"));
$segcolors = array("#2484c1", "#65a620", "#7b6888", "#a05d56", "#961a1a", "#d8d23a", "#e98125", "#d0743c", "#635222", "#6ada6a");
$numcolors = 10;
$summary = array();
foreach (array_keys($fields) as $f) {
$summary[$f] = array();
}
$totals = array();
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? 1 : -1;
}
function stat_block($summary, $stat, $num) {
global $g, $gotlines, $fields;
uasort($summary[$stat] , 'cmp');
print('
');
print('
');
print('' . $fields[$stat] . ' | ' . '' . gettext("Data points") . ' | |
');
$k = array_keys($summary[$stat]);
$total = 0;
$numentries = 0;
for ($i = 0; $i < $num; $i++) {
if ($k[$i]) {
$total += $summary[$stat][$k[$i]];
$numentries++;
$outstr = $k[$i];
if (is_ipaddr($outstr)) {
print('' . $outstr . ' | ' . '' . $summary[$stat][$k[$i]] . ' | Lookup |
');
} elseif (substr_count($outstr, '/') == 1) {
list($proto, $port) = explode('/', $outstr);
$service = getservbyport($port, strtolower($proto));
if ($service) {
$outstr .= ": {$service}";
}
}
if (!is_ipaddr($outstr)) {
print('' . $outstr . ' | ' . $summary[$stat][$k[$i]] . ' | |
');
}
}
}
$leftover = $gotlines - $total;
if ($leftover > 0) {
print "Other | {$leftover} | | ";
}
print "
";
print('
');
}
// Create the JSON document for the chart to be displayed
// Todo: Be good to investigate building this with json_encode and friends some time
function pie_block($summary, $stat, $num, $chartnum) {
global $fields, $segcolors, $gotlines, $numcolors;
?>
");
$infomsg = sprintf('This is a summary of the last %1$s lines of the firewall log (Max %2$s).', $gotlines, $lines);
print_info_box($infomsg, info);
?>