diff options
Diffstat (limited to 'config/havp/havp_log.php')
-rw-r--r-- | config/havp/havp_log.php | 93 |
1 files changed, 54 insertions, 39 deletions
diff --git a/config/havp/havp_log.php b/config/havp/havp_log.php index f4a2dc2e..6011f137 100644 --- a/config/havp/havp_log.php +++ b/config/havp/havp_log.php @@ -1,10 +1,9 @@ <?php -/* $Id$ */ /* havp_log.php + part of pfSense (https://www.pfSense.org/) Copyright (C) 2014 Andrew Nikitin <andrey.b.nikitin@gmail.com>. - Copyright (C) 2005 Bill Marquette <bill.marquette@gmail.com>. - Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,19 +27,21 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require("guiconfig.inc"); +require_once("/usr/local/pkg/havp.inc"); -if (file_exists("/usr/local/pkg/havp.inc")) - require_once("/usr/local/pkg/havp.inc"); -else echo "No havp.inc found"; - -$nentries = $config['syslog']['nentries']; -if (!$nentries) - $nentries = 50; +$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, ''); +if ($_POST['clear']) { + file_put_contents(HAVP_LOGFILE, ''); +} function dump_havp_errorlog($logfile, $tail) { global $g, $config; @@ -48,24 +49,34 @@ function dump_havp_errorlog($logfile, $tail) { $logarr = ""; $grepline = " "; if (is_dir($logfile)) { - $logarr = array("File $logfile is a directory."); - } elseif(file_exists($logfile) && filesize($logfile) == 0) { - $logarr = array(" ... Log file is empty."); + $logarr = array("$logfile is a directory."); + } elseif (file_exists($logfile) && filesize($logfile) == 0) { + $logarr = array(" -> Log file is empty."); } else { - exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); + 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 "<tr valign=\"top\">\n"; $entry_date_time = htmlspecialchars($logent[0] . " " . $logent[1]); $entry_text = htmlspecialchars($logent[2]); - echo "<td class=\"listlr nowrap\" width=\"130\">{$entry_date_time}</td>\n"; - echo "<td class=\"listr\">{$entry_text}</td>\n"; - echo "</tr>\n"; + } + echo "<tr valign=\"top\">\n"; + echo "<td class=\"listlr\" nowrap=\"nowrap\" width=\"130\">{$entry_date_time}</td>\n"; + echo "<td class=\"listr\">{$entry_text}</td>\n"; + echo "</tr>\n"; } } -$pgtitle = "Antivirus: HAVP log"; +if ($_GET['logtab'] === 'havp') { + $pgtitle = "Antivirus: HAVP log"; +} else { + $pgtitle = "Antivirus: Clamd log"; +} include("head.inc"); ?> @@ -73,33 +84,37 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr><td> +<tr><td> <?php $tab_array = array(); - $tab_array[] = array(gettext("General page"), false, "antivirus.php"); - $tab_array[] = array(gettext("HTTP proxy"), false, "pkg_edit.php?xml=havp.xml&id=0"); - $tab_array[] = array(gettext("Settings"), false, "pkg_edit.php?xml=havp_avset.xml&id=0"); - $tab_array[] = array(gettext("HAVP Log"), true, "havp_log.php"); + $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"), !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); ?> - </td></tr> - <tr> - <td> +</td></tr> +<tr><td> <div id="mainarea"> <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0"> - <tr> + <tr> <td colspan="2" class="listtopic"> - <?php printf(gettext("Last %s HAVP log entries"), $nentries);?></td> - </tr> - <?php dump_havp_errorlog(HVDEF_HAVP_ERRORLOG, $nentries); ?> - <tr><td><br/> - <form action="havp_log.php" method="post"> - <input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>" /></form></td></tr> + <?php printf(gettext("Last %s log entries"), $nentries);?></td> + </tr> + <?php dump_havp_errorlog(HAVP_LOGFILE, $nentries); ?> + <tr> + <td><br/> + <form action="havp_log.php?logtab=<?=(HAVP_CLAMDTAB ? 'clamd' : 'havp'); ?>" method="post"> + <input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>" /> + </form> + </td> + </tr> </table> </div> - </td> - </tr> +</td></tr> </table> + <?php include("fend.inc"); ?> </body> </html> |