@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | * the app path list is empty or contains an invalid path |
136 | 136 | */ |
137 | 137 | public static function initPaths() { |
138 | - if(defined('PHPUNIT_CONFIG_DIR')) { |
|
139 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
140 | - } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
141 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
142 | - } elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
143 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
138 | + if (defined('PHPUNIT_CONFIG_DIR')) { |
|
139 | + self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/'; |
|
140 | + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) { |
|
141 | + self::$configDir = OC::$SERVERROOT.'/tests/config/'; |
|
142 | + } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
143 | + self::$configDir = rtrim($dir, '/').'/'; |
|
144 | 144 | } else { |
145 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
145 | + self::$configDir = OC::$SERVERROOT.'/config/'; |
|
146 | 146 | } |
147 | 147 | self::$config = new \OC\Config(self::$configDir); |
148 | 148 | |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | //make sure suburi follows the same rules as scriptName |
165 | 165 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
166 | 166 | if (substr(OC::$SUBURI, -1) != '/') { |
167 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
167 | + OC::$SUBURI = OC::$SUBURI.'/'; |
|
168 | 168 | } |
169 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
169 | + OC::$SUBURI = OC::$SUBURI.'index.php'; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
179 | 179 | |
180 | 180 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
181 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
181 | + OC::$WEBROOT = '/'.OC::$WEBROOT; |
|
182 | 182 | } |
183 | 183 | } else { |
184 | 184 | // The scriptName is not ending with OC::$SUBURI |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | OC::$APPSROOTS[] = $paths; |
208 | 208 | } |
209 | 209 | } |
210 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
211 | - OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true]; |
|
212 | - } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
210 | + } elseif (file_exists(OC::$SERVERROOT.'/apps')) { |
|
211 | + OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true]; |
|
212 | + } elseif (file_exists(OC::$SERVERROOT.'/../apps')) { |
|
213 | 213 | OC::$APPSROOTS[] = [ |
214 | - 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
214 | + 'path' => rtrim(dirname(OC::$SERVERROOT), '/').'/apps', |
|
215 | 215 | 'url' => '/apps', |
216 | 216 | 'writable' => true |
217 | 217 | ]; |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | $l = \OC::$server->getL10N('lib'); |
242 | 242 | |
243 | 243 | // Create config if it does not already exist |
244 | - $configFilePath = self::$configDir .'/config.php'; |
|
245 | - if(!file_exists($configFilePath)) { |
|
244 | + $configFilePath = self::$configDir.'/config.php'; |
|
245 | + if (!file_exists($configFilePath)) { |
|
246 | 246 | @touch($configFilePath); |
247 | 247 | } |
248 | 248 | |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
259 | 259 | echo "\n"; |
260 | 260 | 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"; |
261 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ])."\n"; |
|
261 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')])."\n"; |
|
262 | 262 | exit; |
263 | 263 | } else { |
264 | 264 | OC_Template::printErrorPage( |
265 | 265 | $l->t('Cannot write into "config" directory!'), |
266 | - $l->t('This can usually be fixed by giving the webserver write access to the config directory.') . '. ' |
|
266 | + $l->t('This can usually be fixed by giving the webserver write access to the config directory.').'. ' |
|
267 | 267 | . $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', |
268 | - [ $urlGenerator->linkToDocs('admin-config') ] ), |
|
268 | + [$urlGenerator->linkToDocs('admin-config')]), |
|
269 | 269 | 503 |
270 | 270 | ); |
271 | 271 | } |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | if (OC::$CLI) { |
282 | 282 | throw new Exception('Not installed'); |
283 | 283 | } else { |
284 | - $url = OC::$WEBROOT . '/index.php'; |
|
285 | - header('Location: ' . $url); |
|
284 | + $url = OC::$WEBROOT.'/index.php'; |
|
285 | + header('Location: '.$url); |
|
286 | 286 | } |
287 | 287 | exit(); |
288 | 288 | } |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | $incompatibleShippedApps = []; |
388 | 388 | foreach ($incompatibleApps as $appInfo) { |
389 | 389 | if ($appManager->isShipped($appInfo['id'])) { |
390 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
390 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | 394 | if (!empty($incompatibleShippedApps)) { |
395 | 395 | $l = \OC::$server->getL10N('core'); |
396 | 396 | $hint = $l->t('The files of the app %1$s 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); |
|
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 | 398 | } |
399 | 399 | |
400 | 400 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | public static function initSession() { |
408 | - if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
408 | + if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
409 | 409 | ini_set('session.cookie_secure', true); |
410 | 410 | } |
411 | 411 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | ini_set('session.cookie_httponly', 'true'); |
414 | 414 | |
415 | 415 | // set the cookie path to the Nextcloud directory |
416 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
416 | + $cookie_path = OC::$WEBROOT ?: '/'; |
|
417 | 417 | ini_set('session.cookie_path', $cookie_path); |
418 | 418 | |
419 | 419 | // Let the session name be changed in the initSession Hook |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | // session timeout |
447 | 447 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
448 | 448 | if (isset($_COOKIE[session_name()])) { |
449 | - setcookie(session_name(), '', -1, self::$WEBROOT ? : '/'); |
|
449 | + setcookie(session_name(), '', -1, self::$WEBROOT ?: '/'); |
|
450 | 450 | } |
451 | 451 | \OC::$server->getUserSession()->logout(); |
452 | 452 | } |
@@ -482,14 +482,14 @@ discard block |
||
482 | 482 | |
483 | 483 | // Append __Host to the cookie if it meets the requirements |
484 | 484 | $cookiePrefix = ''; |
485 | - if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
485 | + if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
486 | 486 | $cookiePrefix = '__Host-'; |
487 | 487 | } |
488 | 488 | |
489 | - foreach($policies as $policy) { |
|
489 | + foreach ($policies as $policy) { |
|
490 | 490 | header( |
491 | 491 | sprintf( |
492 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
492 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
493 | 493 | $cookiePrefix, |
494 | 494 | $policy, |
495 | 495 | $cookieParams['path'], |
@@ -528,31 +528,31 @@ discard block |
||
528 | 528 | ]; |
529 | 529 | } |
530 | 530 | |
531 | - if($request->isUserAgent($incompatibleUserAgents)) { |
|
531 | + if ($request->isUserAgent($incompatibleUserAgents)) { |
|
532 | 532 | return; |
533 | 533 | } |
534 | 534 | |
535 | - if(count($_COOKIE) > 0) { |
|
535 | + if (count($_COOKIE) > 0) { |
|
536 | 536 | $requestUri = $request->getScriptName(); |
537 | 537 | $processingScript = explode('/', $requestUri); |
538 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
538 | + $processingScript = $processingScript[count($processingScript) - 1]; |
|
539 | 539 | |
540 | 540 | // index.php routes are handled in the middleware |
541 | - if($processingScript === 'index.php') { |
|
541 | + if ($processingScript === 'index.php') { |
|
542 | 542 | return; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // All other endpoints require the lax and the strict cookie |
546 | - if(!$request->passesStrictCookieCheck()) { |
|
546 | + if (!$request->passesStrictCookieCheck()) { |
|
547 | 547 | self::sendSameSiteCookies(); |
548 | 548 | // Debug mode gets access to the resources without strict cookie |
549 | 549 | // due to the fact that the SabreDAV browser also lives there. |
550 | - if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
550 | + if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
551 | 551 | http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
552 | 552 | exit(); |
553 | 553 | } |
554 | 554 | } |
555 | - } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
555 | + } elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
556 | 556 | self::sendSameSiteCookies(); |
557 | 557 | } |
558 | 558 | } |
@@ -563,12 +563,12 @@ discard block |
||
563 | 563 | |
564 | 564 | // register autoloader |
565 | 565 | $loaderStart = microtime(true); |
566 | - require_once __DIR__ . '/autoloader.php'; |
|
566 | + require_once __DIR__.'/autoloader.php'; |
|
567 | 567 | self::$loader = new \OC\Autoloader([ |
568 | - OC::$SERVERROOT . '/lib/private/legacy', |
|
568 | + OC::$SERVERROOT.'/lib/private/legacy', |
|
569 | 569 | ]); |
570 | 570 | if (defined('PHPUNIT_RUN')) { |
571 | - self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
571 | + self::$loader->addValidRoot(OC::$SERVERROOT.'/tests'); |
|
572 | 572 | } |
573 | 573 | spl_autoload_register([self::$loader, 'load']); |
574 | 574 | $loaderEnd = microtime(true); |
@@ -576,12 +576,12 @@ discard block |
||
576 | 576 | self::$CLI = (php_sapi_name() == 'cli'); |
577 | 577 | |
578 | 578 | // Add default composer PSR-4 autoloader |
579 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
579 | + self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php'; |
|
580 | 580 | |
581 | 581 | try { |
582 | 582 | self::initPaths(); |
583 | 583 | // setup 3rdparty autoloader |
584 | - $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
584 | + $vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php'; |
|
585 | 585 | if (!file_exists($vendorAutoLoad)) { |
586 | 586 | 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".'); |
587 | 587 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | @ini_set('display_errors', '0'); |
612 | 612 | @ini_set('log_errors', '1'); |
613 | 613 | |
614 | - if(!date_default_timezone_set('UTC')) { |
|
614 | + if (!date_default_timezone_set('UTC')) { |
|
615 | 615 | throw new \RuntimeException('Could not set timezone to UTC'); |
616 | 616 | } |
617 | 617 | |
@@ -676,11 +676,11 @@ discard block |
||
676 | 676 | // Convert l10n string into regular string for usage in database |
677 | 677 | $staticErrors = []; |
678 | 678 | foreach ($errors as $error) { |
679 | - echo $error['error'] . "\n"; |
|
680 | - echo $error['hint'] . "\n\n"; |
|
679 | + echo $error['error']."\n"; |
|
680 | + echo $error['hint']."\n\n"; |
|
681 | 681 | $staticErrors[] = [ |
682 | - 'error' => (string)$error['error'], |
|
683 | - 'hint' => (string)$error['hint'], |
|
682 | + 'error' => (string) $error['error'], |
|
683 | + 'hint' => (string) $error['hint'], |
|
684 | 684 | ]; |
685 | 685 | } |
686 | 686 | |
@@ -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 | |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | register_shutdown_function([$lockProvider, 'releaseAll']); |
748 | 748 | |
749 | 749 | // Check whether the sample configuration has been copied |
750 | - if($systemConfig->getValue('copied_sample_config', false)) { |
|
750 | + if ($systemConfig->getValue('copied_sample_config', false)) { |
|
751 | 751 | $l = \OC::$server->getL10N('lib'); |
752 | 752 | OC_Template::printErrorPage( |
753 | 753 | $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') && $userSession->isLoggedIn()) { |
816 | 816 | // reset brute force delay for this IP address and username |
817 | 817 | $uid = \OC::$server->getUserSession()->getUser()->getUID(); |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | |
864 | 864 | private static function registerAppRestrictionsHooks() { |
865 | 865 | $groupManager = self::$server->query(\OCP\IGroupManager::class); |
866 | - $groupManager->listen ('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { |
|
866 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OCP\IGroup $group) { |
|
867 | 867 | $appManager = self::$server->getAppManager(); |
868 | 868 | $apps = $appManager->getEnabledAppsForGroup($group); |
869 | 869 | foreach ($apps as $appId) { |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | if (empty($restrictions)) { |
878 | 878 | $appManager->disableApp($appId); |
879 | 879 | } |
880 | - else{ |
|
880 | + else { |
|
881 | 881 | $appManager->enableAppForGroups($appId, $restrictions); |
882 | 882 | } |
883 | 883 | |
@@ -973,12 +973,12 @@ discard block |
||
973 | 973 | // emergency app disabling |
974 | 974 | if ($requestPath === '/disableapp' |
975 | 975 | && $request->getMethod() === 'POST' |
976 | - && ((array)$request->getParam('appid')) !== '' |
|
976 | + && ((array) $request->getParam('appid')) !== '' |
|
977 | 977 | ) { |
978 | 978 | \OC_JSON::callCheck(); |
979 | 979 | \OC_JSON::checkAdminUser(); |
980 | - $appIds = (array)$request->getParam('appid'); |
|
981 | - foreach($appIds as $appId) { |
|
980 | + $appIds = (array) $request->getParam('appid'); |
|
981 | + foreach ($appIds as $appId) { |
|
982 | 982 | $appId = \OC_App::cleanAppId($appId); |
983 | 983 | \OC::$server->getAppManager()->disableApp($appId); |
984 | 984 | } |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | if (!\OCP\Util::needUpgrade() |
994 | 994 | && !((bool) $systemConfig->getValue('maintenance', false))) { |
995 | 995 | // For logged-in users: Load everything |
996 | - if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
996 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
997 | 997 | OC_App::loadApps(); |
998 | 998 | } else { |
999 | 999 | // For guests: Load only filesystem and logging |