Completed
Push — release-2.1 ( 4bdd41...11eb43 )
by Mathias
07:36
created
Sources/Calendar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -240,8 +240,8 @@
 block discarded – undo
240 240
 		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
241 241
 
242 242
 	$js_time_string = str_replace(
243
-		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
244
-		array('H',  'G',  'h',  'g',  'i',  'A',  'a',  'h:i:s A', 'H:i', 's',  'H:i:s', 'H:i:s'),
243
+		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'),
244
+		array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'),
245 245
 		$time_string
246 246
 	);
247 247
 
Please login to merge, or discard this patch.
Braces   +122 added lines, -97 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Show the calendar.
@@ -47,12 +48,14 @@  discard block
 block discarded – undo
47 48
 		'post' => 'CalendarPost',
48 49
 	);
49 50
 
50
-	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']]))
51
-		return call_helper($subActions[$_GET['sa']]);
51
+	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) {
52
+			return call_helper($subActions[$_GET['sa']]);
53
+	}
52 54
 
53 55
 	// You can't do anything if the calendar is off.
54
-	if (empty($modSettings['cal_enabled']))
55
-		fatal_lang_error('calendar_off', false);
56
+	if (empty($modSettings['cal_enabled'])) {
57
+			fatal_lang_error('calendar_off', false);
58
+	}
56 59
 
57 60
 	// This is gonna be needed...
58 61
 	loadTemplate('Calendar');
@@ -88,22 +91,25 @@  discard block
 block discarded – undo
88 91
 	$context['page_title'] = $txt['calendar'];
89 92
 
90 93
 	// Ensure a default view is defined
91
-	if (empty($modSettings['calendar_default_view']))
92
-		$modSettings['calendar_default_view'] = 'viewlist';
94
+	if (empty($modSettings['calendar_default_view'])) {
95
+			$modSettings['calendar_default_view'] = 'viewlist';
96
+	}
93 97
 
94 98
 	// What view do we want?
95
-	if (isset($_GET['viewweek']))
96
-		$context['calendar_view'] = 'viewweek';
97
-	elseif (isset($_GET['viewmonth']))
98
-		$context['calendar_view'] = 'viewmonth';
99
-	elseif (isset($_GET['viewlist']))
100
-		$context['calendar_view'] = 'viewlist';
101
-	else
102
-		$context['calendar_view'] = $modSettings['calendar_default_view'];
99
+	if (isset($_GET['viewweek'])) {
100
+			$context['calendar_view'] = 'viewweek';
101
+	} elseif (isset($_GET['viewmonth'])) {
102
+			$context['calendar_view'] = 'viewmonth';
103
+	} elseif (isset($_GET['viewlist'])) {
104
+			$context['calendar_view'] = 'viewlist';
105
+	} else {
106
+			$context['calendar_view'] = $modSettings['calendar_default_view'];
107
+	}
103 108
 
104 109
 	// Don't let search engines index the non-default calendar pages
105
-	if ($context['calendar_view'] !== $modSettings['calendar_default_view'])
106
-		$context['robot_no_index'] = true;
110
+	if ($context['calendar_view'] !== $modSettings['calendar_default_view']) {
111
+			$context['robot_no_index'] = true;
112
+	}
107 113
 
108 114
 	// Get the current day of month...
109 115
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -164,16 +170,19 @@  discard block
 block discarded – undo
164 170
 	);
165 171
 
166 172
 	// Make sure the year and month are in valid ranges.
167
-	if ($curPage['month'] < 1 || $curPage['month'] > 12)
168
-		fatal_lang_error('invalid_month', false);
169
-	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear'])
170
-		fatal_lang_error('invalid_year', false);
173
+	if ($curPage['month'] < 1 || $curPage['month'] > 12) {
174
+			fatal_lang_error('invalid_month', false);
175
+	}
176
+	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) {
177
+			fatal_lang_error('invalid_year', false);
178
+	}
171 179
 	// If we have a day clean that too.
172 180
 	if ($context['calendar_view'] != 'viewmonth')
173 181
 	{
174 182
 		$isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']);
175
-		if (!$isValid)
176
-			fatal_lang_error('invalid_day', false);
183
+		if (!$isValid) {
184
+					fatal_lang_error('invalid_day', false);
185
+		}
177 186
 	}
178 187
 
179 188
 	// Load all the context information needed to show the calendar grid.
@@ -195,23 +204,26 @@  discard block
 block discarded – undo
195 204
 	);
196 205
 
197 206
 	// Load up the main view.
198
-	if ($context['calendar_view'] == 'viewlist')
199
-		$context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions);
200
-	elseif ($context['calendar_view'] == 'viewweek')
201
-		$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
202
-	else
203
-		$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
207
+	if ($context['calendar_view'] == 'viewlist') {
208
+			$context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions);
209
+	} elseif ($context['calendar_view'] == 'viewweek') {
210
+			$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
211
+	} else {
212
+			$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
213
+	}
204 214
 
205 215
 	// Load up the previous and next months.
206 216
 	$context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
207 217
 
208 218
 	// Only show previous month if it isn't pre-January of the min-year
209
-	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1)
210
-		$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
219
+	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) {
220
+			$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
221
+	}
211 222
 
212 223
 	// Only show next month if it isn't post-December of the max-year
213
-	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12)
214
-		$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
224
+	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) {
225
+			$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
226
+	}
215 227
 
216 228
 	// Basic template stuff.
217 229
 	$context['allow_calendar_event'] = allowedTo('calendar_post');
@@ -231,8 +243,9 @@  discard block
 block discarded – undo
231 243
 	$context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0;
232 244
 
233 245
 	// Set the page title to mention the month or week, too
234
-	if ($context['calendar_view'] != 'viewlist')
235
-		$context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
246
+	if ($context['calendar_view'] != 'viewlist') {
247
+			$context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
248
+	}
236 249
 
237 250
 	// Load up the linktree!
238 251
 	$context['linktree'][] = array(
@@ -245,17 +258,19 @@  discard block
 block discarded – undo
245 258
 		'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year']
246 259
 	);
247 260
 	// If applicable, add the current week to the linktree.
248
-	if ($context['calendar_view'] == 'viewweek')
249
-		$context['linktree'][] = array(
261
+	if ($context['calendar_view'] == 'viewweek') {
262
+			$context['linktree'][] = array(
250 263
 			'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'],
251 264
 			'name' => $context['calendar_grid_main']['week_title'],
252 265
 		);
266
+	}
253 267
 
254 268
 	// Build the calendar button array.
255 269
 	$context['calendar_buttons'] = array();
256 270
 
257
-	if ($context['can_post'])
258
-		$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
271
+	if ($context['can_post']) {
272
+			$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
273
+	}
259 274
 
260 275
 	// Allow mods to add additional buttons here
261 276
 	call_integration_hook('integrate_calendar_buttons');
@@ -284,14 +299,16 @@  discard block
 block discarded – undo
284 299
 	require_once($sourcedir . '/Subs.php');
285 300
 
286 301
 	// Cast this for safety...
287
-	if (isset($_REQUEST['eventid']))
288
-		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
302
+	if (isset($_REQUEST['eventid'])) {
303
+			$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
304
+	}
289 305
 
290 306
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
291
-	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
292
-		$time_string = '%k:%M';
293
-	else
294
-		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
307
+	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
308
+			$time_string = '%k:%M';
309
+	} else {
310
+			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
311
+	}
295 312
 
296 313
 	$js_time_string = str_replace(
297 314
 		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -305,12 +322,14 @@  discard block
 block discarded – undo
305 322
 		checkSession();
306 323
 
307 324
 		// Validate the post...
308
-		if (!isset($_POST['link_to_board']))
309
-			validateEventPost();
325
+		if (!isset($_POST['link_to_board'])) {
326
+					validateEventPost();
327
+		}
310 328
 
311 329
 		// If you're not allowed to edit any events, you have to be the poster.
312
-		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any'))
313
-			isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
330
+		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) {
331
+					isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
332
+		}
314 333
 
315 334
 		// New - and directing?
316 335
 		if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked']))
@@ -333,8 +352,9 @@  discard block
 block discarded – undo
333 352
 		}
334 353
 
335 354
 		// Deleting...
336
-		elseif (isset($_REQUEST['deleteevent']))
337
-			removeEvent($_REQUEST['eventid']);
355
+		elseif (isset($_REQUEST['deleteevent'])) {
356
+					removeEvent($_REQUEST['eventid']);
357
+		}
338 358
 
339 359
 		// ... or just update it?
340 360
 		else
@@ -357,15 +377,13 @@  discard block
 block discarded – undo
357 377
 			$year = $d['year'];
358 378
 			$month = $d['month'];
359 379
 			$day = $d['day'];
360
-		}
361
-		elseif (isset($_POST['start_datetime']))
380
+		} elseif (isset($_POST['start_datetime']))
362 381
 		{
363 382
 			$d = date_parse($_POST['start_datetime']);
364 383
 			$year = $d['year'];
365 384
 			$month = $d['month'];
366 385
 			$day = $d['day'];
367
-		}
368
-		else
386
+		} else
369 387
 		{
370 388
 			$today = getdate();
371 389
 			$year = isset($_POST['year']) ? $_POST['year'] : $today['year'];
@@ -399,13 +417,13 @@  discard block
 block discarded – undo
399 417
 		$context['event'] = array_merge($context['event'], $eventDatetimes);
400 418
 
401 419
 		$context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year']));
402
-	}
403
-	else
420
+	} else
404 421
 	{
405 422
 		$context['event'] = getEventProperties($_REQUEST['eventid']);
406 423
 
407
-		if ($context['event'] === false)
408
-			fatal_lang_error('no_access', false);
424
+		if ($context['event'] === false) {
425
+					fatal_lang_error('no_access', false);
426
+		}
409 427
 
410 428
 		// If it has a board, then they should be editing it within the topic.
411 429
 		if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg']))
@@ -416,10 +434,11 @@  discard block
 block discarded – undo
416 434
 		}
417 435
 
418 436
 		// Make sure the user is allowed to edit this event.
419
-		if ($context['event']['member'] != $user_info['id'])
420
-			isAllowedTo('calendar_edit_any');
421
-		elseif (!allowedTo('calendar_edit_any'))
422
-			isAllowedTo('calendar_edit_own');
437
+		if ($context['event']['member'] != $user_info['id']) {
438
+					isAllowedTo('calendar_edit_any');
439
+		} elseif (!allowedTo('calendar_edit_any')) {
440
+					isAllowedTo('calendar_edit_own');
441
+		}
423 442
 	}
424 443
 
425 444
 	// An all day event? Set up some nice defaults in case the user wants to change that
@@ -453,8 +472,7 @@  discard block
 block discarded – undo
453 472
 	{
454 473
 		// You can post new events but can't link them to anything...
455 474
 		$context['event']['categories'] = array();
456
-	}
457
-	else
475
+	} else
458 476
 	{
459 477
 		// Load the list of boards and categories in the context.
460 478
 		require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -541,12 +559,14 @@  discard block
 block discarded – undo
541 559
 	global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname;
542 560
 
543 561
 	// You can't export if the calendar export feature is off.
544
-	if (empty($modSettings['cal_export']))
545
-		fatal_lang_error('calendar_export_off', false);
562
+	if (empty($modSettings['cal_export'])) {
563
+			fatal_lang_error('calendar_export_off', false);
564
+	}
546 565
 
547 566
 	// Goes without saying that this is required.
548
-	if (!isset($_REQUEST['eventid']))
549
-		fatal_lang_error('no_access', false);
567
+	if (!isset($_REQUEST['eventid'])) {
568
+			fatal_lang_error('no_access', false);
569
+	}
550 570
 
551 571
 	// This is kinda wanted.
552 572
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -554,15 +574,17 @@  discard block
 block discarded – undo
554 574
 	// Load up the event in question and check it exists.
555 575
 	$event = getEventProperties($_REQUEST['eventid']);
556 576
 
557
-	if ($event === false)
558
-		fatal_lang_error('no_access', false);
577
+	if ($event === false) {
578
+			fatal_lang_error('no_access', false);
579
+	}
559 580
 
560 581
 	// Check the title isn't too long - iCal requires some formatting if so.
561 582
 	$title = str_split($event['title'], 30);
562 583
 	foreach ($title as $id => $line)
563 584
 	{
564
-		if ($id != 0)
565
-			$title[$id] = ' ' . $title[$id];
585
+		if ($id != 0) {
586
+					$title[$id] = ' ' . $title[$id];
587
+		}
566 588
 		$title[$id] .= "\n";
567 589
 	}
568 590
 
@@ -575,8 +597,7 @@  discard block
 block discarded – undo
575 597
 	{
576 598
 		$datestart = date_format($start_date, 'Ymd\THis');
577 599
 		$dateend = date_format($end_date, 'Ymd\THis');
578
-	}
579
-	else
600
+	} else
580 601
 	{
581 602
 		$datestart = date_format($start_date, 'Ymd');
582 603
 
@@ -597,15 +618,18 @@  discard block
 block discarded – undo
597 618
 	$filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n";
598 619
 
599 620
 	// event has a duration
600
-	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate'])
601
-		$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
621
+	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) {
622
+			$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
623
+	}
602 624
 
603 625
 	// event has changed? advance the sequence for this UID
604
-	if ($event['sequence'] > 0)
605
-		$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
626
+	if ($event['sequence'] > 0) {
627
+			$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
628
+	}
606 629
 
607
-	if (!empty($event['location']))
608
-		$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
630
+	if (!empty($event['location'])) {
631
+			$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
632
+	}
609 633
 
610 634
 	$filecontents .= 'SUMMARY:' . implode('', $title);
611 635
 	$filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n";
@@ -614,23 +638,26 @@  discard block
 block discarded – undo
614 638
 
615 639
 	// Send some standard headers.
616 640
 	ob_end_clean();
617
-	if (!empty($modSettings['enableCompressedOutput']))
618
-		@ob_start('ob_gzhandler');
619
-	else
620
-		ob_start();
641
+	if (!empty($modSettings['enableCompressedOutput'])) {
642
+			@ob_start('ob_gzhandler');
643
+	} else {
644
+			ob_start();
645
+	}
621 646
 
622 647
 	// Send the file headers
623 648
 	header('Pragma: ');
624 649
 	header('Cache-Control: no-cache');
625
-	if (!isBrowser('gecko'))
626
-		header('Content-Transfer-Encoding: binary');
650
+	if (!isBrowser('gecko')) {
651
+			header('Content-Transfer-Encoding: binary');
652
+	}
627 653
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
628 654
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
629 655
 	header('Accept-Ranges: bytes');
630 656
 	header('Connection: close');
631 657
 	header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"');
632
-	if (empty($modSettings['enableCompressedOutput']))
633
-		header('Content-Length: ' . $smcFunc['strlen']($filecontents));
658
+	if (empty($modSettings['enableCompressedOutput'])) {
659
+			header('Content-Length: ' . $smcFunc['strlen']($filecontents));
660
+	}
634 661
 
635 662
 	// This is a calendar item!
636 663
 	header('Content-Type: text/calendar');
@@ -669,20 +696,17 @@  discard block
 block discarded – undo
669 696
 		$context['sub_template'] = 'bcd';
670 697
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD');
671 698
 		$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true);
672
-	}
673
-	elseif (!$omfg && !isset($_REQUEST['time']))
699
+	} elseif (!$omfg && !isset($_REQUEST['time']))
674 700
 	{
675 701
 		$context['sub_template'] = 'hms';
676 702
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary');
677 703
 		$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true);
678
-	}
679
-	elseif ($omfg)
704
+	} elseif ($omfg)
680 705
 	{
681 706
 		$context['sub_template'] = 'omfg';
682 707
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG');
683 708
 		$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true);
684
-	}
685
-	elseif (isset($_REQUEST['time']))
709
+	} elseif (isset($_REQUEST['time']))
686 710
 	{
687 711
 		$context['sub_template'] = 'thetime';
688 712
 		$time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']);
@@ -736,12 +760,13 @@  discard block
 block discarded – undo
736 760
 			),
737 761
 		);
738 762
 
739
-		foreach ($context['clockicons'] as $t => $vs)
740
-			foreach ($vs as $v => $dumb)
763
+		foreach ($context['clockicons'] as $t => $vs) {
764
+					foreach ($vs as $v => $dumb)
741 765
 			{
742 766
 				if ($$t >= $v)
743 767
 				{
744 768
 					$$t -= $v;
769
+		}
745 770
 					$context['clockicons'][$t][$v] = true;
746 771
 				}
747 772
 			}
Please login to merge, or discard this patch.
other/install.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1619,8 +1619,7 @@
 block discarded – undo
1619 1619
 	updateStats('topic');
1620 1620
 
1621 1621
 	// This function is needed to do the updateStats('subject') call.
1622
-	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1623
-		function($string){
1622
+	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1624 1623
 			global $sourcedir;
1625 1624
 			if (function_exists('mb_strtolower'))
1626 1625
 				return mb_strtolower($string, 'UTF-8');
Please login to merge, or discard this patch.
Braces   +452 added lines, -336 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 for fatal errors.
154 160
 	error_reporting(E_ERROR | E_PARSE);
@@ -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,45 +473,54 @@  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
 	// Confirm mbstring is loaded...
485
-	if (!extension_loaded('mbstring'))
486
-		$incontext['error'] = $txt['install_no_mbstring'];
515
+	if (!extension_loaded('mbstring')) {
516
+			$incontext['error'] = $txt['install_no_mbstring'];
517
+	}
487 518
 
488 519
 	// Check for https stream support.
489 520
 	$supported_streams = stream_get_wrappers();
490
-	if (!in_array('https', $supported_streams))
491
-		$incontext['warning'] = $txt['install_no_https'];
521
+	if (!in_array('https', $supported_streams)) {
522
+			$incontext['warning'] = $txt['install_no_https'];
523
+	}
492 524
 
493 525
 	return false;
494 526
 }
@@ -514,12 +546,14 @@  discard block
 block discarded – undo
514 546
 		'db_last_error.php',
515 547
 	);
516 548
 
517
-	foreach ($incontext['detected_languages'] as $lang => $temp)
518
-		$extra_files[] = 'Themes/default/languages/' . $lang;
549
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
550
+			$extra_files[] = 'Themes/default/languages/' . $lang;
551
+	}
519 552
 
520 553
 	// With mod_security installed, we could attempt to fix it with .htaccess.
521
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
522
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
554
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
555
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
556
+	}
523 557
 
524 558
 	$failed_files = array();
525 559
 
@@ -531,20 +565,23 @@  discard block
 block discarded – undo
531 565
 		foreach ($writable_files as $file)
532 566
 		{
533 567
 			// Some files won't exist, try to address up front
534
-			if (!file_exists(dirname(__FILE__) . '/' . $file))
535
-				@touch(dirname(__FILE__) . '/' . $file);
568
+			if (!file_exists(dirname(__FILE__) . '/' . $file)) {
569
+							@touch(dirname(__FILE__) . '/' . $file);
570
+			}
536 571
 			// NOW do the writable check...
537 572
 			if (!is_writable(dirname(__FILE__) . '/' . $file))
538 573
 			{
539 574
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
540 575
 
541 576
 				// Well, 755 hopefully worked... if not, try 777.
542
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
543
-					$failed_files[] = $file;
577
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
578
+									$failed_files[] = $file;
579
+				}
544 580
 			}
545 581
 		}
546
-		foreach ($extra_files as $file)
547
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
582
+		foreach ($extra_files as $file) {
583
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
584
+		}
548 585
 	}
549 586
 	// Windows is trickier.  Let's try opening for r+...
550 587
 	else
@@ -554,30 +591,35 @@  discard block
 block discarded – undo
554 591
 		foreach ($writable_files as $file)
555 592
 		{
556 593
 			// Folders can't be opened for write... but the index.php in them can ;)
557
-			if (is_dir(dirname(__FILE__) . '/' . $file))
558
-				$file .= '/index.php';
594
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
595
+							$file .= '/index.php';
596
+			}
559 597
 
560 598
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
561 599
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
562 600
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
563 601
 
564 602
 			// Hmm, okay, try just for write in that case...
565
-			if (!is_resource($fp))
566
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
603
+			if (!is_resource($fp)) {
604
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
605
+			}
567 606
 
568
-			if (!is_resource($fp))
569
-				$failed_files[] = $file;
607
+			if (!is_resource($fp)) {
608
+							$failed_files[] = $file;
609
+			}
570 610
 
571 611
 			@fclose($fp);
572 612
 		}
573
-		foreach ($extra_files as $file)
574
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
613
+		foreach ($extra_files as $file) {
614
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
615
+		}
575 616
 	}
576 617
 
577 618
 	$failure = count($failed_files) >= 1;
578 619
 
579
-	if (!isset($_SERVER))
580
-		return !$failure;
620
+	if (!isset($_SERVER)) {
621
+			return !$failure;
622
+	}
581 623
 
582 624
 	// Put the list into context.
583 625
 	$incontext['failed_files'] = $failed_files;
@@ -625,19 +667,23 @@  discard block
 block discarded – undo
625 667
 
626 668
 		if (!isset($ftp) || $ftp->error !== false)
627 669
 		{
628
-			if (!isset($ftp))
629
-				$ftp = new ftp_connection(null);
670
+			if (!isset($ftp)) {
671
+							$ftp = new ftp_connection(null);
672
+			}
630 673
 			// Save the error so we can mess with listing...
631
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
632
-				$incontext['ftp_errors'][] = $ftp->last_message;
674
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
675
+							$incontext['ftp_errors'][] = $ftp->last_message;
676
+			}
633 677
 
634 678
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
635 679
 
636
-			if (empty($_POST['ftp_path']) && $found_path)
637
-				$_POST['ftp_path'] = $detect_path;
680
+			if (empty($_POST['ftp_path']) && $found_path) {
681
+							$_POST['ftp_path'] = $detect_path;
682
+			}
638 683
 
639
-			if (!isset($_POST['ftp_username']))
640
-				$_POST['ftp_username'] = $username;
684
+			if (!isset($_POST['ftp_username'])) {
685
+							$_POST['ftp_username'] = $username;
686
+			}
641 687
 
642 688
 			// Set the username etc, into context.
643 689
 			$incontext['ftp'] = array(
@@ -649,8 +695,7 @@  discard block
 block discarded – undo
649 695
 			);
650 696
 
651 697
 			return false;
652
-		}
653
-		else
698
+		} else
654 699
 		{
655 700
 			$_SESSION['installer_temp_ftp'] = array(
656 701
 				'server' => $_POST['ftp_server'],
@@ -664,10 +709,12 @@  discard block
 block discarded – undo
664 709
 
665 710
 			foreach ($failed_files as $file)
666 711
 			{
667
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
668
-					$ftp->chmod($file, 0755);
669
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
670
-					$ftp->chmod($file, 0777);
712
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
713
+									$ftp->chmod($file, 0755);
714
+				}
715
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
716
+									$ftp->chmod($file, 0777);
717
+				}
671 718
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
672 719
 				{
673 720
 					$failed_files_updated[] = $file;
@@ -723,15 +770,17 @@  discard block
 block discarded – undo
723 770
 
724 771
 			if (!$foundOne)
725 772
 			{
726
-				if (isset($db['default_host']))
727
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
773
+				if (isset($db['default_host'])) {
774
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
775
+				}
728 776
 				if (isset($db['default_user']))
729 777
 				{
730 778
 					$incontext['db']['user'] = ini_get($db['default_user']);
731 779
 					$incontext['db']['name'] = ini_get($db['default_user']);
732 780
 				}
733
-				if (isset($db['default_password']))
734
-					$incontext['db']['pass'] = ini_get($db['default_password']);
781
+				if (isset($db['default_password'])) {
782
+									$incontext['db']['pass'] = ini_get($db['default_password']);
783
+				}
735 784
 
736 785
 				// For simplicity and less confusion, leave the port blank by default
737 786
 				$incontext['db']['port'] = '';
@@ -750,10 +799,10 @@  discard block
 block discarded – undo
750 799
 		$incontext['db']['server'] = $_POST['db_server'];
751 800
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
752 801
 
753
-		if (!empty($_POST['db_port']))
754
-			$incontext['db']['port'] = $_POST['db_port'];
755
-	}
756
-	else
802
+		if (!empty($_POST['db_port'])) {
803
+					$incontext['db']['port'] = $_POST['db_port'];
804
+		}
805
+	} else
757 806
 	{
758 807
 		$incontext['db']['prefix'] = 'smf_';
759 808
 	}
@@ -789,10 +838,11 @@  discard block
 block discarded – undo
789 838
 		if (!empty($_POST['db_port']))
790 839
 		{
791 840
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
792
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
793
-				$vars['db_port'] = (int) $_POST['db_port'];
794
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
795
-				$vars['db_port'] = (int) $_POST['db_port'];
841
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
842
+							$vars['db_port'] = (int) $_POST['db_port'];
843
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
844
+							$vars['db_port'] = (int) $_POST['db_port'];
845
+			}
796 846
 		}
797 847
 
798 848
 		// God I hope it saved!
@@ -805,8 +855,9 @@  discard block
 block discarded – undo
805 855
 		// Make sure it works.
806 856
 		require(dirname(__FILE__) . '/Settings.php');
807 857
 
808
-		if (empty($sourcedir))
809
-			$sourcedir = dirname(__FILE__) . '/Sources';
858
+		if (empty($sourcedir)) {
859
+					$sourcedir = dirname(__FILE__) . '/Sources';
860
+		}
810 861
 
811 862
 		// Better find the database file!
812 863
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -816,18 +867,21 @@  discard block
 block discarded – undo
816 867
 		}
817 868
 
818 869
 		// Now include it for database functions!
819
-		if (!defined('SMF'))
820
-			define('SMF', 1);
870
+		if (!defined('SMF')) {
871
+					define('SMF', 1);
872
+		}
821 873
 
822 874
 		$modSettings['disableQueryCheck'] = true;
823
-		if (empty($smcFunc))
824
-			$smcFunc = array();
875
+		if (empty($smcFunc)) {
876
+					$smcFunc = array();
877
+		}
825 878
 
826 879
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
827 880
 
828 881
 		// What - running PHP4? The shame!
829
-		if (version_compare(PHP_VERSION, '5', '<'))
830
-			require_once($sourcedir . '/Subs-Compat.php');
882
+		if (version_compare(PHP_VERSION, '5', '<')) {
883
+					require_once($sourcedir . '/Subs-Compat.php');
884
+		}
831 885
 
832 886
 		// Attempt a connection.
833 887
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -915,12 +969,14 @@  discard block
 block discarded – undo
915 969
 	$incontext['page_title'] = $txt['install_settings'];
916 970
 
917 971
 	// Let's see if we got the database type correct.
918
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
919
-		$db_type = $_POST['db_type'];
972
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
973
+			$db_type = $_POST['db_type'];
974
+	}
920 975
 
921 976
 	// Else we'd better be able to get the connection.
922
-	else
923
-		load_database();
977
+	else {
978
+			load_database();
979
+	}
924 980
 
925 981
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
926 982
 
@@ -957,18 +1013,21 @@  discard block
 block discarded – undo
957 1013
 	// Submitting?
