v1.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Joas Schilling <nickvergessen@owncloud.com>
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <icewind@owncloud.com>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. * @author Tom Needham <tom@owncloud.com>
  10. * @author Vincent Petry <pvince81@owncloud.com>
  11. *
  12. * @copyright Copyright (c) 2016, ownCloud, Inc.
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. require_once '../lib/base.php';
  29. if (\OCP\Util::needUpgrade()
  30. || \OC::$server->getSystemConfig()->getValue('maintenance', false)
  31. || \OC::$server->getSystemConfig()->getValue('singleuser', false)) {
  32. // since the behavior of apps or remotes are unpredictable during
  33. // an upgrade, return a 503 directly
  34. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  35. $response = new OC_OCS_Result(null, OC_Response::STATUS_SERVICE_UNAVAILABLE, 'Service unavailable');
  36. OC_API::respond($response, OC_API::requestedFormat());
  37. exit;
  38. }
  39. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  40. use Symfony\Component\Routing\Exception\MethodNotAllowedException;
  41. try {
  42. OC_App::loadApps(['session']);
  43. OC_App::loadApps(['authentication']);
  44. // load all apps to get all api routes properly setup
  45. OC_App::loadApps();
  46. // force language as given in the http request
  47. \OC::$server->getL10NFactory()->setLanguageFromRequest();
  48. OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo());
  49. } catch (ResourceNotFoundException $e) {
  50. OC_API::setContentType();
  51. OC_OCS::notFound();
  52. } catch (MethodNotAllowedException $e) {
  53. OC_API::setContentType();
  54. OC_Response::setStatus(405);
  55. } catch (\OC\OCS\Exception $ex) {
  56. OC_API::respond($ex->getResult(), OC_API::requestedFormat());
  57. }