grommunio /
grommunio-dav
| 1 | <?php |
||||
| 2 | /* |
||||
| 3 | * SPDX-License-Identifier: AGPL-3.0-only |
||||
| 4 | * SPDX-FileCopyrightText: Copyright 2016 - 2018 Kopano b.v. |
||||
| 5 | * SPDX-FileCopyrightText: Copyright 2020 grommunio GmbH |
||||
| 6 | * |
||||
| 7 | * This is the entry point through which all requests are processed. |
||||
| 8 | */ |
||||
| 9 | |||||
| 10 | namespace grommunio\DAV; |
||||
| 11 | |||||
| 12 | // require composer auto-loader |
||||
| 13 | require __DIR__ . '/vendor/autoload.php'; |
||||
| 14 | |||||
| 15 | // Configure & create main logger |
||||
| 16 | GLogger::configure(__DIR__ . '/log4php.xml'); |
||||
| 17 | $logger = new GLogger('main'); |
||||
| 18 | |||||
| 19 | // don't log any Sabre asset requests (images etc) |
||||
| 20 | if (isset($_REQUEST['sabreAction']) && $_REQUEST['sabreAction'] == 'asset') { |
||||
| 21 | $logger->resetConfiguration(); |
||||
| 22 | } |
||||
| 23 | |||||
| 24 | // log the start data |
||||
| 25 | $logger->debug('------------------ Start'); |
||||
| 26 | $logger->debug('%s %s', $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); |
||||
| 27 | $logger->debug('grommunio-dav version %s', GDAV_VERSION); |
||||
| 28 | $logger->debug('SabreDAV version %s', \Sabre\DAV\Version::VERSION); |
||||
| 29 | |||||
| 30 | $gdavBackend = new GrommunioDavBackend(new GLogger('dav')); |
||||
| 31 | $authBackend = new AuthBasicBackend($gdavBackend); |
||||
| 32 | $authBackend->setRealm(SABRE_AUTH_REALM); |
||||
| 33 | $principalBackend = new PrincipalsBackend($gdavBackend); |
||||
| 34 | $gCarddavBackend = new GrommunioCardDavBackend($gdavBackend, new GLogger('card')); |
||||
| 35 | $gCaldavBackend = new GrommunioCalDavBackend($gdavBackend, new GLogger('cal')); |
||||
| 36 | |||||
| 37 | // Setting up the directory tree |
||||
| 38 | $nodes = [ |
||||
| 39 | new \Sabre\DAVACL\PrincipalCollection($principalBackend), |
||||
| 40 | new \Sabre\CardDAV\AddressBookRoot($principalBackend, $gCarddavBackend), |
||||
| 41 | new \Sabre\CalDAV\CalendarRoot($principalBackend, $gCaldavBackend), |
||||
| 42 | ]; |
||||
| 43 | |||||
| 44 | // initialize the server |
||||
| 45 | $server = new \Sabre\DAV\Server($nodes); |
||||
| 46 | $server->setBaseUri(DAV_ROOT_URI); |
||||
| 47 | $server->setLogger(new GPSR3Logger($logger)); |
||||
| 48 | |||||
| 49 | $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend, SABRE_AUTH_REALM); |
||||
|
0 ignored issues
–
show
|
|||||
| 50 | $server->addPlugin($authPlugin); |
||||
| 51 | |||||
| 52 | // add our version to the headers |
||||
| 53 | $server->httpResponse->addHeader('X-GDAV-Version', GDAV_VERSION); |
||||
| 54 | |||||
| 55 | // log the incoming request (only if authenticated) |
||||
| 56 | $logger->LogIncoming($server->httpRequest); |
||||
| 57 | |||||
| 58 | $aclPlugin = new DAVACL(); |
||||
| 59 | $aclPlugin->allowUnauthenticatedAccess = false; |
||||
| 60 | $server->addPlugin($aclPlugin); |
||||
| 61 | |||||
| 62 | // $schedulePlugin = new GrommunioSchedulePlugin($gdavBackend, new GLogger('schedule')); |
||||
| 63 | // $server->addPlugin($schedulePlugin); |
||||
| 64 | |||||
| 65 | $imipPlugin = new GrommunioIMipPlugin($gdavBackend, new GLogger('imip')); |
||||
| 66 | $server->addPlugin($imipPlugin); |
||||
| 67 | |||||
| 68 | $server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
||||
| 69 | $server->addPlugin(new \Sabre\CardDAV\Plugin()); |
||||
| 70 | |||||
| 71 | // TODO: do we need $caldavPlugin for anything? |
||||
| 72 | $caldavPlugin = new \Sabre\CalDAV\Plugin(); |
||||
| 73 | $server->addPlugin($caldavPlugin); |
||||
| 74 | |||||
| 75 | if (strlen(SYNC_DB) > 0) { |
||||
| 76 | $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
||||
| 77 | } |
||||
| 78 | |||||
| 79 | if (DEVELOPER_MODE) { |
||||
| 80 | $server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); |
||||
| 81 | } |
||||
| 82 | |||||
| 83 | $server->exec(); |
||||
|
0 ignored issues
–
show
The function
Sabre\DAV\Server::exec() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 84 | |||||
| 85 | // Log outgoing data |
||||
| 86 | $logger->LogOutgoing($server->httpResponse); |
||||
| 87 | |||||
| 88 | $logger->debug( |
||||
| 89 | "httpcode='%s' memory='%s/%s' time='%ss'", |
||||
| 90 | http_response_code(), |
||||
| 91 | $logger->FormatBytes(memory_get_peak_usage(false)), |
||||
| 92 | $logger->FormatBytes(memory_get_peak_usage(true)), |
||||
| 93 | number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2) |
||||
| 94 | ); |
||||
| 95 | $logger->debug('------------------ End'); |
||||
| 96 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.