query("SELECT id, detdir FROM detectionsdir WHERE id = 1");
$clamavdet = $detectresult->fetch_array();
$clamavreportdir = $clamavdet[1];
echo "ClamAV detections directory: " . $clamavreportdir . "";
?>
$lnvalue) {
if (strpos($lnvalue, "SCAN SUMMARY") !== false) {
$gosel = false;
}
if (trim($lnvalue) == '') { $gosel = false; }
if ($gosel) {
$lnsplit = explode(":", $lnvalue);
$lnsplitreminit = array_slice($lnsplit, 2);
$lnsplitrem = implode(":", $lnsplitreminit);
$lndircolor = $lnsplit[0] . ":" . $lnsplit[1];
$lndirsplit = explode("/", $lndircolor);
$lndirlast = end($lndirsplit);
reset($lndirsplit);
$lndirproc = array_pop($lndirsplit);
$lndirprocfin = implode("/", $lndirsplit);
$lncolored = "
" . $lndirprocfin . "/" . $lndirlast . " :" . $lnsplitrem;
$getdetmaillnarr[$p] = $lncolored;
$p++;
}
if (strpos($lnvalue, "---------------------------") !== false) {
$gosel = true;
}
}
$maildetlnbr = implode("
", $getdetmaillnarr);
}
} else { $mailfilecheck = false; }
// Search for the infected files lines in the Nextcloud scan report
if (is_file($nextdetectrep)) {
$nextfilecheck = true;
$readnextdetrep = file_get_contents($nextdetectrep);
$infectedfltxt = strstr($readnextdetrep, $targetstr);
$txtbreakln = explode("\n", $infectedfltxt);
$nbofinfectedinit = explode("Infected files: ", $txtbreakln[0]);
$nbinfctdflsnext = $nbofinfectedinit[1];
if ($nbinfctdflsnext != 0) {
$getdetnextlines = file($nextdetectrep);
$getdetnextlinesarr = array();
$goselnext = false;
$b = 0;
foreach ($getdetnextlines as $lnextkey => $lnextvalue) {
if (strpos($lnextvalue, "SCAN SUMMARY") !== false) {
$goselnext = false;
}
if (trim($lnextvalue) == '') { $goselnext = false; }
if ($goselnext) {
$lnextsplit = explode(":", $lnextvalue);
$lnextreminit = array_slice($lnextsplit, 1);
$lnextsplitrem = implode(":", $lnextreminit);
$lnextdirsplit = explode("/", $lnextsplit[0]);
$lnextend = end($lnextdirsplit);
reset($lnextdirsplit);
$lnextproc = array_pop($lnextdirsplit);
$lnextprocfin = implode("/", $lnextdirsplit);
$lnextcolored = "
" . $lnextprocfin . "/" . $lnextend . " :" . $lnextsplitrem;
$getdetnextlinesarr[$b] = $lnextcolored;
$b++;
}
if (strpos($lnextvalue, "---------------------------") !== false) {
$goselnext = true;
}
}
$nextdetlnbr = implode("
", $getdetnextlinesarr);
}
} else { $nextfilecheck = false; }
if ($mailfilecheck == false && $nextfilecheck == false) {
$clamdetfilesmissing = "
Error! The files containing the ClamAV antivirus detections weren't found ! Please verify that the detections directory
set up in 'Settings > Detections Directory' is correct and that the crontab jobs for ClamAV periodic scanning are correct.
";
} elseif ($mailfilecheck == false && $nextfilecheck == true) {
$clamdetfilesmissing = "
Error! The file containing the detections made by ClamAV in the '/var/vmail' directory wasn't found ! Please verify ClamAV
status and the crontab jobs for ClamAV periodic scanning.
";
} elseif ($mailfilecheck == true && $nextfilecheck == false) {
$clamdetfilesmissing = "
Error! The file containing the detections made by ClamAV in the '/var/www/cloud.example.com/data' directory wasn't
found ! Please verify ClamAV status and the crontab jobs for ClamAV periodic scanning.
";
} else $clamdetfilesmissing = "";
if (($maildetlnbr != "") && ($nextdetlnbr != "")) {
$clamavperiodicdetect = "
ClamAV antivirus has made the following detections by periodic scanning:
- Viruses detected in received emails directories (You should remove them manually):
" . $maildetlnbr . "
- Viruses detected in Nextcloud upload directories (You should remove them manually):
" . $nextdetlnbr . "
";
} elseif (($maildetlnbr != "") && ($nextdetlnbr == "")) {
$clamavperiodicdetect = "
ClamAV antivirus has made the following detections by periodic scanning:
- Viruses detected in received emails directories (You should remove them manually):
" . $maildetlnbr . "
" . $clamdetfilesmissing;
} elseif (($maildetlnbr == "") && ($nextdetlnbr != "")) {
$clamavperiodicdetect = "
ClamAV antivirus has made the following detections by periodic scanning:
- Viruses detected in Nextcloud upload directories (You should remove them manually):
" . $nextdetlnbr . "
" . $clamdetfilesmissing;
} elseif ((($maildetlnbr == "") && ($nextdetlnbr == "")) && ($mailfilecheck == true && $nextfilecheck == true)) {
$clamavperiodicdetect = "
ClamAV didn't detect any problems by periodic scanning !

";
} elseif ((($maildetlnbr == "") && ($nextdetlnbr == "")) && ($mailfilecheck == false && $nextfilecheck == false)) {
$clamavperiodicdetect = $clamdetfilesmissing;
} elseif ((($maildetlnbr == "") && ($nextdetlnbr == "")) && ($mailfilecheck == false && $nextfilecheck == true)) {
$clamavperiodicdetect = "
Error! The file containing the detections made by ClamAV in the '/var/vmail' directory wasn't found ! Please verify ClamAV
status and the crontab jobs for ClamAV periodic scanning.
";
} elseif ((($maildetlnbr == "") && ($nextdetlnbr == "")) && ($mailfilecheck == true && $nextfilecheck == false)) {
$clamavperiodicdetect = "
Error! The file containing the detections made by ClamAV in the '/var/www/cloud.example.com/data' directory wasn't
found ! Please verify ClamAV status and the crontab jobs for ClamAV periodic scanning.
";
}
echo $clamavperiodicdetect;
?>