File size: 2.07Kb
<?PHP
$sth = pdo()->query('SELECT * FROM `messages__files` WHERE `verified` IS NULL');
if($sth->rowCount()) {
$scanReader = new scanReader;
while($file = $sth->fetch(PDO::FETCH_OBJ)) {
switch($file->type) {
/* Scan Word */
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
case 'application/msword':
$Result = $scanReader->Word($_SERVER['DOCUMENT_ROOT'] . $file->path);
$ath = pdo()->prepare('UPDATE `messages__files` SET `verified`=:verified WHERE `id`=:fileid LIMIT 1');
$ath->execute([
':verified' => (!$Result) ? '1' : $Result,
':fileid' => $file->id
]);
break;
/* Scan Excel */
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
case 'application/vnd.ms-excel':
$Result = $scanReader->Excel($_SERVER['DOCUMENT_ROOT'] . $file->path);
$ath = pdo()->prepare('UPDATE `messages__files` SET `verified`=:verified WHERE `id`=:fileid LIMIT 1');
$ath->execute([
':verified' => (!$Result) ? '1' : $Result,
':fileid' => $file->id
]);
break;
/* Scan pdf */
case 'application/pdf':
$Result = $scanReader->Pdf($_SERVER['DOCUMENT_ROOT'] . $file->path);
$ath = pdo()->prepare('UPDATE `messages__files` SET `verified`=:verified WHERE `id`=:fileid LIMIT 1');
$ath->execute([
':verified' => (!$Result) ? '1' : $Result,
':fileid' => $file->id
]);
break;
/* Scan text */
case 'text/plain':
$Result = $scanReader->Txt($_SERVER['DOCUMENT_ROOT'] . $file->path);
$ath = pdo()->prepare('UPDATE `messages__files` SET `verified`=:verified WHERE `id`=:fileid LIMIT 1');
$ath->execute([
':verified' => (!$Result) ? '1' : $Result,
':fileid' => $file->id
]);
break;
default: {
$ath = pdo()->prepare('UPDATE `messages__files` SET `verified`=:verified WHERE `id`=:fileid LIMIT 1');
$ath->execute([
':verified' => '2',
':fileid' => $file->id
]);
}
}
}
}