Completed
Pull Request — release-2.1 (#4139)
by Michael
08:54
created
Sources/Subscriptions-PayPal.php 1 patch
Braces   +83 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 // This won't be dedicated without this - this must exist in each gateway!
15 15
 // SMF Payment Gateway: paypal
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Class for returning available form data for this gateway
@@ -118,8 +119,7 @@  discard block
 block discarded – undo
118 119
 		{
119 120
 			$return_data['hidden']['p3'] = 1;
120 121
 			$return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1));
121
-		}
122
-		else
122
+		} else
123 123
 		{
124 124
 			preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match);
125 125
 			$unit = $match[1];
@@ -130,14 +130,15 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 
132 132
 		// If it's repeatable do some javascript to respect this idea.
133
-		if (!empty($sub_data['repeatable']))
134
-			$return_data['javascript'] = '
133
+		if (!empty($sub_data['repeatable'])) {
134
+					$return_data['javascript'] = '
135 135
 				document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();" class="input_check">' . $txt['paid_make_recurring'] . '</label><br>\');
136 136
 
137 137
 				function switchPaypalRecur()
138 138
 				{
139 139
 					document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick";
140 140
 				}';
141
+		}
141 142
 
142 143
 		return $return_data;
143 144
 	}
@@ -160,20 +161,24 @@  discard block
 block discarded – undo
160 161
 		global $modSettings;
161 162
 
162 163
 		// Has the user set up an email address?
163
-		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email'])))
164
-			return false;
164
+		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) {
165
+					return false;
166
+		}
165 167
 		// Check the correct transaction types are even here.
166
-		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email'])))
167
-			return false;
168
+		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) {
169
+					return false;
170
+		}
168 171
 		// Correct email address?
169
-		if (!isset($_POST['business']))
170
-			$_POST['business'] = $_POST['receiver_email'];
172
+		if (!isset($_POST['business'])) {
173
+					$_POST['business'] = $_POST['receiver_email'];
174
+		}
171 175
 
172 176
 		// Are we testing?
173
-		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
174
-			return false;
175
-		elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails']))))
176
-			return false;
177
+		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
178
+					return false;
179
+		} elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) {
180
+					return false;
181
+		}
177 182
 		return true;
178 183
 	}
179 184
 
@@ -192,15 +197,17 @@  discard block
 block discarded – undo
192 197
 		global $modSettings, $txt;
193 198
 
194 199
 		// Put this to some default value.
195
-		if (!isset($_POST['txn_type']))
196
-			$_POST['txn_type'] = '';
200
+		if (!isset($_POST['txn_type'])) {
201
+					$_POST['txn_type'] = '';
202
+		}
197 203
 
198 204
 		// Build the request string - starting with the minimum requirement.
199 205
 		$requestString = 'cmd=_notify-validate';
200 206
 
201 207
 		// Now my dear, add all the posted bits in the order we got them
202
-		foreach ($_POST as $k => $v)
203
-			$requestString .= '&' . $k . '=' . urlencode($v);
208
+		foreach ($_POST as $k => $v) {
209
+					$requestString .= '&' . $k . '=' . urlencode($v);
210
+		}
204 211
 
205 212
 		// Can we use curl?
206 213
 		if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'https://www.') . 'paypal.com/cgi-bin/webscr'))
@@ -240,14 +247,16 @@  discard block
 block discarded – undo
240 247
 			$header .= 'Connection: close' . "\r\n\r\n";
241 248
 
242 249
 			// Open the connection.
243
-			if (!empty($modSettings['paidsubs_test']))
244
-				$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
245
-			else
246
-				$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
250
+			if (!empty($modSettings['paidsubs_test'])) {
251
+							$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
252
+			} else {
253
+							$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
254
+			}
247 255
 
248 256
 			// Did it work?
249
-			if (!$fp)
250
-				generateSubscriptionError($txt['paypal_could_not_connect']);
257
+			if (!$fp) {
258
+							generateSubscriptionError($txt['paypal_could_not_connect']);
259
+			}
251 260
 
252 261
 			// Put the data to the port.
253 262
 			fputs($fp, $header . $requestString);
@@ -256,8 +265,9 @@  discard block
 block discarded – undo
256 265
 			while (!feof($fp))
257 266
 			{
258 267
 				$this->return_data = fgets($fp, 1024);
259
-				if (strcmp(trim($this->return_data), 'VERIFIED') === 0)
260
-					break;
268
+				if (strcmp(trim($this->return_data), 'VERIFIED') === 0) {
269
+									break;
270
+				}
261 271
 			}
262 272
 
263 273
 			// Clean up.
@@ -265,28 +275,34 @@  discard block
 block discarded – undo
265 275
 		}
266 276
 
267 277
 		// If this isn't verified then give up...
268
-		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0)
269
-			exit;
278
+		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) {
279
+					exit;
280
+		}
270 281
 
271 282
 		// Check that this is intended for us.
272
-		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
273
-			exit;
283
+		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
284
+					exit;
285
+		}
274 286
 
275 287
 		// Is this a subscription - and if so is it a secondary payment that we need to process?
276 288
 		// If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding.
277
-		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false)
278
-			$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
279
-		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false))
280
-			// Calculate the subscription it relates to!
289
+		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) {
290
+					$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
291
+		}
292
+		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) {
293
+					// Calculate the subscription it relates to!
281 294
 			$this->_findSubscription();
295
+		}
282 296
 
283 297
 		// Verify the currency!
284
-		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code']))
285
-			exit;
298
+		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) {
299
+					exit;
300
+		}
286 301
 
287 302
 		// Can't exist if it doesn't contain anything.
288
-		if (empty($_POST['item_number']))
289
-			exit;
303
+		if (empty($_POST['item_number'])) {
304
+					exit;
305
+		}
290 306
 
291 307
 		// Return the id_sub and id_member
292 308
 		return explode('+', $_POST['item_number']);
@@ -299,10 +315,11 @@  discard block
 block discarded – undo
299 315
 	 */
300 316
 	public function isRefund()
301 317
 	{
302
-		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed'))
303
-			return true;
304
-		else
305
-			return false;
318
+		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) {
319
+					return true;
320
+		} else {
321
+					return false;
322
+		}
306 323
 	}
307 324
 
308 325
 	/**
@@ -312,10 +329,11 @@  discard block
 block discarded – undo
312 329
 	 */
313 330
 	public function isSubscription()
314 331
 	{
315
-		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed')
316
-			return true;
317
-		else
318
-			return false;
332
+		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') {
333
+					return true;
334
+		} else {
335
+					return false;
336
+		}
319 337
 	}
320 338
 
321 339
 	/**
@@ -325,10 +343,11 @@  discard block
 block discarded – undo
325 343
 	 */
326 344
 	public function isPayment()
327 345
 	{
328
-		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept')
329
-			return true;
330
-		else
331
-			return false;
346
+		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') {
347
+					return true;
348
+		} else {
349
+					return false;
350
+		}
332 351
 	}
333 352
 
334 353
 	/**
@@ -341,10 +360,11 @@  discard block
 block discarded – undo
341 360
 		// subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment
342 361
 		// Neither require us to *do* anything as per performCancel().
343 362
 		// subscr_eot, if sent, indicates an end of payments term.
344
-		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot')
345
-			return true;
346
-		else
347
-			return false;
363
+		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') {
364
+					return true;
365
+		} else {
366
+					return false;
367
+		}
348 368
 	}
349 369
 
350 370
 	/**
@@ -409,8 +429,9 @@  discard block
 block discarded – undo
409 429
 		global $smcFunc;
410 430
 
411 431
 		// Assume we have this?
412
-		if (empty($_POST['subscr_id']))
413
-			return false;
432
+		if (empty($_POST['subscr_id'])) {
433
+					return false;
434
+		}
414 435
 
415 436
 		// Do we have this in the database?
416 437
 		$request = $smcFunc['db_query']('', '
@@ -439,11 +460,12 @@  discard block
 block discarded – undo
439 460
 						'payer_email' => $_POST['payer_email'],
440 461
 					)
441 462
 				);
442
-				if ($smcFunc['db_num_rows']($request) === 0)
443
-					return false;
463
+				if ($smcFunc['db_num_rows']($request) === 0) {
464
+									return false;
465
+				}
466
+			} else {
467
+							return false;
444 468
 			}
445
-			else
446
-				return false;
447 469
 		}
448 470
 		list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request);
449 471
 		$_POST['item_number'] = $member_id . '+' . $subscription_id;
Please login to merge, or discard this patch.
Themes/default/Post.template.php 1 patch
Braces   +89 added lines, -61 removed lines patch added patch discarded remove patch
@@ -22,22 +22,24 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32
-	foreach ($context['icons'] as $icon)
33
-		echo '
33
+	foreach ($context['icons'] as $icon) {
34
+			echo '
34 35
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
36
+	}
35 37
 	echo '
36 38
 			};';
37 39
 
38 40
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
39
-	if ($context['make_poll'])
40
-		echo '
41
+	if ($context['make_poll']) {
42
+			echo '
41 43
 			var pollOptionNum = 0, pollTabIndex;
42 44
 			var pollOptionId = ', $context['last_choice_id'], ';
43 45
 			function addPollOption()
@@ -56,11 +58,13 @@  discard block
 block discarded – undo
56 58
 
57 59
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('" class="input_text"></dd><p id="pollMoreOptions"></p>'), ');
58 60
 			}';
61
+	}
59 62
 
60 63
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
61
-	if ($context['make_event'])
62
-		echo '
64
+	if ($context['make_event']) {
65
+			echo '
63 66
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
67
+	}
64 68
 
65 69
 	// End of the javascript, start the form and display the link tree.
66 70
 	echo '
@@ -80,9 +84,10 @@  discard block
 block discarded – undo
80 84
 				</div>
81 85
 			</div><br>';
82 86
 
83
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
84
-		echo '
87
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
88
+			echo '
85 89
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
90
+	}
86 91
 
87 92
 	// Start the main table.
88 93
 	echo '
@@ -117,18 +122,20 @@  discard block
 block discarded – undo
117 122
 	}
118 123
 
119 124
 	// If it's locked, show a message to warn the replier.
120
-	if (!empty($context['locked']))
121
-	echo '
125
+	if (!empty($context['locked'])) {
126
+		echo '
122 127
 					<p class="errorbox">
123 128
 						', $txt['topic_locked_no_reply'], '
124 129
 					</p>';
130
+	}
125 131
 
126
-	if (!empty($modSettings['drafts_post_enabled']))
127
-		echo '
132
+	if (!empty($modSettings['drafts_post_enabled'])) {
133
+			echo '
128 134
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
129 135
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
130 136
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
131 137
 					</div>';
138
+	}
132 139
 
133 140
 	// The post header... important stuff
134 141
 	echo '
@@ -180,9 +187,10 @@  discard block
 block discarded – undo
180 187
 				{
181 188
 					echo '
182 189
 										<optgroup label="', $category['name'], '">';
183
-					foreach ($category['boards'] as $board)
184
-						echo '
190
+					foreach ($category['boards'] as $board) {
191
+											echo '
185 192
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
193
+					}
186 194
 					echo '
187 195
 										</optgroup>';
188 196
 				}
@@ -218,9 +226,10 @@  discard block
 block discarded – undo
218 226
 									<span class="label">', $txt['calendar_timezone'], '</span>
219 227
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
220 228
 
221
-			foreach ($context['all_timezones'] as $tz => $tzname)
222
-				echo '
229
+			foreach ($context['all_timezones'] as $tz => $tzname) {
230
+							echo '
223 231
 										<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
232
+			}
224 233
 
225 234
 			echo '
226 235
 									</select>
@@ -286,14 +295,15 @@  discard block
 block discarded – undo
286 295
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', ' class="input_check">
287 296
 								</dd>';
288 297
 
289
-		if ($context['poll_options']['guest_vote_enabled'])
290
-			echo '
298
+		if ($context['poll_options']['guest_vote_enabled']) {
299
+					echo '
291 300
 								<dt>
292 301
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
293 302
 								</dt>
294 303
 								<dd>
295 304
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', ' class="input_check">
296 305
 								</dd>';
306
+		}
297 307
 
298 308
 		echo '
299 309
 								<dt>
@@ -314,8 +324,8 @@  discard block
 block discarded – undo
314 324
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
315 325
 
316 326
 	// If we're editing and displaying edit details, show a box where they can say why
317
-	if (isset($context['editing']) && $modSettings['show_modify'])
318
-		echo '
327
+	if (isset($context['editing']) && $modSettings['show_modify']) {
328
+			echo '
319 329
 					<dl>
320 330
 						<dt class="clear">
321 331
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -324,20 +334,23 @@  discard block
 block discarded – undo
324 334
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text">
325 335
 						</dd>
326 336
 					</dl>';
337
+	}
327 338
 
328 339
 	// If this message has been edited in the past - display when it was.
329
-	if (isset($context['last_modified']))
330
-		echo '
340
+	if (isset($context['last_modified'])) {
341
+			echo '
331 342
 					<div class="padding smalltext">
332 343
 						', $context['last_modified_text'], '
333 344
 					</div>';
345
+	}
334 346
 
335 347
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
336
-	if (!empty($modSettings['additional_options_collapsable']))
337
-		echo '
348
+	if (!empty($modSettings['additional_options_collapsable'])) {
349
+			echo '
338 350
 					<div id="postAdditionalOptionsHeader">
339 351
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
340 352
 					</div>';
353
+	}
341 354
 
342 355
 	echo '
343 356
 					<div id="postAdditionalOptions">';
@@ -369,19 +382,21 @@  discard block
 block discarded – undo
369 382
 								<input type="hidden" name="attach_del[]" value="0">
370 383
 								', $txt['uncheck_unwatchd_attach'], ':
371 384
 							</dd>';
372
-		foreach ($context['current_attachments'] as $attachment)
373
-			echo '
385
+		foreach ($context['current_attachments'] as $attachment) {
386
+					echo '
374 387
 							<dd class="smalltext">
375 388
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', ' class="input_check"> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
376 389
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0)) : '', '</label>
377 390
 							</dd>';
391
+		}
378 392
 
379 393
 		echo '
380 394
 						</dl>';
381 395
 
382
-		if (!empty($context['files_in_session_warning']))
383
-			echo '
396
+		if (!empty($context['files_in_session_warning'])) {
397
+					echo '
384 398
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
399
+		}
385 400
 	}
386 401
 
387 402
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -434,8 +449,8 @@  discard block
 block discarded – undo
434 449
 								', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '">');
435 450
 
436 451
 		// Show more boxes if they aren't approaching that limit.
437
-		if ($context['num_allowed_attachments'] > 1)
438
-			echo '
452
+		if ($context['num_allowed_attachments'] > 1) {
453
+					echo '
439 454
 										<script>
440 455
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
441 456
 											var current_attachment = 1;
@@ -456,9 +471,10 @@  discard block
 block discarded – undo
456 471
 									</div>
457 472
 								</div>
458 473
 							</dd>';
459
-		else
460
-			echo '
474
+		} else {
475
+					echo '
461 476
 							</dd>';
477
+		}
462 478
 
463 479
 		// Add any template changes for an alternative upload system here.
464 480
 		call_integration_hook('integrate_upload_template');
@@ -467,21 +483,25 @@  discard block
 block discarded – undo
467 483
 							<dd class="smalltext">';
468 484
 
469 485
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
470
-		if (!empty($modSettings['attachmentCheckExtensions']))
471
-			echo '
486
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
487
+					echo '
472 488
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
489
+		}
473 490
 
474
-		if (!empty($context['attachment_restrictions']))
475
-			echo '
491
+		if (!empty($context['attachment_restrictions'])) {
492
+					echo '
476 493
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
494
+		}
477 495
 
478
-		if ($context['num_allowed_attachments'] == 0)
479
-			echo '
496
+		if ($context['num_allowed_attachments'] == 0) {
497
+					echo '
480 498
 								', $txt['attach_limit_nag'], '<br>';
499
+		}
481 500
 
482
-		if (!$context['can_post_attachment_unapproved'])
483
-			echo '
501
+		if (!$context['can_post_attachment_unapproved']) {
502
+					echo '
484 503
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
504
+		}
485 505
 
486 506
 		echo '
487 507
 							</dd>
@@ -504,10 +524,11 @@  discard block
 block discarded – undo
504 524
 							<dt><strong>', $txt['subject'], '</strong></dt>
505 525
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
506 526
 
507
-		foreach ($context['drafts'] as $draft)
508
-			echo '
527
+		foreach ($context['drafts'] as $draft) {
528
+					echo '
509 529
 							<dt>', $draft['link'], '</dt>
510 530
 							<dd>', $draft['poster_time'], '</dd>';
531
+		}
511 532
 		echo '
512 533
 						</dl>
513 534
 					</div>';
@@ -532,9 +553,10 @@  discard block
 block discarded – undo
532 553
 						', template_control_richedit_buttons($context['post_box_name']);
533 554
 
534 555
 	// Option to delete an event if user is editing one.
535
-	if ($context['make_event'] && !$context['event']['new'])
536
-		echo '
556
+	if ($context['make_event'] && !$context['event']['new']) {
557
+			echo '
537 558
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">';
559
+	}
538 560
 
539 561
 	echo '
540 562
 					</span>
@@ -543,9 +565,10 @@  discard block
 block discarded – undo
543 565
 			<br class="clear">';
544 566
 
545 567
 	// Assuming this isn't a new topic pass across the last message id.
546
-	if (isset($context['topic_last_message']))
547
-		echo '
568
+	if (isset($context['topic_last_message'])) {
569
+			echo '
548 570
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
571
+	}
549 572
 
550 573
 	echo '
551 574
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -687,9 +710,10 @@  discard block
 block discarded – undo
687 710
 
688 711
 						newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \'&nbsp;&#187;</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';';
689 712
 
690
-	if ($context['can_quote'])
691
-		echo '
713
+	if ($context['can_quote']) {
714
+			echo '
692 715
 						newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';';
716
+	}
693 717
 
694 718
 	echo '
695 719
 						newPostsHTML += \'<br class="clear">\';
@@ -732,8 +756,8 @@  discard block
 block discarded – undo
732 756
 			}';
733 757
 
734 758
 	// Code for showing and hiding additional options.
735
-	if (!empty($modSettings['additional_options_collapsable']))
736
-		echo '
759
+	if (!empty($modSettings['additional_options_collapsable'])) {
760
+			echo '
737 761
 			var oSwapAdditionalOptions = new smc_Toggle({
738 762
 				bToggleEnabled: true,
739 763
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -761,10 +785,11 @@  discard block
 block discarded – undo
761 785
 					}
762 786
 				]
763 787
 			});';
788
+	}
764 789
 
765 790
 	// Code for showing and hiding drafts
766
-	if (!empty($context['drafts']))
767
-		echo '
791
+	if (!empty($context['drafts'])) {
792
+			echo '
768 793
 			var oSwapDraftOptions = new smc_Toggle({
769 794
 				bToggleEnabled: true,
770 795
 				bCurrentlyCollapsed: true,
@@ -786,6 +811,7 @@  discard block
 block discarded – undo
786 811
 					}
787 812
 				]
788 813
 			});';
814
+	}
789 815
 
790 816
 	echo '
791 817
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -806,8 +832,9 @@  discard block
 block discarded – undo
806 832
 		foreach ($context['previous_posts'] as $post)
807 833
 		{
808 834
 			$ignoring = false;
809
-			if (!empty($post['is_ignored']))
810
-				$ignored_posts[] = $ignoring = $post['id'];
835
+			if (!empty($post['is_ignored'])) {
836
+							$ignored_posts[] = $ignoring = $post['id'];
837
+			}
811 838
 
812 839
 			echo '
813 840
 			<div class="windowbg">
@@ -990,10 +1017,10 @@  discard block
 block discarded – undo
990 1017
 		<div id="temporary_posting_area" style="display: none;"></div>
991 1018
 		<script>';
992 1019
 
993
-	if ($context['close_window'])
994
-		echo '
1020
+	if ($context['close_window']) {
1021
+			echo '
995 1022
 			window.close();';
996
-	else
1023
+	} else
997 1024
 	{
998 1025
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;).
999 1026
 		echo '
@@ -1047,11 +1074,12 @@  discard block
 block discarded – undo
1047 1074
 				</p>
1048 1075
 				<ul>';
1049 1076
 
1050
-	foreach ($context['groups'] as $group)
1051
-		echo '
1077
+	foreach ($context['groups'] as $group) {
1078
+			echo '
1052 1079
 					<li>
1053 1080
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked class="input_check"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
1054 1081
 					</li>';
1082
+	}
1055 1083
 
1056 1084
 	echo '
1057 1085
 					<li>
Please login to merge, or discard this patch.
SSI.php 1 patch
Braces   +426 added lines, -304 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Don't do anything if SMF is already loaded.
15
-if (defined('SMF'))
15
+if (defined('SMF')) {
16 16
 	return true;
17
+}
17 18
 
18 19
 define('SMF', 'SSI');
19 20
 
@@ -28,16 +29,18 @@  discard block
 block discarded – undo
28 29
 $time_start = microtime();
29 30
 
30 31
 // Just being safe...
31
-foreach (array('db_character_set', 'cachedir') as $variable)
32
+foreach (array('db_character_set', 'cachedir') as $variable) {
32 33
 	if (isset($GLOBALS[$variable]))
33 34
 		unset($GLOBALS[$variable]);
35
+}
34 36
 
35 37
 // Get the forum's settings for database and file paths.
36 38
 require_once(dirname(__FILE__) . '/Settings.php');
37 39
 
38 40
 // Make absolutely sure the cache directory is defined.
39
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
41
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
40 42
 	$cachedir = $boarddir . '/cache';
43
+}
41 44
 
42 45
 $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
43 46
 /* Set this to one of three values depending on what you want to happen in the case of a fatal error.
@@ -48,12 +51,14 @@  discard block
 block discarded – undo
48 51
 $ssi_on_error_method = false;
49 52
 
50 53
 // Don't do john didley if the forum's been shut down completely.
51
-if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true))
54
+if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) {
52 55
 	die($mmessage);
56
+}
53 57
 
54 58
 // Fix for using the current directory as a path.
55
-if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
59
+if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') {
56 60
 	$sourcedir = dirname(__FILE__) . substr($sourcedir, 1);
61
+}
57 62
 
58 63
 // Load the important includes.
59 64
 require_once($sourcedir . '/QueryString.php');
@@ -78,34 +83,38 @@  discard block
 block discarded – undo
78 83
 cleanRequest();
79 84
 
80 85
 // Seed the random generator?
81
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
86
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
82 87
 	smf_seed_generator();
88
+}
83 89
 
84 90
 // Check on any hacking attempts.
85
-if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']))
91
+if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
86 92
 	die('No direct access...');
87
-elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme)
93
+} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) {
88 94
 	die('No direct access...');
89
-elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme)
95
+} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) {
90 96
 	die('No direct access...');
91
-elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers)
97
+} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) {
92 98
 	die('No direct access...');
93
-if (isset($_REQUEST['context']))
99
+}
100
+if (isset($_REQUEST['context'])) {
94 101
 	die('No direct access...');
102
+}
95 103
 
96 104
 // Gzip output? (because it must be boolean and true, this can't be hacked.)
97
-if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>='))
105
+if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) {
98 106
 	ob_start('ob_gzhandler');
99
-else
107
+} else {
100 108
 	$modSettings['enableCompressedOutput'] = '0';
109
+}
101 110
 
102 111
 // Primarily, this is to fix the URLs...
103 112
 ob_start('ob_sessrewrite');
104 113
 
105 114
 // Start the session... known to scramble SSI includes in cases...
106
-if (!headers_sent())
115
+if (!headers_sent()) {
107 116
 	loadSession();
108
-else
117
+} else
109 118
 {
110 119
 	if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))
111 120
 	{
@@ -139,12 +148,14 @@  discard block
 block discarded – undo
139 148
 loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
140 149
 
141 150
 // @todo: probably not the best place, but somewhere it should be set...
142
-if (!headers_sent())
151
+if (!headers_sent()) {
143 152
 	header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set']));
153
+}
144 154
 
145 155
 // Take care of any banning that needs to be done.
146
-if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
156
+if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) {
147 157
 	is_not_banned();
158
+}
148 159
 
149 160
 // Do we allow guests in here?
150 161
 if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php')
@@ -159,17 +170,19 @@  discard block
 block discarded – undo
159 170
 {
160 171
 	$context['template_layers'] = $ssi_layers;
161 172
 	template_header();
162
-}
163
-else
173
+} else {
164 174
 	setupThemeContext();
175
+}
165 176
 
166 177
 // Make sure they didn't muss around with the settings... but only if it's not cli.
167
-if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '')
178
+if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') {
168 179
 	trigger_error($txt['ssi_session_broken'], E_USER_NOTICE);
180
+}
169 181
 
170 182
 // Without visiting the forum this session variable might not be set on submit.
171
-if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote'))
183
+if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) {
172 184
 	$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
185
+}
173 186
 
174 187
 // Have the ability to easily add functions to SSI.
175 188
 call_integration_hook('integrate_SSI');
@@ -178,11 +191,13 @@  discard block
 block discarded – undo
178 191
 if (basename($_SERVER['PHP_SELF']) == 'SSI.php')
179 192
 {
180 193
 	// You shouldn't just access SSI.php directly by URL!!
181
-	if (!isset($_GET['ssi_function']))
182
-		die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
194
+	if (!isset($_GET['ssi_function'])) {
195
+			die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
196
+	}
183 197
 	// Call a function passed by GET.
184
-	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest']))
185
-		call_user_func('ssi_' . $_GET['ssi_function']);
198
+	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) {
199
+			call_user_func('ssi_' . $_GET['ssi_function']);
200
+	}
186 201
 	exit;
187 202
 }
188 203
 
@@ -199,9 +214,10 @@  discard block
 block discarded – undo
199 214
  */
200 215
 function ssi_shutdown()
201 216
 {
202
-	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown')
203
-		template_footer();
204
-}
217
+	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') {
218
+			template_footer();
219
+	}
220
+	}
205 221
 
206 222
 /**
207 223
  * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new.
@@ -214,15 +230,17 @@  discard block
 block discarded – undo
214 230
 
215 231
 	if ($output_method == 'echo')
216 232
 	{
217
-		if ($context['user']['is_guest'])
218
-			echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
219
-		else
220
-			echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
233
+		if ($context['user']['is_guest']) {
234
+					echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
235
+		} else {
236
+					echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
237
+		}
221 238
 	}
222 239
 	// Don't echo... then do what?!
223
-	else
224
-		return $context['user'];
225
-}
240
+	else {
241
+			return $context['user'];
242
+	}
243
+	}
226 244
 
227 245
 /**
228 246
  * Display a menu bar, like is displayed at the top of the forum.
@@ -233,12 +251,14 @@  discard block
 block discarded – undo
233 251
 {
234 252
 	global $context;
235 253
 
236
-	if ($output_method == 'echo')
237
-		template_menu();
254
+	if ($output_method == 'echo') {
255
+			template_menu();
256
+	}
238 257
 	// What else could this do?
239
-	else
240
-		return $context['menu_buttons'];
241
-}
258
+	else {
259
+			return $context['menu_buttons'];
260
+	}
261
+	}
242 262
 
243 263
 /**
244 264
  * Show a logout link.
@@ -250,20 +270,23 @@  discard block
 block discarded – undo
250 270
 {
251 271
 	global $context, $txt, $scripturl;
252 272
 
253
-	if ($redirect_to != '')
254
-		$_SESSION['logout_url'] = $redirect_to;
273
+	if ($redirect_to != '') {
274
+			$_SESSION['logout_url'] = $redirect_to;
275
+	}
255 276
 
256 277
 	// Guests can't log out.
257
-	if ($context['user']['is_guest'])
258
-		return false;
278
+	if ($context['user']['is_guest']) {
279
+			return false;
280
+	}
259 281
 
260 282
 	$link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>';
261 283
 
262
-	if ($output_method == 'echo')
263
-		echo $link;
264
-	else
265
-		return $link;
266
-}
284
+	if ($output_method == 'echo') {
285
+			echo $link;
286
+	} else {
287
+			return $link;
288
+	}
289
+	}
267 290
 
268 291
 /**
269 292
  * Recent post list:   [board] Subject by Poster    Date
@@ -279,17 +302,17 @@  discard block
 block discarded – undo
279 302
 	global $modSettings, $context;
280 303
 
281 304
 	// Excluding certain boards...
282
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
283
-		$exclude_boards = array($modSettings['recycle_board']);
284
-	else
285
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
305
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
306
+			$exclude_boards = array($modSettings['recycle_board']);
307
+	} else {
308
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
309
+	}
286 310
 
287 311
 	// What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter.
288 312
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
289 313
 	{
290 314
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
291
-	}
292
-	elseif ($include_boards != null)
315
+	} elseif ($include_boards != null)
293 316
 	{
294 317
 		$include_boards = array();
295 318
 	}
@@ -326,8 +349,9 @@  discard block
 block discarded – undo
326 349
 {
327 350
 	global $modSettings;
328 351
 
329
-	if (empty($post_ids))
330
-		return;
352
+	if (empty($post_ids)) {
353
+			return;
354
+	}
331 355
 
332 356
 	// Allow the user to request more than one - why not?
333 357
 	$post_ids = is_array($post_ids) ? $post_ids : array($post_ids);
@@ -362,8 +386,9 @@  discard block
 block discarded – undo
362 386
 	global $scripturl, $txt, $user_info;
363 387
 	global $modSettings, $smcFunc, $context;
364 388
 
365
-	if (!empty($modSettings['enable_likes']))
366
-		$context['can_like'] = allowedTo('likes_like');
389
+	if (!empty($modSettings['enable_likes'])) {
390
+			$context['can_like'] = allowedTo('likes_like');
391
+	}
367 392
 
368 393
 	// Find all the posts. Newer ones will have higher IDs.
369 394
 	$request = $smcFunc['db_query']('substring', '
@@ -429,12 +454,13 @@  discard block
 block discarded – undo
429 454
 		);
430 455
 
431 456
 		// Get the likes for each message.
432
-		if (!empty($modSettings['enable_likes']))
433
-			$posts[$row['id_msg']]['likes'] = array(
457
+		if (!empty($modSettings['enable_likes'])) {
458
+					$posts[$row['id_msg']]['likes'] = array(
434 459
 				'count' => $row['likes'],
435 460
 				'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])),
436 461
 				'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']),
437 462
 			);
463
+		}
438 464
 	}
439 465
 	$smcFunc['db_free_result']($request);
440 466
 
@@ -442,13 +468,14 @@  discard block
 block discarded – undo
442 468
 	call_integration_hook('integrate_ssi_queryPosts', array(&$posts));
443 469
 
444 470
 	// Just return it.
445
-	if ($output_method != 'echo' || empty($posts))
446
-		return $posts;
471
+	if ($output_method != 'echo' || empty($posts)) {
472
+			return $posts;
473
+	}
447 474
 
448 475
 	echo '
449 476
 		<table style="border: none" class="ssi_table">';
450
-	foreach ($posts as $post)
451
-		echo '
477
+	foreach ($posts as $post) {
478
+			echo '
452 479
 			<tr>
453 480
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
454 481
 					[', $post['board']['link'], ']
@@ -462,6 +489,7 @@  discard block
 block discarded – undo
462 489
 					', $post['time'], '
463 490
 				</td>
464 491
 			</tr>';
492
+	}
465 493
 	echo '
466 494
 		</table>';
467 495
 }
@@ -479,25 +507,26 @@  discard block
 block discarded – undo
479 507
 	global $settings, $scripturl, $txt, $user_info;
480 508
 	global $modSettings, $smcFunc, $context;
481 509
 
482
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
483
-		$exclude_boards = array($modSettings['recycle_board']);
484
-	else
485
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
510
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
511
+			$exclude_boards = array($modSettings['recycle_board']);
512
+	} else {
513
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
514
+	}
486 515
 
487 516
 	// Only some boards?.
488 517
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
489 518
 	{
490 519
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
491
-	}
492
-	elseif ($include_boards != null)
520
+	} elseif ($include_boards != null)
493 521
 	{
494 522
 		$output_method = $include_boards;
495 523
 		$include_boards = array();
496 524
 	}
497 525
 
498 526
 	$icon_sources = array();
499
-	foreach ($context['stable_icons'] as $icon)
500
-		$icon_sources[$icon] = 'images_url';
527
+	foreach ($context['stable_icons'] as $icon) {
528
+			$icon_sources[$icon] = 'images_url';
529
+	}
501 530
 
502 531
 	// Find all the posts in distinct topics.  Newer ones will have higher IDs.
503 532
 	$request = $smcFunc['db_query']('substring', '
@@ -522,13 +551,15 @@  discard block
 block discarded – undo
522 551
 		)
523 552
 	);
524 553
 	$topics = array();
525
-	while ($row = $smcFunc['db_fetch_assoc']($request))
526
-		$topics[$row['id_topic']] = $row;
554
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
555
+			$topics[$row['id_topic']] = $row;
556
+	}
527 557
 	$smcFunc['db_free_result']($request);
528 558
 
529 559
 	// Did we find anything? If not, bail.
530
-	if (empty($topics))
531
-		return array();
560
+	if (empty($topics)) {
561
+			return array();
562
+	}
532 563
 
533 564
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
534 565
 
@@ -556,19 +587,22 @@  discard block
 block discarded – undo
556 587
 	while ($row = $smcFunc['db_fetch_assoc']($request))
557 588
 	{
558 589
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
559
-		if ($smcFunc['strlen']($row['body']) > 128)
560
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
590
+		if ($smcFunc['strlen']($row['body']) > 128) {
591
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
592
+		}
561 593
 
562 594
 		// Censor the subject.
563 595
 		censorText($row['subject']);
564 596
 		censorText($row['body']);
565 597
 
566 598
 		// Recycled icon
567
-		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board'])
568
-			$row['icon'] = 'recycled';
599
+		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) {
600
+					$row['icon'] = 'recycled';
601
+		}
569 602
 
570
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
571
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
603
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
604
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
605
+		}
572 606
 
573 607
 		// Build the array.
574 608
 		$posts[] = array(
@@ -607,13 +641,14 @@  discard block
 block discarded – undo
607 641
 	call_integration_hook('integrate_ssi_recentTopics', array(&$posts));
608 642
 
609 643
 	// Just return it.
610
-	if ($output_method != 'echo' || empty($posts))
611
-		return $posts;
644
+	if ($output_method != 'echo' || empty($posts)) {
645
+			return $posts;
646
+	}
612 647
 
613 648
 	echo '
614 649
 		<table style="border: none" class="ssi_table">';
615
-	foreach ($posts as $post)
616
-		echo '
650
+	foreach ($posts as $post) {
651
+			echo '
617 652
 			<tr>
618 653
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
619 654
 					[', $post['board']['link'], ']
@@ -627,6 +662,7 @@  discard block
 block discarded – undo
627 662
 					', $post['time'], '
628 663
 				</td>
629 664
 			</tr>';
665
+	}
630 666
 	echo '
631 667
 		</table>';
632 668
 }
@@ -651,27 +687,30 @@  discard block
 block discarded – undo
651 687
 		)
652 688
 	);
653 689
 	$return = array();
654
-	while ($row = $smcFunc['db_fetch_assoc']($request))
655
-		$return[] = array(
690
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
691
+			$return[] = array(
656 692
 			'id' => $row['id_member'],
657 693
 			'name' => $row['real_name'],
658 694
 			'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
659 695
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
660 696
 			'posts' => $row['posts']
661 697
 		);
698
+	}
662 699
 	$smcFunc['db_free_result']($request);
663 700
 
664 701
 	// If mods want to do somthing with this list of members, let them do that now.
665 702
 	call_integration_hook('integrate_ssi_topPoster', array(&$return));
666 703
 
667 704
 	// Just return all the top posters.
668
-	if ($output_method != 'echo')
669
-		return $return;
705
+	if ($output_method != 'echo') {
706
+			return $return;
707
+	}
670 708
 
671 709
 	// Make a quick array to list the links in.
672 710
 	$temp_array = array();
673
-	foreach ($return as $member)
674
-		$temp_array[] = $member['link'];
711
+	foreach ($return as $member) {
712
+			$temp_array[] = $member['link'];
713
+	}
675 714
 
676 715
 	echo implode(', ', $temp_array);
677 716
 }
@@ -703,8 +742,8 @@  discard block
 block discarded – undo
703 742
 		)
704 743
 	);
705 744
 	$boards = array();
706
-	while ($row = $smcFunc['db_fetch_assoc']($request))
707
-		$boards[] = array(
745
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
746
+			$boards[] = array(
708 747
 			'id' => $row['id_board'],
709 748
 			'num_posts' => $row['num_posts'],
710 749
 			'num_topics' => $row['num_topics'],
@@ -713,14 +752,16 @@  discard block
 block discarded – undo
713 752
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
714 753
 			'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'
715 754
 		);
755
+	}
716 756
 	$smcFunc['db_free_result']($request);
717 757
 
718 758
 	// If mods want to do somthing with this list of boards, let them do that now.
719 759
 	call_integration_hook('integrate_ssi_topBoards', array(&$boards));
720 760
 
721 761
 	// If we shouldn't output or have nothing to output, just jump out.
722
-	if ($output_method != 'echo' || empty($boards))
723
-		return $boards;
762
+	if ($output_method != 'echo' || empty($boards)) {
763
+			return $boards;
764
+	}
724 765
 
725 766
 	echo '
726 767
 		<table class="ssi_table">
@@ -729,13 +770,14 @@  discard block
 block discarded – undo
729 770
 				<th style="text-align: left">', $txt['board_topics'], '</th>
730 771
 				<th style="text-align: left">', $txt['posts'], '</th>
731 772
 			</tr>';
732
-	foreach ($boards as $sBoard)
733
-		echo '
773
+	foreach ($boards as $sBoard) {
774
+			echo '
734 775
 			<tr>
735 776
 				<td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td>
736 777
 				<td style="text-align: right">', comma_format($sBoard['num_topics']), '</td>
737 778
 				<td style="text-align: right">', comma_format($sBoard['num_posts']), '</td>
738 779
 			</tr>';
780
+	}
739 781
 	echo '
740 782
 		</table>';
741 783
 }
@@ -768,12 +810,13 @@  discard block
 block discarded – undo
768 810
 			)
769 811
 		);
770 812
 		$topic_ids = array();
771
-		while ($row = $smcFunc['db_fetch_assoc']($request))
772
-			$topic_ids[] = $row['id_topic'];
813
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
814
+					$topic_ids[] = $row['id_topic'];
815
+		}
773 816
 		$smcFunc['db_free_result']($request);
817
+	} else {
818
+			$topic_ids = array();
774 819
 	}
775
-	else
776
-		$topic_ids = array();
777 820
 
778 821
 	$request = $smcFunc['db_query']('', '
779 822
 		SELECT m.subject, m.id_topic, t.num_views, t.num_replies
@@ -812,8 +855,9 @@  discard block
 block discarded – undo
812 855
 	// If mods want to do somthing with this list of topics, let them do that now.
813 856
 	call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type));
814 857
 
815
-	if ($output_method != 'echo' || empty($topics))
816
-		return $topics;
858
+	if ($output_method != 'echo' || empty($topics)) {
859
+			return $topics;
860
+	}
817 861
 
818 862
 	echo '
819 863
 		<table class="ssi_table">
@@ -822,8 +866,8 @@  discard block
 block discarded – undo
822 866
 				<th style="text-align: left">', $txt['views'], '</th>
823 867
 				<th style="text-align: left">', $txt['replies'], '</th>
824 868
 			</tr>';
825
-	foreach ($topics as $sTopic)
826
-		echo '
869
+	foreach ($topics as $sTopic) {
870
+			echo '
827 871
 			<tr>
828 872
 				<td style="text-align: left">
829 873
 					', $sTopic['link'], '
@@ -831,6 +875,7 @@  discard block
 block discarded – undo
831 875
 				<td style="text-align: right">', comma_format($sTopic['num_views']), '</td>
832 876
 				<td style="text-align: right">', comma_format($sTopic['num_replies']), '</td>
833 877
 			</tr>';
878
+	}
834 879
 	echo '
835 880
 		</table>';
836 881
 }
@@ -866,12 +911,13 @@  discard block
 block discarded – undo
866 911
 {
867 912
 	global $txt, $context;
868 913
 
869
-	if ($output_method == 'echo')
870
-		echo '
914
+	if ($output_method == 'echo') {
915
+			echo '
871 916
 	', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>';
872
-	else
873
-		return $context['common_stats']['latest_member'];
874
-}
917
+	} else {
918
+			return $context['common_stats']['latest_member'];
919
+	}
920
+	}
875 921
 
876 922
 /**
877 923
  * Fetches a random member.
@@ -920,8 +966,9 @@  discard block
 block discarded – undo
920 966
 	}
921 967
 
922 968
 	// Just to be sure put the random generator back to something... random.
923
-	if ($random_type != '')
924
-		mt_srand(time());
969
+	if ($random_type != '') {
970
+			mt_srand(time());
971
+	}
925 972
 
926 973
 	return $result;
927 974
 }
@@ -934,8 +981,9 @@  discard block
 block discarded – undo
934 981
  */
