You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Georg Ehrke <oc.list@georgehrke.com>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Sergio Bertolín <sbertolin@solidgear.es>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. * @author Vincent Petry <pvince81@owncloud.com>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. // Show warning if a PHP version below 5.6.0 is used, this has to happen here
  31. // because base.php will already use 5.6 syntax.
  32. if (version_compare(PHP_VERSION, '5.6.0') === -1) {
  33. echo 'This version of Nextcloud requires at least PHP 5.6.0<br/>';
  34. echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.';
  35. return;
  36. }
  37. try {
  38. require_once __DIR__ . '/lib/base.php';
  39. OC::handleRequest();
  40. } catch(\OC\ServiceUnavailableException $ex) {
  41. \OC::$server->getLogger()->logException($ex, array('app' => 'index'));
  42. //show the user a detailed error page
  43. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  44. OC_Template::printExceptionErrorPage($ex);
  45. } catch (\OC\HintException $ex) {
  46. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  47. try {
  48. OC_Template::printErrorPage($ex->getMessage(), $ex->getHint());
  49. } catch (Exception $ex2) {
  50. \OC::$server->getLogger()->logException($ex, array('app' => 'index'));
  51. \OC::$server->getLogger()->logException($ex2, array('app' => 'index'));
  52. //show the user a detailed error page
  53. OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
  54. OC_Template::printExceptionErrorPage($ex);
  55. }
  56. } catch (\OC\User\LoginException $ex) {
  57. OC_Response::setStatus(OC_Response::STATUS_FORBIDDEN);
  58. OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage());
  59. } catch (Exception $ex) {
  60. \OC::$server->getLogger()->logException($ex, array('app' => 'index'));
  61. //show the user a detailed error page
  62. OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
  63. OC_Template::printExceptionErrorPage($ex);
  64. } catch (Error $ex) {
  65. try {
  66. \OC::$server->getLogger()->logException($ex, array('app' => 'index'));
  67. } catch (Error $e) {
  68. $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']);
  69. $validProtocols = [
  70. 'HTTP/1.0',
  71. 'HTTP/1.1',
  72. 'HTTP/2',
  73. ];
  74. $protocol = 'HTTP/1.1';
  75. if(in_array($claimedProtocol, $validProtocols, true)) {
  76. $protocol = $claimedProtocol;
  77. }
  78. header($protocol . ' 500 Internal Server Error');
  79. header('Content-Type: text/plain; charset=utf-8');
  80. print("Internal Server Error\n\n");
  81. print("The server encountered an internal error and was unable to complete your request.\n");
  82. print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
  83. print("More details can be found in the webserver log.\n");
  84. throw $e;
  85. }
  86. OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
  87. OC_Template::printExceptionErrorPage($ex);
  88. }