Completed
Pull Request — release-2.1 (#3890)
by Fran
12:33 queued 05:26
created
Themes/default/Calendar.template.php 1 patch
Braces   +152 added lines, -116 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'] == 'view_week')
43
+	} elseif ($context['calendar_view'] == 'view_week')
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, $modSettings;
76 74
 
77 75
 	// Bail out if we have nothing to work with
78
-	if (!isset($context['calendar_grid_' . $grid_name]))
79
-		return false;
76
+	if (!isset($context['calendar_grid_' . $grid_name])) {
77
+			return false;
78
+	}
80 79
 
81 80
 	// Protect programmer sanity
82 81
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -113,11 +112,13 @@  discard block
 block discarded – undo
113 112
 					<li class="windowbg">
114 113
 						<b class="event_title">', $event['link'], '</b>';
115 114
 
116
-				if ($event['can_edit'])
117
-					echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
115
+				if ($event['can_edit']) {
116
+									echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
117
+				}
118 118
 
119
-				if ($event['can_export'])
120
-					echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
119
+				if ($event['can_export']) {
120
+									echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
121
+				}
121 122
 
122 123
 				echo '
123 124
 						<br>';
@@ -125,14 +126,14 @@  discard block
 block discarded – undo
125 126
 				if (!empty($event['allday']))
126 127
 				{
127 128
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
128
-				}
129
-				else
129
+				} else
130 130
 				{
131 131
 					// Display event info relative to user's local timezone
132 132
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
133 133
 
134
-					if ($event['start_date_local'] != $event['end_date_local'])
135
-						echo trim($event['end_date_local']) . ', ';
134
+					if ($event['start_date_local'] != $event['end_date_local']) {
135
+											echo trim($event['end_date_local']) . ', ';
136
+					}
136 137
 
137 138
 					echo trim($event['end_time_local']);
138 139
 
@@ -141,23 +142,27 @@  discard block
 block discarded – undo
141 142
 					{
142 143
 						echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
143 144
 
144
-						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
145
-							echo trim($event['start_date_orig']), ', ';
145
+						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
146
+													echo trim($event['start_date_orig']), ', ';
147
+						}
146 148
 
147 149
 						echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
148 150
 
149
-						if ($event['start_date_orig'] != $event['end_date_orig'])
150
-							echo trim($event['end_date_orig']) . ', ';
151
+						if ($event['start_date_orig'] != $event['end_date_orig']) {
152
+													echo trim($event['end_date_orig']) . ', ';
153
+						}
151 154
 
152 155
 						echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
153 156
 					}
154 157
 					// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
155
-					else
156
-						echo ' ', $event['tz_abbrev'], '</time>';
158
+					else {
159
+											echo ' ', $event['tz_abbrev'], '</time>';
160
+					}
157 161
 				}
158 162
 
159
-				if (!empty($event['location']))
160
-					echo '<br>', $event['location'];
163
+				if (!empty($event['location'])) {
164
+									echo '<br>', $event['location'];
165
+				}
161 166
 
162 167
 				echo '
163 168
 					</li>';
@@ -189,8 +194,9 @@  discard block
 block discarded – undo
189 194
 
190 195
 			$birthdays = array();
191 196
 
192
-			foreach ($date as $member)
193
-				$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
197
+			foreach ($date as $member) {
198
+							$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
199
+			}
194 200
 
195 201
 			echo implode(', ', $birthdays);
196 202
 
@@ -221,8 +227,9 @@  discard block
 block discarded – undo
221 227
 			$date_local = $date['date_local'];
222 228
 			unset($date['date_local']);
223 229
 
224
-			foreach ($date as $holiday)
225
-				$holidays[] = $holiday . ' (' . $date_local . ')';
230
+			foreach ($date as $holiday) {
231
+							$holidays[] = $holiday . ' (' . $date_local . ')';
232
+			}
226 233
 		}
227 234
 
228 235
 		echo implode(', ', $holidays);
@@ -245,17 +252,19 @@  discard block
 block discarded – undo
245 252
 	global $context, $settings, $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,17 +405,19 @@  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
-				else
398
-					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
+				} else {
411
+									echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
412
+				}
399 413
 
400 414
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
401 415
 				if ($is_mini === false)
402 416
 				{
403 417
 					// Holidays are always fun, let's show them!
404
-					if (!empty($day['holidays']))
405
-						echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
418
+					if (!empty($day['holidays'])) {
419
+											echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
420
+					}
406 421
 
407 422
 					// Happy Birthday Dear, Member!
408 423
 					if (!empty($day['birthdays']))
@@ -420,14 +435,16 @@  discard block
 block discarded – undo
420 435
 							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) ? '' : ', ';
421 436
 
422 437
 							// 9...10! Let's stop there.
423
-							if ($birthday_count == 10 && $use_js_hide)
424
-								// !!TODO - Inline CSS and JavaScript should be moved.
438
+							if ($birthday_count == 10 && $use_js_hide) {
439
+															// !!TODO - Inline CSS and JavaScript should be moved.
425 440
 								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;">, ';
441
+							}
426 442
 
427 443
 							++$birthday_count;
428 444
 						}
429
-						if ($use_js_hide)
430
-							echo '</span>';
445
+						if ($use_js_hide) {
446
+													echo '</span>';
447
+						}
431 448
 
432 449
 						echo '</div>';
433 450
 					}
@@ -437,8 +454,9 @@  discard block
 block discarded – undo
437 454
 					{
438 455
 						// Sort events by start time (all day events will be listed first)
439 456
 						uasort($day['events'], function($a, $b) {
440
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
441
-						        return 0;
457
+						    if ($a['start_timestamp'] == $b['start_timestamp']) {
458
+						    						        return 0;
459
+						    }
442 460
 						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
443 461
 						});
444 462
 
@@ -454,17 +472,19 @@  discard block
 block discarded – undo
454 472
 
455 473
 							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' : '', '">';
456 474
 
457
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
458
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
459
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
460
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
461
-							elseif (!empty($event['allday']))
462
-								echo $txt['calendar_allday'];
475
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
476
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
477
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
478
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
479
+							} elseif (!empty($event['allday'])) {
480
+															echo $txt['calendar_allday'];
481
+							}
463 482
 
464 483
 							echo '</span>';
465 484
 
466
-							if (!empty($event['location']))
467
-								echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
485
+							if (!empty($event['location'])) {
486
+															echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
487
+							}
468 488
 
469 489
 							if ($event['can_edit'] || $event['can_export'])
470 490
 							{
@@ -501,10 +521,11 @@  discard block
 block discarded – undo
501 521
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
502 522
 			elseif ($is_mini === false)
503 523
 			{
504
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
505
-					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>';
506
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
507
-					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>';
524
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
525
+									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>';
526
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
527
+									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>';
528
+				}
508 529
 			}
509 530
 
510 531
 			// Close this day and increase var count.
@@ -530,8 +551,9 @@  discard block
 block discarded – undo
530 551
 	global $context, $settings, $txt, $scripturl, $modSettings;
531 552
 
532 553
 	// We might have no reason to proceed, if the variable isn't there.
533
-	if (!isset($context['calendar_grid_' . $grid_name]))
534
-		return false;
554
+	if (!isset($context['calendar_grid_' . $grid_name])) {
555
+			return false;
556
+	}
535 557
 
536 558
 	// Handy pointer.
537 559
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -567,8 +589,9 @@  discard block
 block discarded – undo
567 589
 					}
568 590
 
569 591
 					// The Month Title + Week Number...
570
-					if (!empty($calendar_data['week_title']))
571
-							echo $calendar_data['week_title'];
592
+					if (!empty($calendar_data['week_title'])) {
593
+												echo $calendar_data['week_title'];
594
+					}
572 595
 
573 596
 					echo '
574 597
 					</h3>
@@ -607,10 +630,11 @@  discard block
 block discarded – undo
607 630
 						<tr class="days_wrapper">
608 631
 							<td class="', implode(' ', $classes), ' act_day">';
609 632
 							// Should the day number be a link?
610
-							if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
611
-								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>';
612
-							else
613
-								echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
633
+							if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
634
+															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>';
635
+							} else {
636
+															echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
637
+							}
614 638
 
615 639
 							echo '</td>
616 640
 							<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'] : '', '">';
@@ -619,8 +643,9 @@  discard block
 block discarded – undo
619 643
 							{
620 644
 								// Sort events by start time (all day events will be listed first)
621 645
 								uasort($day['events'], function($a, $b) {
622
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
623
-								        return 0;
646
+								    if ($a['start_timestamp'] == $b['start_timestamp']) {
647
+								    								        return 0;
648
+								    }
624 649
 								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
625 650
 								});
626 651
 
@@ -632,15 +657,17 @@  discard block
 block discarded – undo
632 657
 
633 658
 									echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
634 659
 
635
-									if (!empty($event['start_time_local']))
636
-										echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
637
-									else
638
-										echo $txt['calendar_allday'];
660
+									if (!empty($event['start_time_local'])) {
661
+																			echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
662
+									} else {
663
+																			echo $txt['calendar_allday'];
664
+									}
639 665
 
640 666
 									echo '</span>';
641 667
 
642
-									if (!empty($event['location']))
643
-										echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
668
+									if (!empty($event['location'])) {
669
+																			echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
670
+									}
644 671
 
645 672
 									if (!empty($event_icons_needed))
646 673
 									{
@@ -677,8 +704,7 @@  discard block
 block discarded – undo
677 704
 									</div>
678 705
 									<br class="clear">';
679 706
 								}
680
-							}
681
-							else
707
+							} else
682 708
 							{
683 709
 								if (!empty($context['can_post']))
684 710
 								{
@@ -691,8 +717,9 @@  discard block
 block discarded – undo
691 717
 							echo '</td>
692 718
 							<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
693 719
 							// Show any holidays!
694
-							if (!empty($day['holidays']))
695
-								echo implode('<br>', $day['holidays']);
720
+							if (!empty($day['holidays'])) {
721
+															echo implode('<br>', $day['holidays']);
722
+							}
696 723
 
697 724
 							echo '</td>
698 725
 							<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">';
@@ -750,8 +777,7 @@  discard block
 block discarded – undo
750 777
 				<input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date">
751 778
 				<input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '">
752 779
 			</form>';
753
-	}
754
-	else
780
+	} else
755 781
 	{
756 782
 		echo'
757 783
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
@@ -793,8 +819,9 @@  discard block
 block discarded – undo
793 819
 	echo '
794 820
 		<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;">';
795 821
 
796
-	if (!empty($context['event']['new']))
797
-		echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
822
+	if (!empty($context['event']['new'])) {
823
+			echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
824
+	}
798 825
 
799 826
 	// Start the main table.
800 827
 	echo '
@@ -844,9 +871,10 @@  discard block
 block discarded – undo
844 871
 		{
845 872
 			echo '
846 873
 								<optgroup label="', $category['name'], '">';
847
-			foreach ($category['boards'] as $board)
848
-				echo '
874
+			foreach ($category['boards'] as $board) {
875
+							echo '
849 876
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
877
+			}
850 878
 			echo '
851 879
 								</optgroup>';
852 880
 		}
@@ -882,9 +910,10 @@  discard block
 block discarded – undo
882 910
 							<span class="label">', $txt['calendar_timezone'], '</span>
883 911
 							<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
884 912
 
885
-	foreach ($context['all_timezones'] as $tz => $tzname)
886
-		echo '
913
+	foreach ($context['all_timezones'] as $tz => $tzname) {
914
+			echo '
887 915
 								<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
916
+	}
888 917
 
889 918
 	echo '
890 919
 							</select>
@@ -899,9 +928,10 @@  discard block
 block discarded – undo
899 928
 	echo '
900 929
 				<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">';
901 930
 	// Delete button?
902
-	if (empty($context['event']['new']))
903
-		echo '
931
+	if (empty($context['event']['new'])) {
932
+			echo '
904 933
 				<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">';
934
+	}
905 935
 
906 936
 	echo '
907 937
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -945,9 +975,10 @@  discard block
 block discarded – undo
945 975
 
946 976
 		foreach ($context['clockicons'] as $t => $v)
947 977
 		{
948
-			foreach ($v as $i)
949
-				echo '
978
+			foreach ($v as $i) {
979
+							echo '
950 980
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
981
+			}
951 982
 		}
952 983
 
953 984
 		echo '
@@ -972,13 +1003,14 @@  discard block
 block discarded – undo
972 1003
 
973 1004
 		foreach ($context['clockicons'] as $t => $v)
974 1005
 		{
975
-			foreach ($v as $i)
976
-				echo '
1006
+			foreach ($v as $i) {
1007
+							echo '
977 1008
 			if (', $t, ' >= ', $i, ')
978 1009
 			{
979 1010
 				turnon.push("', $t, '_', $i, '");
980 1011
 				', $t, ' -= ', $i, ';
981 1012
 			}';
1013
+			}
982 1014
 		}
983 1015
 
984 1016
 		echo '
@@ -1042,9 +1074,10 @@  discard block
 block discarded – undo
1042 1074
 
1043 1075
 	foreach ($context['clockicons'] as $t => $v)
1044 1076
 	{
1045
-		foreach ($v as $i)
1046
-			echo '
1077
+		foreach ($v as $i) {
1078
+					echo '
1047 1079
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1080
+		}
1048 1081
 	}
1049 1082
 
1050 1083
 	echo '
@@ -1061,13 +1094,14 @@  discard block
 block discarded – undo
1061 1094
 
1062 1095
 	foreach ($context['clockicons'] as $t => $v)
1063 1096
 	{
1064
-		foreach ($v as $i)
1065
-			echo '
1097
+		foreach ($v as $i) {
1098
+					echo '
1066 1099
 		if (', $t, ' >= ', $i, ')
1067 1100
 		{
1068 1101
 			turnon.push("', $t, '_', $i, '");
1069 1102
 			', $t, ' -= ', $i, ';
1070 1103
 		}';
1104
+		}
1071 1105
 	}
1072 1106
 
1073 1107
 	echo '
@@ -1126,9 +1160,10 @@  discard block
 block discarded – undo
1126 1160
 
1127 1161
 	foreach ($context['clockicons'] as $t => $v)
1128 1162
 	{
1129
-		foreach ($v as $i)
1130
-			echo '
1163
+		foreach ($v as $i) {
1164
+					echo '
1131 1165
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1166
+		}
1132 1167
 	}
1133 1168
 
1134 1169
 	echo '
@@ -1149,13 +1184,14 @@  discard block
 block discarded – undo
1149 1184
 
1150 1185
 	foreach ($context['clockicons'] as $t => $v)
1151 1186
 	{
1152
-		foreach ($v as $i)
1153
-		echo '
1187
+		foreach ($v as $i) {
1188
+				echo '
1154 1189
 		if (', $t, ' >= ', $i, ')
1155 1190
 		{
1156 1191
 			turnon.push("', $t, '_', $i, '");
1157 1192
 			', $t, ' -= ', $i, ';
1158 1193
 		}';
1194
+		}
1159 1195
 	}
1160 1196
 
1161 1197
 	echo '
Please login to merge, or discard this patch.
Sources/ManageMaintenance.php 1 patch
Braces   +266 added lines, -197 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Main dispatcher, the maintenance access point.
@@ -96,14 +97,16 @@  discard block
 block discarded – undo
96 97
 	call_integration_hook('integrate_manage_maintenance', array(&$subActions));
97 98
 
98 99
 	// Yep, sub-action time!
99
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
100
-		$subAction = $_REQUEST['sa'];
101
-	else
102
-		$subAction = 'routine';
100
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
101
+			$subAction = $_REQUEST['sa'];
102
+	} else {
103
+			$subAction = 'routine';
104
+	}
103 105
 
104 106
 	// Doing something special?
105
-	if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']]))
106
-		$activity = $_REQUEST['activity'];
107
+	if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) {
108
+			$activity = $_REQUEST['activity'];
109
+	}
107 110
 
108 111
 	// Set a few things.
109 112
 	$context['page_title'] = $txt['maintain_title'];
@@ -114,12 +117,14 @@  discard block
 block discarded – undo
114 117
 	call_helper($subActions[$subAction]['function']);
115 118
 
116 119
 	// Any special activity?
117
-	if (isset($activity))
118
-		call_helper($subActions[$subAction]['activities'][$activity]);
120
+	if (isset($activity)) {
121
+			call_helper($subActions[$subAction]['activities'][$activity]);
122
+	}
119 123
 
120 124
 	//converted to UTF-8? show a small maintenance info
121
-	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8')
122
-		$context['maintenance_finished'] = $txt['utf8_title'];
125
+	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') {
126
+			$context['maintenance_finished'] = $txt['utf8_title'];
127
+	}
123 128
 
124 129
 	// Create a maintenance token.  Kinda hard to do it any other way.
125 130
 	createToken('admin-maint');
@@ -141,19 +146,22 @@  discard block
 block discarded – undo
141 146
 		db_extend('packages');
142 147
 
143 148
 		$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
144
-		foreach ($colData as $column)
145
-			if ($column['name'] == 'body')
149
+		foreach ($colData as $column) {
150
+					if ($column['name'] == 'body')
146 151
 				$body_type = $column['type'];
152
+		}
147 153
 
148 154
 		$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
149 155
 		$context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536);
150 156
 	}
151 157
 
152
-	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8')
153
-		$context['maintenance_finished'] = $txt['utf8_title'];
154
-	if (isset($_GET['done']) && $_GET['done'] == 'convertentities')
155
-		$context['maintenance_finished'] = $txt['entity_convert_title'];
156
-}
158
+	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') {
159
+			$context['maintenance_finished'] = $txt['utf8_title'];
160
+	}
161
+	if (isset($_GET['done']) && $_GET['done'] == 'convertentities') {
162
+			$context['maintenance_finished'] = $txt['entity_convert_title'];
163
+	}
164
+	}
157 165
 