935 982
 function ssi_fetchMember($member_ids = array(), $output_method = 'echo')
936 983
 {
937
-	if (empty($member_ids))
938
-		return;
984
+	if (empty($member_ids)) {
985
+			return;
986
+	}
939 987
 
940 988
 	// Can have more than one member if you really want...
941 989
 	$member_ids = is_array($member_ids) ? $member_ids : array($member_ids);
@@ -960,8 +1008,9 @@  discard block
 block discarded – undo
960 1008
  */
961 1009
 function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo')
962 1010
 {
963
-	if ($group_id === null)
964
-		return;
1011
+	if ($group_id === null) {
1012
+			return;
1013
+	}
965 1014
 
966 1015
 	$query_where = '
967 1016
 		id_group = {int:id_group}
@@ -988,8 +1037,9 @@  discard block
 block discarded – undo
988 1037
 {
989 1038
 	global $smcFunc, $memberContext;
990 1039
 
991
-	if ($query_where === null)
992
-		return;
1040
+	if ($query_where === null) {
1041
+			return;
1042
+	}
993 1043
 
994 1044
 	// Fetch the members in question.
995 1045
 	$request = $smcFunc['db_query']('', '
@@ -1002,12 +1052,14 @@  discard block
 block discarded – undo
1002 1052
 		))
1003 1053
 	);
1004 1054
 	$members = array();
1005
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1006
-		$members[] = $row['id_member'];
1055
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1056
+			$members[] = $row['id_member'];
1057
+	}
1007 1058
 	$smcFunc['db_free_result']($request);
1008 1059
 
1009
-	if (empty($members))
1010
-		return array();
1060
+	if (empty($members)) {
1061
+			return array();
1062
+	}
1011 1063
 
1012 1064
 	// If mods want to do somthing with this list of members, let them do that now.
1013 1065
 	call_integration_hook('integrate_ssi_queryMembers', array(&$members));
@@ -1016,23 +1068,25 @@  discard block
 block discarded – undo
1016 1068
 	loadMemberData($members);
1017 1069
 
1018 1070
 	// Draw the table!
1019
-	if ($output_method == 'echo')
1020
-		echo '
1071
+	if ($output_method == 'echo') {
1072
+			echo '
1021 1073
 		<table style="border: none" class="ssi_table">';
1074
+	}
1022 1075
 
1023 1076
 	$query_members = array();
1024 1077
 	foreach ($members as $member)
1025 1078
 	{
1026 1079
 		// Load their context data.
1027
-		if (!loadMemberContext($member))
1028
-			continue;
1080
+		if (!loadMemberContext($member)) {
1081
+					continue;
1082
+		}
1029 1083
 
1030 1084
 		// Store this member's information.
1031 1085
 		$query_members[$member] = $memberContext[$member];
1032 1086
 
1033 1087
 		// Only do something if we're echo'ing.
1034
-		if ($output_method == 'echo')
1035
-			echo '
1088
+		if ($output_method == 'echo') {
1089
+					echo '
1036 1090
 			<tr>
1037 1091
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
1038 1092
 					', $query_members[$member]['link'], '
@@ -1040,12 +1094,14 @@  discard block
 block discarded – undo
1040 1094
 					<br>', $query_members[$member]['avatar']['image'], '
1041 1095
 				</td>
1042 1096
 			</tr>';
1097
+		}
1043 1098
 	}
1044 1099
 
1045 1100
 	// End the table if appropriate.
1046
-	if ($output_method == 'echo')
1047
-		echo '
1101
+	if ($output_method == 'echo') {
1102
+			echo '
1048 1103
 		</table>';
1104
+	}
1049 1105
 
1050 1106
 	// Send back the data.
1051 1107
 	return $query_members;
@@ -1060,8 +1116,9 @@  discard block
 block discarded – undo
1060 1116
 {
1061 1117
 	global $txt, $scripturl, $modSettings, $smcFunc;
1062 1118
 
1063
-	if (!allowedTo('view_stats'))
1064
-		return;
1119
+	if (!allowedTo('view_stats')) {
1120
+			return;
1121
+	}
1065 1122
 
1066 1123
 	$totals = array(
1067 1124
 		'members' => $modSettings['totalMembers'],
@@ -1090,8 +1147,9 @@  discard block
 block discarded – undo
1090 1147
 	// If mods want to do somthing with the board stats, let them do that now.
1091 1148
 	call_integration_hook('integrate_ssi_boardStats', array(&$totals));
1092 1149
 
1093
-	if ($output_method != 'echo')
1094
-		return $totals;
1150
+	if ($output_method != 'echo') {
1151
+			return $totals;
1152
+	}
1095 1153
 
1096 1154
 	echo '
1097 1155
 		', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br>
@@ -1120,8 +1178,8 @@  discard block
 block discarded – undo
1120 1178
 	call_integration_hook('integrate_ssi_whosOnline', array(&$return));
1121 1179
 
1122 1180
 	// Add some redundancy for backwards compatibility reasons.
1123
-	if ($output_method != 'echo')
1124
-		return $return + array(
1181
+	if ($output_method != 'echo') {
1182
+			return $return + array(
1125 1183
 			'users' => $return['users_online'],
1126 1184
 			'guests' => $return['num_guests'],
1127 1185
 			'hidden' => $return['num_users_hidden'],
@@ -1129,29 +1187,35 @@  discard block
 block discarded – undo
1129 1187
 			'num_users' => $return['num_users_online'],
1130 1188
 			'total_users' => $return['num_users_online'] + $return['num_guests'],
1131 1189
 		);
1190
+	}
1132 1191
 
1133 1192
 	echo '
1134 1193
 		', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
1135 1194
 
1136 1195
 	$bracketList = array();
1137
-	if (!empty($user_info['buddies']))
1138
-		$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1139
-	if (!empty($return['num_spiders']))
1140
-		$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1141
-	if (!empty($return['num_users_hidden']))
1142
-		$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1196
+	if (!empty($user_info['buddies'])) {
1197
+			$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1198
+	}
1199
+	if (!empty($return['num_spiders'])) {
1200
+			$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1201
+	}
1202
+	if (!empty($return['num_users_hidden'])) {
1203
+			$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1204
+	}
1143 1205
 
1144
-	if (!empty($bracketList))
1145
-		echo ' (' . implode(', ', $bracketList) . ')';
1206
+	if (!empty($bracketList)) {
1207
+			echo ' (' . implode(', ', $bracketList) . ')';
1208
+	}
1146 1209
 
1147 1210
 	echo '<br>
1148 1211
 			', implode(', ', $return['list_users_online']);
1149 1212
 
1150 1213
 	// Showing membergroups?
1151
-	if (!empty($settings['show_group_key']) && !empty($return['membergroups']))
1152
-		echo '<br>
1214
+	if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) {
1215
+			echo '<br>
1153 1216
 			[' . implode(']&nbsp;&nbsp;[', $return['membergroups']) . ']';
1154
-}
1217
+	}
1218
+	}
1155 1219
 
