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 |
* Admin tool "Opcache management" - CLI Script to reset opcache, part "web"
|
|
|
19 |
*
|
|
|
20 |
* @package tool_opcache
|
|
|
21 |
* @copyright 2019 Alexander Bias, Ulm University <alexander.bias@uni-ulm.de>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
// @codingStandardsIgnoreFile
|
|
|
26 |
// Let codechecker ignore this file because otherwise it would complain about a missing MOODLE_INTERNAL check or config.php
|
|
|
27 |
// inclusion which is really not needed.
|
|
|
28 |
|
|
|
29 |
require(__DIR__.'/../../../../config.php');
|
|
|
30 |
|
|
|
31 |
global $CFG, $PAGE;
|
|
|
32 |
|
|
|
33 |
// Die if resetting opcache is not actively enabled.
|
|
|
34 |
if (!isset($CFG->tool_opcache_reset_secretkey)) {
|
|
|
35 |
echo 1;
|
|
|
36 |
exit;
|
|
|
37 |
|
|
|
38 |
// And die if the submitted secret key is not correct.
|
|
|
39 |
} else if ($CFG->tool_opcache_reset_secretkey != clean_param($PAGE->url->get_param('secret'), PARAM_ALPHANUM)) {
|
|
|
40 |
echo 2;
|
|
|
41 |
exit;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
// Reset opcache.
|
|
|
45 |
$retval = opcache_reset();
|
|
|
46 |
|
|
|
47 |
// Echo exit status.
|
|
|
48 |
if ($retval == true) {
|
|
|
49 |
echo 0;
|
|
|
50 |
} else {
|
|
|
51 |
echo 255;
|
|
|
52 |
}
|