webdav.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@owncloud.com>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. // no php execution timeout for webdav
  26. set_time_limit(0);
  27. // Turn off output buffering to prevent memory problems
  28. \OC_Util::obEnd();
  29. $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
  30. \OC::$server->getConfig(),
  31. \OC::$server->getLogger(),
  32. \OC::$server->getDatabaseConnection(),
  33. \OC::$server->getUserSession(),
  34. \OC::$server->getMountManager(),
  35. \OC::$server->getTagManager(),
  36. \OC::$server->getRequest(),
  37. \OC::$server->getPreviewManager()
  38. );
  39. // Backends
  40. $authBackend = new \OCA\DAV\Connector\Sabre\Auth(
  41. \OC::$server->getSession(),
  42. \OC::$server->getUserSession(),
  43. \OC::$server->getRequest(),
  44. \OC::$server->getTwoFactorAuthManager(),
  45. \OC::$server->getBruteForceThrottler(),
  46. 'principals/'
  47. );
  48. $requestUri = \OC::$server->getRequest()->getRequestUri();
  49. $server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function() {
  50. // use the view for the logged in user
  51. return \OC\Files\Filesystem::getView();
  52. });
  53. // And off we go!
  54. $server->exec();