]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/examples/fileserver.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / examples / fileserver.php
1 <?php
2
3 // !!!! Make sure the Sabre directory is in the include_path !!!
4 // example:
5 set_include_path('lib/' . PATH_SEPARATOR . get_include_path());
6
7 /*
8
9 This is the best starting point if you're just interested in setting up a fileserver.
10
11 Make sure that the 'public' and 'tmpdata' exists, with write permissions
12 for your server.
13
14 */
15
16 // settings
17 date_default_timezone_set('Canada/Eastern');
18 $publicDir = 'public';
19 $tmpDir = 'tmpdata';
20
21 // If you want to run the SabreDAV server in a custom location (using mod_rewrite for instance)
22 // You can override the baseUri here.
23 // $baseUri = '/';
24
25
26 // Files we need
27 require_once 'Sabre/autoload.php';
28
29 // Create the root node
30 $root = new Sabre_DAV_FS_Directory($publicDir);
31
32 // The rootnode needs in turn to be passed to the server class
33 $server = new Sabre_DAV_Server($root);
34
35 if (isset($baseUri))
36     $server->setBaseUri($baseUri);
37
38 // Support for LOCK and UNLOCK
39 $lockBackend = new Sabre_DAV_Locks_Backend_File($tmpDir . '/locksdb');
40 $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
41 $server->addPlugin($lockPlugin);
42
43 // Support for html frontend
44 $browser = new Sabre_DAV_Browser_Plugin();
45 $server->addPlugin($browser);
46
47 // Automatically guess (some) contenttypes, based on extesion
48 $server->addPlugin(new Sabre_DAV_Browser_GuessContentType());
49
50 // Authentication backend
51 $authBackend = new Sabre_DAV_Auth_Backend_File('.htdigest');
52 $auth = new Sabre_DAV_Auth_Plugin($authBackend,'SabreDAV');
53 $server->addPlugin($auth);
54
55 // Temporary file filter
56 $tempFF = new Sabre_DAV_TemporaryFileFilterPlugin($tmpDir);
57 $server->addPlugin($tempFF);
58
59 // And off we go!
60 $server->exec();