Completed
Pull Request — master (#4454)
by Lukas
17:18
created
core/templates/installation.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 <input type='hidden' id='hasOracle' value='<?php p($_['hasOracle']) ?>'>
15 15
 <form action="index.php" method="post">
16 16
 <input type="hidden" name="install" value="true">
17
-	<?php if(count($_['errors']) > 0): ?>
17
+	<?php if (count($_['errors']) > 0): ?>
18 18
 	<fieldset class="warning">
19
-		<legend><strong><?php p($l->t('Error'));?></strong></legend>
20
-		<?php foreach($_['errors'] as $err): ?>
19
+		<legend><strong><?php p($l->t('Error')); ?></strong></legend>
20
+		<?php foreach ($_['errors'] as $err): ?>
21 21
 		<p>
22
-			<?php if(is_array($err)):?>
22
+			<?php if (is_array($err)):?>
23 23
 				<?php print_unescaped($err['error']); ?>
24 24
 				<span class='hint'><?php print_unescaped($err['hint']); ?></span>
25 25
 			<?php else: ?>
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 		<?php endforeach; ?>
30 30
 	</fieldset>
31 31
 	<?php endif; ?>
32
-	<?php if(!$_['htaccessWorking']): ?>
32
+	<?php if (!$_['htaccessWorking']): ?>
33 33
 	<fieldset class="warning">
34
-		<legend><strong><?php p($l->t('Security warning'));?></strong></legend>
35
-		<p><?php p($l->t('Your data directory and files are probably accessible from the internet because the .htaccess file does not work.'));?><br>
34
+		<legend><strong><?php p($l->t('Security warning')); ?></strong></legend>
35
+		<p><?php p($l->t('Your data directory and files are probably accessible from the internet because the .htaccess file does not work.')); ?><br>
36 36
 		<?php print_unescaped($l->t(
37 37
 			'For information how to properly configure your server, please see the <a href="%s" target="_blank" rel="noreferrer">documentation</a>.',
38 38
 			link_to_docs('admin-install')
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
 	</fieldset>
41 41
 	<?php endif; ?>
42 42
 	<fieldset id="adminaccount">
43
-		<legend><?php print_unescaped($l->t( 'Create an <strong>admin account</strong>' )); ?></legend>
43
+		<legend><?php print_unescaped($l->t('Create an <strong>admin account</strong>')); ?></legend>
44 44
 		<p class="grouptop">
45 45
 			<input type="text" name="adminlogin" id="adminlogin"
46
-				placeholder="<?php p($l->t( 'Username' )); ?>"
46
+				placeholder="<?php p($l->t('Username')); ?>"
47 47
 				value="<?php p($_['adminlogin']); ?>"
48 48
 				autocomplete="off" autocapitalize="none" autocorrect="off" autofocus required>
49
-			<label for="adminlogin" class="infield"><?php p($l->t( 'Username' )); ?></label>
49
+			<label for="adminlogin" class="infield"><?php p($l->t('Username')); ?></label>
50 50
 		</p>
51 51
 		<p class="groupbottom">
52 52
 			<input type="password" name="adminpass" data-typetoggle="#show" id="adminpass"
53
-				placeholder="<?php p($l->t( 'Password' )); ?>"
53
+				placeholder="<?php p($l->t('Password')); ?>"
54 54
 				value="<?php p($_['adminpass']); ?>"
55 55
 				autocomplete="off" autocapitalize="none" autocorrect="off" required>
56
-			<label for="adminpass" class="infield"><?php p($l->t( 'Password' )); ?></label>
56
+			<label for="adminpass" class="infield"><?php p($l->t('Password')); ?></label>
57 57
 			<input type="checkbox" id="show" name="show">
58 58
 			<label for="show"></label>
59 59
 		</p>
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
 
63 63
 	<fieldset>
64
-		<p class="info"><?php p($l->t( 'Install app bundles' )); ?></p>
64
+		<p class="info"><?php p($l->t('Install app bundles')); ?></p>
65 65
 
66
-		<?php foreach($bundles as $bundle): ?>
66
+		<?php foreach ($bundles as $bundle): ?>
67 67
 		<span class="app-bundle-toggler">
68 68
 			<p style="color: white">
69 69
 				<input type="checkbox" name="bundle[]" value="<?php p($bundle->getIdentifier()) ?>" id="<?php p($bundle->getIdentifier()) ?>" />
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
 		<?php endforeach; ?>
81 81
 	</fieldset>
82 82
 
83
-	<?php if(!$_['directoryIsSet'] OR !$_['dbIsSet'] OR count($_['errors']) > 0): ?>
83
+	<?php if (!$_['directoryIsSet'] OR !$_['dbIsSet'] OR count($_['errors']) > 0): ?>
84 84
 	<fieldset id="advancedHeader">
85
-		<legend><a id="showAdvanced"><?php p($l->t( 'Storage & database' )); ?> <img src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a></legend>
85
+		<legend><a id="showAdvanced"><?php p($l->t('Storage & database')); ?> <img src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a></legend>
86 86
 	</fieldset>
87 87
 	<?php endif; ?>
88 88
 
89
-	<?php if(!$_['directoryIsSet'] OR count($_['errors']) > 0): ?>
89
+	<?php if (!$_['directoryIsSet'] OR count($_['errors']) > 0): ?>
90 90
 	<fieldset id="datadirField">
91 91
 		<div id="datadirContent">
92
-			<label for="directory"><?php p($l->t( 'Data folder' )); ?></label>
92
+			<label for="directory"><?php p($l->t('Data folder')); ?></label>
93 93
 			<input type="text" name="directory" id="directory"
94 94
 				placeholder="<?php p(OC::$SERVERROOT.'/data'); ?>"
95 95
 				value="<?php p($_['directory']); ?>"
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 	</fieldset>
99 99
 	<?php endif; ?>
100 100
 
101
-	<?php if(!$_['dbIsSet'] OR count($_['errors']) > 0): ?>
101
+	<?php if (!$_['dbIsSet'] OR count($_['errors']) > 0): ?>
102 102
 	<fieldset id='databaseBackend'>
103
-		<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'])
104
-			$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite ?>
105
-		<legend><?php p($l->t( 'Configure the database' )); ?></legend>
103
+		<?php if ($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'])
104
+			$hasOtherDB = true; else $hasOtherDB = false; //other than SQLite ?>
105
+		<legend><?php p($l->t('Configure the database')); ?></legend>
106 106
 		<div id="selectDbType">
107
-		<?php foreach($_['databases'] as $type => $label): ?>
108
-		<?php if(count($_['databases']) === 1): ?>
107
+		<?php foreach ($_['databases'] as $type => $label): ?>
108
+		<?php if (count($_['databases']) === 1): ?>
109 109
 		<p class="info">
110
-			<?php p($l->t( 'Only %s is available.', array($label) )); ?>
111
-			<?php p($l->t( 'Install and activate additional PHP modules to choose other database types.' )); ?><br>
110
+			<?php p($l->t('Only %s is available.', array($label))); ?>
111
+			<?php p($l->t('Install and activate additional PHP modules to choose other database types.')); ?><br>
112 112
 			<a href="<?php print_unescaped(link_to_docs('admin-source_install')); ?>" target="_blank" rel="noreferrer">
113
-				<?php p($l->t( 'For more details check out the documentation.' )); ?> ↗</a>
113
+				<?php p($l->t('For more details check out the documentation.')); ?> ↗</a>
114 114
 		</p>
115 115
 		<input type="hidden" id="dbtype" name="dbtype" value="<?php p($type) ?>">
116 116
 		<?php else: ?>
@@ -122,75 +122,75 @@  discard block
 block discarded – undo
122 122
 		</div>
123 123
 	</fieldset>
124 124
 
125
-		<?php if($hasOtherDB): ?>
125
+		<?php if ($hasOtherDB): ?>
126 126
 		<fieldset id='databaseField'>
127 127
 		<div id="use_other_db">
128 128
 			<p class="grouptop">
129
-				<label for="dbuser" class="infield"><?php p($l->t( 'Database user' )); ?></label>
129
+				<label for="dbuser" class="infield"><?php p($l->t('Database user')); ?></label>
130 130
 				<input type="text" name="dbuser" id="dbuser"
131
-					placeholder="<?php p($l->t( 'Database user' )); ?>"
131
+					placeholder="<?php p($l->t('Database user')); ?>"
132 132
 					value="<?php p($_['dbuser']); ?>"
133 133
 					autocomplete="off" autocapitalize="none" autocorrect="off">
134 134
 			</p>
135 135
 			<p class="groupmiddle">
136 136
 				<input type="password" name="dbpass" id="dbpass" data-typetoggle="#dbpassword-toggle"
137
-					placeholder="<?php p($l->t( 'Database password' )); ?>"
137
+					placeholder="<?php p($l->t('Database password')); ?>"
138 138
 					value="<?php p($_['dbpass']); ?>"
139 139
 					autocomplete="off" autocapitalize="none" autocorrect="off">
140
-				<label for="dbpass" class="infield"><?php p($l->t( 'Database password' )); ?></label>
140
+				<label for="dbpass" class="infield"><?php p($l->t('Database password')); ?></label>
141 141
 				<input type="checkbox" id="dbpassword-toggle" name="dbpassword-toggle">
142 142
 				<label for="dbpassword-toggle"></label>
143 143
 			</p>
144 144
 			<p class="groupmiddle">
145
-				<label for="dbname" class="infield"><?php p($l->t( 'Database name' )); ?></label>
145
+				<label for="dbname" class="infield"><?php p($l->t('Database name')); ?></label>
146 146
 				<input type="text" name="dbname" id="dbname"
147
-					placeholder="<?php p($l->t( 'Database name' )); ?>"
147
+					placeholder="<?php p($l->t('Database name')); ?>"
148 148
 					value="<?php p($_['dbname']); ?>"
149 149
 					autocomplete="off" autocapitalize="none" autocorrect="off"
150 150
 					pattern="[0-9a-zA-Z$_-]+">
151 151
 			</p>
152
-			<?php if($_['hasOracle']): ?>
152
+			<?php if ($_['hasOracle']): ?>
153 153
 			<div id="use_oracle_db">
154 154
 				<p class="groupmiddle">
155
-					<label for="dbtablespace" class="infield"><?php p($l->t( 'Database tablespace' )); ?></label>
155
+					<label for="dbtablespace" class="infield"><?php p($l->t('Database tablespace')); ?></label>
156 156
 					<input type="text" name="dbtablespace" id="dbtablespace"
157
-						placeholder="<?php p($l->t( 'Database tablespace' )); ?>"
157
+						placeholder="<?php p($l->t('Database tablespace')); ?>"
158 158
 						value="<?php p($_['dbtablespace']); ?>"
159 159
 						autocomplete="off" autocapitalize="none" autocorrect="off">
160 160
 				</p>
161 161
 			</div>
162 162
 			<?php endif; ?>
163 163
 			<p class="groupbottom">
164
-				<label for="dbhost" class="infield"><?php p($l->t( 'Database host' )); ?></label>
164
+				<label for="dbhost" class="infield"><?php p($l->t('Database host')); ?></label>
165 165
 				<input type="text" name="dbhost" id="dbhost"
166
-					placeholder="<?php p($l->t( 'Database host' )); ?>"
166
+					placeholder="<?php p($l->t('Database host')); ?>"
167 167
 					value="<?php p($_['dbhost']); ?>"
168 168
 					autocomplete="off" autocapitalize="none" autocorrect="off">
169 169
 			</p>
170 170
 			<p class="info">
171
-				<?php p($l->t( 'Please specify the port number along with the host name (e.g., localhost:5432).' )); ?>
171
+				<?php p($l->t('Please specify the port number along with the host name (e.g., localhost:5432).')); ?>
172 172
 			</p>
173 173
 		</div>
174 174
 		</fieldset>
175 175
 		<?php endif; ?>
176 176
 	<?php endif; ?>
177 177
 
178
-	<?php if(!$_['dbIsSet'] OR count($_['errors']) > 0): ?>
178
+	<?php if (!$_['dbIsSet'] OR count($_['errors']) > 0): ?>
179 179
 		<fieldset id="sqliteInformation" class="warning">
180
-			<legend><?php p($l->t('Performance warning'));?></legend>
181
-			<p><?php p($l->t('SQLite will be used as database.'));?></p>
182
-			<p><?php p($l->t('For larger installations we recommend to choose a different database backend.'));?></p>
180
+			<legend><?php p($l->t('Performance warning')); ?></legend>
181
+			<p><?php p($l->t('SQLite will be used as database.')); ?></p>
182
+			<p><?php p($l->t('For larger installations we recommend to choose a different database backend.')); ?></p>
183 183
 			<p><?php p($l->t('Especially when using the desktop client for file syncing the use of SQLite is discouraged.')); ?></p>
184 184
 		</fieldset>
185 185
 	<?php endif ?>
186 186
 
187 187
 	<div class="icon-loading-dark float-spinner">&nbsp;</div>
188 188
 
189
-	<div class="buttons"><input type="submit" class="primary" value="<?php p($l->t( 'Finish setup' )); ?>" data-finishing="<?php p($l->t( 'Finishing …' )); ?>"></div>
189
+	<div class="buttons"><input type="submit" class="primary" value="<?php p($l->t('Finish setup')); ?>" data-finishing="<?php p($l->t('Finishing …')); ?>"></div>
190 190
 
191 191
 	<p class="info">
192 192
 		<span class="icon-info-white"></span>
193
-		<?php p($l->t('Need help?'));?>
194
-		<a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-install')); ?>"><?php p($l->t('See the documentation'));?> ↗</a>
193
+		<?php p($l->t('Need help?')); ?>
194
+		<a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-install')); ?>"><?php p($l->t('See the documentation')); ?> ↗</a>
195 195
 	</p>
196 196
 </form>
Please login to merge, or discard this patch.
lib/private/Installer.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
495 495
 						}
496 496
 					}
497 497
 				}
498
-				closedir( $dir );
498
+				closedir($dir);
499 499
 			}
