ILIAS  release_4-4 Revision
ilVirusScannerClamAV Class Reference

Interface to the ClamAV virus protector. More...

+ Inheritance diagram for ilVirusScannerClamAV:
+ Collaboration diagram for ilVirusScannerClamAV:

Public Member Functions

 ilVirusScannerClamAV ($a_scancommand, $a_cleancommand)
 Constructor public. More...
 
 scanFile ($a_filepath, $a_origname="")
 scan a file for viruses More...
 
- Public Member Functions inherited from ilVirusScanner
 ilVirusScanner ($a_scancommand, $a_cleancommand)
 Constructor public. More...
 
 scanFile ($a_filepath, $a_origname="")
 scan a file for viruses More...
 
 cleanFile ($a_filepath, $a_origname="")
 clean an infected file More...
 
 fileCleaned ()
 returns wether file has been cleaned successfully or not More...
 
 logScanResult ()
 write the result of the last scan to the log More...
 
 logCleanResult ()
 write the result of the last clean to the log More...
 
 getScanResult ()
 get the pure output of the external scan More...
 
 getCleanResult ()
 get the pure output of the external scan More...
 
 getScanMessage ()
 get a located message with the result from the last scan More...
 
 getCleanMessage ()
 get a located message with the result from the last clean More...
 
 getScanZipFiles ()
 get info if class can scan ZIP files More...
 

Additional Inherited Members

- Data Fields inherited from ilVirusScanner
 $type
 
 $scanZipFiles
 
 $scanCommand
 
 $cleanCommand
 
 $scanFilePath
 
 $scanFileOrigName
 
 $cleanFilePath
 
 $cleanFileOrigName
 
 $scanFileIsInfected
 
 $cleanFileIsCleaned
 
 $scanResult
 
 $cleanResult
 
 $ilias
 
 $lng
 
 $log
 

Detailed Description

Interface to the ClamAV virus protector.

Author
Ralf Schenk rs@da.nosp@m.taba.nosp@m.y.de
Version
$Id$

Definition at line 15 of file class.ilVirusScannerClamAV.php.

Member Function Documentation

◆ ilVirusScannerClamAV()

ilVirusScannerClamAV::ilVirusScannerClamAV (   $a_scancommand,
  $a_cleancommand 
)

Constructor public.

Parameters
stringvirus scanner command

Definition at line 22 of file class.ilVirusScannerClamAV.php.

References ilVirusScanner\ilVirusScanner().

23  {
24  $this->ilVirusScanner($a_scancommand, $a_cleancommand);
25  $this->type = "clamav";
26  $this->scanZipFiles = true;
27  }
ilVirusScanner($a_scancommand, $a_cleancommand)
Constructor public.
+ Here is the call graph for this function:

◆ scanFile()

ilVirusScannerClamAV::scanFile (   $a_filepath,
  $a_origname = "" 
)

scan a file for viruses

Parameters
stringpath of file to check
stringoriginal name of the file to ckeck
Returns
string virus message (empty if not infected) public

Definition at line 37 of file class.ilVirusScannerClamAV.php.

References $cmd, $out, $ret, ilVirusScanner\$scanResult, and ilVirusScanner\logScanResult().

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  }
$cmd
Definition: sahs_server.php:35
logScanResult()
write the result of the last scan to the log
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: