ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilVirusScannerAntiVir.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12require_once "Services/VirusScanner/classes/class.ilVirusScanner.php";
13
15{
21 public function __construct($a_scancommand, $a_cleancommand)
22 {
23 parent::__construct($a_scancommand, $a_cleancommand);
24 $this->type = "antivir";
25 $this->scanZipFiles = true;
26 }
27
35 public function scanFile($a_filepath, $a_origname = "")
36 {
37 // This function should:
38 // - call the external scanner for a_filepath
39 // - set scanFilePath to a_filepath
40 // - set scanFileOrigName to a_origname
41 // - set scanFileIsInfected according the scan result
42 // - set scanResult to the scanner output message
43 // - call logScanResult() if file is infected
44 // - return the scanResult, if file is infected
45 // - return an empty string, if file is not infected
46
47 $this->scanFilePath = $a_filepath;
48 $this->scanFileOrigName = $a_origname;
49
50 // Call of antivir command
51 $a_filepath = realpath($a_filepath);
52 $cmd = ilUtil::escapeShellCmd($this->scanCommand);
53 $args = ilUtil::escapeShellArg(" " . $a_filepath . " ");
54 $out = ilUtil::execQuoted($cmd, $args);
55 $this->scanResult = implode("\n", $out);
56
57 // sophie could be called
58 if (preg_match('/ALERT:/', $this->scanResult)) {
59 $this->scanFileIsInfected = true;
60 $this->logScanResult();
61 return $this->scanResult;
62 } else {
63 $this->scanFileIsInfected = false;
64 return "";
65 }
66
67 // antivir has failed (todo)
68 $this->log->write("ERROR (Virus Scanner failed): "
69 . $this->scanResult
70 . "; COMMAMD=" . $cmd);
71 }
72}
An exception for terminatinating execution or to throw for unit testing.
static execQuoted($cmd, $args=null)
exec command and fix spaces on windows
static escapeShellArg($a_arg)
static escapeShellCmd($a_arg)
escape shell cmd
Interface to the AntiVir virus protector.
scanFile($a_filepath, $a_origname="")
scan a file for viruses
__construct($a_scancommand, $a_cleancommand)
Constructor @access public.
Base class for the interface to an external virus scanner This class is abstract and needs to be exte...
logScanResult()
write the result of the last scan to the log @access public
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc