You are here

function clamav_scan in ClamAV 7

Same name and namespace in other branches
  1. 6 clamav.inc \clamav_scan()

Scan a file and raise an error on the form element (if required).

Parameters

String $filepath Path to the file to test:

String $form_element The form element to set an error on.: E.g. foo E.g. foo][bar][baz

File

./clamav.inc, line 15
clamav.inc API and helper functions for the ClamAV module.

Code

function clamav_scan($filepath, $form_element) {
  $result = clamav_scan_file($filepath);
  if ($result == CLAMAV_SCANRESULT_INFECTED) {
    form_set_error($form_element, t('A virus has been detected in the file.  The file will not be accepted.'));
  }
  elseif ($result == CLAMAV_SCANRESULT_UNCHECKED && variable_get('clamav_unchecked_files', CLAMAV_DEFAULT_UNCHECKED) == CLAMAV_BLOCK_UNCHECKED) {
    form_set_error($form_element, t('The anti-virus scanner was not able to check the file.  The file cannot be uploaded.'));
  }
}