ILIAS  release_8 Revision v8.23
class.ilVirusScannerAntiVir.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  public function __construct(string $scan_command, string $clean_command)
24  {
25  parent::__construct($scan_command, $clean_command);
26  $this->type = "antivir";
27  $this->scanZipFiles = true;
28  }
29 
30  public function scanFile(string $file_path, string $org_name = ""): string
31  {
32  $this->scanFilePath = $file_path;
33  $this->scanFileOrigName = $org_name;
34 
35  // Call of antivir command
36  $a_filepath = realpath($file_path);
37  $cmd = ilShellUtil::escapeShellCmd($this->scanCommand);
38  $args = ilShellUtil::escapeShellArg(" " . $a_filepath . " ");
39  $out = ilShellUtil::execQuoted($cmd, $args);
40  $this->scanResult = implode("\n", $out);
41 
42  // sophie could be called
43  if (preg_match('/ALERT:/', $this->scanResult)) {
44  $this->scanFileIsInfected = true;
45  $this->logScanResult();
46  return $this->scanResult;
47  }
48 
49  $this->scanFileIsInfected = false;
50  return "";
51  }
52 }
scanFile(string $file_path, string $org_name="")
__construct(string $scan_command, string $clean_command)
static escapeShellArg(string $a_arg)
$out
Definition: buildRTE.php:24
static execQuoted(string $cmd, ?string $args=null)
static escapeShellCmd(string $a_arg)
__construct(Container $dic, ilPlugin $plugin)