1156 1220
 /**
1157 1221
  * Just like whosOnline except it also logs the online presence.
@@ -1162,11 +1226,12 @@  discard block
 block discarded – undo
1162 1226
 {
1163 1227
 	writeLog();
1164 1228
 
1165
-	if ($output_method != 'echo')
1166
-		return ssi_whosOnline($output_method);
1167
-	else
1168
-		ssi_whosOnline($output_method);
1169
-}
1229
+	if ($output_method != 'echo') {
1230
+			return ssi_whosOnline($output_method);
1231
+	} else {
1232
+			ssi_whosOnline($output_method);
1233
+	}
1234
+	}
1170 1235
 
1171 1236
 // Shows a login box.
1172 1237
 /**
@@ -1179,11 +1244,13 @@  discard block
 block discarded – undo
1179 1244
 {
1180 1245
 	global $scripturl, $txt, $user_info, $context;
1181 1246
 
1182
-	if ($redirect_to != '')
1183
-		$_SESSION['login_url'] = $redirect_to;
1247
+	if ($redirect_to != '') {
1248
+			$_SESSION['login_url'] = $redirect_to;
1249
+	}
1184 1250
 
1185
-	if ($output_method != 'echo' || !$user_info['is_guest'])
1186
-		return $user_info['is_guest'];
1251
+	if ($output_method != 'echo' || !$user_info['is_guest']) {
1252
+			return $user_info['is_guest'];
1253
+	}
1187 1254
 
1188 1255
 	// Create a login token
1189 1256
 	createToken('login');
@@ -1235,8 +1302,9 @@  discard block
 block discarded – undo
1235 1302
 
1236 1303
 	$boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote'));
1237 1304
 
1238
-	if (empty($boardsAllowed))
1239
-		return array();
1305
+	if (empty($boardsAllowed)) {
1306
+			return array();
1307
+	}
1240 1308
 
1241 1309
 	$request = $smcFunc['db_query']('', '
1242 1310
 		SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time
@@ -1269,12 +1337,14 @@  discard block
 block discarded – undo
1269 1337
 	$smcFunc['db_free_result']($request);
1270 1338
 
1271 1339
 	// This user has voted on all the polls.
1272
-	if (empty($row) || !is_array($row))
1273
-		return array();
1340
+	if (empty($row) || !is_array($row)) {
1341
+			return array();
1342
+	}
1274 1343
 
1275 1344
 	// If this is a guest who's voted we'll through ourselves to show poll to show the results.
1276
-	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))))
1277
-		return ssi_showPoll($row['id_topic'], $output_method);
1345
+	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) {
1346
+			return ssi_showPoll($row['id_topic'], $output_method);
1347
+	}
1278 1348
 
1279 1349
 	$request = $smcFunc['db_query']('', '
1280 1350
 		SELECT COUNT(DISTINCT id_member)
@@ -1338,8 +1408,9 @@  discard block
 block discarded – undo
1338 1408
 	// If mods want to do somthing with this list of polls, let them do that now.
1339 1409
 	call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead));
1340 1410
 
1341
-	if ($output_method != 'echo')
1342
-		return $return;
1411
+	if ($output_method != 'echo') {
1412
+			return $return;
1413
+	}
1343 1414
 
1344 1415
 	if ($allow_view_results)
1345 1416
 	{
@@ -1348,19 +1419,20 @@  discard block
 block discarded – undo
1348 1419
 			<strong>', $return['question'], '</strong><br>
1349 1420
 			', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1350 1421
 
1351
-		foreach ($return['options'] as $option)
1352
-			echo '
1422
+		foreach ($return['options'] as $option) {
1423
+					echo '
1353 1424
 			<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1425
+		}
1354 1426
 
1355 1427
 		echo '
1356 1428
 			<input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
1357 1429
 			<input type="hidden" name="poll" value="', $return['id'], '">
1358 1430
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1359 1431
 		</form>';
1432
+	} else {
1433
+			echo $txt['poll_cannot_see'];
1434
+	}
1360 1435
 	}
1361
-	else
1362
-		echo $txt['poll_cannot_see'];
1363
-}
1364 1436
 
1365 1437
 /**
1366 1438
  * Shows the poll from the specified topic
@@ -1374,13 +1446,15 @@  discard block
 block discarded – undo
1374 1446
 
1375 1447
 	$boardsAllowed = boardsAllowedTo('poll_view');
1376 1448
 
1377
-	if (empty($boardsAllowed))
1378
-		return array();
1449
+	if (empty($boardsAllowed)) {
1450
+			return array();
1451
+	}
1379 1452
 
1380
-	if ($topic === null && isset($_REQUEST['ssi_topic']))
1381
-		$topic = (int) $_REQUEST['ssi_topic'];
1382
-	else
1383
-		$topic = (int) $topic;
1453
+	if ($topic === null && isset($_REQUEST['ssi_topic'])) {
1454
+			$topic = (int) $_REQUEST['ssi_topic'];
1455
+	} else {
1456
+			$topic = (int) $topic;
1457
+	}
1384 1458
 
1385 1459
 	$request = $smcFunc['db_query']('', '
1386 1460
 		SELECT
@@ -1401,17 +1475,18 @@  discard block
 block discarded – undo
1401 1475
 	);
1402 1476
 
1403 1477
 	// Either this topic has no poll, or the user cannot view it.
1404
-	if ($smcFunc['db_num_rows']($request) == 0)
1405
-		return array();
1478
+	if ($smcFunc['db_num_rows']($request) == 0) {
1479
+			return array();
1480
+	}
1406 1481
 
1407 1482
 	$row = $smcFunc['db_fetch_assoc']($request);
1408 1483
 	$smcFunc['db_free_result']($request);
1409 1484
 
1410 1485
 	// Check if they can vote.
1411 1486
 	$already_voted = false;
1412
-	if (!empty($row['expire_time']) && $row['expire_time'] < time())
1413
-		$allow_vote = false;
1414
-	elseif ($user_info['is_guest'])
1487
+	if (!empty($row['expire_time']) && $row['expire_time'] < time()) {
1488
+			$allow_vote = false;
1489
+	} elseif ($user_info['is_guest'])
1415 1490
 	{
1416 1491
 		// There's a difference between "allowed to vote" and "already voted"...
1417 1492
 		$allow_vote = $row['guest_vote'];
@@ -1421,10 +1496,9 @@  discard block
 block discarded – undo
1421 1496
 		{
1422 1497
 			$already_voted = true;
1423 1498
 		}
1424
-	}
1425
-	elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board']))
1426
-		$allow_vote = false;
1427
-	else
1499
+	} elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) {
1500
+			$allow_vote = false;
1501
+	} else
1428 1502
 	{
1429 1503
 		$request = $smcFunc['db_query']('', '
1430 1504
 			SELECT id_member
@@ -1506,8 +1580,9 @@  discard block
 block discarded – undo
1506 1580
 	// If mods want to do somthing with this poll, let them do that now.
1507 1581
 	call_integration_hook('integrate_ssi_showPoll', array(&$return));
1508 1582
 
1509
-	if ($output_method != 'echo')
1510
-		return $return;
1583
+	if ($output_method != 'echo') {
1584
+			return $return;
1585
+	}
1511 1586
 
1512 1587
 	if ($return['allow_vote'])
1513 1588
 	{
@@ -1516,17 +1591,17 @@  discard block
 block discarded – undo
1516 1591
 				<strong>', $return['question'], '</strong><br>
1517 1592
 				', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1518 1593
 
1519
-		foreach ($return['options'] as $option)
1520
-			echo '
1594
+		foreach ($return['options'] as $option) {
1595
+					echo '
1521 1596
 				<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1597
+		}
1522 1598
 
1523 1599
 		echo '
1524 1600
 				<input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
1525 1601
 				<input type="hidden" name="poll" value="', $return['id'], '">
1526 1602
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1527 1603
 			</form>';
1528
-	}
1529
-	else
1604
+	} else
1530 1605
 	{
1531 1606
 		echo '
1532 1607
 			<div class="ssi_poll">
@@ -1606,27 +1681,32 @@  discard block
 block discarded – undo
1606 1681
 			'is_approved' => 1,
1607 1682
 		)
1608 1683
 	);
1609
-	if ($smcFunc['db_num_rows']($request) == 0)
1610
-		die;
1684
+	if ($smcFunc['db_num_rows']($request) == 0) {
1685
+			die;
1686
+	}
1611 1687
 	$row = $smcFunc['db_fetch_assoc']($request);
1612 1688
 	$smcFunc['db_free_result']($request);
1613 1689
 
1614
-	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
1615
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1690
+	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
1691
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1692
+	}
1616 1693
 
1617 1694
 	// Too many options checked?
1618
-	if (count($_REQUEST['options']) > $row['max_votes'])
1619
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1695
+	if (count($_REQUEST['options']) > $row['max_votes']) {
1696
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1697
+	}
1620 1698
 
1621 1699
 	// It's a guest who has already voted?
1622 1700
 	if ($user_info['is_guest'])
1623 1701
 	{
1624 1702
 		// Guest voting disabled?
1625
-		if (!$row['guest_vote'])
1626
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1703
+		if (!$row['guest_vote']) {
1704
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1705
+		}
1627 1706
 		// Already voted?
1628
-		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))
1629
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1707
+		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) {
1708
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1709
+		}
1630 1710
 	}
1631 1711
 
1632 1712
 	$sOptions = array();
@@ -1680,11 +1760,13 @@  discard block
 block discarded – undo
1680 1760
 {
1681 1761
 	global $scripturl, $txt, $context;
1682 1762
 
1683
-	if (!allowedTo('search_posts'))
1684
-		return;
1763
+	if (!allowedTo('search_posts')) {
1764
+			return;
1765
+	}
1685 1766
 
1686
-	if ($output_method != 'echo')
1687
-		return $scripturl . '?action=search';
1767
+	if ($output_method != 'echo') {
1768
+			return $scripturl . '?action=search';
1769
+	}
1688 1770
 
1689 1771
 	echo '
1690 1772
 		<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -1706,8 +1788,9 @@  discard block
 block discarded – undo
1706 1788
 	// If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context.
1707 1789
 	call_integration_hook('integrate_ssi_news');
1708 1790
 
1709
-	if ($output_method != 'echo')
1710
-		return $context['random_news_line'];
1791
+	if ($output_method != 'echo') {
1792
+			return $context['random_news_line'];
1793
+	}
1711 1794
 
1712 1795
 	echo $context['random_news_line'];
1713 1796
 }
@@ -1721,8 +1804,9 @@  discard block
 block discarded – undo
1721 1804
 {
1722 1805
 	global $scripturl, $modSettings, $user_info;
1723 1806
 
1724
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view'))
1725
-		return;
1807
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) {
1808
+			return;
1809
+	}
1726 1810
 
1727 1811
 	$eventOptions = array(
1728 1812
 		'include_birthdays' => true,
@@ -1733,13 +1817,15 @@  discard block
 block discarded – undo
1733 1817
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1734 1818
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1735 1819
 
1736
-	if ($output_method != 'echo')
1737
-		return $return['calendar_birthdays'];
1820
+	if ($output_method != 'echo') {
1821
+			return $return['calendar_birthdays'];
1822
+	}
1738 1823
 
1739
-	foreach ($return['calendar_birthdays'] as $member)
1740
-		echo '
1824
+	foreach ($return['calendar_birthdays'] as $member) {
1825
+			echo '
1741 1826
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : '');
1742
-}
1827
+	}
1828
+	}
1743 1829
 
1744 1830
 /**
1745 1831
  * Shows today's holidays.
@@ -1750,8 +1836,9 @@  discard block
 block discarded – undo
1750 1836
 {
1751 1837
 	global $modSettings, $user_info;
1752 1838
 
1753
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1754
-		return;
1839
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1840
+			return;
1841
+	}
1755 1842
 
1756 1843
 	$eventOptions = array(
1757 1844
 		'include_holidays' => true,
@@ -1762,8 +1849,9 @@  discard block
 block discarded – undo
1762 1849
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1763 1850
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1764 1851
 
1765
-	if ($output_method != 'echo')
1766
-		return $return['calendar_holidays'];
1852
+	if ($output_method != 'echo') {
1853
+			return $return['calendar_holidays'];
1854
+	}
1767 1855
 
1768 1856
 	echo '
1769 1857
 		', implode(', ', $return['calendar_holidays']);
@@ -1777,8 +1865,9 @@  discard block
 block discarded – undo
1777 1865
 {
1778 1866
 	global $modSettings, $user_info;
1779 1867
 
1780
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1781
-		return;
1868
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1869
+			return;
1870
+	}
1782 1871
 
1783 1872
 	$eventOptions = array(
1784 1873
 		'include_events' => true,
@@ -1789,14 +1878,16 @@  discard block
 block discarded – undo
1789 1878
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1790 1879
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1791 1880
 
1792
-	if ($output_method != 'echo')
1793
-		return $return['calendar_events'];
1881
+	if ($output_method != 'echo') {
1882
+			return $return['calendar_events'];
1883
+	}
1794 1884
 
1795 1885
 	foreach ($return['calendar_events'] as $event)
1796 1886
 	{
1797
-		if ($event['can_edit'])
1798
-			echo '
1887
+		if ($event['can_edit']) {
1888
+					echo '
1799 1889
 	<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1890
+		}
1800 1891
 		echo '
1801 1892
 	' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1802 1893
 	}
@@ -1811,8 +1902,9 @@  discard block
 block discarded – undo
1811 1902
 {
1812 1903
 	global $modSettings, $txt, $scripturl, $user_info;
1813 1904
 
1814
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1815
-		return;
1905
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1906
+			return;
1907
+	}
1816 1908
 
1817 1909
 	$eventOptions = array(
1818 1910
 		'include_birthdays' => allowedTo('profile_view'),
@@ -1825,19 +1917,22 @@  discard block
 block discarded – undo
1825 1917
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1826 1918
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1827 1919
 
1828
-	if ($output_method != 'echo')
1829
-		return $return;
1920
+	if ($output_method != 'echo') {
1921
+			return $return;
1922
+	}
1830 1923
 
1831
-	if (!empty($return['calendar_holidays']))
1832
-		echo '
1924
+	if (!empty($return['calendar_holidays'])) {
1925
+			echo '
1833 1926
 			<span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>';
1927
+	}
1834 1928
 	if (!empty($return['calendar_birthdays']))
1835 1929
 	{
1836 1930
 		echo '
1837 1931
 			<span class="birthday">' . $txt['birthdays_upcoming'] . '</span> ';
1838
-		foreach ($return['calendar_birthdays'] as $member)
1839
-			echo '
1932
+		foreach ($return['calendar_birthdays'] as $member) {
1933
+					echo '
1840 1934
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : '';
1935
+		}
1841 1936
 		echo '
1842 1937
 			<br>';
1843 1938
 	}
@@ -1847,9 +1942,10 @@  discard block
 block discarded – undo
1847 1942
 			<span class="event">' . $txt['events_upcoming'] . '</span> ';
1848 1943
 		foreach ($return['calendar_events'] as $event)
1849 1944
 		{
1850
-			if ($event['can_edit'])
1851
-				echo '
1945
+			if ($event['can_edit']) {
1946
+							echo '
1852 1947
 			<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1948
+			}
1853 1949
 			echo '
1854 1950
 			' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1855 1951
 		}
@@ -1873,25 +1969,29 @@  discard block
 block discarded – undo
1873 1969
 	loadLanguage('Stats');
1874 1970
 
1875 1971
 	// Must be integers....
1876
-	if ($limit === null)
1877
-		$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1878
-	else
1879
-		$limit = (int) $limit;
1880
-
1881
-	if ($start === null)
1882
-		$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1883
-	else
1884
-		$start = (int) $start;
1885
-
1886
-	if ($board !== null)
1887
-		$board = (int) $board;
1888
-	elseif (isset($_GET['board']))
1889
-		$board = (int) $_GET['board'];
1890
-
1891
-	if ($length === null)
1892
-		$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1893
-	else
1894
-		$length = (int) $length;
1972
+	if ($limit === null) {
1973
+			$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1974
+	} else {
1975
+			$limit = (int) $limit;
1976
+	}
1977
+
1978
+	if ($start === null) {
1979
+			$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1980
+	} else {
1981
+			$start = (int) $start;
1982
+	}
1983
+
1984
+	if ($board !== null) {
1985
+			$board = (int) $board;
1986
+	} elseif (isset($_GET['board'])) {
1987
+			$board = (int) $_GET['board'];
1988
+	}
1989
+
1990
+	if ($length === null) {
1991
+			$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1992
+	} else {
1993
+			$length = (int) $length;
1994
+	}
1895 1995
 
1896 1996
 	$limit = max(0, $limit);
1897 1997
 	$start = max(0, $start);
@@ -1909,17 +2009,19 @@  discard block
 block discarded – undo
1909 2009
 	);
1910 2010
 	if ($smcFunc['db_num_rows']($request) == 0)
1911 2011
 	{
1912
-		if ($output_method == 'echo')
1913
-			die($txt['ssi_no_guests']);
1914
-		else
1915
-			return array();
2012
+		if ($output_method == 'echo') {
2013
+					die($txt['ssi_no_guests']);
2014
+		} else {
2015
+					return array();
2016
+		}
1916 2017
 	}
1917 2018
 	list ($board) = $smcFunc['db_fetch_row']($request);
1918 2019
 	$smcFunc['db_free_result']($request);
1919 2020
 
1920 2021
 	$icon_sources = array();
1921
-	foreach ($context['stable_icons'] as $icon)
1922
-		$icon_sources[$icon] = 'images_url';
2022
+	foreach ($context['stable_icons'] as $icon) {
2023
+			$icon_sources[$icon] = 'images_url';
2024
+	}
1923 2025
 
1924 2026
 	if (!empty($modSettings['enable_likes']))
1925 2027
 	{
@@ -1943,12 +2045,14 @@  discard block
 block discarded – undo
1943 2045
 		)
1944 2046
 	);
1945 2047
 	$posts = array();
1946
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1947
-		$posts[] = $row['id_first_msg'];
2048
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2049
+			$posts[] = $row['id_first_msg'];
2050
+	}
1948 2051
 	$smcFunc['db_free_result']($request);
1949 2052
 
1950
-	if (empty($posts))
1951
-		return array();
2053
+	if (empty($posts)) {
2054
+			return array();
2055
+	}
1952 2056
 
1953 2057
 	// Find the posts.
1954 2058
 	$request = $smcFunc['db_query']('', '
@@ -1978,24 +2082,28 @@  discard block
 block discarded – undo
1978 2082
 			$last_space = strrpos($row['body'], ' ');
1979 2083
 			$last_open = strrpos($row['body'], '<');
1980 2084
 			$last_close = strrpos($row['body'], '>');
1981
-			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6)
1982
-				$cutoff = $last_open;
1983
-			elseif (empty($last_close) || $last_close < $last_open)
1984
-				$cutoff = $last_space;
2085
+			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) {
2086
+							$cutoff = $last_open;
2087
+			} elseif (empty($last_close) || $last_close < $last_open) {
2088
+							$cutoff = $last_space;
2089
+			}
1985 2090
 
1986
-			if ($cutoff !== false)
1987
-				$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2091
+			if ($cutoff !== false) {
2092
+							$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2093
+			}
1988 2094
 			$row['body'] .= '...';
1989 2095
 		}
1990 2096
 
1991 2097
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
1992 2098
 
1993
-		if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
1994
-			$row['icon'] = 'recycled';
2099
+		if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
2100
+					$row['icon'] = 'recycled';
2101
+		}
1995 2102
 
1996 2103
 		// Check that this message icon is there...
1997
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
1998
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2104
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
2105
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2106
+		}
1999 2107
 
2000 2108
 		censorText($row['subject']);
2001 2109
 		censorText($row['body']);
@@ -2032,16 +2140,18 @@  discard block
 block discarded – undo
2032 2140
 	}
2033 2141
 	$smcFunc['db_free_result']($request);
2034 2142
 
2035
-	if (empty($return))
2036
-		return $return;
2143
+	if (empty($return)) {
2144
+			return $return;
2145
+	}
2037 2146
 
2038 2147
 	$return[count($return) - 1]['is_last'] = true;
2039 2148
 
2040 2149
 	// If mods want to do somthing with this list of posts, let them do that now.
2041 2150
 	call_integration_hook('integrate_ssi_boardNews', array(&$return));
2042 2151
 
2043
-	if ($output_method != 'echo')
2044
-		return $return;
2152
+	if ($output_method != 'echo') {
2153
+			return $return;
2154
+	}
2045 2155
 
2046 2156
 	foreach ($return as $news)
2047 2157
 	{
@@ -2093,9 +2203,10 @@  discard block
 block discarded – undo
2093 2203
 		echo '
2094 2204
 			</div>';
2095 2205
 
2096
-		if (!$news['is_last'])
2097
-			echo '
2206
+		if (!$news['is_last']) {
2207
+					echo '
2098 2208
 			<hr>';
2209
+		}
2099 2210
 	}
2100 2211
 }
2101 2212
 
@@ -2109,8 +2220,9 @@  discard block
 block discarded – undo
2109 2220
 {
2110 2221
 	global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc;
2111 2222
 
2112
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
2113
-		return;
2223
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
2224
+			return;
2225
+	}
2114 2226
 
2115 2227
 	// Find all events which are happening in the near future that the member can see.
2116 2228
 	$request = $smcFunc['db_query']('', '
@@ -2136,20 +2248,23 @@  discard block
 block discarded – undo
2136 2248
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2137 2249
 	{
2138 2250
 		// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
2139
-		if (!empty($duplicates[$row['title'] . $row['id_topic']]))
2140
-			continue;
2251
+		if (!empty($duplicates[$row['title'] . $row['id_topic']])) {
2252
+					continue;
2253
+		}
2141 2254
 
2142 2255
 		// Censor the title.
2143 2256
 		censorText($row['title']);
2144 2257
 
2145
-		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false)))
2146
-			$date = strftime('%Y-%m-%d', forum_time(false));
2147
-		else
2148
-			$date = $row['start_date'];
2258
+		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) {
2259
+					$date = strftime('%Y-%m-%d', forum_time(false));
2260
+		} else {
2261
+					$date = $row['start_date'];
2262
+		}
2149 2263
 
2150 2264
 		// If the topic it is attached to is not approved then don't link it.
2151
-		if (!empty($row['id_first_msg']) && !$row['approved'])
2152
-			$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2265
+		if (!empty($row['id_first_msg']) && !$row['approved']) {
2266
+					$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2267
+		}
2153 2268
 
2154 2269
 		$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
2155 2270
 
@@ -2175,24 +2290,27 @@  discard block
 block discarded – undo
2175 2290
 	}
2176 2291
 	$smcFunc['db_free_result']($request);
2177 2292
 
2178
-	foreach ($return as $mday => $array)
2179
-		$return[$mday][count($array) - 1]['is_last'] = true;
2293
+	foreach ($return as $mday => $array) {
2294
+			$return[$mday][count($array) - 1]['is_last'] = true;
2295
+	}
2180 2296
 
2181 2297
 	// If mods want to do somthing with this list of events, let them do that now.
2182 2298
 	call_integration_hook('integrate_ssi_recentEvents', array(&$return));
2183 2299
 
2184
-	if ($output_method != 'echo' || empty($return))
2185
-		return $return;
2300
+	if ($output_method != 'echo' || empty($return)) {
2301
+			return $return;
2302
+	}
2186 2303
 
2187 2304
 	// Well the output method is echo.
2188 2305
 	echo '
2189 2306
 			<span class="event">' . $txt['events'] . '</span> ';
2190
-	foreach ($return as $mday => $array)
2191
-		foreach ($array as $event)
2307
+	foreach ($return as $mday => $array) {
2308
+			foreach ($array as $event)
2192 2309
 		{
2193 2310
 			if ($event['can_edit'])
2194 2311
 				echo '
2195 2312
 				<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
2313
+	}
2196 2314
 
2197 2315
 			echo '
2198 2316
 				' . $event['link'] . (!$event['is_last'] ? ', ' : '');
@@ -2211,8 +2329,9 @@  discard block
 block discarded – undo
2211 2329
 	global $smcFunc;
2212 2330
 
2213 2331
 	// If $id is null, this was most likely called from a query string and should do nothing.
2214
-	if ($id === null)
2215
-		return;
2332
+	if ($id === null) {
2333
+			return;
2334
+	}
2216 2335
 
2217 2336
 	$request = $smcFunc['db_query']('', '
2218 2337
 		SELECT passwd, member_name, is_activated
@@ -2244,8 +2363,9 @@  discard block
 block discarded – undo
2244 2363
 	$attachments_boards = boardsAllowedTo('view_attachments');
2245 2364
 
2246 2365
 	// No boards?  Adios amigo.
2247
-	if (empty($attachments_boards))
2248
-		return array();
2366
+	if (empty($attachments_boards)) {
2367
+			return array();
2368
+	}
2249 2369
 
2250 2370
 	// Is it an array?
2251 2371
 	$attachment_ext = (array) $attachment_ext;
@@ -2329,8 +2449,9 @@  discard block
 block discarded – undo
2329 2449
 	call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments));
2330 2450
 
2331 2451
 	// So you just want an array?  Here you can have it.
2332
-	if ($output_method == 'array' || empty($attachments))
2333
-		return $attachments;
2452
+	if ($output_method == 'array' || empty($attachments)) {
2453
+			return $attachments;
2454
+	}
2334 2455
 
2335 2456
 	// Give them the default.
2336 2457
 	echo '
@@ -2341,14 +2462,15 @@  discard block
 block discarded – undo
2341 2462
 				<th style="text-align: left; padding: 2">', $txt['downloads'], '</th>
2342 2463
 				<th style="text-align: left; padding: 2">', $txt['filesize'], '</th>
2343 2464
 			</tr>';
2344
-	foreach ($attachments as $attach)
2345
-		echo '
2465
+	foreach ($attachments as $attach) {
2466
+			echo '
2346 2467
 			<tr>
2347 2468
 				<td>', $attach['file']['link'], '</td>
2348 2469
 				<td>', $attach['member']['link'], '</td>
2349 2470
 				<td style="text-align: center">', $attach['file']['downloads'], '</td>
2350 2471
 				<td>', $attach['file']['filesize'], '</td>
2351 2472
 			</tr>';
2473
+	}
2352 2474
 	echo '
2353 2475
 		</table>';
2354 2476
 }
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +35 added lines, -24 removed lines patch added patch discarded remove patch
@@ -32,16 +32,18 @@  discard block
 block discarded – undo
32 32
 ob_start();
33 33
 
34 34
 // Do some cleaning, just in case.
35
-foreach (array('db_character_set', 'cachedir') as $variable)
35
+foreach (array('db_character_set', 'cachedir') as $variable) {
36 36
 	if (isset($GLOBALS[$variable]))
37 37
 		unset($GLOBALS[$variable], $GLOBALS[$variable]);
38
+}
38 39
 
39 40
 // Load the settings...
40 41
 require_once(dirname(__FILE__) . '/Settings.php');
41 42
 
42 43
 // Make absolutely sure the cache directory is defined.
43
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
44
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
44 45
 	$cachedir = $boarddir . '/cache';
46
+}
45 47
 
46 48
 // Without those we can't go anywhere
47 49
 require_once($sourcedir . '/QueryString.php');
@@ -51,8 +53,9 @@  discard block
 block discarded – undo
51 53
 require_once($sourcedir . '/Load.php');
52 54
 
53 55
 // If $maintenance is set specifically to 2, then we're upgrading or something.
54
-if (!empty($maintenance) && $maintenance == 2)
56
+if (!empty($maintenance) && $maintenance == 2) {
55 57
 	display_maintenance_message();
58
+}
56 59
 
57 60
 // Create a variable to store some SMF specific functions in.
58 61
 $smcFunc = array();
@@ -67,8 +70,9 @@  discard block
 block discarded – undo
67 70
 cleanRequest();
68 71
 
69 72
 // Seed the random generator.
70
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
73
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
71 74
 	smf_seed_generator();
75
+}
72 76
 
73 77
 // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out!
74 78
 if (isset($_GET['scheduled']))
@@ -88,9 +92,9 @@  discard block
 block discarded – undo
88 92
 if (!empty($modSettings['enableCompressedOutput']) && !headers_sent())
89 93
 {
90 94
 	// If zlib is being used, turn off output compression.
91
-	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler')
92
-		$modSettings['enableCompressedOutput'] = '0';
93
-	else
95
+	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') {
96
+			$modSettings['enableCompressedOutput'] = '0';
97
+	} else
94 98
 	{
95 99
 		ob_end_clean();
96 100
 		ob_start('ob_gzhandler');
@@ -182,18 +186,21 @@  discard block
 block discarded – undo
182 186
 	loadPermissions();
183 187
 
184 188
 	// Attachments don't require the entire theme to be loaded.
185
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach')
186
-		detectBrowser();
189
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') {
190
+			detectBrowser();
191
+	}
187 192
 	// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
188
-	else
189
-		loadTheme();
193
+	else {
194
+			loadTheme();
195
+	}
190 196
 
191 197
 	// Check if the user should be disallowed access.
192 198
 	is_not_banned();
193 199
 
194 200
 	// If we are in a topic and don't have permission to approve it then duck out now.
195
-	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest']))
196
-		fatal_lang_error('not_a_topic', false);
201
+	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
202
+			fatal_lang_error('not_a_topic', false);
203
+	}
197 204
 
198 205
 	$no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile');
199 206
 	call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions));
@@ -204,8 +211,9 @@  discard block
 block discarded – undo
204 211
 		writeLog();
205 212
 
206 213
 		// Track forum statistics and hits...?
207
-		if (!empty($modSettings['hitStats']))
208
-			trackStats(array('hits' => '+'));
214
+		if (!empty($modSettings['hitStats'])) {
215
+					trackStats(array('hits' => '+'));
216
+		}
209 217
 	}
210 218
 	unset($no_stat_actions);
211 219
 
@@ -219,13 +227,14 @@  discard block
 block discarded – undo
219 227
 			return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout'));
220 228
 		}
221 229
 		// Don't even try it, sonny.
222
-		else
223
-			return 'InMaintenance';
230
+		else {
231
+					return 'InMaintenance';
232
+		}
224 233
 	}
225 234
 	// If guest access is off, a guest can only do one of the very few following actions.
226
-	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2'))))
227
-		return 'KickGuest';
228
-	elseif (empty($_REQUEST['action']))
235
+	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) {
236
+			return 'KickGuest';
237
+	} elseif (empty($_REQUEST['action']))
229 238
 	{
230 239
 		// Action and board are both empty... BoardIndex! Unless someone else wants to do something different.
231 240
 		if (empty($board) && empty($topic))
@@ -239,8 +248,9 @@  discard block
 block discarded – undo
239 248
 
240 249
 				$call = call_helper($defaultAction, true);
241 250
 
242
-				if (!empty($call))
243
-					return $call;
251
+				if (!empty($call)) {
252
+									return $call;
253
+				}
244 254
 			}
245 255
 
246 256
 			// No default action huh? then go to our good old BoardIndex.
@@ -370,8 +380,9 @@  discard block
 block discarded – undo
370 380
 
371 381
 			$call = call_helper($fallbackAction, true);
372 382
 
373
-			if (!empty($call))
374
-				return $call;
383
+			if (!empty($call)) {
384
+							return $call;
385
+			}
375 386
 		}
376 387
 
377 388
 		// No fallback action, huh?
Please login to merge, or discard this patch.
Themes/default/Admin.template.php 1 patch
Braces   +173 added lines, -125 removed lines patch added patch discarded remove patch
@@ -64,9 +64,10 @@  discard block
 block discarded – undo
64 64
 										<strong>', $txt['administrators'], ':</strong>
65 65
 										', implode(', ', $context['administrators']);
66 66
 	// If we have lots of admins... don't show them all.
67
-	if (!empty($context['more_admins_link']))
68
-		echo '
67
+	if (!empty($context['more_admins_link'])) {
68
+			echo '
69 69
 							(', $context['more_admins_link'], ')';
70
+	}
70 71
 
71 72
 	echo '
72 73
 									</div>
@@ -83,16 +84,18 @@  discard block
 block discarded – undo
83 84
 		foreach ($area['areas'] as $item_id => $item)
84 85
 		{
85 86
 			// No point showing the 'home' page here, we're already on it!
86
-			if ($area_id == 'forum' && $item_id == 'index')
87
-				continue;
87
+			if ($area_id == 'forum' && $item_id == 'index') {
88
+							continue;
89
+			}
88 90
 
89 91
 			$url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : '');
90
-			if (!empty($item['icon_file']))
91
-				echo '
92
+			if (!empty($item['icon_file'])) {
93
+							echo '
92 94
 							<a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>';
93
-			else
94
-				echo '
95
+			} else {
96
+							echo '
95 97
 							<a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>';
98
+			}
96 99
 		}
97 100
 
98 101
 		echo '
@@ -103,10 +106,11 @@  discard block
 block discarded – undo
103 106
 					</div>';
104 107
 
105 108
 	// The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization.
106
-	if (empty($modSettings['disable_smf_js']))
107
-		echo '
109
+	if (empty($modSettings['disable_smf_js'])) {
110
+			echo '
108 111
 					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
109 112
 					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
113
+	}
110 114
 
111 115
 	// This sets the announcements and current versions themselves ;).
112 116
 	echo '
@@ -185,9 +189,10 @@  discard block
 block discarded – undo
185 189
 								<em>', $version['version'], '</em>';
186 190
 
187 191
 		// more details for this item, show them a link
188
-		if ($context['can_admin'] && isset($version['more']))
189
-			echo
192
+		if ($context['can_admin'] && isset($version['more'])) {
193
+					echo
190 194
 								' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>';
195
+		}
191 196
 		echo '
192 197
 								<br>';
193 198
 	}
@@ -218,20 +223,22 @@  discard block
 block discarded – undo
218 223
 
219 224
 	foreach ($context['credits'] as $section)
220 225
 	{
221
-		if (isset($section['pretext']))
222
-			echo '
226
+		if (isset($section['pretext'])) {
227
+					echo '
223 228
 								<p>', $section['pretext'], '</p><hr>';
229
+		}
224 230
 
225 231
 		echo '
226 232
 								<dl>';
227 233
 
228 234
 		foreach ($section['groups'] as $group)
229 235
 		{
230
-			if (isset($group['title']))
231
-				echo '
236
+			if (isset($group['title'])) {
237
+							echo '
232 238
 									<dt>
233 239
 										<strong>', $group['title'], ':</strong>
234 240
 									</dt>';
241
+			}
235 242
 
236 243
 			echo '
237 244
 									<dd>', implode(', ', $group['members']), '</dd>';
@@ -240,10 +247,11 @@  discard block
 block discarded – undo
240 247
 		echo '
241 248
 								</dl>';
242 249
 
243
-		if (isset($section['posttext']))
244
-			echo '
250
+		if (isset($section['posttext'])) {
251
+					echo '
245 252
 								<hr>
246 253
 								<p>', $section['posttext'], '</p>';
254
+		}
247 255
 	}
248 256
 
249 257
 	echo '
@@ -259,9 +267,10 @@  discard block
 block discarded – undo
259 267
 							smfSupportVersions.forum = "', $context['forum_version'], '";';
260 268
 
261 269
 	// Don't worry, none of this is logged, it's just used to give information that might be of use.
262
-	foreach ($context['current_versions'] as $variable => $version)
263
-		echo '
270
+	foreach ($context['current_versions'] as $variable => $version) {
271
+			echo '
264 272
 							smfSupportVersions.', $variable, ' = "', $version['version'], '";';
273
+	}
265 274
 
266 275
 	// Now we just have to include the script and wait ;).
267 276
 	echo '
@@ -358,8 +367,8 @@  discard block
 block discarded – undo
358 367
 							<tbody>';
359 368
 
360 369
 	// Loop through every source file displaying its version - using javascript.
361
-	foreach ($context['file_versions'] as $filename => $version)
362
-		echo '
370
+	foreach ($context['file_versions'] as $filename => $version) {
371
+			echo '
363 372
 								<tr class="windowbg">
364 373
 									<td class="half_table">
365 374
 										', $filename, '
@@ -371,6 +380,7 @@  discard block
 block discarded – undo
371 380
 										<em id="currentSources', $filename, '">??</em>
372 381
 									</td>
373 382
 								</tr>';
383
+	}
374 384
 
375 385
 	// Default template files.
376 386
 	echo '
@@ -396,8 +406,8 @@  discard block
 block discarded – undo
396 406
 							<table id="Default" class="table_grid">
397 407
 								<tbody>';
398 408
 
399
-	foreach ($context['default_template_versions'] as $filename => $version)
400
-		echo '
409
+	foreach ($context['default_template_versions'] as $filename => $version) {
410
+			echo '
401 411
 									<tr class="windowbg">
402 412
 										<td class="half_table">
403 413
 											', $filename, '
@@ -409,6 +419,7 @@  discard block
 block discarded – undo
409 419
 											<em id="currentDefault', $filename, '">??</em>
410 420
 										</td>
411 421
 									</tr>';
422
+	}
412 423
 
413 424
 	// Now the language files...
414 425
 	echo '
@@ -436,8 +447,8 @@  discard block
 block discarded – undo
436 447
 
437 448
 	foreach ($context['default_language_versions'] as $language => $files)
438 449
 	{
439
-		foreach ($files as $filename => $version)
440
-			echo '
450
+		foreach ($files as $filename => $version) {
451
+					echo '
441 452
 									<tr class="windowbg">
442 453
 										<td class="half_table">
443 454
 											', $filename, '.<em>', $language, '</em>.php
@@ -449,6 +460,7 @@  discard block
 block discarded – undo
449 460
 											<em id="current', $filename, '.', $language, '">??</em>
450 461
 										</td>
451 462
 									</tr>';
463
+		}
452 464
 	}
453 465
 
454 466
 	echo '
@@ -478,8 +490,8 @@  discard block
 block discarded – undo
478 490
 							<table id="Templates" class="table_grid">
479 491
 								<tbody>';
480 492
 
481
-		foreach ($context['template_versions'] as $filename => $version)
482
-			echo '
493
+		foreach ($context['template_versions'] as $filename => $version) {
494
+					echo '
483 495
 									<tr class="windowbg">
484 496
 										<td class="half_table">
485 497
 											', $filename, '
@@ -491,6 +503,7 @@  discard block
 block discarded – undo
491 503
 											<em id="currentTemplates', $filename, '">??</em>
492 504
 										</td>
493 505
 									</tr>';
506
+		}
494 507
 
495 508
 		echo '
496 509
 								</tbody>
@@ -520,8 +533,8 @@  discard block
 block discarded – undo
520 533
 							<table id="Tasks" class="table_grid">
521 534
 								<tbody>';
522 535
 
523
-		foreach ($context['tasks_versions'] as $filename => $version)
524
-			echo '
536
+		foreach ($context['tasks_versions'] as $filename => $version) {
537
+					echo '
525 538
 									<tr class="windowbg">
526 539
 										<td class="half_table">
527 540
 											', $filename, '
@@ -533,6 +546,7 @@  discard block
 block discarded – undo
533 546
 											<em id="currentTasks', $filename, '">??</em>
534 547
 										</td>
535 548
 									</tr>';
549
+		}
536 550
 
537 551
 		echo '
538 552
 								</tbody>
@@ -574,9 +588,10 @@  discard block
 block discarded – undo
574 588
 {
575 589
 	global $context, $scripturl, $txt, $modSettings;
576 590
 
577
-	if (!empty($context['saved_successful']))
578
-		echo '
591
+	if (!empty($context['saved_successful'])) {
592
+			echo '
579 593
 					<div class="infobox">', $txt['settings_saved'], '</div>';
594
+	}
580 595
 
581 596
 	// First section is for adding/removing words from the censored list.
582 597
 	echo '
@@ -591,11 +606,12 @@  discard block
 block discarded – undo
591 606
 								<p>', $txt['admin_censored_where'], '</p>';
592 607
 
593 608
 	// Show text boxes for censoring [bad   ] => [good  ].
594
-	foreach ($context['censored_words'] as $vulgar => $proper)
595
-		echo '
609
+	foreach ($context['censored_words'] as $vulgar => $proper) {
610
+			echo '
596 611
 								<div class="block">
597 612
 									<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> =&gt; <input type="text" name="censor_proper[]" value="', $proper, '" size="30">
598 613
 								</div>';
614
+	}
599 615
 
600 616
 	// Now provide a way to censor more words.
601 617
 	echo '
@@ -669,19 +685,21 @@  discard block
 block discarded – undo
669 685
 						<div class="windowbg2 noup">
670 686
 							', $txt['not_done_reason'];
671 687
 
672
-	if (!empty($context['continue_percent']))
673
-		echo '
688
+	if (!empty($context['continue_percent'])) {
689
+			echo '
674 690
 							<div class="progress_bar">
675 691
 								<div class="full_bar">', $context['continue_percent'], '%</div>
676 692
 								<div class="green_percent" style="width: ', $context['continue_percent'], '%;">&nbsp;</div>
677 693
 							</div>';
694
+	}
678 695
 
679
-	if (!empty($context['substep_enabled']))
680
-		echo '
696
+	if (!empty($context['substep_enabled'])) {
697
+			echo '
681 698
 							<div class="progress_bar">
682 699
 								<div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div>
683 700
 								<div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;">&nbsp;</div>
684 701
 							</div>';
702
+	}
685 703
 
686 704
 	echo '
687 705
 							<form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">
@@ -716,35 +734,40 @@  discard block
 block discarded – undo
716 734
 {
717 735
 	global $context, $txt, $scripturl;
718 736
 
719
-	if (!empty($context['saved_successful']))
720
-		echo '
737
+	if (!empty($context['saved_successful'])) {
738
+			echo '
721 739
 					<div class="infobox">', $txt['settings_saved'], '</div>';
722
-	elseif (!empty($context['saved_failed']))
723
-		echo '
740
+	} elseif (!empty($context['saved_failed'])) {
741
+			echo '
724 742
 					<div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>';
743
+	}
725 744
 
726
-	if (!empty($context['settings_pre_javascript']))
727
-		echo '
745
+	if (!empty($context['settings_pre_javascript'])) {
746
+			echo '
728 747
 					<script>', $context['settings_pre_javascript'], '</script>';
748
+	}
729 749
 
730
-	if (!empty($context['settings_insert_above']))
731
-		echo $context['settings_insert_above'];
750
+	if (!empty($context['settings_insert_above'])) {
751
+			echo $context['settings_insert_above'];
752
+	}
732 753
 
733 754
 	echo '
734 755
 					<div id="admincenter">
735 756
 						<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>';
736 757
 
737 758
 	// Is there a custom title?
738
-	if (isset($context['settings_title']))
739
-		echo '
759
+	if (isset($context['settings_title'])) {
760
+			echo '
740 761
 							<div class="cat_bar">
741 762
 								<h3 class="catbg">', $context['settings_title'], '</h3>
742 763
 							</div>';
764
+	}
743 765
 
744 766
 	// Have we got a message to display?
745
-	if (!empty($context['settings_message']))
746
-		echo '
767
+	if (!empty($context['settings_message'])) {
768
+			echo '
747 769
 							<div class="information">', $context['settings_message'], '</div>';
770
+	}
748 771
 
749 772
 	// Now actually loop through all the variables.
750 773
 	$is_open = false;
@@ -797,8 +820,9 @@  discard block
 block discarded – undo
797 820
 		// Hang about? Are you pulling my leg - a callback?!
798 821
 		if (is_array($config_var) && $config_var['type'] == 'callback')
799 822
 		{
800
-			if (function_exists('template_callback_' . $config_var['name']))
801
-				call_user_func('template_callback_' . $config_var['name']);
823
+			if (function_exists('template_callback_' . $config_var['name'])) {
824
+							call_user_func('template_callback_' . $config_var['name']);
825
+			}
802 826
 
803 827
 			continue;
804 828
 		}
@@ -828,9 +852,10 @@  discard block
 block discarded – undo
828 852
 				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
829 853
 
830 854
 				// Show the [?] button.
831
-				if ($config_var['help'])
832
-					echo '
855
+				if ($config_var['help']) {
856
+									echo '
833 857
 							<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ';
858
+				}
834 859
 
835 860
 				echo '
836 861
 										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
@@ -839,22 +864,25 @@  discard block
 block discarded – undo
839 864
 										$config_var['preinput'];
840 865
 
841 866
 				// Show a check box.
842
-				if ($config_var['type'] == 'check')
843
-					echo '
867
+				if ($config_var['type'] == 'check') {
868
+									echo '
844 869
 										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">';
870
+				}
845 871
 				// Escape (via htmlspecialchars.) the text box.
846
-				elseif ($config_var['type'] == 'password')
847
-					echo '
872
+				elseif ($config_var['type'] == 'password') {
873
+									echo '
848 874
 										<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;" class="input_password"><br>
849 875
 										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">';
876
+				}
850 877
 				// Show a selection box.
851 878
 				elseif ($config_var['type'] == 'select')
852 879
 				{
853 880
 					echo '
854 881
 										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>';
855
-					foreach ($config_var['data'] as $option)
856
-						echo '
882
+					foreach ($config_var['data'] as $option) {
883
+											echo '
857 884
 											<option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>';
885
+					}
858 886
 					echo '
859 887
 										</select>';
860 888
 				}
@@ -868,15 +896,17 @@  discard block
 block discarded – undo
868 896
 												<legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>';
869 897
 					foreach ($context['board_list'] as $id_cat => $cat)
870 898
 					{
871
-						if (!$first)
872
-							echo '
899
+						if (!$first) {
900
+													echo '
873 901
 											<hr>';
902
+						}
874 903
 						echo '
875 904
 											<strong>', $cat['name'], '</strong>
876 905
 											<ul>';
877
-						foreach ($cat['boards'] as $id_board => $brd)
878
-							echo '
906
+						foreach ($cat['boards'] as $id_board => $brd) {
907
+													echo '
879 908
 												<li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat('&nbsp; &nbsp;', $brd['child_level']) : '', $brd['name'], '</label></li>';
909
+						}
880 910
 
881 911
 						echo '
882 912
 											</ul>';
@@ -886,12 +916,14 @@  discard block
 block discarded – undo
886 916
 											</fieldset>';
887 917
 				}
888 918
 				// Text area?
889
-				elseif ($config_var['type'] == 'large_text')
890
-					echo '
919
+				elseif ($config_var['type'] == 'large_text') {
920
+									echo '
891 921
 											<textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>';
922
+				}
892 923
 				// Permission group?
893
-				elseif ($config_var['type'] == 'permissions')
894
-					theme_inline_permissions($config_var['name']);
924
+				elseif ($config_var['type'] == 'permissions') {
925
+									theme_inline_permissions($config_var['name']);
926
+				}
895 927
 				// BBC selection?
896 928
 				elseif ($config_var['type'] == 'bbc')
897 929
 				{
@@ -902,20 +934,22 @@  discard block
 block discarded – undo
902 934
 
903 935
 					foreach ($context['bbc_columns'] as $bbcColumn)
904 936
 					{
905
-						foreach ($bbcColumn as $bbcTag)
906
-							echo '
937
+						foreach ($bbcColumn as $bbcTag) {
938
+													echo '
907 939
 														<li class="list_bbc floatleft">
908 940
 															<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', ' class="input_check"> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', '
909 941
 														</li>';
942
+						}
910 943
 					}
911 944
 					echo '							</ul>
912 945
 												<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
913 946
 											</fieldset>';
914 947
 				}
915 948
 				// A simple message?
916
-				elseif ($config_var['type'] == 'var_message')
917
-					echo '
949
+				elseif ($config_var['type'] == 'var_message') {
950
+									echo '
918 951
 											<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>';
952
+				}
919 953
 				// Assume it must be a text box
920 954
 				else
921 955
 				{
@@ -940,63 +974,70 @@  discard block
 block discarded – undo
940 974
 											' . $config_var['postinput'] : '',
941 975
 										'</dd>';
942 976
 			}
943
-		}
944
-
945
-		else
977
+		} else
946 978
 		{
947 979
 			// Just show a separator.
948
-			if ($config_var == '')
949
-				echo '
980
+			if ($config_var == '') {
981
+							echo '
950 982
 								</dl>
951 983
 								<hr>
952 984
 								<dl class="settings">';
953
-			else
954
-				echo '
985
+			} else {
986
+							echo '
955 987
 									<dd>
956 988
 										<strong>' . $config_var . '</strong>
957 989
 									</dd>';
990
+			}
958 991
 		}
959 992
 	}
960 993
 
961
-	if ($is_open)
962
-		echo '
994
+	if ($is_open) {
995
+			echo '
963 996
 								</dl>';
997
+	}
964 998
 
965
-	if (empty($context['settings_save_dont_show']))
966
-		echo '
999
+	if (empty($context['settings_save_dont_show'])) {
1000
+			echo '
967 1001
 								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">';
1002
+	}
968 1003
 
969
-	if ($is_open)
970
-		echo '
1004
+	if ($is_open) {
1005
+			echo '
971 1006
 							</div>';
1007
+	}
972 1008
 
973 1009
 
974 1010
 	// At least one token has to be used!
975
-	if (isset($context['admin-ssc_token']))
976
-		echo '
1011
+	if (isset($context['admin-ssc_token'])) {
1012
+			echo '
977 1013
 							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
1014
+	}
978 1015
 
979
-	if (isset($context['admin-dbsc_token']))
980
-		echo '
1016
+	if (isset($context['admin-dbsc_token'])) {
1017
+			echo '
981 1018
 							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
1019
+	}
982 1020
 
983
-	if (isset($context['admin-mp_token']))
984
-		echo '
1021
+	if (isset($context['admin-mp_token'])) {
1022
+			echo '
985 1023
 							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
1024
+	}
986 1025
 
987 1026
 	echo '
988 1027
 							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
989 1028
 						</form>
990 1029
 					</div>';
991 1030
 
992
-	if (!empty($context['settings_post_javascript']))
993
-		echo '
1031
+	if (!empty($context['settings_post_javascript'])) {
1032
+			echo '
994 1033
 					<script>
995 1034
 					', $context['settings_post_javascript'], '
996 1035
 					</script>';
1036
+	}
997 1037
 
998
-	if (!empty($context['settings_insert_below']))
999
-		echo $context['settings_insert_below'];
1038
+	if (!empty($context['settings_insert_below'])) {
1039
+			echo $context['settings_insert_below'];
1040
+	}
1000 1041
 
1001 1042
 	// We may have added a board listing. If we did, we need to make it work.
1002 1043
 	addInlineJavascript('
@@ -1019,9 +1060,10 @@  discard block
 block discarded – undo
1019 1060
 {
1020 1061
 	global $context, $txt;
1021 1062
 
1022
-	if (!empty($context['saved_successful']))
1023
-		echo '
1063
+	if (!empty($context['saved_successful'])) {
1064
+			echo '
1024 1065
 					<div class="infobox">', $txt['settings_saved'], '</div>';
1066
+	}
1025 1067
 
1026 1068
 	// Standard fields.
1027 1069
 	template_show_list('standard_profile_fields');
@@ -1053,11 +1095,12 @@  discard block
 block discarded – undo
1053 1095
 	if (isset($_GET['msg']))
1054 1096
 	{
1055 1097
 		loadLanguage('Errors');
1056
-		if (isset($txt['custom_option_' . $_GET['msg']]))
1057
-			echo '
1098
+		if (isset($txt['custom_option_' . $_GET['msg']])) {
1099
+					echo '
1058 1100
 					<div class="errorbox">',
1059 1101
 						$txt['custom_option_' . $_GET['msg']], '
1060 1102
 					</div>';
1103
+		}
1061 1104
 	}
1062 1105
 
1063 1106
 	echo '
@@ -1123,9 +1166,10 @@  discard block
 block discarded – undo
1123 1166
 										<dd>
1124 1167
 											<select name="placement" id="placement">';
1125 1168
 
1126
-	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1127
-		echo '
1169
+	foreach ($context['cust_profile_fields_placement'] as $order => $name) {
1170
+			echo '
1128 1171
 												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1172
+	}
1129 1173
 
1130 1174
 	echo '
1131 1175
 											</select>
@@ -1148,9 +1192,10 @@  discard block
 block discarded – undo
1148 1192
 										</dt>
1149 1193
 										<dd>
1150 1194
 											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1151
-	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1152
-		echo '
1195
+	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) {
1196
+			echo '
1153 1197
 												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1198
+	}
1154 1199
 
1155 1200
 	echo '
1156 1201
 											</select>
@@ -1251,9 +1296,10 @@  discard block
 block discarded – undo
1251 1296
 								</fieldset>
1252 1297
 									<input type="submit" name="save" value="', $txt['save'], '" class="button_submit">';
1253 1298
 
1254
-	if ($context['fid'])
1255
-		echo '
1299
+	if ($context['fid']) {
1300
+			echo '
1256 1301
 									<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">';
1302
+	}
1257 1303
 
1258 1304
 	echo '
1259 1305
 							</div>
@@ -1296,8 +1342,7 @@  discard block
 block discarded – undo
1296 1342
 	{
1297 1343
 		echo '
1298 1344
 						<p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>';
1299
-	}
1300
-	else
1345
+	} else
1301 1346
 	{
1302 1347
 		echo '
1303 1348
 						<ol class="search_results">';
@@ -1323,9 +1368,10 @@  discard block
 block discarded – undo
1323 1368
 							<li>
1324 1369
 								<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1325 1370
 
1326
-				if ($result['help'])
1327
-					echo '
1371
+				if ($result['help']) {
1372
+									echo '
1328 1373
 								<p class="double_height">', $result['help'], '</p>';
1374
+				}
1329 1375
 
1330 1376
 				echo '
1331 1377
 							</li>';
@@ -1365,18 +1411,20 @@  discard block
 block discarded – undo
1365 1411
 									<strong>', $txt['setup_verification_answer'], '</strong>
1366 1412
 								</dd>';
1367 1413
 
1368
-		if (!empty($context['qa_by_lang'][$lang_id]))
1369
-			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1414
+		if (!empty($context['qa_by_lang'][$lang_id])) {
1415
+					foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1370 1416
 			{
1371 1417
 				$question = $context['question_answers'][$q_id];
1418
+		}
1372 1419
 				echo '
1373 1420
 								<dt>
1374 1421
 									<input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question">
1375 1422
 								</dt>
1376 1423
 								<dd>';
1377
-				foreach ($question['answers'] as $answer)
1378
-					echo '
1424
+				foreach ($question['answers'] as $answer) {
1425
+									echo '
1379 1426
 									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">';
1427
+				}
1380 1428
 
1381 1429
 				echo '
1382 1430
 									<div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
@@ -1415,11 +1463,12 @@  discard block
 block discarded – undo
1415 1463
 							', $txt['errors_found'], ':
1416 1464
 							<ul>';
1417 1465
 
1418
-			foreach ($context['repair_errors'] as $error)
1419
-				echo '
1466
+			foreach ($context['repair_errors'] as $error) {
1467
+							echo '
1420 1468
 								<li>
1421 1469
 									', $error, '
1422 1470
 								</li>';
1471
+			}
1423 1472
 
1424 1473
 			echo '
1425 1474
 							</ul>
@@ -1429,16 +1478,15 @@  discard block
 block discarded – undo
1429 1478
 							<p class="padding">
1430 1479
 								<strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong>
1431 1480
 							</p>';
1432
-		}
1433
-		else
1434
-			echo '
1481
+		} else {
1482
+					echo '
1435 1483
 							<p>', $txt['maintain_no_errors'], '</p>
1436 1484
 							<p class="padding">
1437 1485
 								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1438 1486
 							</p>';
1487
+		}
1439 1488
 
1440
-	}
1441
-	else
1489
+	} else
1442 1490
 	{
1443 1491
 		if (!empty($context['redirect_to_recount']))
1444 1492
 		{
@@ -1450,8 +1498,7 @@  discard block
 block discarded – undo
1450 1498
 								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1451 1499
 								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1452 1500
 							</form>';
1453
-		}
1454
-		else
1501
+		} else
1455 1502
 		{
1456 1503
 			echo '
1457 1504
 							<p>', $txt['errors_fixed'], '</p>
@@ -1603,8 +1650,8 @@  discard block
 block discarded – undo
1603 1650
 function template_admin_quick_search()
1604 1651
 {
1605 1652
 	global $context, $txt;
1606
-	if ($context['user']['is_admin'])
1607
-		echo '
1653
+	if ($context['user']['is_admin']) {
1654
+			echo '
1608 1655
 								<span class="floatright admin_search">
1609 1656
 									<span class="generic_icons filter centericon"></span>
1610 1657
 									<input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text">
@@ -1615,6 +1662,7 @@  discard block
 block discarded – undo
1615 1662
 									</select>
1616 1663
 									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit">
1617 1664
 								</span>';
1618
-}
1665
+	}
1666
+	}
1619 1667
 
1620 1668
 ?>
1621 1669
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 1 patch
Braces   +154 added lines, -118 removed lines patch added patch discarded remove patch
@@ -40,16 +40,14 @@  discard block
 block discarded – undo
40 40
 				', template_show_upcoming_list('main'), '
41 41
 			</div>
42 42
 		';
43
-	}
44
-	elseif ($context['calendar_view'] == 'viewweek')
43
+	} elseif ($context['calendar_view'] == 'viewweek')
45 44
 	{
46 45
 		echo '
47 46
 			<div id="main_grid">
48 47
 				', template_show_week_grid('main'), '
49 48
 			</div>
50 49
 		';
51
-	}
52
-	else
50
+	} else
53 51
 	{
54 52
 		echo '
55 53
 			<div id="main_grid">
@@ -75,8 +73,9 @@  discard block
 block discarded – undo
75 73
 	global $context, $scripturl, $txt;
76 74
 
77 75
 	// Bail out if we have nothing to work with
78
-	if (!isset($context['calendar_grid_' . $grid_name]))
79
-		return false;
76
+	if (!isset($context['calendar_grid_' . $grid_name])) {
77
+			return false;
78
+	}
80 79
 
81 80
 	// Protect programmer sanity
82 81
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -113,11 +112,13 @@  discard block
 block discarded – undo
113 112
 					<li class="windowbg">
114 113
 						<b class="event_title">', $event['link'], '</b>';
115 114
 
116
-				if ($event['can_edit'])
117
-					echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
115
+				if ($event['can_edit']) {
116
+									echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
117
+				}
118 118
 
119
-				if ($event['can_export'])
120
-					echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
119
+				if ($event['can_export']) {
120
+									echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
121
+				}
121 122
 
122 123
 				echo '
123 124
 						<br>';
@@ -125,14 +126,14 @@  discard block
 block discarded – undo
125 126
 				if (!empty($event['allday']))
126 127
 				{
127 128
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
128
-				}
129
-				else
129
+				} else
130 130
 				{
131 131
 					// Display event info relative to user's local timezone
132 132
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
133 133
 
134
-					if ($event['start_date_local'] != $event['end_date_local'])
135
-						echo trim($event['end_date_local']) . ', ';
134
+					if ($event['start_date_local'] != $event['end_date_local']) {
135
+											echo trim($event['end_date_local']) . ', ';
136
+					}
136 137
 
137 138
 					echo trim($event['end_time_local']);
138 139
 
@@ -141,23 +142,27 @@  discard block
 block discarded – undo
141 142
 					{
142 143
 						echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
143 144
 
144
-						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
145
-							echo trim($event['start_date_orig']), ', ';
145
+						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
146
+													echo trim($event['start_date_orig']), ', ';
147
+						}
146 148
 
147 149
 						echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
148 150
 
149
-						if ($event['start_date_orig'] != $event['end_date_orig'])
150
-							echo trim($event['end_date_orig']) . ', ';
151
+						if ($event['start_date_orig'] != $event['end_date_orig']) {
152
+													echo trim($event['end_date_orig']) . ', ';
153
+						}
151 154
 
152 155
 						echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
153 156
 					}
154 157
 					// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
155
-					else
156
-						echo ' ', $event['tz_abbrev'], '</time>';
158
+					else {
159
+											echo ' ', $event['tz_abbrev'], '</time>';
160
+					}
157 161
 				}
158 162
 
159
-				if (!empty($event['location']))
160
-					echo '<br>', $event['location'];
163
+				if (!empty($event['location'])) {
164
+									echo '<br>', $event['location'];
165
+				}
161 166
 
162 167
 				echo '
163 168
 					</li>';
@@ -189,8 +194,9 @@  discard block
 block discarded – undo
189 194
 
190 195
 			$birthdays = array();
191 196
 
192
-			foreach ($date as $member)
193
-				$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
197
+			foreach ($date as $member) {
198
+							$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
199
+			}
194 200
 
195 201
 			echo implode(', ', $birthdays);
196 202
 
@@ -221,8 +227,9 @@  discard block
 block discarded – undo
221 227
 			$date_local = $date['date_local'];
222 228
 			unset($date['date_local']);
223 229
 
224
-			foreach ($date as $holiday)
225
-				$holidays[] = $holiday . ' (' . $date_local . ')';
230
+			foreach ($date as $holiday) {
231
+							$holidays[] = $holiday . ' (' . $date_local . ')';
232
+			}
226 233
 		}
227 234
 
228 235
 		echo implode(', ', $holidays);
@@ -245,17 +252,19 @@  discard block
 block discarded – undo
245 252
 	global $context, $txt, $scripturl, $modSettings;
246 253
 
247 254
 	// If the grid doesn't exist, no point in proceeding.
248
-	if (!isset($context['calendar_grid_' . $grid_name]))
249
-		return false;
255
+	if (!isset($context['calendar_grid_' . $grid_name])) {
256
+			return false;
257
+	}
250 258
 
251 259
 	// A handy little pointer variable.
252 260
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
253 261
 
254 262
 	// Some conditions for whether or not we should show the week links *here*.
255
-	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false)))
256
-		$show_week_links = true;
257
-	else
258
-		$show_week_links = false;
263
+	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) {
264
+			$show_week_links = true;
265
+	} else {
266
+			$show_week_links = false;
267
+	}
259 268
 
260 269
 	// Assuming that we've not disabled it, show the title block!
261 270
 	if (empty($calendar_data['disable_title']))
@@ -294,8 +303,9 @@  discard block
 block discarded – undo
294 303
 	}
295 304
 
296 305
 	// Show the controls on main grids
297
-	if ($is_mini === false)
298
-		template_calendar_top($calendar_data);
306
+	if ($is_mini === false) {
307
+			template_calendar_top($calendar_data);
308
+	}
299 309
 
300 310
 	// Finally, the main calendar table.
301 311
 	echo '<table class="calendar_table">';
@@ -306,8 +316,9 @@  discard block
 block discarded – undo
306 316
 		echo '<tr>';
307 317
 
308 318
 		// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared!
309
-		if ($show_week_links === true)
310
-			echo '<th>&nbsp;</th>';
319
+		if ($show_week_links === true) {
320
+					echo '<th>&nbsp;</th>';
321
+		}
311 322
 
312 323
 		// Now, loop through each actual day of the week.
313 324
 		foreach ($calendar_data['week_days'] as $day)
@@ -354,27 +365,29 @@  discard block
 block discarded – undo
354 365
 				// Additional classes are given for events, holidays, and birthdays.
355 366
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
356 367
 				{
357
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3)))
358
-						$classes[] = 'events';
359
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3)))
360
-						$classes[] = 'events';
368
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) {
369
+											$classes[] = 'events';
370
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) {
371
+											$classes[] = 'events';
372
+					}
361 373
 				}
362 374
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
363 375
 				{
364
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3)))
365
-						$classes[] = 'holidays';
366
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3)))
367
-						$classes[] = 'holidays';
376
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) {
377
+											$classes[] = 'holidays';
378
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) {
379
+											$classes[] = 'holidays';
380
+					}
368 381
 				}
369 382
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
370 383
 				{
371
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3)))
372
-						$classes[] = 'birthdays';
373
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3)))
374
-						$classes[] = 'birthdays';
384
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) {
385
+											$classes[] = 'birthdays';
386
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) {
387
+											$classes[] = 'birthdays';
388
+					}
375 389
 				}
376
-			}
377
-			else
390
+			} else
378 391
 			{
379 392
 				// Default Classes (either compact or comfortable and disabled).
380 393
 				$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable';
@@ -392,19 +405,21 @@  discard block
 block discarded – undo
392 405
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
393 406
 
394 407
 				// The actual day number - be it a link, or just plain old text!
395
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
396
-					echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
397
-				elseif ($is_mini)
398
-					echo '<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
399
-				else
400
-					echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
408
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
409
+									echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
410
+				} elseif ($is_mini) {
411
+									echo '<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
412
+				} else {
413
+									echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
414
+				}
401 415
 
402 416
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
403 417
 				if ($is_mini === false)
404 418
 				{
405 419
 					// Holidays are always fun, let's show them!
406
-					if (!empty($day['holidays']))
407
-						echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
420
+					if (!empty($day['holidays'])) {
421
+											echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
422
+					}
408 423
 
409 424
 					// Happy Birthday Dear, Member!
410 425
 					if (!empty($day['birthdays']))
@@ -422,14 +437,16 @@  discard block
 block discarded – undo
422 437
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
423 438
 
424 439
 							// 9...10! Let's stop there.
425
-							if ($birthday_count == 10 && $use_js_hide)
426
-								// !!TODO - Inline CSS and JavaScript should be moved.
440
+							if ($birthday_count == 10 && $use_js_hide) {
441
+															// !!TODO - Inline CSS and JavaScript should be moved.
427 442
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
443
+							}
428 444
 
429 445
 							++$birthday_count;
430 446
 						}
431
-						if ($use_js_hide)
432
-							echo '</span>';
447
+						if ($use_js_hide) {
448
+													echo '</span>';
449
+						}
433 450
 
434 451
 						echo '</div>';
435 452
 					}
@@ -439,8 +456,9 @@  discard block
 block discarded – undo
439 456
 					{
440 457
 						// Sort events by start time (all day events will be listed first)
441 458
 						uasort($day['events'], function($a, $b) {
442
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
443
-						        return 0;
459
+						    if ($a['start_timestamp'] == $b['start_timestamp']) {
460
+						    						        return 0;
461
+						    }
444 462
 						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
445 463
 						});
446 464
 
@@ -456,17 +474,19 @@  discard block
 block discarded – undo
456 474
 
457 475
 							echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
458 476
 
459
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
460
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
461
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
462
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
463
-							elseif (!empty($event['allday']))
464
-								echo $txt['calendar_allday'];
477
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
478
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
479
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
480
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
481
+							} elseif (!empty($event['allday'])) {
482
+															echo $txt['calendar_allday'];
483
+							}
465 484
 
466 485
 							echo '</span>';
467 486
 
468
-							if (!empty($event['location']))
469
-								echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
487
+							if (!empty($event['location'])) {
488
+															echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
489
+							}
470 490
 
471 491
 							if ($event['can_edit'] || $event['can_export'])
472 492
 							{
@@ -503,10 +523,11 @@  discard block
 block discarded – undo
503 523
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
504 524
 			elseif ($is_mini === false)
505 525
 			{
506
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
507
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
508
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
509
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
526
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
527
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
528
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
529
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
530
+				}
510 531
 			}
511 532
 
512 533
 			// Close this day and increase var count.
@@ -532,8 +553,9 @@  discard block
 block discarded – undo
532 553
 	global $context, $txt, $scripturl, $modSettings;
533 554
 
534 555
 	// We might have no reason to proceed, if the variable isn't there.
535
-	if (!isset($context['calendar_grid_' . $grid_name]))
536
-		return false;
556
+	if (!isset($context['calendar_grid_' . $grid_name])) {
557
+			return false;
558
+	}
537 559
 
538 560
 	// Handy pointer.
539 561
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -568,8 +590,9 @@  discard block
 block discarded – undo
568 590
 					}
569 591
 
570 592
 					// The Month Title + Week Number...
571
-					if (!empty($calendar_data['week_title']))
572
-							echo $calendar_data['week_title'];
593
+					if (!empty($calendar_data['week_title'])) {
594
+												echo $calendar_data['week_title'];
595
+					}
573 596
 
574 597
 					echo '
575 598
 					</h3>
@@ -608,10 +631,11 @@  discard block
 block discarded – undo
608 631
 						<tr class="days_wrapper">
609 632
 							<td class="', implode(' ', $classes), ' act_day">';
610 633
 							// Should the day number be a link?
611
-							if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
612
-								echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
613
-							else
614
-								echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
634
+							if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
635
+															echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
636
+							} else {
637
+															echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
638
+							}
615 639
 
616 640
 							echo '</td>
617 641
 							<td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">';
@@ -620,8 +644,9 @@  discard block
 block discarded – undo
620 644
 							{
621 645
 								// Sort events by start time (all day events will be listed first)
622 646
 								uasort($day['events'], function($a, $b) {
623
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
624
-								        return 0;
647
+								    if ($a['start_timestamp'] == $b['start_timestamp']) {
648
+								    								        return 0;
649
+								    }
625 650
 								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
626 651
 								});
627 652
 
@@ -633,15 +658,17 @@  discard block
 block discarded – undo
633 658
 
634 659
 									echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
635 660
 
636
-									if (!empty($event['start_time_local']))
637
-										echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
638
-									else
639
-										echo $txt['calendar_allday'];
661
+									if (!empty($event['start_time_local'])) {
662
+																			echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
663
+									} else {
664
+																			echo $txt['calendar_allday'];
665
+									}
640 666
 
641 667
 									echo '</span>';
642 668
 
643
-									if (!empty($event['location']))
644
-										echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
669
+									if (!empty($event['location'])) {
670
+																			echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
671
+									}
645 672
 
646 673
 									if (!empty($event_icons_needed))
647 674
 									{
@@ -678,8 +705,7 @@  discard block
 block discarded – undo
678 705
 									</div>
679 706
 									<br class="clear">';
680 707
 								}
681
-							}
682
-							else
708
+							} else
683 709
 							{
684 710
 								if (!empty($context['can_post']))
685 711
 								{
@@ -692,8 +718,9 @@  discard block
 block discarded – undo
692 718
 							echo '</td>
693 719
 							<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
694 720
 							// Show any holidays!
695
-							if (!empty($day['holidays']))
696
-								echo implode('<br>', $day['holidays']);
721
+							if (!empty($day['holidays'])) {
722
+															echo implode('<br>', $day['holidays']);
723
+							}
697 724
 
698 725
 							echo '</td>
699 726
 							<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">';
@@ -751,8 +778,7 @@  discard block
 block discarded – undo
751 778
 				<input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date">
752 779
 				<input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '">
753 780
 			</form>';
754
-	}
755
-	else
781
+	} else
756 782
 	{
757 783
 		echo'
758 784
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
@@ -794,8 +820,9 @@  discard block
 block discarded – undo
794 820
 	echo '
795 821
 		<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">';
796 822
 
797
-	if (!empty($context['event']['new']))
798
-		echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
823
+	if (!empty($context['event']['new'])) {
824
+			echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
825
+	}
799 826
 
800 827
 	// Start the main table.
801 828
 	echo '
@@ -845,9 +872,10 @@  discard block
 block discarded – undo
845 872
 		{
846 873
 			echo '
847 874
 								<optgroup label="', $category['name'], '">';
848
-			foreach ($category['boards'] as $board)
849
-				echo '
875
+			foreach ($category['boards'] as $board) {
876
+							echo '
850 877
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
878
+			}
851 879
 			echo '
852 880
 								</optgroup>';
853 881
 		}
@@ -883,9 +911,10 @@  discard block
 block discarded – undo
883 911
 							<span class="label">', $txt['calendar_timezone'], '</span>
884 912
 							<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
885 913
 
886
-	foreach ($context['all_timezones'] as $tz => $tzname)
887
-		echo '
914
+	foreach ($context['all_timezones'] as $tz => $tzname) {
915
+			echo '
888 916
 								<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
917
+	}
889 918
 
890 919
 	echo '
891 920
 							</select>
@@ -900,9 +929,10 @@  discard block
 block discarded – undo
900 929
 	echo '
901 930
 				<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">';
902 931
 	// Delete button?
903
-	if (empty($context['event']['new']))
904
-		echo '
932
+	if (empty($context['event']['new'])) {
933
+			echo '
905 934
 				<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">';
935
+	}
906 936
 
907 937
 	echo '
908 938
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -946,9 +976,10 @@  discard block
 block discarded – undo
946 976
 
947 977
 		foreach ($context['clockicons'] as $t => $v)
948 978
 		{
949
-			foreach ($v as $i)
950
-				echo '
979
+			foreach ($v as $i) {
980
+							echo '
951 981
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
982
+			}
952 983
 		}
953 984
 
954 985
 		echo '
@@ -973,13 +1004,14 @@  discard block
 block discarded – undo
973 1004
 
974 1005
 		foreach ($context['clockicons'] as $t => $v)
975 1006
 		{
976
-			foreach ($v as $i)
977
-				echo '
1007
+			foreach ($v as $i) {
1008
+							echo '
978 1009
 			if (', $t, ' >= ', $i, ')
979 1010
 			{
980 1011
 				turnon.push("', $t, '_', $i, '");
981 1012
 				', $t, ' -= ', $i, ';
982 1013
 			}';
1014
+			}
983 1015
 		}
984 1016
 
985 1017
 		echo '
@@ -1043,9 +1075,10 @@  discard block
 block discarded – undo
1043 1075
 
1044 1076
 	foreach ($context['clockicons'] as $t => $v)
1045 1077
 	{
1046
-		foreach ($v as $i)
1047
-			echo '
1078
+		foreach ($v as $i) {
1079
+					echo '
1048 1080
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1081
+		}
1049 1082
 	}
1050 1083
 
1051 1084
 	echo '
@@ -1062,13 +1095,14 @@  discard block
 block discarded – undo
1062 1095
 
1063 1096
 	foreach ($context['clockicons'] as $t => $v)
1064 1097
 	{
1065
-		foreach ($v as $i)
1066
-			echo '
1098
+		foreach ($v as $i) {
1099
+					echo '
1067 1100
 		if (', $t, ' >= ', $i, ')
1068 1101
 		{
1069 1102
 			turnon.push("', $t, '_', $i, '");
1070 1103
 			', $t, ' -= ', $i, ';
1071 1104
 		}';
1105
+		}
1072 1106
 	}
1073 1107
 
1074 1108
 	echo '
@@ -1127,9 +1161,10 @@  discard block
 block discarded – undo
1127 1161
 
1128 1162
 	foreach ($context['clockicons'] as $t => $v)
1129 1163
 	{
1130
-		foreach ($v as $i)
1131
-			echo '
1164
+		foreach ($v as $i) {
1165
+					echo '
1132 1166
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1167
+		}
1133 1168
 	}
1134 1169
 
1135 1170
 	echo '
@@ -1150,13 +1185,14 @@  discard block
 block discarded – undo
1150 1185
 
1151 1186
 	foreach ($context['clockicons'] as $t => $v)
1152 1187
 	{
1153
-		foreach ($v as $i)
1154
-		echo '
1188
+		foreach ($v as $i) {
1189
+				echo '
1155 1190
 		if (', $t, ' >= ', $i, ')
1156 1191
 		{
1157 1192
 			turnon.push("', $t, '_', $i, '");
1158 1193
 			', $t, ' -= ', $i, ';
1159 1194
 		}';
1195
+		}
1160 1196
 	}
1161 1197
 
1162 1198
 	echo '
Please login to merge, or discard this patch.
other/upgrade.php 1 patch
Braces   +878 added lines, -645 removed lines patch added patch discarded remove patch
@@ -75,8 +75,9 @@  discard block
 block discarded – undo
75 75
 $upcontext['inactive_timeout'] = 10;
76 76
 
77 77
 // The helper is crucial. Include it first thing.
78
-if (!file_exists($upgrade_path . '/upgrade-helper.php'))
78
+if (!file_exists($upgrade_path . '/upgrade-helper.php')) {
79 79
     die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
80
+}
80 81
 
81 82
 require_once($upgrade_path . '/upgrade-helper.php');
82 83
 
@@ -100,11 +101,14 @@  discard block
 block discarded – undo
100 101
 	ini_set('default_socket_timeout', 900);
101 102
 }
102 103
 // Clean the upgrade path if this is from the client.
103
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
104
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
104
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
105
+	for ($i = 1;
106
+}
107
+$i < $_SERVER['argc']; $i++)
105 108
 	{
106
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
107
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
109
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
110
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
111
+		}
108 112
 	}
109 113
 
110 114
 // Are we from the client?
@@ -112,16 +116,17 @@  discard block
 block discarded – undo
112 116
 {
113 117
 	$command_line = true;
114 118
 	$disable_security = true;
115
-}
116
-else
119
+} else {
117 120
 	$command_line = false;
121
+}
118 122
 
119 123
 // Load this now just because we can.
120 124
 require_once($upgrade_path . '/Settings.php');
121 125
 
122 126
 // We don't use "-utf8" anymore...  Tweak the entry that may have been loaded by Settings.php
123
-if (isset($language))
127
+if (isset($language)) {
124 128
 	$language = str_ireplace('-utf8', '', $language);
129
+}
125 130
 
126 131
 // Are we logged in?
127 132
 if (isset($upgradeData))
@@ -129,10 +134,12 @@  discard block
 block discarded – undo
129 134
 	$upcontext['user'] = json_decode(base64_decode($upgradeData), true);
130 135
 
131 136
 	// Check for sensible values.
132
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
133
-		$upcontext['user']['started'] = time();
134
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
135
-		$upcontext['user']['updated'] = 0;
137
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
138
+			$upcontext['user']['started'] = time();
139
+	}
140
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
141
+			$upcontext['user']['updated'] = 0;
142
+	}
136 143
 
137 144
 	$upcontext['started'] = $upcontext['user']['started'];
138 145
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -190,8 +197,9 @@  discard block
 block discarded – undo
190 197
 			'db_error_skip' => true,
191 198
 		)
192 199
 	);
193
-	while ($row = $smcFunc['db_fetch_assoc']($request))
194
-		$modSettings[$row['variable']] = $row['value'];
200
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
201
+			$modSettings[$row['variable']] = $row['value'];
202
+	}
195 203
 	$smcFunc['db_free_result']($request);
196 204
 }
197 205
 
@@ -201,10 +209,12 @@  discard block
 block discarded – undo
201 209
 	$modSettings['theme_url'] = 'Themes/default';
202 210
 	$modSettings['images_url'] = 'Themes/default/images';
203 211
 }
204
-if (!isset($settings['default_theme_url']))
212
+if (!isset($settings['default_theme_url'])) {
205 213
 	$settings['default_theme_url'] = $modSettings['theme_url'];
206
-if (!isset($settings['default_theme_dir']))
214
+}
215
+if (!isset($settings['default_theme_dir'])) {
207 216
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
217
+}
208 218
 
209 219
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
210 220
 // Default title...
@@ -222,13 +232,15 @@  discard block
 block discarded – undo
222 232
 	$support_js = $upcontext['upgrade_status']['js'];
223 233
 
224 234
 	// Only set this if the upgrader status says so.
225
-	if (empty($is_debug))
226
-		$is_debug = $upcontext['upgrade_status']['debug'];
235
+	if (empty($is_debug)) {
236
+			$is_debug = $upcontext['upgrade_status']['debug'];
237
+	}
227 238
 
228 239
 	// Load the language.
229
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
230
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
231
-}
240
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
241
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
242
+	}
243
+	}
232 244
 // Set the defaults.
233 245
 else
234 246
 {
@@ -246,15 +258,18 @@  discard block
 block discarded – undo
246 258
 }
247 259
 
248 260
 // If this isn't the first stage see whether they are logging in and resuming.
249
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
261
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
250 262
 	checkLogin();
263
+}
251 264
 
252
-if ($command_line)
265
+if ($command_line) {
253 266
 	cmdStep0();
267
+}
254 268
 
255 269
 // Don't error if we're using xml.
256
-if (isset($_GET['xml']))
270
+if (isset($_GET['xml'])) {
257 271
 	$upcontext['return_error'] = true;
272
+}
258 273
 
259 274
 // Loop through all the steps doing each one as required.
260 275
 $upcontext['overall_percent'] = 0;
@@ -275,9 +290,9 @@  discard block
 block discarded – undo
275 290
 		}
276 291
 
277 292
 		// Call the step and if it returns false that means pause!
278
-		if (function_exists($step[2]) && $step[2]() === false)
279
-			break;
280
-		elseif (function_exists($step[2])) {
293
+		if (function_exists($step[2]) && $step[2]() === false) {
294
+					break;
295
+		} elseif (function_exists($step[2])) {
281 296
 			//Start each new step with this unset, so the 'normal' template is called first
282 297
 			unset($_GET['xml']);
283 298
 			//Clear out warnings at the start of each step
@@ -323,17 +338,18 @@  discard block
 block discarded – undo
323 338
 		// This should not happen my dear... HELP ME DEVELOPERS!!
324 339
 		if (!empty($command_line))
325 340
 		{
326
-			if (function_exists('debug_print_backtrace'))
327
-				debug_print_backtrace();
341
+			if (function_exists('debug_print_backtrace')) {
342
+							debug_print_backtrace();
343
+			}
328 344
 
329 345
 			echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.';
330 346
 			flush();
331 347
 			die();
332 348
 		}
333 349
 
334
-		if (!isset($_GET['xml']))
335
-			template_upgrade_above();
336
-		else
350
+		if (!isset($_GET['xml'])) {
351
+					template_upgrade_above();
352
+		} else
337 353
 		{
338 354
 			header('Content-Type: text/xml; charset=UTF-8');
339 355
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -355,25 +371,29 @@  discard block
 block discarded – undo
355 371
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(json_encode($upcontext['upgrade_status']));
356 372
 
357 373
 			// Custom stuff to pass back?
358
-			if (!empty($upcontext['query_string']))
359
-				$upcontext['form_url'] .= $upcontext['query_string'];
374
+			if (!empty($upcontext['query_string'])) {
375
+							$upcontext['form_url'] .= $upcontext['query_string'];
376
+			}
360 377
 
361 378
 			// Call the appropriate subtemplate
362
-			if (is_callable('template_' . $upcontext['sub_template']))
363
-				call_user_func('template_' . $upcontext['sub_template']);
364
-			else
365
-				die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
379
+			if (is_callable('template_' . $upcontext['sub_template'])) {
380
+							call_user_func('template_' . $upcontext['sub_template']);
381
+			} else {
382
+							die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
383
+			}
366 384
 		}
367 385
 
368 386
 		// Was there an error?
369
-		if (!empty($upcontext['forced_error_message']))
370
-			echo $upcontext['forced_error_message'];
387
+		if (!empty($upcontext['forced_error_message'])) {
388
+					echo $upcontext['forced_error_message'];
389
+		}
371 390
 
372 391
 		// Show the footer.
373
-		if (!isset($_GET['xml']))
374
-			template_upgrade_below();
375
-		else
376
-			template_xml_below();
392
+		if (!isset($_GET['xml'])) {
393
+					template_upgrade_below();
394
+		} else {
395
+					template_xml_below();
396
+		}
377 397
 	}
378 398
 
379 399
 
@@ -385,15 +405,19 @@  discard block
 block discarded – undo
385 405
 		$seconds = intval($active % 60);
386 406
 
387 407
 		$totalTime = '';
388
-		if ($hours > 0)
389
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
390
-		if ($minutes > 0)
391
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
392
-		if ($seconds > 0)
393
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
408
+		if ($hours > 0) {
409
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
410
+		}
411
+		if ($minutes > 0) {
412
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
413
+		}
414
+		if ($seconds > 0) {
415
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
416
+		}
394 417
 
395
-		if (!empty($totalTime))
396
-			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
418
+		if (!empty($totalTime)) {
419
+					echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
420
+		}
397 421
 	}
398 422
 
399 423
 	// Bang - gone!
@@ -406,8 +430,9 @@  discard block
 block discarded – undo
406 430
 	global $upgradeurl, $upcontext, $command_line;
407 431
 
408 432
 	// Command line users can't be redirected.
409
-	if ($command_line)
410
-		upgradeExit(true);
433
+	if ($command_line) {
434
+			upgradeExit(true);
435
+	}
411 436
 
412 437
 	// Are we providing the core info?
413 438
 	if ($addForm)
@@ -433,12 +458,14 @@  discard block
 block discarded – undo
433 458
 	define('SMF', 1);
434 459
 
435 460
 	// Start the session.
436
-	if (@ini_get('session.save_handler') == 'user')
437
-		@ini_set('session.save_handler', 'files');
461
+	if (@ini_get('session.save_handler') == 'user') {
462
+			@ini_set('session.save_handler', 'files');
463
+	}
438 464
 	@session_start();
439 465
 
440
-	if (empty($smcFunc))
441
-		$smcFunc = array();
466
+	if (empty($smcFunc)) {
467
+			$smcFunc = array();
468
+	}
442 469
 
443 470
 	// We need this for authentication and some upgrade code
444 471
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -450,32 +477,36 @@  discard block
 block discarded – undo
450 477
 	initialize_inputs();
451 478
 
452 479
 	// Get the database going!
453
-	if (empty($db_type) || $db_type == 'mysqli')
454
-		$db_type = 'mysql';
480
+	if (empty($db_type) || $db_type == 'mysqli') {
481
+			$db_type = 'mysql';
482
+	}
455 483
 
456 484
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
457 485
 	{
458 486
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
459 487
 
460 488
 		// Make the connection...
461
-		if (empty($db_connection))
462
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
463
-		else
464
-			// If we've returned here, ping/reconnect to be safe
489
+		if (empty($db_connection)) {
490
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
491
+		} else {
492
+					// If we've returned here, ping/reconnect to be safe
465 493
 			$smcFunc['db_ping']($db_connection);
494
+		}
466 495
 
467 496
 		// Oh dear god!!
468
-		if ($db_connection === null)
469
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
497
+		if ($db_connection === null) {
498
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
499
+		}
470 500
 
471
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
472
-			$smcFunc['db_query']('', '
501
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
502
+					$smcFunc['db_query']('', '
473 503
 			SET NAMES {string:db_character_set}',
474 504
 			array(
475 505
 				'db_error_skip' => true,
476 506
 				'db_character_set' => $db_character_set,
477 507
 			)
478 508
 		);
509
+		}
479 510
 
480 511
 		// Load the modSettings data...
481 512
 		$request = $smcFunc['db_query']('', '
@@ -486,11 +517,11 @@  discard block
 block discarded – undo
486 517
 			)
487 518
 		);
488 519
 		$modSettings = array();
489
-		while ($row = $smcFunc['db_fetch_assoc']($request))
490
-			$modSettings[$row['variable']] = $row['value'];
520
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
521
+					$modSettings[$row['variable']] = $row['value'];
522
+		}
491 523
 		$smcFunc['db_free_result']($request);
492
-	}
493
-	else
524
+	} else
494 525
 	{
495 526
 		return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.');
496 527
 	}
@@ -504,9 +535,10 @@  discard block
 block discarded – undo
504 535
 		cleanRequest();
505 536
 	}
506 537
 
507
-	if (!isset($_GET['substep']))
508
-		$_GET['substep'] = 0;
509
-}
538
+	if (!isset($_GET['substep'])) {
539
+			$_GET['substep'] = 0;
540
+	}
541
+	}
510 542
 
511 543
 function initialize_inputs()
512 544
 {
@@ -536,8 +568,9 @@  discard block
 block discarded – undo
536 568
 		$dh = opendir(dirname(__FILE__));
537 569
 		while ($file = readdir($dh))
538 570
 		{
539
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
540
-				@unlink(dirname(__FILE__) . '/' . $file);
571
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
572
+							@unlink(dirname(__FILE__) . '/' . $file);
573
+			}
541 574
 		}
542 575
 		closedir($dh);
543 576
 
@@ -566,8 +599,9 @@  discard block
 block discarded – undo
566 599
 	$temp = 'upgrade_php?step';
567 600
 	while (strlen($temp) > 4)
568 601
 	{
569
-		if (isset($_GET[$temp]))
570
-			unset($_GET[$temp]);
602
+		if (isset($_GET[$temp])) {
603
+					unset($_GET[$temp]);
604
+		}
571 605
 		$temp = substr($temp, 1);
572 606
 	}
573 607
 
@@ -594,32 +628,39 @@  discard block
 block discarded – undo
594 628
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
595 629
 
596 630
 	// Need legacy scripts?
597
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
598
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
599
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
600
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
601
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
602
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
631
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
632
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
633
+	}
634
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
635
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
636
+	}
637
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
638
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
639
+	}
603 640
 
604 641
 	// We don't need "-utf8" files anymore...
605 642
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
606 643
 
607 644
 	// This needs to exist!
608
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
609
-		return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
610
-	else
611
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
645
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
646
+			return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
647
+	} else {
648
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
649
+	}
612 650
 
613
-	if (!$check)
614
-		// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
651
+	if (!$check) {
652
+			// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
615 653
 		return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.');
654
+	}
616 655
 
617 656
 	// Do they meet the install requirements?
618
-	if (!php_version_check())
619
-		return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.');
657
+	if (!php_version_check()) {
658
+			return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.');
659
+	}
620 660
 
621
-	if (!db_version_check())
622
-		return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
661
+	if (!db_version_check()) {
662
+			return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
663
+	}
623 664
 
624 665
 	// Do some checks to make sure they have proper privileges
625 666
 	db_extend('packages');
@@ -634,14 +675,16 @@  discard block
 block discarded – undo
634 675
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
635 676
 
636 677
 	// Sorry... we need CREATE, ALTER and DROP
637
-	if (!$create || !$alter || !$drop)
638
-		return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
678
+	if (!$create || !$alter || !$drop) {
679
+			return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
680
+	}
639 681
 
640 682
 	// Do a quick version spot check.
641 683
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
642 684
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
643
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
644
-		return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.');
685
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
686
+			return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.');
687
+	}
645 688
 
646 689
 	// What absolutely needs to be writable?
647 690
 	$writable_files = array(
@@ -663,12 +706,13 @@  discard block
 block discarded – undo
663 706
 	quickFileWritable($custom_av_dir);
664 707
 
665 708
 	// Are we good now?
666
-	if (!is_writable($custom_av_dir))
667
-		return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
668
-	elseif ($need_settings_update)
709
+	if (!is_writable($custom_av_dir)) {
710
+			return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
711
+	} elseif ($need_settings_update)
669 712
 	{
670
-		if (!function_exists('cache_put_data'))
671
-			require_once($sourcedir . '/Load.php');
713
+		if (!function_exists('cache_put_data')) {
714
+					require_once($sourcedir . '/Load.php');
715
+		}
672 716
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
673 717
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
674 718
 	}
@@ -677,28 +721,33 @@  discard block
 block discarded – undo
677 721
 
678 722
 	// Check the cache directory.
679 723
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
680
-	if (!file_exists($cachedir_temp))
681
-		@mkdir($cachedir_temp);
682
-	if (!file_exists($cachedir_temp))
683
-		return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
684
-
685
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
686
-		return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
687
-	elseif (!isset($_GET['skiplang']))
724
+	if (!file_exists($cachedir_temp)) {
725
+			@mkdir($cachedir_temp);
726
+	}
727
+	if (!file_exists($cachedir_temp)) {
728
+			return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
729
+	}
730
+
731
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
732
+			return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
733
+	} elseif (!isset($_GET['skiplang']))
688 734
 	{
689 735
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
690 736
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
691 737
 
692
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
693
-			return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
738
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
739
+					return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
740
+		}
694 741
 	}
695 742
 
696
-	if (!makeFilesWritable($writable_files))
697
-		return false;
743
+	if (!makeFilesWritable($writable_files)) {
744
+			return false;
745
+	}
698 746
 
699 747
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
700
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
701
-		return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
748
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
749
+			return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
750
+	}
702 751
 
703 752
 	// Upgrade the agreement.
704 753
 	elseif (isset($modSettings['agreement']))
@@ -709,8 +758,8 @@  discard block
 block discarded – undo
709 758
 	}
710 759
 
711 760
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
712
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
713
-		$upcontext['warning'] = '
761
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
762
+			$upcontext['warning'] = '
714 763
 			It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to &quot;' . $boarddir . '&quot; but should probably be &quot;' . dirname(__FILE__) . '&quot;. Settings.php currently lists your paths as:<br>
715 764
 			<ul>
716 765
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -718,15 +767,18 @@  discard block
 block discarded – undo
718 767
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
719 768
 			</ul>
720 769
 			If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.';
770
+	}
721 771
 
722 772
 	// Check for https stream support.
723 773
 	$supported_streams = stream_get_wrappers();
724
-	if (!in_array('https', $supported_streams))
725
-		$upcontext['custom_warning'] = $txt['install_no_https'];
774
+	if (!in_array('https', $supported_streams)) {
775
+			$upcontext['custom_warning'] = $txt['install_no_https'];
776
+	}
726 777
 
727 778
 	// Either we're logged in or we're going to present the login.
728
-	if (checkLogin())
729
-		return true;
779
+	if (checkLogin()) {
780
+			return true;
781
+	}
730 782
 
731 783
 	$upcontext += createToken('login');
732 784
 
@@ -740,15 +792,17 @@  discard block
 block discarded – undo
740 792
 	global $smcFunc, $db_type, $support_js;
741 793
 
742 794
 	// Don't bother if the security is disabled.
743
-	if ($disable_security)
744
-		return true;
795
+	if ($disable_security) {
796
+			return true;
797
+	}
745 798
 
746 799
 	// Are we trying to login?
747 800
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
748 801
 	{
749 802
 		// If we've disabled security pick a suitable name!
750
-		if (empty($_POST['user']))
751
-			$_POST['user'] = 'Administrator';
803
+		if (empty($_POST['user'])) {
804
+					$_POST['user'] = 'Administrator';
805
+		}
752 806
 
753 807
 		// Before 2.0 these column names were different!
754 808
 		$oldDB = false;
@@ -763,16 +817,17 @@  discard block
 block discarded – undo
763 817
 					'db_error_skip' => true,
764 818
 				)
765 819
 			);
766
-			if ($smcFunc['db_num_rows']($request) != 0)
767
-				$oldDB = true;
820
+			if ($smcFunc['db_num_rows']($request) != 0) {
821
+							$oldDB = true;
822
+			}
768 823
 			$smcFunc['db_free_result']($request);
769 824
 		}
770 825
 
771 826
 		// Get what we believe to be their details.
772 827
 		if (!$disable_security)
773 828
 		{
774
-			if ($oldDB)
775
-				$request = $smcFunc['db_query']('', '
829
+			if ($oldDB) {
830
+							$request = $smcFunc['db_query']('', '
776 831
 					SELECT id_member, memberName AS member_name, passwd, id_group,
777 832
 					additionalGroups AS additional_groups, lngfile
778 833
 					FROM {db_prefix}members
@@ -782,8 +837,8 @@  discard block
 block discarded – undo
782 837
 						'db_error_skip' => true,
783 838
 					)
784 839
 				);
785
-			else
786
-				$request = $smcFunc['db_query']('', '
840
+			} else {
841
+							$request = $smcFunc['db_query']('', '
787 842
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
788 843
 					FROM {db_prefix}members
789 844
 					WHERE member_name = {string:member_name}',
@@ -792,6 +847,7 @@  discard block
 block discarded – undo
792 847
 						'db_error_skip' => true,
793 848
 					)
794 849
 				);
850
+			}
795 851
 			if ($smcFunc['db_num_rows']($request) != 0)
796 852
 			{
797 853
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -799,16 +855,17 @@  discard block
 block discarded – undo
799 855
 				$groups = explode(',', $addGroups);
800 856
 				$groups[] = $id_group;
801 857
 
802
-				foreach ($groups as $k => $v)
803
-					$groups[$k] = (int) $v;
858
+				foreach ($groups as $k => $v) {
859
+									$groups[$k] = (int) $v;
860
+				}
804 861
 
805 862
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
806 863
 
807 864
 				// We don't use "-utf8" anymore...
808 865
 				$user_language = str_ireplace('-utf8', '', $user_language);
866
+			} else {
867
+							$upcontext['username_incorrect'] = true;
809 868
 			}
810
-			else
811
-				$upcontext['username_incorrect'] = true;
812 869
 			$smcFunc['db_free_result']($request);
813 870
 		}
814 871
 		$upcontext['username'] = $_POST['user'];
@@ -818,13 +875,14 @@  discard block
 block discarded – undo
818 875
 		{
819 876
 			$upcontext['upgrade_status']['js'] = 1;
820 877
 			$support_js = 1;
878
+		} else {
879
+					$support_js = 0;
821 880
 		}
822
-		else
823
-			$support_js = 0;
824 881
 
825 882
 		// Note down the version we are coming from.
826
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
827
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
883
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
884
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
885
+		}
828 886
 
829 887
 		// Didn't get anywhere?
830 888
 		if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect']))
@@ -858,15 +916,15 @@  discard block
 block discarded – undo
858 916
 							'db_error_skip' => true,
859 917
 						)
860 918
 					);
861
-					if ($smcFunc['db_num_rows']($request) == 0)
862
-						return throw_error('You need to be an admin to perform an upgrade!');
919
+					if ($smcFunc['db_num_rows']($request) == 0) {
920
+											return throw_error('You need to be an admin to perform an upgrade!');
921
+					}
863 922
 					$smcFunc['db_free_result']($request);
864 923
 				}
865 924
 
866 925
 				$upcontext['user']['id'] = $id_member;
867 926
 				$upcontext['user']['name'] = $name;
868
-			}
869
-			else
927
+			} else
870 928
 			{
871 929
 				$upcontext['user']['id'] = 1;
872 930
 				$upcontext['user']['name'] = 'Administrator';
@@ -882,11 +940,11 @@  discard block
 block discarded – undo
882 940
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
883 941
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
884 942
 
885
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
886
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
887
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
888
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
889
-				else
943
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
944
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
945
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
946
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
947
+				} else
890 948
 				{
891 949
 					// Set this as the new language.
892 950
 					$upcontext['language'] = $user_language;
@@ -930,8 +988,9 @@  discard block
 block discarded – undo
930 988
 	unset($member_columns);
931 989
 
932 990
 	// If we've not submitted then we're done.
933
-	if (empty($_POST['upcont']))
934
-		return false;
991
+	if (empty($_POST['upcont'])) {
992
+			return false;
993
+	}
935 994
 
936 995
 	// Firstly, if they're enabling SM stat collection just do it.
937 996
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
@@ -951,16 +1010,17 @@  discard block
 block discarded – undo
951 1010
 				fwrite($fp, $out);
952 1011
 
953 1012
 				$return_data = '';
954
-				while (!feof($fp))
955
-					$return_data .= fgets($fp, 128);
1013
+				while (!feof($fp)) {
1014
+									$return_data .= fgets($fp, 128);
1015
+				}
956 1016
 
957 1017
 				fclose($fp);
958 1018
 
959 1019
 				// Get the unique site ID.
960 1020
 				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
961 1021
 
962
-				if (!empty($ID[1]))
963
-					$smcFunc['db_insert']('replace',
1022
+				if (!empty($ID[1])) {
1023
+									$smcFunc['db_insert']('replace',
964 1024
 						$db_prefix . 'settings',
965 1025
 						array('variable' => 'string', 'value' => 'string'),
966 1026
 						array(
@@ -969,9 +1029,9 @@  discard block
 block discarded – undo
969 1029
 						),
970 1030
 						array('variable')
971 1031
 					);
1032
+				}
972 1033
 			}
973
-		}
974
-		else
1034
+		} else
975 1035
 		{
976 1036
 			$smcFunc['db_insert']('replace',
977 1037
 				$db_prefix . 'settings',
@@ -982,8 +1042,8 @@  discard block
 block discarded – undo
982 1042
 		}
983 1043
 	}
984 1044
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
985
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
986
-		$smcFunc['db_query']('', '
1045
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1046
+			$smcFunc['db_query']('', '
987 1047
 			DELETE FROM {db_prefix}settings
988 1048
 			WHERE variable = {string:enable_sm_stats}',
989 1049
 			array(
@@ -991,6 +1051,7 @@  discard block
 block discarded – undo
991 1051
 				'db_error_skip' => true,
992 1052
 			)
993 1053
 		);
1054
+	}
994 1055
 
995 1056
 	// Deleting old karma stuff?
996 1057
 	if (!empty($_POST['delete_karma']))
@@ -1005,20 +1066,22 @@  discard block
 block discarded – undo
1005 1066
 		);
1006 1067
 
1007 1068
 		// Cleaning up old karma member settings.
1008
-		if ($upcontext['karma_installed']['good'])
1009
-			$smcFunc['db_query']('', '
1069
+		if ($upcontext['karma_installed']['good']) {
1070
+					$smcFunc['db_query']('', '
1010 1071
 				ALTER TABLE {db_prefix}members
1011 1072
 				DROP karma_good',
1012 1073
 				array()
1013 1074
 			);
1075
+		}
1014 1076
 
1015 1077
 		// Does karma bad was enable?
1016
-		if ($upcontext['karma_installed']['bad'])
1017
-			$smcFunc['db_query']('', '
1078
+		if ($upcontext['karma_installed']['bad']) {
1079
+					$smcFunc['db_query']('', '
1018 1080
 				ALTER TABLE {db_prefix}members
1019 1081
 				DROP karma_bad',
1020 1082
 				array()
1021 1083
 			);
1084
+		}
1022 1085
 
1023 1086
 		// Cleaning up old karma permissions.
1024 1087
 		$smcFunc['db_query']('', '
@@ -1031,26 +1094,29 @@  discard block
 block discarded – undo
1031 1094
 	}
1032 1095
 
1033 1096
 	// Emptying the error log?
1034
-	if (!empty($_POST['empty_error']))
1035
-		$smcFunc['db_query']('truncate_table', '
1097
+	if (!empty($_POST['empty_error'])) {
1098
+			$smcFunc['db_query']('truncate_table', '
1036 1099
 			TRUNCATE {db_prefix}log_errors',
1037 1100
 			array(
1038 1101
 			)
1039 1102
 		);
1103
+	}
1040 1104
 
1041 1105
 	$changes = array();
1042 1106
 
1043 1107
 	// Add proxy settings.
1044
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1045
-		$changes += array(
1108
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1109
+			$changes += array(
1046 1110
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1047 1111
 			'image_proxy_maxsize' => 5190,
1048 1112
 			'image_proxy_enabled' => 0,
1049 1113
 		);
1114
+	}
1050 1115
 
1051 1116
 	// If we're overriding the language follow it through.
1052
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1053
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1117
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1118
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1119
+	}
1054 1120
 
1055 1121
 	if (!empty($_POST['maint']))
1056 1122
 	{
@@ -1062,30 +1128,34 @@  discard block
 block discarded – undo
1062 1128
 		{
1063 1129
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1064 1130
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1065
-		}
1066
-		else
1131
+		} else
1067 1132
 		{
1068 1133
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1069 1134
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1070 1135
 		}
1071 1136
 	}
1072 1137
 
1073
-	if ($command_line)
1074
-		echo ' * Updating Settings.php...';
1138
+	if ($command_line) {
1139
+			echo ' * Updating Settings.php...';
1140
+	}
1075 1141
 
1076 1142
 	// Fix some old paths.
1077
-	if (substr($boarddir, 0, 1) == '.')
1078
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1143
+	if (substr($boarddir, 0, 1) == '.') {
1144
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1145
+	}
1079 1146
 
1080
-	if (substr($sourcedir, 0, 1) == '.')
1081
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1147
+	if (substr($sourcedir, 0, 1) == '.') {
1148
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1149
+	}
1082 1150
 
1083
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1084
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1151
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1152
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1153
+	}
1085 1154
 
1086 1155
 	// Not had the database type added before?
1087
-	if (empty($db_type))
1088
-		$changes['db_type'] = 'mysql';
1156
+	if (empty($db_type)) {
1157
+			$changes['db_type'] = 'mysql';
1158
+	}
1089 1159
 
1090 1160
 	// If they have a "host:port" setup for the host, split that into separate values
1091 1161
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1096,32 +1166,36 @@  discard block
 block discarded – undo
1096 1166
 		$changes['db_server'] = '\'' . $db_server . '\'';
1097 1167
 
1098 1168
 		// Only set this if we're not using the default port
1099
-		if ($db_port != ini_get('mysqli.default_port'))
1100
-			$changes['db_port'] = (int) $db_port;
1101
-	}
1102
-	elseif (!empty($db_port))
1169
+		if ($db_port != ini_get('mysqli.default_port')) {
1170
+					$changes['db_port'] = (int) $db_port;
1171
+		}
1172
+	} elseif (!empty($db_port))
1103 1173
 	{
1104 1174
 		// If db_port is set and is the same as the default, set it to ''
1105 1175
 		if ($db_type == 'mysql')
1106 1176
 		{
1107
-			if ($db_port == ini_get('mysqli.default_port'))
1108
-				$changes['db_port'] = '\'\'';
1109
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1110
-				$changes['db_port'] = '\'\'';
1177
+			if ($db_port == ini_get('mysqli.default_port')) {
1178
+							$changes['db_port'] = '\'\'';
1179
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1180
+							$changes['db_port'] = '\'\'';
1181
+			}
1111 1182
 		}
1112 1183
 	}
1113 1184
 
1114 1185
 	// Maybe we haven't had this option yet?
1115
-	if (empty($packagesdir))
1116
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1186
+	if (empty($packagesdir)) {
1187
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1188
+	}
1117 1189
 
1118 1190
 	// Add support for $tasksdir var.
1119
-	if (empty($tasksdir))
1120
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1191
+	if (empty($tasksdir)) {
1192
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1193
+	}
1121 1194
 
1122 1195
 	// Make sure we fix the language as well.
1123
-	if (stristr($language, '-utf8'))
1124
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1196
+	if (stristr($language, '-utf8')) {
1197
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1198
+	}
1125 1199
 
1126 1200
 	// @todo Maybe change the cookie name if going to 1.1, too?
1127 1201
 
@@ -1129,8 +1203,9 @@  discard block
 block discarded – undo
1129 1203
 	require_once($sourcedir . '/Subs-Admin.php');
1130 1204
 	updateSettingsFile($changes);
1131 1205
 
1132
-	if ($command_line)
1133
-		echo ' Successful.' . "\n";
1206
+	if ($command_line) {
1207
+			echo ' Successful.' . "\n";
1208
+	}
1134 1209
 
1135 1210
 	// Are we doing debug?
1136 1211
 	if (isset($_POST['debug']))
@@ -1140,8 +1215,9 @@  discard block
 block discarded – undo
1140 1215
 	}
1141 1216
 
1142 1217
 	// If we're not backing up then jump one.
1143
-	if (empty($_POST['backup']))
1144
-		$upcontext['current_step']++;
1218
+	if (empty($_POST['backup'])) {
1219
+			$upcontext['current_step']++;
1220
+	}
1145 1221
 
1146 1222
 	// If we've got here then let's proceed to the next step!
1147 1223
 	return true;
@@ -1156,8 +1232,9 @@  discard block
 block discarded – undo
1156 1232
 	$upcontext['page_title'] = 'Backup Database';
1157 1233
 
1158 1234
 	// Done it already - js wise?
1159
-	if (!empty($_POST['backup_done']))
1160
-		return true;
1235
+	if (!empty($_POST['backup_done'])) {
1236
+			return true;
1237
+	}
1161 1238
 
1162 1239
 	// Some useful stuff here.
1163 1240
 	db_extend();
@@ -1171,9 +1248,10 @@  discard block
 block discarded – undo
1171 1248
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1172 1249
 
1173 1250
 	$table_names = array();
1174
-	foreach ($tables as $table)
1175
-		if (substr($table, 0, 7) !== 'backup_')
1251
+	foreach ($tables as $table) {
1252
+			if (substr($table, 0, 7) !== 'backup_')
1176 1253
 			$table_names[] = $table;
1254
+	}
1177 1255
 
1178 1256
 	$upcontext['table_count'] = count($table_names);
1179 1257
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1183,12 +1261,14 @@  discard block
 block discarded – undo
1183 1261
 	$file_steps = $upcontext['table_count'];
1184 1262
 
1185 1263
 	// What ones have we already done?
1186
-	foreach ($table_names as $id => $table)
1187
-		if ($id < $_GET['substep'])
1264
+	foreach ($table_names as $id => $table) {
1265
+			if ($id < $_GET['substep'])
1188 1266
 			$upcontext['previous_tables'][] = $table;
1267
+	}
1189 1268
 
1190
-	if ($command_line)
1191
-		echo 'Backing Up Tables.';
1269
+	if ($command_line) {
1270
+			echo 'Backing Up Tables.';
1271
+	}
1192 1272
 
1193 1273
 	// If we don't support javascript we backup here.
1194 1274
 	if (!$support_js || isset($_GET['xml']))
@@ -1207,8 +1287,9 @@  discard block
 block discarded – undo
1207 1287
 			backupTable($table_names[$substep]);
1208 1288
 
1209 1289
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1210
-			if (isset($_GET['xml']))
1211
-				return upgradeExit();
1290
+			if (isset($_GET['xml'])) {
1291
+							return upgradeExit();
1292
+			}
1212 1293
 		}
1213 1294
 
1214 1295
 		if ($command_line)
@@ -1241,9 +1322,10 @@  discard block
 block discarded – undo
1241 1322
 
1242 1323
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1243 1324
 
1244
-	if ($command_line)
1245
-		echo ' done.';
1246
-}
1325
+	if ($command_line) {
1326
+			echo ' done.';
1327
+	}
1328
+	}
1247 1329
 
1248 1330
 // Step 2: Everything.
1249 1331
 function DatabaseChanges()
@@ -1252,8 +1334,9 @@  discard block
 block discarded – undo
1252 1334
 	global $upcontext, $support_js, $db_type;
1253 1335
 
1254 1336
 	// Have we just completed this?
1255
-	if (!empty($_POST['database_done']))
1256
-		return true;
1337
+	if (!empty($_POST['database_done'])) {
1338
+			return true;
1339
+	}
1257 1340
 
1258 1341
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1259 1342
 	$upcontext['page_title'] = 'Database Changes';
@@ -1268,15 +1351,16 @@  discard block
 block discarded – undo
1268 1351
 	);
1269 1352
 
1270 1353
 	// How many files are there in total?
1271
-	if (isset($_GET['filecount']))
1272
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1273
-	else
1354
+	if (isset($_GET['filecount'])) {
1355
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1356
+	} else
1274 1357
 	{
1275 1358
 		$upcontext['file_count'] = 0;
1276 1359
 		foreach ($files as $file)
1277 1360
 		{
1278
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1279
-				$upcontext['file_count']++;
1361
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1362
+							$upcontext['file_count']++;
1363
+			}
1280 1364
 		}
1281 1365
 	}
1282 1366
 
@@ -1286,9 +1370,9 @@  discard block
 block discarded – undo
1286 1370
 	$upcontext['cur_file_num'] = 0;
1287 1371
 	foreach ($files as $file)
1288 1372
 	{
1289
-		if ($did_not_do)
1290
-			$did_not_do--;
1291
-		else
1373
+		if ($did_not_do) {
1374
+					$did_not_do--;
1375
+		} else
1292 1376
 		{
1293 1377
 			$upcontext['cur_file_num']++;
1294 1378
 			$upcontext['cur_file_name'] = $file[0];
@@ -1315,12 +1399,13 @@  discard block
 block discarded – undo
1315 1399
 					// Flag to move on to the next.
1316 1400
 					$upcontext['completed_step'] = true;
1317 1401
 					// Did we complete the whole file?
1318
-					if ($nextFile)
1319
-						$upcontext['current_debug_item_num'] = -1;
1402
+					if ($nextFile) {
1403
+											$upcontext['current_debug_item_num'] = -1;
1404
+					}
1320 1405
 					return upgradeExit();
1406
+				} elseif ($support_js) {
1407
+									break;
1321 1408
 				}
1322
-				elseif ($support_js)
1323
-					break;
1324 1409
 			}
1325 1410
 			// Set the progress bar to be right as if we had - even if we hadn't...
1326 1411
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1345,8 +1430,9 @@  discard block
 block discarded – undo
1345 1430
 	global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1346 1431
 
1347 1432
 	// Now it's nice to have some of the basic SMF source files.
1348
-	if (!isset($_GET['ssi']) && !$command_line)
1349
-		redirectLocation('&ssi=1');
1433
+	if (!isset($_GET['ssi']) && !$command_line) {
1434
+			redirectLocation('&ssi=1');
1435
+	}
1350 1436
 
1351 1437
 	$upcontext['sub_template'] = 'upgrade_complete';
1352 1438
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1362,14 +1448,16 @@  discard block
 block discarded – undo
1362 1448
 	// Are we in maintenance mode?
1363 1449
 	if (isset($upcontext['user']['main']))
1364 1450
 	{
1365
-		if ($command_line)
1366
-			echo ' * ';
1451
+		if ($command_line) {
1452
+					echo ' * ';
1453
+		}
1367 1454
 		$upcontext['removed_maintenance'] = true;
1368 1455
 		$changes['maintenance'] = $upcontext['user']['main'];
1369 1456
 	}
1370 1457
 	// Otherwise if somehow we are in 2 let's go to 1.
1371
-	elseif (!empty($maintenance) && $maintenance == 2)
1372
-		$changes['maintenance'] = 1;
1458
+	elseif (!empty($maintenance) && $maintenance == 2) {
1459
+			$changes['maintenance'] = 1;
1460
+	}
1373 1461
 
1374 1462
 	// Wipe this out...
1375 1463
 	$upcontext['user'] = array();
@@ -1384,9 +1472,9 @@  discard block
 block discarded – undo
1384 1472
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1385 1473
 
1386 1474
 	// Now is the perfect time to fetch the SM files.
1387
-	if ($command_line)
1388
-		cli_scheduled_fetchSMfiles();
1389
-	else
1475
+	if ($command_line) {
1476
+			cli_scheduled_fetchSMfiles();
1477
+	} else
1390 1478
 	{
1391 1479
 		require_once($sourcedir . '/ScheduledTasks.php');
1392 1480
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1394,8 +1482,9 @@  discard block
 block discarded – undo
1394 1482
 	}
1395 1483
 
1396 1484
 	// Log what we've done.
1397
-	if (empty($user_info['id']))
1398
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1485
+	if (empty($user_info['id'])) {
1486
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1487
+	}
1399 1488
 
1400 1489
 	// Log the action manually, so CLI still works.
1401 1490
 	$smcFunc['db_insert']('',
@@ -1414,8 +1503,9 @@  discard block
 block discarded – undo
1414 1503
 
1415 1504
 	// Save the current database version.
1416 1505
 	$server_version = $smcFunc['db_server_info']();
1417
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1418
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1506
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1507
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1508
+	}
1419 1509
 
1420 1510
 	if ($command_line)
1421 1511
 	{
@@ -1427,8 +1517,9 @@  discard block
 block discarded – undo
1427 1517
 
1428 1518
 	// Make sure it says we're done.
1429 1519
 	$upcontext['overall_percent'] = 100;
1430
-	if (isset($upcontext['step_progress']))
1431
-		unset($upcontext['step_progress']);
1520
+	if (isset($upcontext['step_progress'])) {
1521
+			unset($upcontext['step_progress']);
1522
+	}
1432 1523
 
1433 1524
 	$_GET['substep'] = 0;
1434 1525
 	return false;
@@ -1439,8 +1530,9 @@  discard block
 block discarded – undo
1439 1530
 {
1440 1531
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1441 1532
 
1442
-	if (empty($modSettings['time_format']))
1443
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1533
+	if (empty($modSettings['time_format'])) {
1534
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1535
+	}
1444 1536
 
1445 1537
 	// What files do we want to get
1446 1538
 	$request = $smcFunc['db_query']('', '
@@ -1474,8 +1566,9 @@  discard block
 block discarded – undo
1474 1566
 		$file_data = fetch_web_data($url);
1475 1567
 
1476 1568
 		// If we got an error - give up - the site might be down.
1477
-		if ($file_data === false)
1478
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1569
+		if ($file_data === false) {
1570
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1571
+		}
1479 1572
 
1480 1573
 		// Save the file to the database.
1481 1574
 		$smcFunc['db_query']('substring', '
@@ -1517,8 +1610,9 @@  discard block
 block discarded – undo
1517 1610
 	$themeData = array();
1518 1611
 	foreach ($values as $variable => $value)
1519 1612
 	{
1520
-		if (!isset($value) || $value === null)
1521
-			$value = 0;
1613
+		if (!isset($value) || $value === null) {
1614
+					$value = 0;
1615
+		}
1522 1616
 
1523 1617
 		$themeData[] = array(0, 1, $variable, $value);
1524 1618
 	}
@@ -1547,8 +1641,9 @@  discard block
 block discarded – undo
1547 1641
 
1548 1642
 	foreach ($values as $variable => $value)
1549 1643
 	{
1550
-		if (empty($modSettings[$value[0]]))
1551
-			continue;
1644
+		if (empty($modSettings[$value[0]])) {
1645
+					continue;
1646
+		}
1552 1647
 
1553 1648
 		$smcFunc['db_query']('', '
1554 1649
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1634,19 +1729,21 @@  discard block
 block discarded – undo
1634 1729
 	set_error_handler(
1635 1730
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1636 1731
 		{
1637
-			if ($support_js)
1638
-				return true;
1639
-			else
1640
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1732
+			if ($support_js) {
1733
+							return true;
1734
+			} else {
1735
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1736
+			}
1641 1737
 		}
1642 1738
 	);
1643 1739
 
1644 1740
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1645 1741
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1646
-	if ($db_type == 'mysql')
1647
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1648
-	else
1649
-		$db_collation = '';
1742
+	if ($db_type == 'mysql') {
1743
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1744
+	} else {
1745
+			$db_collation = '';
1746
+	}
1650 1747
 
1651 1748
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1652 1749
 
@@ -1658,8 +1755,9 @@  discard block
 block discarded – undo
1658 1755
 	$last_step = '';
1659 1756
 
1660 1757
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1661
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1662
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1758
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1759
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1760
+	}
1663 1761
 
1664 1762
 	// Count the total number of steps within this file - for progress.
1665 1763
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1679,15 +1777,18 @@  discard block
 block discarded – undo
1679 1777
 		$do_current = $substep >= $_GET['substep'];
1680 1778
 
1681 1779
 		// Get rid of any comments in the beginning of the line...
1682
-		if (substr(trim($line), 0, 2) === '/*')
1683
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1780
+		if (substr(trim($line), 0, 2) === '/*') {
1781
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1782
+		}
1684 1783
 
1685 1784
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1686
-		if ($is_debug && !$support_js && $command_line)
1687
-			flush();
1785
+		if ($is_debug && !$support_js && $command_line) {
1786
+					flush();
1787
+		}
1688 1788
 
1689
-		if (trim($line) === '')
1690
-			continue;
1789
+		if (trim($line) === '') {
1790
+					continue;
1791
+		}
1691 1792
 
1692 1793
 		if (trim(substr($line, 0, 3)) === '---')
1693 1794
 		{
@@ -1697,8 +1798,9 @@  discard block
 block discarded – undo
1697 1798
 			if (trim($current_data) != '' && $type !== '}')
1698 1799
 			{
1699 1800
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1700
-				if ($command_line)
1701
-					echo $upcontext['error_message'];
1801
+				if ($command_line) {
1802
+									echo $upcontext['error_message'];
1803
+				}
1702 1804
 			}
1703 1805
 
1704 1806
 			if ($type == ' ')
@@ -1716,17 +1818,18 @@  discard block
 block discarded – undo
1716 1818
 				if ($do_current)
1717 1819
 				{
1718 1820
 					$upcontext['actioned_items'][] = $last_step;
1719
-					if ($command_line)
1720
-						echo ' * ';
1821
+					if ($command_line) {
1822
+											echo ' * ';
1823
+					}
1721 1824
 				}
1722
-			}
1723
-			elseif ($type == '#')
1825
+			} elseif ($type == '#')
1724 1826
 			{
1725 1827
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1726 1828
 
1727 1829
 				$upcontext['current_debug_item_num']++;
1728
-				if (trim($line) != '---#')
1729
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1830
+				if (trim($line) != '---#') {
1831
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1832
+				}
1730 1833
 
1731 1834
 				// Have we already done something?
1732 1835
 				if (isset($_GET['xml']) && $done_something)
@@ -1737,34 +1840,36 @@  discard block
 block discarded – undo
1737 1840
 
1738 1841
 				if ($do_current)
1739 1842
 				{
1740
-					if (trim($line) == '---#' && $command_line)
1741
-						echo ' done.', $endl;
1742
-					elseif ($command_line)
1743
-						echo ' +++ ', rtrim(substr($line, 4));
1744
-					elseif (trim($line) != '---#')
1843
+					if (trim($line) == '---#' && $command_line) {
1844
+											echo ' done.', $endl;
1845
+					} elseif ($command_line) {
1846
+											echo ' +++ ', rtrim(substr($line, 4));
1847
+					} elseif (trim($line) != '---#')
1745 1848
 					{
1746
-						if ($is_debug)
1747
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1849
+						if ($is_debug) {
1850
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1851
+						}
1748 1852
 					}
1749 1853
 				}
1750 1854
 
1751 1855
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1752 1856
 				{
1753
-					if ($command_line)
1754
-						echo ' * ';
1755
-					else
1756
-						$upcontext['actioned_items'][] = $last_step;
1857
+					if ($command_line) {
1858
+											echo ' * ';
1859
+					} else {
1860
+											$upcontext['actioned_items'][] = $last_step;
1861
+					}
1757 1862
 				}
1758 1863
 
1759 1864
 				// Small step - only if we're actually doing stuff.
1760
-				if ($do_current)
1761
-					nextSubstep(++$substep);
1762
-				else
1763
-					$substep++;
1764
-			}
1765
-			elseif ($type == '{')
1766
-				$current_type = 'code';
1767
-			elseif ($type == '}')
1865
+				if ($do_current) {
1866
+									nextSubstep(++$substep);
1867
+				} else {
1868
+									$substep++;
1869
+				}
1870
+			} elseif ($type == '{') {
1871
+							$current_type = 'code';
1872
+			} elseif ($type == '}')
1768 1873
 			{
1769 1874
 				$current_type = 'sql';
1770 1875
 
@@ -1777,8 +1882,9 @@  discard block
 block discarded – undo
1777 1882
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1778 1883
 				{
1779 1884
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1780
-					if ($command_line)
1781
-						echo $upcontext['error_message'];
1885
+					if ($command_line) {
1886
+											echo $upcontext['error_message'];
1887
+					}
1782 1888
 				}
1783 1889
 
1784 1890
 				// Done with code!
@@ -1858,8 +1964,9 @@  discard block
 block discarded – undo
1858 1964
 	$db_unbuffered = false;
1859 1965
 
1860 1966
 	// Failure?!
1861
-	if ($result !== false)
1862
-		return $result;
1967
+	if ($result !== false) {
1968
+			return $result;
1969
+	}
1863 1970
 
1864 1971
 	$db_error_message = $smcFunc['db_error']($db_connection);
1865 1972
 	// If MySQL we do something more clever.
@@ -1887,54 +1994,61 @@  discard block
 block discarded – undo
1887 1994
 			{
1888 1995
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
1889 1996
 				$result = mysqli_query($db_connection, $string);
1890
-				if ($result !== false)
1891
-					return $result;
1997
+				if ($result !== false) {
1998
+									return $result;
1999
+				}
1892 2000
 			}
1893
-		}
1894
-		elseif ($mysqli_errno == 2013)
2001
+		} elseif ($mysqli_errno == 2013)
1895 2002
 		{
1896 2003
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
1897 2004
 			mysqli_select_db($db_connection, $db_name);
1898 2005
 			if ($db_connection)
1899 2006
 			{
1900 2007
 				$result = mysqli_query($db_connection, $string);
1901
-				if ($result !== false)
1902
-					return $result;
2008
+				if ($result !== false) {
2009
+									return $result;
2010
+				}
1903 2011
 			}
1904 2012
 		}
1905 2013
 		// Duplicate column name... should be okay ;).
1906
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
1907
-			return false;
2014
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2015
+					return false;
2016
+		}
1908 2017
 		// Duplicate insert... make sure it's the proper type of query ;).
1909
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
1910
-			return false;
2018
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2019
+					return false;
2020
+		}
1911 2021
 		// Creating an index on a non-existent column.
1912
-		elseif ($mysqli_errno == 1072)
1913
-			return false;
1914
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
1915
-			return false;
2022
+		elseif ($mysqli_errno == 1072) {
2023
+					return false;
2024
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2025
+					return false;
2026
+		}
1916 2027
 	}
1917 2028
 	// If a table already exists don't go potty.
1918 2029
 	else
1919 2030
 	{
1920 2031
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
1921 2032
 		{
1922
-			if (strpos($db_error_message, 'exist') !== false)
1923
-				return true;
1924
-		}
1925
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2033
+			if (strpos($db_error_message, 'exist') !== false) {
2034
+							return true;
2035
+			}
2036
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
1926 2037
 		{
1927
-			if (strpos($db_error_message, 'duplicate') !== false)
1928
-				return true;
2038
+			if (strpos($db_error_message, 'duplicate') !== false) {
2039
+							return true;
2040
+			}
1929 2041
 		}
1930 2042
 	}
1931 2043
 
1932 2044
 	// Get the query string so we pass everything.
1933 2045
 	$query_string = '';
1934
-	foreach ($_GET as $k => $v)
1935
-		$query_string .= ';' . $k . '=' . $v;
1936
-	if (strlen($query_string) != 0)
1937
-		$query_string = '?' . substr($query_string, 1);
2046
+	foreach ($_GET as $k => $v) {
2047
+			$query_string .= ';' . $k . '=' . $v;
2048
+	}
2049
+	if (strlen($query_string) != 0) {
2050
+			$query_string = '?' . substr($query_string, 1);
2051
+	}
1938 2052
 
1939 2053
 	if ($command_line)
1940 2054
 	{
@@ -1989,16 +2103,18 @@  discard block
 block discarded – undo
1989 2103
 			{
1990 2104
 				$found |= 1;
1991 2105
 				// Do some checks on the data if we have it set.
1992
-				if (isset($change['col_type']))
1993
-					$found &= $change['col_type'] === $column['type'];
1994
-				if (isset($change['null_allowed']))
1995
-					$found &= $column['null'] == $change['null_allowed'];
1996
-				if (isset($change['default']))
1997
-					$found &= $change['default'] === $column['default'];
2106
+				if (isset($change['col_type'])) {
2107
+									$found &= $change['col_type'] === $column['type'];
2108
+				}
2109
+				if (isset($change['null_allowed'])) {
2110
+									$found &= $column['null'] == $change['null_allowed'];
2111
+				}
2112
+				if (isset($change['default'])) {
2113
+									$found &= $change['default'] === $column['default'];
2114
+				}
1998 2115
 			}
1999 2116
 		}
2000
-	}
2001
-	elseif ($change['type'] === 'index')
2117
+	} elseif ($change['type'] === 'index')
2002 2118
 	{
2003 2119
 		$request = upgrade_query('
2004 2120
 			SHOW INDEX
@@ -2007,9 +2123,10 @@  discard block
 block discarded – undo
2007 2123
 		{
2008 2124
 			$cur_index = array();
2009 2125
 
2010
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2011
-				if ($row['Key_name'] === $change['name'])
2126
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2127
+							if ($row['Key_name'] === $change['name'])
2012 2128
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2129
+			}
2013 2130
 
2014 2131
 			ksort($cur_index, SORT_NUMERIC);
2015 2132
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2019,14 +2136,17 @@  discard block
 block discarded – undo
2019 2136
 	}
2020 2137
 
2021 2138
 	// If we're trying to add and it's added, we're done.
2022
-	if ($found && in_array($change['method'], array('add', 'change')))
2023
-		return true;
2139
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2140
+			return true;
2141
+	}
2024 2142
 	// Otherwise if we're removing and it wasn't found we're also done.
2025
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2026
-		return true;
2143
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2144
+			return true;
2145
+	}
2027 2146
 	// Otherwise is it just a test?
2028
-	elseif ($is_test)
2029
-		return false;
2147
+	elseif ($is_test) {
2148
+			return false;
2149
+	}
2030 2150
 
2031 2151
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2032 2152
 	$running = false;
@@ -2037,8 +2157,9 @@  discard block
 block discarded – undo
2037 2157
 			SHOW FULL PROCESSLIST');
2038 2158
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2039 2159
 		{
2040
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2041
-				$found = true;
2160
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2161
+							$found = true;
2162
+			}
2042 2163
 		}
2043 2164
 
2044 2165
 		// Can't find it? Then we need to run it fools!
@@ -2050,8 +2171,9 @@  discard block
 block discarded – undo
2050 2171
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2051 2172
 				' . $change['text'], true) !== false;
2052 2173
 
2053
-			if (!$success)
2054
-				return false;
2174
+			if (!$success) {
2175
+							return false;
2176
+			}
2055 2177
 
2056 2178
 			// Return
2057 2179
 			$running = true;
@@ -2093,8 +2215,9 @@  discard block
 block discarded – undo
2093 2215
 			'db_error_skip' => true,
2094 2216
 		)
2095 2217
 	);
2096
-	if ($smcFunc['db_num_rows']($request) === 0)
2097
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2218
+	if ($smcFunc['db_num_rows']($request) === 0) {
2219
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2220
+	}
2098 2221
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2099 2222
 	$smcFunc['db_free_result']($request);
2100 2223
 
@@ -2116,18 +2239,19 @@  discard block
 block discarded – undo
2116 2239
 			)
2117 2240
 		);
2118 2241
 		// No results? Just forget it all together.
2119
-		if ($smcFunc['db_num_rows']($request) === 0)
2120
-			unset($table_row['Collation']);
2121
-		else
2122
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2242
+		if ($smcFunc['db_num_rows']($request) === 0) {
2243
+					unset($table_row['Collation']);
2244
+		} else {
2245
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2246
+		}
2123 2247
 		$smcFunc['db_free_result']($request);
2124 2248
 	}
2125 2249
 
2126 2250
 	if ($column_fix)
2127 2251
 	{
2128 2252
 		// Make sure there are no NULL's left.
2129
-		if ($null_fix)
2130
-			$smcFunc['db_query']('', '
2253
+		if ($null_fix) {
2254
+					$smcFunc['db_query']('', '
2131 2255
 				UPDATE {db_prefix}' . $change['table'] . '
2132 2256
 				SET ' . $change['column'] . ' = {string:default}
2133 2257
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2136,6 +2260,7 @@  discard block
 block discarded – undo
2136 2260
 					'db_error_skip' => true,
2137 2261
 				)
2138 2262
 			);
2263
+		}
2139 2264
 
2140 2265
 		// Do the actual alteration.
2141 2266
 		$smcFunc['db_query']('', '
@@ -2164,8 +2289,9 @@  discard block
 block discarded – undo
2164 2289
 	}
2165 2290
 
2166 2291
 	// Not a column we need to check on?
2167
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2168
-		return;
2292
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2293
+			return;
2294
+	}
2169 2295
 
2170 2296
 	// Break it up you (six|seven).
2171 2297
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2184,13 +2310,13 @@  discard block
 block discarded – undo
2184 2310
 				'new_name' => $temp[2],
2185 2311
 		));
2186 2312
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2187
-		if ($smcFunc['db_num_rows'] != 1)
2188
-			return;
2313
+		if ($smcFunc['db_num_rows'] != 1) {
2314
+					return;
2315
+		}
2189 2316
 
2190 2317
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2191 2318
 		$smcFunc['db_free_result']($request);
2192
-	}
2193
-	else
2319
+	} else
2194 2320
 	{
2195 2321
 		// Do this the old fashion, sure method way.
2196 2322
 		$request = $smcFunc['db_query']('', '
@@ -2201,21 +2327,24 @@  discard block
 block discarded – undo
2201 2327
 		));
2202 2328
 		// Mayday!
2203 2329
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2204
-		if ($smcFunc['db_num_rows'] == 0)
2205
-			return;
2330
+		if ($smcFunc['db_num_rows'] == 0) {
2331
+					return;
2332
+		}
2206 2333
 
2207 2334
 		// Oh where, oh where has my little field gone. Oh where can it be...
2208
-		while ($row = $smcFunc['db_query']($request))
2209
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2335
+		while ($row = $smcFunc['db_query']($request)) {
2336
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2210 2337
 			{
2211 2338
 				$current_type = $row['Type'];
2339
+		}
2212 2340
 				break;
2213 2341
 			}
2214 2342
 	}
2215 2343
 
2216 2344
 	// If this doesn't match, the column may of been altered for a reason.
2217
-	if (trim($current_type) != trim($temp[3]))
2218
-		$temp[3] = $current_type;
2345
+	if (trim($current_type) != trim($temp[3])) {
2346
+			$temp[3] = $current_type;
2347
+	}
2219 2348
 
2220 2349
 	// Piece this back together.
2221 2350
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2227,8 +2356,9 @@  discard block
 block discarded – undo
2227 2356
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2228 2357
 	global $step_progress, $is_debug, $upcontext;
2229 2358
 
2230
-	if ($_GET['substep'] < $substep)
2231
-		$_GET['substep'] = $substep;
2359
+	if ($_GET['substep'] < $substep) {
2360
+			$_GET['substep'] = $substep;
2361
+	}
2232 2362
 
2233 2363
 	if ($command_line)
2234 2364
 	{
@@ -2241,29 +2371,33 @@  discard block
 block discarded – undo
2241 2371
 	}
2242 2372
 
2243 2373
 	@set_time_limit(300);
2244
-	if (function_exists('apache_reset_timeout'))
2245
-		@apache_reset_timeout();
2374
+	if (function_exists('apache_reset_timeout')) {
2375
+			@apache_reset_timeout();
2376
+	}
2246 2377
 
2247
-	if (time() - $start_time <= $timeLimitThreshold)
2248
-		return;
2378
+	if (time() - $start_time <= $timeLimitThreshold) {
2379
+			return;
2380
+	}
2249 2381
 
2250 2382
 	// Do we have some custom step progress stuff?
2251 2383
 	if (!empty($step_progress))
2252 2384
 	{
2253 2385
 		$upcontext['substep_progress'] = 0;
2254 2386
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2255
-		if ($step_progress['current'] > $step_progress['total'])
2256
-			$upcontext['substep_progress'] = 99.9;
2257
-		else
2258
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2387
+		if ($step_progress['current'] > $step_progress['total']) {
2388
+					$upcontext['substep_progress'] = 99.9;
2389
+		} else {
2390
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2391
+		}
2259 2392
 
2260 2393
 		// Make it nicely rounded.
2261 2394
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2262 2395
 	}
2263 2396
 
2264 2397
 	// If this is XML we just exit right away!
2265
-	if (isset($_GET['xml']))
2266
-		return upgradeExit();
2398
+	if (isset($_GET['xml'])) {
2399
+			return upgradeExit();
2400
+	}
2267 2401
 
2268 2402
 	// We're going to pause after this!
2269 2403
 	$upcontext['pause'] = true;
@@ -2271,13 +2405,15 @@  discard block
 block discarded – undo
2271 2405
 	$upcontext['query_string'] = '';
2272 2406
 	foreach ($_GET as $k => $v)
2273 2407
 	{
2274
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2275
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2408
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2409
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2410
+		}
2276 2411
 	}
2277 2412
 
2278 2413
 	// Custom warning?
2279
-	if (!empty($custom_warning))
2280
-		$upcontext['custom_warning'] = $custom_warning;
2414
+	if (!empty($custom_warning)) {
2415
+			$upcontext['custom_warning'] = $custom_warning;
2416
+	}
2281 2417
 
2282 2418
 	upgradeExit();
2283 2419
 }
@@ -2292,25 +2428,26 @@  discard block
 block discarded – undo
2292 2428
 	ob_implicit_flush(true);
2293 2429
 	@set_time_limit(600);
2294 2430
 
2295
-	if (!isset($_SERVER['argv']))
2296
-		$_SERVER['argv'] = array();
2431
+	if (!isset($_SERVER['argv'])) {
2432
+			$_SERVER['argv'] = array();
2433
+	}
2297 2434
 	$_GET['maint'] = 1;
2298 2435
 
2299 2436
 	foreach ($_SERVER['argv'] as $i => $arg)
2300 2437
 	{
2301
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2302
-			$_GET['lang'] = $match[1];
2303
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2304
-			continue;
2305
-		elseif ($arg == '--no-maintenance')
2306
-			$_GET['maint'] = 0;
2307
-		elseif ($arg == '--debug')
2308
-			$is_debug = true;
2309
-		elseif ($arg == '--backup')
2310
-			$_POST['backup'] = 1;
2311
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2312
-			$_GET['conv'] = 1;
2313
-		elseif ($i != 0)
2438
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2439
+					$_GET['lang'] = $match[1];
2440
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2441
+					continue;
2442
+		} elseif ($arg == '--no-maintenance') {
2443
+					$_GET['maint'] = 0;
2444
+		} elseif ($arg == '--debug') {
2445
+					$is_debug = true;
2446
+		} elseif ($arg == '--backup') {
2447
+					$_POST['backup'] = 1;
2448
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2449
+					$_GET['conv'] = 1;
2450
+		} elseif ($i != 0)
2314 2451
 		{
2315 2452
 			echo 'SMF Command-line Upgrader
2316 2453
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2324,10 +2461,12 @@  discard block
 block discarded – undo
2324 2461
 		}
2325 2462
 	}
2326 2463
 
2327
-	if (!php_version_check())
2328
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2329
-	if (!db_version_check())
2330
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2464
+	if (!php_version_check()) {
2465
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2466
+	}
2467
+	if (!db_version_check()) {
2468
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2469
+	}
2331 2470
 
2332 2471
 	// Do some checks to make sure they have proper privileges
2333 2472
 	db_extend('packages');
@@ -2342,34 +2481,39 @@  discard block
 block discarded – undo
2342 2481
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2343 2482
 
2344 2483
 	// Sorry... we need CREATE, ALTER and DROP
2345
-	if (!$create || !$alter || !$drop)
2346
-		print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true);
2484
+	if (!$create || !$alter || !$drop) {
2485
+			print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true);
2486
+	}
2347 2487
 
2348 2488
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2349 2489
 		&& @file_exists($sourcedir . '/QueryString.php')
2350 2490
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2351
-	if (!$check && !isset($modSettings['smfVersion']))
2352
-		print_error('Error: Some files are missing or out-of-date.', true);
2491
+	if (!$check && !isset($modSettings['smfVersion'])) {
2492
+			print_error('Error: Some files are missing or out-of-date.', true);
2493
+	}
2353 2494
 
2354 2495
 	// Do a quick version spot check.
2355 2496
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2356 2497
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2357
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2358
-		print_error('Error: Some files have not yet been updated properly.');
2498
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2499
+			print_error('Error: Some files have not yet been updated properly.');
2500
+	}
2359 2501
 
2360 2502
 	// Make sure Settings.php is writable.
2361 2503
 		quickFileWritable($boarddir . '/Settings.php');
2362
-	if (!is_writable($boarddir . '/Settings.php'))
2363
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2504
+	if (!is_writable($boarddir . '/Settings.php')) {
2505
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2506
+	}
2364 2507
 
2365 2508
 	// Make sure Settings_bak.php is writable.
2366 2509
 		quickFileWritable($boarddir . '/Settings_bak.php');
2367
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2368
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2510
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2511
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2512
+	}
2369 2513
 
2370
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2371
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2372
-	elseif (isset($modSettings['agreement']))
2514
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2515
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2516
+	} elseif (isset($modSettings['agreement']))
2373 2517
 	{
2374 2518
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2375 2519
 		fwrite($fp, $modSettings['agreement']);
@@ -2379,31 +2523,36 @@  discard block
 block discarded – undo
2379 2523
 	// Make sure Themes is writable.
2380 2524
 	quickFileWritable($modSettings['theme_dir']);
2381 2525
 
2382
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2383
-		print_error('Error: Unable to obtain write access to "Themes".');
2526
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2527
+			print_error('Error: Unable to obtain write access to "Themes".');
2528
+	}
2384 2529
 
2385 2530
 	// Make sure cache directory exists and is writable!
2386 2531
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2387
-	if (!file_exists($cachedir_temp))
2388
-		@mkdir($cachedir_temp);
2532
+	if (!file_exists($cachedir_temp)) {
2533
+			@mkdir($cachedir_temp);
2534
+	}
2389 2535
 
2390 2536
 	// Make sure the cache temp dir is writable.
2391 2537
 	quickFileWritable($cachedir_temp);
2392 2538
 
2393
-	if (!is_writable($cachedir_temp))
2394
-		print_error('Error: Unable to obtain write access to "cache".', true);
2539
+	if (!is_writable($cachedir_temp)) {
2540
+			print_error('Error: Unable to obtain write access to "cache".', true);
2541
+	}
2395 2542
 
2396
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2397
-		print_error('Error: Unable to find language files!', true);
2398
-	else
2543
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2544
+			print_error('Error: Unable to find language files!', true);
2545
+	} else
2399 2546
 	{
2400 2547
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2401 2548
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2402 2549
 
2403
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2404
-			print_error('Error: Language files out of date.', true);
2405
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2406
-			print_error('Error: Install language is missing for selected language.', true);
2550
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2551
+					print_error('Error: Language files out of date.', true);
2552
+		}
2553
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2554
+					print_error('Error: Install language is missing for selected language.', true);
2555
+		}
2407 2556
 
2408 2557
 		// Otherwise include it!
2409 2558
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2422,8 +2571,9 @@  discard block
 block discarded – undo
2422 2571
 	global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js;
2423 2572
 
2424 2573
 	// Done it already?
2425
-	if (!empty($_POST['utf8_done']))
2426
-		return true;
2574
+	if (!empty($_POST['utf8_done'])) {
2575
+			return true;
2576
+	}
2427 2577
 
2428 2578
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2429 2579
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2436,8 +2586,7 @@  discard block
 block discarded – undo
2436 2586
 		);
2437 2587
 
2438 2588
 		return true;
2439
-	}
2440
-	else
2589
+	} else
2441 2590
 	{
2442 2591
 		$upcontext['page_title'] = 'Converting to UTF8';
2443 2592
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2481,8 +2630,9 @@  discard block
 block discarded – undo
2481 2630
 			)
2482 2631
 		);
2483 2632
 		$db_charsets = array();
2484
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2485
-			$db_charsets[] = $row['Charset'];
2633
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2634
+					$db_charsets[] = $row['Charset'];
2635
+		}
2486 2636
 
2487 2637
 		$smcFunc['db_free_result']($request);
2488 2638
 
@@ -2518,13 +2668,15 @@  discard block
 block discarded – undo
2518 2668
 		// If there's a fulltext index, we need to drop it first...
2519 2669
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2520 2670
 		{
2521
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2522
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2671
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2672
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2523 2673
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2674
+			}
2524 2675
 			$smcFunc['db_free_result']($request);
2525 2676
 
2526
-			if (isset($upcontext['fulltext_index']))
2527
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2677
+			if (isset($upcontext['fulltext_index'])) {
2678
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2679
+			}
2528 2680
 		}
2529 2681
 
2530 2682
 		// Drop it and make a note...
@@ -2714,8 +2866,9 @@  discard block
 block discarded – undo
2714 2866
 			$replace = '%field%';
2715 2867
 
2716 2868
 			// Build a huge REPLACE statement...
2717
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2718
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2869
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2870
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2871
+			}
2719 2872
 		}
2720 2873
 
2721 2874
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2725,9 +2878,10 @@  discard block
 block discarded – undo
2725 2878
 		$upcontext['table_count'] = count($queryTables);
2726 2879
 
2727 2880
 		// What ones have we already done?
2728
-		foreach ($queryTables as $id => $table)
2729
-			if ($id < $_GET['substep'])
2881
+		foreach ($queryTables as $id => $table) {
2882
+					if ($id < $_GET['substep'])
2730 2883
 				$upcontext['previous_tables'][] = $table;
2884
+		}
2731 2885
 
2732 2886
 		$upcontext['cur_table_num'] = $_GET['substep'];
2733 2887
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2764,8 +2918,9 @@  discard block
 block discarded – undo
2764 2918
 			nextSubstep($substep);
2765 2919
 
2766 2920
 			// Just to make sure it doesn't time out.
2767
-			if (function_exists('apache_reset_timeout'))
2768
-				@apache_reset_timeout();
2921
+			if (function_exists('apache_reset_timeout')) {
2922
+							@apache_reset_timeout();
2923
+			}
2769 2924
 
2770 2925
 			$table_charsets = array();
2771 2926
 
@@ -2788,8 +2943,9 @@  discard block
 block discarded – undo
2788 2943
 
2789 2944
 						// Build structure of columns to operate on organized by charset; only operate on columns not yet utf8
2790 2945
 						if ($charset != 'utf8') {
2791
-							if (!isset($table_charsets[$charset]))
2792
-								$table_charsets[$charset] = array();
2946
+							if (!isset($table_charsets[$charset])) {
2947
+															$table_charsets[$charset] = array();
2948
+							}
2793 2949
 
2794 2950
 							$table_charsets[$charset][] = $column_info;
2795 2951
 						}
@@ -2830,10 +2986,11 @@  discard block
 block discarded – undo
2830 2986
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2831 2987
 				{
2832 2988
 					$update = '';
2833
-					foreach ($table_charsets as $charset => $columns)
2834
-						foreach ($columns as $column)
2989
+					foreach ($table_charsets as $charset => $columns) {
2990
+											foreach ($columns as $column)
2835 2991
 							$update .= '
2836 2992
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
2993
+					}
2837 2994
 
2838 2995
 					$smcFunc['db_query']('', '
2839 2996
 						UPDATE {raw:table_name}
@@ -2858,8 +3015,9 @@  discard block
 block discarded – undo
2858 3015
 			// Now do the actual conversion (if still needed).
2859 3016
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2860 3017
 			{
2861
-				if ($command_line)
2862
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3018
+				if ($command_line) {
3019
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3020
+				}
2863 3021
 
2864 3022
 				$smcFunc['db_query']('', '
2865 3023
 					ALTER TABLE {raw:table_name}
@@ -2869,12 +3027,14 @@  discard block
 block discarded – undo
2869 3027
 					)
2870 3028
 				);
2871 3029
 
2872
-				if ($command_line)
2873
-					echo " done.\n";
3030
+				if ($command_line) {
3031
+									echo " done.\n";
3032
+				}
2874 3033
 			}
2875 3034
 			// If this is XML to keep it nice for the user do one table at a time anyway!
2876
-			if (isset($_GET['xml']))
2877
-				return upgradeExit();
3035
+			if (isset($_GET['xml'])) {
3036
+							return upgradeExit();
3037
+			}
2878 3038
 		}
2879 3039
 
2880 3040
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -2903,8 +3063,8 @@  discard block
 block discarded – undo
2903 3063
 		);
2904 3064
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2905 3065
 		{
2906
-			if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1)
2907
-				$smcFunc['db_query']('', '
3066
+			if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) {
3067
+							$smcFunc['db_query']('', '
2908 3068
 					UPDATE {db_prefix}log_actions
2909 3069
 					SET extra = {string:extra}
2910 3070
 					WHERE id_action = {int:current_action}',
@@ -2913,6 +3073,7 @@  discard block
 block discarded – undo
2913 3073
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
2914 3074
 					)
2915 3075
 				);
3076
+			}
2916 3077
 		}
2917 3078
 		$smcFunc['db_free_result']($request);
2918 3079
 
@@ -2934,15 +3095,17 @@  discard block
 block discarded – undo
2934 3095
 	// First thing's first - did we already do this?
2935 3096
 	if (!empty($modSettings['json_done']))
2936 3097
 	{
2937
-		if ($command_line)
2938
-			return DeleteUpgrade();
2939
-		else
2940
-			return true;
3098
+		if ($command_line) {
3099
+					return DeleteUpgrade();
3100
+		} else {
3101
+					return true;
3102
+		}
2941 3103
 	}
2942 3104
 
2943 3105
 	// Done it already - js wise?
2944
-	if (!empty($_POST['json_done']))
2945
-		return true;
3106
+	if (!empty($_POST['json_done'])) {
3107
+			return true;
3108
+	}
2946 3109
 
2947 3110
 	// List of tables affected by this function
2948 3111
 	// name => array('key', col1[,col2|true[,col3]])
@@ -2974,12 +3137,14 @@  discard block
 block discarded – undo
2974 3137
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
2975 3138
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2976 3139
 
2977
-	foreach ($keys as $id => $table)
2978
-		if ($id < $_GET['substep'])
3140
+	foreach ($keys as $id => $table) {
3141
+			if ($id < $_GET['substep'])
2979 3142
 			$upcontext['previous_tables'][] = $table;
3143
+	}
2980 3144
 
2981
-	if ($command_line)
2982
-		echo 'Converting data from serialize() to json_encode().';
3145
+	if ($command_line) {
3146
+			echo 'Converting data from serialize() to json_encode().';
3147
+	}
2983 3148
 
2984 3149
 	if (!$support_js || isset($_GET['xml']))
2985 3150
 	{
@@ -3019,8 +3184,9 @@  discard block
 block discarded – undo
3019 3184
 
3020 3185
 				// Loop through and fix these...
3021 3186
 				$new_settings = array();
3022
-				if ($command_line)
3023
-					echo "\n" . 'Fixing some settings...';
3187
+				if ($command_line) {
3188
+									echo "\n" . 'Fixing some settings...';
3189
+				}
3024 3190
 
3025 3191
 				foreach ($serialized_settings as $var)
3026 3192
 				{
@@ -3028,22 +3194,24 @@  discard block
 block discarded – undo
3028 3194
 					{
3029 3195
 						// Attempt to unserialize the setting
3030 3196
 						$temp = @safe_unserialize($modSettings[$var]);
3031
-						if (!$temp && $command_line)
3032
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3033
-						elseif ($temp !== false)
3034
-							$new_settings[$var] = json_encode($temp);
3197
+						if (!$temp && $command_line) {
3198
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3199
+						} elseif ($temp !== false) {
3200
+													$new_settings[$var] = json_encode($temp);
3201
+						}
3035 3202
 					}
3036 3203
 				}
3037 3204
 
3038 3205
 				// Update everything at once
3039
-				if (!function_exists('cache_put_data'))
3040
-					require_once($sourcedir . '/Load.php');
3206
+				if (!function_exists('cache_put_data')) {
3207
+									require_once($sourcedir . '/Load.php');
3208
+				}
3041 3209
 				updateSettings($new_settings, true);
3042 3210
 
3043
-				if ($command_line)
3044
-					echo ' done.';
3045
-			}
3046
-			elseif ($table == 'themes')
3211
+				if ($command_line) {
3212
+									echo ' done.';
3213
+				}
3214
+			} elseif ($table == 'themes')
3047 3215
 			{
3048 3216
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3049 3217
 				$query = $smcFunc['db_query']('', '
@@ -3062,10 +3230,11 @@  discard block
 block discarded – undo
3062 3230
 
3063 3231
 						if ($command_line)
3064 3232
 						{
3065
-							if ($temp === false)
3066
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3067
-							else
3068
-								echo "\n" . 'Fixing admin preferences...';
3233
+							if ($temp === false) {
3234
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3235
+							} else {
3236
+															echo "\n" . 'Fixing admin preferences...';
3237
+							}
3069 3238
 						}
3070 3239
 
3071 3240
 						if ($temp !== false)
@@ -3087,15 +3256,15 @@  discard block
 block discarded – undo
3087 3256
 								)
3088 3257
 							);
3089 3258
 
3090
-							if ($command_line)
3091
-								echo ' done.';
3259
+							if ($command_line) {
3260
+															echo ' done.';
3261
+							}
3092 3262
 						}
3093 3263
 					}
3094 3264
 
3095 3265
 					$smcFunc['db_free_result']($query);
3096 3266
 				}
3097
-			}
3098
-			else
3267
+			} else
3099 3268
 			{
3100 3269
 				// First item is always the key...
3101 3270
 				$key = $info[0];
@@ -3106,8 +3275,7 @@  discard block
 block discarded – undo
3106 3275
 				{
3107 3276
 					$col_select = $info[1];
3108 3277
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3109
-				}
3110
-				else
3278
+				} else
3111 3279
 				{
3112 3280
 					$col_select = implode(', ', $info);
3113 3281
 				}
@@ -3140,8 +3308,7 @@  discard block
 block discarded – undo
3140 3308
 								if ($temp === false && $command_line)
3141 3309
 								{
3142 3310
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3143
-								}
3144
-								else
3311
+								} else
3145 3312
 								{
3146 3313
 									$row[$col] = json_encode($temp);
3147 3314
 
@@ -3166,16 +3333,18 @@  discard block
 block discarded – undo
3166 3333
 						}
3167 3334
 					}
3168 3335
 
3169
-					if ($command_line)
3170
-						echo ' done.';
3336
+					if ($command_line) {
3337
+											echo ' done.';
3338
+					}
3171 3339
 
3172 3340
 					// Free up some memory...
3173 3341
 					$smcFunc['db_free_result']($query);
3174 3342
 				}
3175 3343
 			}
3176 3344
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3177
-			if (isset($_GET['xml']))
3178
-				return upgradeExit();
3345
+			if (isset($_GET['xml'])) {
3346
+							return upgradeExit();
3347
+			}
3179 3348
 		}
3180 3349
 
3181 3350
 		if ($command_line)
@@ -3190,8 +3359,9 @@  discard block
 block discarded – undo
3190 3359
 
3191 3360
 		$_GET['substep'] = 0;
3192 3361
 		// Make sure we move on!
3193
-		if ($command_line)
3194
-			return DeleteUpgrade();
3362
+		if ($command_line) {
3363
+					return DeleteUpgrade();
3364
+		}
3195 3365
 
3196 3366
 		return true;
3197 3367
 	}
@@ -3211,14 +3381,16 @@  discard block
 block discarded – undo
3211 3381
 	global $upcontext, $txt, $settings;
3212 3382
 
3213 3383
 	// Don't call me twice!
3214
-	if (!empty($upcontext['chmod_called']))
3215
-		return;
3384
+	if (!empty($upcontext['chmod_called'])) {
3385
+			return;
3386
+	}
3216 3387
 
3217 3388
 	$upcontext['chmod_called'] = true;
3218 3389
 
3219 3390
 	// Nothing?
3220
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3221
-		return;
3391
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3392
+			return;
3393
+	}
3222 3394
 
3223 3395
 	// Was it a problem with Windows?
3224 3396
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3250,11 +3422,12 @@  discard block
 block discarded – undo
3250 3422
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\');
3251 3423
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3252 3424
 
3253
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3254
-		echo '
3425
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3426
+			echo '
3255 3427
 					content.write(\'<hr>\n\t\t\t\');
3256 3428
 					content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\');
3257 3429
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3430
+	}
3258 3431
 
3259 3432
 	echo '
3260 3433
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3262,17 +3435,19 @@  discard block
 block discarded – undo
3262 3435
 				}
3263 3436
 			</script>';
3264 3437
 
3265
-	if (!empty($upcontext['chmod']['ftp_error']))
3266
-		echo '
3438
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3439
+			echo '
3267 3440
 			<div class="error_message red">
3268 3441
 				The following error was encountered when trying to connect:<br><br>
3269 3442
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3270 3443
 			</div>
3271 3444
 			<br>';
3445
+	}
3272 3446
 
3273
-	if (empty($upcontext['chmod_in_form']))
3274
-		echo '
3447
+	if (empty($upcontext['chmod_in_form'])) {
3448
+			echo '
3275 3449
 	<form action="', $upcontext['form_url'], '" method="post">';
3450
+	}
3276 3451
 
3277 3452
 	echo '
3278 3453
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3307,10 +3482,11 @@  discard block
 block discarded – undo
3307 3482
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
3308 3483
 	</div>';
3309 3484
 
3310
-	if (empty($upcontext['chmod_in_form']))
3311
-		echo '
3485
+	if (empty($upcontext['chmod_in_form'])) {
3486
+			echo '
3312 3487
 	</form>';
3313
-}
3488
+	}
3489
+	}
3314 3490
 
3315 3491
 function template_upgrade_above()
3316 3492
 {
@@ -3370,9 +3546,10 @@  discard block
 block discarded – undo
3370 3546
 				<h2>', $txt['upgrade_progress'], '</h2>
3371 3547
 				<ul>';
3372 3548
 
3373
-	foreach ($upcontext['steps'] as $num => $step)
3374
-		echo '
3549
+	foreach ($upcontext['steps'] as $num => $step) {
3550
+			echo '
3375 3551
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3552
+	}
3376 3553
 
3377 3554
 	echo '
3378 3555
 					</ul>
@@ -3385,8 +3562,8 @@  discard block
 block discarded – undo
3385 3562
 				</div>
3386 3563
 			</div>';
3387 3564
 
3388
-	if (isset($upcontext['step_progress']))
3389
-		echo '
3565
+	if (isset($upcontext['step_progress'])) {
3566
+			echo '
3390 3567
 				<br>
3391 3568
 				<br>
3392 3569
 				<div id="progress_bar_step">
@@ -3395,6 +3572,7 @@  discard block
 block discarded – undo
3395 3572
 						<span>', $txt['upgrade_step_progress'], '</span>
3396 3573
 					</div>
3397 3574
 				</div>';
3575
+	}
3398 3576
 
3399 3577
 	echo '
3400 3578
 				<div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div>
@@ -3425,32 +3603,36 @@  discard block
 block discarded – undo
3425 3603
 {
3426 3604
 	global $upcontext, $txt;
3427 3605
 
3428
-	if (!empty($upcontext['pause']))
3429
-		echo '
3606
+	if (!empty($upcontext['pause'])) {
3607
+			echo '
3430 3608
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3431 3609
 
3432 3610
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3433 3611
 								<h3>
3434 3612
 									', $txt['upgrade_paused_overload'], '
3435 3613
 								</h3>';
3614
+	}
3436 3615
 
3437
-	if (!empty($upcontext['custom_warning']))
3438
-		echo '
3616
+	if (!empty($upcontext['custom_warning'])) {
3617
+			echo '
3439 3618
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3440 3619
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3441 3620
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3442 3621
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3443 3622
 								</div>';
3623
+	}
3444 3624
 
3445 3625
 	echo '
3446 3626
 								<div class="righttext" style="margin: 1ex;">';
3447 3627
 
3448
-	if (!empty($upcontext['continue']))
3449
-		echo '
3628
+	if (!empty($upcontext['continue'])) {
3629
+			echo '
3450 3630
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
3451
-	if (!empty($upcontext['skip']))
3452
-		echo '
3631
+	}
3632
+	if (!empty($upcontext['skip'])) {
3633
+			echo '
3453 3634
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
3635
+	}
3454 3636
 
3455 3637
 	echo '
3456 3638
 								</div>
@@ -3500,11 +3682,12 @@  discard block
 block discarded – undo
3500 3682
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3501 3683
 	<smf>';
3502 3684
 
3503
-	if (!empty($upcontext['get_data']))
3504
-		foreach ($upcontext['get_data'] as $k => $v)
3685
+	if (!empty($upcontext['get_data'])) {
3686
+			foreach ($upcontext['get_data'] as $k => $v)
3505 3687
 			echo '
3506 3688
 		<get key="', $k, '">', $v, '</get>';
3507
-}
3689
+	}
3690
+	}
3508 3691
 
3509 3692
 function template_xml_below()
3510 3693
 {
@@ -3545,8 +3728,8 @@  discard block
 block discarded – undo
3545 3728
 	template_chmod();
3546 3729
 
3547 3730
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3548
-	if ($upcontext['is_large_forum'])
3549
-		echo '
3731
+	if ($upcontext['is_large_forum']) {
3732
+			echo '
3550 3733
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3551 3734
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3552 3735
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3554,10 +3737,11 @@  discard block
 block discarded – undo
3554 3737
 				', $txt['upgrade_warning_lots_data'], '
3555 3738
 			</div>
3556 3739
 		</div>';
3740
+	}
3557 3741
 
3558 3742
 	// A warning message?
3559
-	if (!empty($upcontext['warning']))
3560
-		echo '
3743
+	if (!empty($upcontext['warning'])) {
3744
+			echo '
3561 3745
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3562 3746
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3563 3747
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3565,6 +3749,7 @@  discard block
 block discarded – undo
3565 3749
 				', $upcontext['warning'], '
3566 3750
 			</div>
3567 3751
 		</div>';
3752
+	}
3568 3753
 
3569 3754
 	// Paths are incorrect?
3570 3755
 	echo '
@@ -3580,20 +3765,22 @@  discard block
 block discarded – undo
3580 3765
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3581 3766
 	{
3582 3767
 		$ago = time() - $upcontext['started'];
3583
-		if ($ago < 60)
3584
-			$ago = $ago . ' seconds';
3585
-		elseif ($ago < 3600)
3586
-			$ago = (int) ($ago / 60) . ' minutes';
3587
-		else
3588
-			$ago = (int) ($ago / 3600) . ' hours';
3768
+		if ($ago < 60) {
3769
+					$ago = $ago . ' seconds';
3770
+		} elseif ($ago < 3600) {
3771
+					$ago = (int) ($ago / 60) . ' minutes';
3772
+		} else {
3773
+					$ago = (int) ($ago / 3600) . ' hours';
3774
+		}
3589 3775
 
3590 3776
 		$active = time() - $upcontext['updated'];
3591
-		if ($active < 60)
3592
-			$updated = $active . ' seconds';
3593
-		elseif ($active < 3600)
3594
-			$updated = (int) ($active / 60) . ' minutes';
3595
-		else
3596
-			$updated = (int) ($active / 3600) . ' hours';
3777
+		if ($active < 60) {
3778
+					$updated = $active . ' seconds';
3779
+		} elseif ($active < 3600) {
3780
+					$updated = (int) ($active / 60) . ' minutes';
3781
+		} else {
3782
+					$updated = (int) ($active / 3600) . ' hours';
3783
+		}
3597 3784
 
3598 3785
 		echo '
3599 3786
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3602,16 +3789,18 @@  discard block
 block discarded – undo
3602 3789
 			<div style="padding-left: 6ex;">
3603 3790
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3604 3791
 
3605
-		if ($active < 600)
3606
-			echo '
3792
+		if ($active < 600) {
3793
+					echo '
3607 3794
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
3795
+		}
3608 3796
 
3609
-		if ($active > $upcontext['inactive_timeout'])
3610
-			echo '
3797
+		if ($active > $upcontext['inactive_timeout']) {
3798
+					echo '
3611 3799
 				<br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.';
3612
-		else
3613
-			echo '
3800
+		} else {
3801
+					echo '
3614 3802
 				<br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!');
3803
+		}
3615 3804
 
3616 3805
 		echo '
3617 3806
 			</div>
@@ -3627,9 +3816,10 @@  discard block
 block discarded – undo
3627 3816
 					<td>
3628 3817
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
3629 3818
 
3630
-	if (!empty($upcontext['username_incorrect']))
3631
-		echo '
3819
+	if (!empty($upcontext['username_incorrect'])) {
3820
+			echo '
3632 3821
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
3822
+	}
3633 3823
 
3634 3824
 	echo '
3635 3825
 					</td>
@@ -3640,9 +3830,10 @@  discard block
 block discarded – undo
3640 3830
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
3641 3831
 						<input type="hidden" name="hash_passwrd" value="">';
3642 3832
 
3643
-	if (!empty($upcontext['password_failed']))
3644
-		echo '
3833
+	if (!empty($upcontext['password_failed'])) {
3834
+			echo '
3645 3835
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
3836
+	}
3646 3837
 
3647 3838
 	echo '
3648 3839
 					</td>
@@ -3713,8 +3904,8 @@  discard block
 block discarded – undo
3713 3904
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3714 3905
 
3715 3906
 	// Warning message?
3716
-	if (!empty($upcontext['upgrade_options_warning']))
3717
-		echo '
3907
+	if (!empty($upcontext['upgrade_options_warning'])) {
3908
+			echo '
3718 3909
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3719 3910
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3720 3911
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3722,6 +3913,7 @@  discard block
 block discarded – undo
3722 3913
 				', $upcontext['upgrade_options_warning'], '
3723 3914
 			</div>
3724 3915
 		</div>';
3916
+	}
3725 3917
 
3726 3918
 	echo '
3727 3919
 				<table>
@@ -3764,8 +3956,8 @@  discard block
 block discarded – undo
3764 3956
 						</td>
3765 3957
 					</tr>';
3766 3958
 
3767
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3768
-		echo '
3959
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
3960
+			echo '
3769 3961
 					<tr valign="top">
3770 3962
 						<td width="2%">
3771 3963
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -3774,6 +3966,7 @@  discard block
 block discarded – undo
3774 3966
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
3775 3967
 						</td>
3776 3968
 					</tr>';
3969
+	}
3777 3970
 
3778 3971
 	echo '
3779 3972
 					<tr valign="top">
@@ -3811,10 +4004,11 @@  discard block
 block discarded – undo
3811 4004
 			</div>';
3812 4005
 
3813 4006
 	// Dont any tables so far?
3814
-	if (!empty($upcontext['previous_tables']))
3815
-		foreach ($upcontext['previous_tables'] as $table)
4007
+	if (!empty($upcontext['previous_tables'])) {
4008
+			foreach ($upcontext['previous_tables'] as $table)
3816 4009
 			echo '
3817 4010
 			<br>Completed Table: &quot;', $table, '&quot;.';
4011
+	}
3818 4012
 
3819 4013
 	echo '
3820 4014
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -3851,12 +4045,13 @@  discard block
 block discarded – undo
3851 4045
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3852 4046
 
3853 4047
 		// If debug flood the screen.
3854
-		if ($is_debug)
3855
-			echo '
4048
+		if ($is_debug) {
4049
+					echo '
3856 4050
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
3857 4051
 
3858 4052
 				if (document.getElementById(\'debug_section\').scrollHeight)
3859 4053
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4054
+		}
3860 4055
 
3861 4056
 		echo '
3862 4057
 				// Get the next update...
@@ -3889,8 +4084,9 @@  discard block
 block discarded – undo
3889 4084
 {
3890 4085
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
3891 4086
 
3892
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
3893
-		$is_debug = true;
4087
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4088
+			$is_debug = true;
4089
+	}
3894 4090
 
3895 4091
 	echo '
3896 4092
 		<h3>Executing database changes</h3>
@@ -3905,8 +4101,9 @@  discard block
 block discarded – undo
3905 4101
 	{
3906 4102
 		foreach ($upcontext['actioned_items'] as $num => $item)
3907 4103
 		{
3908
-			if ($num != 0)
3909
-				echo ' Successful!';
4104
+			if ($num != 0) {
4105
+							echo ' Successful!';
4106
+			}
3910 4107
 			echo '<br>' . $item;
3911 4108
 		}
3912 4109
 		if (!empty($upcontext['changes_complete']))
@@ -3919,28 +4116,32 @@  discard block
 block discarded – undo
3919 4116
 				$seconds = intval($active % 60);
3920 4117
 
3921 4118
 				$totalTime = '';
3922
-				if ($hours > 0)
3923
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3924
-				if ($minutes > 0)
3925
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3926
-				if ($seconds > 0)
3927
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4119
+				if ($hours > 0) {
4120
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4121
+				}
4122
+				if ($minutes > 0) {
4123
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4124
+				}
4125
+				if ($seconds > 0) {
4126
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4127
+				}
3928 4128
 			}
3929 4129
 
3930
-			if ($is_debug && !empty($totalTime))
3931
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
3932
-			else
3933
-				echo ' Successful!<br><br>';
4130
+			if ($is_debug && !empty($totalTime)) {
4131
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4132
+			} else {
4133
+							echo ' Successful!<br><br>';
4134
+			}
3934 4135
 
3935 4136
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
3936 4137
 		}
3937
-	}
3938
-	else
4138
+	} else
3939 4139
 	{
3940 4140
 		// Tell them how many files we have in total.
3941
-		if ($upcontext['file_count'] > 1)
3942
-			echo '
4141
+		if ($upcontext['file_count'] > 1) {
4142
+					echo '
3943 4143
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4144
+		}
3944 4145
 
3945 4146
 		echo '
3946 4147
 		<h3 id="info2"><strong>Executing:</strong> &quot;<span id="cur_item_name">', $upcontext['current_item_name'], '</span>&quot; (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3>
@@ -3956,19 +4157,23 @@  discard block
 block discarded – undo
3956 4157
 				$seconds = intval($active % 60);
3957 4158
 
3958 4159
 				$totalTime = '';
3959
-				if ($hours > 0)
3960
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3961
-				if ($minutes > 0)
3962
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3963
-				if ($seconds > 0)
3964
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4160
+				if ($hours > 0) {
4161
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4162
+				}
4163
+				if ($minutes > 0) {
4164
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4165
+				}
4166
+				if ($seconds > 0) {
4167
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4168
+				}
3965 4169
 			}
3966 4170
 
3967 4171
 			echo '
3968 4172
 			<br><span id="upgradeCompleted">';
3969 4173
 
3970
-			if (!empty($totalTime))
3971
-				echo 'Completed in ', $totalTime, '<br>';
4174
+			if (!empty($totalTime)) {
4175
+							echo 'Completed in ', $totalTime, '<br>';
4176
+			}
3972 4177
 
3973 4178
 			echo '</span>
3974 4179
 			<div id="debug_section" style="height: 59px; overflow: auto;">
@@ -4005,9 +4210,10 @@  discard block
 block discarded – undo
4005 4210
 			var getData = "";
4006 4211
 			var debugItems = ', $upcontext['debug_items'], ';';
4007 4212
 
4008
-		if ($is_debug)
4009
-			echo '
4213
+		if ($is_debug) {
4214
+					echo '
4010 4215
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4216
+		}
4011 4217
 
4012 4218
 		echo '
4013 4219
 			function getNextItem()
@@ -4047,9 +4253,10 @@  discard block
 block discarded – undo
4047 4253
 						document.getElementById("error_block").style.display = "";
4048 4254
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4049 4255
 
4050
-	if ($is_debug)
4051
-		echo '
4256
+	if ($is_debug) {
4257
+			echo '
4052 4258
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4259
+	}
4053 4260
 
4054 4261
 	echo '
4055 4262
 					}
@@ -4070,9 +4277,10 @@  discard block
 block discarded – undo
4070 4277
 						document.getElementById("error_block").style.display = "";
4071 4278
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4072 4279
 
4073
-	if ($is_debug)
4074
-		echo '
4280
+	if ($is_debug) {
4281
+			echo '
4075 4282
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4283
+	}
4076 4284
 
4077 4285
 	echo '
4078 4286
 					}
@@ -4131,8 +4339,8 @@  discard block
 block discarded – undo
4131 4339
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4132 4340
 				{';
4133 4341
 
4134
-		if ($is_debug)
4135
-			echo '
4342
+		if ($is_debug) {
4343
+					echo '
4136 4344
 					document.getElementById(\'debug_section\').style.display = "none";
4137 4345
 
4138 4346
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4150,6 +4358,7 @@  discard block
 block discarded – undo
4150 4358
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4151 4359
 
4152 4360
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4361
+		}
4153 4362
 
4154 4363
 		echo '
4155 4364
 
@@ -4157,9 +4366,10 @@  discard block
 block discarded – undo
4157 4366
 					document.getElementById(\'contbutt\').disabled = 0;
4158 4367
 					document.getElementById(\'database_done\').value = 1;';
4159 4368
 
4160
-		if ($upcontext['file_count'] > 1)
4161
-			echo '
4369
+		if ($upcontext['file_count'] > 1) {
4370
+					echo '
4162 4371
 					document.getElementById(\'info1\').style.display = "none";';
4372
+		}
4163 4373
 
4164 4374
 		echo '
4165 4375
 					document.getElementById(\'info2\').style.display = "none";
@@ -4172,9 +4382,10 @@  discard block
 block discarded – undo
4172 4382
 					lastItem = 0;
4173 4383
 					prevFile = curFile;';
4174 4384
 
4175
-		if ($is_debug)
4176
-			echo '
4385
+		if ($is_debug) {
4386
+					echo '
4177 4387
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4388
+		}
4178 4389
 
4179 4390
 		echo '
4180 4391
 					getNextItem();
@@ -4182,8 +4393,8 @@  discard block
 block discarded – undo
4182 4393
 				}';
4183 4394
 
4184 4395
 		// If debug scroll the screen.
4185
-		if ($is_debug)
4186
-			echo '
4396
+		if ($is_debug) {
4397
+					echo '
4187 4398
 				if (iLastSubStepProgress == -1)
4188 4399
 				{
4189 4400
 					// Give it consistent dots.
@@ -4202,6 +4413,7 @@  discard block
 block discarded – undo
4202 4413
 
4203 4414
 				if (document.getElementById(\'debug_section\').scrollHeight)
4204 4415
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4416
+		}
4205 4417
 
4206 4418
 		echo '
4207 4419
 				// Update the page.
@@ -4262,9 +4474,10 @@  discard block
 block discarded – undo
4262 4474
 			}';
4263 4475
 
4264 4476
 		// Start things off assuming we've not errored.
4265
-		if (empty($upcontext['error_message']))
4266
-			echo '
4477
+		if (empty($upcontext['error_message'])) {
4478
+					echo '
4267 4479
 			getNextItem();';
4480
+		}
4268 4481
 
4269 4482
 		echo '
4270 4483
 		//# sourceURL=dynamicScript-dbch.js
@@ -4282,18 +4495,21 @@  discard block
 block discarded – undo
4282 4495
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4283 4496
 	<debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>';
4284 4497
 
4285
-	if (!empty($upcontext['error_message']))
4286
-		echo '
4498
+	if (!empty($upcontext['error_message'])) {
4499
+			echo '
4287 4500
 	<error>', $upcontext['error_message'], '</error>';
4501
+	}
4288 4502
 
4289
-	if (!empty($upcontext['error_string']))
4290
-		echo '
4503
+	if (!empty($upcontext['error_string'])) {
4504
+			echo '
4291 4505
 	<sql>', $upcontext['error_string'], '</sql>';
4506
+	}
4292 4507
 
4293
-	if ($is_debug)
4294
-		echo '
4508
+	if ($is_debug) {
4509
+			echo '
4295 4510
 	<curtime>', time(), '</curtime>';
4296
-}
4511
+	}
4512
+	}
4297 4513
 
4298 4514
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4299 4515
 function template_convert_utf8()
@@ -4312,18 +4528,20 @@  discard block
 block discarded – undo
4312 4528
 			</div>';
4313 4529
 
4314 4530
 	// Done any tables so far?
4315
-	if (!empty($upcontext['previous_tables']))
4316
-		foreach ($upcontext['previous_tables'] as $table)
4531
+	if (!empty($upcontext['previous_tables'])) {
4532
+			foreach ($upcontext['previous_tables'] as $table)
4317 4533
 			echo '
4318 4534
 			<br>Completed Table: &quot;', $table, '&quot;.';
4535
+	}
4319 4536
 
4320 4537
 	echo '
4321 4538
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4322 4539
 
4323 4540
 	// If we dropped their index, let's let them know
4324
-	if ($upcontext['dropping_index'])
4325
-		echo '
4541
+	if ($upcontext['dropping_index']) {
4542
+			echo '
4326 4543
 				<br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>';
4544
+	}
4327 4545
 
4328 4546
 	// Completion notification
4329 4547
 	echo '
@@ -4360,12 +4578,13 @@  discard block
 block discarded – undo
4360 4578
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4361 4579
 
4362 4580
 		// If debug flood the screen.
4363
-		if ($is_debug)
4364
-			echo '
4581
+		if ($is_debug) {
4582
+					echo '
4365 4583
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4366 4584
 
4367 4585
 				if (document.getElementById(\'debug_section\').scrollHeight)
4368 4586
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4587
+		}
4369 4588
 
4370 4589
 		echo '
4371 4590
 				// Get the next update...
@@ -4413,19 +4632,21 @@  discard block
 block discarded – undo
4413 4632
 			</div>';
4414 4633
 
4415 4634
 	// Dont any tables so far?
4416
-	if (!empty($upcontext['previous_tables']))
4417
-		foreach ($upcontext['previous_tables'] as $table)
4635
+	if (!empty($upcontext['previous_tables'])) {
4636
+			foreach ($upcontext['previous_tables'] as $table)
4418 4637
 			echo '
4419 4638
 			<br>Completed Table: &quot;', $table, '&quot;.';
4639
+	}
4420 4640
 
4421 4641
 	echo '
4422 4642
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4423 4643
 			<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>';
4424 4644
 
4425 4645
 	// Try to make sure substep was reset.
4426
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4427
-		echo '
4646
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4647
+			echo '
4428 4648
 			<input type="hidden" name="substep" id="substep" value="0">';
4649
+	}
4429 4650
 
4430 4651
 	// Continue please!
4431 4652
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4458,12 +4679,13 @@  discard block
 block discarded – undo
4458 4679
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4459 4680
 
4460 4681
 		// If debug flood the screen.
4461
-		if ($is_debug)
4462
-			echo '
4682
+		if ($is_debug) {
4683
+					echo '
4463 4684
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4464 4685
 
4465 4686
 				if (document.getElementById(\'debug_section\').scrollHeight)
4466 4687
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4688
+		}
4467 4689
 
4468 4690
 		echo '
4469 4691
 				// Get the next update...
@@ -4499,8 +4721,8 @@  discard block
 block discarded – undo
4499 4721
 	<h3>That wasn\'t so hard, was it?  Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>.  Hope you like it!</h3>
4500 4722
 	<form action="', $boardurl, '/index.php">';
4501 4723
 
4502
-	if (!empty($upcontext['can_delete_script']))
4503
-		echo '
4724
+	if (!empty($upcontext['can_delete_script'])) {
4725
+			echo '
4504 4726
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em>
4505 4727
 			<script>
4506 4728
 				function doTheDelete(theCheck)
@@ -4512,6 +4734,7 @@  discard block
 block discarded – undo
4512 4734
 				}
4513 4735
 			</script>
4514 4736
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4737
+	}
4515 4738
 
4516 4739
 	$active = time() - $upcontext['started'];
4517 4740
 	$hours = floor($active / 3600);
@@ -4521,16 +4744,20 @@  discard block
 block discarded – undo
4521 4744
 	if ($is_debug)
4522 4745
 	{
4523 4746
 		$totalTime = '';
4524
-		if ($hours > 0)
4525
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4526
-		if ($minutes > 0)
4527
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4528
-		if ($seconds > 0)
4529
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4747
+		if ($hours > 0) {
4748
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4749
+		}
4750
+		if ($minutes > 0) {
4751
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4752
+		}
4753
+		if ($seconds > 0) {
4754
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4755
+		}
4530 4756
 	}
4531 4757
 
4532
-	if ($is_debug && !empty($totalTime))
4533
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4758
+	if ($is_debug && !empty($totalTime)) {
4759
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4760
+	}
4534 4761
 
4535 4762
 	echo '<br>
4536 4763
 			If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br>
@@ -4557,8 +4784,9 @@  discard block
 block discarded – undo
4557 4784
 
4558 4785
 	$current_substep = $_GET['substep'];
4559 4786
 
4560
-	if (empty($_GET['a']))
4561
-		$_GET['a'] = 0;
4787
+	if (empty($_GET['a'])) {
4788
+			$_GET['a'] = 0;
4789
+	}
4562 4790
 	$step_progress['name'] = 'Converting ips';
4563 4791
 	$step_progress['current'] = $_GET['a'];
4564 4792
 
@@ -4601,16 +4829,19 @@  discard block
 block discarded – undo
4601 4829
 				'empty' => '',
4602 4830
 				'limit' => $limit,
4603 4831
 		));
4604
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4605
-			$arIp[] = $row[$oldCol];
4832
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4833
+					$arIp[] = $row[$oldCol];
4834
+		}
4606 4835
 		$smcFunc['db_free_result']($request);
4607 4836
 
4608 4837
 		// Special case, null ip could keep us in a loop.
4609
-		if (is_null($arIp[0]))
4610
-			unset($arIp[0]);
4838
+		if (is_null($arIp[0])) {
4839
+					unset($arIp[0]);
4840
+		}
4611 4841
 
4612
-		if (empty($arIp))
4613
-			$is_done = true;
4842
+		if (empty($arIp)) {
4843
+					$is_done = true;
4844
+		}
4614 4845
 
4615 4846
 		$updates = array();
4616 4847
 		$cases = array();
@@ -4619,16 +4850,18 @@  discard block
 block discarded – undo
4619 4850
 		{
4620 4851
 			$arIp[$i] = trim($arIp[$i]);
4621 4852
 
4622
-			if (empty($arIp[$i]))
4623
-				continue;
4853
+			if (empty($arIp[$i])) {
4854
+							continue;
4855
+			}
4624 4856
 
4625 4857
 			$updates['ip' . $i] = $arIp[$i];
4626 4858
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4627 4859
 
4628 4860
 			if ($setSize > 0 && $i % $setSize === 0)
4629 4861
 			{
4630
-				if (count($updates) == 1)
4631
-					continue;
4862
+				if (count($updates) == 1) {
4863
+									continue;
4864
+				}
4632 4865
 
4633 4866
 				$updates['whereSet'] = array_values($updates);
4634 4867
 				$smcFunc['db_query']('', '
@@ -4662,8 +4895,7 @@  discard block
 block discarded – undo
4662 4895
 							'ip' => $ip
4663 4896
 					));
4664 4897
 				}
4665
-			}
4666
-			else
4898
+			} else
4667 4899
 			{
4668 4900
 				$updates['whereSet'] = array_values($updates);
4669 4901
 				$smcFunc['db_query']('', '
@@ -4677,9 +4909,9 @@  discard block
 block discarded – undo
4677 4909
 					$updates
4678 4910
 				);
4679 4911
 			}
4912
+		} else {
4913
+					$is_done = true;
4680 4914
 		}
4681
-		else
4682
-			$is_done = true;
4683 4915
 
4684 4916
 		$_GET['a'] += $limit;
4685 4917
 		$step_progress['current'] = $_GET['a'];
@@ -4705,10 +4937,11 @@  discard block
 block discarded – undo
4705 4937
 
4706 4938
  	$columns = $smcFunc['db_list_columns']($targetTable, true);
4707 4939
 
4708
-	if (isset($columns[$column]))
4709
-		return $columns[$column];
4710
-	else
4711
-		return null;
4712
-}
4940
+	if (isset($columns[$column])) {
4941
+			return $columns[$column];
4942
+	} else {
4943
+			return null;
4944
+	}
4945
+	}
4713 4946
 
4714 4947
 ?>
4715 4948
\ No newline at end of file
Please login to merge, or discard this patch.
other/install.php 1 patch
Braces   +441 added lines, -328 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
21 21
 
22 22
 // Let's pull in useful classes
23
-if (!defined('SMF'))
23
+if (!defined('SMF')) {
24 24
 	define('SMF', 1);
25
+}
25 26
 
26 27
 require_once('Sources/Class-Package.php');
27 28
 
@@ -63,10 +64,11 @@  discard block
 block discarded – undo
63 64
 
64 65
 			list ($charcode) = pg_fetch_row($request);
65 66
 
66
-			if ($charcode == 'UTF8')
67
-				return true;
68
-			else
69
-				return false;
67
+			if ($charcode == 'UTF8') {
68
+							return true;
69
+			} else {
70
+							return false;
71
+			}
70 72
 		},
71 73
 		'utf8_version' => '8.0',
72 74
 		'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;',
@@ -76,12 +78,14 @@  discard block
 block discarded – undo
76 78
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
77 79
 
78 80
 			// Is it reserved?
79
-			if ($value == 'pg_')
80
-				return $txt['error_db_prefix_reserved'];
81
+			if ($value == 'pg_') {
82
+							return $txt['error_db_prefix_reserved'];
83
+			}
81 84
 
82 85
 			// Is the prefix numeric?
83
-			if (preg_match('~^\d~', $value))
84
-				return $txt['error_db_prefix_numeric'];
86
+			if (preg_match('~^\d~', $value)) {
87
+							return $txt['error_db_prefix_numeric'];
88
+			}
85 89
 
86 90
 			return true;
87 91
 		},
@@ -128,10 +132,11 @@  discard block
 block discarded – undo
128 132
 		$incontext['skip'] = false;
129 133
 
130 134
 		// Call the step and if it returns false that means pause!
131
-		if (function_exists($step[2]) && $step[2]() === false)
132
-			break;
133
-		elseif (function_exists($step[2]))
134
-			$incontext['current_step']++;
135
+		if (function_exists($step[2]) && $step[2]() === false) {
136
+					break;
137
+		} elseif (function_exists($step[2])) {
138
+					$incontext['current_step']++;
139
+		}
135 140
 
136 141
 		// No warnings pass on.
137 142
 		$incontext['warning'] = '';
@@ -147,8 +152,9 @@  discard block
 block discarded – undo
147 152
 	global $databases;
148 153
 
149 154
 	// Just so people using older versions of PHP aren't left in the cold.
150
-	if (!isset($_SERVER['PHP_SELF']))
151
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
155
+	if (!isset($_SERVER['PHP_SELF'])) {
156
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
157
+	}
152 158
 
153 159
 	// Enable error reporting.
154 160
 	error_reporting(E_ALL);
@@ -164,21 +170,23 @@  discard block
 block discarded – undo
164 170
 	{
165 171
 		ob_start();
166 172
 
167
-		if (ini_get('session.save_handler') == 'user')
168
-			@ini_set('session.save_handler', 'files');
169
-		if (function_exists('session_start'))
170
-			@session_start();
171
-	}
172
-	else
173
+		if (ini_get('session.save_handler') == 'user') {
174
+					@ini_set('session.save_handler', 'files');
175
+		}
176
+		if (function_exists('session_start')) {
177
+					@session_start();
178
+		}
179
+	} else
173 180
 	{
174 181
 		ob_start('ob_gzhandler');
175 182
 
176
-		if (ini_get('session.save_handler') == 'user')
177
-			@ini_set('session.save_handler', 'files');
183
+		if (ini_get('session.save_handler') == 'user') {
184
+					@ini_set('session.save_handler', 'files');
185
+		}
178 186
 		session_start();
179 187
 
180
-		if (!headers_sent())
181
-			echo '<!DOCTYPE html>
188
+		if (!headers_sent()) {
189
+					echo '<!DOCTYPE html>
182 190
 <html>
183 191
 	<head>
184 192
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -187,14 +195,16 @@  discard block
 block discarded – undo
187 195
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
188 196
 	</body>
189 197
 </html>';
198
+		}
190 199
 		exit;
191 200
 	}
192 201
 
193 202
 	// Add slashes, as long as they aren't already being added.
194
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
195
-		foreach ($_POST as $k => $v)
203
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
204
+			foreach ($_POST as $k => $v)
196 205
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
197 206
 				$_POST[$k] = addslashes($v);
207
+	}
198 208
 
199 209
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
200 210
 	if (isset($_GET['delete']))
@@ -215,8 +225,7 @@  discard block
 block discarded – undo
215 225
 			$ftp->close();
216 226
 
217 227
 			unset($_SESSION['installer_temp_ftp']);
218
-		}
219
-		else
228
+		} else
220 229
 		{
221 230
 			@unlink(__FILE__);
222 231
 
@@ -237,10 +246,11 @@  discard block
 block discarded – undo
237 246
 	{
238 247
 		// Get PHP's default timezone, if set
239 248
 		$ini_tz = ini_get('date.timezone');
240
-		if (!empty($ini_tz))
241
-			$timezone_id = $ini_tz;
242
-		else
243
-			$timezone_id = '';
249
+		if (!empty($ini_tz)) {
250
+					$timezone_id = $ini_tz;
251
+		} else {
252
+					$timezone_id = '';
253
+		}
244 254
 
245 255
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
246 256
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -270,8 +280,9 @@  discard block
 block discarded – undo
270 280
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
271 281
 		while ($entry = $dir->read())
272 282
 		{
273
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
274
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
283
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
284
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
285
+			}
275 286
 		}
276 287
 		$dir->close();
277 288
 	}
@@ -306,10 +317,11 @@  discard block
 block discarded – undo
306 317
 	}
307 318
 
308 319
 	// Override the language file?
309
-	if (isset($_GET['lang_file']))
310
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
311
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
312
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
320
+	if (isset($_GET['lang_file'])) {
321
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
322
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
323
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
324
+	}
313 325
 
314 326
 	// Make sure it exists, if it doesn't reset it.
315 327
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -318,8 +330,9 @@  discard block
 block discarded – undo
318 330
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
319 331
 
320 332
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
321
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
322
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
333
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
334
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
335
+		}
323 336
 	}
324 337
 
325 338
 	// And now include the actual language file itself.
@@ -332,15 +345,18 @@  discard block
 block discarded – undo
332 345
 	global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings;
333 346
 	global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist;
334 347
 
335
-	if (empty($sourcedir))
336
-		$sourcedir = dirname(__FILE__) . '/Sources';
348
+	if (empty($sourcedir)) {
349
+			$sourcedir = dirname(__FILE__) . '/Sources';
350
+	}
337 351
 
338 352
 	// Need this to check whether we need the database password.
339 353
 	require(dirname(__FILE__) . '/Settings.php');
340
-	if (!defined('SMF'))
341
-		define('SMF', 1);
342
-	if (empty($smcFunc))
343
-		$smcFunc = array();
354
+	if (!defined('SMF')) {
355
+			define('SMF', 1);
356
+	}
357
+	if (empty($smcFunc)) {
358
+			$smcFunc = array();
359
+	}
344 360
 
345 361
 	$modSettings['disableQueryCheck'] = true;
346 362
 
@@ -348,8 +364,9 @@  discard block
 block discarded – undo
348 364
 	if (!$db_connection)
349 365
 	{
350 366
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
351
-		if (version_compare(PHP_VERSION, '5', '<'))
352
-			require_once($sourcedir . '/Subs-Compat.php');
367
+		if (version_compare(PHP_VERSION, '5', '<')) {
368
+					require_once($sourcedir . '/Subs-Compat.php');
369
+		}
353 370
 
354 371
 		$db_options = array('persist' => $db_persist);
355 372
 		$port = '';
@@ -360,19 +377,20 @@  discard block
 block discarded – undo
360 377
 			if ($db_type == 'mysql')
361 378
 			{
362 379
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
363
-			}
364
-			elseif ($db_type == 'postgresql')
380
+			} elseif ($db_type == 'postgresql')
365 381
 			{
366 382
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
367 383
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
368 384
 			}
369 385
 		}
370 386
 
371
-		if (!empty($port))
372
-			$db_options['port'] = $port;
387
+		if (!empty($port)) {
388
+					$db_options['port'] = $port;
389
+		}
373 390
 
374
-		if (!$db_connection)
375
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
391
+		if (!$db_connection) {
392
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
393
+		}
376 394
 	}
377 395
 }
378 396
 
@@ -400,8 +418,9 @@  discard block
 block discarded – undo
400 418
 		// @todo REMOVE THIS!!
401 419
 		else
402 420
 		{
403
-			if (function_exists('doStep' . $_GET['step']))
404
-				call_user_func('doStep' . $_GET['step']);
421
+			if (function_exists('doStep' . $_GET['step'])) {
422
+							call_user_func('doStep' . $_GET['step']);
423
+			}
405 424
 		}
406 425
 		// Show the footer.
407 426
 		template_install_below();
@@ -419,8 +438,9 @@  discard block
 block discarded – undo
419 438
 	$incontext['sub_template'] = 'welcome_message';
420 439
 
421 440
 	// Done the submission?
422
-	if (isset($_POST['contbutt']))
423
-		return true;
441
+	if (isset($_POST['contbutt'])) {
442
+			return true;
443
+	}
424 444
 
425 445
 	// See if we think they have already installed it?
426 446
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -428,14 +448,17 @@  discard block
 block discarded – undo
428 448
 		$probably_installed = 0;
429 449
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
430 450
 		{
431
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
432
-				$probably_installed++;
433
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
434
-				$probably_installed++;
451
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
452
+							$probably_installed++;
453
+			}
454
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
455
+							$probably_installed++;
456
+			}
435 457
 		}
436 458
 
437
-		if ($probably_installed == 2)
438
-			$incontext['warning'] = $txt['error_already_installed'];
459
+		if ($probably_installed == 2) {
460
+					$incontext['warning'] = $txt['error_already_installed'];
461
+		}
439 462
 	}
440 463
 
441 464
 	// Is some database support even compiled in?
@@ -450,41 +473,49 @@  discard block
 block discarded – undo
450 473
 				$databases[$key]['supported'] = false;
451 474
 				$notFoundSQLFile = true;
452 475
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
476
+			} else {
477
+							$incontext['supported_databases'][] = $db;
453 478
 			}
454
-			else
455
-				$incontext['supported_databases'][] = $db;
456 479
 		}
457 480
 	}
458 481
 
459 482
 	// Check the PHP version.
460
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>=')))
461
-		$error = 'error_php_too_low';
483
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) {
484
+			$error = 'error_php_too_low';
485
+	}
462 486
 	// Make sure we have a supported database
463
-	elseif (empty($incontext['supported_databases']))
464
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
487
+	elseif (empty($incontext['supported_databases'])) {
488
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
489
+	}
465 490
 	// How about session support?  Some crazy sysadmin remove it?
466
-	elseif (!function_exists('session_start'))
467
-		$error = 'error_session_missing';
491
+	elseif (!function_exists('session_start')) {
492
+			$error = 'error_session_missing';
493
+	}
468 494
 	// Make sure they uploaded all the files.
469
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
470
-		$error = 'error_missing_files';
495
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
496
+			$error = 'error_missing_files';
497
+	}
471 498
 	// Very simple check on the session.save_path for Windows.
472 499
 	// @todo Move this down later if they don't use database-driven sessions?
473
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
474
-		$error = 'error_session_save_path';
500
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
501
+			$error = 'error_session_save_path';
502
+	}
475 503
 
476 504
 	// Since each of the three messages would look the same, anyway...
477
-	if (isset($error))
478
-		$incontext['error'] = $txt[$error];
505
+	if (isset($error)) {
506
+			$incontext['error'] = $txt[$error];
507
+	}
479 508
 
480 509
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
481
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
482
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
510
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
511
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
512
+	}
483 513
 
484 514
 	// Check for https stream support.
485 515
 	$supported_streams = stream_get_wrappers();
486
-	if (!in_array('https', $supported_streams))
487
-		$incontext['warning'] = $txt['install_no_https'];
516
+	if (!in_array('https', $supported_streams)) {
517
+			$incontext['warning'] = $txt['install_no_https'];
518
+	}
488 519
 
489 520
 	return false;
490 521
 }
@@ -510,12 +541,14 @@  discard block
 block discarded – undo
510 541
 		'db_last_error.php',
511 542
 	);
512 543
 
513
-	foreach ($incontext['detected_languages'] as $lang => $temp)
514
-		$extra_files[] = 'Themes/default/languages/' . $lang;
544
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
545
+			$extra_files[] = 'Themes/default/languages/' . $lang;
546
+	}
515 547
 
516 548
 	// With mod_security installed, we could attempt to fix it with .htaccess.
517
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
518
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
549
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
550
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
551
+	}
519 552
 
520 553
 	$failed_files = array();
521 554
 
@@ -531,12 +564,14 @@  discard block
 block discarded – undo
531 564
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
532 565
 
533 566
 				// Well, 755 hopefully worked... if not, try 777.
534
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
535
-					$failed_files[] = $file;
567
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
568
+									$failed_files[] = $file;
569
+				}
536 570
 			}
537 571
 		}
538
-		foreach ($extra_files as $file)
539
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
572
+		foreach ($extra_files as $file) {
573
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
574
+		}
540 575
 	}
541 576
 	// Windows is trickier.  Let's try opening for r+...
542 577
 	else
@@ -546,30 +581,35 @@  discard block
 block discarded – undo
546 581
 		foreach ($writable_files as $file)
547 582
 		{
548 583
 			// Folders can't be opened for write... but the index.php in them can ;)
549
-			if (is_dir(dirname(__FILE__) . '/' . $file))
550
-				$file .= '/index.php';
584
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
585
+							$file .= '/index.php';
586
+			}
551 587
 
552 588
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
553 589
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
554 590
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
555 591
 
556 592
 			// Hmm, okay, try just for write in that case...
557
-			if (!is_resource($fp))
558
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
593
+			if (!is_resource($fp)) {
594
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
595
+			}
559 596
 
560
-			if (!is_resource($fp))
561
-				$failed_files[] = $file;
597
+			if (!is_resource($fp)) {
598
+							$failed_files[] = $file;
599
+			}
562 600
 
563 601
 			@fclose($fp);
564 602
 		}
565
-		foreach ($extra_files as $file)
566
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
603
+		foreach ($extra_files as $file) {
604
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
605
+		}
567 606
 	}
568 607
 
569 608
 	$failure = count($failed_files) >= 1;
570 609
 
571
-	if (!isset($_SERVER))
572
-		return !$failure;
610
+	if (!isset($_SERVER)) {
611
+			return !$failure;
612
+	}
573 613
 
574 614
 	// Put the list into context.
575 615
 	$incontext['failed_files'] = $failed_files;
@@ -617,19 +657,23 @@  discard block
 block discarded – undo
617 657
 
618 658
 		if (!isset($ftp) || $ftp->error !== false)
619 659
 		{
620
-			if (!isset($ftp))
621
-				$ftp = new ftp_connection(null);
660
+			if (!isset($ftp)) {
661
+							$ftp = new ftp_connection(null);
662
+			}
622 663
 			// Save the error so we can mess with listing...
623
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
624
-				$incontext['ftp_errors'][] = $ftp->last_message;
664
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
665
+							$incontext['ftp_errors'][] = $ftp->last_message;
666
+			}
625 667
 
626 668
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
627 669
 
628
-			if (empty($_POST['ftp_path']) && $found_path)
629
-				$_POST['ftp_path'] = $detect_path;
670
+			if (empty($_POST['ftp_path']) && $found_path) {
671
+							$_POST['ftp_path'] = $detect_path;
672
+			}
630 673
 
631
-			if (!isset($_POST['ftp_username']))
632
-				$_POST['ftp_username'] = $username;
674
+			if (!isset($_POST['ftp_username'])) {
675
+							$_POST['ftp_username'] = $username;
676
+			}
633 677
 
634 678
 			// Set the username etc, into context.
635 679
 			$incontext['ftp'] = array(
@@ -641,8 +685,7 @@  discard block
 block discarded – undo
641 685
 			);
642 686
 
643 687
 			return false;
644
-		}
645
-		else
688
+		} else
646 689
 		{
647 690
 			$_SESSION['installer_temp_ftp'] = array(
648 691
 				'server' => $_POST['ftp_server'],
@@ -656,10 +699,12 @@  discard block
 block discarded – undo
656 699
 
657 700
 			foreach ($failed_files as $file)
658 701
 			{
659
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
660
-					$ftp->chmod($file, 0755);
661
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
662
-					$ftp->chmod($file, 0777);
702
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
703
+									$ftp->chmod($file, 0755);
704
+				}
705
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
706
+									$ftp->chmod($file, 0777);
707
+				}
663 708
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
664 709
 				{
665 710
 					$failed_files_updated[] = $file;
@@ -715,15 +760,17 @@  discard block
 block discarded – undo
715 760
 
716 761
 			if (!$foundOne)
717 762
 			{
718
-				if (isset($db['default_host']))
719
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
763
+				if (isset($db['default_host'])) {
764
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
765
+				}
720 766
 				if (isset($db['default_user']))
721 767
 				{
722 768
 					$incontext['db']['user'] = ini_get($db['default_user']);
723 769
 					$incontext['db']['name'] = ini_get($db['default_user']);
724 770
 				}
725
-				if (isset($db['default_password']))
726
-					$incontext['db']['pass'] = ini_get($db['default_password']);
771
+				if (isset($db['default_password'])) {
772
+									$incontext['db']['pass'] = ini_get($db['default_password']);
773
+				}
727 774
 
728 775
 				// For simplicity and less confusion, leave the port blank by default
729 776
 				$incontext['db']['port'] = '';
@@ -742,10 +789,10 @@  discard block
 block discarded – undo
742 789
 		$incontext['db']['server'] = $_POST['db_server'];
743 790
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
744 791
 
745
-		if (!empty($_POST['db_port']))
746
-			$incontext['db']['port'] = $_POST['db_port'];
747
-	}
748
-	else
792
+		if (!empty($_POST['db_port'])) {
793
+					$incontext['db']['port'] = $_POST['db_port'];
794
+		}
795
+	} else
749 796
 	{
750 797
 		$incontext['db']['prefix'] = 'smf_';
751 798
 	}
@@ -781,10 +828,11 @@  discard block
 block discarded – undo
781 828
 		if (!empty($_POST['db_port']))
782 829
 		{
783 830
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
784
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
785
-				$vars['db_port'] = (int) $_POST['db_port'];
786
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
787
-				$vars['db_port'] = (int) $_POST['db_port'];
831
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
832
+							$vars['db_port'] = (int) $_POST['db_port'];
833
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
834
+							$vars['db_port'] = (int) $_POST['db_port'];
835
+			}
788 836
 		}
789 837
 
790 838
 		// God I hope it saved!
@@ -797,8 +845,9 @@  discard block
 block discarded – undo
797 845
 		// Make sure it works.
798 846
 		require(dirname(__FILE__) . '/Settings.php');
799 847
 
800
-		if (empty($sourcedir))
801
-			$sourcedir = dirname(__FILE__) . '/Sources';
848
+		if (empty($sourcedir)) {
849
+					$sourcedir = dirname(__FILE__) . '/Sources';
850
+		}
802 851
 
803 852
 		// Better find the database file!
804 853
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -808,18 +857,21 @@  discard block
 block discarded – undo
808 857
 		}
809 858
 
810 859
 		// Now include it for database functions!
811
-		if (!defined('SMF'))
812
-			define('SMF', 1);
860
+		if (!defined('SMF')) {
861
+					define('SMF', 1);
862
+		}
813 863
 
814 864
 		$modSettings['disableQueryCheck'] = true;
815
-		if (empty($smcFunc))
816
-			$smcFunc = array();
865
+		if (empty($smcFunc)) {
866
+					$smcFunc = array();
867
+		}
817 868
 
818 869
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
819 870
 
820 871
 		// What - running PHP4? The shame!
821
-		if (version_compare(PHP_VERSION, '5', '<'))
822
-			require_once($sourcedir . '/Subs-Compat.php');
872
+		if (version_compare(PHP_VERSION, '5', '<')) {
873
+					require_once($sourcedir . '/Subs-Compat.php');
874
+		}
823 875
 
824 876
 		// Attempt a connection.
825 877
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -907,12 +959,14 @@  discard block
 block discarded – undo
907 959
 	$incontext['page_title'] = $txt['install_settings'];
908 960
 
909 961
 	// Let's see if we got the database type correct.
910
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
911
-		$db_type = $_POST['db_type'];
962
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
963
+			$db_type = $_POST['db_type'];
964
+	}
912 965
 
913 966
 	// Else we'd better be able to get the connection.
914
-	else
915
-		load_database();
967
+	else {
968
+			load_database();
969
+	}
916 970
 
917 971
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
918 972
 
@@ -932,12 +986,14 @@  discard block
 block discarded – undo
932 986
 	// Submitting?
933 987
 	if (isset($_POST['boardurl']))
934 988
 	{
935
-		if (substr($_POST['boardurl'], -10) == '/index.php')
936
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
937
-		elseif (substr($_POST['boardurl'], -1) == '/')
938
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
939
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
940
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
989
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
990
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
991
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
992
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
993
+		}
994
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
995
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
996
+		}
941 997
 
942 998
 		// Save these variables.
943 999
 		$vars = array(
@@ -976,10 +1032,10 @@  discard block
 block discarded – undo
976 1032
 			{
977 1033
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
978 1034
 				return false;
979
-			}
980
-			else
981
-				// Set the character set here.
1035
+			} else {
1036
+							// Set the character set here.
982 1037
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1038
+			}
983 1039
 		}
984 1040
 
985 1041
 		// Good, skip on.
@@ -999,8 +1055,9 @@  discard block
 block discarded – undo
999 1055
 	$incontext['continue'] = 1;
1000 1056
 
1001 1057
 	// Already done?
1002
-	if (isset($_POST['pop_done']))
1003
-		return true;
1058
+	if (isset($_POST['pop_done'])) {
1059
+			return true;
1060
+	}
1004 1061
 
1005 1062
 	// Reload settings.
1006 1063
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1018,8 +1075,9 @@  discard block
 block discarded – undo
1018 1075
 	$modSettings = array();
1019 1076
 	if ($result !== false)
1020 1077
 	{
1021
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1022
-			$modSettings[$row['variable']] = $row['value'];
1078
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1079
+					$modSettings[$row['variable']] = $row['value'];
1080
+		}
1023 1081
 		$smcFunc['db_free_result']($result);
1024 1082
 
1025 1083
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1032,20 +1090,22 @@  discard block
 block discarded – undo
1032 1090
 	$modSettings['disableQueryCheck'] = true;
1033 1091
 
1034 1092
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1035
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1036
-		$smcFunc['db_query']('', '
1093
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1094
+			$smcFunc['db_query']('', '
1037 1095
 			SET NAMES {string:utf8}',
1038 1096
 			array(
1039 1097
 				'db_error_skip' => true,
1040 1098
 				'utf8' => 'utf8',
1041 1099
 			)
1042 1100
 		);
1101
+	}
1043 1102
 
1044 1103
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1045
-	if (substr(__DIR__, -1) == '\\')
1046
-		$attachdir = __DIR__ . 'attachments';
1047
-	else
1048
-		$attachdir = __DIR__ . '/attachments';
1104
+	if (substr(__DIR__, -1) == '\\') {
1105
+			$attachdir = __DIR__ . 'attachments';
1106
+	} else {
1107
+			$attachdir = __DIR__ . '/attachments';
1108
+	}
1049 1109
 
1050 1110
 	$replaces = array(
1051 1111
 		'{$db_prefix}' => $db_prefix,
@@ -1062,8 +1122,9 @@  discard block
 block discarded – undo
1062 1122
 
1063 1123
 	foreach ($txt as $key => $value)
1064 1124
 	{
1065
-		if (substr($key, 0, 8) == 'default_')
1066
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1125
+		if (substr($key, 0, 8) == 'default_') {
1126
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1127
+		}
1067 1128
 	}
1068 1129
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1069 1130
 
@@ -1078,8 +1139,9 @@  discard block
 block discarded – undo
1078 1139
 
1079 1140
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1080 1141
 		{
1081
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1082
-				$engines[] = $row['Engine'];
1142
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1143
+							$engines[] = $row['Engine'];
1144
+			}
1083 1145
 		}
1084 1146
 
1085 1147
 		// Done with this now
@@ -1103,8 +1165,7 @@  discard block
 block discarded – undo
1103 1165
 			$replaces['START TRANSACTION;'] = '';
1104 1166
 			$replaces['COMMIT;'] = '';
1105 1167
 		}
1106
-	}
1107
-	else
1168
+	} else
1108 1169
 	{
1109 1170
 		$has_innodb = false;
1110 1171
 	}
@@ -1126,21 +1187,24 @@  discard block
 block discarded – undo
1126 1187
 	foreach ($sql_lines as $count => $line)
1127 1188
 	{
1128 1189
 		// No comments allowed!
1129
-		if (substr(trim($line), 0, 1) != '#')
1130
-			$current_statement .= "\n" . rtrim($line);
1190
+		if (substr(trim($line), 0, 1) != '#') {
1191
+					$current_statement .= "\n" . rtrim($line);
1192
+		}
1131 1193
 
1132 1194
 		// Is this the end of the query string?
1133
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1134
-			continue;
1195
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1196
+					continue;
1197
+		}
1135 1198
 
1136 1199
 		// Does this table already exist?  If so, don't insert more data into it!
1137 1200
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1138 1201
 		{
1139 1202
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1140
-			if (!empty($matches[0]))
1141
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1142
-			else
1143
-				$incontext['sql_results']['insert_dups']++;
1203
+			if (!empty($matches[0])) {
1204
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1205
+			} else {
1206
+							$incontext['sql_results']['insert_dups']++;
1207
+			}
1144 1208
 
1145 1209
 			$current_statement = '';
1146 1210
 			continue;
@@ -1149,8 +1213,9 @@  discard block
 block discarded – undo
1149 1213
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1150 1214
 		{
1151 1215
 			// Use the appropriate function based on the DB type
1152
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1153
-				$db_errorno = $db_type . '_errno';
1216
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1217
+							$db_errorno = $db_type . '_errno';
1218
+			}
1154 1219
 
1155 1220
 			// Error 1050: Table already exists!
1156 1221
 			// @todo Needs to be made better!
@@ -1165,18 +1230,18 @@  discard block
 block discarded – undo
1165 1230
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1166 1231
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1167 1232
 			}
1168
-		}
1169
-		else
1233
+		} else
1170 1234
 		{
1171
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1172
-				$incontext['sql_results']['tables']++;
1173
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1235
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1236
+							$incontext['sql_results']['tables']++;
1237
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1174 1238
 			{
1175 1239
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1176
-				if (!empty($matches[0]))
1177
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1178
-				else
1179
-					$incontext['sql_results']['inserts']++;
1240
+				if (!empty($matches[0])) {
1241
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1242
+				} else {
1243
+									$incontext['sql_results']['inserts']++;
1244
+				}
1180 1245
 			}
1181 1246
 		}
1182 1247
 
@@ -1189,15 +1254,17 @@  discard block
 block discarded – undo
1189 1254
 	// Sort out the context for the SQL.
1190 1255
 	foreach ($incontext['sql_results'] as $key => $number)
1191 1256
 	{
1192
-		if ($number == 0)
1193
-			unset($incontext['sql_results'][$key]);
1194
-		else
1195
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1257
+		if ($number == 0) {
1258
+					unset($incontext['sql_results'][$key]);
1259
+		} else {
1260
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1261
+		}
1196 1262
 	}
1197 1263
 
1198 1264
 	// Make sure UTF will be used globally.
1199
-	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
1200
-		$newSettings[] = array('global_character_set', 'UTF-8');
1265
+	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) {
1266
+			$newSettings[] = array('global_character_set', 'UTF-8');
1267
+	}
1201 1268
 
1202 1269
 	// Maybe we can auto-detect better cookie settings?
1203 1270
 	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
@@ -1208,16 +1275,20 @@  discard block
 block discarded – undo
1208 1275
 		$globalCookies = false;
1209 1276
 
1210 1277
 		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
1211
-		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
1212
-			$globalCookies = true;
1278
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) {
1279
+					$globalCookies = true;
1280
+		}
1213 1281
 		// If there's a / in the middle of the path, or it starts with ~... we want local.
1214
-		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
1215
-			$localCookies = true;
1282
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) {
1283
+					$localCookies = true;
1284
+		}
1216 1285
 
1217
-		if ($globalCookies)
1218
-			$newSettings[] = array('globalCookies', '1');
1219
-		if ($localCookies)
1220
-			$newSettings[] = array('localCookies', '1');
1286
+		if ($globalCookies) {
1287
+					$newSettings[] = array('globalCookies', '1');
1288
+		}
1289
+		if ($localCookies) {
1290
+					$newSettings[] = array('localCookies', '1');
1291
+		}
1221 1292
 	}
1222 1293
 
1223 1294
 	// Are we allowing stat collection?
@@ -1235,16 +1306,17 @@  discard block
 block discarded – undo
1235 1306
 			fwrite($fp, $out);
1236 1307
 
1237 1308
 			$return_data = '';
1238
-			while (!feof($fp))
1239
-				$return_data .= fgets($fp, 128);
1309
+			while (!feof($fp)) {
1310
+							$return_data .= fgets($fp, 128);
1311
+			}
1240 1312
 
1241 1313
 			fclose($fp);
1242 1314
 
1243 1315
 			// Get the unique site ID.
1244 1316
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1245 1317
 
1246
-			if (!empty($ID[1]))
1247
-				$smcFunc['db_insert']('replace',
1318
+			if (!empty($ID[1])) {
1319
+							$smcFunc['db_insert']('replace',
1248 1320
 					$db_prefix . 'settings',
1249 1321
 					array('variable' => 'string', 'value' => 'string'),
1250 1322
 					array(
@@ -1253,11 +1325,12 @@  discard block
 block discarded – undo
1253 1325
 					),
1254 1326
 					array('variable')
1255 1327
 				);
1328
+			}
1256 1329
 		}
1257 1330
 	}
1258 1331
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1259
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1260
-		$smcFunc['db_query']('', '
1332
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1333
+			$smcFunc['db_query']('', '
1261 1334
 			DELETE FROM {db_prefix}settings
1262 1335
 			WHERE variable = {string:enable_sm_stats}',
1263 1336
 			array(
@@ -1265,20 +1338,23 @@  discard block
 block discarded – undo
1265 1338
 				'db_error_skip' => true,
1266 1339
 			)
1267 1340
 		);
1341
+	}
1268 1342
 
1269 1343
 	// Are we enabling SSL?
1270
-	if (!empty($_POST['force_ssl']))
1271
-		$newSettings[] = array('force_ssl', 2);
1344
+	if (!empty($_POST['force_ssl'])) {
1345
+			$newSettings[] = array('force_ssl', 2);
1346
+	}
1272 1347
 
1273 1348
 	// Setting a timezone is required.
1274 1349
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1275 1350
 	{
1276 1351
 		// Get PHP's default timezone, if set
1277 1352
 		$ini_tz = ini_get('date.timezone');
1278
-		if (!empty($ini_tz))
1279
-			$timezone_id = $ini_tz;
1280
-		else
1281
-			$timezone_id = '';
1353
+		if (!empty($ini_tz)) {
1354
+					$timezone_id = $ini_tz;
1355
+		} else {
1356
+					$timezone_id = '';
1357
+		}
1282 1358
 
1283 1359
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1284 1360
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1287,8 +1363,9 @@  discard block
 block discarded – undo
1287 1363
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1288 1364
 		}
1289 1365
 
1290
-		if (date_default_timezone_set($timezone_id))
1291
-			$newSettings[] = array('default_timezone', $timezone_id);
1366
+		if (date_default_timezone_set($timezone_id)) {
1367
+					$newSettings[] = array('default_timezone', $timezone_id);
1368
+		}
1292 1369
 	}
1293 1370
 
1294 1371
 	if (!empty($newSettings))
@@ -1319,16 +1396,18 @@  discard block
 block discarded – undo
1319 1396
 	}
1320 1397
 
1321 1398
 	// MySQL specific stuff
1322
-	if (substr($db_type, 0, 5) != 'mysql')
1323
-		return false;
1399
+	if (substr($db_type, 0, 5) != 'mysql') {
1400
+			return false;
1401
+	}
1324 1402
 
1325 1403
 	// Find database user privileges.
1326 1404
 	$privs = array();
1327 1405
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1328 1406
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1329 1407
 	{
1330
-		if ($row['Privilege'] == 'Alter')
1331
-			$privs[] = $row['Privilege'];
1408
+		if ($row['Privilege'] == 'Alter') {
1409
+					$privs[] = $row['Privilege'];
1410
+		}
1332 1411
 	}
1333 1412
 	$smcFunc['db_free_result']($get_privs);
1334 1413
 
@@ -1358,8 +1437,9 @@  discard block
 block discarded – undo
1358 1437
 	$incontext['continue'] = 1;
1359 1438
 
1360 1439
 	// Skipping?
1361
-	if (!empty($_POST['skip']))
1362
-		return true;
1440
+	if (!empty($_POST['skip'])) {
1441
+			return true;
1442
+	}
1363 1443
 
1364 1444
 	// Need this to check whether we need the database password.
1365 1445
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1376,18 +1456,22 @@  discard block
 block discarded – undo
1376 1456
 	// We need this to properly hash the password for Admin
1377 1457
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1378 1458
 			global $sourcedir;
1379
-			if (function_exists('mb_strtolower'))
1380
-				return mb_strtolower($string, 'UTF-8');
1459
+			if (function_exists('mb_strtolower')) {
1460
+							return mb_strtolower($string, 'UTF-8');
1461
+			}
1381 1462
 			require_once($sourcedir . '/Subs-Charset.php');
1382 1463
 			return utf8_strtolower($string);
1383 1464
 		};
1384 1465
 
1385
-	if (!isset($_POST['username']))
1386
-		$_POST['username'] = '';
1387
-	if (!isset($_POST['email']))
1388
-		$_POST['email'] = '';
1389
-	if (!isset($_POST['server_email']))
1390
-		$_POST['server_email'] = '';
1466
+	if (!isset($_POST['username'])) {
1467
+			$_POST['username'] = '';
1468
+	}
1469
+	if (!isset($_POST['email'])) {
1470
+			$_POST['email'] = '';
1471
+	}
1472
+	if (!isset($_POST['server_email'])) {
1473
+			$_POST['server_email'] = '';
1474
+	}
1391 1475
 
1392 1476
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1393 1477
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1406,8 +1490,9 @@  discard block
 block discarded – undo
1406 1490
 			'admin_group' => 1,
1407 1491
 		)
1408 1492
 	);
1409
-	if ($smcFunc['db_num_rows']($request) != 0)
1410
-		$incontext['skip'] = 1;
1493
+	if ($smcFunc['db_num_rows']($request) != 0) {
1494
+			$incontext['skip'] = 1;
1495
+	}
1411 1496
 	$smcFunc['db_free_result']($request);
1412 1497
 
1413 1498
 	// Trying to create an account?
@@ -1438,8 +1523,9 @@  discard block
 block discarded – undo
1438 1523
 		}
1439 1524
 
1440 1525
 		// Update the webmaster's email?
1441
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1442
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1526
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1527
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1528
+		}
1443 1529
 
1444 1530
 		// Work out whether we're going to have dodgy characters and remove them.
1445 1531
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1462,32 +1548,27 @@  discard block
 block discarded – undo
1462 1548
 			$smcFunc['db_free_result']($result);
1463 1549
 
1464 1550
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1465
-		}
1466
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1551
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1467 1552
 		{
1468 1553
 			// Try the previous step again.
1469 1554
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1470 1555
 			return false;
1471
-		}
1472
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1556
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1473 1557
 		{
1474 1558
 			// Try the previous step again.
1475 1559
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1476 1560
 			return false;
1477
-		}
1478
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1561
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1479 1562
 		{
1480 1563
 			// One step back, this time fill out a proper admin email address.
1481 1564
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1482 1565
 			return false;
1483
-		}
1484
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1566
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1485 1567
 		{
1486 1568
 			// One step back, this time fill out a proper admin email address.
1487 1569
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1488 1570
 			return false;
1489
-		}
1490
-		elseif ($_POST['username'] != '')
1571
+		} elseif ($_POST['username'] != '')
1491 1572
 		{
1492 1573
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1493 1574
 
@@ -1555,17 +1636,19 @@  discard block
 block discarded – undo
1555 1636
 	reloadSettings();
1556 1637
 
1557 1638
 	// Bring a warning over.
1558
-	if (!empty($incontext['account_existed']))
1559
-		$incontext['warning'] = $incontext['account_existed'];
1639
+	if (!empty($incontext['account_existed'])) {
1640
+			$incontext['warning'] = $incontext['account_existed'];
1641
+	}
1560 1642
 
1561
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1562
-		$smcFunc['db_query']('', '
1643
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1644
+			$smcFunc['db_query']('', '
1563 1645
 			SET NAMES {string:db_character_set}',
1564 1646
 			array(
1565 1647
 				'db_character_set' => $db_character_set,
1566 1648
 				'db_error_skip' => true,
1567 1649
 			)
1568 1650
 		);
1651
+	}
1569 1652
 
1570 1653
 	// As track stats is by default enabled let's add some activity.
1571 1654
 	$smcFunc['db_insert']('ignore',
@@ -1586,14 +1669,16 @@  discard block
 block discarded – undo
1586 1669
 	// Only proceed if we can load the data.
1587 1670
 	if ($request)
1588 1671
 	{
1589
-		while ($row = $smcFunc['db_fetch_row']($request))
1590
-			$modSettings[$row[0]] = $row[1];
1672
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1673
+					$modSettings[$row[0]] = $row[1];
1674
+		}
1591 1675
 		$smcFunc['db_free_result']($request);
1592 1676
 	}
1593 1677
 
1594 1678
 	// Automatically log them in ;)
1595
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1596
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1679
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1680
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1681
+	}
1597 1682
 
1598 1683
 	$result = $smcFunc['db_query']('', '
1599 1684
 		SELECT value
@@ -1604,13 +1689,14 @@  discard block
 block discarded – undo
1604 1689
 			'db_error_skip' => true,
1605 1690
 		)
1606 1691
 	);
1607
-	if ($smcFunc['db_num_rows']($result) != 0)
1608
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1692
+	if ($smcFunc['db_num_rows']($result) != 0) {
1693
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1694
+	}
1609 1695
 	$smcFunc['db_free_result']($result);
1610 1696
 
1611
-	if (empty($db_sessions))
1612
-		$_SESSION['admin_time'] = time();
1613
-	else
1697
+	if (empty($db_sessions)) {
1698
+			$_SESSION['admin_time'] = time();
1699
+	} else
1614 1700
 	{
1615 1701
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1616 1702
 
@@ -1634,8 +1720,9 @@  discard block
 block discarded – undo
1634 1720
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1635 1721
 		function($string){
1636 1722
 			global $sourcedir;
1637
-			if (function_exists('mb_strtolower'))
1638
-				return mb_strtolower($string, 'UTF-8');
1723
+			if (function_exists('mb_strtolower')) {
1724
+							return mb_strtolower($string, 'UTF-8');
1725
+			}
1639 1726
 			require_once($sourcedir . '/Subs-Charset.php');
1640 1727
 			return utf8_strtolower($string);
1641 1728
 		};
@@ -1651,8 +1738,9 @@  discard block
 block discarded – undo
1651 1738
 		)
1652 1739
 	);
1653 1740
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1654
-	if ($smcFunc['db_num_rows']($request) > 0)
1655
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1741
+	if ($smcFunc['db_num_rows']($request) > 0) {
1742
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1743
+	}
1656 1744
 	$smcFunc['db_free_result']($request);
1657 1745
 
1658 1746
 	// Now is the perfect time to fetch the SM files.
@@ -1671,8 +1759,9 @@  discard block
 block discarded – undo
1671 1759
 
1672 1760
 	// Check if we need some stupid MySQL fix.
1673 1761
 	$server_version = $smcFunc['db_server_info']();
1674
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1675
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1762
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1763
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1764
+	}
1676 1765
 
1677 1766
 	// Some final context for the template.
1678 1767
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1692,8 +1781,9 @@  discard block
 block discarded – undo
1692 1781
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1693 1782
 
1694 1783
 	// @todo Do we just want to read the file in clean, and split it this way always?
1695
-	if (count($settingsArray) == 1)
1696
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1784
+	if (count($settingsArray) == 1) {
1785
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1786
+	}
1697 1787
 
1698 1788
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1699 1789
 	{
@@ -1708,19 +1798,22 @@  discard block
 block discarded – undo
1708 1798
 			continue;
1709 1799
 		}
1710 1800
 
1711
-		if (trim($settingsArray[$i]) == '?' . '>')
1712
-			$settingsArray[$i] = '';
1801
+		if (trim($settingsArray[$i]) == '?' . '>') {
1802
+					$settingsArray[$i] = '';
1803
+		}
1713 1804
 
1714 1805
 		// Don't trim or bother with it if it's not a variable.
1715
-		if (substr($settingsArray[$i], 0, 1) != '$')
1716
-			continue;
1806
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1807
+					continue;
1808
+		}
1717 1809
 
1718 1810
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1719 1811
 
1720
-		foreach ($vars as $var => $val)
1721
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1812
+		foreach ($vars as $var => $val) {
1813
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1722 1814
 			{
1723 1815
 				$comment = strstr($settingsArray[$i], '#');
1816
+		}
1724 1817
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1725 1818
 				unset($vars[$var]);
1726 1819
 			}
@@ -1730,36 +1823,41 @@  discard block
 block discarded – undo
1730 1823
 	if (!empty($vars))
1731 1824
 	{
1732 1825
 		$settingsArray[$i++] = '';
1733
-		foreach ($vars as $var => $val)
1734
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1826
+		foreach ($vars as $var => $val) {
1827
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1828
+		}
1735 1829
 	}
1736 1830
 
1737 1831
 	// Blank out the file - done to fix a oddity with some servers.
1738 1832
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1739
-	if (!$fp)
1740
-		return false;
1833
+	if (!$fp) {
1834
+			return false;
1835
+	}
1741 1836
 	fclose($fp);
1742 1837
 
1743 1838
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1744 1839
 
1745 1840
 	// Gotta have one of these ;)
1746
-	if (trim($settingsArray[0]) != '<?php')
1747
-		fwrite($fp, "<?php\n");
1841
+	if (trim($settingsArray[0]) != '<?php') {
1842
+			fwrite($fp, "<?php\n");
1843
+	}
1748 1844
 
1749 1845
 	$lines = count($settingsArray);
1750 1846
 	for ($i = 0; $i < $lines - 1; $i++)
1751 1847
 	{
1752 1848
 		// Don't just write a bunch of blank lines.
1753
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1754
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1849
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1850
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1851
+		}
1755 1852
 	}
1756 1853
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1757 1854
 	fclose($fp);
1758 1855
 
1759 1856
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1760 1857
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1761
-	if (function_exists('opcache_invalidate'))
1762
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1858
+	if (function_exists('opcache_invalidate')) {
1859
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1860
+	}
1763 1861
 
1764 1862
 	return true;
1765 1863
 }
@@ -1784,9 +1882,9 @@  discard block
 block discarded – undo
1784 1882
 	SecFilterScanPOST Off
1785 1883
 </IfModule>';
1786 1884
 
1787
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1788
-		return true;
1789
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1885
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1886
+			return true;
1887
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1790 1888
 	{
1791 1889
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1792 1890
 
@@ -1798,29 +1896,28 @@  discard block
 block discarded – undo
1798 1896
 				fwrite($ht_handle, $htaccess_addition);
1799 1897
 				fclose($ht_handle);
1800 1898
 				return true;
1899
+			} else {
1900
+							return false;
1801 1901
 			}
1802
-			else
1803
-				return false;
1902
+		} else {
1903
+					return true;
1804 1904
 		}
1805
-		else
1806
-			return true;
1807
-	}
1808
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1809
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1810
-	elseif (is_writable(dirname(__FILE__)))
1905
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1906
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1907
+	} elseif (is_writable(dirname(__FILE__)))
1811 1908
 	{
1812 1909
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1813 1910
 		{
1814 1911
 			fwrite($ht_handle, $htaccess_addition);
1815 1912
 			fclose($ht_handle);
1816 1913
 			return true;
1914
+		} else {
1915
+					return false;
1817 1916
 		}
1818
-		else
1917
+	} else {
1819 1918
 			return false;
1820 1919
 	}
1821
-	else
1822
-		return false;
1823
-}
1920
+	}
1824 1921
 
1825 1922
 function template_install_above()
1826 1923
 {
@@ -1858,9 +1955,10 @@  discard block
 block discarded – undo
1858 1955
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1859 1956
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1860 1957
 
1861
-		foreach ($incontext['detected_languages'] as $lang => $name)
1862
-			echo '
1958
+		foreach ($incontext['detected_languages'] as $lang => $name) {
1959
+					echo '
1863 1960
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
1961
+		}
1864 1962
 
1865 1963
 		echo '
1866 1964
 								</select>
@@ -1880,9 +1978,10 @@  discard block
 block discarded – undo
1880 1978
 						<h2>', $txt['upgrade_progress'], '</h2>
1881 1979
 						<ul>';
1882 1980
 
1883
-	foreach ($incontext['steps'] as $num => $step)
1884
-		echo '
1981
+	foreach ($incontext['steps'] as $num => $step) {
1982
+			echo '
1885 1983
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
1984
+	}
1886 1985
 
1887 1986
 	echo '
1888 1987
 						</ul>
@@ -1907,20 +2006,23 @@  discard block
 block discarded – undo
1907 2006
 		echo '
1908 2007
 								<div>';
1909 2008
 
1910
-		if (!empty($incontext['continue']))
1911
-			echo '
2009
+		if (!empty($incontext['continue'])) {
2010
+					echo '
1912 2011
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1913
-		if (!empty($incontext['skip']))
1914
-			echo '
2012
+		}
2013
+		if (!empty($incontext['skip'])) {
2014
+					echo '
1915 2015
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
2016
+		}
1916 2017
 		echo '
1917 2018
 								</div>';
1918 2019
 	}
1919 2020
 
1920 2021
 	// Show the closing form tag and other data only if not in the last step
1921
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1922
-		echo '
2022
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2023
+			echo '
1923 2024
 							</form>';
2025
+	}
1924 2026
 
1925 2027
 	echo '
1926 2028
 						</div>
@@ -1955,13 +2057,15 @@  discard block
 block discarded – undo
1955 2057
 		</div>';
1956 2058
 
1957 2059
 	// Show the warnings, or not.
1958
-	if (template_warning_divs())
1959
-		echo '
2060
+	if (template_warning_divs()) {
2061
+			echo '
1960 2062
 		<h3>', $txt['install_all_lovely'], '</h3>';
2063
+	}
1961 2064
 
1962 2065
 	// Say we want the continue button!
1963
-	if (empty($incontext['error']))
1964
-		$incontext['continue'] = 1;
2066
+	if (empty($incontext['error'])) {
2067
+			$incontext['continue'] = 1;
2068
+	}
1965 2069
 
1966 2070
 	// For the latest version stuff.
1967 2071
 	echo '
@@ -1995,8 +2099,8 @@  discard block
 block discarded – undo
1995 2099
 	global $txt, $incontext;
1996 2100
 
1997 2101
 	// Errors are very serious..
1998
-	if (!empty($incontext['error']))
1999
-		echo '
2102
+	if (!empty($incontext['error'])) {
2103
+			echo '
2000 2104
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2001 2105
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2002 2106
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -2004,9 +2108,10 @@  discard block
 block discarded – undo
2004 2108
 				', $incontext['error'], '
2005 2109
 			</div>
2006 2110
 		</div>';
2111
+	}
2007 2112
 	// A warning message?
2008
-	elseif (!empty($incontext['warning']))
2009
-		echo '
2113
+	elseif (!empty($incontext['warning'])) {
2114
+			echo '
2010 2115
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2011 2116
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2012 2117
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -2014,6 +2119,7 @@  discard block
 block discarded – undo
2014 2119
 				', $incontext['warning'], '
2015 2120
 			</div>
2016 2121
 		</div>';
2122
+	}
2017 2123
 
2018 2124
 	return empty($incontext['error']) && empty($incontext['warning']);
2019 2125
 }
@@ -2029,27 +2135,30 @@  discard block
 block discarded – undo
2029 2135
 			<li>', $incontext['failed_files']), '</li>
2030 2136
 		</ul>';
2031 2137
 
2032
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2033
-		echo '
2138
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2139
+			echo '
2034 2140
 		<hr>
2035 2141
 		<p>', $txt['chmod_linux_info'], '</p>
2036 2142
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2143
+	}
2037 2144
 
2038 2145
 	// This is serious!
2039
-	if (!template_warning_divs())
2040
-		return;
2146
+	if (!template_warning_divs()) {
2147
+			return;
2148
+	}
2041 2149
 
2042 2150
 	echo '
2043 2151
 		<hr>
2044 2152
 		<p>', $txt['ftp_setup_info'], '</p>';
2045 2153
 
2046
-	if (!empty($incontext['ftp_errors']))
2047
-		echo '
2154
+	if (!empty($incontext['ftp_errors'])) {
2155
+			echo '
2048 2156
 		<div class="error_message">
2049 2157
 			', $txt['error_ftp_no_connect'], '<br><br>
2050 2158
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2051 2159
 		</div>
2052 2160
 		<br>';
2161
+	}
2053 2162
 
2054 2163
 	echo '
2055 2164
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2109,17 +2218,17 @@  discard block
 block discarded – undo
2109 2218
 				<td>
2110 2219
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2111 2220
 
2112
-	foreach ($incontext['supported_databases'] as $key => $db)
2113
-			echo '
2221
+	foreach ($incontext['supported_databases'] as $key => $db) {
2222
+				echo '
2114 2223
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2224
+	}
2115 2225
 
2116 2226
 	echo '
2117 2227
 					</select>
2118 2228
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2119 2229
 				</td>
2120 2230
 			</tr>';
2121
-	}
2122
-	else
2231
+	} else
2123 2232
 	{
2124 2233
 		echo '
2125 2234
 			<tr style="display: none;">
@@ -2311,9 +2420,10 @@  discard block
 block discarded – undo
2311 2420
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2312 2421
 				<ul>';
2313 2422
 
2314
-		foreach ($incontext['failures'] as $line => $fail)
2315
-			echo '
2423
+		foreach ($incontext['failures'] as $line => $fail) {
2424
+					echo '
2316 2425
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2426
+		}
2317 2427
 
2318 2428
 		echo '
2319 2429
 				</ul>';
@@ -2374,15 +2484,16 @@  discard block
 block discarded – undo
2374 2484
 			</tr>
2375 2485
 		</table>';
2376 2486
 
2377
-	if ($incontext['require_db_confirm'])
2378
-		echo '
2487
+	if ($incontext['require_db_confirm']) {
2488
+			echo '
2379 2489
 		<h2>', $txt['user_settings_database'], '</h2>
2380 2490
 		<p>', $txt['user_settings_database_info'], '</p>
2381 2491
 
2382 2492
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2383 2493
 			<input type="password" name="password3" size="30" class="input_password" />
2384 2494
 		</div>';
2385
-}
2495
+	}
2496
+	}
2386 2497
 
2387 2498
 // Tell them it's done, and to delete.
2388 2499
 function template_delete_install()
@@ -2395,14 +2506,15 @@  discard block
 block discarded – undo
2395 2506
 	template_warning_divs();
2396 2507
 
2397 2508
 	// Install directory still writable?
2398
-	if ($incontext['dir_still_writable'])
2399
-		echo '
2509
+	if ($incontext['dir_still_writable']) {
2510
+			echo '
2400 2511
 		<em>', $txt['still_writable'], '</em><br>
2401 2512
 		<br>';
2513
+	}
2402 2514
 
2403 2515
 	// Don't show the box if it's like 99% sure it won't work :P.
2404
-	if ($incontext['probably_delete_install'])
2405
-		echo '
2516
+	if ($incontext['probably_delete_install']) {
2517
+			echo '
2406 2518
 		<div style="margin: 1ex; font-weight: bold;">
2407 2519
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2408 2520
 		</div>
@@ -2418,6 +2530,7 @@  discard block
 block discarded – undo
2418 2530
 			}
2419 2531
 		</script>
2420 2532
 		<br>';
2533
+	}
2421 2534
 
2422 2535
 	echo '
2423 2536
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.
Sources/CacheAPI-zend.php 1 patch
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 	{
28 29
 		$supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get');
29 30
 
30
-		if ($test)
31
-			return $supported;
31
+		if ($test) {
32
+					return $supported;
33
+		}
32 34
 		return parent::isSupported() && $supported;
33 35
 	}
34 36
 
@@ -40,10 +42,11 @@  discard block
 block discarded – undo
40 42
 		$key = $this->prefix . strtr($key, ':/', '-_');
41 43
 
42 44
 		// Zend's pricey stuff.
43
-		if (function_exists('zend_shm_cache_fetch'))
44
-			return zend_shm_cache_fetch('SMF::' . $key);
45
-		elseif (function_exists('output_cache_get'))
46
-			return output_cache_get($key, $ttl);
45
+		if (function_exists('zend_shm_cache_fetch')) {
46
+					return zend_shm_cache_fetch('SMF::' . $key);
47
+		} elseif (function_exists('output_cache_get')) {
48
+					return output_cache_get($key, $ttl);
49
+		}
47 50
 	}
48 51
 
49 52
 	/**
@@ -53,10 +56,11 @@  discard block
 block discarded – undo
53 56
 	{
54 57
 		$key = $this->prefix . strtr($key, ':/', '-_');
55 58
 
56
-		if (function_exists('zend_shm_cache_store'))
57
-			return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
58
-		elseif (function_exists('output_cache_put'))
59
-			return output_cache_put($key, $value);
59
+		if (function_exists('zend_shm_cache_store')) {
60
+					return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
61
+		} elseif (function_exists('output_cache_put')) {
62
+					return output_cache_put($key, $value);
63
+		}
60 64
 	}
61 65
 
62 66
 	/**
Please login to merge, or discard this patch.