This is a quick how-to if you are looking to add a clamav function in php.

This has been tested with PHP 5.0.4 on RHEL ES3 running ensim 4.0.3-22 with clamav 0.87.1.

This is an easy how-to, but recommended you backup your files before you continue. If you read on, you agree to install at your own risk.

First I recommend you upgrade clamav to the lastest version (RUN: freshclam to make sure clamav is current).

The reason I installed this function is to add clamav scan to attachment uploads in vBulletin and Squirrelmail. I am writing plugins for both software titles which I will release at a later time.

Anyways, here we go.

The latest clamav software can be found at dag.wieers.com.

You will also need php-devel and clamav-devel.

To check for the software, use the commands below:

CODE
rpm -q php-devel


CODE
rpm -q clamav-devel


If nothing is returned from either rpm command, you will need to install the devel for the appropriate version.

If you have both of those rpms installed, do the following:

wget http://www.phpclamavlib.org/download/sourc...ib-0.12a.tar.gz

CODE
tar xvzf php-clamavlib-0.12a.tar.gz

CODE
cd php-clamav-0.1

CODE
phpize

CODE
./configure --with-clamav

CODE
make

CODE
cp modules/clamav.so /usr/lib/php/modules

Note: /usr/lib/php/modules is my modules directory. Your module directory may be different. Search /etc/php.ini for extension_dir to get yours.

Edit /etc/php.ini (Make sure you make a backup!)
Add the following under the "Dynamic Extensions" section:

CODE
extension=clamav.so



[clamav]

clamav.dbpath="/var/clamav"

clamav.maxreclevel=0

clamav.maxfiles=0

clamav.archivememlim=0

clamav.maxfilesize=0

clamav.maxratio=0

Note: My clamav.dbpath may be different than yours. Do a simple locate main.cvd for the db directory.

Test to see if it works:
[PHP] echo cl_info() . "
";

$file = "/tmp/eicar.com";
cl_scanfile_ex($file, CL_SCAN_STDOPT, $virus, $retcode);
if ($retcode == CL_VIRUS)
echo $file . " returns: " . cl_pretcode($retcode) . " virus name: " . $virus . "
";
else
echo $file . " returns: " . cl_pretcode($retcode) . "
";
?>[/PHP]

Go to http://www.phpclamavlib.org/ for more information on the functions included with this module.

Good luck!