Completed
Push — release-2.1 ( b53708...eb3630 )
by Jeremy
08:31
created
Themes/default/GenericList.template.php 1 patch
Braces   +65 added lines, -46 removed lines patch added patch discarded remove patch
@@ -22,27 +22,31 @@  discard block
 block discarded – undo
22 22
 	// Get a shortcut to the current list.
23 23
 	$list_id = $list_id === null ? (!empty($context['default_list']) ? $context['default_list'] : '') : $list_id;
24 24
 
25
-	if (empty($list_id) || empty($context[$list_id]))
26
-		return;
25
+	if (empty($list_id) || empty($context[$list_id])) {
26
+			return;
27
+	}
27 28
 
28 29
 	$cur_list = &$context[$list_id];
29 30
 
30 31
 	// These are the main tabs that is used all around the template.
31
-	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top'))
32
-		template_create_list_menu($cur_list['list_menu'], 'top');
32
+	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) {
33
+			template_create_list_menu($cur_list['list_menu'], 'top');
34
+	}
33 35
 
34
-	if (isset($cur_list['form']))
35
-		echo '
36
+	if (isset($cur_list['form'])) {
37
+			echo '
36 38
 	<form action="', $cur_list['form']['href'], '" method="post"', empty($cur_list['form']['name']) ? '' : ' name="' . $cur_list['form']['name'] . '" id="' . $cur_list['form']['name'] . '"', ' accept-charset="', $context['character_set'], '">';
39
+	}
37 40
 
38 41
 	// Show the title of the table (if any).
39
-	if (!empty($cur_list['title']))
40
-		echo '
42
+	if (!empty($cur_list['title'])) {
43
+			echo '
41 44
 		<div class="cat_bar">
42 45
 			<h3 class="catbg">
43 46
 				', $cur_list['title'], '
44 47
 			</h3>
45 48
 		</div>';
49
+	}
46 50
 
47 51
 	if (isset($cur_list['additional_rows']['after_title']))
48 52
 	{
@@ -55,20 +59,23 @@  discard block
 block discarded – undo
55 59
 		</div>';
56 60
 	}
57 61
 
58
-	if (isset($cur_list['additional_rows']['top_of_list']))
59
-		template_additional_rows('top_of_list', $cur_list);
62
+	if (isset($cur_list['additional_rows']['top_of_list'])) {
63
+			template_additional_rows('top_of_list', $cur_list);
64
+	}
60 65
 
61 66
 	if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['above_column_headers']))
62 67
 	{
63 68
 		// Show the page index (if this list doesn't intend to show all items).
64
-		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index']))
65
-			echo '
69
+		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) {
70
+					echo '
66 71
 		<div class="floatleft">
67 72
 			<div class="pagesection">', $cur_list['page_index'], '</div>
68 73
 		</div>';
74
+		}
69 75
 
70
-		if (isset($cur_list['additional_rows']['above_column_headers']))
71
-			template_additional_rows('above_column_headers', $cur_list);
76
+		if (isset($cur_list['additional_rows']['above_column_headers'])) {
77
+					template_additional_rows('above_column_headers', $cur_list);
78
+		}
72 79
 	}
73 80
 
74 81
 	echo '
@@ -83,11 +90,12 @@  discard block
 block discarded – undo
83 90
 				<tr class="title_bar">';
84 91
 
85 92
 		// Loop through each column and add a table header.
86
-		foreach ($cur_list['headers'] as $col_header)
87
-			echo '
93
+		foreach ($cur_list['headers'] as $col_header) {
94
+					echo '
88 95
 					<th scope="col" id="header_', $list_id, '_', $col_header['id'], '" class="' , $col_header['id'], empty($col_header['class']) ? '' : ' '.$col_header['class'] , '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '>
89 96
 						', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? '' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <span class="generic_icons sort_' . $col_header['sort_image'] . '"></span></a>'), '
90 97
 					</th>';
98
+		}
91 99
 
92 100
 		echo '
93 101
 				</tr>
@@ -98,13 +106,14 @@  discard block
 block discarded – undo
98 106
 			<tbody>';
99 107
 
100 108
 	// Show a nice message informing there are no items in this list.
101
-	if (empty($cur_list['rows']) && !empty($cur_list['no_items_label']))
102
-		echo '
109
+	if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) {
110
+			echo '
103 111
 				<tr class="windowbg">
104 112
 					<td colspan="', $cur_list['num_columns'], '" class="', !empty($cur_list['no_items_align']) ? $cur_list['no_items_align'] : 'centertext', '">
105 113
 						', $cur_list['no_items_label'], '
106 114
 					</td>
107 115
 				</tr>';
116
+	}
108 117
 
109 118
 	// Show the list rows.
110 119
 	elseif (!empty($cur_list['rows']))
@@ -114,12 +123,13 @@  discard block
 block discarded – undo
114 123
 			echo '
115 124
 				<tr class="windowbg', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', ' id="list_', $list_id, '_', $id, '">';
116 125
 
117
-			if (!empty($row['data']))
118
-				foreach ($row['data'] as $row_id => $row_data)
126
+			if (!empty($row['data'])) {
127
+							foreach ($row['data'] as $row_id => $row_data)
119 128
 					echo '
120 129
 					<td class="', $row_id, empty($row_data['class']) ? '' : ' ' . $row_data['class'] .'', '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '>
121 130
 						', $row_data['value'], '
122 131
 					</td>';
132
+			}
123 133
 
124 134
 			echo '
125 135
 				</tr>';
@@ -136,46 +146,53 @@  discard block
 block discarded – undo
136 146
 		<div class="flow_auto">';
137 147
 
138 148
 		// Show the page index (if this list doesn't intend to show all items).
139
-		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index']))
140
-			echo '
149
+		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) {
150
+					echo '
141 151
 			<div class="floatleft">
142 152
 				<div class="pagesection">', $cur_list['page_index'], '</div>
143 153
 			</div>';
154
+		}
144 155
 
145
-		if (isset($cur_list['additional_rows']['below_table_data']))
146
-			template_additional_rows('below_table_data', $cur_list);
156
+		if (isset($cur_list['additional_rows']['below_table_data'])) {
157
+					template_additional_rows('below_table_data', $cur_list);
158
+		}
147 159
 
148 160
 		echo '
149 161
 		</div>';
150 162
 	}
151 163
 
152
-	if (isset($cur_list['additional_rows']['bottom_of_list']))
153
-		template_additional_rows('bottom_of_list', $cur_list);
164
+	if (isset($cur_list['additional_rows']['bottom_of_list'])) {
165
+			template_additional_rows('bottom_of_list', $cur_list);
166
+	}
154 167
 
155 168
 	if (isset($cur_list['form']))
156 169
 	{
157
-		foreach ($cur_list['form']['hidden_fields'] as $name => $value)
158
-			echo '
170
+		foreach ($cur_list['form']['hidden_fields'] as $name => $value) {
171
+					echo '
159 172
 		<input type="hidden" name="', $name, '" value="', $value, '">';
173
+		}
160 174
 
161
-		if (isset($cur_list['form']['token']))
162
-			echo '
175
+		if (isset($cur_list['form']['token'])) {
176
+					echo '
163 177
 		<input type="hidden" name="', $context[$cur_list['form']['token'] . '_token_var'], '" value="', $context[$cur_list['form']['token'] . '_token'], '">';
178
+		}
164 179
 
165 180
 		echo '
166 181
 	</form>';
167 182
 	}
168 183
 
169 184
 	// Tabs at the bottom.  Usually bottom aligned.
170
-	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom'))
171
-		template_create_list_menu($cur_list['list_menu'], 'bottom');
185
+	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom')) {
186
+			template_create_list_menu($cur_list['list_menu'], 'bottom');
187
+	}
172 188
 
173
-	if (isset($cur_list['javascript']))
174
-		echo '
189
+	if (isset($cur_list['javascript'])) {
190
+			echo '
175 191
 	<script>
176 192
 		', $cur_list['javascript'], '
177 193
 	</script>';
178
-}
194
+	}
195
+	}
179 196
 
180 197
 /**
181 198
  * This template displays additional rows above or below the list.
@@ -185,12 +202,13 @@  discard block
 block discarded – undo
185 202
  */
186 203
 function template_additional_rows($row_position, $cur_list)
187 204
 {
188
-	foreach ($cur_list['additional_rows'][$row_position] as $row)
189
-		echo '
205
+	foreach ($cur_list['additional_rows'][$row_position] as $row) {
206
+			echo '
190 207
 			<div class="additional_row', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '>
191 208
 				', $row['value'], '
192 209
 			</div>';
193
-}
210
+	}
211
+	}
194 212
 
195 213
 /**
196 214
  * This function creates a menu
@@ -249,18 +267,19 @@  discard block
 block discarded – undo
249 267
 
250 268
 		foreach ($list_menu['links'] as $link)
251 269
 		{
252
-			if ($link['is_selected'])
253
-				echo '
270
+			if ($link['is_selected']) {
271
+							echo '
254 272
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $first, '"></td>
255 273
 							<td class="', $direction == 'top' ? 'mirrortab' : 'maintab', '_active_back">
256 274
 								<a href="', $link['href'], '">', $link['label'], '</a>
257 275
 							</td>
258 276
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $last, '"></td>';
259
-			else
260
-				echo '
277
+			} else {
278
+							echo '
261 279
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back">
262 280
 								<a href="', $link['href'], '">', $link['label'], '</a>
263 281
 							</td>';
282
+			}
264 283
 		}
265 284
 
266 285
 		echo '
@@ -271,12 +290,12 @@  discard block
 block discarded – undo
271 290
 				<td></td>' : '', '
272 291
 			</tr>
273 292
 		</table>';
274
-	}
275
-	elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons')
293
+	} elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons')
276 294
 	{
277 295
 		$links = array();
278
-		foreach ($list_menu['links'] as $link)
279
-			$links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';
296
+		foreach ($list_menu['links'] as $link) {
297
+					$links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';
298
+		}
280 299
 
281 300
 		echo '
282 301
 		<table style="margin-', $list_menu['position'], ': 10px; width: 100%;">
Please login to merge, or discard this patch.
Themes/default/Admin.template.php 1 patch
Braces   +182 added lines, -130 removed lines patch added patch discarded remove patch
@@ -65,9 +65,10 @@  discard block
 block discarded – undo
65 65
 										', implode(', ', $context['administrators']);
66 66
 
67 67
 	// If we have lots of admins... don't show them all.
68
-	if (!empty($context['more_admins_link']))
69
-		echo '
68
+	if (!empty($context['more_admins_link'])) {
69
+			echo '
70 70
 										(', $context['more_admins_link'], ')';
71
+	}
71 72
 
72 73
 	echo '
73 74
 									</div><!-- #version_details -->
@@ -84,17 +85,19 @@  discard block
 block discarded – undo
84 85
 		foreach ($area['areas'] as $item_id => $item)
85 86
 		{
86 87
 			// No point showing the 'home' page here, we're already on it!
87
-			if ($area_id == 'forum' && $item_id == 'index')
88
-				continue;
88
+			if ($area_id == 'forum' && $item_id == 'index') {
89
+							continue;
90
+			}
89 91
 
90 92
 			$url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : '');
91 93
 
92
-			if (!empty($item['icon_file']))
93
-				echo '
94
+			if (!empty($item['icon_file'])) {
95
+							echo '
94 96
 							<a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>';
95
-			else
96
-				echo '
97
+			} else {
98
+							echo '
97 99
 							<a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>';
100
+			}
98 101
 		}
99 102
 
100 103
 		echo '
@@ -105,10 +108,11 @@  discard block
 block discarded – undo
105 108
 					</div><!-- #admincenter -->';
106 109
 
107 110
 	// The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization.
108
-	if (empty($modSettings['disable_smf_js']))
109
-		echo '
111
+	if (empty($modSettings['disable_smf_js'])) {
112
+			echo '
110 113
 					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
111 114
 					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
115
+	}
112 116
 
113 117
 	// This sets the announcements and current versions themselves ;).
114 118
 	echo '
@@ -186,9 +190,10 @@  discard block
 block discarded – undo
186 190
 								<em>', $version['version'], '</em>';
187 191
 
188 192
 		// more details for this item, show them a link
189
-		if ($context['can_admin'] && isset($version['more']))
190
-			echo
193
+		if ($context['can_admin'] && isset($version['more'])) {
194
+					echo
191 195
 								' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>';
196
+		}
192 197
 		echo '
193 198
 								<br>';
194 199
 	}
@@ -219,21 +224,23 @@  discard block
 block discarded – undo
219 224
 
220 225
 	foreach ($context['credits'] as $section)
221 226
 	{
222
-		if (isset($section['pretext']))
223
-			echo '
227
+		if (isset($section['pretext'])) {
228
+					echo '
224 229
 								<p>', $section['pretext'], '</p>
225 230
 								<hr>';
231
+		}
226 232
 
227 233
 		echo '
228 234
 								<dl>';
229 235
 
230 236
 		foreach ($section['groups'] as $group)
231 237
 		{
232
-			if (isset($group['title']))
233
-				echo '
238
+			if (isset($group['title'])) {
239
+							echo '
234 240
 									<dt>
235 241
 										<strong>', $group['title'], ':</strong>
236 242
 									</dt>';
243
+			}
237 244
 
238 245
 			echo '
239 246
 									<dd>', implode(', ', $group['members']), '</dd>';
@@ -242,10 +249,11 @@  discard block
 block discarded – undo
242 249
 		echo '
243 250
 								</dl>';
244 251
 
245
-		if (isset($section['posttext']))
246
-			echo '
252
+		if (isset($section['posttext'])) {
253
+					echo '
247 254
 								<hr>
248 255
 								<p>', $section['posttext'], '</p>';
256
+		}
249 257
 	}
250 258
 
251 259
 	echo '
@@ -261,9 +269,10 @@  discard block
 block discarded – undo
261 269
 						smfSupportVersions.forum = "', $context['forum_version'], '";';
262 270
 
263 271
 	// Don't worry, none of this is logged, it's just used to give information that might be of use.
264
-	foreach ($context['current_versions'] as $variable => $version)
265
-		echo '
272
+	foreach ($context['current_versions'] as $variable => $version) {
273
+			echo '
266 274
 						smfSupportVersions.', $variable, ' = "', $version['version'], '";';
275
+	}
267 276
 
268 277
 	// Now we just have to include the script and wait ;).
269 278
 	echo '
@@ -360,8 +369,8 @@  discard block
 block discarded – undo
360 369
 								<tbody>';
361 370
 
362 371
 	// Loop through every source file displaying its version - using javascript.
363
-	foreach ($context['file_versions'] as $filename => $version)
364
-		echo '
372
+	foreach ($context['file_versions'] as $filename => $version) {
373
+			echo '
365 374
 									<tr class="windowbg">
366 375
 										<td class="half_table">
367 376
 											', $filename, '
@@ -373,6 +382,7 @@  discard block
 block discarded – undo
373 382
 											<em id="currentSources', $filename, '">??</em>
374 383
 										</td>
375 384
 									</tr>';
385
+	}
376 386
 
377 387
 	// Default template files.
378 388
 	echo '
@@ -398,8 +408,8 @@  discard block
 block discarded – undo
398 408
 							<table id="Default" class="table_grid">
399 409
 								<tbody>';
400 410
 
401
-	foreach ($context['default_template_versions'] as $filename => $version)
402
-		echo '
411
+	foreach ($context['default_template_versions'] as $filename => $version) {
412
+			echo '
403 413
 									<tr class="windowbg">
404 414
 										<td class="half_table">
405 415
 											', $filename, '
@@ -411,6 +421,7 @@  discard block
 block discarded – undo
411 421
 											<em id="currentDefault', $filename, '">??</em>
412 422
 										</td>
413 423
 									</tr>';
424
+	}
414 425
 
415 426
 	// Now the language files...
416 427
 	echo '
@@ -438,8 +449,8 @@  discard block
 block discarded – undo
438 449
 
439 450
 	foreach ($context['default_language_versions'] as $language => $files)
440 451
 	{
441
-		foreach ($files as $filename => $version)
442
-			echo '
452
+		foreach ($files as $filename => $version) {
453
+					echo '
443 454
 									<tr class="windowbg">
444 455
 										<td class="half_table">
445 456
 											', $filename, '.<em>', $language, '</em>.php
@@ -451,6 +462,7 @@  discard block
 block discarded – undo
451 462
 											<em id="current', $filename, '.', $language, '">??</em>
452 463
 										</td>
453 464
 									</tr>';
465
+		}
454 466
 	}
455 467
 
456 468
 	echo '
@@ -480,8 +492,8 @@  discard block
 block discarded – undo
480 492
 							<table id="Templates" class="table_grid">
481 493
 								<tbody>';
482 494
 
483
-		foreach ($context['template_versions'] as $filename => $version)
484
-			echo '
495
+		foreach ($context['template_versions'] as $filename => $version) {
496
+					echo '
485 497
 									<tr class="windowbg">
486 498
 										<td class="half_table">
487 499
 											', $filename, '
@@ -493,6 +505,7 @@  discard block
 block discarded – undo
493 505
 											<em id="currentTemplates', $filename, '">??</em>
494 506
 										</td>
495 507
 									</tr>';
508
+		}
496 509
 
497 510
 		echo '
498 511
 								</tbody>
@@ -522,8 +535,8 @@  discard block
 block discarded – undo
522 535
 							<table id="Tasks" class="table_grid">
523 536
 								<tbody>';
524 537
 
525
-		foreach ($context['tasks_versions'] as $filename => $version)
526
-			echo '
538
+		foreach ($context['tasks_versions'] as $filename => $version) {
539
+					echo '
527 540
 									<tr class="windowbg">
528 541
 										<td class="half_table">
529 542
 											', $filename, '
@@ -535,6 +548,7 @@  discard block
 block discarded – undo
535 548
 											<em id="currentTasks', $filename, '">??</em>
536 549
 										</td>
537 550
 									</tr>';
551
+		}
538 552
 
539 553
 		echo '
540 554
 								</tbody>
@@ -576,9 +590,10 @@  discard block
 block discarded – undo
576 590
 {
577 591
 	global $context, $scripturl, $txt, $modSettings;
578 592
 
579
-	if (!empty($context['saved_successful']))
580
-		echo '
593
+	if (!empty($context['saved_successful'])) {
594
+			echo '
581 595
 					<div class="infobox">', $txt['settings_saved'], '</div>';
596
+	}
582 597
 
583 598
 	// First section is for adding/removing words from the censored list.
584 599
 	echo '
@@ -593,11 +608,12 @@  discard block
 block discarded – undo
593 608
 								<p>', $txt['admin_censored_where'], '</p>';
594 609
 
595 610
 	// Show text boxes for censoring [bad   ] => [good  ].
596
-	foreach ($context['censored_words'] as $vulgar => $proper)
597
-		echo '
611
+	foreach ($context['censored_words'] as $vulgar => $proper) {
612
+			echo '
598 613
 								<div class="block">
599 614
 									<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> =&gt; <input type="text" name="censor_proper[]" value="', $proper, '" size="30">
600 615
 								</div>';
616
+	}
601 617
 
602 618
 	// Now provide a way to censor more words.
603 619
 	echo '
@@ -672,27 +688,30 @@  discard block
 block discarded – undo
672 688
 						<div class="windowbg">
673 689
 							', $txt['not_done_reason'];
674 690
 
675
-	if (!empty($context['continue_percent']))
676
-		echo '
691
+	if (!empty($context['continue_percent'])) {
692
+			echo '
677 693
 							<div class="progress_bar">
678 694
 								<span>', $context['continue_percent'], '%</span>
679 695
 								<div class="bar" style="width: ', $context['continue_percent'], '%;"></div>
680 696
 							</div>';
697
+	}
681 698
 
682
-	if (!empty($context['substep_enabled']))
683
-		echo '
699
+	if (!empty($context['substep_enabled'])) {
700
+			echo '
684 701
 							<div class="progress_bar progress_blue">
685 702
 								<span>', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</span>
686 703
 								<div class="bar" style="width: ', $context['substep_continue_percent'], '%;"></div>
687 704
 							</div>';
705
+	}
688 706
 
689 707
 	echo '
690 708
 							<form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">';
691 709
 
692 710
 	// Do we have a token?
693
-	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var']))
694
-		echo '
711
+	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var'])) {
712
+			echo '
695 713
 							<input type="hidden" name="', $context[$context['not_done_token'] . '_token_var'], '" value="', $context[$context['not_done_token'] . '_token'], '">';
714
+	}
696 715
 
697 716
 	echo '
698 717
 								<input type="submit" name="cont" value="', $txt['not_done_continue'], '" class="button">
@@ -726,35 +745,40 @@  discard block
 block discarded – undo
726 745
 {
727 746
 	global $context, $txt, $scripturl;
728 747
 
729
-	if (!empty($context['saved_successful']))
730
-		echo '
748
+	if (!empty($context['saved_successful'])) {
749
+			echo '
731 750
 					<div class="infobox">', $txt['settings_saved'], '</div>';
732
-	elseif (!empty($context['saved_failed']))
733
-		echo '
751
+	} elseif (!empty($context['saved_failed'])) {
752
+			echo '
734 753
 					<div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>';
754
+	}
735 755
 
736
-	if (!empty($context['settings_pre_javascript']))
737
-		echo '
756
+	if (!empty($context['settings_pre_javascript'])) {
757
+			echo '
738 758
 					<script>', $context['settings_pre_javascript'], '</script>';
759
+	}
739 760
 
740
-	if (!empty($context['settings_insert_above']))
741
-		echo $context['settings_insert_above'];
761
+	if (!empty($context['settings_insert_above'])) {
762
+			echo $context['settings_insert_above'];
763
+	}
742 764
 
743 765
 	echo '
744 766
 					<div id="admincenter">
745 767
 						<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>';
746 768
 
747 769
 	// Is there a custom title?
748
-	if (isset($context['settings_title']))
749
-		echo '
770
+	if (isset($context['settings_title'])) {
771
+			echo '
750 772
 							<div class="cat_bar">
751 773
 								<h3 class="catbg">', $context['settings_title'], '</h3>
752 774
 							</div>';
775
+	}
753 776
 
754 777
 	// Have we got a message to display?
755
-	if (!empty($context['settings_message']))
756
-		echo '
778
+	if (!empty($context['settings_message'])) {
779
+			echo '
757 780
 							<div class="information">', $context['settings_message'], '</div>';
781
+	}
758 782
 
759 783
 	// Now actually loop through all the variables.
760 784
 	$is_open = false;
@@ -807,8 +831,9 @@  discard block
 block discarded – undo
807 831
 		// Hang about? Are you pulling my leg - a callback?!
808 832
 		if (is_array($config_var) && $config_var['type'] == 'callback')
809 833
 		{
810
-			if (function_exists('template_callback_' . $config_var['name']))
811
-				call_user_func('template_callback_' . $config_var['name']);
834
+			if (function_exists('template_callback_' . $config_var['name'])) {
835
+							call_user_func('template_callback_' . $config_var['name']);
836
+			}
812 837
 
813 838
 			continue;
814 839
 		}
@@ -838,9 +863,10 @@  discard block
 block discarded – undo
838 863
 				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
839 864
 
840 865
 				// Show the [?] button.
841
-				if ($config_var['help'])
842
-					echo '
866
+				if ($config_var['help']) {
867
+									echo '
843 868
 										<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ';
869
+				}
844 870
 
845 871
 				echo '
846 872
 										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
@@ -849,23 +875,26 @@  discard block
 block discarded – undo
849 875
 										$config_var['preinput'];
850 876
 
851 877
 				// Show a check box.
852
-				if ($config_var['type'] == 'check')
853
-					echo '
878
+				if ($config_var['type'] == 'check') {
879
+									echo '
854 880
 										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">';
881
+				}
855 882
 				// Escape (via htmlspecialchars.) the text box.
856
-				elseif ($config_var['type'] == 'password')
857
-					echo '
883
+				elseif ($config_var['type'] == 'password') {
884
+									echo '
858 885
 										<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br>
859 886
 										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>';
887
+				}
860 888
 				// Show a selection box.
861 889
 				elseif ($config_var['type'] == 'select')
862 890
 				{
863 891
 					echo '
864 892
 										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>';
865 893
 
866
-					foreach ($config_var['data'] as $option)
867
-						echo '
894
+					foreach ($config_var['data'] as $option) {
895
+											echo '
868 896
 											<option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>';
897
+					}
869 898
 					echo '
870 899
 										</select>';
871 900
 				}
@@ -882,16 +911,18 @@  discard block
 block discarded – undo
882 911
 
883 912
 					foreach ($context['board_list'] as $id_cat => $cat)
884 913
 					{
885
-						if (!$first)
886
-							echo '
914
+						if (!$first) {
915
+													echo '
887 916
 											<hr>';
917
+						}
888 918
 						echo '
889 919
 											<strong>', $cat['name'], '</strong>
890 920
 											<ul>';
891 921
 
892
-						foreach ($cat['boards'] as $id_board => $brd)
893
-							echo '
922
+						foreach ($cat['boards'] as $id_board => $brd) {
923
+													echo '
894 924
 												<li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat('&nbsp; &nbsp;', $brd['child_level']) : '', $brd['name'], '</label></li>';
925
+						}
895 926
 
896 927
 						echo '
897 928
 											</ul>';
@@ -901,12 +932,14 @@  discard block
 block discarded – undo
901 932
 										</fieldset>';
902 933
 				}
903 934
 				// Text area?
904
-				elseif ($config_var['type'] == 'large_text')
905
-					echo '
935
+				elseif ($config_var['type'] == 'large_text') {
936
+									echo '
906 937
 										<textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>';
938
+				}
907 939
 				// Permission group?
908
-				elseif ($config_var['type'] == 'permissions')
909
-					theme_inline_permissions($config_var['name']);
940
+				elseif ($config_var['type'] == 'permissions') {
941
+									theme_inline_permissions($config_var['name']);
942
+				}
910 943
 
911 944
 				// BBC selection?
912 945
 				elseif ($config_var['type'] == 'bbc')
@@ -918,22 +951,24 @@  discard block
 block discarded – undo
918 951
 
919 952
 					foreach ($context['bbc_columns'] as $bbcColumn)
920 953
 					{
921
-						foreach ($bbcColumn as $bbcTag)
922
-							echo '
954
+						foreach ($bbcColumn as $bbcTag) {
955
+													echo '
923 956
 												<li class="list_bbc floatleft">
924 957
 													<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', '
925 958
 												</li>';
959
+						}
926 960
 					}
927 961
 					echo '					</ul>
928 962
 											<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
929 963
 										</fieldset>';
930 964
 				}
931 965
 				// A simple message?
932
-				elseif ($config_var['type'] == 'var_message')
933
-					echo '
966
+				elseif ($config_var['type'] == 'var_message') {
967
+									echo '
934 968
 										<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>
935 969
 											', $config_var['var_message'], '
936 970
 										</div>';
971
+				}
937 972
 				// Assume it must be a text box
938 973
 				else
939 974
 				{
@@ -958,62 +993,70 @@  discard block
 block discarded – undo
958 993
 											' . $config_var['postinput'] : '','
959 994
 									</dd>';
960 995
 			}
961
-		}
962
-		else
996
+		} else
963 997
 		{
964 998
 			// Just show a separator.
965
-			if ($config_var == '')
966
-				echo '
999
+			if ($config_var == '') {
1000
+							echo '
967 1001
 								</dl>
968 1002
 								<hr>
969 1003
 								<dl class="settings">';
970
-			else
971
-				echo '
1004
+			} else {
1005
+							echo '
972 1006
 									<dd>
973 1007
 										<strong>' . $config_var . '</strong>
974 1008
 									</dd>';
1009
+			}
975 1010
 		}
976 1011
 	}
977 1012
 
978
-	if ($is_open)
979
-		echo '
1013
+	if ($is_open) {
1014
+			echo '
980 1015
 								</dl>';
1016
+	}
981 1017
 
982
-	if (empty($context['settings_save_dont_show']))
983
-		echo '
1018
+	if (empty($context['settings_save_dont_show'])) {
1019
+			echo '
984 1020
 								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">';
1021
+	}
985 1022
 
986
-	if ($is_open)
987
-		echo '
1023
+	if ($is_open) {
1024
+			echo '
988 1025
 							</div><!-- .windowbg -->';
1026
+	}
989 1027
 
990 1028
 
991 1029
 	// At least one token has to be used!
992
-	if (isset($context['admin-ssc_token']))
993
-		echo '
1030
+	if (isset($context['admin-ssc_token'])) {
1031
+			echo '
994 1032
 							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
1033
+	}
995 1034
 
996
-	if (isset($context['admin-dbsc_token']))
997
-		echo '
1035
+	if (isset($context['admin-dbsc_token'])) {
1036
+			echo '
998 1037
 							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
1038
+	}
999 1039
 
1000
-	if (isset($context['admin-mp_token']))
1001
-		echo '
1040
+	if (isset($context['admin-mp_token'])) {
1041
+			echo '
1002 1042
 							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
1043
+	}
1003 1044
 
1004 1045
 	echo '
1005 1046
 							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1006 1047
 						</form>
1007 1048
 					</div><!-- #admincenter -->';
1008 1049
 
1009
-	if (!empty($context['settings_post_javascript']))
1010
-		echo '
1050
+	if (!empty($context['settings_post_javascript'])) {
1051
+			echo '
1011 1052
 					<script>
1012 1053
 						', $context['settings_post_javascript'], '
1013 1054
 					</script>';
1055
+	}
1014 1056
 
1015
-	if (!empty($context['settings_insert_below']))
1016
-		echo $context['settings_insert_below'];
1057
+	if (!empty($context['settings_insert_below'])) {
1058
+			echo $context['settings_insert_below'];
1059
+	}
1017 1060
 
1018 1061
 	// We may have added a board listing. If we did, we need to make it work.
1019 1062
 	addInlineJavascript('
@@ -1036,9 +1079,10 @@  discard block
 block discarded – undo
1036 1079
 {
1037 1080
 	global $context, $txt;
1038 1081
 
1039
-	if (!empty($context['saved_successful']))
1040
-		echo '
1082
+	if (!empty($context['saved_successful'])) {
1083
+			echo '
1041 1084
 					<div class="infobox">', $txt['settings_saved'], '</div>';
1085
+	}
1042 1086
 
1043 1087
 	// Standard fields.
1044 1088
 	template_show_list('standard_profile_fields');
@@ -1072,11 +1116,12 @@  discard block
 block discarded – undo
1072 1116
 	{
1073 1117
 		loadLanguage('Errors');
1074 1118
 
1075
-		if (isset($txt['custom_option_' . $_GET['msg']]))
1076
-			echo '
1119
+		if (isset($txt['custom_option_' . $_GET['msg']])) {
1120
+					echo '
1077 1121
 					<div class="errorbox">',
1078 1122
 						$txt['custom_option_' . $_GET['msg']], '
1079 1123
 					</div>';
1124
+		}
1080 1125
 	}
1081 1126
 
1082 1127
 	echo '
@@ -1143,9 +1188,10 @@  discard block
 block discarded – undo
1143 1188
 										<dd>
1144 1189
 											<select name="placement" id="placement">';
1145 1190
 
1146
-	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1147
-		echo '
1191
+	foreach ($context['cust_profile_fields_placement'] as $order => $name) {
1192
+			echo '
1148 1193
 												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1194
+	}
1149 1195
 
1150 1196
 	echo '
1151 1197
 											</select>
@@ -1169,9 +1215,10 @@  discard block
 block discarded – undo
1169 1215
 										<dd>
1170 1216
 											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1171 1217
 
1172
-	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1173
-		echo '
1218
+	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) {
1219
+			echo '
1174 1220
 												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1221
+	}
1175 1222
 
1176 1223
 	echo '
1177 1224
 											</select>
@@ -1203,9 +1250,10 @@  discard block
 block discarded – undo
1203 1250
 										</dt>
1204 1251
 										<dd id="options_dd">';
1205 1252
 
1206
-	foreach ($context['field']['options'] as $k => $option)
1207
-		echo '
1253
+	foreach ($context['field']['options'] as $k => $option) {
1254
+			echo '
1208 1255
 											', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">';
1256
+	}
1209 1257
 
1210 1258
 	echo '
1211 1259
 											<span id="addopt"></span>
@@ -1269,9 +1317,10 @@  discard block
 block discarded – undo
1269 1317
 								</fieldset>
1270 1318
 								<input type="submit" name="save" value="', $txt['save'], '" class="button">';
1271 1319
 
1272
-	if ($context['fid'])
1273
-		echo '
1320
+	if ($context['fid']) {
1321
+			echo '
1274 1322
 								<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">';
1323
+	}
1275 1324
 
1276 1325
 	echo '
1277 1326
 							</div><!-- .windowbg -->
@@ -1318,8 +1367,7 @@  discard block
 block discarded – undo
1318 1367
 							<p class="centertext">
1319 1368
 								<strong>', $txt['admin_search_results_none'], '</strong>
1320 1369
 							</p>';
1321
-	}
1322
-	else
1370
+	} else
1323 1371
 	{
1324 1372
 		echo '
1325 1373
 							<ol class="search_results">';
@@ -1346,9 +1394,10 @@  discard block
 block discarded – undo
1346 1394
 								<li>
1347 1395
 									<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1348 1396
 
1349
-				if ($result['help'])
1350
-					echo '
1397
+				if ($result['help']) {
1398
+									echo '
1351 1399
 									<p class="double_height">', $result['help'], '</p>';
1400
+				}
1352 1401
 
1353 1402
 				echo '
1354 1403
 								</li>';
@@ -1388,10 +1437,11 @@  discard block
 block discarded – undo
1388 1437
 									<strong>', $txt['setup_verification_answer'], '</strong>
1389 1438
 								</dd>';
1390 1439
 
1391
-		if (!empty($context['qa_by_lang'][$lang_id]))
1392
-			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1440
+		if (!empty($context['qa_by_lang'][$lang_id])) {
1441
+					foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1393 1442
 			{
1394 1443
 				$question = $context['question_answers'][$q_id];
1444
+		}
1395 1445
 
1396 1446
 				echo '
1397 1447
 								<dt>
@@ -1399,9 +1449,10 @@  discard block
 block discarded – undo
1399 1449
 								</dt>
1400 1450
 								<dd>';
1401 1451
 
1402
-				foreach ($question['answers'] as $answer)
1403
-					echo '
1452
+				foreach ($question['answers'] as $answer) {
1453
+									echo '
1404 1454
 									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">';
1455
+				}
1405 1456
 
1406 1457
 				echo '
1407 1458
 									<div class="qa_add_answer"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
@@ -1440,11 +1491,12 @@  discard block
 block discarded – undo
1440 1491
 							', $txt['errors_found'], ':
1441 1492
 							<ul>';
1442 1493
 
1443
-			foreach ($context['repair_errors'] as $error)
1444
-				echo '
1494
+			foreach ($context['repair_errors'] as $error) {
1495
+							echo '
1445 1496
 								<li>
1446 1497
 									', $error, '
1447 1498
 								</li>';
1499
+			}
1448 1500
 
1449 1501
 			echo '
1450 1502
 							</ul>
@@ -1454,15 +1506,14 @@  discard block
 block discarded – undo
1454 1506
 							<p class="padding">
1455 1507
 								<strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong>
1456 1508
 							</p>';
1457
-		}
1458
-		else
1459
-			echo '
1509
+		} else {
1510
+					echo '
1460 1511
 							<p>', $txt['maintain_no_errors'], '</p>
1461 1512
 							<p class="padding">
1462 1513
 								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1463 1514
 							</p>';
1464
-	}
1465
-	else
1515
+		}
1516
+	} else
1466 1517
 	{
1467 1518
 		if (!empty($context['redirect_to_recount']))
1468 1519
 		{
@@ -1474,8 +1525,7 @@  discard block
 block discarded – undo
1474 1525
 								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1475 1526
 								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1476 1527
 							</form>';
1477
-		}
1478
-		else
1528
+		} else
1479 1529
 		{
1480 1530
 			echo '
1481 1531
 							<p>', $txt['errors_fixed'], '</p>
@@ -1566,9 +1616,10 @@  discard block
 block discarded – undo
1566 1616
 								<tr class="windowbg">
1567 1617
 									<td class="equal_table">', $key, '</td>';
1568 1618
 
1569
-				foreach ($setting as $key_lm => $value)
1570
-					echo '
1619
+				foreach ($setting as $key_lm => $value) {
1620
+									echo '
1571 1621
 									<td class="equal_table">', $value, '</td>';
1622
+				}
1572 1623
 
1573 1624
 				echo '
1574 1625
 								</tr>';
@@ -1628,8 +1679,8 @@  discard block
 block discarded – undo
1628 1679
 {
1629 1680
 	global $context, $txt;
1630 1681
 
1631
-	if ($context['user']['is_admin'])
1632
-		echo '
1682
+	if ($context['user']['is_admin']) {
1683
+			echo '
1633 1684
 								<span class="floatright admin_search">
1634 1685
 									<span class="generic_icons filter centericon"></span>
1635 1686
 									<input type="search" name="search_term" placeholder="', $txt['admin_search'], '">
@@ -1640,6 +1691,7 @@  discard block
 block discarded – undo
1640 1691
 									</select>
1641 1692
 									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button">
1642 1693
 								</span>';
1643
-}
1694
+	}
1695
+	}
1644 1696
 
1645 1697
 ?>
1646 1698
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs.php 1 patch
Braces   +1480 added lines, -1106 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
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
  * Update some basic statistics.
@@ -122,10 +123,11 @@  discard block
 block discarded – undo
122 123
 						$smcFunc['db_free_result']($result);
123 124
 
124 125
 						// Add this to the number of unapproved members
125
-						if (!empty($changes['unapprovedMembers']))
126
-							$changes['unapprovedMembers'] += $coppa_approvals;
127
-						else
128
-							$changes['unapprovedMembers'] = $coppa_approvals;
126
+						if (!empty($changes['unapprovedMembers'])) {
127
+													$changes['unapprovedMembers'] += $coppa_approvals;
128
+						} else {
129
+													$changes['unapprovedMembers'] = $coppa_approvals;
130
+						}
129 131
 					}
130 132
 				}
131 133
 			}
@@ -133,9 +135,9 @@  discard block
 block discarded – undo
133 135
 			break;
134 136
 
135 137
 		case 'message':
136
-			if ($parameter1 === true && $parameter2 !== null)
137
-				updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
138
-			else
138
+			if ($parameter1 === true && $parameter2 !== null) {
139
+							updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
140
+			} else
139 141
 			{
140 142
 				// SUM and MAX on a smaller table is better for InnoDB tables.
141 143
 				$result = $smcFunc['db_query']('', '
@@ -175,24 +177,25 @@  discard block
 block discarded – undo
175 177
 				$parameter2 = text2words($parameter2);
176 178
 
177 179
 				$inserts = array();
178
-				foreach ($parameter2 as $word)
179
-					$inserts[] = array($word, $parameter1);
180
+				foreach ($parameter2 as $word) {
181
+									$inserts[] = array($word, $parameter1);
182
+				}
180 183
 
181
-				if (!empty($inserts))
182
-					$smcFunc['db_insert']('ignore',
184
+				if (!empty($inserts)) {
185
+									$smcFunc['db_insert']('ignore',
183 186
 						'{db_prefix}log_search_subjects',
184 187
 						array('word' => 'string', 'id_topic' => 'int'),
185 188
 						$inserts,
186 189
 						array('word', 'id_topic')
187 190
 					);
191
+				}
188 192
 			}
189 193
 			break;
190 194
 
191 195
 		case 'topic':
192
-			if ($parameter1 === true)
193
-				updateSettings(array('totalTopics' => true), true);
194
-
195
-			else
196
+			if ($parameter1 === true) {
197
+							updateSettings(array('totalTopics' => true), true);
198
+			} else
196 199
 			{
197 200
 				// Get the number of topics - a SUM is better for InnoDB tables.
198 201
 				// We also ignore the recycle bin here because there will probably be a bunch of one-post topics there.
@@ -213,8 +216,9 @@  discard block
 block discarded – undo
213 216
 
214 217
 		case 'postgroups':
215 218
 			// Parameter two is the updated columns: we should check to see if we base groups off any of these.
216
-			if ($parameter2 !== null && !in_array('posts', $parameter2))
217
-				return;
219
+			if ($parameter2 !== null && !in_array('posts', $parameter2)) {
220
+							return;
221
+			}
218 222
 
219 223
 			$postgroups = cache_get_data('updateStats:postgroups', 360);
220 224
 			if ($postgroups == null || $parameter1 == null)
@@ -229,8 +233,9 @@  discard block
 block discarded – undo
229 233
 					)
230 234
 				);
231 235
 				$postgroups = array();
232
-				while ($row = $smcFunc['db_fetch_assoc']($request))
233
-					$postgroups[$row['id_group']] = $row['min_posts'];
236
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
237
+									$postgroups[$row['id_group']] = $row['min_posts'];
238
+				}
234 239
 
235 240
 				$smcFunc['db_free_result']($request);
236 241
 
@@ -241,8 +246,9 @@  discard block
 block discarded – undo
241 246
 			}
242 247
 
243 248
 			// Oh great, they've screwed their post groups.
244
-			if (empty($postgroups))
245
-				return;
249
+			if (empty($postgroups)) {
250
+							return;
251
+			}
246 252
 
247 253
 			// Set all membergroups from most posts to least posts.
248 254
 			$conditions = '';
@@ -301,12 +307,9 @@  discard block
 block discarded – undo
301 307
 	{
302 308
 		$condition = 'id_member IN ({array_int:members})';
303 309
 		$parameters['members'] = $members;
304
-	}
305
-
306
-	elseif ($members === null)
307
-		$condition = '1=1';
308
-
309
-	else
310
+	} elseif ($members === null) {
311
+			$condition = '1=1';
312
+	} else
310 313
 	{
311 314
 		$condition = 'id_member = {int:member}';
312 315
 		$parameters['member'] = $members;
@@ -346,9 +349,9 @@  discard block
 block discarded – undo
346 349
 		if (count($vars_to_integrate) != 0)
347 350
 		{
348 351
 			// Fetch a list of member_names if necessary
349
-			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members)))
350
-				$member_names = array($user_info['username']);
351
-			else
352
+			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) {
353
+							$member_names = array($user_info['username']);
354
+			} else
352 355
 			{
353 356
 				$member_names = array();
354 357
 				$request = $smcFunc['db_query']('', '
@@ -357,14 +360,16 @@  discard block
 block discarded – undo
357 360
 					WHERE ' . $condition,
358 361
 					$parameters
359 362
 				);
360
-				while ($row = $smcFunc['db_fetch_assoc']($request))
361
-					$member_names[] = $row['member_name'];
363
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
364
+									$member_names[] = $row['member_name'];
365
+				}
362 366
 				$smcFunc['db_free_result']($request);
363 367
 			}
364 368
 
365
-			if (!empty($member_names))
366
-				foreach ($vars_to_integrate as $var)
369
+			if (!empty($member_names)) {
370
+							foreach ($vars_to_integrate as $var)
367 371
 					call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats));
372
+			}
368 373
 		}
369 374
 	}
370 375
 
@@ -372,16 +377,17 @@  discard block
 block discarded – undo
372 377
 	foreach ($data as $var => $val)
373 378
 	{
374 379
 		$type = 'string';
375
-		if (in_array($var, $knownInts))
376
-			$type = 'int';
377
-		elseif (in_array($var, $knownFloats))
378
-			$type = 'float';
379
-		elseif ($var == 'birthdate')
380
-			$type = 'date';
381
-		elseif ($var == 'member_ip')
382
-			$type = 'inet';
383
-		elseif ($var == 'member_ip2')
384
-			$type = 'inet';
380
+		if (in_array($var, $knownInts)) {
381
+					$type = 'int';
382
+		} elseif (in_array($var, $knownFloats)) {
383
+					$type = 'float';
384
+		} elseif ($var == 'birthdate') {
385
+					$type = 'date';
386
+		} elseif ($var == 'member_ip') {
387
+					$type = 'inet';
388
+		} elseif ($var == 'member_ip2') {
389
+					$type = 'inet';
390
+		}
385 391
 
386 392
 		// Doing an increment?
387 393
 		if ($var == 'alerts' && ($val === '+' || $val === '-'))
@@ -390,18 +396,17 @@  discard block
 block discarded – undo
390 396
 			if (is_array($members))
391 397
 			{
392 398
 				$val = 'CASE ';
393
-				foreach ($members as $k => $v)
394
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
399
+				foreach ($members as $k => $v) {
400
+									$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
401
+				}
395 402
 				$val = $val . ' END';
396 403
 				$type = 'raw';
397
-			}
398
-			else
404
+			} else
399 405
 			{
400 406
 				$blub = fetch_alerts($members, false, 0, array(), false);
401 407
 				$val = count($blub);
402 408
 			}
403
-		}
404
-		else if ($type == 'int' && ($val === '+' || $val === '-'))
409
+		} else if ($type == 'int' && ($val === '+' || $val === '-'))
405 410
 		{
406 411
 			$val = $var . ' ' . $val . ' 1';
407 412
 			$type = 'raw';
@@ -412,8 +417,9 @@  discard block
 block discarded – undo
412 417
 		{
413 418
 			if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match))
414 419
 			{
415
-				if ($match[1] != '+ ')
416
-					$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
420
+				if ($match[1] != '+ ') {
421
+									$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
422
+				}
417 423
 				$type = 'raw';
418 424
 			}
419 425
 		}
@@ -434,8 +440,9 @@  discard block
 block discarded – undo
434 440
 	// Clear any caching?
435 441
 	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members))
436 442
 	{
437
-		if (!is_array($members))
438
-			$members = array($members);
443
+		if (!is_array($members)) {
444
+					$members = array($members);
445
+		}
439 446
 
440 447
 		foreach ($members as $member)
441 448
 		{
@@ -468,29 +475,32 @@  discard block
 block discarded – undo
468 475
 {
469 476
 	global $modSettings, $smcFunc;
470 477
 
471
-	if (empty($changeArray) || !is_array($changeArray))
472
-		return;
478
+	if (empty($changeArray) || !is_array($changeArray)) {
479
+			return;
480
+	}
473 481
 
474 482
 	$toRemove = array();
475 483
 
476 484
 	// Go check if there is any setting to be removed.
477
-	foreach ($changeArray as $k => $v)
478
-		if ($v === null)
485
+	foreach ($changeArray as $k => $v) {
486
+			if ($v === null)
479 487
 		{
480 488
 			// Found some, remove them from the original array and add them to ours.
481 489
 			unset($changeArray[$k]);
490
+	}
482 491
 			$toRemove[] = $k;
483 492
 		}
484 493
 
485 494
 	// Proceed with the deletion.
486
-	if (!empty($toRemove))
487
-		$smcFunc['db_query']('', '
495
+	if (!empty($toRemove)) {
496
+			$smcFunc['db_query']('', '
488 497
 			DELETE FROM {db_prefix}settings
489 498
 			WHERE variable IN ({array_string:remove})',
490 499
 			array(
491 500
 				'remove' => $toRemove,
492 501
 			)
493 502
 		);
503
+	}
494 504
 
495 505
 	// In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs.
496 506
 	if ($update)
@@ -519,19 +529,22 @@  discard block
 block discarded – undo
519 529
 	foreach ($changeArray as $variable => $value)
520 530
 	{
521 531
 		// Don't bother if it's already like that ;).
522
-		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value)
523
-			continue;
532
+		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) {
533
+					continue;
534
+		}
524 535
 		// If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it.
525
-		elseif (!isset($modSettings[$variable]) && empty($value))
526
-			continue;
536
+		elseif (!isset($modSettings[$variable]) && empty($value)) {
537
+					continue;
538
+		}
527 539
 
528 540
 		$replaceArray[] = array($variable, $value);
529 541
 
530 542
 		$modSettings[$variable] = $value;
531 543
 	}
532 544
 
533
-	if (empty($replaceArray))
534
-		return;
545
+	if (empty($replaceArray)) {
546
+			return;
547
+	}
535 548
 
536 549
 	$smcFunc['db_insert']('replace',
537 550
 		'{db_prefix}settings',
@@ -577,14 +590,17 @@  discard block
 block discarded – undo
577 590
 	$start_invalid = $start < 0;
578 591
 
579 592
 	// Make sure $start is a proper variable - not less than 0.
580
-	if ($start_invalid)
581
-		$start = 0;
593
+	if ($start_invalid) {
594
+			$start = 0;
595
+	}
582 596
 	// Not greater than the upper bound.
583
-	elseif ($start >= $max_value)
584
-		$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
597
+	elseif ($start >= $max_value) {
598
+			$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
599
+	}
585 600
 	// And it has to be a multiple of $num_per_page!
586
-	else
587
-		$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
601
+	else {
602
+			$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
603
+	}
588 604
 
589 605
 	$context['current_page'] = $start / $num_per_page;
590 606
 
@@ -614,77 +630,87 @@  discard block
 block discarded – undo
614 630
 
615 631
 		// Show all the pages.
616 632
 		$display_page = 1;
617
-		for ($counter = 0; $counter < $max_value; $counter += $num_per_page)
618
-			$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
633
+		for ($counter = 0; $counter < $max_value; $counter += $num_per_page) {
634
+					$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
635
+		}
619 636
 
620 637
 		// Show the right arrow.
621 638
 		$display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page);
622
-		if ($start != $counter - $max_value && !$start_invalid)
623
-			$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
624
-	}
625
-	else
639
+		if ($start != $counter - $max_value && !$start_invalid) {
640
+					$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
641
+		}
642
+	} else
626 643
 	{
627 644
 		// If they didn't enter an odd value, pretend they did.
628 645
 		$PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2;
629 646
 
630 647
 		// Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page)
631
-		if (!empty($start) && $show_prevnext)
632
-			$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
633
-		else
634
-			$pageindex .= '';
648
+		if (!empty($start) && $show_prevnext) {
649
+					$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
650
+		} else {
651
+					$pageindex .= '';
652
+		}
635 653
 
636 654
 		// Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15)
637
-		if ($start > $num_per_page * $PageContiguous)
638
-			$pageindex .= sprintf($base_link, 0, '1');
655
+		if ($start > $num_per_page * $PageContiguous) {
656
+					$pageindex .= sprintf($base_link, 0, '1');
657
+		}
639 658
 
640 659
 		// Show the ... after the first page.  (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page)
641
-		if ($start > $num_per_page * ($PageContiguous + 1))
642
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
660
+		if ($start > $num_per_page * ($PageContiguous + 1)) {
661
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
643 662
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
644 663
 				'{FIRST_PAGE}' => $num_per_page,
645 664
 				'{LAST_PAGE}' => $start - $num_per_page * $PageContiguous,
646 665
 				'{PER_PAGE}' => $num_per_page,
647 666
 			));
667
+		}
648 668
 
649 669
 		// Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page)
650
-		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--)
651
-			if ($start >= $num_per_page * $nCont)
670
+		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) {
671
+					if ($start >= $num_per_page * $nCont)
652 672
 			{
653 673
 				$tmpStart = $start - $num_per_page * $nCont;
674
+		}
654 675
 				$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
655 676
 			}
656 677
 
657 678
 		// Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page)
658
-		if (!$start_invalid)
659
-			$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
660
-		else
661
-			$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
679
+		if (!$start_invalid) {
680
+					$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
681
+		} else {
682
+					$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
683
+		}
662 684
 
663 685
 		// Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page)
664 686
 		$tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page;
665
-		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++)
666
-			if ($start + $num_per_page * $nCont <= $tmpMaxPages)
687
+		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) {
688
+					if ($start + $num_per_page * $nCont <= $tmpMaxPages)
667 689
 			{
668 690
 				$tmpStart = $start + $num_per_page * $nCont;
691
+		}
669 692
 				$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
670 693
 			}
671 694
 
672 695
 		// Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page)
673
-		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages)
674
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
696
+		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) {
697
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
675 698
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
676 699
 				'{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1),
677 700
 				'{LAST_PAGE}' => $tmpMaxPages,
678 701
 				'{PER_PAGE}' => $num_per_page,
679 702
 			));
703
+		}
680 704
 
681 705
 		// Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15<  next page)
682
-		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages)
683
-			$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
706
+		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) {
707
+					$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
708
+		}
684 709
 
685 710
 		// Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<)
686
-		if ($start != $tmpMaxPages && $show_prevnext)
687
-			$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
711
+		if ($start != $tmpMaxPages && $show_prevnext) {
712
+					$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
713
+		}
688 714
 	}
689 715
 	$pageindex .= $settings['page_index']['extra_after'];
690 716
 
@@ -710,8 +736,9 @@  discard block
 block discarded – undo
710 736
 	if ($decimal_separator === null)
711 737
 	{
712 738
 		// Not set for whatever reason?
713
-		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1)
714
-			return $number;
739
+		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) {
740
+					return $number;
741
+		}
715 742
 
716 743
 		// Cache these each load...
717 744
 		$thousands_separator = $matches[1];
@@ -752,17 +779,20 @@  discard block
 block discarded – undo
752 779
 	$user_info['time_format'] = !empty($user_info['time_format']) ? $user_info['time_format'] : (!empty($modSettings['time_format']) ? $modSettings['time_format'] : '%F %H:%M');
753 780
 
754 781
 	// Offset the time.
755
-	if (!$offset_type)
756
-		$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
782
+	if (!$offset_type) {
783
+			$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
784
+	}
757 785
 	// Just the forum offset?
758
-	elseif ($offset_type == 'forum')
759
-		$time = $log_time + $modSettings['time_offset'] * 3600;
760
-	else
761
-		$time = $log_time;
786
+	elseif ($offset_type == 'forum') {
787
+			$time = $log_time + $modSettings['time_offset'] * 3600;
788
+	} else {
789
+			$time = $log_time;
790
+	}
762 791
 
763 792
 	// We can't have a negative date (on Windows, at least.)
764
-	if ($log_time < 0)
765
-		$log_time = 0;
793
+	if ($log_time < 0) {
794
+			$log_time = 0;
795
+	}
766 796
 
767 797
 	// Today and Yesterday?
768 798
 	if ($modSettings['todayMod'] >= 1 && $show_today === true)
@@ -779,24 +809,27 @@  discard block
 block discarded – undo
779 809
 		{
780 810
 			$h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l';
781 811
 			$today_fmt = $h . ':%M' . $s . ' %p';
812
+		} else {
813
+					$today_fmt = '%H:%M' . $s;
782 814
 		}
783
-		else
784
-			$today_fmt = '%H:%M' . $s;
785 815
 
786 816
 		// Same day of the year, same year.... Today!
787
-		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
788
-			return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
817
+		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) {
818
+					return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
819
+		}
789 820
 
790 821
 		// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
791
-		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
792
-			return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
822
+		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) {
823
+					return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
824
+		}
793 825
 	}
794 826
 
795 827
 	$str = !is_bool($show_today) ? $show_today : $user_info['time_format'];
796 828
 
797 829
 	// Use the cached formats if available
798
-	if (is_null($finalizedFormats))
799
-		$finalizedFormats = (array) cache_get_data('timeformatstrings', 86400);
830
+	if (is_null($finalizedFormats)) {
831
+			$finalizedFormats = (array) cache_get_data('timeformatstrings', 86400);
832
+	}
800 833
 
801 834
 	// Make a supported version for this format if we don't already have one
802 835
 	if (empty($finalizedFormats[$str]))
@@ -825,8 +858,9 @@  discard block
 block discarded – undo
825 858
 		);
826 859
 
827 860
 		// No need to do this part again if we already did it once
828
-		if (is_null($unsupportedFormats))
829
-			$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
861
+		if (is_null($unsupportedFormats)) {
862
+					$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
863
+		}
830 864
 		if (empty($unsupportedFormats))
831 865
 		{
832 866
 			foreach($strftimeFormatSubstitutions as $format => $substitution)
@@ -842,20 +876,23 @@  discard block
 block discarded – undo
842 876
 
843 877
 				// Windows will return false for unsupported formats
844 878
 				// Other operating systems return the format string as a literal
845
-				if ($value === false || $value === $format)
846
-					$unsupportedFormats[] = $format;
879
+				if ($value === false || $value === $format) {
880
+									$unsupportedFormats[] = $format;
881
+				}
847 882
 			}
848 883
 			cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400);
849 884
 		}
850 885
 
851 886
 		// Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q'
852
-		if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
853
-			$timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '&#37;', $timeformat);
887
+		if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
888
+					$timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '&#37;', $timeformat);
889
+		}
854 890
 
855 891
 		// Substitute unsupported formats with supported ones
856
-		if (!empty($unsupportedFormats))
857
-			while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches))
892
+		if (!empty($unsupportedFormats)) {
893
+					while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches))
858 894
 				$timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat);
895
+		}
859 896
 
860 897
 		// Remember this so we don't need to do it again
861 898
 		$finalizedFormats[$str] = $timeformat;
@@ -864,33 +901,39 @@  discard block
 block discarded – undo
864 901
 
865 902
 	$str = $finalizedFormats[$str];
866 903
 
867
-	if (!isset($locale_cache))
868
-		$locale_cache = setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : '');
904
+	if (!isset($locale_cache)) {
905
+			$locale_cache = setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : '');
906
+	}
869 907
 
870 908
 	if ($locale_cache !== false)
871 909
 	{
872 910
 		// Check if another process changed the locale
873
-		if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache)
874
-			setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : '');
911
+		if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) {
912
+					setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : '');
913
+		}
875 914
 
876
-		if (!isset($non_twelve_hour))
877
-			$non_twelve_hour = trim(strftime('%p')) === '';
878
-		if ($non_twelve_hour && strpos($str, '%p') !== false)
879
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
915
+		if (!isset($non_twelve_hour)) {
916
+					$non_twelve_hour = trim(strftime('%p')) === '';
917
+		}
918
+		if ($non_twelve_hour && strpos($str, '%p') !== false) {
919
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
920
+		}
880 921
 
881
-		foreach (array('%a', '%A', '%b', '%B') as $token)
882
-			if (strpos($str, $token) !== false)
922
+		foreach (array('%a', '%A', '%b', '%B') as $token) {
923
+					if (strpos($str, $token) !== false)
883 924
 				$str = str_replace($token, strftime($token, $time), $str);
884
-	}
885
-	else
925
+		}
926
+	} else
886 927
 	{
887 928
 		// Do-it-yourself time localization.  Fun.
888
-		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
889
-			if (strpos($str, $token) !== false)
929
+		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) {
930
+					if (strpos($str, $token) !== false)
890 931
 				$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
932
+		}
891 933
 
892
-		if (strpos($str, '%p') !== false)
893
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
934
+		if (strpos($str, '%p') !== false) {
935
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
936
+		}
894 937
 	}
895 938
 
896 939
 	// Format the time and then restore any literal percent characters
@@ -913,16 +956,19 @@  discard block
 block discarded – undo
913 956
 	static $translation = array();
914 957
 
915 958
 	// Determine the character set... Default to UTF-8
916
-	if (empty($context['character_set']))
917
-		$charset = 'UTF-8';
959
+	if (empty($context['character_set'])) {
960
+			$charset = 'UTF-8';
961
+	}
918 962
 	// Use ISO-8859-1 in place of non-supported ISO-8859 charsets...
919
-	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15')))
920
-		$charset = 'ISO-8859-1';
921
-	else
922
-		$charset = $context['character_set'];
963
+	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) {
964
+			$charset = 'ISO-8859-1';
965
+	} else {
966
+			$charset = $context['character_set'];
967
+	}
923 968
 
924
-	if (empty($translation))
925
-		$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
969
+	if (empty($translation)) {
970
+			$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
971
+	}
926 972
 
927 973
 	return strtr($string, $translation);
928 974
 }
@@ -944,8 +990,9 @@  discard block
 block discarded – undo
944 990
 	global $smcFunc;
945 991
 
946 992
 	// It was already short enough!
947
-	if ($smcFunc['strlen']($subject) <= $len)
948
-		return $subject;
993
+	if ($smcFunc['strlen']($subject) <= $len) {
994
+			return $subject;
995
+	}
949 996
 
950 997
 	// Shorten it by the length it was too long, and strip off junk from the end.
951 998
 	return $smcFunc['substr']($subject, 0, $len) . '...';
@@ -964,10 +1011,11 @@  discard block
 block discarded – undo
964 1011
 {
965 1012
 	global $user_info, $modSettings;
966 1013
 
967
-	if ($timestamp === null)
968
-		$timestamp = time();
969
-	elseif ($timestamp == 0)
970
-		return 0;
1014
+	if ($timestamp === null) {
1015
+			$timestamp = time();
1016
+	} elseif ($timestamp == 0) {
1017
+			return 0;
1018
+	}
971 1019
 
972 1020
 	return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600;
973 1021
 }
@@ -996,8 +1044,9 @@  discard block
 block discarded – undo
996 1044
 		$array[$i] = $array[$j];
997 1045
 		$array[$j] = $temp;
998 1046
 
999
-		for ($i = 1; $p[$i] == 0; $i++)
1000
-			$p[$i] = 1;
1047
+		for ($i = 1; $p[$i] == 0; $i++) {
1048
+					$p[$i] = 1;
1049
+		}
1001 1050
 
1002 1051
 		$orders[] = $array;
1003 1052
 	}
@@ -1029,12 +1078,14 @@  discard block
 block discarded – undo
1029 1078
 	static $disabled;
1030 1079
 
1031 1080
 	// Don't waste cycles
1032
-	if ($message === '')
1033
-		return '';
1081
+	if ($message === '') {
1082
+			return '';
1083
+	}
1034 1084
 
1035 1085
 	// Just in case it wasn't determined yet whether UTF-8 is enabled.
1036
-	if (!isset($context['utf8']))
1037
-		$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
1086
+	if (!isset($context['utf8'])) {
1087
+			$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
1088
+	}
1038 1089
 
1039 1090
 	// Clean up any cut/paste issues we may have
1040 1091
 	$message = sanitizeMSCutPaste($message);
@@ -1046,13 +1097,15 @@  discard block
 block discarded – undo
1046 1097
 		return $message;
1047 1098
 	}
1048 1099
 
1049
-	if ($smileys !== null && ($smileys == '1' || $smileys == '0'))
1050
-		$smileys = (bool) $smileys;
1100
+	if ($smileys !== null && ($smileys == '1' || $smileys == '0')) {
1101
+			$smileys = (bool) $smileys;
1102
+	}
1051 1103
 
1052 1104
 	if (empty($modSettings['enableBBC']) && $message !== false)
1053 1105
 	{
1054
-		if ($smileys === true)
1055
-			parsesmileys($message);
1106
+		if ($smileys === true) {
1107
+					parsesmileys($message);
1108
+		}
1056 1109
 
1057 1110
 		return $message;
1058 1111
 	}
@@ -1065,8 +1118,9 @@  discard block
 block discarded – undo
1065 1118
 	}
1066 1119
 
1067 1120
 	// Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker
1068
-	if (!empty($modSettings['autoLinkUrls']))
1069
-		set_tld_regex();
1121
+	if (!empty($modSettings['autoLinkUrls'])) {
1122
+			set_tld_regex();
1123
+	}
1070 1124
 
1071 1125
 	// Allow mods access before entering the main parse_bbc loop
1072 1126
 	call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
@@ -1080,12 +1134,14 @@  discard block
 block discarded – undo
1080 1134
 
1081 1135
 			$temp = explode(',', strtolower($modSettings['disabledBBC']));
1082 1136
 
1083
-			foreach ($temp as $tag)
1084
-				$disabled[trim($tag)] = true;
1137
+			foreach ($temp as $tag) {
1138
+							$disabled[trim($tag)] = true;
1139
+			}
1085 1140
 		}
1086 1141
 
1087
-		if (empty($modSettings['enableEmbeddedFlash']))
1088
-			$disabled['flash'] = true;
1142
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1143
+					$disabled['flash'] = true;
1144
+		}
1089 1145
 
1090 1146
 		/* The following bbc are formatted as an array, with keys as follows:
1091 1147
 
@@ -1214,8 +1270,9 @@  discard block
 block discarded – undo
1214 1270
 					$returnContext = '';
1215 1271
 
1216 1272
 					// BBC or the entire attachments feature is disabled
1217
-					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach']))
1218
-						return $data;
1273
+					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) {
1274
+											return $data;
1275
+					}
1219 1276
 
1220 1277
 					// Save the attach ID.
1221 1278
 					$attachID = $data;
@@ -1226,8 +1283,9 @@  discard block
 block discarded – undo
1226 1283
 					$currentAttachment = parseAttachBBC($attachID);
1227 1284
 
1228 1285
 					// parseAttachBBC will return a string ($txt key) rather than dying with a fatal_error. Up to you to decide what to do.
1229
-					if (is_string($currentAttachment))
1230
-						return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1286
+					if (is_string($currentAttachment)) {
1287
+											return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1288
+					}
1231 1289
 
1232 1290
 					if (!empty($currentAttachment['is_image']))
1233 1291
 					{
@@ -1243,15 +1301,17 @@  discard block
 block discarded – undo
1243 1301
 							$height = ' height="' . $currentAttachment['height'] . '"';
1244 1302
 						}
1245 1303
 
1246
-						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1247
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1248
-						else
1249
-							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1304
+						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) {
1305
+													$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1306
+						} else {
1307
+													$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1308
+						}
1250 1309
 					}
1251 1310
 
1252 1311
 					// No image. Show a link.
1253
-					else
1254
-						$returnContext .= $currentAttachment['link'];
1312
+					else {
1313
+											$returnContext .= $currentAttachment['link'];
1314
+					}
1255 1315
 
1256 1316
 					// Gotta append what we just did.
1257 1317
 					$data = $returnContext;
@@ -1305,8 +1365,9 @@  discard block
 block discarded – undo
1305 1365
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1306 1366
 						{
1307 1367
 							// Do PHP code coloring?
1308
-							if ($php_parts[$php_i] != '&lt;?php')
1309
-								continue;
1368
+							if ($php_parts[$php_i] != '&lt;?php') {
1369
+															continue;
1370
+							}
1310 1371
 
1311 1372
 							$php_string = '';
1312 1373
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1322,8 +1383,9 @@  discard block
 block discarded – undo
1322 1383
 						$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
1323 1384
 
1324 1385
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1325
-						if ($context['browser']['is_opera'])
1326
-							$data .= '&nbsp;';
1386
+						if ($context['browser']['is_opera']) {
1387
+													$data .= '&nbsp;';
1388
+						}
1327 1389
 					}
1328 1390
 				},
1329 1391
 				'block_level' => true,
@@ -1342,8 +1404,9 @@  discard block
 block discarded – undo
1342 1404
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1343 1405
 						{
1344 1406
 							// Do PHP code coloring?
1345
-							if ($php_parts[$php_i] != '&lt;?php')
1346
-								continue;
1407
+							if ($php_parts[$php_i] != '&lt;?php') {
1408
+															continue;
1409
+							}
1347 1410
 
1348 1411
 							$php_string = '';
1349 1412
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1359,8 +1422,9 @@  discard block
 block discarded – undo
1359 1422
 						$data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]);
1360 1423
 
1361 1424
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1362
-						if ($context['browser']['is_opera'])
1363
-							$data[0] .= '&nbsp;';
1425
+						if ($context['browser']['is_opera']) {
1426
+													$data[0] .= '&nbsp;';
1427
+						}
1364 1428
 					}
1365 1429
 				},
1366 1430
 				'block_level' => true,
@@ -1398,11 +1462,13 @@  discard block
 block discarded – undo
1398 1462
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1399 1463
 				'validate' => function (&$tag, &$data, $disabled)
1400 1464
 				{
1401
-					if (isset($disabled['url']))
1402
-						$tag['content'] = '$1';
1465
+					if (isset($disabled['url'])) {
1466
+											$tag['content'] = '$1';
1467
+					}
1403 1468
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1404
-					if (empty($scheme))
1405
-						$data[0] = '//' . ltrim($data[0], ':/');
1469
+					if (empty($scheme)) {
1470
+											$data[0] = '//' . ltrim($data[0], ':/');
1471
+					}
1406 1472
 				},
1407 1473
 				'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>',
1408 1474
 			),
@@ -1416,10 +1482,11 @@  discard block
 block discarded – undo
1416 1482
 				{
1417 1483
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1418 1484
 
1419
-					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches))
1420
-						$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1421
-					else
1422
-						$css = '';
1485
+					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) {
1486
+											$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1487
+					} else {
1488
+											$css = '';
1489
+					}
1423 1490
 
1424 1491
 					$data = $class . $css;
1425 1492
 				},
@@ -1434,8 +1501,9 @@  discard block
 block discarded – undo
1434 1501
 				{
1435 1502
 					$data = strtr($data, array('<br />' => ''));
1436 1503
 
1437
-					if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0)
1438
-						$data = 'ftp://' . $data;
1504
+					if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) {
1505
+											$data = 'ftp://' . $data;
1506
+					}
1439 1507
 				},
1440 1508
 			),
1441 1509
 			array(
@@ -1445,8 +1513,9 @@  discard block
 block discarded – undo
1445 1513
 				'after' => '</a>',
1446 1514
 				'validate' => function(&$tag, &$data, $disabled)
1447 1515
 				{
1448
-					if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0)
1449
-						$data = 'ftp://' . $data;
1516
+					if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) {
1517
+											$data = 'ftp://' . $data;
1518
+					}
1450 1519
 				},
1451 1520
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1452 1521
 				'disabled_after' => ' ($1)',
@@ -1506,17 +1575,20 @@  discard block
 block discarded – undo
1506 1575
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1507 1576
 					if ($image_proxy_enabled)
1508 1577
 					{
1509
-						if (!empty($user_info['possibly_robot']))
1510
-							return;
1578
+						if (!empty($user_info['possibly_robot'])) {
1579
+													return;
1580
+						}
1511 1581
 
1512
-						if (empty($scheme))
1513
-							$data = 'http://' . ltrim($data, ':/');
1582
+						if (empty($scheme)) {
1583
+													$data = 'http://' . ltrim($data, ':/');
1584
+						}
1514 1585
 
1515
-						if ($scheme != 'https')
1516
-							$data = get_proxied_url($data);
1586
+						if ($scheme != 'https') {
1587
+													$data = get_proxied_url($data);
1588
+						}
1589
+					} elseif (empty($scheme)) {
1590
+											$data = '//' . ltrim($data, ':/');
1517 1591
 					}
1518
-					elseif (empty($scheme))
1519
-						$data = '//' . ltrim($data, ':/');
1520 1592
 				},
1521 1593
 				'disabled_content' => '($1)',
1522 1594
 			),
@@ -1532,17 +1604,20 @@  discard block
 block discarded – undo
1532 1604
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1533 1605
 					if ($image_proxy_enabled)
1534 1606
 					{
1535
-						if (!empty($user_info['possibly_robot']))
1536
-							return;
1607
+						if (!empty($user_info['possibly_robot'])) {
1608
+													return;
1609
+						}
1537 1610
 
1538
-						if (empty($scheme))
1539
-							$data = 'http://' . ltrim($data, ':/');
1611
+						if (empty($scheme)) {
1612
+													$data = 'http://' . ltrim($data, ':/');
1613
+						}
1540 1614
 
1541
-						if ($scheme != 'https')
1542
-							$data = get_proxied_url($data);
1615
+						if ($scheme != 'https') {
1616
+													$data = get_proxied_url($data);
1617
+						}
1618
+					} elseif (empty($scheme)) {
1619
+											$data = '//' . ltrim($data, ':/');
1543 1620
 					}
1544
-					elseif (empty($scheme))
1545
-						$data = '//' . ltrim($data, ':/');
1546 1621
 				},
1547 1622
 				'disabled_content' => '($1)',
1548 1623
 			),
@@ -1554,8 +1629,9 @@  discard block
 block discarded – undo
1554 1629
 				{
1555 1630
 					$data = strtr($data, array('<br>' => ''));
1556 1631
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1557
-					if (empty($scheme))
1558
-						$data = '//' . ltrim($data, ':/');
1632
+					if (empty($scheme)) {
1633
+											$data = '//' . ltrim($data, ':/');
1634
+					}
1559 1635
 				},
1560 1636
 			),
1561 1637
 			array(
@@ -1566,13 +1642,14 @@  discard block
 block discarded – undo
1566 1642
 				'after' => '</a>',
1567 1643
 				'validate' => function (&$tag, &$data, $disabled)
1568 1644
 				{
1569
-					if (substr($data, 0, 1) == '#')
1570
-						$data = '#post_' . substr($data, 1);
1571
-					else
1645
+					if (substr($data, 0, 1) == '#') {
1646
+											$data = '#post_' . substr($data, 1);
1647
+					} else
1572 1648
 					{
1573 1649
 						$scheme = parse_url($data, PHP_URL_SCHEME);
1574
-						if (empty($scheme))
1575
-							$data = '//' . ltrim($data, ':/');
1650
+						if (empty($scheme)) {
1651
+													$data = '//' . ltrim($data, ':/');
1652
+						}
1576 1653
 					}
1577 1654
 				},
1578 1655
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
@@ -1663,8 +1740,9 @@  discard block
 block discarded – undo
1663 1740
 					{
1664 1741
 						$add_begin = substr(trim($data), 0, 5) != '&lt;?';
1665 1742
 						$data = highlight_php_code($add_begin ? '&lt;?php ' . $data . '?&gt;' : $data);
1666
-						if ($add_begin)
1667
-							$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1743
+						if ($add_begin) {
1744
+													$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1745
+						}
1668 1746
 					}
1669 1747
 				},
1670 1748
 				'block_level' => false,
@@ -1777,20 +1855,17 @@  discard block
 block discarded – undo
1777 1855
 					: function(&$tag, &$data, $disabled)
1778 1856
 					{
1779 1857
 
1780
-						if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50))
1781
-							$data[1] = '0 -2px 1px';
1782
-
1783
-						elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100))
1784
-							$data[1] = '2px 0 1px';
1785
-
1786
-						elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190))
1787
-							$data[1] = '0 2px 1px';
1788
-
1789
-						elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280))
1790
-							$data[1] = '-2px 0 1px';
1791
-
1792
-						else
1793
-							$data[1] = '1px 1px 1px';
1858
+						if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50)) {
1859
+													$data[1] = '0 -2px 1px';
1860
+						} elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100)) {
1861
+													$data[1] = '2px 0 1px';
1862
+						} elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190)) {
1863
+													$data[1] = '0 2px 1px';
1864
+						} elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280)) {
1865
+													$data[1] = '-2px 0 1px';
1866
+						} else {
1867
+													$data[1] = '1px 1px 1px';
1868
+						}
1794 1869
 					},
1795 1870
 			),
1796 1871
 			array(
@@ -1846,10 +1921,11 @@  discard block
 block discarded – undo
1846 1921
 				'content' => '$1',
1847 1922
 				'validate' => function (&$tag, &$data, $disabled)
1848 1923
 				{
1849
-					if (is_numeric($data))
1850
-						$data = timeformat($data);
1851
-					else
1852
-						$tag['content'] = '[time]$1[/time]';
1924
+					if (is_numeric($data)) {
1925
+											$data = timeformat($data);
1926
+					} else {
1927
+											$tag['content'] = '[time]$1[/time]';
1928
+					}
1853 1929
 				},
1854 1930
 			),
1855 1931
 			array(
@@ -1881,8 +1957,9 @@  discard block
 block discarded – undo
1881 1957
 				{
1882 1958
 					$data = strtr($data, array('<br>' => ''));
1883 1959
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1884
-					if (empty($scheme))
1885
-						$data = '//' . ltrim($data, ':/');
1960
+					if (empty($scheme)) {
1961
+											$data = '//' . ltrim($data, ':/');
1962
+					}
1886 1963
 				},
1887 1964
 			),
1888 1965
 			array(
@@ -1894,8 +1971,9 @@  discard block
 block discarded – undo
1894 1971
 				'validate' => function (&$tag, &$data, $disabled)
1895 1972
 				{
1896 1973
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1897
-					if (empty($scheme))
1898
-						$data = '//' . ltrim($data, ':/');
1974
+					if (empty($scheme)) {
1975
+											$data = '//' . ltrim($data, ':/');
1976
+					}
1899 1977
 				},
1900 1978
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1901 1979
 				'disabled_after' => ' ($1)',
@@ -1915,12 +1993,13 @@  discard block
 block discarded – undo
1915 1993
 		);
1916 1994
 
1917 1995
 		// Handle legacy bbc codes.
1918
-		foreach ($context['legacy_bbc'] as $bbc)
1919
-			$codes[] = array(
1996
+		foreach ($context['legacy_bbc'] as $bbc) {
1997
+					$codes[] = array(
1920 1998
 				'tag' => $bbc,
1921 1999
 				'before' => '',
1922 2000
 				'after' => '',
1923 2001
 			);
2002
+		}
1924 2003
 
1925 2004
 		// Let mods add new BBC without hassle.
1926 2005
 		call_integration_hook('integrate_bbc_codes', array(&$codes, &$no_autolink_tags));
@@ -1928,8 +2007,9 @@  discard block
 block discarded – undo
1928 2007
 		// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.
1929 2008
 		if ($message === false)
1930 2009
 		{
1931
-			if (isset($temp_bbc))
1932
-				$bbc_codes = $temp_bbc;
2010
+			if (isset($temp_bbc)) {
2011
+							$bbc_codes = $temp_bbc;
2012
+			}
1933 2013
 			usort($codes, function ($a, $b) {
1934 2014
 				return strcmp($a['tag'], $b['tag']);
1935 2015
 			});
@@ -1949,8 +2029,9 @@  discard block
 block discarded – undo
1949 2029
 		);
1950 2030
 		if (!isset($disabled['li']) && !isset($disabled['list']))
1951 2031
 		{
1952
-			foreach ($itemcodes as $c => $dummy)
1953
-				$bbc_codes[$c] = array();
2032
+			foreach ($itemcodes as $c => $dummy) {
2033
+							$bbc_codes[$c] = array();
2034
+			}
1954 2035
 		}
1955 2036
 
1956 2037
 		// Shhhh!
@@ -1971,12 +2052,14 @@  discard block
 block discarded – undo
1971 2052
 		foreach ($codes as $code)
1972 2053
 		{
1973 2054
 			// Make it easier to process parameters later
1974
-			if (!empty($code['parameters']))
1975
-				ksort($code['parameters'], SORT_STRING);
2055
+			if (!empty($code['parameters'])) {
2056
+							ksort($code['parameters'], SORT_STRING);
2057
+			}
1976 2058
 
1977 2059
 			// If we are not doing every tag only do ones we are interested in.
1978
-			if (empty($parse_tags) || in_array($code['tag'], $parse_tags))
1979
-				$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
2060
+			if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) {
2061
+							$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
2062
+			}
1980 2063
 		}
1981 2064
 		$codes = null;
1982 2065
 	}
@@ -1987,8 +2070,9 @@  discard block
 block discarded – undo
1987 2070
 		// It's likely this will change if the message is modified.
1988 2071
 		$cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']);
1989 2072
 
1990
-		if (($temp = cache_get_data($cache_key, 240)) != null)
1991
-			return $temp;
2073
+		if (($temp = cache_get_data($cache_key, 240)) != null) {
2074
+					return $temp;
2075
+		}
1992 2076
 
1993 2077
 		$cache_t = microtime();
1994 2078
 	}
@@ -2020,8 +2104,9 @@  discard block
 block discarded – undo
2020 2104
 		$disabled['flash'] = true;
2021 2105
 
2022 2106
 		// @todo Change maybe?
2023
-		if (!isset($_GET['images']))
2024
-			$disabled['img'] = true;
2107
+		if (!isset($_GET['images'])) {
2108
+					$disabled['img'] = true;
2109
+		}
2025 2110
 
2026 2111
 		// @todo Interface/setting to add more?
2027 2112
 	}
@@ -2032,8 +2117,9 @@  discard block
 block discarded – undo
2032 2117
 	$alltags = array();
2033 2118
 	foreach ($bbc_codes as $section)
2034 2119
 	{
2035
-		foreach ($section as $code)
2036
-			$alltags[] = $code['tag'];
2120
+		foreach ($section as $code) {
2121
+					$alltags[] = $code['tag'];
2122
+		}
2037 2123
 	}
2038 2124
 	$alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b';
2039 2125
 
@@ -2045,8 +2131,9 @@  discard block
 block discarded – undo
2045 2131
 		$pos = isset($matches[0][1]) ? $matches[0][1] : false;
2046 2132
 
2047 2133
 		// Failsafe.
2048
-		if ($pos === false || $last_pos > $pos)
2049
-			$pos = strlen($message) + 1;
2134
+		if ($pos === false || $last_pos > $pos) {
2135
+					$pos = strlen($message) + 1;
2136
+		}
2050 2137
 
2051 2138
 		// Can't have a one letter smiley, URL, or email! (sorry.)
2052 2139
 		if ($last_pos < $pos - 1)
@@ -2064,8 +2151,9 @@  discard block
 block discarded – undo
2064 2151
 
2065 2152
 				// <br> should be empty.
2066 2153
 				$empty_tags = array('br', 'hr');
2067
-				foreach ($empty_tags as $tag)
2068
-					$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . '>', $data);
2154
+				foreach ($empty_tags as $tag) {
2155
+									$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . '>', $data);
2156
+				}
2069 2157
 
2070 2158
 				// b, u, i, s, pre... basic tags.
2071 2159
 				$closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong');
@@ -2074,8 +2162,9 @@  discard block
 block discarded – undo
2074 2162
 					$diff = substr_count($data, '&lt;' . $tag . '&gt;') - substr_count($data, '&lt;/' . $tag . '&gt;');
2075 2163
 					$data = strtr($data, array('&lt;' . $tag . '&gt;' => '<' . $tag . '>', '&lt;/' . $tag . '&gt;' => '</' . $tag . '>'));
2076 2164
 
2077
-					if ($diff > 0)
2078
-						$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
2165
+					if ($diff > 0) {
2166
+											$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
2167
+					}
2079 2168
 				}
2080 2169
 
2081 2170
 				// Do <img ...> - with security... action= -> action-.
@@ -2088,8 +2177,9 @@  discard block
 block discarded – undo
2088 2177
 						$alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^&quot;|&quot;$~', '', $matches[3][$match]);
2089 2178
 
2090 2179
 						// Remove action= from the URL - no funny business, now.
2091
-						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0)
2092
-							$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
2180
+						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) {
2181
+													$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
2182
+						}
2093 2183
 
2094 2184
 						$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
2095 2185
 					}
@@ -2104,16 +2194,18 @@  discard block
 block discarded – undo
2104 2194
 				$no_autolink_area = false;
2105 2195
 				if (!empty($open_tags))
2106 2196
 				{
2107
-					foreach ($open_tags as $open_tag)
2108
-						if (in_array($open_tag['tag'], $no_autolink_tags))
2197
+					foreach ($open_tags as $open_tag) {
2198
+											if (in_array($open_tag['tag'], $no_autolink_tags))
2109 2199
 							$no_autolink_area = true;
2200
+					}
2110 2201
 				}
2111 2202
 
2112 2203
 				// Don't go backwards.
2113 2204
 				// @todo Don't think is the real solution....
2114 2205
 				$lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0;
2115
-				if ($pos < $lastAutoPos)
2116
-					$no_autolink_area = true;
2206
+				if ($pos < $lastAutoPos) {
2207
+									$no_autolink_area = true;
2208
+				}
2117 2209
 				$lastAutoPos = $pos;
2118 2210
 
2119 2211
 				if (!$no_autolink_area)
@@ -2218,29 +2310,33 @@  discard block
 block discarded – undo
2218 2310
 							$url = array_shift($matches);
2219 2311
 
2220 2312
 							// If this isn't a clean URL, bail out
2221
-							if ($url != sanitize_iri($url))
2222
-								return $url;
2313
+							if ($url != sanitize_iri($url)) {
2314
+															return $url;
2315
+							}
2223 2316
 
2224 2317
 							$scheme = parse_url($url, PHP_URL_SCHEME);
2225 2318
 
2226 2319
 							if ($scheme == 'mailto')
2227 2320
 							{
2228 2321
 								$email_address = str_replace('mailto:', '', $url);
2229
-								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false)
2230
-									return '[email=' . $email_address . ']' . $url . '[/email]';
2231
-								else
2232
-									return $url;
2322
+								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) {
2323
+																	return '[email=' . $email_address . ']' . $url . '[/email]';
2324
+								} else {
2325
+																	return $url;
2326
+								}
2233 2327
 							}
2234 2328
 
2235 2329
 							// Are we linking a schemeless URL or naked domain name (e.g. "example.com")?
2236
-							if (empty($scheme))
2237
-								$fullUrl = '//' . ltrim($url, ':/');
2238
-							else
2239
-								$fullUrl = $url;
2330
+							if (empty($scheme)) {
2331
+															$fullUrl = '//' . ltrim($url, ':/');
2332
+							} else {
2333
+															$fullUrl = $url;
2334
+							}
2240 2335
 
2241 2336
 							// Make sure that $fullUrl really is valid
2242
-							if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false)
2243
-								return $url;
2337
+							if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) {
2338
+															return $url;
2339
+							}
2244 2340
 
2245 2341
 							return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
2246 2342
 						}, $data);
@@ -2289,22 +2385,25 @@  discard block
 block discarded – undo
2289 2385
 		}
2290 2386
 
2291 2387
 		// Are we there yet?  Are we there yet?
2292
-		if ($pos >= strlen($message) - 1)
2293
-			break;
2388
+		if ($pos >= strlen($message) - 1) {
2389
+					break;
2390
+		}
2294 2391
 
2295 2392
 		$tags = strtolower($message[$pos + 1]);
2296 2393
 
2297 2394
 		if ($tags == '/' && !empty($open_tags))
2298 2395
 		{
2299 2396
 			$pos2 = strpos($message, ']', $pos + 1);
2300
-			if ($pos2 == $pos + 2)
2301
-				continue;
2397
+			if ($pos2 == $pos + 2) {
2398
+							continue;
2399
+			}
2302 2400
 
2303 2401
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2304 2402
 
2305 2403
 			// A closing tag that doesn't match any open tags? Skip it.
2306
-			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags)))
2307
-				continue;
2404
+			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) {
2405
+							continue;
2406
+			}
2308 2407
 
2309 2408
 			$to_close = array();
2310 2409
 			$block_level = null;
@@ -2312,8 +2411,9 @@  discard block
 block discarded – undo
2312 2411
 			do
2313 2412
 			{
2314 2413
 				$tag = array_pop($open_tags);
2315
-				if (!$tag)
2316
-					break;
2414
+				if (!$tag) {
2415
+									break;
2416
+				}
2317 2417
 
2318 2418
 				if (!empty($tag['block_level']))
2319 2419
 				{
@@ -2327,10 +2427,11 @@  discard block
 block discarded – undo
2327 2427
 					// The idea is, if we are LOOKING for a block level tag, we can close them on the way.
2328 2428
 					if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]]))
2329 2429
 					{
2330
-						foreach ($bbc_codes[$look_for[0]] as $temp)
2331
-							if ($temp['tag'] == $look_for)
2430
+						foreach ($bbc_codes[$look_for[0]] as $temp) {
2431
+													if ($temp['tag'] == $look_for)
2332 2432
 							{
2333 2433
 								$block_level = !empty($temp['block_level']);
2434
+						}
2334 2435
 								break;
2335 2436
 							}
2336 2437
 					}
@@ -2352,15 +2453,15 @@  discard block
 block discarded – undo
2352 2453
 			{
2353 2454
 				$open_tags = $to_close;
2354 2455
 				continue;
2355
-			}
2356
-			elseif (!empty($to_close) && $tag['tag'] != $look_for)
2456
+			} elseif (!empty($to_close) && $tag['tag'] != $look_for)
2357 2457
 			{
2358 2458
 				if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]]))
2359 2459
 				{
2360
-					foreach ($bbc_codes[$look_for[0]] as $temp)
2361
-						if ($temp['tag'] == $look_for)
2460
+					foreach ($bbc_codes[$look_for[0]] as $temp) {
2461
+											if ($temp['tag'] == $look_for)
2362 2462
 						{
2363 2463
 							$block_level = !empty($temp['block_level']);
2464
+					}
2364 2465
 							break;
2365 2466
 						}
2366 2467
 				}
@@ -2368,8 +2469,9 @@  discard block
 block discarded – undo
2368 2469
 				// We're not looking for a block level tag (or maybe even a tag that exists...)
2369 2470
 				if (!$block_level)
2370 2471
 				{
2371
-					foreach ($to_close as $tag)
2372
-						array_push($open_tags, $tag);
2472
+					foreach ($to_close as $tag) {
2473
+											array_push($open_tags, $tag);
2474
+					}
2373 2475
 					continue;
2374 2476
 				}
2375 2477
 			}
@@ -2382,14 +2484,17 @@  discard block
 block discarded – undo
2382 2484
 
2383 2485
 				// See the comment at the end of the big loop - just eating whitespace ;).
2384 2486
 				$whitespace_regex = '';
2385
-				if (!empty($tag['block_level']))
2386
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2487
+				if (!empty($tag['block_level'])) {
2488
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2489
+				}
2387 2490
 				// Trim one line of whitespace after unnested tags, but all of it after nested ones
2388
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2389
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2491
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2492
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2493
+				}
2390 2494
 
2391
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2392
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2495
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2496
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2497
+				}
2393 2498
 			}
2394 2499
 
2395 2500
 			if (!empty($to_close))
@@ -2402,8 +2507,9 @@  discard block
 block discarded – undo
2402 2507
 		}
2403 2508
 
2404 2509
 		// No tags for this character, so just keep going (fastest possible course.)
2405
-		if (!isset($bbc_codes[$tags]))
2406
-			continue;
2510
+		if (!isset($bbc_codes[$tags])) {
2511
+					continue;
2512
+		}
2407 2513
 
2408 2514
 		$inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1];
2409 2515
 		$tag = null;
@@ -2412,48 +2518,57 @@  discard block
 block discarded – undo
2412 2518
 			$pt_strlen = strlen($possible['tag']);
2413 2519
 
2414 2520
 			// Not a match?
2415
-			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag'])
2416
-				continue;
2521
+			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) {
2522
+							continue;
2523
+			}
2417 2524
 
2418 2525
 			$next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : '';
2419 2526
 
2420 2527
 			// A tag is the last char maybe
2421
-			if ($next_c == '')
2422
-				break;
2528
+			if ($next_c == '') {
2529
+							break;
2530
+			}
2423 2531
 
2424 2532
 			// A test validation?
2425
-			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0)
2426
-				continue;
2533
+			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) {
2534
+							continue;
2535
+			}
2427 2536
 			// Do we want parameters?
2428 2537
 			elseif (!empty($possible['parameters']))
2429 2538
 			{
2430
-				if ($next_c != ' ')
2431
-					continue;
2432
-			}
2433
-			elseif (isset($possible['type']))
2539
+				if ($next_c != ' ') {
2540
+									continue;
2541
+				}
2542
+			} elseif (isset($possible['type']))
2434 2543
 			{
2435 2544
 				// Do we need an equal sign?
2436
-				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
2437
-					continue;
2545
+				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') {
2546
+									continue;
2547
+				}
2438 2548
 				// Maybe we just want a /...
2439
-				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]')
2440
-					continue;
2549
+				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') {
2550
+									continue;
2551
+				}
2441 2552
 				// An immediate ]?
2442
-				if ($possible['type'] == 'unparsed_content' && $next_c != ']')
2443
-					continue;
2553
+				if ($possible['type'] == 'unparsed_content' && $next_c != ']') {
2554
+									continue;
2555
+				}
2444 2556
 			}
2445 2557
 			// No type means 'parsed_content', which demands an immediate ] without parameters!
2446
-			elseif ($next_c != ']')
2447
-				continue;
2558
+			elseif ($next_c != ']') {
2559
+							continue;
2560
+			}
2448 2561
 
2449 2562
 			// Check allowed tree?
2450
-			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents'])))
2451
-				continue;
2452
-			elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children']))
2453
-				continue;
2563
+			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) {
2564
+							continue;
2565
+			} elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) {
2566
+							continue;
2567
+			}
2454 2568
 			// If this is in the list of disallowed child tags, don't parse it.
2455
-			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children']))
2456
-				continue;
2569
+			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) {
2570
+							continue;
2571
+			}
2457 2572
 
2458 2573
 			$pos1 = $pos + 1 + $pt_strlen + 1;
2459 2574
 
@@ -2465,8 +2580,9 @@  discard block
 block discarded – undo
2465 2580
 				foreach ($open_tags as $open_quote)
2466 2581
 				{
2467 2582
 					// Every parent quote this quote has flips the styling
2468
-					if ($open_quote['tag'] == 'quote')
2469
-						$quote_alt = !$quote_alt;
2583
+					if ($open_quote['tag'] == 'quote') {
2584
+											$quote_alt = !$quote_alt;
2585
+					}
2470 2586
 				}
2471 2587
 				// Add a class to the quote to style alternating blockquotes
2472 2588
 				$possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">'));
@@ -2477,8 +2593,9 @@  discard block
 block discarded – undo
2477 2593
 			{
2478 2594
 				// Build a regular expression for each parameter for the current tag.
2479 2595
 				$preg = array();
2480
-				foreach ($possible['parameters'] as $p => $info)
2481
-					$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2596
+				foreach ($possible['parameters'] as $p => $info) {
2597
+									$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2598
+				}
2482 2599
 
2483 2600
 				// Extract the string that potentially holds our parameters.
2484 2601
 				$blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos));
@@ -2497,24 +2614,27 @@  discard block
 block discarded – undo
2497 2614
 
2498 2615
 					$match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0;
2499 2616
 
2500
-					if ($match)
2501
-						$blob_counter = count($blobs) + 1;
2617
+					if ($match) {
2618
+											$blob_counter = count($blobs) + 1;
2619
+					}
2502 2620
 				}
2503 2621
 
2504 2622
 				// Didn't match our parameter list, try the next possible.
2505
-				if (!$match)
2506
-					continue;
2623
+				if (!$match) {
2624
+									continue;
2625
+				}
2507 2626
 
2508 2627
 				$params = array();
2509 2628
 				for ($i = 1, $n = count($matches); $i < $n; $i += 2)
2510 2629
 				{
2511 2630
 					$key = strtok(ltrim($matches[$i]), '=');
2512
-					if (isset($possible['parameters'][$key]['value']))
2513
-						$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2514
-					elseif (isset($possible['parameters'][$key]['validate']))
2515
-						$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2516
-					else
2517
-						$params['{' . $key . '}'] = $matches[$i + 1];
2631
+					if (isset($possible['parameters'][$key]['value'])) {
2632
+											$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2633
+					} elseif (isset($possible['parameters'][$key]['validate'])) {
2634
+											$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2635
+					} else {
2636
+											$params['{' . $key . '}'] = $matches[$i + 1];
2637
+					}
2518 2638
 
2519 2639
 					// Just to make sure: replace any $ or { so they can't interpolate wrongly.
2520 2640
 					$params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '&#036;', '{' => '&#123;'));
@@ -2522,23 +2642,26 @@  discard block
 block discarded – undo
2522 2642
 
2523 2643
 				foreach ($possible['parameters'] as $p => $info)
2524 2644
 				{
2525
-					if (!isset($params['{' . $p . '}']))
2526
-						$params['{' . $p . '}'] = '';
2645
+					if (!isset($params['{' . $p . '}'])) {
2646
+											$params['{' . $p . '}'] = '';
2647
+					}
2527 2648
 				}
2528 2649
 
2529 2650
 				$tag = $possible;
2530 2651
 
2531 2652
 				// Put the parameters into the string.
2532
-				if (isset($tag['before']))
2533
-					$tag['before'] = strtr($tag['before'], $params);
2534
-				if (isset($tag['after']))
2535
-					$tag['after'] = strtr($tag['after'], $params);
2536
-				if (isset($tag['content']))
2537
-					$tag['content'] = strtr($tag['content'], $params);
2653
+				if (isset($tag['before'])) {
2654
+									$tag['before'] = strtr($tag['before'], $params);
2655
+				}
2656
+				if (isset($tag['after'])) {
2657
+									$tag['after'] = strtr($tag['after'], $params);
2658
+				}
2659
+				if (isset($tag['content'])) {
2660
+									$tag['content'] = strtr($tag['content'], $params);
2661
+				}
2538 2662
 
2539 2663
 				$pos1 += strlen($given_param_string);
2540
-			}
2541
-			else
2664
+			} else
2542 2665
 			{
2543 2666
 				$tag = $possible;
2544 2667
 				$params = array();
@@ -2549,8 +2672,9 @@  discard block
 block discarded – undo
2549 2672
 		// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
2550 2673
 		if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li']))
2551 2674
 		{
2552
-			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>')))
2553
-				continue;
2675
+			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) {
2676
+							continue;
2677
+			}
2554 2678
 
2555 2679
 			$tag = $itemcodes[$message[$pos + 1]];
2556 2680
 
@@ -2571,9 +2695,9 @@  discard block
 block discarded – undo
2571 2695
 			{
2572 2696
 				array_pop($open_tags);
2573 2697
 				$code = '</li>';
2698
+			} else {
2699
+							$code = '';
2574 2700
 			}
2575
-			else
2576
-				$code = '';
2577 2701
 
2578 2702
 			// Now we open a new tag.
2579 2703
 			$open_tags[] = array(
@@ -2620,12 +2744,14 @@  discard block
 block discarded – undo
2620 2744
 		}
2621 2745
 
2622 2746
 		// No tag?  Keep looking, then.  Silly people using brackets without actual tags.
2623
-		if ($tag === null)
2624
-			continue;
2747
+		if ($tag === null) {
2748
+					continue;
2749
+		}
2625 2750
 
2626 2751
 		// Propagate the list to the child (so wrapping the disallowed tag won't work either.)
2627
-		if (isset($inside['disallow_children']))
2628
-			$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2752
+		if (isset($inside['disallow_children'])) {
2753
+					$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2754
+		}
2629 2755
 
2630 2756
 		// Is this tag disabled?
2631 2757
 		if (isset($disabled[$tag['tag']]))
@@ -2635,14 +2761,13 @@  discard block
 block discarded – undo
2635 2761
 				$tag['before'] = !empty($tag['block_level']) ? '<div>' : '';
2636 2762
 				$tag['after'] = !empty($tag['block_level']) ? '</div>' : '';
2637 2763
 				$tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1');
2638
-			}
2639
-			elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2764
+			} elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2640 2765
 			{
2641 2766
 				$tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : '');
2642 2767
 				$tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : '');
2768
+			} else {
2769
+							$tag['content'] = $tag['disabled_content'];
2643 2770
 			}
2644
-			else
2645
-				$tag['content'] = $tag['disabled_content'];
2646 2771
 		}
2647 2772
 
2648 2773
 		// we use this a lot
@@ -2652,8 +2777,9 @@  discard block
 block discarded – undo
2652 2777
 		if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level']))
2653 2778
 		{
2654 2779
 			$n = count($open_tags) - 1;
2655
-			while (empty($open_tags[$n]['block_level']) && $n >= 0)
2656
-				$n--;
2780
+			while (empty($open_tags[$n]['block_level']) && $n >= 0) {
2781
+							$n--;
2782
+			}
2657 2783
 
2658 2784
 			// Close all the non block level tags so this tag isn't surrounded by them.
2659 2785
 			for ($i = count($open_tags) - 1; $i > $n; $i--)
@@ -2665,12 +2791,15 @@  discard block
 block discarded – undo
2665 2791
 
2666 2792
 				// Trim or eat trailing stuff... see comment at the end of the big loop.
2667 2793
 				$whitespace_regex = '';
2668
-				if (!empty($tag['block_level']))
2669
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2670
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2671
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2672
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2673
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2794
+				if (!empty($tag['block_level'])) {
2795
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2796
+				}
2797
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2798
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2799
+				}
2800
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2801
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2802
+				}
2674 2803
 
2675 2804
 				array_pop($open_tags);
2676 2805
 			}
@@ -2691,16 +2820,19 @@  discard block
 block discarded – undo
2691 2820
 		elseif ($tag['type'] == 'unparsed_content')
2692 2821
 		{
2693 2822
 			$pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1);
2694
-			if ($pos2 === false)
2695
-				continue;
2823
+			if ($pos2 === false) {
2824
+							continue;
2825
+			}
2696 2826
 
2697 2827
 			$data = substr($message, $pos1, $pos2 - $pos1);
2698 2828
 
2699
-			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>')
2700
-				$data = substr($data, 4);
2829
+			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') {
2830
+							$data = substr($data, 4);
2831
+			}
2701 2832
 
2702
-			if (isset($tag['validate']))
2703
-				$tag['validate']($tag, $data, $disabled, $params);
2833
+			if (isset($tag['validate'])) {
2834
+							$tag['validate']($tag, $data, $disabled, $params);
2835
+			}
2704 2836
 
2705 2837
 			$code = strtr($tag['content'], array('$1' => $data));
2706 2838
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen);
@@ -2715,34 +2847,40 @@  discard block
 block discarded – undo
2715 2847
 			if (isset($tag['quoted']))
2716 2848
 			{
2717 2849
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2718
-				if ($tag['quoted'] != 'optional' && !$quoted)
2719
-					continue;
2850
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2851
+									continue;
2852
+				}
2720 2853
 
2721
-				if ($quoted)
2722
-					$pos1 += 6;
2854
+				if ($quoted) {
2855
+									$pos1 += 6;
2856
+				}
2857
+			} else {
2858
+							$quoted = false;
2723 2859
 			}
2724
-			else
2725
-				$quoted = false;
2726 2860
 
2727 2861
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2728
-			if ($pos2 === false)
2729
-				continue;
2862
+			if ($pos2 === false) {
2863
+							continue;
2864
+			}
2730 2865
 
2731 2866
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2732
-			if ($pos3 === false)
2733
-				continue;
2867
+			if ($pos3 === false) {
2868
+							continue;
2869
+			}
2734 2870
 
2735 2871
 			$data = array(
2736 2872
 				substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))),
2737 2873
 				substr($message, $pos1, $pos2 - $pos1)
2738 2874
 			);
2739 2875
 
2740
-			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>')
2741
-				$data[0] = substr($data[0], 4);
2876
+			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') {
2877
+							$data[0] = substr($data[0], 4);
2878
+			}
2742 2879
 
2743 2880
 			// Validation for my parking, please!
2744
-			if (isset($tag['validate']))
2745
-				$tag['validate']($tag, $data, $disabled, $params);
2881
+			if (isset($tag['validate'])) {
2882
+							$tag['validate']($tag, $data, $disabled, $params);
2883
+			}
2746 2884
 
2747 2885
 			$code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));
2748 2886
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
@@ -2759,23 +2897,27 @@  discard block
 block discarded – undo
2759 2897
 		elseif ($tag['type'] == 'unparsed_commas_content')
2760 2898
 		{
2761 2899
 			$pos2 = strpos($message, ']', $pos1);
2762
-			if ($pos2 === false)
2763
-				continue;
2900
+			if ($pos2 === false) {
2901
+							continue;
2902
+			}
2764 2903
 
2765 2904
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2766
-			if ($pos3 === false)
2767
-				continue;
2905
+			if ($pos3 === false) {
2906
+							continue;
2907
+			}
2768 2908
 
2769 2909
 			// We want $1 to be the content, and the rest to be csv.
2770 2910
 			$data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1));
2771 2911
 			$data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1);
2772 2912
 
2773
-			if (isset($tag['validate']))
2774
-				$tag['validate']($tag, $data, $disabled, $params);
2913
+			if (isset($tag['validate'])) {
2914
+							$tag['validate']($tag, $data, $disabled, $params);
2915
+			}
2775 2916
 
2776 2917
 			$code = $tag['content'];
2777
-			foreach ($data as $k => $d)
2778
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2918
+			foreach ($data as $k => $d) {
2919
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2920
+			}
2779 2921
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
2780 2922
 			$pos += strlen($code) - 1 + 2;
2781 2923
 		}
@@ -2783,24 +2925,28 @@  discard block
 block discarded – undo
2783 2925
 		elseif ($tag['type'] == 'unparsed_commas')
2784 2926
 		{
2785 2927
 			$pos2 = strpos($message, ']', $pos1);
2786
-			if ($pos2 === false)
2787
-				continue;
2928
+			if ($pos2 === false) {
2929
+							continue;
2930
+			}
2788 2931
 
2789 2932
 			$data = explode(',', substr($message, $pos1, $pos2 - $pos1));
2790 2933
 
2791
-			if (isset($tag['validate']))
2792
-				$tag['validate']($tag, $data, $disabled, $params);
2934
+			if (isset($tag['validate'])) {
2935
+							$tag['validate']($tag, $data, $disabled, $params);
2936
+			}
2793 2937
 
2794 2938
 			// Fix after, for disabled code mainly.
2795
-			foreach ($data as $k => $d)
2796
-				$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2939
+			foreach ($data as $k => $d) {
2940
+							$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2941
+			}
2797 2942
 
2798 2943
 			$open_tags[] = $tag;
2799 2944
 
2800 2945
 			// Replace them out, $1, $2, $3, $4, etc.
2801 2946
 			$code = $tag['before'];
2802
-			foreach ($data as $k => $d)
2803
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2947
+			foreach ($data as $k => $d) {
2948
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2949
+			}
2804 2950
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1);
2805 2951
 			$pos += strlen($code) - 1 + 2;
2806 2952
 		}
@@ -2811,28 +2957,33 @@  discard block
 block discarded – undo
2811 2957
 			if (isset($tag['quoted']))
2812 2958
 			{
2813 2959
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2814
-				if ($tag['quoted'] != 'optional' && !$quoted)
2815
-					continue;
2960
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2961
+									continue;
2962
+				}
2816 2963
 
2817
-				if ($quoted)
2818
-					$pos1 += 6;
2964
+				if ($quoted) {
2965
+									$pos1 += 6;
2966
+				}
2967
+			} else {
2968
+							$quoted = false;
2819 2969
 			}
2820
-			else
2821
-				$quoted = false;
2822 2970
 
2823 2971
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2824
-			if ($pos2 === false)
2825
-				continue;
2972
+			if ($pos2 === false) {
2973
+							continue;
2974
+			}
2826 2975
 
2827 2976
 			$data = substr($message, $pos1, $pos2 - $pos1);
2828 2977
 
2829 2978
 			// Validation for my parking, please!
2830
-			if (isset($tag['validate']))
2831
-				$tag['validate']($tag, $data, $disabled, $params);
2979
+			if (isset($tag['validate'])) {
2980
+							$tag['validate']($tag, $data, $disabled, $params);
2981
+			}
2832 2982
 
2833 2983
 			// For parsed content, we must recurse to avoid security problems.
2834
-			if ($tag['type'] != 'unparsed_equals')
2835
-				$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2984
+			if ($tag['type'] != 'unparsed_equals') {
2985
+							$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2986
+			}
2836 2987
 
2837 2988
 			$tag['after'] = strtr($tag['after'], array('$1' => $data));
2838 2989
 
@@ -2844,34 +2995,40 @@  discard block
 block discarded – undo
2844 2995
 		}
2845 2996
 
2846 2997
 		// If this is block level, eat any breaks after it.
2847
-		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>')
2848
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2998
+		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') {
2999
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
3000
+		}
2849 3001
 
2850 3002
 		// Are we trimming outside this tag?
2851
-		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0)
2852
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
3003
+		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0) {
3004
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
3005
+		}
2853 3006
 	}
2854 3007
 
2855 3008
 	// Close any remaining tags.
2856
-	while ($tag = array_pop($open_tags))
2857
-		$message .= "\n" . $tag['after'] . "\n";
3009
+	while ($tag = array_pop($open_tags)) {
3010
+			$message .= "\n" . $tag['after'] . "\n";
3011
+	}
2858 3012
 
2859 3013
 	// Parse the smileys within the parts where it can be done safely.
2860 3014
 	if ($smileys === true)
2861 3015
 	{
2862 3016
 		$message_parts = explode("\n", $message);
2863
-		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2)
2864
-			parsesmileys($message_parts[$i]);
3017
+		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) {
3018
+					parsesmileys($message_parts[$i]);
3019
+		}
2865 3020
 
2866 3021
 		$message = implode('', $message_parts);
2867 3022
 	}
2868 3023
 
2869 3024
 	// No smileys, just get rid of the markers.
2870
-	else
2871
-		$message = strtr($message, array("\n" => ''));
3025
+	else {
3026
+			$message = strtr($message, array("\n" => ''));
3027
+	}
2872 3028
 
2873
-	if ($message !== '' && $message[0] === ' ')
2874
-		$message = '&nbsp;' . substr($message, 1);
3029
+	if ($message !== '' && $message[0] === ' ') {
3030
+			$message = '&nbsp;' . substr($message, 1);
3031
+	}
2875 3032
 
2876 3033
 	// Cleanup whitespace.
2877 3034
 	$message = strtr($message, array('  ' => ' &nbsp;', "\r" => '', "\n" => '<br>', '<br> ' => '<br>&nbsp;', '&#13;' => "\n"));
@@ -2880,15 +3037,16 @@  discard block
 block discarded – undo
2880 3037
 	call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
2881 3038
 
2882 3039
 	// Cache the output if it took some time...
2883
-	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05)
2884
-		cache_put_data($cache_key, $message, 240);
3040
+	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) {
3041
+			cache_put_data($cache_key, $message, 240);
3042
+	}
2885 3043
 
2886 3044
 	// If this was a force parse revert if needed.
2887 3045
 	if (!empty($parse_tags))
2888 3046
 	{
2889
-		if (empty($temp_bbc))
2890
-			$bbc_codes = array();
2891
-		else
3047
+		if (empty($temp_bbc)) {
3048
+					$bbc_codes = array();
3049
+		} else
2892 3050
 		{
2893 3051
 			$bbc_codes = $temp_bbc;
2894 3052
 			unset($temp_bbc);
@@ -2915,8 +3073,9 @@  discard block
 block discarded – undo
2915 3073
 	static $smileyPregSearch = null, $smileyPregReplacements = array();
2916 3074
 
2917 3075
 	// No smiley set at all?!
2918
-	if ($user_info['smiley_set'] == 'none' || trim($message) == '')
2919
-		return;
3076
+	if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
3077
+			return;
3078
+	}
2920 3079
 
2921 3080
 	// Maybe a mod wants to implement an alternative method (e.g. emojis instead of images)
2922 3081
 	call_integration_hook('integrate_smileys', array(&$smileyPregSearch, &$smileyPregReplacements));
@@ -2930,8 +3089,7 @@  discard block
 block discarded – undo
2930 3089
 			$smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
2931 3090
 			$smileysto = array('evil.png', 'cheesy.png', 'rolleyes.png', 'angry.png', 'laugh.png', 'smiley.png', 'wink.png', 'grin.png', 'sad.png', 'shocked.png', 'cool.png', 'tongue.png', 'huh.png', 'embarrassed.png', 'lipsrsealed.png', 'kiss.png', 'cry.png', 'undecided.png', 'azn.png', 'afro.png', 'police.png', 'angel.png');
2932 3091
 			$smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', '');
2933
-		}
2934
-		else
3092
+		} else
2935 3093
 		{
2936 3094
 			// Load the smileys in reverse order by length so they don't get parsed wrong.
2937 3095
 			if (($temp = cache_get_data('parsing_smileys', 480)) == null)
@@ -2955,9 +3113,9 @@  discard block
 block discarded – undo
2955 3113
 				$smcFunc['db_free_result']($result);
2956 3114
 
2957 3115
 				cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
3116
+			} else {
3117
+							list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2958 3118
 			}
2959
-			else
2960
-				list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2961 3119
 		}
2962 3120
 
2963 3121
 		// The non-breaking-space is a complex thing...
@@ -2979,16 +3137,18 @@  discard block
 block discarded – undo
2979 3137
 				$alt_images = glob($smileys_dir . $fname .  '.{' . (implode(',', $exts)) . '}', GLOB_BRACE);
2980 3138
 				if (!empty($alt_images))
2981 3139
 				{
2982
-					foreach ($exts as $ext)
2983
-						if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images))
3140
+					foreach ($exts as $ext) {
3141
+											if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images))
2984 3142
 						{
2985 3143
 							$smileysto[$i] = $fname . '.' . $ext;
3144
+					}
2986 3145
 							break;
2987 3146
 						}
2988 3147
 				}
2989 3148
 				// If we have no image, just leave the text version in place
2990
-				else
2991
-					continue;
3149
+				else {
3150
+									continue;
3151
+				}
2992 3152
 			}
2993 3153
 
2994 3154
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
@@ -3056,12 +3216,14 @@  discard block
 block discarded – undo
3056 3216
 	global $boardurl, $image_proxy_enabled, $image_proxy_secret;
3057 3217
 
3058 3218
 	// Only use the proxy if enabled and necessary
3059
-	if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https')
3060
-		return $url;
3219
+	if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') {
3220
+			return $url;
3221
+	}
3061 3222
 
3062 3223
 	// We don't need to proxy our own resources
3063
-	if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0)
3064
-		return strtr($url, array('http://' => 'https://'));
3224
+	if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) {
3225
+			return strtr($url, array('http://' => 'https://'));
3226
+	}
3065 3227
 
3066 3228
 	// By default, use SMF's own image proxy script
3067 3229
 	$proxied_url = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($url) . '&hash=' . md5($url . $image_proxy_secret);
@@ -3086,35 +3248,41 @@  discard block
 block discarded – undo
3086 3248
 	global $scripturl, $context, $modSettings, $db_show_debug, $db_cache;
3087 3249
 
3088 3250
 	// In case we have mail to send, better do that - as obExit doesn't always quite make it...
3089
-	if (!empty($context['flush_mail']))
3090
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3251
+	if (!empty($context['flush_mail'])) {
3252
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3091 3253
 		AddMailQueue(true);
3254
+	}
3092 3255
 
3093 3256
 	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
3094 3257
 
3095
-	if ($add)
3096
-		$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
3258
+	if ($add) {
3259
+			$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
3260
+	}
3097 3261
 
3098 3262
 	// Put the session ID in.
3099
-	if (defined('SID') && SID != '')
3100
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
3263
+	if (defined('SID') && SID != '') {
3264
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
3265
+	}
3101 3266
 	// Keep that debug in their for template debugging!
3102
-	elseif (isset($_GET['debug']))
3103
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
3267
+	elseif (isset($_GET['debug'])) {
3268
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
3269
+	}
3104 3270
 
3105 3271
 	if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
3106 3272
 	{
3107
-		if (defined('SID') && SID != '')
3108
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
3273
+		if (defined('SID') && SID != '') {
3274
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
3109 3275
 				function ($m) use ($scripturl)
3110 3276
 				{
3111 3277
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
3278
+		}
3112 3279
 				}, $setLocation);
3113
-		else
3114
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
3280
+		else {
3281
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
3115 3282
 				function ($m) use ($scripturl)
3116 3283
 				{
3117 3284
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
3285
+		}
3118 3286
 				}, $setLocation);
3119 3287
 	}
3120 3288
 
@@ -3125,8 +3293,9 @@  discard block
 block discarded – undo
3125 3293
 	header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302);
3126 3294
 
3127 3295
 	// Debugging.
3128
-	if (isset($db_show_debug) && $db_show_debug === true)
3129
-		$_SESSION['debug_redirect'] = $db_cache;
3296
+	if (isset($db_show_debug) && $db_show_debug === true) {
3297
+			$_SESSION['debug_redirect'] = $db_cache;
3298
+	}
3130 3299
 
3131 3300
 	obExit(false);
3132 3301
 }
@@ -3145,51 +3314,60 @@  discard block
 block discarded – undo
3145 3314
 
3146 3315
 	// Attempt to prevent a recursive loop.
3147 3316
 	++$level;
3148
-	if ($level > 1 && !$from_fatal_error && !$has_fatal_error)
3149
-		exit;
3150
-	if ($from_fatal_error)
3151
-		$has_fatal_error = true;
3317
+	if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
3318
+			exit;
3319
+	}
3320
+	if ($from_fatal_error) {
3321
+			$has_fatal_error = true;
3322
+	}
3152 3323
 
3153 3324
 	// Clear out the stat cache.
3154 3325
 	trackStats();
3155 3326
 
3156 3327
 	// If we have mail to send, send it.
3157
-	if (!empty($context['flush_mail']))
3158
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3328
+	if (!empty($context['flush_mail'])) {
3329
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3159 3330
 		AddMailQueue(true);
3331
+	}
3160 3332
 
3161 3333
 	$do_header = $header === null ? !$header_done : $header;
3162
-	if ($do_footer === null)
3163
-		$do_footer = $do_header;
3334
+	if ($do_footer === null) {
3335
+			$do_footer = $do_header;
3336
+	}
3164 3337
 
3165 3338
 	// Has the template/header been done yet?
3166 3339
 	if ($do_header)
3167 3340
 	{
3168 3341
 		// Was the page title set last minute? Also update the HTML safe one.
3169
-		if (!empty($context['page_title']) && empty($context['page_title_html_safe']))
3170
-			$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3342
+		if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
3343
+					$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3344
+		}
3171 3345
 
3172 3346
 		// Start up the session URL fixer.
3173 3347
 		ob_start('ob_sessrewrite');
3174 3348
 
3175
-		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers']))
3176
-			$buffers = explode(',', $settings['output_buffers']);
3177
-		elseif (!empty($settings['output_buffers']))
3178
-			$buffers = $settings['output_buffers'];
3179
-		else
3180
-			$buffers = array();
3349
+		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
3350
+					$buffers = explode(',', $settings['output_buffers']);
3351
+		} elseif (!empty($settings['output_buffers'])) {
3352
+					$buffers = $settings['output_buffers'];
3353
+		} else {
3354
+					$buffers = array();
3355
+		}
3181 3356
 
3182
-		if (isset($modSettings['integrate_buffer']))
3183
-			$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3357
+		if (isset($modSettings['integrate_buffer'])) {
3358
+					$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3359
+		}
3184 3360
 
3185
-		if (!empty($buffers))
3186
-			foreach ($buffers as $function)
3361
+		if (!empty($buffers)) {
3362
+					foreach ($buffers as $function)
3187 3363
 			{
3188 3364
 				$call = call_helper($function, true);
3365
+		}
3189 3366
 
3190 3367
 				// Is it valid?
3191
-				if (!empty($call))
3192
-					ob_start($call);
3368
+				if (!empty($call)) {
3369
+									ob_start($call);
3370
+				}
3193 3371
 			}
3194 3372
 
3195 3373
 		// Display the screen in the logical order.
@@ -3201,8 +3379,9 @@  discard block
 block discarded – undo
3201 3379
 		loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
3202 3380
 
3203 3381
 		// Anything special to put out?
3204
-		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml']))
3205
-			echo $context['insert_after_template'];
3382
+		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
3383
+					echo $context['insert_after_template'];
3384
+		}
3206 3385
 
3207 3386
 		// Just so we don't get caught in an endless loop of errors from the footer...
3208 3387
 		if (!$footer_done)
@@ -3211,14 +3390,16 @@  discard block
 block discarded – undo
3211 3390
 			template_footer();
3212 3391
 
3213 3392
 			// (since this is just debugging... it's okay that it's after </html>.)
3214
-			if (!isset($_REQUEST['xml']))
3215
-				displayDebug();
3393
+			if (!isset($_REQUEST['xml'])) {
3394
+							displayDebug();
3395
+			}
3216 3396
 		}
3217 3397
 	}
3218 3398
 
3219 3399
 	// Remember this URL in case someone doesn't like sending HTTP_REFERER.
3220
-	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false)
3221
-		$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3400
+	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
3401
+			$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3402
+	}
3222 3403
 
3223 3404
 	// For session check verification.... don't switch browsers...
3224 3405
 	$_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
@@ -3227,9 +3408,10 @@  discard block
 block discarded – undo
3227 3408
 	call_integration_hook('integrate_exit', array($do_footer));
3228 3409
 
3229 3410
 	// Don't exit if we're coming from index.php; that will pass through normally.
3230
-	if (!$from_index)
3231
-		exit;
3232
-}
3411
+	if (!$from_index) {
3412
+			exit;
3413
+	}
3414
+	}
3233 3415
 
3234 3416
 /**
3235 3417
  * Get the size of a specified image with better error handling.
@@ -3248,8 +3430,9 @@  discard block
 block discarded – undo
3248 3430
 	$url = str_replace(' ', '%20', $url);
3249 3431
 
3250 3432
 	// Can we pull this from the cache... please please?
3251
-	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null)
3252
-		return $temp;
3433
+	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) {
3434
+			return $temp;
3435
+	}
3253 3436
 	$t = microtime();
3254 3437
 
3255 3438
 	// Get the host to pester...
@@ -3259,12 +3442,10 @@  discard block
 block discarded – undo
3259 3442
 	if ($url == '' || $url == 'http://' || $url == 'https://')
3260 3443
 	{
3261 3444
 		return false;
3262
-	}
3263
-	elseif (!isset($match[1]))
3445
+	} elseif (!isset($match[1]))
3264 3446
 	{
3265 3447
 		$size = @getimagesize($url);
3266
-	}
3267
-	else
3448
+	} else
3268 3449
 	{
3269 3450
 		// Try to connect to the server... give it half a second.
3270 3451
 		$temp = 0;
@@ -3301,12 +3482,14 @@  discard block
 block discarded – undo
3301 3482
 	}
3302 3483
 
3303 3484
 	// If we didn't get it, we failed.
3304
-	if (!isset($size))
3305
-		$size = false;
3485
+	if (!isset($size)) {
3486
+			$size = false;
3487
+	}
3306 3488
 
3307 3489
 	// If this took a long time, we may never have to do it again, but then again we might...
3308
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8)
3309
-		cache_put_data('url_image_size-' . md5($url), $size, 240);
3490
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) {
3491
+			cache_put_data('url_image_size-' . md5($url), $size, 240);
3492
+	}
3310 3493
 
3311 3494
 	// Didn't work.
3312 3495
 	return $size;
@@ -3324,8 +3507,9 @@  discard block
 block discarded – undo
3324 3507
 
3325 3508
 	// Under SSI this function can be called more then once.  That can cause some problems.
3326 3509
 	//   So only run the function once unless we are forced to run it again.
3327
-	if ($loaded && !$forceload)
3328
-		return;
3510
+	if ($loaded && !$forceload) {
3511
+			return;
3512
+	}
3329 3513
 
3330 3514
 	$loaded = true;
3331 3515
 
@@ -3337,14 +3521,16 @@  discard block
 block discarded – undo
3337 3521
 	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
3338 3522
 	for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++)
3339 3523
 	{
3340
-		if (trim($context['news_lines'][$i]) == '')
3341
-			continue;
3524
+		if (trim($context['news_lines'][$i]) == '') {
3525
+					continue;
3526
+		}
3342 3527
 
3343 3528
 		// Clean it up for presentation ;).
3344 3529
 		$context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i);
3345 3530
 	}
3346
-	if (!empty($context['news_lines']))
3347
-		$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3531
+	if (!empty($context['news_lines'])) {
3532
+			$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3533
+	}
3348 3534
 
3349 3535
 	if (!$user_info['is_guest'])
3350 3536
 	{
@@ -3353,40 +3539,48 @@  discard block
 block discarded – undo
3353 3539
 		$context['user']['alerts'] = &$user_info['alerts'];
3354 3540
 
3355 3541
 		// Personal message popup...
3356
-		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0))
3357
-			$context['user']['popup_messages'] = true;
3358
-		else
3359
-			$context['user']['popup_messages'] = false;
3542
+		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) {
3543
+					$context['user']['popup_messages'] = true;
3544
+		} else {
3545
+					$context['user']['popup_messages'] = false;
3546
+		}
3360 3547
 		$_SESSION['unread_messages'] = $user_info['unread_messages'];
3361 3548
 
3362
-		if (allowedTo('moderate_forum'))
3363
-			$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3549
+		if (allowedTo('moderate_forum')) {
3550
+					$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3551
+		}
3364 3552
 
3365 3553
 		$context['user']['avatar'] = array();
3366 3554
 
3367 3555
 		// Check for gravatar first since we might be forcing them...
3368 3556
 		if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride']))
3369 3557
 		{
3370
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11)
3371
-				$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3372
-			else
3373
-				$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3558
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) {
3559
+							$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3560
+			} else {
3561
+							$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3562
+			}
3374 3563
 		}
3375 3564
 		// Uploaded?
3376
-		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
3377
-			$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3565
+		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) {
3566
+					$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3567
+		}
3378 3568
 		// Full URL?
3379
-		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0)
3380
-			$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3569
+		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) {
3570
+					$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3571
+		}
3381 3572
 		// Otherwise we assume it's server stored.
3382
-		elseif ($user_info['avatar']['url'] != '')
3383
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3573
+		elseif ($user_info['avatar']['url'] != '') {
3574
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3575
+		}
3384 3576
 		// No avatar at all? Fine, we have a big fat default avatar ;)
3385
-		else
3386
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3577
+		else {
3578
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3579
+		}
3387 3580
 
3388
-		if (!empty($context['user']['avatar']))
3389
-			$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3581
+		if (!empty($context['user']['avatar'])) {
3582
+					$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3583
+		}
3390 3584
 
3391 3585
 		// Figure out how long they've been logged in.
3392 3586
 		$context['user']['total_time_logged_in'] = array(
@@ -3394,8 +3588,7 @@  discard block
 block discarded – undo
3394 3588
 			'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600),
3395 3589
 			'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60)
3396 3590
 		);
3397
-	}
3398
-	else
3591
+	} else
3399 3592
 	{
3400 3593
 		$context['user']['messages'] = 0;
3401 3594
 		$context['user']['unread_messages'] = 0;
@@ -3403,12 +3596,14 @@  discard block
 block discarded – undo
3403 3596
 		$context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0);
3404 3597
 		$context['user']['popup_messages'] = false;
3405 3598
 
3406
-		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1)
3407
-			$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3599
+		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) {
3600
+					$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3601
+		}
3408 3602
 
3409 3603
 		// If we've upgraded recently, go easy on the passwords.
3410
-		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime']))
3411
-			$context['disable_login_hashing'] = true;
3604
+		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) {
3605
+					$context['disable_login_hashing'] = true;
3606
+		}
3412 3607
 	}
3413 3608
 
3414 3609
 	// Setup the main menu items.
@@ -3421,8 +3616,8 @@  discard block
 block discarded – undo
3421 3616
 	$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');
3422 3617
 
3423 3618
 	// 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array.
3424
-	if ($context['show_pm_popup'])
3425
-		addInlineJavaScript('
3619
+	if ($context['show_pm_popup']) {
3620
+			addInlineJavaScript('
3426 3621
 		jQuery(document).ready(function($) {
3427 3622
 			new smc_Popup({
3428 3623
 				heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ',
@@ -3430,24 +3625,28 @@  discard block
 block discarded – undo
3430 3625
 				icon_class: \'generic_icons mail_new\'
3431 3626
 			});
3432 3627
 		});');
3628
+	}
3433 3629
 
3434 3630
 	// Add a generic "Are you sure?" confirmation message.
3435 3631
 	addInlineJavaScript('
3436 3632
 	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3437 3633
 
3438 3634
 	// Now add the capping code for avatars.
3439
-	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
3440
-		addInlineCss('
3635
+	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') {
3636
+			addInlineCss('
3441 3637
 	img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }');
3638
+	}
3442 3639
 
3443 3640
 	// Add max image limits
3444
-	if (!empty($modSettings['max_image_width']))
3445
-		addInlineCss('
3641
+	if (!empty($modSettings['max_image_width'])) {
3642
+			addInlineCss('
3446 3643
 	.postarea .bbc_img { max-width: ' . $modSettings['max_image_width'] . 'px; }');
3644
+	}
3447 3645
 
3448
-	if (!empty($modSettings['max_image_height']))
3449
-		addInlineCss('
3646
+	if (!empty($modSettings['max_image_height'])) {
3647
+			addInlineCss('
3450 3648
 	.postarea .bbc_img { max-height: ' . $modSettings['max_image_height'] . 'px; }');
3649
+	}
3451 3650
 
3452 3651
 	// This looks weird, but it's because BoardIndex.php references the variable.
3453 3652
 	$context['common_stats']['latest_member'] = array(
@@ -3464,11 +3663,13 @@  discard block
 block discarded – undo
3464 3663
 	);
3465 3664
 	$context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']);
3466 3665
 
3467
-	if (empty($settings['theme_version']))
3468
-		addJavaScriptVar('smf_scripturl', $scripturl);
3666
+	if (empty($settings['theme_version'])) {
3667
+			addJavaScriptVar('smf_scripturl', $scripturl);
3668
+	}
3469 3669
 
3470
-	if (!isset($context['page_title']))
3471
-		$context['page_title'] = '';
3670
+	if (!isset($context['page_title'])) {
3671
+			$context['page_title'] = '';
3672
+	}
3472 3673
 
3473 3674
 	// Set some specific vars.
3474 3675
 	$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
@@ -3478,21 +3679,23 @@  discard block
 block discarded – undo
3478 3679
 	$context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']);
3479 3680
 	$context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']);
3480 3681
 
3481
-	if (!empty($context['meta_keywords']))
3482
-		$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3682
+	if (!empty($context['meta_keywords'])) {
3683
+			$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3684
+	}
3483 3685
 
3484
-	if (!empty($context['canonical_url']))
3485
-		$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3686
+	if (!empty($context['canonical_url'])) {
3687
+			$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3688
+	}
3486 3689
 
3487
-	if (!empty($settings['og_image']))
3488
-		$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3690
+	if (!empty($settings['og_image'])) {
3691
+			$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3692
+	}
3489 3693
 
3490 3694
 	if (!empty($context['meta_description']))
3491 3695
 	{
3492 3696
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']);
3493 3697
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']);
3494
-	}
3495
-	else
3698
+	} else
3496 3699
 	{
3497 3700
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']);
3498 3701
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']);
@@ -3517,8 +3720,9 @@  discard block
 block discarded – undo
3517 3720
 	$memory_needed = memoryReturnBytes($needed);
3518 3721
 
3519 3722
 	// should we account for how much is currently being used?
3520
-	if ($in_use)
3521
-		$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3723
+	if ($in_use) {
3724
+			$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3725
+	}
3522 3726
 
3523 3727
 	// if more is needed, request it
3524 3728
 	if ($memory_current < $memory_needed)
@@ -3541,8 +3745,9 @@  discard block
 block discarded – undo
3541 3745
  */
3542 3746
 function memoryReturnBytes($val)
3543 3747
 {
3544
-	if (is_integer($val))
3545
-		return $val;
3748
+	if (is_integer($val)) {
3749
+			return $val;
3750
+	}
3546 3751
 
3547 3752
 	// Separate the number from the designator
3548 3753
 	$val = trim($val);
@@ -3578,10 +3783,11 @@  discard block
 block discarded – undo
3578 3783
 		header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
3579 3784
 
3580 3785
 		// Are we debugging the template/html content?
3581
-		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie'))
3582
-			header('content-type: application/xhtml+xml');
3583
-		elseif (!isset($_REQUEST['xml']))
3584
-			header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3786
+		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) {
3787
+					header('content-type: application/xhtml+xml');
3788
+		} elseif (!isset($_REQUEST['xml'])) {
3789
+					header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3790
+		}
3585 3791
 	}
3586 3792
 
3587 3793
 	header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
@@ -3590,8 +3796,9 @@  discard block
 block discarded – undo
3590 3796
 	if ($context['in_maintenance'] && $context['user']['is_admin'])
3591 3797
 	{
3592 3798
 		$position = array_search('body', $context['template_layers']);
3593
-		if ($position === false)
3594
-			$position = array_search('main', $context['template_layers']);
3799
+		if ($position === false) {
3800
+					$position = array_search('main', $context['template_layers']);
3801
+		}
3595 3802
 
3596 3803
 		if ($position !== false)
3597 3804
 		{
@@ -3619,23 +3826,25 @@  discard block
 block discarded – undo
3619 3826
 
3620 3827
 			foreach ($securityFiles as $i => $securityFile)
3621 3828
 			{
3622
-				if (!file_exists($boarddir . '/' . $securityFile))
3623
-					unset($securityFiles[$i]);
3829
+				if (!file_exists($boarddir . '/' . $securityFile)) {
3830
+									unset($securityFiles[$i]);
3831
+				}
3624 3832
 			}
3625 3833
 
3626 3834
 			// We are already checking so many files...just few more doesn't make any difference! :P
3627
-			if (!empty($modSettings['currentAttachmentUploadDir']))
3628
-				$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3629
-
3630
-			else
3631
-				$path = $modSettings['attachmentUploadDir'];
3835
+			if (!empty($modSettings['currentAttachmentUploadDir'])) {
3836
+							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3837
+			} else {
3838
+							$path = $modSettings['attachmentUploadDir'];
3839
+			}
3632 3840
 
3633 3841
 			secureDirectory($path, true);
3634 3842
 			secureDirectory($cachedir);
3635 3843
 
3636 3844
 			// If agreement is enabled, at least the english version shall exists
3637
-			if ($modSettings['requireAgreement'])
3638
-				$agreement = !file_exists($boarddir . '/agreement.txt');
3845
+			if ($modSettings['requireAgreement']) {
3846
+							$agreement = !file_exists($boarddir . '/agreement.txt');
3847
+			}
3639 3848
 
3640 3849
 			if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement))
3641 3850
 			{
@@ -3650,18 +3859,21 @@  discard block
 block discarded – undo
3650 3859
 					echo '
3651 3860
 				', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>';
3652 3861
 
3653
-					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~')
3654
-						echo '
3862
+					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') {
3863
+											echo '
3655 3864
 				', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>';
3865
+					}
3656 3866
 				}
3657 3867
 
3658
-				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir))
3659
-					echo '
3868
+				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) {
3869
+									echo '
3660 3870
 				<strong>', $txt['cache_writable'], '</strong><br>';
3871
+				}
3661 3872
 
3662
-				if (!empty($agreement))
3663
-					echo '
3873
+				if (!empty($agreement)) {
3874
+									echo '
3664 3875
 				<strong>', $txt['agreement_missing'], '</strong><br>';
3876
+				}
3665 3877
 
3666 3878
 				echo '
3667 3879
 			</p>
@@ -3676,16 +3888,18 @@  discard block
 block discarded – undo
3676 3888
 				<div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;">
3677 3889
 					', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']);
3678 3890
 
3679
-			if (!empty($_SESSION['ban']['cannot_post']['reason']))
3680
-				echo '
3891
+			if (!empty($_SESSION['ban']['cannot_post']['reason'])) {
3892
+							echo '
3681 3893
 					<div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>';
3894
+			}
3682 3895
 
3683
-			if (!empty($_SESSION['ban']['expire_time']))
3684
-				echo '
3896
+			if (!empty($_SESSION['ban']['expire_time'])) {
3897
+							echo '
3685 3898
 					<div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>';
3686
-			else
3687
-				echo '
3899
+			} else {
3900
+							echo '
3688 3901
 					<div>', $txt['your_ban_expires_never'], '</div>';
3902
+			}
3689 3903
 
3690 3904
 			echo '
3691 3905
 				</div>';
@@ -3701,8 +3915,9 @@  discard block
 block discarded – undo
3701 3915
 	global $forum_copyright, $software_year, $forum_version;
3702 3916
 
3703 3917
 	// Don't display copyright for things like SSI.
3704
-	if (!isset($forum_version) || !isset($software_year))
3705
-		return;
3918
+	if (!isset($forum_version) || !isset($software_year)) {
3919
+			return;
3920
+	}
3706 3921
 
3707 3922
 	// Put in the version...
3708 3923
 	printf($forum_copyright, $forum_version, $software_year);
@@ -3720,9 +3935,10 @@  discard block
 block discarded – undo
3720 3935
 	$context['load_time'] = round(microtime(true) - $time_start, 3);
3721 3936
 	$context['load_queries'] = $db_count;
3722 3937
 
3723
-	foreach (array_reverse($context['template_layers']) as $layer)
3724
-		loadSubTemplate($layer . '_below', true);
3725
-}
3938
+	foreach (array_reverse($context['template_layers']) as $layer) {
3939
+			loadSubTemplate($layer . '_below', true);
3940
+	}
3941
+	}
3726 3942
 
3727 3943
 /**
3728 3944
  * Output the Javascript files
@@ -3756,8 +3972,7 @@  discard block
 block discarded – undo
3756 3972
 			{
3757 3973
 				echo '
3758 3974
 		var ', $key, ';';
3759
-			}
3760
-			else
3975
+			} else
3761 3976
 			{
3762 3977
 				echo '
3763 3978
 		var ', $key, ' = ', $value, ';';
@@ -3776,27 +3991,29 @@  discard block
 block discarded – undo
3776 3991
 		foreach ($context['javascript_files'] as $id => $js_file)
3777 3992
 		{
3778 3993
 			// Last minute call! allow theme authors to disable single files.
3779
-			if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3780
-				continue;
3994
+			if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3995
+							continue;
3996
+			}
3781 3997
 
3782 3998
 			// By default files don't get minimized unless the file explicitly says so!
3783 3999
 			if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files']))
3784 4000
 			{
3785
-				if (!empty($js_file['options']['async']))
3786
-					$toMinify['async'][] = $js_file;
3787
-				elseif (!empty($js_file['options']['defer']))
3788
-					$toMinify['defer'][] = $js_file;
3789
-				else
3790
-					$toMinify['standard'][] = $js_file;
4001
+				if (!empty($js_file['options']['async'])) {
4002
+									$toMinify['async'][] = $js_file;
4003
+				} elseif (!empty($js_file['options']['defer'])) {
4004
+									$toMinify['defer'][] = $js_file;
4005
+				} else {
4006
+									$toMinify['standard'][] = $js_file;
4007
+				}
3791 4008
 
3792 4009
 				// Grab a random seed.
3793
-				if (!isset($minSeed) && isset($js_file['options']['seed']))
3794
-					$minSeed = $js_file['options']['seed'];
3795
-			}
3796
-
3797
-			else
3798
-				echo '
4010
+				if (!isset($minSeed) && isset($js_file['options']['seed'])) {
4011
+									$minSeed = $js_file['options']['seed'];
4012
+				}
4013
+			} else {
4014
+							echo '
3799 4015
 	<script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async' : '', !empty($js_file['options']['defer']) ? ' defer' : '', '></script>';
4016
+			}
3800 4017
 		}
3801 4018
 
3802 4019
 		foreach ($toMinify as $js_files)
@@ -3807,9 +4024,10 @@  discard block
 block discarded – undo
3807 4024
 
3808 4025
 				$minSuccessful = array_keys($result) === array('smf_minified');
3809 4026
 
3810
-				foreach ($result as $minFile)
3811
-					echo '
4027
+				foreach ($result as $minFile) {
4028
+									echo '
3812 4029
 	<script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async' : '', !empty($minFile['options']['defer']) ? ' defer' : '', '></script>';
4030
+				}
3813 4031
 			}
3814 4032
 		}
3815 4033
 	}
@@ -3823,8 +4041,9 @@  discard block
 block discarded – undo
3823 4041
 <script>
3824 4042
 window.addEventListener("DOMContentLoaded", function() {';
3825 4043
 
3826
-			foreach ($context['javascript_inline']['defer'] as $js_code)
3827
-				echo $js_code;
4044
+			foreach ($context['javascript_inline']['defer'] as $js_code) {
4045
+							echo $js_code;
4046
+			}
3828 4047
 
3829 4048
 			echo '
3830 4049
 });
@@ -3836,8 +4055,9 @@  discard block
 block discarded – undo
3836 4055
 			echo '
3837 4056
 	<script>';
3838 4057
 
3839
-			foreach ($context['javascript_inline']['standard'] as $js_code)
3840
-				echo $js_code;
4058
+			foreach ($context['javascript_inline']['standard'] as $js_code) {
4059
+							echo $js_code;
4060
+			}
3841 4061
 
3842 4062
 			echo '
3843 4063
 	</script>';
@@ -3865,23 +4085,26 @@  discard block
 block discarded – undo
3865 4085
 	foreach ($context['css_files'] as $id => $file)
3866 4086
 	{
3867 4087
 		// Last minute call! allow theme authors to disable single files.
3868
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3869
-			continue;
4088
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
4089
+					continue;
4090
+		}
3870 4091
 
3871 4092
 		// Files are minimized unless they explicitly opt out.
3872
-		if (!isset($file['options']['minimize']))
3873
-			$file['options']['minimize'] = true;
4093
+		if (!isset($file['options']['minimize'])) {
4094
+					$file['options']['minimize'] = true;
4095
+		}
3874 4096
 
3875 4097
 		if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files']))
3876 4098
 		{
3877 4099
 			$toMinify[] = $file;
3878 4100
 
3879 4101
 			// Grab a random seed.
3880
-			if (!isset($minSeed) && isset($file['options']['seed']))
3881
-				$minSeed = $file['options']['seed'];
4102
+			if (!isset($minSeed) && isset($file['options']['seed'])) {
4103
+							$minSeed = $file['options']['seed'];
4104
+			}
4105
+		} else {
4106
+					$normal[] = $file['fileUrl'];
3882 4107
 		}
3883
-		else
3884
-			$normal[] = $file['fileUrl'];
3885 4108
 	}
3886 4109
 
3887 4110
 	if (!empty($toMinify))
@@ -3890,23 +4113,26 @@  discard block
 block discarded – undo
3890 4113
 
3891 4114
 		$minSuccessful = array_keys($result) === array('smf_minified');
3892 4115
 
3893
-		foreach ($result as $minFile)
3894
-			echo '
4116
+		foreach ($result as $minFile) {
4117
+					echo '
3895 4118
 	<link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">';
4119
+		}
3896 4120
 	}
3897 4121
 
3898 4122
 	// Print the rest after the minified files.
3899
-	if (!empty($normal))
3900
-		foreach ($normal as $nf)
4123
+	if (!empty($normal)) {
4124
+			foreach ($normal as $nf)
3901 4125
 			echo '
3902 4126
 	<link rel="stylesheet" href="', $nf ,'">';
4127
+	}
3903 4128
 
3904 4129
 	if ($db_show_debug === true)
3905 4130
 	{
3906 4131
 		// Try to keep only what's useful.
3907 4132
 		$repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => '');
3908
-		foreach ($context['css_files'] as $file)
3909
-			$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
4133
+		foreach ($context['css_files'] as $file) {
4134
+					$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
4135
+		}
3910 4136
 	}
3911 4137
 
3912 4138
 	if (!empty($context['css_header']))
@@ -3914,9 +4140,10 @@  discard block
 block discarded – undo
3914 4140
 		echo '
3915 4141
 	<style>';
3916 4142
 
3917
-		foreach ($context['css_header'] as $css)
3918
-			echo $css .'
4143
+		foreach ($context['css_header'] as $css) {
4144
+					echo $css .'
3919 4145
 	';
4146
+		}
3920 4147
 
3921 4148
 		echo'
3922 4149
 	</style>';
@@ -3939,8 +4166,9 @@  discard block
 block discarded – undo
3939 4166
 	$type = !empty($type) && in_array($type, $types) ? $type : false;
3940 4167
 	$data = is_array($data) ? $data : array();
3941 4168
 
3942
-	if (empty($type) || empty($data))
3943
-		return $data;
4169
+	if (empty($type) || empty($data)) {
4170
+			return $data;
4171
+	}
3944 4172
 
3945 4173
 	// Different pages include different files, so we use a hash to label the different combinations
3946 4174
 	$hash = md5(implode(' ', array_map(function($file) { return $file['filePath'] . (int) @filesize($file['filePath']) . (int) @filemtime($file['filePath']); }, $data)));
@@ -3949,13 +4177,14 @@  discard block
 block discarded – undo
3949 4177
 	list($toCache, $async, $defer) = array_pad((array) cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400), 3, null);
3950 4178
 
3951 4179
 	// Already done?
3952
-	if (!empty($toCache))
3953
-		return array('smf_minified' => array(
4180
+	if (!empty($toCache)) {
4181
+			return array('smf_minified' => array(
3954 4182
 			'fileUrl' => $settings['theme_url'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/' . basename($toCache),
3955 4183
 			'filePath' => $toCache,
3956 4184
 			'fileName' => basename($toCache),
3957 4185
 			'options' => array('async' => !empty($async), 'defer' => !empty($defer)),
3958 4186
 		));
4187
+	}
3959 4188
 
3960 4189
 
3961 4190
 	// No namespaces, sorry!
@@ -3985,9 +4214,9 @@  discard block
 block discarded – undo
3985 4214
 
3986 4215
 	foreach ($data as $id => $file)
3987 4216
 	{
3988
-		if (empty($file['filePath']))
3989
-			$toAdd = false;
3990
-		else
4217
+		if (empty($file['filePath'])) {
4218
+					$toAdd = false;
4219
+		} else
3991 4220
 		{
3992 4221
 			$seed = isset($file['options']['seed']) ? $file['options']['seed'] : '';
3993 4222
 			$tempFile = str_replace($seed, '', $file['filePath']);
@@ -3995,12 +4224,14 @@  discard block
 block discarded – undo
3995 4224
 		}
3996 4225
 
3997 4226
 		// A minified script should only be loaded asynchronously if all its components wanted to be.
3998
-		if (empty($file['options']['async']))
3999
-			$async = false;
4227
+		if (empty($file['options']['async'])) {
4228
+					$async = false;
4229
+		}
4000 4230
 
4001 4231
 		// A minified script should only be deferred if all its components wanted to be.
4002
-		if (empty($file['options']['defer']))
4003
-			$defer = false;
4232
+		if (empty($file['options']['defer'])) {
4233
+					$defer = false;
4234
+		}
4004 4235
 
4005 4236
 		// The file couldn't be located so it won't be added. Log this error.
4006 4237
 		if (empty($toAdd))
@@ -4066,12 +4297,14 @@  discard block
 block discarded – undo
4066 4297
 			foreach (glob(rtrim($theme['dir'], '/') . '/' . ($type == 'css' ? 'css' : 'scripts') . '/minified*.' . $type) as $filename)
4067 4298
 			{
4068 4299
 				// Remove the cache entry
4069
-				if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches))
4070
-					cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null);
4300
+				if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) {
4301
+									cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null);
4302
+				}
4071 4303
 
4072 4304
 				// Try to delete the file. Add it to our error list if it fails.
4073
-				if (!@unlink($filename))
4074
-					$not_deleted[] = $filename;
4305
+				if (!@unlink($filename)) {
4306
+									$not_deleted[] = $filename;
4307
+				}
4075 4308
 			}
4076 4309
 		}
4077 4310
 	}
@@ -4103,8 +4336,9 @@  discard block
 block discarded – undo
4103 4336
 	global $modSettings, $smcFunc;
4104 4337
 
4105 4338
 	// Just make up a nice hash...
4106
-	if ($new)
4107
-		return sha1(md5($filename . time()) . mt_rand());
4339
+	if ($new) {
4340
+			return sha1(md5($filename . time()) . mt_rand());
4341
+	}
4108 4342
 
4109 4343
 	// Just make sure that attachment id is only a int
4110 4344
 	$attachment_id = (int) $attachment_id;
@@ -4121,23 +4355,25 @@  discard block
 block discarded – undo
4121 4355
 				'id_attach' => $attachment_id,
4122 4356
 			));
4123 4357
 
4124
-		if ($smcFunc['db_num_rows']($request) === 0)
4125
-			return false;
4358
+		if ($smcFunc['db_num_rows']($request) === 0) {
4359
+					return false;
4360
+		}
4126 4361
 
4127 4362
 		list ($file_hash) = $smcFunc['db_fetch_row']($request);
4128 4363
 		$smcFunc['db_free_result']($request);
4129 4364
 	}
4130 4365
 
4131 4366
 	// Still no hash? mmm...
4132
-	if (empty($file_hash))
4133
-		$file_hash = sha1(md5($filename . time()) . mt_rand());
4367
+	if (empty($file_hash)) {
4368
+			$file_hash = sha1(md5($filename . time()) . mt_rand());
4369
+	}
4134 4370
 
4135 4371
 	// Are we using multiple directories?
4136
-	if (is_array($modSettings['attachmentUploadDir']))
4137
-		$path = $modSettings['attachmentUploadDir'][$dir];
4138
-
4139
-	else
4140
-		$path = $modSettings['attachmentUploadDir'];
4372
+	if (is_array($modSettings['attachmentUploadDir'])) {
4373
+			$path = $modSettings['attachmentUploadDir'][$dir];
4374
+	} else {
4375
+			$path = $modSettings['attachmentUploadDir'];
4376
+	}
4141 4377
 
4142 4378
 	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
4143 4379
 }
@@ -4152,8 +4388,9 @@  discard block
 block discarded – undo
4152 4388
 function ip2range($fullip)
4153 4389
 {
4154 4390
 	// Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.)
4155
-	if ($fullip == 'unknown')
4156
-		$fullip = '255.255.255.255';
4391
+	if ($fullip == 'unknown') {
4392
+			$fullip = '255.255.255.255';
4393
+	}
4157 4394
 
4158 4395
 	$ip_parts = explode('-', $fullip);
4159 4396
 	$ip_array = array();
@@ -4177,10 +4414,11 @@  discard block
 block discarded – undo
4177 4414
 		$ip_array['low'] = $ip_parts[0];
4178 4415
 		$ip_array['high'] = $ip_parts[1];
4179 4416
 		return $ip_array;
4180
-	}
4181
-	elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.*
4417
+	} elseif (count($ip_parts) == 2) {
4418
+		// if ip 22.22.*-22.22.*
4182 4419
 	{
4183 4420
 		$valid_low = isValidIP($ip_parts[0]);
4421
+	}
4184 4422
 		$valid_high = isValidIP($ip_parts[1]);
4185 4423
 		$count = 0;
4186 4424
 		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
@@ -4195,7 +4433,9 @@  discard block
 block discarded – undo
4195 4433
 				$ip_parts[0] .= $mode . $min;
4196 4434
 				$valid_low = isValidIP($ip_parts[0]);
4197 4435
 				$count++;
4198
-				if ($count > 9) break;
4436
+				if ($count > 9) {
4437
+					break;
4438
+				}
4199 4439
 			}
4200 4440
 		}
4201 4441
 
@@ -4209,7 +4449,9 @@  discard block
 block discarded – undo
4209 4449
 				$ip_parts[1] .= $mode . $max;
4210 4450
 				$valid_high = isValidIP($ip_parts[1]);
4211 4451
 				$count++;
4212
-				if ($count > 9) break;
4452
+				if ($count > 9) {
4453
+					break;
4454
+				}
4213 4455
 			}
4214 4456
 		}
4215 4457
 
@@ -4233,46 +4475,54 @@  discard block
 block discarded – undo
4233 4475
 {
4234 4476
 	global $modSettings;
4235 4477
 
4236
-	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null)
4237
-		return $host;
4478
+	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) {
4479
+			return $host;
4480
+	}
4238 4481
 	$t = microtime();
4239 4482
 
4240 4483
 	// Try the Linux host command, perhaps?
4241 4484
 	if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1)
4242 4485
 	{
4243
-		if (!isset($modSettings['host_to_dis']))
4244
-			$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
4245
-		else
4246
-			$test = @shell_exec('host ' . @escapeshellarg($ip));
4486
+		if (!isset($modSettings['host_to_dis'])) {
4487
+					$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
4488
+		} else {
4489
+					$test = @shell_exec('host ' . @escapeshellarg($ip));
4490
+		}
4247 4491
 
4248 4492
 		// Did host say it didn't find anything?
4249
-		if (strpos($test, 'not found') !== false)
4250
-			$host = '';
4493
+		if (strpos($test, 'not found') !== false) {
4494
+					$host = '';
4495
+		}
4251 4496
 		// Invalid server option?
4252
-		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis']))
4253
-			updateSettings(array('host_to_dis' => 1));
4497
+		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) {
4498
+					updateSettings(array('host_to_dis' => 1));
4499
+		}
4254 4500
 		// Maybe it found something, after all?
4255
-		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1)
4256
-			$host = $match[1];
4501
+		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) {
4502
+					$host = $match[1];
4503
+		}
4257 4504
 	}
4258 4505
 
4259 4506
 	// This is nslookup; usually only Windows, but possibly some Unix?
4260 4507
 	if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
4261 4508
 	{
4262 4509
 		$test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip));
4263
-		if (strpos($test, 'Non-existent domain') !== false)
4264
-			$host = '';
4265
-		elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1)
4266
-			$host = $match[1];
4510
+		if (strpos($test, 'Non-existent domain') !== false) {
4511
+					$host = '';
4512
+		} elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) {
4513
+					$host = $match[1];
4514
+		}
4267 4515
 	}
4268 4516
 
4269 4517
 	// This is the last try :/.
4270
-	if (!isset($host) || $host === false)
4271
-		$host = @gethostbyaddr($ip);
4518
+	if (!isset($host) || $host === false) {
4519
+			$host = @gethostbyaddr($ip);
4520
+	}
4272 4521
 
4273 4522
 	// It took a long time, so let's cache it!
4274
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5)
4275
-		cache_put_data('hostlookup-' . $ip, $host, 600);
4523
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) {
4524
+			cache_put_data('hostlookup-' . $ip, $host, 600);
4525
+	}
4276 4526
 
4277 4527
 	return $host;
4278 4528
 }
@@ -4308,20 +4558,21 @@  discard block
 block discarded – undo
4308 4558
 			{
4309 4559
 				$encrypted = substr(crypt($word, 'uk'), 2, $max_chars);
4310 4560
 				$total = 0;
4311
-				for ($i = 0; $i < $max_chars; $i++)
4312
-					$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4561
+				for ($i = 0; $i < $max_chars; $i++) {
4562
+									$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4563
+				}
4313 4564
 				$returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total;
4314 4565
 			}
4315 4566
 		}
4316 4567
 		return array_unique($returned_ints);
4317
-	}
4318
-	else
4568
+	} else
4319 4569
 	{
4320 4570
 		// Trim characters before and after and add slashes for database insertion.
4321 4571
 		$returned_words = array();
4322
-		foreach ($words as $word)
4323
-			if (($word = trim($word, '-_\'')) !== '')
4572
+		foreach ($words as $word) {
4573
+					if (($word = trim($word, '-_\'')) !== '')
4324 4574
 				$returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars);
4575
+		}
4325 4576
 
4326 4577
 		// Filter out all words that occur more than once.
4327 4578
 		return array_unique($returned_words);
@@ -4343,16 +4594,18 @@  discard block
 block discarded – undo
4343 4594
 	global $settings, $txt;
4344 4595
 
4345 4596
 	// Does the current loaded theme have this and we are not forcing the usage of this function?
4346
-	if (function_exists('template_create_button') && !$force_use)
4347
-		return template_create_button($name, $alt, $label = '', $custom = '');
4597
+	if (function_exists('template_create_button') && !$force_use) {
4598
+			return template_create_button($name, $alt, $label = '', $custom = '');
4599
+	}
4348 4600
 
4349
-	if (!$settings['use_image_buttons'])
4350
-		return $txt[$alt];
4351
-	elseif (!empty($settings['use_buttons']))
4352
-		return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4353
-	else
4354
-		return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4355
-}
4601
+	if (!$settings['use_image_buttons']) {
4602
+			return $txt[$alt];
4603
+	} elseif (!empty($settings['use_buttons'])) {
4604
+			return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4605
+	} else {
4606
+			return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4607
+	}
4608
+	}
4356 4609
 
4357 4610
 /**
4358 4611
  * Sets up all of the top menu buttons
@@ -4395,9 +4648,10 @@  discard block
 block discarded – undo
4395 4648
 	var user_menus = new smc_PopupMenu();
4396 4649
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4397 4650
 	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4398
-		if ($context['allow_pm'])
4399
-			addInlineJavaScript('
4651
+		if ($context['allow_pm']) {
4652
+					addInlineJavaScript('
4400 4653
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
4654
+		}
4401 4655
 
4402 4656
 		if (!empty($modSettings['enable_ajax_alerts']))
4403 4657
 		{
@@ -4557,88 +4811,96 @@  discard block
 block discarded – undo
4557 4811
 
4558 4812
 		// Now we put the buttons in the context so the theme can use them.
4559 4813
 		$menu_buttons = array();
4560
-		foreach ($buttons as $act => $button)
4561
-			if (!empty($button['show']))
4814
+		foreach ($buttons as $act => $button) {
4815
+					if (!empty($button['show']))
4562 4816
 			{
4563 4817
 				$button['active_button'] = false;
4818
+		}
4564 4819
 
4565 4820
 				// This button needs some action.
4566
-				if (isset($button['action_hook']))
4567
-					$needs_action_hook = true;
4821
+				if (isset($button['action_hook'])) {
4822
+									$needs_action_hook = true;
4823
+				}
4568 4824
 
4569 4825
 				// Make sure the last button truly is the last button.
4570 4826
 				if (!empty($button['is_last']))
4571 4827
 				{
4572
-					if (isset($last_button))
4573
-						unset($menu_buttons[$last_button]['is_last']);
4828
+					if (isset($last_button)) {
4829
+											unset($menu_buttons[$last_button]['is_last']);
4830
+					}
4574 4831
 					$last_button = $act;
4575 4832
 				}
4576 4833
 
4577 4834
 				// Go through the sub buttons if there are any.
4578
-				if (!empty($button['sub_buttons']))
4579
-					foreach ($button['sub_buttons'] as $key => $subbutton)
4835
+				if (!empty($button['sub_buttons'])) {
4836
+									foreach ($button['sub_buttons'] as $key => $subbutton)
4580 4837
 					{
4581 4838
 						if (empty($subbutton['show']))
4582 4839
 							unset($button['sub_buttons'][$key]);
4840
+				}
4583 4841
 
4584 4842
 						// 2nd level sub buttons next...
4585 4843
 						if (!empty($subbutton['sub_buttons']))
4586 4844
 						{
4587 4845
 							foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
4588 4846
 							{
4589
-								if (empty($sub_button2['show']))
4590
-									unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4847
+								if (empty($sub_button2['show'])) {
4848
+																	unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4849
+								}
4591 4850
 							}
4592 4851
 						}
4593 4852
 					}
4594 4853
 
4595 4854
 				// Does this button have its own icon?
4596
-				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon']))
4597
-					$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4598
-				elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon']))
4599
-					$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4600
-				elseif (isset($button['icon']))
4601
-					$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4602
-				else
4603
-					$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4855
+				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) {
4856
+									$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4857
+				} elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) {
4858
+									$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4859
+				} elseif (isset($button['icon'])) {
4860
+									$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4861
+				} else {
4862
+									$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4863
+				}
4604 4864
 
4605 4865
 				$menu_buttons[$act] = $button;
4606 4866
 			}
4607 4867
 
4608
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
4609
-			cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4868
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
4869
+					cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4870
+		}
4610 4871
 	}
4611 4872
 
4612 4873
 	$context['menu_buttons'] = $menu_buttons;
4613 4874
 
4614 4875
 	// Logging out requires the session id in the url.
4615
-	if (isset($context['menu_buttons']['logout']))
4616
-		$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4876
+	if (isset($context['menu_buttons']['logout'])) {
4877
+			$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4878
+	}
4617 4879
 
4618 4880
 	// Figure out which action we are doing so we can set the active tab.
4619 4881
 	// Default to home.
4620 4882
 	$current_action = 'home';
4621 4883
 
4622
-	if (isset($context['menu_buttons'][$context['current_action']]))
4623
-		$current_action = $context['current_action'];
4624
-	elseif ($context['current_action'] == 'search2')
4625
-		$current_action = 'search';
4626
-	elseif ($context['current_action'] == 'theme')
4627
-		$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4628
-	elseif ($context['current_action'] == 'register2')
4629
-		$current_action = 'register';
4630
-	elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
4631
-		$current_action = 'login';
4632
-	elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
4633
-		$current_action = 'moderate';
4884
+	if (isset($context['menu_buttons'][$context['current_action']])) {
4885
+			$current_action = $context['current_action'];
4886
+	} elseif ($context['current_action'] == 'search2') {
4887
+			$current_action = 'search';
4888
+	} elseif ($context['current_action'] == 'theme') {
4889
+			$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4890
+	} elseif ($context['current_action'] == 'register2') {
4891
+			$current_action = 'register';
4892
+	} elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) {
4893
+			$current_action = 'login';
4894
+	} elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) {
4895
+			$current_action = 'moderate';
4896
+	}
4634 4897
 
4635 4898
 	// There are certain exceptions to the above where we don't want anything on the menu highlighted.
4636 4899
 	if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner']))
4637 4900
 	{
4638 4901
 		$current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile';
4639 4902
 		$context[$current_action] = true;
4640
-	}
4641
-	elseif ($context['current_action'] == 'pm')
4903
+	} elseif ($context['current_action'] == 'pm')
4642 4904
 	{
4643 4905
 		$current_action = 'self_pm';
4644 4906
 		$context['self_pm'] = true;
@@ -4695,12 +4957,14 @@  discard block
 block discarded – undo
4695 4957
 	}
4696 4958
 
4697 4959
 	// Not all actions are simple.
4698
-	if (!empty($needs_action_hook))
4699
-		call_integration_hook('integrate_current_action', array(&$current_action));
4960
+	if (!empty($needs_action_hook)) {
4961
+			call_integration_hook('integrate_current_action', array(&$current_action));
4962
+	}
4700 4963
 
4701
-	if (isset($context['menu_buttons'][$current_action]))
4702
-		$context['menu_buttons'][$current_action]['active_button'] = true;
4703
-}
4964
+	if (isset($context['menu_buttons'][$current_action])) {
4965
+			$context['menu_buttons'][$current_action]['active_button'] = true;
4966
+	}
4967
+	}
4704 4968
 
4705 4969
 /**
4706 4970
  * Generate a random seed and ensure it's stored in settings.
@@ -4724,30 +4988,35 @@  discard block
 block discarded – undo
4724 4988
 	global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug;
4725 4989
 	global $context, $txt;
4726 4990
 
4727
-	if ($db_show_debug === true)
4728
-		$context['debug']['hooks'][] = $hook;
4991
+	if ($db_show_debug === true) {
4992
+			$context['debug']['hooks'][] = $hook;
4993
+	}
4729 4994
 
4730 4995
 	// Need to have some control.
4731
-	if (!isset($context['instances']))
4732
-		$context['instances'] = array();
4996
+	if (!isset($context['instances'])) {
4997
+			$context['instances'] = array();
4998
+	}
4733 4999
 
4734 5000
 	$results = array();
4735
-	if (empty($modSettings[$hook]))
4736
-		return $results;
5001
+	if (empty($modSettings[$hook])) {
5002
+			return $results;
5003
+	}
4737 5004
 
4738 5005
 	$functions = explode(',', $modSettings[$hook]);
4739 5006
 	// Loop through each function.
4740 5007
 	foreach ($functions as $function)
4741 5008
 	{
4742 5009
 		// Hook has been marked as "disabled". Skip it!
4743
-		if (strpos($function, '!') !== false)
4744
-			continue;
5010
+		if (strpos($function, '!') !== false) {
5011
+					continue;
5012
+		}
4745 5013
 
4746 5014
 		$call = call_helper($function, true);
4747 5015
 
4748 5016
 		// Is it valid?
4749
-		if (!empty($call))
4750
-			$results[$function] = call_user_func_array($call, $parameters);
5017
+		if (!empty($call)) {
5018
+					$results[$function] = call_user_func_array($call, $parameters);
5019
+		}
4751 5020
 
4752 5021
 		// Whatever it was suppose to call, it failed :(
4753 5022
 		elseif (!empty($function))
@@ -4763,8 +5032,9 @@  discard block
 block discarded – undo
4763 5032
 			}
4764 5033
 
4765 5034
 			// "Assume" the file resides on $boarddir somewhere...
4766
-			else
4767
-				log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
5035
+			else {
5036
+							log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
5037
+			}
4768 5038
 		}
4769 5039
 	}
4770 5040
 
@@ -4786,12 +5056,14 @@  discard block
 block discarded – undo
4786 5056
 	global $smcFunc, $modSettings;
4787 5057
 
4788 5058
 	// Any objects?
4789
-	if ($object)
4790
-		$function = $function . '#';
5059
+	if ($object) {
5060
+			$function = $function . '#';
5061
+	}
4791 5062
 
4792 5063
 	// Any files  to load?
4793
-	if (!empty($file) && is_string($file))
4794
-		$function = $file . (!empty($function) ? '|' . $function : '');
5064
+	if (!empty($file) && is_string($file)) {
5065
+			$function = $file . (!empty($function) ? '|' . $function : '');
5066
+	}
4795 5067
 
4796 5068
 	// Get the correct string.
4797 5069
 	$integration_call = $function;
@@ -4813,13 +5085,14 @@  discard block
 block discarded – undo
4813 5085
 		if (!empty($current_functions))
4814 5086
 		{
4815 5087
 			$current_functions = explode(',', $current_functions);
4816
-			if (in_array($integration_call, $current_functions))
4817
-				return;
5088
+			if (in_array($integration_call, $current_functions)) {
5089
+							return;
5090
+			}
4818 5091
 
4819 5092
 			$permanent_functions = array_merge($current_functions, array($integration_call));
5093
+		} else {
5094
+					$permanent_functions = array($integration_call);
4820 5095
 		}
4821
-		else
4822
-			$permanent_functions = array($integration_call);
4823 5096
 
4824 5097
 		updateSettings(array($hook => implode(',', $permanent_functions)));
4825 5098
 	}
@@ -4828,8 +5101,9 @@  discard block
 block discarded – undo
4828 5101
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4829 5102
 
4830 5103
 	// Do nothing, if it's already there.
4831
-	if (in_array($integration_call, $functions))
4832
-		return;
5104
+	if (in_array($integration_call, $functions)) {
5105
+			return;
5106
+	}
4833 5107
 
4834 5108
 	$functions[] = $integration_call;
4835 5109
 	$modSettings[$hook] = implode(',', $functions);
@@ -4852,12 +5126,14 @@  discard block
 block discarded – undo
4852 5126
 	global $smcFunc, $modSettings;
4853 5127
 
4854 5128
 	// Any objects?
4855
-	if ($object)
4856
-		$function = $function . '#';
5129
+	if ($object) {
5130
+			$function = $function . '#';
5131
+	}
4857 5132
 
4858 5133
 	// Any files  to load?
4859
-	if (!empty($file) && is_string($file))
4860
-		$function = $file . '|' . $function;
5134
+	if (!empty($file) && is_string($file)) {
5135
+			$function = $file . '|' . $function;
5136
+	}
4861 5137
 
4862 5138
 	// Get the correct string.
4863 5139
 	$integration_call = $function;
@@ -4878,16 +5154,18 @@  discard block
 block discarded – undo
4878 5154
 	{
4879 5155
 		$current_functions = explode(',', $current_functions);
4880 5156
 
4881
-		if (in_array($integration_call, $current_functions))
4882
-			updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
5157
+		if (in_array($integration_call, $current_functions)) {
5158
+					updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
5159
+		}
4883 5160
 	}
4884 5161
 
4885 5162
 	// Turn the function list into something usable.
4886 5163
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4887 5164
 
4888 5165
 	// You can only remove it if it's available.
4889
-	if (!in_array($integration_call, $functions))
4890
-		return;
5166
+	if (!in_array($integration_call, $functions)) {
5167
+			return;
5168
+	}
4891 5169
 
4892 5170
 	$functions = array_diff($functions, array($integration_call));
4893 5171
 	$modSettings[$hook] = implode(',', $functions);
@@ -4908,17 +5186,20 @@  discard block
 block discarded – undo
4908 5186
 	global $context, $smcFunc, $txt, $db_show_debug;
4909 5187
 
4910 5188
 	// Really?
4911
-	if (empty($string))
4912
-		return false;
5189
+	if (empty($string)) {
5190
+			return false;
5191
+	}
4913 5192
 
4914 5193
 	// An array? should be a "callable" array IE array(object/class, valid_callable).
4915 5194
 	// A closure? should be a callable one.
4916
-	if (is_array($string) || $string instanceof Closure)
4917
-		return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
5195
+	if (is_array($string) || $string instanceof Closure) {
5196
+			return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
5197
+	}
4918 5198
 
4919 5199
 	// No full objects, sorry! pass a method or a property instead!
4920
-	if (is_object($string))
4921
-		return false;
5200
+	if (is_object($string)) {
5201
+			return false;
5202
+	}
4922 5203
 
4923 5204
 	// Stay vitaminized my friends...
4924 5205
 	$string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string));
@@ -4927,8 +5208,9 @@  discard block
 block discarded – undo
4927 5208
 	$string = load_file($string);
4928 5209
 
4929 5210
 	// Loaded file failed
4930
-	if (empty($string))
4931
-		return false;
5211
+	if (empty($string)) {
5212
+			return false;
5213
+	}
4932 5214
 
4933 5215
 	// Found a method.
4934 5216
 	if (strpos($string, '::') !== false)
@@ -4949,8 +5231,9 @@  discard block
 block discarded – undo
4949 5231
 				// Add another one to the list.
4950 5232
 				if ($db_show_debug === true)
4951 5233
 				{
4952
-					if (!isset($context['debug']['instances']))
4953
-						$context['debug']['instances'] = array();
5234
+					if (!isset($context['debug']['instances'])) {
5235
+											$context['debug']['instances'] = array();
5236
+					}
4954 5237
 
4955 5238
 					$context['debug']['instances'][$class] = $class;
4956 5239
 				}
@@ -4960,13 +5243,15 @@  discard block
 block discarded – undo
4960 5243
 		}
4961 5244
 
4962 5245
 		// Right then. This is a call to a static method.
4963
-		else
4964
-			$func = array($class, $method);
5246
+		else {
5247
+					$func = array($class, $method);
5248
+		}
4965 5249
 	}
4966 5250
 
4967 5251
 	// Nope! just a plain regular function.
4968
-	else
4969
-		$func = $string;
5252
+	else {
5253
+			$func = $string;
5254
+	}
4970 5255
 
4971 5256
 	// Right, we got what we need, time to do some checks.
4972 5257
 	if (!is_callable($func, false, $callable_name))
@@ -4982,17 +5267,18 @@  discard block
 block discarded – undo
4982 5267
 	else
4983 5268
 	{
4984 5269
 		// What are we gonna do about it?
4985
-		if ($return)
4986
-			return $func;
5270
+		if ($return) {
5271
+					return $func;
5272
+		}
4987 5273
 
4988 5274
 		// If this is a plain function, avoid the heat of calling call_user_func().
4989 5275
 		else
4990 5276
 		{
4991
-			if (is_array($func))
4992
-				call_user_func($func);
4993
-
4994
-			else
4995
-				$func();
5277
+			if (is_array($func)) {
5278
+							call_user_func($func);
5279
+			} else {
5280
+							$func();
5281
+			}
4996 5282
 		}
4997 5283
 	}
4998 5284
 }
@@ -5009,31 +5295,34 @@  discard block
 block discarded – undo
5009 5295
 {
5010 5296
 	global $sourcedir, $txt, $boarddir, $settings;
5011 5297
 
5012
-	if (empty($string))
5013
-		return false;
5298
+	if (empty($string)) {
5299
+			return false;
5300
+	}
5014 5301
 
5015 5302
 	if (strpos($string, '|') !== false)
5016 5303
 	{
5017 5304
 		list ($file, $string) = explode('|', $string);
5018 5305
 
5019 5306
 		// Match the wildcards to their regular vars.
5020
-		if (empty($settings['theme_dir']))
5021
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
5022
-
5023
-		else
5024
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
5307
+		if (empty($settings['theme_dir'])) {
5308
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
5309
+		} else {
5310
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
5311
+		}
5025 5312
 
5026 5313
 		// Load the file if it can be loaded.
5027
-		if (file_exists($absPath))
5028
-			require_once($absPath);
5314
+		if (file_exists($absPath)) {
5315
+					require_once($absPath);
5316
+		}
5029 5317
 
5030 5318
 		// No? try a fallback to $sourcedir
5031 5319
 		else
5032 5320
 		{
5033 5321
 			$absPath = $sourcedir .'/'. $file;
5034 5322
 
5035
-			if (file_exists($absPath))
5036
-				require_once($absPath);
5323
+			if (file_exists($absPath)) {
5324
+							require_once($absPath);
5325
+			}
5037 5326
 
5038 5327
 			// Sorry, can't do much for you at this point.
5039 5328
 			else
@@ -5072,8 +5361,9 @@  discard block
 block discarded – undo
5072 5361
 	preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match);
5073 5362
 
5074 5363
 	// No scheme? No data for you!
5075
-	if (empty($match[1]))
5076
-		return false;
5364
+	if (empty($match[1])) {
5365
+			return false;
5366
+	}
5077 5367
 
5078 5368
 	// An FTP url. We should try connecting and RETRieving it...
5079 5369
 	elseif ($match[1] == 'ftp')
@@ -5083,23 +5373,26 @@  discard block
 block discarded – undo
5083 5373
 
5084 5374
 		// Establish a connection and attempt to enable passive mode.
5085 5375
 		$ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email);
5086
-		if ($ftp->error !== false || !$ftp->passive())
5087
-			return false;
5376
+		if ($ftp->error !== false || !$ftp->passive()) {
5377
+					return false;
5378
+		}
5088 5379
 
5089 5380
 		// I want that one *points*!
5090 5381
 		fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n");
5091 5382
 
5092 5383
 		// Since passive mode worked (or we would have returned already!) open the connection.
5093 5384
 		$fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5);
5094
-		if (!$fp)
5095
-			return false;
5385
+		if (!$fp) {
5386
+					return false;
5387
+		}
5096 5388
 
5097 5389
 		// The server should now say something in acknowledgement.
5098 5390
 		$ftp->check_response(150);
5099 5391
 
5100 5392
 		$data = '';
5101
-		while (!feof($fp))
5102
-			$data .= fread($fp, 4096);
5393
+		while (!feof($fp)) {
5394
+					$data .= fread($fp, 4096);
5395
+		}
5103 5396
 		fclose($fp);
5104 5397
 
5105 5398
 		// All done, right?  Good.
@@ -5111,8 +5404,9 @@  discard block
 block discarded – undo
5111 5404
 	elseif (isset($match[1]) && $match[1] == 'http')
5112 5405
 	{
5113 5406
 		// First try to use fsockopen, because it is fastest.
5114
-		if ($keep_alive && $match[3] == $keep_alive_dom)
5115
-			$fp = $keep_alive_fp;
5407
+		if ($keep_alive && $match[3] == $keep_alive_dom) {
5408
+					$fp = $keep_alive_fp;
5409
+		}
5116 5410
 		if (empty($fp))
5117 5411
 		{
5118 5412
 			// Open the socket on the port we want...
@@ -5132,20 +5426,21 @@  discard block
 block discarded – undo
5132 5426
 				fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n");
5133 5427
 				fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
5134 5428
 				fwrite($fp, 'user-agent: PHP/SMF' . "\r\n");
5135
-				if ($keep_alive)
5136
-					fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n");
5137
-				else
5138
-					fwrite($fp, 'connection: close' . "\r\n\r\n");
5139
-			}
5140
-			else
5429
+				if ($keep_alive) {
5430
+									fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n");
5431
+				} else {
5432
+									fwrite($fp, 'connection: close' . "\r\n\r\n");
5433
+				}
5434
+			} else
5141 5435
 			{
5142 5436
 				fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n");
5143 5437
 				fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
5144 5438
 				fwrite($fp, 'user-agent: PHP/SMF' . "\r\n");
5145
-				if ($keep_alive)
5146
-					fwrite($fp, 'connection: Keep-Alive' . "\r\n");
5147
-				else
5148
-					fwrite($fp, 'connection: close' . "\r\n");
5439
+				if ($keep_alive) {
5440
+									fwrite($fp, 'connection: Keep-Alive' . "\r\n");
5441
+				} else {
5442
+									fwrite($fp, 'connection: close' . "\r\n");
5443
+				}
5149 5444
 				fwrite($fp, 'content-type: application/x-www-form-urlencoded' . "\r\n");
5150 5445
 				fwrite($fp, 'content-length: ' . strlen($post_data) . "\r\n\r\n");
5151 5446
 				fwrite($fp, $post_data);
@@ -5158,30 +5453,33 @@  discard block
 block discarded – undo
5158 5453
 			{
5159 5454
 				$header = '';
5160 5455
 				$location = '';
5161
-				while (!feof($fp) && trim($header = fgets($fp, 4096)) != '')
5162
-					if (strpos($header, 'location:') !== false)
5456
+				while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') {
5457
+									if (strpos($header, 'location:') !== false)
5163 5458
 						$location = trim(substr($header, strpos($header, ':') + 1));
5459
+				}
5164 5460
 
5165
-				if (empty($location))
5166
-					return false;
5167
-				else
5461
+				if (empty($location)) {
5462
+									return false;
5463
+				} else
5168 5464
 				{
5169
-					if (!$keep_alive)
5170
-						fclose($fp);
5465
+					if (!$keep_alive) {
5466
+											fclose($fp);
5467
+					}
5171 5468
 					return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1);
5172 5469
 				}
5173 5470
 			}
5174 5471
 
5175 5472
 			// Make sure we get a 200 OK.
5176
-			elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0)
5177
-				return false;
5473
+			elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) {
5474
+							return false;
5475
+			}
5178 5476
 
5179 5477
 			// Skip the headers...
5180 5478
 			while (!feof($fp) && trim($header = fgets($fp, 4096)) != '')
5181 5479
 			{
5182
-				if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0)
5183
-					$content_length = $match[1];
5184
-				elseif (preg_match('~connection:\s*close~i', $header) != 0)
5480
+				if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) {
5481
+									$content_length = $match[1];
5482
+				} elseif (preg_match('~connection:\s*close~i', $header) != 0)
5185 5483
 				{
5186 5484
 					$keep_alive_dom = null;
5187 5485
 					$keep_alive = false;
@@ -5193,17 +5491,19 @@  discard block
 block discarded – undo
5193 5491
 			$data = '';
5194 5492
 			if (isset($content_length))
5195 5493
 			{
5196
-				while (!feof($fp) && strlen($data) < $content_length)
5197
-					$data .= fread($fp, $content_length - strlen($data));
5198
-			}
5199
-			else
5494
+				while (!feof($fp) && strlen($data) < $content_length) {
5495
+									$data .= fread($fp, $content_length - strlen($data));
5496
+				}
5497
+			} else
5200 5498
 			{
5201
-				while (!feof($fp))
5202
-					$data .= fread($fp, 4096);
5499
+				while (!feof($fp)) {
5500
+									$data .= fread($fp, 4096);
5501
+				}
5203 5502
 			}
5204 5503
 
5205
-			if (!$keep_alive)
5206
-				fclose($fp);
5504
+			if (!$keep_alive) {
5505
+							fclose($fp);
5506
+			}
5207 5507
 		}
5208 5508
 
5209 5509
 		// If using fsockopen didn't work, try to use cURL if available.
@@ -5216,17 +5516,18 @@  discard block
 block discarded – undo
5216 5516
 			$fetch_data->get_url_data($url, $post_data);
5217 5517
 
5218 5518
 			// no errors and a 200 result, then we have a good dataset, well we at least have data. ;)
5219
-			if ($fetch_data->result('code') == 200 && !$fetch_data->result('error'))
5220
-				$data = $fetch_data->result('body');
5221
-			else
5222
-				return false;
5519
+			if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) {
5520
+							$data = $fetch_data->result('body');
5521
+			} else {
5522
+							return false;
5523
+			}
5223 5524
 		}
5224 5525
 
5225 5526
 		// Neither fsockopen nor curl are available. Well, phooey.
5226
-		else
5227
-			return false;
5228
-	}
5229
-	else
5527
+		else {
5528
+					return false;
5529
+		}
5530
+	} else
5230 5531
 	{
5231 5532
 		// Umm, this shouldn't happen?
5232 5533
 		trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE);
@@ -5246,8 +5547,9 @@  discard block
 block discarded – undo
5246 5547
 	global $user_info, $smcFunc;
5247 5548
 
5248 5549
 	// Make sure we have something to work with.
5249
-	if (empty($topic))
5250
-		return array();
5550
+	if (empty($topic)) {
5551
+			return array();
5552
+	}
5251 5553
 
5252 5554
 
5253 5555
 	// We already know the number of likes per message, we just want to know whether the current user liked it or not.
@@ -5270,8 +5572,9 @@  discard block
 block discarded – undo
5270 5572
 				'topic' => $topic,
5271 5573
 			)
5272 5574
 		);
5273
-		while ($row = $smcFunc['db_fetch_assoc']($request))
5274
-			$temp[] = (int) $row['content_id'];
5575
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5576
+					$temp[] = (int) $row['content_id'];
5577
+		}
5275 5578
 
5276 5579
 		cache_put_data($cache_key, $temp, $ttl);
5277 5580
 	}
@@ -5292,8 +5595,9 @@  discard block
 block discarded – undo
5292 5595
 {
5293 5596
 	global $context;
5294 5597
 
5295
-	if (empty($string))
5296
-		return $string;
5598
+	if (empty($string)) {
5599
+			return $string;
5600
+	}
5297 5601
 
5298 5602
 	// UTF-8 occurences of MS special characters
5299 5603
 	$findchars_utf8 = array(
@@ -5334,10 +5638,11 @@  discard block
 block discarded – undo
5334 5638
 		'--',	// &mdash;
5335 5639
 	);
5336 5640
 
5337
-	if ($context['utf8'])
5338
-		$string = str_replace($findchars_utf8, $replacechars, $string);
5339
-	else
5340
-		$string = str_replace($findchars_iso, $replacechars, $string);
5641
+	if ($context['utf8']) {
5642
+			$string = str_replace($findchars_utf8, $replacechars, $string);
5643
+	} else {
5644
+			$string = str_replace($findchars_iso, $replacechars, $string);
5645
+	}
5341 5646
 
5342 5647
 	return $string;
5343 5648
 }
@@ -5356,49 +5661,59 @@  discard block
 block discarded – undo
5356 5661
 {
5357 5662
 	global $context;
5358 5663
 
5359
-	if (!isset($matches[2]))
5360
-		return '';
5664
+	if (!isset($matches[2])) {
5665
+			return '';
5666
+	}
5361 5667
 
5362 5668
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
5363 5669
 
5364 5670
 	// remove left to right / right to left overrides
5365
-	if ($num === 0x202D || $num === 0x202E)
5366
-		return '';
5671
+	if ($num === 0x202D || $num === 0x202E) {
5672
+			return '';
5673
+	}
5367 5674
 
5368 5675
 	// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
5369
-	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E)))
5370
-		return '&#' . $num . ';';
5676
+	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) {
5677
+			return '&#' . $num . ';';
5678
+	}
5371 5679
 
5372 5680
 	if (empty($context['utf8']))
5373 5681
 	{
5374 5682
 		// no control characters
5375
-		if ($num < 0x20)
5376
-			return '';
5683
+		if ($num < 0x20) {
5684
+					return '';
5685
+		}
5377 5686
 		// text is text
5378
-		elseif ($num < 0x80)
5379
-			return chr($num);
5687
+		elseif ($num < 0x80) {
5688
+					return chr($num);
5689
+		}
5380 5690
 		// all others get html-ised
5381
-		else
5382
-			return '&#' . $matches[2] . ';';
5383
-	}
5384
-	else
5691
+		else {
5692
+					return '&#' . $matches[2] . ';';
5693
+		}
5694
+	} else
5385 5695
 	{
5386 5696
 		// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
5387 5697
 		// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
5388
-		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
5389
-			return '';
5698
+		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) {
5699
+					return '';
5700
+		}
5390 5701
 		// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
5391
-		elseif ($num < 0x80)
5392
-			return chr($num);
5702
+		elseif ($num < 0x80) {
5703
+					return chr($num);
5704
+		}
5393 5705
 		// <0x800 (2048)
5394
-		elseif ($num < 0x800)
5395
-			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5706
+		elseif ($num < 0x800) {
5707
+					return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5708
+		}
5396 5709
 		// < 0x10000 (65536)
5397
-		elseif ($num < 0x10000)
5398
-			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5710
+		elseif ($num < 0x10000) {
5711
+					return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5712
+		}
5399 5713
 		// <= 0x10FFFF (1114111)
5400
-		else
5401
-			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5714
+		else {
5715
+					return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5716
+		}
5402 5717
 	}
5403 5718
 }
5404 5719
 
@@ -5414,28 +5729,34 @@  discard block
 block discarded – undo
5414 5729
  */
5415 5730
 function fixchar__callback($matches)
5416 5731
 {
5417
-	if (!isset($matches[1]))
5418
-		return '';
5732
+	if (!isset($matches[1])) {
5733
+			return '';
5734
+	}
5419 5735
 
5420 5736
 	$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];
5421 5737
 
5422 5738
 	// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
5423 5739
 	// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
5424
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
5425
-		return '';
5740
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) {
5741
+			return '';
5742
+	}
5426 5743
 	// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
5427
-	elseif ($num < 0x80)
5428
-		return chr($num);
5744
+	elseif ($num < 0x80) {
5745
+			return chr($num);
5746
+	}
5429 5747
 	// <0x800 (2048)
5430
-	elseif ($num < 0x800)
5431
-		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5748
+	elseif ($num < 0x800) {
5749
+			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5750
+	}
5432 5751
 	// < 0x10000 (65536)
5433
-	elseif ($num < 0x10000)
5434
-		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5752
+	elseif ($num < 0x10000) {
5753
+			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5754
+	}
5435 5755
 	// <= 0x10FFFF (1114111)
5436
-	else
5437
-		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5438
-}
5756
+	else {
5757
+			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5758
+	}
5759
+	}
5439 5760
 
5440 5761
 /**
5441 5762
  * Strips out invalid html entities, replaces others with html style &#123; codes
@@ -5448,17 +5769,19 @@  discard block
 block discarded – undo
5448 5769
  */
5449 5770
 function entity_fix__callback($matches)
5450 5771
 {
5451
-	if (!isset($matches[2]))
5452
-		return '';
5772
+	if (!isset($matches[2])) {
5773
+			return '';
5774
+	}
5453 5775
 
5454 5776
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
5455 5777
 
5456 5778
 	// we don't allow control characters, characters out of range, byte markers, etc
5457
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
5458
-		return '';
5459
-	else
5460
-		return '&#' . $num . ';';
5461
-}
5779
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) {
5780
+			return '';
5781
+	} else {
5782
+			return '&#' . $num . ';';
5783
+	}
5784
+	}
5462 5785
 
5463 5786
 /**
5464 5787
  * Return a Gravatar URL based on
@@ -5482,18 +5805,23 @@  discard block
 block discarded – undo
5482 5805
 		$ratings = array('G', 'PG', 'R', 'X');
5483 5806
 		$defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank');
5484 5807
 		$url_params = array();
5485
-		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings))
5486
-			$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5487
-		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults))
5488
-			$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5489
-		if (!empty($modSettings['avatar_max_width_external']))
5490
-			$size_string = (int) $modSettings['avatar_max_width_external'];
5491
-		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string))
5492
-			if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5808
+		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) {
5809
+					$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5810
+		}
5811
+		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) {
5812
+					$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5813
+		}
5814
+		if (!empty($modSettings['avatar_max_width_external'])) {
5815
+					$size_string = (int) $modSettings['avatar_max_width_external'];
5816
+		}
5817
+		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) {
5818
+					if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5493 5819
 				$size_string = $modSettings['avatar_max_height_external'];
5820
+		}
5494 5821
 
5495
-		if (!empty($size_string))
5496
-			$url_params[] = 's=' . $size_string;
5822
+		if (!empty($size_string)) {
5823
+					$url_params[] = 's=' . $size_string;
5824
+		}
5497 5825
 	}
5498 5826
 	$http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www';
5499 5827
 
@@ -5512,22 +5840,26 @@  discard block
 block discarded – undo
5512 5840
 	static $timezones = null, $lastwhen = null;
5513 5841
 
5514 5842
 	// No point doing this over if we already did it once
5515
-	if (!empty($timezones) && $when == $lastwhen)
5516
-		return $timezones;
5517
-	else
5518
-		$lastwhen = $when;
5843
+	if (!empty($timezones) && $when == $lastwhen) {
5844
+			return $timezones;
5845
+	} else {
5846
+			$lastwhen = $when;
5847
+	}
5519 5848
 
5520 5849
 	// Parseable datetime string?
5521
-	if (is_int($timestamp = strtotime($when)))
5522
-		$when = $timestamp;
5850
+	if (is_int($timestamp = strtotime($when))) {
5851
+			$when = $timestamp;
5852
+	}
5523 5853
 
5524 5854
 	// A Unix timestamp?
5525
-	elseif (is_numeric($when))
5526
-		$when = intval($when);
5855
+	elseif (is_numeric($when)) {
5856
+			$when = intval($when);
5857
+	}
5527 5858
 
5528 5859
 	// Invalid value? Just get current Unix timestamp.
5529
-	else
5530
-		$when = time();
5860
+	else {
5861
+			$when = time();
5862
+	}
5531 5863
 
5532 5864
 	// We'll need these too
5533 5865
 	$date_when = date_create('@' . $when);
@@ -5542,8 +5874,9 @@  discard block
 block discarded – undo
5542 5874
 	foreach ($priority_countries as $country)
5543 5875
 	{
5544 5876
 		$country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country)));
5545
-		if (!empty($country_tzids))
5546
-			$priority_tzids = array_merge($priority_tzids, $country_tzids);
5877
+		if (!empty($country_tzids)) {
5878
+					$priority_tzids = array_merge($priority_tzids, $country_tzids);
5879
+		}
5547 5880
 	}
5548 5881
 
5549 5882
 	// Antarctic research stations should be listed last, unless you're running a penguin forum
@@ -5557,8 +5890,9 @@  discard block
 block discarded – undo
5557 5890
 	foreach ($tzids as $tzid)
5558 5891
 	{
5559 5892
 		// We don't want UTC right now
5560
-		if ($tzid == 'UTC')
5561
-			continue;
5893
+		if ($tzid == 'UTC') {
5894
+					continue;
5895
+		}
5562 5896
 
5563 5897
 		$tz = timezone_open($tzid);
5564 5898
 
@@ -5579,13 +5913,14 @@  discard block
 block discarded – undo
5579 5913
 		}
5580 5914
 
5581 5915
 		// A time zone from a prioritized country?
5582
-		if (in_array($tzid, $priority_tzids))
5583
-			$priority_zones[$tzkey] = true;
5916
+		if (in_array($tzid, $priority_tzids)) {
5917
+					$priority_zones[$tzkey] = true;
5918
+		}
5584 5919
 
5585 5920
 		// Keep track of the location and offset for this tzid
5586
-		if (!empty($txt[$tzid]))
5587
-			$zones[$tzkey]['locations'][] = $txt[$tzid];
5588
-		else
5921
+		if (!empty($txt[$tzid])) {
5922
+					$zones[$tzkey]['locations'][] = $txt[$tzid];
5923
+		} else
5589 5924
 		{
5590 5925
 			$tzid_parts = explode('/', $tzid);
5591 5926
 			$zones[$tzkey]['locations'][] = str_replace(array('St_', '_'), array('St. ', ' '), array_pop($tzid_parts));
@@ -5605,23 +5940,27 @@  discard block
 block discarded – undo
5605 5940
 		date_timezone_set($date_when, timezone_open($tzvalue['tzid']));
5606 5941
 
5607 5942
 		// Use the custom description, if there is one
5608
-		if (!empty($tztxt[$tzvalue['tzid']]))
5609
-			$desc = $tztxt[$tzvalue['tzid']];
5943
+		if (!empty($tztxt[$tzvalue['tzid']])) {
5944
+					$desc = $tztxt[$tzvalue['tzid']];
5945
+		}
5610 5946
 		// Otherwise, use the list of locations (max 5, so things don't get silly)
5611
-		else
5612
-			$desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : '');
5947
+		else {
5948
+					$desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : '');
5949
+		}
5613 5950
 
5614 5951
 		// Show the UTC offset and the abbreviation, if it's something like 'MST' and not '-06'
5615 5952
 		$desc = '[UTC' . date_format($date_when, 'P') . '] - ' . (!strspn($tzvalue['abbr'], '+-') ? $tzvalue['abbr'] . ' - ' : '') . $desc;
5616 5953
 
5617
-		if (isset($priority_zones[$tzkey]))
5618
-			$priority_timezones[$tzvalue['tzid']] = $desc;
5619
-		else
5620
-			$timezones[$tzvalue['tzid']] = $desc;
5954
+		if (isset($priority_zones[$tzkey])) {
5955
+					$priority_timezones[$tzvalue['tzid']] = $desc;
5956
+		} else {
5957
+					$timezones[$tzvalue['tzid']] = $desc;
5958
+		}
5621 5959
 	}
5622 5960
 
5623
-	if (!empty($priority_timezones))
5624
-		$priority_timezones[] = '-----';
5961
+	if (!empty($priority_timezones)) {
5962
+			$priority_timezones[] = '-----';
5963
+	}
5625 5964
 
5626 5965
 	$timezones = array_merge(
5627 5966
 		$priority_timezones,
@@ -5638,8 +5977,9 @@  discard block
 block discarded – undo
5638 5977
  */
5639 5978
 function inet_ptod($ip_address)
5640 5979
 {
5641
-	if (!isValidIP($ip_address))
5642
-		return $ip_address;
5980
+	if (!isValidIP($ip_address)) {
5981
+			return $ip_address;
5982
+	}
5643 5983
 
5644 5984
 	$bin = inet_pton($ip_address);
5645 5985
 	return $bin;
@@ -5651,13 +5991,15 @@  discard block
 block discarded – undo
5651 5991
  */
5652 5992
 function inet_dtop($bin)
5653 5993
 {
5654
-	if(empty($bin))
5655
-		return '';
5994
+	if(empty($bin)) {
5995
+			return '';
5996
+	}
5656 5997
 
5657 5998
 	global $db_type;
5658 5999
 
5659
-	if ($db_type == 'postgresql')
5660
-		return $bin;
6000
+	if ($db_type == 'postgresql') {
6001
+			return $bin;
6002
+	}
5661 6003
 
5662 6004
 	$ip_address = inet_ntop($bin);
5663 6005
 
@@ -5682,26 +6024,32 @@  discard block
 block discarded – undo
5682 6024
  */
5683 6025
 function _safe_serialize($value)
5684 6026
 {
5685
-	if(is_null($value))
5686
-		return 'N;';
6027
+	if(is_null($value)) {
6028
+			return 'N;';
6029
+	}
5687 6030
 
5688
-	if(is_bool($value))
5689
-		return 'b:'. (int) $value .';';
6031
+	if(is_bool($value)) {
6032
+			return 'b:'. (int) $value .';';
6033
+	}
5690 6034
 
5691
-	if(is_int($value))
5692
-		return 'i:'. $value .';';
6035
+	if(is_int($value)) {
6036
+			return 'i:'. $value .';';
6037
+	}
5693 6038
 
5694
-	if(is_float($value))
5695
-		return 'd:'. str_replace(',', '.', $value) .';';
6039
+	if(is_float($value)) {
6040
+			return 'd:'. str_replace(',', '.', $value) .';';
6041
+	}
5696 6042
 
5697
-	if(is_string($value))
5698
-		return 's:'. strlen($value) .':"'. $value .'";';
6043
+	if(is_string($value)) {
6044
+			return 's:'. strlen($value) .':"'. $value .'";';
6045
+	}
5699 6046
 
5700 6047
 	if(is_array($value))
5701 6048
 	{
5702 6049
 		$out = '';
5703
-		foreach($value as $k => $v)
5704
-			$out .= _safe_serialize($k) . _safe_serialize($v);
6050
+		foreach($value as $k => $v) {
6051
+					$out .= _safe_serialize($k) . _safe_serialize($v);
6052
+		}
5705 6053
 
5706 6054
 		return 'a:'. count($value) .':{'. $out .'}';
5707 6055
 	}
@@ -5727,8 +6075,9 @@  discard block
 block discarded – undo
5727 6075
 
5728 6076
 	$out = _safe_serialize($value);
5729 6077
 
5730
-	if (isset($mbIntEnc))
5731
-		mb_internal_encoding($mbIntEnc);
6078
+	if (isset($mbIntEnc)) {
6079
+			mb_internal_encoding($mbIntEnc);
6080
+	}
5732 6081
 
5733 6082
 	return $out;
5734 6083
 }
@@ -5745,8 +6094,9 @@  discard block
 block discarded – undo
5745 6094
 function _safe_unserialize($str)
5746 6095
 {
5747 6096
 	// Input  is not a string.
5748
-	if(empty($str) || !is_string($str))
5749
-		return false;
6097
+	if(empty($str) || !is_string($str)) {
6098
+			return false;
6099
+	}
5750 6100
 
5751 6101
 	$stack = array();
5752 6102
 	$expected = array();
@@ -5762,43 +6112,38 @@  discard block
 block discarded – undo
5762 6112
 	while($state != 1)
5763 6113
 	{
5764 6114
 		$type = isset($str[0]) ? $str[0] : '';
5765
-		if($type == '}')
5766
-			$str = substr($str, 1);
5767
-
5768
-		else if($type == 'N' && $str[1] == ';')
6115
+		if($type == '}') {
6116
+					$str = substr($str, 1);
6117
+		} else if($type == 'N' && $str[1] == ';')
5769 6118
 		{
5770 6119
 			$value = null;
5771 6120
 			$str = substr($str, 2);
5772
-		}
5773
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
6121
+		} else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5774 6122
 		{
5775 6123
 			$value = $matches[1] == '1' ? true : false;
5776 6124
 			$str = substr($str, 4);
5777
-		}
5778
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
6125
+		} else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5779 6126
 		{
5780 6127
 			$value = (int)$matches[1];
5781 6128
 			$str = $matches[2];
5782
-		}
5783
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
6129
+		} else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5784 6130
 		{
5785 6131
 			$value = (float)$matches[1];
5786 6132
 			$str = $matches[3];
5787
-		}
5788
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
6133
+		} else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5789 6134
 		{
5790 6135
 			$value = substr($matches[2], 0, (int)$matches[1]);
5791 6136
 			$str = substr($matches[2], (int)$matches[1] + 2);
5792
-		}
5793
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
6137
+		} else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5794 6138
 		{
5795 6139
 			$expectedLength = (int)$matches[1];
5796 6140
 			$str = $matches[2];
5797 6141
 		}
5798 6142
 
5799 6143
 		// Object or unknown/malformed type.
5800
-		else
5801
-			return false;
6144
+		else {
6145
+					return false;
6146
+		}
5802 6147
 
5803 6148
 		switch($state)
5804 6149
 		{
@@ -5826,8 +6171,9 @@  discard block
 block discarded – undo
5826 6171
 				if($type == '}')
5827 6172
 				{
5828 6173
 					// Array size is less than expected.
5829
-					if(count($list) < end($expected))
5830
-						return false;
6174
+					if(count($list) < end($expected)) {
6175
+											return false;
6176
+					}
5831 6177
 
5832 6178
 					unset($list);
5833 6179
 					$list = &$stack[count($stack)-1];
@@ -5836,8 +6182,9 @@  discard block
 block discarded – undo
5836 6182
 					// Go to terminal state if we're at the end of the root array.
5837 6183
 					array_pop($expected);
5838 6184
 
5839
-					if(count($expected) == 0)
5840
-						$state = 1;
6185
+					if(count($expected) == 0) {
6186
+											$state = 1;
6187
+					}
5841 6188
 
5842 6189
 					break;
5843 6190
 				}
@@ -5845,8 +6192,9 @@  discard block
 block discarded – undo
5845 6192
 				if($type == 'i' || $type == 's')
5846 6193
 				{
5847 6194
 					// Array size exceeds expected length.
5848
-					if(count($list) >= end($expected))
5849
-						return false;
6195
+					if(count($list) >= end($expected)) {
6196
+											return false;
6197
+					}
5850 6198
 
5851 6199
 					$key = $value;
5852 6200
 					$state = 3;
@@ -5880,8 +6228,9 @@  discard block
 block discarded – undo
5880 6228
 	}
5881 6229
 
5882 6230
 	// Trailing data in input.
5883
-	if(!empty($str))
5884
-		return false;
6231
+	if(!empty($str)) {
6232
+			return false;
6233
+	}
5885 6234
 
5886 6235
 	return $data;
5887 6236
 }
@@ -5904,8 +6253,9 @@  discard block
 block discarded – undo
5904 6253
 
5905 6254
 	$out = _safe_unserialize($str);
5906 6255
 
5907
-	if (isset($mbIntEnc))
5908
-		mb_internal_encoding($mbIntEnc);
6256
+	if (isset($mbIntEnc)) {
6257
+			mb_internal_encoding($mbIntEnc);
6258
+	}
5909 6259
 
5910 6260
 	return $out;
5911 6261
 }
@@ -5920,12 +6270,14 @@  discard block
 block discarded – undo
5920 6270
 function smf_chmod($file, $value = 0)
5921 6271
 {
5922 6272
 	// No file? no checks!
5923
-	if (empty($file))
5924
-		return false;
6273
+	if (empty($file)) {
6274
+			return false;
6275
+	}
5925 6276
 
5926 6277
 	// Already writable?
5927
-	if (is_writable($file))
5928
-		return true;
6278
+	if (is_writable($file)) {
6279
+			return true;
6280
+	}
5929 6281
 
5930 6282
 	// Do we have a file or a dir?
5931 6283
 	$isDir = is_dir($file);
@@ -5941,10 +6293,9 @@  discard block
 block discarded – undo
5941 6293
 		{
5942 6294
 			$isWritable = true;
5943 6295
 			break;
6296
+		} else {
6297
+					@chmod($file, $val);
5944 6298
 		}
5945
-
5946
-		else
5947
-			@chmod($file, $val);
5948 6299
 	}
5949 6300
 
5950 6301
 	return $isWritable;
@@ -5963,8 +6314,9 @@  discard block
 block discarded – undo
5963 6314
 	global $txt;
5964 6315
 
5965 6316
 	// Come on...
5966
-	if (empty($json) || !is_string($json))
5967
-		return array();
6317
+	if (empty($json) || !is_string($json)) {
6318
+			return array();
6319
+	}
5968 6320
 
5969 6321
 	$returnArray = @json_decode($json, $returnAsArray);
5970 6322
 
@@ -6002,11 +6354,11 @@  discard block
 block discarded – undo
6002 6354
 		$jsonDebug = $jsonDebug[0];
6003 6355
 		loadLanguage('Errors');
6004 6356
 
6005
-		if (!empty($jsonDebug))
6006
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
6007
-
6008
-		else
6009
-			log_error($txt['json_'. $jsonError], 'critical');
6357
+		if (!empty($jsonDebug)) {
6358
+					log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
6359
+		} else {
6360
+					log_error($txt['json_'. $jsonError], 'critical');
6361
+		}
6010 6362
 
6011 6363
 		// Everyone expects an array.
6012 6364
 		return array();
@@ -6040,8 +6392,9 @@  discard block
 block discarded – undo
6040 6392
 	global $db_show_debug, $modSettings;
6041 6393
 
6042 6394
 	// Defensive programming anyone?
6043
-	if (empty($data))
6044
-		return false;
6395
+	if (empty($data)) {
6396
+			return false;
6397
+	}
6045 6398
 
6046 6399
 	// Don't need extra stuff...
6047 6400
 	$db_show_debug = false;
@@ -6049,11 +6402,11 @@  discard block
 block discarded – undo
6049 6402
 	// Kill anything else.
6050 6403
 	ob_end_clean();
6051 6404
 
6052
-	if (!empty($modSettings['CompressedOutput']))
6053
-		@ob_start('ob_gzhandler');
6054
-
6055
-	else
6056
-		ob_start();
6405
+	if (!empty($modSettings['CompressedOutput'])) {
6406
+			@ob_start('ob_gzhandler');
6407
+	} else {
6408
+			ob_start();
6409
+	}
6057 6410
 
6058 6411
 	// Set the header.
6059 6412
 	header($type);
@@ -6085,8 +6438,9 @@  discard block
 block discarded – undo
6085 6438
 	static $done = false;
6086 6439
 
6087 6440
 	// If we don't need to do anything, don't
6088
-	if (!$update && $done)
6089
-		return;
6441
+	if (!$update && $done) {
6442
+			return;
6443
+	}
6090 6444
 
6091 6445
 	// Should we get a new copy of the official list of TLDs?
6092 6446
 	if ($update)
@@ -6098,8 +6452,9 @@  discard block
 block discarded – undo
6098 6452
 		// marauding bandits roaming on the surface. We don't want to waste precious electricity on
6099 6453
 		// pointlessly repeating background tasks, so we'll wait until the next regularly scheduled
6100 6454
 		// update to see if civilization has been restored.
6101
-		if ($tlds === false)
6102
-			$postapocalypticNightmare = true;
6455
+		if ($tlds === false) {
6456
+					$postapocalypticNightmare = true;
6457
+		}
6103 6458
 	}
6104 6459
 	// If we aren't updating and the regex is valid, we're done
6105 6460
 	elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false)
@@ -6114,10 +6469,11 @@  discard block
 block discarded – undo
6114 6469
 		// Clean $tlds and convert it to an array
6115 6470
 		$tlds = array_filter(explode("\n", strtolower($tlds)), function($line) {
6116 6471
 			$line = trim($line);
6117
-			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false)
6118
-				return false;
6119
-			else
6120
-				return true;
6472
+			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) {
6473
+							return false;
6474
+			} else {
6475
+							return true;
6476
+			}
6121 6477
 		});
6122 6478
 
6123 6479
 		// Convert Punycode to Unicode
@@ -6209,8 +6565,7 @@  discard block
 block discarded – undo
6209 6565
 
6210 6566
 		$strlen = 'mb_strlen';
6211 6567
 		$substr = 'mb_substr';
6212
-	}
6213
-	else
6568
+	} else
6214 6569
 	{
6215 6570
 		$strlen = $smcFunc['strlen'];
6216 6571
 		$substr = $smcFunc['substr'];
@@ -6224,20 +6579,21 @@  discard block
 block discarded – undo
6224 6579
 
6225 6580
 		$first = $substr($string, 0, 1);
6226 6581
 
6227
-		if (empty($index[$first]))
6228
-			$index[$first] = array();
6582
+		if (empty($index[$first])) {
6583
+					$index[$first] = array();
6584
+		}
6229 6585
 
6230 6586
 		if ($strlen($string) > 1)
6231 6587
 		{
6232 6588
 			// Sanity check on recursion
6233
-			if ($depth > 99)
6234
-				$index[$first][$substr($string, 1)] = '';
6235
-
6236
-			else
6237
-				$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6589
+			if ($depth > 99) {
6590
+							$index[$first][$substr($string, 1)] = '';
6591
+			} else {
6592
+							$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6593
+			}
6594
+		} else {
6595
+					$index[$first][''] = '';
6238 6596
 		}
6239
-		else
6240
-			$index[$first][''] = '';
6241 6597
 
6242 6598
 		$depth--;
6243 6599
 		return $index;
@@ -6260,9 +6616,9 @@  discard block
 block discarded – undo
6260 6616
 			$key_regex = preg_quote($key, $delim);
6261 6617
 			$new_key = $key;
6262 6618
 
6263
-			if (empty($value))
6264
-				$sub_regex = '';
6265
-			else
6619
+			if (empty($value)) {
6620
+							$sub_regex = '';
6621
+			} else
6266 6622
 			{
6267 6623
 				$sub_regex = $index_to_regex($value, $delim);
6268 6624
 
@@ -6270,22 +6626,22 @@  discard block
 block discarded – undo
6270 6626
 				{
6271 6627
 					$new_key_array = explode('(?'.'>', $sub_regex);
6272 6628
 					$new_key .= $new_key_array[0];
6629
+				} else {
6630
+									$sub_regex = '(?'.'>' . $sub_regex . ')';
6273 6631
 				}
6274
-				else
6275
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
6276 6632
 			}
6277 6633
 
6278
-			if ($depth > 1)
6279
-				$regex[$new_key] = $key_regex . $sub_regex;
6280
-			else
6634
+			if ($depth > 1) {
6635
+							$regex[$new_key] = $key_regex . $sub_regex;
6636
+			} else
6281 6637
 			{
6282 6638
 				if (($length += strlen($key_regex) + 1) < $max_length || empty($regex))
6283 6639
 				{
6284 6640
 					$regex[$new_key] = $key_regex . $sub_regex;
6285 6641
 					unset($index[$key]);
6642
+				} else {
6643
+									break;
6286 6644
 				}
6287
-				else
6288
-					break;
6289 6645
 			}
6290 6646
 		}
6291 6647
 
@@ -6294,10 +6650,11 @@  discard block
 block discarded – undo
6294 6650
 			$l1 = $strlen($k1);
6295 6651
 			$l2 = $strlen($k2);
6296 6652
 
6297
-			if ($l1 == $l2)
6298
-				return strcmp($k1, $k2) > 0 ? 1 : -1;
6299
-			else
6300
-				return $l1 > $l2 ? -1 : 1;
6653
+			if ($l1 == $l2) {
6654
+							return strcmp($k1, $k2) > 0 ? 1 : -1;
6655
+			} else {
6656
+							return $l1 > $l2 ? -1 : 1;
6657
+			}
6301 6658
 		});
6302 6659
 
6303 6660
 		$depth--;
@@ -6308,21 +6665,24 @@  discard block
 block discarded – undo
6308 6665
 	$index = array();
6309 6666
 	$regex = '';
6310 6667
 
6311
-	foreach ($strings as $string)
6312
-		$index = $add_string_to_index($string, $index);
6668
+	foreach ($strings as $string) {
6669
+			$index = $add_string_to_index($string, $index);
6670
+	}
6313 6671
 
6314 6672
 	if ($returnArray === true)
6315 6673
 	{
6316 6674
 		$regex = array();
6317
-		while (!empty($index))
6318
-			$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6675
+		while (!empty($index)) {
6676
+					$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6677
+		}
6678
+	} else {
6679
+			$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6319 6680
 	}
6320
-	else
6321
-		$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6322 6681
 
6323 6682
 	// Restore PHP's internal character encoding to whatever it was originally
6324
-	if (!empty($current_encoding))
6325
-		mb_internal_encoding($current_encoding);
6683
+	if (!empty($current_encoding)) {
6684
+			mb_internal_encoding($current_encoding);
6685
+	}
6326 6686
 
6327 6687
 	return $regex;
6328 6688
 }
@@ -6365,13 +6725,15 @@  discard block
 block discarded – undo
6365 6725
 	// Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't...
6366 6726
 	$url = str_ireplace('https://', 'http://', $url) . '/';
6367 6727
 	$headers = @get_headers($url);
6368
-	if ($headers === false)
6369
-		return false;
6728
+	if ($headers === false) {
6729
+			return false;
6730
+	}
6370 6731
 
6371 6732
 	// Now to see if it came back https...
6372 6733
 	// First check for a redirect status code in first row (301, 302, 307)
6373
-	if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false)
6374
-		return false;
6734
+	if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) {
6735
+			return false;
6736
+	}
6375 6737
 
6376 6738
 	// Search for the location entry to confirm https
6377 6739
 	$result = false;
@@ -6409,8 +6771,7 @@  discard block
 block discarded – undo
6409 6771
 		$is_admin = $user_info['is_admin'];
6410 6772
 		$mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null;
6411 6773
 		$ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null;
6412
-	}
6413
-	else
6774
+	} else
6414 6775
 	{
6415 6776
 		$request = $smcFunc['db_query']('', '
6416 6777
 				SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group
@@ -6424,17 +6785,19 @@  discard block
 block discarded – undo
6424 6785
 
6425 6786
 		$row = $smcFunc['db_fetch_assoc']($request);
6426 6787
 
6427
-		if (empty($row['additional_groups']))
6428
-			$groups = array($row['id_group'], $row['id_post_group']);
6429
-		else
6430
-			$groups = array_merge(
6788
+		if (empty($row['additional_groups'])) {
6789
+					$groups = array($row['id_group'], $row['id_post_group']);
6790
+		} else {
6791
+					$groups = array_merge(
6431 6792
 					array($row['id_group'], $row['id_post_group']),
6432 6793
 					explode(',', $row['additional_groups'])
6433 6794
 			);
6795
+		}
6434 6796
 
6435 6797
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
6436
-		foreach ($groups as $k => $v)
6437
-			$groups[$k] = (int) $v;
6798
+		foreach ($groups as $k => $v) {
6799
+					$groups[$k] = (int) $v;
6800
+		}
6438 6801
 
6439 6802
 		$is_admin = in_array(1, $groups);
6440 6803
 
@@ -6451,8 +6814,9 @@  discard block
 block discarded – undo
6451 6814
 				'current_member' => $userid,
6452 6815
 			)
6453 6816
 		);
6454
-		while ($row = $smcFunc['db_fetch_assoc']($request))
6455
-			$boards_mod[] = $row['id_board'];
6817
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
6818
+					$boards_mod[] = $row['id_board'];
6819
+		}
6456 6820
 		$smcFunc['db_free_result']($request);
6457 6821
 
6458 6822
 		// Can any of the groups they're in moderate any of the boards?
@@ -6464,8 +6828,9 @@  discard block
 block discarded – undo
6464 6828
 				'groups' => $groups,
6465 6829
 			)
6466 6830
 		);
6467
-		while ($row = $smcFunc['db_fetch_assoc']($request))
6468
-			$boards_mod[] = $row['id_board'];
6831
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
6832
+					$boards_mod[] = $row['id_board'];
6833
+		}
6469 6834
 		$smcFunc['db_free_result']($request);
6470 6835
 
6471 6836
 		// Just in case we've got duplicates here...
@@ -6475,21 +6840,25 @@  discard block
 block discarded – undo
6475 6840
 	}
6476 6841
 
6477 6842
 	// Just build this here, it makes it easier to change/use - administrators can see all boards.
6478
-	if ($is_admin)
6479
-		$query_part['query_see_board'] = '1=1';
6843
+	if ($is_admin) {
6844
+			$query_part['query_see_board'] = '1=1';
6845
+	}
6480 6846
 	// Otherwise just the groups in $user_info['groups'].
6481
-	else
6482
-		$query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')';
6847
+	else {
6848
+			$query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')';
6849
+	}
6483 6850
 
6484 6851
 	// Build the list of boards they WANT to see.
6485 6852
 	// This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
6486 6853
 
6487 6854
 	// If they aren't ignoring any boards then they want to see all the boards they can see
6488
-	if (empty($ignoreboards))
6489
-		$query_part['query_wanna_see_board'] = $query_part['query_see_board'];
6855
+	if (empty($ignoreboards)) {
6856
+			$query_part['query_wanna_see_board'] = $query_part['query_see_board'];
6857
+	}
6490 6858
 	// Ok I guess they don't want to see all the boards
6491
-	else
6492
-		$query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))';
6859
+	else {
6860
+			$query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))';
6861
+	}
6493 6862
 
6494 6863
 	return $query_part;
6495 6864
 }
@@ -6503,10 +6872,11 @@  discard block
 block discarded – undo
6503 6872
 {
6504 6873
 	$secure = false;
6505 6874
 
6506
-	if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
6507
-		$secure = true;
6508
-	elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
6509
-		$secure = true;
6875
+	if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
6876
+			$secure = true;
6877
+	} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
6878
+			$secure = true;
6879
+	}
6510 6880
 
6511 6881
 	return $secure;
6512 6882
 }
@@ -6523,11 +6893,12 @@  discard block
 block discarded – undo
6523 6893
 {
6524 6894
 	$url = iri_to_url($iri);
6525 6895
 
6526
-	if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false)
6527
-		return $iri;
6528
-	else
6529
-		return false;
6530
-}
6896
+	if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) {
6897
+			return $iri;
6898
+	} else {
6899
+			return false;
6900
+	}
6901
+	}
6531 6902
 
6532 6903
 /**
6533 6904
  * A wrapper for `filter_var($url, FILTER_SANITIZE_URL)` that can handle URLs
@@ -6570,8 +6941,9 @@  discard block
 block discarded – undo
6570 6941
 
6571 6942
 	$host = parse_url((strpos($iri, '://') === false ? 'http://' : '') . ltrim($iri, ':/'), PHP_URL_HOST);
6572 6943
 
6573
-	if (empty($host))
6574
-		return $iri;
6944
+	if (empty($host)) {
6945
+			return $iri;
6946
+	}
6575 6947
 
6576 6948
 	// Convert the domain using the Punycode algorithm
6577 6949
 	require_once($sourcedir . '/Class-Punycode.php');
@@ -6607,8 +6979,9 @@  discard block
 block discarded – undo
6607 6979
 
6608 6980
 	$host = parse_url((strpos($url, '://') === false ? 'http://' : '') . ltrim($url, ':/'), PHP_URL_HOST);
6609 6981
 
6610
-	if (empty($host))
6611
-		return $url;
6982
+	if (empty($host)) {
6983
+			return $url;
6984
+	}
6612 6985
 
6613 6986
 	// Decode the domain from Punycode
6614 6987
 	require_once($sourcedir . '/Class-Punycode.php');
@@ -6634,8 +7007,9 @@  discard block
 block discarded – undo
6634 7007
 {
6635 7008
 	global $user_info, $modSettings, $smcFunc, $txt;
6636 7009
 
6637
-	if (empty($modSettings['cron_last_checked']))
6638
-		$modSettings['cron_last_checked'] = 0;
7010
+	if (empty($modSettings['cron_last_checked'])) {
7011
+			$modSettings['cron_last_checked'] = 0;
7012
+	}
6639 7013
 
6640 7014
 	if (!empty($modSettings['cron_is_real_cron']) && time() - $modSettings['cron_last_checked'] > 84600)
6641 7015
 	{
@@ -6655,9 +7029,9 @@  discard block
 block discarded – undo
6655 7029
 			loadLanguage('ManageScheduledTasks');
6656 7030
 			log_error($txt['cron_not_working']);
6657 7031
 			updateSettings(array('cron_is_real_cron' => 0));
7032
+		} else {
7033
+					updateSettings(array('cron_last_checked' => time()));
6658 7034
 		}
6659
-		else
6660
-			updateSettings(array('cron_last_checked' => time()));
6661 7035
 	}
6662 7036
 }
6663 7037
 
Please login to merge, or discard this patch.
Themes/default/ManagePaid.template.php 1 patch
Braces   +63 added lines, -45 removed lines patch added patch discarded remove patch
@@ -21,9 +21,10 @@  discard block
 block discarded – undo
21 21
 	<div id="admincenter">
22 22
 		<form action="', $scripturl, '?action=admin;area=paidsubscribe;sa=modify;sid=', $context['sub_id'], '" method="post">';
23 23
 
24
-	if (!empty($context['disable_groups']))
25
-		echo '
24
+	if (!empty($context['disable_groups'])) {
25
+			echo '
26 26
 			<div class="noticebox">', $txt['paid_mod_edit_note'], '</div>';
27
+	}
27 28
 
28 29
 		echo '
29 30
 			<div class="cat_bar">
@@ -67,9 +68,10 @@  discard block
 block discarded – undo
67 68
 							<option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>';
68 69
 
69 70
 	// Put each group into the box.
70
-	foreach ($context['groups'] as $id => $name)
71
-		echo '
71
+	foreach ($context['groups'] as $id => $name) {
72
+			echo '
72 73
 							<option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>';
74
+	}
73 75
 
74 76
 	echo '
75 77
 						</select>
@@ -81,12 +83,13 @@  discard block
 block discarded – undo
81 83
 					<dd>';
82 84
 
83 85
 	// Put a checkbox in for each group
84
-	foreach ($context['groups'] as $id => $name)
85
-		echo '
86
+	foreach ($context['groups'] as $id => $name) {
87
+			echo '
86 88
 						<label for="addgroup_', $id, '">
87 89
 							<input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '>
88 90
 							<span class="smalltext">', $name, '</span>
89 91
 						</label><br>';
92
+	}
90 93
 
91 94
 	echo '
92 95
 					</dd>
@@ -236,8 +239,8 @@  discard block
 block discarded – undo
236 239
 				<dl class="settings">';
237 240
 
238 241
 	// Do we need a username?
239
-	if ($context['action_type'] == 'add')
240
-		echo '
242
+	if ($context['action_type'] == 'add') {
243
+			echo '
241 244
 					<dt>
242 245
 						<strong>', $txt['paid_username'], ':</strong><br>
243 246
 						<span class="smalltext">', $txt['one_username'], '</span>
@@ -245,6 +248,7 @@  discard block
 block discarded – undo
245 248
 					<dd>
246 249
 						<input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30">
247 250
 					</dd>';
251
+	}
248 252
 
249 253
 	echo '
250 254
 					<dt>
@@ -262,9 +266,10 @@  discard block
 block discarded – undo
262 266
 					<select name="year" id="year" onchange="generateDays();">';
263 267
 
264 268
 	// Show a list of all the years we allow...
265
-	for ($year = 2005; $year <= 2030; $year++)
266
-		echo '
269
+	for ($year = 2005; $year <= 2030; $year++) {
270
+			echo '
267 271
 						<option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>';
272
+	}
268 273
 
269 274
 	echo '
270 275
 					</select>&nbsp;
@@ -272,9 +277,10 @@  discard block
 block discarded – undo
272 277
 					<select name="month" id="month" onchange="generateDays();">';
273 278
 
274 279
 	// There are 12 months per year - ensure that they all get listed.
275
-	for ($month = 1; $month <= 12; $month++)
276
-		echo '
280
+	for ($month = 1; $month <= 12; $month++) {
281
+			echo '
277 282
 						<option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
283
+	}
278 284
 
279 285
 	echo '
280 286
 					</select>&nbsp;
@@ -282,9 +288,10 @@  discard block
 block discarded – undo
282 288
 					<select name="day" id="day">';
283 289
 
284 290
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
285
-	for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++)
286
-		echo '
291
+	for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) {
292
+			echo '
287 293
 						<option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>';
294
+	}
288 295
 
289 296
 	echo '
290 297
 					</select>
@@ -296,9 +303,10 @@  discard block
 block discarded – undo
296 303
 					<select name="yearend" id="yearend" onchange="generateDays(\'end\');">';
297 304
 
298 305
 	// Show a list of all the years we allow...
299
-	for ($year = 2005; $year <= 2030; $year++)
300
-		echo '
306
+	for ($year = 2005; $year <= 2030; $year++) {
307
+			echo '
301 308
 						<option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>';
309
+	}
302 310
 
303 311
 	echo '
304 312
 					</select>&nbsp;
@@ -306,9 +314,10 @@  discard block
 block discarded – undo
306 314
 					<select name="monthend" id="monthend" onchange="generateDays(\'end\');">';
307 315
 
308 316
 	// There are 12 months per year - ensure that they all get listed.
309
-	for ($month = 1; $month <= 12; $month++)
310
-		echo '
317
+	for ($month = 1; $month <= 12; $month++) {
318
+			echo '
311 319
 						<option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
320
+	}
312 321
 
313 322
 	echo '
314 323
 					</select>&nbsp;
@@ -316,9 +325,10 @@  discard block
 block discarded – undo
316 325
 					<select name="dayend" id="dayend">';
317 326
 
318 327
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
319
-	for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++)
320
-		echo '
328
+	for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) {
329
+			echo '
321 330
 						<option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>';
331
+	}
322 332
 
323 333
 	echo '
324 334
 					</select>
@@ -357,8 +367,8 @@  discard block
 block discarded – undo
357 367
 		<div class="windowbg">
358 368
 			<ul>';
359 369
 
360
-		foreach ($context['pending_payments'] as $id => $payment)
361
-			echo '
370
+		foreach ($context['pending_payments'] as $id => $payment) {
371
+					echo '
362 372
 				<li>
363 373
 					', $payment['desc'], '
364 374
 					<span class="floatleft">
@@ -368,6 +378,7 @@  discard block
 block discarded – undo
368 378
 						<a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a>
369 379
 					</span>
370 380
 				</li>';
381
+		}
371 382
 
372 383
 		echo '
373 384
 			</ul>
@@ -392,12 +403,12 @@  discard block
 block discarded – undo
392 403
 				<h3 class="catbg">', $txt['subscriptions'], '</h3>
393 404
 			</div>';
394 405
 
395
-	if (empty($context['subscriptions']))
396
-		echo '
406
+	if (empty($context['subscriptions'])) {
407
+			echo '
397 408
 			<div class="information">
398 409
 				', $txt['paid_subs_none'], '
399 410
 			</div>';
400
-	else
411
+	} else
401 412
 	{
402 413
 		echo '
403 414
 			<div class="information">
@@ -408,8 +419,9 @@  discard block
 block discarded – undo
408 419
 		foreach ($context['subscriptions'] as $id => $subscription)
409 420
 		{
410 421
 			// Ignore the inactive ones...
411
-			if (empty($subscription['active']))
412
-				continue;
422
+			if (empty($subscription['active'])) {
423
+							continue;
424
+			}
413 425
 
414 426
 			echo '
415 427
 			<div class="cat_bar">
@@ -419,9 +431,10 @@  discard block
 block discarded – undo
419 431
 				<p><strong>', $subscription['name'], '</strong></p>
420 432
 				<p class="smalltext">', $subscription['desc'], '</p>';
421 433
 
422
-			if (!$subscription['flexible'])
423
-				echo '
434
+			if (!$subscription['flexible']) {
435
+							echo '
424 436
 				<div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>';
437
+			}
425 438
 
426 439
 			if ($context['user']['is_owner'])
427 440
 			{
@@ -434,24 +447,25 @@  discard block
 block discarded – undo
434 447
 				<select name="cur[', $subscription['id'], ']">';
435 448
 
436 449
 					// Print out the costs for this one.
437
-					foreach ($subscription['costs'] as $duration => $value)
438
-						echo '
450
+					foreach ($subscription['costs'] as $duration => $value) {
451
+											echo '
439 452
 					<option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>';
453
+					}
440 454
 
441 455
 					echo '
442 456
 				</select>';
443
-				}
444
-				else
445
-					echo '
457
+				} else {
458
+									echo '
446 459
 				', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']);
460
+				}
447 461
 
448 462
 				echo '
449 463
 				<hr>
450 464
 				<input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">';
451
-			}
452
-			else
453
-				echo '
465
+			} else {
466
+							echo '
454 467
 				<a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>';
468
+			}
455 469
 
456 470
 			echo '
457 471
 			</div><!-- .windowbg -->';
@@ -478,18 +492,19 @@  discard block
 block discarded – undo
478 492
 			</thead>
479 493
 			<tbody>';
480 494
 
481
-	if (empty($context['current']))
482
-		echo '
495
+	if (empty($context['current'])) {
496
+			echo '
483 497
 				<tr class="windowbg">
484 498
 					<td colspan="4">
485 499
 						', $txt['paid_none_yet'], '
486 500
 					</td>
487 501
 				</tr>';
502
+	}
488 503
 
489 504
 	foreach ($context['current'] as $sub)
490 505
 	{
491
-		if (!$sub['hide'])
492
-			echo '
506
+		if (!$sub['hide']) {
507
+					echo '
493 508
 				<tr class="windowbg">
494 509
 					<td>
495 510
 						', ($context['user']['is_admin'] ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), '
@@ -500,6 +515,7 @@  discard block
 block discarded – undo
500 515
 					<td>', $sub['start'], '</td>
501 516
 					<td>', $sub['end'], '</td>
502 517
 				</tr>';
518
+		}
503 519
 	}
504 520
 
505 521
 	echo '
@@ -551,15 +567,17 @@  discard block
 block discarded – undo
551 567
 			', $gateway['desc'], '<br>
552 568
 			<form action="', $gateway['form'], '" method="post">';
553 569
 
554
-		if (!empty($gateway['javascript']))
555
-			echo '
570
+		if (!empty($gateway['javascript'])) {
571
+					echo '
556 572
 				<script>
557 573
 					', $gateway['javascript'], '
558 574
 				</script>';
575
+		}
559 576
 
560
-		foreach ($gateway['hidden'] as $name => $value)
561
-			echo '
577
+		foreach ($gateway['hidden'] as $name => $value) {
578
+					echo '
562 579
 				<input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">';
580
+		}
563 581
 
564 582
 		echo '
565 583
 				<br>
Please login to merge, or discard this patch.
other/upgrade.php 1 patch
Braces   +911 added lines, -667 removed lines patch added patch discarded remove patch
@@ -75,8 +75,9 @@  discard block
 block discarded – undo
75 75
 $upcontext['inactive_timeout'] = 10;
76 76
 
77 77
 // The helper is crucial. Include it first thing.
78
-if (!file_exists($upgrade_path . '/upgrade-helper.php'))
78
+if (!file_exists($upgrade_path . '/upgrade-helper.php')) {
79 79
 	die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
80
+}
80 81
 
81 82
 require_once($upgrade_path . '/upgrade-helper.php');
82 83
 
@@ -107,11 +108,14 @@  discard block
 block discarded – undo
107 108
 	ini_set('default_socket_timeout', 900);
108 109
 }
109 110
 // Clean the upgrade path if this is from the client.
110
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
111
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
111
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
112
+	for ($i = 1;
113
+}
114
+$i < $_SERVER['argc']; $i++)
112 115
 	{
113
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
114
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
116
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
117
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
118
+		}
115 119
 	}
116 120
 
117 121
 // Are we from the client?
@@ -119,16 +123,17 @@  discard block
 block discarded – undo
119 123
 {
120 124
 	$command_line = true;
121 125
 	$disable_security = true;
122
-}
123
-else
126
+} else {
124 127
 	$command_line = false;
128
+}
125 129
 
126 130
 // Load this now just because we can.
127 131
 require_once($upgrade_path . '/Settings.php');
128 132
 
129 133
 // We don't use "-utf8" anymore...  Tweak the entry that may have been loaded by Settings.php
130
-if (isset($language))
134
+if (isset($language)) {
131 135
 	$language = str_ireplace('-utf8', '', $language);
136
+}
132 137
 
133 138
 // Are we logged in?
134 139
 if (isset($upgradeData))
@@ -136,10 +141,12 @@  discard block
 block discarded – undo
136 141
 	$upcontext['user'] = json_decode(base64_decode($upgradeData), true);
137 142
 
138 143
 	// Check for sensible values.
139
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
140
-		$upcontext['user']['started'] = time();
141
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
142
-		$upcontext['user']['updated'] = 0;
144
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
145
+			$upcontext['user']['started'] = time();
146
+	}
147
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
148
+			$upcontext['user']['updated'] = 0;
149
+	}
143 150
 
144 151
 	$upcontext['started'] = $upcontext['user']['started'];
145 152
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -204,8 +211,9 @@  discard block
 block discarded – undo
204 211
 			'db_error_skip' => true,
205 212
 		)
206 213
 	);
207
-	while ($row = $smcFunc['db_fetch_assoc']($request))
208
-		$modSettings[$row['variable']] = $row['value'];
214
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
215
+			$modSettings[$row['variable']] = $row['value'];
216
+	}
209 217
 	$smcFunc['db_free_result']($request);
210 218
 }
211 219
 
@@ -215,14 +223,17 @@  discard block
 block discarded – undo
215 223
 	$modSettings['theme_url'] = 'Themes/default';
216 224
 	$modSettings['images_url'] = 'Themes/default/images';
217 225
 }
218
-if (!isset($settings['default_theme_url']))
226
+if (!isset($settings['default_theme_url'])) {
219 227
 	$settings['default_theme_url'] = $modSettings['theme_url'];
220
-if (!isset($settings['default_theme_dir']))
228
+}
229
+if (!isset($settings['default_theme_dir'])) {
221 230
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
231
+}
222 232
 
223 233
 // This is needed in case someone invokes the upgrader using https when upgrading an http forum
224
-if (httpsOn())
234
+if (httpsOn()) {
225 235
 	$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
236
+}
226 237
 
227 238
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
228 239
 // Default title...
@@ -240,13 +251,15 @@  discard block
 block discarded – undo
240 251
 	$support_js = $upcontext['upgrade_status']['js'];
241 252
 
242 253
 	// Only set this if the upgrader status says so.
243
-	if (empty($is_debug))
244
-		$is_debug = $upcontext['upgrade_status']['debug'];
254
+	if (empty($is_debug)) {
255
+			$is_debug = $upcontext['upgrade_status']['debug'];
256
+	}
245 257
 
246 258
 	// Load the language.
247
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
248
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
249
-}
259
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
260
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
261
+	}
262
+	}
250 263
 // Set the defaults.
251 264
 else
252 265
 {
@@ -264,15 +277,18 @@  discard block
 block discarded – undo
264 277
 }
265 278
 
266 279
 // If this isn't the first stage see whether they are logging in and resuming.
267
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
280
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
268 281
 	checkLogin();
282
+}
269 283
 
270
-if ($command_line)
284
+if ($command_line) {
271 285
 	cmdStep0();
286
+}
272 287
 
273 288
 // Don't error if we're using xml.
274
-if (isset($_GET['xml']))
289
+if (isset($_GET['xml'])) {
275 290
 	$upcontext['return_error'] = true;
291
+}
276 292
 
277 293
 // Loop through all the steps doing each one as required.
278 294
 $upcontext['overall_percent'] = 0;
@@ -293,9 +309,9 @@  discard block
 block discarded – undo
293 309
 		}
294 310
 
295 311
 		// Call the step and if it returns false that means pause!
296
-		if (function_exists($step[2]) && $step[2]() === false)
297
-			break;
298
-		elseif (function_exists($step[2])) {
312
+		if (function_exists($step[2]) && $step[2]() === false) {
313
+					break;
314
+		} elseif (function_exists($step[2])) {
299 315
 			//Start each new step with this unset, so the 'normal' template is called first
300 316
 			unset($_GET['xml']);
301 317
 			//Clear out warnings at the start of each step
@@ -341,17 +357,18 @@  discard block
 block discarded – undo
341 357
 		// This should not happen my dear... HELP ME DEVELOPERS!!
342 358
 		if (!empty($command_line))
343 359
 		{
344
-			if (function_exists('debug_print_backtrace'))
345
-				debug_print_backtrace();
360
+			if (function_exists('debug_print_backtrace')) {
361
+							debug_print_backtrace();
362
+			}
346 363
 
347 364
 			echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.';
348 365
 			flush();
349 366
 			die();
350 367
 		}
351 368
 
352
-		if (!isset($_GET['xml']))
353
-			template_upgrade_above();
354
-		else
369
+		if (!isset($_GET['xml'])) {
370
+					template_upgrade_above();
371
+		} else
355 372
 		{
356 373
 			header('content-type: text/xml; charset=UTF-8');
357 374
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -373,25 +390,29 @@  discard block
 block discarded – undo
373 390
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(json_encode($upcontext['upgrade_status']));
374 391
 
375 392
 			// Custom stuff to pass back?
376
-			if (!empty($upcontext['query_string']))
377
-				$upcontext['form_url'] .= $upcontext['query_string'];
393
+			if (!empty($upcontext['query_string'])) {
394
+							$upcontext['form_url'] .= $upcontext['query_string'];
395
+			}
378 396
 
379 397
 			// Call the appropriate subtemplate
380
-			if (is_callable('template_' . $upcontext['sub_template']))
381
-				call_user_func('template_' . $upcontext['sub_template']);
382
-			else
383
-				die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
398
+			if (is_callable('template_' . $upcontext['sub_template'])) {
399
+							call_user_func('template_' . $upcontext['sub_template']);
400
+			} else {
401
+							die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
402
+			}
384 403
 		}
385 404
 
386 405
 		// Was there an error?
387
-		if (!empty($upcontext['forced_error_message']))
388
-			echo $upcontext['forced_error_message'];
406
+		if (!empty($upcontext['forced_error_message'])) {
407
+					echo $upcontext['forced_error_message'];
408
+		}
389 409
 
390 410
 		// Show the footer.
391
-		if (!isset($_GET['xml']))
392
-			template_upgrade_below();
393
-		else
394
-			template_xml_below();
411
+		if (!isset($_GET['xml'])) {
412
+					template_upgrade_below();
413
+		} else {
414
+					template_xml_below();
415
+		}
395 416
 	}
396 417
 
397 418
 
@@ -403,15 +424,19 @@  discard block
 block discarded – undo
403 424
 		$seconds = intval($active % 60);
404 425
 
405 426
 		$totalTime = '';
406
-		if ($hours > 0)
407
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
408
-		if ($minutes > 0)
409
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
410
-		if ($seconds > 0)
411
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
427
+		if ($hours > 0) {
428
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
429
+		}
430
+		if ($minutes > 0) {
431
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
432
+		}
433
+		if ($seconds > 0) {
434
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
435
+		}
412 436
 
413
-		if (!empty($totalTime))
414
-			echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n";
437
+		if (!empty($totalTime)) {
438
+					echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n";
439
+		}
415 440
 	}
416 441
 
417 442
 	// Bang - gone!
@@ -432,8 +457,9 @@  discard block
 block discarded – undo
432 457
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
433 458
 		while ($entry = $dir->read())
434 459
 		{
435
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
436
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
460
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
461
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
462
+			}
437 463
 		}
438 464
 		$dir->close();
439 465
 	}
@@ -477,10 +503,11 @@  discard block
 block discarded – undo
477 503
 	}
478 504
 
479 505
 	// Override the language file?
480
-	if (isset($_GET['lang_file']))
481
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
482
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
483
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
506
+	if (isset($_GET['lang_file'])) {
507
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
508
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
509
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
510
+	}
484 511
 
485 512
 	// Make sure it exists, if it doesn't reset it.
486 513
 	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']))
@@ -489,12 +516,14 @@  discard block
 block discarded – undo
489 516
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
490 517
 
491 518
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
492
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
493
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
519
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
520
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
521
+		}
494 522
 
495 523
 		// For backup we load the english at first -> second language overwrite the english one
496
-		if (count($incontext['detected_languages']) > 1)
497
-			require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php');
524
+		if (count($incontext['detected_languages']) > 1) {
525
+					require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php');
526
+		}
498 527
 	}
499 528
 
500 529
 	// And now include the actual language file itself.
@@ -502,11 +531,12 @@  discard block
 block discarded – undo
502 531
 
503 532
 	// Which language did we load? Assume that he likes his language.
504 533
 	preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches);
505
-	if (empty($matches[1]))
506
-		$matches = [
534
+	if (empty($matches[1])) {
535
+			$matches = [
507 536
 			0 => 'nothing',
508 537
 			1 => 'english',
509 538
 		];
539
+	}
510 540
 	$user_info['language'] = $matches[1];
511 541
 }
512 542
 
@@ -516,8 +546,9 @@  discard block
 block discarded – undo
516 546
 	global $upgradeurl, $upcontext, $command_line;
517 547
 
518 548
 	// Command line users can't be redirected.
519
-	if ($command_line)
520
-		upgradeExit(true);
549
+	if ($command_line) {
550
+			upgradeExit(true);
551
+	}
521 552
 
522 553
 	// Are we providing the core info?
523 554
 	if ($addForm)
@@ -543,12 +574,14 @@  discard block
 block discarded – undo
543 574
 	define('SMF', 1);
544 575
 
545 576
 	// Start the session.
546
-	if (@ini_get('session.save_handler') == 'user')
547
-		@ini_set('session.save_handler', 'files');
577
+	if (@ini_get('session.save_handler') == 'user') {
578
+			@ini_set('session.save_handler', 'files');
579
+	}
548 580
 	@session_start();
549 581
 
550
-	if (empty($smcFunc))
551
-		$smcFunc = array();
582
+	if (empty($smcFunc)) {
583
+			$smcFunc = array();
584
+	}
552 585
 
553 586
 	// We need this for authentication and some upgrade code
554 587
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -579,30 +612,34 @@  discard block
 block discarded – undo
579 612
 		{
580 613
 			$options = array('non_fatal' => true);
581 614
 			// Add in the port if needed
582
-			if (!empty($db_port))
583
-				$options['port'] = $db_port;
615
+			if (!empty($db_port)) {
616
+							$options['port'] = $db_port;
617
+			}
584 618
 			
585
-			if (!empty($db_mb4))
586
-				$options['db_mb4'] = $db_mb4;
619
+			if (!empty($db_mb4)) {
620
+							$options['db_mb4'] = $db_mb4;
621
+			}
587 622
 			
588 623
 			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options);
589
-		}
590
-		else
591
-			// If we've returned here, ping/reconnect to be safe
624
+		} else {
625
+					// If we've returned here, ping/reconnect to be safe
592 626
 			$smcFunc['db_ping']($db_connection);
627
+		}
593 628
 
594 629
 		// Oh dear god!!
595
-		if ($db_connection === null)
596
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
630
+		if ($db_connection === null) {
631
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
632
+		}
597 633
 
598
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
599
-			$smcFunc['db_query']('', '
634
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
635
+					$smcFunc['db_query']('', '
600 636
 			SET NAMES {string:db_character_set}',
601 637
 			array(
602 638
 				'db_error_skip' => true,
603 639
 				'db_character_set' => $db_character_set,
604 640
 			)
605 641
 		);
642
+		}
606 643
 
607 644
 		// Load the modSettings data...
608 645
 		$request = $smcFunc['db_query']('', '
@@ -613,11 +650,11 @@  discard block
 block discarded – undo
613 650
 			)
614 651
 		);
615 652
 		$modSettings = array();
616
-		while ($row = $smcFunc['db_fetch_assoc']($request))
617
-			$modSettings[$row['variable']] = $row['value'];
653
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
654
+					$modSettings[$row['variable']] = $row['value'];
655
+		}
618 656
 		$smcFunc['db_free_result']($request);
619
-	}
620
-	else
657
+	} else
621 658
 	{
622 659
 		return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.');
623 660
 	}
@@ -631,9 +668,10 @@  discard block
 block discarded – undo
631 668
 		cleanRequest();
632 669
 	}
633 670
 
634
-	if (!isset($_GET['substep']))
635
-		$_GET['substep'] = 0;
636
-}
671
+	if (!isset($_GET['substep'])) {
672
+			$_GET['substep'] = 0;
673
+	}
674
+	}
637 675
 
638 676
 function initialize_inputs()
639 677
 {
@@ -663,8 +701,9 @@  discard block
 block discarded – undo
663 701
 		$dh = opendir(dirname(__FILE__));
664 702
 		while ($file = readdir($dh))
665 703
 		{
666
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
667
-				@unlink(dirname(__FILE__) . '/' . $file);
704
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
705
+							@unlink(dirname(__FILE__) . '/' . $file);
706
+			}
668 707
 		}
669 708
 		closedir($dh);
670 709
 
@@ -693,8 +732,9 @@  discard block
 block discarded – undo
693 732
 	$temp = 'upgrade_php?step';
694 733
 	while (strlen($temp) > 4)
695 734
 	{
696
-		if (isset($_GET[$temp]))
697
-			unset($_GET[$temp]);
735
+		if (isset($_GET[$temp])) {
736
+					unset($_GET[$temp]);
737
+		}
698 738
 		$temp = substr($temp, 1);
699 739
 	}
700 740
 
@@ -721,32 +761,39 @@  discard block
 block discarded – undo
721 761
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
722 762
 
723 763
 	// Need legacy scripts?
724
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
725
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
726
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
727
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
728
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
729
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
764
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
765
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
766
+	}
767
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
768
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
769
+	}
770
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
771
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
772
+	}
730 773
 
731 774
 	// We don't need "-utf8" files anymore...
732 775
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
733 776
 
734 777
 	// This needs to exist!
735
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
736
-		return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
737
-	else
738
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
778
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
779
+			return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
780
+	} else {
781
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
782
+	}
739 783
 
740
-	if (!$check)
741
-		// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
784
+	if (!$check) {
785
+			// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
742 786
 		return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.');
787
+	}
743 788
 
744 789
 	// Do they meet the install requirements?
745
-	if (!php_version_check())
746
-		return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.');
790
+	if (!php_version_check()) {
791
+			return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.');
792
+	}
747 793
 
748
-	if (!db_version_check())
749
-		return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
794
+	if (!db_version_check()) {
795
+			return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
796
+	}
750 797
 
751 798
 	// Do some checks to make sure they have proper privileges
752 799
 	db_extend('packages');
@@ -761,14 +808,16 @@  discard block
 block discarded – undo
761 808
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
762 809
 
763 810
 	// Sorry... we need CREATE, ALTER and DROP
764
-	if (!$create || !$alter || !$drop)
765
-		return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
811
+	if (!$create || !$alter || !$drop) {
812
+			return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
813
+	}
766 814
 
767 815
 	// Do a quick version spot check.
768 816
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
769 817
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
770
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
771
-		return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.');
818
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
819
+			return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.');
820
+	}
772 821
 
773 822
 	// What absolutely needs to be writable?
774 823
 	$writable_files = array(
@@ -777,12 +826,13 @@  discard block
 block discarded – undo
777 826
 	);
778 827
 
779 828
 	// Only check for minified writable files if we have it enabled or not set.
780
-	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files']))
781
-		$writable_files += array(
829
+	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) {
830
+			$writable_files += array(
782 831
 			$modSettings['theme_dir'] . '/css/minified.css',
783 832
 			$modSettings['theme_dir'] . '/scripts/minified.js',
784 833
 			$modSettings['theme_dir'] . '/scripts/minified_deferred.js',
785 834
 		);
835
+	}
786 836
 
787 837
 	// Do we need to add this setting?
788 838
 	$need_settings_update = empty($modSettings['custom_avatar_dir']);
@@ -794,12 +844,13 @@  discard block
 block discarded – undo
794 844
 	quickFileWritable($custom_av_dir);
795 845
 
796 846
 	// Are we good now?
797
-	if (!is_writable($custom_av_dir))
798
-		return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
799
-	elseif ($need_settings_update)
847
+	if (!is_writable($custom_av_dir)) {
848
+			return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
849
+	} elseif ($need_settings_update)
800 850
 	{
801
-		if (!function_exists('cache_put_data'))
802
-			require_once($sourcedir . '/Load.php');
851
+		if (!function_exists('cache_put_data')) {
852
+					require_once($sourcedir . '/Load.php');
853
+		}
803 854
 
804 855
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
805 856
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
@@ -809,29 +860,34 @@  discard block
 block discarded – undo
809 860
 
810 861
 	// Check the cache directory.
811 862
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
812
-	if (!file_exists($cachedir_temp))
813
-		@mkdir($cachedir_temp);
863
+	if (!file_exists($cachedir_temp)) {
864
+			@mkdir($cachedir_temp);
865
+	}
814 866
 
815
-	if (!file_exists($cachedir_temp))
816
-		return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
867
+	if (!file_exists($cachedir_temp)) {
868
+			return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
869
+	}
817 870
 
818
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
819
-		return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
820
-	elseif (!isset($_GET['skiplang']))
871
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
872
+			return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
873
+	} elseif (!isset($_GET['skiplang']))
821 874
 	{
822 875
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
823 876
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
824 877
 
825
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
826
-			return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
878
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
879
+					return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
880
+		}
827 881
 	}
828 882
 
829
-	if (!makeFilesWritable($writable_files))
830
-		return false;
883
+	if (!makeFilesWritable($writable_files)) {
884
+			return false;
885
+	}
831 886
 
832 887
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
833
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
834
-		return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
888
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
889
+			return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
890
+	}
835 891
 
836 892
 	// Upgrade the agreement.
837 893
 	elseif (isset($modSettings['agreement']))
@@ -842,8 +898,8 @@  discard block
 block discarded – undo
842 898
 	}
843 899
 
844 900
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
845
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
846
-		$upcontext['warning'] = '
901
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
902
+			$upcontext['warning'] = '
847 903
 			'. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br>
848 904
 			<ul>
849 905
 				<li>'. $txt['upgrade_boarddir'] .'  ' . $boarddir . '</li>
@@ -851,19 +907,23 @@  discard block
 block discarded – undo
851 907
 				<li>'. $txt['upgrade_cachedir'] .'  ' . $cachedir_temp . '</li>
852 908
 			</ul>
853 909
 			'. $txt['upgrade_incorrect_settings'] .'';
910
+	}
854 911
 
855 912
 	// Confirm mbstring is loaded...
856
-	if (!extension_loaded('mbstring'))
857
-		return throw_error($txt['install_no_mbstring']);
913
+	if (!extension_loaded('mbstring')) {
914
+			return throw_error($txt['install_no_mbstring']);
915
+	}
858 916
 
859 917
 	// Check for https stream support.
860 918
 	$supported_streams = stream_get_wrappers();
861
-	if (!in_array('https', $supported_streams))
862
-		$upcontext['custom_warning'] = $txt['install_no_https'];
919
+	if (!in_array('https', $supported_streams)) {
920
+			$upcontext['custom_warning'] = $txt['install_no_https'];
921
+	}
863 922
 
864 923
 	// Either we're logged in or we're going to present the login.
865
-	if (checkLogin())
866
-		return true;
924
+	if (checkLogin()) {
925
+			return true;
926
+	}
867 927
 
868 928
 	$upcontext += createToken('login');
869 929
 
@@ -877,15 +937,17 @@  discard block
 block discarded – undo
877 937
 	global $smcFunc, $db_type, $support_js;
878 938
 
879 939
 	// Don't bother if the security is disabled.
880
-	if ($disable_security)
881
-		return true;
940
+	if ($disable_security) {
941
+			return true;
942
+	}
882 943
 
883 944
 	// Are we trying to login?
884 945
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
885 946
 	{
886 947
 		// If we've disabled security pick a suitable name!
887
-		if (empty($_POST['user']))
888
-			$_POST['user'] = 'Administrator';
948
+		if (empty($_POST['user'])) {
949
+					$_POST['user'] = 'Administrator';
950
+		}
889 951
 
890 952
 		// Before 2.0 these column names were different!
891 953
 		$oldDB = false;
@@ -900,16 +962,17 @@  discard block
 block discarded – undo
900 962
 					'db_error_skip' => true,
901 963
 				)
902 964
 			);
903
-			if ($smcFunc['db_num_rows']($request) != 0)
904
-				$oldDB = true;
965
+			if ($smcFunc['db_num_rows']($request) != 0) {
966
+							$oldDB = true;
967
+			}
905 968
 			$smcFunc['db_free_result']($request);
906 969
 		}
907 970
 
908 971
 		// Get what we believe to be their details.
909 972
 		if (!$disable_security)
910 973
 		{
911
-			if ($oldDB)
912
-				$request = $smcFunc['db_query']('', '
974
+			if ($oldDB) {
975
+							$request = $smcFunc['db_query']('', '
913 976
 					SELECT id_member, memberName AS member_name, passwd, id_group,
914 977
 					additionalGroups AS additional_groups, lngfile
915 978
 					FROM {db_prefix}members
@@ -919,8 +982,8 @@  discard block
 block discarded – undo
919 982
 						'db_error_skip' => true,
920 983
 					)
921 984
 				);
922
-			else
923
-				$request = $smcFunc['db_query']('', '
985
+			} else {
986
+							$request = $smcFunc['db_query']('', '
924 987
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
925 988
 					FROM {db_prefix}members
926 989
 					WHERE member_name = {string:member_name}',
@@ -929,6 +992,7 @@  discard block
 block discarded – undo
929 992
 						'db_error_skip' => true,
930 993
 					)
931 994
 				);
995
+			}
932 996
 			if ($smcFunc['db_num_rows']($request) != 0)
933 997
 			{
934 998
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -936,16 +1000,17 @@  discard block
 block discarded – undo
936 1000
 				$groups = explode(',', $addGroups);
937 1001
 				$groups[] = $id_group;
938 1002
 
939
-				foreach ($groups as $k => $v)
940
-					$groups[$k] = (int) $v;
1003
+				foreach ($groups as $k => $v) {
1004
+									$groups[$k] = (int) $v;
1005
+				}
941 1006
 
942 1007
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
943 1008
 
944 1009
 				// We don't use "-utf8" anymore...
945 1010
 				$user_language = str_ireplace('-utf8', '', $user_language);
1011
+			} else {
1012
+							$upcontext['username_incorrect'] = true;
946 1013
 			}
947
-			else
948
-				$upcontext['username_incorrect'] = true;
949 1014
 
950 1015
 			$smcFunc['db_free_result']($request);
951 1016
 		}
@@ -956,13 +1021,14 @@  discard block
 block discarded – undo
956 1021
 		{
957 1022
 			$upcontext['upgrade_status']['js'] = 1;
958 1023
 			$support_js = 1;
1024
+		} else {
1025
+					$support_js = 0;
959 1026
 		}
960
-		else
961
-			$support_js = 0;
962 1027
 
963 1028
 		// Note down the version we are coming from.
964
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
965
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
1029
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
1030
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
1031
+		}
966 1032
 
967 1033
 		// Didn't get anywhere?
968 1034
 		if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect']))
@@ -996,15 +1062,15 @@  discard block
 block discarded – undo
996 1062
 							'db_error_skip' => true,
997 1063
 						)
998 1064
 					);
999
-					if ($smcFunc['db_num_rows']($request) == 0)
1000
-						return throw_error('You need to be an admin to perform an upgrade!');
1065
+					if ($smcFunc['db_num_rows']($request) == 0) {
1066
+											return throw_error('You need to be an admin to perform an upgrade!');
1067
+					}
1001 1068
 					$smcFunc['db_free_result']($request);
1002 1069
 				}
1003 1070
 
1004 1071
 				$upcontext['user']['id'] = $id_member;
1005 1072
 				$upcontext['user']['name'] = $name;
1006
-			}
1007
-			else
1073
+			} else
1008 1074
 			{
1009 1075
 				$upcontext['user']['id'] = 1;
1010 1076
 				$upcontext['user']['name'] = 'Administrator';
@@ -1020,11 +1086,11 @@  discard block
 block discarded – undo
1020 1086
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
1021 1087
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
1022 1088
 
1023
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
1024
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
1025
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
1026
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
1027
-				else
1089
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
1090
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
1091
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
1092
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
1093
+				} else
1028 1094
 				{
1029 1095
 					// Set this as the new language.
1030 1096
 					$upcontext['language'] = $user_language;
@@ -1068,8 +1134,9 @@  discard block
 block discarded – undo
1068 1134
 	unset($member_columns);
1069 1135
 
1070 1136
 	// If we've not submitted then we're done.
1071
-	if (empty($_POST['upcont']))
1072
-		return false;
1137
+	if (empty($_POST['upcont'])) {
1138
+			return false;
1139
+	}
1073 1140
 
1074 1141
 	// Firstly, if they're enabling SM stat collection just do it.
1075 1142
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
@@ -1089,16 +1156,17 @@  discard block
 block discarded – undo
1089 1156
 				fwrite($fp, $out);
1090 1157
 
1091 1158
 				$return_data = '';
1092
-				while (!feof($fp))
1093
-					$return_data .= fgets($fp, 128);
1159
+				while (!feof($fp)) {
1160
+									$return_data .= fgets($fp, 128);
1161
+				}
1094 1162
 
1095 1163
 				fclose($fp);
1096 1164
 
1097 1165
 				// Get the unique site ID.
1098 1166
 				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1099 1167
 
1100
-				if (!empty($ID[1]))
1101
-					$smcFunc['db_insert']('replace',
1168
+				if (!empty($ID[1])) {
1169
+									$smcFunc['db_insert']('replace',
1102 1170
 						$db_prefix . 'settings',
1103 1171
 						array('variable' => 'string', 'value' => 'string'),
1104 1172
 						array(
@@ -1107,9 +1175,9 @@  discard block
 block discarded – undo
1107 1175
 						),
1108 1176
 						array('variable')
1109 1177
 					);
1178
+				}
1110 1179
 			}
1111
-		}
1112
-		else
1180
+		} else
1113 1181
 		{
1114 1182
 			$smcFunc['db_insert']('replace',
1115 1183
 				$db_prefix . 'settings',
@@ -1120,8 +1188,8 @@  discard block
 block discarded – undo
1120 1188
 		}
1121 1189
 	}
1122 1190
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1123
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1124
-		$smcFunc['db_query']('', '
1191
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1192
+			$smcFunc['db_query']('', '
1125 1193
 			DELETE FROM {db_prefix}settings
1126 1194
 			WHERE variable = {string:enable_sm_stats}',
1127 1195
 			array(
@@ -1129,6 +1197,7 @@  discard block
 block discarded – undo
1129 1197
 				'db_error_skip' => true,
1130 1198
 			)
1131 1199
 		);
1200
+	}
1132 1201
 
1133 1202
 	// Deleting old karma stuff?
1134 1203
 	if (!empty($_POST['delete_karma']))
@@ -1143,20 +1212,22 @@  discard block
 block discarded – undo
1143 1212
 		);
1144 1213
 
1145 1214
 		// Cleaning up old karma member settings.
1146
-		if ($upcontext['karma_installed']['good'])
1147
-			$smcFunc['db_query']('', '
1215
+		if ($upcontext['karma_installed']['good']) {
1216
+					$smcFunc['db_query']('', '
1148 1217
 				ALTER TABLE {db_prefix}members
1149 1218
 				DROP karma_good',
1150 1219
 				array()
1151 1220
 			);
1221
+		}
1152 1222
 
1153 1223
 		// Does karma bad was enable?
1154
-		if ($upcontext['karma_installed']['bad'])
1155
-			$smcFunc['db_query']('', '
1224
+		if ($upcontext['karma_installed']['bad']) {
1225
+					$smcFunc['db_query']('', '
1156 1226
 				ALTER TABLE {db_prefix}members
1157 1227
 				DROP karma_bad',
1158 1228
 				array()
1159 1229
 			);
1230
+		}
1160 1231
 
1161 1232
 		// Cleaning up old karma permissions.
1162 1233
 		$smcFunc['db_query']('', '
@@ -1174,32 +1245,37 @@  discard block
 block discarded – undo
1174 1245
 	}
1175 1246
 
1176 1247
 	// Emptying the error log?
1177
-	if (!empty($_POST['empty_error']))
1178
-		$smcFunc['db_query']('truncate_table', '
1248
+	if (!empty($_POST['empty_error'])) {
1249
+			$smcFunc['db_query']('truncate_table', '
1179 1250
 			TRUNCATE {db_prefix}log_errors',
1180 1251
 			array(
1181 1252
 			)
1182 1253
 		);
1254
+	}
1183 1255
 
1184 1256
 	$changes = array();
1185 1257
 
1186 1258
 	// Add proxy settings.
1187
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1188
-		$changes += array(
1259
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1260
+			$changes += array(
1189 1261
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1190 1262
 			'image_proxy_maxsize' => 5190,
1191 1263
 			'image_proxy_enabled' => 0,
1192 1264
 		);
1265
+	}
1193 1266
 
1194 1267
 	// If $boardurl reflects https, set force_ssl
1195
-	if (!function_exists('cache_put_data'))
1196
-		require_once($sourcedir . '/Load.php');
1197
-	if (stripos($boardurl, 'https://') !== false)
1198
-		updateSettings(array('force_ssl' => '1'));
1268
+	if (!function_exists('cache_put_data')) {
1269
+			require_once($sourcedir . '/Load.php');
1270
+	}
1271
+	if (stripos($boardurl, 'https://') !== false) {
1272
+			updateSettings(array('force_ssl' => '1'));
1273
+	}
1199 1274
 
1200 1275
 	// If we're overriding the language follow it through.
1201
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1202
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1276
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1277
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1278
+	}
1203 1279
 
1204 1280
 	if (!empty($_POST['maint']))
1205 1281
 	{
@@ -1211,26 +1287,29 @@  discard block
 block discarded – undo
1211 1287
 		{
1212 1288
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1213 1289
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1214
-		}
1215
-		else
1290
+		} else
1216 1291
 		{
1217 1292
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1218 1293
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1219 1294
 		}
1220 1295
 	}
1221 1296
 
1222
-	if ($command_line)
1223
-		echo ' * Updating Settings.php...';
1297
+	if ($command_line) {
1298
+			echo ' * Updating Settings.php...';
1299
+	}
1224 1300
 
1225 1301
 	// Fix some old paths.
1226
-	if (substr($boarddir, 0, 1) == '.')
1227
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1302
+	if (substr($boarddir, 0, 1) == '.') {
1303
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1304
+	}
1228 1305
 
1229
-	if (substr($sourcedir, 0, 1) == '.')
1230
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1306
+	if (substr($sourcedir, 0, 1) == '.') {
1307
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1308
+	}
1231 1309
 
1232
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1233
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1310
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1311
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1312
+	}
1234 1313
 
1235 1314
 	// If they have a "host:port" setup for the host, split that into separate values
1236 1315
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1241,32 +1320,36 @@  discard block
 block discarded – undo
1241 1320
 		$changes['db_server'] = '\'' . $db_server . '\'';
1242 1321
 
1243 1322
 		// Only set this if we're not using the default port
1244
-		if ($db_port != ini_get('mysqli.default_port'))
1245
-			$changes['db_port'] = (int) $db_port;
1246
-	}
1247
-	elseif (!empty($db_port))
1323
+		if ($db_port != ini_get('mysqli.default_port')) {
1324
+					$changes['db_port'] = (int) $db_port;
1325
+		}
1326
+	} elseif (!empty($db_port))
1248 1327
 	{
1249 1328
 		// If db_port is set and is the same as the default, set it to ''
1250 1329
 		if ($db_type == 'mysql')
1251 1330
 		{
1252
-			if ($db_port == ini_get('mysqli.default_port'))
1253
-				$changes['db_port'] = '\'\'';
1254
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1255
-				$changes['db_port'] = '\'\'';
1331
+			if ($db_port == ini_get('mysqli.default_port')) {
1332
+							$changes['db_port'] = '\'\'';
1333
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1334
+							$changes['db_port'] = '\'\'';
1335
+			}
1256 1336
 		}
1257 1337
 	}
1258 1338
 
1259 1339
 	// Maybe we haven't had this option yet?
1260
-	if (empty($packagesdir))
1261
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1340
+	if (empty($packagesdir)) {
1341
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1342
+	}
1262 1343
 
1263 1344
 	// Add support for $tasksdir var.
1264
-	if (empty($tasksdir))
1265
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1345
+	if (empty($tasksdir)) {
1346
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1347
+	}
1266 1348
 
1267 1349
 	// Make sure we fix the language as well.
1268
-	if (stristr($language, '-utf8'))
1269
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1350
+	if (stristr($language, '-utf8')) {
1351
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1352
+	}
1270 1353
 
1271 1354
 	// @todo Maybe change the cookie name if going to 1.1, too?
1272 1355
 
@@ -1277,8 +1360,9 @@  discard block
 block discarded – undo
1277 1360
 	// Tell Settings.php to store db_last_error.php in the cache
1278 1361
 	move_db_last_error_to_cachedir();
1279 1362
 
1280
-	if ($command_line)
1281
-		echo ' Successful.' . "\n";
1363
+	if ($command_line) {
1364
+			echo ' Successful.' . "\n";
1365
+	}
1282 1366
 
1283 1367
 	// Are we doing debug?
1284 1368
 	if (isset($_POST['debug']))
@@ -1288,8 +1372,9 @@  discard block
 block discarded – undo
1288 1372
 	}
1289 1373
 
1290 1374
 	// If we're not backing up then jump one.
1291
-	if (empty($_POST['backup']))
1292
-		$upcontext['current_step']++;
1375
+	if (empty($_POST['backup'])) {
1376
+			$upcontext['current_step']++;
1377
+	}
1293 1378
 
1294 1379
 	// If we've got here then let's proceed to the next step!
1295 1380
 	return true;
@@ -1304,8 +1389,9 @@  discard block
 block discarded – undo
1304 1389
 	$upcontext['page_title'] = $txt['backup_database'];
1305 1390
 
1306 1391
 	// Done it already - js wise?
1307
-	if (!empty($_POST['backup_done']))
1308
-		return true;
1392
+	if (!empty($_POST['backup_done'])) {
1393
+			return true;
1394
+	}
1309 1395
 
1310 1396
 	// Some useful stuff here.
1311 1397
 	db_extend();
@@ -1319,9 +1405,10 @@  discard block
 block discarded – undo
1319 1405
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1320 1406
 
1321 1407
 	$table_names = array();
1322
-	foreach ($tables as $table)
1323
-		if (substr($table, 0, 7) !== 'backup_')
1408
+	foreach ($tables as $table) {
1409
+			if (substr($table, 0, 7) !== 'backup_')
1324 1410
 			$table_names[] = $table;
1411
+	}
1325 1412
 
1326 1413
 	$upcontext['table_count'] = count($table_names);
1327 1414
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1331,12 +1418,14 @@  discard block
 block discarded – undo
1331 1418
 	$file_steps = $upcontext['table_count'];
1332 1419
 
1333 1420
 	// What ones have we already done?
1334
-	foreach ($table_names as $id => $table)
1335
-		if ($id < $_GET['substep'])
1421
+	foreach ($table_names as $id => $table) {
1422
+			if ($id < $_GET['substep'])
1336 1423
 			$upcontext['previous_tables'][] = $table;
1424
+	}
1337 1425
 
1338
-	if ($command_line)
1339
-		echo 'Backing Up Tables.';
1426
+	if ($command_line) {
1427
+			echo 'Backing Up Tables.';
1428
+	}
1340 1429
 
1341 1430
 	// If we don't support javascript we backup here.
1342 1431
 	if (!$support_js || isset($_GET['xml']))
@@ -1355,8 +1444,9 @@  discard block
 block discarded – undo
1355 1444
 			backupTable($table_names[$substep]);
1356 1445
 
1357 1446
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1358
-			if (isset($_GET['xml']))
1359
-				return upgradeExit();
1447
+			if (isset($_GET['xml'])) {
1448
+							return upgradeExit();
1449
+			}
1360 1450
 		}
1361 1451
 
1362 1452
 		if ($command_line)
@@ -1389,9 +1479,10 @@  discard block
 block discarded – undo
1389 1479
 
1390 1480
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1391 1481
 
1392
-	if ($command_line)
1393
-		echo ' done.';
1394
-}
1482
+	if ($command_line) {
1483
+			echo ' done.';
1484
+	}
1485
+	}
1395 1486
 
1396 1487
 // Step 2: Everything.
1397 1488
 function DatabaseChanges()
@@ -1400,8 +1491,9 @@  discard block
 block discarded – undo
1400 1491
 	global $upcontext, $support_js, $db_type;
1401 1492
 
1402 1493
 	// Have we just completed this?
1403
-	if (!empty($_POST['database_done']))
1404
-		return true;
1494
+	if (!empty($_POST['database_done'])) {
1495
+			return true;
1496
+	}
1405 1497
 
1406 1498
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1407 1499
 	$upcontext['page_title'] = $txt['database_changes'];
@@ -1416,15 +1508,16 @@  discard block
 block discarded – undo
1416 1508
 	);
1417 1509
 
1418 1510
 	// How many files are there in total?
1419
-	if (isset($_GET['filecount']))
1420
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1421
-	else
1511
+	if (isset($_GET['filecount'])) {
1512
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1513
+	} else
1422 1514
 	{
1423 1515
 		$upcontext['file_count'] = 0;
1424 1516
 		foreach ($files as $file)
1425 1517
 		{
1426
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1427
-				$upcontext['file_count']++;
1518
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1519
+							$upcontext['file_count']++;
1520
+			}
1428 1521
 		}
1429 1522
 	}
1430 1523
 
@@ -1434,9 +1527,9 @@  discard block
 block discarded – undo
1434 1527
 	$upcontext['cur_file_num'] = 0;
1435 1528
 	foreach ($files as $file)
1436 1529
 	{
1437
-		if ($did_not_do)
1438
-			$did_not_do--;
1439
-		else
1530
+		if ($did_not_do) {
1531
+					$did_not_do--;
1532
+		} else
1440 1533
 		{
1441 1534
 			$upcontext['cur_file_num']++;
1442 1535
 			$upcontext['cur_file_name'] = $file[0];
@@ -1463,12 +1556,13 @@  discard block
 block discarded – undo
1463 1556
 					// Flag to move on to the next.
1464 1557
 					$upcontext['completed_step'] = true;
1465 1558
 					// Did we complete the whole file?
1466
-					if ($nextFile)
1467
-						$upcontext['current_debug_item_num'] = -1;
1559
+					if ($nextFile) {
1560
+											$upcontext['current_debug_item_num'] = -1;
1561
+					}
1468 1562
 					return upgradeExit();
1563
+				} elseif ($support_js) {
1564
+									break;
1469 1565
 				}
1470
-				elseif ($support_js)
1471
-					break;
1472 1566
 			}
1473 1567
 			// Set the progress bar to be right as if we had - even if we hadn't...
1474 1568
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1494,8 +1588,9 @@  discard block
 block discarded – undo
1494 1588
 	global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings;
1495 1589
 
1496 1590
 	// Now it's nice to have some of the basic SMF source files.
1497
-	if (!isset($_GET['ssi']) && !$command_line)
1498
-		redirectLocation('&ssi=1');
1591
+	if (!isset($_GET['ssi']) && !$command_line) {
1592
+			redirectLocation('&ssi=1');
1593
+	}
1499 1594
 
1500 1595
 	$upcontext['sub_template'] = 'upgrade_complete';
1501 1596
 	$upcontext['page_title'] = $txt['upgrade_complete'];
@@ -1511,14 +1606,16 @@  discard block
 block discarded – undo
1511 1606
 	// Are we in maintenance mode?
1512 1607
 	if (isset($upcontext['user']['main']))
1513 1608
 	{
1514
-		if ($command_line)
1515
-			echo ' * ';
1609
+		if ($command_line) {
1610
+					echo ' * ';
1611
+		}
1516 1612
 		$upcontext['removed_maintenance'] = true;
1517 1613
 		$changes['maintenance'] = $upcontext['user']['main'];
1518 1614
 	}
1519 1615
 	// Otherwise if somehow we are in 2 let's go to 1.
1520
-	elseif (!empty($maintenance) && $maintenance == 2)
1521
-		$changes['maintenance'] = 1;
1616
+	elseif (!empty($maintenance) && $maintenance == 2) {
1617
+			$changes['maintenance'] = 1;
1618
+	}
1522 1619
 
1523 1620
 	// Wipe this out...
1524 1621
 	$upcontext['user'] = array();
@@ -1533,21 +1630,23 @@  discard block
 block discarded – undo
1533 1630
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1534 1631
 
1535 1632
 	// Now is the perfect time to fetch the SM files.
1536
-	if ($command_line)
1537
-		cli_scheduled_fetchSMfiles();
1538
-	else
1633
+	if ($command_line) {
1634
+			cli_scheduled_fetchSMfiles();
1635
+	} else
1539 1636
 	{
1540 1637
 		require_once($sourcedir . '/ScheduledTasks.php');
1541 1638
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
1542 1639
 		scheduled_fetchSMfiles(); // Now go get those files!
1543 1640
 		// This is needed in case someone invokes the upgrader using https when upgrading an http forum
1544
-		if (httpsOn())
1545
-			$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
1641
+		if (httpsOn()) {
1642
+					$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
1643
+		}
1546 1644
 	}
1547 1645
 
1548 1646
 	// Log what we've done.
1549
-	if (empty($user_info['id']))
1550
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1647
+	if (empty($user_info['id'])) {
1648
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1649
+	}
1551 1650
 
1552 1651
 	// Log the action manually, so CLI still works.
1553 1652
 	$smcFunc['db_insert']('',
@@ -1566,8 +1665,9 @@  discard block
 block discarded – undo
1566 1665
 
1567 1666
 	// Save the current database version.
1568 1667
 	$server_version = $smcFunc['db_server_info']();
1569
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1570
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1668
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1669
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1670
+	}
1571 1671
 
1572 1672
 	if ($command_line)
1573 1673
 	{
@@ -1579,8 +1679,9 @@  discard block
 block discarded – undo
1579 1679
 
1580 1680
 	// Make sure it says we're done.
1581 1681
 	$upcontext['overall_percent'] = 100;
1582
-	if (isset($upcontext['step_progress']))
1583
-		unset($upcontext['step_progress']);
1682
+	if (isset($upcontext['step_progress'])) {
1683
+			unset($upcontext['step_progress']);
1684
+	}
1584 1685
 
1585 1686
 	$_GET['substep'] = 0;
1586 1687
 	return false;
@@ -1591,8 +1692,9 @@  discard block
 block discarded – undo
1591 1692
 {
1592 1693
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1593 1694
 
1594
-	if (empty($modSettings['time_format']))
1595
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1695
+	if (empty($modSettings['time_format'])) {
1696
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1697
+	}
1596 1698
 
1597 1699
 	// What files do we want to get
1598 1700
 	$request = $smcFunc['db_query']('', '
@@ -1626,8 +1728,9 @@  discard block
 block discarded – undo
1626 1728
 		$file_data = fetch_web_data($url);
1627 1729
 
1628 1730
 		// If we got an error - give up - the site might be down.
1629
-		if ($file_data === false)
1630
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1731
+		if ($file_data === false) {
1732
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1733
+		}
1631 1734
 
1632 1735
 		// Save the file to the database.
1633 1736
 		$smcFunc['db_query']('substring', '
@@ -1669,8 +1772,9 @@  discard block
 block discarded – undo
1669 1772
 	$themeData = array();
1670 1773
 	foreach ($values as $variable => $value)
1671 1774
 	{
1672
-		if (!isset($value) || $value === null)
1673
-			$value = 0;
1775
+		if (!isset($value) || $value === null) {
1776
+					$value = 0;
1777
+		}
1674 1778
 
1675 1779
 		$themeData[] = array(0, 1, $variable, $value);
1676 1780
 	}
@@ -1699,8 +1803,9 @@  discard block
 block discarded – undo
1699 1803
 
1700 1804
 	foreach ($values as $variable => $value)
1701 1805
 	{
1702
-		if (empty($modSettings[$value[0]]))
1703
-			continue;
1806
+		if (empty($modSettings[$value[0]])) {
1807
+					continue;
1808
+		}
1704 1809
 
1705 1810
 		$smcFunc['db_query']('', '
1706 1811
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1786,19 +1891,21 @@  discard block
 block discarded – undo
1786 1891
 	set_error_handler(
1787 1892
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1788 1893
 		{
1789
-			if ($support_js)
1790
-				return true;
1791
-			else
1792
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1894
+			if ($support_js) {
1895
+							return true;
1896
+			} else {
1897
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1898
+			}
1793 1899
 		}
1794 1900
 	);
1795 1901
 
1796 1902
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1797 1903
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1798
-	if ($db_type == 'mysql')
1799
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1800
-	else
1801
-		$db_collation = '';
1904
+	if ($db_type == 'mysql') {
1905
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1906
+	} else {
1907
+			$db_collation = '';
1908
+	}
1802 1909
 
1803 1910
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1804 1911
 
@@ -1810,8 +1917,9 @@  discard block
 block discarded – undo
1810 1917
 	$last_step = '';
1811 1918
 
1812 1919
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1813
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1814
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1920
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1921
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1922
+	}
1815 1923
 
1816 1924
 	// Count the total number of steps within this file - for progress.
1817 1925
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1831,15 +1939,18 @@  discard block
 block discarded – undo
1831 1939
 		$do_current = $substep >= $_GET['substep'];
1832 1940
 
1833 1941
 		// Get rid of any comments in the beginning of the line...
1834
-		if (substr(trim($line), 0, 2) === '/*')
1835
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1942
+		if (substr(trim($line), 0, 2) === '/*') {
1943
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1944
+		}
1836 1945
 
1837 1946
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1838
-		if ($is_debug && !$support_js && $command_line)
1839
-			flush();
1947
+		if ($is_debug && !$support_js && $command_line) {
1948
+					flush();
1949
+		}
1840 1950
 
1841
-		if (trim($line) === '')
1842
-			continue;
1951
+		if (trim($line) === '') {
1952
+					continue;
1953
+		}
1843 1954
 
1844 1955
 		if (trim(substr($line, 0, 3)) === '---')
1845 1956
 		{
@@ -1849,8 +1960,9 @@  discard block
 block discarded – undo
1849 1960
 			if (trim($current_data) != '' && $type !== '}')
1850 1961
 			{
1851 1962
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1852
-				if ($command_line)
1853
-					echo $upcontext['error_message'];
1963
+				if ($command_line) {
1964
+									echo $upcontext['error_message'];
1965
+				}
1854 1966
 			}
1855 1967
 
1856 1968
 			if ($type == ' ')
@@ -1868,17 +1980,18 @@  discard block
 block discarded – undo
1868 1980
 				if ($do_current)
1869 1981
 				{
1870 1982
 					$upcontext['actioned_items'][] = $last_step;
1871
-					if ($command_line)
1872
-						echo ' * ';
1983
+					if ($command_line) {
1984
+											echo ' * ';
1985
+					}
1873 1986
 				}
1874
-			}
1875
-			elseif ($type == '#')
1987
+			} elseif ($type == '#')
1876 1988
 			{
1877 1989
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1878 1990
 
1879 1991
 				$upcontext['current_debug_item_num']++;
1880
-				if (trim($line) != '---#')
1881
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1992
+				if (trim($line) != '---#') {
1993
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1994
+				}
1882 1995
 
1883 1996
 				// Have we already done something?
1884 1997
 				if (isset($_GET['xml']) && $done_something)
@@ -1889,34 +2002,36 @@  discard block
 block discarded – undo
1889 2002
 
1890 2003
 				if ($do_current)
1891 2004
 				{
1892
-					if (trim($line) == '---#' && $command_line)
1893
-						echo ' done.', $endl;
1894
-					elseif ($command_line)
1895
-						echo ' +++ ', rtrim(substr($line, 4));
1896
-					elseif (trim($line) != '---#')
2005
+					if (trim($line) == '---#' && $command_line) {
2006
+											echo ' done.', $endl;
2007
+					} elseif ($command_line) {
2008
+											echo ' +++ ', rtrim(substr($line, 4));
2009
+					} elseif (trim($line) != '---#')
1897 2010
 					{
1898
-						if ($is_debug)
1899
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2011
+						if ($is_debug) {
2012
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2013
+						}
1900 2014
 					}
1901 2015
 				}
1902 2016
 
1903 2017
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1904 2018
 				{
1905
-					if ($command_line)
1906
-						echo ' * ';
1907
-					else
1908
-						$upcontext['actioned_items'][] = $last_step;
2019
+					if ($command_line) {
2020
+											echo ' * ';
2021
+					} else {
2022
+											$upcontext['actioned_items'][] = $last_step;
2023
+					}
1909 2024
 				}
1910 2025
 
1911 2026
 				// Small step - only if we're actually doing stuff.
1912
-				if ($do_current)
1913
-					nextSubstep(++$substep);
1914
-				else
1915
-					$substep++;
1916
-			}
1917
-			elseif ($type == '{')
1918
-				$current_type = 'code';
1919
-			elseif ($type == '}')
2027
+				if ($do_current) {
2028
+									nextSubstep(++$substep);
2029
+				} else {
2030
+									$substep++;
2031
+				}
2032
+			} elseif ($type == '{') {
2033
+							$current_type = 'code';
2034
+			} elseif ($type == '}')
1920 2035
 			{
1921 2036
 				$current_type = 'sql';
1922 2037
 
@@ -1929,8 +2044,9 @@  discard block
 block discarded – undo
1929 2044
 				if (eval('global $db_prefix, $modSettings, $smcFunc, $txt; ' . $current_data) === false)
1930 2045
 				{
1931 2046
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1932
-					if ($command_line)
1933
-						echo $upcontext['error_message'];
2047
+					if ($command_line) {
2048
+											echo $upcontext['error_message'];
2049
+					}
1934 2050
 				}
1935 2051
 
1936 2052
 				// Done with code!
@@ -2018,8 +2134,9 @@  discard block
 block discarded – undo
2018 2134
 	$db_unbuffered = false;
2019 2135
 
2020 2136
 	// Failure?!
2021
-	if ($result !== false)
2022
-		return $result;
2137
+	if ($result !== false) {
2138
+			return $result;
2139
+	}
2023 2140
 
2024 2141
 	$db_error_message = $smcFunc['db_error']($db_connection);
2025 2142
 	// If MySQL we do something more clever.
@@ -2047,54 +2164,61 @@  discard block
 block discarded – undo
2047 2164
 			{
2048 2165
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
2049 2166
 				$result = mysqli_query($db_connection, $string);
2050
-				if ($result !== false)
2051
-					return $result;
2167
+				if ($result !== false) {
2168
+									return $result;
2169
+				}
2052 2170
 			}
2053
-		}
2054
-		elseif ($mysqli_errno == 2013)
2171
+		} elseif ($mysqli_errno == 2013)
2055 2172
 		{
2056 2173
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
2057 2174
 			mysqli_select_db($db_connection, $db_name);
2058 2175
 			if ($db_connection)
2059 2176
 			{
2060 2177
 				$result = mysqli_query($db_connection, $string);
2061
-				if ($result !== false)
2062
-					return $result;
2178
+				if ($result !== false) {
2179
+									return $result;
2180
+				}
2063 2181
 			}
2064 2182
 		}
2065 2183
 		// Duplicate column name... should be okay ;).
2066
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
2067
-			return false;
2184
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2185
+					return false;
2186
+		}
2068 2187
 		// Duplicate insert... make sure it's the proper type of query ;).
2069
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
2070
-			return false;
2188
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2189
+					return false;
2190
+		}
2071 2191
 		// Creating an index on a non-existent column.
2072
-		elseif ($mysqli_errno == 1072)
2073
-			return false;
2074
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
2075
-			return false;
2192
+		elseif ($mysqli_errno == 1072) {
2193
+					return false;
2194
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2195
+					return false;
2196
+		}
2076 2197
 	}
2077 2198
 	// If a table already exists don't go potty.
2078 2199
 	else
2079 2200
 	{
2080 2201
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
2081 2202
 		{
2082
-			if (strpos($db_error_message, 'exist') !== false)
2083
-				return true;
2084
-		}
2085
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2203
+			if (strpos($db_error_message, 'exist') !== false) {
2204
+							return true;
2205
+			}
2206
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
2086 2207
 		{
2087
-			if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error)
2088
-				return true;
2208
+			if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) {
2209
+							return true;
2210
+			}
2089 2211
 		}
2090 2212
 	}
2091 2213
 
2092 2214
 	// Get the query string so we pass everything.
2093 2215
 	$query_string = '';
2094
-	foreach ($_GET as $k => $v)
2095
-		$query_string .= ';' . $k . '=' . $v;
2096
-	if (strlen($query_string) != 0)
2097
-		$query_string = '?' . substr($query_string, 1);
2216
+	foreach ($_GET as $k => $v) {
2217
+			$query_string .= ';' . $k . '=' . $v;
2218
+	}
2219
+	if (strlen($query_string) != 0) {
2220
+			$query_string = '?' . substr($query_string, 1);
2221
+	}
2098 2222
 
2099 2223
 	if ($command_line)
2100 2224
 	{
@@ -2149,16 +2273,18 @@  discard block
 block discarded – undo
2149 2273
 			{
2150 2274
 				$found |= 1;
2151 2275
 				// Do some checks on the data if we have it set.
2152
-				if (isset($change['col_type']))
2153
-					$found &= $change['col_type'] === $column['type'];
2154
-				if (isset($change['null_allowed']))
2155
-					$found &= $column['null'] == $change['null_allowed'];
2156
-				if (isset($change['default']))
2157
-					$found &= $change['default'] === $column['default'];
2276
+				if (isset($change['col_type'])) {
2277
+									$found &= $change['col_type'] === $column['type'];
2278
+				}
2279
+				if (isset($change['null_allowed'])) {
2280
+									$found &= $column['null'] == $change['null_allowed'];
2281
+				}
2282
+				if (isset($change['default'])) {
2283
+									$found &= $change['default'] === $column['default'];
2284
+				}
2158 2285
 			}
2159 2286
 		}
2160
-	}
2161
-	elseif ($change['type'] === 'index')
2287
+	} elseif ($change['type'] === 'index')
2162 2288
 	{
2163 2289
 		$request = upgrade_query('
2164 2290
 			SHOW INDEX
@@ -2167,9 +2293,10 @@  discard block
 block discarded – undo
2167 2293
 		{
2168 2294
 			$cur_index = array();
2169 2295
 
2170
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2171
-				if ($row['Key_name'] === $change['name'])
2296
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2297
+							if ($row['Key_name'] === $change['name'])
2172 2298
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2299
+			}
2173 2300
 
2174 2301
 			ksort($cur_index, SORT_NUMERIC);
2175 2302
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2179,14 +2306,17 @@  discard block
 block discarded – undo
2179 2306
 	}
2180 2307
 
2181 2308
 	// If we're trying to add and it's added, we're done.
2182
-	if ($found && in_array($change['method'], array('add', 'change')))
2183
-		return true;
2309
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2310
+			return true;
2311
+	}
2184 2312
 	// Otherwise if we're removing and it wasn't found we're also done.
2185
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2186
-		return true;
2313
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2314
+			return true;
2315
+	}
2187 2316
 	// Otherwise is it just a test?
2188
-	elseif ($is_test)
2189
-		return false;
2317
+	elseif ($is_test) {
2318
+			return false;
2319
+	}
2190 2320
 
2191 2321
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2192 2322
 	$running = false;
@@ -2197,8 +2327,9 @@  discard block
 block discarded – undo
2197 2327
 			SHOW FULL PROCESSLIST');
2198 2328
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2199 2329
 		{
2200
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2201
-				$found = true;
2330
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2331
+							$found = true;
2332
+			}
2202 2333
 		}
2203 2334
 
2204 2335
 		// Can't find it? Then we need to run it fools!
@@ -2210,8 +2341,9 @@  discard block
 block discarded – undo
2210 2341
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2211 2342
 				' . $change['text'], true) !== false;
2212 2343
 
2213
-			if (!$success)
2214
-				return false;
2344
+			if (!$success) {
2345
+							return false;
2346
+			}
2215 2347
 
2216 2348
 			// Return
2217 2349
 			$running = true;
@@ -2253,8 +2385,9 @@  discard block
 block discarded – undo
2253 2385
 			'db_error_skip' => true,
2254 2386
 		)
2255 2387
 	);
2256
-	if ($smcFunc['db_num_rows']($request) === 0)
2257
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2388
+	if ($smcFunc['db_num_rows']($request) === 0) {
2389
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2390
+	}
2258 2391
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2259 2392
 	$smcFunc['db_free_result']($request);
2260 2393
 
@@ -2276,18 +2409,19 @@  discard block
 block discarded – undo
2276 2409
 			)
2277 2410
 		);
2278 2411
 		// No results? Just forget it all together.
2279
-		if ($smcFunc['db_num_rows']($request) === 0)
2280
-			unset($table_row['Collation']);
2281
-		else
2282
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2412
+		if ($smcFunc['db_num_rows']($request) === 0) {
2413
+					unset($table_row['Collation']);
2414
+		} else {
2415
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2416
+		}
2283 2417
 		$smcFunc['db_free_result']($request);
2284 2418
 	}
2285 2419
 
2286 2420
 	if ($column_fix)
2287 2421
 	{
2288 2422
 		// Make sure there are no NULL's left.
2289
-		if ($null_fix)
2290
-			$smcFunc['db_query']('', '
2423
+		if ($null_fix) {
2424
+					$smcFunc['db_query']('', '
2291 2425
 				UPDATE {db_prefix}' . $change['table'] . '
2292 2426
 				SET ' . $change['column'] . ' = {string:default}
2293 2427
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2296,6 +2430,7 @@  discard block
 block discarded – undo
2296 2430
 					'db_error_skip' => true,
2297 2431
 				)
2298 2432
 			);
2433
+		}
2299 2434
 
2300 2435
 		// Do the actual alteration.
2301 2436
 		$smcFunc['db_query']('', '
@@ -2324,8 +2459,9 @@  discard block
 block discarded – undo
2324 2459
 	}
2325 2460
 
2326 2461
 	// Not a column we need to check on?
2327
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2328
-		return;
2462
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2463
+			return;
2464
+	}
2329 2465
 
2330 2466
 	// Break it up you (six|seven).
2331 2467
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2344,13 +2480,13 @@  discard block
 block discarded – undo
2344 2480
 				'new_name' => $temp[2],
2345 2481
 		));
2346 2482
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2347
-		if ($smcFunc['db_num_rows'] != 1)
2348
-			return;
2483
+		if ($smcFunc['db_num_rows'] != 1) {
2484
+					return;
2485
+		}
2349 2486
 
2350 2487
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2351 2488
 		$smcFunc['db_free_result']($request);
2352
-	}
2353
-	else
2489
+	} else
2354 2490
 	{
2355 2491
 		// Do this the old fashion, sure method way.
2356 2492
 		$request = $smcFunc['db_query']('', '
@@ -2361,21 +2497,24 @@  discard block
 block discarded – undo
2361 2497
 		));
2362 2498
 		// Mayday!
2363 2499
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2364
-		if ($smcFunc['db_num_rows'] == 0)
2365
-			return;
2500
+		if ($smcFunc['db_num_rows'] == 0) {
2501
+					return;
2502
+		}
2366 2503
 
2367 2504
 		// Oh where, oh where has my little field gone. Oh where can it be...
2368
-		while ($row = $smcFunc['db_query']($request))
2369
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2505
+		while ($row = $smcFunc['db_query']($request)) {
2506
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2370 2507
 			{
2371 2508
 				$current_type = $row['Type'];
2509
+		}
2372 2510
 				break;
2373 2511
 			}
2374 2512
 	}
2375 2513
 
2376 2514
 	// If this doesn't match, the column may of been altered for a reason.
2377
-	if (trim($current_type) != trim($temp[3]))
2378
-		$temp[3] = $current_type;
2515
+	if (trim($current_type) != trim($temp[3])) {
2516
+			$temp[3] = $current_type;
2517
+	}
2379 2518
 
2380 2519
 	// Piece this back together.
2381 2520
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2387,8 +2526,9 @@  discard block
 block discarded – undo
2387 2526
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2388 2527
 	global $step_progress, $is_debug, $upcontext;
2389 2528
 
2390
-	if ($_GET['substep'] < $substep)
2391
-		$_GET['substep'] = $substep;
2529
+	if ($_GET['substep'] < $substep) {
2530
+			$_GET['substep'] = $substep;
2531
+	}
2392 2532
 
2393 2533
 	if ($command_line)
2394 2534
 	{
@@ -2401,29 +2541,33 @@  discard block
 block discarded – undo
2401 2541
 	}
2402 2542
 
2403 2543
 	@set_time_limit(300);
2404
-	if (function_exists('apache_reset_timeout'))
2405
-		@apache_reset_timeout();
2544
+	if (function_exists('apache_reset_timeout')) {
2545
+			@apache_reset_timeout();
2546
+	}
2406 2547
 
2407
-	if (time() - $start_time <= $timeLimitThreshold)
2408
-		return;
2548
+	if (time() - $start_time <= $timeLimitThreshold) {
2549
+			return;
2550
+	}
2409 2551
 
2410 2552
 	// Do we have some custom step progress stuff?
2411 2553
 	if (!empty($step_progress))
2412 2554
 	{
2413 2555
 		$upcontext['substep_progress'] = 0;
2414 2556
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2415
-		if ($step_progress['current'] > $step_progress['total'])
2416
-			$upcontext['substep_progress'] = 99.9;
2417
-		else
2418
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2557
+		if ($step_progress['current'] > $step_progress['total']) {
2558
+					$upcontext['substep_progress'] = 99.9;
2559
+		} else {
2560
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2561
+		}
2419 2562
 
2420 2563
 		// Make it nicely rounded.
2421 2564
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2422 2565
 	}
2423 2566
 
2424 2567
 	// If this is XML we just exit right away!
2425
-	if (isset($_GET['xml']))
2426
-		return upgradeExit();
2568
+	if (isset($_GET['xml'])) {
2569
+			return upgradeExit();
2570
+	}
2427 2571
 
2428 2572
 	// We're going to pause after this!
2429 2573
 	$upcontext['pause'] = true;
@@ -2431,13 +2575,15 @@  discard block
 block discarded – undo
2431 2575
 	$upcontext['query_string'] = '';
2432 2576
 	foreach ($_GET as $k => $v)
2433 2577
 	{
2434
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2435
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2578
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2579
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2580
+		}
2436 2581
 	}
2437 2582
 
2438 2583
 	// Custom warning?
2439
-	if (!empty($custom_warning))
2440
-		$upcontext['custom_warning'] = $custom_warning;
2584
+	if (!empty($custom_warning)) {
2585
+			$upcontext['custom_warning'] = $custom_warning;
2586
+	}
2441 2587
 
2442 2588
 	upgradeExit();
2443 2589
 }
@@ -2452,25 +2598,26 @@  discard block
 block discarded – undo
2452 2598
 	ob_implicit_flush(true);
2453 2599
 	@set_time_limit(600);
2454 2600
 
2455
-	if (!isset($_SERVER['argv']))
2456
-		$_SERVER['argv'] = array();
2601
+	if (!isset($_SERVER['argv'])) {
2602
+			$_SERVER['argv'] = array();
2603
+	}
2457 2604
 	$_GET['maint'] = 1;
2458 2605
 
2459 2606
 	foreach ($_SERVER['argv'] as $i => $arg)
2460 2607
 	{
2461
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2462
-			$_GET['lang'] = $match[1];
2463
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2464
-			continue;
2465
-		elseif ($arg == '--no-maintenance')
2466
-			$_GET['maint'] = 0;
2467
-		elseif ($arg == '--debug')
2468
-			$is_debug = true;
2469
-		elseif ($arg == '--backup')
2470
-			$_POST['backup'] = 1;
2471
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2472
-			$_GET['conv'] = 1;
2473
-		elseif ($i != 0)
2608
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2609
+					$_GET['lang'] = $match[1];
2610
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2611
+					continue;
2612
+		} elseif ($arg == '--no-maintenance') {
2613
+					$_GET['maint'] = 0;
2614
+		} elseif ($arg == '--debug') {
2615
+					$is_debug = true;
2616
+		} elseif ($arg == '--backup') {
2617
+					$_POST['backup'] = 1;
2618
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2619
+					$_GET['conv'] = 1;
2620
+		} elseif ($i != 0)
2474 2621
 		{
2475 2622
 			echo 'SMF Command-line Upgrader
2476 2623
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2484,10 +2631,12 @@  discard block
 block discarded – undo
2484 2631
 		}
2485 2632
 	}
2486 2633
 
2487
-	if (!php_version_check())
2488
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2489
-	if (!db_version_check())
2490
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2634
+	if (!php_version_check()) {
2635
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2636
+	}
2637
+	if (!db_version_check()) {
2638
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2639
+	}
2491 2640
 
2492 2641
 	// Do some checks to make sure they have proper privileges
2493 2642
 	db_extend('packages');
@@ -2502,34 +2651,39 @@  discard block
 block discarded – undo
2502 2651
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2503 2652
 
2504 2653
 	// Sorry... we need CREATE, ALTER and DROP
2505
-	if (!$create || !$alter || !$drop)
2506
-		print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true);
2654
+	if (!$create || !$alter || !$drop) {
2655
+			print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true);
2656
+	}
2507 2657
 
2508 2658
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2509 2659
 		&& @file_exists($sourcedir . '/QueryString.php')
2510 2660
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2511
-	if (!$check && !isset($modSettings['smfVersion']))
2512
-		print_error('Error: Some files are missing or out-of-date.', true);
2661
+	if (!$check && !isset($modSettings['smfVersion'])) {
2662
+			print_error('Error: Some files are missing or out-of-date.', true);
2663
+	}
2513 2664
 
2514 2665
 	// Do a quick version spot check.
2515 2666
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2516 2667
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2517
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2518
-		print_error('Error: Some files have not yet been updated properly.');
2668
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2669
+			print_error('Error: Some files have not yet been updated properly.');
2670
+	}
2519 2671
 
2520 2672
 	// Make sure Settings.php is writable.
2521 2673
 	quickFileWritable($boarddir . '/Settings.php');
2522
-	if (!is_writable($boarddir . '/Settings.php'))
2523
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2674
+	if (!is_writable($boarddir . '/Settings.php')) {
2675
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2676
+	}
2524 2677
 
2525 2678
 	// Make sure Settings_bak.php is writable.
2526 2679
 	quickFileWritable($boarddir . '/Settings_bak.php');
2527
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2528
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2680
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2681
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2682
+	}
2529 2683
 
2530
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2531
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2532
-	elseif (isset($modSettings['agreement']))
2684
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2685
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2686
+	} elseif (isset($modSettings['agreement']))
2533 2687
 	{
2534 2688
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2535 2689
 		fwrite($fp, $modSettings['agreement']);
@@ -2539,36 +2693,42 @@  discard block
 block discarded – undo
2539 2693
 	// Make sure Themes is writable.
2540 2694
 	quickFileWritable($modSettings['theme_dir']);
2541 2695
 
2542
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2543
-		print_error('Error: Unable to obtain write access to "Themes".');
2696
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2697
+			print_error('Error: Unable to obtain write access to "Themes".');
2698
+	}
2544 2699
 
2545 2700
 	// Make sure cache directory exists and is writable!
2546 2701
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2547
-	if (!file_exists($cachedir_temp))
2548
-		@mkdir($cachedir_temp);
2702
+	if (!file_exists($cachedir_temp)) {
2703
+			@mkdir($cachedir_temp);
2704
+	}
2549 2705
 
2550 2706
 	// Make sure the cache temp dir is writable.
2551 2707
 	quickFileWritable($cachedir_temp);
2552 2708
 
2553
-	if (!is_writable($cachedir_temp))
2554
-		print_error('Error: Unable to obtain write access to "cache".', true);
2709
+	if (!is_writable($cachedir_temp)) {
2710
+			print_error('Error: Unable to obtain write access to "cache".', true);
2711
+	}
2555 2712
 
2556 2713
 	// Make sure db_last_error.php is writable.
2557 2714
 	quickFileWritable($cachedir_temp . '/db_last_error.php');
2558
-	if (!is_writable($cachedir_temp . '/db_last_error.php'))
2559
-		print_error('Error: Unable to obtain write access to "db_last_error.php".');
2715
+	if (!is_writable($cachedir_temp . '/db_last_error.php')) {
2716
+			print_error('Error: Unable to obtain write access to "db_last_error.php".');
2717
+	}
2560 2718
 
2561
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2562
-		print_error('Error: Unable to find language files!', true);
2563
-	else
2719
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2720
+			print_error('Error: Unable to find language files!', true);
2721
+	} else
2564 2722
 	{
2565 2723
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2566 2724
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2567 2725
 
2568
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2569
-			print_error('Error: Language files out of date.', true);
2570
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2571
-			print_error('Error: Install language is missing for selected language.', true);
2726
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2727
+					print_error('Error: Language files out of date.', true);
2728
+		}
2729
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2730
+					print_error('Error: Install language is missing for selected language.', true);
2731
+		}
2572 2732
 
2573 2733
 		// Otherwise include it!
2574 2734
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2588,8 +2748,9 @@  discard block
 block discarded – undo
2588 2748
 	global $db_prefix, $db_type, $command_line, $support_js, $txt;
2589 2749
 
2590 2750
 	// Done it already?
2591
-	if (!empty($_POST['utf8_done']))
2592
-		return true;
2751
+	if (!empty($_POST['utf8_done'])) {
2752
+			return true;
2753
+	}
2593 2754
 
2594 2755
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2595 2756
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2602,8 +2763,7 @@  discard block
 block discarded – undo
2602 2763
 		);
2603 2764
 
2604 2765
 		return true;
2605
-	}
2606
-	else
2766
+	} else
2607 2767
 	{
2608 2768
 		$upcontext['page_title'] = $txt['converting_utf8'];
2609 2769
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2647,8 +2807,9 @@  discard block
 block discarded – undo
2647 2807
 			)
2648 2808
 		);
2649 2809
 		$db_charsets = array();
2650
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2651
-			$db_charsets[] = $row['Charset'];
2810
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2811
+					$db_charsets[] = $row['Charset'];
2812
+		}
2652 2813
 
2653 2814
 		$smcFunc['db_free_result']($request);
2654 2815
 
@@ -2684,13 +2845,15 @@  discard block
 block discarded – undo
2684 2845
 		// If there's a fulltext index, we need to drop it first...
2685 2846
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2686 2847
 		{
2687
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2688
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2848
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2849
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2689 2850
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2851
+			}
2690 2852
 			$smcFunc['db_free_result']($request);
2691 2853
 
2692
-			if (isset($upcontext['fulltext_index']))
2693
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2854
+			if (isset($upcontext['fulltext_index'])) {
2855
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2856
+			}
2694 2857
 		}
2695 2858
 
2696 2859
 		// Drop it and make a note...
@@ -2880,8 +3043,9 @@  discard block
 block discarded – undo
2880 3043
 			$replace = '%field%';
2881 3044
 
2882 3045
 			// Build a huge REPLACE statement...
2883
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2884
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3046
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
3047
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3048
+			}
2885 3049
 		}
2886 3050
 
2887 3051
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2891,9 +3055,10 @@  discard block
 block discarded – undo
2891 3055
 		$upcontext['table_count'] = count($queryTables);
2892 3056
 
2893 3057
 		// What ones have we already done?
2894
-		foreach ($queryTables as $id => $table)
2895
-			if ($id < $_GET['substep'])
3058
+		foreach ($queryTables as $id => $table) {
3059
+					if ($id < $_GET['substep'])
2896 3060
 				$upcontext['previous_tables'][] = $table;
3061
+		}
2897 3062
 
2898 3063
 		$upcontext['cur_table_num'] = $_GET['substep'];
2899 3064
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2930,8 +3095,9 @@  discard block
 block discarded – undo
2930 3095
 			nextSubstep($substep);
2931 3096
 
2932 3097
 			// Just to make sure it doesn't time out.
2933
-			if (function_exists('apache_reset_timeout'))
2934
-				@apache_reset_timeout();
3098
+			if (function_exists('apache_reset_timeout')) {
3099
+							@apache_reset_timeout();
3100
+			}
2935 3101
 
2936 3102
 			$table_charsets = array();
2937 3103
 
@@ -2954,8 +3120,9 @@  discard block
 block discarded – undo
2954 3120
 
2955 3121
 						// Build structure of columns to operate on organized by charset; only operate on columns not yet utf8
2956 3122
 						if ($charset != 'utf8') {
2957
-							if (!isset($table_charsets[$charset]))
2958
-								$table_charsets[$charset] = array();
3123
+							if (!isset($table_charsets[$charset])) {
3124
+															$table_charsets[$charset] = array();
3125
+							}
2959 3126
 
2960 3127
 							$table_charsets[$charset][] = $column_info;
2961 3128
 						}
@@ -2996,10 +3163,11 @@  discard block
 block discarded – undo
2996 3163
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2997 3164
 				{
2998 3165
 					$update = '';
2999
-					foreach ($table_charsets as $charset => $columns)
3000
-						foreach ($columns as $column)
3166
+					foreach ($table_charsets as $charset => $columns) {
3167
+											foreach ($columns as $column)
3001 3168
 							$update .= '
3002 3169
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3170
+					}
3003 3171
 
3004 3172
 					$smcFunc['db_query']('', '
3005 3173
 						UPDATE {raw:table_name}
@@ -3024,8 +3192,9 @@  discard block
 block discarded – undo
3024 3192
 			// Now do the actual conversion (if still needed).
3025 3193
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
3026 3194
 			{
3027
-				if ($command_line)
3028
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3195
+				if ($command_line) {
3196
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3197
+				}
3029 3198
 
3030 3199
 				$smcFunc['db_query']('', '
3031 3200
 					ALTER TABLE {raw:table_name}
@@ -3035,12 +3204,14 @@  discard block
 block discarded – undo
3035 3204
 					)
3036 3205
 				);
3037 3206
 
3038
-				if ($command_line)
3039
-					echo " done.\n";
3207
+				if ($command_line) {
3208
+									echo " done.\n";
3209
+				}
3040 3210
 			}
3041 3211
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3042
-			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count'])
3043
-				return upgradeExit();
3212
+			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) {
3213
+							return upgradeExit();
3214
+			}
3044 3215
 		}
3045 3216
 
3046 3217
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -3069,8 +3240,8 @@  discard block
 block discarded – undo
3069 3240
 		);
3070 3241
 		while ($row = $smcFunc['db_fetch_assoc']($request))
3071 3242
 		{
3072
-			if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1)
3073
-				$smcFunc['db_query']('', '
3243
+			if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) {
3244
+							$smcFunc['db_query']('', '
3074 3245
 					UPDATE {db_prefix}log_actions
3075 3246
 					SET extra = {string:extra}
3076 3247
 					WHERE id_action = {int:current_action}',
@@ -3079,6 +3250,7 @@  discard block
 block discarded – undo
3079 3250
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
3080 3251
 					)
3081 3252
 				);
3253
+			}
3082 3254
 		}
3083 3255
 		$smcFunc['db_free_result']($request);
3084 3256
 
@@ -3100,15 +3272,17 @@  discard block
 block discarded – undo
3100 3272
 	// First thing's first - did we already do this?
3101 3273
 	if (!empty($modSettings['json_done']))
3102 3274
 	{
3103
-		if ($command_line)
3104
-			return DeleteUpgrade();
3105
-		else
3106
-			return true;
3275
+		if ($command_line) {
3276
+					return DeleteUpgrade();
3277
+		} else {
3278
+					return true;
3279
+		}
3107 3280
 	}
3108 3281
 
3109 3282
 	// Done it already - js wise?
3110
-	if (!empty($_POST['json_done']))
3111
-		return true;
3283
+	if (!empty($_POST['json_done'])) {
3284
+			return true;
3285
+	}
3112 3286
 
3113 3287
 	// List of tables affected by this function
3114 3288
 	// name => array('key', col1[,col2|true[,col3]])
@@ -3140,12 +3314,14 @@  discard block
 block discarded – undo
3140 3314
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
3141 3315
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3142 3316
 
3143
-	foreach ($keys as $id => $table)
3144
-		if ($id < $_GET['substep'])
3317
+	foreach ($keys as $id => $table) {
3318
+			if ($id < $_GET['substep'])
3145 3319
 			$upcontext['previous_tables'][] = $table;
3320
+	}
3146 3321
 
3147
-	if ($command_line)
3148
-		echo 'Converting data from serialize() to json_encode().';
3322
+	if ($command_line) {
3323
+			echo 'Converting data from serialize() to json_encode().';
3324
+	}
3149 3325
 
3150 3326
 	if (!$support_js || isset($_GET['xml']))
3151 3327
 	{
@@ -3185,8 +3361,9 @@  discard block
 block discarded – undo
3185 3361
 
3186 3362
 				// Loop through and fix these...
3187 3363
 				$new_settings = array();
3188
-				if ($command_line)
3189
-					echo "\n" . 'Fixing some settings...';
3364
+				if ($command_line) {
3365
+									echo "\n" . 'Fixing some settings...';
3366
+				}
3190 3367
 
3191 3368
 				foreach ($serialized_settings as $var)
3192 3369
 				{
@@ -3194,22 +3371,24 @@  discard block
 block discarded – undo
3194 3371
 					{
3195 3372
 						// Attempt to unserialize the setting
3196 3373
 						$temp = @safe_unserialize($modSettings[$var]);
3197
-						if (!$temp && $command_line)
3198
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3199
-						elseif ($temp !== false)
3200
-							$new_settings[$var] = json_encode($temp);
3374
+						if (!$temp && $command_line) {
3375
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3376
+						} elseif ($temp !== false) {
3377
+													$new_settings[$var] = json_encode($temp);
3378
+						}
3201 3379
 					}
3202 3380
 				}
3203 3381
 
3204 3382
 				// Update everything at once
3205
-				if (!function_exists('cache_put_data'))
3206
-					require_once($sourcedir . '/Load.php');
3383
+				if (!function_exists('cache_put_data')) {
3384
+									require_once($sourcedir . '/Load.php');
3385
+				}
3207 3386
 				updateSettings($new_settings, true);
3208 3387
 
3209
-				if ($command_line)
3210
-					echo ' done.';
3211
-			}
3212
-			elseif ($table == 'themes')
3388
+				if ($command_line) {
3389
+									echo ' done.';
3390
+				}
3391
+			} elseif ($table == 'themes')
3213 3392
 			{
3214 3393
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3215 3394
 				$query = $smcFunc['db_query']('', '
@@ -3228,10 +3407,11 @@  discard block
 block discarded – undo
3228 3407
 
3229 3408
 						if ($command_line)
3230 3409
 						{
3231
-							if ($temp === false)
3232
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3233
-							else
3234
-								echo "\n" . 'Fixing admin preferences...';
3410
+							if ($temp === false) {
3411
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3412
+							} else {
3413
+															echo "\n" . 'Fixing admin preferences...';
3414
+							}
3235 3415
 						}
3236 3416
 
3237 3417
 						if ($temp !== false)
@@ -3253,15 +3433,15 @@  discard block
 block discarded – undo
3253 3433
 								)
3254 3434
 							);
3255 3435
 
3256
-							if ($command_line)
3257
-								echo ' done.';
3436
+							if ($command_line) {
3437
+															echo ' done.';
3438
+							}
3258 3439
 						}
3259 3440
 					}
3260 3441
 
3261 3442
 					$smcFunc['db_free_result']($query);
3262 3443
 				}
3263
-			}
3264
-			else
3444
+			} else
3265 3445
 			{
3266 3446
 				// First item is always the key...
3267 3447
 				$key = $info[0];
@@ -3272,8 +3452,7 @@  discard block
 block discarded – undo
3272 3452
 				{
3273 3453
 					$col_select = $info[1];
3274 3454
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3275
-				}
3276
-				else
3455
+				} else
3277 3456
 				{
3278 3457
 					$col_select = implode(', ', $info);
3279 3458
 				}
@@ -3306,8 +3485,7 @@  discard block
 block discarded – undo
3306 3485
 								if ($temp === false && $command_line)
3307 3486
 								{
3308 3487
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3309
-								}
3310
-								else
3488
+								} else
3311 3489
 								{
3312 3490
 									$row[$col] = json_encode($temp);
3313 3491
 
@@ -3332,16 +3510,18 @@  discard block
 block discarded – undo
3332 3510
 						}
3333 3511
 					}
3334 3512
 
3335
-					if ($command_line)
3336
-						echo ' done.';
3513
+					if ($command_line) {
3514
+											echo ' done.';
3515
+					}
3337 3516
 
3338 3517
 					// Free up some memory...
3339 3518
 					$smcFunc['db_free_result']($query);
3340 3519
 				}
3341 3520
 			}
3342 3521
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3343
-			if (isset($_GET['xml']))
3344
-				return upgradeExit();
3522
+			if (isset($_GET['xml'])) {
3523
+							return upgradeExit();
3524
+			}
3345 3525
 		}
3346 3526
 
3347 3527
 		if ($command_line)
@@ -3356,8 +3536,9 @@  discard block
 block discarded – undo
3356 3536
 
3357 3537
 		$_GET['substep'] = 0;
3358 3538
 		// Make sure we move on!
3359
-		if ($command_line)
3360
-			return DeleteUpgrade();
3539
+		if ($command_line) {
3540
+					return DeleteUpgrade();
3541
+		}
3361 3542
 
3362 3543
 		return true;
3363 3544
 	}
@@ -3414,14 +3595,16 @@  discard block
 block discarded – undo
3414 3595
 	global $upcontext, $txt, $settings;
3415 3596
 
3416 3597
 	// Don't call me twice!
3417
-	if (!empty($upcontext['chmod_called']))
3418
-		return;
3598
+	if (!empty($upcontext['chmod_called'])) {
3599
+			return;
3600
+	}
3419 3601
 
3420 3602
 	$upcontext['chmod_called'] = true;
3421 3603
 
3422 3604
 	// Nothing?
3423
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3424
-		return;
3605
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3606
+			return;
3607
+	}
3425 3608
 
3426 3609
 	// Was it a problem with Windows?
3427 3610
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3453,11 +3636,12 @@  discard block
 block discarded – undo
3453 3636
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\');
3454 3637
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3455 3638
 
3456
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3457
-		echo '
3639
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3640
+			echo '
3458 3641
 					content.write(\'<hr>\n\t\t\t\');
3459 3642
 					content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\');
3460 3643
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3644
+	}
3461 3645
 
3462 3646
 	echo '
3463 3647
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3465,16 +3649,18 @@  discard block
 block discarded – undo
3465 3649
 				}
3466 3650
 			</script>';
3467 3651
 
3468
-	if (!empty($upcontext['chmod']['ftp_error']))
3469
-		echo '
3652
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3653
+			echo '
3470 3654
 			<div class="error_message red">
3471 3655
 				<p>', $txt['upgrade_ftp_error'], '<p>
3472 3656
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3473 3657
 			</div>';
3658
+	}
3474 3659
 
3475
-	if (empty($upcontext['chmod_in_form']))
3476
-		echo '
3660
+	if (empty($upcontext['chmod_in_form'])) {
3661
+			echo '
3477 3662
 			<form action="', $upcontext['form_url'], '" method="post">';
3663
+	}
3478 3664
 
3479 3665
 	echo '
3480 3666
 				<dl class="settings">
@@ -3516,9 +3702,10 @@  discard block
 block discarded – undo
3516 3702
 					<input type="submit" value="', $txt['ftp_connect'], '" class="button">
3517 3703
 				</div>';
3518 3704
 
3519
-	if (empty($upcontext['chmod_in_form']))
3520
-		echo '
3705
+	if (empty($upcontext['chmod_in_form'])) {
3706
+			echo '
3521 3707
 			</form>';
3708
+	}
3522 3709
 
3523 3710
 	echo '
3524 3711
 		</div><!-- .panel -->';
@@ -3582,9 +3769,10 @@  discard block
 block discarded – undo
3582 3769
 					<h2>', $txt['upgrade_progress'], '</h2>
3583 3770
 					<ul>';
3584 3771
 
3585
-	foreach ($upcontext['steps'] as $num => $step)
3586
-		echo '
3772
+	foreach ($upcontext['steps'] as $num => $step) {
3773
+			echo '
3587 3774
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3775
+	}
3588 3776
 
3589 3777
 	echo '
3590 3778
 					</ul>
@@ -3597,13 +3785,14 @@  discard block
 block discarded – undo
3597 3785
 						<span id="overall_text">', $upcontext['overall_percent'], '%</span>
3598 3786
 					</div>';
3599 3787
 
3600
-	if (isset($upcontext['step_progress']))
3601
-		echo '
3788
+	if (isset($upcontext['step_progress'])) {
3789
+			echo '
3602 3790
 					<div id="progress_bar_step" class="progress_bar progress_yellow">
3603 3791
 						<h3>', $txt['upgrade_step_progress'], '</h3>
3604 3792
 						<div id="step_progress" class="bar" style="width: ', $upcontext['step_progress'], '%;"></div>
3605 3793
 						<span id="step_text">', $upcontext['step_progress'], '%</span>
3606 3794
 					</div>';
3795
+	}
3607 3796
 
3608 3797
 	echo '
3609 3798
 					<div id="substep_bar_div" class="progress_bar" style="display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">
@@ -3634,31 +3823,35 @@  discard block
 block discarded – undo
3634 3823
 {
3635 3824
 	global $upcontext, $txt;
3636 3825
 
3637
-	if (!empty($upcontext['pause']))
3638
-		echo '
3826
+	if (!empty($upcontext['pause'])) {
3827
+			echo '
3639 3828
 					<em>', $txt['upgrade_incomplete'], '.</em><br>
3640 3829
 
3641 3830
 					<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3642 3831
 					<h3>
3643 3832
 						', $txt['upgrade_paused_overload'], '
3644 3833
 					</h3>';
3834
+	}
3645 3835
 
3646
-	if (!empty($upcontext['custom_warning']))
3647
-		echo '
3836
+	if (!empty($upcontext['custom_warning'])) {
3837
+			echo '
3648 3838
 					<div class="errorbox">
3649 3839
 						<h3>', $txt['upgrade_note'], '</h3>
3650 3840
 						', $upcontext['custom_warning'], '
3651 3841
 					</div>';
3842
+	}
3652 3843
 
3653 3844
 	echo '
3654 3845
 					<div class="righttext" style="margin: 1ex;">';
3655 3846
 
3656
-	if (!empty($upcontext['continue']))
3657
-		echo '
3847
+	if (!empty($upcontext['continue'])) {
3848
+			echo '
3658 3849
 						<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">';
3659
-	if (!empty($upcontext['skip']))
3660
-		echo '
3850
+	}
3851
+	if (!empty($upcontext['skip'])) {
3852
+			echo '
3661 3853
 						<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">';
3854
+	}
3662 3855
 
3663 3856
 	echo '
3664 3857
 					</div>
@@ -3709,11 +3902,12 @@  discard block
 block discarded – undo
3709 3902
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3710 3903
 	<smf>';
3711 3904
 
3712
-	if (!empty($upcontext['get_data']))
3713
-		foreach ($upcontext['get_data'] as $k => $v)
3905
+	if (!empty($upcontext['get_data'])) {
3906
+			foreach ($upcontext['get_data'] as $k => $v)
3714 3907
 			echo '
3715 3908
 		<get key="', $k, '">', $v, '</get>';
3716
-}
3909
+	}
3910
+	}
3717 3911
 
3718 3912
 function template_xml_below()
3719 3913
 {
@@ -3753,20 +3947,22 @@  discard block
 block discarded – undo
3753 3947
 	template_chmod();
3754 3948
 
3755 3949
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3756
-	if ($upcontext['is_large_forum'])
3757
-		echo '
3950
+	if ($upcontext['is_large_forum']) {
3951
+			echo '
3758 3952
 					<div class="errorbox">
3759 3953
 						<h3>', $txt['upgrade_warning'], '</h3>
3760 3954
 						', $txt['upgrade_warning_lots_data'], '
3761 3955
 					</div>';
3956
+	}
3762 3957
 
3763 3958
 	// A warning message?
3764
-	if (!empty($upcontext['warning']))
3765
-		echo '
3959
+	if (!empty($upcontext['warning'])) {
3960
+			echo '
3766 3961
 					<div class="errorbox">
3767 3962
 						<h3>', $txt['upgrade_warning'], '</h3>
3768 3963
 						', $upcontext['warning'], '
3769 3964
 					</div>';
3965
+	}
3770 3966
 
3771 3967
 	// Paths are incorrect?
3772 3968
 	echo '
@@ -3779,35 +3975,39 @@  discard block
 block discarded – undo
3779 3975
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3780 3976
 	{
3781 3977
 		$ago = time() - $upcontext['started'];
3782
-		if ($ago < 60)
3783
-			$ago = $ago . ' seconds';
3784
-		elseif ($ago < 3600)
3785
-			$ago = (int) ($ago / 60) . ' minutes';
3786
-		else
3787
-			$ago = (int) ($ago / 3600) . ' hours';
3978
+		if ($ago < 60) {
3979
+					$ago = $ago . ' seconds';
3980
+		} elseif ($ago < 3600) {
3981
+					$ago = (int) ($ago / 60) . ' minutes';
3982
+		} else {
3983
+					$ago = (int) ($ago / 3600) . ' hours';
3984
+		}
3788 3985
 
3789 3986
 		$active = time() - $upcontext['updated'];
3790
-		if ($active < 60)
3791
-			$updated = $active . ' seconds';
3792
-		elseif ($active < 3600)
3793
-			$updated = (int) ($active / 60) . ' minutes';
3794
-		else
3795
-			$updated = (int) ($active / 3600) . ' hours';
3987
+		if ($active < 60) {
3988
+					$updated = $active . ' seconds';
3989
+		} elseif ($active < 3600) {
3990
+					$updated = (int) ($active / 60) . ' minutes';
3991
+		} else {
3992
+					$updated = (int) ($active / 3600) . ' hours';
3993
+		}
3796 3994
 
3797 3995
 		echo '
3798 3996
 					<div class="errorbox">
3799 3997
 						<h3>', $txt['upgrade_warning'], '</h3>
3800 3998
 						<p>', sprintf($txt['upgrade_time'], $upcontext['user']['name'], $ago, $updated), '</p>';
3801
-		if ($active < 600)
3802
-			echo '
3999
+		if ($active < 600) {
4000
+					echo '
3803 4001
 						<p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>';
4002
+		}
3804 4003
 
3805
-		if ($active > $upcontext['inactive_timeout'])
3806
-			echo '
4004
+		if ($active > $upcontext['inactive_timeout']) {
4005
+					echo '
3807 4006
 						<p>',$txt['upgrade_run'], '</p>';
3808
-		else
3809
-			echo '
4007
+		} else {
4008
+					echo '
3810 4009
 						<p>', $txt['upgrade_script_timeout'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_script_timeout2'], ' ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'), '</p>';
4010
+		}
3811 4011
 
3812 4012
 		echo '
3813 4013
 					</div>';
@@ -3823,9 +4023,10 @@  discard block
 block discarded – undo
3823 4023
 						<dd>
3824 4024
 							<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>';
3825 4025
 
3826
-	if (!empty($upcontext['username_incorrect']))
3827
-		echo '
4026
+	if (!empty($upcontext['username_incorrect'])) {
4027
+			echo '
3828 4028
 							<div class="smalltext red">', $txt['upgrade_wrong_username'], '</div>';
4029
+	}
3829 4030
 
3830 4031
 	echo '
3831 4032
 						</dd>
@@ -3836,9 +4037,10 @@  discard block
 block discarded – undo
3836 4037
 							<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '>
3837 4038
 							<input type="hidden" name="hash_passwrd" value="">';
3838 4039
 
3839
-	if (!empty($upcontext['password_failed']))
3840
-		echo '
4040
+	if (!empty($upcontext['password_failed'])) {
4041
+			echo '
3841 4042
 							<div class="smalltext red">', $txt['upgrade_wrong_password'], '</div>';
4043
+	}
3842 4044
 
3843 4045
 	echo '
3844 4046
 						</dd>';
@@ -3906,12 +4108,13 @@  discard block
 block discarded – undo
3906 4108
 				<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3907 4109
 
3908 4110
 	// Warning message?
3909
-	if (!empty($upcontext['upgrade_options_warning']))
3910
-		echo '
4111
+	if (!empty($upcontext['upgrade_options_warning'])) {
4112
+			echo '
3911 4113
 				<div class="errorbox">
3912 4114
 					<h3>', $txt['upgrade_warning'] ,'</h3>
3913 4115
 					', $upcontext['upgrade_options_warning'], '
3914 4116
 				</div>';
4117
+	}
3915 4118
 
3916 4119
 	echo '
3917 4120
 				<ul class="upgrade_settings">
@@ -3940,12 +4143,13 @@  discard block
 block discarded – undo
3940 4143
 						<label for="empty_error">', $txt['upgrade_empty_errlog'], '</label>
3941 4144
 					</li>';
3942 4145
 
3943
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3944
-		echo '
4146
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
4147
+			echo '
3945 4148
 					<li>
3946 4149
 						<input type="checkbox" name="delete_karma" id="delete_karma" value="1">
3947 4150
 						<label for="delete_karma">', $txt['upgrade_delete_karma'], '</label>
3948 4151
 					</li>';
4152
+	}
3949 4153
 
3950 4154
 	echo '
3951 4155
 					<li>
@@ -3979,10 +4183,11 @@  discard block
 block discarded – undo
3979 4183
 					</div>';
3980 4184
 
3981 4185
 	// Dont any tables so far?
3982
-	if (!empty($upcontext['previous_tables']))
3983
-		foreach ($upcontext['previous_tables'] as $table)
4186
+	if (!empty($upcontext['previous_tables'])) {
4187
+			foreach ($upcontext['previous_tables'] as $table)
3984 4188
 			echo '
3985 4189
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4190
+	}
3986 4191
 
3987 4192
 	echo '
3988 4193
 					<h3 id="current_tab">
@@ -4021,12 +4226,13 @@  discard block
 block discarded – undo
4021 4226
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4022 4227
 
4023 4228
 		// If debug flood the screen.
4024
-		if ($is_debug)
4025
-			echo '
4229
+		if ($is_debug) {
4230
+					echo '
4026 4231
 							setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4027 4232
 
4028 4233
 							if (document.getElementById(\'debug_section\').scrollHeight)
4029 4234
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4235
+		}
4030 4236
 
4031 4237
 		echo '
4032 4238
 							// Get the next update...
@@ -4059,8 +4265,9 @@  discard block
 block discarded – undo
4059 4265
 {
4060 4266
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt;
4061 4267
 
4062
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
4063
-		$is_debug = true;
4268
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4269
+			$is_debug = true;
4270
+	}
4064 4271
 
4065 4272
 	echo '
4066 4273
 				<h3>', $txt['upgrade_db_changes'], '</h3>
@@ -4075,8 +4282,9 @@  discard block
 block discarded – undo
4075 4282
 	{
4076 4283
 		foreach ($upcontext['actioned_items'] as $num => $item)
4077 4284
 		{
4078
-			if ($num != 0)
4079
-				echo ' Successful!';
4285
+			if ($num != 0) {
4286
+							echo ' Successful!';
4287
+			}
4080 4288
 			echo '<br>' . $item;
4081 4289
 		}
4082 4290
 		if (!empty($upcontext['changes_complete']))
@@ -4089,29 +4297,33 @@  discard block
 block discarded – undo
4089 4297
 				$seconds = intval($active % 60);
4090 4298
 
4091 4299
 				$totalTime = '';
4092
-				if ($hours > 0)
4093
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4094
-				if ($minutes > 0)
4095
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4096
-				if ($seconds > 0)
4097
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4300
+				if ($hours > 0) {
4301
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4302
+				}
4303
+				if ($minutes > 0) {
4304
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4305
+				}
4306
+				if ($seconds > 0) {
4307
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4308
+				}
4098 4309
 			}
4099 4310
 
4100
-			if ($is_debug && !empty($totalTime))
4101
-				echo '', sprintf($txt['upgrade_success_time'], $totalTime), '<br>';
4102
-			else
4103
-				echo '', $txt['upgrade_success'], '<br>';
4311
+			if ($is_debug && !empty($totalTime)) {
4312
+							echo '', sprintf($txt['upgrade_success_time'], $totalTime), '<br>';
4313
+			} else {
4314
+							echo '', $txt['upgrade_success'], '<br>';
4315
+			}
4104 4316
 
4105 4317
 			echo '
4106 4318
 					<p id="commess">', $txt['upgrade_db_complete'], '</p>';
4107 4319
 		}
4108
-	}
4109
-	else
4320
+	} else
4110 4321
 	{
4111 4322
 		// Tell them how many files we have in total.
4112
-		if ($upcontext['file_count'] > 1)
4113
-			echo '
4323
+		if ($upcontext['file_count'] > 1) {
4324
+					echo '
4114 4325
 					<strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4326
+		}
4115 4327
 
4116 4328
 		echo '
4117 4329
 					<h3 id="info2">
@@ -4129,19 +4341,23 @@  discard block
 block discarded – undo
4129 4341
 				$seconds = intval($active % 60);
4130 4342
 
4131 4343
 				$totalTime = '';
4132
-				if ($hours > 0)
4133
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4134
-				if ($minutes > 0)
4135
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4136
-				if ($seconds > 0)
4137
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4344
+				if ($hours > 0) {
4345
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4346
+				}
4347
+				if ($minutes > 0) {
4348
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4349
+				}
4350
+				if ($seconds > 0) {
4351
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4352
+				}
4138 4353
 			}
4139 4354
 
4140 4355
 			echo '
4141 4356
 					<p id="upgradeCompleted">';
4142 4357
 
4143
-			if (!empty($totalTime))
4144
-				echo '', sprintf($txt['upgrade_completed_time2'], $totalTime), '';
4358
+			if (!empty($totalTime)) {
4359
+							echo '', sprintf($txt['upgrade_completed_time2'], $totalTime), '';
4360
+			}
4145 4361
 
4146 4362
 			echo '
4147 4363
 					</p>
@@ -4178,9 +4394,10 @@  discard block
 block discarded – undo
4178 4394
 						var getData = "";
4179 4395
 						var debugItems = ', $upcontext['debug_items'], ';';
4180 4396
 
4181
-		if ($is_debug)
4182
-			echo '
4397
+		if ($is_debug) {
4398
+					echo '
4183 4399
 						var upgradeStartTime = ' . $upcontext['started'] . ';';
4400
+		}
4184 4401
 
4185 4402
 		echo '
4186 4403
 						function getNextItem()
@@ -4220,9 +4437,10 @@  discard block
 block discarded – undo
4220 4437
 									document.getElementById("error_block").style.display = "";
4221 4438
 									setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4222 4439
 
4223
-	if ($is_debug)
4224
-		echo '
4440
+	if ($is_debug) {
4441
+			echo '
4225 4442
 									setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4443
+	}
4226 4444
 
4227 4445
 	echo '
4228 4446
 								}
@@ -4243,9 +4461,10 @@  discard block
 block discarded – undo
4243 4461
 									document.getElementById("error_block").style.display = "";
4244 4462
 									setInnerHTML(document.getElementById("error_message"), "', $txt['upgrade_loop'], '" + sDebugName);';
4245 4463
 
4246
-	if ($is_debug)
4247
-		echo '
4464
+	if ($is_debug) {
4465
+			echo '
4248 4466
 									setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4467
+	}
4249 4468
 
4250 4469
 	echo '
4251 4470
 								}
@@ -4302,8 +4521,8 @@  discard block
 block discarded – undo
4302 4521
 							if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4303 4522
 							{';
4304 4523
 
4305
-		if ($is_debug)
4306
-			echo '
4524
+		if ($is_debug) {
4525
+					echo '
4307 4526
 								document.getElementById(\'debug_section\').style.display = "none";
4308 4527
 
4309 4528
 								var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4321,6 +4540,7 @@  discard block
 block discarded – undo
4321 4540
 									totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4322 4541
 
4323 4542
 								setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4543
+		}
4324 4544
 
4325 4545
 		echo '
4326 4546
 
@@ -4328,9 +4548,10 @@  discard block
 block discarded – undo
4328 4548
 								document.getElementById(\'contbutt\').disabled = 0;
4329 4549
 								document.getElementById(\'database_done\').value = 1;';
4330 4550
 
4331
-		if ($upcontext['file_count'] > 1)
4332
-			echo '
4551
+		if ($upcontext['file_count'] > 1) {
4552
+					echo '
4333 4553
 								document.getElementById(\'info1\').style.display = "none";';
4554
+		}
4334 4555
 
4335 4556
 		echo '
4336 4557
 								document.getElementById(\'info2\').style.display = "none";
@@ -4343,9 +4564,10 @@  discard block
 block discarded – undo
4343 4564
 								lastItem = 0;
4344 4565
 								prevFile = curFile;';
4345 4566
 
4346
-		if ($is_debug)
4347
-			echo '
4567
+		if ($is_debug) {
4568
+					echo '
4348 4569
 								setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4570
+		}
4349 4571
 
4350 4572
 		echo '
4351 4573
 								getNextItem();
@@ -4353,8 +4575,8 @@  discard block
 block discarded – undo
4353 4575
 							}';
4354 4576
 
4355 4577
 		// If debug scroll the screen.
4356
-		if ($is_debug)
4357
-			echo '
4578
+		if ($is_debug) {
4579
+					echo '
4358 4580
 							if (iLastSubStepProgress == -1)
4359 4581
 							{
4360 4582
 								// Give it consistent dots.
@@ -4373,6 +4595,7 @@  discard block
 block discarded – undo
4373 4595
 
4374 4596
 							if (document.getElementById(\'debug_section\').scrollHeight)
4375 4597
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4598
+		}
4376 4599
 
4377 4600
 		echo '
4378 4601
 							// Update the page.
@@ -4433,9 +4656,10 @@  discard block
 block discarded – undo
4433 4656
 						}';
4434 4657
 
4435 4658
 		// Start things off assuming we've not errored.
4436
-		if (empty($upcontext['error_message']))
4437
-			echo '
4659
+		if (empty($upcontext['error_message'])) {
4660
+					echo '
4438 4661
 						getNextItem();';
4662
+		}
4439 4663
 
4440 4664
 		echo '
4441 4665
 					//# sourceURL=dynamicScript-dbch.js
@@ -4453,18 +4677,21 @@  discard block
 block discarded – undo
4453 4677
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4454 4678
 	<debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>';
4455 4679
 
4456
-	if (!empty($upcontext['error_message']))
4457
-		echo '
4680
+	if (!empty($upcontext['error_message'])) {
4681
+			echo '
4458 4682
 	<error>', $upcontext['error_message'], '</error>';
4683
+	}
4459 4684
 
4460
-	if (!empty($upcontext['error_string']))
4461
-		echo '
4685
+	if (!empty($upcontext['error_string'])) {
4686
+			echo '
4462 4687
 	<sql>', $upcontext['error_string'], '</sql>';
4688
+	}
4463 4689
 
4464
-	if ($is_debug)
4465
-		echo '
4690
+	if ($is_debug) {
4691
+			echo '
4466 4692
 	<curtime>', time(), '</curtime>';
4467
-}
4693
+	}
4694
+	}
4468 4695
 
4469 4696
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4470 4697
 function template_convert_utf8()
@@ -4481,10 +4708,11 @@  discard block
 block discarded – undo
4481 4708
 					</div>';
4482 4709
 
4483 4710
 	// Done any tables so far?
4484
-	if (!empty($upcontext['previous_tables']))
4485
-		foreach ($upcontext['previous_tables'] as $table)
4711
+	if (!empty($upcontext['previous_tables'])) {
4712
+			foreach ($upcontext['previous_tables'] as $table)
4486 4713
 			echo '
4487 4714
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4715
+	}
4488 4716
 
4489 4717
 	echo '
4490 4718
 					<h3 id="current_tab">
@@ -4492,9 +4720,10 @@  discard block
 block discarded – undo
4492 4720
 					</h3>';
4493 4721
 
4494 4722
 	// If we dropped their index, let's let them know
4495
-	if ($upcontext['dropping_index'])
4496
-		echo '
4723
+	if ($upcontext['dropping_index']) {
4724
+			echo '
4497 4725
 					<p id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</p>';
4726
+	}
4498 4727
 
4499 4728
 	// Completion notification
4500 4729
 	echo '
@@ -4531,12 +4760,13 @@  discard block
 block discarded – undo
4531 4760
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4532 4761
 
4533 4762
 		// If debug flood the screen.
4534
-		if ($is_debug)
4535
-			echo '
4763
+		if ($is_debug) {
4764
+					echo '
4536 4765
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4537 4766
 
4538 4767
 						if (document.getElementById(\'debug_section\').scrollHeight)
4539 4768
 							document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4769
+		}
4540 4770
 
4541 4771
 		echo '
4542 4772
 						// Get the next update...
@@ -4582,10 +4812,11 @@  discard block
 block discarded – undo
4582 4812
 					</div>';
4583 4813
 
4584 4814
 	// Dont any tables so far?
4585
-	if (!empty($upcontext['previous_tables']))
4586
-		foreach ($upcontext['previous_tables'] as $table)
4815
+	if (!empty($upcontext['previous_tables'])) {
4816
+			foreach ($upcontext['previous_tables'] as $table)
4587 4817
 			echo '
4588 4818
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4819
+	}
4589 4820
 
4590 4821
 	echo '
4591 4822
 					<h3 id="current_tab">
@@ -4594,9 +4825,10 @@  discard block
 block discarded – undo
4594 4825
 					<p id="commess" style="display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</p>';
4595 4826
 
4596 4827
 	// Try to make sure substep was reset.
4597
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4598
-		echo '
4828
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4829
+			echo '
4599 4830
 					<input type="hidden" name="substep" id="substep" value="0">';
4831
+	}
4600 4832
 
4601 4833
 	// Continue please!
4602 4834
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4629,12 +4861,13 @@  discard block
 block discarded – undo
4629 4861
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4630 4862
 
4631 4863
 		// If debug flood the screen.
4632
-		if ($is_debug)
4633
-			echo '
4864
+		if ($is_debug) {
4865
+					echo '
4634 4866
 							setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4635 4867
 
4636 4868
 							if (document.getElementById(\'debug_section\').scrollHeight)
4637 4869
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4870
+		}
4638 4871
 
4639 4872
 		echo '
4640 4873
 							// Get the next update...
@@ -4670,8 +4903,8 @@  discard block
 block discarded – undo
4670 4903
 				<h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>.  ', $txt['upgrade_done3'], '</h3>
4671 4904
 				<form action="', $boardurl, '/index.php">';
4672 4905
 
4673
-	if (!empty($upcontext['can_delete_script']))
4674
-		echo '
4906
+	if (!empty($upcontext['can_delete_script'])) {
4907
+			echo '
4675 4908
 					<label>
4676 4909
 						<input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '
4677 4910
 					</label>
@@ -4685,6 +4918,7 @@  discard block
 block discarded – undo
4685 4918
 						}
4686 4919
 					</script>
4687 4920
 					<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4921
+	}
4688 4922
 
4689 4923
 	$active = time() - $upcontext['started'];
4690 4924
 	$hours = floor($active / 3600);
@@ -4694,17 +4928,21 @@  discard block
 block discarded – undo
4694 4928
 	if ($is_debug)
4695 4929
 	{
4696 4930
 		$totalTime = '';
4697
-		if ($hours > 0)
4698
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4699
-		if ($minutes > 0)
4700
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4701
-		if ($seconds > 0)
4702
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4931
+		if ($hours > 0) {
4932
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4933
+		}
4934
+		if ($minutes > 0) {
4935
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4936
+		}
4937
+		if ($seconds > 0) {
4938
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4939
+		}
4703 4940
 	}
4704 4941
 
4705
-	if ($is_debug && !empty($totalTime))
4706
-		echo '
4942
+	if ($is_debug && !empty($totalTime)) {
4943
+			echo '
4707 4944
 					<p> ', $txt['upgrade_completed_time'], ' ', $totalTime, '</p>';
4945
+	}
4708 4946
 
4709 4947
 	echo '
4710 4948
 					<p>
@@ -4733,8 +4971,9 @@  discard block
 block discarded – undo
4733 4971
 
4734 4972
 	$current_substep = $_GET['substep'];
4735 4973
 
4736
-	if (empty($_GET['a']))
4737
-		$_GET['a'] = 0;
4974
+	if (empty($_GET['a'])) {
4975
+			$_GET['a'] = 0;
4976
+	}
4738 4977
 	$step_progress['name'] = 'Converting ips';
4739 4978
 	$step_progress['current'] = $_GET['a'];
4740 4979
 
@@ -4777,16 +5016,19 @@  discard block
 block discarded – undo
4777 5016
 				'empty' => '',
4778 5017
 				'limit' => $limit,
4779 5018
 		));
4780
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4781
-			$arIp[] = $row[$oldCol];
5019
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5020
+					$arIp[] = $row[$oldCol];
5021
+		}
4782 5022
 		$smcFunc['db_free_result']($request);
4783 5023
 
4784 5024
 		// Special case, null ip could keep us in a loop.
4785
-		if (is_null($arIp[0]))
4786
-			unset($arIp[0]);
5025
+		if (is_null($arIp[0])) {
5026
+					unset($arIp[0]);
5027
+		}
4787 5028
 
4788
-		if (empty($arIp))
4789
-			$is_done = true;
5029
+		if (empty($arIp)) {
5030
+					$is_done = true;
5031
+		}
4790 5032
 
4791 5033
 		$updates = array();
4792 5034
 		$cases = array();
@@ -4795,16 +5037,18 @@  discard block
 block discarded – undo
4795 5037
 		{
4796 5038
 			$arIp[$i] = trim($arIp[$i]);
4797 5039
 
4798
-			if (empty($arIp[$i]))
4799
-				continue;
5040
+			if (empty($arIp[$i])) {
5041
+							continue;
5042
+			}
4800 5043
 
4801 5044
 			$updates['ip' . $i] = $arIp[$i];
4802 5045
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4803 5046
 
4804 5047
 			if ($setSize > 0 && $i % $setSize === 0)
4805 5048
 			{
4806
-				if (count($updates) == 1)
4807
-					continue;
5049
+				if (count($updates) == 1) {
5050
+									continue;
5051
+				}
4808 5052
 
4809 5053
 				$updates['whereSet'] = array_values($updates);
4810 5054
 				$smcFunc['db_query']('', '
@@ -4838,8 +5082,7 @@  discard block
 block discarded – undo
4838 5082
 							'ip' => $ip
4839 5083
 					));
4840 5084
 				}
4841
-			}
4842
-			else
5085
+			} else
4843 5086
 			{
4844 5087
 				$updates['whereSet'] = array_values($updates);
4845 5088
 				$smcFunc['db_query']('', '
@@ -4853,9 +5096,9 @@  discard block
 block discarded – undo
4853 5096
 					$updates
4854 5097
 				);
4855 5098
 			}
5099
+		} else {
5100
+					$is_done = true;
4856 5101
 		}
4857
-		else
4858
-			$is_done = true;
4859 5102
 
4860 5103
 		$_GET['a'] += $limit;
4861 5104
 		$step_progress['current'] = $_GET['a'];
@@ -4881,10 +5124,11 @@  discard block
 block discarded – undo
4881 5124
 
4882 5125
 	$columns = $smcFunc['db_list_columns']($targetTable, true);
4883 5126
 
4884
-	if (isset($columns[$column]))
4885
-		return $columns[$column];
4886
-	else
4887
-		return null;
4888
-}
5127
+	if (isset($columns[$column])) {
5128
+			return $columns[$column];
5129
+	} else {
5130
+			return null;
5131
+	}
5132
+	}
4889 5133
 
4890 5134
 ?>
4891 5135
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Search.template.php 1 patch
Braces   +75 added lines, -55 removed lines patch added patch discarded remove patch
@@ -20,17 +20,19 @@  discard block
 block discarded – undo
20 20
 	echo '
21 21
 	<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">';
22 22
 
23
-	if (!empty($context['search_errors']))
24
-		echo '
23
+	if (!empty($context['search_errors'])) {
24
+			echo '
25 25
 		<div class="errorbox">
26 26
 			', implode('<br>', $context['search_errors']['messages']), '
27 27
 		</div>';
28
+	}
28 29
 
29
-	if (!empty($context['search_ignored']))
30
-		echo '
30
+	if (!empty($context['search_ignored'])) {
31
+			echo '
31 32
 		<div class="noticebox">
32 33
 			', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
33 34
 		</div>';
35
+	}
34 36
 
35 37
 	echo '
36 38
 		<div class="cat_bar">
@@ -48,9 +50,10 @@  discard block
 block discarded – undo
48 50
 				<dd>
49 51
 					<input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">';
50 52
 
51
-	if (empty($modSettings['search_simple_fulltext']))
52
-		echo '
53
+	if (empty($modSettings['search_simple_fulltext'])) {
54
+			echo '
53 55
 					<br><em class="smalltext">', $txt['search_example'], '</em>';
56
+	}
54 57
 
55 58
 	echo '
56 59
 				</dd>
@@ -114,21 +117,23 @@  discard block
 block discarded – undo
114 117
 			<input type="hidden" name="advanced" value="1">';
115 118
 
116 119
 	// Require an image to be typed to save spamming?
117
-	if ($context['require_verification'])
118
-		echo '
120
+	if ($context['require_verification']) {
121
+			echo '
119 122
 			<p>
120 123
 				<strong>', $txt['verification'], ':</strong>
121 124
 				', template_control_verification($context['visual_verification_id'], 'all'), '
122 125
 			</p>';
126
+	}
123 127
 
124 128
 	// If $context['search_params']['topic'] is set, that means we're searching just one topic.
125
-	if (!empty($context['search_params']['topic']))
126
-		echo '
129
+	if (!empty($context['search_params']['topic'])) {
130
+			echo '
127 131
 			<p>
128 132
 				', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.
129 133
 			</p>
130 134
 			<input type="hidden" name="topic" value="', $context['search_topic']['id'], '">
131 135
 			<input type="submit" name="b_search" value="', $txt['search'], '" class="button">';
136
+	}
132 137
 
133 138
 	echo '
134 139
 		</div>';
@@ -238,17 +243,19 @@  discard block
 block discarded – undo
238 243
 		<div class="roundframe">';
239 244
 
240 245
 		// Did they make any typos or mistakes, perhaps?
241
-		if (isset($context['did_you_mean']))
242
-			echo '
246
+		if (isset($context['did_you_mean'])) {
247
+					echo '
243 248
 			<p>
244 249
 				', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.
245 250
 			</p>';
251
+		}
246 252
 
247
-		if (!empty($context['search_ignored']))
248
-			echo '
253
+		if (!empty($context['search_ignored'])) {
254
+					echo '
249 255
 			<p>
250 256
 				', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
251 257
 			</p>';
258
+		}
252 259
 
253 260
 		echo '
254 261
 			<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -271,10 +278,11 @@  discard block
 block discarded – undo
271 278
 					<input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '">
272 279
 				</div>';
273 280
 
274
-		if (!empty($context['search_params']['brd']))
275
-			foreach ($context['search_params']['brd'] as $board_id)
281
+		if (!empty($context['search_params']['brd'])) {
282
+					foreach ($context['search_params']['brd'] as $board_id)
276 283
 				echo '
277 284
 				<input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">';
285
+		}
278 286
 
279 287
 		echo '
280 288
 			</form>
@@ -285,18 +293,20 @@  discard block
 block discarded – undo
285 293
 	if ($context['compact'])
286 294
 	{
287 295
 		// Quick moderation set to checkboxes? Oh, how fun :/
288
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
289
-			echo '
296
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
297
+					echo '
290 298
 	<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">';
299
+		}
291 300
 
292 301
 		echo '
293 302
 		<div class="cat_bar">
294 303
 			<h3 class="catbg">
295 304
 				<span class="floatright">';
296 305
 
297
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
298
-			echo '
306
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
307
+					echo '
299 308
 					<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">';
309
+		}
300 310
 		echo '
301 311
 				</span>
302 312
 				<span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], '
@@ -304,15 +314,15 @@  discard block
 block discarded – undo
304 314
 		</div>';
305 315
 
306 316
 		// Was anything even found?
307
-		if (!empty($context['topics']))
308
-			echo '
317
+		if (!empty($context['topics'])) {
318
+					echo '
309 319
 		<div class="pagesection">
310 320
 			<span>', $context['page_index'], '</span>
311 321
 		</div>';
312
-
313
-		else
314
-			echo '
322
+		} else {
323
+					echo '
315 324
 		<div class="roundframe noup">', $txt['find_no_results'], '</div>';
325
+		}
316 326
 
317 327
 		// While we have results to show ...
318 328
 		while ($topic = $context['get_topics']())
@@ -335,31 +345,35 @@  discard block
 block discarded – undo
335 345
 					echo '
336 346
 				<span class="floatright">';
337 347
 
338
-					if ($options['display_quick_mod'] == 1)
339
-						echo '
348
+					if ($options['display_quick_mod'] == 1) {
349
+											echo '
340 350
 					<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
341
-
342
-					else
351
+					} else
343 352
 					{
344
-						if ($topic['quick_mod']['remove'])
345
-							echo '
353
+						if ($topic['quick_mod']['remove']) {
354
+													echo '
346 355
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
356
+						}
347 357
 
348
-						if ($topic['quick_mod']['lock'])
349
-							echo '
358
+						if ($topic['quick_mod']['lock']) {
359
+													echo '
350 360
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
361
+						}
351 362
 
352
-						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
353
-							echo '
363
+						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
364
+													echo '
354 365
 					<br>';
366
+						}
355 367
 
356
-						if ($topic['quick_mod']['sticky'])
357
-							echo '
368
+						if ($topic['quick_mod']['sticky']) {
369
+													echo '
358 370
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
371
+						}
359 372
 
360
-						if ($topic['quick_mod']['move'])
361
-							echo '
373
+						if ($topic['quick_mod']['move']) {
374
+													echo '
362 375
 					<a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
376
+						}
363 377
 					}
364 378
 
365 379
 					echo '
@@ -369,20 +383,22 @@  discard block
 block discarded – undo
369 383
 			echo '
370 384
 			</div><!-- .block -->';
371 385
 
372
-				if ($message['body_highlighted'] != '')
373
-					echo '
386
+				if ($message['body_highlighted'] != '') {
387
+									echo '
374 388
 				<div class="list_posts double_height">', $message['body_highlighted'], '</div>';
389
+				}
375 390
 			}
376 391
 
377 392
 			echo '
378 393
 		</div><!-- $topic[css_class] -->';
379 394
 		}
380 395
 
381
-		if (!empty($context['topics']))
382
-			echo '
396
+		if (!empty($context['topics'])) {
397
+					echo '
383 398
 		<div class="pagesection">
384 399
 			<span>', $context['page_index'], '</span>
385 400
 		</div>';
401
+		}
386 402
 
387 403
 		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
388 404
 		{
@@ -391,17 +407,19 @@  discard block
 block discarded – undo
391 407
 			<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
392 408
 				<option value="">--------</option>';
393 409
 
394
-			foreach ($context['qmod_actions'] as $qmod_action)
395
-				if ($context['can_' . $qmod_action])
410
+			foreach ($context['qmod_actions'] as $qmod_action) {
411
+							if ($context['can_' . $qmod_action])
396 412
 					echo '
397 413
 				<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
414
+			}
398 415
 
399 416
 			echo '
400 417
 			</select>';
401 418
 
402
-			if ($context['can_move'])
403
-				echo '
419
+			if ($context['can_move']) {
420
+							echo '
404 421
 			<span id="quick_mod_jump_to"></span>';
422
+			}
405 423
 
406 424
 			echo '
407 425
 			<input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '">
@@ -410,12 +428,12 @@  discard block
 block discarded – undo
410 428
 		}
411 429
 
412 430
 
413
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
414
-			echo '
431
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) {
432
+					echo '
415 433
 		<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
416 434
 	</form>';
417
-	}
418
-	else
435
+		}
436
+	} else
419 437
 	{
420 438
 		echo '
421 439
 	<div class="cat_bar">
@@ -427,9 +445,10 @@  discard block
 block discarded – undo
427 445
 		<span>', $context['page_index'], '</span>
428 446
 	</div>';
429 447
 
430
-		if (empty($context['topics']))
431
-			echo '
448
+		if (empty($context['topics'])) {
449
+					echo '
432 450
 	<div class="information">(', $txt['search_no_results'], ')</div>';
451
+		}
433 452
 
434 453
 		while ($topic = $context['get_topics']())
435 454
 		{
@@ -464,8 +483,8 @@  discard block
 block discarded – undo
464 483
 	<div class="smalltext righttext" id="search_jump_to"></div>
465 484
 	<script>';
466 485
 
467
-	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
468
-		echo '
486
+	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
487
+			echo '
469 488
 		if (typeof(window.XMLHttpRequest) != "undefined")
470 489
 			aJumpTo[aJumpTo.length] = new JumpTo({
471 490
 				sContainerId: "quick_mod_jump_to",
@@ -480,6 +499,7 @@  discard block
 block discarded – undo
480 499
 				bDisabled: true,
481 500
 				sCustomName: "move_to"
482 501
 			});';
502
+	}
483 503
 
484 504
 	echo '
485 505
 		if (typeof(window.XMLHttpRequest) != "undefined")
Please login to merge, or discard this patch.
Sources/Profile-Modify.php 1 patch
Braces   +710 added lines, -533 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * This defines every profile field known to man.
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $sourcedir, $profile_vars;
30 31
 
31 32
 	// Don't load this twice!
32
-	if (!empty($profile_fields) && !$force_reload)
33
-		return;
33
+	if (!empty($profile_fields) && !$force_reload) {
34
+			return;
35
+	}
34 36
 
35 37
 	/* This horrific array defines all the profile fields in the whole world!
36 38
 		In general each "field" has one array - the key of which is the database column name associated with said field. Each item
@@ -103,13 +105,14 @@  discard block
 block discarded – undo
103 105
 				if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0)
104 106
 				{
105 107
 					// Set to blank?
106
-					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1)
107
-						$value = '1004-01-01';
108
-					else
109
-						$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
108
+					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) {
109
+											$value = '1004-01-01';
110
+					} else {
111
+											$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
112
+					}
113
+				} else {
114
+									$value = '1004-01-01';
110 115
 				}
111
-				else
112
-					$value = '1004-01-01';
113 116
 
114 117
 				$profile_vars['birthdate'] = $value;
115 118
 				$cur_profile['birthdate'] = $value;
@@ -127,8 +130,7 @@  discard block
 block discarded – undo
127 130
 				{
128 131
 					$value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01';
129 132
 					return true;
130
-				}
131
-				else
133
+				} else
132 134
 				{
133 135
 					$value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate'];
134 136
 					return false;
@@ -150,10 +152,11 @@  discard block
 block discarded – undo
150 152
 					return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false));
151 153
 				}
152 154
 				// As long as it doesn't equal "N/A"...
153
-				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600)))
154
-					$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
155
-				else
156
-					$value = $cur_profile['date_registered'];
155
+				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) {
156
+									$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
157
+				} else {
158
+									$value = $cur_profile['date_registered'];
159
+				}
157 160
 
158 161
 				return true;
159 162
 			},
@@ -177,8 +180,9 @@  discard block
 block discarded – undo
177 180
 			{
178 181
 				global $context, $old_profile, $profile_vars, $sourcedir, $modSettings;
179 182
 
180
-				if (strtolower($value) == strtolower($old_profile['email_address']))
181
-					return false;
183
+				if (strtolower($value) == strtolower($old_profile['email_address'])) {
184
+									return false;
185
+				}
182 186
 
183 187
 				$isValid = profileValidateEmail($value, $context['id_member']);
184 188
 
@@ -254,11 +258,11 @@  discard block
 block discarded – undo
254 258
 
255 259
 				if (isset($context['profile_languages'][$value]))
256 260
 				{
257
-					if ($context['user']['is_owner'] && empty($context['password_auth_failed']))
258
-						$_SESSION['language'] = $value;
261
+					if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) {
262
+											$_SESSION['language'] = $value;
263
+					}
259 264
 					return true;
260
-				}
261
-				else
265
+				} else
262 266
 				{
263 267
 					$value = $cur_profile['lngfile'];
264 268
 					return false;
@@ -282,13 +286,14 @@  discard block
 block discarded – undo
282 286
 
283 287
 					// Maybe they are trying to change their password as well?
284 288
 					$resetPassword = true;
285
-					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null)
286
-						$resetPassword = false;
289
+					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) {
290
+											$resetPassword = false;
291
+					}
287 292
 
288 293
 					// Do the reset... this will send them an email too.
289
-					if ($resetPassword)
290
-						resetPassword($context['id_member'], $value);
291
-					elseif ($value !== null)
294
+					if ($resetPassword) {
295
+											resetPassword($context['id_member'], $value);
296
+					} elseif ($value !== null)
292 297
 					{
293 298
 						validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)));
294 299
 						updateMemberData($context['id_member'], array('member_name' => $value));
@@ -312,20 +317,23 @@  discard block
 block discarded – undo
312 317
 			'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile)
313 318
 			{
314 319
 				// If we didn't try it then ignore it!
315
-				if ($value == '')
316
-					return false;
320
+				if ($value == '') {
321
+									return false;
322
+				}
317 323
 
318 324
 				// Do the two entries for the password even match?
319
-				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2'])
320
-					return 'bad_new_password';
325
+				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) {
326
+									return 'bad_new_password';
327
+				}
321 328
 
322 329
 				// Let's get the validation function into play...
323 330
 				require_once($sourcedir . '/Subs-Auth.php');
324 331
 				$passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email']));
325 332
 
326 333
 				// Were there errors?
327
-				if ($passwordErrors != null)
328
-					return 'password_' . $passwordErrors;
334
+				if ($passwordErrors != null) {
335
+									return 'password_' . $passwordErrors;
336
+				}
329 337
 
330 338
 				// Set up the new password variable... ready for storage.
331 339
 				$value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value));
@@ -350,8 +358,9 @@  discard block
 block discarded – undo
350 358
 			'permission' => 'profile_blurb',
351 359
 			'input_validate' => function(&$value) use ($smcFunc)
352 360
 			{
353
-				if ($smcFunc['strlen']($value) > 50)
354
-					return 'personal_text_too_long';
361
+				if ($smcFunc['strlen']($value) > 50) {
362
+									return 'personal_text_too_long';
363
+				}
355 364
 
356 365
 				return true;
357 366
 			},
@@ -386,10 +395,11 @@  discard block
 block discarded – undo
386 395
 			'permission' => 'moderate_forum',
387 396
 			'input_validate' => function(&$value)
388 397
 			{
389
-				if (!is_numeric($value))
390
-					return 'digits_only';
391
-				else
392
-					$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
398
+				if (!is_numeric($value)) {
399
+									return 'digits_only';
400
+				} else {
401
+									$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
402
+				}
393 403
 				return true;
394 404
 			},
395 405
 		),
@@ -405,15 +415,16 @@  discard block
 block discarded – undo
405 415
 			{
406 416
 				$value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value));
407 417
 
408
-				if (trim($value) == '')
409
-					return 'no_name';
410
-				elseif ($smcFunc['strlen']($value) > 60)
411
-					return 'name_too_long';
412
-				elseif ($cur_profile['real_name'] != $value)
418
+				if (trim($value) == '') {
419
+									return 'no_name';
420
+				} elseif ($smcFunc['strlen']($value) > 60) {
421
+									return 'name_too_long';
422
+				} elseif ($cur_profile['real_name'] != $value)
413 423
 				{
414 424
 					require_once($sourcedir . '/Subs-Members.php');
415
-					if (isReservedName($value, $context['id_member']))
416
-						return 'name_taken';
425
+					if (isReservedName($value, $context['id_member'])) {
426
+											return 'name_taken';
427
+					}
417 428
 				}
418 429
 				return true;
419 430
 			},
@@ -471,8 +482,9 @@  discard block
 block discarded – undo
471 482
 						'selected' => $set == $context['member']['smiley_set']['id']
472 483
 					);
473 484
 
474
-					if ($context['smiley_sets'][$i]['selected'])
475
-						$context['member']['smiley_set']['name'] = $set_names[$i];
485
+					if ($context['smiley_sets'][$i]['selected']) {
486
+											$context['member']['smiley_set']['name'] = $set_names[$i];
487
+					}
476 488
 				}
477 489
 				return true;
478 490
 			},
@@ -481,8 +493,9 @@  discard block
 block discarded – undo
481 493
 				global $modSettings;
482 494
 
483 495
 				$smiley_sets = explode(',', $modSettings['smiley_sets_known']);
484
-				if (!in_array($value, $smiley_sets) && $value != 'none')
485
-					$value = '';
496
+				if (!in_array($value, $smiley_sets) && $value != 'none') {
497
+									$value = '';
498
+				}
486 499
 				return true;
487 500
 			},
488 501
 		),
@@ -497,8 +510,9 @@  discard block
 block discarded – undo
497 510
 				loadLanguage('Settings');
498 511
 
499 512
 				$context['allow_no_censored'] = false;
500
-				if ($user_info['is_admin'] || $context['user']['is_owner'])
501
-					$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
513
+				if ($user_info['is_admin'] || $context['user']['is_owner']) {
514
+									$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
515
+				}
502 516
 
503 517
 				return true;
504 518
 			},
@@ -545,8 +559,9 @@  discard block
 block discarded – undo
545 559
 			'input_validate' => function($value)
546 560
 			{
547 561
 				$tz = smf_list_timezones();
548
-				if (!isset($tz[$value]))
549
-					return 'bad_timezone';
562
+				if (!isset($tz[$value])) {
563
+									return 'bad_timezone';
564
+				}
550 565
 
551 566
 				return true;
552 567
 			},
@@ -561,8 +576,9 @@  discard block
 block discarded – undo
561 576
 			'enabled' => !empty($modSettings['titlesEnable']),
562 577
 			'input_validate' => function(&$value) use ($smcFunc)
563 578
 			{
564
-				if ($smcFunc['strlen']($value) > 50)
565
-					return 'user_title_too_long';
579
+				if ($smcFunc['strlen']($value) > 50) {
580
+									return 'user_title_too_long';
581
+				}
566 582
 
567 583
 				return true;
568 584
 			},
@@ -584,10 +600,12 @@  discard block
 block discarded – undo
584 600
 			// Fix the URL...
585 601
 			'input_validate' => function(&$value)
586 602
 			{
587
-				if (strlen(trim($value)) > 0 && strpos($value, '://') === false)
588
-					$value = 'http://' . $value;
589
-				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://'))
590
-					$value = '';
603
+				if (strlen(trim($value)) > 0 && strpos($value, '://') === false) {
604
+									$value = 'http://' . $value;
605
+				}
606
+				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) {
607
+									$value = '';
608
+				}
591 609
 				$value = (string) validate_iri(sanitize_iri($value));
592 610
 				return true;
593 611
 			},
@@ -602,16 +620,19 @@  discard block
 block discarded – undo
602 620
 	foreach ($profile_fields as $key => $field)
603 621
 	{
604 622
 		// Do we have permission to do this?
605
-		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission']))
606
-			unset($profile_fields[$key]);
623
+		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) {
624
+					unset($profile_fields[$key]);
625
+		}
607 626
 
608 627
 		// Is it enabled?
609
-		if (isset($field['enabled']) && !$field['enabled'])
610
-			unset($profile_fields[$key]);
628
+		if (isset($field['enabled']) && !$field['enabled']) {
629
+					unset($profile_fields[$key]);
630
+		}
611 631
 
612 632
 		// Is it specifically disabled?
613
-		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields)))
614
-			unset($profile_fields[$key]);
633
+		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) {
634
+					unset($profile_fields[$key]);
635
+		}
615 636
 	}
616 637
 }
617 638
 
@@ -636,9 +657,10 @@  discard block
 block discarded – undo
636 657
 	loadProfileFields(true);
637 658
 
638 659
 	// First check for any linked sets.
639
-	foreach ($profile_fields as $key => $field)
640
-		if (isset($field['link_with']) && in_array($field['link_with'], $fields))
660
+	foreach ($profile_fields as $key => $field) {
661
+			if (isset($field['link_with']) && in_array($field['link_with'], $fields))
641 662
 			$fields[] = $key;
663
+	}
642 664
 
643 665
 	$i = 0;
644 666
 	$last_type = '';
@@ -650,38 +672,46 @@  discard block
 block discarded – undo
650 672
 			$cur_field = &$profile_fields[$field];
651 673
 
652 674
 			// Does it have a preload and does that preload succeed?
653
-			if (isset($cur_field['preload']) && !$cur_field['preload']())
654
-				continue;
675
+			if (isset($cur_field['preload']) && !$cur_field['preload']()) {
676
+							continue;
677
+			}
655 678
 
656 679
 			// If this is anything but complex we need to do more cleaning!
657 680
 			if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden')
658 681
 			{
659
-				if (!isset($cur_field['label']))
660
-					$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
682
+				if (!isset($cur_field['label'])) {
683
+									$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
684
+				}
661 685
 
662 686
 				// Everything has a value!
663
-				if (!isset($cur_field['value']))
664
-					$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
687
+				if (!isset($cur_field['value'])) {
688
+									$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
689
+				}
665 690
 
666 691
 				// Any input attributes?
667 692
 				$cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : '';
668 693
 			}
669 694
 
670 695
 			// Was there an error with this field on posting?
671
-			if (isset($context['profile_errors'][$field]))
672
-				$cur_field['is_error'] = true;
696
+			if (isset($context['profile_errors'][$field])) {
697
+							$cur_field['is_error'] = true;
698
+			}
673 699
 
674 700
 			// Any javascript stuff?
675
-			if (!empty($cur_field['js_submit']))
676
-				$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
677
-			if (!empty($cur_field['js']))
678
-				$context['profile_javascript'] .= $cur_field['js'];
701
+			if (!empty($cur_field['js_submit'])) {
702
+							$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
703
+			}
704
+			if (!empty($cur_field['js'])) {
705
+							$context['profile_javascript'] .= $cur_field['js'];
706
+			}
679 707
 
680 708
 			// Any template stuff?
681
-			if (!empty($cur_field['prehtml']))
682
-				$context['profile_prehtml'] .= $cur_field['prehtml'];
683
-			if (!empty($cur_field['posthtml']))
684
-				$context['profile_posthtml'] .= $cur_field['posthtml'];
709
+			if (!empty($cur_field['prehtml'])) {
710
+							$context['profile_prehtml'] .= $cur_field['prehtml'];
711
+			}
712
+			if (!empty($cur_field['posthtml'])) {
713
+							$context['profile_posthtml'] .= $cur_field['posthtml'];
714
+			}
685 715
 
686 716
 			// Finally put it into context?
687 717
 			if ($cur_field['type'] != 'hidden')
@@ -714,12 +744,14 @@  discard block
 block discarded – undo
714 744
 	}, false);' : ''), true);
715 745
 
716 746
 	// Any onsubmit javascript?
717
-	if (!empty($context['profile_onsubmit_javascript']))
718
-		addInlineJavaScript($context['profile_onsubmit_javascript'], true);
747
+	if (!empty($context['profile_onsubmit_javascript'])) {
748
+			addInlineJavaScript($context['profile_onsubmit_javascript'], true);
749
+	}
719 750
 
720 751
 	// Any totally custom stuff?
721
-	if (!empty($context['profile_javascript']))
722
-		addInlineJavaScript($context['profile_javascript'], true);
752
+	if (!empty($context['profile_javascript'])) {
753
+			addInlineJavaScript($context['profile_javascript'], true);
754
+	}
723 755
 
724 756
 	// Free up some memory.
725 757
 	unset($profile_fields);
@@ -740,8 +772,9 @@  discard block
 block discarded – undo
740 772
 
741 773
 	// This allows variables to call activities when they save - by default just to reload their settings
742 774
 	$context['profile_execute_on_save'] = array();
743
-	if ($context['user']['is_owner'])
744
-		$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
775
+	if ($context['user']['is_owner']) {
776
+			$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
777
+	}
745 778
 
746 779
 	// Assume we log nothing.
747 780
 	$context['log_changes'] = array();
@@ -749,8 +782,9 @@  discard block
 block discarded – undo
749 782
 	// Cycle through the profile fields working out what to do!
750 783
 	foreach ($profile_fields as $key => $field)
751 784
 	{
752
-		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature'))
753
-			continue;
785
+		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) {
786
+					continue;
787
+		}
754 788
 
755 789
 		// What gets updated?
756 790
 		$db_key = isset($field['save_key']) ? $field['save_key'] : $key;
@@ -778,12 +812,13 @@  discard block
 block discarded – undo
778 812
 		$field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type'];
779 813
 
780 814
 		// Finally, clean up certain types.
781
-		if ($field['cast_type'] == 'int')
782
-			$_POST[$key] = (int) $_POST[$key];
783
-		elseif ($field['cast_type'] == 'float')
784
-			$_POST[$key] = (float) $_POST[$key];
785
-		elseif ($field['cast_type'] == 'check')
786
-			$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
815
+		if ($field['cast_type'] == 'int') {
816
+					$_POST[$key] = (int) $_POST[$key];
817
+		} elseif ($field['cast_type'] == 'float') {
818
+					$_POST[$key] = (float) $_POST[$key];
819
+		} elseif ($field['cast_type'] == 'check') {
820
+					$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
821
+		}
787 822
 
788 823
 		// If we got here we're doing OK.
789 824
 		if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key]))
@@ -794,11 +829,12 @@  discard block
 block discarded – undo
794 829
 			$cur_profile[$key] = $_POST[$key];
795 830
 
796 831
 			// Are we logging it?
797
-			if (!empty($field['log_change']) && isset($old_profile[$key]))
798
-				$context['log_changes'][$key] = array(
832
+			if (!empty($field['log_change']) && isset($old_profile[$key])) {
833
+							$context['log_changes'][$key] = array(
799 834
 					'previous' => $old_profile[$key],
800 835
 					'new' => $_POST[$key],
801 836
 				);
837
+			}
802 838
 		}
803 839
 
804 840
 		// Logging group changes are a bit different...
@@ -831,10 +867,11 @@  discard block
 block discarded – undo
831 867
 				{
832 868
 					foreach ($groups as $id => $group)
833 869
 					{
834
-						if (isset($context['member_groups'][$group]))
835
-							$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
836
-						else
837
-							unset($additional_groups[$type][$id]);
870
+						if (isset($context['member_groups'][$group])) {
871
+													$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
872
+						} else {
873
+													unset($additional_groups[$type][$id]);
874
+						}
838 875
 					}
839 876
 					$additional_groups[$type] = implode(', ', $additional_groups[$type]);
840 877
 				}
@@ -845,10 +882,11 @@  discard block
 block discarded – undo
845 882
 	}
846 883
 
847 884
 	// @todo Temporary
848
-	if ($context['user']['is_owner'])
849
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
850
-	else
851
-		$changeOther = allowedTo('profile_extra_any');
885
+	if ($context['user']['is_owner']) {
886
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
887
+	} else {
888
+			$changeOther = allowedTo('profile_extra_any');
889
+	}
852 890
 	if ($changeOther && empty($post_errors))
853 891
 	{
854 892
 		makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
@@ -856,8 +894,9 @@  discard block
 block discarded – undo
856 894
 		{
857 895
 			$custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true);
858 896
 
859
-			if (!empty($custom_fields_errors))
860
-				$post_errors = array_merge($post_errors, $custom_fields_errors);
897
+			if (!empty($custom_fields_errors)) {
898
+							$post_errors = array_merge($post_errors, $custom_fields_errors);
899
+			}
861 900
 		}
862 901
 	}
863 902
 
@@ -883,9 +922,9 @@  discard block
 block discarded – undo
883 922
 	if ($context['user']['is_owner'])
884 923
 	{
885 924
 		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own'));
925
+	} else {
926
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
886 927
 	}
887
-	else
888
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
889 928
 
890 929
 	// Arrays of all the changes - makes things easier.
891 930
 	$profile_bools = array();
@@ -896,22 +935,25 @@  discard block
 block discarded – undo
896 935
 		'ignore_boards',
897 936
 	);
898 937
 
899
-	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd']))
900
-		$_POST['ignore_brd'] = array();
938
+	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) {
939
+			$_POST['ignore_brd'] = array();
940
+	}
901 941
 
902 942
 	unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing.  Kinda like our minds.
903 943
 	if (isset($_POST['ignore_brd']))
904 944
 	{
905
-		if (!is_array($_POST['ignore_brd']))
906
-			$_POST['ignore_brd'] = array($_POST['ignore_brd']);
945
+		if (!is_array($_POST['ignore_brd'])) {
946
+					$_POST['ignore_brd'] = array($_POST['ignore_brd']);
947
+		}
907 948
 
908 949
 		foreach ($_POST['ignore_brd'] as $k => $d)
909 950
 		{
910 951
 			$d = (int) $d;
911
-			if ($d != 0)
912
-				$_POST['ignore_brd'][$k] = $d;
913
-			else
914
-				unset($_POST['ignore_brd'][$k]);
952
+			if ($d != 0) {
953
+							$_POST['ignore_brd'][$k] = $d;
954
+			} else {
955
+							unset($_POST['ignore_brd'][$k]);
956
+			}
915 957
 		}
916 958
 		$_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']);
917 959
 		unset($_POST['ignore_brd']);
@@ -923,21 +965,26 @@  discard block
 block discarded – undo
923 965
 		makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
924 966
 		//makeAvatarChanges($memID, $post_errors);
925 967
 
926
-		if (!empty($_REQUEST['sa']))
927
-			makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
968
+		if (!empty($_REQUEST['sa'])) {
969
+					makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
970
+		}
928 971
 
929
-		foreach ($profile_bools as $var)
930
-			if (isset($_POST[$var]))
972
+		foreach ($profile_bools as $var) {
973
+					if (isset($_POST[$var]))
931 974
 				$profile_vars[$var] = empty($_POST[$var]) ? '0' : '1';
932
-		foreach ($profile_ints as $var)
933
-			if (isset($_POST[$var]))
975
+		}
976
+		foreach ($profile_ints as $var) {
977
+					if (isset($_POST[$var]))
934 978
 				$profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : '';
935
-		foreach ($profile_floats as $var)
936
-			if (isset($_POST[$var]))
979
+		}
980
+		foreach ($profile_floats as $var) {
981
+					if (isset($_POST[$var]))
937 982
 				$profile_vars[$var] = (float) $_POST[$var];
938
-		foreach ($profile_strings as $var)
939
-			if (isset($_POST[$var]))
983
+		}
984
+		foreach ($profile_strings as $var) {
985
+					if (isset($_POST[$var]))
940 986
 				$profile_vars[$var] = $_POST[$var];
987
+		}
941 988
 	}
942 989
 }
943 990
 
@@ -971,8 +1018,9 @@  discard block
 block discarded – undo
971 1018
 	);
972 1019
 
973 1020
 	// Can't change reserved vars.
974
-	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0))
975
-		fatal_lang_error('no_access', false);
1021
+	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) {
1022
+			fatal_lang_error('no_access', false);
1023
+	}
976 1024
 
977 1025
 	// Don't allow any overriding of custom fields with default or non-default options.
978 1026
 	$request = $smcFunc['db_query']('', '
@@ -984,8 +1032,9 @@  discard block
 block discarded – undo
984 1032
 		)
985 1033
 	);
986 1034
 	$custom_fields = array();
987
-	while ($row = $smcFunc['db_fetch_assoc']($request))
988
-		$custom_fields[] = $row['col_name'];
1035
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1036
+			$custom_fields[] = $row['col_name'];
1037
+	}
989 1038
 	$smcFunc['db_free_result']($request);
990 1039
 
991 1040
 	// These are the theme changes...
@@ -994,33 +1043,39 @@  discard block
 block discarded – undo
994 1043
 	{
995 1044
 		foreach ($_POST['options'] as $opt => $val)
996 1045
 		{
997
-			if (in_array($opt, $custom_fields))
998
-				continue;
1046
+			if (in_array($opt, $custom_fields)) {
1047
+							continue;
1048
+			}
999 1049
 
1000 1050
 			// These need to be controlled.
1001
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1002
-				$val = max(0, min($val, 50));
1051
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1052
+							$val = max(0, min($val, 50));
1053
+			}
1003 1054
 			// We don't set this per theme anymore.
1004
-			elseif ($opt == 'allow_no_censored')
1005
-				continue;
1055
+			elseif ($opt == 'allow_no_censored') {
1056
+							continue;
1057
+			}
1006 1058
 
1007 1059
 			$themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val);
1008 1060
 		}
1009 1061
 	}
1010 1062
 
1011 1063
 	$erase_options = array();
1012
-	if (isset($_POST['default_options']) && is_array($_POST['default_options']))
1013
-		foreach ($_POST['default_options'] as $opt => $val)
1064
+	if (isset($_POST['default_options']) && is_array($_POST['default_options'])) {
1065
+			foreach ($_POST['default_options'] as $opt => $val)
1014 1066
 		{
1015 1067
 			if (in_array($opt, $custom_fields))
1016 1068
 				continue;
1069
+	}
1017 1070
 
1018 1071
 			// These need to be controlled.
1019
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1020
-				$val = max(0, min($val, 50));
1072
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1073
+							$val = max(0, min($val, 50));
1074
+			}
1021 1075
 			// Only let admins and owners change the censor.
1022
-			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner'])
1023
-					continue;
1076
+			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) {
1077
+								continue;
1078
+			}
1024 1079
 
1025 1080
 			$themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val);
1026 1081
 			$erase_options[] = $opt;
@@ -1056,8 +1111,9 @@  discard block
 block discarded – undo
1056 1111
 
1057 1112
 		// Admins can choose any theme, even if it's not enabled...
1058 1113
 		$themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']);
1059
-		foreach ($themes as $t)
1060
-			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1114
+		foreach ($themes as $t) {
1115
+					cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1116
+		}
1061 1117
 	}
1062 1118
 }
1063 1119
 
@@ -1076,8 +1132,9 @@  discard block
 block discarded – undo
1076 1132
 	if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards']))
1077 1133
 	{
1078 1134
 		// Make sure only integers are deleted.
1079
-		foreach ($_POST['notify_boards'] as $index => $id)
1080
-			$_POST['notify_boards'][$index] = (int) $id;
1135
+		foreach ($_POST['notify_boards'] as $index => $id) {
1136
+					$_POST['notify_boards'][$index] = (int) $id;
1137
+		}
1081 1138
 
1082 1139
 		// id_board = 0 is reserved for topic notifications.
1083 1140
 		$_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0));
@@ -1096,8 +1153,9 @@  discard block
 block discarded – undo
1096 1153
 	// We are editing topic notifications......
1097 1154
 	elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics']))
1098 1155
 	{
1099
-		foreach ($_POST['notify_topics'] as $index => $id)
1100
-			$_POST['notify_topics'][$index] = (int) $id;
1156
+		foreach ($_POST['notify_topics'] as $index => $id) {
1157
+					$_POST['notify_topics'][$index] = (int) $id;
1158
+		}
1101 1159
 
1102 1160
 		// Make sure there are no zeros left.
1103 1161
 		$_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0));
@@ -1111,16 +1169,18 @@  discard block
 block discarded – undo
1111 1169
 				'selected_member' => $memID,
1112 1170
 			)
1113 1171
 		);
1114
-		foreach ($_POST['notify_topics'] as $topic)
1115
-			setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1172
+		foreach ($_POST['notify_topics'] as $topic) {
1173
+					setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1174
+		}
1116 1175
 	}
1117 1176
 
1118 1177
 	// We are removing topic preferences
1119 1178
 	elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics']))
1120 1179
 	{
1121 1180
 		$prefs = array();
1122
-		foreach ($_POST['notify_topics'] as $topic)
1123
-			$prefs[] = 'topic_notify_' . $topic;
1181
+		foreach ($_POST['notify_topics'] as $topic) {
1182
+					$prefs[] = 'topic_notify_' . $topic;
1183
+		}
1124 1184
 		deleteNotifyPrefs($memID, $prefs);
1125 1185
 	}
1126 1186
 
@@ -1128,8 +1188,9 @@  discard block
 block discarded – undo
1128 1188
 	elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards']))
1129 1189
 	{
1130 1190
 		$prefs = array();
1131
-		foreach ($_POST['notify_boards'] as $board)
1132
-			$prefs[] = 'board_notify_' . $board;
1191
+		foreach ($_POST['notify_boards'] as $board) {
1192
+					$prefs[] = 'board_notify_' . $board;
1193
+		}
1133 1194
 		deleteNotifyPrefs($memID, $prefs);
1134 1195
 	}
1135 1196
 }
@@ -1150,8 +1211,9 @@  discard block
 block discarded – undo
1150 1211
 
1151 1212
 	$errors = array();
1152 1213
 
1153
-	if ($sanitize && isset($_POST['customfield']))
1154
-		$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1214
+	if ($sanitize && isset($_POST['customfield'])) {
1215
+			$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1216
+	}
1155 1217
 
1156 1218
 	$where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}';
1157 1219
 
@@ -1177,26 +1239,29 @@  discard block
 block discarded – undo
1177 1239
 			- The data is not invisible to users but editable by the owner (or if it is the user is not the owner)
1178 1240
 			- The area isn't registration, and if it is that the field is not supposed to be shown there.
1179 1241
 		*/
1180
-		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0))
1181
-			continue;
1242
+		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) {
1243
+					continue;
1244
+		}
1182 1245
 
1183 1246
 		// Validate the user data.
1184
-		if ($row['field_type'] == 'check')
1185
-			$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1186
-		elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1247
+		if ($row['field_type'] == 'check') {
1248
+					$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1249
+		} elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1187 1250
 		{
1188 1251
 			$value = $row['default_value'];
1189
-			foreach (explode(',', $row['field_options']) as $k => $v)
1190
-				if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1252
+			foreach (explode(',', $row['field_options']) as $k => $v) {
1253
+							if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1191 1254
 					$value = $v;
1255
+			}
1192 1256
 		}
1193 1257
 		// Otherwise some form of text!
1194 1258
 		else
1195 1259
 		{
1196 1260
 			$value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : '';
1197 1261
 
1198
-			if ($row['field_length'])
1199
-				$value = $smcFunc['substr']($value, 0, $row['field_length']);
1262
+			if ($row['field_length']) {
1263
+							$value = $smcFunc['substr']($value, 0, $row['field_length']);
1264
+			}
1200 1265
 
1201 1266
 			// Any masks?
1202 1267
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
@@ -1205,36 +1270,34 @@  discard block
 block discarded – undo
1205 1270
 				$valueReference = un_htmlspecialchars($value);
1206 1271
 
1207 1272
 				// Try and avoid some checks. '0' could be a valid non-empty value.
1208
-				if (empty($value) && !is_numeric($value))
1209
-					$value = '';
1273
+				if (empty($value) && !is_numeric($value)) {
1274
+									$value = '';
1275
+				}
1210 1276
 
1211 1277
 				if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference)))
1212 1278
 				{
1213
-					if ($returnErrors)
1214
-						$errors[] = 'custom_field_nohtml_fail';
1215
-
1216
-					else
1217
-						$value = '';
1218
-				}
1219
-				elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1279
+					if ($returnErrors) {
1280
+											$errors[] = 'custom_field_nohtml_fail';
1281
+					} else {
1282
+											$value = '';
1283
+					}
1284
+				} elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1220 1285
 				{
1221
-					if ($returnErrors)
1222
-						$errors[] = 'custom_field_mail_fail';
1223
-
1224
-					else
1225
-						$value = '';
1226
-				}
1227
-				elseif ($row['mask'] == 'number')
1286
+					if ($returnErrors) {
1287
+											$errors[] = 'custom_field_mail_fail';
1288
+					} else {
1289
+											$value = '';
1290
+					}
1291
+				} elseif ($row['mask'] == 'number')
1228 1292
 				{
1229 1293
 					$value = (int) $value;
1230
-				}
1231
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1294
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1232 1295
 				{
1233
-					if ($returnErrors)
1234
-						$errors[] = 'custom_field_regex_fail';
1235
-
1236
-					else
1237
-						$value = '';
1296
+					if ($returnErrors) {
1297
+											$errors[] = 'custom_field_regex_fail';
1298
+					} else {
1299
+											$value = '';
1300
+					}
1238 1301
 				}
1239 1302
 
1240 1303
 				unset($valueReference);
@@ -1258,8 +1321,7 @@  discard block
 block discarded – undo
1258 1321
 			{
1259 1322
 				$deletes = array('id_theme' => 1 , 'variable' => $row['col_name'], 'id_member' => $memID);
1260 1323
 				unset($user_profile[$memID]['options'][$row['col_name']]);
1261
-			}
1262
-			else
1324
+			} else
1263 1325
 			{
1264 1326
 				$changes[] = array(1, $row['col_name'], $value, $memID);
1265 1327
 				$user_profile[$memID]['options'][$row['col_name']] = $value;
@@ -1270,27 +1332,30 @@  discard block
 block discarded – undo
1270 1332
 
1271 1333
 	$hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize, &$deletes));
1272 1334
 
1273
-	if (!empty($hook_errors) && is_array($hook_errors))
1274
-		$errors = array_merge($errors, $hook_errors);
1335
+	if (!empty($hook_errors) && is_array($hook_errors)) {
1336
+			$errors = array_merge($errors, $hook_errors);
1337
+	}
1275 1338
 
1276 1339
 	// Make those changes!
1277 1340
 	if ((!empty($changes) || !empty($deletes)) && empty($context['password_auth_failed']) && empty($errors))
1278 1341
 	{
1279
-		if (!empty($changes))
1280
-			$smcFunc['db_insert']('replace',
1342
+		if (!empty($changes)) {
1343
+					$smcFunc['db_insert']('replace',
1281 1344
 				'{db_prefix}themes',
1282 1345
 				array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534', 'id_member' => 'int'),
1283 1346
 				$changes,
1284 1347
 				array('id_theme', 'variable', 'id_member')
1285 1348
 			);
1286
-		if (!empty($deletes))
1287
-			$smcFunc['db_query']('','
1349
+		}
1350
+		if (!empty($deletes)) {
1351
+					$smcFunc['db_query']('','
1288 1352
 				DELETE FROM {db_prefix}themes
1289 1353
 				WHERE id_theme = {int:id_theme} AND
1290 1354
 						variable = {string:variable} AND
1291 1355
 						id_member = {int:id_member}',
1292 1356
 				$deletes
1293 1357
 				);
1358
+		}
1294 1359
 		if (!empty($log_changes) && !empty($modSettings['modlog_enabled']))
1295 1360
 		{
1296 1361
 			require_once($sourcedir . '/Logging.php');
@@ -1298,9 +1363,10 @@  discard block
 block discarded – undo
1298 1363
 		}
1299 1364
 	}
1300 1365
 
1301
-	if ($returnErrors)
1302
-		return $errors;
1303
-}
1366
+	if ($returnErrors) {
1367
+			return $errors;
1368
+	}
1369
+	}
1304 1370
 
1305 1371
 /**
1306 1372
  * Show all the users buddies, as well as a add/delete interface.
@@ -1312,8 +1378,9 @@  discard block
 block discarded – undo
1312 1378
 	global $context, $txt, $modSettings;
1313 1379
 
1314 1380
 	// Do a quick check to ensure people aren't getting here illegally!
1315
-	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist']))
1316
-		fatal_lang_error('no_access', false);
1381
+	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) {
1382
+			fatal_lang_error('no_access', false);
1383
+	}
1317 1384
 
1318 1385
 	// Can we email the user direct?
1319 1386
 	$context['can_moderate_forum'] = allowedTo('moderate_forum');
@@ -1343,9 +1410,10 @@  discard block
 block discarded – undo
1343 1410
 	$context['sub_template'] = $subActions[$context['list_area']][0];
1344 1411
 	$call = call_helper($subActions[$context['list_area']][0], true);
1345 1412
 
1346
-	if (!empty($call))
1347
-		call_user_func($call, $memID);
1348
-}
1413
+	if (!empty($call)) {
1414
+			call_user_func($call, $memID);
1415
+	}
1416
+	}
1349 1417
 
1350 1418
 /**
1351 1419
  * Show all the users buddies, as well as a add/delete interface.
@@ -1359,9 +1427,10 @@  discard block
 block discarded – undo
1359 1427
 
1360 1428
 	// For making changes!
1361 1429
 	$buddiesArray = explode(',', $user_profile[$memID]['buddy_list']);
1362
-	foreach ($buddiesArray as $k => $dummy)
1363
-		if ($dummy == '')
1430
+	foreach ($buddiesArray as $k => $dummy) {
1431
+			if ($dummy == '')
1364 1432
 			unset($buddiesArray[$k]);
1433
+	}
1365 1434
 
1366 1435
 	// Removing a buddy?
1367 1436
 	if (isset($_GET['remove']))
@@ -1373,10 +1442,11 @@  discard block
 block discarded – undo
1373 1442
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1374 1443
 
1375 1444
 		// Heh, I'm lazy, do it the easy way...
1376
-		foreach ($buddiesArray as $key => $buddy)
1377
-			if ($buddy == (int) $_GET['remove'])
1445
+		foreach ($buddiesArray as $key => $buddy) {
1446
+					if ($buddy == (int) $_GET['remove'])
1378 1447
 			{
1379 1448
 				unset($buddiesArray[$key]);
1449
+		}
1380 1450
 				$_SESSION['prf-save'] = true;
1381 1451
 			}
1382 1452
 
@@ -1386,8 +1456,7 @@  discard block
 block discarded – undo
1386 1456
 
1387 1457
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1388 1458
 		redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID);
1389
-	}
1390
-	elseif (isset($_POST['new_buddy']))
1459
+	} elseif (isset($_POST['new_buddy']))
1391 1460
 	{
1392 1461
 		checkSession();
1393 1462
 
@@ -1400,8 +1469,9 @@  discard block
 block discarded – undo
1400 1469
 		{
1401 1470
 			$new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => '&#039;'));
1402 1471
 
1403
-			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1404
-				unset($new_buddies[$k]);
1472
+			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1473
+							unset($new_buddies[$k]);
1474
+			}
1405 1475
 		}
1406 1476
 
1407 1477
 		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies));
@@ -1421,16 +1491,18 @@  discard block
 block discarded – undo
1421 1491
 				)
1422 1492
 			);
1423 1493
 
1424
-			if ($smcFunc['db_num_rows']($request) != 0)
1425
-				$_SESSION['prf-save'] = true;
1494
+			if ($smcFunc['db_num_rows']($request) != 0) {
1495
+							$_SESSION['prf-save'] = true;
1496
+			}
1426 1497
 
1427 1498
 			// Add the new member to the buddies array.
1428 1499
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1429 1500
 			{
1430
-				if (in_array($row['id_member'], $buddiesArray))
1431
-					continue;
1432
-				else
1433
-					$buddiesArray[] = (int) $row['id_member'];
1501
+				if (in_array($row['id_member'], $buddiesArray)) {
1502
+									continue;
1503
+				} else {
1504
+									$buddiesArray[] = (int) $row['id_member'];
1505
+				}
1434 1506
 			}
1435 1507
 			$smcFunc['db_free_result']($request);
1436 1508
 
@@ -1460,18 +1532,20 @@  discard block
 block discarded – undo
1460 1532
 
1461 1533
 	$context['custom_pf'] = array();
1462 1534
 	$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
1463
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1464
-		if (!isset($disabled_fields[$row['col_name']]))
1535
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1536
+			if (!isset($disabled_fields[$row['col_name']]))
1465 1537
 			$context['custom_pf'][$row['col_name']] = array(
1466 1538
 				'label' => $row['field_name'],
1467 1539
 				'type' => $row['field_type'],
1468 1540
 				'bbc' => !empty($row['bbc']),
1469 1541
 				'enclose' => $row['enclose'],
1470 1542
 			);
1543
+	}
1471 1544
 
1472 1545
 	// Gotta disable the gender option.
1473
-	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None')
1474
-		unset($context['custom_pf']['cust_gender']);
1546
+	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') {
1547
+			unset($context['custom_pf']['cust_gender']);
1548
+	}
1475 1549
 
1476 1550
 	$smcFunc['db_free_result']($request);
1477 1551
 
@@ -1488,8 +1562,9 @@  discard block
 block discarded – undo
1488 1562
 				'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1,
1489 1563
 			)
1490 1564
 		);
1491
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1492
-			$buddies[] = $row['id_member'];
1565
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1566
+					$buddies[] = $row['id_member'];
1567
+		}
1493 1568
 		$smcFunc['db_free_result']($result);
1494 1569
 	}
1495 1570
 
@@ -1517,30 +1592,32 @@  discard block
 block discarded – undo
1517 1592
 					continue;
1518 1593
 				}
1519 1594
 
1520
-				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key]))
1521
-					$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1522
-
1523
-				elseif ($column['type'] == 'check')
1524
-					$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1595
+				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) {
1596
+									$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1597
+				} elseif ($column['type'] == 'check') {
1598
+									$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1599
+				}
1525 1600
 
1526 1601
 				// Enclosing the user input within some other text?
1527
-				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key]))
1528
-					$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1602
+				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) {
1603
+									$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1529 1604
 						'{SCRIPTURL}' => $scripturl,
1530 1605
 						'{IMAGES_URL}' => $settings['images_url'],
1531 1606
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1532 1607
 						'{INPUT}' => $context['buddies'][$buddy]['options'][$key],
1533 1608
 					));
1609
+				}
1534 1610
 			}
1535 1611
 		}
1536 1612
 	}
1537 1613
 
1538 1614
 	if (isset($_SESSION['prf-save']))
1539 1615
 	{
1540
-		if ($_SESSION['prf-save'] === true)
1541
-			$context['saved_successful'] = true;
1542
-		else
1543
-			$context['saved_failed'] = $_SESSION['prf-save'];
1616
+		if ($_SESSION['prf-save'] === true) {
1617
+					$context['saved_successful'] = true;
1618
+		} else {
1619
+					$context['saved_failed'] = $_SESSION['prf-save'];
1620
+		}
1544 1621
 
1545 1622
 		unset($_SESSION['prf-save']);
1546 1623
 	}
@@ -1560,9 +1637,10 @@  discard block
 block discarded – undo
1560 1637
 
1561 1638
 	// For making changes!
1562 1639
 	$ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']);
1563
-	foreach ($ignoreArray as $k => $dummy)
1564
-		if ($dummy == '')
1640
+	foreach ($ignoreArray as $k => $dummy) {
1641
+			if ($dummy == '')
1565 1642
 			unset($ignoreArray[$k]);
1643
+	}
1566 1644
 
1567 1645
 	// Removing a member from the ignore list?
1568 1646
 	if (isset($_GET['remove']))
@@ -1572,10 +1650,11 @@  discard block
 block discarded – undo
1572 1650
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1573 1651
 
1574 1652
 		// Heh, I'm lazy, do it the easy way...
1575
-		foreach ($ignoreArray as $key => $id_remove)
1576
-			if ($id_remove == (int) $_GET['remove'])
1653
+		foreach ($ignoreArray as $key => $id_remove) {
1654
+					if ($id_remove == (int) $_GET['remove'])
1577 1655
 			{
1578 1656
 				unset($ignoreArray[$key]);
1657
+		}
1579 1658
 				$_SESSION['prf-save'] = true;
1580 1659
 			}
1581 1660
 
@@ -1585,8 +1664,7 @@  discard block
 block discarded – undo
1585 1664
 
1586 1665
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1587 1666
 		redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID);
1588
-	}
1589
-	elseif (isset($_POST['new_ignore']))
1667
+	} elseif (isset($_POST['new_ignore']))
1590 1668
 	{
1591 1669
 		checkSession();
1592 1670
 		// Prepare the string for extraction...
@@ -1598,8 +1676,9 @@  discard block
 block discarded – undo
1598 1676
 		{
1599 1677
 			$new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => '&#039;'));
1600 1678
 
1601
-			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1602
-				unset($new_entries[$k]);
1679
+			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1680
+							unset($new_entries[$k]);
1681
+			}
1603 1682
 		}
1604 1683
 
1605 1684
 		$_SESSION['prf-save'] = $txt['could_not_add_person'];
@@ -1617,16 +1696,18 @@  discard block
 block discarded – undo
1617 1696
 				)
1618 1697
 			);
1619 1698
 
1620
-			if ($smcFunc['db_num_rows']($request) != 0)
1621
-				$_SESSION['prf-save'] = true;
1699
+			if ($smcFunc['db_num_rows']($request) != 0) {
1700
+							$_SESSION['prf-save'] = true;
1701
+			}
1622 1702
 
1623 1703
 			// Add the new member to the buddies array.
1624 1704
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1625 1705
 			{
1626
-				if (in_array($row['id_member'], $ignoreArray))
1627
-					continue;
1628
-				else
1629
-					$ignoreArray[] = (int) $row['id_member'];
1706
+				if (in_array($row['id_member'], $ignoreArray)) {
1707
+									continue;
1708
+				} else {
1709
+									$ignoreArray[] = (int) $row['id_member'];
1710
+				}
1630 1711
 			}
1631 1712
 			$smcFunc['db_free_result']($request);
1632 1713
 
@@ -1655,8 +1736,9 @@  discard block
 block discarded – undo
1655 1736
 				'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1,
1656 1737
 			)
1657 1738
 		);
1658
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1659
-			$ignored[] = $row['id_member'];
1739
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1740
+					$ignored[] = $row['id_member'];
1741
+		}
1660 1742
 		$smcFunc['db_free_result']($result);
1661 1743
 	}
1662 1744
 
@@ -1675,10 +1757,11 @@  discard block
 block discarded – undo
1675 1757
 
1676 1758
 	if (isset($_SESSION['prf-save']))
1677 1759
 	{
1678
-		if ($_SESSION['prf-save'] === true)
1679
-			$context['saved_successful'] = true;
1680
-		else
1681
-			$context['saved_failed'] = $_SESSION['prf-save'];
1760
+		if ($_SESSION['prf-save'] === true) {
1761
+					$context['saved_successful'] = true;
1762
+		} else {
1763
+					$context['saved_failed'] = $_SESSION['prf-save'];
1764
+		}
1682 1765
 
1683 1766
 		unset($_SESSION['prf-save']);
1684 1767
 	}
@@ -1694,8 +1777,9 @@  discard block
 block discarded – undo
1694 1777
 	global $context, $txt;
1695 1778
 
1696 1779
 	loadThemeOptions($memID);
1697
-	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any')))
1698
-		loadCustomFields($memID, 'account');
1780
+	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) {
1781
+			loadCustomFields($memID, 'account');
1782
+	}
1699 1783
 
1700 1784
 	$context['sub_template'] = 'edit_options';
1701 1785
 	$context['page_desc'] = $txt['account_info'];
@@ -1722,8 +1806,9 @@  discard block
 block discarded – undo
1722 1806
 	global $context, $txt;
1723 1807
 
1724 1808
 	loadThemeOptions($memID);
1725
-	if (allowedTo(array('profile_forum_own', 'profile_forum_any')))
1726
-		loadCustomFields($memID, 'forumprofile');
1809
+	if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) {
1810
+			loadCustomFields($memID, 'forumprofile');
1811
+	}
1727 1812
 
1728 1813
 	$context['sub_template'] = 'edit_options';
1729 1814
 	$context['page_desc'] = $txt['forumProfile_info'];
@@ -1756,18 +1841,21 @@  discard block
 block discarded – undo
1756 1841
 	$dirs = array();
1757 1842
 	$files = array();
1758 1843
 
1759
-	if (!$dir)
1760
-		return array();
1844
+	if (!$dir) {
1845
+			return array();
1846
+	}
1761 1847
 
1762 1848
 	while ($line = $dir->read())
1763 1849
 	{
1764
-		if (in_array($line, array('.', '..', 'blank.png', 'index.php')))
1765
-			continue;
1850
+		if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) {
1851
+					continue;
1852
+		}
1766 1853
 
1767
-		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
1768
-			$dirs[] = $line;
1769
-		else
1770
-			$files[] = $line;
1854
+		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) {
1855
+					$dirs[] = $line;
1856
+		} else {
1857
+					$files[] = $line;
1858
+		}
1771 1859
 	}
1772 1860
 	$dir->close();
1773 1861
 
@@ -1788,14 +1876,15 @@  discard block
 block discarded – undo
1788 1876
 	foreach ($dirs as $line)
1789 1877
 	{
1790 1878
 		$tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
1791
-		if (!empty($tmp))
1792
-			$result[] = array(
1879
+		if (!empty($tmp)) {
1880
+					$result[] = array(
1793 1881
 				'filename' => $smcFunc['htmlspecialchars']($line),
1794 1882
 				'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
1795 1883
 				'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']',
1796 1884
 				'is_dir' => true,
1797 1885
 				'files' => $tmp
1798 1886
 		);
1887
+		}
1799 1888
 		unset($tmp);
1800 1889
 	}
1801 1890
 
@@ -1805,8 +1894,9 @@  discard block
 block discarded – undo
1805 1894
 		$extension = substr(strrchr($line, '.'), 1);
1806 1895
 
1807 1896
 		// Make sure it is an image.
1808
-		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
1809
-			continue;
1897
+		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) {
1898
+					continue;
1899
+		}
1810 1900
 
1811 1901
 		$result[] = array(
1812 1902
 			'filename' => $smcFunc['htmlspecialchars']($line),
@@ -1814,8 +1904,9 @@  discard block
 block discarded – undo
1814 1904
 			'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)),
1815 1905
 			'is_dir' => false
1816 1906
 		);
1817
-		if ($level == 1)
1818
-			$context['avatar_list'][] = $directory . '/' . $line;
1907
+		if ($level == 1) {
1908
+					$context['avatar_list'][] = $directory . '/' . $line;
1909
+		}
1819 1910
 	}
1820 1911
 
1821 1912
 	return $result;
@@ -1837,8 +1928,9 @@  discard block
 block discarded – undo
1837 1928
 	call_integration_hook('integrate_theme_options');
1838 1929
 
1839 1930
 	loadThemeOptions($memID);
1840
-	if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
1841
-		loadCustomFields($memID, 'theme');
1931
+	if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) {
1932
+			loadCustomFields($memID, 'theme');
1933
+	}
1842 1934
 
1843 1935
 	$context['sub_template'] = 'edit_options';
1844 1936
 	$context['page_desc'] = $txt['theme_info'];
@@ -1892,16 +1984,19 @@  discard block
 block discarded – undo
1892 1984
 {
1893 1985
 	global $txt, $context, $modSettings, $smcFunc, $sourcedir;
1894 1986
 
1895
-	if (!isset($context['token_check']))
1896
-		$context['token_check'] = 'profile-nt' . $memID;
1987
+	if (!isset($context['token_check'])) {
1988
+			$context['token_check'] = 'profile-nt' . $memID;
1989
+	}
1897 1990
 
1898 1991
 	is_not_guest();
1899
-	if (!$context['user']['is_owner'])
1900
-		isAllowedTo('profile_extra_any');
1992
+	if (!$context['user']['is_owner']) {
1993
+			isAllowedTo('profile_extra_any');
1994
+	}
1901 1995
 
1902 1996
 	// Set the post action if we're coming from the profile...
1903
-	if (!isset($context['action']))
1904
-		$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1997
+	if (!isset($context['action'])) {
1998
+			$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1999
+	}
1905 2000
 
1906 2001
 	// What options are set
1907 2002
 	loadThemeOptions($memID);
@@ -1988,28 +2083,34 @@  discard block
 block discarded – undo
1988 2083
 	);
1989 2084
 
1990 2085
 	// There are certain things that are disabled at the group level.
1991
-	if (empty($modSettings['cal_enabled']))
1992
-		unset($alert_types['calendar']);
2086
+	if (empty($modSettings['cal_enabled'])) {
2087
+			unset($alert_types['calendar']);
2088
+	}
1993 2089
 
1994 2090
 	// Disable paid subscriptions at group level if they're disabled
1995
-	if (empty($modSettings['paid_enabled']))
1996
-		unset($alert_types['paidsubs']);
2091
+	if (empty($modSettings['paid_enabled'])) {
2092
+			unset($alert_types['paidsubs']);
2093
+	}
1997 2094
 
1998 2095
 	// Disable membergroup requests at group level if they're disabled
1999
-	if (empty($modSettings['show_group_membership']))
2000
-		unset($alert_types['groupr'], $alert_types['members']['request_group']);
2096
+	if (empty($modSettings['show_group_membership'])) {
2097
+			unset($alert_types['groupr'], $alert_types['members']['request_group']);
2098
+	}
2001 2099
 
2002 2100
 	// Disable mentions if they're disabled
2003
-	if (empty($modSettings['enable_mentions']))
2004
-		unset($alert_types['msg']['msg_mention']);
2101
+	if (empty($modSettings['enable_mentions'])) {
2102
+			unset($alert_types['msg']['msg_mention']);
2103
+	}
2005 2104
 
2006 2105
 	// Disable likes if they're disabled
2007
-	if (empty($modSettings['enable_likes']))
2008
-		unset($alert_types['msg']['msg_like']);
2106
+	if (empty($modSettings['enable_likes'])) {
2107
+			unset($alert_types['msg']['msg_like']);
2108
+	}
2009 2109
 
2010 2110
 	// Disable buddy requests if they're disabled
2011
-	if (empty($modSettings['enable_buddylist']))
2012
-		unset($alert_types['members']['buddy_request']);
2111
+	if (empty($modSettings['enable_buddylist'])) {
2112
+			unset($alert_types['members']['buddy_request']);
2113
+	}
2013 2114
 
2014 2115
 	// Now, now, we could pass this through global but we should really get into the habit of
2015 2116
 	// passing content to hooks, not expecting hooks to splatter everything everywhere.
@@ -2037,15 +2138,17 @@  discard block
 block discarded – undo
2037 2138
 			$perms_cache['manage_membergroups'] = in_array($memID, $members);
2038 2139
 		}
2039 2140
 
2040
-		if (!($perms_cache['manage_membergroups'] || $can_mod != 0))
2041
-			unset($alert_types['members']['request_group']);
2141
+		if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) {
2142
+					unset($alert_types['members']['request_group']);
2143
+		}
2042 2144
 
2043 2145
 		foreach ($alert_types as $group => $items)
2044 2146
 		{
2045 2147
 			foreach ($items as $alert_key => $alert_value)
2046 2148
 			{
2047
-				if (!isset($alert_value['permission']))
2048
-					continue;
2149
+				if (!isset($alert_value['permission'])) {
2150
+									continue;
2151
+				}
2049 2152
 				if (!isset($perms_cache[$alert_value['permission']['name']]))
2050 2153
 				{
2051 2154
 					$in_board = !empty($alert_value['permission']['is_board']) ? 0 : null;
@@ -2053,12 +2156,14 @@  discard block
 block discarded – undo
2053 2156
 					$perms_cache[$alert_value['permission']['name']] = in_array($memID, $members);
2054 2157
 				}
2055 2158
 
2056
-				if (!$perms_cache[$alert_value['permission']['name']])
2057
-					unset ($alert_types[$group][$alert_key]);
2159
+				if (!$perms_cache[$alert_value['permission']['name']]) {
2160
+									unset ($alert_types[$group][$alert_key]);
2161
+				}
2058 2162
 			}
2059 2163
 
2060
-			if (empty($alert_types[$group]))
2061
-				unset ($alert_types[$group]);
2164
+			if (empty($alert_types[$group])) {
2165
+							unset ($alert_types[$group]);
2166
+			}
2062 2167
 		}
2063 2168
 	}
2064 2169
 
@@ -2090,9 +2195,9 @@  discard block
 block discarded – undo
2090 2195
 						$update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0;
2091 2196
 						break;
2092 2197
 					case 'select':
2093
-						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]]))
2094
-							$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2095
-						else
2198
+						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) {
2199
+													$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2200
+						} else
2096 2201
 						{
2097 2202
 							// We didn't have a sane value. Let's grab the first item from the possibles.
2098 2203
 							$keys = array_keys($this_option['opts']);
@@ -2112,23 +2217,28 @@  discard block
 block discarded – undo
2112 2217
 				$this_value = 0;
2113 2218
 				foreach ($context['alert_bits'] as $type => $bitvalue)
2114 2219
 				{
2115
-					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always')
2116
-						$this_value |= $bitvalue;
2220
+					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') {
2221
+											$this_value |= $bitvalue;
2222
+					}
2223
+				}
2224
+				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) {
2225
+									$update_prefs[$item_key] = $this_value;
2117 2226
 				}
2118
-				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value)
2119
-					$update_prefs[$item_key] = $this_value;
2120 2227
 			}
2121 2228
 		}
2122 2229
 
2123
-		if (!empty($_POST['opt_alert_timeout']))
2124
-			$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2230
+		if (!empty($_POST['opt_alert_timeout'])) {
2231
+					$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2232
+		}
2125 2233
 
2126
-		if (!empty($_POST['notify_announcements']))
2127
-			$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2234
+		if (!empty($_POST['notify_announcements'])) {
2235
+					$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2236
+		}
2128 2237
 
2129 2238
 		setNotifyPrefs((int) $memID, $update_prefs);
2130
-		foreach ($update_prefs as $pref => $value)
2131
-			$context['alert_prefs'][$pref] = $value;
2239
+		foreach ($update_prefs as $pref => $value) {
2240
+					$context['alert_prefs'][$pref] = $value;
2241
+		}
2132 2242
 
2133 2243
 		makeNotificationChanges($memID);
2134 2244
 
@@ -2158,8 +2268,9 @@  discard block
 block discarded – undo
2158 2268
 
2159 2269
 	// Now we're all set up.
2160 2270
 	is_not_guest();
2161
-	if (!$context['user']['is_owner'])
2162
-		fatal_error('no_access');
2271
+	if (!$context['user']['is_owner']) {
2272
+			fatal_error('no_access');
2273
+	}
2163 2274
 
2164 2275
 	checkSession('get');
2165 2276
 
@@ -2191,8 +2302,9 @@  discard block
 block discarded – undo
2191 2302
 {
2192 2303
 	global $smcFunc;
2193 2304
 
2194
-	if (empty($toMark) || empty($memID))
2195
-		return false;
2305
+	if (empty($toMark) || empty($memID)) {
2306
+			return false;
2307
+	}
2196 2308
 
2197 2309
 	$toMark = (array) $toMark;
2198 2310
 
@@ -2226,8 +2338,9 @@  discard block
 block discarded – undo
2226 2338
 {
2227 2339
 	global $smcFunc;
2228 2340
 
2229
-	if (empty($toDelete))
2230
-		return false;
2341
+	if (empty($toDelete)) {
2342
+			return false;
2343
+	}
2231 2344
 
2232 2345
 	$toDelete = (array) $toDelete;
2233 2346
 
@@ -2262,8 +2375,9 @@  discard block
 block discarded – undo
2262 2375
 {
2263 2376
 	global $smcFunc;
2264 2377
 
2265
-	if (empty($memID))
2266
-		return false;
2378
+	if (empty($memID)) {
2379
+			return false;
2380
+	}
2267 2381
 
2268 2382
 	$request = $smcFunc['db_query']('', '
2269 2383
 		SELECT id_alert
@@ -2340,8 +2454,9 @@  discard block
 block discarded – undo
2340 2454
 					{
2341 2455
 						$link = $topic['link'];
2342 2456
 
2343
-						if ($topic['new'])
2344
-							$link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2457
+						if ($topic['new']) {
2458
+													$link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2459
+						}
2345 2460
 
2346 2461
 						$link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>';
2347 2462
 
@@ -2492,8 +2607,9 @@  discard block
 block discarded – undo
2492 2607
 					{
2493 2608
 						$link = $board['link'];
2494 2609
 
2495
-						if ($board['new'])
2496
-							$link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2610
+						if ($board['new']) {
2611
+													$link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2612
+						}
2497 2613
 
2498 2614
 						return $link;
2499 2615
 					},
@@ -2693,8 +2809,8 @@  discard block
 block discarded – undo
2693 2809
 		)
2694 2810
 	);
2695 2811
 	$notification_boards = array();
2696
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2697
-		$notification_boards[] = array(
2812
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2813
+			$notification_boards[] = array(
2698 2814
 			'id' => $row['id_board'],
2699 2815
 			'name' => $row['name'],
2700 2816
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
@@ -2702,6 +2818,7 @@  discard block
 block discarded – undo
2702 2818
 			'new' => $row['board_read'] < $row['id_msg_updated'],
2703 2819
 			'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0),
2704 2820
 		);
2821
+	}
2705 2822
 	$smcFunc['db_free_result']($request);
2706 2823
 
2707 2824
 	return $notification_boards;
@@ -2716,17 +2833,18 @@  discard block
 block discarded – undo
2716 2833
 {
2717 2834
 	global $context, $options, $cur_profile, $smcFunc;
2718 2835
 
2719
-	if (isset($_POST['default_options']))
2720
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2836
+	if (isset($_POST['default_options'])) {
2837
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2838
+	}
2721 2839
 
2722 2840
 	if ($context['user']['is_owner'])
2723 2841
 	{
2724 2842
 		$context['member']['options'] = $options;
2725
-		if (isset($_POST['options']) && is_array($_POST['options']))
2726
-			foreach ($_POST['options'] as $k => $v)
2843
+		if (isset($_POST['options']) && is_array($_POST['options'])) {
2844
+					foreach ($_POST['options'] as $k => $v)
2727 2845
 				$context['member']['options'][$k] = $v;
2728
-	}
2729
-	else
2846
+		}
2847
+	} else
2730 2848
 	{
2731 2849
 		$request = $smcFunc['db_query']('', '
2732 2850
 			SELECT id_member, variable, value
@@ -2747,8 +2865,9 @@  discard block
 block discarded – undo
2747 2865
 				continue;
2748 2866
 			}
2749 2867
 
2750
-			if (isset($_POST['options'][$row['variable']]))
2751
-				$row['value'] = $_POST['options'][$row['variable']];
2868
+			if (isset($_POST['options'][$row['variable']])) {
2869
+							$row['value'] = $_POST['options'][$row['variable']];
2870
+			}
2752 2871
 			$context['member']['options'][$row['variable']] = $row['value'];
2753 2872
 		}
2754 2873
 		$smcFunc['db_free_result']($request);
@@ -2756,8 +2875,9 @@  discard block
 block discarded – undo
2756 2875
 		// Load up the default theme options for any missing.
2757 2876
 		foreach ($temp as $k => $v)
2758 2877
 		{
2759
-			if (!isset($context['member']['options'][$k]))
2760
-				$context['member']['options'][$k] = $v;
2878
+			if (!isset($context['member']['options'][$k])) {
2879
+							$context['member']['options'][$k] = $v;
2880
+			}
2761 2881
 		}
2762 2882
 	}
2763 2883
 }
@@ -2772,8 +2892,9 @@  discard block
 block discarded – undo
2772 2892
 	global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir;
2773 2893
 
2774 2894
 	// Have the admins enabled this option?
2775
-	if (empty($modSettings['allow_ignore_boards']))
2776
-		fatal_lang_error('ignoreboards_disallowed', 'user');
2895
+	if (empty($modSettings['allow_ignore_boards'])) {
2896
+			fatal_lang_error('ignoreboards_disallowed', 'user');
2897
+	}
2777 2898
 
2778 2899
 	// Find all the boards this user is allowed to see.
2779 2900
 	$request = $smcFunc['db_query']('order_by_board_order', '
@@ -2793,12 +2914,13 @@  discard block
 block discarded – undo
2793 2914
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2794 2915
 	{
2795 2916
 		// This category hasn't been set up yet..
2796
-		if (!isset($context['categories'][$row['id_cat']]))
2797
-			$context['categories'][$row['id_cat']] = array(
2917
+		if (!isset($context['categories'][$row['id_cat']])) {
2918
+					$context['categories'][$row['id_cat']] = array(
2798 2919
 				'id' => $row['id_cat'],
2799 2920
 				'name' => $row['cat_name'],
2800 2921
 				'boards' => array()
2801 2922
 			);
2923
+		}
2802 2924
 
2803 2925
 		// Set this board up, and let the template know when it's a child.  (indent them..)
2804 2926
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -2828,18 +2950,20 @@  discard block
 block discarded – undo
2828 2950
 	}
2829 2951
 
2830 2952
 	$max_boards = ceil(count($temp_boards) / 2);
2831
-	if ($max_boards == 1)
2832
-		$max_boards = 2;
2953
+	if ($max_boards == 1) {
2954
+			$max_boards = 2;
2955
+	}
2833 2956
 
2834 2957
 	// Now, alternate them so they can be shown left and right ;).
2835 2958
 	$context['board_columns'] = array();
2836 2959
 	for ($i = 0; $i < $max_boards; $i++)
2837 2960
 	{
2838 2961
 		$context['board_columns'][] = $temp_boards[$i];
2839
-		if (isset($temp_boards[$i + $max_boards]))
2840
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
2841
-		else
2842
-			$context['board_columns'][] = array();
2962
+		if (isset($temp_boards[$i + $max_boards])) {
2963
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
2964
+		} else {
2965
+					$context['board_columns'][] = array();
2966
+		}
2843 2967
 	}
2844 2968
 
2845 2969
 	loadThemeOptions($memID);
@@ -2908,8 +3032,9 @@  discard block
 block discarded – undo
2908 3032
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2909 3033
 	{
2910 3034
 		// We should skip the administrator group if they don't have the admin_forum permission!
2911
-		if ($row['id_group'] == 1 && !allowedTo('admin_forum'))
2912
-			continue;
3035
+		if ($row['id_group'] == 1 && !allowedTo('admin_forum')) {
3036
+					continue;
3037
+		}
2913 3038
 
2914 3039
 		$context['member_groups'][$row['id_group']] = array(
2915 3040
 			'id' => $row['id_group'],
@@ -2955,16 +3080,17 @@  discard block
 block discarded – undo
2955 3080
 	$context['max_signature_length'] = $context['signature_limits']['max_length'];
2956 3081
 	// Warning message for signature image limits?
2957 3082
 	$context['signature_warning'] = '';
2958
-	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height'])
2959
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
2960
-	elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height'])
2961
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3083
+	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) {
3084
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
3085
+	} elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) {
3086
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3087
+	}
2962 3088
 
2963 3089
 	$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
2964 3090
 
2965
-	if (empty($context['do_preview']))
2966
-		$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
2967
-	else
3091
+	if (empty($context['do_preview'])) {
3092
+			$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
3093
+	} else
2968 3094
 	{
2969 3095
 		$signature = !empty($_POST['signature']) ? $_POST['signature'] : '';
2970 3096
 		$validation = profileValidateSignature($signature);
@@ -2974,8 +3100,9 @@  discard block
 block discarded – undo
2974 3100
 			$context['post_errors'] = array();
2975 3101
 		}
2976 3102
 		$context['post_errors'][] = 'signature_not_yet_saved';
2977
-		if ($validation !== true && $validation !== false)
2978
-			$context['post_errors'][] = $validation;
3103
+		if ($validation !== true && $validation !== false) {
3104
+					$context['post_errors'][] = $validation;
3105
+		}
2979 3106
 
2980 3107
 		censorText($context['member']['signature']);
2981 3108
 		$context['member']['current_signature'] = $context['member']['signature'];
@@ -2985,8 +3112,9 @@  discard block
 block discarded – undo
2985 3112
 	}
2986 3113
 
2987 3114
 	// Load the spell checker?
2988
-	if ($context['show_spellchecking'])
2989
-		loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3115
+	if ($context['show_spellchecking']) {
3116
+			loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3117
+	}
2990 3118
 
2991 3119
 	return true;
2992 3120
 }
@@ -3020,8 +3148,7 @@  discard block
 block discarded – undo
3020 3148
 			'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11)
3021 3149
 		);
3022 3150
 		$context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']);
3023
-	}
3024
-	elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3151
+	} elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3025 3152
 	{
3026 3153
 		$context['member']['avatar'] += array(
3027 3154
 			'choice' => 'upload',
@@ -3031,33 +3158,34 @@  discard block
 block discarded – undo
3031 3158
 		$context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename'];
3032 3159
 	}
3033 3160
 	// Use "avatar_original" here so we show what the user entered even if the image proxy is enabled
3034
-	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external'])
3035
-		$context['member']['avatar'] += array(
3161
+	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) {
3162
+			$context['member']['avatar'] += array(
3036 3163
 			'choice' => 'external',
3037 3164
 			'server_pic' => 'blank.png',
3038 3165
 			'external' => $cur_profile['avatar_original']
3039 3166
 		);
3040
-	elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored'])
3041
-		$context['member']['avatar'] += array(
3167
+	} elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) {
3168
+			$context['member']['avatar'] += array(
3042 3169
 			'choice' => 'server_stored',
3043 3170
 			'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'],
3044 3171
 			'external' => 'http://'
3045 3172
 		);
3046
-	else
3047
-		$context['member']['avatar'] += array(
3173
+	} else {
3174
+			$context['member']['avatar'] += array(
3048 3175
 			'choice' => 'none',
3049 3176
 			'server_pic' => 'blank.png',
3050 3177
 			'external' => 'http://'
3051 3178
 		);
3179
+	}
3052 3180
 
3053 3181
 	// Get a list of all the avatars.
3054 3182
 	if ($context['member']['avatar']['allow_server_stored'])
3055 3183
 	{
3056 3184
 		$context['avatar_list'] = array();
3057 3185
 		$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array();
3186
+	} else {
3187
+			$context['avatars'] = array();
3058 3188
 	}
3059
-	else
3060
-		$context['avatars'] = array();
3061 3189
 
3062 3190
 	// Second level selected avatar...
3063 3191
 	$context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1);
@@ -3086,19 +3214,22 @@  discard block
 block discarded – undo
3086 3214
 			)
3087 3215
 		);
3088 3216
 		$protected_groups = array(1);
3089
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3090
-			$protected_groups[] = $row['id_group'];
3217
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3218
+					$protected_groups[] = $row['id_group'];
3219
+		}
3091 3220
 		$smcFunc['db_free_result']($request);
3092 3221
 
3093 3222
 		$protected_groups = array_unique($protected_groups);
3094 3223
 	}
3095 3224
 
3096 3225
 	// The account page allows the change of your id_group - but not to a protected group!
3097
-	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0)
3098
-		$value = (int) $value;
3226
+	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) {
3227
+			$value = (int) $value;
3228
+	}
3099 3229
 	// ... otherwise it's the old group sir.
3100
-	else
3101
-		$value = $old_profile['id_group'];
3230
+	else {
3231
+			$value = $old_profile['id_group'];
3232
+	}
3102 3233
 
3103 3234
 	// Find the additional membergroups (if any)
3104 3235
 	if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups']))
@@ -3107,16 +3238,18 @@  discard block
 block discarded – undo
3107 3238
 		foreach ($_POST['additional_groups'] as $group_id)
3108 3239
 		{
3109 3240
 			$group_id = (int) $group_id;
3110
-			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups)))
3111
-				$additional_groups[] = $group_id;
3241
+			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) {
3242
+							$additional_groups[] = $group_id;
3243
+			}
3112 3244
 		}
3113 3245
 
3114 3246
 		// Put the protected groups back in there if you don't have permission to take them away.
3115 3247
 		$old_additional_groups = explode(',', $old_profile['additional_groups']);
3116 3248
 		foreach ($old_additional_groups as $group_id)
3117 3249
 		{
3118
-			if (!empty($protected_groups) && in_array($group_id, $protected_groups))
3119
-				$additional_groups[] = $group_id;
3250
+			if (!empty($protected_groups) && in_array($group_id, $protected_groups)) {
3251
+							$additional_groups[] = $group_id;
3252
+			}
3120 3253
 		}
3121 3254
 
3122 3255
 		if (implode(',', $additional_groups) !== $old_profile['additional_groups'])
@@ -3148,18 +3281,20 @@  discard block
 block discarded – undo
3148 3281
 			list ($another) = $smcFunc['db_fetch_row']($request);
3149 3282
 			$smcFunc['db_free_result']($request);
3150 3283
 
3151
-			if (empty($another))
3152
-				fatal_lang_error('at_least_one_admin', 'critical');
3284
+			if (empty($another)) {
3285
+							fatal_lang_error('at_least_one_admin', 'critical');
3286
+			}
3153 3287
 		}
3154 3288
 	}
3155 3289
 
3156 3290
 	// If we are changing group status, update permission cache as necessary.
3157 3291
 	if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups']))
3158 3292
 	{
3159
-		if ($context['user']['is_owner'])
3160
-			$_SESSION['mc']['time'] = 0;
3161
-		else
3162
-			updateSettings(array('settings_updated' => time()));
3293
+		if ($context['user']['is_owner']) {
3294
+					$_SESSION['mc']['time'] = 0;
3295
+		} else {
3296
+					updateSettings(array('settings_updated' => time()));
3297
+		}
3163 3298
 	}
3164 3299
 
3165 3300
 	// Announce to any hooks that we have changed groups, but don't allow them to change it.
@@ -3180,8 +3315,9 @@  discard block
 block discarded – undo
3180 3315
 	global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;
3181 3316
 
3182 3317
 	$memID = $context['id_member'];
3183
-	if (empty($memID) && !empty($context['password_auth_failed']))
3184
-		return false;
3318
+	if (empty($memID) && !empty($context['password_auth_failed'])) {
3319
+			return false;
3320
+	}
3185 3321
 
3186 3322
 	require_once($sourcedir . '/ManageAttachments.php');
3187 3323
 
@@ -3192,8 +3328,9 @@  discard block
 block discarded – undo
3192 3328
 	$downloadedExternalAvatar = false;
3193 3329
 	if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external']))
3194 3330
 	{
3195
-		if (!is_writable($uploadDir))
3196
-			fatal_lang_error('attachments_no_write', 'critical');
3331
+		if (!is_writable($uploadDir)) {
3332
+					fatal_lang_error('attachments_no_write', 'critical');
3333
+		}
3197 3334
 
3198 3335
 		$url = parse_url($_POST['userpicpersonal']);
3199 3336
 		$contents = fetch_web_data($url['scheme'] . '://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path'])));
@@ -3235,19 +3372,18 @@  discard block
 block discarded – undo
3235 3372
 
3236 3373
 		// Get rid of their old avatar. (if uploaded.)
3237 3374
 		removeAttachments(array('id_member' => $memID));
3238
-	}
3239
-	elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3375
+	} elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3240 3376
 	{
3241 3377
 		// One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar.
3242
-		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL))
3243
-			$profile_vars['avatar'] = 'gravatar://';
3244
-		else
3245
-			$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3378
+		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) {
3379
+					$profile_vars['avatar'] = 'gravatar://';
3380
+		} else {
3381
+					$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3382
+		}
3246 3383
 
3247 3384
 		// Get rid of their old avatar. (if uploaded.)
3248 3385
 		removeAttachments(array('id_member' => $memID));
3249
-	}
3250
-	elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3386
+	} elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3251 3387
 	{
3252 3388
 		// We need these clean...
3253 3389
 		$cur_profile['id_attach'] = 0;
@@ -3259,11 +3395,13 @@  discard block
 block discarded – undo
3259 3395
 
3260 3396
 		$profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']));
3261 3397
 
3262
-		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///')
3263
-			$profile_vars['avatar'] = '';
3398
+		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') {
3399
+					$profile_vars['avatar'] = '';
3400
+		}
3264 3401
 		// Trying to make us do something we'll regret?
3265
-		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://')
3266
-			return 'bad_avatar_invalid_url';
3402
+		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') {
3403
+					return 'bad_avatar_invalid_url';
3404
+		}
3267 3405
 		// Should we check dimensions?
3268 3406
 		elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))
3269 3407
 		{
@@ -3273,9 +3411,9 @@  discard block
 block discarded – undo
3273 3411
 			if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))))
3274 3412
 			{
3275 3413
 				// Houston, we have a problem. The avatar is too large!!
3276
-				if ($modSettings['avatar_action_too_large'] == 'option_refuse')
3277
-					return 'bad_avatar_too_large';
3278
-				elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3414
+				if ($modSettings['avatar_action_too_large'] == 'option_refuse') {
3415
+									return 'bad_avatar_too_large';
3416
+				} elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3279 3417
 				{
3280 3418
 					// @todo remove this if appropriate
3281 3419
 					require_once($sourcedir . '/Subs-Graphics.php');
@@ -3285,26 +3423,27 @@  discard block
 block discarded – undo
3285 3423
 						$cur_profile['id_attach'] = $modSettings['new_avatar_data']['id'];
3286 3424
 						$cur_profile['filename'] = $modSettings['new_avatar_data']['filename'];
3287 3425
 						$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
3426
+					} else {
3427
+											return 'bad_avatar';
3288 3428
 					}
3289
-					else
3290
-						return 'bad_avatar';
3291 3429
 				}
3292 3430
 			}
3293 3431
 		}
3294
-	}
3295
-	elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3432
+	} elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3296 3433
 	{
3297 3434
 		if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar)
3298 3435
 		{
3299 3436
 			// Get the dimensions of the image.
3300 3437
 			if (!$downloadedExternalAvatar)
3301 3438
 			{
3302
-				if (!is_writable($uploadDir))
3303
-					fatal_lang_error('attachments_no_write', 'critical');
3439
+				if (!is_writable($uploadDir)) {
3440
+									fatal_lang_error('attachments_no_write', 'critical');
3441
+				}
3304 3442
 
3305 3443
 				$new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true);
3306
-				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename))
3307
-					fatal_lang_error('attach_timeout', 'critical');
3444
+				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) {
3445
+									fatal_lang_error('attach_timeout', 'critical');
3446
+				}
3308 3447
 
3309 3448
 				$_FILES['attachment']['tmp_name'] = $new_filename;
3310 3449
 			}
@@ -3417,17 +3556,19 @@  discard block
 block discarded – undo
3417 3556
 			$profile_vars['avatar'] = '';
3418 3557
 
3419 3558
 			// Delete any temporary file.
3420
-			if (file_exists($_FILES['attachment']['tmp_name']))
3421
-				@unlink($_FILES['attachment']['tmp_name']);
3559
+			if (file_exists($_FILES['attachment']['tmp_name'])) {
3560
+							@unlink($_FILES['attachment']['tmp_name']);
3561
+			}
3422 3562
 		}
3423 3563
 		// Selected the upload avatar option and had one already uploaded before or didn't upload one.
3424
-		else
3564
+		else {
3565
+					$profile_vars['avatar'] = '';
3566
+		}
3567
+	} elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) {
3568
+			$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3569
+	} else {
3425 3570
 			$profile_vars['avatar'] = '';
3426 3571
 	}
3427
-	elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar'))
3428
-		$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3429
-	else
3430
-		$profile_vars['avatar'] = '';
3431 3572
 
3432 3573
 	// Setup the profile variables so it shows things right on display!
3433 3574
 	$cur_profile['avatar'] = $profile_vars['avatar'];
@@ -3475,9 +3616,9 @@  discard block
 block discarded – undo
3475 3616
 		$smiley_parsed = $unparsed_signature;
3476 3617
 		parsesmileys($smiley_parsed);
3477 3618
 		$smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img');
3478
-		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0)
3479
-			return 'signature_allow_smileys';
3480
-		elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3619
+		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) {
3620
+					return 'signature_allow_smileys';
3621
+		} elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3481 3622
 		{
3482 3623
 			$txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]);
3483 3624
 			return 'signature_max_smileys';
@@ -3490,14 +3631,15 @@  discard block
 block discarded – undo
3490 3631
 			{
3491 3632
 				$limit_broke = 0;
3492 3633
 				// Attempt to allow all sizes of abuse, so to speak.
3493
-				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
3494
-					$limit_broke = $sig_limits[7] . 'px';
3495
-				elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
3496
-					$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3497
-				elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
3498
-					$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3499
-				elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
3500
-					$limit_broke = 'large';
3634
+				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
3635
+									$limit_broke = $sig_limits[7] . 'px';
3636
+				} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
3637
+									$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3638
+				} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
3639
+									$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3640
+				} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
3641
+									$limit_broke = 'large';
3642
+				}
3501 3643
 
3502 3644
 				if ($limit_broke)
3503 3645
 				{
@@ -3539,24 +3681,26 @@  discard block
 block discarded – undo
3539 3681
 					$width = -1; $height = -1;
3540 3682
 
3541 3683
 					// Does it have predefined restraints? Width first.
3542
-					if ($matches[6][$key])
3543
-						$matches[2][$key] = $matches[6][$key];
3684
+					if ($matches[6][$key]) {
3685
+											$matches[2][$key] = $matches[6][$key];
3686
+					}
3544 3687
 					if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
3545 3688
 					{
3546 3689
 						$width = $sig_limits[5];
3547 3690
 						$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
3691
+					} elseif ($matches[2][$key]) {
3692
+											$width = $matches[2][$key];
3548 3693
 					}
3549
-					elseif ($matches[2][$key])
3550
-						$width = $matches[2][$key];
3551 3694
 					// ... and height.
3552 3695
 					if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
3553 3696
 					{
3554 3697
 						$height = $sig_limits[6];
3555
-						if ($width != -1)
3556
-							$width = $width * ($height / $matches[4][$key]);
3698
+						if ($width != -1) {
3699
+													$width = $width * ($height / $matches[4][$key]);
3700
+						}
3701
+					} elseif ($matches[4][$key]) {
3702
+											$height = $matches[4][$key];
3557 3703
 					}
3558
-					elseif ($matches[4][$key])
3559
-						$height = $matches[4][$key];
3560 3704
 
3561 3705
 					// If the dimensions are still not fixed - we need to check the actual image.
3562 3706
 					if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -3574,21 +3718,24 @@  discard block
 block discarded – undo
3574 3718
 							if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
3575 3719
 							{
3576 3720
 								$height = $sig_limits[6];
3577
-								if ($width == -1)
3578
-									$width = $sizes[0];
3721
+								if ($width == -1) {
3722
+																	$width = $sizes[0];
3723
+								}
3579 3724
 								$width = $width * ($height / $sizes[1]);
3725
+							} elseif ($width != -1) {
3726
+															$height = $sizes[1];
3580 3727
 							}
3581
-							elseif ($width != -1)
3582
-								$height = $sizes[1];
3583 3728
 						}
3584 3729
 					}
3585 3730
 
3586 3731
 					// Did we come up with some changes? If so remake the string.
3587
-					if ($width != -1 || $height != -1)
3588
-						$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3732
+					if ($width != -1 || $height != -1) {
3733
+											$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3734
+					}
3735
+				}
3736
+				if (!empty($replaces)) {
3737
+									$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3589 3738
 				}
3590
-				if (!empty($replaces))
3591
-					$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3592 3739
 			}
3593 3740
 		}
3594 3741
 
@@ -3632,10 +3779,12 @@  discard block
 block discarded – undo
3632 3779
 	$email = strtr($email, array('&#039;' => '\''));
3633 3780
 
3634 3781
 	// Check the name and email for validity.
3635
-	if (trim($email) == '')
3636
-		return 'no_email';
3637
-	if (!filter_var($email, FILTER_VALIDATE_EMAIL))
3638
-		return 'bad_email';
3782
+	if (trim($email) == '') {
3783
+			return 'no_email';
3784
+	}
3785
+	if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
3786
+			return 'bad_email';
3787
+	}
3639 3788
 
3640 3789
 	// Email addresses should be and stay unique.
3641 3790
 	$request = $smcFunc['db_query']('', '
@@ -3650,8 +3799,9 @@  discard block
 block discarded – undo
3650 3799
 		)
3651 3800
 	);
3652 3801
 
3653
-	if ($smcFunc['db_num_rows']($request) > 0)
3654
-		return 'email_taken';
3802
+	if ($smcFunc['db_num_rows']($request) > 0) {
3803
+			return 'email_taken';
3804
+	}
3655 3805
 	$smcFunc['db_free_result']($request);
3656 3806
 
3657 3807
 	return true;
@@ -3664,8 +3814,9 @@  discard block
 block discarded – undo
3664 3814
 {
3665 3815
 	global $modSettings, $context, $cur_profile;
3666 3816
 
3667
-	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '')
3668
-		setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3817
+	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') {
3818
+			setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3819
+	}
3669 3820
 
3670 3821
 	loadUserSettings();
3671 3822
 	writeLog();
@@ -3681,8 +3832,9 @@  discard block
 block discarded – undo
3681 3832
 	require_once($sourcedir . '/Subs-Post.php');
3682 3833
 
3683 3834
 	// Shouldn't happen but just in case.
3684
-	if (empty($profile_vars['email_address']))
3685
-		return;
3835
+	if (empty($profile_vars['email_address'])) {
3836
+			return;
3837
+	}
3686 3838
 
3687 3839
 	$replacements = array(
3688 3840
 		'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'],
@@ -3705,8 +3857,9 @@  discard block
 block discarded – undo
3705 3857
 	$_SESSION['log_time'] = 0;
3706 3858
 	$_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0));
3707 3859
 
3708
-	if (isset($_COOKIE[$cookiename]))
3709
-		$_COOKIE[$cookiename] = '';
3860
+	if (isset($_COOKIE[$cookiename])) {
3861
+			$_COOKIE[$cookiename] = '';
3862
+	}
3710 3863
 
3711 3864
 	loadUserSettings();
3712 3865
 
@@ -3739,11 +3892,13 @@  discard block
 block discarded – undo
3739 3892
 	$groups[] = $curMember['id_group'];
3740 3893
 
3741 3894
 	// Ensure the query doesn't croak!
3742
-	if (empty($groups))
3743
-		$groups = array(0);
3895
+	if (empty($groups)) {
3896
+			$groups = array(0);
3897
+	}
3744 3898
 	// Just to be sure...
3745
-	foreach ($groups as $k => $v)
3746
-		$groups[$k] = (int) $v;
3899
+	foreach ($groups as $k => $v) {
3900
+			$groups[$k] = (int) $v;
3901
+	}
3747 3902
 
3748 3903
 	// Get all the membergroups they can join.
3749 3904
 	$request = $smcFunc['db_query']('', '
@@ -3773,12 +3928,14 @@  discard block
 block discarded – undo
3773 3928
 	while ($row = $smcFunc['db_fetch_assoc']($request))
3774 3929
 	{
3775 3930
 		// Can they edit their primary group?
3776
-		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups)))
3777
-			$context['can_edit_primary'] = true;
3931
+		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) {
3932
+					$context['can_edit_primary'] = true;
3933
+		}
3778 3934
 
3779 3935
 		// If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it.
3780
-		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group'])
3781
-			continue;
3936
+		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) {
3937
+					continue;
3938
+		}
3782 3939
 
3783 3940
 		$context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array(
3784 3941
 			'id' => $row['id_group'],
@@ -3807,13 +3964,15 @@  discard block
 block discarded – undo
3807 3964
 	);
3808 3965
 
3809 3966
 	// No changing primary one unless you have enough groups!
3810
-	if (count($context['groups']['member']) < 2)
3811
-		$context['can_edit_primary'] = false;
3967
+	if (count($context['groups']['member']) < 2) {
3968
+			$context['can_edit_primary'] = false;
3969
+	}
3812 3970
 
3813 3971
 	// In the special case that someone is requesting membership of a group, setup some special context vars.
3814
-	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2)
3815
-		$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3816
-}
3972
+	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) {
3973
+			$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3974
+	}
3975
+	}
3817 3976
 
3818 3977
 /**
3819 3978
  * This function actually makes all the group changes
@@ -3828,10 +3987,12 @@  discard block
 block discarded – undo
3828 3987
 	global $user_info, $context, $user_profile, $modSettings, $smcFunc;
3829 3988
 
3830 3989
 	// Let's be extra cautious...
3831
-	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership']))
3832
-		isAllowedTo('manage_membergroups');
3833
-	if (!isset($_REQUEST['gid']) && !isset($_POST['primary']))
3834
-		fatal_lang_error('no_access', false);
3990
+	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) {
3991
+			isAllowedTo('manage_membergroups');
3992
+	}
3993
+	if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) {
3994
+			fatal_lang_error('no_access', false);
3995
+	}
3835 3996
 
3836 3997
 	checkSession(isset($_GET['gid']) ? 'get' : 'post');
3837 3998
 
@@ -3850,8 +4011,9 @@  discard block
 block discarded – undo
3850 4011
 	$foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false;
3851 4012
 
3852 4013
 	// Sanity check!!
3853
-	if ($group_id == 1)
3854
-		isAllowedTo('admin_forum');
4014
+	if ($group_id == 1) {
4015
+			isAllowedTo('admin_forum');
4016
+	}
3855 4017
 	// Protected groups too!
3856 4018
 	else
3857 4019
 	{
@@ -3868,8 +4030,9 @@  discard block
 block discarded – undo
3868 4030
 		list ($is_protected) = $smcFunc['db_fetch_row']($request);
3869 4031
 		$smcFunc['db_free_result']($request);
3870 4032
 
3871
-		if ($is_protected == 1)
3872
-			isAllowedTo('admin_forum');
4033
+		if ($is_protected == 1) {
4034
+					isAllowedTo('admin_forum');
4035
+		}
3873 4036
 	}
3874 4037
 
3875 4038
 	// What ever we are doing, we need to determine if changing primary is possible!
@@ -3891,36 +4054,43 @@  discard block
 block discarded – undo
3891 4054
 			$group_name = $row['group_name'];
3892 4055
 
3893 4056
 			// Does the group type match what we're doing - are we trying to request a non-requestable group?
3894
-			if ($changeType == 'request' && $row['group_type'] != 2)
3895
-				fatal_lang_error('no_access', false);
4057
+			if ($changeType == 'request' && $row['group_type'] != 2) {
4058
+							fatal_lang_error('no_access', false);
4059
+			}
3896 4060
 			// What about leaving a requestable group we are not a member of?
3897
-			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']]))
3898
-				fatal_lang_error('no_access', false);
3899
-			elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2)
3900
-				fatal_lang_error('no_access', false);
4061
+			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) {
4062
+							fatal_lang_error('no_access', false);
4063
+			} elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) {
4064
+							fatal_lang_error('no_access', false);
4065
+			}
3901 4066
 
3902 4067
 			// We can't change the primary group if this is hidden!
3903
-			if ($row['hidden'] == 2)
3904
-				$canChangePrimary = false;
4068
+			if ($row['hidden'] == 2) {
4069
+							$canChangePrimary = false;
4070
+			}
3905 4071
 		}
3906 4072
 
3907 4073
 		// If this is their old primary, can we change it?
3908
-		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false)
3909
-			$canChangePrimary = 1;
4074
+		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) {
4075
+					$canChangePrimary = 1;
4076
+		}
3910 4077
 
3911 4078
 		// If we are not doing a force primary move, don't do it automatically if current primary is not 0.
3912
-		if ($changeType != 'primary' && $old_profile['id_group'] != 0)
3913
-			$canChangePrimary = false;
4079
+		if ($changeType != 'primary' && $old_profile['id_group'] != 0) {
4080
+					$canChangePrimary = false;
4081
+		}
3914 4082
 
3915 4083
 		// If this is the one we are acting on, can we even act?
3916
-		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0))
3917
-			$canChangePrimary = false;
4084
+		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) {
4085
+					$canChangePrimary = false;
4086
+		}
3918 4087
 	}
3919 4088
 	$smcFunc['db_free_result']($request);
3920 4089
 
3921 4090
 	// Didn't find the target?
3922
-	if (!$foundTarget)
3923
-		fatal_lang_error('no_access', false);
4091
+	if (!$foundTarget) {
4092
+			fatal_lang_error('no_access', false);
4093
+	}
3924 4094
 
3925 4095
 	// Final security check, don't allow users to promote themselves to admin.
3926 4096
 	if ($context['can_manage_membergroups'] && !allowedTo('admin_forum'))
@@ -3940,8 +4110,9 @@  discard block
 block discarded – undo
3940 4110
 		list ($disallow) = $smcFunc['db_fetch_row']($request);
3941 4111
 		$smcFunc['db_free_result']($request);
3942 4112
 
3943
-		if ($disallow)
3944
-			isAllowedTo('admin_forum');
4113
+		if ($disallow) {
4114
+					isAllowedTo('admin_forum');
4115
+		}
3945 4116
 	}
3946 4117
 
3947 4118
 	// If we're requesting, add the note then return.
@@ -3959,8 +4130,9 @@  discard block
 block discarded – undo
3959 4130
 				'status_open' => 0,
3960 4131
 			)
3961 4132
 		);
3962
-		if ($smcFunc['db_num_rows']($request) != 0)
3963
-			fatal_lang_error('profile_error_already_requested_group');
4133
+		if ($smcFunc['db_num_rows']($request) != 0) {
4134
+					fatal_lang_error('profile_error_already_requested_group');
4135
+		}
3964 4136
 		$smcFunc['db_free_result']($request);
3965 4137
 
3966 4138
 		// Log the request.
@@ -3994,10 +4166,11 @@  discard block
 block discarded – undo
3994 4166
 		// Are we leaving?
3995 4167
 		if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id]))
3996 4168
 		{
3997
-			if ($old_profile['id_group'] == $group_id)
3998
-				$newPrimary = 0;
3999
-			else
4000
-				unset($addGroups[$group_id]);
4169
+			if ($old_profile['id_group'] == $group_id) {
4170
+							$newPrimary = 0;
4171
+			} else {
4172
+							unset($addGroups[$group_id]);
4173
+			}
4001 4174
 		}
4002 4175
 		// ... if not, must be joining.
4003 4176
 		else
@@ -4005,36 +4178,42 @@  discard block
 block discarded – undo
4005 4178
 			// Can we change the primary, and do we want to?
4006 4179
 			if ($canChangePrimary)
4007 4180
 			{
4008
-				if ($old_profile['id_group'] != 0)
4009
-					$addGroups[$old_profile['id_group']] = -1;
4181
+				if ($old_profile['id_group'] != 0) {
4182
+									$addGroups[$old_profile['id_group']] = -1;
4183
+				}
4010 4184
 				$newPrimary = $group_id;
4011 4185
 			}
4012 4186
 			// Otherwise it's an additional group...
4013
-			else
4014
-				$addGroups[$group_id] = -1;
4187
+			else {
4188
+							$addGroups[$group_id] = -1;
4189
+			}
4015 4190
 		}
4016 4191
 	}
4017 4192
 	// Finally, we must be setting the primary.
4018 4193
 	elseif ($canChangePrimary)
4019 4194
 	{
4020
-		if ($old_profile['id_group'] != 0)
4021
-			$addGroups[$old_profile['id_group']] = -1;
4022
-		if (isset($addGroups[$group_id]))
4023
-			unset($addGroups[$group_id]);
4195
+		if ($old_profile['id_group'] != 0) {
4196
+					$addGroups[$old_profile['id_group']] = -1;
4197
+		}
4198
+		if (isset($addGroups[$group_id])) {
4199
+					unset($addGroups[$group_id]);
4200
+		}
4024 4201
 		$newPrimary = $group_id;
4025 4202
 	}
4026 4203
 
4027 4204
 	// Finally, we can make the changes!
4028
-	foreach ($addGroups as $id => $dummy)
4029
-		if (empty($id))
4205
+	foreach ($addGroups as $id => $dummy) {
4206
+			if (empty($id))
4030 4207
 			unset($addGroups[$id]);
4208
+	}
4031 4209
 	$addGroups = implode(',', array_flip($addGroups));
4032 4210
 
4033 4211
 	// Ensure that we don't cache permissions if the group is changing.
4034
-	if ($context['user']['is_owner'])
4035
-		$_SESSION['mc']['time'] = 0;
4036
-	else
4037
-		updateSettings(array('settings_updated' => time()));
4212
+	if ($context['user']['is_owner']) {
4213
+			$_SESSION['mc']['time'] = 0;
4214
+	} else {
4215
+			updateSettings(array('settings_updated' => time()));
4216
+	}
4038 4217
 
4039 4218
 	updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups));
4040 4219
 
@@ -4057,8 +4236,9 @@  discard block
 block discarded – undo
4057 4236
 	if (empty($user_settings['tfa_secret']) && $context['user']['is_owner'])
4058 4237
 	{
4059 4238
 		// Check to ensure we're forcing SSL for authentication
4060
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
4061
-			fatal_lang_error('login_ssl_required');
4239
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
4240
+					fatal_lang_error('login_ssl_required');
4241
+		}
4062 4242
 
4063 4243
 		// In some cases (forced 2FA or backup code) they would be forced to be redirected here,
4064 4244
 		// we do not want too much AJAX to confuse them.
@@ -4095,8 +4275,7 @@  discard block
 block discarded – undo
4095 4275
 				$context['sub_template'] = 'tfasetup_backup';
4096 4276
 
4097 4277
 				return;
4098
-			}
4099
-			else
4278
+			} else
4100 4279
 			{
4101 4280
 				$context['tfa_secret'] = $_SESSION['tfa_secret'];
4102 4281
 				$context['tfa_error'] = !$valid_code;
@@ -4104,8 +4283,7 @@  discard block
 block discarded – undo
4104 4283
 				$context['tfa_pass_value'] = $_POST['passwd'];
4105 4284
 				$context['tfa_value'] = $_POST['tfa_code'];
4106 4285
 			}
4107
-		}
4108
-		else
4286
+		} else
4109 4287
 		{
4110 4288
 			$totp = new \TOTP\Auth();
4111 4289
 			$secret = $totp->generateCode();
@@ -4115,17 +4293,16 @@  discard block
 block discarded – undo
4115 4293
 		}
4116 4294
 
4117 4295
 		$context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']);
4118
-	}
4119
-	elseif (isset($_REQUEST['disable']))
4296
+	} elseif (isset($_REQUEST['disable']))
4120 4297
 	{
4121 4298
 		updateMemberData($memID, array(
4122 4299
 			'tfa_secret' => '',
4123 4300
 			'tfa_backup' => '',
4124 4301
 		));
4125 4302
 		redirectexit('action=profile;area=account;u=' . $memID);
4303
+	} else {
4304
+			redirectexit('action=profile;area=account;u=' . $memID);
4305
+	}
4126 4306
 	}
4127
-	else
4128
-		redirectexit('action=profile;area=account;u=' . $memID);
4129
-}
4130 4307
 
4131 4308
 ?>
4132 4309
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 1 patch
Braces   +409 added lines, -307 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * !!!Compatibility!!!
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 {
32 33
 	global $modSettings;
33 34
 
34
-	if (!$compat_mode)
35
-		return $text;
35
+	if (!$compat_mode) {
36
+			return $text;
37
+	}
36 38
 
37 39
 	// Turn line breaks back into br's.
38 40
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
50 52
 			{
51 53
 				// Value of 2 means we're inside the tag.
52
-				if ($i % 4 == 2)
53
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
54
+				if ($i % 4 == 2) {
55
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
56
+				}
54 57
 			}
55 58
 			// Put our humpty dumpty message back together again.
56 59
 			$text = implode('', $parts);
@@ -109,8 +112,9 @@  discard block
 block discarded – undo
109 112
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
110 113
 
111 114
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
112
-	if (isBrowser('webkit'))
113
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
115
+	if (isBrowser('webkit')) {
116
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
117
+	}
114 118
 
115 119
 	// If there's a trailing break get rid of it - Firefox tends to add one.
116 120
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -125,8 +129,9 @@  discard block
 block discarded – undo
125 129
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
126 130
 		{
127 131
 			// Value of 2 means we're inside the tag.
128
-			if ($i % 4 == 2)
129
-				$parts[$i] = strip_tags($parts[$i]);
132
+			if ($i % 4 == 2) {
133
+							$parts[$i] = strip_tags($parts[$i]);
134
+			}
130 135
 		}
131 136
 
132 137
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -152,18 +157,19 @@  discard block
 block discarded – undo
152 157
 			{
153 158
 				$found = array_search($file, $smileysto);
154 159
 				// Note the weirdness here is to stop double spaces between smileys.
155
-				if ($found)
156
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
157
-				else
158
-					$matches[1][$k] = '';
160
+				if ($found) {
161
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
162
+				} else {
163
+									$matches[1][$k] = '';
164
+				}
159 165
 			}
160
-		}
161
-		else
166
+		} else
162 167
 		{
163 168
 			// Load all the smileys.
164 169
 			$names = array();
165
-			foreach ($matches[1] as $file)
166
-				$names[] = $file;
170
+			foreach ($matches[1] as $file) {
171
+							$names[] = $file;
172
+			}
167 173
 			$names = array_unique($names);
168 174
 
169 175
 			if (!empty($names))
@@ -177,13 +183,15 @@  discard block
 block discarded – undo
177 183
 					)
178 184
 				);
179 185
 				$mappings = array();
180
-				while ($row = $smcFunc['db_fetch_assoc']($request))
181
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
186
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
187
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
188
+				}
182 189
 				$smcFunc['db_free_result']($request);
183 190
 
184
-				foreach ($matches[1] as $k => $file)
185
-					if (isset($mappings[$file]))
191
+				foreach ($matches[1] as $k => $file) {
192
+									if (isset($mappings[$file]))
186 193
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
194
+				}
187 195
 			}
188 196
 		}
189 197
 
@@ -195,8 +203,9 @@  discard block
 block discarded – undo
195 203
 	}
196 204
 
197 205
 	// Only try to buy more time if the client didn't quit.
198
-	if (connection_aborted() && $context['server']['is_apache'])
199
-		@apache_reset_timeout();
206
+	if (connection_aborted() && $context['server']['is_apache']) {
207
+			@apache_reset_timeout();
208
+	}
200 209
 
201 210
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
202 211
 	$replacement = '';
@@ -207,9 +216,9 @@  discard block
 block discarded – undo
207 216
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
208 217
 		{
209 218
 			// If it's being closed instantly, we can't deal with it...yet.
210
-			if ($matches[5] === '/')
211
-				continue;
212
-			else
219
+			if ($matches[5] === '/') {
220
+							continue;
221
+			} else
213 222
 			{
214 223
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
215 224
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -225,8 +234,9 @@  discard block
 block discarded – undo
225 234
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
226 235
 
227 236
 					// Something like 'font-weight: bold' is expected here.
228
-					if (strpos($clean_type_value_pair, ':') === false)
229
-						continue;
237
+					if (strpos($clean_type_value_pair, ':') === false) {
238
+											continue;
239
+					}
230 240
 
231 241
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
232 242
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -248,8 +258,7 @@  discard block
 block discarded – undo
248 258
 							{
249 259
 								$curCloseTags .= '[/u]';
250 260
 								$replacement .= '[u]';
251
-							}
252
-							elseif ($style_value == 'line-through')
261
+							} elseif ($style_value == 'line-through')
253 262
 							{
254 263
 								$curCloseTags .= '[/s]';
255 264
 								$replacement .= '[s]';
@@ -261,13 +270,11 @@  discard block
 block discarded – undo
261 270
 							{
262 271
 								$curCloseTags .= '[/left]';
263 272
 								$replacement .= '[left]';
264
-							}
265
-							elseif ($style_value == 'center')
273
+							} elseif ($style_value == 'center')
266 274
 							{
267 275
 								$curCloseTags .= '[/center]';
268 276
 								$replacement .= '[center]';
269
-							}
270
-							elseif ($style_value == 'right')
277
+							} elseif ($style_value == 'right')
271 278
 							{
272 279
 								$curCloseTags .= '[/right]';
273 280
 								$replacement .= '[right]';
@@ -289,8 +296,9 @@  discard block
 block discarded – undo
289 296
 
290 297
 						case 'font-size':
291 298
 							// Sometimes people put decimals where decimals should not be.
292
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
293
-								$style_value = $dec_matches[1] . $dec_matches[2];
299
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
300
+															$style_value = $dec_matches[1] . $dec_matches[2];
301
+							}
294 302
 
295 303
 							$curCloseTags .= '[/size]';
296 304
 							$replacement .= '[size=' . $style_value . ']';
@@ -298,8 +306,9 @@  discard block
 block discarded – undo
298 306
 
299 307
 						case 'font-family':
300 308
 							// Only get the first freaking font if there's a list!
301
-							if (strpos($style_value, ',') !== false)
302
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
309
+							if (strpos($style_value, ',') !== false) {
310
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
311
+							}
303 312
 
304 313
 							$curCloseTags .= '[/font]';
305 314
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -308,13 +317,15 @@  discard block
 block discarded – undo
308 317
 						// This is a hack for images with dimensions embedded.
309 318
 						case 'width':
310 319
 						case 'height':
311
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
312
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
320
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
321
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
322
+							}
313 323
 						break;
314 324
 
315 325
 						case 'list-style-type':
316
-							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1)
317
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
326
+							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) {
327
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
328
+							}
318 329
 						break;
319 330
 					}
320 331
 				}
@@ -327,18 +338,17 @@  discard block
 block discarded – undo
327 338
 				}
328 339
 
329 340
 				// If there's something that still needs closing, push it to the stack.
330
-				if (!empty($curCloseTags))
331
-					array_push($stack, array(
341
+				if (!empty($curCloseTags)) {
342
+									array_push($stack, array(
332 343
 							'element' => strtolower($curElement),
333 344
 							'closeTags' => $curCloseTags
334 345
 						)
335 346
 					);
336
-				elseif (!empty($extra_attr))
337
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
347
+				} elseif (!empty($extra_attr)) {
348
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
349
+				}
338 350
 			}
339
-		}
340
-
341
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
351
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
342 352
 		{
343 353
 			// Is this the element that we've been waiting for to be closed?
344 354
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -348,28 +358,32 @@  discard block
 block discarded – undo
348 358
 			}
349 359
 
350 360
 			// Must've been something else.
351
-			else
352
-				$replacement .= $part;
361
+			else {
362
+							$replacement .= $part;
363
+			}
353 364
 		}
354 365
 		// In all other cases, just add the part to the replacement.
355
-		else
356
-			$replacement .= $part;
366
+		else {
367
+					$replacement .= $part;
368
+		}
357 369
 	}
358 370
 
359 371
 	// Now put back the replacement in the text.
360 372
 	$text = $replacement;
361 373
 
362 374
 	// We are not finished yet, request more time.
363
-	if (connection_aborted() && $context['server']['is_apache'])
364
-		@apache_reset_timeout();
375
+	if (connection_aborted() && $context['server']['is_apache']) {
376
+			@apache_reset_timeout();
377
+	}
365 378
 
366 379
 	// Let's pull out any legacy alignments.
367 380
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
368 381
 	{
369 382
 		// Find the position in the text of this tag over again.
370 383
 		$start_pos = strpos($text, $matches[0]);
371
-		if ($start_pos === false)
372
-			break;
384
+		if ($start_pos === false) {
385
+					break;
386
+		}
373 387
 
374 388
 		// End tag?
375 389
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -383,8 +397,7 @@  discard block
 block discarded – undo
383 397
 
384 398
 			// Put the tags back into the body.
385 399
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
386
-		}
387
-		else
400
+		} else
388 401
 		{
389 402
 			// Just get rid of this evil tag.
390 403
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -397,8 +410,9 @@  discard block
 block discarded – undo
397 410
 		// Find the position of this again.
398 411
 		$start_pos = strpos($text, $matches[0]);
399 412
 		$end_pos = false;
400
-		if ($start_pos === false)
401
-			break;
413
+		if ($start_pos === false) {
414
+					break;
415
+		}
402 416
 
403 417
 		// This must have an end tag - and we must find the right one.
404 418
 		$lower_text = strtolower($text);
@@ -431,8 +445,9 @@  discard block
 block discarded – undo
431 445
 				break;
432 446
 			}
433 447
 		}
434
-		if ($end_pos === false)
435
-			break;
448
+		if ($end_pos === false) {
449
+					break;
450
+		}
436 451
 
437 452
 		// Now work out what the attributes are.
438 453
 		$attribs = fetchTagAttributes($matches[1]);
@@ -446,11 +461,11 @@  discard block
 block discarded – undo
446 461
 				$v = (int) trim($v);
447 462
 				$v = empty($v) ? 1 : $v;
448 463
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
464
+			} elseif ($s == 'face') {
465
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
466
+			} elseif ($s == 'color') {
467
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
449 468
 			}
450
-			elseif ($s == 'face')
451
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
452
-			elseif ($s == 'color')
453
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
454 469
 		}
455 470
 
456 471
 		// As before add in our tags.
@@ -458,8 +473,9 @@  discard block
 block discarded – undo
458 473
 		foreach ($tags as $tag)
459 474
 		{
460 475
 			$before .= $tag[0];
461
-			if (isset($tag[1]))
462
-				$after = $tag[1] . $after;
476
+			if (isset($tag[1])) {
477
+							$after = $tag[1] . $after;
478
+			}
463 479
 		}
464 480
 
465 481
 		// Remove the tag so it's never checked again.
@@ -470,8 +486,9 @@  discard block
 block discarded – undo
470 486
 	}
471 487
 
472 488
 	// Almost there, just a little more time.
473
-	if (connection_aborted() && $context['server']['is_apache'])
474
-		@apache_reset_timeout();
489
+	if (connection_aborted() && $context['server']['is_apache']) {
490
+			@apache_reset_timeout();
491
+	}
475 492
 
476 493
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
477 494
 	{
@@ -527,12 +544,13 @@  discard block
 block discarded – undo
527 544
 						{
528 545
 							$inList = true;
529 546
 
530
-							if ($tag === 'ol')
531
-								$listType = 'decimal';
532
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
533
-								$listType = $listTypeMapping[$match[1]];
534
-							else
535
-								$listType = null;
547
+							if ($tag === 'ol') {
548
+															$listType = 'decimal';
549
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
550
+															$listType = $listTypeMapping[$match[1]];
551
+							} else {
552
+															$listType = null;
553
+							}
536 554
 
537 555
 							$listDepth++;
538 556
 
@@ -596,9 +614,7 @@  discard block
 block discarded – undo
596 614
 							$parts[$i + 1] = '';
597 615
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
598 616
 							$parts[$i + 3] = '';
599
-						}
600
-
601
-						else
617
+						} else
602 618
 						{
603 619
 							// We're in a list item.
604 620
 							if ($listDepth > 0)
@@ -635,9 +651,7 @@  discard block
 block discarded – undo
635 651
 							$parts[$i + 1] = '';
636 652
 							$parts[$i + 2] = '';
637 653
 							$parts[$i + 3] = '';
638
-						}
639
-
640
-						else
654
+						} else
641 655
 						{
642 656
 							// Remove the trailing breaks from the list item.
643 657
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -675,8 +689,9 @@  discard block
 block discarded – undo
675 689
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
676 690
 		}
677 691
 
678
-		for ($i = $listDepth; $i > 0; $i--)
679
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
692
+		for ($i = $listDepth; $i > 0; $i--) {
693
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
694
+		}
680 695
 	}
681 696
 
682 697
 	// I love my own image...
@@ -684,8 +699,9 @@  discard block
 block discarded – undo
684 699
 	{
685 700
 		// Find the position of the image.
686 701
 		$start_pos = strpos($text, $matches[0]);
687
-		if ($start_pos === false)
688
-			break;
702
+		if ($start_pos === false) {
703
+					break;
704
+		}
689 705
 		$end_pos = $start_pos + strlen($matches[0]);
690 706
 
691 707
 		$params = '';
@@ -694,12 +710,13 @@  discard block
 block discarded – undo
694 710
 		$attrs = fetchTagAttributes($matches[1]);
695 711
 		foreach ($attrs as $attrib => $value)
696 712
 		{
697
-			if (in_array($attrib, array('width', 'height')))
698
-				$params .= ' ' . $attrib . '=' . (int) $value;
699
-			elseif ($attrib == 'alt' && trim($value) != '')
700
-				$params .= ' alt=' . trim($value);
701
-			elseif ($attrib == 'src')
702
-				$src = trim($value);
713
+			if (in_array($attrib, array('width', 'height'))) {
714
+							$params .= ' ' . $attrib . '=' . (int) $value;
715
+			} elseif ($attrib == 'alt' && trim($value) != '') {
716
+							$params .= ' alt=' . trim($value);
717
+			} elseif ($attrib == 'src') {
718
+							$src = trim($value);
719
+			}
703 720
 		}
704 721
 
705 722
 		$tag = '';
@@ -710,10 +727,11 @@  discard block
 block discarded – undo
710 727
 			{
711 728
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
712 729
 
713
-				if (substr($src, 0, 1) === '/')
714
-					$src = $baseURL . $src;
715
-				else
716
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
730
+				if (substr($src, 0, 1) === '/') {
731
+									$src = $baseURL . $src;
732
+				} else {
733
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
734
+				}
717 735
 			}
718 736
 
719 737
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -891,20 +909,23 @@  discard block
 block discarded – undo
891 909
 		},
892 910
 	);
893 911
 
894
-	foreach ($tags as $tag => $replace)
895
-		$text = preg_replace_callback($tag, $replace, $text);
912
+	foreach ($tags as $tag => $replace) {
913
+			$text = preg_replace_callback($tag, $replace, $text);
914
+	}
896 915
 
897 916
 	// Please give us just a little more time.
898
-	if (connection_aborted() && $context['server']['is_apache'])
899
-		@apache_reset_timeout();
917
+	if (connection_aborted() && $context['server']['is_apache']) {
918
+			@apache_reset_timeout();
919
+	}
900 920
 
901 921
 	// What about URL's - the pain in the ass of the tag world.
902 922
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
903 923
 	{
904 924
 		// Find the position of the URL.
905 925
 		$start_pos = strpos($text, $matches[0]);
906
-		if ($start_pos === false)
907
-			break;
926
+		if ($start_pos === false) {
927
+					break;
928
+		}
908 929
 		$end_pos = $start_pos + strlen($matches[0]);
909 930
 
910 931
 		$tag_type = 'url';
@@ -918,8 +939,9 @@  discard block
 block discarded – undo
918 939
 				$href = trim($value);
919 940
 
920 941
 				// Are we dealing with an FTP link?
921
-				if (preg_match('~^ftps?://~', $href) === 1)
922
-					$tag_type = 'ftp';
942
+				if (preg_match('~^ftps?://~', $href) === 1) {
943
+									$tag_type = 'ftp';
944
+				}
923 945
 
924 946
 				// Or is this a link to an email address?
925 947
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -933,28 +955,31 @@  discard block
 block discarded – undo
933 955
 				{
934 956
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
935 957
 
936
-					if (substr($href, 0, 1) === '/')
937
-						$href = $baseURL . $href;
938
-					else
939
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
958
+					if (substr($href, 0, 1) === '/') {
959
+											$href = $baseURL . $href;
960
+					} else {
961
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
962
+					}
940 963
 				}
941 964
 			}
942 965
 
943 966
 			// External URL?
944 967
 			if ($attrib == 'target' && $tag_type == 'url')
945 968
 			{
946
-				if (trim($value) == '_blank')
947
-					$tag_type == 'iurl';
969
+				if (trim($value) == '_blank') {
970
+									$tag_type == 'iurl';
971
+				}
948 972
 			}
949 973
 		}
950 974
 
951 975
 		$tag = '';
952 976
 		if ($href != '')
953 977
 		{
954
-			if ($matches[2] == $href)
955
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
956
-			else
957
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
978
+			if ($matches[2] == $href) {
979
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
980
+			} else {
981
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
982
+			}
958 983
 		}
959 984
 
960 985
 		// Replace the tag
@@ -994,17 +1019,18 @@  discard block
 block discarded – undo
994 1019
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
995 1020
 		if ($text[$i] == '=')
996 1021
 		{
997
-			if ($tag_state == 0)
998
-				$tag_state = 1;
999
-			elseif ($tag_state == 2)
1000
-				$value .= '=';
1022
+			if ($tag_state == 0) {
1023
+							$tag_state = 1;
1024
+			} elseif ($tag_state == 2) {
1025
+							$value .= '=';
1026
+			}
1001 1027
 		}
1002 1028
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
1003 1029
 		elseif ($text[$i] == ' ')
1004 1030
 		{
1005
-			if ($tag_state == 2)
1006
-				$value .= ' ';
1007
-			elseif ($tag_state == 1)
1031
+			if ($tag_state == 2) {
1032
+							$value .= ' ';
1033
+			} elseif ($tag_state == 1)
1008 1034
 			{
1009 1035
 				$attribs[$key] = $value;
1010 1036
 				$key = $value = '';
@@ -1015,24 +1041,27 @@  discard block
 block discarded – undo
1015 1041
 		elseif ($text[$i] == '"')
1016 1042
 		{
1017 1043
 			// Must be either going into or out of a string.
1018
-			if ($tag_state == 1)
1019
-				$tag_state = 2;
1020
-			else
1021
-				$tag_state = 1;
1044
+			if ($tag_state == 1) {
1045
+							$tag_state = 2;
1046
+			} else {
1047
+							$tag_state = 1;
1048
+			}
1022 1049
 		}
1023 1050
 		// Otherwise it's fine.
1024 1051
 		else
1025 1052
 		{
1026
-			if ($tag_state == 0)
1027
-				$key .= $text[$i];
1028
-			else
1029
-				$value .= $text[$i];
1053
+			if ($tag_state == 0) {
1054
+							$key .= $text[$i];
1055
+			} else {
1056
+							$value .= $text[$i];
1057
+			}
1030 1058
 		}
1031 1059
 	}
1032 1060
 
1033 1061
 	// Anything left?
1034
-	if ($key != '' && $value != '')
1035
-		$attribs[$key] = $value;
1062
+	if ($key != '' && $value != '') {
1063
+			$attribs[$key] = $value;
1064
+	}
1036 1065
 
1037 1066
 	return $attribs;
1038 1067
 }
@@ -1050,15 +1079,17 @@  discard block
 block discarded – undo
1050 1079
 	global $modSettings;
1051 1080
 
1052 1081
 	// Don't care about the texts that are too short.
1053
-	if (strlen($text) < 3)
1054
-		return $text;
1082
+	if (strlen($text) < 3) {
1083
+			return $text;
1084
+	}
1055 1085
 
1056 1086
 	// A list of tags that's disabled by the admin.
1057 1087
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
1058 1088
 
1059 1089
 	// Add flash if it's disabled as embedded tag.
1060
-	if (empty($modSettings['enableEmbeddedFlash']))
1061
-		$disabled['flash'] = true;
1090
+	if (empty($modSettings['enableEmbeddedFlash'])) {
1091
+			$disabled['flash'] = true;
1092
+	}
1062 1093
 
1063 1094
 	// Get a list of all the tags that are not disabled.
1064 1095
 	$all_tags = parse_bbc(false);
@@ -1066,10 +1097,12 @@  discard block
 block discarded – undo
1066 1097
 	$self_closing_tags = array();
1067 1098
 	foreach ($all_tags as $tag)
1068 1099
 	{
1069
-		if (!isset($disabled[$tag['tag']]))
1070
-			$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1071
-		if (isset($tag['type']) && $tag['type'] == 'closed')
1072
-			$self_closing_tags[] = $tag['tag'];
1100
+		if (!isset($disabled[$tag['tag']])) {
1101
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1102
+		}
1103
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1104
+					$self_closing_tags[] = $tag['tag'];
1105
+		}
1073 1106
 	}
1074 1107
 
1075 1108
 	// Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid!
@@ -1096,16 +1129,19 @@  discard block
 block discarded – undo
1096 1129
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1097 1130
 
1098 1131
 				// We're closing the exact same tag that we opened.
1099
-				if ($isClosingTag && $insideTag === $tagName)
1100
-					$insideTag = null;
1132
+				if ($isClosingTag && $insideTag === $tagName) {
1133
+									$insideTag = null;
1134
+				}
1101 1135
 
1102 1136
 				// We're opening a tag and we're not yet inside one either
1103
-				elseif (!$isClosingTag && $insideTag === null)
1104
-					$insideTag = $tagName;
1137
+				elseif (!$isClosingTag && $insideTag === null) {
1138
+									$insideTag = $tagName;
1139
+				}
1105 1140
 
1106 1141
 				// In all other cases, this tag must be invalid
1107
-				else
1108
-					unset($matches[$i]);
1142
+				else {
1143
+									unset($matches[$i]);
1144
+				}
1109 1145
 			}
1110 1146
 
1111 1147
 			// The next one is gonna be the other one.
@@ -1113,8 +1149,9 @@  discard block
 block discarded – undo
1113 1149
 		}
1114 1150
 
1115 1151
 		// We're still inside a tag and had no chance for closure?
1116
-		if ($insideTag !== null)
1117
-			$matches[] = '[/' . $insideTag . ']';
1152
+		if ($insideTag !== null) {
1153
+					$matches[] = '[/' . $insideTag . ']';
1154
+		}
1118 1155
 
1119 1156
 		// And a complete text string again.
1120 1157
 		$text = implode('', $matches);
@@ -1123,8 +1160,9 @@  discard block
 block discarded – undo
1123 1160
 	// Quickly remove any tags which are back to back.
1124 1161
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1125 1162
 	$lastlen = 0;
1126
-	while (strlen($text) !== $lastlen)
1127
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1163
+	while (strlen($text) !== $lastlen) {
1164
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1165
+	}
1128 1166
 
1129 1167
 	// Need to sort the tags my name length.
1130 1168
 	uksort($valid_tags, 'sort_array_length');
@@ -1161,8 +1199,9 @@  discard block
 block discarded – undo
1161 1199
 			$isCompetingTag = in_array($tag, $competing_tags);
1162 1200
 
1163 1201
 			// Check if this might be one of those cleaned out tags.
1164
-			if ($tag === '')
1165
-				continue;
1202
+			if ($tag === '') {
1203
+							continue;
1204
+			}
1166 1205
 
1167 1206
 			// Special case: inside [code] blocks any code is left untouched.
1168 1207
 			elseif ($tag === 'code')
@@ -1173,8 +1212,9 @@  discard block
 block discarded – undo
1173 1212
 					$inCode = false;
1174 1213
 
1175 1214
 					// Reopen tags that were closed before the code block.
1176
-					if (!empty($inlineElements))
1177
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1215
+					if (!empty($inlineElements)) {
1216
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1217
+					}
1178 1218
 				}
1179 1219
 
1180 1220
 				// We're outside a coding and nobbc block and opening it.
@@ -1203,8 +1243,9 @@  discard block
 block discarded – undo
1203 1243
 					$inNoBbc = false;
1204 1244
 
1205 1245
 					// Some inline elements might've been closed that need reopening.
1206
-					if (!empty($inlineElements))
1207
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1246
+					if (!empty($inlineElements)) {
1247
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1248
+					}
1208 1249
 				}
1209 1250
 
1210 1251
 				// We're outside a nobbc and coding block and opening it.
@@ -1224,8 +1265,9 @@  discard block
 block discarded – undo
1224 1265
 			}
1225 1266
 
1226 1267
 			// So, we're inside one of the special blocks: ignore any tag.
1227
-			elseif ($inCode || $inNoBbc)
1228
-				continue;
1268
+			elseif ($inCode || $inNoBbc) {
1269
+							continue;
1270
+			}
1229 1271
 
1230 1272
 			// We're dealing with an opening tag.
1231 1273
 			if ($isOpeningTag)
@@ -1266,8 +1308,9 @@  discard block
 block discarded – undo
1266 1308
 							if ($parts[$j + 3] === $tag)
1267 1309
 							{
1268 1310
 								// If it's an opening tag, increase the level.
1269
-								if ($parts[$j + 2] === '')
1270
-									$curLevel++;
1311
+								if ($parts[$j + 2] === '') {
1312
+																	$curLevel++;
1313
+								}
1271 1314
 
1272 1315
 								// A closing tag, decrease the level.
1273 1316
 								else
@@ -1290,13 +1333,15 @@  discard block
 block discarded – undo
1290 1333
 					{
1291 1334
 						if ($isCompetingTag)
1292 1335
 						{
1293
-							if (!isset($competingElements[$tag]))
1294
-								$competingElements[$tag] = array();
1336
+							if (!isset($competingElements[$tag])) {
1337
+															$competingElements[$tag] = array();
1338
+							}
1295 1339
 
1296 1340
 							$competingElements[$tag][] = $parts[$i + 4];
1297 1341
 
1298
-							if (count($competingElements[$tag]) > 1)
1299
-								$parts[$i] .= '[/' . $tag . ']';
1342
+							if (count($competingElements[$tag]) > 1) {
1343
+															$parts[$i] .= '[/' . $tag . ']';
1344
+							}
1300 1345
 						}
1301 1346
 
1302 1347
 						$inlineElements[$elementContent] = $tag;
@@ -1316,15 +1361,17 @@  discard block
 block discarded – undo
1316 1361
 						$addClosingTags = array();
1317 1362
 						while ($element = array_pop($blockElements))
1318 1363
 						{
1319
-							if ($element === $tag)
1320
-								break;
1364
+							if ($element === $tag) {
1365
+															break;
1366
+							}
1321 1367
 
1322 1368
 							// Still a block tag was open not equal to this tag.
1323 1369
 							$addClosingTags[] = $element['type'];
1324 1370
 						}
1325 1371
 
1326
-						if (!empty($addClosingTags))
1327
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1372
+						if (!empty($addClosingTags)) {
1373
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1374
+						}
1328 1375
 
1329 1376
 						// Apparently the closing tag was not found on the stack.
1330 1377
 						if (!is_string($element) || $element !== $tag)
@@ -1334,8 +1381,7 @@  discard block
 block discarded – undo
1334 1381
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1335 1382
 							continue;
1336 1383
 						}
1337
-					}
1338
-					else
1384
+					} else
1339 1385
 					{
1340 1386
 						// Get rid of this closing tag!
1341 1387
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1364,53 +1410,62 @@  discard block
 block discarded – undo
1364 1410
 							unset($inlineElements[$tagContentToBeClosed]);
1365 1411
 
1366 1412
 							// Was this the tag we were looking for?
1367
-							if ($tagToBeClosed === $tag)
1368
-								break;
1413
+							if ($tagToBeClosed === $tag) {
1414
+															break;
1415
+							}
1369 1416
 
1370 1417
 							// Nope, close it and look further!
1371
-							else
1372
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1418
+							else {
1419
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1420
+							}
1373 1421
 						}
1374 1422
 
1375 1423
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1376 1424
 						{
1377 1425
 							array_pop($competingElements[$tag]);
1378 1426
 
1379
-							if (count($competingElements[$tag]) > 0)
1380
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1427
+							if (count($competingElements[$tag]) > 0) {
1428
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1429
+							}
1381 1430
 						}
1382 1431
 					}
1383 1432
 
1384 1433
 					// Unexpected closing tag, ex-ter-mi-nate.
1385
-					else
1386
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1434
+					else {
1435
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1436
+					}
1387 1437
 				}
1388 1438
 			}
1389 1439
 		}
1390 1440
 
1391 1441
 		// Close the code tags.
1392
-		if ($inCode)
1393
-			$parts[$i] .= '[/code]';
1442
+		if ($inCode) {
1443
+					$parts[$i] .= '[/code]';
1444
+		}
1394 1445
 
1395 1446
 		// The same for nobbc tags.
1396
-		elseif ($inNoBbc)
1397
-			$parts[$i] .= '[/nobbc]';
1447
+		elseif ($inNoBbc) {
1448
+					$parts[$i] .= '[/nobbc]';
1449
+		}
1398 1450
 
1399 1451
 		// Still inline tags left unclosed? Close them now, better late than never.
1400
-		elseif (!empty($inlineElements))
1401
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1452
+		elseif (!empty($inlineElements)) {
1453
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1454
+		}
1402 1455
 
1403 1456
 		// Now close the block elements.
1404
-		if (!empty($blockElements))
1405
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1457
+		if (!empty($blockElements)) {
1458
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1459
+		}
1406 1460
 
1407 1461
 		$text = implode('', $parts);
1408 1462
 	}
1409 1463
 
1410 1464
 	// Final clean up of back to back tags.
1411 1465
 	$lastlen = 0;
1412
-	while (strlen($text) !== $lastlen)
1413
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1466
+	while (strlen($text) !== $lastlen) {
1467
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1468
+	}
1414 1469
 
1415 1470
 	return $text;
1416 1471
 }
@@ -1441,22 +1496,25 @@  discard block
 block discarded – undo
1441 1496
 	$context['template_layers'] = array();
1442 1497
 	// Lets make sure we aren't going to output anything nasty.
1443 1498
 	@ob_end_clean();
1444
-	if (!empty($modSettings['enableCompressedOutput']))
1445
-		@ob_start('ob_gzhandler');
1446
-	else
1447
-		@ob_start();
1499
+	if (!empty($modSettings['enableCompressedOutput'])) {
1500
+			@ob_start('ob_gzhandler');
1501
+	} else {
1502
+			@ob_start();
1503
+	}
1448 1504
 
1449 1505
 	// If we don't have any locale better avoid broken js
1450
-	if (empty($txt['lang_locale']))
1451
-		die();
1506
+	if (empty($txt['lang_locale'])) {
1507
+			die();
1508
+	}
1452 1509
 
1453 1510
 	$file_data = '(function ($) {
1454 1511
 	\'use strict\';
1455 1512
 
1456 1513
 	$.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {';
1457
-	foreach ($editortxt as $key => $val)
1458
-		$file_data .= '
1514
+	foreach ($editortxt as $key => $val) {
1515
+			$file_data .= '
1459 1516
 		' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ',';
1517
+	}
1460 1518
 
1461 1519
 	$file_data .= '
1462 1520
 		dateFormat: "day.month.year"
@@ -1524,8 +1582,9 @@  discard block
 block discarded – undo
1524 1582
 				)
1525 1583
 			);
1526 1584
 			$icon_data = array();
1527
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1528
-				$icon_data[] = $row;
1585
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1586
+							$icon_data[] = $row;
1587
+			}
1529 1588
 			$smcFunc['db_free_result']($request);
1530 1589
 
1531 1590
 			$icons = array();
@@ -1540,9 +1599,9 @@  discard block
 block discarded – undo
1540 1599
 			}
1541 1600
 
1542 1601
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1602
+		} else {
1603
+					$icons = $temp;
1543 1604
 		}
1544
-		else
1545
-			$icons = $temp;
1546 1605
 	}
1547 1606
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1548 1607
 
@@ -1585,8 +1644,9 @@  discard block
 block discarded – undo
1585 1644
 	{
1586 1645
 		// Some general stuff.
1587 1646
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1588
-		if (!empty($context['drafts_autosave']))
1589
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1647
+		if (!empty($context['drafts_autosave'])) {
1648
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1649
+		}
1590 1650
 
1591 1651
 		// This really has some WYSIWYG stuff.
1592 1652
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1603,8 +1663,9 @@  discard block
 block discarded – undo
1603 1663
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1604 1664
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1605 1665
 		// editor language file
1606
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1607
-			loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1666
+		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') {
1667
+					loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1668
+		}
1608 1669
 
1609 1670
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))];
1610 1671
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
@@ -1613,11 +1674,12 @@  discard block
 block discarded – undo
1613 1674
 			loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck');
1614 1675
 
1615 1676
 			// Some hidden information is needed in order to make the spell checking work.
1616
-			if (!isset($_REQUEST['xml']))
1617
-				$context['insert_after_template'] .= '
1677
+			if (!isset($_REQUEST['xml'])) {
1678
+							$context['insert_after_template'] .= '
1618 1679
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1619 1680
 			<input type="hidden" name="spellstring" value="">
1620 1681
 		</form>';
1682
+			}
1621 1683
 		}
1622 1684
 	}
1623 1685
 
@@ -1809,10 +1871,12 @@  discard block
 block discarded – undo
1809 1871
 
1810 1872
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1811 1873
 		$disabled_tags = array();
1812
-		if (!empty($modSettings['disabledBBC']))
1813
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1814
-		if (empty($modSettings['enableEmbeddedFlash']))
1815
-			$disabled_tags[] = 'flash';
1874
+		if (!empty($modSettings['disabledBBC'])) {
1875
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1876
+		}
1877
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1878
+					$disabled_tags[] = 'flash';
1879
+		}
1816 1880
 
1817 1881
 		foreach ($disabled_tags as $tag)
1818 1882
 		{
@@ -1824,9 +1888,10 @@  discard block
 block discarded – undo
1824 1888
 				$context['disabled_tags']['orderedlist'] = true;
1825 1889
 			}
1826 1890
 
1827
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1828
-				if ($tag === $thisTag)
1891
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1892
+							if ($tag === $thisTag)
1829 1893
 					$context['disabled_tags'][$tagNameBBC] = true;
1894
+			}
1830 1895
 
1831 1896
 			$context['disabled_tags'][$tag] = true;
1832 1897
 		}
@@ -1837,8 +1902,9 @@  discard block
 block discarded – undo
1837 1902
 
1838 1903
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1839 1904
 		{
1840
-			if (!isset($context['bbc_toolbar'][$row]))
1841
-				$context['bbc_toolbar'][$row] = array();
1905
+			if (!isset($context['bbc_toolbar'][$row])) {
1906
+							$context['bbc_toolbar'][$row] = array();
1907
+			}
1842 1908
 
1843 1909
 			$tagsRow = array();
1844 1910
 
@@ -1874,20 +1940,21 @@  discard block
 block discarded – undo
1874 1940
 
1875 1941
 					$context['bbcodes_handlers'] .= '
1876 1942
 						});';
1877
-				}
1878
-				else
1943
+				} else
1879 1944
 				{
1880 1945
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1881 1946
 					$tagsRow = array();
1882 1947
 				}
1883 1948
 			}
1884 1949
 
1885
-			if (!empty($tagsRow))
1886
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1950
+			if (!empty($tagsRow)) {
1951
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1952
+			}
1887 1953
 		}
1888 1954
 
1889
-		if (!empty($bbcodes_styles))
1890
-			addInlineCss($bbcodes_styles);
1955
+		if (!empty($bbcodes_styles)) {
1956
+					addInlineCss($bbcodes_styles);
1957
+		}
1891 1958
 	}
1892 1959
 
1893 1960
 	// Initialize smiley array... if not loaded before.
@@ -1899,8 +1966,8 @@  discard block
 block discarded – undo
1899 1966
 		);
1900 1967
 
1901 1968
 		// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
1902
-		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
1903
-			$context['smileys']['postform'][] = array(
1969
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1970
+					$context['smileys']['postform'][] = array(
1904 1971
 				'smileys' => array(
1905 1972
 					array(
1906 1973
 						'code' => ':)',
@@ -1986,7 +2053,7 @@  discard block
 block discarded – undo
1986 2053
 				),
1987 2054
 				'isLast' => true,
1988 2055
 			);
1989
-		elseif ($user_info['smiley_set'] != 'none')
2056
+		} elseif ($user_info['smiley_set'] != 'none')
1990 2057
 		{
1991 2058
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1992 2059
 			{
@@ -2009,17 +2076,19 @@  discard block
 block discarded – undo
2009 2076
 
2010 2077
 				foreach ($context['smileys'] as $section => $smileyRows)
2011 2078
 				{
2012
-					foreach ($smileyRows as $rowIndex => $smileys)
2013
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2079
+					foreach ($smileyRows as $rowIndex => $smileys) {
2080
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2081
+					}
2014 2082
 
2015
-					if (!empty($smileyRows))
2016
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2083
+					if (!empty($smileyRows)) {
2084
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2085
+					}
2017 2086
 				}
2018 2087
 
2019 2088
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2089
+			} else {
2090
+							$context['smileys'] = $temp;
2020 2091
 			}
2021
-			else
2022
-				$context['smileys'] = $temp;
2023 2092
 		}
2024 2093
 	}
2025 2094
 
@@ -2035,12 +2104,15 @@  discard block
 block discarded – undo
2035 2104
 		'plugins' => 'undo',
2036 2105
 		'bbcodeTrim' => true,
2037 2106
 	);
2038
-	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale']))
2039
-		$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2040
-	if (!empty($context['right_to_left']))
2041
-		$sce_options['rtl'] = true;
2042
-	if ($editorOptions['id'] != 'quickReply')
2043
-		$sce_options['autofocus'] = true;
2107
+	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) {
2108
+			$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2109
+	}
2110
+	if (!empty($context['right_to_left'])) {
2111
+			$sce_options['rtl'] = true;
2112
+	}
2113
+	if ($editorOptions['id'] != 'quickReply') {
2114
+			$sce_options['autofocus'] = true;
2115
+	}
2044 2116
 
2045 2117
 	$sce_options['emoticons'] = array();
2046 2118
 	$sce_options['emoticonsDescriptions'] = array();
@@ -2057,10 +2129,11 @@  discard block
 block discarded – undo
2057 2129
 			$countLocations--;
2058 2130
 
2059 2131
 			unset($smiley_location);
2060
-			if ($location == 'postform')
2061
-				$smiley_location = &$sce_options['emoticons']['dropdown'];
2062
-			elseif ($location == 'popup')
2063
-				$smiley_location = &$sce_options['emoticons']['popup'];
2132
+			if ($location == 'postform') {
2133
+							$smiley_location = &$sce_options['emoticons']['dropdown'];
2134
+			} elseif ($location == 'popup') {
2135
+							$smiley_location = &$sce_options['emoticons']['popup'];
2136
+			}
2064 2137
 
2065 2138
 			$numRows = count($smileyRows);
2066 2139
 
@@ -2074,8 +2147,9 @@  discard block
 block discarded – undo
2074 2147
 					$sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description'];
2075 2148
 				}
2076 2149
 
2077
-				if (empty($smileyRow['isLast']) && $numRows != 1)
2078
-					$smiley_location['-' . $emptyPlaceholder++] = '';
2150
+				if (empty($smileyRow['isLast']) && $numRows != 1) {
2151
+									$smiley_location['-' . $emptyPlaceholder++] = '';
2152
+				}
2079 2153
 			}
2080 2154
 		}
2081 2155
 	}
@@ -2090,8 +2164,9 @@  discard block
 block discarded – undo
2090 2164
 
2091 2165
 			$count_tags--;
2092 2166
 
2093
-			if (!empty($count_tags))
2094
-				$sce_options['toolbar'] .= '||';
2167
+			if (!empty($count_tags)) {
2168
+							$sce_options['toolbar'] .= '||';
2169
+			}
2095 2170
 		}
2096 2171
 	}
2097 2172
 
@@ -2119,8 +2194,9 @@  discard block
 block discarded – undo
2119 2194
 		loadTemplate('GenericControls');
2120 2195
 
2121 2196
 		// Some javascript ma'am?
2122
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2123
-			loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2197
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2198
+					loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2199
+		}
2124 2200
 
2125 2201
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2126 2202
 
@@ -2133,8 +2209,8 @@  discard block
 block discarded – undo
2133 2209
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2134 2210
 
2135 2211
 	// Log this into our collection.
2136
-	if ($isNew)
2137
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2212
+	if ($isNew) {
2213
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2138 2214
 			'id' => $verificationOptions['id'],
2139 2215
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2140 2216
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2145,13 +2221,15 @@  discard block
 block discarded – undo
2145 2221
 			'questions' => array(),
2146 2222
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2147 2223
 		);
2224
+	}
2148 2225
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2149 2226
 
2150 2227
 	// Is there actually going to be anything?
2151
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2152
-		return false;
2153
-	elseif (!$isNew && !$do_test)
2154
-		return true;
2228
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2229
+			return false;
2230
+	} elseif (!$isNew && !$do_test) {
2231
+			return true;
2232
+	}
2155 2233
 
2156 2234
 	// Sanitize reCAPTCHA fields?
2157 2235
 	if ($thisVerification['can_recaptcha'])
@@ -2164,11 +2242,12 @@  discard block
 block discarded – undo
2164 2242
 	}
2165 2243
 
2166 2244
 	// Add javascript for the object.
2167
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2168
-		$context['insert_after_template'] .= '
2245
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2246
+			$context['insert_after_template'] .= '
2169 2247
 			<script>
2170 2248
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2171 2249
 			</script>';
2250
+	}
2172 2251
 
2173 2252
 	// If we want questions do we have a cache of all the IDs?
2174 2253
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2191,8 +2270,9 @@  discard block
 block discarded – undo
2191 2270
 				unset ($row['id_question']);
2192 2271
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2193 2272
 				$row['answers'] = $smcFunc['json_decode']($row['answers'], true);
2194
-				foreach ($row['answers'] as $k => $v)
2195
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2273
+				foreach ($row['answers'] as $k => $v) {
2274
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2275
+				}
2196 2276
 
2197 2277
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2198 2278
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2203,35 +2283,42 @@  discard block
 block discarded – undo
2203 2283
 		}
2204 2284
 	}
2205 2285
 
2206
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2207
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2286
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2287
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2288
+	}
2208 2289
 
2209 2290
 	// Do we need to refresh the verification?
2210
-	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh']))
2211
-		$force_refresh = true;
2212
-	else
2213
-		$force_refresh = false;
2291
+	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) {
2292
+			$force_refresh = true;
2293
+	} else {
2294
+			$force_refresh = false;
2295
+	}
2214 2296
 
2215 2297
 	// This can also force a fresh, although unlikely.
2216
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2217
-		$force_refresh = true;
2298
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2299
+			$force_refresh = true;
2300
+	}
2218 2301
 
2219 2302
 	$verification_errors = array();
2220 2303
 	// Start with any testing.
2221 2304
 	if ($do_test)
2222 2305
 	{
2223 2306
 		// This cannot happen!
2224
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2225
-			fatal_lang_error('no_access', false);
2307
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2308
+					fatal_lang_error('no_access', false);
2309
+		}
2226 2310
 		// ... nor this!
2227
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2228
-			fatal_lang_error('no_access', false);
2311
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2312
+					fatal_lang_error('no_access', false);
2313
+		}
2229 2314
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2230
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2231
-			fatal_lang_error('no_access', false);
2315
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2316
+					fatal_lang_error('no_access', false);
2317
+		}
2232 2318
 		// While we're here, did the user do something bad?
2233
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2234
-			$verification_errors[] = 'wrong_verification_answer';
2319
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2320
+					$verification_errors[] = 'wrong_verification_answer';
2321
+		}
2235 2322
 
2236 2323
 		if ($thisVerification['can_recaptcha'])
2237 2324
 		{
@@ -2242,22 +2329,25 @@  discard block
 block discarded – undo
2242 2329
 			{
2243 2330
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']);
2244 2331
 
2245
-				if (!$resp->isSuccess())
2246
-					$verification_errors[] = 'wrong_verification_code';
2332
+				if (!$resp->isSuccess()) {
2333
+									$verification_errors[] = 'wrong_verification_code';
2334
+				}
2335
+			} else {
2336
+							$verification_errors[] = 'wrong_verification_code';
2247 2337
 			}
2248
-			else
2249
-				$verification_errors[] = 'wrong_verification_code';
2250 2338
 		}
2251
-		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code']))
2252
-			$verification_errors[] = 'wrong_verification_code';
2339
+		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) {
2340
+					$verification_errors[] = 'wrong_verification_code';
2341
+		}
2253 2342
 		if ($thisVerification['number_questions'])
2254 2343
 		{
2255 2344
 			$incorrectQuestions = array();
2256 2345
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2257 2346
 			{
2258 2347
 				// We don't have this question any more, thus no answers.
2259
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2260
-					continue;
2348
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2349
+									continue;
2350
+				}
2261 2351
 				// This is quite complex. We have our question but it might have multiple answers.
2262 2352
 				// First, did they actually answer this question?
2263 2353
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2269,24 +2359,28 @@  discard block
 block discarded – undo
2269 2359
 				else
2270 2360
 				{
2271 2361
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2272
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2273
-						$incorrectQuestions[] = $q;
2362
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2363
+											$incorrectQuestions[] = $q;
2364
+					}
2274 2365
 				}
2275 2366
 			}
2276 2367
 
2277
-			if (!empty($incorrectQuestions))
2278
-				$verification_errors[] = 'wrong_verification_answer';
2368
+			if (!empty($incorrectQuestions)) {
2369
+							$verification_errors[] = 'wrong_verification_answer';
2370
+			}
2279 2371
 		}
2280 2372
 	}
2281 2373
 
2282 2374
 	// Any errors means we refresh potentially.
2283 2375
 	if (!empty($verification_errors))
2284 2376
 	{
2285
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2286
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2377
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2378
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2379
+		}
2287 2380
 		// Too many errors?
2288
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2289
-			$force_refresh = true;
2381
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2382
+					$force_refresh = true;
2383
+		}
2290 2384
 
2291 2385
 		// Keep a track of these.
2292 2386
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2319,8 +2413,9 @@  discard block
 block discarded – undo
2319 2413
 			// Are we overriding the range?
2320 2414
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2321 2415
 
2322
-			for ($i = 0; $i < 6; $i++)
2323
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2416
+			for ($i = 0; $i < 6; $i++) {
2417
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2418
+			}
2324 2419
 		}
2325 2420
 
2326 2421
 		// Getting some new questions?
@@ -2328,8 +2423,9 @@  discard block
 block discarded – undo
2328 2423
 		{
2329 2424
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2330 2425
 			$possible_langs = array();
2331
-			if (isset($_SESSION['language']))
2332
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2426
+			if (isset($_SESSION['language'])) {
2427
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2428
+			}
2333 2429
 			if (!empty($user_info['language']));
2334 2430
 			$possible_langs[] = $user_info['language'];
2335 2431
 			$possible_langs[] = $language;
@@ -2348,8 +2444,7 @@  discard block
 block discarded – undo
2348 2444
 				}
2349 2445
 			}
2350 2446
 		}
2351
-	}
2352
-	else
2447
+	} else
2353 2448
 	{
2354 2449
 		// Same questions as before.
2355 2450
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2359,8 +2454,9 @@  discard block
 block discarded – undo
2359 2454
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2360 2455
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2361 2456
 	{
2362
-		if (!isset($context['html_headers']))
2363
-			$context['html_headers'] = '';
2457
+		if (!isset($context['html_headers'])) {
2458
+					$context['html_headers'] = '';
2459
+		}
2364 2460
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2365 2461
 	}
2366 2462
 
@@ -2386,11 +2482,13 @@  discard block
 block discarded – undo
2386 2482
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2387 2483
 
2388 2484
 	// Return errors if we have them.
2389
-	if (!empty($verification_errors))
2390
-		return $verification_errors;
2485
+	if (!empty($verification_errors)) {
2486
+			return $verification_errors;
2487
+	}
2391 2488
 	// If we had a test that one, make a note.
2392
-	elseif ($do_test)
2393
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2489
+	elseif ($do_test) {
2490
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2491
+	}
2394 2492
 
2395 2493
 	// Say that everything went well chaps.
2396 2494
 	return true;
@@ -2415,8 +2513,9 @@  discard block
 block discarded – undo
2415 2513
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2416 2514
 
2417 2515
 	// If we're just checking the callback function is registered return true or false.
2418
-	if ($checkRegistered != null)
2419
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2516
+	if ($checkRegistered != null) {
2517
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2518
+	}
2420 2519
 
2421 2520
 	checkSession('get');
2422 2521
 	loadTemplate('Xml');
@@ -2567,24 +2666,27 @@  discard block
 block discarded – undo
2567 2666
 		foreach ($possible_versions as $ver)
2568 2667
 		{
2569 2668
 			$ver = trim($ver);
2570
-			if (strpos($ver, 'SMF') === 0)
2571
-				$versions[] = $ver;
2669
+			if (strpos($ver, 'SMF') === 0) {
2670
+							$versions[] = $ver;
2671
+			}
2572 2672
 		}
2573 2673
 	}
2574 2674
 	$smcFunc['db_free_result']($request);
2575 2675
 
2576 2676
 	// Just in case we don't have ANYthing.
2577
-	if (empty($versions))
2578
-		$versions = array('SMF 2.0');
2677
+	if (empty($versions)) {
2678
+			$versions = array('SMF 2.0');
2679
+	}
2579 2680
 
2580
-	foreach ($versions as $id => $version)
2581
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2681
+	foreach ($versions as $id => $version) {
2682
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2582 2683
 			$xml_data['items']['children'][] = array(
2583 2684
 				'attributes' => array(
2584 2685
 					'id' => $id,
2585 2686
 				),
2586 2687
 				'value' => $version,
2587 2688
 			);
2689
+	}
2588 2690
 
2589 2691
 	return $xml_data;
2590 2692
 }
Please login to merge, or discard this patch.
Sources/ManagePosts.php 1 patch
Braces   +39 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
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
  * The main entrance point for the 'Posts and topics' screen.
@@ -98,23 +99,23 @@  discard block
 block discarded – undo
98 99
 		{
99 100
 			$_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
100 101
 
101
-			foreach ($_POST['censortext'] as $c)
102
-				list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
103
-		}
104
-		elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
102
+			foreach ($_POST['censortext'] as $c) {
103
+							list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
104
+			}
105
+		} elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
105 106
 		{
106 107
 			if (is_array($_POST['censor_vulgar']))
107 108
 			{
108 109
 				foreach ($_POST['censor_vulgar'] as $i => $value)
109 110
 				{
110
-					if (trim(strtr($value, '*', ' ')) == '')
111
-						unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
111
+					if (trim(strtr($value, '*', ' ')) == '') {
112
+											unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
113
+					}
112 114
 				}
113 115
 
114 116
 				$censored_vulgar = $_POST['censor_vulgar'];
115 117
 				$censored_proper = $_POST['censor_proper'];
116
-			}
117
-			else
118
+			} else
118 119
 			{
119 120
 				$censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
120 121
 				$censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
@@ -151,12 +152,14 @@  discard block
 block discarded – undo
151 152
 	$context['censored_words'] = array();
152 153
 	for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
153 154
 	{
154
-		if (empty($censor_vulgar[$i]))
155
-			continue;
155
+		if (empty($censor_vulgar[$i])) {
156
+					continue;
157
+		}
156 158
 
157 159
 		// Skip it, it's either spaces or stars only.
158
-		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
159
-			continue;
160
+		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') {
161
+					continue;
162
+		}
160 163
 
161 164
 		$context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : '';
162 165
 	}
@@ -187,10 +190,11 @@  discard block
 block discarded – undo
187 190
 
188 191
 	// Make an inline conditional a little shorter...
189 192
 	$can_spell_check = false;
190
-	if (function_exists('pspell_new'))
191
-		$can_spell_check = true;
192
-	elseif (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv')))
193
-		$can_spell_check = true;
193
+	if (function_exists('pspell_new')) {
194
+			$can_spell_check = true;
195
+	} elseif (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))) {
196
+			$can_spell_check = true;
197
+	}
194 198
 
195 199
 	// All the settings...
196 200
 	$config_vars = array(
@@ -220,8 +224,9 @@  discard block
 block discarded – undo
220 224
 
221 225
 	call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
222 226
 
223
-	if ($return_config)
224
-		return $config_vars;
227
+	if ($return_config) {
228
+			return $config_vars;
229
+	}
225 230
 
226 231
 	// We'll want this for our easy save.
227 232
 	require_once($sourcedir . '/ManageServer.php');
@@ -241,17 +246,20 @@  discard block
 block discarded – undo
241 246
 			db_extend('packages');
242 247
 
243 248
 			$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
244
-			foreach ($colData as $column)
245
-				if ($column['name'] == 'body')
249
+			foreach ($colData as $column) {
250
+							if ($column['name'] == 'body')
246 251
 					$body_type = $column['type'];
252
+			}
247 253
 
248
-			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text')
249
-				fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
254
+			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') {
255
+							fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
256
+			}
250 257
 		}
251 258
 
252 259
 		// If we're changing the post preview length let's check its valid
253
-		if (!empty($_POST['preview_characters']))
254
-			$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
260
+		if (!empty($_POST['preview_characters'])) {
261
+					$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
262
+		}
255 263
 
256 264
 		call_integration_hook('integrate_save_post_settings');
257 265
 
@@ -312,8 +320,9 @@  discard block
 block discarded – undo
312 320
 
313 321
 	call_integration_hook('integrate_modify_topic_settings', array(&$config_vars));
314 322
 
315
-	if ($return_config)
316
-		return $config_vars;
323
+	if ($return_config) {
324
+			return $config_vars;
325
+	}
317 326
 
318 327
 	// Get the settings template ready.
319 328
 	require_once($sourcedir . '/ManageServer.php');
@@ -366,8 +375,9 @@  discard block
 block discarded – undo
366 375
 		array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
367 376
 	);
368 377
 
369
-	if ($return_config)
370
-		return $config_vars;
378
+	if ($return_config) {
379
+			return $config_vars;
380
+	}
371 381
 
372 382
 	// Get the settings template ready.
373 383
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.