158 166
 /**
159 167
  * Supporting function for the routine maintenance area.
@@ -162,9 +170,10 @@  discard block
 block discarded – undo
162 170
 {
163 171
 	global $context, $txt;
164 172
 
165
-	if (isset($_GET['done']) && $_GET['done'] == 'recount')
166
-		$context['maintenance_finished'] = $txt['maintain_recount'];
167
-}
173
+	if (isset($_GET['done']) && $_GET['done'] == 'recount') {
174
+			$context['maintenance_finished'] = $txt['maintain_recount'];
175
+	}
176
+	}
168 177
 
169 178
 /**
170 179
  * Supporting function for the members maintenance area.
@@ -195,8 +204,9 @@  discard block
 block discarded – undo
195 204
 	}
196 205
 	$smcFunc['db_free_result']($result);
197 206
 
198
-	if (isset($_GET['done']) && $_GET['done'] == 'recountposts')
199
-		$context['maintenance_finished'] = $txt['maintain_recountposts'];
207
+	if (isset($_GET['done']) && $_GET['done'] == 'recountposts') {
208
+			$context['maintenance_finished'] = $txt['maintain_recountposts'];
209
+	}
200 210
 
201 211
 	loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest');
202 212
 }
@@ -222,11 +232,12 @@  discard block
 block discarded – undo
222 232
 	$context['categories'] = array();
223 233
 	while ($row = $smcFunc['db_fetch_assoc']($result))
224 234
 	{
225
-		if (!isset($context['categories'][$row['id_cat']]))
226
-			$context['categories'][$row['id_cat']] = array(
235
+		if (!isset($context['categories'][$row['id_cat']])) {
236
+					$context['categories'][$row['id_cat']] = array(
227 237
 				'name' => $row['cat_name'],
228 238
 				'boards' => array()
229 239
 			);
240
+		}
230 241
 
231 242
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
232 243
 			'id' => $row['id_board'],
@@ -239,11 +250,12 @@  discard block
 block discarded – undo
239 250
 	require_once($sourcedir . '/Subs-Boards.php');
240 251
 	sortCategories($context['categories']);
241 252
 
242
-	if (isset($_GET['done']) && $_GET['done'] == 'purgeold')
243
-		$context['maintenance_finished'] = $txt['maintain_old'];
244
-	elseif (isset($_GET['done']) && $_GET['done'] == 'massmove')
245
-		$context['maintenance_finished'] = $txt['move_topics_maintenance'];
246
-}
253
+	if (isset($_GET['done']) && $_GET['done'] == 'purgeold') {
254
+			$context['maintenance_finished'] = $txt['maintain_old'];
255
+	} elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') {
256
+			$context['maintenance_finished'] = $txt['move_topics_maintenance'];
257
+	}
258
+	}
247 259
 
248 260
 /**
249 261
  * Find and fix all errors on the forum.
@@ -351,15 +363,17 @@  discard block
 block discarded – undo
351 363
 	// Show me your badge!
352 364
 	isAllowedTo('admin_forum');
353 365
 
354
-	if ($db_type != 'mysql')
355
-		return;
366
+	if ($db_type != 'mysql') {
367
+			return;
368
+	}
356 369
 
357 370
 	db_extend('packages');
358 371
 
359 372
 	$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
360
-	foreach ($colData as $column)
361
-		if ($column['name'] == 'body')
373
+	foreach ($colData as $column) {
374
+			if ($column['name'] == 'body')
362 375
 			$body_type = $column['type'];
376
+	}
363 377
 
364 378
 	$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
365 379
 
@@ -369,33 +383,36 @@  discard block
 block discarded – undo
369 383
 		validateToken('admin-maint');
370 384
 
371 385
 		// Make it longer so we can do their limit.
372
-		if ($body_type == 'text')
373
-			$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext'));
386
+		if ($body_type == 'text') {
387
+					$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext'));
388
+		}
374 389
 		// Shorten the column so we can have a bit (literally per record) less space occupied
375
-		else
376
-			$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
390
+		else {
391
+					$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
392
+		}
377 393
 
378 394
 		// 3rd party integrations may be interested in knowning about this.
379 395
 		call_integration_hook('integrate_convert_msgbody', array($body_type));
380 396
 
381 397
 		$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
382
-		foreach ($colData as $column)
383
-			if ($column['name'] == 'body')
398
+		foreach ($colData as $column) {
399
+					if ($column['name'] == 'body')
384 400
 				$body_type = $column['type'];
401
+		}
385 402
 
386 403
 		$context['maintenance_finished'] = $txt[$context['convert_to'] . '_title'];
387 404
 		$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
388 405
 		$context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536);
389 406
 
390 407
 		return;
391
-	}
392
-	elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont'])))
408
+	} elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont'])))
393 409
 	{
394 410
 		checkSession();
395
-		if (empty($_REQUEST['start']))
396
-			validateToken('admin-maint');
397
-		else
398
-			validateToken('admin-convertMsg');
411
+		if (empty($_REQUEST['start'])) {
412
+					validateToken('admin-maint');
413
+		} else {
414
+					validateToken('admin-convertMsg');
415
+		}
399 416
 
400 417
 		$context['page_title'] = $txt['not_done_title'];
401 418
 		$context['continue_post_data'] = '';
@@ -427,8 +444,9 @@  discard block
 block discarded – undo
427 444
 					'increment' => $increment - 1,
428 445
 				)
429 446
 			);
430
-			while ($row = $smcFunc['db_fetch_assoc']($request))
431
-				$id_msg_exceeding[] = $row['id_msg'];
447
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
448
+							$id_msg_exceeding[] = $row['id_msg'];
449
+			}
432 450
 			$smcFunc['db_free_result']($request);
433 451
 
434 452
 			$_REQUEST['start'] += $increment;
@@ -457,9 +475,9 @@  discard block
 block discarded – undo
457 475
 			{
458 476
 				$query_msg = array_slice($id_msg_exceeding, 0, 100);
459 477
 				$context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding));
478
+			} else {
479
+							$query_msg = $id_msg_exceeding;
460 480
 			}
461
-			else
462
-				$query_msg = $id_msg_exceeding;
463 481
 
464 482
 			$context['exceeding_messages'] = array();
465 483
 			$request = $smcFunc['db_query']('', '
@@ -470,8 +488,9 @@  discard block
 block discarded – undo
470 488
 					'messages' => $query_msg,
471 489
 				)
472 490
 			);
473
-			while ($row = $smcFunc['db_fetch_assoc']($request))
474
-				$context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
491
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
492
+							$context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
493
+			}
475 494
 			$smcFunc['db_free_result']($request);
476 495
 		}
477 496
 	}
@@ -495,8 +514,9 @@  discard block
 block discarded – undo
495 514
 	isAllowedTo('admin_forum');
496 515
 
497 516
 	// Check to see if UTF-8 is currently the default character set.
498
-	if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8')
499
-		fatal_lang_error('entity_convert_only_utf8');
517
+	if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') {
518
+			fatal_lang_error('entity_convert_only_utf8');
519
+	}
500 520
 
501 521
 	// Some starting values.
502 522
 	$context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table'];
@@ -558,8 +578,9 @@  discard block
 block discarded – undo
558 578
 		// Make sure we keep stuff unique!
559 579
 		$primary_keys = array();
560 580
 
561
-		if (function_exists('apache_reset_timeout'))
562
-			@apache_reset_timeout();
581
+		if (function_exists('apache_reset_timeout')) {
582
+					@apache_reset_timeout();
583
+		}
563 584
 
564 585
 		// Get a list of text columns.
565 586
 		$columns = array();
@@ -570,9 +591,10 @@  discard block
 block discarded – undo
570 591
 				'cur_table' => $cur_table,
571 592
 			)
572 593
 		);
573
-		while ($column_info = $smcFunc['db_fetch_assoc']($request))
574
-			if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false)
594
+		while ($column_info = $smcFunc['db_fetch_assoc']($request)) {
595
+					if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false)
575 596
 				$columns[] = strtolower($column_info['Field']);
597
+		}
576 598
 
577 599
 		// Get the column with the (first) primary key.
578 600
 		$request = $smcFunc['db_query']('', '
@@ -586,8 +608,9 @@  discard block
 block discarded – undo
586 608
 		{
587 609
 			if ($row['Key_name'] === 'PRIMARY')
588 610
 			{
589
-				if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns)))
590
-					$primary_key = $row['Column_name'];
611
+				if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) {
612
+									$primary_key = $row['Column_name'];
613
+				}
591 614
 
592 615
 				$primary_keys[] = $row['Column_name'];
593 616
 			}
@@ -596,8 +619,9 @@  discard block
 block discarded – undo
596 619
 
597 620
 		// No primary key, no glory.
598 621
 		// Same for columns. Just to be sure we've work to do!
599
-		if (empty($primary_key) || empty($columns))
600
-			continue;
622
+		if (empty($primary_key) || empty($columns)) {
623
+					continue;
624
+		}
601 625
 
602 626
 		// Get the maximum value for the primary key.
603 627
 		$request = $smcFunc['db_query']('', '
@@ -611,8 +635,9 @@  discard block
 block discarded – undo
611 635
 		list($max_value) = $smcFunc['db_fetch_row']($request);
612 636
 		$smcFunc['db_free_result']($request);
613 637
 
614
-		if (empty($max_value))
615
-			continue;
638
+		if (empty($max_value)) {
639
+					continue;
640
+		}
616 641
 
617 642
 		while ($context['start'] <= $max_value)
618 643
 		{
@@ -636,10 +661,11 @@  discard block
 block discarded – undo
636 661
 			{
637 662
 				$insertion_variables = array();
638 663
 				$changes = array();
639
-				foreach ($row as $column_name => $column_value)
640
-					if ($column_name !== $primary_key && strpos($column_value, '&#') !== false)
664
+				foreach ($row as $column_name => $column_value) {
665
+									if ($column_name !== $primary_key && strpos($column_value, '&#') !== false)
641 666
 					{
642 667
 						$changes[] = $column_name . ' = {string:changes_' . $column_name . '}';
668
+				}
643 669
 						$insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value);
644 670
 					}
645 671
 
@@ -651,8 +677,8 @@  discard block
 block discarded – undo
651 677
 				}
652 678
 
653 679
 				// Update the row.
654
-				if (!empty($changes))
655
-					$smcFunc['db_query']('', '
680
+				if (!empty($changes)) {
681
+									$smcFunc['db_query']('', '
656 682
 						UPDATE {db_prefix}' . $cur_table . '
657 683
 						SET
658 684
 							' . implode(',
@@ -660,6 +686,7 @@  discard block
 block discarded – undo
660 686
 						WHERE ' . implode(' AND ', $where),
661 687
 						$insertion_variables
662 688
 					);
689
+				}
663 690
 			}
664 691
 			$smcFunc['db_free_result']($request);
665 692
 			$context['start'] += 500;
@@ -704,10 +731,11 @@  discard block
 block discarded – undo
704 731
 
705 732
 	checkSession('request');
706 733
 
707
-	if (!isset($_SESSION['optimized_tables']))
708
-		validateToken('admin-maint');
709
-	else
710
-		validateToken('admin-optimize', 'post', false);
734
+	if (!isset($_SESSION['optimized_tables'])) {
735
+			validateToken('admin-maint');
736
+	} else {
737
+			validateToken('admin-optimize', 'post', false);
738
+	}
711 739
 
712 740
 	ignore_user_abort(true);
713 741
 	db_extend();
@@ -723,13 +751,15 @@  discard block
 block discarded – undo
723 751
 	// Get a list of tables, as well as how many there are.
724 752
 	$temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%');
725 753
 	$tables = array();
726
-	foreach ($temp_tables as $table)
727
-		$tables[] = array('table_name' => $table);
754
+	foreach ($temp_tables as $table) {
755
+			$tables[] = array('table_name' => $table);
756
+	}
728 757
 
729 758
 	// If there aren't any tables then I believe that would mean the world has exploded...
730 759
 	$context['num_tables'] = count($tables);
731
-	if ($context['num_tables'] == 0)
732
-		fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false);
760
+	if ($context['num_tables'] == 0) {
761
+			fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false);
762
+	}
733 763
 
734 764
 	$_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
735 765
 
@@ -740,8 +770,9 @@  discard block
 block discarded – undo
740 770
 	$_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array();
741 771
 	for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++)
742 772
 	{
743
-		if (empty($tables[$key]))
744
-			break;
773
+		if (empty($tables[$key])) {
774
+					break;
775
+		}
745 776
 
746 777
 		// Continue?
747 778
 		if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 10)
@@ -755,8 +786,9 @@  discard block
 block discarded – undo
755 786
 			createToken('admin-optimize');
756 787
 			$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">';
757 788
 
758
-			if (function_exists('apache_reset_timeout'))
759
-				apache_reset_timeout();
789
+			if (function_exists('apache_reset_timeout')) {
790
+							apache_reset_timeout();
791
+			}
760 792
 
761 793
 			return;
762 794
 		}
@@ -764,11 +796,12 @@  discard block
 block discarded – undo
764 796
 		// Optimize the table!  We use backticks here because it might be a custom table.
765 797
 		$data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']);
766 798
 
767
-		if ($data_freed > 0)
768
-			$_SESSION['optimized_tables'][] = array(
799
+		if ($data_freed > 0) {
800
+					$_SESSION['optimized_tables'][] = array(
769 801
 				'name' => $tables[$key]['table_name'],
770 802
 				'data_freed' => $data_freed,
771 803
 			);
804
+		}
772 805
 	}
773 806
 
774 807
 	// Number of tables, etc...
@@ -803,10 +836,11 @@  discard block
 block discarded – undo
803 836
 	checkSession('request');
804 837
 
805 838
 	// validate the request or the loop
806
-	if (!isset($_REQUEST['step']))
807
-		validateToken('admin-maint');
808
-	else
809
-		validateToken('admin-boardrecount');
839
+	if (!isset($_REQUEST['step'])) {
840
+			validateToken('admin-maint');
841
+	} else {
842
+			validateToken('admin-boardrecount');
843
+	}
810 844
 
811 845
 	$context['page_title'] = $txt['not_done_title'];
812 846
 	$context['continue_post_data'] = '';
@@ -827,8 +861,9 @@  discard block
 block discarded – undo
827 861
 	$smcFunc['db_free_result']($request);
828 862
 
829 863
 	$increment = min(max(50, ceil($max_topics / 4)), 2000);
830
-	if (empty($_REQUEST['start']))
831
-		$_REQUEST['start'] = 0;
864
+	if (empty($_REQUEST['start'])) {
865
+			$_REQUEST['start'] = 0;
866
+	}
832 867
 
833 868
 	$total_steps = 8;
834 869
 
@@ -855,8 +890,8 @@  discard block
 block discarded – undo
855 890
 					'max_id' => $_REQUEST['start'] + $increment,
856 891
 				)
857 892
 			);
858
-			while ($row = $smcFunc['db_fetch_assoc']($request))
859
-				$smcFunc['db_query']('', '
893
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
894
+							$smcFunc['db_query']('', '
860 895
 					UPDATE {db_prefix}topics
861 896
 					SET num_replies = {int:num_replies}
862 897
 					WHERE id_topic = {int:id_topic}',
@@ -865,6 +900,7 @@  discard block
 block discarded – undo
865 900
 						'id_topic' => $row['id_topic'],
866 901
 					)
867 902
 				);
903
+			}
868 904
 			$smcFunc['db_free_result']($request);
869 905
 
870 906
 			// Recount unapproved messages
@@ -883,8 +919,8 @@  discard block
 block discarded – undo
883 919
 					'max_id' => $_REQUEST['start'] + $increment,
884 920
 				)
885 921
 			);
886
-			while ($row = $smcFunc['db_fetch_assoc']($request))
887
-				$smcFunc['db_query']('', '
922
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
923
+							$smcFunc['db_query']('', '
888 924
 					UPDATE {db_prefix}topics
889 925
 					SET unapproved_posts = {int:unapproved_posts}
890 926
 					WHERE id_topic = {int:id_topic}',
@@ -893,6 +929,7 @@  discard block
 block discarded – undo
893 929
 						'id_topic' => $row['id_topic'],
894 930
 					)
895 931
 				);
932
+			}
896 933
 			$smcFunc['db_free_result']($request);
897 934
 
898 935
 			$_REQUEST['start'] += $increment;
@@ -915,8 +952,8 @@  discard block
 block discarded – undo
915 952
 	// Update the post count of each board.
916 953
 	if ($_REQUEST['step'] <= 1)
917 954
 	{
918
-		if (empty($_REQUEST['start']))
919
-			$smcFunc['db_query']('', '
955
+		if (empty($_REQUEST['start'])) {
956
+					$smcFunc['db_query']('', '
920 957
 				UPDATE {db_prefix}boards
921 958
 				SET num_posts = {int:num_posts}
922 959
 				WHERE redirect = {string:redirect}',
@@ -925,6 +962,7 @@  discard block
 block discarded – undo
925 962
 					'redirect' => '',
926 963
 				)
927 964
 			);
965
+		}
928 966
 
929 967
 		while ($_REQUEST['start'] < $max_topics)
930 968
 		{
@@ -941,8 +979,8 @@  discard block
 block discarded – undo
941 979
 					'is_approved' => 1,
942 980
 				)
943 981
 			);
944
-			while ($row = $smcFunc['db_fetch_assoc']($request))
945
-				$smcFunc['db_query']('', '
982
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
983
+							$smcFunc['db_query']('', '
946 984
 					UPDATE {db_prefix}boards
947 985
 					SET num_posts = num_posts + {int:real_num_posts}
948 986
 					WHERE id_board = {int:id_board}',
@@ -951,6 +989,7 @@  discard block
 block discarded – undo
951 989
 						'real_num_posts' => $row['real_num_posts'],
952 990
 					)
953 991
 				);
992
+			}
954 993
 			$smcFunc['db_free_result']($request);
955 994
 
956 995
 			$_REQUEST['start'] += $increment;
@@ -973,14 +1012,15 @@  discard block
 block discarded – undo
973 1012
 	// Update the topic count of each board.
974 1013
 	if ($_REQUEST['step'] <= 2)
975 1014
 	{
976
-		if (empty($_REQUEST['start']))
977
-			$smcFunc['db_query']('', '
1015
+		if (empty($_REQUEST['start'])) {
1016
+					$smcFunc['db_query']('', '
978 1017
 				UPDATE {db_prefix}boards
979 1018
 				SET num_topics = {int:num_topics}',
980 1019
 				array(
981 1020
 					'num_topics' => 0,
982 1021
 				)
983 1022
 			);
1023
+		}
984 1024
 
985 1025
 		while ($_REQUEST['start'] < $max_topics)
986 1026
 		{
@@ -997,8 +1037,8 @@  discard block
 block discarded – undo
997 1037
 					'id_topic_max' => $_REQUEST['start'] + $increment,
998 1038
 				)
999 1039
 			);
1000
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1001
-				$smcFunc['db_query']('', '
1040
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1041
+							$smcFunc['db_query']('', '
1002 1042
 					UPDATE {db_prefix}boards
1003 1043
 					SET num_topics = num_topics + {int:real_num_topics}
1004 1044
 					WHERE id_board = {int:id_board}',
@@ -1007,6 +1047,7 @@  discard block
 block discarded – undo
1007 1047
 						'real_num_topics' => $row['real_num_topics'],
1008 1048
 					)
1009 1049
 				);
1050
+			}
1010 1051
 			$smcFunc['db_free_result']($request);
1011 1052
 
1012 1053
 			$_REQUEST['start'] += $increment;
@@ -1029,14 +1070,15 @@  discard block
 block discarded – undo
1029 1070
 	// Update the unapproved post count of each board.
1030 1071
 	if ($_REQUEST['step'] <= 3)
1031 1072
 	{
1032
-		if (empty($_REQUEST['start']))
1033
-			$smcFunc['db_query']('', '
1073
+		if (empty($_REQUEST['start'])) {
1074
+					$smcFunc['db_query']('', '
1034 1075
 				UPDATE {db_prefix}boards
1035 1076
 				SET unapproved_posts = {int:unapproved_posts}',
1036 1077
 				array(
1037 1078
 					'unapproved_posts' => 0,
1038 1079
 				)
1039 1080
 			);
1081
+		}
1040 1082
 
1041 1083
 		while ($_REQUEST['start'] < $max_topics)
1042 1084
 		{
@@ -1053,8 +1095,8 @@  discard block
 block discarded – undo
1053 1095
 					'is_approved' => 0,
1054 1096
 				)
1055 1097
 			);
1056
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1057
-				$smcFunc['db_query']('', '
1098
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1099
+							$smcFunc['db_query']('', '
1058 1100
 					UPDATE {db_prefix}boards
1059 1101
 					SET unapproved_posts = unapproved_posts + {int:unapproved_posts}
1060 1102
 					WHERE id_board = {int:id_board}',
@@ -1063,6 +1105,7 @@  discard block
 block discarded – undo
1063 1105
 						'unapproved_posts' => $row['real_unapproved_posts'],
1064 1106
 					)
1065 1107
 				);
1108
+			}
1066 1109
 			$smcFunc['db_free_result']($request);
1067 1110
 
1068 1111
 			$_REQUEST['start'] += $increment;
@@ -1085,14 +1128,15 @@  discard block
 block discarded – undo
1085 1128
 	// Update the unapproved topic count of each board.
1086 1129
 	if ($_REQUEST['step'] <= 4)
1087 1130
 	{
1088
-		if (empty($_REQUEST['start']))
1089
-			$smcFunc['db_query']('', '
1131
+		if (empty($_REQUEST['start'])) {
1132
+					$smcFunc['db_query']('', '
1090 1133
 				UPDATE {db_prefix}boards
1091 1134
 				SET unapproved_topics = {int:unapproved_topics}',
1092 1135
 				array(
1093 1136
 					'unapproved_topics' => 0,
1094 1137
 				)
1095 1138
 			);
1139
+		}
1096 1140
 
1097 1141
 		while ($_REQUEST['start'] < $max_topics)
1098 1142
 		{
@@ -1109,8 +1153,8 @@  discard block
 block discarded – undo
1109 1153
 					'id_topic_max' => $_REQUEST['start'] + $increment,
1110 1154
 				)
1111 1155
 			);
1112
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1113
-				$smcFunc['db_query']('', '
1156
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1157
+							$smcFunc['db_query']('', '
1114 1158
 					UPDATE {db_prefix}boards
1115 1159
 					SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics}
1116 1160
 					WHERE id_board = {int:id_board}',
@@ -1119,6 +1163,7 @@  discard block
 block discarded – undo
1119 1163
 						'real_unapproved_topics' => $row['real_unapproved_topics'],
1120 1164
 					)
1121 1165
 				);
1166
+			}
1122 1167
 			$smcFunc['db_free_result']($request);
1123 1168
 
1124 1169
 			$_REQUEST['start'] += $increment;
@@ -1152,8 +1197,9 @@  discard block
 block discarded – undo
1152 1197
 				'is_not_deleted' => 0,
1153 1198
 			)
1154 1199
 		);
1155
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1156
-			updateMemberData($row['id_member'], array('instant_messages' => $row['real_num']));
1200
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1201
+					updateMemberData($row['id_member'], array('instant_messages' => $row['real_num']));
1202
+		}
1157 1203
 		$smcFunc['db_free_result']($request);
1158 1204
 
1159 1205
 		$request = $smcFunc['db_query']('', '
@@ -1168,8 +1214,9 @@  discard block
 block discarded – undo
1168 1214
 				'is_not_read' => 0,
1169 1215
 			)
1170 1216
 		);
1171
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1172
-			updateMemberData($row['id_member'], array('unread_messages' => $row['real_num']));
1217
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1218
+					updateMemberData($row['id_member'], array('unread_messages' => $row['real_num']));
1219
+		}
1173 1220
 		$smcFunc['db_free_result']($request);
1174 1221
 
1175 1222
 		if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
@@ -1201,12 +1248,13 @@  discard block
 block discarded – undo
1201 1248
 				)
1202 1249
 			);
1203 1250
 			$boards = array();
1204
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1205
-				$boards[$row['id_board']][] = $row['id_msg'];
1251
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1252
+							$boards[$row['id_board']][] = $row['id_msg'];
1253
+			}
1206 1254
 			$smcFunc['db_free_result']($request);
1207 1255
 
1208
-			foreach ($boards as $board_id => $messages)
1209
-				$smcFunc['db_query']('', '
1256
+			foreach ($boards as $board_id => $messages) {
1257
+							$smcFunc['db_query']('', '
1210 1258
 					UPDATE {db_prefix}messages
1211 1259
 					SET id_board = {int:id_board}
1212 1260
 					WHERE id_msg IN ({array_int:id_msg_array})',
@@ -1215,6 +1263,7 @@  discard block
 block discarded – undo
1215 1263
 						'id_board' => $board_id,
1216 1264
 					)
1217 1265
 				);
1266
+			}
1218 1267
 
1219 1268
 			$_REQUEST['start'] += $increment;
1220 1269
 
@@ -1244,8 +1293,9 @@  discard block
 block discarded – undo
1244 1293
 		)
1245 1294
 	);
1246 1295
 	$realBoardCounts = array();
1247
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1248
-		$realBoardCounts[$row['id_board']] = $row['local_last_msg'];
1296
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1297
+			$realBoardCounts[$row['id_board']] = $row['local_last_msg'];
1298
+	}
1249 1299
 	$smcFunc['db_free_result']($request);
1250 1300
 
1251 1301
 	$request = $smcFunc['db_query']('', '
@@ -1265,18 +1315,20 @@  discard block
 block discarded – undo
1265 1315
 	krsort($resort_me);
1266 1316
 
1267 1317
 	$lastModifiedMsg = array();
1268
-	foreach ($resort_me as $rows)
1269
-		foreach ($rows as $row)
1318
+	foreach ($resort_me as $rows) {
1319
+			foreach ($rows as $row)
1270 1320
 		{
1271 1321
 			// The latest message is the latest of the current board and its children.
1272 1322
 			if (isset($lastModifiedMsg[$row['id_board']]))
1273 1323
 				$curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]);
1274
-			else
1275
-				$curLastModifiedMsg = $row['local_last_msg'];
1324
+	}
1325
+			else {
1326
+							$curLastModifiedMsg = $row['local_last_msg'];
1327
+			}
1276 1328
 
1277 1329
 			// If what is and what should be the latest message differ, an update is necessary.
1278
-			if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated'])
1279
-				$smcFunc['db_query']('', '
1330
+			if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) {
1331
+							$smcFunc['db_query']('', '
1280 1332
 					UPDATE {db_prefix}boards
1281 1333
 					SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated}
1282 1334
 					WHERE id_board = {int:id_board}',
@@ -1286,12 +1338,14 @@  discard block
 block discarded – undo
1286 1338
 						'id_board' => $row['id_board'],
1287 1339
 					)
1288 1340
 				);
1341
+			}
1289 1342
 
1290 1343
 			// Parent boards inherit the latest modified message of their children.
1291
-			if (isset($lastModifiedMsg[$row['id_parent']]))
1292
-				$lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]);
1293
-			else
1294
-				$lastModifiedMsg[$row['id_parent']] = $row['local_last_msg'];
1344
+			if (isset($lastModifiedMsg[$row['id_parent']])) {
1345
+							$lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]);
1346
+			} else {
1347
+							$lastModifiedMsg[$row['id_parent']] = $row['local_last_msg'];
1348
+			}
1295 1349
 		}
1296 1350
 
1297 1351
 	// Update all the basic statistics.
@@ -1363,8 +1417,9 @@  discard block
 block discarded – undo
1363 1417
 	require_once($sourcedir . '/Subs-Auth.php');
1364 1418
 	$members = findMembers($_POST['to']);
1365 1419
 
1366
-	if (empty($members))
1367
-		fatal_lang_error('reattribute_cannot_find_member');
1420
+	if (empty($members)) {
1421
+			fatal_lang_error('reattribute_cannot_find_member');
1422
+	}
1368 1423
 
1369 1424
 	$memID = array_shift($members);
1370 1425
 	$memID = $memID['id'];
@@ -1394,8 +1449,9 @@  discard block
 block discarded – undo
1394 1449
 		validateToken('admin-maint');
1395 1450
 
1396 1451
 		$groups = array();
1397
-		foreach ($_POST['groups'] as $id => $dummy)
1398
-			$groups[] = (int) $id;
1452
+		foreach ($_POST['groups'] as $id => $dummy) {
1453
+					$groups[] = (int) $id;
1454
+		}
1399 1455
 		$time_limit = (time() - ($_POST['maxdays'] * 24 * 3600));
1400 1456
 		$where_vars = array(
1401 1457
 			'time_limit' => $time_limit,
@@ -1404,9 +1460,9 @@  discard block
 block discarded – undo
1404 1460
 		{
1405 1461
 			$where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}';
1406 1462
 			$where_vars['is_activated'] = 0;
1463
+		} else {
1464
+					$where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})';
1407 1465
 		}
1408
-		else
1409
-			$where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})';
1410 1466
 
1411 1467
 		// Need to get *all* groups then work out which (if any) we avoid.
1412 1468
 		$request = $smcFunc['db_query']('', '
@@ -1425,8 +1481,7 @@  discard block
 block discarded – undo
1425 1481
 				{
1426 1482
 					$where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}';
1427 1483
 					$where_vars['id_post_group_' . $row['id_group']] = $row['id_group'];
1428
-				}
1429
-				else
1484
+				} else
1430 1485
 				{
1431 1486
 					$where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0';
1432 1487
 					$where_vars['id_group_' . $row['id_group']] = $row['id_group'];
@@ -1453,8 +1508,9 @@  discard block
 block discarded – undo
1453 1508
 		$members = array();
1454 1509
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1455 1510
 		{
1456
-			if (!$row['is_mod'] || !in_array(3, $groups))
1457
-				$members[] = $row['id_member'];
1511
+			if (!$row['is_mod'] || !in_array(3, $groups)) {
1512
+							$members[] = $row['id_member'];
1513
+			}
1458 1514
 		}
1459 1515
 		$smcFunc['db_free_result']($request);
1460 1516
 
@@ -1501,8 +1557,9 @@  discard block
 block discarded – undo
1501 1557
 		)
1502 1558
 	);
1503 1559
 
1504
-	while ($row = $smcFunc['db_fetch_row']($request))
1505
-		$drafts[] = (int) $row[0];
1560
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1561
+			$drafts[] = (int) $row[0];
1562
+	}
1506 1563
 	$smcFunc['db_free_result']($request);
1507 1564
 
1508 1565
 	// If we have old drafts, remove them
@@ -1545,8 +1602,9 @@  discard block
 block discarded – undo
1545 1602
 	$sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']);
1546 1603
 
1547 1604
 	// No boards then this is your stop.
1548
-	if (empty($id_board_from) || empty($id_board_to))
1549
-		return;
1605
+	if (empty($id_board_from) || empty($id_board_to)) {
1606
+			return;
1607
+	}
1550 1608
 
1551 1609
 	// The big WHERE clause
1552 1610
 	$conditions = 'WHERE t.id_board = {int:id_board_from}
@@ -1594,18 +1652,20 @@  discard block
 block discarded – undo
1594 1652
 		);
1595 1653
 		list ($total_topics) = $smcFunc['db_fetch_row']($request);
1596 1654
 		$smcFunc['db_free_result']($request);
1655
+	} else {
1656
+			$total_topics = (int) $_REQUEST['totaltopics'];
1597 1657
 	}
1598
-	else
1599
-		$total_topics = (int) $_REQUEST['totaltopics'];
1600 1658
 
1601 1659
 	// Seems like we need this here.
1602 1660
 	$context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days;
1603 1661
 
1604
-	if ($locked)
1605
-		$context['continue_get_data'] .= ';locked';
1662
+	if ($locked) {
1663
+			$context['continue_get_data'] .= ';locked';
1664
+	}
1606 1665
 
1607
-	if ($sticky)
1608
-		$context['continue_get_data'] .= ';sticky';
1666
+	if ($sticky) {
1667
+			$context['continue_get_data'] .= ';sticky';
1668
+	}
1609 1669
 
1610 1670
 	$context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1611 1671
 
@@ -1626,8 +1686,9 @@  discard block
 block discarded – undo
1626 1686
 
1627 1687
 			// Get the ids.
1628 1688
 			$topics = array();
1629
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1630
-				$topics[] = $row['id_topic'];
1689
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1690
+							$topics[] = $row['id_topic'];
1691
+			}
1631 1692
 
1632 1693
 			// Just return if we don't have any topics left to move.
1633 1694
 			if (empty($topics))
@@ -1718,9 +1779,9 @@  discard block
 block discarded – undo
1718 1779
 		// save it so we don't do this again for this task
1719 1780
 		list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request);
1720 1781
 		$smcFunc['db_free_result']($request);
1782
+	} else {
1783
+			validateToken('admin-recountposts');
1721 1784
 	}
1722
-	else
1723
-		validateToken('admin-recountposts');
1724 1785
 
1725 1786
 	// Lets get a group of members and determine their post count (from the boards that have post count enabled of course).
1726 1787
 	$request = $smcFunc['db_query']('', '
@@ -1766,8 +1827,9 @@  discard block
 block discarded – undo
1766 1827
 		createToken('admin-recountposts');
1767 1828
 		$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">';
1768 1829
 
1769
-		if (function_exists('apache_reset_timeout'))
1770
-			apache_reset_timeout();
1830
+		if (function_exists('apache_reset_timeout')) {
1831
+					apache_reset_timeout();
1832
+		}
1771 1833
 		return;
1772 1834
 	}
1773 1835
 
@@ -1853,10 +1915,9 @@  discard block
 block discarded – undo
1853 1915
 		checkSession('request');
1854 1916
 		validateToken('admin-hook', 'request');
1855 1917
 
1856
-		if ($_REQUEST['do'] == 'remove')
1857
-			remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function']));
1858
-
1859
-		else
1918
+		if ($_REQUEST['do'] == 'remove') {
1919
+					remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function']));
1920
+		} else
1860 1921
 		{
1861 1922
 			$function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!');
1862 1923
 			$function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : '');
@@ -1906,11 +1967,11 @@  discard block
 block discarded – undo
1906 1967
 						// Show a nice icon to indicate this is an instance.
1907 1968
 						$instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : '');
1908 1969
 
1909
-						if (!empty($data['included_file']))
1910
-							return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file'];
1911
-
1912
-						else
1913
-							return $instance . $data['real_function'];
1970
+						if (!empty($data['included_file'])) {
1971
+													return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file'];
1972
+						} else {
1973
+													return $instance . $data['real_function'];
1974
+						}
1914 1975
 					},
1915 1976
 				),
1916 1977
 				'sort' =>  array(
@@ -1975,11 +2036,12 @@  discard block
 block discarded – undo
1975 2036
 		'data' => array(
1976 2037
 			'function' => function($data) use ($txt, $scripturl, $context)
1977 2038
 			{
1978
-				if (!$data['hook_exists'])
1979
-					return '
2039
+				if (!$data['hook_exists']) {
2040
+									return '
1980 2041
 					<a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure">
1981 2042
 						<span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span>
1982 2043
 					</a>';
2044
+				}
1983 2045
 			},
1984 2046
 			'class' => 'centertext',
1985 2047
 		),
@@ -2014,10 +2076,11 @@  discard block
 block discarded – undo
2014 2076
 		{
2015 2077
 			if ($file != '.' && $file != '..')
2016 2078
 			{
2017
-				if (is_dir($dir_path . '/' . $file))
2018
-					$files = array_merge($files, get_files_recursive($dir_path . '/' . $file));
2019
-				else
2020
-					$files[] = array('dir' => $dir_path, 'name' => $file);
2079
+				if (is_dir($dir_path . '/' . $file)) {
2080
+									$files = array_merge($files, get_files_recursive($dir_path . '/' . $file));
2081
+				} else {
2082
+									$files[] = array('dir' => $dir_path, 'name' => $file);
2083
+				}
2021 2084
 			}
2022 2085
 		}
2023 2086
 	}
@@ -2066,16 +2129,16 @@  discard block
 block discarded – undo
2066 2129
 							// I need to know if there is at least one function called in this file.
2067 2130
 							$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2068 2131
 							unset($temp_hooks[$hook][$rawFunc]);
2069
-						}
2070
-						elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false)
2132
+						} elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false)
2071 2133
 						{
2072 2134
 							$hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData;
2073 2135
 							$hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true;
2074 2136
 							$hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : ''));
2075 2137
 
2076 2138
 							// Does the hook has its own file?
2077
-							if (!empty($hookParsedData['hookFile']))
2078
-								$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2139
+							if (!empty($hookParsedData['hookFile'])) {
2140
+															$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2141
+							}
2079 2142
 
2080 2143
 							// I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too)
2081 2144
 							$temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled'];
@@ -2102,15 +2165,17 @@  discard block
 block discarded – undo
2102 2165
 	$sort = array();
2103 2166
 	$hooks_filters = array();
2104 2167
 
2105
-	foreach ($hooks as $hook => $functions)
2106
-		$hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>';
2168
+	foreach ($hooks as $hook => $functions) {
2169
+			$hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>';
2170
+	}
2107 2171
 
2108
-	if (!empty($hooks_filters))
2109
-		$context['insert_after_template'] .= '
2172
+	if (!empty($hooks_filters)) {
2173
+			$context['insert_after_template'] .= '
2110 2174
 		<script>
2111 2175
 			var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\');
2112 2176
 			hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . ';
2113 2177
 		</script>';
2178
+	}
2114 2179
 
2115 2180
 	$temp_data = array();
2116 2181
 	$id = 0;
@@ -2152,10 +2217,11 @@  discard block
 block discarded – undo
2152 2217
 
2153 2218
 	foreach ($temp_data as $data)
2154 2219
 	{
2155
-		if (++$counter < $start)
2156
-			continue;
2157
-		elseif ($counter == $start + $per_page)
2158
-			break;
2220
+		if (++$counter < $start) {
2221
+					continue;
2222
+		} elseif ($counter == $start + $per_page) {
2223
+					break;
2224
+		}
2159 2225
 
2160 2226
 		$hooks_data[] = $data;
2161 2227
 	}
@@ -2177,13 +2243,15 @@  discard block
 block discarded – undo
2177 2243
 	$hooks_count = 0;
2178 2244
 
2179 2245
 	$context['filter'] = false;
2180
-	if (isset($_GET['filter']))
2181
-		$context['filter'] = $_GET['filter'];
2246
+	if (isset($_GET['filter'])) {
2247
+			$context['filter'] = $_GET['filter'];
2248
+	}
2182 2249
 
2183 2250
 	foreach ($hooks as $hook => $functions)
2184 2251
 	{
2185
-		if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook))
2186
-			$hooks_count += count($functions);
2252
+		if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) {
2253
+					$hooks_count += count($functions);
2254
+		}
2187 2255
 	}
2188 2256
 
2189 2257
 	return $hooks_count;
@@ -2204,8 +2272,9 @@  discard block
 block discarded – undo
2204 2272
 		$integration_hooks = array();
2205 2273
 		foreach ($modSettings as $key => $value)
2206 2274
 		{
2207
-			if (!empty($value) && substr($key, 0, 10) === 'integrate_')
2208
-				$integration_hooks[$key] = explode(',', $value);
2275
+			if (!empty($value) && substr($key, 0, 10) === 'integrate_') {
2276
+							$integration_hooks[$key] = explode(',', $value);
2277
+			}
2209 2278
 		}
2210 2279
 	}
2211 2280
 
@@ -2236,8 +2305,9 @@  discard block
 block discarded – undo
2236 2305
 	);
2237 2306
 
2238 2307
 	// Meh...
2239
-	if (empty($rawData))
2240
-		return $hookData;
2308
+	if (empty($rawData)) {
2309
+			return $hookData;
2310
+	}
2241 2311
 
2242 2312
 	// For convenience purposes only!
2243 2313
 	$modFunc = $rawData;
@@ -2248,11 +2318,11 @@  discard block
 block discarded – undo
2248 2318
 		list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc);
2249 2319
 
2250 2320
 		// Does the file exists? who knows!
2251
-		if (empty($settings['theme_dir']))
2252
-			$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
2253
-
2254
-		else
2255
-			$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2321
+		if (empty($settings['theme_dir'])) {
2322
+					$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
2323
+		} else {
2324
+					$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2325
+		}
2256 2326
 
2257 2327
 		$hookData['fileExists'] = file_exists($hookData['absPath']);
2258 2328
 		$hookData['hookFile'] = basename($hookData['hookFile']);
@@ -2277,11 +2347,10 @@  discard block
 block discarded – undo
2277 2347
 	{
2278 2348
 		list ($hookData['class'], $hookData['method']) = explode('::', $modFunc);
2279 2349
 		$hookData['pureFunc'] = $hookData['method'];
2350
+	} else {
2351
+			$hookData['pureFunc'] = $modFunc;
2280 2352
 	}
2281 2353
 
2282
-	else
2283
-		$hookData['pureFunc'] = $modFunc;
2284
-
2285 2354
 	return $hookData;
2286 2355
 }
2287 2356
 
Please login to merge, or discard this patch.
Sources/ScheduledTasks.php 1 patch
Braces   +282 added lines, -205 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * This function works out what to do!
@@ -24,9 +25,9 @@  discard block
 block discarded – undo
24 25
 	global $time_start, $smcFunc, $modSettings;
25 26
 
26 27
 	// Special case for doing the mail queue.
27
-	if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq')
28
-		ReduceMailQueue();
29
-	else
28
+	if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') {
29
+			ReduceMailQueue();
30
+	} else
30 31
 	{
31 32
 		$task_string = '';
32 33
 
@@ -53,18 +54,20 @@  discard block
 block discarded – undo
53 54
 
54 55
 			// How long in seconds it the gap?
55 56
 			$duration = $row['time_regularity'];
56
-			if ($row['time_unit'] == 'm')
57
-				$duration *= 60;
58
-			elseif ($row['time_unit'] == 'h')
59
-				$duration *= 3600;
60
-			elseif ($row['time_unit'] == 'd')
61
-				$duration *= 86400;
62
-			elseif ($row['time_unit'] == 'w')
63
-				$duration *= 604800;
57
+			if ($row['time_unit'] == 'm') {
58
+							$duration *= 60;
59
+			} elseif ($row['time_unit'] == 'h') {
60
+							$duration *= 3600;
61
+			} elseif ($row['time_unit'] == 'd') {
62
+							$duration *= 86400;
63
+			} elseif ($row['time_unit'] == 'w') {
64
+							$duration *= 604800;
65
+			}
64 66
 
65 67
 			// If we were really late running this task actually skip the next one.
66
-			if (time() + ($duration / 2) > $next_time)
67
-				$next_time += $duration;
68
+			if (time() + ($duration / 2) > $next_time) {
69
+							$next_time += $duration;
70
+			}
68 71
 
69 72
 			// Update it now, so no others run this!
70 73
 			$smcFunc['db_query']('', '
@@ -81,16 +84,19 @@  discard block
 block discarded – undo
81 84
 			$affected_rows = $smcFunc['db_affected_rows']();
82 85
 
83 86
 			// What kind of task are we handling?
84
-			if (!empty($row['callable']))
85
-				$task_string = $row['callable'];
87
+			if (!empty($row['callable'])) {
88
+							$task_string = $row['callable'];
89
+			}
86 90
 
87 91
 			// Default SMF task or old mods?
88
-			elseif (function_exists('scheduled_' . $row['task']))
89
-				$task_string = 'scheduled_' . $row['task'];
92
+			elseif (function_exists('scheduled_' . $row['task'])) {
93
+							$task_string = 'scheduled_' . $row['task'];
94
+			}
90 95
 
91 96
 			// One last resource, the task name.
92
-			elseif (!empty($row['task']))
93
-				$task_string = $row['task'];
97
+			elseif (!empty($row['task'])) {
98
+							$task_string = $row['task'];
99
+			}
94 100
 
95 101
 			// The function must exist or we are wasting our time, plus do some timestamp checking, and database check!
96 102
 			if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows)
@@ -101,11 +107,11 @@  discard block
 block discarded – undo
101 107
 				$callable_task = call_helper($task_string, true);
102 108
 
103 109
 				// Perform the task.
104
-				if (!empty($callable_task))
105
-					$completed = call_user_func($callable_task);
106
-
107
-				else
108
-					$completed = false;
110
+				if (!empty($callable_task)) {
111
+									$completed = call_user_func($callable_task);
112
+				} else {
113
+									$completed = false;
114
+				}
109 115
 
110 116
 				// Log that we did it ;)
111 117
 				if ($completed)
@@ -138,18 +144,20 @@  discard block
 block discarded – undo
138 144
 			)
139 145
 		);
140 146
 		// No new task scheduled yet?
141
-		if ($smcFunc['db_num_rows']($request) === 0)
142
-			$nextEvent = time() + 86400;
143
-		else
144
-			list ($nextEvent) = $smcFunc['db_fetch_row']($request);
147
+		if ($smcFunc['db_num_rows']($request) === 0) {
148
+					$nextEvent = time() + 86400;
149
+		} else {
150
+					list ($nextEvent) = $smcFunc['db_fetch_row']($request);
151
+		}
145 152
 		$smcFunc['db_free_result']($request);
146 153
 
147 154
 		updateSettings(array('next_task_time' => $nextEvent));
148 155
 	}
149 156
 
150 157
 	// Shall we return?
151
-	if (!isset($_GET['scheduled']))
152
-		return true;
158
+	if (!isset($_GET['scheduled'])) {
159
+			return true;
160
+	}
153 161
 
154 162
 	// Finally, send some stuff...
155 163
 	header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -181,16 +189,18 @@  discard block
 block discarded – undo
181 189
 	while ($row = $smcFunc['db_fetch_assoc']($request))
182 190
 	{
183 191
 		// If this is no longer around we'll ignore it.
184
-		if (empty($row['id_topic']))
185
-			continue;
192
+		if (empty($row['id_topic'])) {
193
+					continue;
194
+		}
186 195
 
187 196
 		// What type is it?
188
-		if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg'])
189
-			$type = 'topic';
190
-		elseif ($row['id_attach'])
191
-			$type = 'attach';
192
-		else
193
-			$type = 'msg';
197
+		if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) {
198
+					$type = 'topic';
199
+		} elseif ($row['id_attach']) {
200
+					$type = 'attach';
201
+		} else {
202
+					$type = 'msg';
203
+		}
194 204
 
195 205
 		// Add it to the array otherwise.
196 206
 		$notices[$row['id_board']][$type][] = array(
@@ -211,8 +221,9 @@  discard block
 block discarded – undo
211 221
 	);
212 222
 
213 223
 	// If nothing quit now.
214
-	if (empty($notices))
215
-		return true;
224
+	if (empty($notices)) {
225
+			return true;
226
+	}
216 227
 
217 228
 	// Now we need to think about finding out *who* can approve - this is hard!
218 229
 
@@ -231,14 +242,16 @@  discard block
 block discarded – undo
231 242
 	while ($row = $smcFunc['db_fetch_assoc']($request))
232 243
 	{
233 244
 		// Sorry guys, but we have to ignore guests AND members - it would be too many otherwise.
234
-		if ($row['id_group'] < 2)
235
-			continue;
245
+		if ($row['id_group'] < 2) {
246
+					continue;
247
+		}
236 248
 
237 249
 		$perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group'];
238 250
 
239 251
 		// Anyone who can access has to be considered.
240
-		if ($row['add_deny'])
241
-			$addGroups[] = $row['id_group'];
252
+		if ($row['add_deny']) {
253
+					$addGroups[] = $row['id_group'];
254
+		}
242 255
 	}
243 256
 	$smcFunc['db_free_result']($request);
244 257
 
@@ -283,8 +296,9 @@  discard block
 block discarded – undo
283 296
 		if (!empty($row['mod_prefs']))
284 297
 		{
285 298
 			list(,, $pref_binary) = explode('|', $row['mod_prefs']);
286
-			if (!($pref_binary & 4))
287
-				continue;
299
+			if (!($pref_binary & 4)) {
300
+							continue;
301
+			}
288 302
 		}
289 303
 
290 304
 		$members[$row['id_member']] = array(
@@ -309,8 +323,9 @@  discard block
 block discarded – undo
309 323
 		$emailbody = '';
310 324
 
311 325
 		// Load the language file as required.
312
-		if (empty($current_language) || $current_language != $member['language'])
313
-			$current_language = loadLanguage('EmailTemplates', $member['language'], false);
326
+		if (empty($current_language) || $current_language != $member['language']) {
327
+					$current_language = loadLanguage('EmailTemplates', $member['language'], false);
328
+		}
314 329
 
315 330
 		// Loop through each notice...
316 331
 		foreach ($notices as $board => $notice)
@@ -318,29 +333,34 @@  discard block
 block discarded – undo
318 333
 			$access = false;
319 334
 
320 335
 			// Can they mod in this board?
321
-			if (isset($mods[$id][$board]))
322
-				$access = true;
336
+			if (isset($mods[$id][$board])) {
337
+							$access = true;
338
+			}
323 339
 
324 340
 			// Do the group check...
325 341
 			if (!$access && isset($perms[$profiles[$board]]['add']))
326 342
 			{
327 343
 				// They can access?!
328
-				if (array_intersect($perms[$profiles[$board]]['add'], $member['groups']))
329
-					$access = true;
344
+				if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) {
345
+									$access = true;
346
+				}
330 347
 
331 348
 				// If they have deny rights don't consider them!
332
-				if (isset($perms[$profiles[$board]]['deny']))
333
-					if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups']))
349
+				if (isset($perms[$profiles[$board]]['deny'])) {
350
+									if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups']))
334 351
 						$access = false;
352
+				}
335 353
 			}
336 354
 
337 355
 			// Finally, fix it for admins!
338
-			if (in_array(1, $member['groups']))
339
-				$access = true;
356
+			if (in_array(1, $member['groups'])) {
357
+							$access = true;
358
+			}
340 359
 
341 360
 			// If they can't access it then give it a break!
342
-			if (!$access)
343
-				continue;
361
+			if (!$access) {
362
+							continue;
363
+			}
344 364
 
345 365
 			foreach ($notice as $type => $items)
346 366
 			{
@@ -348,15 +368,17 @@  discard block
 block discarded – undo
348 368
 				$emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" .
349 369
 					'------------------------------------------------------' . "\n";
350 370
 
351
-				foreach ($items as $item)
352
-					$emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n";
371
+				foreach ($items as $item) {
372
+									$emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n";
373
+				}
353 374
 
354 375
 				$emailbody .= "\n";
355 376
 			}
356 377
 		}
357 378
 
358
-		if ($emailbody == '')
359
-			continue;
379
+		if ($emailbody == '') {
380
+					continue;
381
+		}
360 382
 
361 383
 		$replacements = array(
362 384
 			'REALNAME' => $member['name'],
@@ -397,8 +419,9 @@  discard block
 block discarded – undo
397 419
 			)
398 420
 		);
399 421
 		$members = array();
400
-		while ($row = $smcFunc['db_fetch_assoc']($request))
401
-			$members[$row['id_member']] = $row['warning'];
422
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
423
+					$members[$row['id_member']] = $row['warning'];
424
+		}
402 425
 		$smcFunc['db_free_result']($request);
403 426
 
404 427
 		// Have some members to check?
@@ -420,17 +443,18 @@  discard block
 block discarded – undo
420 443
 			while ($row = $smcFunc['db_fetch_assoc']($request))
421 444
 			{
422 445
 				// More than 24 hours ago?
423
-				if ($row['last_warning'] <= time() - 86400)
424
-					$member_changes[] = array(
446
+				if ($row['last_warning'] <= time() - 86400) {
447
+									$member_changes[] = array(
425 448
 						'id' => $row['id_recipient'],
426 449
 						'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0,
427 450
 					);
451
+				}
428 452
 			}
429 453
 			$smcFunc['db_free_result']($request);
430 454
 
431 455
 			// Have some members to change?
432
-			if (!empty($member_changes))
433
-				foreach ($member_changes as $change)
456
+			if (!empty($member_changes)) {
457
+							foreach ($member_changes as $change)
434 458
 					$smcFunc['db_query']('', '
435 459
 						UPDATE {db_prefix}members
436 460
 						SET warning = {int:warning}
@@ -440,6 +464,7 @@  discard block
 block discarded – undo
440 464
 							'id_member' => $change['id'],
441 465
 						)
442 466
 					);
467
+			}
443 468
 		}
444 469
 	}
445 470
 
@@ -452,16 +477,17 @@  discard block
 block discarded – undo
452 477
 
453 478
 	// Check the database version - for some buggy MySQL version.
454 479
 	$server_version = $smcFunc['db_server_info']();
455
-	if (($db_type == 'mysql') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
456
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
457
-	elseif (!empty($modSettings['db_mysql_group_by_fix']))
458
-		$smcFunc['db_query']('', '
480
+	if (($db_type == 'mysql') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
481
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
482
+	} elseif (!empty($modSettings['db_mysql_group_by_fix'])) {
483
+			$smcFunc['db_query']('', '
459 484
 			DELETE FROM {db_prefix}settings
460 485
 			WHERE variable = {string:mysql_fix}',
461 486
 			array(
462 487
 				'mysql_fix' => 'db_mysql_group_by_fix',
463 488
 			)
464 489
 		);
490
+	}
465 491
 
466 492
 	// Clean up some old login history information.
467 493
 	$smcFunc['db_query']('', '
@@ -519,15 +545,17 @@  discard block
 block discarded – undo
519 545
 
520 546
 		// Store this useful data!
521 547
 		$boards[$row['id_board']] = $row['id_board'];
522
-		if ($row['id_topic'])
523
-			$notify['topics'][$row['id_topic']][] = $row['id_member'];
524
-		else
525
-			$notify['boards'][$row['id_board']][] = $row['id_member'];
548
+		if ($row['id_topic']) {
549
+					$notify['topics'][$row['id_topic']][] = $row['id_member'];
550
+		} else {
551
+					$notify['boards'][$row['id_board']][] = $row['id_member'];
552
+		}
526 553
 	}
527 554
 	$smcFunc['db_free_result']($request);
528 555
 
529
-	if (empty($boards))
530
-		return true;
556
+	if (empty($boards)) {
557
+			return true;
558
+	}
531 559
 
532 560
 	// Just get the board names.
533 561
 	$request = $smcFunc['db_query']('', '
@@ -539,12 +567,14 @@  discard block
 block discarded – undo
539 567
 		)
540 568
 	);
541 569
 	$boards = array();
542
-	while ($row = $smcFunc['db_fetch_assoc']($request))
543
-		$boards[$row['id_board']] = $row['name'];
570
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
571
+			$boards[$row['id_board']] = $row['name'];
572
+	}
544 573
 	$smcFunc['db_free_result']($request);
545 574
 
546
-	if (empty($boards))
547
-		return true;
575
+	if (empty($boards)) {
576
+			return true;
577
+	}
548 578
 
549 579
 	// Get the actual topics...
550 580
 	$request = $smcFunc['db_query']('', '
@@ -564,52 +594,57 @@  discard block
 block discarded – undo
564 594
 	$types = array();
565 595
 	while ($row = $smcFunc['db_fetch_assoc']($request))
566 596
 	{
567
-		if (!isset($types[$row['note_type']][$row['id_board']]))
568
-			$types[$row['note_type']][$row['id_board']] = array(
597
+		if (!isset($types[$row['note_type']][$row['id_board']])) {
598
+					$types[$row['note_type']][$row['id_board']] = array(
569 599
 				'lines' => array(),
570 600
 				'name' => $row['board_name'],
571 601
 				'id' => $row['id_board'],
572 602
 			);
603
+		}
573 604
 
574 605
 		if ($row['note_type'] == 'reply')
575 606
 		{
576
-			if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
577
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
578
-			else
579
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
607
+			if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
608
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
609
+			} else {
610
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
580 611
 					'id' => $row['id_topic'],
581 612
 					'subject' => un_htmlspecialchars($row['subject']),
582 613
 					'count' => 1,
583 614
 				);
584
-		}
585
-		elseif ($row['note_type'] == 'topic')
615
+			}
616
+		} elseif ($row['note_type'] == 'topic')
586 617
 		{
587
-			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
588
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
618
+			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
619
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
589 620
 					'id' => $row['id_topic'],
590 621
 					'subject' => un_htmlspecialchars($row['subject']),
591 622
 				);
592
-		}
593
-		else
623
+			}
624
+		} else
594 625
 		{
595
-			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
596
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
626
+			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
627
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
597 628
 					'id' => $row['id_topic'],
598 629
 					'subject' => un_htmlspecialchars($row['subject']),
599 630
 					'starter' => $row['id_member_started'],
600 631
 				);
632
+			}
601 633
 		}
602 634
 
603 635
 		$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array();
604
-		if (!empty($notify['topics'][$row['id_topic']]))
605
-			$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]);
606
-		if (!empty($notify['boards'][$row['id_board']]))
607
-			$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]);
636
+		if (!empty($notify['topics'][$row['id_topic']])) {
637
+					$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]);
638
+		}
639
+		if (!empty($notify['boards'][$row['id_board']])) {
640
+					$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]);
641
+		}
608 642
 	}
609 643
 	$smcFunc['db_free_result']($request);
610 644
 
611
-	if (empty($types))
612
-		return true;
645
+	if (empty($types)) {
646
+			return true;
647
+	}
613 648
 
614 649
 	// Let's load all the languages into a cache thingy.
615 650
 	$langtxt = array();
@@ -650,8 +685,9 @@  discard block
 block discarded – undo
650 685
 		$notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1;
651 686
 
652 687
 		// Did they not elect to choose this?
653
-		if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4)
654
-			continue;
688
+		if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) {
689
+					continue;
690
+		}
655 691
 
656 692
 		// Right character set!
657 693
 		$context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set'];
@@ -667,39 +703,43 @@  discard block
 block discarded – undo
667 703
 		if (isset($types['topic']))
668 704
 		{
669 705
 			$titled = false;
670
-			foreach ($types['topic'] as $id => $board)
671
-				foreach ($board['lines'] as $topic)
706
+			foreach ($types['topic'] as $id => $board) {
707
+							foreach ($board['lines'] as $topic)
672 708
 					if (in_array($mid, $topic['members']))
673 709
 					{
674 710
 						if (!$titled)
675 711
 						{
676 712
 							$email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------';
713
+			}
677 714
 							$titled = true;
678 715
 						}
679 716
 						$email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']);
680 717
 					}
681
-			if ($titled)
682
-				$email['body'] .= "\n";
718
+			if ($titled) {
719
+							$email['body'] .= "\n";
720
+			}
683 721
 		}
684 722
 
685 723
 		// What about replies?
686 724
 		if (isset($types['reply']))
687 725
 		{
688 726
 			$titled = false;
689
-			foreach ($types['reply'] as $id => $board)
690
-				foreach ($board['lines'] as $topic)
727
+			foreach ($types['reply'] as $id => $board) {
728
+							foreach ($board['lines'] as $topic)
691 729
 					if (in_array($mid, $topic['members']))
692 730
 					{
693 731
 						if (!$titled)
694 732
 						{
695 733
 							$email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------';
734
+			}
696 735
 							$titled = true;
697 736
 						}
698 737
 						$email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject']));
699 738
 					}
700 739
 
701
-			if ($titled)
702
-				$email['body'] .= "\n";
740
+			if ($titled) {
741
+							$email['body'] .= "\n";
742
+			}
703 743
 		}
704 744
 
705 745
 		// Finally, moderation actions!
@@ -708,24 +748,27 @@  discard block
 block discarded – undo
708 748
 			$titled = false;
709 749
 			foreach ($types as $note_type => $type)
710 750
 			{
711
-				if ($note_type == 'topic' || $note_type == 'reply')
712
-					continue;
751
+				if ($note_type == 'topic' || $note_type == 'reply') {
752
+									continue;
753
+				}
713 754
 
714
-				foreach ($type as $id => $board)
715
-					foreach ($board['lines'] as $topic)
755
+				foreach ($type as $id => $board) {
756
+									foreach ($board['lines'] as $topic)
716 757
 						if (in_array($mid, $topic['members']))
717 758
 						{
718 759
 							if (!$titled)
719 760
 							{
720 761
 								$email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------';
762
+				}
721 763
 								$titled = true;
722 764
 							}
723 765
 							$email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']);
724 766
 						}
725 767
 			}
726 768
 		}
727
-		if ($titled)
728
-			$email['body'] .= "\n";
769
+		if ($titled) {
770
+					$email['body'] .= "\n";
771
+		}
729 772
 
730 773
 		// Then just say our goodbyes!
731 774
 		$email['body'] .= "\n\n" . $txt['regards_team'];
@@ -753,8 +796,7 @@  discard block
 block discarded – undo
753 796
 				'not_daily' => 0,
754 797
 			)
755 798
 		);
756
-	}
757
-	else
799
+	} else
758 800
 	{
759 801
 		// Clear any only weekly ones, and stop us from sending daily again.
760 802
 		$smcFunc['db_query']('', '
@@ -816,16 +858,19 @@  discard block
 block discarded – undo
816 858
 	global $modSettings, $smcFunc, $sourcedir;
817 859
 
818 860
 	// Are we intending another script to be sending out the queue?
819
-	if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send))
820
-		return false;
861
+	if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) {
862
+			return false;
863
+	}
821 864
 
822 865
 	// By default send 5 at once.
823
-	if (!$number)
824
-		$number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
866
+	if (!$number) {
867
+			$number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
868
+	}
825 869
 
826 870
 	// If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us.
827
-	if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send))
828
-		return false;
871
+	if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) {
872
+			return false;
873
+	}
829 874
 
830 875
 	// By default move the next sending on by 10 seconds, and require an affected row.
831 876
 	if (!$override_limit)
@@ -842,8 +887,9 @@  discard block
 block discarded – undo
842 887
 				'last_send' => $modSettings['mail_next_send'],
843 888
 			)
844 889
 		);
845
-		if ($smcFunc['db_affected_rows']() == 0)
846
-			return false;
890
+		if ($smcFunc['db_affected_rows']() == 0) {
891
+					return false;
892
+		}
847 893
 		$modSettings['mail_next_send'] = time() + $delay;
848 894
 	}
849 895
 
@@ -864,8 +910,9 @@  discard block
 block discarded – undo
864 910
 			$mn += $number;
865 911
 		}
866 912
 		// No more I'm afraid, return!
867
-		else
868
-			return false;
913
+		else {
914
+					return false;
915
+		}
869 916
 
870 917
 		// Reflect that we're about to send some, do it now to be safe.
871 918
 		updateSettings(array('mail_recent' => $mt . '|' . $mn));
@@ -900,14 +947,15 @@  discard block
 block discarded – undo
900 947
 	$smcFunc['db_free_result']($request);
901 948
 
902 949
 	// Delete, delete, delete!!!
903
-	if (!empty($ids))
904
-		$smcFunc['db_query']('', '
950
+	if (!empty($ids)) {
951
+			$smcFunc['db_query']('', '
905 952
 			DELETE FROM {db_prefix}mail_queue
906 953
 			WHERE id_mail IN ({array_int:mail_list})',
907 954
 			array(
908 955
 				'mail_list' => $ids,
909 956
 			)
910 957
 		);
958
+	}
911 959
 
912 960
 	// Don't believe we have any left?
913 961
 	if (count($ids) < $number)
@@ -925,11 +973,13 @@  discard block
 block discarded – undo
925 973
 		);
926 974
 	}
927 975
 
928
-	if (empty($ids))
929
-		return false;
976
+	if (empty($ids)) {
977
+			return false;
978
+	}
930 979
 
931
-	if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '')
932
-		require_once($sourcedir . '/Subs-Post.php');
980
+	if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') {
981
+			require_once($sourcedir . '/Subs-Post.php');
982
+	}
933 983
 
934 984
 	// Send each email, yea!
935 985
 	$failed_emails = array();
@@ -949,15 +999,17 @@  discard block
 block discarded – undo
949 999
 
950 1000
 			// Try to stop a timeout, this would be bad...
951 1001
 			@set_time_limit(300);
952
-			if (function_exists('apache_reset_timeout'))
953
-				@apache_reset_timeout();
1002
+			if (function_exists('apache_reset_timeout')) {
1003
+							@apache_reset_timeout();
1004
+			}
1005
+		} else {
1006
+					$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']);
954 1007
 		}
955
-		else
956
-			$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']);
957 1008
 
958 1009
 		// Hopefully it sent?
959
-		if (!$result)
960
-			$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
1010
+		if (!$result) {
1011
+					$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
1012
+		}
961 1013
 	}
962 1014
 
963 1015
 	// Any emails that didn't send?
@@ -972,8 +1024,8 @@  discard block
 block discarded – undo
972 1024
 		);
973 1025
 
974 1026
 		// If we have failed to many times, tell mail to wait a bit and try again.
975
-		if ($modSettings['mail_failed_attempts'] > 5)
976
-			$smcFunc['db_query']('', '
1027
+		if ($modSettings['mail_failed_attempts'] > 5) {
1028
+					$smcFunc['db_query']('', '
977 1029
 				UPDATE {db_prefix}settings
978 1030
 				SET value = {string:next_mail_send}
979 1031
 				WHERE variable = {literal:mail_next_send}
@@ -982,6 +1034,7 @@  discard block
 block discarded – undo
982 1034
 					'next_mail_send' => time() + 60,
983 1035
 					'last_send' => $modSettings['mail_next_send'],
984 1036
 			));
1037
+		}
985 1038
 
986 1039
 		// Add our email back to the queue, manually.
987 1040
 		$smcFunc['db_insert']('insert',
@@ -994,8 +1047,8 @@  discard block
 block discarded – undo
994 1047
 		return false;
995 1048
 	}
996 1049
 	// We where unable to send the email, clear our failed attempts.
997
-	elseif (!empty($modSettings['mail_failed_attempts']))
998
-		$smcFunc['db_query']('', '
1050
+	elseif (!empty($modSettings['mail_failed_attempts'])) {
1051
+			$smcFunc['db_query']('', '
999 1052
 			UPDATE {db_prefix}settings
1000 1053
 			SET value = {string:zero}
1001 1054
 			WHERE variable = {string:mail_failed_attempts}',
@@ -1003,6 +1056,7 @@  discard block
 block discarded – undo
1003 1056
 				'zero' => '0',
1004 1057
 				'mail_failed_attempts' => 'mail_failed_attempts',
1005 1058
 		));
1059
+	}
1006 1060
 
1007 1061
 	// Had something to send...
1008 1062
 	return true;
@@ -1019,16 +1073,18 @@  discard block
 block discarded – undo
1019 1073
 	global $modSettings, $smcFunc;
1020 1074
 
1021 1075
 	$task_query = '';
1022
-	if (!is_array($tasks))
1023
-		$tasks = array($tasks);
1076
+	if (!is_array($tasks)) {
1077
+			$tasks = array($tasks);
1078
+	}
1024 1079
 
1025 1080
 	// Actually have something passed?
1026 1081
 	if (!empty($tasks))
1027 1082
 	{
1028
-		if (!isset($tasks[0]) || is_numeric($tasks[0]))
1029
-			$task_query = ' AND id_task IN ({array_int:tasks})';
1030
-		else
1031
-			$task_query = ' AND task IN ({array_string:tasks})';
1083
+		if (!isset($tasks[0]) || is_numeric($tasks[0])) {
1084
+					$task_query = ' AND id_task IN ({array_int:tasks})';
1085
+		} else {
1086
+					$task_query = ' AND task IN ({array_string:tasks})';
1087
+		}
1032 1088
 	}
1033 1089
 	$nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time'];
1034 1090
 
@@ -1049,20 +1105,22 @@  discard block
 block discarded – undo
1049 1105
 		$next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']);
1050 1106
 
1051 1107
 		// Only bother moving the task if it's out of place or we're forcing it!
1052
-		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time())
1053
-			$tasks[$row['id_task']] = $next_time;
1054
-		else
1055
-			$next_time = $row['next_time'];
1108
+		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) {
1109
+					$tasks[$row['id_task']] = $next_time;
1110
+		} else {
1111
+					$next_time = $row['next_time'];
1112
+		}
1056 1113
 
1057 1114
 		// If this is sooner than the current next task, make this the next task.
1058
-		if ($next_time < $nextTaskTime)
1059
-			$nextTaskTime = $next_time;
1115
+		if ($next_time < $nextTaskTime) {
1116
+					$nextTaskTime = $next_time;
1117
+		}
1060 1118
 	}
1061 1119
 	$smcFunc['db_free_result']($request);
1062 1120
 
1063 1121
 	// Now make the changes!
1064
-	foreach ($tasks as $id => $time)
1065
-		$smcFunc['db_query']('', '
1122
+	foreach ($tasks as $id => $time) {
1123
+			$smcFunc['db_query']('', '
1066 1124
 			UPDATE {db_prefix}scheduled_tasks
1067 1125
 			SET next_time = {int:next_time}
1068 1126
 			WHERE id_task = {int:id_task}',
@@ -1071,11 +1129,13 @@  discard block
 block discarded – undo
1071 1129
 				'id_task' => $id,
1072 1130
 			)
1073 1131
 		);
1132
+	}
1074 1133
 
1075 1134
 	// If the next task is now different update.
1076
-	if ($modSettings['next_task_time'] != $nextTaskTime)
1077
-		updateSettings(array('next_task_time' => $nextTaskTime));
1078
-}
1135
+	if ($modSettings['next_task_time'] != $nextTaskTime) {
1136
+			updateSettings(array('next_task_time' => $nextTaskTime));
1137
+	}
1138
+	}
1079 1139
 
1080 1140
 /**
1081 1141
  * Simply returns a time stamp of the next instance of these time parameters.
@@ -1088,8 +1148,9 @@  discard block
 block discarded – undo
1088 1148
 function next_time($regularity, $unit, $offset)
1089 1149
 {
1090 1150
 	// Just in case!
1091
-	if ($regularity == 0)
1092
-		$regularity = 2;
1151
+	if ($regularity == 0) {
1152
+			$regularity = 2;
1153
+	}
1093 1154
 
1094 1155
 	$curMin = date('i', time());
1095 1156
 
@@ -1099,15 +1160,16 @@  discard block
 block discarded – undo
1099 1160
 		$off = date('i', $offset);
1100 1161
 
1101 1162
 		// If it's now just pretend it ain't,
1102
-		if ($off == $curMin)
1103
-			$next_time = time() + $regularity;
1104
-		else
1163
+		if ($off == $curMin) {
1164
+					$next_time = time() + $regularity;
1165
+		} else
1105 1166
 		{
1106 1167
 			// Make sure that the offset is always in the past.
1107 1168
 			$off = $off > $curMin ? $off - 60 : $off;
1108 1169
 
1109
-			while ($off <= $curMin)
1110
-				$off += $regularity;
1170
+			while ($off <= $curMin) {
1171
+							$off += $regularity;
1172
+			}
1111 1173
 
1112 1174
 			// Now we know when the time should be!
1113 1175
 			$next_time = time() + 60 * ($off - $curMin);
@@ -1127,11 +1189,13 @@  discard block
 block discarded – undo
1127 1189
 		// Default we'll jump in hours.
1128 1190
 		$applyOffset = 3600;
1129 1191
 		// 24 hours = 1 day.
1130
-		if ($unit == 'd')
1131
-			$applyOffset = 86400;
1192
+		if ($unit == 'd') {
1193
+					$applyOffset = 86400;
1194
+		}
1132 1195
 		// Otherwise a week.
1133
-		if ($unit == 'w')
1134
-			$applyOffset = 604800;
1196
+		if ($unit == 'w') {
1197
+					$applyOffset = 604800;
1198
+		}
1135 1199
 
1136 1200
 		$applyOffset *= $regularity;
1137 1201
 
@@ -1168,8 +1232,9 @@  discard block
 block discarded – undo
1168 1232
 		$settings[$row['variable']] = $row['value'];
1169 1233
 
1170 1234
 		// Is this the default theme?
1171
-		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1')
1172
-			$settings['default_' . $row['variable']] = $row['value'];
1235
+		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') {
1236
+					$settings['default_' . $row['variable']] = $row['value'];
1237
+		}
1173 1238
 	}
1174 1239
 	$smcFunc['db_free_result']($result);
1175 1240
 
@@ -1179,12 +1244,14 @@  discard block
 block discarded – undo
1179 1244
 		$settings['template_dirs'] = array($settings['theme_dir']);
1180 1245
 
1181 1246
 		// Based on theme (if there is one).
1182
-		if (!empty($settings['base_theme_dir']))
1183
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1247
+		if (!empty($settings['base_theme_dir'])) {
1248
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1249
+		}
1184 1250
 
1185 1251
 		// Lastly the default theme.
1186
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1187
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1252
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1253
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1254
+		}
1188 1255
 	}
1189 1256
 
1190 1257
 	// Assume we want this.
@@ -1330,8 +1397,9 @@  discard block
 block discarded – undo
1330 1397
 	// Ok should we prune the logs?
1331 1398
 	if (!empty($modSettings['pruningOptions']))
1332 1399
 	{
1333
-		if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false)
1334
-			list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
1400
+		if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) {
1401
+					list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
1402
+		}
1335 1403
 
1336 1404
 		if (!empty($modSettings['pruneErrorLog']))
1337 1405
 		{
@@ -1397,8 +1465,9 @@  discard block
 block discarded – undo
1397 1465
 				)
1398 1466
 			);
1399 1467
 
1400
-			while ($row = $smcFunc['db_fetch_row']($result))
1401
-				$reports[] = $row[0];
1468
+			while ($row = $smcFunc['db_fetch_row']($result)) {
1469
+							$reports[] = $row[0];
1470
+			}
1402 1471
 
1403 1472
 			$smcFunc['db_free_result']($result);
1404 1473
 
@@ -1560,8 +1629,9 @@  discard block
 block discarded – undo
1560 1629
 		$emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
1561 1630
 
1562 1631
 		// Send the actual email.
1563
-		if ($notifyPrefs[$row['id_member']] & 0x02)
1564
-			sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
1632
+		if ($notifyPrefs[$row['id_member']] & 0x02) {
1633
+					sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
1634
+		}
1565 1635
 
1566 1636
 		if ($notifyPrefs[$row['id_member']] & 0x01)
1567 1637
 		{
@@ -1584,18 +1654,19 @@  discard block
 block discarded – undo
1584 1654
 	}
1585 1655
 
1586 1656
 	// Insert the alerts if any
1587
-	if (!empty($alert_rows))
1588
-		$smcFunc['db_insert']('',
1657
+	if (!empty($alert_rows)) {
1658
+			$smcFunc['db_insert']('',
1589 1659
 			'{db_prefix}user_alerts',
1590 1660
 			array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
1591 1661
 				'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
1592 1662
 			$alert_rows,
1593 1663
 			array()
1594 1664
 		);
1665
+	}
1595 1666
 
1596 1667
 	// Mark the reminder as sent.
1597
-	if (!empty($subs_reminded))
1598
-		$smcFunc['db_query']('', '
1668
+	if (!empty($subs_reminded)) {
1669
+			$smcFunc['db_query']('', '
1599 1670
 			UPDATE {db_prefix}log_subscribed
1600 1671
 			SET reminder_sent = {int:reminder_sent}
1601 1672
 			WHERE id_sublog IN ({array_int:subscription_list})',
@@ -1604,6 +1675,7 @@  discard block
 block discarded – undo
1604 1675
 				'reminder_sent' => 1,
1605 1676
 			)
1606 1677
 		);
1678
+	}
1607 1679
 
1608 1680
 	return true;
1609 1681
 }
@@ -1619,13 +1691,13 @@  discard block
 block discarded – undo
1619 1691
 	// We need to know where this thing is going.
1620 1692
 	if (!empty($modSettings['currentAttachmentUploadDir']))
1621 1693
 	{
1622
-		if (!is_array($modSettings['attachmentUploadDir']))
1623
-			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
1694
+		if (!is_array($modSettings['attachmentUploadDir'])) {
1695
+					$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
1696
+		}
1624 1697
 
1625 1698
 		// Just use the current path for temp files.
1626 1699
 		$attach_dirs = $modSettings['attachmentUploadDir'];
1627
-	}
1628
-	else
1700
+	} else
1629 1701
 	{
1630 1702
 		$attach_dirs = array($modSettings['attachmentUploadDir']);
1631 1703
 	}
@@ -1644,14 +1716,16 @@  discard block
 block discarded – undo
1644 1716
 
1645 1717
 		while ($file = readdir($dir))
1646 1718
 		{
1647
-			if ($file == '.' || $file == '..')
1648
-				continue;
1719
+			if ($file == '.' || $file == '..') {
1720
+							continue;
1721
+			}
1649 1722
 
1650 1723
 			if (strpos($file, 'post_tmp_') !== false)
1651 1724
 			{
1652 1725
 				// Temp file is more than 5 hours old!
1653
-				if (filemtime($attach_dir . '/' . $file) < time() - 18000)
1654
-					@unlink($attach_dir . '/' . $file);
1726
+				if (filemtime($attach_dir . '/' . $file) < time() - 18000) {
1727
+									@unlink($attach_dir . '/' . $file);
1728
+				}
1655 1729
 			}
1656 1730
 		}
1657 1731
 		closedir($dir);
@@ -1684,8 +1758,9 @@  discard block
 block discarded – undo
1684 1758
 		)
1685 1759
 	);
1686 1760
 
1687
-	while ($row = $smcFunc['db_fetch_row']($request))
1688
-		$topics[] = $row[0];
1761
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1762
+			$topics[] = $row[0];
1763
+	}
1689 1764
 	$smcFunc['db_free_result']($request);
1690 1765
 
1691 1766
 	// Zap, your gone
@@ -1705,8 +1780,9 @@  discard block
 block discarded – undo
1705 1780
 {
1706 1781
 	global $smcFunc, $sourcedir, $modSettings;
1707 1782
 
1708
-	if (empty($modSettings['drafts_keep_days']))
1709
-		return true;
1783
+	if (empty($modSettings['drafts_keep_days'])) {
1784
+			return true;
1785
+	}
1710 1786
 
1711 1787
 	// init
1712 1788
 	$drafts = array();
@@ -1724,8 +1800,9 @@  discard block
 block discarded – undo
1724 1800
 		)
1725 1801
 	);
1726 1802
 
1727
-	while ($row = $smcFunc['db_fetch_row']($request))
1728
-		$drafts[] = (int) $row[0];
1803
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1804
+			$drafts[] = (int) $row[0];
1805
+	}
1729 1806
 	$smcFunc['db_free_result']($request);
1730 1807
 
1731 1808
 	// If we have old one, remove them
Please login to merge, or discard this patch.
Sources/ReCaptcha/RequestMethod/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/minify/path-converter/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/minify/path-converter/src/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Themes.template.php 1 patch
Braces   +108 added lines, -82 removed lines patch added patch discarded remove patch
@@ -54,9 +54,10 @@  discard block
 block discarded – undo
54 54
 					<dd>
55 55
 						<div id="known_themes_list">';
56 56
 
57
-	foreach ($context['themes'] as $theme)
58
-		echo '
57
+	foreach ($context['themes'] as $theme) {
58
+			echo '
59 59
 							<label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', ' class="input_check"> ', $theme['name'], '</label><br>';
60
+	}
60 61
 
61 62
 		echo '
62 63
 						</div>
@@ -73,9 +74,10 @@  discard block
 block discarded – undo
73 74
 						<select name="options[theme_guests]" id="theme_guests">';
74 75
 
75 76
 	// Put an option for each theme in the select box.
76
-	foreach ($context['themes'] as $theme)
77
-		echo '
77
+	foreach ($context['themes'] as $theme) {
78
+			echo '
78 79
 							<option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
80
+	}
79 81
 
80 82
 	echo '
81 83
 						</select>
@@ -90,9 +92,10 @@  discard block
 block discarded – undo
90 92
 							<option value="0">', $txt['theme_forum_default'], '</option>';
91 93
 
92 94
 	// Same thing, this time for changing the theme of everyone.
93
-	foreach ($context['themes'] as $theme)
94
-		echo '
95
+	foreach ($context['themes'] as $theme) {
96
+			echo '
95 97
 							<option value="', $theme['id'], '">', $theme['name'], '</option>';
98
+	}
96 99
 
97 100
 	echo '
98 101
 						</select>
@@ -189,11 +192,12 @@  discard block
 block discarded – undo
189 192
 	global $context, $scripturl, $txt;
190 193
 
191 194
 	// Show a nice confirmation message.
192
-	if (isset($_GET['done']))
193
-		echo '
195
+	if (isset($_GET['done'])) {
196
+			echo '
194 197
 	<div class="infobox">
195 198
 		', $txt['theme_confirmed_' . $_GET['done']], '
196 199
 	</div>';
200
+	}
197 201
 
198 202
 	echo '
199 203
 	<div id="admincenter">';
@@ -353,22 +357,24 @@  discard block
 block discarded – undo
353 357
 					<dt ', $context['theme_options_reset'] ? 'style="width:50%"' : '', '>';
354 358
 
355 359
 		// Show the change option box ?
356
-		if ($context['theme_options_reset'])
357
-			echo '
360
+		if ($context['theme_options_reset']) {
361
+					echo '
358 362
 						<span class="floatleft"><select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;">
359 363
 							<option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option>
360 364
 							<option value="1">', $txt['themeadmin_reset_options_change'], '</option>
361 365
 							<option value="2">', $txt['themeadmin_reset_options_default'], '</option>
362 366
 						</select>&nbsp;</span>';
367
+		}
363 368
 
364 369
 		// display checkbox options
365 370
 		if ($setting['type'] == 'checkbox')
366 371
 		{
367 372
 			echo '
368 373
 						<label for="options_', $setting['id'], '">', $setting['label'], '</label>';
369
-			if (isset($setting['description']))
370
-				echo '
374
+			if (isset($setting['description'])) {
375
+							echo '
371 376
 						<br><span class="smalltext">', $setting['description'], '</span>';
377
+			}
372 378
 		echo '
373 379
 					</dt>
374 380
 					<dd ', $context['theme_options_reset'] ? 'style="width:40%"' : '', '>
@@ -380,9 +386,10 @@  discard block
 block discarded – undo
380 386
 		{
381 387
 			echo '
382 388
 						<label for="options_', $setting['id'], '">', $setting['label'], '</label>';
383
-			if (isset($setting['description']))
384
-				echo '
389
+			if (isset($setting['description'])) {
390
+							echo '
385 391
 						<br><span class="smalltext">', $setting['description'], '</span>';
392
+			}
386 393
 		echo '
387 394
 					</dt>
388 395
 					<dd ', $context['theme_options_reset'] ? 'style="width:40%"' : '', '>
@@ -402,9 +409,10 @@  discard block
 block discarded – undo
402 409
 		{
403 410
 			echo '
404 411
 						<label for="options_', $setting['id'], '">', $setting['label'], '</label>';
405
-			if (isset($setting['description']))
406
-				echo '
412
+			if (isset($setting['description'])) {
413
+							echo '
407 414
 						<br><span class="smalltext">', $setting['description'], '</span>';
415
+			}
408 416
 		echo '
409 417
 					</dt>
410 418
 					<dd ', $context['theme_options_reset'] ? 'style="width:40%"' : '', '>';
@@ -417,13 +425,11 @@  discard block
 block discarded – undo
417 425
 
418 426
 				echo '
419 427
 						<input type="number"', $min . $max . $step;
420
-			}
421
-			else if (isset($setting['type']) && $setting['type'] == 'url')
428
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
422 429
 			{
423 430
 			echo'
424 431
 			<input type="url"';
425
-			}
426
-			else
432
+			} else
427 433
 			{
428 434
 				echo '
429 435
 						<input type="text"';
@@ -467,8 +473,8 @@  discard block
 block discarded – undo
467 473
 			<br>';
468 474
 
469 475
 	// @todo Why can't I edit the default theme popup.
470
-	if ($context['theme_settings']['theme_id'] != 1)
471
-		echo '
476
+	if ($context['theme_settings']['theme_id'] != 1) {
477
+			echo '
472 478
 			<div class="cat_bar">
473 479
 				<h3 class="catbg config_hd">
474 480
 					', $txt['theme_edit'], '
@@ -484,6 +490,7 @@  discard block
 block discarded – undo
484 490
 					</li>
485 491
 				</ul>
486 492
 			</div>';
493
+	}
487 494
 
488 495
 	echo '
489 496
 			<div class="cat_bar">
@@ -537,9 +544,10 @@  discard block
 block discarded – undo
537 544
 					<dd>
538 545
 						<select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">';
539 546
 
540
-		foreach ($context['theme_variants'] as $key => $variant)
541
-			echo '
547
+		foreach ($context['theme_variants'] as $key => $variant) {
548
+					echo '
542 549
 							<option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
550
+		}
543 551
 
544 552
 		echo '
545 553
 						</select>
@@ -582,9 +590,10 @@  discard block
 block discarded – undo
582 590
 					<dt>
583 591
 						<label for="', $setting['id'], '">', $setting['label'], '</label>:';
584 592
 
585
-			if (isset($setting['description']))
586
-				echo '<br>
593
+			if (isset($setting['description'])) {
594
+							echo '<br>
587 595
 						<span class="smalltext">', $setting['description'], '</span>';
596
+			}
588 597
 
589 598
 			echo '
590 599
 					</dt>
@@ -600,18 +609,20 @@  discard block
 block discarded – undo
600 609
 					<dt>
601 610
 						<label for="', $setting['id'], '">', $setting['label'], '</label>:';
602 611
 
603
-			if (isset($setting['description']))
604
-				echo '<br>
612
+			if (isset($setting['description'])) {
613
+							echo '<br>
605 614
 						<span class="smalltext">', $setting['description'], '</span>';
615
+			}
606 616
 
607 617
 			echo '
608 618
 					</dt>
609 619
 					<dd>
610 620
 						<select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">';
611 621
 
612
-			foreach ($setting['options'] as $value => $label)
613
-				echo '
622
+			foreach ($setting['options'] as $value => $label) {
623
+							echo '
614 624
 							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
625
+			}
615 626
 
616 627
 			echo '
617 628
 						</select>
@@ -624,9 +635,10 @@  discard block
 block discarded – undo
624 635
 					<dt>
625 636
 						<label for="', $setting['id'], '">', $setting['label'], '</label>:';
626 637
 
627
-			if (isset($setting['description']))
628
-				echo '<br>
638
+			if (isset($setting['description'])) {
639
+							echo '<br>
629 640
 						<span class="smalltext">', $setting['description'], '</span>';
641
+			}
630 642
 			echo '
631 643
 					</dt>
632 644
 					<dd>
@@ -641,9 +653,10 @@  discard block
 block discarded – undo
641 653
 					<dt>
642 654
 						<label for="', $setting['id'], '">', $setting['label'], '</label>:';
643 655
 
644
-			if (isset($setting['description']))
645
-				echo '<br>
656
+			if (isset($setting['description'])) {
657
+							echo '<br>
646 658
 						<span class="smalltext">', $setting['description'], '</span>';
659
+			}
647 660
 
648 661
 			echo '
649 662
 					</dt>
@@ -657,13 +670,11 @@  discard block
 block discarded – undo
657 670
 
658 671
 				echo '
659 672
 						<input type="number"', $min . $max . $step;
660
-			}
661
-			else if (isset($setting['type']) && $setting['type'] == 'url')
673
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
662 674
 			{
663 675
 			echo'
664 676
 			<input type="url"';
665
-			}
666
-			else
677
+			} else
667 678
 			{
668 679
 				echo '
669 680
 						<input type="text"';
@@ -816,21 +827,23 @@  discard block
 block discarded – undo
816 827
 		<div class="windowbg">';
817 828
 
818 829
 	// Oops! there was an error :(
819
-	if (!empty($context['error_message']))
820
-		echo '
830
+	if (!empty($context['error_message'])) {
831
+			echo '
821 832
 			<p>
822 833
 				', $context['error_message'], '
823 834
 			</p>';
835
+	}
824 836
 
825 837
 	// Not much to show except a link back...
826
-	else
827
-		echo '
838
+	else {
839
+			echo '
828 840
 			<p>
829 841
 				<a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], '
830 842
 			</p>
831 843
 			<p>
832 844
 				<a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a>
833 845
 			</p>';
846
+	}
834 847
 
835 848
 	echo '
836 849
 		</div>
@@ -897,10 +910,11 @@  discard block
 block discarded – undo
897 910
 					<span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span>
898 911
 					<span class="floatright">';
899 912
 
900
-		if ($template['can_copy'])
901
-			echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
902
-		else
903
-			echo $txt['themeadmin_edit_no_copy'];
913
+		if ($template['can_copy']) {
914
+					echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
915
+		} else {
916
+					echo $txt['themeadmin_edit_no_copy'];
917
+		}
904 918
 
905 919
 		echo '
906 920
 					</span>
@@ -923,11 +937,12 @@  discard block
 block discarded – undo
923 937
 	echo '
924 938
 	<div id="admincenter">';
925 939
 
926
-	if (!empty($context['browse_title']))
927
-		echo '
940
+	if (!empty($context['browse_title'])) {
941
+			echo '
928 942
 		<div class="cat_bar">
929 943
 			<h3 class="catbg">', $context['browse_title'], '</h3>
930 944
 		</div>';
945
+	}
931 946
 
932 947
 	echo '
933 948
 		<table class="table_grid tborder">
@@ -947,14 +962,13 @@  discard block
 block discarded – undo
947 962
 			<tr class="windowbg">
948 963
 				<td>';
949 964
 
950
-		if ($file['is_editable'])
951
-			echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
952
-
953
-		elseif ($file['is_directory'])
954
-			echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>';
955
-
956
-		else
957
-			echo $file['filename'];
965
+		if ($file['is_editable']) {
966
+					echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
967
+		} elseif ($file['is_directory']) {
968
+					echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>';
969
+		} else {
970
+					echo $file['filename'];
971
+		}
958 972
 
959 973
 		echo '
960 974
 				</td>
@@ -976,11 +990,12 @@  discard block
 block discarded – undo
976 990
 {
977 991
 	global $context, $settings, $scripturl, $txt;
978 992
 
979
-	if ($context['session_error'])
980
-		echo '
993
+	if ($context['session_error']) {
994
+			echo '
981 995
 	<div class="errorbox">
982 996
 		', $txt['error_session_timeout'], '
983 997
 	</div>';
998
+	}
984 999
 
985 1000
 	// From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com.
986 1001
 	echo '
@@ -1043,17 +1058,18 @@  discard block
 block discarded – undo
1043 1058
 					try
1044 1059
 					{
1045 1060
 					';
1046
-	if (isBrowser('is_ie'))
1047
-		echo '
1061
+	if (isBrowser('is_ie')) {
1062
+			echo '
1048 1063
 						var sheets = frames["css_preview_box"].document.styleSheets;
1049 1064
 						for (var j = 0; j < sheets.length; j++)
1050 1065
 						{
1051 1066
 							if (sheets[j].id == "css_preview_box")
1052 1067
 								sheets[j].cssText = document.forms.stylesheetForm.entire_file.value;
1053 1068
 						}';
1054
-	else
1055
-		echo '
1069
+	} else {
1070
+			echo '
1056 1071
 						setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);';
1072
+	}
1057 1073
 	echo '
1058 1074
 					}
1059 1075
 					catch (e)
@@ -1105,9 +1121,10 @@  discard block
 block discarded – undo
1105 1121
 			</div>
1106 1122
 			<div class="windowbg">';
1107 1123
 
1108
-	if (!$context['allow_save'])
1109
-		echo '
1124
+	if (!$context['allow_save']) {
1125
+			echo '
1110 1126
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1127
+	}
1111 1128
 
1112 1129
 	echo '
1113 1130
 				<textarea name="entire_file" cols="80" rows="20" style="width: 96%; font-family: monospace; margin-top: 1ex; white-space: pre;" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea><br>
@@ -1120,9 +1137,10 @@  discard block
 block discarded – undo
1120 1137
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1121 1138
 
1122 1139
 	// Hopefully it exists.
1123
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1124
-		echo '
1140
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1141
+			echo '
1125 1142
 			<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1143
+	}
1126 1144
 
1127 1145
 	echo '
1128 1146
 		</form>
@@ -1136,18 +1154,20 @@  discard block
 block discarded – undo
1136 1154
 {
1137 1155
 	global $context, $scripturl, $txt;
1138 1156
 
1139
-	if ($context['session_error'])
1140
-		echo '
1157
+	if ($context['session_error']) {
1158
+			echo '
1141 1159
 	<div class="errorbox">
1142 1160
 		', $txt['error_session_timeout'], '
1143 1161
 	</div>';
1162
+	}
1144 1163
 
1145
-	if (isset($context['parse_error']))
1146
-		echo '
1164
+	if (isset($context['parse_error'])) {
1165
+			echo '
1147 1166
 	<div class="errorbox">
1148 1167
 		', $txt['themeadmin_edit_error'], '
1149 1168
 			<div><pre>', $context['parse_error'], '</pre></div>
1150 1169
 	</div>';
1170
+	}
1151 1171
 
1152 1172
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1153 1173
 	echo '
@@ -1158,16 +1178,18 @@  discard block
 block discarded – undo
1158 1178
 			</div>
1159 1179
 			<div class="windowbg">';
1160 1180
 
1161
-	if (!$context['allow_save'])
1162
-		echo '
1181
+	if (!$context['allow_save']) {
1182
+			echo '
1163 1183
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1184
+	}
1164 1185
 
1165
-	foreach ($context['file_parts'] as $part)
1166
-		echo '
1186
+	foreach ($context['file_parts'] as $part) {
1187
+			echo '
1167 1188
 				<label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br>
1168 1189
 				<div class="centertext">
1169 1190
 					<textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea>
1170 1191
 				</div>';
1192
+	}
1171 1193
 
1172 1194
 	echo '
1173 1195
 				<div class="padding righttext">
@@ -1176,9 +1198,10 @@  discard block
 block discarded – undo
1176 1198
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1177 1199
 
1178 1200
 	// Hopefully it exists.
1179
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1180
-		echo '
1201
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1202
+			echo '
1181 1203
 					<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1204
+	}
1182 1205
 
1183 1206
 	echo '
1184 1207
 				</div>
@@ -1194,18 +1217,20 @@  discard block
 block discarded – undo
1194 1217
 {
1195 1218
 	global $context, $scripturl, $txt;
1196 1219
 
1197
-	if ($context['session_error'])
1198
-		echo '
1220
+	if ($context['session_error']) {
1221
+			echo '
1199 1222
 	<div class="errorbox">
1200 1223
 		', $txt['error_session_timeout'], '
1201 1224
 	</div>';
1225
+	}
1202 1226
 
1203 1227
 	//Is this file writeable?
1204
-	if (!$context['allow_save'])
1205
-		echo '
1228
+	if (!$context['allow_save']) {
1229
+			echo '
1206 1230
 	<div class="errorbox">
1207 1231
 		', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '
1208 1232
 	</div>';
1233
+	}
1209 1234
 
1210 1235
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1211 1236
 	echo '
@@ -1221,9 +1246,10 @@  discard block
 block discarded – undo
1221 1246
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1222 1247
 
1223 1248
 	// Hopefully it exists.
1224
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1225
-		echo '
1249
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1250
+			echo '
1226 1251
 				<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1252
+	}
1227 1253
 
1228 1254
 	echo '
1229 1255
 			</div>
Please login to merge, or discard this patch.
other/install.php 1 patch
Braces   +436 added lines, -324 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,12 +64,14 @@  discard block
 block discarded – undo
63 64
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
64 65
 
65 66
 			// Is it reserved?
66
-			if ($value == 'pg_')
67
-				return $txt['error_db_prefix_reserved'];
67
+			if ($value == 'pg_') {
68
+							return $txt['error_db_prefix_reserved'];
69
+			}
68 70
 
69 71
 			// Is the prefix numeric?
70
-			if (preg_match('~^\d~', $value))
71
-				return $txt['error_db_prefix_numeric'];
72
+			if (preg_match('~^\d~', $value)) {
73
+							return $txt['error_db_prefix_numeric'];
74
+			}
72 75
 
73 76
 			return true;
74 77
 		},
@@ -115,10 +118,11 @@  discard block
 block discarded – undo
115 118
 		$incontext['skip'] = false;
116 119
 
117 120
 		// Call the step and if it returns false that means pause!
118
-		if (function_exists($step[2]) && $step[2]() === false)
119
-			break;
120
-		elseif (function_exists($step[2]))
121
-			$incontext['current_step']++;
121
+		if (function_exists($step[2]) && $step[2]() === false) {
122
+					break;
123
+		} elseif (function_exists($step[2])) {
124
+					$incontext['current_step']++;
125
+		}
122 126
 
123 127
 		// No warnings pass on.
124 128
 		$incontext['warning'] = '';
@@ -134,12 +138,14 @@  discard block
 block discarded – undo
134 138
 	global $databases, $incontext;
135 139
 
136 140
 	// Just so people using older versions of PHP aren't left in the cold.
137
-	if (!isset($_SERVER['PHP_SELF']))
138
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
141
+	if (!isset($_SERVER['PHP_SELF'])) {
142
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
143
+	}
139 144
 
140 145
 	// Turn off magic quotes runtime and enable error reporting.
141
-	if (function_exists('set_magic_quotes_runtime'))
142
-		@set_magic_quotes_runtime(0);
146
+	if (function_exists('set_magic_quotes_runtime')) {
147
+			@set_magic_quotes_runtime(0);
148
+	}
143 149
 	error_reporting(E_ALL);
144 150
 
145 151
 	// Fun.  Low PHP version...
@@ -153,21 +159,23 @@  discard block
 block discarded – undo
153 159
 	{
154 160
 		ob_start();
155 161
 
156
-		if (ini_get('session.save_handler') == 'user')
157
-			@ini_set('session.save_handler', 'files');
158
-		if (function_exists('session_start'))
159
-			@session_start();
160
-	}
161
-	else
162
+		if (ini_get('session.save_handler') == 'user') {
163
+					@ini_set('session.save_handler', 'files');
164
+		}
165
+		if (function_exists('session_start')) {
166
+					@session_start();
167
+		}
168
+	} else
162 169
 	{
163 170
 		ob_start('ob_gzhandler');
164 171
 
165
-		if (ini_get('session.save_handler') == 'user')
166
-			@ini_set('session.save_handler', 'files');
172
+		if (ini_get('session.save_handler') == 'user') {
173
+					@ini_set('session.save_handler', 'files');
174
+		}
167 175
 		session_start();
168 176
 
169
-		if (!headers_sent())
170
-			echo '<!DOCTYPE html>
177
+		if (!headers_sent()) {
178
+					echo '<!DOCTYPE html>
171 179
 <html>
172 180
 	<head>
173 181
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -176,6 +184,7 @@  discard block
 block discarded – undo
176 184
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
177 185
 	</body>
178 186
 </html>';
187
+		}
179 188
 		exit;
180 189
 	}
181 190
 
@@ -184,16 +193,18 @@  discard block
 block discarded – undo
184 193
 	{
185 194
 		$incontext['remote_files_available'] = false;
186 195
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
187
-		if ($test)
188
-			$incontext['remote_files_available'] = true;
196
+		if ($test) {
197
+					$incontext['remote_files_available'] = true;
198
+		}
189 199
 		@fclose($test);
190 200
 	}
191 201
 
192 202
 	// Add slashes, as long as they aren't already being added.
193
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
194
-		foreach ($_POST as $k => $v)
203
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
204
+			foreach ($_POST as $k => $v)
195 205
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
196 206
 				$_POST[$k] = addslashes($v);
207
+	}
197 208
 
198 209
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
199 210
 	if (isset($_GET['delete']))
@@ -214,8 +225,7 @@  discard block
 block discarded – undo
214 225
 			$ftp->close();
215 226
 
216 227
 			unset($_SESSION['installer_temp_ftp']);
217
-		}
218
-		else
228
+		} else
219 229
 		{
220 230
 			@unlink(__FILE__);
221 231
 
@@ -236,10 +246,11 @@  discard block
 block discarded – undo
236 246
 	{
237 247
 		// Get PHP's default timezone, if set
238 248
 		$ini_tz = ini_get('date.timezone');
239
-		if (!empty($ini_tz))
240
-			$timezone_id = $ini_tz;
241
-		else
242
-			$timezone_id = '';
249
+		if (!empty($ini_tz)) {
250
+					$timezone_id = $ini_tz;
251
+		} else {
252
+					$timezone_id = '';
253
+		}
243 254
 
244 255
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
245 256
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -269,8 +280,9 @@  discard block
 block discarded – undo
269 280
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
270 281
 		while ($entry = $dir->read())
271 282
 		{
272
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
273
-				$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
+			}
274 286
 		}
275 287
 		$dir->close();
276 288
 	}
@@ -305,10 +317,11 @@  discard block
 block discarded – undo
305 317
 	}
306 318
 
307 319
 	// Override the language file?
308
-	if (isset($_GET['lang_file']))
309
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
310
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
311
-		$_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
+	}
312 325
 
313 326
 	// Make sure it exists, if it doesn't reset it.
314 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']))
@@ -317,8 +330,9 @@  discard block
 block discarded – undo
317 330
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
318 331
 
319 332
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
320
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
321
-			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
+		}
322 336
 	}
323 337
 
324 338
 	// And now include the actual language file itself.
@@ -331,15 +345,18 @@  discard block
 block discarded – undo
331 345
 	global $db_prefix, $db_connection, $sourcedir;
332 346
 	global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist;
333 347
 
334
-	if (empty($sourcedir))
335
-		$sourcedir = dirname(__FILE__) . '/Sources';
348
+	if (empty($sourcedir)) {
349
+			$sourcedir = dirname(__FILE__) . '/Sources';
350
+	}
336 351
 
337 352
 	// Need this to check whether we need the database password.
338 353
 	require(dirname(__FILE__) . '/Settings.php');
339
-	if (!defined('SMF'))
340
-		define('SMF', 1);
341
-	if (empty($smcFunc))
342
-		$smcFunc = array();
354
+	if (!defined('SMF')) {
355
+			define('SMF', 1);
356
+	}
357
+	if (empty($smcFunc)) {
358
+			$smcFunc = array();
359
+	}
343 360
 
344 361
 	$modSettings['disableQueryCheck'] = true;
345 362
 
@@ -347,8 +364,9 @@  discard block
 block discarded – undo
347 364
 	if (!$db_connection)
348 365
 	{
349 366
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
350
-		if (version_compare(PHP_VERSION, '5', '<'))
351
-			require_once($sourcedir . '/Subs-Compat.php');
367
+		if (version_compare(PHP_VERSION, '5', '<')) {
368
+					require_once($sourcedir . '/Subs-Compat.php');
369
+		}
352 370
 
353 371
 		$db_options = array('persist' => $db_persist);
354 372
 		$port = '';
@@ -359,19 +377,20 @@  discard block
 block discarded – undo
359 377
 			if ($db_type == 'mysql')
360 378
 			{
361 379
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
362
-			}
363
-			elseif ($db_type == 'postgresql')
380
+			} elseif ($db_type == 'postgresql')
364 381
 			{
365 382
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
366 383
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
367 384
 			}
368 385
 		}
369 386
 
370
-		if (!empty($port))
371
-			$db_options['port'] = $port;
387
+		if (!empty($port)) {
388
+					$db_options['port'] = $port;
389
+		}
372 390
 
373
-		if (!$db_connection)
374
-			$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
+		}
375 394
 	}
376 395
 }
377 396
 
@@ -399,8 +418,9 @@  discard block
 block discarded – undo
399 418
 		// @todo REMOVE THIS!!
400 419
 		else
401 420
 		{
402
-			if (function_exists('doStep' . $_GET['step']))
403
-				call_user_func('doStep' . $_GET['step']);
421
+			if (function_exists('doStep' . $_GET['step'])) {
422
+							call_user_func('doStep' . $_GET['step']);
423
+			}
404 424
 		}
405 425
 		// Show the footer.
406 426
 		template_install_below();
@@ -418,8 +438,9 @@  discard block
 block discarded – undo
418 438
 	$incontext['sub_template'] = 'welcome_message';
419 439
 
420 440
 	// Done the submission?
421
-	if (isset($_POST['contbutt']))
422
-		return true;
441
+	if (isset($_POST['contbutt'])) {
442
+			return true;
443
+	}
423 444
 
424 445
 	// See if we think they have already installed it?
425 446
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -427,14 +448,17 @@  discard block
 block discarded – undo
427 448
 		$probably_installed = 0;
428 449
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
429 450
 		{
430
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
431
-				$probably_installed++;
432
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
433
-				$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
+			}
434 457
 		}
435 458
 
436
-		if ($probably_installed == 2)
437
-			$incontext['warning'] = $txt['error_already_installed'];
459
+		if ($probably_installed == 2) {
460
+					$incontext['warning'] = $txt['error_already_installed'];
461
+		}
438 462
 	}
439 463
 
440 464
 	// Is some database support even compiled in?
@@ -449,36 +473,43 @@  discard block
 block discarded – undo
449 473
 				$databases[$key]['supported'] = false;
450 474
 				$notFoundSQLFile = true;
451 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;
452 478
 			}
453
-			else
454
-				$incontext['supported_databases'][] = $db;
455 479
 		}
456 480
 	}
457 481
 
458 482
 	// Check the PHP version.
459
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>')))
460
-		$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
+	}
461 486
 	// Make sure we have a supported database
462
-	elseif (empty($incontext['supported_databases']))
463
-		$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
+	}
464 490
 	// How about session support?  Some crazy sysadmin remove it?
465
-	elseif (!function_exists('session_start'))
466
-		$error = 'error_session_missing';
491
+	elseif (!function_exists('session_start')) {
492
+			$error = 'error_session_missing';
493
+	}
467 494
 	// Make sure they uploaded all the files.
468
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
469
-		$error = 'error_missing_files';
495
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
496
+			$error = 'error_missing_files';
497
+	}
470 498
 	// Very simple check on the session.save_path for Windows.
471 499
 	// @todo Move this down later if they don't use database-driven sessions?
472
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
473
-		$error = 'error_session_save_path';
500
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
501
+			$error = 'error_session_save_path';
502
+	}
474 503
 
475 504
 	// Since each of the three messages would look the same, anyway...
476
-	if (isset($error))
477
-		$incontext['error'] = $txt[$error];
505
+	if (isset($error)) {
506
+			$incontext['error'] = $txt[$error];
507
+	}
478 508
 
479 509
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
480
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
481
-		$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
+	}
482 513
 
483 514
 	return false;
484 515
 }
@@ -503,12 +534,14 @@  discard block
 block discarded – undo
503 534
 		'Settings_bak.php',
504 535
 	);
505 536
 
506
-	foreach ($incontext['detected_languages'] as $lang => $temp)
507
-		$extra_files[] = 'Themes/default/languages/' . $lang;
537
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
538
+			$extra_files[] = 'Themes/default/languages/' . $lang;
539
+	}
508 540
 
509 541
 	// With mod_security installed, we could attempt to fix it with .htaccess.
510
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
511
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
542
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
543
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
544
+	}
512 545
 
513 546
 	$failed_files = array();
514 547
 
@@ -524,12 +557,14 @@  discard block
 block discarded – undo
524 557
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
525 558
 
526 559
 				// Well, 755 hopefully worked... if not, try 777.
527
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
528
-					$failed_files[] = $file;
560
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
561
+									$failed_files[] = $file;
562
+				}
529 563
 			}
530 564
 		}
531
-		foreach ($extra_files as $file)
532
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
565
+		foreach ($extra_files as $file) {
566
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
567
+		}
533 568
 	}
534 569
 	// Windows is trickier.  Let's try opening for r+...
535 570
 	else
@@ -539,30 +574,35 @@  discard block
 block discarded – undo
539 574
 		foreach ($writable_files as $file)
540 575
 		{
541 576
 			// Folders can't be opened for write... but the index.php in them can ;)
542
-			if (is_dir(dirname(__FILE__) . '/' . $file))
543
-				$file .= '/index.php';
577
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
578
+							$file .= '/index.php';
579
+			}
544 580
 
545 581
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
546 582
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
547 583
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
548 584
 
549 585
 			// Hmm, okay, try just for write in that case...
550
-			if (!is_resource($fp))
551
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
586
+			if (!is_resource($fp)) {
587
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
588
+			}
552 589
 
553
-			if (!is_resource($fp))
554
-				$failed_files[] = $file;
590
+			if (!is_resource($fp)) {
591
+							$failed_files[] = $file;
592
+			}
555 593
 
556 594
 			@fclose($fp);
557 595
 		}
558
-		foreach ($extra_files as $file)
559
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
596
+		foreach ($extra_files as $file) {
597
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
598
+		}
560 599
 	}
561 600
 
562 601
 	$failure = count($failed_files) >= 1;
563 602
 
564
-	if (!isset($_SERVER))
565
-		return !$failure;
603
+	if (!isset($_SERVER)) {
604
+			return !$failure;
605
+	}
566 606
 
567 607
 	// Put the list into context.
568 608
 	$incontext['failed_files'] = $failed_files;
@@ -610,19 +650,23 @@  discard block
 block discarded – undo
610 650
 
611 651
 		if (!isset($ftp) || $ftp->error !== false)
612 652
 		{
613
-			if (!isset($ftp))
614
-				$ftp = new ftp_connection(null);
653
+			if (!isset($ftp)) {
654
+							$ftp = new ftp_connection(null);
655
+			}
615 656
 			// Save the error so we can mess with listing...
616
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
617
-				$incontext['ftp_errors'][] = $ftp->last_message;
657
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
658
+							$incontext['ftp_errors'][] = $ftp->last_message;
659
+			}
618 660
 
619 661
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
620 662
 
621
-			if (empty($_POST['ftp_path']) && $found_path)
622
-				$_POST['ftp_path'] = $detect_path;
663
+			if (empty($_POST['ftp_path']) && $found_path) {
664
+							$_POST['ftp_path'] = $detect_path;
665
+			}
623 666
 
624
-			if (!isset($_POST['ftp_username']))
625
-				$_POST['ftp_username'] = $username;
667
+			if (!isset($_POST['ftp_username'])) {
668
+							$_POST['ftp_username'] = $username;
669
+			}
626 670
 
627 671
 			// Set the username etc, into context.
628 672
 			$incontext['ftp'] = array(
@@ -634,8 +678,7 @@  discard block
 block discarded – undo
634 678
 			);
635 679
 
636 680
 			return false;
637
-		}
638
-		else
681
+		} else
639 682
 		{
640 683
 			$_SESSION['installer_temp_ftp'] = array(
641 684
 				'server' => $_POST['ftp_server'],
@@ -649,10 +692,12 @@  discard block
 block discarded – undo
649 692
 
650 693
 			foreach ($failed_files as $file)
651 694
 			{
652
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
653
-					$ftp->chmod($file, 0755);
654
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
655
-					$ftp->chmod($file, 0777);
695
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
696
+									$ftp->chmod($file, 0755);
697
+				}
698
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
699
+									$ftp->chmod($file, 0777);
700
+				}
656 701
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
657 702
 				{
658 703
 					$failed_files_updated[] = $file;
@@ -707,15 +752,17 @@  discard block
 block discarded – undo
707 752
 
708 753
 			if (!$foundOne)
709 754
 			{
710
-				if (isset($db['default_host']))
711
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
755
+				if (isset($db['default_host'])) {
756
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
757
+				}
712 758
 				if (isset($db['default_user']))
713 759
 				{
714 760
 					$incontext['db']['user'] = ini_get($db['default_user']);
715 761
 					$incontext['db']['name'] = ini_get($db['default_user']);
716 762
 				}
717
-				if (isset($db['default_password']))
718
-					$incontext['db']['pass'] = ini_get($db['default_password']);
763
+				if (isset($db['default_password'])) {
764
+									$incontext['db']['pass'] = ini_get($db['default_password']);
765
+				}
719 766
 
720 767
 				// For simplicity and less confusion, leave the port blank by default
721 768
 				$incontext['db']['port'] = '';
@@ -734,10 +781,10 @@  discard block
 block discarded – undo
734 781
 		$incontext['db']['server'] = $_POST['db_server'];
735 782
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
736 783
 
737
-		if (!empty($_POST['db_port']))
738
-			$incontext['db']['port'] = $_POST['db_port'];
739
-	}
740
-	else
784
+		if (!empty($_POST['db_port'])) {
785
+					$incontext['db']['port'] = $_POST['db_port'];
786
+		}
787
+	} else
741 788
 	{
742 789
 		$incontext['db']['prefix'] = 'smf_';
743 790
 	}
@@ -773,10 +820,11 @@  discard block
 block discarded – undo
773 820
 		if (!empty($_POST['db_port']))
774 821
 		{
775 822
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
776
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
777
-				$vars['db_port'] = (int) $_POST['db_port'];
778
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
779
-				$vars['db_port'] = (int) $_POST['db_port'];
823
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
824
+							$vars['db_port'] = (int) $_POST['db_port'];
825
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
826
+							$vars['db_port'] = (int) $_POST['db_port'];
827
+			}
780 828
 		}
781 829
 
782 830
 		// God I hope it saved!
@@ -789,8 +837,9 @@  discard block
 block discarded – undo
789 837
 		// Make sure it works.
790 838
 		require(dirname(__FILE__) . '/Settings.php');
791 839
 
792
-		if (empty($sourcedir))
793
-			$sourcedir = dirname(__FILE__) . '/Sources';
840
+		if (empty($sourcedir)) {
841
+					$sourcedir = dirname(__FILE__) . '/Sources';
842
+		}
794 843
 
795 844
 		// Better find the database file!
796 845
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -800,18 +849,21 @@  discard block
 block discarded – undo
800 849
 		}
801 850
 
802 851
 		// Now include it for database functions!
803
-		if (!defined('SMF'))
804
-			define('SMF', 1);
852
+		if (!defined('SMF')) {
853
+					define('SMF', 1);
854
+		}
805 855
 
806 856
 		$modSettings['disableQueryCheck'] = true;
807
-		if (empty($smcFunc))
808
-			$smcFunc = array();
857
+		if (empty($smcFunc)) {
858
+					$smcFunc = array();
859
+		}
809 860
 
810 861
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
811 862
 
812 863
 		// What - running PHP4? The shame!
813
-		if (version_compare(PHP_VERSION, '5', '<'))
814
-			require_once($sourcedir . '/Subs-Compat.php');
864
+		if (version_compare(PHP_VERSION, '5', '<')) {
865
+					require_once($sourcedir . '/Subs-Compat.php');
866
+		}
815 867
 
816 868
 		// Attempt a connection.
817 869
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -899,12 +951,14 @@  discard block
 block discarded – undo
899 951
 	$incontext['page_title'] = $txt['install_settings'];
900 952
 
901 953
 	// Let's see if we got the database type correct.
902
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
903
-		$db_type = $_POST['db_type'];
954
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
955
+			$db_type = $_POST['db_type'];
956
+	}
904 957
 
905 958
 	// Else we'd better be able to get the connection.
906
-	else
907
-		load_database();
959
+	else {
960
+			load_database();
961
+	}
908 962
 
909 963
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
910 964
 
@@ -924,12 +978,14 @@  discard block
 block discarded – undo
924 978
 	// Submitting?
925 979
 	if (isset($_POST['boardurl']))
926 980
 	{
927
-		if (substr($_POST['boardurl'], -10) == '/index.php')
928
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
929
-		elseif (substr($_POST['boardurl'], -1) == '/')
930
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
931
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
932
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
981
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
982
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
983
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
984
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
985
+		}
986
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
987
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
988
+		}
933 989
 
934 990
 		// Save these variables.
935 991
 		$vars = array(
@@ -960,10 +1016,10 @@  discard block
 block discarded – undo
960 1016
 			{
961 1017
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
962 1018
 				return false;
963
-			}
964
-			else
965
-				// Set the character set here.
1019
+			} else {
1020
+							// Set the character set here.
966 1021
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1022
+			}
967 1023
 		}
968 1024
 
969 1025
 		// Good, skip on.
@@ -983,8 +1039,9 @@  discard block
 block discarded – undo
983 1039
 	$incontext['continue'] = 1;
984 1040
 
985 1041
 	// Already done?
986
-	if (isset($_POST['pop_done']))
987
-		return true;
1042
+	if (isset($_POST['pop_done'])) {
1043
+			return true;
1044
+	}
988 1045
 
989 1046
 	// Reload settings.
990 1047
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1002,8 +1059,9 @@  discard block
 block discarded – undo
1002 1059
 	$modSettings = array();
1003 1060
 	if ($result !== false)
1004 1061
 	{
1005
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1006
-			$modSettings[$row['variable']] = $row['value'];
1062
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1063
+					$modSettings[$row['variable']] = $row['value'];
1064
+		}
1007 1065
 		$smcFunc['db_free_result']($result);
1008 1066
 
1009 1067
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1016,20 +1074,22 @@  discard block
 block discarded – undo
1016 1074
 	$modSettings['disableQueryCheck'] = true;
1017 1075
 
1018 1076
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1019
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1020
-		$smcFunc['db_query']('', '
1077
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1078
+			$smcFunc['db_query']('', '
1021 1079
 			SET NAMES {string:utf8}',
1022 1080
 			array(
1023 1081
 				'db_error_skip' => true,
1024 1082
 				'utf8' => 'utf8',
1025 1083
 			)
1026 1084
 		);
1085
+	}
1027 1086
 
1028 1087
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1029
-	if (substr(__DIR__, -1) == '\\')
1030
-		$attachdir = __DIR__ . 'attachments';
1031
-	else
1032
-		$attachdir = __DIR__ . '/attachments';
1088
+	if (substr(__DIR__, -1) == '\\') {
1089
+			$attachdir = __DIR__ . 'attachments';
1090
+	} else {
1091
+			$attachdir = __DIR__ . '/attachments';
1092
+	}
1033 1093
 
1034 1094
 	$replaces = array(
1035 1095
 		'{$db_prefix}' => $db_prefix,
@@ -1046,8 +1106,9 @@  discard block
 block discarded – undo
1046 1106
 
1047 1107
 	foreach ($txt as $key => $value)
1048 1108
 	{
1049
-		if (substr($key, 0, 8) == 'default_')
1050
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1109
+		if (substr($key, 0, 8) == 'default_') {
1110
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1111
+		}
1051 1112
 	}
1052 1113
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1053 1114
 
@@ -1062,8 +1123,9 @@  discard block
 block discarded – undo
1062 1123
 
1063 1124
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1064 1125
 		{
1065
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1066
-				$engines[] = $row['Engine'];
1126
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1127
+							$engines[] = $row['Engine'];
1128
+			}
1067 1129
 		}
1068 1130
 
1069 1131
 		// Done with this now
@@ -1087,8 +1149,7 @@  discard block
 block discarded – undo
1087 1149
 			$replaces['START TRANSACTION;'] = '';
1088 1150
 			$replaces['COMMIT;'] = '';
1089 1151
 		}
1090
-	}
1091
-	else
1152
+	} else
1092 1153
 	{
1093 1154
 		$has_innodb = false;
1094 1155
 	}
@@ -1110,21 +1171,24 @@  discard block
 block discarded – undo
1110 1171
 	foreach ($sql_lines as $count => $line)
1111 1172
 	{
1112 1173
 		// No comments allowed!
1113
-		if (substr(trim($line), 0, 1) != '#')
1114
-			$current_statement .= "\n" . rtrim($line);
1174
+		if (substr(trim($line), 0, 1) != '#') {
1175
+					$current_statement .= "\n" . rtrim($line);
1176
+		}
1115 1177
 
1116 1178
 		// Is this the end of the query string?
1117
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1118
-			continue;
1179
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1180
+					continue;
1181
+		}
1119 1182
 
1120 1183
 		// Does this table already exist?  If so, don't insert more data into it!
1121 1184
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1122 1185
 		{
1123 1186
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1124
-			if (!empty($matches[0]))
1125
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1126
-			else
1127
-				$incontext['sql_results']['insert_dups']++;
1187
+			if (!empty($matches[0])) {
1188
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1189
+			} else {
1190
+							$incontext['sql_results']['insert_dups']++;
1191
+			}
1128 1192
 
1129 1193
 			$current_statement = '';
1130 1194
 			continue;
@@ -1133,8 +1197,9 @@  discard block
 block discarded – undo
1133 1197
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1134 1198
 		{
1135 1199
 			// Use the appropriate function based on the DB type
1136
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1137
-				$db_errorno = $db_type . '_errno';
1200
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1201
+							$db_errorno = $db_type . '_errno';
1202
+			}
1138 1203
 
1139 1204
 			// Error 1050: Table already exists!
1140 1205
 			// @todo Needs to be made better!
@@ -1149,18 +1214,18 @@  discard block
 block discarded – undo
1149 1214
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1150 1215
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1151 1216
 			}
1152
-		}
1153
-		else
1217
+		} else
1154 1218
 		{
1155
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1156
-				$incontext['sql_results']['tables']++;
1157
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1219
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1220
+							$incontext['sql_results']['tables']++;
1221
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1158 1222
 			{
1159 1223
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1160
-				if (!empty($matches[0]))
1161
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1162
-				else
1163
-					$incontext['sql_results']['inserts']++;
1224
+				if (!empty($matches[0])) {
1225
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1226
+				} else {
1227
+									$incontext['sql_results']['inserts']++;
1228
+				}
1164 1229
 			}
1165 1230
 		}
1166 1231
 
@@ -1173,15 +1238,17 @@  discard block
 block discarded – undo
1173 1238
 	// Sort out the context for the SQL.
1174 1239
 	foreach ($incontext['sql_results'] as $key => $number)
1175 1240
 	{
1176
-		if ($number == 0)
1177
-			unset($incontext['sql_results'][$key]);
1178
-		else
1179
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1241
+		if ($number == 0) {
1242
+					unset($incontext['sql_results'][$key]);
1243
+		} else {
1244
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1245
+		}
1180 1246
 	}
1181 1247
 
1182 1248
 	// Make sure UTF will be used globally.
1183
-	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'])))
1184
-		$newSettings[] = array('global_character_set', 'UTF-8');
1249
+	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']))) {
1250
+			$newSettings[] = array('global_character_set', 'UTF-8');
1251
+	}
1185 1252
 
1186 1253
 	// Maybe we can auto-detect better cookie settings?
1187 1254
 	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
@@ -1192,16 +1259,20 @@  discard block
 block discarded – undo
1192 1259
 		$globalCookies = false;
1193 1260
 
1194 1261
 		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
1195
-		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
1196
-			$globalCookies = true;
1262
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) {
1263
+					$globalCookies = true;
1264
+		}
1197 1265
 		// If there's a / in the middle of the path, or it starts with ~... we want local.
1198
-		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
1199
-			$localCookies = true;
1266
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) {
1267
+					$localCookies = true;
1268
+		}
1200 1269
 
1201
-		if ($globalCookies)
1202
-			$newSettings[] = array('globalCookies', '1');
1203
-		if ($localCookies)
1204
-			$newSettings[] = array('localCookies', '1');
1270
+		if ($globalCookies) {
1271
+					$newSettings[] = array('globalCookies', '1');
1272
+		}
1273
+		if ($localCookies) {
1274
+					$newSettings[] = array('localCookies', '1');
1275
+		}
1205 1276
 	}
1206 1277
 
1207 1278
 	// Are we allowing stat collection?
@@ -1217,32 +1288,36 @@  discard block
 block discarded – undo
1217 1288
 			fwrite($fp, $out);
1218 1289
 
1219 1290
 			$return_data = '';
1220
-			while (!feof($fp))
1221
-				$return_data .= fgets($fp, 128);
1291
+			while (!feof($fp)) {
1292
+							$return_data .= fgets($fp, 128);
1293
+			}
1222 1294
 
1223 1295
 			fclose($fp);
1224 1296
 
1225 1297
 			// Get the unique site ID.
1226 1298
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1227 1299
 
1228
-			if (!empty($ID[1]))
1229
-				$newSettings[] = array('allow_sm_stats', $ID[1]);
1300
+			if (!empty($ID[1])) {
1301
+							$newSettings[] = array('allow_sm_stats', $ID[1]);
1302
+			}
1230 1303
 		}
1231 1304
 	}
1232 1305
 
1233 1306
 	// Are we enabling SSL?
1234
-	if (!empty($_POST['force_ssl']))
1235
-		$newSettings[] = array('force_ssl', 2);
1307
+	if (!empty($_POST['force_ssl'])) {
1308
+			$newSettings[] = array('force_ssl', 2);
1309
+	}
1236 1310
 
1237 1311
 	// Setting a timezone is required.
1238 1312
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1239 1313
 	{
1240 1314
 		// Get PHP's default timezone, if set
1241 1315
 		$ini_tz = ini_get('date.timezone');
1242
-		if (!empty($ini_tz))
1243
-			$timezone_id = $ini_tz;
1244
-		else
1245
-			$timezone_id = '';
1316
+		if (!empty($ini_tz)) {
1317
+					$timezone_id = $ini_tz;
1318
+		} else {
1319
+					$timezone_id = '';
1320
+		}
1246 1321
 
1247 1322
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1248 1323
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1251,8 +1326,9 @@  discard block
 block discarded – undo
1251 1326
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1252 1327
 		}
1253 1328
 
1254
-		if (date_default_timezone_set($timezone_id))
1255
-			$newSettings[] = array('default_timezone', $timezone_id);
1329
+		if (date_default_timezone_set($timezone_id)) {
1330
+					$newSettings[] = array('default_timezone', $timezone_id);
1331
+		}
1256 1332
 	}
1257 1333
 
1258 1334
 	if (!empty($newSettings))
@@ -1283,16 +1359,18 @@  discard block
 block discarded – undo
1283 1359
 	}
1284 1360
 
1285 1361
 	// MySQL specific stuff
1286
-	if (substr($db_type, 0, 5) != 'mysql')
1287
-		return false;
1362
+	if (substr($db_type, 0, 5) != 'mysql') {
1363
+			return false;
1364
+	}
1288 1365
 
1289 1366
 	// Find database user privileges.
1290 1367
 	$privs = array();
1291 1368
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1292 1369
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1293 1370
 	{
1294
-		if ($row['Privilege'] == 'Alter')
1295
-			$privs[] = $row['Privilege'];
1371
+		if ($row['Privilege'] == 'Alter') {
1372
+					$privs[] = $row['Privilege'];
1373
+		}
1296 1374
 	}
1297 1375
 	$smcFunc['db_free_result']($get_privs);
1298 1376
 
@@ -1322,8 +1400,9 @@  discard block
 block discarded – undo
1322 1400
 	$incontext['continue'] = 1;
1323 1401
 
1324 1402
 	// Skipping?
1325
-	if (!empty($_POST['skip']))
1326
-		return true;
1403
+	if (!empty($_POST['skip'])) {
1404
+			return true;
1405
+	}
1327 1406
 
1328 1407
 	// Need this to check whether we need the database password.
1329 1408
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1336,18 +1415,22 @@  discard block
 block discarded – undo
1336 1415
 	// We need this to properly hash the password for Admin
1337 1416
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1338 1417
 			global $sourcedir;
1339
-			if (function_exists('mb_strtolower'))
1340
-				return mb_strtolower($string, 'UTF-8');
1418
+			if (function_exists('mb_strtolower')) {
1419
+							return mb_strtolower($string, 'UTF-8');
1420
+			}
1341 1421
 			require_once($sourcedir . '/Subs-Charset.php');
1342 1422
 			return utf8_strtolower($string);
1343 1423
 		};
1344 1424
 
1345
-	if (!isset($_POST['username']))
1346
-		$_POST['username'] = '';
1347
-	if (!isset($_POST['email']))
1348
-		$_POST['email'] = '';
1349
-	if (!isset($_POST['server_email']))
1350
-		$_POST['server_email'] = '';
1425
+	if (!isset($_POST['username'])) {
1426
+			$_POST['username'] = '';
1427
+	}
1428
+	if (!isset($_POST['email'])) {
1429
+			$_POST['email'] = '';
1430
+	}
1431
+	if (!isset($_POST['server_email'])) {
1432
+			$_POST['server_email'] = '';
1433
+	}
1351 1434
 
1352 1435
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1353 1436
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1366,8 +1449,9 @@  discard block
 block discarded – undo
1366 1449
 			'admin_group' => 1,
1367 1450
 		)
1368 1451
 	);
1369
-	if ($smcFunc['db_num_rows']($request) != 0)
1370
-		$incontext['skip'] = 1;
1452
+	if ($smcFunc['db_num_rows']($request) != 0) {
1453
+			$incontext['skip'] = 1;
1454
+	}
1371 1455
 	$smcFunc['db_free_result']($request);
1372 1456
 
1373 1457
 	// Trying to create an account?
@@ -1398,8 +1482,9 @@  discard block
 block discarded – undo
1398 1482
 		}
1399 1483
 
1400 1484
 		// Update the webmaster's email?
1401
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1402
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1485
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1486
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1487
+		}
1403 1488
 
1404 1489
 		// Work out whether we're going to have dodgy characters and remove them.
1405 1490
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1422,32 +1507,27 @@  discard block
 block discarded – undo
1422 1507
 			$smcFunc['db_free_result']($result);
1423 1508
 
1424 1509
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1425
-		}
1426
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1510
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1427 1511
 		{
1428 1512
 			// Try the previous step again.
1429 1513
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1430 1514
 			return false;
1431
-		}
1432
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1515
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1433 1516
 		{
1434 1517
 			// Try the previous step again.
1435 1518
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1436 1519
 			return false;
1437
-		}
1438
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1520
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1439 1521
 		{
1440 1522
 			// One step back, this time fill out a proper admin email address.
1441 1523
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1442 1524
 			return false;
1443
-		}
1444
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1525
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1445 1526
 		{
1446 1527
 			// One step back, this time fill out a proper admin email address.
1447 1528
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1448 1529
 			return false;
1449
-		}
1450
-		elseif ($_POST['username'] != '')
1530
+		} elseif ($_POST['username'] != '')
1451 1531
 		{
1452 1532
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1453 1533
 
@@ -1513,17 +1593,19 @@  discard block
 block discarded – undo
1513 1593
 	require_once($sourcedir . '/Subs-Auth.php');
1514 1594
 
1515 1595
 	// Bring a warning over.
1516
-	if (!empty($incontext['account_existed']))
1517
-		$incontext['warning'] = $incontext['account_existed'];
1596
+	if (!empty($incontext['account_existed'])) {
1597
+			$incontext['warning'] = $incontext['account_existed'];
1598
+	}
1518 1599
 
1519
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1520
-		$smcFunc['db_query']('', '
1600
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1601
+			$smcFunc['db_query']('', '
1521 1602
 			SET NAMES {string:db_character_set}',
1522 1603
 			array(
1523 1604
 				'db_character_set' => $db_character_set,
1524 1605
 				'db_error_skip' => true,
1525 1606
 			)
1526 1607
 		);
1608
+	}
1527 1609
 
1528 1610
 	// As track stats is by default enabled let's add some activity.
1529 1611
 	$smcFunc['db_insert']('ignore',
@@ -1544,14 +1626,16 @@  discard block
 block discarded – undo
1544 1626
 	// Only proceed if we can load the data.
1545 1627
 	if ($request)
1546 1628
 	{
1547
-		while ($row = $smcFunc['db_fetch_row']($request))
1548
-			$modSettings[$row[0]] = $row[1];
1629
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1630
+					$modSettings[$row[0]] = $row[1];
1631
+		}
1549 1632
 		$smcFunc['db_free_result']($request);
1550 1633
 	}
1551 1634
 
1552 1635
 	// Automatically log them in ;)
1553
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1554
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1636
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1637
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1638
+	}
1555 1639
 
1556 1640
 	$result = $smcFunc['db_query']('', '
1557 1641
 		SELECT value
@@ -1562,13 +1646,14 @@  discard block
 block discarded – undo
1562 1646
 			'db_error_skip' => true,
1563 1647
 		)
1564 1648
 	);
1565
-	if ($smcFunc['db_num_rows']($result) != 0)
1566
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1649
+	if ($smcFunc['db_num_rows']($result) != 0) {
1650
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1651
+	}
1567 1652
 	$smcFunc['db_free_result']($result);
1568 1653
 
1569
-	if (empty($db_sessions))
1570
-		$_SESSION['admin_time'] = time();
1571
-	else
1654
+	if (empty($db_sessions)) {
1655
+			$_SESSION['admin_time'] = time();
1656
+	} else
1572 1657
 	{
1573 1658
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1574 1659
 
@@ -1592,8 +1677,9 @@  discard block
 block discarded – undo
1592 1677
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1593 1678
 		function($string){
1594 1679
 			global $sourcedir;
1595
-			if (function_exists('mb_strtolower'))
1596
-				return mb_strtolower($string, 'UTF-8');
1680
+			if (function_exists('mb_strtolower')) {
1681
+							return mb_strtolower($string, 'UTF-8');
1682
+			}
1597 1683
 			require_once($sourcedir . '/Subs-Charset.php');
1598 1684
 			return utf8_strtolower($string);
1599 1685
 		};
@@ -1609,8 +1695,9 @@  discard block
 block discarded – undo
1609 1695
 		)
1610 1696
 	);
1611 1697
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1612
-	if ($smcFunc['db_num_rows']($request) > 0)
1613
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1698
+	if ($smcFunc['db_num_rows']($request) > 0) {
1699
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1700
+	}
1614 1701
 	$smcFunc['db_free_result']($request);
1615 1702
 
1616 1703
 	// Now is the perfect time to fetch the SM files.
@@ -1629,8 +1716,9 @@  discard block
 block discarded – undo
1629 1716
 
1630 1717
 	// Check if we need some stupid MySQL fix.
1631 1718
 	$server_version = $smcFunc['db_server_info']();
1632
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1633
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1719
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1720
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1721
+	}
1634 1722
 
1635 1723
 	// Some final context for the template.
1636 1724
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1650,8 +1738,9 @@  discard block
 block discarded – undo
1650 1738
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1651 1739
 
1652 1740
 	// @todo Do we just want to read the file in clean, and split it this way always?
1653
-	if (count($settingsArray) == 1)
1654
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1741
+	if (count($settingsArray) == 1) {
1742
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1743
+	}
1655 1744
 
1656 1745
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1657 1746
 	{
@@ -1666,19 +1755,22 @@  discard block
 block discarded – undo
1666 1755
 			continue;
1667 1756
 		}
1668 1757
 
1669
-		if (trim($settingsArray[$i]) == '?' . '>')
1670
-			$settingsArray[$i] = '';
1758
+		if (trim($settingsArray[$i]) == '?' . '>') {
1759
+					$settingsArray[$i] = '';
1760
+		}
1671 1761
 
1672 1762
 		// Don't trim or bother with it if it's not a variable.
1673
-		if (substr($settingsArray[$i], 0, 1) != '$')
1674
-			continue;
1763
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1764
+					continue;
1765
+		}
1675 1766
 
1676 1767
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1677 1768
 
1678
-		foreach ($vars as $var => $val)
1679
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1769
+		foreach ($vars as $var => $val) {
1770
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1680 1771
 			{
1681 1772
 				$comment = strstr($settingsArray[$i], '#');
1773
+		}
1682 1774
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1683 1775
 				unset($vars[$var]);
1684 1776
 			}
@@ -1688,36 +1780,41 @@  discard block
 block discarded – undo
1688 1780
 	if (!empty($vars))
1689 1781
 	{
1690 1782
 		$settingsArray[$i++] = '';
1691
-		foreach ($vars as $var => $val)
1692
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1783
+		foreach ($vars as $var => $val) {
1784
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1785
+		}
1693 1786
 	}
1694 1787
 
1695 1788
 	// Blank out the file - done to fix a oddity with some servers.
1696 1789
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1697
-	if (!$fp)
1698
-		return false;
1790
+	if (!$fp) {
1791
+			return false;
1792
+	}
1699 1793
 	fclose($fp);
1700 1794
 
1701 1795
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1702 1796
 
1703 1797
 	// Gotta have one of these ;)
1704
-	if (trim($settingsArray[0]) != '<?php')
1705
-		fwrite($fp, "<?php\n");
1798
+	if (trim($settingsArray[0]) != '<?php') {
1799
+			fwrite($fp, "<?php\n");
1800
+	}
1706 1801
 
1707 1802
 	$lines = count($settingsArray);
1708 1803
 	for ($i = 0; $i < $lines - 1; $i++)
1709 1804
 	{
1710 1805
 		// Don't just write a bunch of blank lines.
1711
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1712
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1806
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1807
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1808
+		}
1713 1809
 	}
1714 1810
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1715 1811
 	fclose($fp);
1716 1812
 
1717 1813
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1718 1814
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1719
-	if (function_exists('opcache_invalidate'))
1720
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1815
+	if (function_exists('opcache_invalidate')) {
1816
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1817
+	}
1721 1818
 
1722 1819
 	return true;
1723 1820
 }
@@ -1742,9 +1839,9 @@  discard block
 block discarded – undo
1742 1839
 	SecFilterScanPOST Off
1743 1840
 </IfModule>';
1744 1841
 
1745
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1746
-		return true;
1747
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1842
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1843
+			return true;
1844
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1748 1845
 	{
1749 1846
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1750 1847
 
@@ -1756,29 +1853,28 @@  discard block
 block discarded – undo
1756 1853
 				fwrite($ht_handle, $htaccess_addition);
1757 1854
 				fclose($ht_handle);
1758 1855
 				return true;
1856
+			} else {
1857
+							return false;
1759 1858
 			}
1760
-			else
1761
-				return false;
1859
+		} else {
1860
+					return true;
1762 1861
 		}
1763
-		else
1764
-			return true;
1765
-	}
1766
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1767
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1768
-	elseif (is_writable(dirname(__FILE__)))
1862
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1863
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1864
+	} elseif (is_writable(dirname(__FILE__)))
1769 1865
 	{
1770 1866
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1771 1867
 		{
1772 1868
 			fwrite($ht_handle, $htaccess_addition);
1773 1869
 			fclose($ht_handle);
1774 1870
 			return true;
1871
+		} else {
1872
+					return false;
1775 1873
 		}
1776
-		else
1874
+	} else {
1777 1875
 			return false;
1778 1876
 	}
1779
-	else
1780
-		return false;
1781
-}
1877
+	}
1782 1878
 
1783 1879
 function template_install_above()
1784 1880
 {
@@ -1816,9 +1912,10 @@  discard block
 block discarded – undo
1816 1912
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1817 1913
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1818 1914
 
1819
-		foreach ($incontext['detected_languages'] as $lang => $name)
1820
-			echo '
1915
+		foreach ($incontext['detected_languages'] as $lang => $name) {
1916
+					echo '
1821 1917
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
1918
+		}
1822 1919
 
1823 1920
 		echo '
1824 1921
 								</select>
@@ -1838,9 +1935,10 @@  discard block
 block discarded – undo
1838 1935
 						<h2>', $txt['upgrade_progress'], '</h2>
1839 1936
 						<ul>';
1840 1937
 
1841
-	foreach ($incontext['steps'] as $num => $step)
1842
-		echo '
1938
+	foreach ($incontext['steps'] as $num => $step) {
1939
+			echo '
1843 1940
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
1941
+	}
1844 1942
 
1845 1943
 	echo '
1846 1944
 						</ul>
@@ -1865,20 +1963,23 @@  discard block
 block discarded – undo
1865 1963
 		echo '
1866 1964
 								<div>';
1867 1965
 
1868
-		if (!empty($incontext['continue']))
1869
-			echo '
1966
+		if (!empty($incontext['continue'])) {
1967
+					echo '
1870 1968
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1871
-		if (!empty($incontext['skip']))
1872
-			echo '
1969
+		}
1970
+		if (!empty($incontext['skip'])) {
1971
+					echo '
1873 1972
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1973
+		}
1874 1974
 		echo '
1875 1975
 								</div>';
1876 1976
 	}
1877 1977
 
1878 1978
 	// Show the closing form tag and other data only if not in the last step
1879
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1880
-		echo '
1979
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
1980
+			echo '
1881 1981
 							</form>';
1982
+	}
1882 1983
 
1883 1984
 	echo '
1884 1985
 						</div>
@@ -1913,13 +2014,15 @@  discard block
 block discarded – undo
1913 2014
 		</div>';
1914 2015
 
1915 2016
 	// Show the warnings, or not.
1916
-	if (template_warning_divs())
1917
-		echo '
2017
+	if (template_warning_divs()) {
2018
+			echo '
1918 2019
 		<h3>', $txt['install_all_lovely'], '</h3>';
2020
+	}
1919 2021
 
1920 2022
 	// Say we want the continue button!
1921
-	if (empty($incontext['error']))
1922
-		$incontext['continue'] = 1;
2023
+	if (empty($incontext['error'])) {
2024
+			$incontext['continue'] = 1;
2025
+	}
1923 2026
 
1924 2027
 	// For the latest version stuff.
1925 2028
 	echo '
@@ -1953,8 +2056,8 @@  discard block
 block discarded – undo
1953 2056
 	global $txt, $incontext;
1954 2057
 
1955 2058
 	// Errors are very serious..
1956
-	if (!empty($incontext['error']))
1957
-		echo '
2059
+	if (!empty($incontext['error'])) {
2060
+			echo '
1958 2061
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1959 2062
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1960 2063
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -1962,9 +2065,10 @@  discard block
 block discarded – undo
1962 2065
 				', $incontext['error'], '
1963 2066
 			</div>
1964 2067
 		</div>';
2068
+	}
1965 2069
 	// A warning message?
1966
-	elseif (!empty($incontext['warning']))
1967
-		echo '
2070
+	elseif (!empty($incontext['warning'])) {
2071
+			echo '
1968 2072
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1969 2073
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1970 2074
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -1972,6 +2076,7 @@  discard block
 block discarded – undo
1972 2076
 				', $incontext['warning'], '
1973 2077
 			</div>
1974 2078
 		</div>';
2079
+	}
1975 2080
 
1976 2081
 	return empty($incontext['error']) && empty($incontext['warning']);
1977 2082
 }
@@ -1987,27 +2092,30 @@  discard block
 block discarded – undo
1987 2092
 			<li>', $incontext['failed_files']), '</li>
1988 2093
 		</ul>';
1989 2094
 
1990
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
1991
-		echo '
2095
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2096
+			echo '
1992 2097
 		<hr>
1993 2098
 		<p>', $txt['chmod_linux_info'], '</p>
1994 2099
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2100
+	}
1995 2101
 
1996 2102
 	// This is serious!
1997
-	if (!template_warning_divs())
1998
-		return;
2103
+	if (!template_warning_divs()) {
2104
+			return;
2105
+	}
1999 2106
 
2000 2107
 	echo '
2001 2108
 		<hr>
2002 2109
 		<p>', $txt['ftp_setup_info'], '</p>';
2003 2110
 
2004
-	if (!empty($incontext['ftp_errors']))
2005
-		echo '
2111
+	if (!empty($incontext['ftp_errors'])) {
2112
+			echo '
2006 2113
 		<div class="error_message">
2007 2114
 			', $txt['error_ftp_no_connect'], '<br><br>
2008 2115
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2009 2116
 		</div>
2010 2117
 		<br>';
2118
+	}
2011 2119
 
2012 2120
 	echo '
2013 2121
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2067,17 +2175,17 @@  discard block
 block discarded – undo
2067 2175
 				<td>
2068 2176
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2069 2177
 
2070
-	foreach ($incontext['supported_databases'] as $key => $db)
2071
-			echo '
2178
+	foreach ($incontext['supported_databases'] as $key => $db) {
2179
+				echo '
2072 2180
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2181
+	}
2073 2182
 
2074 2183
 	echo '
2075 2184
 					</select>
2076 2185
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2077 2186
 				</td>
2078 2187
 			</tr>';
2079
-	}
2080
-	else
2188
+	} else
2081 2189
 	{
2082 2190
 		echo '
2083 2191
 			<tr style="display: none;">
@@ -2269,9 +2377,10 @@  discard block
 block discarded – undo
2269 2377
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2270 2378
 				<ul>';
2271 2379
 
2272
-		foreach ($incontext['failures'] as $line => $fail)
2273
-			echo '
2380
+		foreach ($incontext['failures'] as $line => $fail) {
2381
+					echo '
2274 2382
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2383
+		}
2275 2384
 
2276 2385
 		echo '
2277 2386
 				</ul>';
@@ -2332,15 +2441,16 @@  discard block
 block discarded – undo
2332 2441
 			</tr>
2333 2442
 		</table>';
2334 2443
 
2335
-	if ($incontext['require_db_confirm'])
2336
-		echo '
2444
+	if ($incontext['require_db_confirm']) {
2445
+			echo '
2337 2446
 		<h2>', $txt['user_settings_database'], '</h2>
2338 2447
 		<p>', $txt['user_settings_database_info'], '</p>
2339 2448
 
2340 2449
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2341 2450
 			<input type="password" name="password3" size="30" class="input_password" />
2342 2451
 		</div>';
2343
-}
2452
+	}
2453
+	}
2344 2454
 
2345 2455
 // Tell them it's done, and to delete.
2346 2456
 function template_delete_install()
@@ -2353,14 +2463,15 @@  discard block
 block discarded – undo
2353 2463
 	template_warning_divs();
2354 2464
 
2355 2465
 	// Install directory still writable?
2356
-	if ($incontext['dir_still_writable'])
2357
-		echo '
2466
+	if ($incontext['dir_still_writable']) {
2467
+			echo '
2358 2468
 		<em>', $txt['still_writable'], '</em><br>
2359 2469
 		<br>';
2470
+	}
2360 2471
 
2361 2472
 	// Don't show the box if it's like 99% sure it won't work :P.
2362
-	if ($incontext['probably_delete_install'])
2363
-		echo '
2473
+	if ($incontext['probably_delete_install']) {
2474
+			echo '
2364 2475
 		<div style="margin: 1ex; font-weight: bold;">
2365 2476
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2366 2477
 		</div>
@@ -2376,6 +2487,7 @@  discard block
 block discarded – undo
2376 2487
 			}
2377 2488
 		</script>
2378 2489
 		<br>';
2490
+	}
2379 2491
 
2380 2492
 	echo '
2381 2493
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.
other/upgrade-helper.php 1 patch
Braces   +90 added lines, -64 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * This file contains helper functions for upgrade.php
14 14
  */
