Usage
There are several ini options available, although all are set to the recommended defaults. All ini options are marked PHP_INI_SYSTEM to allow for easy shared hosting administration.Name
Default
Effect
clamav.db_path
no value
If this path is set then the module will attempt to preload the path as a ClamAV database at module startup. This will consume memory for every process and so is off by default. If you wanted to guarantee access to a ClamAV database then set this.
clamav.scan_file_uploads
0
If set to a value > 0, and if the clamav.db_path ini option is set and the database is successfully loaded, then files will be scanned during upload. If the scan produces malware, or an error occures then the uploaded file is deleted and the UPLOAD_ERR_EXTENSION error is added to the $_FILES entry. This option is only available for php >= 5.2
clamav.maxfiles
1000
The maximum number of files to scan in an archive.
clamav.maxfilesize
10485760
The maximum filesize of scanned files in bytes.
clamav.maxreclevel
5
The maximum recursion when scanning archives.
clamav.maxratio
200
The maximum compression ratio for scanned files.
This ini option is no longer provided in phplibclamav version 0.6.0 and higher. It remains documented for people running older clamav installations (which is not recommended).
clamav.archivememlimit
0
Memory limit for bzip2 archives. Use 0 for no limit.
mixed clamav_open_db([string path])
This functions opens a ClamAV database ready for scanning files. It must load the database in memory, and so should be called only when used. If you don‘t pass in a path, and you have set a clamav.db_path ini option, you will get that database (if loaded). You may pass in a directory to load all available databases in that directory. If you have previously loaded a directory of databases, say in your php.ini, and the databases change, then the database will automatically reload. In order to avoid the clamav engine startup time during script execution you should set the clamav.db_path ini option, so that the default db path is already loaded. The downside is then memory usage depending on SAPI. This function returns a resource or false on error.
mixed clamav_scan_file(resource db, string file)
This function scans a file for malware using the db previously opened. This function returns a string identifying the malware found, or false if the file is clean.
string clamav_default_db()
This function returns the built in path for ClamAV database files.
mixed clamav_scan_string(resource db, string string_to_scan)
This function is no longer provided in phplibclamav version 0.5.0 and higher. It remains documented for people running older clamav installations (which is not recommended).