958 1014
 	if (isset($_POST['boardurl']))
959 1015
 	{
960
-		if (substr($_POST['boardurl'], -10) == '/index.php')
961
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
962
-		elseif (substr($_POST['boardurl'], -1) == '/')
963
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
964
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
965
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1016
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1017
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1018
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1019
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1020
+		}
1021
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1022
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1023
+		}
966 1024
 
967 1025
 		//Make sure boardurl is aligned with ssl setting
968
-		if (empty($_POST['force_ssl']))
969
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
970
-		else
971
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));		
1026
+		if (empty($_POST['force_ssl'])) {
1027
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
1028
+		} else {
1029
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1030
+		}
972 1031
 
973 1032
 		// Save these variables.
974 1033
 		$vars = array(
@@ -1007,10 +1066,10 @@  discard block
 block discarded – undo
1007 1066
 			{
1008 1067
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
1009 1068
 				return false;
1010
-			}
1011
-			else
1012
-				// Set the character set here.
1069
+			} else {
1070
+							// Set the character set here.
1013 1071
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1072
+			}
1014 1073
 		}
1015 1074
 
1016 1075
 		// Good, skip on.
@@ -1030,8 +1089,9 @@  discard block
 block discarded – undo
1030 1089
 	$incontext['continue'] = 1;
1031 1090
 
1032 1091
 	// Already done?
1033
-	if (isset($_POST['pop_done']))
1034
-		return true;
1092
+	if (isset($_POST['pop_done'])) {
1093
+			return true;
1094
+	}
1035 1095
 
1036 1096
 	// Reload settings.
1037 1097
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1049,8 +1109,9 @@  discard block
 block discarded – undo
1049 1109
 	$modSettings = array();
1050 1110
 	if ($result !== false)
1051 1111
 	{
1052
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1053
-			$modSettings[$row['variable']] = $row['value'];
1112
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1113
+					$modSettings[$row['variable']] = $row['value'];
1114
+		}
1054 1115
 		$smcFunc['db_free_result']($result);
1055 1116
 
1056 1117
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1063,20 +1124,22 @@  discard block
 block discarded – undo
1063 1124
 	$modSettings['disableQueryCheck'] = true;
1064 1125
 
1065 1126
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1066
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1067
-		$smcFunc['db_query']('', '
1127
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1128
+			$smcFunc['db_query']('', '
1068 1129
 			SET NAMES {string:utf8}',
1069 1130
 			array(
1070 1131
 				'db_error_skip' => true,
1071 1132
 				'utf8' => 'utf8',
1072 1133
 			)
1073 1134
 		);
1135
+	}
1074 1136
 
1075 1137
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1076
-	if (substr(__DIR__, -1) == '\\')
1077
-		$attachdir = __DIR__ . 'attachments';
1078
-	else
1079
-		$attachdir = __DIR__ . '/attachments';
1138
+	if (substr(__DIR__, -1) == '\\') {
1139
+			$attachdir = __DIR__ . 'attachments';
1140
+	} else {
1141
+			$attachdir = __DIR__ . '/attachments';
1142
+	}
1080 1143
 
1081 1144
 	$replaces = array(
1082 1145
 		'{$db_prefix}' => $db_prefix,
@@ -1093,8 +1156,9 @@  discard block
 block discarded – undo
1093 1156
 
1094 1157
 	foreach ($txt as $key => $value)
1095 1158
 	{
1096
-		if (substr($key, 0, 8) == 'default_')
1097
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1159
+		if (substr($key, 0, 8) == 'default_') {
1160
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1161
+		}
1098 1162
 	}
1099 1163
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1100 1164
 
@@ -1109,8 +1173,9 @@  discard block
 block discarded – undo
1109 1173
 
1110 1174
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1111 1175
 		{
1112
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1113
-				$engines[] = $row['Engine'];
1176
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1177
+							$engines[] = $row['Engine'];
1178
+			}
1114 1179
 		}
1115 1180
 
1116 1181
 		// Done with this now
@@ -1134,8 +1199,7 @@  discard block
 block discarded – undo
1134 1199
 			$replaces['START TRANSACTION;'] = '';
1135 1200
 			$replaces['COMMIT;'] = '';
1136 1201
 		}
1137
-	}
1138
-	else
1202
+	} else
1139 1203
 	{
1140 1204
 		$has_innodb = false;
1141 1205
 	}
@@ -1157,21 +1221,24 @@  discard block
 block discarded – undo
1157 1221
 	foreach ($sql_lines as $count => $line)
1158 1222
 	{
1159 1223
 		// No comments allowed!
1160
-		if (substr(trim($line), 0, 1) != '#')
1161
-			$current_statement .= "\n" . rtrim($line);
1224
+		if (substr(trim($line), 0, 1) != '#') {
1225
+					$current_statement .= "\n" . rtrim($line);
1226
+		}
1162 1227
 
1163 1228
 		// Is this the end of the query string?
1164
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1165
-			continue;
1229
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1230
+					continue;
1231
+		}
1166 1232
 
1167 1233
 		// Does this table already exist?  If so, don't insert more data into it!
1168 1234
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1169 1235
 		{
1170 1236
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1171
-			if (!empty($matches[0]))
1172
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1173
-			else
1174
-				$incontext['sql_results']['insert_dups']++;
1237
+			if (!empty($matches[0])) {
1238
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1239
+			} else {
1240
+							$incontext['sql_results']['insert_dups']++;
1241
+			}
1175 1242
 
1176 1243
 			$current_statement = '';
1177 1244
 			continue;
@@ -1180,8 +1247,9 @@  discard block
 block discarded – undo
1180 1247
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1181 1248
 		{
1182 1249
 			// Use the appropriate function based on the DB type
1183
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1184
-				$db_errorno = $db_type . '_errno';
1250
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1251
+							$db_errorno = $db_type . '_errno';
1252
+			}
1185 1253
 
1186 1254
 			// Error 1050: Table already exists!
1187 1255
 			// @todo Needs to be made better!
@@ -1196,18 +1264,18 @@  discard block
 block discarded – undo
1196 1264
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1197 1265
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1198 1266
 			}
1199
-		}
1200
-		else
1267
+		} else
1201 1268
 		{
1202
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1203
-				$incontext['sql_results']['tables']++;
1204
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1269
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1270
+							$incontext['sql_results']['tables']++;
1271
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1205 1272
 			{
1206 1273
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1207
-				if (!empty($matches[0]))
1208
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1209
-				else
1210
-					$incontext['sql_results']['inserts']++;
1274
+				if (!empty($matches[0])) {
1275
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1276
+				} else {
1277
+									$incontext['sql_results']['inserts']++;
1278
+				}
1211 1279
 			}
1212 1280
 		}
1213 1281
 
@@ -1220,15 +1288,17 @@  discard block
 block discarded – undo
1220 1288
 	// Sort out the context for the SQL.
1221 1289
 	foreach ($incontext['sql_results'] as $key => $number)
1222 1290
 	{
1223
-		if ($number == 0)
1224
-			unset($incontext['sql_results'][$key]);
1225
-		else
1226
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1291
+		if ($number == 0) {
1292
+					unset($incontext['sql_results'][$key]);
1293
+		} else {
1294
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1295
+		}
1227 1296
 	}
1228 1297
 
1229 1298
 	// Make sure UTF will be used globally.
1230
-	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'])))
1231
-		$newSettings[] = array('global_character_set', 'UTF-8');
1299
+	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']))) {
1300
+			$newSettings[] = array('global_character_set', 'UTF-8');
1301
+	}
1232 1302
 
1233 1303
 	// Auto-detect local & global cookie settings
1234 1304
 	$url_parts = parse_url($boardurl);
@@ -1257,15 +1327,19 @@  discard block
 block discarded – undo
1257 1327
 
1258 1328
 		// Look for subfolder, if found, set localCookie
1259 1329
 		// Checking for len > 1 ensures you don't have just a slash...
1260
-		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1)
1261
-			$localCookies = '1';
1330
+		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) {
1331
+					$localCookies = '1';
1332
+		}
1262 1333
 
1263
-		if (isset($globalCookies))
1264
-			$newSettings[] = array('globalCookies', $globalCookies);
1265
-		if (isset($globalCookiesDomain))
1266
-			$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1267
-		if (isset($localCookies))
1268
-			$newSettings[] = array('localCookies', $localCookies);
1334
+		if (isset($globalCookies)) {
1335
+					$newSettings[] = array('globalCookies', $globalCookies);
1336
+		}
1337
+		if (isset($globalCookiesDomain)) {
1338
+					$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1339
+		}
1340
+		if (isset($localCookies)) {
1341
+					$newSettings[] = array('localCookies', $localCookies);
1342
+		}
1269 1343
 	}
1270 1344
 
1271 1345
 	// Are we allowing stat collection?
@@ -1283,16 +1357,17 @@  discard block
 block discarded – undo
1283 1357
 			fwrite($fp, $out);
1284 1358
 
1285 1359
 			$return_data = '';
1286
-			while (!feof($fp))
1287
-				$return_data .= fgets($fp, 128);
1360
+			while (!feof($fp)) {
1361
+							$return_data .= fgets($fp, 128);
1362
+			}
1288 1363
 
1289 1364
 			fclose($fp);
1290 1365
 
1291 1366
 			// Get the unique site ID.
1292 1367
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1293 1368
 
1294
-			if (!empty($ID[1]))
1295
-				$smcFunc['db_insert']('replace',
1369
+			if (!empty($ID[1])) {
1370
+							$smcFunc['db_insert']('replace',
1296 1371
 					$db_prefix . 'settings',
1297 1372
 					array('variable' => 'string', 'value' => 'string'),
1298 1373
 					array(
@@ -1301,11 +1376,12 @@  discard block
 block discarded – undo
1301 1376
 					),
1302 1377
 					array('variable')
1303 1378
 				);
1379
+			}
1304 1380
 		}
1305 1381
 	}
1306 1382
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1307
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1308
-		$smcFunc['db_query']('', '
1383
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1384
+			$smcFunc['db_query']('', '
1309 1385
 			DELETE FROM {db_prefix}settings
1310 1386
 			WHERE variable = {string:enable_sm_stats}',
1311 1387
 			array(
@@ -1313,20 +1389,23 @@  discard block
 block discarded – undo
1313 1389
 				'db_error_skip' => true,
1314 1390
 			)
1315 1391
 		);
1392
+	}
1316 1393
 
1317 1394
 	// Are we enabling SSL?
1318
-	if (!empty($_POST['force_ssl']))
1319
-		$newSettings[] = array('force_ssl', 2);
1395
+	if (!empty($_POST['force_ssl'])) {
1396
+			$newSettings[] = array('force_ssl', 2);
1397
+	}
1320 1398
 
1321 1399
 	// Setting a timezone is required.
1322 1400
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1323 1401
 	{
1324 1402
 		// Get PHP's default timezone, if set
1325 1403
 		$ini_tz = ini_get('date.timezone');
1326
-		if (!empty($ini_tz))
1327
-			$timezone_id = $ini_tz;
1328
-		else
1329
-			$timezone_id = '';
1404
+		if (!empty($ini_tz)) {
1405
+					$timezone_id = $ini_tz;
1406
+		} else {
1407
+					$timezone_id = '';
1408
+		}
1330 1409
 
1331 1410
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1332 1411
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1335,8 +1414,9 @@  discard block
 block discarded – undo
1335 1414
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1336 1415
 		}
1337 1416
 
1338
-		if (date_default_timezone_set($timezone_id))
1339
-			$newSettings[] = array('default_timezone', $timezone_id);
1417
+		if (date_default_timezone_set($timezone_id)) {
1418
+					$newSettings[] = array('default_timezone', $timezone_id);
1419
+		}
1340 1420
 	}
1341 1421
 
1342 1422
 	if (!empty($newSettings))
@@ -1367,16 +1447,18 @@  discard block
 block discarded – undo
1367 1447
 	}
1368 1448
 
1369 1449
 	// MySQL specific stuff
1370
-	if (substr($db_type, 0, 5) != 'mysql')
1371
-		return false;
1450
+	if (substr($db_type, 0, 5) != 'mysql') {
1451
+			return false;
1452
+	}
1372 1453
 
1373 1454
 	// Find database user privileges.
1374 1455
 	$privs = array();
1375 1456
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1376 1457
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1377 1458
 	{
1378
-		if ($row['Privilege'] == 'Alter')
1379
-			$privs[] = $row['Privilege'];
1459
+		if ($row['Privilege'] == 'Alter') {
1460
+					$privs[] = $row['Privilege'];
1461
+		}
1380 1462
 	}
1381 1463
 	$smcFunc['db_free_result']($get_privs);
1382 1464
 
@@ -1406,8 +1488,9 @@  discard block
 block discarded – undo
1406 1488
 	$incontext['continue'] = 1;
1407 1489
 
1408 1490
 	// Skipping?
1409
-	if (!empty($_POST['skip']))
1410
-		return true;
1491
+	if (!empty($_POST['skip'])) {
1492
+			return true;
1493
+	}
1411 1494
 
1412 1495
 	// Need this to check whether we need the database password.
1413 1496
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1424,18 +1507,22 @@  discard block
 block discarded – undo
1424 1507
 	// We need this to properly hash the password for Admin
1425 1508
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1426 1509
 			global $sourcedir;
1427
-			if (function_exists('mb_strtolower'))
1428
-				return mb_strtolower($string, 'UTF-8');
1510
+			if (function_exists('mb_strtolower')) {
1511
+							return mb_strtolower($string, 'UTF-8');
1512
+			}
1429 1513
 			require_once($sourcedir . '/Subs-Charset.php');
1430 1514
 			return utf8_strtolower($string);
1431 1515
 		};
1432 1516
 
1433
-	if (!isset($_POST['username']))
1434
-		$_POST['username'] = '';
1435
-	if (!isset($_POST['email']))
1436
-		$_POST['email'] = '';
1437
-	if (!isset($_POST['server_email']))
1438
-		$_POST['server_email'] = '';
1517
+	if (!isset($_POST['username'])) {
1518
+			$_POST['username'] = '';
1519
+	}
1520
+	if (!isset($_POST['email'])) {
1521
+			$_POST['email'] = '';
1522
+	}
1523
+	if (!isset($_POST['server_email'])) {
1524
+			$_POST['server_email'] = '';
1525
+	}
1439 1526
 
1440 1527
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1441 1528
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1454,8 +1541,9 @@  discard block
 block discarded – undo
1454 1541
 			'admin_group' => 1,
1455 1542
 		)
1456 1543
 	);
1457
-	if ($smcFunc['db_num_rows']($request) != 0)
1458
-		$incontext['skip'] = 1;
1544
+	if ($smcFunc['db_num_rows']($request) != 0) {
1545
+			$incontext['skip'] = 1;
1546
+	}
1459 1547
 	$smcFunc['db_free_result']($request);
1460 1548
 
1461 1549
 	// Trying to create an account?
@@ -1486,8 +1574,9 @@  discard block
 block discarded – undo
1486 1574
 		}
1487 1575
 
1488 1576
 		// Update the webmaster's email?
1489
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1490
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1577
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1578
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1579
+		}
1491 1580
 
1492 1581
 		// Work out whether we're going to have dodgy characters and remove them.
1493 1582
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1510,32 +1599,27 @@  discard block
 block discarded – undo
1510 1599
 			$smcFunc['db_free_result']($result);
1511 1600
 
1512 1601
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1513
-		}
1514
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1602
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1515 1603
 		{
1516 1604
 			// Try the previous step again.
1517 1605
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1518 1606
 			return false;
1519
-		}
1520
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1607
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1521 1608
 		{
1522 1609
 			// Try the previous step again.
1523 1610
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1524 1611
 			return false;
1525
-		}
1526
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1612
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1527 1613
 		{
1528 1614
 			// One step back, this time fill out a proper admin email address.
1529 1615
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1530 1616
 			return false;
1531
-		}
1532
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1617
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1533 1618
 		{
1534 1619
 			// One step back, this time fill out a proper admin email address.
1535 1620
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1536 1621
 			return false;
1537
-		}
1538
-		elseif ($_POST['username'] != '')
1622
+		} elseif ($_POST['username'] != '')
1539 1623
 		{
1540 1624
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1541 1625
 
@@ -1603,17 +1687,19 @@  discard block
 block discarded – undo
1603 1687
 	reloadSettings();
1604 1688
 
1605 1689
 	// Bring a warning over.
1606
-	if (!empty($incontext['account_existed']))
1607
-		$incontext['warning'] = $incontext['account_existed'];
1690
+	if (!empty($incontext['account_existed'])) {
1691
+			$incontext['warning'] = $incontext['account_existed'];
1692
+	}
1608 1693
 
1609
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1610
-		$smcFunc['db_query']('', '
1694
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1695
+			$smcFunc['db_query']('', '
1611 1696
 			SET NAMES {string:db_character_set}',
1612 1697
 			array(
1613 1698
 				'db_character_set' => $db_character_set,
1614 1699
 				'db_error_skip' => true,
1615 1700
 			)
1616 1701
 		);
1702
+	}
1617 1703
 
1618 1704
 	// As track stats is by default enabled let's add some activity.
1619 1705
 	$smcFunc['db_insert']('ignore',
@@ -1634,14 +1720,16 @@  discard block
 block discarded – undo
1634 1720
 	// Only proceed if we can load the data.
1635 1721
 	if ($request)
1636 1722
 	{
1637
-		while ($row = $smcFunc['db_fetch_row']($request))
1638
-			$modSettings[$row[0]] = $row[1];
1723
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1724
+					$modSettings[$row[0]] = $row[1];
1725
+		}
1639 1726
 		$smcFunc['db_free_result']($request);
1640 1727
 	}
1641 1728
 
1642 1729
 	// Automatically log them in ;)
1643
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1644
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1730
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1731
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1732
+	}
1645 1733
 
1646 1734
 	$result = $smcFunc['db_query']('', '
1647 1735
 		SELECT value
@@ -1652,13 +1740,14 @@  discard block
 block discarded – undo
1652 1740
 			'db_error_skip' => true,
1653 1741
 		)
1654 1742
 	);
1655
-	if ($smcFunc['db_num_rows']($result) != 0)
1656
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1743
+	if ($smcFunc['db_num_rows']($result) != 0) {
1744
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1745
+	}
1657 1746
 	$smcFunc['db_free_result']($result);
1658 1747
 
1659
-	if (empty($db_sessions))
1660
-		$_SESSION['admin_time'] = time();
1661
-	else
1748
+	if (empty($db_sessions)) {
1749
+			$_SESSION['admin_time'] = time();
1750
+	} else
1662 1751
 	{
1663 1752
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1664 1753
 
@@ -1682,8 +1771,9 @@  discard block
 block discarded – undo
1682 1771
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1683 1772
 		function($string){
1684 1773
 			global $sourcedir;
1685
-			if (function_exists('mb_strtolower'))
1686
-				return mb_strtolower($string, 'UTF-8');
1774
+			if (function_exists('mb_strtolower')) {
1775
+							return mb_strtolower($string, 'UTF-8');
1776
+			}
1687 1777
 			require_once($sourcedir . '/Subs-Charset.php');
1688 1778
 			return utf8_strtolower($string);
1689 1779
 		};
@@ -1699,8 +1789,9 @@  discard block
 block discarded – undo
1699 1789
 		)
1700 1790
 	);
1701 1791
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1702
-	if ($smcFunc['db_num_rows']($request) > 0)
1703
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1792
+	if ($smcFunc['db_num_rows']($request) > 0) {
1793
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1794
+	}
1704 1795
 	$smcFunc['db_free_result']($request);
1705 1796
 
1706 1797
 	// Now is the perfect time to fetch the SM files.
@@ -1719,8 +1810,9 @@  discard block
 block discarded – undo
1719 1810
 
1720 1811
 	// Check if we need some stupid MySQL fix.
1721 1812
 	$server_version = $smcFunc['db_server_info']();
1722
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1723
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1813
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1814
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1815
+	}
1724 1816
 
1725 1817
 	// Some final context for the template.
1726 1818
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1740,8 +1832,9 @@  discard block
 block discarded – undo
1740 1832
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1741 1833
 
1742 1834
 	// @todo Do we just want to read the file in clean, and split it this way always?
1743
-	if (count($settingsArray) == 1)
1744
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1835
+	if (count($settingsArray) == 1) {
1836
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1837
+	}
1745 1838
 
1746 1839
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1747 1840
 	{
@@ -1756,19 +1849,22 @@  discard block
 block discarded – undo
1756 1849
 			continue;
1757 1850
 		}
1758 1851
 
1759
-		if (trim($settingsArray[$i]) == '?' . '>')
1760
-			$settingsArray[$i] = '';
1852
+		if (trim($settingsArray[$i]) == '?' . '>') {
1853
+					$settingsArray[$i] = '';
1854
+		}
1761 1855
 
1762 1856
 		// Don't trim or bother with it if it's not a variable.
1763
-		if (substr($settingsArray[$i], 0, 1) != '$')
1764
-			continue;
1857
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1858
+					continue;
1859
+		}
1765 1860
 
1766 1861
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1767 1862
 
1768
-		foreach ($vars as $var => $val)
1769
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1863
+		foreach ($vars as $var => $val) {
1864
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1770 1865
 			{
1771 1866
 				$comment = strstr($settingsArray[$i], '#');
1867
+		}
1772 1868
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1773 1869
 				unset($vars[$var]);
1774 1870
 			}
@@ -1778,36 +1874,41 @@  discard block
 block discarded – undo
1778 1874
 	if (!empty($vars))
1779 1875
 	{
1780 1876
 		$settingsArray[$i++] = '';
1781
-		foreach ($vars as $var => $val)
1782
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1877
+		foreach ($vars as $var => $val) {
1878
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1879
+		}
1783 1880
 	}
1784 1881
 
1785 1882
 	// Blank out the file - done to fix a oddity with some servers.
1786 1883
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1787
-	if (!$fp)
1788
-		return false;
1884
+	if (!$fp) {
1885
+			return false;
1886
+	}
1789 1887
 	fclose($fp);
1790 1888
 
1791 1889
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1792 1890
 
1793 1891
 	// Gotta have one of these ;)
1794
-	if (trim($settingsArray[0]) != '<?php')
1795
-		fwrite($fp, "<?php\n");
1892
+	if (trim($settingsArray[0]) != '<?php') {
1893
+			fwrite($fp, "<?php\n");
1894
+	}
1796 1895
 
1797 1896
 	$lines = count($settingsArray);
1798 1897
 	for ($i = 0; $i < $lines - 1; $i++)
1799 1898
 	{
1800 1899
 		// Don't just write a bunch of blank lines.
1801
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1802
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1900
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1901
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1902
+		}
1803 1903
 	}
1804 1904
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1805 1905
 	fclose($fp);
1806 1906
 
1807 1907
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1808 1908
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1809
-	if (function_exists('opcache_invalidate'))
1810
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1909
+	if (function_exists('opcache_invalidate')) {
1910
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1911
+	}
1811 1912
 
1812 1913
 	return true;
1813 1914
 }
@@ -1832,9 +1933,9 @@  discard block
 block discarded – undo
1832 1933
 	SecFilterScanPOST Off
1833 1934
 </IfModule>';
1834 1935
 
1835
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1836
-		return true;
1837
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1936
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1937
+			return true;
1938
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1838 1939
 	{
1839 1940
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1840 1941
 
@@ -1846,29 +1947,28 @@  discard block
 block discarded – undo
1846 1947
 				fwrite($ht_handle, $htaccess_addition);
1847 1948
 				fclose($ht_handle);
1848 1949
 				return true;
1950
+			} else {
1951
+							return false;
1849 1952
 			}
1850
-			else
1851
-				return false;
1953
+		} else {
1954
+					return true;
1852 1955
 		}
1853
-		else
1854
-			return true;
1855
-	}
1856
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1857
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1858
-	elseif (is_writable(dirname(__FILE__)))
1956
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1957
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1958
+	} elseif (is_writable(dirname(__FILE__)))
1859 1959
 	{
1860 1960
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1861 1961
 		{
1862 1962
 			fwrite($ht_handle, $htaccess_addition);
1863 1963
 			fclose($ht_handle);
1864 1964
 			return true;
1965
+		} else {
1966
+					return false;
1865 1967
 		}
1866
-		else
1968
+	} else {
1867 1969
 			return false;
1868 1970
 	}
1869
-	else
1870
-		return false;
1871
-}
1971
+	}
1872 1972
 
1873 1973
 function template_install_above()
1874 1974
 {
@@ -1906,9 +2006,10 @@  discard block
 block discarded – undo
1906 2006
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1907 2007
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1908 2008
 
1909
-		foreach ($incontext['detected_languages'] as $lang => $name)
1910
-			echo '
2009
+		foreach ($incontext['detected_languages'] as $lang => $name) {
2010
+					echo '
1911 2011
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
2012
+		}
1912 2013
 
1913 2014
 		echo '
1914 2015
 								</select>
@@ -1928,9 +2029,10 @@  discard block
 block discarded – undo
1928 2029
 						<h2>', $txt['upgrade_progress'], '</h2>
1929 2030
 						<ul>';
1930 2031
 
1931
-	foreach ($incontext['steps'] as $num => $step)
1932
-		echo '
2032
+	foreach ($incontext['steps'] as $num => $step) {
2033
+			echo '
1933 2034
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
2035
+	}
1934 2036
 
1935 2037
 	echo '
1936 2038
 						</ul>
@@ -1955,20 +2057,23 @@  discard block
 block discarded – undo
1955 2057
 		echo '
1956 2058
 								<div class="floatright">';
1957 2059
 
1958
-		if (!empty($incontext['continue']))
1959
-			echo '
2060
+		if (!empty($incontext['continue'])) {
2061
+					echo '
1960 2062
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />';
1961
-		if (!empty($incontext['skip']))
1962
-			echo '
2063
+		}
2064
+		if (!empty($incontext['skip'])) {
2065
+					echo '
1963 2066
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />';
2067
+		}
1964 2068
 		echo '
1965 2069
 								</div>';
1966 2070
 	}
1967 2071
 
1968 2072
 	// Show the closing form tag and other data only if not in the last step
1969
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1970
-		echo '
2073
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2074
+			echo '
1971 2075
 							</form>';
2076
+	}
1972 2077
 
1973 2078
 	echo '
1974 2079
 						</div>
@@ -2003,13 +2108,15 @@  discard block
 block discarded – undo
2003 2108
 		</div>';
2004 2109
 
2005 2110
 	// Show the warnings, or not.
2006
-	if (template_warning_divs())
2007
-		echo '
2111
+	if (template_warning_divs()) {
2112
+			echo '
2008 2113
 		<h3>', $txt['install_all_lovely'], '</h3>';
2114
+	}
2009 2115
 
2010 2116
 	// Say we want the continue button!
2011
-	if (empty($incontext['error']))
2012
-		$incontext['continue'] = 1;
2117
+	if (empty($incontext['error'])) {
2118
+			$incontext['continue'] = 1;
2119
+	}
2013 2120
 
2014 2121
 	// For the latest version stuff.
2015 2122
 	echo '
@@ -2043,8 +2150,8 @@  discard block
 block discarded – undo
2043 2150
 	global $txt, $incontext;
