Completed
Push — master ( fb17f1...ff55bc )
by Blizzz
17:03
created
lib/private/Setup.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 			$configuredDatabases = $this->config->getValue('supportedDatabases',
168 168
 				['sqlite', 'mysql', 'pgsql']);
169 169
 		}
170
-		if(!is_array($configuredDatabases)) {
170
+		if (!is_array($configuredDatabases)) {
171 171
 			throw new Exception('Supported databases are not properly configured.');
172 172
 		}
173 173
 
174 174
 		$supportedDatabases = array();
175 175
 
176
-		foreach($configuredDatabases as $database) {
177
-			if(array_key_exists($database, $availableDatabases)) {
176
+		foreach ($configuredDatabases as $database) {
177
+			if (array_key_exists($database, $availableDatabases)) {
178 178
 				$working = false;
179 179
 				$type = $availableDatabases[$database]['type'];
180 180
 				$call = $availableDatabases[$database]['call'];
181 181
 
182 182
 				if ($type === 'function') {
183 183
 					$working = $this->is_callable($call);
184
-				} elseif($type === 'pdo') {
184
+				} elseif ($type === 'pdo') {
185 185
 					$working = in_array($call, $this->getAvailableDbDriversForPdo(), true);
186 186
 				}
187
-				if($working) {
187
+				if ($working) {
188 188
 					$supportedDatabases[$database] = $availableDatabases[$database]['name'];
189 189
 				}
190 190
 			}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		// Create data directory to test whether the .htaccess works
211 211
 		// Notice that this is not necessarily the same data directory as the one
212 212
 		// that will effectively be used.
213
-		if(!file_exists($dataDir)) {
213
+		if (!file_exists($dataDir)) {
214 214
 			@mkdir($dataDir);
215 215
 		}
216 216
 		$htAccessWorking = true;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		if (\OC_Util::runningOnMac()) {
234 234
 			$errors[] = [
235 235
 				'error' => $this->l10n->t(
236
-					'Mac OS X is not supported and %s will not work properly on this platform. ' .
236
+					'Mac OS X is not supported and %s will not work properly on this platform. '.
237 237
 					'Use it at your own risk! ',
238 238
 					[$this->defaults->getName()]
239 239
 				),
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 			];
242 242
 		}
243 243
 
244
-		if($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
244
+		if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
245 245
 			$errors[] = [
246 246
 				'error' => $this->l10n->t(
247
-					'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' .
247
+					'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. '.
248 248
 					'This will lead to problems with files over 4 GB and is highly discouraged.',
249 249
 					[$this->defaults->getName()]
250 250
 				),
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 		$error = array();
275 275
 		$dbType = $options['dbtype'];
276 276
 
277
-		if(empty($options['adminlogin'])) {
277
+		if (empty($options['adminlogin'])) {
278 278
 			$error[] = $l->t('Set an admin username.');
279 279
 		}
280
-		if(empty($options['adminpass'])) {
280
+		if (empty($options['adminpass'])) {
281 281
 			$error[] = $l->t('Set an admin password.');
282 282
 		}
283
-		if(empty($options['directory'])) {
283
+		if (empty($options['directory'])) {
284 284
 			$options['directory'] = \OC::$SERVERROOT."/data";
285 285
 		}
286 286
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		$request = \OC::$server->getRequest();
310 310
 
311 311
 		//no errors, good
312
-		if(isset($options['trusted_domains'])
312
+		if (isset($options['trusted_domains'])
313 313
 		    && is_array($options['trusted_domains'])) {
314 314
 			$trustedDomains = $options['trusted_domains'];
315 315
 		} else {
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		];
338 338
 
339 339
 		if ($this->config->getValue('overwrite.cli.url', null) === null) {
340
-			$newConfigValues['overwrite.cli.url'] = $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT;
340
+			$newConfigValues['overwrite.cli.url'] = $request->getServerProtocol().'://'.$request->getInsecureServerHost().\OC::$WEBROOT;
341 341
 		}
342 342
 
343 343
 		$this->config->setValues($newConfigValues);
@@ -355,20 +355,20 @@  discard block
 block discarded – undo
355 355
 			return $error;
356 356
 		} catch (Exception $e) {
357 357
 			$error[] = [
358
-				'error' => 'Error while trying to create admin user: ' . $e->getMessage(),
358
+				'error' => 'Error while trying to create admin user: '.$e->getMessage(),
359 359
 				'hint' => '',
360 360
 			];
361 361
 			return $error;
362 362
 		}
363 363
 
364 364
 		//create the user and group
365
-		$user =  null;
365
+		$user = null;
366 366
 		try {
367 367
 			$user = \OC::$server->getUserManager()->createUser($username, $password);
368 368
 			if (!$user) {
369 369
 				$error[] = "User <$username> could not be created.";
370 370
 			}
371
-		} catch(Exception $exception) {
371
+		} catch (Exception $exception) {
372 372
 			$error[] = $exception->getMessage();
373 373
 		}
374 374
 
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
 			$config->setAppValue('core', 'lastupdatedat', microtime(true));
379 379
 			$config->setAppValue('core', 'vendor', $this->getVendor());
380 380
 
381
-			$group =\OC::$server->getGroupManager()->createGroup('admin');
381
+			$group = \OC::$server->getGroupManager()->createGroup('admin');
382 382
 			$group->addUser($user);
383 383
 
384 384
 			// Install shipped apps and specified app bundles
385 385
 			Installer::installShippedApps();
386 386
 			$bundleFetcher = new BundleFetcher(\OC::$server->getL10N('lib'));
387 387
 			$defaultInstallationBundles = $bundleFetcher->getDefaultInstallationBundle();
388
-			foreach($defaultInstallationBundles as $bundle) {
388
+			foreach ($defaultInstallationBundles as $bundle) {
389 389
 				try {
390 390
 					$this->installer->installAppBundle($bundle);
391 391
 				} catch (Exception $e) {}
@@ -487,14 +487,14 @@  discard block
 block discarded – undo
487 487
 		$htaccessContent = explode($content, $htaccessContent, 2)[0];
488 488
 
489 489
 		//custom 403 error page
490
-		$content .= "\nErrorDocument 403 " . $webRoot . '/';
490
+		$content .= "\nErrorDocument 403 ".$webRoot.'/';
491 491
 
492 492
 		//custom 404 error page
493
-		$content .= "\nErrorDocument 404 " . $webRoot . '/';
493
+		$content .= "\nErrorDocument 404 ".$webRoot.'/';
494 494
 
495 495
 		// Add rewrite rules if the RewriteBase is configured
496 496
 		$rewriteBase = $config->getValue('htaccess.RewriteBase', '');
497
-		if($rewriteBase !== '') {
497
+		if ($rewriteBase !== '') {
498 498
 			$content .= "\n<IfModule mod_rewrite.c>";
499 499
 			$content .= "\n  Options -MultiViews";
500 500
 			$content .= "\n  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]";
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 			$content .= "\n  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/";
515 515
 			$content .= "\n  RewriteCond %{REQUEST_URI} !^/\\.well-known/(acme-challenge|pki-validation)/.*";
516 516
 			$content .= "\n  RewriteRule . index.php [PT,E=PATH_INFO:$1]";
517
-			$content .= "\n  RewriteBase " . $rewriteBase;
517
+			$content .= "\n  RewriteBase ".$rewriteBase;
518 518
 			$content .= "\n  <IfModule mod_env.c>";
519 519
 			$content .= "\n    SetEnv front_controller_active true";
520 520
 			$content .= "\n    <IfModule mod_dir.c>";
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
 		if ($content !== '') {
528 528
 			//suppress errors in case we don't have permissions for it
529
-			return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content . "\n");
529
+			return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content."\n");
530 530
 		}
531 531
 
532 532
 		return false;
@@ -534,25 +534,25 @@  discard block
 block discarded – undo
534 534
 
535 535
 	public static function protectDataDirectory() {
536 536
 		//Require all denied
537
-		$now =  date('Y-m-d H:i:s');
537
+		$now = date('Y-m-d H:i:s');
538 538
 		$content = "# Generated by Nextcloud on $now\n";
539
-		$content.= "# line below if for Apache 2.4\n";
540
-		$content.= "<ifModule mod_authz_core.c>\n";
541
-		$content.= "Require all denied\n";
542
-		$content.= "</ifModule>\n\n";
543
-		$content.= "# line below if for Apache 2.2\n";
544
-		$content.= "<ifModule !mod_authz_core.c>\n";
545
-		$content.= "deny from all\n";
546
-		$content.= "Satisfy All\n";
547
-		$content.= "</ifModule>\n\n";
548
-		$content.= "# section for Apache 2.2 and 2.4\n";
549
-		$content.= "<ifModule mod_autoindex.c>\n";
550
-		$content.= "IndexIgnore *\n";
551
-		$content.= "</ifModule>\n";
552
-
553
-		$baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
554
-		file_put_contents($baseDir . '/.htaccess', $content);
555
-		file_put_contents($baseDir . '/index.html', '');
539
+		$content .= "# line below if for Apache 2.4\n";
540
+		$content .= "<ifModule mod_authz_core.c>\n";
541
+		$content .= "Require all denied\n";
542
+		$content .= "</ifModule>\n\n";
543
+		$content .= "# line below if for Apache 2.2\n";
544
+		$content .= "<ifModule !mod_authz_core.c>\n";
545
+		$content .= "deny from all\n";
546
+		$content .= "Satisfy All\n";
547
+		$content .= "</ifModule>\n\n";
548
+		$content .= "# section for Apache 2.2 and 2.4\n";
549
+		$content .= "<ifModule mod_autoindex.c>\n";
550
+		$content .= "IndexIgnore *\n";
551
+		$content .= "</ifModule>\n";
552
+
553
+		$baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
554
+		file_put_contents($baseDir.'/.htaccess', $content);
555
+		file_put_contents($baseDir.'/index.html', '');
556 556
 	}
557 557
 
558 558
 	/**
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 	 */
565 565
 	private function getVendor() {
566 566
 		// this should really be a JSON file
567
-		require \OC::$SERVERROOT . '/version.php';
567
+		require \OC::$SERVERROOT.'/version.php';
568 568
 		/** @var string $vendor */
569 569
 		return (string) $vendor;
570 570
 	}
Please login to merge, or discard this patch.