ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilVirusScannerAntiVir.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
34 require_once "class.ilVirusScanner.php";
35 
37 {
43  function ilVirusScannerAntivir($a_scancommand, $a_cleancommand)
44  {
45  $this->ilVirusScanner($a_scancommand, $a_cleancommand);
46  $this->type = "antivir";
47  $this->scanZipFiles = true;
48  }
49 
58  function scanFile($a_filepath, $a_origname = "")
59  {
60  // This function should:
61  // - call the external scanner for a_filepath
62  // - set scanFilePath to a_filepath
63  // - set scanFileOrigName to a_origname
64  // - set scanFileIsInfected according the scan result
65  // - set scanResult to the scanner output message
66  // - call logScanResult() if file is infected
67  // - return the scanResult, if file is infected
68  // - return an empty string, if file is not infected
69 
70  $this->scanFilePath = $a_filepath;
71  $this->scanFileOrigName = $a_origname;
72 
73  // Call of antivir command
74  $cmd = $this->scanCommand . " " . $a_filepath. " ";
75  exec($cmd, $out, $ret);
76  $this->scanResult = implode("\n", $out);
77 
78  // sophie could be called
79  if (ereg("ALERT:", $this->scanResult))
80  {
81  $this->scanFileIsInfected = true;
82  $this->logScanResult();
83  return $this->scanResult;
84  }
85  else
86  {
87  $this->scanFileIsInfected = false;
88  return "";
89  }
90 
91  // antivir has failed (todo)
92  $this->log->write("ERROR (Virus Scanner failed): "
93  . $this->scanResult
94  . "; COMMAMD=" . $cmd);
95 
96  }
97 
98 
99 }
100 ?>