From 8480b9bb4eb6e7f737c9afc2e3209ddd0df73f48 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 2 Jul 2015 15:44:04 +0000 Subject: [PATCH] fixed --- composer.json | 3 +- composer.lock | 267 +++++++++++++++++++++++++++++++++++++++++++++++--- sabredav.php | 105 ++++++++++++++++++++ 3 files changed, 361 insertions(+), 14 deletions(-) create mode 100644 sabredav.php diff --git a/composer.json b/composer.json index 094a4dedfc..856837a145 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "pear-pear.horde.org/Horde_Mapi": ">=1.0.0", "pear-pear.php.net/XML_Feed_Parser": "*", "pear-pear.php.net/Log": "*", - "pear-pear.php.net/Text_Diff": "*" + "pear-pear.php.net/Text_Diff": "*", + "sabre/dav": "~2.1.2" } } diff --git a/composer.lock b/composer.lock index e47abc83cc..bbd7a80e9d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "21eef0e85f0c15237feb09a236c221f8", + "hash": "1ca4cae9136d32583c7a1d05ccfe706b", "packages": [ { "name": "pear-pear.horde.org/Horde_Compress", @@ -157,10 +157,10 @@ }, { "name": "pear-pear.horde.org/Horde_Idna", - "version": "1.0.1", + "version": "1.0.2", "dist": { "type": "file", - "url": "http://pear.horde.org/get/Horde_Idna-1.0.1.tgz", + "url": "http://pear.horde.org/get/Horde_Idna-1.0.2.tgz", "reference": null, "shasum": null }, @@ -169,7 +169,7 @@ "php": "<6.0.0.0" }, "replace": { - "pear-horde/horde_idna": "== 1.0.1.0" + "pear-horde/horde_idna": "== 1.0.2.0" }, "type": "pear-library", "autoload": { @@ -180,6 +180,9 @@ "include-path": [ "/" ], + "license": [ + "BSD-2-Clause" + ], "description": "Normalized access to various backends providing IDNA (Internationalized Domain Names in Applications) support." }, { @@ -311,10 +314,10 @@ }, { "name": "pear-pear.horde.org/Horde_Mime", - "version": "2.8.0", + "version": "2.8.1", "dist": { "type": "file", - "url": "http://pear.horde.org/get/Horde_Mime-2.8.0.tgz", + "url": "http://pear.horde.org/get/Horde_Mime-2.8.1.tgz", "reference": null, "shasum": null }, @@ -331,7 +334,7 @@ "php": "<6.0.0.0" }, "replace": { - "pear-horde/horde_mime": "== 2.8.0.0" + "pear-horde/horde_mime": "== 2.8.1.0" }, "type": "pear-library", "autoload": { @@ -634,10 +637,10 @@ }, { "name": "pear-pear.horde.org/Horde_Util", - "version": "2.5.4", + "version": "2.5.5", "dist": { "type": "file", - "url": "http://pear.horde.org/get/Horde_Util-2.5.4.tgz", + "url": "http://pear.horde.org/get/Horde_Util-2.5.5.tgz", "reference": null, "shasum": null }, @@ -646,7 +649,7 @@ "php": "<6.0.0.0" }, "replace": { - "pear-horde/horde_util": "== 2.5.4.0" + "pear-horde/horde_util": "== 2.5.5.0" }, "type": "pear-library", "autoload": { @@ -664,10 +667,10 @@ }, { "name": "pear-pear.php.net/Archive_Tar", - "version": "1.3.15", + "version": "1.3.16", "dist": { "type": "file", - "url": "http://pear.php.net/get/Archive_Tar-1.3.15.tgz", + "url": "http://pear.php.net/get/Archive_Tar-1.3.16.tgz", "reference": null, "shasum": null }, @@ -675,7 +678,7 @@ "php": ">=4.3.0.0" }, "replace": { - "pear-pear/archive_tar": "== 1.3.15.0" + "pear-pear/archive_tar": "== 1.3.16.0" }, "type": "pear-library", "autoload": { @@ -960,6 +963,244 @@ "BSD License" ], "description": "Selection of methods that are often needed when working with XML documents. Functionality includes creating of attribute lists from arrays, creation of tags, validation of XML names and more." + }, + { + "name": "sabre/dav", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/fruux/sabre-dav.git", + "reference": "6a8aec204688d36681e0185fbaf1974b97e4a070" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fruux/sabre-dav/zipball/6a8aec204688d36681e0185fbaf1974b97e4a070", + "reference": "6a8aec204688d36681e0185fbaf1974b97e4a070", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-date": "*", + "ext-dom": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-pcre": "*", + "ext-simplexml": "*", + "ext-spl": "*", + "php": ">=5.4.1", + "sabre/event": "~2.0.0", + "sabre/http": "~3.0.0", + "sabre/vobject": "~3.3" + }, + "require-dev": { + "evert/phpdoc-md": "~0.1.0", + "phpunit/phpunit": "~4.2", + "squizlabs/php_codesniffer": "~1.5.3" + }, + "suggest": { + "ext-curl": "*", + "ext-pdo": "*" + }, + "bin": [ + "bin/sabredav", + "bin/naturalselection" + ], + "type": "library", + "autoload": { + "psr-4": { + "Sabre\\DAV\\": "lib/DAV/", + "Sabre\\DAVACL\\": "lib/DAVACL/", + "Sabre\\CalDAV\\": "lib/CalDAV/", + "Sabre\\CardDAV\\": "lib/CardDAV/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "WebDAV Framework for PHP", + "homepage": "http://sabre.io/", + "keywords": [ + "CalDAV", + "CardDAV", + "WebDAV", + "framework", + "iCalendar" + ], + "time": "2015-02-25 18:13:20" + }, + { + "name": "sabre/event", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/fruux/sabre-event.git", + "reference": "f33d60742d7dff63d3722d0f70016704bf32e8db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fruux/sabre-event/zipball/f33d60742d7dff63d3722d0f70016704bf32e8db", + "reference": "f33d60742d7dff63d3722d0f70016704bf32e8db", + "shasum": "" + }, + "require": { + "php": ">=5.4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Sabre\\Event\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "sabre/event is a library for lightweight event-based programming", + "homepage": "http://sabre.io/event/", + "keywords": [ + "EventEmitter", + "events", + "hooks", + "plugin", + "promise", + "signal" + ], + "time": "2014-10-06 23:26:48" + }, + { + "name": "sabre/http", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/fruux/sabre-http.git", + "reference": "efae5aa7155ba73aa517e33c20aba9c001bb6588" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fruux/sabre-http/zipball/efae5aa7155ba73aa517e33c20aba9c001bb6588", + "reference": "efae5aa7155ba73aa517e33c20aba9c001bb6588", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.4", + "sabre/event": ">=1.0.0,<3.0.0" + }, + "require-dev": { + "phpunit/phpunit": "*", + "squizlabs/php_codesniffer": "~1.5.3" + }, + "suggest": { + "ext-curl": " to make http requests with the Client class" + }, + "type": "library", + "autoload": { + "psr-4": { + "Sabre\\HTTP\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "The sabre/http library provides utilities for dealing with http requests and responses. ", + "homepage": "https://github.com/fruux/sabre-http", + "keywords": [ + "http" + ], + "time": "2014-12-10 20:14:39" + }, + { + "name": "sabre/vobject", + "version": "3.4.2", + "source": { + "type": "git", + "url": "https://github.com/fruux/sabre-vobject.git", + "reference": "0c90f60dae40137f1903c7b5915d3691c4fc99b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fruux/sabre-vobject/zipball/0c90f60dae40137f1903c7b5915d3691c4fc99b0", + "reference": "0c90f60dae40137f1903c7b5915d3691c4fc99b0", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.3.1" + }, + "require-dev": { + "phpunit/phpunit": "*", + "squizlabs/php_codesniffer": "*" + }, + "bin": [ + "bin/vobject", + "bin/generate_vcards" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sabre\\VObject\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Dominik Tobschall", + "email": "dominik@fruux.com", + "homepage": "http://tobschall.de/", + "role": "Developer" + } + ], + "description": "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects", + "homepage": "http://sabre.io/vobject/", + "keywords": [ + "VObject", + "iCalendar", + "jCal", + "jCard", + "vCard" + ], + "time": "2015-02-25 17:47:50" } ], "packages-dev": [], diff --git a/sabredav.php b/sabredav.php new file mode 100644 index 0000000000..7dd87ec437 --- /dev/null +++ b/sabredav.php @@ -0,0 +1,105 @@ + + * @copyright (c) 2006-15 by Ralf Becker + * @version $Id$ + */ + +$starttime = microtime(true); + +/** + * check if the given user has access + * + * Create a session or if the user has no account return authenticate header and 401 Unauthorized + * + * @param array &$account + * @return int session-id + */ +function check_access(&$account) +{ + if (isset($_GET['auth'])) + { + list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = explode(':',base64_decode($_GET['auth']),2); + } + return egw_digest_auth::autocreate_session_callback($account); +} + +$GLOBALS['egw_info'] = array( + 'flags' => array( + 'disable_Template_class' => True, + 'noheader' => True, + 'currentapp' => preg_match('#/(sabre|web)dav.php/apps/([A-Za-z0-9_-]+)/#', $_SERVER['REQUEST_URI'], $matches) ? $matches[1] : 'filemanager', + 'autocreate_session_callback' => 'check_access', + 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) + 'auth_realm' => 'EGroupware WebDAV server', // cant use vfs_webdav_server::REALM as autoloading and include path not yet setup! + ) +); +require_once('phpgwapi/inc/class.egw_digest_auth.inc.php'); + +// if you move this file somewhere else, you need to adapt the path to the header! +try +{ + include(dirname(__FILE__).'/header.inc.php'); +} +catch (egw_exception_no_permission_app $e) +{ + if (isset($GLOBALS['egw_info']['user']['apps']['filemanager'])) + { + $GLOBALS['egw_info']['currentapp'] = 'filemanager'; + } + elseif (isset($GLOBALS['egw_info']['user']['apps']['sitemgr-link'])) + { + $GLOBALS['egw_info']['currentapp'] = 'sitemgr-link'; + } + else + { + throw $e; + } +} +//$headertime = microtime(true); + +// webdav is stateless: we dont need to keep the session open, it only blocks other calls to same basic-auth session +$GLOBALS['egw']->session->commit_session(); + +use EGroupware\Api\Vfs; +use Sabre\DAV; + +// Now we're creating a whole bunch of objects +$rootDirectory = new Vfs\Dav\Directory('/'); + +// The server object is responsible for making sense out of the WebDAV protocol +$server = new DAV\Server($rootDirectory); + +// If your server is not on your webroot, make sure the following line has the +// correct information +$server->setBaseUri($_SERVER['SCRIPT_NAME']); + +// The lock manager is reponsible for making sure users don't overwrite +// each others changes. +/*$lockBackend = new DAV\Locks\Backend\File('data/locks'); +$lockPlugin = new DAV\Locks\Plugin($lockBackend); +$server->addPlugin($lockPlugin);*/ + +// This ensures that we get a pretty index in the browser, but it is +// optional. +$server->addPlugin(new DAV\Browser\Plugin()); + +// All we need to do now, is to fire up the server +$server->exec(); + +//error_log(sprintf('WebDAV %s request: status "%s", took %5.3f s'.($headertime?' (header include took %5.3f s)':''),$_SERVER['REQUEST_METHOD'].' '.$_SERVER['PATH_INFO'],$webdav_server->_http_status,microtime(true)-$starttime,$headertime-$starttime));