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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 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) 2015, 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. // load all apps to get all api routes properly setup
  43. OC_App::loadApps();
  44. // force language as given in the http request
  45. \OC_L10N::setLanguageFromRequest();
  46. OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo());
  47. } catch (ResourceNotFoundException $e) {
  48. OC_API::setContentType();
  49. OC_OCS::notFound();
  50. } catch (MethodNotAllowedException $e) {
  51. OC_API::setContentType();
  52. OC_Response::setStatus(405);
  53. } catch (\OC\OCS\Exception $ex) {
  54. OC_API::respond($ex->getResult(), OC_API::requestedFormat());
  55. }