Commit 6af1ccbc authored by Ad Schellevis's avatar Ad Schellevis

(legacy) some minor cleanups to filter_log.inc

parent a5027cc3
...@@ -43,8 +43,9 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = '', $fil ...@@ -43,8 +43,9 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = '', $fil
if (!(is_numeric($tail))) if (!(is_numeric($tail)))
return; return;
if ($filtertext) if ($filtertext!=""){
$tail = 5000; $tail = 5000;
}
/* Always do a reverse tail, to be sure we're grabbing the 'end' of the log. */ /* Always do a reverse tail, to be sure we're grabbing the 'end' of the log. */
$logarr = ""; $logarr = "";
...@@ -54,20 +55,22 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = '', $fil ...@@ -54,20 +55,22 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = '', $fil
$filterlog = array(); $filterlog = array();
$counter = 0; $counter = 0;
$filterinterface = strtoupper($filterinterface);
foreach ($logarr as $logent) { foreach ($logarr as $logent) {
if($counter >= $nentries) if($counter >= $nentries)
break; break;
$flent = parse_filter_line($logent); $flent = parse_filter_line($logent);
if (!$filterinterface || ($filterinterface == $flent['interface'])) if (isset($flent) && is_array($flent)) {
{ if ($filterinterface == null || strtoupper($filterinterface) == $flent['interface']) {
if ( ( ($flent != "") && (!is_array($filtertext)) && (match_filter_line ($flent, $filtertext))) || if ( (!is_array($filtertext) && match_filter_line ($flent, $filtertext)) ||
( ($flent != "") && ( is_array($filtertext)) && (match_filter_field($flent, $filtertext)) ) ) { ( is_array($filtertext) && match_filter_field($flent, $filtertext))
$counter++; ) {
$filterlog[] = $flent; $counter++;
$filterlog[] = $flent;
}
} }
} }
} }
/* Since the lines are in reverse order, flip them around if needed based on the user's preference */ /* Since the lines are in reverse order, flip them around if needed based on the user's preference */
return isset($config['syslog']['reverse']) ? $filterlog : array_reverse($filterlog); return isset($config['syslog']['reverse']) ? $filterlog : array_reverse($filterlog);
...@@ -248,7 +251,9 @@ function parse_filter_line($line) ...@@ -248,7 +251,9 @@ function parse_filter_line($line)
$flent['icmp_ttime'] = $rule_data[$field++]; $flent['icmp_ttime'] = $rule_data[$field++];
break; break;
default : default :
$flent['icmp_descr'] = $rule_data[$field++]; if (isset($rule_data[$field++])) {
$flent['icmp_descr'] = $rule_data[$field++];
}
break; break;
} }
} elseif ($flent['protoid'] == '112') { // CARP } elseif ($flent['protoid'] == '112') { // CARP
...@@ -378,11 +383,11 @@ function find_action_image($action) ...@@ -378,11 +383,11 @@ function find_action_image($action)
/* AJAX specific handlers */ /* AJAX specific handlers */
function handle_ajax($nentries, $tail = 50) { function handle_ajax($nentries, $tail = 50) {
global $config; global $config;
if($_GET['lastsawtime'] or $_POST['lastsawtime']) { if(isset($_GET['lastsawtime']) || isset($_POST['lastsawtime'])) {
global $filter_logfile,$filterent; global $filter_logfile,$filterent;
if($_GET['lastsawtime']) if(isset($_GET['lastsawtime']))
$lastsawtime = $_GET['lastsawtime']; $lastsawtime = $_GET['lastsawtime'];
if($_POST['lastsawtime']) if(isset($_POST['lastsawtime']))
$lastsawtime = $_POST['lastsawtime']; $lastsawtime = $_POST['lastsawtime'];
/* compare lastsawrule's time stamp to filter logs. /* compare lastsawrule's time stamp to filter logs.
* afterwards return the newer records so that client * afterwards return the newer records so that client
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment