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.

remote.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Frank Karlitschek <frank@owncloud.org>
  5. * @author Jakob Sack <mail@jakobsack.de>
  6. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  7. * @author Lukas Reschke <lukas@owncloud.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <icewind@owncloud.com>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. * @author Vincent Petry <pvince81@owncloud.com>
  12. *
  13. * @copyright Copyright (c) 2015, ownCloud, Inc.
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. // Backends
  30. $authBackend = new \OC\Connector\Sabre\Auth();
  31. // Fire up server
  32. $objectTree = new \OC\Connector\Sabre\ObjectTree();
  33. $server = new \OC\Connector\Sabre\Server($objectTree);
  34. // Set URL explicitly due to reverse-proxy situations
  35. $server->httpRequest->setUrl(\OC::$server->getRequest()->getRequestUri());
  36. $server->setBaseUri($baseuri);
  37. // Load plugins
  38. $defaults = new OC_Defaults();
  39. $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
  40. // FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
  41. $server->addPlugin(new \OC\Connector\Sabre\DummyGetResponsePlugin());
  42. $server->addPlugin(new \OC\Connector\Sabre\FilesPlugin($objectTree));
  43. $server->addPlugin(new \OC\Connector\Sabre\MaintenancePlugin());
  44. $server->addPlugin(new \OC\Connector\Sabre\ExceptionLoggerPlugin('webdav', \OC::$server->getLogger()));
  45. // wait with registering these until auth is handled and the filesystem is setup
  46. $server->on('beforeMethod', function () use ($server, $objectTree) {
  47. $view = \OC\Files\Filesystem::getView();
  48. $rootInfo = $view->getFileInfo('');
  49. // Create ownCloud Dir
  50. $mountManager = \OC\Files\Filesystem::getMountManager();
  51. $rootDir = new \OC\Connector\Sabre\Directory($view, $rootInfo);
  52. $objectTree->init($rootDir, $view, $mountManager);
  53. $server->addPlugin(new \OC\Connector\Sabre\TagsPlugin($objectTree, \OC::$server->getTagManager()));
  54. $server->addPlugin(new \OC\Connector\Sabre\QuotaPlugin($view));
  55. // custom properties plugin must be the last one
  56. $server->addPlugin(
  57. new \Sabre\DAV\PropertyStorage\Plugin(
  58. new \OC\Connector\Sabre\CustomPropertiesBackend(
  59. $objectTree,
  60. \OC::$server->getDatabaseConnection(),
  61. \OC::$server->getUserSession()->getUser()
  62. )
  63. )
  64. );
  65. }, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
  66. // And off we go!
  67. $server->exec();