@@ -128,14 +128,14 @@ discard block |
||
| 128 | 128 | * the app path list is empty or contains an invalid path |
| 129 | 129 | */ |
| 130 | 130 | public static function initPaths() { |
| 131 | - if(defined('PHPUNIT_CONFIG_DIR')) { |
|
| 132 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
| 133 | - } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
| 134 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
| 135 | - } elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
| 136 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
| 131 | + if (defined('PHPUNIT_CONFIG_DIR')) { |
|
| 132 | + self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/'; |
|
| 133 | + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) { |
|
| 134 | + self::$configDir = OC::$SERVERROOT.'/tests/config/'; |
|
| 135 | + } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
| 136 | + self::$configDir = rtrim($dir, '/').'/'; |
|
| 137 | 137 | } else { |
| 138 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
| 138 | + self::$configDir = OC::$SERVERROOT.'/config/'; |
|
| 139 | 139 | } |
| 140 | 140 | self::$config = new \OC\Config(self::$configDir); |
| 141 | 141 | |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | //make sure suburi follows the same rules as scriptName |
| 158 | 158 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
| 159 | 159 | if (substr(OC::$SUBURI, -1) != '/') { |
| 160 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
| 160 | + OC::$SUBURI = OC::$SUBURI.'/'; |
|
| 161 | 161 | } |
| 162 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
| 162 | + OC::$SUBURI = OC::$SUBURI.'index.php'; |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
| 172 | 172 | |
| 173 | 173 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
| 174 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
| 174 | + OC::$WEBROOT = '/'.OC::$WEBROOT; |
|
| 175 | 175 | } |
| 176 | 176 | } else { |
| 177 | 177 | // The scriptName is not ending with OC::$SUBURI |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | OC::$APPSROOTS[] = $paths; |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
| 204 | - OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true); |
|
| 205 | - } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
| 203 | + } elseif (file_exists(OC::$SERVERROOT.'/apps')) { |
|
| 204 | + OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true); |
|
| 205 | + } elseif (file_exists(OC::$SERVERROOT.'/../apps')) { |
|
| 206 | 206 | OC::$APPSROOTS[] = array( |
| 207 | - 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
| 207 | + 'path' => rtrim(dirname(OC::$SERVERROOT), '/').'/apps', |
|
| 208 | 208 | 'url' => '/apps', |
| 209 | 209 | 'writable' => true |
| 210 | 210 | ); |
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | $l = \OC::$server->getL10N('lib'); |
| 235 | 235 | |
| 236 | 236 | // Create config if it does not already exist |
| 237 | - $configFilePath = self::$configDir .'/config.php'; |
|
| 238 | - if(!file_exists($configFilePath)) { |
|
| 237 | + $configFilePath = self::$configDir.'/config.php'; |
|
| 238 | + if (!file_exists($configFilePath)) { |
|
| 239 | 239 | @touch($configFilePath); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -249,18 +249,18 @@ discard block |
||
| 249 | 249 | if (self::$CLI) { |
| 250 | 250 | echo $l->t('Cannot write into "config" directory!')."\n"; |
| 251 | 251 | echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
| 252 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-dir_permissions') ])."\n"; |
|
| 252 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-dir_permissions')])."\n"; |
|
| 253 | 253 | echo "\n"; |
| 254 | 254 | echo $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.')."\n"; |
| 255 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ])."\n"; |
|
| 255 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')])."\n"; |
|
| 256 | 256 | exit; |
| 257 | 257 | } else { |
| 258 | 258 | OC_Template::printErrorPage( |
| 259 | 259 | $l->t('Cannot write into "config" directory!'), |
| 260 | 260 | $l->t('This can usually be fixed by giving the webserver write access to the config directory. See %s', |
| 261 | - [ $urlGenerator->linkToDocs('admin-dir_permissions') ]) . '. ' |
|
| 261 | + [$urlGenerator->linkToDocs('admin-dir_permissions')]).'. ' |
|
| 262 | 262 | . $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it. See %s', |
| 263 | - [ $urlGenerator->linkToDocs('admin-config') ] ), |
|
| 263 | + [$urlGenerator->linkToDocs('admin-config')]), |
|
| 264 | 264 | 503 |
| 265 | 265 | ); |
| 266 | 266 | } |
@@ -276,8 +276,8 @@ discard block |
||
| 276 | 276 | if (OC::$CLI) { |
| 277 | 277 | throw new Exception('Not installed'); |
| 278 | 278 | } else { |
| 279 | - $url = OC::$WEBROOT . '/index.php'; |
|
| 280 | - header('Location: ' . $url); |
|
| 279 | + $url = OC::$WEBROOT.'/index.php'; |
|
| 280 | + header('Location: '.$url); |
|
| 281 | 281 | } |
| 282 | 282 | exit(); |
| 283 | 283 | } |
@@ -382,14 +382,14 @@ discard block |
||
| 382 | 382 | $incompatibleShippedApps = []; |
| 383 | 383 | foreach ($incompatibleApps as $appInfo) { |
| 384 | 384 | if ($appManager->isShipped($appInfo['id'])) { |
| 385 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
| 385 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | if (!empty($incompatibleShippedApps)) { |
| 390 | 390 | $l = \OC::$server->getL10N('core'); |
| 391 | 391 | $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)]); |
| 392 | - 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); |
|
| 392 | + 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); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | public static function initSession() { |
| 403 | - if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
| 403 | + if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
| 404 | 404 | ini_set('session.cookie_secure', true); |
| 405 | 405 | } |
| 406 | 406 | |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | ini_set('session.cookie_httponly', 'true'); |
| 409 | 409 | |
| 410 | 410 | // set the cookie path to the Nextcloud directory |
| 411 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
| 411 | + $cookie_path = OC::$WEBROOT ?: '/'; |
|
| 412 | 412 | ini_set('session.cookie_path', $cookie_path); |
| 413 | 413 | |
| 414 | 414 | // Let the session name be changed in the initSession Hook |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | // session timeout |
| 442 | 442 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
| 443 | 443 | if (isset($_COOKIE[session_name()])) { |
| 444 | - setcookie(session_name(), '', -1, self::$WEBROOT ? : '/'); |
|
| 444 | + setcookie(session_name(), '', -1, self::$WEBROOT ?: '/'); |
|
| 445 | 445 | } |
| 446 | 446 | \OC::$server->getUserSession()->logout(); |
| 447 | 447 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | continue; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - $file = $appPath . '/appinfo/classpath.php'; |
|
| 466 | + $file = $appPath.'/appinfo/classpath.php'; |
|
| 467 | 467 | if (file_exists($file)) { |
| 468 | 468 | require_once $file; |
| 469 | 469 | } |
@@ -491,14 +491,14 @@ discard block |
||
| 491 | 491 | |
| 492 | 492 | // Append __Host to the cookie if it meets the requirements |
| 493 | 493 | $cookiePrefix = ''; |
| 494 | - if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
| 494 | + if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
| 495 | 495 | $cookiePrefix = '__Host-'; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - foreach($policies as $policy) { |
|
| 498 | + foreach ($policies as $policy) { |
|
| 499 | 499 | header( |
| 500 | 500 | sprintf( |
| 501 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
| 501 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
| 502 | 502 | $cookiePrefix, |
| 503 | 503 | $policy, |
| 504 | 504 | $cookieParams['path'], |
@@ -537,31 +537,31 @@ discard block |
||
| 537 | 537 | ]; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - if($request->isUserAgent($incompatibleUserAgents)) { |
|
| 540 | + if ($request->isUserAgent($incompatibleUserAgents)) { |
|
| 541 | 541 | return; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - if(count($_COOKIE) > 0) { |
|
| 544 | + if (count($_COOKIE) > 0) { |
|
| 545 | 545 | $requestUri = $request->getScriptName(); |
| 546 | 546 | $processingScript = explode('/', $requestUri); |
| 547 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
| 547 | + $processingScript = $processingScript[count($processingScript) - 1]; |
|
| 548 | 548 | |
| 549 | 549 | // index.php routes are handled in the middleware |
| 550 | - if($processingScript === 'index.php') { |
|
| 550 | + if ($processingScript === 'index.php') { |
|
| 551 | 551 | return; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | // All other endpoints require the lax and the strict cookie |
| 555 | - if(!$request->passesStrictCookieCheck()) { |
|
| 555 | + if (!$request->passesStrictCookieCheck()) { |
|
| 556 | 556 | self::sendSameSiteCookies(); |
| 557 | 557 | // Debug mode gets access to the resources without strict cookie |
| 558 | 558 | // due to the fact that the SabreDAV browser also lives there. |
| 559 | - if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 559 | + if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 560 | 560 | http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
| 561 | 561 | exit(); |
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | - } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
| 564 | + } elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
| 565 | 565 | self::sendSameSiteCookies(); |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -572,12 +572,12 @@ discard block |
||
| 572 | 572 | |
| 573 | 573 | // register autoloader |
| 574 | 574 | $loaderStart = microtime(true); |
| 575 | - require_once __DIR__ . '/autoloader.php'; |
|
| 575 | + require_once __DIR__.'/autoloader.php'; |
|
| 576 | 576 | self::$loader = new \OC\Autoloader([ |
| 577 | - OC::$SERVERROOT . '/lib/private/legacy', |
|
| 577 | + OC::$SERVERROOT.'/lib/private/legacy', |
|
| 578 | 578 | ]); |
| 579 | 579 | if (defined('PHPUNIT_RUN')) { |
| 580 | - self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
| 580 | + self::$loader->addValidRoot(OC::$SERVERROOT.'/tests'); |
|
| 581 | 581 | } |
| 582 | 582 | spl_autoload_register(array(self::$loader, 'load')); |
| 583 | 583 | $loaderEnd = microtime(true); |
@@ -585,12 +585,12 @@ discard block |
||
| 585 | 585 | self::$CLI = (php_sapi_name() == 'cli'); |
| 586 | 586 | |
| 587 | 587 | // Add default composer PSR-4 autoloader |
| 588 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
| 588 | + self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php'; |
|
| 589 | 589 | |
| 590 | 590 | try { |
| 591 | 591 | self::initPaths(); |
| 592 | 592 | // setup 3rdparty autoloader |
| 593 | - $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
| 593 | + $vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php'; |
|
| 594 | 594 | if (!file_exists($vendorAutoLoad)) { |
| 595 | 595 | 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".'); |
| 596 | 596 | } |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | @ini_set('display_errors', '0'); |
| 617 | 617 | @ini_set('log_errors', '1'); |
| 618 | 618 | |
| 619 | - if(!date_default_timezone_set('UTC')) { |
|
| 619 | + if (!date_default_timezone_set('UTC')) { |
|
| 620 | 620 | throw new \RuntimeException('Could not set timezone to UTC'); |
| 621 | 621 | } |
| 622 | 622 | |
@@ -670,11 +670,11 @@ discard block |
||
| 670 | 670 | // Convert l10n string into regular string for usage in database |
| 671 | 671 | $staticErrors = []; |
| 672 | 672 | foreach ($errors as $error) { |
| 673 | - echo $error['error'] . "\n"; |
|
| 674 | - echo $error['hint'] . "\n\n"; |
|
| 673 | + echo $error['error']."\n"; |
|
| 674 | + echo $error['hint']."\n\n"; |
|
| 675 | 675 | $staticErrors[] = [ |
| 676 | - 'error' => (string)$error['error'], |
|
| 677 | - 'hint' => (string)$error['hint'], |
|
| 676 | + 'error' => (string) $error['error'], |
|
| 677 | + 'hint' => (string) $error['hint'], |
|
| 678 | 678 | ]; |
| 679 | 679 | } |
| 680 | 680 | |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | //try to set the session lifetime |
| 698 | 698 | $sessionLifeTime = self::getSessionLifeTime(); |
| 699 | - @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
| 699 | + @ini_set('gc_maxlifetime', (string) $sessionLifeTime); |
|
| 700 | 700 | |
| 701 | 701 | $systemConfig = \OC::$server->getSystemConfig(); |
| 702 | 702 | |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | register_shutdown_function(array($lockProvider, 'releaseAll')); |
| 745 | 745 | |
| 746 | 746 | // Check whether the sample configuration has been copied |
| 747 | - if($systemConfig->getValue('copied_sample_config', false)) { |
|
| 747 | + if ($systemConfig->getValue('copied_sample_config', false)) { |
|
| 748 | 748 | $l = \OC::$server->getL10N('lib'); |
| 749 | 749 | OC_Template::printErrorPage( |
| 750 | 750 | $l->t('Sample configuration detected'), |
@@ -769,11 +769,11 @@ discard block |
||
| 769 | 769 | ) { |
| 770 | 770 | // Allow access to CSS resources |
| 771 | 771 | $isScssRequest = false; |
| 772 | - if(strpos($request->getPathInfo(), '/css/') === 0) { |
|
| 772 | + if (strpos($request->getPathInfo(), '/css/') === 0) { |
|
| 773 | 773 | $isScssRequest = true; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - if(substr($request->getRequestUri(), -11) === '/status.php') { |
|
| 776 | + if (substr($request->getRequestUri(), -11) === '/status.php') { |
|
| 777 | 777 | http_response_code(400); |
| 778 | 778 | header('Content-Type: application/json'); |
| 779 | 779 | echo '{"error": "Trusted domain error.", "code": 15}'; |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | |
| 812 | 812 | // NOTE: This will be replaced to use OCP |
| 813 | 813 | $userSession = self::$server->getUserSession(); |
| 814 | - $userSession->listen('\OC\User', 'postLogin', function () use ($userSession) { |
|
| 814 | + $userSession->listen('\OC\User', 'postLogin', function() use ($userSession) { |
|
| 815 | 815 | if (!defined('PHPUNIT_RUN')) { |
| 816 | 816 | // reset brute force delay for this IP address and username |
| 817 | 817 | $uid = \OC::$server->getUserSession()->getUser()->getUID(); |
@@ -948,12 +948,12 @@ discard block |
||
| 948 | 948 | // emergency app disabling |
| 949 | 949 | if ($requestPath === '/disableapp' |
| 950 | 950 | && $request->getMethod() === 'POST' |
| 951 | - && ((array)$request->getParam('appid')) !== '' |
|
| 951 | + && ((array) $request->getParam('appid')) !== '' |
|
| 952 | 952 | ) { |
| 953 | 953 | \OC_JSON::callCheck(); |
| 954 | 954 | \OC_JSON::checkAdminUser(); |
| 955 | - $appIds = (array)$request->getParam('appid'); |
|
| 956 | - foreach($appIds as $appId) { |
|
| 955 | + $appIds = (array) $request->getParam('appid'); |
|
| 956 | + foreach ($appIds as $appId) { |
|
| 957 | 957 | $appId = \OC_App::cleanAppId($appId); |
| 958 | 958 | \OC::$server->getAppManager()->disableApp($appId); |
| 959 | 959 | } |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | if (!\OCP\Util::needUpgrade() |
| 969 | 969 | && !$systemConfig->getValue('maintenance', false)) { |
| 970 | 970 | // For logged-in users: Load everything |
| 971 | - if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 971 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 972 | 972 | OC_App::loadApps(); |
| 973 | 973 | } else { |
| 974 | 974 | // For guests: Load only filesystem and logging |