function clamav_scan_file in ClamAV 7
Same name and namespace in other branches
- 6 clamav.inc \clamav_scan_file()
Scan a single file
Parameters
String $filepath: Full filepath to the file which is to be scanned. This must be a file which is readable by the web server.
optional String $filename: Filename of the uploaded file. This is used to log the original name of the uploaded file ($filepath will typically be a random string generated by PHP). Defaults to $filepath if not provided.
Return value
int one of:
2 calls to clamav_scan_file()
- clamav_file_validate in ./
clamav.module - Implements hook_file_validate().
- clamav_scan in ./
clamav.inc - Scan a file and raise an error on the form element (if required).
File
- ./
clamav.inc, line 43 - clamav.inc API and helper functions for the ClamAV module.
Code
function clamav_scan_file($filepath, $filename = NULL) {
if (is_null($filename)) {
// Use the filepath to provide a default for the filename.
$filename = basename($filepath);
}
else {
// Ensure that the filename doesn't include the path.
$filename = basename($filename);
}
switch (variable_get('clamav_mode', CLAMAV_DEFAULT_MODE)) {
case CLAMAV_USE_DAEMON:
return _clamav_scan_via_daemon($filepath, $filename);
case CLAMAV_USE_EXECUTABLE:
return _clamav_scan_via_exec($filepath, $filename);
case CLAMAV_USE_DAEMON_UNIX_SOCKET:
return _clamav_scan_via_unix_socket($filepath, $filename);
default:
watchdog('ClamAV', 'Unrecognised configuration.', array(), WATCHDOG_ERROR);
return CLAMAV_SCANRESULT_UNCHECKED;
}
}