2044 2151
 
2045 2152
 	// Errors are very serious..
2046
-	if (!empty($incontext['error']))
2047
-		echo '
2153
+	if (!empty($incontext['error'])) {
2154
+			echo '
2048 2155
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2049 2156
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2050 2157
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -2052,9 +2159,10 @@  discard block
 block discarded – undo
2052 2159
 				', $incontext['error'], '
2053 2160
 			</div>
2054 2161
 		</div>';
2162
+	}
2055 2163
 	// A warning message?
2056
-	elseif (!empty($incontext['warning']))
2057
-		echo '
2164
+	elseif (!empty($incontext['warning'])) {
2165
+			echo '
2058 2166
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2059 2167
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2060 2168
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -2062,6 +2170,7 @@  discard block
 block discarded – undo
2062 2170
 				', $incontext['warning'], '
2063 2171
 			</div>
2064 2172
 		</div>';
2173
+	}
2065 2174
 
2066 2175
 	return empty($incontext['error']) && empty($incontext['warning']);
2067 2176
 }
@@ -2077,27 +2186,30 @@  discard block
 block discarded – undo
2077 2186
 			<li>', $incontext['failed_files']), '</li>
2078 2187
 		</ul>';
2079 2188
 
2080
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2081
-		echo '
2189
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2190
+			echo '
2082 2191
 		<hr>
2083 2192
 		<p>', $txt['chmod_linux_info'], '</p>
2084 2193
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2194
+	}
2085 2195
 
2086 2196
 	// This is serious!
2087
-	if (!template_warning_divs())
2088
-		return;
2197
+	if (!template_warning_divs()) {
2198
+			return;
2199
+	}
2089 2200
 
2090 2201
 	echo '
2091 2202
 		<hr>
2092 2203
 		<p>', $txt['ftp_setup_info'], '</p>';
2093 2204
 
2094
-	if (!empty($incontext['ftp_errors']))
2095
-		echo '
2205
+	if (!empty($incontext['ftp_errors'])) {
2206
+			echo '
2096 2207
 		<div class="error_message">
2097 2208
 			', $txt['error_ftp_no_connect'], '<br><br>
2098 2209
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2099 2210
 		</div>
2100 2211
 		<br>';
2212
+	}
2101 2213
 
2102 2214
 	echo '
2103 2215
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2157,17 +2269,17 @@  discard block
 block discarded – undo
2157 2269
 				<td>
2158 2270
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2159 2271
 
2160
-	foreach ($incontext['supported_databases'] as $key => $db)
2161
-			echo '
2272
+	foreach ($incontext['supported_databases'] as $key => $db) {
2273
+				echo '
2162 2274
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2275
+	}
2163 2276
 
2164 2277
 	echo '
2165 2278
 					</select>
2166 2279
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2167 2280
 				</td>
2168 2281
 			</tr>';
2169
-	}
2170
-	else
2282
+	} else
2171 2283
 	{
2172 2284
 		echo '
2173 2285
 			<tr style="display: none;">
@@ -2360,9 +2472,10 @@  discard block
 block discarded – undo
2360 2472
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2361 2473
 				<ul>';
2362 2474
 
2363
-		foreach ($incontext['failures'] as $line => $fail)
2364
-			echo '
2475
+		foreach ($incontext['failures'] as $line => $fail) {
2476
+					echo '
2365 2477
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2478
+		}
2366 2479
 
2367 2480
 		echo '
2368 2481
 				</ul>';
@@ -2423,15 +2536,16 @@  discard block
 block discarded – undo
2423 2536
 			</tr>
2424 2537
 		</table>';
2425 2538
 
2426
-	if ($incontext['require_db_confirm'])
2427
-		echo '
2539
+	if ($incontext['require_db_confirm']) {
2540
+			echo '
2428 2541
 		<h2>', $txt['user_settings_database'], '</h2>
2429 2542
 		<p>', $txt['user_settings_database_info'], '</p>
2430 2543
 
2431 2544
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2432 2545
 			<input type="password" name="password3" size="30" />
2433 2546
 		</div>';
2434
-}
2547
+	}
2548
+	}
2435 2549
 
2436 2550
 // Tell them it's done, and to delete.
2437 2551
 function template_delete_install()
@@ -2444,14 +2558,15 @@  discard block
 block discarded – undo
2444 2558
 	template_warning_divs();
2445 2559
 
2446 2560
 	// Install directory still writable?
2447
-	if ($incontext['dir_still_writable'])
2448
-		echo '
2561
+	if ($incontext['dir_still_writable']) {
2562
+			echo '
2449 2563
 		<em>', $txt['still_writable'], '</em><br>
2450 2564
 		<br>';
2565
+	}
2451 2566
 
2452 2567
 	// Don't show the box if it's like 99% sure it won't work :P.
2453
-	if ($incontext['probably_delete_install'])
2454
-		echo '
2568
+	if ($incontext['probably_delete_install']) {
2569
+			echo '
2455 2570
 		<div style="margin: 1ex; font-weight: bold;">
2456 2571
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2457 2572
 		</div>
@@ -2467,6 +2582,7 @@  discard block
 block discarded – undo
2467 2582
 			}
2468 2583
 		</script>
2469 2584
 		<br>';
2585
+	}
2470 2586
 
2471 2587
 	echo '
2472 2588
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.
Themes/default/Recent.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 	<div id="recent" class="main_section">
22 22
 		<div class="cat_bar">
23 23
 			<h3 class="catbg">
24
-				<span class="xx"></span>',$txt['recent_posts'],'
24
+				<span class="xx"></span>',$txt['recent_posts'], '
25 25
 			</h3>
26 26
 		</div>
27 27
 		<div class="pagesection">', $context['page_index'], '</div>';
Please login to merge, or discard this patch.
Braces   +74 added lines, -52 removed lines patch added patch discarded remove patch
@@ -43,28 +43,33 @@  discard block
 block discarded – undo
43 43
 					</div>
44 44
 					<div class="list_posts">', $post['message'], '</div>';
45 45
 
46
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
47
-			echo '
46
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
47
+					echo '
48 48
 					<ul class="quickbuttons">';
49
+		}
49 50
 
50 51
 		// If they *can* reply?
51
-		if ($post['can_reply'])
52
-			echo '
52
+		if ($post['can_reply']) {
53
+					echo '
53 54
 						<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
55
+		}
54 56
 
55 57
 		// If they *can* quote?
56
-		if ($post['can_quote'])
57
-			echo '
58
+		if ($post['can_quote']) {
59
+					echo '
58 60
 						<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
61
+		}
59 62
 
60 63
 		// How about... even... remove it entirely?!
61
-		if ($post['can_delete'])
62
-			echo '
64
+		if ($post['can_delete']) {
65
+					echo '
63 66
 						<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
67
+		}
64 68
 
65
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
66
-			echo '
69
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
70
+					echo '
67 71
 					</ul>';
72
+		}
68 73
 
69 74
 		echo '
70 75
 			</div>';
@@ -86,12 +91,13 @@  discard block
 block discarded – undo
86 91
 	echo '
87 92
 	<div id="recent" class="main_content">';
88 93
 
89
-	if ($context['showCheckboxes'])
90
-		echo '
94
+	if ($context['showCheckboxes']) {
95
+			echo '
91 96
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
92 97
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
93 98
 			<input type="hidden" name="qaction" value="markread">
94 99
 			<input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
100
+	}
95 101
 
96 102
 	if (!empty($context['topics']))
97 103
 	{
@@ -120,11 +126,12 @@  discard block
 block discarded – undo
120 126
 					</div>';
121 127
 
122 128
 		// Show a "select all" box for quick moderation?
123
-		if ($context['showCheckboxes'])
124
-			echo '
129
+		if ($context['showCheckboxes']) {
130
+					echo '
125 131
 					<div class="moderation">
126 132
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
127 133
 					</div>';
134
+		}
128 135
 
129 136
 		echo '
130 137
 				</div>
@@ -143,15 +150,18 @@  discard block
 block discarded – undo
143 150
 			// Now we handle the icons
144 151
 			echo '
145 152
 							<div class="icons floatright">';
146
-			if ($topic['is_locked'])
147
-				echo '
153
+			if ($topic['is_locked']) {
154
+							echo '
148 155
 								<span class="generic_icons lock"></span>';
149
-			if ($topic['is_sticky'])
150
-				echo '
156
+			}
157
+			if ($topic['is_sticky']) {
158
+							echo '
151 159
 								<span class="generic_icons sticky"></span>';
152
-			if ($topic['is_poll'])
153
-				echo '
160
+			}
161
+			if ($topic['is_poll']) {
162
+							echo '
154 163
 								<span class="generic_icons poll"></span>';
164
+			}
155 165
 			echo '
156 166
 							</div>';
157 167
 
@@ -176,19 +186,21 @@  discard block
 block discarded – undo
176 186
 							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
177 187
 						</div>';
178 188
 
179
-			if ($context['showCheckboxes'])
180
-				echo '
189
+			if ($context['showCheckboxes']) {
190
+							echo '
181 191
 						<div class="moderation">
182 192
 							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
183 193
 						</div>';
194
+			}
184 195
 
185 196
 				echo '
186 197
 					</div>';
187 198
 		}
188 199
 
189
-		if (empty($context['topics']))
190
-			echo '
200
+		if (empty($context['topics'])) {
201
+					echo '
191 202
 						<div style="display: none;"></div>';
203
+		}
192 204
 
193 205
 		echo '
194 206
 				</div>
@@ -203,25 +215,27 @@  discard block
 block discarded – undo
203 215
 					', $context['page_index'], '
204 216
 				</div>
205 217
 			</div>';
206
-	}
207
-	else
208
-		echo '
218
+	} else {
219
+			echo '
209 220
 			<div class="cat_bar">
210 221
 				<h3 class="catbg centertext">
211 222
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
212 223
 				</h3>
213 224
 			</div>';
225
+	}
214 226
 
215
-	if ($context['showCheckboxes'])
216
-		echo '
227
+	if ($context['showCheckboxes']) {
228
+			echo '
217 229
 		</form>';
230
+	}
218 231
 
219 232
 	echo '
220 233
 	</div>';
221 234
 
222
-	if (empty($context['no_topic_listing']))
223
-		template_topic_legend();
224
-}
235
+	if (empty($context['no_topic_listing'])) {
236
+			template_topic_legend();
237
+	}
238
+	}
225 239
 
226 240
 /**
227 241
  * Template for showing unread replies (eg new replies to topics you've posted in)
@@ -233,12 +247,13 @@  discard block
 block discarded – undo
233 247
 	echo '
234 248
 	<div id="recent">';
235 249
 
236
-	if ($context['showCheckboxes'])
237
-		echo '
250
+	if ($context['showCheckboxes']) {
251
+			echo '
238 252
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
239 253
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
240 254
 			<input type="hidden" name="qaction" value="markread">
241 255
 			<input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
256
+	}
242 257
 
243 258
 	if (!empty($context['topics']))
244 259
 	{
@@ -267,11 +282,12 @@  discard block
 block discarded – undo
267 282
 					</div>';
268 283
 
269 284
 		// Show a "select all" box for quick moderation?
270
-		if ($context['showCheckboxes'])
271
-				echo '
285
+		if ($context['showCheckboxes']) {
286
+						echo '
272 287
 					<div class="moderation">
273 288
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
274 289
 					</div>';
290
+		}
275 291
 
276 292
 		echo '
277 293
 				</div>
@@ -290,15 +306,18 @@  discard block
 block discarded – undo
290 306
 			// Now we handle the icons
291 307
 			echo '
292 308
 								<div class="icons floatright">';
293
-			if ($topic['is_locked'])
294
-				echo '
309
+			if ($topic['is_locked']) {
310
+							echo '
295 311
 									<span class="generic_icons lock"></span>';
296
-			if ($topic['is_sticky'])
297
-				echo '
312
+			}
313
+			if ($topic['is_sticky']) {
314
+							echo '
298 315
 									<span class="generic_icons sticky"></span>';
299
-			if ($topic['is_poll'])
300
-				echo '
316
+			}
317
+			if ($topic['is_poll']) {
318
+							echo '
301 319
 									<span class="generic_icons poll"></span>';
320
+			}
302 321
 			echo '
303 322
 								</div>';
304 323
 
@@ -323,11 +342,12 @@  discard block
 block discarded – undo
323 342
 								', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
324 343
 							</div>';
325 344
 
326
-			if ($context['showCheckboxes'])
327
-				echo '
345
+			if ($context['showCheckboxes']) {
346
+							echo '
328 347
 							<div class="moderation">
329 348
 								<input type="checkbox" name="topics[]" value="', $topic['id'], '">
330 349
 							</div>';
350
+			}
331 351
 			echo '
332 352
 						</div>';
333 353
 		}
@@ -343,24 +363,26 @@  discard block
 block discarded – undo
343 363
 					', $context['page_index'], '
344 364
 				</div>
345 365
 			</div>';
346
-	}
347
-	else
348
-		echo '
366
+	} else {
367
+			echo '
349 368
 			<div class="cat_bar">
350 369
 				<h3 class="catbg centertext">
351 370
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
352 371
 				</h3>
353 372
 			</div>';
373
+	}
354 374
 
355
-	if ($context['showCheckboxes'])
356
-		echo '
375
+	if ($context['showCheckboxes']) {
376
+			echo '
357 377
 		</form>';
378
+	}
358 379
 
359 380
 	echo '
360 381
 	</div>';
361 382
 
362
-	if (empty($context['no_topic_listing']))
363
-		template_topic_legend();
364
-}
383
+	if (empty($context['no_topic_listing'])) {
384
+			template_topic_legend();
385
+	}
386
+	}
365 387
 
366 388
 ?>
367 389
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Braces   +50 added lines, -37 removed lines patch added patch discarded remove patch
@@ -89,8 +89,9 @@  discard block
 block discarded – undo
89 89
 		foreach ($section['areas'] as $i => $area)
90 90
 		{
91 91
 			// Not supposed to be printed?
92
-			if (empty($area['label']))
93
-				continue;
92
+			if (empty($area['label'])) {
93
+							continue;
94
+			}
94 95
 
95 96
 			echo '
96 97
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>';
@@ -99,8 +100,9 @@  discard block
 block discarded – undo
99 100
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>';
100 101
 
101 102
 			// Is this the current area, or just some area?
102
-			if (!empty($area['selected']) && empty($context['tabs']))
103
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
103
+			if (!empty($area['selected']) && empty($context['tabs'])) {
104
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
105
+			}
104 106
 
105 107
 			// Are there any subsections?
106 108
 			if (!empty($area['subsections']))
@@ -110,8 +112,9 @@  discard block
 block discarded – undo
110 112
 
111 113
 				foreach ($area['subsections'] as $sa => $sub)
112 114
 				{
113
-					if (!empty($sub['disabled']))
114
-						continue;
115
+					if (!empty($sub['disabled'])) {
116
+											continue;
117
+					}
115 118
 
116 119
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
117 120
 
@@ -158,8 +161,9 @@  discard block
 block discarded – undo
158 161
 							<h3 class="catbg">';
159 162
 
160 163
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
161
-		if (function_exists('template_admin_quick_search'))
162
-			template_admin_quick_search();
164
+		if (function_exists('template_admin_quick_search')) {
165
+					template_admin_quick_search();
166
+		}
163 167
 
164 168
 		// Exactly how many tabs do we have?
165 169
 		if (!empty($context['tabs']))
@@ -174,30 +178,36 @@  discard block
 block discarded – undo
174 178
 				}
175 179
 
176 180
 				// Did this not even exist - or do we not have a label?
177
-				if (!isset($tab_context['tabs'][$id]))
178
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
179
-				elseif (!isset($tab_context['tabs'][$id]['label']))
180
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
181
+				if (!isset($tab_context['tabs'][$id])) {
182
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
183
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
184
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
185
+				}
181 186
 
182 187
 				// Has a custom URL defined in the main admin structure?
183
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
184
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
188
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
189
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
190
+				}
185 191
 
186 192
 				// Any additional paramaters for the url?
187
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
188
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
193
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
194
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
195
+				}
189 196
 
190 197
 				// Has it been deemed selected?
191
-				if (!empty($tab['is_selected']))
192
-					$tab_context['tabs'][$id]['is_selected'] = true;
198
+				if (!empty($tab['is_selected'])) {
199
+									$tab_context['tabs'][$id]['is_selected'] = true;
200
+				}
193 201
 
194 202
 				// Does it have its own help?
195
-				if (!empty($tab['help']))
196
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
203
+				if (!empty($tab['help'])) {
204
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
205
+				}
197 206
 
198 207
 				// Is this the last one?
199
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
200
-					$tab_context['tabs'][$id]['is_last'] = true;
208
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
209
+									$tab_context['tabs'][$id]['is_last'] = true;
210
+				}
201 211
 			}
202 212
 
203 213
 			// Find the selected tab
@@ -214,17 +224,18 @@  discard block
 block discarded – undo
214 224
 		// Show an icon and/or a help item?
215 225
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
216 226
 		{
217
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
218
-				echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
219
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
220
-				echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
227
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
228
+							echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
229
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
230
+							echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
231
+			}
221 232
 
222
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
223
-				echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
233
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
234
+							echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
235
+			}
224 236
 
225 237
 			echo $tab_context['title'];
226
-		}
227
-		else
238
+		} else
228 239
 		{
229 240
 			echo '
230 241
 							', $tab_context['title'];
@@ -237,11 +248,12 @@  discard block
 block discarded – undo
237 248
 	}
238 249
 
239 250
 	// Shall we use the tabs? Yes, it's the only known way!
240
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
241
-		echo '
251
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
252
+			echo '
242 253
 					<p class="information">
243 254
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
244 255
 					</p>';
256
+	}
245 257
 
246 258
 	// Print out all the items in this tab (if any).
247 259
 	if (!empty($context['tabs']))
@@ -253,8 +265,9 @@  discard block
 block discarded – undo
253 265
 
254 266
 		foreach ($tab_context['tabs'] as $sa => $tab)
255 267
 		{
256
-			if (!empty($tab['disabled']))
257
-				continue;
268
+			if (!empty($tab['disabled'])) {
269
+							continue;
270
+			}
258 271
 
259 272
 			if (!empty($tab['is_selected']))
260 273
 			{
@@ -262,12 +275,12 @@  discard block
 block discarded – undo
262 275
 							<li>
263 276
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
264 277
 							</li>';
265
-			}
266
-			else
267
-				echo '
278
+			} else {
279
+							echo '
268 280
 							<li>
269 281
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
270 282
 							</li>';
283
+			}
271 284
 		}
272 285
 
273 286
 		// the end of tabs
Please login to merge, or discard this patch.
Sources/Who.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -673,7 +673,7 @@
 block discarded – undo
673 673
 						'Nikola &quot;Dzonny&quot; Novakovi&cacute;',
674 674
 						// Localizers
675 675
 						'Dr. Deejay',
676
-                        			'd3vcho',
676
+									'd3vcho',
677 677
 						// Former Localizers
678 678
 						'Relyana',
679 679
 					),
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 						'Shitiz &quot;Dragooon&quot; Garg',
591 591
 						'Karl &quot;RegularExpression&quot; Benson',
592 592
 						'Matthew &quot;Labradoodle-360&quot; Kerle',
593
-						$user_info['is_admin'] ? 'Matt &quot;Grudge&quot; Wolf': 'Grudge',
593
+						$user_info['is_admin'] ? 'Matt &quot;Grudge&quot; Wolf' : 'Grudge',
594 594
 						'Michael &quot;Thantos&quot; Miller',
595 595
 						'Norv',
596 596
 						'Peter "Arantor" Spicer',
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 			$credit_info = $smcFunc['json_decode']($row['credits'], true);
815 815
 
816 816
 			$copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' &copy; ' . $smcFunc['htmlspecialchars']($credit_info['copyright']);
817
-			$license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license']));
817
+			$license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license']));
818 818
 			$version = $txt['credits_version'] . ' ' . $row['version'];
819 819
 			$title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version;
820 820
 
821 821
 			// build this one out and stash it away
822 822
 			$mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>';
823
-			$mods[] = $mod_name . (!empty($license) ? ' | ' . $license  : '') . (!empty($copyright) ? ' | ' . $copyright  : '');
823
+			$mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : '');
824 824
 		}
825 825
 		cache_put_data('mods_credits', $mods, 86400);
826 826
 	}
Please login to merge, or discard this patch.
Braces   +126 added lines, -95 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Who's online, and what are they doing?
@@ -35,8 +36,9 @@  discard block
 block discarded – undo
35 36
 	isAllowedTo('who_view');
36 37
 
37 38
 	// You can't do anything if this is off.
38
-	if (empty($modSettings['who_enabled']))
39
-		fatal_lang_error('who_off', false);
39
+	if (empty($modSettings['who_enabled'])) {
40
+			fatal_lang_error('who_off', false);
41
+	}
40 42
 
41 43
 	// Load the 'Who' template.
42 44
 	loadTemplate('Who');
@@ -71,9 +73,9 @@  discard block
 block discarded – undo
71 73
 		$show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
72 74
 		$show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
73 75
 		$context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
76
+	} elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') {
77
+			unset($_SESSION['who_online_filter']);
74 78
 	}
75
-	elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders')
76
-		unset($_SESSION['who_online_filter']);
77 79
 
78 80
 	// Does the user prefer a different sort direction?
79 81
 	if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']]))
@@ -97,20 +99,24 @@  discard block
 block discarded – undo
97 99
 	$context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down';
98 100
 
99 101
 	$conditions = array();
100
-	if (!allowedTo('moderate_forum'))
101
-		$conditions[] = '(COALESCE(mem.show_online, 1) = 1)';
102
+	if (!allowedTo('moderate_forum')) {
103
+			$conditions[] = '(COALESCE(mem.show_online, 1) = 1)';
104
+	}
102 105
 
103 106
 	// Fallback to top filter?
104
-	if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
105
-		$_REQUEST['show'] = $_REQUEST['show_top'];
107
+	if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) {
108
+			$_REQUEST['show'] = $_REQUEST['show_top'];
109
+	}
106 110
 	// Does the user wish to apply a filter?
107
-	if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
108
-		$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
111
+	if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) {
112
+			$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
113
+	}
109 114
 	// Perhaps we saved a filter earlier in the session?
110
-	elseif (isset($_SESSION['who_online_filter']))
111
-		$context['show_by'] = $_SESSION['who_online_filter'];
112
-	else
113
-		$context['show_by'] = 'members';
115
+	elseif (isset($_SESSION['who_online_filter'])) {
116
+			$context['show_by'] = $_SESSION['who_online_filter'];
117
+	} else {
118
+			$context['show_by'] = 'members';
119
+	}
114 120
 
115 121
 	$conditions[] = $show_methods[$context['show_by']];
116 122
 
@@ -156,8 +162,9 @@  discard block
 block discarded – undo
156 162
 	while ($row = $smcFunc['db_fetch_assoc']($request))
157 163
 	{
158 164
 		$actions = $smcFunc['json_decode']($row['url'], true);
159
-		if ($actions === false)
160
-			continue;
165
+		if ($actions === false) {
166
+					continue;
167
+		}
161 168
 
162 169
 		// Send the information to the template.
163 170
 		$context['members'][$row['session']] = array(
@@ -195,8 +202,8 @@  discard block
 block discarded – undo
195 202
 	$spiderContext = array();
196 203
 	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
197 204
 	{
198
-		foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name)
199
-			$spiderContext[$id] = array(
205
+		foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) {
206
+					$spiderContext[$id] = array(
200 207
 				'id' => 0,
201 208
 				'name' => $name,
202 209
 				'group' => $txt['spiders'],
@@ -205,6 +212,7 @@  discard block
 block discarded – undo
205 212
 				'email' => $name,
206 213
 				'is_guest' => true
207 214
 			);
215
+		}
208 216
 	}
209 217
 
210 218
 	$url_data = determineActions($url_data);
@@ -219,16 +227,18 @@  discard block
 block discarded – undo
219 227
 	// Put it in the context variables.
220 228
 	foreach ($context['members'] as $i => $member)
221 229
 	{
222
-		if ($member['id'] != 0)
223
-			$member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
230
+		if ($member['id'] != 0) {
231
+					$member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
232
+		}
224 233
 
225 234
 		// Keep the IP that came from the database.
226 235
 		$memberContext[$member['id']]['ip'] = $member['ip'];
227 236
 		$context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden'];
228
-		if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']]))
229
-			$context['members'][$i] += $spiderContext[$member['id_spider']];
230
-		else
231
-			$context['members'][$i] += $memberContext[$member['id']];
237
+		if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) {
238
+					$context['members'][$i] += $spiderContext[$member['id_spider']];
239
+		} else {
240
+					$context['members'][$i] += $memberContext[$member['id']];
241
+		}
232 242
 	}
233 243
 
234 244
 	// Some people can't send personal messages...
@@ -263,8 +273,9 @@  discard block
 block discarded – undo
263 273
 {
264 274
 	global $txt, $user_info, $modSettings, $smcFunc;
265 275
 
266
-	if (!allowedTo('who_view'))
267
-		return array();
276
+	if (!allowedTo('who_view')) {
277
+			return array();
278
+	}
268 279
 	loadLanguage('Who');
269 280
 
270 281
 	// Actions that require a specific permission level.
@@ -292,10 +303,11 @@  discard block
 block discarded – undo
292 303
 	);
293 304
 	call_integration_hook('who_allowed', array(&$allowedActions));
294 305
 
295
-	if (!is_array($urls))
296
-		$url_list = array(array($urls, $user_info['id']));
297
-	else
298
-		$url_list = $urls;
306
+	if (!is_array($urls)) {
307
+			$url_list = array(array($urls, $user_info['id']));
308
+	} else {
309
+			$url_list = $urls;
310
+	}
299 311
 
300 312
 	// These are done to later query these in large chunks. (instead of one by one.)
301 313
 	$topic_ids = array();
@@ -307,12 +319,14 @@  discard block
 block discarded – undo
307 319
 	{
308 320
 		// Get the request parameters..
309 321
 		$actions = $smcFunc['json_decode']($url[0], true);
310
-		if ($actions === false)
311
-			continue;
322
+		if ($actions === false) {
323
+					continue;
324
+		}
312 325
 
313 326
 		// If it's the admin or moderation center, and there is an area set, use that instead.
314
-		if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area']))
315
-			$actions['action'] = $actions['area'];
327
+		if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) {
328
+					$actions['action'] = $actions['area'];
329
+		}
316 330
 
317 331
 		// Check if there was no action or the action is display.
318 332
 		if (!isset($actions['action']) || $actions['action'] == 'display')
@@ -332,12 +346,14 @@  discard block
 block discarded – undo
332 346
 				$board_ids[$actions['board']][$k] = $txt['who_board'];
333 347
 			}
334 348
 			// It's the board index!!  It must be!
335
-			else
336
-				$data[$k] = $txt['who_index'];
349
+			else {
350
+							$data[$k] = $txt['who_index'];
351
+			}
337 352
 		}
338 353
 		// Probably an error or some goon?
339
-		elseif ($actions['action'] == '')
340
-			$data[$k] = $txt['who_index'];
354
+		elseif ($actions['action'] == '') {
355
+					$data[$k] = $txt['who_index'];
356
+		}
341 357
 		// Some other normal action...?
342 358
 		else
343 359
 		{
@@ -345,23 +361,25 @@  discard block
 block discarded – undo
345 361
 			if ($actions['action'] == 'profile')
346 362
 			{
347 363
 				// Whose?  Their own?
348
-				if (empty($actions['u']))
349
-					$actions['u'] = $url[1];
364
+				if (empty($actions['u'])) {
365
+									$actions['u'] = $url[1];
366
+				}
350 367
 
351 368
 				$data[$k] = $txt['who_hidden'];
352 369
 				$profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile'];
353
-			}
354
-			elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
370
+			} elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
355 371
 			{
356 372
 				$data[$k] = $txt['who_hidden'];
357 373
 				$board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post'];
358 374
 			}
359 375
 			// A subaction anyone can view... if the language string is there, show it.
360
-			elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']]))
361
-				$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
376
+			elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) {
377
+							$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
378
+			}
362 379
 			// An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
363
-			elseif (isset($txt['whoall_' . $actions['action']]))
364
-				$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
380
+			elseif (isset($txt['whoall_' . $actions['action']])) {
381
+							$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
382
+			}
365 383
 			// Viewable if and only if they can see the board...
366 384
 			elseif (isset($txt['whotopic_' . $actions['action']]))
367 385
 			{
@@ -370,8 +388,7 @@  discard block
 block discarded – undo
370 388
 
371 389
 				$data[$k] = $txt['who_hidden'];
372 390
 				$topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']];
373
-			}
374
-			elseif (isset($txt['whopost_' . $actions['action']]))
391
+			} elseif (isset($txt['whopost_' . $actions['action']]))
375 392
 			{
376 393
 				// Find out what message they are accessing.
377 394
 				$msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0));
@@ -394,41 +411,46 @@  discard block
 block discarded – undo
394 411
 				$data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject);
395 412
 				$smcFunc['db_free_result']($result);
396 413
 
397
-				if (empty($id_topic))
398
-					$data[$k] = $txt['who_hidden'];
414
+				if (empty($id_topic)) {
415
+									$data[$k] = $txt['who_hidden'];
416
+				}
399 417
 			}
400 418
 			// Viewable only by administrators.. (if it starts with whoadmin, it's admin only!)
401
-			elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']]))
402
-				$data[$k] = $txt['whoadmin_' . $actions['action']];
419
+			elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) {
420
+							$data[$k] = $txt['whoadmin_' . $actions['action']];
421
+			}
403 422
 			// Viewable by permission level.
404 423
 			elseif (isset($allowedActions[$actions['action']]))
405 424
 			{
406
-				if (allowedTo($allowedActions[$actions['action']]))
407
-					$data[$k] = $txt['whoallow_' . $actions['action']];
408
-				elseif (in_array('moderate_forum', $allowedActions[$actions['action']]))
409
-					$data[$k] = $txt['who_moderate'];
410
-				elseif (in_array('admin_forum', $allowedActions[$actions['action']]))
411
-					$data[$k] = $txt['who_admin'];
412
-				else
413
-					$data[$k] = $txt['who_hidden'];
425
+				if (allowedTo($allowedActions[$actions['action']])) {
426
+									$data[$k] = $txt['whoallow_' . $actions['action']];
427
+				} elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) {
428
+									$data[$k] = $txt['who_moderate'];
429
+				} elseif (in_array('admin_forum', $allowedActions[$actions['action']])) {
430
+									$data[$k] = $txt['who_admin'];
431
+				} else {
432
+									$data[$k] = $txt['who_hidden'];
433
+				}
434
+			} elseif (!empty($actions['action'])) {
435
+							$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
436
+			} else {
437
+							$data[$k] = $txt['who_unknown'];
414 438
 			}
415
-			elseif (!empty($actions['action']))
416
-				$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
417
-			else
418
-				$data[$k] = $txt['who_unknown'];
419 439
 		}
420 440
 
421 441
 		if (isset($actions['error']))
422 442
 		{
423
-			if (isset($txt[$actions['error']]))
424
-				$error_message = str_replace('"', '&quot;', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params']));
425
-			elseif ($actions['error'] == 'guest_login')
426
-				$error_message = str_replace('"', '&quot;', $txt['who_guest_login']);
427
-			else
428
-				$error_message = str_replace('"', '&quot;', $actions['error']);
429
-
430
-			if (!empty($error_message))
431
-				$data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>';
443
+			if (isset($txt[$actions['error']])) {
444
+							$error_message = str_replace('"', '&quot;', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params']));
445
+			} elseif ($actions['error'] == 'guest_login') {
446
+							$error_message = str_replace('"', '&quot;', $txt['who_guest_login']);
447
+			} else {
448
+							$error_message = str_replace('"', '&quot;', $actions['error']);
449
+			}
450
+
451
+			if (!empty($error_message)) {
452
+							$data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>';
453
+			}
432 454
 		}
433 455
 
434 456
 		// Maybe the action is integrated into another system?
@@ -439,12 +461,15 @@  discard block
 block discarded – undo
439 461
 				if (!empty($integrate_action))
440 462
 				{
441 463
 					$data[$k] = $integrate_action;
442
-					if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k]))
443
-						$topic_ids[(int) $actions['topic']][$k] = $integrate_action;
444
-					if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k]))
445
-						$board_ids[(int) $actions['board']][$k] = $integrate_action;
446
-					if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k]))
447
-						$profile_ids[(int) $actions['u']][$k] = $integrate_action;
464
+					if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) {
465
+											$topic_ids[(int) $actions['topic']][$k] = $integrate_action;
466
+					}
467
+					if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) {
468
+											$board_ids[(int) $actions['board']][$k] = $integrate_action;
469
+					}
470
+					if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) {
471
+											$profile_ids[(int) $actions['u']][$k] = $integrate_action;
472
+					}
448 473
 					break;
449 474
 				}
450 475
 			}
@@ -472,8 +497,9 @@  discard block
 block discarded – undo
472 497
 		while ($row = $smcFunc['db_fetch_assoc']($result))
473 498
 		{
474 499
 			// Show the topic's subject for each of the actions.
475
-			foreach ($topic_ids[$row['id_topic']] as $k => $session_text)
476
-				$data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
500
+			foreach ($topic_ids[$row['id_topic']] as $k => $session_text) {
501
+							$data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
502
+			}
477 503
 		}
478 504
 		$smcFunc['db_free_result']($result);
479 505
 	}
@@ -495,8 +521,9 @@  discard block
 block discarded – undo
495 521
 		while ($row = $smcFunc['db_fetch_assoc']($result))
496 522
 		{
497 523
 			// Put the board name into the string for each member...
498
-			foreach ($board_ids[$row['id_board']] as $k => $session_text)
499
-				$data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
524
+			foreach ($board_ids[$row['id_board']] as $k => $session_text) {
525
+							$data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
526
+			}
500 527
 		}
501 528
 		$smcFunc['db_free_result']($result);
502 529
 	}
@@ -518,23 +545,26 @@  discard block
 block discarded – undo
518 545
 		while ($row = $smcFunc['db_fetch_assoc']($result))
519 546
 		{
520 547
 			// If they aren't allowed to view this person's profile, skip it.
521
-			if (!$allow_view_any && ($user_info['id'] != $row['id_member']))
522
-				continue;
548
+			if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) {
549
+							continue;
550
+			}
523 551
 
524 552
 			// Set their action on each - session/text to sprintf.
525
-			foreach ($profile_ids[$row['id_member']] as $k => $session_text)
526
-				$data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
553
+			foreach ($profile_ids[$row['id_member']] as $k => $session_text) {
554
+							$data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
555
+			}
527 556
 		}
528 557
 		$smcFunc['db_free_result']($result);
529 558
 	}
530 559
 
531 560
 	call_integration_hook('whos_online_after', array(&$urls, &$data));
532 561
 
533
-	if (!is_array($urls))
534
-		return isset($data[0]) ? $data[0] : false;
535
-	else
536
-		return $data;
537
-}
562
+	if (!is_array($urls)) {
563
+			return isset($data[0]) ? $data[0] : false;
564
+	} else {
565
+			return $data;
566
+	}
567
+	}
538 568
 
539 569
 /**
540 570
  * It prepares credit and copyright information for the credits page or the admin page
@@ -710,8 +740,8 @@  discard block
 block discarded – undo
710 740
 	);
711 741
 
712 742
 	// Give the translators some credit for their hard work.
713
-	if (!empty($txt['translation_credits']))
714
-		$context['credits'][] = array(
743
+	if (!empty($txt['translation_credits'])) {
744
+			$context['credits'][] = array(
715 745
 			'title' => $txt['credits_groups_translation'],
716 746
 			'groups' => array(
717 747
 				array(
@@ -720,6 +750,7 @@  discard block
 block discarded – undo
720 750
 				),
721 751
 			),
722 752
 		);
753
+	}
723 754
 
724 755
 	$context['credits'][] = array(
725 756
 		'title' => $txt['credits_special'],
Please login to merge, or discard this patch.
index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
  *
105 105
  * @param string $class The fully-qualified class name.
106 106
  */
