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.

owncloud.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @author Morris Jobke <hey@morrisjobke.de>
  4. * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
  5. * @author Vincent Petry <pvince81@owncloud.com>
  6. *
  7. * @copyright Copyright (c) 2015, ownCloud, Inc.
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OC\Files\Storage;
  24. /**
  25. * ownCloud backend for external storage based on DAV backend.
  26. *
  27. * The ownCloud URL consists of three parts:
  28. * http://%host/%context/remote.php/webdav/%root
  29. *
  30. */
  31. class OwnCloud extends \OC\Files\Storage\DAV{
  32. const OC_URL_SUFFIX = 'remote.php/webdav';
  33. public function __construct($params) {
  34. // extract context path from host if specified
  35. // (owncloud install path on host)
  36. $host = $params['host'];
  37. // strip protocol
  38. if (substr($host, 0, 8) == "https://") {
  39. $host = substr($host, 8);
  40. $params['secure'] = true;
  41. } else if (substr($host, 0, 7) == "http://") {
  42. $host = substr($host, 7);
  43. $params['secure'] = false;
  44. }
  45. $contextPath = '';
  46. $hostSlashPos = strpos($host, '/');
  47. if ($hostSlashPos !== false){
  48. $contextPath = substr($host, $hostSlashPos);
  49. $host = substr($host, 0, $hostSlashPos);
  50. }
  51. if (substr($contextPath, -1) !== '/'){
  52. $contextPath .= '/';
  53. }
  54. if (isset($params['root'])){
  55. $root = $params['root'];
  56. if (substr($root, 0, 1) !== '/'){
  57. $root = '/' . $root;
  58. }
  59. }
  60. else{
  61. $root = '/';
  62. }
  63. $params['host'] = $host;
  64. $params['root'] = $contextPath . self::OC_URL_SUFFIX . $root;
  65. parent::__construct($params);
  66. }
  67. }