1<?php
2
3/**
4 * DokuWiki WebDAV Plugin Endpoint
5 *
6 * @link     https://dokuwiki.org/plugin:webdav
7 * @author   Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
8 * @license  GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 */
10
11# NOTE Some Linux distributon change the location of DokuWiki core libraries (DOKU_INC)
12#
13#      Bitnami (Docker)         /opt/bitnami/dokuwiki
14#      LinuxServer.io (Docker)  /app/dokuwiki
15#      Arch Linux               /usr/share/webapps/dokuwiki
16#      Debian/Ubuntu            /usr/share/dokuwiki
17#
18# NOTE If DokuWiki core libraries (DOKU_INC) is in another location you can
19#      create a PHP file in this directory called "doku_inc.php" with
20#      this content:
21#
22#           <?php define('DOKU_INC', '/path/dokuwiki/');
23#
24#      (!) This file may be deleted on every upgrade of plugin
25
26$doku_inc_dirs = [
27    '/opt/bitnami/dokuwiki',
28    '/usr/share/webapps/dokuwiki',
29    '/usr/share/dokuwiki',
30    '/app/dokuwiki',
31    realpath(dirname(__FILE__) . '/../../../'), # Default DokuWiki path
32];
33
34# Load doku_inc.php file
35#
36if (file_exists(dirname(__FILE__) . '/doku_inc.php')) {
37    require_once dirname(__FILE__) . '/doku_inc.php';
38}
39
40if (!defined('DOKU_INC')) {
41    foreach ($doku_inc_dirs as $dir) {
42        if (!defined('DOKU_INC') && @file_exists("$dir/inc/init.php")) {
43            define('DOKU_INC', "$dir/");
44        }
45    }
46}
47
48require_once DOKU_INC . 'inc/init.php';
49require_once DOKU_PLUGIN . 'webdav/vendor/autoload.php';
50
51use dokuwiki\plugin\webdav\core\Utils;
52
53session_write_close();
54
55if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
56    @set_time_limit(0);
57}
58ignore_user_abort(true);
59
60$base_uri = DOKU_REL . 'lib/plugins/webdav/server.php/';
61
62try {
63    $server = new dokuwiki\plugin\webdav\core\Server($base_uri);
64    $server->exec();
65} catch (Exception $e) {
66    Utils::log('fatal', "[{class}] {message} in {file}({line})", [
67        'class'   => get_class($e),
68        'message' => $e->getMessage(),
69        'file'    => $e->getFile(),
70        'line'    => $e->getLine(),
71    ]);
72}
73
74Utils::log('debug', '====================');
75