ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
11 require_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 }
Interface to the AntiVir virus protector.
scanFile($a_filepath, $a_origname="")
scan a file for viruses
logScanResult()
write the result of the last scan to the log public
static escapeShellCmd($a_arg)
escape shell cmd
__construct($a_scancommand, $a_cleancommand)
Constructor public.
static execQuoted($cmd, $args=null)
exec command and fix spaces on windows
Base class for the interface to an external virus scanner This class is abstract and needs to be exte...
static escapeShellArg($a_arg)
__construct(Container $dic, ilPlugin $plugin)