From 2d65485637b23d6042baa25054370c97e6d61e61 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 7 Oct 2006 05:19:40 +0000 Subject: CACHE /var/log/snort/alert in between calls --- packages/snort/snort.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/snort/snort.inc b/packages/snort/snort.inc index fb0b7343..aba44a75 100644 --- a/packages/snort/snort.inc +++ b/packages/snort/snort.inc @@ -485,9 +485,13 @@ function update_all_status($status) { } } +$snort_alert_file_split = split("\n", file_get_contents("/var/log/snort/alert")); + function get_snort_alert($ip) { - $file_split = split("\n", file_get_contents("/var/log/snort/alert")); - foreach($file_split as $fileline) { + global $snort_alert_file_split; + if(!$snort_alert_file_split) + $snort_alert_file_split = split("\n", file_get_contents("/var/log/snort/alert")); + foreach($snort_alert_file_split as $fileline) { if (preg_match("/\[\*\*\] (\[.*\]) (.*) (\[\*\*\])/", $fileline, $matches)) $alert_title = $matches[2]; if (preg_match("/(\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)/", $fileline, $matches)) -- cgit v1.2.3