v1.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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() || \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
  29. // since the behavior of apps or remotes are unpredictable during
  30. // an upgrade, return a 503 directly
  31. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  32. $response = new OC_OCS_Result(null, OC_Response::STATUS_SERVICE_UNAVAILABLE, 'Service unavailable');
  33. OC_API::respond($response, OC_API::requestedFormat());
  34. exit;
  35. }
  36. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  37. use Symfony\Component\Routing\Exception\MethodNotAllowedException;
  38. try {
  39. // load all apps to get all api routes properly setup
  40. OC_App::loadApps();
  41. // force language as given in the http request
  42. \OC_L10N::setLanguageFromRequest();
  43. OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo());
  44. } catch (ResourceNotFoundException $e) {
  45. OC_API::setContentType();
  46. OC_OCS::notFound();
  47. } catch (MethodNotAllowedException $e) {
  48. OC_API::setContentType();
  49. OC_Response::setStatus(405);
  50. }