<?php $app = new \OCA\Files_Antivirus\AppInfo\Application(); $ruleMapper = $app->getContainer()->query('RuleMapper'); $rules = $ruleMapper->findAll(); if (!count($rules)) { $ruleMapper->populate(); } \OC::$server->getConfig()->setAppValue('files_antivirus', 'av_path', '/usr/bin/clamscan'); \OC::$server->getJobList()->add('OCA\\Files_Antivirus\\Cron\\Task');
/** * Action to take if this item is infected * @param Status $status * @param boolean $isBackground */ public function processInfected(Status $status, $isBackground) { $application = new \OCA\Files_Antivirus\AppInfo\Application(); $appConfig = $application->getContainer()->query('AppConfig'); $infectedAction = $appConfig->getAvInfectedAction(); $shouldDelete = !$isBackground || $isBackground && $infectedAction === 'delete'; $message = $shouldDelete ? Activity::MESSAGE_FILE_DELETED : ''; \OC::$server->getActivityManager()->publishActivity('files_antivirus', Activity::SUBJECT_VIRUS_DETECTED, array($this->path, $status->getDetails()), $message, array(), $this->path, '', $this->view->getOwner($this->path), Activity::TYPE_VIRUS_DETECTED, Activity::PRIORITY_HIGH); if ($isBackground) { if ($shouldDelete) { $this->logError('Infected file deleted. ' . $status->getDetails()); $this->view->unlink($this->path); } else { $this->logError('File is infected. ' . $status->getDetails()); } } else { $this->logError('Virus(es) found: ' . $status->getDetails()); //remove file $this->view->unlink($this->path); Notification::sendMail($this->path); $message = $this->l10n->t("Virus detected! Can't upload the file %s", array(basename($this->path))); \OCP\JSON::error(array("data" => array("message" => $message))); exit; } }