Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 35 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| tao_install_checks_AllowOverride | |
0.00% |
0 / 35 |
|
0.00% |
0 / 1 |
42 | |
0.00% |
0 / 1 |
| check | |
0.00% |
0 / 35 |
|
0.00% |
0 / 1 |
42 | |||
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program 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 this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
| 19 | * (under the project TAO & TAO2); |
| 20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
| 21 | * (under the project TAO-TRANSFER); |
| 22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 23 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | class tao_install_checks_AllowOverride extends common_configuration_Component |
| 28 | { |
| 29 | public function check() |
| 30 | { |
| 31 | $report = null; |
| 32 | |
| 33 | if (php_sapi_name() === 'cli') { |
| 34 | // @todo find a way to detect this in CLI. |
| 35 | return new common_configuration_Report( |
| 36 | common_configuration_Report::VALID, |
| 37 | 'The AllowOverride directive cannot be checked in CLI mode.', |
| 38 | $this |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | $server = |
| 43 | ((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") ? 'https' : 'http') |
| 44 | . "://" . $_SERVER['SERVER_NAME'] |
| 45 | . (($_SERVER["SERVER_PORT"] != "80") ? ":" . $_SERVER["SERVER_PORT"] : ''); |
| 46 | |
| 47 | $request = $_SERVER["REQUEST_URI"]; |
| 48 | $request = substr($request, 0, strpos($request, '?')); |
| 49 | $request = substr($request, 0, strrpos($request, '/')); |
| 50 | |
| 51 | $url = $server . $request . '/checks/testAllowOverride/noneOrAll/'; |
| 52 | |
| 53 | $ch = curl_init($url); |
| 54 | curl_setopt($ch, CURLOPT_HEADER, true); |
| 55 | curl_setopt($ch, CURLOPT_NOBODY, true); |
| 56 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 57 | curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
| 58 | $output = curl_exec($ch); |
| 59 | $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 60 | curl_close($ch); |
| 61 | |
| 62 | if ($httpcode == '403') { |
| 63 | $report = new common_configuration_Report( |
| 64 | common_configuration_Report::VALID, |
| 65 | 'The AllowOverride directive is set to All.', |
| 66 | $this |
| 67 | ); |
| 68 | } else { |
| 69 | $report = new common_configuration_Report( |
| 70 | common_configuration_Report::INVALID, |
| 71 | 'The AllowOverride directive may not be set to All.', |
| 72 | $this |
| 73 | ); |
| 74 | } |
| 75 | |
| 76 | return $report; |
| 77 | } |
| 78 | } |