Test Failed
Push — master ( 8b9220...69ee03 )
by
unknown
09:18
created

server.php (2 issues)

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
// FIXME:  solve the including of shared files properly
16
require_once GROMOX_PHP_PATH . 'lib/db.php';
17
18
// Configure & create main logger
19
GLogger::configure(__DIR__ . '/log4php.xml');
20
$logger = new GLogger('main');
21
22
// don't log any Sabre asset requests (images etc)
23
if (isset($_REQUEST['sabreAction']) && $_REQUEST['sabreAction'] == 'asset') {
24
	$logger->resetConfiguration();
25
}
26
27
// log the start data
28
$logger->debug('------------------ Start');
29
$logger->debug('%s %s', $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
30
$logger->debug('grommunio-dav version %s', GDAV_VERSION);
31
$logger->debug('SabreDAV version %s', \Sabre\DAV\Version::VERSION);
32
33
$gdavBackend = new GrommunioDavBackend(new GLogger('dav'));
34
$authBackend = new AuthBasicBackend($gdavBackend);
35
$authBackend->setRealm(SABRE_AUTH_REALM);
36
$principalBackend = new PrincipalsBackend($gdavBackend);
37
$gCarddavBackend = new GrommunioCardDavBackend($gdavBackend, new GLogger('card'));
38
$gCaldavBackend = new GrommunioCalDavBackend($gdavBackend, new GLogger('cal'));
39
40
// Setting up the directory tree
41
$nodes = [
42
	new \Sabre\DAVACL\PrincipalCollection($principalBackend),
43
	new \Sabre\CardDAV\AddressBookRoot($principalBackend, $gCarddavBackend),
44
	new \Sabre\CalDAV\CalendarRoot($principalBackend, $gCaldavBackend),
45
];
46
47
// initialize the server
48
$server = new \Sabre\DAV\Server($nodes);
49
$server->setBaseUri(DAV_ROOT_URI);
50
$server->setLogger(new GPSR3Logger($logger));
51
52
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend, SABRE_AUTH_REALM);
0 ignored issues
show
The call to Sabre\DAV\Auth\Plugin::__construct() has too many arguments starting with grommunio\DAV\SABRE_AUTH_REALM. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
$authPlugin = /** @scrutinizer ignore-call */ new \Sabre\DAV\Auth\Plugin($authBackend, SABRE_AUTH_REALM);

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.

Loading history...
53
$server->addPlugin($authPlugin);
54
55
// add our version to the headers
56
$server->httpResponse->addHeader('X-GDAV-Version', GDAV_VERSION);
57
58
// log the incoming request (only if authenticated)
59
$logger->LogIncoming($server->httpRequest);
60
61
$aclPlugin = new DAVACL();
62
$aclPlugin->allowUnauthenticatedAccess = false;
63
$server->addPlugin($aclPlugin);
64
65
// $schedulePlugin = new GrommunioSchedulePlugin($gdavBackend, new GLogger('schedule'));
66
// $server->addPlugin($schedulePlugin);
67
68
$imipPlugin = new GrommunioIMipPlugin($gdavBackend, new GLogger('imip'));
69
$server->addPlugin($imipPlugin);
70
71
$server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
72
$server->addPlugin(new \Sabre\CardDAV\Plugin());
73
74
// TODO: do we need $caldavPlugin for anything?
75
$caldavPlugin = new \Sabre\CalDAV\Plugin();
76
$server->addPlugin($caldavPlugin);
77
78
if (strlen(SYNC_DB) > 0) {
79
	$server->addPlugin(new \Sabre\DAV\Sync\Plugin());
80
}
81
82
if (DEVELOPER_MODE) {
83
	$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false));
84
}
85
86
$server->exec();
0 ignored issues
show
Deprecated Code introduced by
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 ignore-deprecated  annotation

86
/** @scrutinizer ignore-deprecated */ $server->exec();
Loading history...
87
88
// Log outgoing data
89
$logger->LogOutgoing($server->httpResponse);
90
91
$logger->debug(
92
	"httpcode='%s' memory='%s/%s' time='%ss'",
93
	http_response_code(),
94
	$logger->FormatBytes(memory_get_peak_usage(false)),
95
	$logger->FormatBytes(memory_get_peak_usage(true)),
96
	number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2)
97
);
98
$logger->debug('------------------ End');
99