Sorry, got sidetracked on another issue. Our config looks good and the code (when called in a separate .php file can be made to work against clamscan and clamdscan).
We found the regex issue too. (Hacky fix for iterating at the bottom)
The problem is a default distro install of ClamAV will often (unless you're repackaging the engine frequently yourself) dump 13 lines of whining about your ClamAV engine being out of date.
A better solution would be to call clamdscan (since it's already running as a daemon) because it's much, much faster (.05 of a second vs 4 seconds) i.e:
Code:
pete@moodle:~$ time clamscan test2.txt
LibClamAV Warning: ***********************************************************
LibClamAV Warning: *** This version of the ClamAV engine is outdated. ***
LibClamAV Warning: *** DON'T PANIC! Read http://www.clamav.net/support/faq ***
<snip> LibClamAV Whining</snip>
LibClamAV Warning: ***********************************************************
test2.txt: Eicar-Test-Signature FOUND
----------- SCAN SUMMARY -----------
Known viruses: 1151693
Engine version: 0.96.5
Scanned directories: 0
Scanned files: 1
Infected files: 1
Data scanned: 0.00 MB
Data read: 0.00 MB (ratio 0.00:1)
Time: 4.936 sec (0 m 4 s)
real 0m4.965s
user 0m4.730s
sys 0m0.210s
vs
Code:
pete@moodle:~$ time clamdscan test2.txt
/home/pete/test2.txt: Eicar-Test-Signature FOUND
----------- SCAN SUMMARY -----------
Infected files: 1
Time: 0.000 sec (0 m 0 s)
real 0m0.004s
user 0m0.010s
sys 0m0.000s
Hacky fix that properly iterates, but needs some TLC and debug code removed
Code:
function ClamAV ($file)
{
$out = preg_split('/\n/',`clamscan $file`);
error_log("Starting - Scanning file:".$file, 0);
error_log("Starting - Preg Split result:".$out[0], 0);
if (preg_match('/FOUND/s', $out[0], $regs)) {
$this->status = 'VIRUS: '.$regs[0];
error_log("Found Virus!", 0);
return true;
} else {
error_log("No Virus Found.", 0);
return false;
}
}