ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
11require_once "Services/VirusScanner/classes/class.ilVirusScanner.php";
12
14{
20 public function __construct($a_scancommand, $a_cleancommand)
21 {
22 parent::__construct($a_scancommand, $a_cleancommand);
23 $this->type = "antivir";
24 $this->scanZipFiles = true;
25 }
26
34 public function scanFile($a_filepath, $a_origname = "")
35 {
36 // This function should:
37 // - call the external scanner for a_filepath
38 // - set scanFilePath to a_filepath
39 // - set scanFileOrigName to a_origname
40 // - set scanFileIsInfected according the scan result
41 // - set scanResult to the scanner output message
42 // - call logScanResult() if file is infected
43 // - return the scanResult, if file is infected
44 // - return an empty string, if file is not infected
45
46 $this->scanFilePath = $a_filepath;
47 $this->scanFileOrigName = $a_origname;
48
49 // Call of antivir command
50 $a_filepath = realpath($a_filepath);
51 $cmd = ilUtil::escapeShellCmd($this->scanCommand);
52 $args = ilUtil::escapeShellArg(" " . $a_filepath . " ");
53 $out = ilUtil::execQuoted($cmd, $args);
54 $this->scanResult = implode("\n", $out);
55
56 // sophie could be called
57 if (preg_match('/ALERT:/', $this->scanResult)) {
58 $this->scanFileIsInfected = true;
59 $this->logScanResult();
60 return $this->scanResult;
61 } else {
62 $this->scanFileIsInfected = false;
63 return "";
64 }
65
66 // antivir has failed (todo)
67 $this->log->write("ERROR (Virus Scanner failed): "
68 . $this->scanResult
69 . "; COMMAMD=" . $cmd);
70 }
71}
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