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 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @author Jakob Sack
  7. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  8. * @copyright 2011 Jakob Sack kde@jakobsack.de
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  12. * License as published by the Free Software Foundation; either
  13. * version 3 of the License, or any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public
  21. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. // Backends
  25. $authBackend = new OC_Connector_Sabre_Auth();
  26. $lockBackend = new OC_Connector_Sabre_Locks();
  27. $requestBackend = new OC_Connector_Sabre_Request();
  28. // Fire up server
  29. $objectTree = new \OC\Connector\Sabre\ObjectTree();
  30. $server = new OC_Connector_Sabre_Server($objectTree);
  31. $server->httpRequest = $requestBackend;
  32. $server->setBaseUri($baseuri);
  33. // Load plugins
  34. $defaults = new OC_Defaults();
  35. $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, $defaults->getName()));
  36. $server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend));
  37. $server->addPlugin(new Sabre_DAV_Browser_Plugin(false));
  38. $server->addPlugin(new OC_Connector_Sabre_FilesPlugin());
  39. $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin());
  40. $server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav'));
  41. // wait with registering these until auth is handled and the filesystem is setup
  42. $server->subscribeEvent('beforeMethod', function () use ($server, $objectTree) {
  43. $view = \OC\Files\Filesystem::getView();
  44. $rootInfo = $view->getFileInfo('');
  45. // Create ownCloud Dir
  46. $rootDir = new OC_Connector_Sabre_Directory($view, $rootInfo);
  47. $objectTree->init($rootDir, $view);
  48. $server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin($view));
  49. $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view));
  50. }, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
  51. // And off we go!
  52. $server->exec();