@@ -133,14 +133,14 @@ discard block |
||
133 | 133 | * the app path list is empty or contains an invalid path |
134 | 134 | */ |
135 | 135 | public static function initPaths() { |
136 | - if(defined('PHPUNIT_CONFIG_DIR')) { |
|
137 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
138 | - } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
139 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
140 | - } elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
141 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
136 | + if (defined('PHPUNIT_CONFIG_DIR')) { |
|
137 | + self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/'; |
|
138 | + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) { |
|
139 | + self::$configDir = OC::$SERVERROOT.'/tests/config/'; |
|
140 | + } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
141 | + self::$configDir = rtrim($dir, '/').'/'; |
|
142 | 142 | } else { |
143 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
143 | + self::$configDir = OC::$SERVERROOT.'/config/'; |
|
144 | 144 | } |
145 | 145 | self::$config = new \OC\Config(self::$configDir); |
146 | 146 | |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | //make sure suburi follows the same rules as scriptName |
163 | 163 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
164 | 164 | if (substr(OC::$SUBURI, -1) != '/') { |
165 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
165 | + OC::$SUBURI = OC::$SUBURI.'/'; |
|
166 | 166 | } |
167 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
167 | + OC::$SUBURI = OC::$SUBURI.'index.php'; |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
177 | 177 | |
178 | 178 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
179 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
179 | + OC::$WEBROOT = '/'.OC::$WEBROOT; |
|
180 | 180 | } |
181 | 181 | } else { |
182 | 182 | // The scriptName is not ending with OC::$SUBURI |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | OC::$APPSROOTS[] = $paths; |
206 | 206 | } |
207 | 207 | } |
208 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
209 | - OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true]; |
|
210 | - } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
208 | + } elseif (file_exists(OC::$SERVERROOT.'/apps')) { |
|
209 | + OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true]; |
|
210 | + } elseif (file_exists(OC::$SERVERROOT.'/../apps')) { |
|
211 | 211 | OC::$APPSROOTS[] = [ |
212 | - 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
212 | + 'path' => rtrim(dirname(OC::$SERVERROOT), '/').'/apps', |
|
213 | 213 | 'url' => '/apps', |
214 | 214 | 'writable' => true |
215 | 215 | ]; |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | $l = \OC::$server->getL10N('lib'); |
240 | 240 | |
241 | 241 | // Create config if it does not already exist |
242 | - $configFilePath = self::$configDir .'/config.php'; |
|
243 | - if(!file_exists($configFilePath)) { |
|
242 | + $configFilePath = self::$configDir.'/config.php'; |
|
243 | + if (!file_exists($configFilePath)) { |
|
244 | 244 | @touch($configFilePath); |
245 | 245 | } |
246 | 246 | |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
257 | 257 | echo "\n"; |
258 | 258 | 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"; |
259 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ])."\n"; |
|
259 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')])."\n"; |
|
260 | 260 | exit; |
261 | 261 | } else { |
262 | 262 | OC_Template::printErrorPage( |
263 | 263 | $l->t('Cannot write into "config" directory!'), |
264 | - $l->t('This can usually be fixed by giving the webserver write access to the config directory.') . '. ' |
|
264 | + $l->t('This can usually be fixed by giving the webserver write access to the config directory.').'. ' |
|
265 | 265 | . $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', |
266 | - [ $urlGenerator->linkToDocs('admin-config') ] ), |
|
266 | + [$urlGenerator->linkToDocs('admin-config')]), |
|
267 | 267 | 503 |
268 | 268 | ); |
269 | 269 | } |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | if (OC::$CLI) { |
280 | 280 | throw new Exception('Not installed'); |
281 | 281 | } else { |
282 | - $url = OC::$WEBROOT . '/index.php'; |
|
283 | - header('Location: ' . $url); |
|
282 | + $url = OC::$WEBROOT.'/index.php'; |
|
283 | + header('Location: '.$url); |
|
284 | 284 | } |
285 | 285 | exit(); |
286 | 286 | } |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | $incompatibleShippedApps = []; |
386 | 386 | foreach ($incompatibleApps as $appInfo) { |
387 | 387 | if ($appManager->isShipped($appInfo['id'])) { |
388 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
388 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | |
392 | 392 | if (!empty($incompatibleShippedApps)) { |
393 | 393 | $l = \OC::$server->getL10N('core'); |
394 | 394 | $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)]); |
395 | - 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); |
|
395 | + 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); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | } |
404 | 404 | |
405 | 405 | public static function initSession() { |
406 | - if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
406 | + if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
407 | 407 | ini_set('session.cookie_secure', true); |
408 | 408 | } |
409 | 409 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | ini_set('session.cookie_httponly', 'true'); |
412 | 412 | |
413 | 413 | // set the cookie path to the Nextcloud directory |
414 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
414 | + $cookie_path = OC::$WEBROOT ?: '/'; |
|
415 | 415 | ini_set('session.cookie_path', $cookie_path); |
416 | 416 | |
417 | 417 | // Let the session name be changed in the initSession Hook |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | // session timeout |
445 | 445 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
446 | 446 | if (isset($_COOKIE[session_name()])) { |
447 | - setcookie(session_name(), '', -1, self::$WEBROOT ? : '/'); |
|
447 | + setcookie(session_name(), '', -1, self::$WEBROOT ?: '/'); |
|
448 | 448 | } |
449 | 449 | \OC::$server->getUserSession()->logout(); |
450 | 450 | } |
@@ -480,14 +480,14 @@ discard block |
||
480 | 480 | |
481 | 481 | // Append __Host to the cookie if it meets the requirements |
482 | 482 | $cookiePrefix = ''; |
483 | - if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
483 | + if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
484 | 484 | $cookiePrefix = '__Host-'; |
485 | 485 | } |
486 | 486 | |
487 | - foreach($policies as $policy) { |
|
487 | + foreach ($policies as $policy) { |
|
488 | 488 | header( |
489 | 489 | sprintf( |
490 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
490 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
491 | 491 | $cookiePrefix, |
492 | 492 | $policy, |
493 | 493 | $cookieParams['path'], |
@@ -526,31 +526,31 @@ discard block |
||
526 | 526 | ]; |
527 | 527 | } |
528 | 528 | |
529 | - if($request->isUserAgent($incompatibleUserAgents)) { |
|
529 | + if ($request->isUserAgent($incompatibleUserAgents)) { |
|
530 | 530 | return; |
531 | 531 | } |
532 | 532 | |
533 | - if(count($_COOKIE) > 0) { |
|
533 | + if (count($_COOKIE) > 0) { |
|
534 | 534 | $requestUri = $request->getScriptName(); |
535 | 535 | $processingScript = explode('/', $requestUri); |
536 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
536 | + $processingScript = $processingScript[count($processingScript) - 1]; |
|
537 | 537 | |
538 | 538 | // index.php routes are handled in the middleware |
539 | - if($processingScript === 'index.php') { |
|
539 | + if ($processingScript === 'index.php') { |
|
540 | 540 | return; |
541 | 541 | } |
542 | 542 | |
543 | 543 | // All other endpoints require the lax and the strict cookie |
544 | - if(!$request->passesStrictCookieCheck()) { |
|
544 | + if (!$request->passesStrictCookieCheck()) { |
|
545 | 545 | self::sendSameSiteCookies(); |
546 | 546 | // Debug mode gets access to the resources without strict cookie |
547 | 547 | // due to the fact that the SabreDAV browser also lives there. |
548 | - if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
548 | + if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
549 | 549 | http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
550 | 550 | exit(); |
551 | 551 | } |
552 | 552 | } |
553 | - } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
553 | + } elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
554 | 554 | self::sendSameSiteCookies(); |
555 | 555 | } |
556 | 556 | } |
@@ -561,12 +561,12 @@ discard block |
||
561 | 561 | |
562 | 562 | // register autoloader |
563 | 563 | $loaderStart = microtime(true); |
564 | - require_once __DIR__ . '/autoloader.php'; |
|
564 | + require_once __DIR__.'/autoloader.php'; |
|
565 | 565 | self::$loader = new \OC\Autoloader([ |
566 | - OC::$SERVERROOT . '/lib/private/legacy', |
|
566 | + OC::$SERVERROOT.'/lib/private/legacy', |
|
567 | 567 | ]); |
568 | 568 | if (defined('PHPUNIT_RUN')) { |
569 | - self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
569 | + self::$loader->addValidRoot(OC::$SERVERROOT.'/tests'); |
|
570 | 570 | } |
571 | 571 | spl_autoload_register([self::$loader, 'load']); |
572 | 572 | $loaderEnd = microtime(true); |
@@ -574,12 +574,12 @@ discard block |
||
574 | 574 | self::$CLI = (php_sapi_name() == 'cli'); |
575 | 575 | |
576 | 576 | // Add default composer PSR-4 autoloader |
577 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
577 | + self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php'; |
|
578 | 578 | |
579 | 579 | try { |
580 | 580 | self::initPaths(); |
581 | 581 | // setup 3rdparty autoloader |
582 | - $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
582 | + $vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php'; |
|
583 | 583 | if (!file_exists($vendorAutoLoad)) { |
584 | 584 | 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".'); |
585 | 585 | } |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | @ini_set('display_errors', '0'); |
610 | 610 | @ini_set('log_errors', '1'); |
611 | 611 | |
612 | - if(!date_default_timezone_set('UTC')) { |
|
612 | + if (!date_default_timezone_set('UTC')) { |
|
613 | 613 | throw new \RuntimeException('Could not set timezone to UTC'); |
614 | 614 | } |
615 | 615 | |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | // Convert l10n string into regular string for usage in database |
675 | 675 | $staticErrors = []; |
676 | 676 | foreach ($errors as $error) { |
677 | - echo $error['error'] . "\n"; |
|
678 | - echo $error['hint'] . "\n\n"; |
|
677 | + echo $error['error']."\n"; |
|
678 | + echo $error['hint']."\n\n"; |
|
679 | 679 | $staticErrors[] = [ |
680 | - 'error' => (string)$error['error'], |
|
681 | - 'hint' => (string)$error['hint'], |
|
680 | + 'error' => (string) $error['error'], |
|
681 | + 'hint' => (string) $error['hint'], |
|
682 | 682 | ]; |
683 | 683 | } |
684 | 684 | |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | } |
695 | 695 | //try to set the session lifetime |
696 | 696 | $sessionLifeTime = self::getSessionLifeTime(); |
697 | - @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
697 | + @ini_set('gc_maxlifetime', (string) $sessionLifeTime); |
|
698 | 698 | |
699 | 699 | $systemConfig = \OC::$server->getSystemConfig(); |
700 | 700 | |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | register_shutdown_function([$lockProvider, 'releaseAll']); |
746 | 746 | |
747 | 747 | // Check whether the sample configuration has been copied |
748 | - if($systemConfig->getValue('copied_sample_config', false)) { |
|
748 | + if ($systemConfig->getValue('copied_sample_config', false)) { |
|
749 | 749 | $l = \OC::$server->getL10N('lib'); |
750 | 750 | OC_Template::printErrorPage( |
751 | 751 | $l->t('Sample configuration detected'), |
@@ -767,11 +767,11 @@ discard block |
||
767 | 767 | ) { |
768 | 768 | // Allow access to CSS resources |
769 | 769 | $isScssRequest = false; |
770 | - if(strpos($request->getPathInfo(), '/css/') === 0) { |
|
770 | + if (strpos($request->getPathInfo(), '/css/') === 0) { |
|
771 | 771 | $isScssRequest = true; |
772 | 772 | } |
773 | 773 | |
774 | - if(substr($request->getRequestUri(), -11) === '/status.php') { |
|
774 | + if (substr($request->getRequestUri(), -11) === '/status.php') { |
|
775 | 775 | http_response_code(400); |
776 | 776 | header('Content-Type: application/json'); |
777 | 777 | echo '{"error": "Trusted domain error.", "code": 15}'; |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | |
810 | 810 | // NOTE: This will be replaced to use OCP |
811 | 811 | $userSession = self::$server->getUserSession(); |
812 | - $userSession->listen('\OC\User', 'postLogin', function () use ($userSession) { |
|
812 | + $userSession->listen('\OC\User', 'postLogin', function() use ($userSession) { |
|
813 | 813 | if (!defined('PHPUNIT_RUN')) { |
814 | 814 | // reset brute force delay for this IP address and username |
815 | 815 | $uid = \OC::$server->getUserSession()->getUser()->getUID(); |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | |
862 | 862 | private static function registerAppRestrictionsHooks() { |
863 | 863 | $groupManager = self::$server->query(\OCP\IGroupManager::class); |
864 | - $groupManager->listen ('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { |
|
864 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OCP\IGroup $group) { |
|
865 | 865 | $appManager = self::$server->getAppManager(); |
866 | 866 | $apps = $appManager->getEnabledAppsForGroup($group); |
867 | 867 | foreach ($apps as $appId) { |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | if (empty($restrictions)) { |
876 | 876 | $appManager->disableApp($appId); |
877 | 877 | } |
878 | - else{ |
|
878 | + else { |
|
879 | 879 | $appManager->enableAppForGroups($appId, $restrictions); |
880 | 880 | } |
881 | 881 | |
@@ -971,12 +971,12 @@ discard block |
||
971 | 971 | // emergency app disabling |
972 | 972 | if ($requestPath === '/disableapp' |
973 | 973 | && $request->getMethod() === 'POST' |
974 | - && ((array)$request->getParam('appid')) !== '' |
|
974 | + && ((array) $request->getParam('appid')) !== '' |
|
975 | 975 | ) { |
976 | 976 | \OC_JSON::callCheck(); |
977 | 977 | \OC_JSON::checkAdminUser(); |
978 | - $appIds = (array)$request->getParam('appid'); |
|
979 | - foreach($appIds as $appId) { |
|
978 | + $appIds = (array) $request->getParam('appid'); |
|
979 | + foreach ($appIds as $appId) { |
|
980 | 980 | $appId = \OC_App::cleanAppId($appId); |
981 | 981 | \OC::$server->getAppManager()->disableApp($appId); |
982 | 982 | } |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | if (!\OCP\Util::needUpgrade() |
992 | 992 | && !((bool) $systemConfig->getValue('maintenance', false))) { |
993 | 993 | // For logged-in users: Load everything |
994 | - if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
994 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
995 | 995 | OC_App::loadApps(); |
996 | 996 | } else { |
997 | 997 | // For guests: Load only filesystem and logging |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return mixed the value or $default |
88 | 88 | */ |
89 | 89 | public function getValue($key, $default = null) { |
90 | - $envValue = getenv(self::ENV_PREFIX . $key); |
|
90 | + $envValue = getenv(self::ENV_PREFIX.$key); |
|
91 | 91 | if ($envValue !== false) { |
92 | 92 | return $envValue; |
93 | 93 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | foreach ($configFiles as $file) { |
200 | 200 | $fileExistsAndIsReadable = file_exists($file) && is_readable($file); |
201 | 201 | $filePointer = $fileExistsAndIsReadable ? fopen($file, 'r') : false; |
202 | - if($file === $this->configFilePath && |
|
202 | + if ($file === $this->configFilePath && |
|
203 | 203 | $filePointer === false) { |
204 | 204 | // Opening the main config might not be possible, e.g. if the wrong |
205 | 205 | // permissions are set (likely on a new installation) |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | // Try to acquire a file lock |
210 | - if(!flock($filePointer, LOCK_SH)) { |
|
210 | + if (!flock($filePointer, LOCK_SH)) { |
|
211 | 211 | throw new \Exception(sprintf('Could not acquire a shared lock on the config file %s', $file)); |
212 | 212 | } |
213 | 213 | |
214 | 214 | unset($CONFIG); |
215 | 215 | include $file; |
216 | - if(isset($CONFIG) && is_array($CONFIG)) { |
|
216 | + if (isset($CONFIG) && is_array($CONFIG)) { |
|
217 | 217 | $this->cache = array_merge($this->cache, $CONFIG); |
218 | 218 | } |
219 | 219 | |
@@ -238,26 +238,26 @@ discard block |
||
238 | 238 | $content .= var_export($this->cache, true); |
239 | 239 | $content .= ";\n"; |
240 | 240 | |
241 | - touch ($this->configFilePath); |
|
241 | + touch($this->configFilePath); |
|
242 | 242 | $filePointer = fopen($this->configFilePath, 'r+'); |
243 | 243 | |
244 | 244 | // Prevent others not to read the config |
245 | 245 | chmod($this->configFilePath, 0640); |
246 | 246 | |
247 | 247 | // File does not exist, this can happen when doing a fresh install |
248 | - if(!is_resource ($filePointer)) { |
|
248 | + if (!is_resource($filePointer)) { |
|
249 | 249 | throw new HintException( |
250 | 250 | "Can't write into config directory!", |
251 | 251 | 'This can usually be fixed by giving the webserver write access to the config directory.'); |
252 | 252 | } |
253 | 253 | |
254 | 254 | // Try to acquire a file lock |
255 | - if(!flock($filePointer, LOCK_EX)) { |
|
255 | + if (!flock($filePointer, LOCK_EX)) { |
|
256 | 256 | throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $this->configFilePath)); |
257 | 257 | } |
258 | 258 | |
259 | 259 | // Write the config and release the lock |
260 | - ftruncate ($filePointer, 0); |
|
260 | + ftruncate($filePointer, 0); |
|
261 | 261 | fwrite($filePointer, $content); |
262 | 262 | fflush($filePointer); |
263 | 263 | flock($filePointer, LOCK_UN); |