40 public $errors = array();
78 if (preg_match(
'/\.virus$/i', $file)) {
79 $this->errors[] =
'File has an extension saying file is a virus';
88 $safemode = ini_get(
"safe_mode");
90 dol_syslog(
"AntiVir::dol_avscan_file Run command=".$fullcommand.
" with safe_mode ".($safemode ?
"on" :
"off"));
92 include_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
93 $utils =
new Utils($this->db);
94 $outputfile = $conf->user->dir_temp.
'/antivir.tmp';
96 $result = $utils->executeCLI($fullcommand, $outputfile);
98 $return_var = $result[
'result'];
99 $output = $result[
'output'];
100 $errorstring = $result[
'error'];
102 if (is_null($output)) {
106 dol_syslog(
"AntiVir::dol_avscan_file Result return_var=".$return_var.
" output=".$output);
108 $returncodevirus = 1;
109 if ($return_var == $returncodevirus) {
110 $this->errors = array($errorstring, $output);
114 if ($return_var > 0) {
115 $this->errors = array($errorstring, $output);
138 $bz2archivememlim = 0;
139 $maxfilesize = 10485760;
141 $command = $conf->global->MAIN_ANTIVIRUS_COMMAND;
142 $param = $conf->global->MAIN_ANTIVIRUS_PARAM;
144 $param = preg_replace(
'/%maxreclevel/', $maxreclevel, $param);
145 $param = preg_replace(
'/%maxfiles/', $maxfiles, $param);
146 $param = preg_replace(
'/%maxratio/', $maxratio, $param);
147 $param = preg_replace(
'/%bz2archivememlim/', $bz2archivememlim, $param);
148 $param = preg_replace(
'/%maxfilesize/', $maxfilesize, $param);
149 $param = preg_replace(
'/%file/', trim($file), $param);
151 if (!preg_match(
'/%file/', $conf->global->MAIN_ANTIVIRUS_PARAM)) {
152 $param = $param.
" ".escapeshellarg(trim($file));
155 if (preg_match(
"/\s/", $command)) {
156 $command = escapeshellarg($command);
159 $forbidden_chars_to_replace = array(
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
'°',
'$');
__construct($db)
Constructor.
dol_avscan_file($file)
Scan a file with antivirus.
getCliCommand($file)
Get full Command Line to run.
Class to manage utility methods.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.