ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 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 $cmd = $this->scanCommand . " " . $a_filepath . " ";
51 exec($cmd, $out, $ret);
52 $this->scanResult = implode("\n", $out);
53
54 // sophie could be called
55 if(preg_match('/ALERT:/', $this->scanResult))
56 {
57 $this->scanFileIsInfected = true;
58 $this->logScanResult();
59 return $this->scanResult;
60 }
61 else
62 {
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 }
73
74}
An exception for terminatinating execution or to throw for unit testing.
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
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35