From f1841f89e8929d3042efc6d55147648d2eb69aee Mon Sep 17 00:00:00 2001 From: doktornotor Date: Thu, 27 Aug 2015 21:54:48 +0200 Subject: havp code style cleanup - Update copyright header - Fix indentation/whitespace - XHTML fixes --- config/havp/antivirus.php | 644 +++++++++++++++++++++++----------------------- 1 file changed, 327 insertions(+), 317 deletions(-) (limited to 'config/havp') diff --git a/config/havp/antivirus.php b/config/havp/antivirus.php index bf5f1879..1c1fc7cc 100644 --- a/config/havp/antivirus.php +++ b/config/havp/antivirus.php @@ -1,383 +1,393 @@ + Copyright (C) 2014 Andrew Nikitin . + 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("pkg-utils.inc"); require_once("service-utils.inc"); - -include("head.inc"); - -header("Content-type: text/html; charset=utf-8"); +require_once("/usr/local/pkg/havp.inc"); $pgtitle = "Antivirus: General page"; +include("head.inc"); -if (file_exists("/usr/local/pkg/havp.inc")) - require_once("/usr/local/pkg/havp.inc"); -else echo "No havp.inc found"; - -define('PATH_CLAMDB', '/var/db/clamav'); -define('PATH_HAVPLOG', '/var/log/havp/access.log'); +define('PATH_CLAMDB', '/var/db/clamav'); +define('PATH_HAVPLOG', '/var/log/havp/access.log'); define('PATH_AVSTATUS', '/var/tmp/havp.status'); -function get_avdb_info() -{ - $r = ''; - $path = PATH_CLAMDB . "/{$filename}"; - $fl = get_dir(PATH_CLAMDB . "/"); - - array_shift($fl); - array_shift($fl); - - foreach ($fl as $fname) { - $path = PATH_CLAMDB . "/{$fname}"; - $ext = end(explode(".", $fname)); - - if ( $ext == "cvd" || $ext == "cld") { - $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; - if (file_exists($path)) { - $handle = ''; - if ($handle = fopen($path, "r")) { - $fsize = sprintf("%.2f M", filesize($path)/1024/1024); - - $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 .= "{$fname}{$s[1]}$fsize{$s[2]}{$s[3]}{$s[7]}"; - } - fclose($handle); - } - } - } - - return $r; -} - -function get_av_statistic() -{ - return function_exists("havp_get_av_statistic") ? havp_get_av_statistic() : "Function 'havp_get_av_statistic' not found."; +function get_avdb_info() { + $r = ''; + $path = PATH_CLAMDB . "/{$filename}"; + $fl = get_dir(PATH_CLAMDB . "/"); + + array_shift($fl); + array_shift($fl); + + foreach ($fl as $fname) { + $path = PATH_CLAMDB . "/{$fname}"; + $ext = end(explode(".", $fname)); + + if ($ext == "cvd" || $ext == "cld") { + $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; + if (file_exists($path)) { + $handle = ''; + if ($handle = fopen($path, "r")) { + $fsize = sprintf("%.2f M", filesize($path)/1024/1024); + + $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 .= "{$fname}{$s[1]}$fsize{$s[2]}{$s[3]}{$s[7]}"; + } + } + fclose($handle); + } + } + } + + return $r; } -function get_av_viruslog() -{ - return function_exists("havp_get_av_viruslog") ? havp_get_av_viruslog() : "Function 'havp_get_av_viruslog' not found."; +function get_av_statistic() { + return function_exists("havp_get_av_statistic") ? havp_get_av_statistic() : "Function 'havp_get_av_statistic' not found."; } -function get_scanlist() -{ - return function_exists("havp_get_filescanlist") ? havp_get_filescanlist() : "Function 'havp_get_filescanlist()' not found."; +function get_av_viruslog() { + return function_exists("havp_get_av_viruslog") ? havp_get_av_viruslog() : "Function 'havp_get_av_viruslog' not found."; } -function get_scan_log() -{ - $s = function_exists("havp_get_scan_log") ? havp_get_scan_log() : "Function 'havp_get_scan_log()' not found."; - $s = str_replace("\n", "
", $s); - return $s; +function get_scanlist() { + return function_exists("havp_get_filescanlist") ? havp_get_filescanlist() : "Function 'havp_get_filescanlist()' not found."; } -function pfsense_version_A() -{ - return function_exists("pfsense_version_") ? pfsense_version_() : 1; +function get_scan_log() { + $s = function_exists("havp_get_scan_log") ? havp_get_scan_log() : "Function 'havp_get_scan_log()' not found."; + $s = str_replace("\n", "
", $s); + return $s; } -function havp_status() -{ - $s = ""; - if (HVDEF_HAVP_STATUS_FILE && file_exists(HVDEF_HAVP_STATUS_FILE)) - $s = file_get_contents(HVDEF_HAVP_STATUS_FILE); - return $s; +function havp_status() { + $s = ""; + if (HVDEF_HAVP_STATUS_FILE && file_exists(HVDEF_HAVP_STATUS_FILE)) { + $s = file_get_contents(HVDEF_HAVP_STATUS_FILE); + } + return $s; } -function clamd_status() -{ - $s = ""; - if (HVDEF_CLAM_STATUS_FILE && file_exists(HVDEF_CLAM_STATUS_FILE)) - $s = file_get_contents(HVDEF_CLAM_STATUS_FILE); - return $s; +function clamd_status() { + $s = ""; + if (HVDEF_CLAM_STATUS_FILE && file_exists(HVDEF_CLAM_STATUS_FILE)) { + $s = file_get_contents(HVDEF_CLAM_STATUS_FILE); + } + return $s; } -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 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 ); } -# ------------------------------------------------------------------------------ - -/* start service */ -if($_POST['start'] != '') { - #start_service($_POST['start']); - if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) { - mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " start"); - sleep(3); - } -} else -/* restart service */ -if($_POST['restart'] != '') { - #restart_service($_POST['restart']); - if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) { - mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " restart"); - sleep(3); - } -} else -/* stop service */ -if($_POST['stop'] != '') { - #stop_service($_POST['stop']); - if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) { - mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " stop"); - sleep(3); - } +/* ------------------------------------------------------------------------------ */ + +/* Start service */ +if ($_POST['start'] != '') { + // start_service($_POST['start']); + if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) { + mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " start"); + sleep(3); + } +/* Restart service */ +} elseif ($_POST['restart'] != '') { + // restart_service($_POST['restart']); + if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) { + mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " restart"); + sleep(3); + } +/* Stop service */ +} elseif ($_POST['stop'] != '') { + // stop_service($_POST['stop']); + if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) { + mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " stop"); + sleep(3); + } } /* Scan start */ if ($_POST['scanpath'] != '') { $scandir = $_POST['scanpath']; - if(function_exists("start_antivirus_scanner")) { + if (function_exists("start_antivirus_scanner")) { start_antivirus_scanner($scandir); - } - else echo "No 'start_antivirus_scanner' function found."; + } } /* Start AV Update */ if ($_POST['startupdate'] != '') { - if( function_exists("havp_update_AV")) { - havp_update_AV(); - } -# else echo "No 'start_antivirus_scanner' function found."; + if (function_exists("havp_update_AV")) { + havp_update_AV(); + } } /* Clear havp access log */ if ($_POST['clearlog_x'] != '') { - file_put_contents(HVDEF_HAVP_ACCESSLOG, ''); + file_put_contents(HVDEF_HAVP_ACCESSLOG, ''); } -# ------------------------------------------------------------------------------ +/* ------------------------------------------------------------------------------ */ ?> -$pgtitle

"; -} -?> -
- - - -
+
-
- - - + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ServiceStatus   Version
HTTP Antivirus Proxy ( )
- Running"; - else echo " Stopped"; - ?> -
- "; - echo " "; - echo ""; - } else echo ""; - ?> - - -
Antivirus Server ( )
- Running"; - else echo " Stopped"; - ?> -
  - -
 
Antivirus UpdateUpdate status
- "; ?> -  Start Update - - -
Antivirus Base Info - - - -
DatabaseDateSizeVer.SignaturesBuilder
-
 
File scannerScanner status
- - - - - - - -
-  Path:
-
-  Enter file path or catalog for scanning. -
- \n"; - echo "\n"; - echo "{$scan['descr']}\n"; - echo ""; - echo "
"; - } - ?> -
- "; ?> -  Start Scanner -
-
- -
 
- - - "; - $count--; - } - } - else echo ""; - ?> - -
Last Viruses
{$ln[0]} {$ln[1]}{$ln[2]}{$ln[5]}{$ln[9]}
Not found
"; ?> Clear log
-
-
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ServiceStatus   Version
HTTP Antivirus Proxy ( )
+ Running"; + } else { + echo "\"\" Stopped"; + } + ?> +
+ "; + echo " "; + echo ""; + } else { + echo ""; + } + ?> + + + +
Antivirus Server ( )
+ Running"; + } else { + echo "\"\" Stopped"; + } + ?> +
  + +
 
Antivirus UpdateUpdate Status
+ "; ?> +  Start Update + + +
Antivirus Base Info + + + + + + + + + + +
DatabaseDateSizeVer.SignaturesBuilder
+
 
File ScannerScanner Status
+ + + + + + + +
+  Path:
+
+  Enter file path or catalog for scanning. +
+ \n"; + echo "\n"; + echo "{$scan['descr']}\n"; + echo ""; + echo "
"; + } + } + ?> +
+ "; ?> +  Start Scanner +
+
+ +
 
+ + + + + + "; + $count--; + } + } else { + echo ""; + } + ?> + + + + +
Last Viruses
{$ln[0]} {$ln[1]}{$ln[2]}{$ln[5]}{$ln[9]}
Not found
+ + "; ?> Clear log +
+
+ +
+ +
+ +
-
- -- cgit v1.2.3