You are here

function clamav_scan in ClamAV 6

Same name and namespace in other branches
  1. 7 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

1 call to clamav_scan()
clamav_elements_file_validate in ./clamav.module
Form element validator for the file FAPI type.

File

./clamav.inc, line 15
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.'));
  }
}