From c9029e6ca3f17f7b0f26d564dcb435084deb06f3 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 9 Aug 2015 05:09:03 +0200 Subject: antivirus_status.widget.php - code style cleanup while here --- .../widget-antivirus/antivirus_status.widget.php | 260 ++++++++++----------- 1 file changed, 119 insertions(+), 141 deletions(-) (limited to 'config/widget-antivirus') diff --git a/config/widget-antivirus/antivirus_status.widget.php b/config/widget-antivirus/antivirus_status.widget.php index 6bca68a2..9c18d3f6 100644 --- a/config/widget-antivirus/antivirus_status.widget.php +++ b/config/widget-antivirus/antivirus_status.widget.php @@ -1,108 +1,96 @@ . - Part of pfSense widgets (www.pfsense.org) - originally based on m0n0wall (http://m0n0.ch/wall) - - Copyright (C) 2004-2005 T. Lechat , Manuel Kasper - and Jonathan Watt . - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. + antivirus_status.widget.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Serg Dvoriancev + Copyright (C) 2015 ESF, LLC + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ - require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); -define('PATH_CLAMDB', '/var/db/clamav'); -$pfSversion = str_replace("\s", "", file_get_contents("/etc/version")); -if(preg_match("/^2.0/",$pfSversion)) - define('PATH_HAVPLOG', '/var/log/havp/access.log'); -else - define('PATH_HAVPLOG', '/var/log/access.log'); - +define('PATH_CLAMDB', '/var/db/clamav'); +define('PATH_HAVPLOG', '/var/log/access.log'); define('PATH_AVSTATUS', '/var/tmp/havp.status'); - -if (file_exists("/usr/local/pkg/havp.inc")) - require_once("/usr/local/pkg/havp.inc"); -else echo "No havp.inc found"; - -function havp_avdb_info($filename) -{ - $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; - $r = ''; - $path = PATH_CLAMDB . "/{$filename}"; - if (file_exists($path)) { - $handle = ''; - if ($handle = fopen($path, "r")) { - $s = fread($handle, 1024); - $s = explode(':', $s); - - # datetime - $dt = explode(" ", $s[1]); - $s[1] = strftime("%Y.%m.%d", strtotime("{$dt[0]} {$dt[1]} {$dt[2]}")); - if ($s[0] == 'ClamAV-VDB') - $r .= "{$filename}{$s[1]}{$s[2]}{$s[7]}"; - } - fclose($handle); - } - return $r; +if (file_exists("/usr/local/pkg/havp.inc")) { + require_once("/usr/local/pkg/havp.inc"); +} else { + echo "No havp.inc found. You must have HAVP package installed to use this widget."; } -function dwg_avbases_info() -{ - $db = ''; - $db .= ''; - $db .= havp_avdb_info("daily.cld"); - $db .= havp_avdb_info("daily.cvd"); - $db .= havp_avdb_info("bytecode.cld"); - $db .= havp_avdb_info("bytecode.cvd"); - $db .= havp_avdb_info("main.cld"); - $db .= havp_avdb_info("main.cvd"); - $db .= havp_avdb_info("safebrowsing.cld"); - $db .= havp_avdb_info("safebrowsing.cvd"); - $db .= '
DatabaseDateVer.Builder
'; - return $db; +function havp_avdb_info($filename) { + $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; + $r = ''; + $path = PATH_CLAMDB . "/{$filename}"; + if (file_exists($path)) { + $handle = ''; + if ($handle = fopen($path, "r")) { + $s = fread($handle, 1024); + $s = explode(':', $s); + # datetime + $dt = explode(" ", $s[1]); + $s[1] = strftime("%Y.%m.%d", strtotime("{$dt[0]} {$dt[1]} {$dt[2]}")); + if ($s[0] == 'ClamAV-VDB') { + $r .= "{$filename}{$s[1]}{$s[2]}{$s[7]}"; + } + fclose($handle); + } + return $r; + } } -function avupdate_status() -{ - $s = "Not found."; - if (HVDEF_UPD_STATUS_FILE && file_exists(HVDEF_UPD_STATUS_FILE)) - $s = file_get_contents(HVDEF_UPD_STATUS_FILE); - return str_replace( "\n", "
", $s ); +function dwg_avbases_info() { + $db = ''; + $db .= ''; + $db .= havp_avdb_info("daily.cld"); + $db .= havp_avdb_info("daily.cvd"); + $db .= havp_avdb_info("bytecode.cld"); + $db .= havp_avdb_info("bytecode.cvd"); + $db .= havp_avdb_info("main.cld"); + $db .= havp_avdb_info("main.cvd"); + $db .= havp_avdb_info("safebrowsing.cld"); + $db .= havp_avdb_info("safebrowsing.cvd"); + $db .= '
DatabaseDateVer.Builder
'; + return $db; } -function dwg_av_statistic() -{ - $s = "Unknown."; - if (file_exists(PATH_HAVPLOG)) { - $log = file_get_contents(PATH_HAVPLOG); +function avupdate_status() { + $s = "Not found."; + if (HVDEF_UPD_STATUS_FILE && file_exists(HVDEF_UPD_STATUS_FILE)) { + $s = file_get_contents(HVDEF_UPD_STATUS_FILE); + return str_replace( "\n", "
", $s ); + } +} -$count = substr_count(strtolower($log), "virus clamd:"); -$s = "Found $count viruses (total)."; +function dwg_av_statistic() { + $s = "Unknown."; + if (file_exists(PATH_HAVPLOG)) { + $log = file_get_contents(PATH_HAVPLOG); + $count = substr_count(strtolower($log), "virus clamd:"); + $s = "Found $count viruses (total)."; /* # slowly worked - need apply cache or preparse stat @@ -123,59 +111,49 @@ $s = "Found $count viruses (total)."; $s .= "000$count"; $s .= ""; */ - } - - return $s; + } + return $s; } ?> - - - - - - - - - - - - - - - - - - - - - - - -
HTTP Scanner - -
Antivirus Scanner - -
Antivirus Bases - -
Last Update - -
Statistic - -
- + + + + + + + + + + + + + + + + + + + + + + + +
HTTP Scanner + +
Antivirus Scanner + +
Antivirus Bases + +
Last Update + +
Statistics + +
-- cgit v1.2.3