From 6b087576132e5a22f0bae2efd0ed3cffb99c91cc Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 9 Sep 2015 12:37:32 +0200 Subject: havp - add clamd log tab to GUI --- config/havp/havp_log.php | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'config/havp') diff --git a/config/havp/havp_log.php b/config/havp/havp_log.php index 56a89928..6011f137 100644 --- a/config/havp/havp_log.php +++ b/config/havp/havp_log.php @@ -31,9 +31,16 @@ require("guiconfig.inc"); require_once("/usr/local/pkg/havp.inc"); $nentries = $config['syslog']['nentries'] ?: "50"; +if ($_GET['logtab'] === 'havp') { + define('HAVP_CLAMDTAB', false); + define('HAVP_LOGFILE', HVDEF_HAVP_ERRORLOG); +} else { + define('HAVP_CLAMDTAB', true); + define('HAVP_LOGFILE', HVDEF_CLAM_LOG); +} if ($_POST['clear']) { - file_put_contents(HVDEF_HAVP_ERRORLOG, ''); + file_put_contents(HAVP_LOGFILE, ''); } function dump_havp_errorlog($logfile, $tail) { @@ -44,22 +51,32 @@ function dump_havp_errorlog($logfile, $tail) { if (is_dir($logfile)) { $logarr = array("$logfile is a directory."); } elseif (file_exists($logfile) && filesize($logfile) == 0) { - $logarr = array("Log file is empty."); + $logarr = array(" -> Log file is empty."); } else { exec("/bin/cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); } foreach ($logarr as $logent) { + if (HAVP_CLAMDTAB) { + $logent = explode(" -> ", $logent); + $entry_date_time = htmlspecialchars($logent[0]); + $entry_text = htmlspecialchars($logent[1]); + } else { $logent = preg_split("/\s+/", $logent, 3); - echo "\n"; - $entry_date_time = htmlspecialchars($logent[0] . " " . $logent[1]); + $entry_date_time = htmlspecialchars($logent[0] . " " . $logent[1]); $entry_text = htmlspecialchars($logent[2]); - echo "{$entry_date_time}\n"; - echo "{$entry_text}\n"; - echo "\n"; + } + echo "\n"; + echo "{$entry_date_time}\n"; + echo "{$entry_text}\n"; + echo "\n"; } } -$pgtitle = "Antivirus: HAVP log"; +if ($_GET['logtab'] === 'havp') { + $pgtitle = "Antivirus: HAVP log"; +} else { + $pgtitle = "Antivirus: Clamd log"; +} include("head.inc"); ?> @@ -73,7 +90,8 @@ include("head.inc"); $tab_array[] = array(gettext("General Page"), false, "antivirus.php"); $tab_array[] = array(gettext("HTTP Proxy"), false, "pkg_edit.php?xml=havp.xml"); $tab_array[] = array(gettext("Settings"), false, "pkg_edit.php?xml=havp_avset.xml"); - $tab_array[] = array(gettext("HAVP Log"), true, "havp_log.php"); + $tab_array[] = array(gettext("HAVP Log"), !HAVP_CLAMDTAB, "havp_log.php?logtab=havp"); + $tab_array[] = array(gettext("Clamd Log"), HAVP_CLAMDTAB, "havp_log.php?logtab=clamd"); display_top_tabs($tab_array); ?> @@ -82,12 +100,12 @@ include("head.inc"); + - + -- cgit v1.2.3
-

-
+ " />