v1.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Frank Karlitschek <frank@owncloud.org>
  5. * @author Lukas Reschke <lukas@owncloud.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. * @author Tom Needham <tom@owncloud.com>
  9. * @author Vincent Petry <pvince81@owncloud.com>
  10. *
  11. * @copyright Copyright (c) 2015, ownCloud, Inc.
  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. require_once '../lib/base.php';
  28. if (\OCP\Util::needUpgrade()
  29. || \OC::$server->getSystemConfig()->getValue('maintenance', false)
  30. || \OC::$server->getSystemConfig()->getValue('singleuser', false)) {
  31. // since the behavior of apps or remotes are unpredictable during
  32. // an upgrade, return a 503 directly
  33. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  34. $response = new OC_OCS_Result(null, OC_Response::STATUS_SERVICE_UNAVAILABLE, 'Service unavailable');
  35. OC_API::respond($response, OC_API::requestedFormat());
  36. exit;
  37. }
  38. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  39. use Symfony\Component\Routing\Exception\MethodNotAllowedException;
  40. try {
  41. // load all apps to get all api routes properly setup
  42. OC_App::loadApps();
  43. // force language as given in the http request
  44. \OC_L10N::setLanguageFromRequest();
  45. OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo());
  46. } catch (ResourceNotFoundException $e) {
  47. OC_API::setContentType();
  48. OC_OCS::notFound();
  49. } catch (MethodNotAllowedException $e) {
  50. OC_API::setContentType();
  51. OC_Response::setStatus(405);
  52. }