107
-spl_autoload_register(function ($class) use ($sourcedir)
107
+spl_autoload_register(function($class) use ($sourcedir)
108 108
 {
109 109
 	$classMap = array(
110 110
 		'ReCaptcha\\' => 'ReCaptcha/',
Please login to merge, or discard this patch.
Braces   +38 added lines, -26 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?
@@ -382,8 +393,9 @@  discard block
 block discarded – undo
382 393
 	}
383 394
 
384 395
 	// Otherwise, it was set - so let's go to that action.
385
-	if (!empty($actionArray[$_REQUEST['action']][0]))
386
-		require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]);
396
+	if (!empty($actionArray[$_REQUEST['action']][0])) {
397
+			require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]);
398
+	}
387 399
 
388 400
 	// Do the right thing.
389 401
 	return call_helper($actionArray[$_REQUEST['action']][1], true);
Please login to merge, or discard this patch.
other/upgrade.php 4 patches
Doc Comments   +14 added lines, -1 removed lines patch added patch discarded remove patch
@@ -393,6 +393,9 @@  discard block
 block discarded – undo
393 393
 }
394 394
 
395 395
 // Used to direct the user to another location.
396
+/**
397
+ * @param string $location
398
+ */
396 399
 function redirectLocation($location, $addForm = true)
397 400
 {
398 401
 	global $upgradeurl, $upcontext, $command_line;
@@ -1573,6 +1576,9 @@  discard block
 block discarded – undo
1573 1576
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
1574 1577
 }
1575 1578
 
1579
+/**
1580
+ * @param string $filename
1581
+ */
1576 1582
 function parse_sql($filename)
1577 1583
 {
1578 1584
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -1607,6 +1613,10 @@  discard block
 block discarded – undo
1607 1613
 
1608 1614
 	// Our custom error handler - does nothing but does stop public errors from XML!
1609 1615
 	set_error_handler(
1616
+
1617
+		/**
1618
+		 * @param string $errno
1619
+		 */
1610 1620
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1611 1621
 		{
1612 1622
 			if ($support_js)
@@ -1853,6 +1863,9 @@  discard block
 block discarded – undo
1853 1863
 	return true;
1854 1864
 }
1855 1865
 
1866
+/**
1867
+ * @param string $string
1868
+ */
1856 1869
 function upgrade_query($string, $unbuffered = false)
1857 1870
 {
1858 1871
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -4512,7 +4525,7 @@  discard block
 block discarded – undo
4512 4525
  * @param int $setSize The amount of entries after which to update the database.
4513 4526
  *
4514 4527
  * newCol needs to be a varbinary(16) null able field
4515
- * @return bool
4528
+ * @return boolean|null
4516 4529
  */
4517 4530
 function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100)
4518 4531
 {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 
83 83
 // The helper is crucial. Include it first thing.
84 84
 if (!file_exists($upgrade_path . '/upgrade-helper.php'))
85
-    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.');
85
+	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.');
86 86
 
87 87
 require_once($upgrade_path . '/upgrade-helper.php');
88 88
 
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 
1626 1626
 	// Our custom error handler - does nothing but does stop public errors from XML!
1627 1627
 	set_error_handler(
1628
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1628
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1629 1629
 		{
1630 1630
 			if ($support_js)
1631 1631
 				return true;
@@ -2610,94 +2610,94 @@  discard block
 block discarded – undo
2610 2610
 		// Translation table for the character sets not native for MySQL.
2611 2611
 		$translation_tables = array(
2612 2612
 			'windows-1255' => array(
2613
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2614
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2615
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2616
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2617
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2618
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2619
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2620
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2621
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2622
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2623
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2624
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2625
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2626
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2627
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2628
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2629
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2630
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2631
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2632
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2633
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2634
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2635
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2636
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2637
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2638
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2639
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2640
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2641
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2642
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2643
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2644
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2645
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2646
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2647
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2648
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2649
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2650
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2651
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2652
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2653
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2654
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2613
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2614
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2615
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2616
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2617
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2618
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2619
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2620
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2621
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2622
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2623
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2624
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2625
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2626
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2627
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2628
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2629
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2630
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2631
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2632
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2633
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2634
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2635
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2636
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2637
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2638
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2639
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2640
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2641
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2642
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2643
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2644
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2645
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2646
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2647
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2648
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2649
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2650
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2651
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2652
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2653
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2654
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2655 2655
 				'0xFA' => '0xD7AA',
2656 2656
 			),
2657 2657
 			'windows-1253' => array(
2658
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2659
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2660
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2661
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2662
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2663
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2664
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2665
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2666
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2667
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2668
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2669
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2670
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2671
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2672
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2673
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2674
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2675
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2676
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2677
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2678
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2679
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2680
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2681
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2682
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2683
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2684
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2685
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2686
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2687
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2688
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2689
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2690
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2691
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2692
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2693
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2694
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2695
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2696
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2697
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2698
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2699
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2700
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2658
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2659
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2660
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2661
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2662
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2663
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2664
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2665
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2666
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2667
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2668
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2669
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2670
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2671
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2672
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2673
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2674
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2675
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2676
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2677
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2678
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2679
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2680
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2681
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2682
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2683
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2684
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2685
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2686
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2687
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2688
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2689
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2690
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2691
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2692
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2693
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2694
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2695
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2696
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2697
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2698
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2699
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2700
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2701 2701
 			),
2702 2702
 		);
2703 2703
 
@@ -3799,7 +3799,7 @@  discard block
 block discarded – undo
3799 3799
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
3800 3800
 			<input type="hidden" name="backup_done" id="backup_done" value="0">
3801 3801
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
3802
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
3802
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
3803 3803
 			<span id="debuginfo"></span>
3804 3804
 			</div>';
3805 3805
 
@@ -4300,7 +4300,7 @@  discard block
 block discarded – undo
4300 4300
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4301 4301
 			<input type="hidden" name="utf8_done" id="utf8_done" value="0">
4302 4302
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4303
-			<div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;">
4303
+			<div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;">
4304 4304
 			<span id="debuginfo"></span>
4305 4305
 			</div>';
4306 4306
 
@@ -4401,7 +4401,7 @@  discard block
 block discarded – undo
4401 4401
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4402 4402
 			<input type="hidden" name="json_done" id="json_done" value="0">
4403 4403
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4404
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
4404
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
4405 4405
 			<span id="debuginfo"></span>
4406 4406
 			</div>';
4407 4407
 
Please login to merge, or discard this patch.
Braces   +884 added lines, -649 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'];
@@ -197,8 +204,9 @@  discard block
 block discarded – undo
197 204
 			'db_error_skip' => true,
198 205
 		)
199 206
 	);
200
-	while ($row = $smcFunc['db_fetch_assoc']($request))
201
-		$modSettings[$row['variable']] = $row['value'];
207
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
208
+			$modSettings[$row['variable']] = $row['value'];
209
+	}
202 210
 	$smcFunc['db_free_result']($request);
203 211
 }
204 212
 
@@ -208,10 +216,12 @@  discard block
 block discarded – undo
208 216
 	$modSettings['theme_url'] = 'Themes/default';
209 217
 	$modSettings['images_url'] = 'Themes/default/images';
210 218
 }
211
-if (!isset($settings['default_theme_url']))
219
+if (!isset($settings['default_theme_url'])) {
212 220
 	$settings['default_theme_url'] = $modSettings['theme_url'];
213
-if (!isset($settings['default_theme_dir']))
221
+}
222
+if (!isset($settings['default_theme_dir'])) {
214 223
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
224
+}
215 225
 
216 226
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
217 227
 // Default title...
@@ -229,13 +239,15 @@  discard block
 block discarded – undo
229 239
 	$support_js = $upcontext['upgrade_status']['js'];
230 240
 
231 241
 	// Only set this if the upgrader status says so.
232
-	if (empty($is_debug))
233
-		$is_debug = $upcontext['upgrade_status']['debug'];
242
+	if (empty($is_debug)) {
243
+			$is_debug = $upcontext['upgrade_status']['debug'];
244
+	}
234 245
 
235 246
 	// Load the language.
236
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
237
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
238
-}
247
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
248
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
249
+	}
250
+	}
239 251
 // Set the defaults.
240 252
 else
241 253
 {
@@ -253,15 +265,18 @@  discard block
 block discarded – undo
253 265
 }
254 266
 
255 267
 // If this isn't the first stage see whether they are logging in and resuming.
256
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
268
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
257 269
 	checkLogin();
270
+}
258 271
 
259
-if ($command_line)
272
+if ($command_line) {
260 273
 	cmdStep0();
274
+}
261 275
 
262 276
 // Don't error if we're using xml.
263
-if (isset($_GET['xml']))
277
+if (isset($_GET['xml'])) {
264 278
 	$upcontext['return_error'] = true;
279
+}
265 280
 
266 281
 // Loop through all the steps doing each one as required.
267 282
 $upcontext['overall_percent'] = 0;
@@ -282,9 +297,9 @@  discard block
 block discarded – undo
282 297
 		}
283 298
 
284 299
 		// Call the step and if it returns false that means pause!
285
-		if (function_exists($step[2]) && $step[2]() === false)
286
-			break;
287
-		elseif (function_exists($step[2])) {
300
+		if (function_exists($step[2]) && $step[2]() === false) {
301
+					break;
302
+		} elseif (function_exists($step[2])) {
288 303
 			//Start each new step with this unset, so the 'normal' template is called first
289 304
 			unset($_GET['xml']);
290 305
 			//Clear out warnings at the start of each step
@@ -330,17 +345,18 @@  discard block
 block discarded – undo
330 345
 		// This should not happen my dear... HELP ME DEVELOPERS!!
331 346
 		if (!empty($command_line))
332 347
 		{
333
-			if (function_exists('debug_print_backtrace'))
334
-				debug_print_backtrace();
348
+			if (function_exists('debug_print_backtrace')) {
349
+							debug_print_backtrace();
350
+			}
335 351
 
336 352
 			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.';
337 353
 			flush();
338 354
 			die();
339 355
 		}
340 356
 
341
-		if (!isset($_GET['xml']))
342
-			template_upgrade_above();
343
-		else
357
+		if (!isset($_GET['xml'])) {
358
+					template_upgrade_above();
359
+		} else
344 360
 		{
345 361
 			header('Content-Type: text/xml; charset=UTF-8');
346 362
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -362,25 +378,29 @@  discard block
 block discarded – undo
362 378
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(json_encode($upcontext['upgrade_status']));
363 379
 
364 380
 			// Custom stuff to pass back?
365
-			if (!empty($upcontext['query_string']))
366
-				$upcontext['form_url'] .= $upcontext['query_string'];
381
+			if (!empty($upcontext['query_string'])) {
382
+							$upcontext['form_url'] .= $upcontext['query_string'];
383
+			}
367 384
 
368 385
 			// Call the appropriate subtemplate
369
-			if (is_callable('template_' . $upcontext['sub_template']))
370
-				call_user_func('template_' . $upcontext['sub_template']);
371
-			else
372
-				die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
386
+			if (is_callable('template_' . $upcontext['sub_template'])) {
387
+							call_user_func('template_' . $upcontext['sub_template']);
388
+			} else {
389
+							die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
390
+			}
373 391
 		}
374 392
 
375 393
 		// Was there an error?
376
-		if (!empty($upcontext['forced_error_message']))
377
-			echo $upcontext['forced_error_message'];
394
+		if (!empty($upcontext['forced_error_message'])) {
395
+					echo $upcontext['forced_error_message'];
396
+		}
378 397
 
379 398
 		// Show the footer.
380
-		if (!isset($_GET['xml']))
381
-			template_upgrade_below();
382
-		else
383
-			template_xml_below();
399
+		if (!isset($_GET['xml'])) {
400
+					template_upgrade_below();
401
+		} else {
402
+					template_xml_below();
403
+		}
384 404
 	}
385 405
 
386 406
 
@@ -392,15 +412,19 @@  discard block
 block discarded – undo
392 412
 		$seconds = intval($active % 60);
393 413
 
394 414
 		$totalTime = '';
395
-		if ($hours > 0)
396
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
397
-		if ($minutes > 0)
398
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
399
-		if ($seconds > 0)
400
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
415
+		if ($hours > 0) {
416
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
417
+		}
418
+		if ($minutes > 0) {
419
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
420
+		}
421
+		if ($seconds > 0) {
422
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
423
+		}
401 424
 
402
-		if (!empty($totalTime))
403
-			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
425
+		if (!empty($totalTime)) {
426
+					echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
427
+		}
404 428
 	}
405 429
 
406 430
 	// Bang - gone!
@@ -413,8 +437,9 @@  discard block
 block discarded – undo
413 437
 	global $upgradeurl, $upcontext, $command_line;
414 438
 
415 439
 	// Command line users can't be redirected.
416
-	if ($command_line)
417
-		upgradeExit(true);
440
+	if ($command_line) {
441
+			upgradeExit(true);
442
+	}
418 443
 
419 444
 	// Are we providing the core info?
420 445
 	if ($addForm)
@@ -440,12 +465,14 @@  discard block
 block discarded – undo
440 465
 	define('SMF', 1);
441 466
 
442 467
 	// Start the session.
443
-	if (@ini_get('session.save_handler') == 'user')
444
-		@ini_set('session.save_handler', 'files');
468
+	if (@ini_get('session.save_handler') == 'user') {
469
+			@ini_set('session.save_handler', 'files');
470
+	}
445 471
 	@session_start();
446 472
 
447
-	if (empty($smcFunc))
448
-		$smcFunc = array();
473
+	if (empty($smcFunc)) {
474
+			$smcFunc = array();
475
+	}
449 476
 
450 477
 	// We need this for authentication and some upgrade code
451 478
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -472,24 +499,27 @@  discard block
 block discarded – undo
472 499
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
473 500
 
474 501
 		// Make the connection...
475
-		if (empty($db_connection))
476
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
477
-		else
478
-			// If we've returned here, ping/reconnect to be safe
502
+		if (empty($db_connection)) {
503
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
504
+		} else {
505
+					// If we've returned here, ping/reconnect to be safe
479 506
 			$smcFunc['db_ping']($db_connection);
507
+		}
480 508
 
481 509
 		// Oh dear god!!
482
-		if ($db_connection === null)
483
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
510
+		if ($db_connection === null) {
511
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
512
+		}
484 513
 
485
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
486
-			$smcFunc['db_query']('', '
514
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
515
+					$smcFunc['db_query']('', '
487 516
 			SET NAMES {string:db_character_set}',
488 517
 			array(
489 518
 				'db_error_skip' => true,
490 519
 				'db_character_set' => $db_character_set,
491 520
 			)
492 521
 		);
522
+		}
493 523
 
494 524
 		// Load the modSettings data...
495 525
 		$request = $smcFunc['db_query']('', '
@@ -500,11 +530,11 @@  discard block
 block discarded – undo
500 530
 			)
501 531
 		);
502 532
 		$modSettings = array();
503
-		while ($row = $smcFunc['db_fetch_assoc']($request))
504
-			$modSettings[$row['variable']] = $row['value'];
533
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
534
+					$modSettings[$row['variable']] = $row['value'];
535
+		}
505 536
 		$smcFunc['db_free_result']($request);
506
-	}
507
-	else
537
+	} else
508 538
 	{
509 539
 		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.');
510 540
 	}
@@ -518,9 +548,10 @@  discard block
 block discarded – undo
518 548
 		cleanRequest();
519 549
 	}
520 550
 
521
-	if (!isset($_GET['substep']))
522
-		$_GET['substep'] = 0;
523
-}
551
+	if (!isset($_GET['substep'])) {
552
+			$_GET['substep'] = 0;
553
+	}
554
+	}
524 555
 
525 556
 function initialize_inputs()
526 557
 {
@@ -550,8 +581,9 @@  discard block
 block discarded – undo
550 581
 		$dh = opendir(dirname(__FILE__));
551 582
 		while ($file = readdir($dh))
552 583
 		{
553
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
554
-				@unlink(dirname(__FILE__) . '/' . $file);
584
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
585
+							@unlink(dirname(__FILE__) . '/' . $file);
586
+			}
555 587
 		}
556 588
 		closedir($dh);
557 589
 
@@ -580,8 +612,9 @@  discard block
 block discarded – undo
580 612
 	$temp = 'upgrade_php?step';
581 613
 	while (strlen($temp) > 4)
582 614
 	{
583
-		if (isset($_GET[$temp]))
584
-			unset($_GET[$temp]);
615
+		if (isset($_GET[$temp])) {
616
+					unset($_GET[$temp]);
617
+		}
585 618
 		$temp = substr($temp, 1);
586 619
 	}
587 620
 
@@ -608,32 +641,39 @@  discard block
 block discarded – undo
608 641
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
609 642
 
610 643
 	// Need legacy scripts?
611
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
612
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
613
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
614
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
615
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
616
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
644
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
645
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
646
+	}
647
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
648
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
649
+	}
650
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
651
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
652
+	}
617 653
 
618 654
 	// We don't need "-utf8" files anymore...
619 655
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
620 656
 
621 657
 	// This needs to exist!
622
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
623
-		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>]');
624
-	else
625
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
658
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
659
+			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>]');
660
+	} else {
661
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
662
+	}
626 663
 
627
-	if (!$check)
628
-		// 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.
664
+	if (!$check) {
665
+			// 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.
629 666
 		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.');
667
+	}
630 668
 
631 669
 	// Do they meet the install requirements?
632
-	if (!php_version_check())
633
-		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.');
670
+	if (!php_version_check()) {
671
+			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.');
672
+	}
634 673
 
635
-	if (!db_version_check())
636
-		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.');
674
+	if (!db_version_check()) {
675
+			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.');
676
+	}
637 677
 
638 678
 	// Do some checks to make sure they have proper privileges
639 679
 	db_extend('packages');
@@ -648,14 +688,16 @@  discard block
 block discarded – undo
648 688
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
649 689
 
650 690
 	// Sorry... we need CREATE, ALTER and DROP
651
-	if (!$create || !$alter || !$drop)
652
-		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.');
691
+	if (!$create || !$alter || !$drop) {
692
+			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.');
693
+	}
653 694
 
654 695
 	// Do a quick version spot check.
655 696
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
656 697
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
657
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
658
-		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.');
698
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
699
+			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.');
700
+	}
659 701
 
660 702
 	// What absolutely needs to be writable?
661 703
 	$writable_files = array(
@@ -677,12 +719,13 @@  discard block
 block discarded – undo
677 719
 	quickFileWritable($custom_av_dir);
678 720
 
679 721
 	// Are we good now?
680
-	if (!is_writable($custom_av_dir))
681
-		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));
682
-	elseif ($need_settings_update)
722
+	if (!is_writable($custom_av_dir)) {
723
+			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));
724
+	} elseif ($need_settings_update)
683 725
 	{
684
-		if (!function_exists('cache_put_data'))
685
-			require_once($sourcedir . '/Load.php');
726
+		if (!function_exists('cache_put_data')) {
727
+					require_once($sourcedir . '/Load.php');
728
+		}
686 729
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
687 730
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
688 731
 	}
@@ -691,28 +734,33 @@  discard block
 block discarded – undo
691 734
 
692 735
 	// Check the cache directory.
693 736
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
694
-	if (!file_exists($cachedir_temp))
695
-		@mkdir($cachedir_temp);
696
-	if (!file_exists($cachedir_temp))
697
-		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.');
698
-
699
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
700
-		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>.');
701
-	elseif (!isset($_GET['skiplang']))
737
+	if (!file_exists($cachedir_temp)) {
738
+			@mkdir($cachedir_temp);
739
+	}
740
+	if (!file_exists($cachedir_temp)) {
741
+			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.');
742
+	}
743
+
744
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
745
+			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>.');
746
+	} elseif (!isset($_GET['skiplang']))
702 747
 	{
703 748
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
704 749
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
705 750
 
706
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
707
-			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>]');
751
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
752
+					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>]');
753
+		}
708 754
 	}
709 755
 
710
-	if (!makeFilesWritable($writable_files))
711
-		return false;
756
+	if (!makeFilesWritable($writable_files)) {
757
+			return false;
758
+	}
712 759
 
713 760
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
714
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
715
-		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.');
761
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
762
+			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.');
763
+	}
716 764
 
717 765
 	// Upgrade the agreement.
718 766
 	elseif (isset($modSettings['agreement']))
@@ -723,8 +771,8 @@  discard block
 block discarded – undo
723 771
 	}
724 772
 
725 773
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
726
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
727
-		$upcontext['warning'] = '
774
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
775
+			$upcontext['warning'] = '
728 776
 			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>
729 777
 			<ul>
730 778
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -732,19 +780,23 @@  discard block
 block discarded – undo
732 780
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
733 781
 			</ul>
734 782
 			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.';
783
+	}
735 784
 
736 785
 	// Confirm mbstring is loaded...
737
-	if (!extension_loaded('mbstring'))
738
-		return throw_error($txt['install_no_mbstring']);
786
+	if (!extension_loaded('mbstring')) {
787
+			return throw_error($txt['install_no_mbstring']);
788
+	}
739 789
 
740 790
 	// Check for https stream support.
741 791
 	$supported_streams = stream_get_wrappers();
742
-	if (!in_array('https', $supported_streams))
743
-		$upcontext['custom_warning'] = $txt['install_no_https'];
792
+	if (!in_array('https', $supported_streams)) {
793
+			$upcontext['custom_warning'] = $txt['install_no_https'];
794
+	}
744 795
 
745 796
 	// Either we're logged in or we're going to present the login.
746
-	if (checkLogin())
747
-		return true;
797
+	if (checkLogin()) {
798
+			return true;
799
+	}
748 800
 
749 801
 	$upcontext += createToken('login');
750 802
 
@@ -758,15 +810,17 @@  discard block
 block discarded – undo
758 810
 	global $smcFunc, $db_type, $support_js;
759 811
 
760 812
 	// Don't bother if the security is disabled.
761
-	if ($disable_security)
762
-		return true;
813
+	if ($disable_security) {
814
+			return true;
815
+	}
763 816
 
764 817
 	// Are we trying to login?
765 818
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
766 819
 	{
767 820
 		// If we've disabled security pick a suitable name!
768
-		if (empty($_POST['user']))
769
-			$_POST['user'] = 'Administrator';
821
+		if (empty($_POST['user'])) {
822
+					$_POST['user'] = 'Administrator';
823
+		}
770 824
 
771 825
 		// Before 2.0 these column names were different!
772 826
 		$oldDB = false;
@@ -781,16 +835,17 @@  discard block
 block discarded – undo
781 835
 					'db_error_skip' => true,
782 836
 				)
783 837
 			);
784
-			if ($smcFunc['db_num_rows']($request) != 0)
785
-				$oldDB = true;
838
+			if ($smcFunc['db_num_rows']($request) != 0) {
839
+							$oldDB = true;
840
+			}
786 841
 			$smcFunc['db_free_result']($request);
787 842
 		}
788 843
 
789 844
 		// Get what we believe to be their details.
790 845
 		if (!$disable_security)
791 846
 		{
792
-			if ($oldDB)
793
-				$request = $smcFunc['db_query']('', '
847
+			if ($oldDB) {
848
+							$request = $smcFunc['db_query']('', '
794 849
 					SELECT id_member, memberName AS member_name, passwd, id_group,
795 850
 					additionalGroups AS additional_groups, lngfile
796 851
 					FROM {db_prefix}members
@@ -800,8 +855,8 @@  discard block
 block discarded – undo
800 855
 						'db_error_skip' => true,
801 856
 					)
802 857
 				);
803
-			else
804
-				$request = $smcFunc['db_query']('', '
858
+			} else {
859
+							$request = $smcFunc['db_query']('', '
805 860
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
806 861
 					FROM {db_prefix}members
807 862
 					WHERE member_name = {string:member_name}',
@@ -810,6 +865,7 @@  discard block
 block discarded – undo
810 865
 						'db_error_skip' => true,
811 866
 					)
812 867
 				);
868
+			}
813 869
 			if ($smcFunc['db_num_rows']($request) != 0)
814 870
 			{
815 871
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -817,16 +873,17 @@  discard block
 block discarded – undo
817 873
 				$groups = explode(',', $addGroups);
818 874
 				$groups[] = $id_group;
819 875
 
820
-				foreach ($groups as $k => $v)
821
-					$groups[$k] = (int) $v;
876
+				foreach ($groups as $k => $v) {
877
+									$groups[$k] = (int) $v;
878
+				}
822 879
 
823 880
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
824 881
 
825 882
 				// We don't use "-utf8" anymore...
826 883
 				$user_language = str_ireplace('-utf8', '', $user_language);
884
+			} else {
885
+							$upcontext['username_incorrect'] = true;
827 886
 			}
828
-			else
829
-				$upcontext['username_incorrect'] = true;
830 887
 			$smcFunc['db_free_result']($request);
831 888
 		}
832 889
 		$upcontext['username'] = $_POST['user'];
@@ -836,13 +893,14 @@  discard block
 block discarded – undo
836 893
 		{
837 894
 			$upcontext['upgrade_status']['js'] = 1;
838 895
 			$support_js = 1;
896
+		} else {
897
+					$support_js = 0;
839 898
 		}
840
-		else
841
-			$support_js = 0;
842 899
 
843 900
 		// Note down the version we are coming from.
844
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
845
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
901
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
902
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
903
+		}
846 904
 
847 905
 		// Didn't get anywhere?
848 906
 		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']))
@@ -876,15 +934,15 @@  discard block
 block discarded – undo
876 934
 							'db_error_skip' => true,
877 935
 						)
878 936
 					);
879
-					if ($smcFunc['db_num_rows']($request) == 0)
880
-						return throw_error('You need to be an admin to perform an upgrade!');
937
+					if ($smcFunc['db_num_rows']($request) == 0) {
938
+											return throw_error('You need to be an admin to perform an upgrade!');
939
+					}
881 940
 					$smcFunc['db_free_result']($request);
882 941
 				}
883 942
 
884 943
 				$upcontext['user']['id'] = $id_member;
885 944
 				$upcontext['user']['name'] = $name;
886
-			}
887
-			else
945
+			} else
888 946
 			{
889 947
 				$upcontext['user']['id'] = 1;
890 948
 				$upcontext['user']['name'] = 'Administrator';
@@ -900,11 +958,11 @@  discard block
 block discarded – undo
900 958
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
901 959
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
902 960
 
903
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
904
-					$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'] . '.';
905
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
906
-					$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'] . '.';
907
-				else
961
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
962
+									$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'] . '.';
963
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
964
+									$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'] . '.';
965
+				} else
908 966
 				{
909 967
 					// Set this as the new language.
910 968
 					$upcontext['language'] = $user_language;
@@ -948,8 +1006,9 @@  discard block
 block discarded – undo
948 1006
 	unset($member_columns);
949 1007
 
950 1008
 	// If we've not submitted then we're done.
951
-	if (empty($_POST['upcont']))
952
-		return false;
1009
+	if (empty($_POST['upcont'])) {
1010
+			return false;
1011
+	}
953 1012
 
954 1013
 	// Firstly, if they're enabling SM stat collection just do it.
955 1014
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
@@ -969,16 +1028,17 @@  discard block
 block discarded – undo
969 1028
 				fwrite($fp, $out);
970 1029
 
971 1030
 				$return_data = '';
972
-				while (!feof($fp))
973
-					$return_data .= fgets($fp, 128);
1031
+				while (!feof($fp)) {
1032
+									$return_data .= fgets($fp, 128);
1033
+				}
974 1034
 
975 1035
 				fclose($fp);
976 1036
 
977 1037
 				// Get the unique site ID.
978 1038
 				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
979 1039
 
980
-				if (!empty($ID[1]))
981
-					$smcFunc['db_insert']('replace',
1040
+				if (!empty($ID[1])) {
1041
+									$smcFunc['db_insert']('replace',
982 1042
 						$db_prefix . 'settings',
983 1043
 						array('variable' => 'string', 'value' => 'string'),
984 1044
 						array(
@@ -987,9 +1047,9 @@  discard block
 block discarded – undo
987 1047
 						),
988 1048
 						array('variable')
989 1049
 					);
1050
+				}
990 1051
 			}
991
-		}
992
-		else
1052
+		} else
993 1053
 		{
994 1054
 			$smcFunc['db_insert']('replace',
995 1055
 				$db_prefix . 'settings',
@@ -1000,8 +1060,8 @@  discard block
 block discarded – undo
1000 1060
 		}
1001 1061
 	}
1002 1062
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1003
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1004
-		$smcFunc['db_query']('', '
1063
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1064
+			$smcFunc['db_query']('', '
1005 1065
 			DELETE FROM {db_prefix}settings
1006 1066
 			WHERE variable = {string:enable_sm_stats}',
1007 1067
 			array(
@@ -1009,6 +1069,7 @@  discard block
 block discarded – undo
1009 1069
 				'db_error_skip' => true,
1010 1070
 			)
1011 1071
 		);
1072
+	}
1012 1073
 
1013 1074
 	// Deleting old karma stuff?
1014 1075
 	if (!empty($_POST['delete_karma']))
@@ -1023,20 +1084,22 @@  discard block
 block discarded – undo
1023 1084
 		);
1024 1085
 
1025 1086
 		// Cleaning up old karma member settings.
1026
-		if ($upcontext['karma_installed']['good'])
1027
-			$smcFunc['db_query']('', '
1087
+		if ($upcontext['karma_installed']['good']) {
1088
+					$smcFunc['db_query']('', '
1028 1089
 				ALTER TABLE {db_prefix}members
1029 1090
 				DROP karma_good',
1030 1091
 				array()
1031 1092
 			);
1093
+		}
1032 1094
 
1033 1095
 		// Does karma bad was enable?
1034
-		if ($upcontext['karma_installed']['bad'])
1035
-			$smcFunc['db_query']('', '
1096
+		if ($upcontext['karma_installed']['bad']) {
1097
+					$smcFunc['db_query']('', '
1036 1098
 				ALTER TABLE {db_prefix}members
1037 1099
 				DROP karma_bad',
1038 1100
 				array()
1039 1101
 			);
1102
+		}
1040 1103
 
1041 1104
 		// Cleaning up old karma permissions.
1042 1105
 		$smcFunc['db_query']('', '
@@ -1049,32 +1112,37 @@  discard block
 block discarded – undo
1049 1112
 	}
1050 1113
 
1051 1114
 	// Emptying the error log?
1052
-	if (!empty($_POST['empty_error']))
1053
-		$smcFunc['db_query']('truncate_table', '
1115
+	if (!empty($_POST['empty_error'])) {
1116
+			$smcFunc['db_query']('truncate_table', '
1054 1117
 			TRUNCATE {db_prefix}log_errors',
1055 1118
 			array(
1056 1119
 			)
1057 1120
 		);
1121
+	}
1058 1122
 
1059 1123
 	$changes = array();
1060 1124
 
1061 1125
 	// Add proxy settings.
1062
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1063
-		$changes += array(
1126
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1127
+			$changes += array(
1064 1128
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1065 1129
 			'image_proxy_maxsize' => 5190,
1066 1130
 			'image_proxy_enabled' => 0,
1067 1131
 		);
1132
+	}
1068 1133
 
1069 1134
 	// If $boardurl reflects https, set force_ssl
1070
-	if (!function_exists('cache_put_data'))
1071
-		require_once($sourcedir . '/Load.php');
1072
-	if (stripos($boardurl, 'https://') !== false)
1073
-		updateSettings(array('force_ssl' => '2'));
1135
+	if (!function_exists('cache_put_data')) {
1136
+			require_once($sourcedir . '/Load.php');
1137
+	}
1138
+	if (stripos($boardurl, 'https://') !== false) {
1139
+			updateSettings(array('force_ssl' => '2'));
1140
+	}
1074 1141
 
1075 1142
 	// If we're overriding the language follow it through.
1076
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1077
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1143
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1144
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1145
+	}
1078 1146
 
1079 1147
 	if (!empty($_POST['maint']))
1080 1148
 	{
@@ -1086,26 +1154,29 @@  discard block
 block discarded – undo
1086 1154
 		{
1087 1155
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1088 1156
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1089
-		}
1090
-		else
1157
+		} else
1091 1158
 		{
1092 1159
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1093 1160
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1094 1161
 		}
1095 1162
 	}
1096 1163
 
1097
-	if ($command_line)
1098
-		echo ' * Updating Settings.php...';
1164
+	if ($command_line) {
1165
+			echo ' * Updating Settings.php...';
1166
+	}
1099 1167
 
1100 1168
 	// Fix some old paths.
1101
-	if (substr($boarddir, 0, 1) == '.')
1102
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1169
+	if (substr($boarddir, 0, 1) == '.') {
1170
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1171
+	}
1103 1172
 
1104
-	if (substr($sourcedir, 0, 1) == '.')
1105
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1173
+	if (substr($sourcedir, 0, 1) == '.') {
1174
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1175
+	}
1106 1176
 
1107
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1108
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1177
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1178
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1179
+	}
1109 1180
 
1110 1181
 	// If they have a "host:port" setup for the host, split that into separate values
1111 1182
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1116,32 +1187,36 @@  discard block
 block discarded – undo
1116 1187
 		$changes['db_server'] = '\'' . $db_server . '\'';
1117 1188
 
1118 1189
 		// Only set this if we're not using the default port
1119
-		if ($db_port != ini_get('mysqli.default_port'))
1120
-			$changes['db_port'] = (int) $db_port;
1121
-	}
1122
-	elseif (!empty($db_port))
1190
+		if ($db_port != ini_get('mysqli.default_port')) {
1191
+					$changes['db_port'] = (int) $db_port;
1192
+		}
1193
+	} elseif (!empty($db_port))
1123 1194
 	{
1124 1195
 		// If db_port is set and is the same as the default, set it to ''
1125 1196
 		if ($db_type == 'mysql')
1126 1197
 		{
1127
-			if ($db_port == ini_get('mysqli.default_port'))
1128
-				$changes['db_port'] = '\'\'';
1129
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1130
-				$changes['db_port'] = '\'\'';
1198
+			if ($db_port == ini_get('mysqli.default_port')) {
1199
+							$changes['db_port'] = '\'\'';
1200
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1201
+							$changes['db_port'] = '\'\'';
1202
+			}
1131 1203
 		}
1132 1204
 	}
1133 1205
 
1134 1206
 	// Maybe we haven't had this option yet?
1135
-	if (empty($packagesdir))
1136
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1207
+	if (empty($packagesdir)) {
1208
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1209
+	}
1137 1210
 
1138 1211
 	// Add support for $tasksdir var.
1139
-	if (empty($tasksdir))
1140
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1212
+	if (empty($tasksdir)) {
1213
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1214
+	}
1141 1215
 
1142 1216
 	// Make sure we fix the language as well.
1143
-	if (stristr($language, '-utf8'))
1144
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1217
+	if (stristr($language, '-utf8')) {
1218
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1219
+	}
1145 1220
 
1146 1221
 	// @todo Maybe change the cookie name if going to 1.1, too?
1147 1222
 
@@ -1149,8 +1224,9 @@  discard block
 block discarded – undo
1149 1224
 	require_once($sourcedir . '/Subs-Admin.php');
1150 1225
 	updateSettingsFile($changes);
1151 1226
 
1152
-	if ($command_line)
1153
-		echo ' Successful.' . "\n";
1227
+	if ($command_line) {
1228
+			echo ' Successful.' . "\n";
1229
+	}
1154 1230
 
1155 1231
 	// Are we doing debug?
1156 1232
 	if (isset($_POST['debug']))
@@ -1160,8 +1236,9 @@  discard block
 block discarded – undo
1160 1236
 	}
1161 1237
 
1162 1238
 	// If we're not backing up then jump one.
1163
-	if (empty($_POST['backup']))
1164
-		$upcontext['current_step']++;
1239
+	if (empty($_POST['backup'])) {
1240
+			$upcontext['current_step']++;
1241
+	}
1165 1242
 
1166 1243
 	// If we've got here then let's proceed to the next step!
1167 1244
 	return true;
@@ -1176,8 +1253,9 @@  discard block
 block discarded – undo
1176 1253
 	$upcontext['page_title'] = 'Backup Database';
1177 1254
 
1178 1255
 	// Done it already - js wise?
1179
-	if (!empty($_POST['backup_done']))
1180
-		return true;
1256
+	if (!empty($_POST['backup_done'])) {
1257
+			return true;
1258
+	}
1181 1259
 
1182 1260
 	// Some useful stuff here.
1183 1261
 	db_extend();
@@ -1191,9 +1269,10 @@  discard block
 block discarded – undo
1191 1269
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1192 1270
 
1193 1271
 	$table_names = array();
1194
-	foreach ($tables as $table)
1195
-		if (substr($table, 0, 7) !== 'backup_')
1272
+	foreach ($tables as $table) {
1273
+			if (substr($table, 0, 7) !== 'backup_')
1196 1274
 			$table_names[] = $table;
1275
+	}
1197 1276
 
1198 1277
 	$upcontext['table_count'] = count($table_names);
1199 1278
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1203,12 +1282,14 @@  discard block
 block discarded – undo
1203 1282
 	$file_steps = $upcontext['table_count'];
1204 1283
 
1205 1284
 	// What ones have we already done?
1206
-	foreach ($table_names as $id => $table)
1207
-		if ($id < $_GET['substep'])
1285
+	foreach ($table_names as $id => $table) {
1286
+			if ($id < $_GET['substep'])
1208 1287
 			$upcontext['previous_tables'][] = $table;
1288
+	}
1209 1289
 
1210
-	if ($command_line)
1211
-		echo 'Backing Up Tables.';
1290
+	if ($command_line) {
1291
+			echo 'Backing Up Tables.';
1292
+	}
1212 1293
 
1213 1294
 	// If we don't support javascript we backup here.
1214 1295
 	if (!$support_js || isset($_GET['xml']))
@@ -1227,8 +1308,9 @@  discard block
 block discarded – undo
1227 1308
 			backupTable($table_names[$substep]);
1228 1309
 
1229 1310
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1230
-			if (isset($_GET['xml']))
1231
-				return upgradeExit();
1311
+			if (isset($_GET['xml'])) {
1312
+							return upgradeExit();
1313
+			}
1232 1314
 		}
1233 1315
 
1234 1316
 		if ($command_line)
@@ -1261,9 +1343,10 @@  discard block
 block discarded – undo
1261 1343
 
1262 1344
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1263 1345
 
1264
-	if ($command_line)
1265
-		echo ' done.';
1266
-}
1346
+	if ($command_line) {
1347
+			echo ' done.';
1348
+	}
1349
+	}
1267 1350
 
1268 1351
 // Step 2: Everything.
1269 1352
 function DatabaseChanges()
@@ -1272,8 +1355,9 @@  discard block
 block discarded – undo
1272 1355
 	global $upcontext, $support_js, $db_type;
1273 1356
 
1274 1357
 	// Have we just completed this?
1275
-	if (!empty($_POST['database_done']))
1276
-		return true;
1358
+	if (!empty($_POST['database_done'])) {
1359
+			return true;
1360
+	}
1277 1361
 
1278 1362
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1279 1363
 	$upcontext['page_title'] = 'Database Changes';
@@ -1288,15 +1372,16 @@  discard block
 block discarded – undo
1288 1372
 	);
1289 1373
 
1290 1374
 	// How many files are there in total?
1291
-	if (isset($_GET['filecount']))
1292
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1293
-	else
1375
+	if (isset($_GET['filecount'])) {
1376
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1377
+	} else
1294 1378
 	{
1295 1379
 		$upcontext['file_count'] = 0;
1296 1380
 		foreach ($files as $file)
1297 1381
 		{
1298
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1299
-				$upcontext['file_count']++;
1382
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1383
+							$upcontext['file_count']++;
1384
+			}
1300 1385
 		}
1301 1386
 	}
1302 1387
 
@@ -1306,9 +1391,9 @@  discard block
 block discarded – undo
1306 1391
 	$upcontext['cur_file_num'] = 0;
1307 1392
 	foreach ($files as $file)
1308 1393
 	{
1309
-		if ($did_not_do)
1310
-			$did_not_do--;
1311
-		else
1394
+		if ($did_not_do) {
1395
+					$did_not_do--;
1396
+		} else
1312 1397
 		{
1313 1398
 			$upcontext['cur_file_num']++;
1314 1399
 			$upcontext['cur_file_name'] = $file[0];
@@ -1335,12 +1420,13 @@  discard block
 block discarded – undo
1335 1420
 					// Flag to move on to the next.
1336 1421
 					$upcontext['completed_step'] = true;
1337 1422
 					// Did we complete the whole file?
1338
-					if ($nextFile)
1339
-						$upcontext['current_debug_item_num'] = -1;
1423
+					if ($nextFile) {
1424
+											$upcontext['current_debug_item_num'] = -1;
1425
+					}
1340 1426
 					return upgradeExit();
1427
+				} elseif ($support_js) {
1428
+									break;
1341 1429
 				}
1342
-				elseif ($support_js)
1343
-					break;
1344 1430
 			}
1345 1431
 			// Set the progress bar to be right as if we had - even if we hadn't...
1346 1432
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1365,8 +1451,9 @@  discard block
 block discarded – undo
1365 1451
 	global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1366 1452
 
1367 1453
 	// Now it's nice to have some of the basic SMF source files.
1368
-	if (!isset($_GET['ssi']) && !$command_line)
1369
-		redirectLocation('&ssi=1');
1454
+	if (!isset($_GET['ssi']) && !$command_line) {
1455
+			redirectLocation('&ssi=1');
1456
+	}
1370 1457
 
1371 1458
 	$upcontext['sub_template'] = 'upgrade_complete';
1372 1459
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1382,14 +1469,16 @@  discard block
 block discarded – undo
1382 1469
 	// Are we in maintenance mode?
1383 1470
 	if (isset($upcontext['user']['main']))
1384 1471
 	{
1385
-		if ($command_line)
1386
-			echo ' * ';
1472
+		if ($command_line) {
1473
+					echo ' * ';
1474
+		}
1387 1475
 		$upcontext['removed_maintenance'] = true;
1388 1476
 		$changes['maintenance'] = $upcontext['user']['main'];
1389 1477
 	}
1390 1478
 	// Otherwise if somehow we are in 2 let's go to 1.
1391
-	elseif (!empty($maintenance) && $maintenance == 2)
1392
-		$changes['maintenance'] = 1;
1479
+	elseif (!empty($maintenance) && $maintenance == 2) {
1480
+			$changes['maintenance'] = 1;
1481
+	}
1393 1482
 
1394 1483
 	// Wipe this out...
1395 1484
 	$upcontext['user'] = array();
@@ -1404,9 +1493,9 @@  discard block
 block discarded – undo
1404 1493
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1405 1494
 
1406 1495
 	// Now is the perfect time to fetch the SM files.
1407
-	if ($command_line)
1408
-		cli_scheduled_fetchSMfiles();
1409
-	else
1496
+	if ($command_line) {
1497
+			cli_scheduled_fetchSMfiles();
1498
+	} else
1410 1499
 	{
1411 1500
 		require_once($sourcedir . '/ScheduledTasks.php');
1412 1501
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1414,8 +1503,9 @@  discard block
 block discarded – undo
1414 1503
 	}
1415 1504
 
1416 1505
 	// Log what we've done.
1417
-	if (empty($user_info['id']))
1418
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1506
+	if (empty($user_info['id'])) {
1507
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1508
+	}
1419 1509
 
1420 1510
 	// Log the action manually, so CLI still works.
1421 1511
 	$smcFunc['db_insert']('',
@@ -1434,8 +1524,9 @@  discard block
 block discarded – undo
1434 1524
 
1435 1525
 	// Save the current database version.
1436 1526
 	$server_version = $smcFunc['db_server_info']();
1437
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1438
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1527
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1528
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1529
+	}
1439 1530
 
1440 1531
 	if ($command_line)
1441 1532
 	{
@@ -1447,8 +1538,9 @@  discard block
 block discarded – undo
1447 1538
 
1448 1539
 	// Make sure it says we're done.
1449 1540
 	$upcontext['overall_percent'] = 100;
1450
-	if (isset($upcontext['step_progress']))
1451
-		unset($upcontext['step_progress']);
1541
+	if (isset($upcontext['step_progress'])) {
1542
+			unset($upcontext['step_progress']);
1543
+	}
1452 1544
 
1453 1545
 	$_GET['substep'] = 0;
1454 1546
 	return false;
@@ -1459,8 +1551,9 @@  discard block
 block discarded – undo
1459 1551
 {
1460 1552
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1461 1553
 
1462
-	if (empty($modSettings['time_format']))
1463
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1554
+	if (empty($modSettings['time_format'])) {
1555
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1556
+	}
1464 1557
 
1465 1558
 	// What files do we want to get
1466 1559
 	$request = $smcFunc['db_query']('', '
@@ -1494,8 +1587,9 @@  discard block
 block discarded – undo
1494 1587
 		$file_data = fetch_web_data($url);
1495 1588
 
1496 1589
 		// If we got an error - give up - the site might be down.
1497
-		if ($file_data === false)
1498
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1590
+		if ($file_data === false) {
1591
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1592
+		}
1499 1593
 
1500 1594
 		// Save the file to the database.
1501 1595
 		$smcFunc['db_query']('substring', '
@@ -1537,8 +1631,9 @@  discard block
 block discarded – undo
1537 1631
 	$themeData = array();
1538 1632
 	foreach ($values as $variable => $value)
1539 1633
 	{
1540
-		if (!isset($value) || $value === null)
1541
-			$value = 0;
1634
+		if (!isset($value) || $value === null) {
1635
+					$value = 0;
1636
+		}
1542 1637
 
1543 1638
 		$themeData[] = array(0, 1, $variable, $value);
1544 1639
 	}
@@ -1567,8 +1662,9 @@  discard block
 block discarded – undo
1567 1662
 
1568 1663
 	foreach ($values as $variable => $value)
1569 1664
 	{
1570
-		if (empty($modSettings[$value[0]]))
1571
-			continue;
1665
+		if (empty($modSettings[$value[0]])) {
1666
+					continue;
1667
+		}
1572 1668
 
1573 1669
 		$smcFunc['db_query']('', '
1574 1670
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1654,19 +1750,21 @@  discard block
 block discarded – undo
1654 1750
 	set_error_handler(
1655 1751
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1656 1752
 		{
1657
-			if ($support_js)
1658
-				return true;
1659
-			else
1660
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1753
+			if ($support_js) {
1754
+							return true;
1755
+			} else {
1756
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1757
+			}
1661 1758
 		}
1662 1759
 	);
1663 1760
 
1664 1761
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1665 1762
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1666
-	if ($db_type == 'mysql')
1667
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1668
-	else
1669
-		$db_collation = '';
1763
+	if ($db_type == 'mysql') {
1764
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1765
+	} else {
1766
+			$db_collation = '';
1767
+	}
1670 1768
 
1671 1769
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1672 1770
 
@@ -1678,8 +1776,9 @@  discard block
 block discarded – undo
1678 1776
 	$last_step = '';
1679 1777
 
1680 1778
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1681
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1682
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1779
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1780
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1781
+	}
1683 1782
 
1684 1783
 	// Count the total number of steps within this file - for progress.
1685 1784
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1699,15 +1798,18 @@  discard block
 block discarded – undo
1699 1798
 		$do_current = $substep >= $_GET['substep'];
1700 1799
 
1701 1800
 		// Get rid of any comments in the beginning of the line...
1702
-		if (substr(trim($line), 0, 2) === '/*')
1703
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1801
+		if (substr(trim($line), 0, 2) === '/*') {
1802
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1803
+		}
1704 1804
 
1705 1805
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1706
-		if ($is_debug && !$support_js && $command_line)
1707
-			flush();
1806
+		if ($is_debug && !$support_js && $command_line) {
1807
+					flush();
1808
+		}
1708 1809
 
1709
-		if (trim($line) === '')
1710
-			continue;
1810
+		if (trim($line) === '') {
1811
+					continue;
1812
+		}
1711 1813
 
1712 1814
 		if (trim(substr($line, 0, 3)) === '---')
1713 1815
 		{
@@ -1717,8 +1819,9 @@  discard block
 block discarded – undo
1717 1819
 			if (trim($current_data) != '' && $type !== '}')
1718 1820
 			{
1719 1821
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1720
-				if ($command_line)
1721
-					echo $upcontext['error_message'];
1822
+				if ($command_line) {
1823
+									echo $upcontext['error_message'];
1824
+				}
1722 1825
 			}
1723 1826
 
1724 1827
 			if ($type == ' ')
@@ -1736,17 +1839,18 @@  discard block
 block discarded – undo
1736 1839
 				if ($do_current)
1737 1840
 				{
1738 1841
 					$upcontext['actioned_items'][] = $last_step;
1739
-					if ($command_line)
1740
-						echo ' * ';
1842
+					if ($command_line) {
1843
+											echo ' * ';
1844
+					}
1741 1845
 				}
1742
-			}
1743
-			elseif ($type == '#')
1846
+			} elseif ($type == '#')
1744 1847
 			{
1745 1848
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1746 1849
 
1747 1850
 				$upcontext['current_debug_item_num']++;
1748
-				if (trim($line) != '---#')
1749
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1851
+				if (trim($line) != '---#') {
1852
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1853
+				}
1750 1854
 
1751 1855
 				// Have we already done something?
1752 1856
 				if (isset($_GET['xml']) && $done_something)
@@ -1757,34 +1861,36 @@  discard block
 block discarded – undo
1757 1861
 
1758 1862
 				if ($do_current)
1759 1863
 				{
1760
-					if (trim($line) == '---#' && $command_line)
1761
-						echo ' done.', $endl;
1762
-					elseif ($command_line)
1763
-						echo ' +++ ', rtrim(substr($line, 4));
1764
-					elseif (trim($line) != '---#')
1864
+					if (trim($line) == '---#' && $command_line) {
1865
+											echo ' done.', $endl;
1866
+					} elseif ($command_line) {
1867
+											echo ' +++ ', rtrim(substr($line, 4));
1868
+					} elseif (trim($line) != '---#')
1765 1869
 					{
1766
-						if ($is_debug)
1767
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1870
+						if ($is_debug) {
1871
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1872
+						}
1768 1873
 					}
1769 1874
 				}
1770 1875
 
1771 1876
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1772 1877
 				{
1773
-					if ($command_line)
1774
-						echo ' * ';
1775
-					else
1776
-						$upcontext['actioned_items'][] = $last_step;
1878
+					if ($command_line) {
1879
+											echo ' * ';
1880
+					} else {
1881
+											$upcontext['actioned_items'][] = $last_step;
1882
+					}
1777 1883
 				}
1778 1884
 
1779 1885
 				// Small step - only if we're actually doing stuff.
1780
-				if ($do_current)
1781
-					nextSubstep(++$substep);
1782
-				else
1783
-					$substep++;
1784
-			}
1785
-			elseif ($type == '{')
1786
-				$current_type = 'code';
1787
-			elseif ($type == '}')
1886
+				if ($do_current) {
1887
+									nextSubstep(++$substep);
1888
+				} else {
1889
+									$substep++;
1890
+				}
1891
+			} elseif ($type == '{') {
1892
+							$current_type = 'code';
1893
+			} elseif ($type == '}')
1788 1894
 			{
1789 1895
 				$current_type = 'sql';
1790 1896
 
@@ -1797,8 +1903,9 @@  discard block
 block discarded – undo
1797 1903
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1798 1904
 				{
1799 1905
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1800
-					if ($command_line)
1801
-						echo $upcontext['error_message'];
1906
+					if ($command_line) {
1907
+											echo $upcontext['error_message'];
1908
+					}
1802 1909
 				}
1803 1910
 
1804 1911
 				// Done with code!
@@ -1878,8 +1985,9 @@  discard block
 block discarded – undo
1878 1985
 	$db_unbuffered = false;
1879 1986
 
1880 1987
 	// Failure?!
1881
-	if ($result !== false)
1882
-		return $result;
1988
+	if ($result !== false) {
1989
+			return $result;
1990
+	}
1883 1991
 
1884 1992
 	$db_error_message = $smcFunc['db_error']($db_connection);
1885 1993
 	// If MySQL we do something more clever.
@@ -1907,54 +2015,61 @@  discard block
 block discarded – undo
1907 2015
 			{
1908 2016
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
1909 2017
 				$result = mysqli_query($db_connection, $string);
1910
-				if ($result !== false)
1911
-					return $result;
2018
+				if ($result !== false) {
2019
+									return $result;
2020
+				}
1912 2021
 			}
1913
-		}
1914
-		elseif ($mysqli_errno == 2013)
2022
+		} elseif ($mysqli_errno == 2013)
1915 2023
 		{
1916 2024
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
1917 2025
 			mysqli_select_db($db_connection, $db_name);
1918 2026
 			if ($db_connection)
1919 2027
 			{
1920 2028
 				$result = mysqli_query($db_connection, $string);
1921
-				if ($result !== false)
1922
-					return $result;
2029
+				if ($result !== false) {
2030
+									return $result;
2031
+				}
1923 2032
 			}
1924 2033
 		}
1925 2034
 		// Duplicate column name... should be okay ;).
1926
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
1927
-			return false;
2035
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2036
+					return false;
2037
+		}
1928 2038
 		// Duplicate insert... make sure it's the proper type of query ;).
1929
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
1930
-			return false;
2039
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2040
+					return false;
2041
+		}
1931 2042
 		// Creating an index on a non-existent column.
1932
-		elseif ($mysqli_errno == 1072)
1933
-			return false;
1934
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
1935
-			return false;
2043
+		elseif ($mysqli_errno == 1072) {
2044
+					return false;
2045
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2046
+					return false;
2047
+		}
1936 2048
 	}
1937 2049
 	// If a table already exists don't go potty.
1938 2050
 	else
1939 2051
 	{
1940 2052
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
1941 2053
 		{
1942
-			if (strpos($db_error_message, 'exist') !== false)
1943
-				return true;
1944
-		}
1945
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2054
+			if (strpos($db_error_message, 'exist') !== false) {
2055
+							return true;
2056
+			}
2057
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
1946 2058
 		{
1947
-			if (strpos($db_error_message, 'duplicate') !== false)
1948
-				return true;
2059
+			if (strpos($db_error_message, 'duplicate') !== false) {
2060
+							return true;
2061
+			}
1949 2062
 		}
1950 2063
 	}
1951 2064
 
1952 2065
 	// Get the query string so we pass everything.
1953 2066
 	$query_string = '';
1954
-	foreach ($_GET as $k => $v)
1955
-		$query_string .= ';' . $k . '=' . $v;
1956
-	if (strlen($query_string) != 0)
1957
-		$query_string = '?' . substr($query_string, 1);
2067
+	foreach ($_GET as $k => $v) {
2068
+			$query_string .= ';' . $k . '=' . $v;
2069
+	}
2070
+	if (strlen($query_string) != 0) {
2071
+			$query_string = '?' . substr($query_string, 1);
2072
+	}
1958 2073
 
1959 2074
 	if ($command_line)
1960 2075
 	{
@@ -2009,16 +2124,18 @@  discard block
 block discarded – undo
2009 2124
 			{
2010 2125
 				$found |= 1;
2011 2126
 				// Do some checks on the data if we have it set.
2012
-				if (isset($change['col_type']))
2013
-					$found &= $change['col_type'] === $column['type'];
2014
-				if (isset($change['null_allowed']))
2015
-					$found &= $column['null'] == $change['null_allowed'];
2016
-				if (isset($change['default']))
2017
-					$found &= $change['default'] === $column['default'];
2127
+				if (isset($change['col_type'])) {
2128
+									$found &= $change['col_type'] === $column['type'];
2129
+				}
2130
+				if (isset($change['null_allowed'])) {
2131
+									$found &= $column['null'] == $change['null_allowed'];
2132
+				}
2133
+				if (isset($change['default'])) {
2134
+									$found &= $change['default'] === $column['default'];
2135
+				}
2018 2136
 			}
2019 2137
 		}
2020
-	}
2021
-	elseif ($change['type'] === 'index')
2138
+	} elseif ($change['type'] === 'index')
2022 2139
 	{
2023 2140
 		$request = upgrade_query('
2024 2141
 			SHOW INDEX
@@ -2027,9 +2144,10 @@  discard block
 block discarded – undo
2027 2144
 		{
2028 2145
 			$cur_index = array();
2029 2146
 
2030
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2031
-				if ($row['Key_name'] === $change['name'])
2147
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2148
+							if ($row['Key_name'] === $change['name'])
2032 2149
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2150
+			}
2033 2151
 
2034 2152
 			ksort($cur_index, SORT_NUMERIC);
2035 2153
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2039,14 +2157,17 @@  discard block
 block discarded – undo
2039 2157
 	}
2040 2158
 
2041 2159
 	// If we're trying to add and it's added, we're done.
2042
-	if ($found && in_array($change['method'], array('add', 'change')))
2043
-		return true;
2160
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2161
+			return true;
2162
+	}
2044 2163
 	// Otherwise if we're removing and it wasn't found we're also done.
2045
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2046
-		return true;
2164
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2165
+			return true;
2166
+	}
2047 2167
 	// Otherwise is it just a test?
2048
-	elseif ($is_test)
2049
-		return false;
2168
+	elseif ($is_test) {
2169
+			return false;
2170
+	}
2050 2171
 
2051 2172
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2052 2173
 	$running = false;
@@ -2057,8 +2178,9 @@  discard block
 block discarded – undo
2057 2178
 			SHOW FULL PROCESSLIST');
2058 2179
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2059 2180
 		{
2060
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2061
-				$found = true;
2181
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2182
+							$found = true;
2183
+			}
2062 2184
 		}
2063 2185
 
2064 2186
 		// Can't find it? Then we need to run it fools!
@@ -2070,8 +2192,9 @@  discard block
 block discarded – undo
2070 2192
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2071 2193
 				' . $change['text'], true) !== false;
2072 2194
 
2073
-			if (!$success)
2074
-				return false;
2195
+			if (!$success) {
2196
+							return false;
2197
+			}
2075 2198
 
2076 2199
 			// Return
2077 2200
 			$running = true;
@@ -2113,8 +2236,9 @@  discard block
 block discarded – undo
2113 2236
 			'db_error_skip' => true,
2114 2237
 		)
2115 2238
 	);
2116
-	if ($smcFunc['db_num_rows']($request) === 0)
2117
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2239
+	if ($smcFunc['db_num_rows']($request) === 0) {
2240
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2241
+	}
2118 2242
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2119 2243
 	$smcFunc['db_free_result']($request);
2120 2244
 
@@ -2136,18 +2260,19 @@  discard block
 block discarded – undo
2136 2260
 			)
2137 2261
 		);
2138 2262
 		// No results? Just forget it all together.
2139
-		if ($smcFunc['db_num_rows']($request) === 0)
2140
-			unset($table_row['Collation']);
2141
-		else
2142
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2263
+		if ($smcFunc['db_num_rows']($request) === 0) {
2264
+					unset($table_row['Collation']);
2265
+		} else {
2266
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2267
+		}
2143 2268
 		$smcFunc['db_free_result']($request);
2144 2269
 	}
2145 2270
 
2146 2271
 	if ($column_fix)
2147 2272
 	{
2148 2273
 		// Make sure there are no NULL's left.
2149
-		if ($null_fix)
2150
-			$smcFunc['db_query']('', '
2274
+		if ($null_fix) {
2275
+					$smcFunc['db_query']('', '
2151 2276
 				UPDATE {db_prefix}' . $change['table'] . '
2152 2277
 				SET ' . $change['column'] . ' = {string:default}
2153 2278
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2156,6 +2281,7 @@  discard block
 block discarded – undo
2156 2281
 					'db_error_skip' => true,
2157 2282
 				)
2158 2283
 			);
2284
+		}
2159 2285
 
2160 2286
 		// Do the actual alteration.
2161 2287
 		$smcFunc['db_query']('', '
@@ -2184,8 +2310,9 @@  discard block
 block discarded – undo
2184 2310
 	}
2185 2311
 
2186 2312
 	// Not a column we need to check on?
2187
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2188
-		return;
2313
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2314
+			return;
2315
+	}
2189 2316
 
2190 2317
 	// Break it up you (six|seven).
2191 2318
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2204,13 +2331,13 @@  discard block
 block discarded – undo
2204 2331
 				'new_name' => $temp[2],
2205 2332
 		));
2206 2333
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2207
-		if ($smcFunc['db_num_rows'] != 1)
2208
-			return;
2334
+		if ($smcFunc['db_num_rows'] != 1) {
2335
+					return;
2336
+		}
2209 2337
 
2210 2338
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2211 2339
 		$smcFunc['db_free_result']($request);
2212
-	}
2213
-	else
2340
+	} else
2214 2341
 	{
2215 2342
 		// Do this the old fashion, sure method way.
2216 2343
 		$request = $smcFunc['db_query']('', '
@@ -2221,21 +2348,24 @@  discard block
 block discarded – undo
2221 2348
 		));
2222 2349
 		// Mayday!
2223 2350
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2224
-		if ($smcFunc['db_num_rows'] == 0)
2225
-			return;
2351
+		if ($smcFunc['db_num_rows'] == 0) {
2352
+					return;
2353
+		}
2226 2354
 
2227 2355
 		// Oh where, oh where has my little field gone. Oh where can it be...
2228
-		while ($row = $smcFunc['db_query']($request))
2229
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2356
+		while ($row = $smcFunc['db_query']($request)) {
2357
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2230 2358
 			{
2231 2359
 				$current_type = $row['Type'];
2360
+		}
2232 2361
 				break;
2233 2362
 			}
2234 2363
 	}
2235 2364
 
2236 2365
 	// If this doesn't match, the column may of been altered for a reason.
2237
-	if (trim($current_type) != trim($temp[3]))
2238
-		$temp[3] = $current_type;
2366
+	if (trim($current_type) != trim($temp[3])) {
2367
+			$temp[3] = $current_type;
2368
+	}
2239 2369
 
2240 2370
 	// Piece this back together.
2241 2371
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2247,8 +2377,9 @@  discard block
 block discarded – undo
2247 2377
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2248 2378
 	global $step_progress, $is_debug, $upcontext;
2249 2379
 
2250
-	if ($_GET['substep'] < $substep)
2251
-		$_GET['substep'] = $substep;
2380
+	if ($_GET['substep'] < $substep) {
2381
+			$_GET['substep'] = $substep;
2382
+	}
2252 2383
 
2253 2384
 	if ($command_line)
2254 2385
 	{
@@ -2261,29 +2392,33 @@  discard block
 block discarded – undo
2261 2392
 	}
2262 2393
 
2263 2394
 	@set_time_limit(300);
2264
-	if (function_exists('apache_reset_timeout'))
2265
-		@apache_reset_timeout();
2395
+	if (function_exists('apache_reset_timeout')) {
2396
+			@apache_reset_timeout();
2397
+	}
2266 2398
 
2267
-	if (time() - $start_time <= $timeLimitThreshold)
2268
-		return;
2399
+	if (time() - $start_time <= $timeLimitThreshold) {
2400
+			return;
2401
+	}
2269 2402
 
2270 2403
 	// Do we have some custom step progress stuff?
2271 2404
 	if (!empty($step_progress))
2272 2405
 	{
2273 2406
 		$upcontext['substep_progress'] = 0;
2274 2407
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2275
-		if ($step_progress['current'] > $step_progress['total'])
2276
-			$upcontext['substep_progress'] = 99.9;
2277
-		else
2278
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2408
+		if ($step_progress['current'] > $step_progress['total']) {
2409
+					$upcontext['substep_progress'] = 99.9;
2410
+		} else {
2411
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2412
+		}
2279 2413
 
2280 2414
 		// Make it nicely rounded.
2281 2415
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2282 2416
 	}
2283 2417
 
2284 2418
 	// If this is XML we just exit right away!
2285
-	if (isset($_GET['xml']))
2286
-		return upgradeExit();
2419
+	if (isset($_GET['xml'])) {
2420
+			return upgradeExit();
2421
+	}
2287 2422
 
2288 2423
 	// We're going to pause after this!
2289 2424
 	$upcontext['pause'] = true;
@@ -2291,13 +2426,15 @@  discard block
 block discarded – undo
2291 2426
 	$upcontext['query_string'] = '';
2292 2427
 	foreach ($_GET as $k => $v)
2293 2428
 	{
2294
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2295
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2429
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2430
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2431
+		}
2296 2432
 	}
2297 2433
 
2298 2434
 	// Custom warning?
2299
-	if (!empty($custom_warning))
2300
-		$upcontext['custom_warning'] = $custom_warning;
2435
+	if (!empty($custom_warning)) {
2436
+			$upcontext['custom_warning'] = $custom_warning;
2437
+	}
2301 2438
 
2302 2439
 	upgradeExit();
2303 2440
 }
@@ -2312,25 +2449,26 @@  discard block
 block discarded – undo
2312 2449
 	ob_implicit_flush(true);
2313 2450
 	@set_time_limit(600);
2314 2451
 
2315
-	if (!isset($_SERVER['argv']))
2316
-		$_SERVER['argv'] = array();
2452
+	if (!isset($_SERVER['argv'])) {
2453
+			$_SERVER['argv'] = array();
2454
+	}
2317 2455
 	$_GET['maint'] = 1;
2318 2456
 
2319 2457
 	foreach ($_SERVER['argv'] as $i => $arg)
2320 2458
 	{
2321
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2322
-			$_GET['lang'] = $match[1];
2323
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2324
-			continue;
2325
-		elseif ($arg == '--no-maintenance')
2326
-			$_GET['maint'] = 0;
2327
-		elseif ($arg == '--debug')
2328
-			$is_debug = true;
2329
-		elseif ($arg == '--backup')
2330
-			$_POST['backup'] = 1;
2331
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2332
-			$_GET['conv'] = 1;
2333
-		elseif ($i != 0)
2459
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2460
+					$_GET['lang'] = $match[1];
2461
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2462
+					continue;
2463
+		} elseif ($arg == '--no-maintenance') {
2464
+					$_GET['maint'] = 0;
2465
+		} elseif ($arg == '--debug') {
2466
+					$is_debug = true;
2467
+		} elseif ($arg == '--backup') {
2468
+					$_POST['backup'] = 1;
2469
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2470
+					$_GET['conv'] = 1;
2471
+		} elseif ($i != 0)
2334 2472
 		{
2335 2473
 			echo 'SMF Command-line Upgrader
2336 2474
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2344,10 +2482,12 @@  discard block
 block discarded – undo
2344 2482
 		}
2345 2483
 	}
2346 2484
 
2347
-	if (!php_version_check())
2348
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2349
-	if (!db_version_check())
2350
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2485
+	if (!php_version_check()) {
2486
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2487
+	}
2488
+	if (!db_version_check()) {
2489
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2490
+	}
2351 2491
 
2352 2492
 	// Do some checks to make sure they have proper privileges
2353 2493
 	db_extend('packages');
@@ -2362,39 +2502,45 @@  discard block
 block discarded – undo
2362 2502
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2363 2503
 
2364 2504
 	// Sorry... we need CREATE, ALTER and DROP
2365
-	if (!$create || !$alter || !$drop)
2366
-		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);
2505
+	if (!$create || !$alter || !$drop) {
2506
+			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);
2507
+	}
2367 2508
 
2368 2509
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2369 2510
 		&& @file_exists($sourcedir . '/QueryString.php')
2370 2511
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2371
-	if (!$check && !isset($modSettings['smfVersion']))
2372
-		print_error('Error: Some files are missing or out-of-date.', true);
2512
+	if (!$check && !isset($modSettings['smfVersion'])) {
2513
+			print_error('Error: Some files are missing or out-of-date.', true);
2514
+	}
2373 2515
 
2374 2516
 	// Do a quick version spot check.
2375 2517
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2376 2518
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2377
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2378
-		print_error('Error: Some files have not yet been updated properly.');
2519
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2520
+			print_error('Error: Some files have not yet been updated properly.');
2521
+	}
2379 2522
 
2380 2523
 	// Make sure Settings.php is writable.
2381 2524
 	quickFileWritable($boarddir . '/Settings.php');
2382
-	if (!is_writable($boarddir . '/Settings.php'))
2383
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2525
+	if (!is_writable($boarddir . '/Settings.php')) {
2526
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2527
+	}
2384 2528
 
2385 2529
 	// Make sure Settings_bak.php is writable.
2386 2530
 	quickFileWritable($boarddir . '/Settings_bak.php');
2387
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2388
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2531
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2532
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2533
+	}
2389 2534
 
2390 2535
 	// Make sure db_last_error.php is writable.
2391 2536
 	quickFileWritable($boarddir . '/db_last_error.php');
2392
-	if (!is_writable($boarddir . '/db_last_error.php'))
2393
-		print_error('Error: Unable to obtain write access to "db_last_error.php".');
2537
+	if (!is_writable($boarddir . '/db_last_error.php')) {
2538
+			print_error('Error: Unable to obtain write access to "db_last_error.php".');
2539
+	}
2394 2540
 
2395
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2396
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2397
-	elseif (isset($modSettings['agreement']))
2541
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2542
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2543
+	} elseif (isset($modSettings['agreement']))
2398 2544
 	{
2399 2545
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2400 2546
 		fwrite($fp, $modSettings['agreement']);
@@ -2404,31 +2550,36 @@  discard block
 block discarded – undo
2404 2550
 	// Make sure Themes is writable.
2405 2551
 	quickFileWritable($modSettings['theme_dir']);
2406 2552
 
2407
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2408
-		print_error('Error: Unable to obtain write access to "Themes".');
2553
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2554
+			print_error('Error: Unable to obtain write access to "Themes".');
2555
+	}
2409 2556
 
2410 2557
 	// Make sure cache directory exists and is writable!
2411 2558
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2412
-	if (!file_exists($cachedir_temp))
2413
-		@mkdir($cachedir_temp);
2559
+	if (!file_exists($cachedir_temp)) {
2560
+			@mkdir($cachedir_temp);
2561
+	}
2414 2562
 
2415 2563
 	// Make sure the cache temp dir is writable.
2416 2564
 	quickFileWritable($cachedir_temp);
2417 2565
 
2418
-	if (!is_writable($cachedir_temp))
2419
-		print_error('Error: Unable to obtain write access to "cache".', true);
2566
+	if (!is_writable($cachedir_temp)) {
2567
+			print_error('Error: Unable to obtain write access to "cache".', true);
2568
+	}
2420 2569
 
2421
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2422
-		print_error('Error: Unable to find language files!', true);
2423
-	else
2570
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2571
+			print_error('Error: Unable to find language files!', true);
2572
+	} else
2424 2573
 	{
2425 2574
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2426 2575
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2427 2576
 
2428
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2429
-			print_error('Error: Language files out of date.', true);
2430
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2431
-			print_error('Error: Install language is missing for selected language.', true);
2577
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2578
+					print_error('Error: Language files out of date.', true);
2579
+		}
2580
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2581
+					print_error('Error: Install language is missing for selected language.', true);
2582
+		}
2432 2583
 
2433 2584
 		// Otherwise include it!
2434 2585
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2447,8 +2598,9 @@  discard block
 block discarded – undo
2447 2598
 	global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js;
2448 2599
 
2449 2600
 	// Done it already?
2450
-	if (!empty($_POST['utf8_done']))
2451
-		return true;
2601
+	if (!empty($_POST['utf8_done'])) {
2602
+			return true;
2603
+	}
2452 2604
 
2453 2605
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2454 2606
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2461,8 +2613,7 @@  discard block
 block discarded – undo
2461 2613
 		);
2462 2614
 
2463 2615
 		return true;
2464
-	}
2465
-	else
2616
+	} else
2466 2617
 	{
2467 2618
 		$upcontext['page_title'] = 'Converting to UTF8';
2468 2619
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2506,8 +2657,9 @@  discard block
 block discarded – undo
2506 2657
 			)
2507 2658
 		);
2508 2659
 		$db_charsets = array();
2509
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2510
-			$db_charsets[] = $row['Charset'];
2660
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2661
+					$db_charsets[] = $row['Charset'];
2662
+		}
2511 2663
 
2512 2664
 		$smcFunc['db_free_result']($request);
2513 2665
 
@@ -2543,13 +2695,15 @@  discard block
 block discarded – undo
2543 2695
 		// If there's a fulltext index, we need to drop it first...
2544 2696
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2545 2697
 		{
2546
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2547
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2698
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2699
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2548 2700
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2701
+			}
2549 2702
 			$smcFunc['db_free_result']($request);
2550 2703
 
2551
-			if (isset($upcontext['fulltext_index']))
2552
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2704
+			if (isset($upcontext['fulltext_index'])) {
2705
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2706
+			}
2553 2707
 		}
2554 2708
 
2555 2709
 		// Drop it and make a note...
@@ -2739,8 +2893,9 @@  discard block
 block discarded – undo
2739 2893
 			$replace = '%field%';
2740 2894
 
2741 2895
 			// Build a huge REPLACE statement...
2742
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2743
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2896
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2897
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2898
+			}
2744 2899
 		}
2745 2900
 
2746 2901
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2750,9 +2905,10 @@  discard block
 block discarded – undo
2750 2905
 		$upcontext['table_count'] = count($queryTables);
2751 2906
 
2752 2907
 		// What ones have we already done?
2753
-		foreach ($queryTables as $id => $table)
2754
-			if ($id < $_GET['substep'])
2908
+		foreach ($queryTables as $id => $table) {
2909
+					if ($id < $_GET['substep'])
2755 2910
 				$upcontext['previous_tables'][] = $table;
2911
+		}
2756 2912
 
2757 2913
 		$upcontext['cur_table_num'] = $_GET['substep'];
2758 2914
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2789,8 +2945,9 @@  discard block
 block discarded – undo
2789 2945
 			nextSubstep($substep);
2790 2946
 
2791 2947
 			// Just to make sure it doesn't time out.
2792
-			if (function_exists('apache_reset_timeout'))
2793
-				@apache_reset_timeout();
2948
+			if (function_exists('apache_reset_timeout')) {
2949
+							@apache_reset_timeout();
2950
+			}
2794 2951
 
2795 2952
 			$table_charsets = array();
2796 2953
 
@@ -2813,8 +2970,9 @@  discard block
 block discarded – undo
2813 2970
 
2814 2971
 						// Build structure of columns to operate on organized by charset; only operate on columns not yet utf8
2815 2972
 						if ($charset != 'utf8') {
2816
-							if (!isset($table_charsets[$charset]))
2817
-								$table_charsets[$charset] = array();
2973
+							if (!isset($table_charsets[$charset])) {
2974
+															$table_charsets[$charset] = array();
2975
+							}
2818 2976
 
2819 2977
 							$table_charsets[$charset][] = $column_info;
2820 2978
 						}
@@ -2855,10 +3013,11 @@  discard block
 block discarded – undo
2855 3013
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2856 3014
 				{
2857 3015
 					$update = '';
2858
-					foreach ($table_charsets as $charset => $columns)
2859
-						foreach ($columns as $column)
3016
+					foreach ($table_charsets as $charset => $columns) {
3017
+											foreach ($columns as $column)
2860 3018
 							$update .= '
2861 3019
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3020
+					}
2862 3021
 
2863 3022
 					$smcFunc['db_query']('', '
2864 3023
 						UPDATE {raw:table_name}
@@ -2883,8 +3042,9 @@  discard block
 block discarded – undo
2883 3042
 			// Now do the actual conversion (if still needed).
2884 3043
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2885 3044
 			{
2886
-				if ($command_line)
2887
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3045
+				if ($command_line) {
3046
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3047
+				}
2888 3048
 
2889 3049
 				$smcFunc['db_query']('', '
2890 3050
 					ALTER TABLE {raw:table_name}
@@ -2894,12 +3054,14 @@  discard block
 block discarded – undo
2894 3054
 					)
2895 3055
 				);
2896 3056
 
2897
-				if ($command_line)
2898
-					echo " done.\n";
3057
+				if ($command_line) {
3058
+									echo " done.\n";
3059
+				}
2899 3060
 			}
2900 3061
 			// If this is XML to keep it nice for the user do one table at a time anyway!
2901
-			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count'])
2902
-				return upgradeExit();
3062
+			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) {
3063
+							return upgradeExit();
3064
+			}
2903 3065
 		}
2904 3066
 
2905 3067
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -2928,8 +3090,8 @@  discard block
 block discarded – undo
2928 3090
 		);
2929 3091
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2930 3092
 		{
2931
-			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)
2932
-				$smcFunc['db_query']('', '
3093
+			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) {
3094
+							$smcFunc['db_query']('', '
2933 3095
 					UPDATE {db_prefix}log_actions
2934 3096
 					SET extra = {string:extra}
2935 3097
 					WHERE id_action = {int:current_action}',
@@ -2938,6 +3100,7 @@  discard block
 block discarded – undo
2938 3100
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
2939 3101
 					)
2940 3102
 				);
3103
+			}
2941 3104
 		}
2942 3105
 		$smcFunc['db_free_result']($request);
2943 3106
 
@@ -2959,15 +3122,17 @@  discard block
 block discarded – undo
2959 3122
 	// First thing's first - did we already do this?
2960 3123
 	if (!empty($modSettings['json_done']))
2961 3124
 	{
2962
-		if ($command_line)
2963
-			return DeleteUpgrade();
2964
-		else
2965
-			return true;
3125
+		if ($command_line) {
3126
+					return DeleteUpgrade();
3127
+		} else {
3128
+					return true;
3129
+		}
2966 3130
 	}
2967 3131
 
2968 3132
 	// Done it already - js wise?
2969
-	if (!empty($_POST['json_done']))
2970
-		return true;
3133
+	if (!empty($_POST['json_done'])) {
3134
+			return true;
3135
+	}
2971 3136
 
2972 3137
 	// List of tables affected by this function
2973 3138
 	// name => array('key', col1[,col2|true[,col3]])
@@ -2999,12 +3164,14 @@  discard block
 block discarded – undo
2999 3164
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
3000 3165
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3001 3166
 
3002
-	foreach ($keys as $id => $table)
3003
-		if ($id < $_GET['substep'])
3167
+	foreach ($keys as $id => $table) {
3168
+			if ($id < $_GET['substep'])
3004 3169
 			$upcontext['previous_tables'][] = $table;
3170
+	}
3005 3171
 
3006
-	if ($command_line)
3007
-		echo 'Converting data from serialize() to json_encode().';
3172
+	if ($command_line) {
3173
+			echo 'Converting data from serialize() to json_encode().';
3174
+	}
3008 3175
 
3009 3176
 	if (!$support_js || isset($_GET['xml']))
3010 3177
 	{
@@ -3044,8 +3211,9 @@  discard block
 block discarded – undo
3044 3211
 
3045 3212
 				// Loop through and fix these...
3046 3213
 				$new_settings = array();
3047
-				if ($command_line)
3048
-					echo "\n" . 'Fixing some settings...';
3214
+				if ($command_line) {
3215
+									echo "\n" . 'Fixing some settings...';
3216
+				}
3049 3217
 
3050 3218
 				foreach ($serialized_settings as $var)
3051 3219
 				{
@@ -3053,22 +3221,24 @@  discard block
 block discarded – undo
3053 3221
 					{
3054 3222
 						// Attempt to unserialize the setting
3055 3223
 						$temp = @safe_unserialize($modSettings[$var]);
3056
-						if (!$temp && $command_line)
3057
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3058
-						elseif ($temp !== false)
3059
-							$new_settings[$var] = json_encode($temp);
3224
+						if (!$temp && $command_line) {
3225
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3226
+						} elseif ($temp !== false) {
3227
+													$new_settings[$var] = json_encode($temp);
3228
+						}
3060 3229
 					}
3061 3230
 				}
3062 3231
 
3063 3232
 				// Update everything at once
3064
-				if (!function_exists('cache_put_data'))
3065
-					require_once($sourcedir . '/Load.php');
3233
+				if (!function_exists('cache_put_data')) {
3234
+									require_once($sourcedir . '/Load.php');
3235
+				}
3066 3236
 				updateSettings($new_settings, true);
3067 3237
 
3068
-				if ($command_line)
3069
-					echo ' done.';
3070
-			}
3071
-			elseif ($table == 'themes')
3238
+				if ($command_line) {
3239
+									echo ' done.';
3240
+				}
3241
+			} elseif ($table == 'themes')
3072 3242
 			{
3073 3243
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3074 3244
 				$query = $smcFunc['db_query']('', '
@@ -3087,10 +3257,11 @@  discard block
 block discarded – undo
3087 3257
 
3088 3258
 						if ($command_line)
3089 3259
 						{
3090
-							if ($temp === false)
3091
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3092
-							else
3093
-								echo "\n" . 'Fixing admin preferences...';
3260
+							if ($temp === false) {
3261
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3262
+							} else {
3263
+															echo "\n" . 'Fixing admin preferences...';
3264
+							}
3094 3265
 						}
3095 3266
 
3096 3267
 						if ($temp !== false)
@@ -3112,15 +3283,15 @@  discard block
 block discarded – undo
3112 3283
 								)
3113 3284
 							);
3114 3285
 
3115
-							if ($command_line)
3116
-								echo ' done.';
3286
+							if ($command_line) {
3287
+															echo ' done.';
3288
+							}
3117 3289
 						}
3118 3290
 					}
3119 3291
 
3120 3292
 					$smcFunc['db_free_result']($query);
3121 3293
 				}
3122
-			}
3123
-			else
3294
+			} else
3124 3295
 			{
3125 3296
 				// First item is always the key...
3126 3297
 				$key = $info[0];
@@ -3131,8 +3302,7 @@  discard block
 block discarded – undo
3131 3302
 				{
3132 3303
 					$col_select = $info[1];
3133 3304
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3134
-				}
3135
-				else
3305
+				} else
3136 3306
 				{
3137 3307
 					$col_select = implode(', ', $info);
3138 3308
 				}
@@ -3165,8 +3335,7 @@  discard block
 block discarded – undo
3165 3335
 								if ($temp === false && $command_line)
3166 3336
 								{
3167 3337
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3168
-								}
3169
-								else
3338
+								} else
3170 3339
 								{
3171 3340
 									$row[$col] = json_encode($temp);
3172 3341
 
@@ -3191,16 +3360,18 @@  discard block
 block discarded – undo
3191 3360
 						}
3192 3361
 					}
3193 3362
 
3194
-					if ($command_line)
3195
-						echo ' done.';
3363
+					if ($command_line) {
3364
+											echo ' done.';
3365
+					}
3196 3366
 
3197 3367
 					// Free up some memory...
3198 3368
 					$smcFunc['db_free_result']($query);
3199 3369
 				}
3200 3370
 			}
3201 3371
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3202
-			if (isset($_GET['xml']))
3203
-				return upgradeExit();
3372
+			if (isset($_GET['xml'])) {
3373
+							return upgradeExit();
3374
+			}
3204 3375
 		}
3205 3376
 
3206 3377
 		if ($command_line)
@@ -3215,8 +3386,9 @@  discard block
 block discarded – undo
3215 3386
 
3216 3387
 		$_GET['substep'] = 0;
3217 3388
 		// Make sure we move on!
3218
-		if ($command_line)
3219
-			return DeleteUpgrade();
3389
+		if ($command_line) {
3390
+					return DeleteUpgrade();
3391
+		}
3220 3392
 
3221 3393
 		return true;
3222 3394
 	}
@@ -3236,14 +3408,16 @@  discard block
 block discarded – undo
3236 3408
 	global $upcontext, $txt, $settings;
3237 3409
 
3238 3410
 	// Don't call me twice!
3239
-	if (!empty($upcontext['chmod_called']))
3240
-		return;
3411
+	if (!empty($upcontext['chmod_called'])) {
3412
+			return;
3413
+	}
3241 3414
 
3242 3415
 	$upcontext['chmod_called'] = true;
3243 3416
 
3244 3417
 	// Nothing?
3245
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3246
-		return;
3418
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3419
+			return;
3420
+	}
3247 3421
 
3248 3422
 	// Was it a problem with Windows?
3249 3423
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3275,11 +3449,12 @@  discard block
 block discarded – undo
3275 3449
 					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\');
3276 3450
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3277 3451
 
3278
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3279
-		echo '
3452
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3453
+			echo '
3280 3454
 					content.write(\'<hr>\n\t\t\t\');
3281 3455
 					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\');
3282 3456
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3457
+	}
3283 3458
 
3284 3459
 	echo '
3285 3460
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3287,17 +3462,19 @@  discard block
 block discarded – undo
3287 3462
 				}
3288 3463
 			</script>';
3289 3464
 
3290
-	if (!empty($upcontext['chmod']['ftp_error']))
3291
-		echo '
3465
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3466
+			echo '
3292 3467
 			<div class="error_message red">
3293 3468
 				The following error was encountered when trying to connect:<br><br>
3294 3469
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3295 3470
 			</div>
3296 3471
 			<br>';
3472
+	}
3297 3473
 
3298
-	if (empty($upcontext['chmod_in_form']))
3299
-		echo '
3474
+	if (empty($upcontext['chmod_in_form'])) {
3475
+			echo '
3300 3476
 	<form action="', $upcontext['form_url'], '" method="post">';
3477
+	}
3301 3478
 
3302 3479
 	echo '
3303 3480
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3332,10 +3509,11 @@  discard block
 block discarded – undo
3332 3509
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div>
3333 3510
 	</div>';
3334 3511
 
3335
-	if (empty($upcontext['chmod_in_form']))
3336
-		echo '
3512
+	if (empty($upcontext['chmod_in_form'])) {
3513
+			echo '
3337 3514
 	</form>';
3338
-}
3515
+	}
3516
+	}
3339 3517
 
3340 3518
 function template_upgrade_above()
3341 3519
 {
@@ -3395,9 +3573,10 @@  discard block
 block discarded – undo
3395 3573
 				<h2>', $txt['upgrade_progress'], '</h2>
3396 3574
 				<ul>';
3397 3575
 
3398
-	foreach ($upcontext['steps'] as $num => $step)
3399
-		echo '
3576
+	foreach ($upcontext['steps'] as $num => $step) {
3577
+			echo '
3400 3578
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3579
+	}
3401 3580
 
3402 3581
 	echo '
3403 3582
 					</ul>
@@ -3410,8 +3589,8 @@  discard block
 block discarded – undo
3410 3589
 				</div>
3411 3590
 			</div>';
3412 3591
 
3413
-	if (isset($upcontext['step_progress']))
3414
-		echo '
3592
+	if (isset($upcontext['step_progress'])) {
3593
+			echo '
3415 3594
 				<br>
3416 3595
 				<br>
3417 3596
 				<div id="progress_bar_step">
@@ -3420,6 +3599,7 @@  discard block
 block discarded – undo
3420 3599
 						<span>', $txt['upgrade_step_progress'], '</span>
3421 3600
 					</div>
3422 3601
 				</div>';
3602
+	}
3423 3603
 
3424 3604
 	echo '
3425 3605
 				<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>
@@ -3450,32 +3630,36 @@  discard block
 block discarded – undo
3450 3630
 {
3451 3631
 	global $upcontext, $txt;
3452 3632
 
3453
-	if (!empty($upcontext['pause']))
3454
-		echo '
3633
+	if (!empty($upcontext['pause'])) {
3634
+			echo '
3455 3635
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3456 3636
 
3457 3637
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3458 3638
 								<h3>
3459 3639
 									', $txt['upgrade_paused_overload'], '
3460 3640
 								</h3>';
3641
+	}
3461 3642
 
3462
-	if (!empty($upcontext['custom_warning']))
3463
-		echo '
3643
+	if (!empty($upcontext['custom_warning'])) {
3644
+			echo '
3464 3645
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3465 3646
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3466 3647
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3467 3648
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3468 3649
 								</div>';
3650
+	}
3469 3651
 
3470 3652
 	echo '
3471 3653
 								<div class="righttext" style="margin: 1ex;">';
3472 3654
 
3473
-	if (!empty($upcontext['continue']))
3474
-		echo '
3655
+	if (!empty($upcontext['continue'])) {
3656
+			echo '
3475 3657
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">';
3476
-	if (!empty($upcontext['skip']))
3477
-		echo '
3658
+	}
3659
+	if (!empty($upcontext['skip'])) {
3660
+			echo '
3478 3661
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">';
3662
+	}
3479 3663
 
3480 3664
 	echo '
3481 3665
 								</div>
@@ -3525,11 +3709,12 @@  discard block
 block discarded – undo
3525 3709
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3526 3710
 	<smf>';
3527 3711
 
3528
-	if (!empty($upcontext['get_data']))
3529
-		foreach ($upcontext['get_data'] as $k => $v)
3712
+	if (!empty($upcontext['get_data'])) {
3713
+			foreach ($upcontext['get_data'] as $k => $v)
3530 3714
 			echo '
3531 3715
 		<get key="', $k, '">', $v, '</get>';
3532
-}
3716
+	}
3717
+	}
3533 3718
 
3534 3719
 function template_xml_below()
3535 3720
 {
@@ -3570,8 +3755,8 @@  discard block
 block discarded – undo
3570 3755
 	template_chmod();
3571 3756
 
3572 3757
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3573
-	if ($upcontext['is_large_forum'])
3574
-		echo '
3758
+	if ($upcontext['is_large_forum']) {
3759
+			echo '
3575 3760
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3576 3761
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3577 3762
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3579,10 +3764,11 @@  discard block
 block discarded – undo
3579 3764
 				', $txt['upgrade_warning_lots_data'], '
3580 3765
 			</div>
3581 3766
 		</div>';
3767
+	}
3582 3768
 
3583 3769
 	// A warning message?
3584
-	if (!empty($upcontext['warning']))
3585
-		echo '
3770
+	if (!empty($upcontext['warning'])) {
3771
+			echo '
3586 3772
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3587 3773
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3588 3774
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3590,6 +3776,7 @@  discard block
 block discarded – undo
3590 3776
 				', $upcontext['warning'], '
3591 3777
 			</div>
3592 3778
 		</div>';
3779
+	}
3593 3780
 
3594 3781
 	// Paths are incorrect?
3595 3782
 	echo '
@@ -3605,20 +3792,22 @@  discard block
 block discarded – undo
3605 3792
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3606 3793
 	{
3607 3794
 		$ago = time() - $upcontext['started'];
3608
-		if ($ago < 60)
3609
-			$ago = $ago . ' seconds';
3610
-		elseif ($ago < 3600)
3611
-			$ago = (int) ($ago / 60) . ' minutes';
3612
-		else
3613
-			$ago = (int) ($ago / 3600) . ' hours';
3795
+		if ($ago < 60) {
3796
+					$ago = $ago . ' seconds';
3797
+		} elseif ($ago < 3600) {
3798
+					$ago = (int) ($ago / 60) . ' minutes';
3799
+		} else {
3800
+					$ago = (int) ($ago / 3600) . ' hours';
3801
+		}
3614 3802
 
3615 3803
 		$active = time() - $upcontext['updated'];
3616
-		if ($active < 60)
3617
-			$updated = $active . ' seconds';
3618
-		elseif ($active < 3600)
3619
-			$updated = (int) ($active / 60) . ' minutes';
3620
-		else
3621
-			$updated = (int) ($active / 3600) . ' hours';
3804
+		if ($active < 60) {
3805
+					$updated = $active . ' seconds';
3806
+		} elseif ($active < 3600) {
3807
+					$updated = (int) ($active / 60) . ' minutes';
3808
+		} else {
3809
+					$updated = (int) ($active / 3600) . ' hours';
3810
+		}
3622 3811
 
3623 3812
 		echo '
3624 3813
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3627,16 +3816,18 @@  discard block
 block discarded – undo
3627 3816
 			<div style="padding-left: 6ex;">
3628 3817
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3629 3818
 
3630
-		if ($active < 600)
3631
-			echo '
3819
+		if ($active < 600) {
3820
+					echo '
3632 3821
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
3822
+		}
3633 3823
 
3634
-		if ($active > $upcontext['inactive_timeout'])
3635
-			echo '
3824
+		if ($active > $upcontext['inactive_timeout']) {
3825
+					echo '
3636 3826
 				<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.';
3637
-		else
3638
-			echo '
3827
+		} else {
3828
+					echo '
3639 3829
 				<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!');
3830
+		}
3640 3831
 
3641 3832
 		echo '
3642 3833
 			</div>
@@ -3652,9 +3843,10 @@  discard block
 block discarded – undo
3652 3843
 					<td>
3653 3844
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>';
3654 3845
 
3655
-	if (!empty($upcontext['username_incorrect']))
3656
-		echo '
3846
+	if (!empty($upcontext['username_incorrect'])) {
3847
+			echo '
3657 3848
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
3849
+	}
3658 3850
 
3659 3851
 	echo '
3660 3852
 					</td>
@@ -3665,9 +3857,10 @@  discard block
 block discarded – undo
3665 3857
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '>
3666 3858
 						<input type="hidden" name="hash_passwrd" value="">';
3667 3859
 
3668
-	if (!empty($upcontext['password_failed']))
3669
-		echo '
3860
+	if (!empty($upcontext['password_failed'])) {
3861
+			echo '
3670 3862
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
3863
+	}
3671 3864
 
3672 3865
 	echo '
3673 3866
 					</td>
@@ -3738,8 +3931,8 @@  discard block
 block discarded – undo
3738 3931
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3739 3932
 
3740 3933
 	// Warning message?
3741
-	if (!empty($upcontext['upgrade_options_warning']))
3742
-		echo '
3934
+	if (!empty($upcontext['upgrade_options_warning'])) {
3935
+			echo '
3743 3936
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3744 3937
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3745 3938
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3747,6 +3940,7 @@  discard block
 block discarded – undo
3747 3940
 				', $upcontext['upgrade_options_warning'], '
3748 3941
 			</div>
3749 3942
 		</div>';
3943
+	}
3750 3944
 
3751 3945
 	echo '
3752 3946
 				<table>
@@ -3789,8 +3983,8 @@  discard block
 block discarded – undo
3789 3983
 						</td>
3790 3984
 					</tr>';
3791 3985
 
3792
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3793
-		echo '
3986
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
3987
+			echo '
3794 3988
 					<tr valign="top">
3795 3989
 						<td width="2%">
3796 3990
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1">
@@ -3799,6 +3993,7 @@  discard block
 block discarded – undo
3799 3993
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
3800 3994
 						</td>
3801 3995
 					</tr>';
3996
+	}
3802 3997
 
3803 3998
 	echo '
3804 3999
 					<tr valign="top">
@@ -3836,10 +4031,11 @@  discard block
 block discarded – undo
3836 4031
 			</div>';
3837 4032
 
3838 4033
 	// Dont any tables so far?
3839
-	if (!empty($upcontext['previous_tables']))
3840
-		foreach ($upcontext['previous_tables'] as $table)
4034
+	if (!empty($upcontext['previous_tables'])) {
4035
+			foreach ($upcontext['previous_tables'] as $table)
3841 4036
 			echo '
3842 4037
 			<br>Completed Table: &quot;', $table, '&quot;.';
4038
+	}
3843 4039
 
3844 4040
 	echo '
3845 4041
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -3876,12 +4072,13 @@  discard block
 block discarded – undo
3876 4072
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3877 4073
 
3878 4074
 		// If debug flood the screen.
3879
-		if ($is_debug)
3880
-			echo '
4075
+		if ($is_debug) {
4076
+					echo '
3881 4077
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
3882 4078
 
3883 4079
 				if (document.getElementById(\'debug_section\').scrollHeight)
3884 4080
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4081
+		}
3885 4082
 
3886 4083
 		echo '
3887 4084
 				// Get the next update...
@@ -3914,8 +4111,9 @@  discard block
 block discarded – undo
3914 4111
 {
3915 4112
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
3916 4113
 
3917
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
3918
-		$is_debug = true;
4114
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4115
+			$is_debug = true;
4116
+	}
3919 4117
 
3920 4118
 	echo '
3921 4119
 		<h3>Executing database changes</h3>
@@ -3930,8 +4128,9 @@  discard block
 block discarded – undo
3930 4128
 	{
3931 4129
 		foreach ($upcontext['actioned_items'] as $num => $item)
3932 4130
 		{
3933
-			if ($num != 0)
3934
-				echo ' Successful!';
4131
+			if ($num != 0) {
4132
+							echo ' Successful!';
4133
+			}
3935 4134
 			echo '<br>' . $item;
3936 4135
 		}
3937 4136
 		if (!empty($upcontext['changes_complete']))
@@ -3944,28 +4143,32 @@  discard block
 block discarded – undo
3944 4143
 				$seconds = intval($active % 60);
3945 4144
 
3946 4145
 				$totalTime = '';
3947
-				if ($hours > 0)
3948
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3949
-				if ($minutes > 0)
3950
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3951
-				if ($seconds > 0)
3952
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4146
+				if ($hours > 0) {
4147
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4148
+				}
4149
+				if ($minutes > 0) {
4150
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4151
+				}
4152
+				if ($seconds > 0) {
4153
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4154
+				}
3953 4155
 			}
3954 4156
 
3955
-			if ($is_debug && !empty($totalTime))
3956
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
3957
-			else
3958
-				echo ' Successful!<br><br>';
4157
+			if ($is_debug && !empty($totalTime)) {
4158
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4159
+			} else {
4160
+							echo ' Successful!<br><br>';
4161
+			}
3959 4162
 
3960 4163
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
3961 4164
 		}
3962
-	}
3963
-	else
4165
+	} else
3964 4166
 	{
3965 4167
 		// Tell them how many files we have in total.
3966
-		if ($upcontext['file_count'] > 1)
3967
-			echo '
4168
+		if ($upcontext['file_count'] > 1) {
4169
+					echo '
3968 4170
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4171
+		}
3969 4172
 
3970 4173
 		echo '
3971 4174
 		<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>
@@ -3981,19 +4184,23 @@  discard block
 block discarded – undo
3981 4184
 				$seconds = intval($active % 60);
3982 4185
 
3983 4186
 				$totalTime = '';
3984
-				if ($hours > 0)
3985
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3986
-				if ($minutes > 0)
3987
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3988
-				if ($seconds > 0)
3989
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4187
+				if ($hours > 0) {
4188
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4189
+				}
4190
+				if ($minutes > 0) {
4191
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4192
+				}
4193
+				if ($seconds > 0) {
4194
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4195
+				}
3990 4196
 			}
3991 4197
 
3992 4198
 			echo '
3993 4199
 			<br><span id="upgradeCompleted">';
3994 4200
 
3995
-			if (!empty($totalTime))
3996
-				echo 'Completed in ', $totalTime, '<br>';
4201
+			if (!empty($totalTime)) {
4202
+							echo 'Completed in ', $totalTime, '<br>';
4203
+			}
3997 4204
 
3998 4205
 			echo '</span>
3999 4206
 			<div id="debug_section" style="height: 59px; overflow: auto;">
@@ -4030,9 +4237,10 @@  discard block
 block discarded – undo
4030 4237
 			var getData = "";
4031 4238
 			var debugItems = ', $upcontext['debug_items'], ';';
4032 4239
 
