These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
||
4 | * |
||
5 | * @author Jörn Friedrich Dreyer <[email protected]> |
||
6 | * @author Lukas Reschke <[email protected]> |
||
7 | * @author Morris Jobke <[email protected]> |
||
8 | * @author Robin Appelman <[email protected]> |
||
9 | * @author Thomas Müller <[email protected]> |
||
10 | * @author Vincent Petry <[email protected]> |
||
11 | * |
||
12 | * @license AGPL-3.0 |
||
13 | * |
||
14 | * This code is free software: you can redistribute it and/or modify |
||
15 | * it under the terms of the GNU Affero General Public License, version 3, |
||
16 | * as published by the Free Software Foundation. |
||
17 | * |
||
18 | * This program is distributed in the hope that it will be useful, |
||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
21 | * GNU Affero General Public License for more details. |
||
22 | * |
||
23 | * You should have received a copy of the GNU Affero General Public License, version 3, |
||
24 | * along with this program. If not, see <http://www.gnu.org/licenses/> |
||
25 | * |
||
26 | */ |
||
27 | |||
28 | // Show warning if a PHP version below 5.4.0 is used, this has to happen here |
||
29 | // because base.php will already use 5.4 syntax. |
||
30 | if (version_compare(PHP_VERSION, '5.4.0') === -1) { |
||
31 | echo 'This version of Nextcloud requires at least PHP 5.4.0<br/>'; |
||
32 | echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.'; |
||
33 | return; |
||
34 | } |
||
35 | |||
36 | // Show warning if PHP 7.1 is used as Nextcloud is not compatible with PHP 7.1 for now |
||
37 | // @see https://github.com/nextcloud/docker-ci/issues/10 |
||
38 | View Code Duplication | if (version_compare(PHP_VERSION, '7.1.0') !== -1) { |
|
0 ignored issues
–
show
|
|||
39 | echo 'This version of Nextcloud is not compatible with PHP 7.1.<br/>'; |
||
40 | echo 'You are currently running ' . PHP_VERSION . '.'; |
||
41 | return; |
||
42 | } |
||
43 | |||
44 | try { |
||
45 | |||
46 | require_once __DIR__ . '/lib/base.php'; |
||
47 | |||
48 | OC::handleRequest(); |
||
49 | |||
50 | } catch(\OC\ServiceUnavailableException $ex) { |
||
51 | \OC::$server->getLogger()->logException($ex, ['app' => 'index']); |
||
52 | |||
53 | //show the user a detailed error page |
||
54 | OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); |
||
55 | OC_Template::printExceptionErrorPage($ex); |
||
56 | } catch (\OC\HintException $ex) { |
||
57 | OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); |
||
58 | OC_Template::printErrorPage($ex->getMessage(), $ex->getHint()); |
||
59 | } catch (Exception $ex) { |
||
60 | \OC::$server->getLogger()->logException($ex, ['app' => 'index']); |
||
61 | |||
62 | //show the user a detailed error page |
||
63 | OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); |
||
64 | OC_Template::printExceptionErrorPage($ex); |
||
65 | } catch (Error $ex) { |
||
66 | \OC::$server->getLogger()->logException($ex, ['app' => 'index']); |
||
67 | OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); |
||
68 | OC_Template::printExceptionErrorPage($ex); |
||
69 | } |
||
70 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.