15 15
 
16
-if (!defined('SMF_VERSION'))
16
+if (!defined('SMF_VERSION')) {
17 17
 	die('No direct access!');
18
+}
18 19
 
19 20
 /**
20 21
  * Clean the cache using the SMF 2.1 CacheAPI.
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
 	global $smcFunc;
46 47
 	static $member_groups = array();
47 48
 
48
-	if (!empty($member_groups))
49
-		return $member_groups;
49
+	if (!empty($member_groups)) {
50
+			return $member_groups;
51
+	}
50 52
 
51 53
 	$request = $smcFunc['db_query']('', '
52 54
 		SELECT group_name, id_group
@@ -71,8 +73,9 @@  discard block
 block discarded – undo
71 73
 			)
72 74
 		);
73 75
 	}
74
-	while ($row = $smcFunc['db_fetch_row']($request))
75
-		$member_groups[trim($row[0])] = $row[1];
76
+	while ($row = $smcFunc['db_fetch_row']($request)) {
77
+			$member_groups[trim($row[0])] = $row[1];
78
+	}
76 79
 	$smcFunc['db_free_result']($request);
77 80
 
78 81
 	return $member_groups;
@@ -88,8 +91,9 @@  discard block
 block discarded – undo
88 91
 {
89 92
 	global $upcontext, $boarddir, $sourcedir;
90 93
 
91
-	if (empty($files))
92
-		return true;
94
+	if (empty($files)) {
95
+			return true;
96
+	}
93 97
 
94 98
 	$failure = false;
95 99
 	// On linux, it's easy - just use is_writable!
@@ -104,14 +108,16 @@  discard block
 block discarded – undo
104 108
 				@chmod($file, 0755);
105 109
 
106 110
 				// Well, 755 hopefully worked... if not, try 777.
107
-				if (!is_writable($file) && !@chmod($file, 0777))
108
-					$failure = true;
111
+				if (!is_writable($file) && !@chmod($file, 0777)) {
112
+									$failure = true;
113
+				}
109 114
 				// Otherwise remove it as it's good!
110
-				else
111
-					unset($files[$k]);
115
+				else {
116
+									unset($files[$k]);
117
+				}
118
+			} else {
119
+							unset($files[$k]);
112 120
 			}
113
-			else
114
-				unset($files[$k]);
115 121
 		}
116 122
 	}
117 123
 	// Windows is trickier.  Let's try opening for r+...
@@ -122,30 +128,35 @@  discard block
 block discarded – undo
122 128
 		foreach ($files as $k => $file)
123 129
 		{
124 130
 			// Folders can't be opened for write... but the index.php in them can ;).
125
-			if (is_dir($file))
126
-				$file .= '/index.php';
131
+			if (is_dir($file)) {
132
+							$file .= '/index.php';
133
+			}
127 134
 
128 135
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
129 136
 			@chmod($file, 0777);
130 137
 			$fp = @fopen($file, 'r+');
131 138
 
132 139
 			// Hmm, okay, try just for write in that case...
133
-			if (!$fp)
134
-				$fp = @fopen($file, 'w');
140
+			if (!$fp) {
141
+							$fp = @fopen($file, 'w');
142
+			}
135 143
 
136
-			if (!$fp)
137
-				$failure = true;
138
-			else
139
-				unset($files[$k]);
144
+			if (!$fp) {
145
+							$failure = true;
146
+			} else {
147
+							unset($files[$k]);
148
+			}
140 149
 			@fclose($fp);
141 150
 		}
142 151
 	}
143 152
 
144
-	if (empty($files))
145
-		return true;
153
+	if (empty($files)) {
154
+			return true;
155
+	}
146 156
 
147
-	if (!isset($_SERVER))
148
-		return !$failure;
157
+	if (!isset($_SERVER)) {
158
+			return !$failure;
159
+	}
149 160
 
150 161
 	// What still needs to be done?
151 162
 	$upcontext['chmod']['files'] = $files;
@@ -197,36 +208,40 @@  discard block
 block discarded – undo
197 208
 
198 209
 		if (!isset($ftp) || $ftp->error !== false)
199 210
 		{
200
-			if (!isset($ftp))
201
-				$ftp = new ftp_connection(null);
211
+			if (!isset($ftp)) {
212
+							$ftp = new ftp_connection(null);
213
+			}
202 214
 			// Save the error so we can mess with listing...
203
-			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error']))
204
-				$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
215
+			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) {
216
+							$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
217
+			}
205 218
 
206 219
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
207 220
 
208
-			if ($found_path || !isset($upcontext['chmod']['path']))
209
-				$upcontext['chmod']['path'] = $detect_path;
221
+			if ($found_path || !isset($upcontext['chmod']['path'])) {
222
+							$upcontext['chmod']['path'] = $detect_path;
223
+			}
210 224
 
211
-			if (!isset($upcontext['chmod']['username']))
212
-				$upcontext['chmod']['username'] = $username;
225
+			if (!isset($upcontext['chmod']['username'])) {
226
+							$upcontext['chmod']['username'] = $username;
227
+			}
213 228
 
214 229
 			// Don't forget the login token.
215 230
 			$upcontext += createToken('login');
216 231
 
217 232
 			return false;
218
-		}
219
-		else
233
+		} else
220 234
 		{
221 235
 			// We want to do a relative path for FTP.
222 236
 			if (!in_array($upcontext['chmod']['path'], array('', '/')))
223 237
 			{
224 238
 				$ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => ''));
225
-				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/'))
226
-					$ftp_root = substr($ftp_root, 0, -1);
239
+				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) {
240
+									$ftp_root = substr($ftp_root, 0, -1);
241
+				}
242
+			} else {
243
+							$ftp_root = $boarddir;
227 244
 			}
228
-			else
229
-				$ftp_root = $boarddir;
230 245
 
231 246
 			// Save the info for next time!
232 247
 			$_SESSION['installer_temp_ftp'] = array(
@@ -240,10 +255,12 @@  discard block
 block discarded – undo
240 255
 
241 256
 			foreach ($files as $k => $file)
242 257
 			{
243
-				if (!is_writable($file))
244
-					$ftp->chmod($file, 0755);
245
-				if (!is_writable($file))
246
-					$ftp->chmod($file, 0777);
258
+				if (!is_writable($file)) {
259
+									$ftp->chmod($file, 0755);
260
+				}
261
+				if (!is_writable($file)) {
262
+									$ftp->chmod($file, 0777);
263
+				}
247 264
 
248 265
 				// Assuming that didn't work calculate the path without the boarddir.
249 266
 				if (!is_writable($file))
@@ -252,19 +269,23 @@  discard block
 block discarded – undo
252 269
 					{
253 270
 						$ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => ''));
254 271
 						$ftp->chmod($ftp_file, 0755);
255
-						if (!is_writable($file))
256
-							$ftp->chmod($ftp_file, 0777);
272
+						if (!is_writable($file)) {
273
+													$ftp->chmod($ftp_file, 0777);
274
+						}
257 275
 						// Sometimes an extra slash can help...
258 276
 						$ftp_file = '/' . $ftp_file;
259
-						if (!is_writable($file))
260
-							$ftp->chmod($ftp_file, 0755);
261
-						if (!is_writable($file))
262
-							$ftp->chmod($ftp_file, 0777);
277
+						if (!is_writable($file)) {
278
+													$ftp->chmod($ftp_file, 0755);
279
+						}
280
+						if (!is_writable($file)) {
281
+													$ftp->chmod($ftp_file, 0777);
282
+						}
263 283
 					}
264 284
 				}
265 285
 
266
-				if (is_writable($file))
267
-					unset($files[$k]);
286
+				if (is_writable($file)) {
287
+									unset($files[$k]);
288
+				}
268 289
 			}
269 290
 
270 291
 			$ftp->close();
@@ -274,8 +295,9 @@  discard block
 block discarded – undo
274 295
 	// What remains?
275 296
 	$upcontext['chmod']['files'] = $files;
276 297
 
277
-	if (empty($files))
278
-		return true;
298
+	if (empty($files)) {
299
+			return true;
300
+	}
279 301
 
280 302
 	return false;
281 303
 }
@@ -288,8 +310,9 @@  discard block
 block discarded – undo
288 310
  */
