40 public $errors = array();
78 if (preg_match(
'/\.virus$/i', $file)) {
79 $this->errors[] =
'File has an extension saying file is a virus';
85 $fullcommand .=
' 2>&1';
89 $safemode = ini_get(
"safe_mode");
91 dol_syslog(
"AntiVir::dol_avscan_file Run command=".$fullcommand.
" with safe_mode ".($safemode ?
"on" :
"off"));
93 $lastline = exec($fullcommand, $output, $return_var);
95 if (is_null($output)) {
131 dol_syslog(
"AntiVir::dol_avscan_file Result return_var=".$return_var.
" output=".join(
',', $output));
133 $returncodevirus = 1;
134 if ($return_var == $returncodevirus) {
135 $this->errors = $output;
139 if ($return_var > 0) {
140 $this->errors = $output;
163 $bz2archivememlim = 0;
164 $maxfilesize = 10485760;
166 $command = $conf->global->MAIN_ANTIVIRUS_COMMAND;
167 $param = $conf->global->MAIN_ANTIVIRUS_PARAM;
169 $param = preg_replace(
'/%maxreclevel/', $maxreclevel, $param);
170 $param = preg_replace(
'/%maxfiles/', $maxfiles, $param);
171 $param = preg_replace(
'/%maxratio/', $maxratio, $param);
172 $param = preg_replace(
'/%bz2archivememlim/', $bz2archivememlim, $param);
173 $param = preg_replace(
'/%maxfilesize/', $maxfilesize, $param);
174 $param = preg_replace(
'/%file/', trim($file), $param);
176 if (!preg_match(
'/%file/', $conf->global->MAIN_ANTIVIRUS_PARAM)) {
177 $param = $param.
" ".escapeshellarg(trim($file));
180 if (preg_match(
"/\s/", $command)) {
181 $command = escapeshellarg($command);
184 $ret = $command.
' '.$param;
__construct($db)
Constructor.
dol_avscan_file($file)
Scan a file with antivirus.
getCliCommand($file)
Get full Command Line to run.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.