@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | * the app path list is empty or contains an invalid path |
120 | 120 | */ |
121 | 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, '/') . '/'; |
|
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 | 128 | } else { |
129 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
129 | + self::$configDir = OC::$SERVERROOT.'/config/'; |
|
130 | 130 | } |
131 | 131 | self::$config = new \OC\Config(self::$configDir); |
132 | 132 | |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | //make sure suburi follows the same rules as scriptName |
149 | 149 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
150 | 150 | if (substr(OC::$SUBURI, -1) != '/') { |
151 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
151 | + OC::$SUBURI = OC::$SUBURI.'/'; |
|
152 | 152 | } |
153 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
153 | + OC::$SUBURI = OC::$SUBURI.'index.php'; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
163 | 163 | |
164 | 164 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
165 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
165 | + OC::$WEBROOT = '/'.OC::$WEBROOT; |
|
166 | 166 | } |
167 | 167 | } else { |
168 | 168 | // The scriptName is not ending with OC::$SUBURI |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | OC::$APPSROOTS[] = $paths; |
192 | 192 | } |
193 | 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')) { |
|
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 | 197 | OC::$APPSROOTS[] = array( |
198 | - 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
198 | + 'path' => rtrim(dirname(OC::$SERVERROOT), '/').'/apps', |
|
199 | 199 | 'url' => '/apps', |
200 | 200 | 'writable' => true |
201 | 201 | ); |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | $l = \OC::$server->getL10N('lib'); |
226 | 226 | |
227 | 227 | // Create config if it does not already exist |
228 | - $configFilePath = self::$configDir .'/config.php'; |
|
229 | - if(!file_exists($configFilePath)) { |
|
228 | + $configFilePath = self::$configDir.'/config.php'; |
|
229 | + if (!file_exists($configFilePath)) { |
|
230 | 230 | @touch($configFilePath); |
231 | 231 | } |
232 | 232 | |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | echo $l->t('Cannot write into "config" directory!')."\n"; |
242 | 242 | echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
243 | 243 | echo "\n"; |
244 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-dir_permissions') ])."\n"; |
|
244 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-dir_permissions')])."\n"; |
|
245 | 245 | exit; |
246 | 246 | } else { |
247 | 247 | OC_Template::printErrorPage( |
248 | 248 | $l->t('Cannot write into "config" directory!'), |
249 | 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') ]) |
|
250 | + [$urlGenerator->linkToDocs('admin-dir_permissions')]) |
|
251 | 251 | ); |
252 | 252 | } |
253 | 253 | } |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | if (OC::$CLI) { |
263 | 263 | throw new Exception('Not installed'); |
264 | 264 | } else { |
265 | - $url = OC::$WEBROOT . '/index.php'; |
|
266 | - header('Location: ' . $url); |
|
265 | + $url = OC::$WEBROOT.'/index.php'; |
|
266 | + header('Location: '.$url); |
|
267 | 267 | } |
268 | 268 | exit(); |
269 | 269 | } |
@@ -391,14 +391,14 @@ discard block |
||
391 | 391 | $incompatibleShippedApps = []; |
392 | 392 | foreach ($incompatibleApps as $appInfo) { |
393 | 393 | if ($appManager->isShipped($appInfo['id'])) { |
394 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
394 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
398 | 398 | $l10n = \OC::$server->getL10N('core'); |
399 | 399 | if (!empty($incompatibleShippedApps)) { |
400 | 400 | $hint = $l10n->t('The files of the app %$1s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); |
401 | - 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); |
|
401 | + 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); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion, $l10n->getLanguageCode())); |
@@ -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 |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | // session timeout |
448 | 448 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
449 | 449 | if (isset($_COOKIE[session_name()])) { |
450 | - setcookie(session_name(), null, -1, self::$WEBROOT ? : '/'); |
|
450 | + setcookie(session_name(), null, -1, self::$WEBROOT ?: '/'); |
|
451 | 451 | } |
452 | 452 | \OC::$server->getUserSession()->logout(); |
453 | 453 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | continue; |
470 | 470 | } |
471 | 471 | |
472 | - $file = $appPath . '/appinfo/classpath.php'; |
|
472 | + $file = $appPath.'/appinfo/classpath.php'; |
|
473 | 473 | if (file_exists($file)) { |
474 | 474 | require_once $file; |
475 | 475 | } |
@@ -497,14 +497,14 @@ discard block |
||
497 | 497 | |
498 | 498 | // Append __Host to the cookie if it meets the requirements |
499 | 499 | $cookiePrefix = ''; |
500 | - if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
500 | + if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
501 | 501 | $cookiePrefix = '__Host-'; |
502 | 502 | } |
503 | 503 | |
504 | - foreach($policies as $policy) { |
|
504 | + foreach ($policies as $policy) { |
|
505 | 505 | header( |
506 | 506 | sprintf( |
507 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
507 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
508 | 508 | $cookiePrefix, |
509 | 509 | $policy, |
510 | 510 | $cookieParams['path'], |
@@ -535,14 +535,14 @@ discard block |
||
535 | 535 | // OS X Finder |
536 | 536 | '/^WebDAVFS/', |
537 | 537 | ]; |
538 | - if($request->isUserAgent($incompatibleUserAgents)) { |
|
538 | + if ($request->isUserAgent($incompatibleUserAgents)) { |
|
539 | 539 | return; |
540 | 540 | } |
541 | 541 | |
542 | - if(count($_COOKIE) > 0) { |
|
542 | + if (count($_COOKIE) > 0) { |
|
543 | 543 | $requestUri = $request->getScriptName(); |
544 | 544 | $processingScript = explode('/', $requestUri); |
545 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
545 | + $processingScript = $processingScript[count($processingScript) - 1]; |
|
546 | 546 | // FIXME: In a SAML scenario we don't get any strict or lax cookie |
547 | 547 | // send for the ACS endpoint. Since we have some legacy code in Nextcloud |
548 | 548 | // (direct PHP files) the enforcement of lax cookies is performed here |
@@ -555,30 +555,30 @@ discard block |
||
555 | 555 | // the verification into a middleware and also adds some exemptions. |
556 | 556 | // |
557 | 557 | // Questions about this code? Ask Lukas ;-) |
558 | - $currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
|
559 | - if($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
|
558 | + $currentUrl = substr(explode('?', $request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
|
559 | + if ($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
|
560 | 560 | return; |
561 | 561 | } |
562 | 562 | // For the "index.php" endpoint only a lax cookie is required. |
563 | - if($processingScript === 'index.php') { |
|
564 | - if(!$request->passesLaxCookieCheck()) { |
|
563 | + if ($processingScript === 'index.php') { |
|
564 | + if (!$request->passesLaxCookieCheck()) { |
|
565 | 565 | self::sendSameSiteCookies(); |
566 | 566 | header('Location: '.$_SERVER['REQUEST_URI']); |
567 | 567 | exit(); |
568 | 568 | } |
569 | 569 | } else { |
570 | 570 | // All other endpoints require the lax and the strict cookie |
571 | - if(!$request->passesStrictCookieCheck()) { |
|
571 | + if (!$request->passesStrictCookieCheck()) { |
|
572 | 572 | self::sendSameSiteCookies(); |
573 | 573 | // Debug mode gets access to the resources without strict cookie |
574 | 574 | // due to the fact that the SabreDAV browser also lives there. |
575 | - if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
575 | + if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
576 | 576 | http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
577 | 577 | exit(); |
578 | 578 | } |
579 | 579 | } |
580 | 580 | } |
581 | - } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
581 | + } elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
582 | 582 | self::sendSameSiteCookies(); |
583 | 583 | } |
584 | 584 | } |
@@ -589,12 +589,12 @@ discard block |
||
589 | 589 | |
590 | 590 | // register autoloader |
591 | 591 | $loaderStart = microtime(true); |
592 | - require_once __DIR__ . '/autoloader.php'; |
|
592 | + require_once __DIR__.'/autoloader.php'; |
|
593 | 593 | self::$loader = new \OC\Autoloader([ |
594 | - OC::$SERVERROOT . '/lib/private/legacy', |
|
594 | + OC::$SERVERROOT.'/lib/private/legacy', |
|
595 | 595 | ]); |
596 | 596 | if (defined('PHPUNIT_RUN')) { |
597 | - self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
597 | + self::$loader->addValidRoot(OC::$SERVERROOT.'/tests'); |
|
598 | 598 | } |
599 | 599 | spl_autoload_register(array(self::$loader, 'load')); |
600 | 600 | $loaderEnd = microtime(true); |
@@ -602,12 +602,12 @@ discard block |
||
602 | 602 | self::$CLI = (php_sapi_name() == 'cli'); |
603 | 603 | |
604 | 604 | // Add default composer PSR-4 autoloader |
605 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
605 | + self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php'; |
|
606 | 606 | |
607 | 607 | try { |
608 | 608 | self::initPaths(); |
609 | 609 | // setup 3rdparty autoloader |
610 | - $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
610 | + $vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php'; |
|
611 | 611 | if (!file_exists($vendorAutoLoad)) { |
612 | 612 | 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".'); |
613 | 613 | } |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | if (!self::$CLI) { |
618 | 618 | $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
619 | 619 | $protocol = in_array($claimedProtocol, ['HTTP/1.0', 'HTTP/1.1', 'HTTP/2']) ? $claimedProtocol : 'HTTP/1.1'; |
620 | - header($protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
620 | + header($protocol.' '.OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
621 | 621 | } |
622 | 622 | // we can't use the template error page here, because this needs the |
623 | 623 | // DI container which isn't available yet |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | @ini_set('display_errors', 0); |
636 | 636 | @ini_set('log_errors', 1); |
637 | 637 | |
638 | - if(!date_default_timezone_set('UTC')) { |
|
638 | + if (!date_default_timezone_set('UTC')) { |
|
639 | 639 | throw new \RuntimeException('Could not set timezone to UTC'); |
640 | 640 | }; |
641 | 641 | |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | self::checkInstalled(); |
680 | 680 | |
681 | 681 | OC_Response::addSecurityHeaders(); |
682 | - if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
682 | + if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
683 | 683 | ini_set('session.cookie_secure', true); |
684 | 684 | } |
685 | 685 | |
@@ -692,11 +692,11 @@ discard block |
||
692 | 692 | // Convert l10n string into regular string for usage in database |
693 | 693 | $staticErrors = []; |
694 | 694 | foreach ($errors as $error) { |
695 | - echo $error['error'] . "\n"; |
|
696 | - echo $error['hint'] . "\n\n"; |
|
695 | + echo $error['error']."\n"; |
|
696 | + echo $error['hint']."\n\n"; |
|
697 | 697 | $staticErrors[] = [ |
698 | - 'error' => (string)$error['error'], |
|
699 | - 'hint' => (string)$error['hint'], |
|
698 | + 'error' => (string) $error['error'], |
|
699 | + 'hint' => (string) $error['hint'], |
|
700 | 700 | ]; |
701 | 701 | } |
702 | 702 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | } |
719 | 719 | //try to set the session lifetime |
720 | 720 | $sessionLifeTime = self::getSessionLifeTime(); |
721 | - @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
721 | + @ini_set('gc_maxlifetime', (string) $sessionLifeTime); |
|
722 | 722 | |
723 | 723 | $systemConfig = \OC::$server->getSystemConfig(); |
724 | 724 | |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | register_shutdown_function(array($lockProvider, 'releaseAll')); |
766 | 766 | |
767 | 767 | // Check whether the sample configuration has been copied |
768 | - if($systemConfig->getValue('copied_sample_config', false)) { |
|
768 | + if ($systemConfig->getValue('copied_sample_config', false)) { |
|
769 | 769 | $l = \OC::$server->getL10N('lib'); |
770 | 770 | header('HTTP/1.1 503 Service Temporarily Unavailable'); |
771 | 771 | header('Status: 503 Service Temporarily Unavailable'); |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | ) { |
792 | 792 | // Allow access to CSS resources |
793 | 793 | $isScssRequest = false; |
794 | - if(strpos($request->getPathInfo(), '/css/') === 0) { |
|
794 | + if (strpos($request->getPathInfo(), '/css/') === 0) { |
|
795 | 795 | $isScssRequest = true; |
796 | 796 | } |
797 | 797 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | |
828 | 828 | // NOTE: This will be replaced to use OCP |
829 | 829 | $userSession = self::$server->getUserSession(); |
830 | - $userSession->listen('\OC\User', 'postLogin', function () { |
|
830 | + $userSession->listen('\OC\User', 'postLogin', function() { |
|
831 | 831 | try { |
832 | 832 | $cache = new \OC\Cache\File(); |
833 | 833 | $cache->gc(); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | } catch (\Exception $e) { |
840 | 840 | // a GC exception should not prevent users from using OC, |
841 | 841 | // so log the exception |
842 | - \OC::$server->getLogger()->warning('Exception when running cache gc: ' . $e->getMessage(), array('app' => 'core')); |
|
842 | + \OC::$server->getLogger()->warning('Exception when running cache gc: '.$e->getMessage(), array('app' => 'core')); |
|
843 | 843 | } |
844 | 844 | }); |
845 | 845 | } |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | /** @var \OCP\App\ManagerEvent $event */ |
856 | 856 | $jobList = \OC::$server->getJobList(); |
857 | 857 | $job = 'OC\\Settings\\RemoveOrphaned'; |
858 | - if(!($jobList->has($job, null))) { |
|
858 | + if (!($jobList->has($job, null))) { |
|
859 | 859 | $jobList->add($job); |
860 | 860 | } |
861 | 861 | }); |
@@ -965,12 +965,12 @@ discard block |
||
965 | 965 | // emergency app disabling |
966 | 966 | if ($requestPath === '/disableapp' |
967 | 967 | && $request->getMethod() === 'POST' |
968 | - && ((array)$request->getParam('appid')) !== '' |
|
968 | + && ((array) $request->getParam('appid')) !== '' |
|
969 | 969 | ) { |
970 | 970 | \OCP\JSON::callCheck(); |
971 | 971 | \OCP\JSON::checkAdminUser(); |
972 | - $appIds = (array)$request->getParam('appid'); |
|
973 | - foreach($appIds as $appId) { |
|
972 | + $appIds = (array) $request->getParam('appid'); |
|
973 | + foreach ($appIds as $appId) { |
|
974 | 974 | $appId = \OC_App::cleanAppId($appId); |
975 | 975 | \OC_App::disable($appId); |
976 | 976 | } |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | if (!self::checkUpgrade(false) |
986 | 986 | && !$systemConfig->getValue('maintenance', false)) { |
987 | 987 | // For logged-in users: Load everything |
988 | - if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
988 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
989 | 989 | OC_App::loadApps(); |
990 | 990 | } else { |
991 | 991 | // For guests: Load only filesystem and logging |