public function validate(\Foundation\Form\Input $input) { $fileArr = $input->get($this->e->getName()); $retcode = cl_scanfile($fileArr['tmp_name'], $virusname); if ($retcode == CL_VIRUS) { unlink($fileArr['tmp_name']); $this->addError('Virus Detection Error: ' . cl_pretcode($retcode) . " {$virusname}."); return false; } return true; }
echo "<b>cl_version() return : </b>" . cl_version() . $br; /* Run cl_retcode() and return result for a CL_CLEAN and CL_VIRUS */ echo "<b>cl_pretcode(CL_CLEAN) return : </b>" . cl_pretcode(CL_CLEAN) . $br; echo "<b>cl_pretcode(CL_VIRUS) return : </b>" . cl_pretcode(CL_VIRUS) . $br; /* For future use */ //echo "<b>cl_engine_get_num(\"CL_ENGINE_MAX_SCANSIZE\") return : </b>".cl_engine_get_num("CL_ENGINE_MAX_SCANSIZE").$br; //echo "<b>cl_engine_get_num(\"CL_ENGINE_MAX_FILESIZE\") return : </b>".cl_engine_get_num("CL_ENGINE_MAX_FILESIZE").$br; //echo "<b>cl_engine_get_num(\"CL_ENGINE_MAX_RECURSION\") return : </b>".cl_engine_get_num("CL_ENGINE_MAX_RECURSION").$br; /* Start counter for bench execution time */ $time_start = microtime(true); /* Run cl_engine() for set the limits values on scan */ cl_engine(10000, 734003200, 734003200, 25, 0); /* Set max_execution_time to 120 second * Only if safe_mode is disabled */ ini_set('max_execution_time', 120); /* Run a cl_scanfile() and return the result into $retcode and the virus name if found in $virusname */ $retcode = cl_scanfile($file, $virusname); /* Restore max_execution_time value from php.ini */ ini_restore('max_execution_time'); /* Stop counter for bench execution time */ $time_end = microtime(true); $time = $time_end - $time_start; /* Check if a virus founded by scan */ if ($retcode == CL_VIRUS) { echo "<b>Execution time : </b>" . round($time, 2) . " seconds" . $br . "<b>File path : </b>" . $file . $br . "<b>Return code : </b>" . cl_pretcode($retcode) . $br . "<b>Virus found name : </b>" . $virusname . $br; } else { echo "<b>Execution time : </b>" . $time . " seconds" . $br . "<b>File path : </b>" . $file . $br . "<b>Return code : </b>" . cl_pretcode($retcode) . $br; } } else { echo "Module {$module} is not loaded into PHP"; }