11 require_once
"./Services/VirusScanner/classes/class.ilVirusScanner.php";
26 $this->scanCommand = IL_ICAP_CLIENT;
35 return ' -i ' . IL_ICAP_HOST .
' -p ' . IL_ICAP_PORT .
' -v -s ' . IL_ICAP_AV_COMMAND .
' -f ' . $file;
43 function scanFile($a_filepath, $a_origname =
"")
46 if (file_exists($a_filepath)) {
47 if (is_readable($a_filepath)) {
48 $a_filepath = realpath($a_filepath);
53 $timeout = preg_grep(
'/failed\/timedout.*/',
$out);
54 $virus_detected = preg_grep(
'/' . self::HEADER_INFECTION_FOUND .
'.*/',
$out);
55 if (is_array($virus_detected) && count($virus_detected) > 0) {
56 $return_string = sprintf(
'Virus detected in %s', $a_filepath);
57 $this->log->warning($return_string);
59 } elseif (is_array($timeout) && count($timeout) > 0) {
60 $return_string =
'Cannot connect to icap server.';
61 $this->log->warning($return_string);
63 $this->scanResult = implode(
"\n",
$out);
65 $return_string = sprintf(
'File "%s" not readable.', $a_filepath);
66 $this->log->info($return_string);
69 $return_string = sprintf(
'File "%s" not found.', $a_filepath);
70 $this->log->info($return_string);
72 $this->log->info(sprintf(
'No virus found in file "%s".', $a_filepath));
73 return $return_string;
const HEADER_INFECTION_FOUND
Interface to the ClamAV virus protector.
__construct($a_scancommand, $a_cleancommand)
ilVirusScannerICapClient constructor.
static escapeShellCmd($a_arg)
escape shell cmd
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)
buildScanCommandArguments($file='-')
scanFile($a_filepath, $a_origname="")