Commit d4effbee authored by Zachary Seguin's avatar Zachary Seguin

Initial commit

parents
config.php
{
"require": {
"sabre/dav": "~3.0.0"
}
}
<?php
// DATABASE CONFIGURATION
define('PDO_CONNECTION_STRING', 'pgsql:dbname=sabredav;host=localhost');
define('PDO_USER', 'sabredav');
define('PDO_PASSWORD', 'passwd');
<?php
require_once __DIR__ . '/vendor/autoload.php';
use
Sabre\DAV,
Sabre\DAV\Auth,
Sabre\CalDAV,
Sabre\CardDAV,
Sabre\DAVACL;
// Authentication
$pdo = new \PDO(PDO_CONNECTION_STRING, PDO_USER, PDO_PASSWORD);
$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
$serverBackend = new DAV\Auth\Backend\Apache();
$authBackend = new DAV\Auth\Backend\PDO($pdo);
$principalBackend = new DAVACL\PrincipalBackend\PDO($pdo);
$calendarBackend = new CalDAV\Backend\PDO($pdo);
$contactsBackend = new CardDAV\Backend\PDO($pdo);
// Directory tree
$tree = array(
new CalDAV\Principal\Collection($principalBackend),
new CalDAV\CalendarRoot($principalBackend, $calendarBackend),
new CardDAV\AddressBookRoot($principalBackend, $contactsBackend)
);
// DAV Server
$server = new DAV\Server($tree);
$server->setBaseUri('/');
// Authentication plugin
$authPlugin = new DAV\Auth\Plugin($serverBackend,'ZacharyDAV');
$server->addPlugin($authPlugin);
// CalDAV plugin
$caldavPlugin = new CalDAV\Plugin();
$server->addPlugin($caldavPlugin);
$server->addPlugin(new Sabre\CalDAV\Notifications\Plugin());
$server->addPlugin(new Sabre\CalDAV\Schedule\Plugin());
$server->addPlugin(new Sabre\CalDAV\Subscriptions\Plugin());
// CardDAV plugin
$server->addPlugin(new CardDAV\Plugin());
// ACL plugin
$server->addPlugin(new DAVACL\Plugin());
// Lock for WebDav
$server->addPlugin(new DAV\Locks\Plugin(new DAV\Locks\Backend\File('data/locks')));
// TEMP file
$server->addPlugin(new DAV\TemporaryFileFilterPlugin('temp'));
// HTML support
$server->addPlugin(new DAV\Browser\Plugin());
// SYNC
$server->addPlugin(new Sabre\DAV\Sync\Plugin());
$server->exec();
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment