ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilVirusScannerClamAV.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 require_once "class.ilVirusScanner.php";
14 
16 {
22  function ilVirusScannerClamAV($a_scancommand, $a_cleancommand)
23  {
24  $this->ilVirusScanner($a_scancommand, $a_cleancommand);
25  $this->type = "clamav";
26  $this->scanZipFiles = true;
27  }
28 
37  function scanFile($a_filepath, $a_origname = "")
38  {
39  // This function should:
40  // - call the external scanner for a_filepath
41  // - set scanFilePath to a_filepath
42  // - set scanFileOrigName to a_origname
43  // - set scanFileIsInfected according the scan result
44  // - set scanResult to the scanner output message
45  // - call logScanResult() if file is infected
46  // - return the scanResult, if file is infected
47  // - return an empty string, if file is not infected
48 
49  $this->scanFilePath = $a_filepath;
50  $this->scanFileOrigName = $a_origname;
51 
52  // Call of antivir command
53  $cmd = $this->scanCommand . " --no-summary -i " . $a_filepath. " 2>&1";
54  exec($cmd, $out, $ret);
55  $this->scanResult = implode("\n", $out);
56 
57  // sophie could be called
58  if (ereg("FOUND", $this->scanResult))
59  {
60  $this->scanFileIsInfected = true;
61  $this->logScanResult();
62  return $this->scanResult;
63  }
64  else
65  {
66  $this->scanFileIsInfected = false;
67  return "";
68  }
69 
70  // antivir has failed (todo)
71  $this->log->write("ERROR (Virus Scanner failed): "
72  . $this->scanResult
73  . "; COMMAMD=" . $cmd);
74 
75  }
76 
77 
78 }
79 ?>