1
0

remote.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. // no php execution timeout for webdav
  30. set_time_limit(0);
  31. // Backends
  32. $authBackend = new \OC\Connector\Sabre\Auth();
  33. // Fire up server
  34. $objectTree = new \OC\Connector\Sabre\ObjectTree();
  35. $server = new \OC\Connector\Sabre\Server($objectTree);
  36. // Set URL explicitly due to reverse-proxy situations
  37. $server->httpRequest->setUrl(\OC::$server->getRequest()->getRequestUri());
  38. $server->setBaseUri($baseuri);
  39. // Load plugins
  40. $defaults = new OC_Defaults();
  41. $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
  42. // FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
  43. $server->addPlugin(new \OC\Connector\Sabre\DummyGetResponsePlugin());
  44. $server->addPlugin(new \OC\Connector\Sabre\FilesPlugin($objectTree));
  45. $server->addPlugin(new \OC\Connector\Sabre\MaintenancePlugin());
  46. $server->addPlugin(new \OC\Connector\Sabre\ExceptionLoggerPlugin('webdav', \OC::$server->getLogger()));
  47. // wait with registering these until auth is handled and the filesystem is setup
  48. $server->on('beforeMethod', function () use ($server, $objectTree) {
  49. $view = \OC\Files\Filesystem::getView();
  50. $rootInfo = $view->getFileInfo('');
  51. // Create ownCloud Dir
  52. $mountManager = \OC\Files\Filesystem::getMountManager();
  53. $rootDir = new \OC\Connector\Sabre\Directory($view, $rootInfo);
  54. $objectTree->init($rootDir, $view, $mountManager);
  55. $server->addPlugin(new \OC\Connector\Sabre\TagsPlugin($objectTree, \OC::$server->getTagManager()));
  56. $server->addPlugin(new \OC\Connector\Sabre\QuotaPlugin($view));
  57. // custom properties plugin must be the last one
  58. $server->addPlugin(
  59. new \Sabre\DAV\PropertyStorage\Plugin(
  60. new \OC\Connector\Sabre\CustomPropertiesBackend(
  61. $objectTree,
  62. \OC::$server->getDatabaseConnection(),
  63. \OC::$server->getUserSession()->getUser()
  64. )
  65. )
  66. );
  67. $server->addPlugin(new \OC\Connector\Sabre\CopyEtagHeaderPlugin());
  68. }, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
  69. // And off we go!
  70. $server->exec();