4033
-		if ($is_debug)
4034
-			echo '
4240
+		if ($is_debug) {
4241
+					echo '
4035 4242
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4243
+		}
4036 4244
 
4037 4245
 		echo '
4038 4246
 			function getNextItem()
@@ -4072,9 +4280,10 @@  discard block
 block discarded – undo
4072 4280
 						document.getElementById("error_block").style.display = "";
4073 4281
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4074 4282
 
4075
-	if ($is_debug)
4076
-		echo '
4283
+	if ($is_debug) {
4284
+			echo '
4077 4285
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4286
+	}
4078 4287
 
4079 4288
 	echo '
4080 4289
 					}
@@ -4095,9 +4304,10 @@  discard block
 block discarded – undo
4095 4304
 						document.getElementById("error_block").style.display = "";
4096 4305
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4097 4306
 
4098
-	if ($is_debug)
4099
-		echo '
4307
+	if ($is_debug) {
4308
+			echo '
4100 4309
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4310
+	}
4101 4311
 
4102 4312
 	echo '
4103 4313
 					}
@@ -4156,8 +4366,8 @@  discard block
 block discarded – undo
4156 4366
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4157 4367
 				{';
4158 4368
 
4159
-		if ($is_debug)
4160
-			echo '
4369
+		if ($is_debug) {
4370
+					echo '
4161 4371
 					document.getElementById(\'debug_section\').style.display = "none";
4162 4372
 
4163 4373
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4175,6 +4385,7 @@  discard block
 block discarded – undo
4175 4385
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4176 4386
 
4177 4387
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4388
+		}
4178 4389
 
4179 4390
 		echo '
4180 4391
 
@@ -4182,9 +4393,10 @@  discard block
 block discarded – undo
4182 4393
 					document.getElementById(\'contbutt\').disabled = 0;
4183 4394
 					document.getElementById(\'database_done\').value = 1;';
4184 4395
 
4185
-		if ($upcontext['file_count'] > 1)
4186
-			echo '
4396
+		if ($upcontext['file_count'] > 1) {
4397
+					echo '
4187 4398
 					document.getElementById(\'info1\').style.display = "none";';
4399
+		}
4188 4400
 
4189 4401
 		echo '
4190 4402
 					document.getElementById(\'info2\').style.display = "none";
@@ -4197,9 +4409,10 @@  discard block
 block discarded – undo
4197 4409
 					lastItem = 0;
4198 4410
 					prevFile = curFile;';
4199 4411
 
4200
-		if ($is_debug)
4201
-			echo '
4412
+		if ($is_debug) {
4413
+					echo '
4202 4414
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4415
+		}
4203 4416
 
4204 4417
 		echo '
4205 4418
 					getNextItem();
@@ -4207,8 +4420,8 @@  discard block
 block discarded – undo
4207 4420
 				}';
4208 4421
 
4209 4422
 		// If debug scroll the screen.
4210
-		if ($is_debug)
4211
-			echo '
4423
+		if ($is_debug) {
4424
+					echo '
4212 4425
 				if (iLastSubStepProgress == -1)
4213 4426
 				{
4214 4427
 					// Give it consistent dots.
@@ -4227,6 +4440,7 @@  discard block
 block discarded – undo
4227 4440
 
4228 4441
 				if (document.getElementById(\'debug_section\').scrollHeight)
4229 4442
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4443
+		}
4230 4444
 
4231 4445
 		echo '
4232 4446
 				// Update the page.
@@ -4287,9 +4501,10 @@  discard block
 block discarded – undo
4287 4501
 			}';
4288 4502
 
4289 4503
 		// Start things off assuming we've not errored.
4290
-		if (empty($upcontext['error_message']))
4291
-			echo '
4504
+		if (empty($upcontext['error_message'])) {
4505
+					echo '
4292 4506
 			getNextItem();';
4507
+		}
4293 4508
 
4294 4509
 		echo '
4295 4510
 		//# sourceURL=dynamicScript-dbch.js
@@ -4307,18 +4522,21 @@  discard block
 block discarded – undo
4307 4522
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4308 4523
 	<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>';
4309 4524
 
4310
-	if (!empty($upcontext['error_message']))
4311
-		echo '
4525
+	if (!empty($upcontext['error_message'])) {
4526
+			echo '
4312 4527
 	<error>', $upcontext['error_message'], '</error>';
4528
+	}
4313 4529
 
4314
-	if (!empty($upcontext['error_string']))
4315
-		echo '
4530
+	if (!empty($upcontext['error_string'])) {
4531
+			echo '
4316 4532
 	<sql>', $upcontext['error_string'], '</sql>';
4533
+	}
4317 4534
 
4318
-	if ($is_debug)
4319
-		echo '
4535
+	if ($is_debug) {
4536
+			echo '
4320 4537
 	<curtime>', time(), '</curtime>';
4321
-}
4538
+	}
4539
+	}
4322 4540
 
4323 4541
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4324 4542
 function template_convert_utf8()
@@ -4337,18 +4555,20 @@  discard block
 block discarded – undo
4337 4555
 			</div>';
4338 4556
 
4339 4557
 	// Done any tables so far?
4340
-	if (!empty($upcontext['previous_tables']))
4341
-		foreach ($upcontext['previous_tables'] as $table)
4558
+	if (!empty($upcontext['previous_tables'])) {
4559
+			foreach ($upcontext['previous_tables'] as $table)
4342 4560
 			echo '
4343 4561
 			<br>Completed Table: &quot;', $table, '&quot;.';
4562
+	}
4344 4563
 
4345 4564
 	echo '
4346 4565
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4347 4566
 
4348 4567
 	// If we dropped their index, let's let them know
4349
-	if ($upcontext['dropping_index'])
4350
-		echo '
4568
+	if ($upcontext['dropping_index']) {
4569
+			echo '
4351 4570
 				<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>';
4571
+	}
4352 4572
 
4353 4573
 	// Completion notification
4354 4574
 	echo '
@@ -4385,12 +4605,13 @@  discard block
 block discarded – undo
4385 4605
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4386 4606
 
4387 4607
 		// If debug flood the screen.
4388
-		if ($is_debug)
4389
-			echo '
4608
+		if ($is_debug) {
4609
+					echo '
4390 4610
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4391 4611
 
4392 4612
 				if (document.getElementById(\'debug_section\').scrollHeight)
4393 4613
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4614
+		}
4394 4615
 
4395 4616
 		echo '
4396 4617
 				// Get the next update...
@@ -4438,19 +4659,21 @@  discard block
 block discarded – undo
4438 4659
 			</div>';
4439 4660
 
4440 4661
 	// Dont any tables so far?
4441
-	if (!empty($upcontext['previous_tables']))
4442
-		foreach ($upcontext['previous_tables'] as $table)
4662
+	if (!empty($upcontext['previous_tables'])) {
4663
+			foreach ($upcontext['previous_tables'] as $table)
4443 4664
 			echo '
4444 4665
 			<br>Completed Table: &quot;', $table, '&quot;.';
4666
+	}
4445 4667
 
4446 4668
 	echo '
4447 4669
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4448 4670
 			<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>';
4449 4671
 
4450 4672
 	// Try to make sure substep was reset.
4451
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4452
-		echo '
4673
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4674
+			echo '
4453 4675
 			<input type="hidden" name="substep" id="substep" value="0">';
4676
+	}
4454 4677
 
4455 4678
 	// Continue please!
4456 4679
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4483,12 +4706,13 @@  discard block
 block discarded – undo
4483 4706
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4484 4707
 
4485 4708
 		// If debug flood the screen.
4486
-		if ($is_debug)
4487
-			echo '
4709
+		if ($is_debug) {
4710
+					echo '
4488 4711
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4489 4712
 
4490 4713
 				if (document.getElementById(\'debug_section\').scrollHeight)
4491 4714
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4715
+		}
4492 4716
 
4493 4717
 		echo '
4494 4718
 				// Get the next update...
@@ -4524,8 +4748,8 @@  discard block
 block discarded – undo
4524 4748
 	<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>
4525 4749
 	<form action="', $boardurl, '/index.php">';
4526 4750
 
4527
-	if (!empty($upcontext['can_delete_script']))
4528
-		echo '
4751
+	if (!empty($upcontext['can_delete_script'])) {
4752
+			echo '
4529 4753
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em>
4530 4754
 			<script>
4531 4755
 				function doTheDelete(theCheck)
@@ -4537,6 +4761,7 @@  discard block
 block discarded – undo
4537 4761
 				}
4538 4762
 			</script>
4539 4763
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4764
+	}
4540 4765
 
4541 4766
 	$active = time() - $upcontext['started'];
4542 4767
 	$hours = floor($active / 3600);
@@ -4546,16 +4771,20 @@  discard block
 block discarded – undo
4546 4771
 	if ($is_debug)
4547 4772
 	{
4548 4773
 		$totalTime = '';
4549
-		if ($hours > 0)
4550
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4551
-		if ($minutes > 0)
4552
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4553
-		if ($seconds > 0)
4554
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4774
+		if ($hours > 0) {
4775
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4776
+		}
4777
+		if ($minutes > 0) {
4778
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4779
+		}
4780
+		if ($seconds > 0) {
4781
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4782
+		}
4555 4783
 	}
4556 4784
 
4557
-	if ($is_debug && !empty($totalTime))
4558
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4785
+	if ($is_debug && !empty($totalTime)) {
4786
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4787
+	}
4559 4788
 
4560 4789
 	echo '<br>
4561 4790
 			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>
@@ -4582,8 +4811,9 @@  discard block
 block discarded – undo
4582 4811
 
4583 4812
 	$current_substep = $_GET['substep'];
4584 4813
 
4585
-	if (empty($_GET['a']))
4586
-		$_GET['a'] = 0;
4814
+	if (empty($_GET['a'])) {
4815
+			$_GET['a'] = 0;
4816
+	}
4587 4817
 	$step_progress['name'] = 'Converting ips';
4588 4818
 	$step_progress['current'] = $_GET['a'];
4589 4819
 
@@ -4626,16 +4856,19 @@  discard block
 block discarded – undo
4626 4856
 				'empty' => '',
4627 4857
 				'limit' => $limit,
4628 4858
 		));
4629
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4630
-			$arIp[] = $row[$oldCol];
4859
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4860
+					$arIp[] = $row[$oldCol];
4861
+		}
4631 4862
 		$smcFunc['db_free_result']($request);
4632 4863
 
4633 4864
 		// Special case, null ip could keep us in a loop.
4634
-		if (is_null($arIp[0]))
4635
-			unset($arIp[0]);
4865
+		if (is_null($arIp[0])) {
4866
+					unset($arIp[0]);
4867
+		}
4636 4868
 
4637
-		if (empty($arIp))
4638
-			$is_done = true;
4869
+		if (empty($arIp)) {
4870
+					$is_done = true;
4871
+		}
4639 4872
 
4640 4873
 		$updates = array();
4641 4874
 		$cases = array();
@@ -4644,16 +4877,18 @@  discard block
 block discarded – undo
4644 4877
 		{
4645 4878
 			$arIp[$i] = trim($arIp[$i]);
4646 4879
 
4647
-			if (empty($arIp[$i]))
4648
-				continue;
4880
+			if (empty($arIp[$i])) {
4881
+							continue;
4882
+			}
4649 4883
 
4650 4884
 			$updates['ip' . $i] = $arIp[$i];
4651 4885
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4652 4886
 
4653 4887
 			if ($setSize > 0 && $i % $setSize === 0)
4654 4888
 			{
4655
-				if (count($updates) == 1)
4656
-					continue;
4889
+				if (count($updates) == 1) {
4890
+									continue;
4891
+				}
4657 4892
 
4658 4893
 				$updates['whereSet'] = array_values($updates);
4659 4894
 				$smcFunc['db_query']('', '
@@ -4687,8 +4922,7 @@  discard block
 block discarded – undo
4687 4922
 							'ip' => $ip
4688 4923
 					));
4689 4924
 				}
4690
-			}
4691
-			else
4925
+			} else
4692 4926
 			{
4693 4927
 				$updates['whereSet'] = array_values($updates);
4694 4928
 				$smcFunc['db_query']('', '
@@ -4702,9 +4936,9 @@  discard block
 block discarded – undo
4702 4936
 					$updates
4703 4937
 				);
4704 4938
 			}
4939
+		} else {
4940
+					$is_done = true;
4705 4941
 		}
4706
-		else
4707
-			$is_done = true;
4708 4942
 
4709 4943
 		$_GET['a'] += $limit;
4710 4944
 		$step_progress['current'] = $_GET['a'];
@@ -4730,10 +4964,11 @@  discard block
 block discarded – undo
4730 4964
 
4731 4965
  	$columns = $smcFunc['db_list_columns']($targetTable, true);
4732 4966
 
4733
-	if (isset($columns[$column]))
4734
-		return $columns[$column];
4735
-	else
4736
-		return null;
4737
-}
4967
+	if (isset($columns[$column])) {
4968
+			return $columns[$column];
4969
+	} else {
4970
+			return null;
4971
+	}
4972
+	}
4738 4973
 
4739 4974
 ?>
4740 4975
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * Display a list of upcoming events, birthdays, and holidays.
69 69
  *
70 70
  * @param string $grid_name The grid name
71
- * @return void|bool Returns false if the grid doesn't exist.
71
+ * @return false|null Returns false if the grid doesn't exist.
72 72
  */
73 73
 function template_show_upcoming_list($grid_name)
74 74
 {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @param string $grid_name The grid name
240 240
  * @param bool $is_mini Is this a mini grid?
241
- * @return void|bool Returns false if the grid doesn't exist.
241
+ * @return false|null Returns false if the grid doesn't exist.
242 242
  */
243 243
 function template_show_month_grid($grid_name, $is_mini = false)
244 244
 {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
  * Shows a weekly grid
524 524
  *
525 525
  * @param string $grid_name The name of the grid
526
- * @return void|bool Returns false if the grid doesn't exist
526
+ * @return false|null Returns false if the grid doesn't exist
527 527
  */
528 528
 function template_show_week_grid($grid_name)
529 529
 {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 					{
438 438
 						// Sort events by start time (all day events will be listed first)
439 439
 						uasort($day['events'], function($a, $b) {
440
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
441
-						        return 0;
442
-						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
440
+							if ($a['start_timestamp'] == $b['start_timestamp'])
441
+								return 0;
442
+							return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
443 443
 						});
444 444
 
445 445
 						echo '
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
 							{
620 620
 								// Sort events by start time (all day events will be listed first)
621 621
 								uasort($day['events'], function($a, $b) {
622
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
623
-								        return 0;
624
-								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
622
+									if ($a['start_timestamp'] == $b['start_timestamp'])
623
+										return 0;
624
+									return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
625 625
 								});
626 626
 
627 627
 								foreach ($day['events'] as $event)
Please login to merge, or discard this 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
 						<strong class="event_title">', $event['link'], '</strong>';
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="date_input end" data-type="date">
752 779
 				<input type="submit" class="button" 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">';
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 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.
Themes/default/index.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
 			//In maintenance mode, only login is allowed and don't show OverlayDiv
230 230
 			echo '
231 231
 			<ul class="floatleft welcome">
232
-				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
232
+				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl . '?action=login', 'return true;'), '</li>
233 233
 			</ul>';
234 234
 
235 235
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
Please login to merge, or discard this patch.
Braces   +89 added lines, -61 removed lines patch added patch discarded remove patch
@@ -72,9 +72,10 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// Allow css/js files to be disable for this specific theme.
74 74
 	// Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference.
75
-	if (!isset($settings['disable_files']))
76
-		$settings['disable_files'] = array();
77
-}
75
+	if (!isset($settings['disable_files'])) {
76
+			$settings['disable_files'] = array();
77
+	}
78
+	}
78 79
 
79 80
 /**
80 81
  * The main sub template above the content.
@@ -111,8 +112,9 @@  discard block
 block discarded – undo
111 112
 		echo '
112 113
 	<meta';
113 114
 
114
-		foreach ($meta_tag as $meta_key => $meta_value)
115
-			echo ' ', $meta_key, '="', $meta_value, '"';
115
+		foreach ($meta_tag as $meta_key => $meta_value) {
116
+					echo ' ', $meta_key, '="', $meta_value, '"';
117
+		}
116 118
 
117 119
 		echo '>';
118 120
 	}
@@ -123,14 +125,16 @@  discard block
 block discarded – undo
123 125
 	<meta name="theme-color" content="#557EA0">';
124 126
 
125 127
 	// Please don't index these Mr Robot.
126
-	if (!empty($context['robot_no_index']))
127
-		echo '
128
+	if (!empty($context['robot_no_index'])) {
129
+			echo '
128 130
 	<meta name="robots" content="noindex">';
131
+	}
129 132
 
130 133
 	// Present a canonical url for search engines to prevent duplicate content in their indices.
131
-	if (!empty($context['canonical_url']))
132
-		echo '
134
+	if (!empty($context['canonical_url'])) {
135
+			echo '
133 136
 	<link rel="canonical" href="', $context['canonical_url'], '">';
137
+	}
134 138
 
135 139
 	// Show all the relative links, such as help, search, contents, and the like.
136 140
 	echo '
@@ -139,10 +143,11 @@  discard block
 block discarded – undo
139 143
 	<link rel="search" href="' . $scripturl . '?action=search">' : '');
140 144
 
141 145
 	// If RSS feeds are enabled, advertise the presence of one.
142
-	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
143
-		echo '
146
+	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) {
147
+			echo '
144 148
 	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">
145 149
 	<link rel="alternate" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">';
150
+	}
146 151
 
147 152
 	// If we're viewing a topic, these should be the previous and next topics, respectively.
148 153
 	if (!empty($context['links']['next']))
@@ -158,9 +163,10 @@  discard block
 block discarded – undo
158 163
 	}
159 164
 
160 165
 	// If we're in a board, or a topic for that matter, the index will be the board's index.
161
-	if (!empty($context['current_board']))
162
-		echo '
166
+	if (!empty($context['current_board'])) {
167
+			echo '
163 168
 	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">';
169
+	}
164 170
 
165 171
 	// Output any remaining HTML headers. (from mods, maybe?)
166 172
 	echo $context['html_headers'];
@@ -192,8 +198,9 @@  discard block
 block discarded – undo
192 198
 			<ul class="floatleft" id="top_info">
193 199
 				<li>
194 200
 					<a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">';
195
-			if (!empty($context['user']['avatar']))
196
-				echo $context['user']['avatar']['image'];
201
+			if (!empty($context['user']['avatar'])) {
202
+							echo $context['user']['avatar']['image'];
203
+			}
197 204
 			echo $context['user']['name'], '</a>
198 205
 					<div id="profile_menu" class="top_menu"></div>
199 206
 				</li>';
@@ -221,17 +228,18 @@  discard block
 block discarded – undo
221 228
 	}
222 229
 	// Otherwise they're a guest. Ask them to either register or login.
223 230
 	else
224
-		if (empty($maintenance))
225
-			echo '
231
+		if (empty($maintenance)) {
232
+					echo '
226 233
 			<ul class="floatleft welcome">
227 234
 				<li>', 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'), '</li>
228 235
 			</ul>';
229
-		else
230
-			//In maintenance mode, only login is allowed and don't show OverlayDiv
236
+		} else {
237
+					//In maintenance mode, only login is allowed and don't show OverlayDiv
231 238
 			echo '
232 239
 			<ul class="floatleft welcome">
233 240
 				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
234 241
 			</ul>';
242
+		}
235 243
 
236 244
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
237 245
 	{
@@ -239,9 +247,10 @@  discard block
 block discarded – undo
239 247
 			<form id="languages_form" method="get" class="floatright">
240 248
 				<select id="language_select" name="language" onchange="this.form.submit()">';
241 249
 
242
-		foreach ($context['languages'] as $language)
243
-			echo '
250
+		foreach ($context['languages'] as $language) {
251
+					echo '
244 252
 					<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>';
253
+		}
245 254
 
246 255
 		echo '
247 256
 				</select>
@@ -265,31 +274,36 @@  discard block
 block discarded – undo
265 274
 					<option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>';
266 275
 
267 276
 		// Can't limit it to a specific topic if we are not in one
268
-		if (!empty($context['current_topic']))
269
-			echo '
277
+		if (!empty($context['current_topic'])) {
278
+					echo '
270 279
 					<option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>';
280
+		}
271 281
 
272 282
 		// Can't limit it to a specific board if we are not in one
273
-		if (!empty($context['current_board']))
274
-			echo '
283
+		if (!empty($context['current_board'])) {
284
+					echo '
275 285
 					<option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>';
286
+		}
276 287
 
277 288
 		// Can't search for members if we can't see the memberlist
278
-		if (!empty($context['allow_memberlist']))
279
-			echo '
289
+		if (!empty($context['allow_memberlist'])) {
290
+					echo '
280 291
 					<option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>';
292
+		}
281 293
 
282 294
 		echo '
283 295
 				</select>';
284 296
 
285 297
 		// Search within current topic?
286
-		if (!empty($context['current_topic']))
287
-			echo '
298
+		if (!empty($context['current_topic'])) {
299
+					echo '
288 300
 				<input type="hidden" name="sd_topic" value="', $context['current_topic'], '">';
301
+		}
289 302
 		// If we're on a certain board, limit it to this board ;).
290
-		elseif (!empty($context['current_board']))
291
-			echo '
303
+		elseif (!empty($context['current_board'])) {
304
+					echo '
292 305
 				<input type="hidden" name="sd_brd" value="', $context['current_board'], '">';
306
+		}
293 307
 
294 308
 		echo '
295 309
 				<input type="submit" name="search2" value="', $txt['search'], '" class="button">
@@ -320,12 +334,13 @@  discard block
 block discarded – undo
320 334
 						', $context['current_time'], '
321 335
 					</div>';
322 336
 	// Show a random news item? (or you could pick one from news_lines...)
323
-	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
324
-		echo '
337
+	if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) {
338
+			echo '
325 339
 					<div class="news">
326 340
 						<h2>', $txt['news'], ': </h2>
327 341
 						<p>', $context['random_news_line'], '</p>
328 342
 					</div>';
343
+	}
329 344
 
330 345
 	echo '
331 346
 					<hr class="clear">
@@ -388,9 +403,10 @@  discard block
 block discarded – undo
388 403
 		</ul>';
389 404
 
390 405
 	// Show the load time?
391
-	if ($context['show_load_time'])
392
-		echo '
406
+	if ($context['show_load_time']) {
407
+			echo '
393 408
 		<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
409
+	}
394 410
 
395 411
 	echo '
396 412
 		</div>
@@ -421,19 +437,21 @@  discard block
 block discarded – undo
421 437
 	global $context, $shown_linktree, $scripturl, $txt;
422 438
 
423 439
 	// If linktree is empty, just return - also allow an override.
424
-	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
425
-		return;
440
+	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) {
441
+			return;
442
+	}
426 443
 
427 444
 	echo '
428 445
 				<div class="navigate_section">
429 446
 					<ul>';
430 447
 
431
-	if ($context['user']['is_logged'])
432
-	echo '
448
+	if ($context['user']['is_logged']) {
449
+		echo '
433 450
 						<li class="unread_links">
434 451
 							<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
435 452
 							<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
436 453
 						</li>';
454
+	}
437 455
 
438 456
 	// Each tree item has a URL and name. Some may have extra_before and extra_after.
439 457
 	foreach ($context['linktree'] as $link_num => $tree)
@@ -444,25 +462,29 @@  discard block
 block discarded – undo
444 462
 		// Don't show a separator for the first one.
445 463
 		// Better here. Always points to the next level when the linktree breaks to a second line.
446 464
 		// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
447
-		if ($link_num != 0)
448
-			echo '
465
+		if ($link_num != 0) {
466
+					echo '
449 467
 							<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';
468
+		}
450 469
 
451 470
 		// Show something before the link?
452
-		if (isset($tree['extra_before']))
453
-			echo $tree['extra_before'], ' ';
471
+		if (isset($tree['extra_before'])) {
472
+					echo $tree['extra_before'], ' ';
473
+		}
454 474
 
455 475
 		// Show the link, including a URL if it should have one.
456
-		if (isset($tree['url']))
457
-			echo '
476
+		if (isset($tree['url'])) {
477
+					echo '
458 478
 					<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
459
-		else
460
-			echo '
479
+		} else {
480
+					echo '
461 481
 					<span>' . $tree['name'] . '</span>';
482
+		}
462 483
 
463 484
 		// Show something after the link...?
464
-		if (isset($tree['extra_after']))
465
-			echo ' ', $tree['extra_after'];
485
+		if (isset($tree['extra_after'])) {
486
+					echo ' ', $tree['extra_after'];
487
+		}
466 488
 
467 489
 		echo '
468 490
 						</li>';
@@ -512,13 +534,14 @@  discard block
 block discarded – undo
512 534
 					echo '
513 535
 									<ul>';
514 536
 
515
-					foreach ($childbutton['sub_buttons'] as $grandchildbutton)
516
-						echo '
537
+					foreach ($childbutton['sub_buttons'] as $grandchildbutton) {
538
+											echo '
517 539
 										<li>
518 540
 											<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
519 541
 												', $grandchildbutton['title'], '
520 542
 											</a>
521 543
 										</li>';
544
+					}
522 545
 
523 546
 					echo '
524 547
 									</ul>';
@@ -549,8 +572,9 @@  discard block
 block discarded – undo
549 572
 {
550 573
 	global $context, $txt;
551 574
 
552
-	if (!is_array($strip_options))
553
-		$strip_options = array();
575
+	if (!is_array($strip_options)) {
576
+			$strip_options = array();
577
+	}
554 578
 
555 579
 	// Create the buttons...
556 580
 	$buttons = array();
@@ -559,8 +583,9 @@  discard block
 block discarded – undo
559 583
 		// As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!)
560 584
 		if (!isset($value['test']) || !empty($context[$value['test']]))
561 585
 		{
562
-			if (!isset($value['id']))
563
-				$value['id'] = $key;
586
+			if (!isset($value['id'])) {
587
+							$value['id'] = $key;
588
+			}
564 589
 
565 590
 			$button = '
566 591
 				<a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>';
@@ -573,13 +598,15 @@  discard block
 block discarded – undo
573 598
 							<div class="overview">';
574 599
 				foreach ($value['sub_buttons'] as $element)
575 600
 				{
576
-					if (isset($element['test']) && empty($context[$element['test']]))
577
-						continue;
601
+					if (isset($element['test']) && empty($context[$element['test']])) {
602
+											continue;
603
+					}
578 604
 
579 605
 					$button .= '
580 606
 								<a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>';
581
-					if (isset($txt[$element['text'] . '_desc']))
582
-						$button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>';
607
+					if (isset($txt[$element['text'] . '_desc'])) {
608
+											$button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>';
609
+					}
583 610
 					$button .= '</a>';
584 611
 				}
585 612
 				$button .= '
@@ -593,8 +620,9 @@  discard block
 block discarded – undo
593 620
 	}
594 621
 
595 622
 	// No buttons? No button strip either.
596
-	if (empty($buttons))
597
-		return;
623
+	if (empty($buttons)) {
624
+			return;
625
+	}
598 626
 
599 627
 	echo '
600 628
 		<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '>
Please login to merge, or discard this patch.