Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like OC often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use OC, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 61 | class OC { |
||
| 62 | /** |
||
| 63 | * Associative array for autoloading. classname => filename |
||
| 64 | */ |
||
| 65 | public static $CLASSPATH = array(); |
||
| 66 | /** |
||
| 67 | * The installation path for Nextcloud on the server (e.g. /srv/http/nextcloud) |
||
| 68 | */ |
||
| 69 | public static $SERVERROOT = ''; |
||
| 70 | /** |
||
| 71 | * the current request path relative to the Nextcloud root (e.g. files/index.php) |
||
| 72 | */ |
||
| 73 | private static $SUBURI = ''; |
||
| 74 | /** |
||
| 75 | * the Nextcloud root path for http requests (e.g. nextcloud/) |
||
| 76 | */ |
||
| 77 | public static $WEBROOT = ''; |
||
| 78 | /** |
||
| 79 | * The installation path array of the apps folder on the server (e.g. /srv/http/nextcloud) 'path' and |
||
| 80 | * web path in 'url' |
||
| 81 | */ |
||
| 82 | public static $APPSROOTS = array(); |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @var string |
||
| 86 | */ |
||
| 87 | public static $configDir; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * requested app |
||
| 91 | */ |
||
| 92 | public static $REQUESTEDAPP = ''; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * check if Nextcloud runs in cli mode |
||
| 96 | */ |
||
| 97 | public static $CLI = false; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var \OC\Autoloader $loader |
||
| 101 | */ |
||
| 102 | public static $loader = null; |
||
| 103 | |||
| 104 | /** @var \Composer\Autoload\ClassLoader $composerAutoloader */ |
||
| 105 | public static $composerAutoloader = null; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @var \OC\Server |
||
| 109 | */ |
||
| 110 | public static $server = null; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @var \OC\Config |
||
| 114 | */ |
||
| 115 | private static $config = null; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @throws \RuntimeException when the 3rdparty directory is missing or |
||
| 119 | * the app path list is empty or contains an invalid path |
||
| 120 | */ |
||
| 121 | public static function initPaths() { |
||
| 122 | if(defined('PHPUNIT_CONFIG_DIR')) { |
||
| 123 | self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
||
| 124 | } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
||
| 125 | self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
||
| 126 | } elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
||
| 127 | self::$configDir = rtrim($dir, '/') . '/'; |
||
| 128 | } else { |
||
| 129 | self::$configDir = OC::$SERVERROOT . '/config/'; |
||
| 130 | } |
||
| 131 | self::$config = new \OC\Config(self::$configDir); |
||
| 132 | |||
| 133 | OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); |
||
| 134 | /** |
||
| 135 | * FIXME: The following lines are required because we can't yet instantiiate |
||
| 136 | * \OC::$server->getRequest() since \OC::$server does not yet exist. |
||
| 137 | */ |
||
| 138 | $params = [ |
||
| 139 | 'server' => [ |
||
| 140 | 'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'], |
||
| 141 | 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], |
||
| 142 | ], |
||
| 143 | ]; |
||
| 144 | $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig(self::$config))); |
||
| 145 | $scriptName = $fakeRequest->getScriptName(); |
||
| 146 | if (substr($scriptName, -1) == '/') { |
||
| 147 | $scriptName .= 'index.php'; |
||
| 148 | //make sure suburi follows the same rules as scriptName |
||
| 149 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
||
| 150 | if (substr(OC::$SUBURI, -1) != '/') { |
||
| 151 | OC::$SUBURI = OC::$SUBURI . '/'; |
||
| 152 | } |
||
| 153 | OC::$SUBURI = OC::$SUBURI . 'index.php'; |
||
| 154 | } |
||
| 155 | } |
||
| 156 | |||
| 157 | |||
| 158 | if (OC::$CLI) { |
||
| 159 | OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
||
| 160 | } else { |
||
| 161 | if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { |
||
| 162 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
||
| 163 | |||
| 164 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
||
| 165 | OC::$WEBROOT = '/' . OC::$WEBROOT; |
||
| 166 | } |
||
| 167 | } else { |
||
| 168 | // The scriptName is not ending with OC::$SUBURI |
||
| 169 | // This most likely means that we are calling from CLI. |
||
| 170 | // However some cron jobs still need to generate |
||
| 171 | // a web URL, so we use overwritewebroot as a fallback. |
||
| 172 | OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
||
| 173 | } |
||
| 174 | |||
| 175 | // Resolve /nextcloud to /nextcloud/ to ensure to always have a trailing |
||
| 176 | // slash which is required by URL generation. |
||
| 177 | if($_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
||
| 178 | substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
||
| 179 | header('Location: '.\OC::$WEBROOT.'/'); |
||
| 180 | exit(); |
||
| 181 | } |
||
| 182 | } |
||
| 183 | |||
| 184 | // search the apps folder |
||
| 185 | $config_paths = self::$config->getValue('apps_paths', array()); |
||
| 186 | if (!empty($config_paths)) { |
||
| 187 | foreach ($config_paths as $paths) { |
||
| 188 | if (isset($paths['url']) && isset($paths['path'])) { |
||
| 189 | $paths['url'] = rtrim($paths['url'], '/'); |
||
| 190 | $paths['path'] = rtrim($paths['path'], '/'); |
||
| 191 | OC::$APPSROOTS[] = $paths; |
||
| 192 | } |
||
| 193 | } |
||
| 194 | } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
||
| 195 | OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true); |
||
| 196 | } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
||
| 197 | OC::$APPSROOTS[] = array( |
||
| 198 | 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
||
| 199 | 'url' => '/apps', |
||
| 200 | 'writable' => true |
||
| 201 | ); |
||
| 202 | } |
||
| 203 | |||
| 204 | if (empty(OC::$APPSROOTS)) { |
||
| 205 | throw new \RuntimeException('apps directory not found! Please put the Nextcloud apps folder in the Nextcloud folder' |
||
| 206 | . ' or the folder above. You can also configure the location in the config.php file.'); |
||
| 207 | } |
||
| 208 | $paths = array(); |
||
| 209 | foreach (OC::$APPSROOTS as $path) { |
||
| 210 | $paths[] = $path['path']; |
||
| 211 | if (!is_dir($path['path'])) { |
||
| 212 | throw new \RuntimeException(sprintf('App directory "%s" not found! Please put the Nextcloud apps folder in the' |
||
| 213 | . ' Nextcloud folder or the folder above. You can also configure the location in the' |
||
| 214 | . ' config.php file.', $path['path'])); |
||
| 215 | } |
||
| 216 | } |
||
| 217 | |||
| 218 | // set the right include path |
||
| 219 | set_include_path( |
||
| 220 | implode(PATH_SEPARATOR, $paths) |
||
| 221 | ); |
||
| 222 | } |
||
| 223 | |||
| 224 | public static function checkConfig() { |
||
| 225 | $l = \OC::$server->getL10N('lib'); |
||
| 226 | |||
| 227 | // Create config if it does not already exist |
||
| 228 | $configFilePath = self::$configDir .'/config.php'; |
||
| 229 | if(!file_exists($configFilePath)) { |
||
| 230 | @touch($configFilePath); |
||
|
|
|||
| 231 | } |
||
| 232 | |||
| 233 | // Check if config is writable |
||
| 234 | $configFileWritable = is_writable($configFilePath); |
||
| 235 | if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() |
||
| 236 | || !$configFileWritable && self::checkUpgrade(false)) { |
||
| 237 | |||
| 238 | $urlGenerator = \OC::$server->getURLGenerator(); |
||
| 239 | |||
| 240 | if (self::$CLI) { |
||
| 241 | echo $l->t('Cannot write into "config" directory!')."\n"; |
||
| 242 | echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
||
| 243 | echo "\n"; |
||
| 244 | echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-dir_permissions') ])."\n"; |
||
| 245 | exit; |
||
| 246 | } else { |
||
| 247 | OC_Template::printErrorPage( |
||
| 248 | $l->t('Cannot write into "config" directory!'), |
||
| 249 | $l->t('This can usually be fixed by giving the webserver write access to the config directory. See %s', |
||
| 250 | [ $urlGenerator->linkToDocs('admin-dir_permissions') ]) |
||
| 251 | ); |
||
| 252 | } |
||
| 253 | } |
||
| 254 | } |
||
| 255 | |||
| 256 | public static function checkInstalled() { |
||
| 257 | if (defined('OC_CONSOLE')) { |
||
| 258 | return; |
||
| 259 | } |
||
| 260 | // Redirect to installer if not installed |
||
| 261 | if (!\OC::$server->getSystemConfig()->getValue('installed', false) && OC::$SUBURI !== '/index.php' && OC::$SUBURI !== '/status.php') { |
||
| 262 | if (OC::$CLI) { |
||
| 263 | throw new Exception('Not installed'); |
||
| 264 | } else { |
||
| 265 | $url = OC::$WEBROOT . '/index.php'; |
||
| 266 | header('Location: ' . $url); |
||
| 267 | } |
||
| 268 | exit(); |
||
| 269 | } |
||
| 270 | } |
||
| 271 | |||
| 272 | public static function checkMaintenanceMode() { |
||
| 273 | // Allow ajax update script to execute without being stopped |
||
| 274 | if (\OC::$server->getSystemConfig()->getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php') { |
||
| 275 | // send http status 503 |
||
| 276 | header('HTTP/1.1 503 Service Temporarily Unavailable'); |
||
| 277 | header('Status: 503 Service Temporarily Unavailable'); |
||
| 278 | header('Retry-After: 120'); |
||
| 279 | |||
| 280 | // render error page |
||
| 281 | $template = new OC_Template('', 'update.user', 'guest'); |
||
| 282 | OC_Util::addScript('maintenance-check'); |
||
| 283 | $template->printPage(); |
||
| 284 | die(); |
||
| 285 | } |
||
| 286 | } |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Checks if the version requires an update and shows |
||
| 290 | * @param bool $showTemplate Whether an update screen should get shown |
||
| 291 | * @return bool|void |
||
| 292 | */ |
||
| 293 | public static function checkUpgrade($showTemplate = true) { |
||
| 294 | if (\OCP\Util::needUpgrade()) { |
||
| 295 | $systemConfig = \OC::$server->getSystemConfig(); |
||
| 296 | if ($showTemplate && !$systemConfig->getValue('maintenance', false)) { |
||
| 297 | self::printUpgradePage(); |
||
| 298 | exit(); |
||
| 299 | } else { |
||
| 300 | return true; |
||
| 301 | } |
||
| 302 | } |
||
| 303 | return false; |
||
| 304 | } |
||
| 305 | |||
| 306 | /** |
||
| 307 | * Prints the upgrade page |
||
| 308 | */ |
||
| 309 | private static function printUpgradePage() { |
||
| 310 | $systemConfig = \OC::$server->getSystemConfig(); |
||
| 311 | |||
| 312 | $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false); |
||
| 313 | $tooBig = false; |
||
| 314 | if (!$disableWebUpdater) { |
||
| 315 | $apps = \OC::$server->getAppManager(); |
||
| 316 | $tooBig = false; |
||
| 317 | View Code Duplication | if ($apps->isInstalled('user_ldap')) { |
|
| 318 | $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
||
| 319 | |||
| 320 | $result = $qb->selectAlias($qb->createFunction('COUNT(*)'), 'user_count') |
||
| 321 | ->from('ldap_user_mapping') |
||
| 322 | ->execute(); |
||
| 323 | $row = $result->fetch(); |
||
| 324 | $result->closeCursor(); |
||
| 325 | |||
| 326 | $tooBig = ($row['user_count'] > 50); |
||
| 327 | } |
||
| 328 | View Code Duplication | if (!$tooBig && $apps->isInstalled('user_saml')) { |
|
| 329 | $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
||
| 330 | |||
| 331 | $result = $qb->selectAlias($qb->createFunction('COUNT(*)'), 'user_count') |
||
| 332 | ->from('user_saml_users') |
||
| 333 | ->execute(); |
||
| 334 | $row = $result->fetch(); |
||
| 335 | $result->closeCursor(); |
||
| 336 | |||
| 337 | $tooBig = ($row['user_count'] > 50); |
||
| 338 | } |
||
| 339 | if (!$tooBig) { |
||
| 340 | // count users |
||
| 341 | $stats = \OC::$server->getUserManager()->countUsers(); |
||
| 342 | $totalUsers = array_sum($stats); |
||
| 343 | $tooBig = ($totalUsers > 50); |
||
| 344 | } |
||
| 345 | } |
||
| 346 | $ignoreTooBigWarning = isset($_GET['IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup']) && |
||
| 347 | $_GET['IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup'] === 'IAmSuperSureToDoThis'; |
||
| 348 | |||
| 349 | if ($disableWebUpdater || ($tooBig && !$ignoreTooBigWarning)) { |
||
| 350 | // send http status 503 |
||
| 351 | header('HTTP/1.1 503 Service Temporarily Unavailable'); |
||
| 352 | header('Status: 503 Service Temporarily Unavailable'); |
||
| 353 | header('Retry-After: 120'); |
||
| 354 | |||
| 355 | // render error page |
||
| 356 | $template = new OC_Template('', 'update.use-cli', 'guest'); |
||
| 357 | $template->assign('productName', 'nextcloud'); // for now |
||
| 358 | $template->assign('version', OC_Util::getVersionString()); |
||
| 359 | $template->assign('tooBig', $tooBig); |
||
| 360 | |||
| 361 | $template->printPage(); |
||
| 362 | die(); |
||
| 363 | } |
||
| 364 | |||
| 365 | // check whether this is a core update or apps update |
||
| 366 | $installedVersion = $systemConfig->getValue('version', '0.0.0'); |
||
| 367 | $currentVersion = implode('.', \OCP\Util::getVersion()); |
||
| 368 | |||
| 369 | // if not a core upgrade, then it's apps upgrade |
||
| 370 | $isAppsOnlyUpgrade = (version_compare($currentVersion, $installedVersion, '=')); |
||
| 371 | |||
| 372 | $oldTheme = $systemConfig->getValue('theme'); |
||
| 373 | $systemConfig->setValue('theme', ''); |
||
| 374 | OC_Util::addScript('config'); // needed for web root |
||
| 375 | OC_Util::addScript('update'); |
||
| 376 | |||
| 377 | /** @var \OC\App\AppManager $appManager */ |
||
| 378 | $appManager = \OC::$server->getAppManager(); |
||
| 379 | |||
| 380 | $tmpl = new OC_Template('', 'update.admin', 'guest'); |
||
| 381 | $tmpl->assign('version', OC_Util::getVersionString()); |
||
| 382 | $tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade); |
||
| 383 | |||
| 384 | // get third party apps |
||
| 385 | $ocVersion = \OCP\Util::getVersion(); |
||
| 386 | $incompatibleApps = $appManager->getIncompatibleApps($ocVersion); |
||
| 387 | $incompatibleShippedApps = []; |
||
| 388 | foreach ($incompatibleApps as $appInfo) { |
||
| 389 | if ($appManager->isShipped($appInfo['id'])) { |
||
| 390 | $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
||
| 391 | } |
||
| 392 | } |
||
| 393 | |||
| 394 | if (!empty($incompatibleShippedApps)) { |
||
| 395 | $l = \OC::$server->getL10N('core'); |
||
| 396 | $hint = $l->t('The files of the app %$1s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); |
||
| 397 | throw new \OC\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint); |
||
| 398 | } |
||
| 399 | |||
| 400 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
||
| 401 | $tmpl->assign('incompatibleAppsList', $incompatibleApps); |
||
| 402 | $tmpl->assign('productName', 'Nextcloud'); // for now |
||
| 403 | $tmpl->assign('oldTheme', $oldTheme); |
||
| 404 | $tmpl->printPage(); |
||
| 405 | } |
||
| 406 | |||
| 407 | public static function initSession() { |
||
| 453 | |||
| 454 | /** |
||
| 455 | * @return string |
||
| 456 | */ |
||
| 457 | private static function getSessionLifeTime() { |
||
| 460 | |||
| 461 | public static function loadAppClassPaths() { |
||
| 474 | |||
| 475 | /** |
||
| 476 | * Try to set some values to the required Nextcloud default |
||
| 477 | */ |
||
| 478 | public static function setRequiredIniValues() { |
||
| 482 | |||
| 483 | /** |
||
| 484 | * Send the same site cookies |
||
| 485 | */ |
||
| 486 | private static function sendSameSiteCookies() { |
||
| 487 | $cookieParams = session_get_cookie_params(); |
||
| 488 | $secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : ''; |
||
| 489 | $policies = [ |
||
| 490 | 'lax', |
||
| 491 | 'strict', |
||
| 492 | ]; |
||
| 493 | |||
| 494 | // Append __Host to the cookie if it meets the requirements |
||
| 495 | $cookiePrefix = ''; |
||
| 496 | if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
||
| 497 | $cookiePrefix = '__Host-'; |
||
| 498 | } |
||
| 499 | |||
| 500 | foreach($policies as $policy) { |
||
| 501 | header( |
||
| 502 | sprintf( |
||
| 503 | 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
||
| 504 | $cookiePrefix, |
||
| 505 | $policy, |
||
| 506 | $cookieParams['path'], |
||
| 507 | $policy |
||
| 508 | ), |
||
| 509 | false |
||
| 510 | ); |
||
| 511 | } |
||
| 512 | } |
||
| 513 | |||
| 514 | /** |
||
| 515 | * Same Site cookie to further mitigate CSRF attacks. This cookie has to |
||
| 516 | * be set in every request if cookies are sent to add a second level of |
||
| 517 | * defense against CSRF. |
||
| 518 | * |
||
| 519 | * If the cookie is not sent this will set the cookie and reload the page. |
||
| 520 | * We use an additional cookie since we want to protect logout CSRF and |
||
| 521 | * also we can't directly interfere with PHP's session mechanism. |
||
| 522 | */ |
||
| 523 | private static function performSameSiteCookieProtection() { |
||
| 524 | $request = \OC::$server->getRequest(); |
||
| 525 | |||
| 526 | // Some user agents are notorious and don't really properly follow HTTP |
||
| 527 | // specifications. For those, have an automated opt-out. Since the protection |
||
| 528 | // for remote.php is applied in base.php as starting point we need to opt out |
||
| 529 | // here. |
||
| 530 | $incompatibleUserAgents = [ |
||
| 531 | // OS X Finder |
||
| 532 | '/^WebDAVFS/', |
||
| 533 | ]; |
||
| 534 | if($request->isUserAgent($incompatibleUserAgents)) { |
||
| 535 | return; |
||
| 536 | } |
||
| 537 | |||
| 538 | if(count($_COOKIE) > 0) { |
||
| 539 | $requestUri = $request->getScriptName(); |
||
| 540 | $processingScript = explode('/', $requestUri); |
||
| 541 | $processingScript = $processingScript[count($processingScript)-1]; |
||
| 542 | // FIXME: In a SAML scenario we don't get any strict or lax cookie |
||
| 543 | // send for the ACS endpoint. Since we have some legacy code in Nextcloud |
||
| 544 | // (direct PHP files) the enforcement of lax cookies is performed here |
||
| 545 | // instead of the middleware. |
||
| 546 | // |
||
| 547 | // This means we cannot exclude some routes from the cookie validation, |
||
| 548 | // which normally is not a problem but is a little bit cumbersome for |
||
| 549 | // this use-case. |
||
| 550 | // Once the old legacy PHP endpoints have been removed we can move |
||
| 551 | // the verification into a middleware and also adds some exemptions. |
||
| 552 | // |
||
| 553 | // Questions about this code? Ask Lukas ;-) |
||
| 554 | $currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
||
| 555 | if($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
||
| 556 | return; |
||
| 557 | } |
||
| 558 | // For the "index.php" endpoint only a lax cookie is required. |
||
| 559 | if($processingScript === 'index.php') { |
||
| 560 | if(!$request->passesLaxCookieCheck()) { |
||
| 561 | self::sendSameSiteCookies(); |
||
| 562 | header('Location: '.$_SERVER['REQUEST_URI']); |
||
| 563 | exit(); |
||
| 564 | } |
||
| 565 | } else { |
||
| 566 | // All other endpoints require the lax and the strict cookie |
||
| 567 | if(!$request->passesStrictCookieCheck()) { |
||
| 568 | self::sendSameSiteCookies(); |
||
| 569 | // Debug mode gets access to the resources without strict cookie |
||
| 570 | // due to the fact that the SabreDAV browser also lives there. |
||
| 571 | if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
||
| 572 | http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
||
| 573 | exit(); |
||
| 574 | } |
||
| 575 | } |
||
| 576 | } |
||
| 577 | } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
||
| 578 | self::sendSameSiteCookies(); |
||
| 579 | } |
||
| 580 | } |
||
| 581 | |||
| 582 | public static function init() { |
||
| 583 | // calculate the root directories |
||
| 584 | OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4)); |
||
| 585 | |||
| 586 | // register autoloader |
||
| 587 | $loaderStart = microtime(true); |
||
| 588 | require_once __DIR__ . '/autoloader.php'; |
||
| 589 | self::$loader = new \OC\Autoloader([ |
||
| 590 | OC::$SERVERROOT . '/lib/private/legacy', |
||
| 591 | ]); |
||
| 592 | if (defined('PHPUNIT_RUN')) { |
||
| 593 | self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
||
| 594 | } |
||
| 595 | spl_autoload_register(array(self::$loader, 'load')); |
||
| 596 | $loaderEnd = microtime(true); |
||
| 597 | |||
| 598 | self::$CLI = (php_sapi_name() == 'cli'); |
||
| 599 | |||
| 600 | // Add default composer PSR-4 autoloader |
||
| 601 | self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
||
| 602 | |||
| 603 | try { |
||
| 604 | self::initPaths(); |
||
| 605 | // setup 3rdparty autoloader |
||
| 606 | $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
||
| 607 | if (!file_exists($vendorAutoLoad)) { |
||
| 608 | throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".'); |
||
| 609 | } |
||
| 610 | require_once $vendorAutoLoad; |
||
| 611 | |||
| 612 | } catch (\RuntimeException $e) { |
||
| 613 | if (!self::$CLI) { |
||
| 614 | $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
||
| 615 | $protocol = in_array($claimedProtocol, ['HTTP/1.0', 'HTTP/1.1', 'HTTP/2']) ? $claimedProtocol : 'HTTP/1.1'; |
||
| 616 | header($protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE); |
||
| 617 | } |
||
| 618 | // we can't use the template error page here, because this needs the |
||
| 619 | // DI container which isn't available yet |
||
| 620 | print($e->getMessage()); |
||
| 621 | exit(); |
||
| 622 | } |
||
| 623 | |||
| 624 | // setup the basic server |
||
| 625 | self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); |
||
| 626 | \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); |
||
| 627 | \OC::$server->getEventLogger()->start('boot', 'Initialize'); |
||
| 628 | |||
| 629 | // Don't display errors and log them |
||
| 630 | error_reporting(E_ALL | E_STRICT); |
||
| 631 | @ini_set('display_errors', 0); |
||
| 632 | @ini_set('log_errors', 1); |
||
| 633 | |||
| 634 | if(!date_default_timezone_set('UTC')) { |
||
| 635 | throw new \RuntimeException('Could not set timezone to UTC'); |
||
| 636 | }; |
||
| 637 | |||
| 638 | //try to configure php to enable big file uploads. |
||
| 639 | //this doesn´t work always depending on the webserver and php configuration. |
||
| 640 | //Let´s try to overwrite some defaults anyway |
||
| 641 | |||
| 642 | //try to set the maximum execution time to 60min |
||
| 643 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
||
| 644 | @set_time_limit(3600); |
||
| 645 | } |
||
| 646 | @ini_set('max_execution_time', 3600); |
||
| 647 | @ini_set('max_input_time', 3600); |
||
| 648 | |||
| 649 | //try to set the maximum filesize to 10G |
||
| 650 | @ini_set('upload_max_filesize', '10G'); |
||
| 651 | @ini_set('post_max_size', '10G'); |
||
| 652 | @ini_set('file_uploads', '50'); |
||
| 653 | |||
| 654 | self::setRequiredIniValues(); |
||
| 655 | self::handleAuthHeaders(); |
||
| 656 | self::registerAutoloaderCache(); |
||
| 657 | |||
| 658 | // initialize intl fallback is necessary |
||
| 659 | \Patchwork\Utf8\Bootup::initIntl(); |
||
| 660 | OC_Util::isSetLocaleWorking(); |
||
| 661 | |||
| 662 | if (!defined('PHPUNIT_RUN')) { |
||
| 663 | OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger()); |
||
| 664 | $debug = \OC::$server->getConfig()->getSystemValue('debug', false); |
||
| 665 | OC\Log\ErrorHandler::register($debug); |
||
| 666 | } |
||
| 667 | |||
| 668 | \OC::$server->getEventLogger()->start('init_session', 'Initialize session'); |
||
| 669 | OC_App::loadApps(array('session')); |
||
| 670 | if (!self::$CLI) { |
||
| 671 | self::initSession(); |
||
| 672 | } |
||
| 673 | \OC::$server->getEventLogger()->end('init_session'); |
||
| 674 | self::checkConfig(); |
||
| 675 | self::checkInstalled(); |
||
| 676 | |||
| 677 | OC_Response::addSecurityHeaders(); |
||
| 678 | if(self::$server->getRequest()->getServerProtocol() === 'https') { |
||
| 679 | ini_set('session.cookie_secure', true); |
||
| 680 | } |
||
| 681 | |||
| 682 | self::performSameSiteCookieProtection(); |
||
| 683 | |||
| 684 | if (!defined('OC_CONSOLE')) { |
||
| 685 | $errors = OC_Util::checkServer(\OC::$server->getSystemConfig()); |
||
| 686 | if (count($errors) > 0) { |
||
| 687 | if (self::$CLI) { |
||
| 688 | // Convert l10n string into regular string for usage in database |
||
| 689 | $staticErrors = []; |
||
| 690 | foreach ($errors as $error) { |
||
| 691 | echo $error['error'] . "\n"; |
||
| 692 | echo $error['hint'] . "\n\n"; |
||
| 693 | $staticErrors[] = [ |
||
| 694 | 'error' => (string)$error['error'], |
||
| 695 | 'hint' => (string)$error['hint'], |
||
| 696 | ]; |
||
| 697 | } |
||
| 698 | |||
| 699 | try { |
||
| 700 | \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); |
||
| 701 | } catch (\Exception $e) { |
||
| 702 | echo('Writing to database failed'); |
||
| 703 | } |
||
| 704 | exit(1); |
||
| 705 | } else { |
||
| 706 | OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); |
||
| 707 | OC_Util::addStyle('guest'); |
||
| 708 | OC_Template::printGuestPage('', 'error', array('errors' => $errors)); |
||
| 709 | exit; |
||
| 710 | } |
||
| 711 | View Code Duplication | } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { |
|
| 712 | \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); |
||
| 713 | } |
||
| 714 | } |
||
| 715 | //try to set the session lifetime |
||
| 716 | $sessionLifeTime = self::getSessionLifeTime(); |
||
| 717 | @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
||
| 718 | |||
| 719 | $systemConfig = \OC::$server->getSystemConfig(); |
||
| 720 | |||
| 721 | // User and Groups |
||
| 722 | if (!$systemConfig->getValue("installed", false)) { |
||
| 723 | self::$server->getSession()->set('user_id', ''); |
||
| 724 | } |
||
| 725 | |||
| 726 | OC_User::useBackend(new \OC\User\Database()); |
||
| 727 | \OC::$server->getGroupManager()->addBackend(new \OC\Group\Database()); |
||
| 728 | |||
| 729 | // Subscribe to the hook |
||
| 730 | \OCP\Util::connectHook( |
||
| 731 | '\OCA\Files_Sharing\API\Server2Server', |
||
| 732 | 'preLoginNameUsedAsUserName', |
||
| 733 | '\OC\User\Database', |
||
| 734 | 'preLoginNameUsedAsUserName' |
||
| 735 | ); |
||
| 736 | |||
| 737 | //setup extra user backends |
||
| 738 | if (!self::checkUpgrade(false)) { |
||
| 739 | OC_User::setupBackends(); |
||
| 740 | } else { |
||
| 741 | // Run upgrades in incognito mode |
||
| 742 | OC_User::setIncognitoMode(true); |
||
| 743 | } |
||
| 744 | |||
| 745 | self::registerCacheHooks(); |
||
| 746 | self::registerFilesystemHooks(); |
||
| 747 | self::registerShareHooks(); |
||
| 748 | self::registerLogRotate(); |
||
| 749 | self::registerEncryptionWrapper(); |
||
| 750 | self::registerEncryptionHooks(); |
||
| 751 | self::registerAccountHooks(); |
||
| 752 | self::registerSettingsHooks(); |
||
| 753 | |||
| 754 | $settings = new \OC\Settings\Application(); |
||
| 755 | $settings->register(); |
||
| 756 | |||
| 757 | //make sure temporary files are cleaned up |
||
| 758 | $tmpManager = \OC::$server->getTempManager(); |
||
| 759 | register_shutdown_function(array($tmpManager, 'clean')); |
||
| 760 | $lockProvider = \OC::$server->getLockingProvider(); |
||
| 761 | register_shutdown_function(array($lockProvider, 'releaseAll')); |
||
| 762 | |||
| 763 | // Check whether the sample configuration has been copied |
||
| 764 | if($systemConfig->getValue('copied_sample_config', false)) { |
||
| 765 | $l = \OC::$server->getL10N('lib'); |
||
| 766 | header('HTTP/1.1 503 Service Temporarily Unavailable'); |
||
| 767 | header('Status: 503 Service Temporarily Unavailable'); |
||
| 768 | OC_Template::printErrorPage( |
||
| 769 | $l->t('Sample configuration detected'), |
||
| 770 | $l->t('It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php') |
||
| 771 | ); |
||
| 772 | return; |
||
| 773 | } |
||
| 774 | |||
| 775 | $request = \OC::$server->getRequest(); |
||
| 776 | $host = $request->getInsecureServerHost(); |
||
| 777 | /** |
||
| 778 | * if the host passed in headers isn't trusted |
||
| 779 | * FIXME: Should not be in here at all :see_no_evil: |
||
| 780 | */ |
||
| 781 | if (!OC::$CLI |
||
| 782 | // overwritehost is always trusted, workaround to not have to make |
||
| 783 | // \OC\AppFramework\Http\Request::getOverwriteHost public |
||
| 784 | && self::$server->getConfig()->getSystemValue('overwritehost') === '' |
||
| 785 | && !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host) |
||
| 786 | && self::$server->getConfig()->getSystemValue('installed', false) |
||
| 787 | ) { |
||
| 788 | // Allow access to CSS resources |
||
| 789 | $isScssRequest = false; |
||
| 790 | if(strpos($request->getPathInfo(), '/css/') === 0) { |
||
| 791 | $isScssRequest = true; |
||
| 792 | } |
||
| 793 | |||
| 794 | if (!$isScssRequest) { |
||
| 795 | header('HTTP/1.1 400 Bad Request'); |
||
| 796 | header('Status: 400 Bad Request'); |
||
| 797 | |||
| 798 | \OC::$server->getLogger()->warning( |
||
| 799 | 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host.', |
||
| 800 | [ |
||
| 801 | 'app' => 'core', |
||
| 802 | 'remoteAddress' => $request->getRemoteAddress(), |
||
| 803 | 'host' => $host, |
||
| 804 | ] |
||
| 805 | ); |
||
| 806 | |||
| 807 | $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); |
||
| 808 | $tmpl->assign('domain', $host); |
||
| 809 | $tmpl->printPage(); |
||
| 810 | |||
| 811 | exit(); |
||
| 812 | } |
||
| 813 | } |
||
| 814 | \OC::$server->getEventLogger()->end('boot'); |
||
| 815 | } |
||
| 816 | |||
| 817 | /** |
||
| 818 | * register hooks for the cache |
||
| 819 | */ |
||
| 820 | public static function registerCacheHooks() { |
||
| 821 | //don't try to do this before we are properly setup |
||
| 822 | if (\OC::$server->getSystemConfig()->getValue('installed', false) && !self::checkUpgrade(false)) { |
||
| 823 | |||
| 824 | // NOTE: This will be replaced to use OCP |
||
| 825 | $userSession = self::$server->getUserSession(); |
||
| 826 | $userSession->listen('\OC\User', 'postLogin', function () { |
||
| 827 | try { |
||
| 828 | $cache = new \OC\Cache\File(); |
||
| 829 | $cache->gc(); |
||
| 830 | } catch (\OC\ServerNotAvailableException $e) { |
||
| 831 | // not a GC exception, pass it on |
||
| 832 | throw $e; |
||
| 833 | } catch (\OC\ForbiddenException $e) { |
||
| 834 | // filesystem blocked for this request, ignore |
||
| 835 | } catch (\Exception $e) { |
||
| 836 | // a GC exception should not prevent users from using OC, |
||
| 837 | // so log the exception |
||
| 838 | \OC::$server->getLogger()->warning('Exception when running cache gc: ' . $e->getMessage(), array('app' => 'core')); |
||
| 839 | } |
||
| 840 | }); |
||
| 841 | } |
||
| 842 | } |
||
| 843 | |||
| 844 | public static function registerSettingsHooks() { |
||
| 845 | $dispatcher = \OC::$server->getEventDispatcher(); |
||
| 846 | $dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_DISABLE, function($event) { |
||
| 847 | /** @var \OCP\App\ManagerEvent $event */ |
||
| 848 | \OC::$server->getSettingsManager()->onAppDisabled($event->getAppID()); |
||
| 849 | }); |
||
| 850 | $dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_UPDATE, function($event) { |
||
| 851 | /** @var \OCP\App\ManagerEvent $event */ |
||
| 852 | $jobList = \OC::$server->getJobList(); |
||
| 853 | $job = 'OC\\Settings\\RemoveOrphaned'; |
||
| 854 | if(!($jobList->has($job, null))) { |
||
| 855 | $jobList->add($job); |
||
| 856 | } |
||
| 857 | }); |
||
| 858 | } |
||
| 859 | |||
| 860 | private static function registerEncryptionWrapper() { |
||
| 861 | $manager = self::$server->getEncryptionManager(); |
||
| 862 | \OCP\Util::connectHook('OC_Filesystem', 'preSetup', $manager, 'setupStorage'); |
||
| 863 | } |
||
| 864 | |||
| 865 | private static function registerEncryptionHooks() { |
||
| 866 | $enabled = self::$server->getEncryptionManager()->isEnabled(); |
||
| 867 | if ($enabled) { |
||
| 868 | \OCP\Util::connectHook('OCP\Share', 'post_shared', 'OC\Encryption\HookManager', 'postShared'); |
||
| 869 | \OCP\Util::connectHook('OCP\Share', 'post_unshare', 'OC\Encryption\HookManager', 'postUnshared'); |
||
| 870 | \OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OC\Encryption\HookManager', 'postRename'); |
||
| 871 | \OCP\Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', 'OC\Encryption\HookManager', 'postRestore'); |
||
| 872 | } |
||
| 873 | } |
||
| 874 | |||
| 875 | private static function registerAccountHooks() { |
||
| 876 | $hookHandler = new \OC\Accounts\Hooks(\OC::$server->getLogger()); |
||
| 877 | \OCP\Util::connectHook('OC_User', 'changeUser', $hookHandler, 'changeUserHook'); |
||
| 878 | } |
||
| 879 | |||
| 880 | /** |
||
| 881 | * register hooks for the cache |
||
| 882 | */ |
||
| 883 | public static function registerLogRotate() { |
||
| 884 | $systemConfig = \OC::$server->getSystemConfig(); |
||
| 885 | if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) { |
||
| 886 | //don't try to do this before we are properly setup |
||
| 887 | //use custom logfile path if defined, otherwise use default of nextcloud.log in data directory |
||
| 888 | \OC::$server->getJobList()->add('OC\Log\Rotate'); |
||
| 889 | } |
||
| 890 | } |
||
| 891 | |||
| 892 | /** |
||
| 893 | * register hooks for the filesystem |
||
| 894 | */ |
||
| 895 | public static function registerFilesystemHooks() { |
||
| 896 | // Check for blacklisted files |
||
| 897 | OC_Hook::connect('OC_Filesystem', 'write', 'OC\Files\Filesystem', 'isBlacklisted'); |
||
| 898 | OC_Hook::connect('OC_Filesystem', 'rename', 'OC\Files\Filesystem', 'isBlacklisted'); |
||
| 899 | } |
||
| 900 | |||
| 901 | /** |
||
| 902 | * register hooks for sharing |
||
| 903 | */ |
||
| 904 | public static function registerShareHooks() { |
||
| 911 | |||
| 912 | protected static function registerAutoloaderCache() { |
||
| 928 | |||
| 929 | /** |
||
| 930 | * Handle the request |
||
| 931 | */ |
||
| 932 | public static function handleRequest() { |
||
| 933 | |||
| 934 | \OC::$server->getEventLogger()->start('handle_request', 'Handle request'); |
||
| 935 | $systemConfig = \OC::$server->getSystemConfig(); |
||
| 936 | // load all the classpaths from the enabled apps so they are available |
||
| 937 | // in the routing files of each app |
||
| 938 | OC::loadAppClassPaths(); |
||
| 939 | |||
| 940 | // Check if Nextcloud is installed or in maintenance (update) mode |
||
| 941 | if (!$systemConfig->getValue('installed', false)) { |
||
| 942 | \OC::$server->getSession()->clear(); |
||
| 943 | $setupHelper = new OC\Setup(\OC::$server->getSystemConfig(), \OC::$server->getIniWrapper(), |
||
| 944 | \OC::$server->getL10N('lib'), \OC::$server->query(\OCP\Defaults::class), \OC::$server->getLogger(), |
||
| 945 | \OC::$server->getSecureRandom()); |
||
| 946 | $controller = new OC\Core\Controller\SetupController($setupHelper); |
||
| 947 | $controller->run($_POST); |
||
| 948 | exit(); |
||
| 949 | } |
||
| 950 | |||
| 951 | $request = \OC::$server->getRequest(); |
||
| 952 | $requestPath = $request->getRawPathInfo(); |
||
| 953 | if ($requestPath === '/heartbeat') { |
||
| 954 | return; |
||
| 955 | } |
||
| 956 | if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade |
||
| 957 | self::checkMaintenanceMode(); |
||
| 958 | self::checkUpgrade(); |
||
| 959 | } |
||
| 960 | |||
| 961 | // emergency app disabling |
||
| 962 | if ($requestPath === '/disableapp' |
||
| 963 | && $request->getMethod() === 'POST' |
||
| 964 | && ((array)$request->getParam('appid')) !== '' |
||
| 965 | ) { |
||
| 966 | \OCP\JSON::callCheck(); |
||
| 967 | \OCP\JSON::checkAdminUser(); |
||
| 968 | $appIds = (array)$request->getParam('appid'); |
||
| 969 | foreach($appIds as $appId) { |
||
| 970 | $appId = \OC_App::cleanAppId($appId); |
||
| 971 | \OC_App::disable($appId); |
||
| 972 | } |
||
| 973 | \OC_JSON::success(); |
||
| 974 | exit(); |
||
| 975 | } |
||
| 976 | |||
| 977 | // Always load authentication apps |
||
| 978 | OC_App::loadApps(['authentication']); |
||
| 979 | |||
| 980 | // Load minimum set of apps |
||
| 981 | if (!self::checkUpgrade(false) |
||
| 982 | && !$systemConfig->getValue('maintenance', false)) { |
||
| 983 | // For logged-in users: Load everything |
||
| 984 | if(\OC::$server->getUserSession()->isLoggedIn()) { |
||
| 985 | OC_App::loadApps(); |
||
| 986 | } else { |
||
| 987 | // For guests: Load only filesystem and logging |
||
| 988 | OC_App::loadApps(array('filesystem', 'logging')); |
||
| 989 | self::handleLogin($request); |
||
| 990 | } |
||
| 991 | } |
||
| 992 | |||
| 993 | if (!self::$CLI) { |
||
| 994 | try { |
||
| 995 | if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) { |
||
| 996 | OC_App::loadApps(array('filesystem', 'logging')); |
||
| 997 | OC_App::loadApps(); |
||
| 998 | } |
||
| 999 | OC_Util::setupFS(); |
||
| 1000 | OC::$server->getRouter()->match(\OC::$server->getRequest()->getRawPathInfo()); |
||
| 1001 | return; |
||
| 1002 | } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { |
||
| 1003 | //header('HTTP/1.0 404 Not Found'); |
||
| 1004 | } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { |
||
| 1005 | OC_Response::setStatus(405); |
||
| 1006 | return; |
||
| 1007 | } |
||
| 1008 | } |
||
| 1009 | |||
| 1010 | // Handle WebDAV |
||
| 1011 | if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') { |
||
| 1012 | // not allowed any more to prevent people |
||
| 1013 | // mounting this root directly. |
||
| 1014 | // Users need to mount remote.php/webdav instead. |
||
| 1015 | header('HTTP/1.1 405 Method Not Allowed'); |
||
| 1016 | header('Status: 405 Method Not Allowed'); |
||
| 1017 | return; |
||
| 1018 | } |
||
| 1019 | |||
| 1020 | // Someone is logged in |
||
| 1021 | if (\OC::$server->getUserSession()->isLoggedIn()) { |
||
| 1022 | OC_App::loadApps(); |
||
| 1023 | OC_User::setupBackends(); |
||
| 1024 | OC_Util::setupFS(); |
||
| 1025 | // FIXME |
||
| 1026 | // Redirect to default application |
||
| 1027 | OC_Util::redirectToDefaultPage(); |
||
| 1028 | } else { |
||
| 1029 | // Not handled and not logged in |
||
| 1030 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute('core.login.showLoginForm')); |
||
| 1031 | } |
||
| 1032 | } |
||
| 1033 | |||
| 1034 | /** |
||
| 1035 | * Check login: apache auth, auth token, basic auth |
||
| 1036 | * |
||
| 1037 | * @param OCP\IRequest $request |
||
| 1038 | * @return boolean |
||
| 1039 | */ |
||
| 1040 | static function handleLogin(OCP\IRequest $request) { |
||
| 1059 | |||
| 1060 | protected static function handleAuthHeaders() { |
||
| 1080 | } |
||
| 1081 | |||
| 1082 | OC::init(); |
||
| 1083 |
If you suppress an error, we recommend checking for the error condition explicitly: