25 error_reporting(E_ALL);
26 if ((php_sapi_name() !=
'cli')) trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
28 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
29 if (empty($SYSTEM_ROOT)) {
30 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
34 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
35 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
39 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
40 require_once(SQ_FUDGE_PATH.
'/general/file_system.inc');
41 require_once(SQ_FUDGE_PATH.
'/antivirus/antivirus.inc');
52 foreach ($report as $line_no => $line) {
54 if (preg_match(
'/FOUND/', $line)) {
55 list($file, $virus_info) = explode(
':', $line);
57 if (preg_match(
'/Infection/', $line)) {
58 list($file, $virus_info) = explode(
'Infection', $line);
60 if (strpos($file,
'->') !== FALSE) {
62 $file_parts = explode(
'->', $file);
63 $file = $file_parts[0];
67 if (preg_match(
'/^Infected/', $line)) {
68 list($info, $infected_files) = explode(
':', $line);
69 if (!empty($infected_files)) {
70 $virus_count = $infected_files;
77 if (is_file_versioning($file)) {
78 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
92 if ($count == $virus_count) {
93 echo
'Found '.$virus_count.
" Infected files\n";
95 echo
"An error occurred\n";
108 function is_file_versioning($real_file)
110 $ffv_dir = dirname($real_file).
'/.FFV';
111 if (!is_dir($ffv_dir))
return FALSE;
113 $ffv_file = $ffv_dir.
'/'.basename($real_file);
114 if (!is_file($ffv_file)) {