@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function installApp($appId) { |
110 | 110 | $app = \OC_App::findAppInDirectories($appId); |
111 | - if($app === false) { |
|
111 | + if ($app === false) { |
|
112 | 112 | throw new \Exception('App not found in any app directory'); |
113 | 113 | } |
114 | 114 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true); |
117 | 117 | |
118 | 118 | //install the database |
119 | - if(is_file($basedir.'/appinfo/database.xml')) { |
|
119 | + if (is_file($basedir.'/appinfo/database.xml')) { |
|
120 | 120 | if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) { |
121 | 121 | OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml'); |
122 | 122 | } else { |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | \OC_App::setupBackgroundJobs($info['background-jobs']); |
129 | 129 | |
130 | 130 | //run appinfo/install.php |
131 | - if((!isset($data['noinstall']) or $data['noinstall']==false)) { |
|
132 | - self::includeAppScript($basedir . '/appinfo/install.php'); |
|
131 | + if ((!isset($data['noinstall']) or $data['noinstall'] == false)) { |
|
132 | + self::includeAppScript($basedir.'/appinfo/install.php'); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $appData = OC_App::getAppInfo($appId); |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | \OC::$server->getConfig()->setAppValue($info['id'], 'enabled', 'no'); |
141 | 141 | |
142 | 142 | //set remote/public handlers |
143 | - foreach($info['remote'] as $name=>$path) { |
|
143 | + foreach ($info['remote'] as $name=>$path) { |
|
144 | 144 | \OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $info['id'].'/'.$path); |
145 | 145 | } |
146 | - foreach($info['public'] as $name=>$path) { |
|
146 | + foreach ($info['public'] as $name=>$path) { |
|
147 | 147 | \OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $info['id'].'/'.$path); |
148 | 148 | } |
149 | 149 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * |
160 | 160 | * Checks whether or not an app is installed, i.e. registered in apps table. |
161 | 161 | */ |
162 | - public static function isInstalled( $app ) { |
|
162 | + public static function isInstalled($app) { |
|
163 | 163 | return (\OC::$server->getConfig()->getAppValue($app, "installed_version", null) !== null); |
164 | 164 | } |
165 | 165 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return bool |
171 | 171 | */ |
172 | 172 | public function updateAppstoreApp($appId) { |
173 | - if(self::isUpdateAvailable($appId, $this->appFetcher)) { |
|
173 | + if (self::isUpdateAvailable($appId, $this->appFetcher)) { |
|
174 | 174 | try { |
175 | 175 | $this->downloadApp($appId); |
176 | 176 | } catch (\Exception $e) { |
@@ -194,18 +194,18 @@ discard block |
||
194 | 194 | $appId = strtolower($appId); |
195 | 195 | |
196 | 196 | $apps = $this->appFetcher->get(); |
197 | - foreach($apps as $app) { |
|
198 | - if($app['id'] === $appId) { |
|
197 | + foreach ($apps as $app) { |
|
198 | + if ($app['id'] === $appId) { |
|
199 | 199 | // Load the certificate |
200 | 200 | $certificate = new X509(); |
201 | - $certificate->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt')); |
|
201 | + $certificate->loadCA(file_get_contents(__DIR__.'/../../resources/codesigning/root.crt')); |
|
202 | 202 | $loadedCertificate = $certificate->loadX509($app['certificate']); |
203 | 203 | |
204 | 204 | // Verify if the certificate has been revoked |
205 | 205 | $crl = new X509(); |
206 | - $crl->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt')); |
|
207 | - $crl->loadCRL(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crl')); |
|
208 | - if($crl->validateSignature() !== true) { |
|
206 | + $crl->loadCA(file_get_contents(__DIR__.'/../../resources/codesigning/root.crt')); |
|
207 | + $crl->loadCRL(file_get_contents(__DIR__.'/../../resources/codesigning/root.crl')); |
|
208 | + if ($crl->validateSignature() !== true) { |
|
209 | 209 | throw new \Exception('Could not validate CRL signature'); |
210 | 210 | } |
211 | 211 | $csn = $loadedCertificate['tbsCertificate']['serialNumber']->toString(); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | // Verify if the certificate has been issued by the Nextcloud Code Authority CA |
223 | - if($certificate->validateSignature() !== true) { |
|
223 | + if ($certificate->validateSignature() !== true) { |
|
224 | 224 | throw new \Exception( |
225 | 225 | sprintf( |
226 | 226 | 'App with id %s has a certificate not issued by a trusted Code Signing Authority', |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | // Verify if the certificate is issued for the requested app id |
233 | 233 | $certInfo = openssl_x509_parse($app['certificate']); |
234 | - if(!isset($certInfo['subject']['CN'])) { |
|
234 | + if (!isset($certInfo['subject']['CN'])) { |
|
235 | 235 | throw new \Exception( |
236 | 236 | sprintf( |
237 | 237 | 'App with id %s has a cert with no CN', |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | ) |
240 | 240 | ); |
241 | 241 | } |
242 | - if($certInfo['subject']['CN'] !== $appId) { |
|
242 | + if ($certInfo['subject']['CN'] !== $appId) { |
|
243 | 243 | throw new \Exception( |
244 | 244 | sprintf( |
245 | 245 | 'App with id %s has a cert issued to %s', |
@@ -256,21 +256,21 @@ discard block |
||
256 | 256 | |
257 | 257 | // Check if the signature actually matches the downloaded content |
258 | 258 | $certificate = openssl_get_publickey($app['certificate']); |
259 | - $verified = (bool)openssl_verify(file_get_contents($tempFile), base64_decode($app['releases'][0]['signature']), $certificate, OPENSSL_ALGO_SHA512); |
|
259 | + $verified = (bool) openssl_verify(file_get_contents($tempFile), base64_decode($app['releases'][0]['signature']), $certificate, OPENSSL_ALGO_SHA512); |
|
260 | 260 | openssl_free_key($certificate); |
261 | 261 | |
262 | - if($verified === true) { |
|
262 | + if ($verified === true) { |
|
263 | 263 | // Seems to match, let's proceed |
264 | 264 | $extractDir = $this->tempManager->getTemporaryFolder(); |
265 | 265 | $archive = new TAR($tempFile); |
266 | 266 | |
267 | - if($archive) { |
|
267 | + if ($archive) { |
|
268 | 268 | $archive->extract($extractDir); |
269 | 269 | $allFiles = scandir($extractDir); |
270 | 270 | $folders = array_diff($allFiles, ['.', '..']); |
271 | 271 | $folders = array_values($folders); |
272 | 272 | |
273 | - if(count($folders) > 1) { |
|
273 | + if (count($folders) > 1) { |
|
274 | 274 | throw new \Exception( |
275 | 275 | sprintf( |
276 | 276 | 'Extracted app %s has more than 1 folder', |
@@ -281,22 +281,22 @@ discard block |
||
281 | 281 | |
282 | 282 | // Check if appinfo/info.xml has the same app ID as well |
283 | 283 | $loadEntities = libxml_disable_entity_loader(false); |
284 | - $xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml'); |
|
284 | + $xml = simplexml_load_file($extractDir.'/'.$folders[0].'/appinfo/info.xml'); |
|
285 | 285 | libxml_disable_entity_loader($loadEntities); |
286 | - if((string)$xml->id !== $appId) { |
|
286 | + if ((string) $xml->id !== $appId) { |
|
287 | 287 | throw new \Exception( |
288 | 288 | sprintf( |
289 | 289 | 'App for id %s has a wrong app ID in info.xml: %s', |
290 | 290 | $appId, |
291 | - (string)$xml->id |
|
291 | + (string) $xml->id |
|
292 | 292 | ) |
293 | 293 | ); |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Check if the version is lower than before |
297 | 297 | $currentVersion = OC_App::getAppVersion($appId); |
298 | - $newVersion = (string)$xml->version; |
|
299 | - if(version_compare($currentVersion, $newVersion) === 1) { |
|
298 | + $newVersion = (string) $xml->version; |
|
299 | + if (version_compare($currentVersion, $newVersion) === 1) { |
|
300 | 300 | throw new \Exception( |
301 | 301 | sprintf( |
302 | 302 | 'App for id %s has version %s and tried to update to lower version %s', |
@@ -307,12 +307,12 @@ discard block |
||
307 | 307 | ); |
308 | 308 | } |
309 | 309 | |
310 | - $baseDir = OC_App::getInstallPath() . '/' . $appId; |
|
310 | + $baseDir = OC_App::getInstallPath().'/'.$appId; |
|
311 | 311 | // Remove old app with the ID if existent |
312 | 312 | OC_Helper::rmdirr($baseDir); |
313 | 313 | // Move to app folder |
314 | - if(@mkdir($baseDir)) { |
|
315 | - $extractDir .= '/' . $folders[0]; |
|
314 | + if (@mkdir($baseDir)) { |
|
315 | + $extractDir .= '/'.$folders[0]; |
|
316 | 316 | OC_Helper::copyr($extractDir, $baseDir); |
317 | 317 | } |
318 | 318 | OC_Helper::copyr($extractDir, $baseDir); |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | } |
373 | 373 | |
374 | 374 | $apps = $appFetcher->get(); |
375 | - foreach($apps as $app) { |
|
376 | - if($app['id'] === $appId) { |
|
375 | + foreach ($apps as $app) { |
|
376 | + if ($app['id'] === $appId) { |
|
377 | 377 | $currentVersion = OC_App::getAppVersion($appId); |
378 | 378 | $newestVersion = $app['releases'][0]['version']; |
379 | 379 | if (version_compare($newestVersion, $currentVersion, '>')) { |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * The function will check if the app is already downloaded in the apps repository |
396 | 396 | */ |
397 | 397 | public function isDownloaded($name) { |
398 | - foreach(\OC::$APPSROOTS as $dir) { |
|
398 | + foreach (\OC::$APPSROOTS as $dir) { |
|
399 | 399 | $dirToTest = $dir['path']; |
400 | 400 | $dirToTest .= '/'; |
401 | 401 | $dirToTest .= $name; |
@@ -423,11 +423,11 @@ discard block |
||
423 | 423 | * this has to be done by the function oc_app_uninstall(). |
424 | 424 | */ |
425 | 425 | public function removeApp($appId) { |
426 | - if($this->isDownloaded( $appId )) { |
|
427 | - $appDir = OC_App::getInstallPath() . '/' . $appId; |
|
426 | + if ($this->isDownloaded($appId)) { |
|
427 | + $appDir = OC_App::getInstallPath().'/'.$appId; |
|
428 | 428 | OC_Helper::rmdirr($appDir); |
429 | 429 | return true; |
430 | - }else{ |
|
430 | + } else { |
|
431 | 431 | \OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', \OCP\Util::ERROR); |
432 | 432 | |
433 | 433 | return false; |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | */ |
444 | 444 | public function installAppBundle(Bundle $bundle) { |
445 | 445 | $appIds = $bundle->getAppIdentifiers(); |
446 | - foreach($appIds as $appId) { |
|
447 | - if(!$this->isDownloaded($appId)) { |
|
446 | + foreach ($appIds as $appId) { |
|
447 | + if (!$this->isDownloaded($appId)) { |
|
448 | 448 | $this->downloadApp($appId); |
449 | 449 | } |
450 | 450 | $this->installApp($appId); |
@@ -466,13 +466,13 @@ discard block |
||
466 | 466 | */ |
467 | 467 | public static function installShippedApps($softErrors = false) { |
468 | 468 | $errors = []; |
469 | - foreach(\OC::$APPSROOTS as $app_dir) { |
|
470 | - if($dir = opendir( $app_dir['path'] )) { |
|
471 | - while( false !== ( $filename = readdir( $dir ))) { |
|
472 | - if( substr( $filename, 0, 1 ) != '.' and is_dir($app_dir['path']."/$filename") ) { |
|
473 | - if( file_exists( $app_dir['path']."/$filename/appinfo/info.xml" )) { |
|
474 | - if(!Installer::isInstalled($filename)) { |
|
475 | - $info=OC_App::getAppInfo($filename); |
|
469 | + foreach (\OC::$APPSROOTS as $app_dir) { |
|
470 | + if ($dir = opendir($app_dir['path'])) { |
|
471 | + while (false !== ($filename = readdir($dir))) { |
|
472 | + if (substr($filename, 0, 1) != '.' and is_dir($app_dir['path']."/$filename")) { |
|
473 | + if (file_exists($app_dir['path']."/$filename/appinfo/info.xml")) { |
|
474 | + if (!Installer::isInstalled($filename)) { |
|
475 | + $info = OC_App::getAppInfo($filename); |
|
476 | 476 | $enabled = isset($info['default_enable']); |
477 | 477 | if (($enabled || in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps())) |
478 | 478 | && \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') { |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | } |
496 | 496 | } |
497 | 497 | } |
498 | - closedir( $dir ); |
|
498 | + closedir($dir); |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
@@ -510,12 +510,12 @@ discard block |
||
510 | 510 | public static function installShippedApp($app) { |
511 | 511 | //install the database |
512 | 512 | $appPath = OC_App::getAppPath($app); |
513 | - if(is_file("$appPath/appinfo/database.xml")) { |
|
513 | + if (is_file("$appPath/appinfo/database.xml")) { |
|
514 | 514 | try { |
515 | 515 | OC_DB::createDbFromStructure("$appPath/appinfo/database.xml"); |
516 | 516 | } catch (TableExistsException $e) { |
517 | 517 | throw new HintException( |
518 | - 'Failed to enable app ' . $app, |
|
518 | + 'Failed to enable app '.$app, |
|
519 | 519 | 'Please ask for help via one of our <a href="https://nextcloud.com/support/" target="_blank" rel="noreferrer">support channels</a>.', |
520 | 520 | 0, $e |
521 | 521 | ); |
@@ -542,16 +542,16 @@ discard block |
||
542 | 542 | } |
543 | 543 | |
544 | 544 | //set remote/public handlers |
545 | - foreach($info['remote'] as $name=>$path) { |
|
545 | + foreach ($info['remote'] as $name=>$path) { |
|
546 | 546 | $config->setAppValue('core', 'remote_'.$name, $app.'/'.$path); |
547 | 547 | } |
548 | - foreach($info['public'] as $name=>$path) { |
|
548 | + foreach ($info['public'] as $name=>$path) { |
|
549 | 549 | $config->setAppValue('core', 'public_'.$name, $app.'/'.$path); |
550 | 550 | } |
551 | 551 | |
552 | 552 | OC_App::setAppTypes($info['id']); |
553 | 553 | |
554 | - if(isset($info['settings']) && is_array($info['settings'])) { |
|
554 | + if (isset($info['settings']) && is_array($info['settings'])) { |
|
555 | 555 | // requires that autoloading was registered for the app, |
556 | 556 | // as happens before running the install.php some lines above |
557 | 557 | \OC::$server->getSettingsManager()->setupSettings($info['settings']); |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | */ |
568 | 568 | public static function checkCode($folder) { |
569 | 569 | // is the code checker enabled? |
570 | - if(!\OC::$server->getConfig()->getSystemValue('appcodechecker', false)) { |
|
570 | + if (!\OC::$server->getConfig()->getSystemValue('appcodechecker', false)) { |
|
571 | 571 | return true; |
572 | 572 | } |
573 | 573 | |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @param string $script |
582 | 582 | */ |
583 | 583 | private static function includeAppScript($script) { |
584 | - if ( file_exists($script) ){ |
|
584 | + if (file_exists($script)) { |
|
585 | 585 | include $script; |
586 | 586 | } |
587 | 587 | } |
@@ -68,8 +68,8 @@ |
||
68 | 68 | $this->getBundles(), |
69 | 69 | $this->getDefaultInstallationBundle() |
70 | 70 | ); |
71 | - foreach($bundles as $bundle) { |
|
72 | - if($bundle->getIdentifier() === $identifier) { |
|
71 | + foreach ($bundles as $bundle) { |
|
72 | + if ($bundle->getIdentifier() === $identifier) { |
|
73 | 73 | return $bundle; |
74 | 74 | } |
75 | 75 | } |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | $configuredDatabases = $this->config->getValue('supportedDatabases', |
156 | 156 | array('sqlite', 'mysql', 'pgsql')); |
157 | 157 | } |
158 | - if(!is_array($configuredDatabases)) { |
|
158 | + if (!is_array($configuredDatabases)) { |
|
159 | 159 | throw new Exception('Supported databases are not properly configured.'); |
160 | 160 | } |
161 | 161 | |
162 | 162 | $supportedDatabases = array(); |
163 | 163 | |
164 | - foreach($configuredDatabases as $database) { |
|
165 | - if(array_key_exists($database, $availableDatabases)) { |
|
164 | + foreach ($configuredDatabases as $database) { |
|
165 | + if (array_key_exists($database, $availableDatabases)) { |
|
166 | 166 | $working = false; |
167 | 167 | $type = $availableDatabases[$database]['type']; |
168 | 168 | $call = $availableDatabases[$database]['call']; |
169 | 169 | |
170 | 170 | if ($type === 'function') { |
171 | 171 | $working = $this->is_callable($call); |
172 | - } elseif($type === 'pdo') { |
|
172 | + } elseif ($type === 'pdo') { |
|
173 | 173 | $working = in_array($call, $this->getAvailableDbDriversForPdo(), TRUE); |
174 | 174 | } |
175 | - if($working) { |
|
175 | + if ($working) { |
|
176 | 176 | $supportedDatabases[$database] = $availableDatabases[$database]['name']; |
177 | 177 | } |
178 | 178 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | // Create data directory to test whether the .htaccess works |
199 | 199 | // Notice that this is not necessarily the same data directory as the one |
200 | 200 | // that will effectively be used. |
201 | - if(!file_exists($dataDir)) { |
|
201 | + if (!file_exists($dataDir)) { |
|
202 | 202 | @mkdir($dataDir); |
203 | 203 | } |
204 | 204 | $htAccessWorking = true; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | if (\OC_Util::runningOnMac()) { |
222 | 222 | $errors[] = array( |
223 | 223 | 'error' => $this->l10n->t( |
224 | - 'Mac OS X is not supported and %s will not work properly on this platform. ' . |
|
224 | + 'Mac OS X is not supported and %s will not work properly on this platform. '. |
|
225 | 225 | 'Use it at your own risk! ', |
226 | 226 | $this->defaults->getName() |
227 | 227 | ), |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | ); |
230 | 230 | } |
231 | 231 | |
232 | - if($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) { |
|
232 | + if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) { |
|
233 | 233 | $errors[] = array( |
234 | 234 | 'error' => $this->l10n->t( |
235 | - 'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' . |
|
235 | + 'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. '. |
|
236 | 236 | 'This will lead to problems with files over 4 GB and is highly discouraged.', |
237 | 237 | $this->defaults->getName() |
238 | 238 | ), |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | $error = array(); |
263 | 263 | $dbType = $options['dbtype']; |
264 | 264 | |
265 | - if(empty($options['adminlogin'])) { |
|
265 | + if (empty($options['adminlogin'])) { |
|
266 | 266 | $error[] = $l->t('Set an admin username.'); |
267 | 267 | } |
268 | - if(empty($options['adminpass'])) { |
|
268 | + if (empty($options['adminpass'])) { |
|
269 | 269 | $error[] = $l->t('Set an admin password.'); |
270 | 270 | } |
271 | - if(empty($options['directory'])) { |
|
271 | + if (empty($options['directory'])) { |
|
272 | 272 | $options['directory'] = \OC::$SERVERROOT."/data"; |
273 | 273 | } |
274 | 274 | |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | $error[] = $l->t("Can't create or write into the data directory %s", array($dataDir)); |
295 | 295 | } |
296 | 296 | |
297 | - if(count($error) != 0) { |
|
297 | + if (count($error) != 0) { |
|
298 | 298 | return $error; |
299 | 299 | } |
300 | 300 | |
301 | 301 | $request = \OC::$server->getRequest(); |
302 | 302 | |
303 | 303 | //no errors, good |
304 | - if(isset($options['trusted_domains']) |
|
304 | + if (isset($options['trusted_domains']) |
|
305 | 305 | && is_array($options['trusted_domains'])) { |
306 | 306 | $trustedDomains = $options['trusted_domains']; |
307 | 307 | } else { |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | //use sqlite3 when available, otherwise sqlite2 will be used. |
312 | - if($dbType=='sqlite' and class_exists('SQLite3')) { |
|
313 | - $dbType='sqlite3'; |
|
312 | + if ($dbType == 'sqlite' and class_exists('SQLite3')) { |
|
313 | + $dbType = 'sqlite3'; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | //generate a random salt that is used to salt the local user passwords |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | 'secret' => $secret, |
325 | 325 | 'trusted_domains' => $trustedDomains, |
326 | 326 | 'datadirectory' => $dataDir, |
327 | - 'overwrite.cli.url' => $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT, |
|
327 | + 'overwrite.cli.url' => $request->getServerProtocol().'://'.$request->getInsecureServerHost().\OC::$WEBROOT, |
|
328 | 328 | 'dbtype' => $dbType, |
329 | 329 | 'version' => implode('.', \OCP\Util::getVersion()), |
330 | 330 | ]); |
@@ -340,30 +340,30 @@ discard block |
||
340 | 340 | return($error); |
341 | 341 | } catch (Exception $e) { |
342 | 342 | $error[] = array( |
343 | - 'error' => 'Error while trying to create admin user: ' . $e->getMessage(), |
|
343 | + 'error' => 'Error while trying to create admin user: '.$e->getMessage(), |
|
344 | 344 | 'hint' => '' |
345 | 345 | ); |
346 | 346 | return($error); |
347 | 347 | } |
348 | 348 | |
349 | 349 | //create the user and group |
350 | - $user = null; |
|
350 | + $user = null; |
|
351 | 351 | try { |
352 | 352 | $user = \OC::$server->getUserManager()->createUser($username, $password); |
353 | 353 | if (!$user) { |
354 | 354 | $error[] = "User <$username> could not be created."; |
355 | 355 | } |
356 | - } catch(Exception $exception) { |
|
356 | + } catch (Exception $exception) { |
|
357 | 357 | $error[] = $exception->getMessage(); |
358 | 358 | } |
359 | 359 | |
360 | - if(count($error) == 0) { |
|
360 | + if (count($error) == 0) { |
|
361 | 361 | $config = \OC::$server->getConfig(); |
362 | 362 | $config->setAppValue('core', 'installedat', microtime(true)); |
363 | 363 | $config->setAppValue('core', 'lastupdatedat', microtime(true)); |
364 | 364 | $config->setAppValue('core', 'vendor', $this->getVendor()); |
365 | 365 | |
366 | - $group =\OC::$server->getGroupManager()->createGroup('admin'); |
|
366 | + $group = \OC::$server->getGroupManager()->createGroup('admin'); |
|
367 | 367 | $group->addUser($user); |
368 | 368 | |
369 | 369 | // Install shipped apps and specified app bundles |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | ); |
378 | 378 | $bundleFetcher = new BundleFetcher(\OC::$server->getL10N('lib')); |
379 | 379 | $defaultInstallationBundles = $bundleFetcher->getDefaultInstallationBundle(); |
380 | - foreach($defaultInstallationBundles as $bundle) { |
|
380 | + foreach ($defaultInstallationBundles as $bundle) { |
|
381 | 381 | try { |
382 | 382 | $installer->installAppBundle($bundle); |
383 | 383 | } catch (Exception $e) {} |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | $config = \OC::$server->getSystemConfig(); |
429 | 429 | |
430 | 430 | // For CLI read the value from overwrite.cli.url |
431 | - if(\OC::$CLI) { |
|
431 | + if (\OC::$CLI) { |
|
432 | 432 | $webRoot = $config->getValue('overwrite.cli.url', ''); |
433 | - if($webRoot === '') { |
|
433 | + if ($webRoot === '') { |
|
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | $webRoot = parse_url($webRoot, PHP_URL_PATH); |
@@ -448,14 +448,14 @@ discard block |
||
448 | 448 | $htaccessContent = explode($content, $htaccessContent, 2)[0]; |
449 | 449 | |
450 | 450 | //custom 403 error page |
451 | - $content.= "\nErrorDocument 403 ".$webRoot."/core/templates/403.php"; |
|
451 | + $content .= "\nErrorDocument 403 ".$webRoot."/core/templates/403.php"; |
|
452 | 452 | |
453 | 453 | //custom 404 error page |
454 | - $content.= "\nErrorDocument 404 ".$webRoot."/core/templates/404.php"; |
|
454 | + $content .= "\nErrorDocument 404 ".$webRoot."/core/templates/404.php"; |
|
455 | 455 | |
456 | 456 | // Add rewrite rules if the RewriteBase is configured |
457 | 457 | $rewriteBase = $config->getValue('htaccess.RewriteBase', ''); |
458 | - if($rewriteBase !== '') { |
|
458 | + if ($rewriteBase !== '') { |
|
459 | 459 | $content .= "\n<IfModule mod_rewrite.c>"; |
460 | 460 | $content .= "\n Options -MultiViews"; |
461 | 461 | $content .= "\n RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]"; |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | $content .= "\n RewriteCond %{REQUEST_FILENAME} !/ocs-provider/"; |
475 | 475 | $content .= "\n RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*"; |
476 | 476 | $content .= "\n RewriteRule . index.php [PT,E=PATH_INFO:$1]"; |
477 | - $content .= "\n RewriteBase " . $rewriteBase; |
|
477 | + $content .= "\n RewriteBase ".$rewriteBase; |
|
478 | 478 | $content .= "\n <IfModule mod_env.c>"; |
479 | 479 | $content .= "\n SetEnv front_controller_active true"; |
480 | 480 | $content .= "\n <IfModule mod_dir.c>"; |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | if ($content !== '') { |
488 | 488 | //suppress errors in case we don't have permissions for it |
489 | - return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content . "\n"); |
|
489 | + return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content."\n"); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | return false; |
@@ -494,25 +494,25 @@ discard block |
||
494 | 494 | |
495 | 495 | public static function protectDataDirectory() { |
496 | 496 | //Require all denied |
497 | - $now = date('Y-m-d H:i:s'); |
|
497 | + $now = date('Y-m-d H:i:s'); |
|
498 | 498 | $content = "# Generated by Nextcloud on $now\n"; |
499 | - $content.= "# line below if for Apache 2.4\n"; |
|
500 | - $content.= "<ifModule mod_authz_core.c>\n"; |
|
501 | - $content.= "Require all denied\n"; |
|
502 | - $content.= "</ifModule>\n\n"; |
|
503 | - $content.= "# line below if for Apache 2.2\n"; |
|
504 | - $content.= "<ifModule !mod_authz_core.c>\n"; |
|
505 | - $content.= "deny from all\n"; |
|
506 | - $content.= "Satisfy All\n"; |
|
507 | - $content.= "</ifModule>\n\n"; |
|
508 | - $content.= "# section for Apache 2.2 and 2.4\n"; |
|
509 | - $content.= "<ifModule mod_autoindex.c>\n"; |
|
510 | - $content.= "IndexIgnore *\n"; |
|
511 | - $content.= "</ifModule>\n"; |
|
512 | - |
|
513 | - $baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
514 | - file_put_contents($baseDir . '/.htaccess', $content); |
|
515 | - file_put_contents($baseDir . '/index.html', ''); |
|
499 | + $content .= "# line below if for Apache 2.4\n"; |
|
500 | + $content .= "<ifModule mod_authz_core.c>\n"; |
|
501 | + $content .= "Require all denied\n"; |
|
502 | + $content .= "</ifModule>\n\n"; |
|
503 | + $content .= "# line below if for Apache 2.2\n"; |
|
504 | + $content .= "<ifModule !mod_authz_core.c>\n"; |
|
505 | + $content .= "deny from all\n"; |
|
506 | + $content .= "Satisfy All\n"; |
|
507 | + $content .= "</ifModule>\n\n"; |
|
508 | + $content .= "# section for Apache 2.2 and 2.4\n"; |
|
509 | + $content .= "<ifModule mod_autoindex.c>\n"; |
|
510 | + $content .= "IndexIgnore *\n"; |
|
511 | + $content .= "</ifModule>\n"; |
|
512 | + |
|
513 | + $baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'); |
|
514 | + file_put_contents($baseDir.'/.htaccess', $content); |
|
515 | + file_put_contents($baseDir.'/index.html', ''); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | */ |
525 | 525 | private function getVendor() { |
526 | 526 | // this should really be a JSON file |
527 | - require \OC::$SERVERROOT . '/version.php'; |
|
527 | + require \OC::$SERVERROOT.'/version.php'; |
|
528 | 528 | /** @var string $vendor */ |
529 | 529 | return (string) $vendor; |
530 | 530 | } |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm'); |
32 | 32 | if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay |
33 | 33 | $l = \OC::$server->getL10N('core'); |
34 | - OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required')))); |
|
34 | + OC_JSON::error(array('data' => array('message' => $l->t('Password confirmation is required')))); |
|
35 | 35 | exit(); |
36 | 36 | } |
37 | 37 | |
38 | -$groups = isset($_POST['groups']) ? (array)$_POST['groups'] : null; |
|
39 | -$appIds = isset($_POST['appIds']) ? (array)$_POST['appIds'] : []; |
|
38 | +$groups = isset($_POST['groups']) ? (array) $_POST['groups'] : null; |
|
39 | +$appIds = isset($_POST['appIds']) ? (array) $_POST['appIds'] : []; |
|
40 | 40 | |
41 | 41 | try { |
42 | 42 | $updateRequired = false; |
43 | - foreach($appIds as $appId) { |
|
43 | + foreach ($appIds as $appId) { |
|
44 | 44 | $app = new OC_App(); |
45 | 45 | $appId = OC_App::cleanAppId($appId); |
46 | 46 | $app->enable($appId, $groups); |
47 | - if(\OC_App::shouldUpgrade($appId)) { |
|
47 | + if (\OC_App::shouldUpgrade($appId)) { |
|
48 | 48 | $updateRequired = true; |
49 | 49 | } |
50 | 50 | } |
@@ -52,5 +52,5 @@ discard block |
||
52 | 52 | OC_JSON::success(['data' => ['update_required' => $updateRequired]]); |
53 | 53 | } catch (Exception $e) { |
54 | 54 | \OCP\Util::writeLog('core', $e->getMessage(), \OCP\Util::ERROR); |
55 | - OC_JSON::error(array("data" => array("message" => $e->getMessage()) )); |
|
55 | + OC_JSON::error(array("data" => array("message" => $e->getMessage()))); |
|
56 | 56 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm'); |
28 | 28 | if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay |
29 | 29 | $l = \OC::$server->getL10N('core'); |
30 | - OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required')))); |
|
30 | + OC_JSON::error(array('data' => array('message' => $l->t('Password confirmation is required')))); |
|
31 | 31 | exit(); |
32 | 32 | } |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | exit; |
37 | 37 | } |
38 | 38 | |
39 | -$appIds = (array)$_POST['appid']; |
|
40 | -foreach($appIds as $appId) { |
|
39 | +$appIds = (array) $_POST['appid']; |
|
40 | +foreach ($appIds as $appId) { |
|
41 | 41 | $appId = OC_App::cleanAppId($appId); |
42 | 42 | OC_App::disable($appId); |
43 | 43 | } |
@@ -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 |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | // Resolve /nextcloud to /nextcloud/ to ensure to always have a trailing |
176 | 176 | // slash which is required by URL generation. |
177 | - if($_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
|
177 | + if ($_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
|
178 | 178 | substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
179 | 179 | header('Location: '.\OC::$WEBROOT.'/'); |
180 | 180 | exit(); |
@@ -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,14 +241,14 @@ 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 ' |
250 | 250 | . '%sgiving the webserver write access to the config directory%s.', |
251 | - array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>')) |
|
251 | + array('<a href="'.$urlGenerator->linkToDocs('admin-dir_permissions').'" target="_blank" rel="noreferrer">', '</a>')) |
|
252 | 252 | ); |
253 | 253 | } |
254 | 254 | } |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | if (OC::$CLI) { |
264 | 264 | throw new Exception('Not installed'); |
265 | 265 | } else { |
266 | - $url = OC::$WEBROOT . '/index.php'; |
|
267 | - header('Location: ' . $url); |
|
266 | + $url = OC::$WEBROOT.'/index.php'; |
|
267 | + header('Location: '.$url); |
|
268 | 268 | } |
269 | 269 | exit(); |
270 | 270 | } |
@@ -363,14 +363,14 @@ discard block |
||
363 | 363 | $incompatibleShippedApps = []; |
364 | 364 | foreach ($incompatibleApps as $appInfo) { |
365 | 365 | if ($appManager->isShipped($appInfo['id'])) { |
366 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
366 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | 370 | if (!empty($incompatibleShippedApps)) { |
371 | 371 | $l = \OC::$server->getL10N('core'); |
372 | 372 | $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)]); |
373 | - 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); |
|
373 | + 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); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | ini_set('session.cookie_httponly', true); |
386 | 386 | |
387 | 387 | // set the cookie path to the Nextcloud directory |
388 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
388 | + $cookie_path = OC::$WEBROOT ?: '/'; |
|
389 | 389 | ini_set('session.cookie_path', $cookie_path); |
390 | 390 | |
391 | 391 | // Let the session name be changed in the initSession Hook |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | // session timeout |
420 | 420 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
421 | 421 | if (isset($_COOKIE[session_name()])) { |
422 | - setcookie(session_name(), null, -1, self::$WEBROOT ? : '/'); |
|
422 | + setcookie(session_name(), null, -1, self::$WEBROOT ?: '/'); |
|
423 | 423 | } |
424 | 424 | \OC::$server->getUserSession()->logout(); |
425 | 425 | } |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | continue; |
442 | 442 | } |
443 | 443 | |
444 | - $file = $appPath . '/appinfo/classpath.php'; |
|
444 | + $file = $appPath.'/appinfo/classpath.php'; |
|
445 | 445 | if (file_exists($file)) { |
446 | 446 | require_once $file; |
447 | 447 | } |
@@ -469,14 +469,14 @@ discard block |
||
469 | 469 | |
470 | 470 | // Append __Host to the cookie if it meets the requirements |
471 | 471 | $cookiePrefix = ''; |
472 | - if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
472 | + if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
473 | 473 | $cookiePrefix = '__Host-'; |
474 | 474 | } |
475 | 475 | |
476 | - foreach($policies as $policy) { |
|
476 | + foreach ($policies as $policy) { |
|
477 | 477 | header( |
478 | 478 | sprintf( |
479 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
479 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
480 | 480 | $cookiePrefix, |
481 | 481 | $policy, |
482 | 482 | $cookieParams['path'], |
@@ -507,14 +507,14 @@ discard block |
||
507 | 507 | // OS X Finder |
508 | 508 | '/^WebDAVFS/', |
509 | 509 | ]; |
510 | - if($request->isUserAgent($incompatibleUserAgents)) { |
|
510 | + if ($request->isUserAgent($incompatibleUserAgents)) { |
|
511 | 511 | return; |
512 | 512 | } |
513 | 513 | |
514 | - if(count($_COOKIE) > 0) { |
|
514 | + if (count($_COOKIE) > 0) { |
|
515 | 515 | $requestUri = $request->getScriptName(); |
516 | 516 | $processingScript = explode('/', $requestUri); |
517 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
517 | + $processingScript = $processingScript[count($processingScript) - 1]; |
|
518 | 518 | // FIXME: In a SAML scenario we don't get any strict or lax cookie |
519 | 519 | // send for the ACS endpoint. Since we have some legacy code in Nextcloud |
520 | 520 | // (direct PHP files) the enforcement of lax cookies is performed here |
@@ -527,30 +527,30 @@ discard block |
||
527 | 527 | // the verification into a middleware and also adds some exemptions. |
528 | 528 | // |
529 | 529 | // Questions about this code? Ask Lukas ;-) |
530 | - $currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
|
531 | - if($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
|
530 | + $currentUrl = substr(explode('?', $request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
|
531 | + if ($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
|
532 | 532 | return; |
533 | 533 | } |
534 | 534 | // For the "index.php" endpoint only a lax cookie is required. |
535 | - if($processingScript === 'index.php') { |
|
536 | - if(!$request->passesLaxCookieCheck()) { |
|
535 | + if ($processingScript === 'index.php') { |
|
536 | + if (!$request->passesLaxCookieCheck()) { |
|
537 | 537 | self::sendSameSiteCookies(); |
538 | 538 | header('Location: '.$_SERVER['REQUEST_URI']); |
539 | 539 | exit(); |
540 | 540 | } |
541 | 541 | } else { |
542 | 542 | // All other endpoints require the lax and the strict cookie |
543 | - if(!$request->passesStrictCookieCheck()) { |
|
543 | + if (!$request->passesStrictCookieCheck()) { |
|
544 | 544 | self::sendSameSiteCookies(); |
545 | 545 | // Debug mode gets access to the resources without strict cookie |
546 | 546 | // due to the fact that the SabreDAV browser also lives there. |
547 | - if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
547 | + if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
548 | 548 | http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
549 | 549 | exit(); |
550 | 550 | } |
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(array(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 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | if (!self::$CLI) { |
590 | 590 | $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
591 | 591 | $protocol = in_array($claimedProtocol, ['HTTP/1.0', 'HTTP/1.1', 'HTTP/2']) ? $claimedProtocol : 'HTTP/1.1'; |
592 | - header($protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
592 | + header($protocol.' '.OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
593 | 593 | } |
594 | 594 | // we can't use the template error page here, because this needs the |
595 | 595 | // DI container which isn't available yet |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | @ini_set('display_errors', 0); |
608 | 608 | @ini_set('log_errors', 1); |
609 | 609 | |
610 | - if(!date_default_timezone_set('UTC')) { |
|
610 | + if (!date_default_timezone_set('UTC')) { |
|
611 | 611 | throw new \RuntimeException('Could not set timezone to UTC'); |
612 | 612 | }; |
613 | 613 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | self::checkInstalled(); |
652 | 652 | |
653 | 653 | OC_Response::addSecurityHeaders(); |
654 | - if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
654 | + if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
655 | 655 | ini_set('session.cookie_secure', true); |
656 | 656 | } |
657 | 657 | |
@@ -664,11 +664,11 @@ discard block |
||
664 | 664 | // Convert l10n string into regular string for usage in database |
665 | 665 | $staticErrors = []; |
666 | 666 | foreach ($errors as $error) { |
667 | - echo $error['error'] . "\n"; |
|
668 | - echo $error['hint'] . "\n\n"; |
|
667 | + echo $error['error']."\n"; |
|
668 | + echo $error['hint']."\n\n"; |
|
669 | 669 | $staticErrors[] = [ |
670 | - 'error' => (string)$error['error'], |
|
671 | - 'hint' => (string)$error['hint'], |
|
670 | + 'error' => (string) $error['error'], |
|
671 | + 'hint' => (string) $error['hint'], |
|
672 | 672 | ]; |
673 | 673 | } |
674 | 674 | |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | } |
691 | 691 | //try to set the session lifetime |
692 | 692 | $sessionLifeTime = self::getSessionLifeTime(); |
693 | - @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
693 | + @ini_set('gc_maxlifetime', (string) $sessionLifeTime); |
|
694 | 694 | |
695 | 695 | $systemConfig = \OC::$server->getSystemConfig(); |
696 | 696 | |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | register_shutdown_function(array($lockProvider, 'releaseAll')); |
738 | 738 | |
739 | 739 | // Check whether the sample configuration has been copied |
740 | - if($systemConfig->getValue('copied_sample_config', false)) { |
|
740 | + if ($systemConfig->getValue('copied_sample_config', false)) { |
|
741 | 741 | $l = \OC::$server->getL10N('lib'); |
742 | 742 | header('HTTP/1.1 503 Service Temporarily Unavailable'); |
743 | 743 | header('Status: 503 Service Temporarily Unavailable'); |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | ) { |
764 | 764 | // Allow access to CSS resources |
765 | 765 | $isScssRequest = false; |
766 | - if(strpos($request->getPathInfo(), '/css/') === 0) { |
|
766 | + if (strpos($request->getPathInfo(), '/css/') === 0) { |
|
767 | 767 | $isScssRequest = true; |
768 | 768 | } |
769 | 769 | |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | |
800 | 800 | // NOTE: This will be replaced to use OCP |
801 | 801 | $userSession = self::$server->getUserSession(); |
802 | - $userSession->listen('\OC\User', 'postLogin', function () { |
|
802 | + $userSession->listen('\OC\User', 'postLogin', function() { |
|
803 | 803 | try { |
804 | 804 | $cache = new \OC\Cache\File(); |
805 | 805 | $cache->gc(); |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } catch (\Exception $e) { |
810 | 810 | // a GC exception should not prevent users from using OC, |
811 | 811 | // so log the exception |
812 | - \OC::$server->getLogger()->warning('Exception when running cache gc: ' . $e->getMessage(), array('app' => 'core')); |
|
812 | + \OC::$server->getLogger()->warning('Exception when running cache gc: '.$e->getMessage(), array('app' => 'core')); |
|
813 | 813 | } |
814 | 814 | }); |
815 | 815 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | /** @var \OCP\App\ManagerEvent $event */ |
826 | 826 | $jobList = \OC::$server->getJobList(); |
827 | 827 | $job = 'OC\\Settings\\RemoveOrphaned'; |
828 | - if(!($jobList->has($job, null))) { |
|
828 | + if (!($jobList->has($job, null))) { |
|
829 | 829 | $jobList->add($job); |
830 | 830 | } |
831 | 831 | }); |
@@ -935,12 +935,12 @@ discard block |
||
935 | 935 | // emergency app disabling |
936 | 936 | if ($requestPath === '/disableapp' |
937 | 937 | && $request->getMethod() === 'POST' |
938 | - && ((array)$request->getParam('appid')) !== '' |
|
938 | + && ((array) $request->getParam('appid')) !== '' |
|
939 | 939 | ) { |
940 | 940 | \OCP\JSON::callCheck(); |
941 | 941 | \OCP\JSON::checkAdminUser(); |
942 | - $appIds = (array)$request->getParam('appid'); |
|
943 | - foreach($appIds as $appId) { |
|
942 | + $appIds = (array) $request->getParam('appid'); |
|
943 | + foreach ($appIds as $appId) { |
|
944 | 944 | $appId = \OC_App::cleanAppId($appId); |
945 | 945 | \OC_App::disable($appId); |
946 | 946 | } |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | if (!self::checkUpgrade(false) |
956 | 956 | && !$systemConfig->getValue('maintenance', false)) { |
957 | 957 | // For logged-in users: Load everything |
958 | - if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
958 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
959 | 959 | OC_App::loadApps(); |
960 | 960 | } else { |
961 | 961 | // For guests: Load only filesystem and logging |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * {@inheritDoc} |
28 | 28 | */ |
29 | 29 | public function getName() { |
30 | - return (string)$this->l10n->t('Groupware bundle'); |
|
30 | + return (string) $this->l10n->t('Groupware bundle'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * {@inheritDoc} |
28 | 28 | */ |
29 | 29 | public function getName() { |
30 | - return (string)$this->l10n->t('Enterprise bundle'); |
|
30 | + return (string) $this->l10n->t('Enterprise bundle'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -66,12 +66,12 @@ |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | $defaultBundle = $this->bundleFetcher->getDefaultInstallationBundle(); |
69 | - foreach($defaultBundle as $bundle) { |
|
69 | + foreach ($defaultBundle as $bundle) { |
|
70 | 70 | try { |
71 | 71 | $this->installer->installAppBundle($bundle); |
72 | 72 | $output->info('Successfully installed core app bundle.'); |
73 | 73 | } catch (\Exception $e) { |
74 | - $output->warning('Could not install core app bundle: ' . $e->getMessage()); |
|
74 | + $output->warning('Could not install core app bundle: '.$e->getMessage()); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |