[openupload-devel] Virus checker
Status: Beta
Brought to you by:
tsdogs
|
From: Eric K. <ek...@tr...> - 2011-06-02 21:16:00
|
I implemented a basic virus checker. The code is pasted below:
<?php
/* Virus check implemented by Eric Kelly */
class virusCheckPlugin extends OpenUploadPlugin {
function virusScan($files) {
$virus = false;
$msg = '';
foreach ($files as $file) {
$retcode = cl_scanfile($file['tmp'], $virusname);
if($retcode == CL_VIRUS) {
$virus = true;
if(empty($msg)) {
$msg = 'Virus found! File(s): ' . $file['name'];
} else {
$msg = $msg . ', ' . $file['name'];
}
unset($retcode);
unset($virusname);
}
}
if ($virus) {
app()->log('warning','uploadOptions','','DENY',$msg);
app()->error(tr($msg));
}
return $virus;
}
function virusCheckPlugin() {
$this->description = tr('Scans all uploaded files for viruses');
}
function uploadOptions(&$finfo, $acl) {
$this->loadConfig();
if ($acl == 'enable') {
return !($this->virusScan($finfo));
} else {
return true;
}
}
}
?>
And yes, I do know there is another plugin submitted... but I didn't notice that before I wrote this.
-Eric
P.S. Also, how would I gain access to the openupload-devel mailing list? I'd like to contribute more.
|