function setup() { $this->caldavBackend = new CalDAV\Backend\MockSharing(); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $calendars = new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend); $principals = new CalDAV\Principal\Collection($principalBackend); $root = new DAV\SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $this->server = new DAV\Server($root); $this->server->sapi = new HTTP\SapiMock(); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); // Adding ACL plugin $this->server->addPlugin(new DAVACL\Plugin()); // CalDAV is also required. $this->server->addPlugin(new CalDAV\Plugin()); // Adding Auth plugin, and ensuring that we are logged in. $authBackend = new DAV\Auth\Backend\Mock(); $authBackend->defaultUser = '******'; $authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV'); $this->server->addPlugin($authPlugin); // This forces a login $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; }
function setup() { $this->caldavBackend = new Backend\Mock(array(array('id' => 1, 'uri' => 'UUID-123467', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT', 'VTODO'))), array('id' => 2, 'uri' => 'UUID-123468', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar2', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT', 'VTODO')))), array(1 => array('UUID-2345' => array('calendardata' => TestUtil::getTestCalendarData())))); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', array('principals/user1')); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', array('principals/user1')); $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-read')); $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-write')); $calendars = new CalendarRootNode($principalBackend, $this->caldavBackend); $principals = new Principal\Collection($principalBackend); $root = new DAV\SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $objectTree = new DAV\ObjectTree($root); $this->server = new DAV\Server($objectTree); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); // Adding ACL plugin $this->server->addPlugin(new DAVACL\Plugin()); // Adding Auth plugin, and ensuring that we are logged in. $authBackend = new DAV\Auth\Backend\Mock(); $authBackend->defaultUser = '******'; $authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV'); $this->server->addPlugin($authPlugin); $authPlugin->beforeMethod('GET', '/'); $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; }
public static function handleRequest() { if (extension_loaded('newrelic')) { newrelic_disable_autorum(); } // retrieve authentication attempt if ($GLOBALS['Session']->hasAccountLevel('Developer')) { $User = $GLOBALS['Session']->Person; } else { $authEngine = new \Sabre\HTTP\BasicAuth(); $authEngine->setRealm('Develop ' . \Site::$title); $authUserPass = $authEngine->getUserPass(); // try to get user $userClass = \User::$defaultClass; $User = $userClass::getByLogin($authUserPass[0], $authUserPass[1]); // send auth request if login is inadiquate if (!$User || !$User->hasAccountLevel('Developer')) { $authEngine->requireLogin(); die("You must login using a " . \Site::getConfig('primary_hostname') . " account with Developer access\n"); } } // store login to session if (isset($GLOBALS['Session'])) { $GLOBALS['Session'] = $GLOBALS['Session']->changeClass('UserSession', array('PersonID' => $User->ID)); } // detect base path $basePath = array_slice(\Site::$requestPath, 0, count(\Site::$resolvedPath)); // switch to JSON response mode if (static::peekPath() == 'json') { $basePath[] = static::$responseMode = static::shiftPath(); } // handle /develop request if ($_SERVER['REQUEST_METHOD'] == 'GET' && static::getResponseMode() == 'html' && !static::peekPath()) { \RequestHandler::respond('app/ext', array('App' => \Sencha_App::getByName('EmergenceEditor'), 'mode' => 'production', 'title' => 'EmergenceEditor')); } // initial and configure SabreDAV $server = new \Sabre\DAV\Server(new RootCollection()); $server->setBaseUri('/' . join('/', $basePath)); // The lock manager is reponsible for making sure users don't overwrite each others changes. Change 'data' to a different // directory, if you're storing your data somewhere else. # $lockBackend = new Sabre_DAV_Locks_Backend_FS('/tmp/dav-lock'); # $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); # $server->addPlugin($lockPlugin); // filter temporary files $server->addPlugin(new \Sabre\DAV\TemporaryFileFilterPlugin('/tmp/dav-tmp')); // ?mount support $server->addPlugin(new \Sabre\DAV\Mount\Plugin()); // emergence :) $server->addPlugin(new \Emergence\DAV\ServerPlugin()); // All we need to do now, is to fire up the server $server->exec(); }
function init() { if (argv(1) !== 'calendar' && argv(1) !== 'addressbook') { if (\DBA::$dba && \DBA::$dba->connected) { $pdovars = \DBA::$dba->pdo_get(); } else { killme(); } // workaround for HTTP-auth in CGI mode if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)); if (strlen($userpass)) { list($name, $password) = explode(':', $userpass); $_SERVER['PHP_AUTH_USER'] = $name; $_SERVER['PHP_AUTH_PW'] = $password; } } if (x($_SERVER, 'HTTP_AUTHORIZATION')) { $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)); if (strlen($userpass)) { list($name, $password) = explode(':', $userpass); $_SERVER['PHP_AUTH_USER'] = $name; $_SERVER['PHP_AUTH_PW'] = $password; } } /** * This server combines both CardDAV and CalDAV functionality into a single * server. It is assumed that the server runs at the root of a HTTP domain (be * that a domainname-based vhost or a specific TCP port. * * This example also assumes that you're using SQLite and the database has * already been setup (along with the database tables). * * You may choose to use MySQL instead, just change the PDO connection * statement. */ /** * UTC or GMT is easy to work with, and usually recommended for any * application. */ date_default_timezone_set('UTC'); /** * Make sure this setting is turned on and reflect the root url for your WebDAV * server. * * This can be for example the root / or a complete path to your server script. */ $baseUri = '/cdav/'; /** * Database * */ $pdo = new \PDO($pdovars[0], $pdovars[1], $pdovars[2]); $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); // Autoloader require_once 'vendor/autoload.php'; /** * The backends. Yes we do really need all of them. * * This allows any developer to subclass just any of them and hook into their * own backend systems. */ $auth = new \Zotlabs\Storage\BasicAuth(); $auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . 'CalDAV/CardDAV'); // $ob_hash = get_observer_hash(); // if ($ob_hash) { if (local_channel()) { logger('loggedin'); $channel = \App::get_channel(); $auth->setCurrentUser($channel['channel_address']); $auth->channel_id = $channel['channel_id']; $auth->channel_hash = $channel['channel_hash']; $auth->channel_account_id = $channel['channel_account_id']; if ($channel['channel_timezone']) { $auth->setTimezone($channel['channel_timezone']); } $auth->observer = $channel['channel_hash']; } // $auth->observer = $ob_hash; // } //$authBackend = new \Sabre\DAV\Auth\Backend\PDO($pdo); $principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($pdo); $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); /** * The directory tree * * Basically this is an array which contains the 'top-level' directories in the * WebDAV server. */ $nodes = [new \Sabre\CalDAV\Principal\Collection($principalBackend), new \Sabre\CalDAV\CalendarRoot($principalBackend, $caldavBackend), new \Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend)]; // The object tree needs in turn to be passed to the server class $server = new \Sabre\DAV\Server($nodes); if (isset($baseUri)) { $server->setBaseUri($baseUri); } // Plugins $server->addPlugin(new \Sabre\DAV\Auth\Plugin($auth)); //$server->addPlugin(new \Sabre\DAV\Browser\Plugin()); $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); $server->addPlugin(new \Sabre\DAV\Sharing\Plugin()); $server->addPlugin(new \Sabre\DAVACL\Plugin()); // CalDAV plugins $server->addPlugin(new \Sabre\CalDAV\Plugin()); $server->addPlugin(new \Sabre\CalDAV\SharingPlugin()); //$server->addPlugin(new \Sabre\CalDAV\Schedule\Plugin()); $server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); // CardDAV plugins $server->addPlugin(new \Sabre\CardDAV\Plugin()); $server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin()); // And off we go! $server->exec(); killme(); } }
if ($repository != null) { $repositoryId = $repository->getId(); } } if ($repository == null) { AJXP_Logger::debug("not found, dying {$repositoryId}"); die('You are not allowed to access this service'); } $rId = $repositoryId; $rootDir = new AJXP_Sabre_Collection("/", $repository, null); $server = new Sabre\DAV\Server($rootDir); $server->setBaseUri($baseURI . "/" . $pathBase); } else { $rootDir = new AJXP_Sabre_RootCollection("root"); $server = new Sabre\DAV\Server($rootDir); $server->setBaseUri($baseURI); } if ((AJXP_Sabre_AuthBackendBasic::detectBasicHeader() || ConfService::getCoreConf("WEBDAV_FORCE_BASIC")) && ConfService::getAuthDriverImpl()->getOption("TRANSMIT_CLEAR_PASS")) { $authBackend = new AJXP_Sabre_AuthBackendBasic($rId); } else { $authBackend = new AJXP_Sabre_AuthBackendDigest($rId); } $authPlugin = new Sabre\DAV\Auth\Plugin($authBackend, ConfService::getCoreConf("WEBDAV_DIGESTREALM")); $server->addPlugin($authPlugin); if (!is_dir(AJXP_DATA_PATH . "/plugins/server.sabredav")) { mkdir(AJXP_DATA_PATH . "/plugins/server.sabredav", 0755); $fp = fopen(AJXP_DATA_PATH . "/plugins/server.sabredav/locks", "w"); fwrite($fp, ""); fclose($fp); } $lockBackend = new Sabre\DAV\Locks\Backend\File(AJXP_DATA_PATH . "/plugins/server.sabredav/locks");
// settings date_default_timezone_set('Europe/Berlin'); // Make sure this setting is turned on and reflect the root url for your WebDAV server. // This can be for example the root / or a complete path to your server script $baseUri = '/server.php'; /* Database */ $pdo = new PDO('mysql:host=localhost;dbname=carddav', 'carddav', 'carddav'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //Mapping PHP errors to exceptions function exception_error_handler($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler"); // Backends $authBackend = new Sabre\DAV\Auth\Backend\PDO($pdo); $principalBackend = new Sabre\DAVACL\PrincipalBackend\PDO($pdo); $carddavBackend = new Sabre\CardDAV\Backend\PDO($pdo); // Setting up the directory tree // $nodes = [new Sabre\DAVACL\PrincipalCollection($principalBackend), new Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend)]; // The object tree needs in turn to be passed to the server class $server = new Sabre\DAV\Server($nodes); $server->setBaseUri($baseUri); // Plugins $server->addPlugin(new Sabre\DAV\Auth\Plugin($authBackend)); $server->addPlugin(new Sabre\CardDAV\Plugin()); $server->addPlugin(new Sabre\DAV\Browser\Plugin()); $server->addPlugin(new Sabre\DAVACL\Plugin()); $server->addPlugin(new Sabre\DAV\Sync\Plugin()); // And off we go! $server->exec();
function process($source_id, $pmb_user_id) { global $class_path; global $webdav_current_user_id, $webdav_current_user_name; global $pmb_url_base; $source_object = $this->instantiate_source_class($source_id); $webdav_current_user_id = 0; $webdav_current_user_name = "Anonymous"; $rootDir = new Sabre\PMB\Tree($source_object->config); $server = new Sabre\DAV\Server($rootDir); if ($source_object->config['allow_web']) { $web = new Sabre\PMB\BrowserPlugin(); $server->addPlugin($web); } if ($source_object->config['authentication'] != "anonymous") { $auth = new Sabre\PMB\Auth($source_object->config['authentication']); $authPlugin = new Sabre\DAV\Auth\Plugin($auth, md5($pmb_url_base)); // Adding the plugin to the server $server->addPlugin($authPlugin); } // We're required to set the base uri, it is recommended to put your webdav server on a root of a domain $server->setBaseUri($source_object->config['base_uri']); // And off we go! $server->exec(); }
/** * handle webdav request * * @param bool $body * * @note this init procedure is copied from /apps/files/appinfo/remote.php */ function handleWebdavRequest($body = false) { // Backends $authBackend = new OC_Connector_Sabre_Auth(); $lockBackend = new OC_Connector_Sabre_Locks(); $requestBackend = new OC_Connector_Sabre_Request(); // Create ownCloud Dir $root = '/' . $this->userId . '/files'; $view = new \OC\Files\View($root); $publicDir = new OC_Connector_Sabre_Directory($view, $view->getFileInfo('')); $objectTree = new \OC\Connector\Sabre\ObjectTree(); $mountManager = \OC\Files\Filesystem::getMountManager(); $objectTree->init($publicDir, $view, $mountManager); // Fire up server $server = new \Sabre\DAV\Server($publicDir); $server->httpRequest = $requestBackend; $server->setBaseUri('/remote.php/webdav/'); // Load plugins $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud')); $server->addPlugin(new \Sabre\DAV\Locks\Plugin($lockBackend)); $server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view)); $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin()); $server->debugExceptions = true; // And off we go! if ($body) { $server->httpRequest->setBody($body); } // turn on output buffering ob_start(); // handle request $server->exec(); // file content is written in the output buffer $content = ob_get_contents(); // flush the output buffer and turn off output buffering ob_end_clean(); // return captured content return $content; }
} if (!file_exists(PROJECT_PATH_ROOT . 'vendor/')) { die('<h1>Incomplete installation</h1><p>Baïkal dependencies have not been installed. Please, execute "<strong>composer install</strong>" in the folder where you installed Baïkal.'); } require PROJECT_PATH_ROOT . 'vendor/autoload.php'; # Bootstraping Flake \Flake\Framework::bootstrap(); # Bootstrapping Baïkal \Baikal\Framework::bootstrap(); if (!defined("BAIKAL_CAL_ENABLED") || BAIKAL_CAL_ENABLED !== TRUE) { throw new ErrorException("Baikal CalDAV is disabled.", 0, 255, __FILE__, __LINE__); } # Backends if (BAIKAL_DAV_AUTH_TYPE == "Basic" || array_key_exists('HTTP_USER_AGENT', $_SERVER) && (preg_match('/Windows-Phone-WebDAV-Client/i', $_SERVER['HTTP_USER_AGENT']) || preg_match('/MSFT-WP\\/8.10.*/i', $_SERVER['HTTP_USER_AGENT']))) { $authBackend = new \Baikal\Core\PDOBasicAuth($GLOBALS["DB"]->getPDO(), BAIKAL_AUTH_REALM); } else { $authBackend = new \Sabre\DAV\Auth\Backend\PDO($GLOBALS["DB"]->getPDO()); } $principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($GLOBALS["DB"]->getPDO()); $calendarBackend = new \Sabre\CalDAV\Backend\PDO($GLOBALS["DB"]->getPDO()); # Directory structure $nodes = array(new \Sabre\CalDAV\Principal\Collection($principalBackend), new \Sabre\CalDAV\CalendarRootNode($principalBackend, $calendarBackend)); # Initializing server $server = new \Sabre\DAV\Server($nodes); $server->setBaseUri(BAIKAL_CAL_BASEURI); # Server Plugins $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, BAIKAL_AUTH_REALM)); $server->addPlugin(new \Sabre\DAVACL\Plugin()); $server->addPlugin(new \Sabre\CalDAV\Plugin()); # And off we go! $server->exec();
public function webdavAction() { $homeDir = Asset::getById(1); try { $publicDir = new Asset\WebDAV\Folder($homeDir); $objectTree = new Asset\WebDAV\Tree($publicDir); $server = new \Sabre\DAV\Server($objectTree); $server->setBaseUri("/admin/asset/webdav/"); // lock plugin $lockBackend = new \Sabre\DAV\Locks\Backend\File(PIMCORE_WEBDAV_TEMP . '/locks.dat'); $lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend); $server->addPlugin($lockPlugin); // sync plugin $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); // browser plugin $server->addPlugin(new Sabre\DAV\Browser\Plugin()); $server->exec(); } catch (\Exception $e) { Logger::error($e); } exit; }
function cdav_init(&$a) { if (DBA::$dba && DBA::$dba->connected) { $pdovars = DBA::$dba->pdo_get(); } else { killme(); } // workaround for HTTP-auth in CGI mode if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)); if (strlen($userpass)) { list($name, $password) = explode(':', $userpass); $_SERVER['PHP_AUTH_USER'] = $name; $_SERVER['PHP_AUTH_PW'] = $password; } } if (x($_SERVER, 'HTTP_AUTHORIZATION')) { $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)); if (strlen($userpass)) { list($name, $password) = explode(':', $userpass); $_SERVER['PHP_AUTH_USER'] = $name; $_SERVER['PHP_AUTH_PW'] = $password; } } /** * This server combines both CardDAV and CalDAV functionality into a single * server. It is assumed that the server runs at the root of a HTTP domain (be * that a domainname-based vhost or a specific TCP port. * * This example also assumes that you're using SQLite and the database has * already been setup (along with the database tables). * * You may choose to use MySQL instead, just change the PDO connection * statement. */ /** * UTC or GMT is easy to work with, and usually recommended for any * application. */ date_default_timezone_set('UTC'); /** * Make sure this setting is turned on and reflect the root url for your WebDAV * server. * * This can be for example the root / or a complete path to your server script. */ $baseUri = '/cdav'; /** * Database * */ $pdo = new \PDO($pdovars[0], $pdovars[1], $pdovars[2]); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /** * Mapping PHP errors to exceptions. * * While this is not strictly needed, it makes a lot of sense to do so. If an * E_NOTICE or anything appears in your code, this allows SabreDAV to intercept * the issue and send a proper response back to the client (HTTP/1.1 500). */ function exception_error_handler($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler"); // Autoloader require_once 'vendor/autoload.php'; /** * The backends. Yes we do really need all of them. * * This allows any developer to subclass just any of them and hook into their * own backend systems. */ $auth = new \Zotlabs\Storage\BasicAuth(); $auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . 'CalDAV/CardDAV'); //$authBackend = new \Sabre\DAV\Auth\Backend\PDO($pdo); $principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($pdo); $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); /** * The directory tree * * Basically this is an array which contains the 'top-level' directories in the * WebDAV server. */ $nodes = [new \Sabre\CalDAV\Principal\Collection($principalBackend), new \Sabre\CalDAV\CalendarRoot($principalBackend, $caldavBackend), new \Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend)]; // The object tree needs in turn to be passed to the server class $server = new \Sabre\DAV\Server($nodes); if (isset($baseUri)) { $server->setBaseUri($baseUri); } // Plugins $server->addPlugin(new \Sabre\DAV\Auth\Plugin($auth)); // $browser = new \Zotlabs\Storage\Browser($auth); // $auth->setBrowserPlugin($browser); // $server->addPlugin($browser); $server->addPlugin(new \Sabre\DAV\Browser\Plugin()); $server->addPlugin(new \Sabre\CalDAV\Plugin()); $server->addPlugin(new \Sabre\CardDAV\Plugin()); $server->addPlugin(new \Sabre\DAVACL\Plugin()); $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); // And off we go! $server->exec(); killme(); }
* the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ // Require autoloader. require_once __DIR__ . "/../config/autoloader.php"; // Load config. require_once __DIR__ . "/../config/config.php"; // Create a new server with a public directory. $rootDirectory = new \Sabre\DAV\FS\Directory($publicDir); $server = new \Sabre\DAV\Server($rootDirectory); // Set up authentication. $authBackend = new \OMVWebDAV\Auth\Openmediavault(); $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend, "OpenMediaVault WebDAV"); // Set up WebDAV locks. $lockBackend = new \Sabre\DAV\Locks\Backend\File(tempnam(sys_get_temp_dir(), "webdav")); $lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend); // Set base URI. $server->setBaseUri("/webdav/"); // Add plugins. $server->addPlugin($lockPlugin); $server->addPlugin($authPlugin); $server->addPlugin(new \Sabre\DAV\Browser\Plugin()); return $server;
function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler"); */ // Backends $authBackend = new myAuth(); $principalBackend = new MySabre_DAVACL_PrincipalBackend($authBackend); $calendarBackend = new MySabre_CalDAV_Backend($authBackend); $tree = array(new \Sabre\CalDAV\Principal\Collection($principalBackend), new \Sabre\CalDAV\CalendarRootNode($principalBackend, $calendarBackend)); // The object tree needs in turn to be passed to the server class $server = new \Sabre\DAV\Server($tree); // You are highly encouraged to set your WebDAV server base url. Without it, // SabreDAV will guess, but the guess is not always correct. Putting the // server on the root of the domain will improve compatibility. $path = str_replace($_SERVER['DOCUMENT_ROOT'], '', __FILE__) . '/'; $server->setBaseUri($path); // Authentication plugin $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend, 'SabreDAV'); $server->addPlugin($authPlugin); // CalDAV plugin $caldavPlugin = new \Sabre\CalDAV\Plugin(); $server->addPlugin($caldavPlugin); // ACL plugin $aclPlugin = new \Sabre\DAVACL\Plugin(); $server->addPlugin($aclPlugin); // Support for html frontend $browser = new \Sabre\DAV\Browser\Plugin(); $server->addPlugin($browser); // And off we go! $server->exec();