forked from kissit/php-clamav-scan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
31 lines (27 loc) · 970 Bytes
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// A simple test file for php-clamav-scan library
require 'Clamav.php';
// Directory where test files will be written
$test_dir = '/tmp';
// EICAR is a test string for AV scanners: https://en.wikipedia.org/wiki/EICAR_test_file
$bad_test = 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*';
$good_test = 'This is a safe string!';
$clamav = new Clamav();
if(file_put_contents("$test_dir/clamav_test.txt", $good_test)) {
echo "Testing a good file...\n";
if($clamav->scan("$test_dir/clamav_test.txt")) {
echo "YAY, file is safe!\n";
} else {
echo "BOO, file is a virus!\n";
}
unlink("$test_dir/clamav_test.txt");
}
if(file_put_contents("$test_dir/clamav_test.txt", $bad_test)) {
echo "Testing a bad file...\n";
if($clamav->scan("$test_dir/clamav_test.txt")) {
echo "YAY, file is safe!\n";
} else {
echo "BOO, file is a virus!\n";
}
unlink("$test_dir/clamav_test.txt");
}