289 311
 function quickFileWritable($file)
290 312
 {
291
-	if (is_writable($file))
292
-		return true;
313
+	if (is_writable($file)) {
314
+			return true;
315
+	}
293 316
 
294 317
 	@chmod($file, 0755);
295 318
 
@@ -299,10 +322,11 @@  discard block
 block discarded – undo
299 322
 	foreach ($chmod_values as $val)
300 323
 	{
301 324
 		// If it's writable, break out of the loop
302
-		if (is_writable($file))
303
-			break;
304
-		else
305
-			@chmod($file, $val);
325
+		if (is_writable($file)) {
326
+					break;
327
+		} else {
328
+					@chmod($file, $val);
329
+		}
306 330
 	}
307 331
 
308 332
 	return is_writable($file);
@@ -329,14 +353,16 @@  discard block
 block discarded – undo
329 353
 {
330 354
 	static $fp = null;
331 355
 
332
-	if ($fp === null)
333
-		$fp = fopen('php://stderr', 'wb');
356
+	if ($fp === null) {
357
+			$fp = fopen('php://stderr', 'wb');
358
+	}
334 359
 
335 360
 	fwrite($fp, $message . "\n");
336 361
 
337
-	if ($fatal)
338
-		exit;
339
-}
362
+	if ($fatal) {
363
+			exit;
364
+	}
365
+	}
340 366
 
341 367
 /**
342 368
  * Throws a graphical error message.
Please login to merge, or discard this patch.