ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
fileserver.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4 
5 This is the best starting point if you're just interested in setting up a fileserver.
6 
7 Make sure that the 'public' and 'tmpdata' exists, with write permissions
8 for your server.
9 
10 */
11 
12 // settings
13 date_default_timezone_set('Canada/Eastern');
14 $publicDir = 'public';
15 $tmpDir = 'tmpdata';
16 
17 // If you want to run the SabreDAV server in a custom location (using mod_rewrite for instance)
18 // You can override the baseUri here.
19 // $baseUri = '/';
20 
21 
22 // Files we need
23 require_once 'vendor/autoload.php';
24 
25 // Create the root node
26 $root = new \Sabre\DAV\FS\Directory($publicDir);
27 
28 // The rootnode needs in turn to be passed to the server class
29 $server = new \Sabre\DAV\Server($root);
30 
31 if (isset($baseUri))
32  $server->setBaseUri($baseUri);
33 
34 // Support for LOCK and UNLOCK
35 $lockBackend = new \Sabre\DAV\Locks\Backend\File($tmpDir . '/locksdb');
36 $lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend);
37 $server->addPlugin($lockPlugin);
38 
39 // Support for html frontend
40 $browser = new \Sabre\DAV\Browser\Plugin();
41 $server->addPlugin($browser);
42 
43 // Automatically guess (some) contenttypes, based on extesion
44 $server->addPlugin(new \Sabre\DAV\Browser\GuessContentType());
45 
46 // Authentication backend
47 $authBackend = new \Sabre\DAV\Auth\Backend\File('.htdigest');
48 $auth = new \Sabre\DAV\Auth\Plugin($authBackend);
49 $server->addPlugin($auth);
50 
51 // Temporary file filter
52 $tempFF = new \Sabre\DAV\TemporaryFileFilterPlugin($tmpDir);
53 $server->addPlugin($tempFF);
54 
55 // And off we go!
56 $server->exec();
$server
Definition: fileserver.php:29
$tempFF
Definition: fileserver.php:52
$root
Definition: fileserver.php:26
$auth
Definition: fileserver.php:48
$authBackend
Definition: fileserver.php:47
$tmpDir
Definition: fileserver.php:15
$lockPlugin
Definition: fileserver.php:36
$browser
Definition: fileserver.php:40
$publicDir
Definition: fileserver.php:14
$lockBackend
Definition: fileserver.php:35