500 500
 		}
501 501
 
@@ -510,12 +510,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
lib/private/Setup.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -155,24 +155,24 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 				\OC::$server->getLogger(),
377 377
 				\OC::$server->getConfig()
378 378
 			);
379
-			foreach($options['bundle'] as $bundle) {
379
+			foreach ($options['bundle'] as $bundle) {
380 380
 				try {
381 381
 					$bundle = (new BundleFetcher(\OC::$server->getL10N('lib')))->getBundleByIdentifier($bundle);
382 382
 					$installer->installAppBundle($bundle);
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
 		$config = \OC::$server->getSystemConfig();
432 432
 
433 433
 		// For CLI read the value from overwrite.cli.url
434
-		if(\OC::$CLI) {
434
+		if (\OC::$CLI) {
435 435
 			$webRoot = $config->getValue('overwrite.cli.url', '');
436
-			if($webRoot === '') {
436
+			if ($webRoot === '') {
437 437
 				return false;
438 438
 			}
439 439
 			$webRoot = parse_url($webRoot, PHP_URL_PATH);
@@ -451,14 +451,14 @@  discard block
 block discarded – undo
451 451
 		$htaccessContent = explode($content, $htaccessContent, 2)[0];
452 452
 
453 453
 		//custom 403 error page
454
-		$content.= "\nErrorDocument 403 ".$webRoot."/core/templates/403.php";
454
+		$content .= "\nErrorDocument 403 ".$webRoot."/core/templates/403.php";
455 455
 
456 456
 		//custom 404 error page
457
-		$content.= "\nErrorDocument 404 ".$webRoot."/core/templates/404.php";
457
+		$content .= "\nErrorDocument 404 ".$webRoot."/core/templates/404.php";
458 458
 
459 459
 		// Add rewrite rules if the RewriteBase is configured
460 460
 		$rewriteBase = $config->getValue('htaccess.RewriteBase', '');
461
-		if($rewriteBase !== '') {
461
+		if ($rewriteBase !== '') {
462 462
 			$content .= "\n<IfModule mod_rewrite.c>";
463 463
 			$content .= "\n  Options -MultiViews";
464 464
 			$content .= "\n  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]";
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 			$content .= "\n  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/";
478 478
 			$content .= "\n  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*";
479 479
 			$content .= "\n  RewriteRule . index.php [PT,E=PATH_INFO:$1]";
480
-			$content .= "\n  RewriteBase " . $rewriteBase;
480
+			$content .= "\n  RewriteBase ".$rewriteBase;
481 481
 			$content .= "\n  <IfModule mod_env.c>";
482 482
 			$content .= "\n    SetEnv front_controller_active true";
483 483
 			$content .= "\n    <IfModule mod_dir.c>";
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 
490 490
 		if ($content !== '') {
491 491
 			//suppress errors in case we don't have permissions for it
492
-			return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content . "\n");
492
+			return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content."\n");
493 493
 		}
494 494
 
495 495
 		return false;
@@ -497,25 +497,25 @@  discard block
 block discarded – undo
497 497
 
498 498
 	public static function protectDataDirectory() {
499 499
 		//Require all denied
500
-		$now =  date('Y-m-d H:i:s');
500
+		$now = date('Y-m-d H:i:s');
501 501
 		$content = "# Generated by Nextcloud on $now\n";
502
-		$content.= "# line below if for Apache 2.4\n";
503
-		$content.= "<ifModule mod_authz_core.c>\n";
504
-		$content.= "Require all denied\n";
505
-		$content.= "</ifModule>\n\n";
506
-		$content.= "# line below if for Apache 2.2\n";
507
-		$content.= "<ifModule !mod_authz_core.c>\n";
508
-		$content.= "deny from all\n";
509
-		$content.= "Satisfy All\n";
510
-		$content.= "</ifModule>\n\n";
511
-		$content.= "# section for Apache 2.2 and 2.4\n";
512
-		$content.= "<ifModule mod_autoindex.c>\n";
513
-		$content.= "IndexIgnore *\n";
514
-		$content.= "</ifModule>\n";
515
-
516
-		$baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
517
-		file_put_contents($baseDir . '/.htaccess', $content);
518
-		file_put_contents($baseDir . '/index.html', '');
502
+		$content .= "# line below if for Apache 2.4\n";
503
+		$content .= "<ifModule mod_authz_core.c>\n";
504
+		$content .= "Require all denied\n";
505
+		$content .= "</ifModule>\n\n";
506
+		$content .= "# line below if for Apache 2.2\n";
507
+		$content .= "<ifModule !mod_authz_core.c>\n";
508
+		$content .= "deny from all\n";
509
+		$content .= "Satisfy All\n";
510
+		$content .= "</ifModule>\n\n";
511
+		$content .= "# section for Apache 2.2 and 2.4\n";
512
+		$content .= "<ifModule mod_autoindex.c>\n";
513
+		$content .= "IndexIgnore *\n";
514
+		$content .= "</ifModule>\n";
515
+
516
+		$baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
517
+		file_put_contents($baseDir.'/.htaccess', $content);
518
+		file_put_contents($baseDir.'/index.html', '');
519 519
 	}
520 520
 
521 521
 	/**
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 	 */
528 528
 	private function getVendor() {
529 529
 		// this should really be a JSON file
530
-		require \OC::$SERVERROOT . '/version.php';
530
+		require \OC::$SERVERROOT.'/version.php';
531 531
 		/** @var string $vendor */
532 532
 		return (string) $vendor;
533 533
 	}
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/BundleFetcher.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@
 block discarded – undo
53 53
 	 */
54 54
 	public function getBundleByIdentifier($identifier) {
55 55
 		$bundles = $this->getBundles();
56
-		foreach($bundles as $bundle) {
57
-			if($bundle->getIdentifier() === $identifier) {
56
+		foreach ($bundles as $bundle) {
57
+			if ($bundle->getIdentifier() === $identifier) {
58 58
 				return $bundle;
59 59
 			}
60 60
 		}
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/EnterpriseBundle.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@
 block discarded – undo
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
 	/**
34 34
 	 * {@inheritDoc}
35 35
 	 */
36 36
 	public function getDescription() {
37
-		return (string)$this->l10n->t('Apps for the Enterprise.');
37
+		return (string) $this->l10n->t('Apps for the Enterprise.');
38 38
 	}
39 39
 
40 40
 	/**
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/GroupwareBundle.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@
 block discarded – undo
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
 	/**
34 34
 	 * {@inheritDoc}
35 35
 	 */
36 36
 	public function getDescription() {
37
-		return (string)$this->l10n->t('Apps for groupware functionalities.');
37
+		return (string) $this->l10n->t('Apps for groupware functionalities.');
38 38
 	}
39 39
 
40 40
 	/**
Please login to merge, or discard this patch.