Created
March 18, 2011 12:46
-
-
Save evert/876002 to your computer and use it in GitHub Desktop.
SabreDAV demo server sourcecode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
ini_set('display_errors',1); | |
$publicDir = '/home/groups/s/sa/sabredav/persistent/public'; | |
$pdo = new PDO('sqlite:/home/groups/s/sa/sabredav/persistent/db/db.sqlite'); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
date_default_timezone_set('UTC'); | |
include dirname(__FILE__) . '/SabreDAV/lib/Sabre.autoload.php'; | |
include dirname(__FILE__) . '/MyBrowser.php'; | |
/* Backends */ | |
$authBackend = new Sabre_DAV_Auth_Backend_PDO($pdo); | |
$principalBackend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); | |
$locksBackend = new Sabre_DAV_Locks_Backend_PDO($pdo); | |
$calendarBackend = new Sabre_CalDAV_Backend_PDO($pdo); | |
/* Directory structure */ | |
$nodes = array( | |
new Sabre_DAV_FS_Directory($publicDir), | |
new Sabre_CalDAV_Principal_Collection($principalBackend), | |
new Sabre_CalDAV_CalendarRootNode($principalBackend, $calendarBackend), | |
); | |
$server = new Sabre_DAV_Server($nodes); | |
$server->setBaseUri('/'); | |
/* Locks */ | |
$locksPlugin = new Sabre_DAV_Locks_Plugin($locksBackend); | |
$server->addPlugin($locksPlugin); | |
/* Authentication */ | |
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV'); | |
$server->addPlugin($authPlugin); | |
/* CalDAV */ | |
$caldavPlugin = new Sabre_CalDAV_Plugin(); | |
$server->addPlugin($caldavPlugin); | |
/* ACL */ | |
$aclPlugin = new Sabre_DAVACL_Plugin(); | |
$server->addPlugin($aclPlugin); | |
/* ICS */ | |
$icsPlugin = new Sabre_CalDAV_ICSExportPlugin(); | |
$server->addPlugin($icsPlugin); | |
/* Handy plugins */ | |
$server->addPlugin(new MyBrowser(false)); | |
$server->addPlugin(new Sabre_DAV_Mount_Plugin()); | |
$server->addPlugin(new Sabre_DAV_Browser_GuessContentType()); | |
$server->exec(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment