array("name" => "Firewall", "shortcut" => "filter"), ); // The logs to display are specified in a GET argument. Default to 'system' logs if (!$_GET['logfile']) { $logfile = 'filter'; $view = 'normal'; } else { $logfile = $_GET['logfile']; $view = $_GET['view']; if (!array_key_exists($logfile, $allowed_logs)) { /* Do not let someone attempt to load an unauthorized log. */ $logfile = 'filter'; $view = 'normal'; } } if ($view == 'normal') { $view_title = gettext("Normal View"); } if ($view == 'dynamic') { $view_title = gettext("Dynamic View"); } if ($view == 'summary') { $view_title = gettext("Summary View"); } // Status Logs Common - Code status_logs_common_code(); $pgtitle = array(gettext("Status"), gettext("System Logs"), gettext($allowed_logs[$logfile]["name"]), $view_title); include("head.inc"); if (!$input_errors && $savemsg) { print_info_box($savemsg, 'success'); $manage_log_active = false; } // Tab Array tab_array_logs_common(); $filterlog = conv_log_filter($logfile_path, $lines, $lines); $gotlines = count($filterlog); $fields = array( 'act' => 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(); foreach ($filterlog as $fe) { $specialfields = array('srcport', 'dstport'); foreach (array_keys($fields) as $field) { if (!in_array($field, $specialfields)) { $summary[$field][$fe[$field]]++; } } /* Handle some special cases */ if ($fe['srcport']) { $summary['srcport'][$fe['proto'].'/'.$fe['srcport']]++; } else { $summary['srcport'][$fe['srcport']]++; } if ($fe['dstport']) { $summary['dstport'][$fe['proto'].'/'.$fe['dstport']]++; } else { $summary['dstport'][$fe['dstport']]++; } } print("
"); $infomsg = sprintf(gettext('This is a summary of the last %1$s lines of the firewall log (Max %2$s).'), $gotlines, $lines); ?>

'); print(''); print('' . ''); $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('' . ''); } elseif (substr_count($outstr, '/') == 1) { list($proto, $port) = explode('/', $outstr); $service = getservbyport($port, strtolower($proto)); if ($service) { $outstr .= ": {$service}"; } } if (!is_ipaddr($outstr)) { print(''); } } } $leftover = $gotlines - $total; if ($leftover > 0) { print ""; } print "
' . $fields[$stat] . '' . gettext("Data points") . '
' . $outstr . '' . $summary[$stat][$k[$i]] . '' . gettext("Lookup") . '
' . $outstr . '' . $summary[$stat][$k[$i]] . '
Other{$leftover}
"; 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; ?>