1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Infected file report
|
|
|
19 |
*
|
|
|
20 |
* @package report_infectedfiles
|
|
|
21 |
* @author Nathan Nguyen <nathannguyen@catalyst-au.net>
|
|
|
22 |
* @copyright Catalyst IT
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
require(__DIR__.'/../../config.php');
|
|
|
27 |
require_once($CFG->libdir.'/adminlib.php');
|
|
|
28 |
use \core\antivirus\quarantine;
|
|
|
29 |
|
|
|
30 |
admin_externalpage_setup('reportinfectedfiles', '', null, '', array('pagelayout' => 'report'));
|
|
|
31 |
|
|
|
32 |
$action = optional_param('action', '', PARAM_TEXT);
|
|
|
33 |
// If action exists, we need to process the actions safely.
|
|
|
34 |
if (!empty($action)) {
|
|
|
35 |
// Nothing can be done without a valid sesskey.
|
|
|
36 |
require_sesskey();
|
|
|
37 |
// For any cancel actions, just reload the page clean.
|
|
|
38 |
$cancel = $PAGE->url;
|
|
|
39 |
|
|
|
40 |
// Decide on page action.
|
|
|
41 |
switch ($action) {
|
|
|
42 |
case 'download':
|
|
|
43 |
$fileid = required_param('file', PARAM_INT);
|
|
|
44 |
quarantine::download_quarantined_file($fileid);
|
|
|
45 |
break;
|
|
|
46 |
|
|
|
47 |
case 'downloadall':
|
|
|
48 |
quarantine::download_all_quarantined_files();
|
|
|
49 |
break;
|
|
|
50 |
|
|
|
51 |
case 'delete':
|
|
|
52 |
$fileid = required_param('file', PARAM_INT);
|
|
|
53 |
quarantine::delete_quarantined_file($fileid);
|
|
|
54 |
break;
|
|
|
55 |
|
|
|
56 |
case 'deleteall':
|
|
|
57 |
// Remove file until current time.
|
|
|
58 |
quarantine::clean_up_quarantine_folder(time());
|
|
|
59 |
break;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
// Reload page cleanly once actions are processed.
|
|
|
63 |
redirect($PAGE->url);
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
// Once actions are dealt with, display the page.
|
|
|
67 |
$page = optional_param('page', 0, PARAM_INT);
|
|
|
68 |
|
|
|
69 |
echo $OUTPUT->header();
|
|
|
70 |
echo $OUTPUT->heading(get_string('infectedfiles', 'report_infectedfiles'));
|
|
|
71 |
$table = new \report_infectedfiles\table\infectedfiles_table('report-infectedfiles-report-table', $PAGE->url, $page);
|
|
|
72 |
$table->define_baseurl($PAGE->url);
|
|
|
73 |
echo $PAGE->get_renderer('report_infectedfiles')->render($table);
|
|
|
74 |
echo $OUTPUT->footer();
|