Completed
Push — release-2.1 ( cfdc59...af3d3b )
by Jeremy
12:06 queued 05:35
created
Themes/default/GenericMenu.template.php 1 patch
Braces   +54 added lines, -39 removed lines patch added patch discarded remove patch
@@ -83,16 +83,18 @@  discard block
 block discarded – undo
83 83
 		foreach ($section['areas'] as $i => $area)
84 84
 		{
85 85
 			// Not supposed to be printed?
86
-			if (empty($area['label']))
87
-				continue;
86
+			if (empty($area['label'])) {
87
+							continue;
88
+			}
88 89
 
89 90
 			echo '
90 91
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>
91 92
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>';
92 93
 
93 94
 			// Is this the current area, or just some area?
94
-			if (!empty($area['selected']) && empty($context['tabs']))
95
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
95
+			if (!empty($area['selected']) && empty($context['tabs'])) {
96
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
97
+			}
96 98
 
97 99
 			// Are there any subsections?
98 100
 			if (!empty($area['subsections']))
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 
103 105
 				foreach ($area['subsections'] as $sa => $sub)
104 106
 				{
105
-					if (!empty($sub['disabled']))
106
-						continue;
107
+					if (!empty($sub['disabled'])) {
108
+											continue;
109
+					}
107 110
 
108 111
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
109 112
 
@@ -150,8 +153,9 @@  discard block
 block discarded – undo
150 153
 							<h3 class="catbg">';
151 154
 
152 155
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
153
-		if (function_exists('template_admin_quick_search'))
154
-			template_admin_quick_search();
156
+		if (function_exists('template_admin_quick_search')) {
157
+					template_admin_quick_search();
158
+		}
155 159
 
156 160
 		// Exactly how many tabs do we have?
157 161
 		if (!empty($context['tabs']))
@@ -166,30 +170,36 @@  discard block
 block discarded – undo
166 170
 				}
167 171
 
168 172
 				// Did this not even exist - or do we not have a label?
169
-				if (!isset($tab_context['tabs'][$id]))
170
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
171
-				elseif (!isset($tab_context['tabs'][$id]['label']))
172
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
173
+				if (!isset($tab_context['tabs'][$id])) {
174
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
175
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
176
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
177
+				}
173 178
 
174 179
 				// Has a custom URL defined in the main admin structure?
175
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
176
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
180
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
181
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
182
+				}
177 183
 
178 184
 				// Any additional paramaters for the url?
179
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
180
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
185
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
186
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
187
+				}
181 188
 
182 189
 				// Has it been deemed selected?
183
-				if (!empty($tab['is_selected']))
184
-					$tab_context['tabs'][$id]['is_selected'] = true;
190
+				if (!empty($tab['is_selected'])) {
191
+									$tab_context['tabs'][$id]['is_selected'] = true;
192
+				}
185 193
 
186 194
 				// Does it have its own help?
187
-				if (!empty($tab['help']))
188
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
195
+				if (!empty($tab['help'])) {
196
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
197
+				}
189 198
 
190 199
 				// Is this the last one?
191
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
192
-					$tab_context['tabs'][$id]['is_last'] = true;
200
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
201
+									$tab_context['tabs'][$id]['is_last'] = true;
202
+				}
193 203
 			}
194 204
 
195 205
 			// Find the selected tab
@@ -206,22 +216,24 @@  discard block
 block discarded – undo
206 216
 		// Show an icon and/or a help item?
207 217
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
208 218
 		{
209
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
210
-				echo '
219
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
220
+							echo '
211 221
 								<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
212
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
213
-				echo '
222
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
223
+							echo '
214 224
 								<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
225
+			}
215 226
 
216
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
217
-				echo '
227
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
228
+							echo '
218 229
 								<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
230
+			}
219 231
 
220 232
 			echo $tab_context['title'];
221
-		}
222
-		else
223
-			echo '
233
+		} else {
234
+					echo '
224 235
 								', $tab_context['title'];
236
+		}
225 237
 
226 238
 		echo '
227 239
 							</h3>', (function_exists('template_admin_quick_search') ? '
@@ -230,11 +242,12 @@  discard block
 block discarded – undo
230 242
 	}
231 243
 
232 244
 	// Shall we use the tabs? Yes, it's the only known way!
233
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
234
-		echo '
245
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
246
+			echo '
235 247
 					<p class="information">
236 248
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
237 249
 					</p>';
250
+	}
238 251
 
239 252
 	// Print out all the items in this tab (if any).
240 253
 	if (!empty($context['tabs']))
@@ -246,19 +259,21 @@  discard block
 block discarded – undo
246 259
 
247 260
 		foreach ($tab_context['tabs'] as $sa => $tab)
248 261
 		{
249
-			if (!empty($tab['disabled']))
250
-				continue;
262
+			if (!empty($tab['disabled'])) {
263
+							continue;
264
+			}
251 265
 
252
-			if (!empty($tab['is_selected']))
253
-				echo '
266
+			if (!empty($tab['is_selected'])) {
267
+							echo '
254 268
 							<li>
255 269
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
256 270
 							</li>';
257
-			else
258
-				echo '
271
+			} else {
272
+							echo '
259 273
 							<li>
260 274
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
261 275
 							</li>';
276
+			}
262 277
 		}
263 278
 
264 279
 		// The end of tabs
Please login to merge, or discard this patch.
Themes/default/index.template.php 1 patch
Braces   +98 added lines, -67 removed lines patch added patch discarded remove patch
@@ -72,9 +72,10 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// Allow css/js files to be disabled for this specific theme.
74 74
 	// Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference.
75
-	if (!isset($settings['disable_files']))
76
-		$settings['disable_files'] = array();
77
-}
75
+	if (!isset($settings['disable_files'])) {
76
+			$settings['disable_files'] = array();
77
+	}
78
+	}
78 79
 
79 80
 /**
80 81
  * The main sub template above the content.
@@ -121,8 +122,9 @@  discard block
 block discarded – undo
121 122
 		echo '
122 123
 	<meta';
123 124
 
124
-		foreach ($meta_tag as $meta_key => $meta_value)
125
-			echo ' ', $meta_key, '="', $meta_value, '"';
125
+		foreach ($meta_tag as $meta_key => $meta_value) {
126
+					echo ' ', $meta_key, '="', $meta_value, '"';
127
+		}
126 128
 
127 129
 		echo '>';
128 130
 	}
@@ -133,14 +135,16 @@  discard block
 block discarded – undo
133 135
 	<meta name="theme-color" content="#557EA0">';
134 136
 
135 137
 	// Please don't index these Mr Robot.
136
-	if (!empty($context['robot_no_index']))
137
-		echo '
138
+	if (!empty($context['robot_no_index'])) {
139
+			echo '
138 140
 	<meta name="robots" content="noindex">';
141
+	}
139 142
 
140 143
 	// Present a canonical url for search engines to prevent duplicate content in their indices.
141
-	if (!empty($context['canonical_url']))
142
-		echo '
144
+	if (!empty($context['canonical_url'])) {
145
+			echo '
143 146
 	<link rel="canonical" href="', $context['canonical_url'], '">';
147
+	}
144 148
 
145 149
 	// Show all the relative links, such as help, search, contents, and the like.
146 150
 	echo '
@@ -149,24 +153,28 @@  discard block
 block discarded – undo
149 153
 	<link rel="search" href="' . $scripturl . '?action=search">' : '');
150 154
 
151 155
 	// If RSS feeds are enabled, advertise the presence of one.
152
-	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
153
-		echo '
156
+	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) {
157
+			echo '
154 158
 	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">
155 159
 	<link rel="alternate" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">';
160
+	}
156 161
 
157 162
 	// If we're viewing a topic, these should be the previous and next topics, respectively.
158
-	if (!empty($context['links']['next']))
159
-		echo '
163
+	if (!empty($context['links']['next'])) {
164
+			echo '
160 165
 	<link rel="next" href="', $context['links']['next'], '">';
166
+	}
161 167
 
162
-	if (!empty($context['links']['prev']))
163
-		echo '
168
+	if (!empty($context['links']['prev'])) {
169
+			echo '
164 170
 	<link rel="prev" href="', $context['links']['prev'], '">';
171
+	}
165 172
 
166 173
 	// If we're in a board, or a topic for that matter, the index will be the board's index.
167
-	if (!empty($context['current_board']))
168
-		echo '
174
+	if (!empty($context['current_board'])) {
175
+			echo '
169 176
 	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">';
177
+	}
170 178
 
171 179
 	// Output any remaining HTML headers. (from mods, maybe?)
172 180
 	echo $context['html_headers'];
@@ -199,20 +207,22 @@  discard block
 block discarded – undo
199 207
 				<li>
200 208
 					<a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">';
201 209
 
202
-		if (!empty($context['user']['avatar']))
203
-			echo $context['user']['avatar']['image'];
210
+		if (!empty($context['user']['avatar'])) {
211
+					echo $context['user']['avatar']['image'];
212
+		}
204 213
 
205 214
 		echo $context['user']['name'], '</a>
206 215
 					<div id="profile_menu" class="top_menu"></div>
207 216
 				</li>';
208 217
 
209 218
 		// Secondly, PMs if we're doing them
210
-		if ($context['allow_pm'])
211
-			echo '
219
+		if ($context['allow_pm']) {
220
+					echo '
212 221
 				<li>
213 222
 					<a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">', $txt['pm_short'], !empty($context['user']['unread_messages']) ? ' <span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '</a>
214 223
 					<div id="pm_menu" class="top_menu scrollable"></div>
215 224
 				</li>';
225
+		}
216 226
 
217 227
 		// Thirdly, alerts
218 228
 		echo '
@@ -227,17 +237,18 @@  discard block
 block discarded – undo
227 237
 	}
228 238
 	// Otherwise they're a guest. Ask them to either register or login.
229 239
 	else
230
-		if (empty($maintenance))
231
-			echo '
240
+		if (empty($maintenance)) {
241
+					echo '
232 242
 			<ul class="floatleft welcome">
233 243
 				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li>
234 244
 			</ul>';
235
-		else
236
-			// In maintenance mode, only login is allowed and don't show OverlayDiv
245
+		} else {
246
+					// In maintenance mode, only login is allowed and don't show OverlayDiv
237 247
 			echo '
238 248
 			<ul class="floatleft welcome">
239 249
 				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
240 250
 			</ul>';
251
+		}
241 252
 
242 253
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
243 254
 	{
@@ -245,9 +256,10 @@  discard block
 block discarded – undo
245 256
 			<form id="languages_form" method="get" class="floatright">
246 257
 				<select id="language_select" name="language" onchange="this.form.submit()">';
247 258
 
248
-		foreach ($context['languages'] as $language)
249
-			echo '
259
+		foreach ($context['languages'] as $language) {
260
+					echo '
250 261
 					<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>';
262
+		}
251 263
 
252 264
 		echo '
253 265
 				</select>
@@ -271,32 +283,37 @@  discard block
 block discarded – undo
271 283
 					<option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>';
272 284
 
273 285
 		// Can't limit it to a specific topic if we are not in one
274
-		if (!empty($context['current_topic']))
275
-			echo '
286
+		if (!empty($context['current_topic'])) {
287
+					echo '
276 288
 					<option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>';
289
+		}
277 290
 
278 291
 		// Can't limit it to a specific board if we are not in one
279
-		if (!empty($context['current_board']))
280
-			echo '
292
+		if (!empty($context['current_board'])) {
293
+					echo '
281 294
 					<option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>';
295
+		}
282 296
 
283 297
 		// Can't search for members if we can't see the memberlist
284
-		if (!empty($context['allow_memberlist']))
285
-			echo '
298
+		if (!empty($context['allow_memberlist'])) {
299
+					echo '
286 300
 					<option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>';
301
+		}
287 302
 
288 303
 		echo '
289 304
 				</select>';
290 305
 
291 306
 		// Search within current topic?
292
-		if (!empty($context['current_topic']))
293
-			echo '
307
+		if (!empty($context['current_topic'])) {
308
+					echo '
294 309
 				<input type="hidden" name="sd_topic" value="', $context['current_topic'], '">';
310
+		}
295 311
 
296 312
 		// If we're on a certain board, limit it to this board ;).
297
-		elseif (!empty($context['current_board']))
298
-			echo '
313
+		elseif (!empty($context['current_board'])) {
314
+					echo '
299 315
 				<input type="hidden" name="sd_brd" value="', $context['current_board'], '">';
316
+		}
300 317
 
301 318
 		echo '
302 319
 				<input type="submit" name="search2" value="', $txt['search'], '" class="button">
@@ -328,12 +345,13 @@  discard block
 block discarded – undo
328 345
 					</div>';
329 346
 
330 347
 	// Show a random news item? (or you could pick one from news_lines...)
331
-	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
332
-		echo '
348
+	if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) {
349
+			echo '
333 350
 					<div class="news">
334 351
 						<h2>', $txt['news'], ': </h2>
335 352
 						<p>', $context['random_news_line'], '</p>
336 353
 					</div>';
354
+	}
337 355
 
338 356
 	echo '
339 357
 					<hr class="clear">
@@ -392,9 +410,10 @@  discard block
 block discarded – undo
392 410
 		</ul>';
393 411
 
394 412
 	// Show the load time?
395
-	if ($context['show_load_time'])
396
-		echo '
413
+	if ($context['show_load_time']) {
414
+			echo '
397 415
 		<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
416
+	}
398 417
 
399 418
 	echo '
400 419
 		</div>
@@ -425,18 +444,20 @@  discard block
 block discarded – undo
425 444
 	global $context, $shown_linktree, $scripturl, $txt;
426 445
 
427 446
 	// If linktree is empty, just return - also allow an override.
428
-	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
429
-		return;
447
+	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) {
448
+			return;
449
+	}
430 450
 		echo '
431 451
 				<div class="navigate_section">
432 452
 					<ul>';
433 453
 
434
-	if ($context['user']['is_logged'])
435
-		echo '
454
+	if ($context['user']['is_logged']) {
455
+			echo '
436 456
 						<li class="unread_links">
437 457
 							<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
438 458
 							<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
439 459
 						</li>';
460
+	}
440 461
 
441 462
 	// Each tree item has a URL and name. Some may have extra_before and extra_after.
442 463
 	foreach ($context['linktree'] as $link_num => $tree)
@@ -447,25 +468,29 @@  discard block
 block discarded – undo
447 468
 		// Don't show a separator for the first one.
448 469
 		// Better here. Always points to the next level when the linktree breaks to a second line.
449 470
 		// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
450
-		if ($link_num != 0)
451
-			echo '
471
+		if ($link_num != 0) {
472
+					echo '
452 473
 							<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';
474
+		}
453 475
 
454 476
 		// Show something before the link?
455
-		if (isset($tree['extra_before']))
456
-			echo $tree['extra_before'], ' ';
477
+		if (isset($tree['extra_before'])) {
478
+					echo $tree['extra_before'], ' ';
479
+		}
457 480
 
458 481
 		// Show the link, including a URL if it should have one.
459
-		if (isset($tree['url']))
460
-			echo '
482
+		if (isset($tree['url'])) {
483
+					echo '
461 484
 							<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
462
-		else
463
-			echo '
485
+		} else {
486
+					echo '
464 487
 							<span>' . $tree['name'] . '</span>';
488
+		}
465 489
 
466 490
 		// Show something after the link...?
467
-		if (isset($tree['extra_after']))
468
-			echo ' ', $tree['extra_after'];
491
+		if (isset($tree['extra_after'])) {
492
+					echo ' ', $tree['extra_after'];
493
+		}
469 494
 
470 495
 		echo '
471 496
 						</li>';
@@ -516,13 +541,14 @@  discard block
 block discarded – undo
516 541
 					echo '
517 542
 									<ul>';
518 543
 
519
-					foreach ($childbutton['sub_buttons'] as $grandchildbutton)
520
-						echo '
544
+					foreach ($childbutton['sub_buttons'] as $grandchildbutton) {
545
+											echo '
521 546
 										<li>
522 547
 											<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
523 548
 												', $grandchildbutton['title'], !empty($grandchildbutton['amt']) ? ' <span class="amt">' . $grandchildbutton['amt'] . '</span>' : '', '
524 549
 											</a>
525 550
 										</li>';
551
+					}
526 552
 
527 553
 					echo '
528 554
 									</ul>';
@@ -553,8 +579,9 @@  discard block
 block discarded – undo
553 579
 {
554 580
 	global $context, $txt;
555 581
 
556
-	if (!is_array($strip_options))
557
-		$strip_options = array();
582
+	if (!is_array($strip_options)) {
583
+			$strip_options = array();
584
+	}
558 585
 
559 586
 	// Create the buttons...
560 587
 	$buttons = array();
@@ -563,8 +590,9 @@  discard block
 block discarded – undo
563 590
 		// As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!)
564 591
 		if (!isset($value['test']) || !empty($context[$value['test']]))
565 592
 		{
566
-			if (!isset($value['id']))
567
-				$value['id'] = $key;
593
+			if (!isset($value['id'])) {
594
+							$value['id'] = $key;
595
+			}
568 596
 
569 597
 			$button = '
570 598
 				<a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>';
@@ -577,13 +605,15 @@  discard block
 block discarded – undo
577 605
 							<div class="overview">';
578 606
 				foreach ($value['sub_buttons'] as $element)
579 607
 				{
580
-					if (isset($element['test']) && empty($context[$element['test']]))
581
-						continue;
608
+					if (isset($element['test']) && empty($context[$element['test']])) {
609
+											continue;
610
+					}
582 611
 
583 612
 					$button .= '
584 613
 								<a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>';
585
-					if (isset($txt[$element['text'] . '_desc']))
586
-						$button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>';
614
+					if (isset($txt[$element['text'] . '_desc'])) {
615
+											$button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>';
616
+					}
587 617
 					$button .= '</a>';
588 618
 				}
589 619
 				$button .= '
@@ -597,8 +627,9 @@  discard block
 block discarded – undo
597 627
 	}
598 628
 
599 629
 	// No buttons? No button strip either.
600
-	if (empty($buttons))
601
-		return;
630
+	if (empty($buttons)) {
631
+			return;
632
+	}
602 633
 
603 634
 	echo '
604 635
 		<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '>
Please login to merge, or discard this patch.
Sources/Subs.php 1 patch
Braces   +1477 added lines, -1105 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,8 +1134,9 @@  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 1142
 		// The YouTube bbc needs this for its origin parameter
@@ -1215,8 +1270,9 @@  discard block
 block discarded – undo
1215 1270
 					$returnContext = '';
1216 1271
 
1217 1272
 					// BBC or the entire attachments feature is disabled
1218
-					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach']))
1219
-						return $data;
1273
+					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) {
1274
+											return $data;
1275
+					}
1220 1276
 
1221 1277
 					// Save the attach ID.
1222 1278
 					$attachID = $data;
@@ -1227,8 +1283,9 @@  discard block
 block discarded – undo
1227 1283
 					$currentAttachment = parseAttachBBC($attachID);
1228 1284
 
1229 1285
 					// parseAttachBBC will return a string ($txt key) rather than dying with a fatal_error. Up to you to decide what to do.
1230
-					if (is_string($currentAttachment))
1231
-						return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1286
+					if (is_string($currentAttachment)) {
1287
+											return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1288
+					}
1232 1289
 
1233 1290
 					if (!empty($currentAttachment['is_image']))
1234 1291
 					{
@@ -1244,15 +1301,17 @@  discard block
 block discarded – undo
1244 1301
 							$height = ' height="' . $currentAttachment['height'] . '"';
1245 1302
 						}
1246 1303
 
1247
-						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1248
-							$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>';
1249
-						else
1250
-							$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
+						}
1251 1309
 					}
1252 1310
 
1253 1311
 					// No image. Show a link.
1254
-					else
1255
-						$returnContext .= $currentAttachment['link'];
1312
+					else {
1313
+											$returnContext .= $currentAttachment['link'];
1314
+					}
1256 1315
 
1257 1316
 					// Gotta append what we just did.
1258 1317
 					$data = $returnContext;
@@ -1306,8 +1365,9 @@  discard block
 block discarded – undo
1306 1365
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1307 1366
 						{
1308 1367
 							// Do PHP code coloring?
1309
-							if ($php_parts[$php_i] != '&lt;?php')
1310
-								continue;
1368
+							if ($php_parts[$php_i] != '&lt;?php') {
1369
+															continue;
1370
+							}
1311 1371
 
1312 1372
 							$php_string = '';
1313 1373
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1323,8 +1383,9 @@  discard block
 block discarded – undo
1323 1383
 						$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
1324 1384
 
1325 1385
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1326
-						if (!empty($context['browser']['is_opera']))
1327
-							$data .= '&nbsp;';
1386
+						if (!empty($context['browser']['is_opera'])) {
1387
+													$data .= '&nbsp;';
1388
+						}
1328 1389
 					}
1329 1390
 				},
1330 1391
 				'block_level' => true,
@@ -1343,8 +1404,9 @@  discard block
 block discarded – undo
1343 1404
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1344 1405
 						{
1345 1406
 							// Do PHP code coloring?
1346
-							if ($php_parts[$php_i] != '&lt;?php')
1347
-								continue;
1407
+							if ($php_parts[$php_i] != '&lt;?php') {
1408
+															continue;
1409
+							}
1348 1410
 
1349 1411
 							$php_string = '';
1350 1412
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1360,8 +1422,9 @@  discard block
 block discarded – undo
1360 1422
 						$data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]);
1361 1423
 
1362 1424
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1363
-						if (!empty($context['browser']['is_opera']))
1364
-							$data[0] .= '&nbsp;';
1425
+						if (!empty($context['browser']['is_opera'])) {
1426
+													$data[0] .= '&nbsp;';
1427
+						}
1365 1428
 					}
1366 1429
 				},
1367 1430
 				'block_level' => true,
@@ -1402,10 +1465,11 @@  discard block
 block discarded – undo
1402 1465
 				{
1403 1466
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1404 1467
 
1405
-					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches))
1406
-						$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1407
-					else
1408
-						$css = '';
1468
+					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) {
1469
+											$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1470
+					} else {
1471
+											$css = '';
1472
+					}
1409 1473
 
1410 1474
 					$data = $class . $css;
1411 1475
 				},
@@ -1420,8 +1484,9 @@  discard block
 block discarded – undo
1420 1484
 				{
1421 1485
 					$data = strtr($data, array('<br />' => ''));
1422 1486
 
1423
-					if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0)
1424
-						$data = 'ftp://' . $data;
1487
+					if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) {
1488
+											$data = 'ftp://' . $data;
1489
+					}
1425 1490
 				},
1426 1491
 			),
1427 1492
 			array(
@@ -1431,8 +1496,9 @@  discard block
 block discarded – undo
1431 1496
 				'after' => '</a>',
1432 1497
 				'validate' => function(&$tag, &$data, $disabled)
1433 1498
 				{
1434
-					if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0)
1435
-						$data = 'ftp://' . $data;
1499
+					if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) {
1500
+											$data = 'ftp://' . $data;
1501
+					}
1436 1502
 				},
1437 1503
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1438 1504
 				'disabled_after' => ' ($1)',
@@ -1492,17 +1558,20 @@  discard block
 block discarded – undo
1492 1558
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1493 1559
 					if ($image_proxy_enabled)
1494 1560
 					{
1495
-						if (!empty($user_info['possibly_robot']))
1496
-							return;
1561
+						if (!empty($user_info['possibly_robot'])) {
1562
+													return;
1563
+						}
1497 1564
 
1498
-						if (empty($scheme))
1499
-							$data = 'http://' . ltrim($data, ':/');
1565
+						if (empty($scheme)) {
1566
+													$data = 'http://' . ltrim($data, ':/');
1567
+						}
1500 1568
 
1501
-						if ($scheme != 'https')
1502
-							$data = get_proxied_url($data);
1569
+						if ($scheme != 'https') {
1570
+													$data = get_proxied_url($data);
1571
+						}
1572
+					} elseif (empty($scheme)) {
1573
+											$data = '//' . ltrim($data, ':/');
1503 1574
 					}
1504
-					elseif (empty($scheme))
1505
-						$data = '//' . ltrim($data, ':/');
1506 1575
 				},
1507 1576
 				'disabled_content' => '($1)',
1508 1577
 			),
@@ -1518,17 +1587,20 @@  discard block
 block discarded – undo
1518 1587
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1519 1588
 					if ($image_proxy_enabled)
1520 1589
 					{
1521
-						if (!empty($user_info['possibly_robot']))
1522
-							return;
1590
+						if (!empty($user_info['possibly_robot'])) {
1591
+													return;
1592
+						}
1523 1593
 
1524
-						if (empty($scheme))
1525
-							$data = 'http://' . ltrim($data, ':/');
1594
+						if (empty($scheme)) {
1595
+													$data = 'http://' . ltrim($data, ':/');
1596
+						}
1526 1597
 
1527
-						if ($scheme != 'https')
1528
-							$data = get_proxied_url($data);
1598
+						if ($scheme != 'https') {
1599
+													$data = get_proxied_url($data);
1600
+						}
1601
+					} elseif (empty($scheme)) {
1602
+											$data = '//' . ltrim($data, ':/');
1529 1603
 					}
1530
-					elseif (empty($scheme))
1531
-						$data = '//' . ltrim($data, ':/');
1532 1604
 				},
1533 1605
 				'disabled_content' => '($1)',
1534 1606
 			),
@@ -1540,8 +1612,9 @@  discard block
 block discarded – undo
1540 1612
 				{
1541 1613
 					$data = strtr($data, array('<br>' => ''));
1542 1614
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1543
-					if (empty($scheme))
1544
-						$data = '//' . ltrim($data, ':/');
1615
+					if (empty($scheme)) {
1616
+											$data = '//' . ltrim($data, ':/');
1617
+					}
1545 1618
 				},
1546 1619
 			),
1547 1620
 			array(
@@ -1552,13 +1625,14 @@  discard block
 block discarded – undo
1552 1625
 				'after' => '</a>',
1553 1626
 				'validate' => function (&$tag, &$data, $disabled)
1554 1627
 				{
1555
-					if (substr($data, 0, 1) == '#')
1556
-						$data = '#post_' . substr($data, 1);
1557
-					else
1628
+					if (substr($data, 0, 1) == '#') {
1629
+											$data = '#post_' . substr($data, 1);
1630
+					} else
1558 1631
 					{
1559 1632
 						$scheme = parse_url($data, PHP_URL_SCHEME);
1560
-						if (empty($scheme))
1561
-							$data = '//' . ltrim($data, ':/');
1633
+						if (empty($scheme)) {
1634
+													$data = '//' . ltrim($data, ':/');
1635
+						}
1562 1636
 					}
1563 1637
 				},
1564 1638
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
@@ -1649,8 +1723,9 @@  discard block
 block discarded – undo
1649 1723
 					{
1650 1724
 						$add_begin = substr(trim($data), 0, 5) != '&lt;?';
1651 1725
 						$data = highlight_php_code($add_begin ? '&lt;?php ' . $data . '?&gt;' : $data);
1652
-						if ($add_begin)
1653
-							$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1726
+						if ($add_begin) {
1727
+													$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1728
+						}
1654 1729
 					}
1655 1730
 				},
1656 1731
 				'block_level' => false,
@@ -1742,20 +1817,17 @@  discard block
 block discarded – undo
1742 1817
 				'validate' => function(&$tag, &$data, $disabled)
1743 1818
 					{
1744 1819
 
1745
-						if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50))
1746
-							$data[1] = '0 -2px 1px';
1747
-
1748
-						elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100))
1749
-							$data[1] = '2px 0 1px';
1750
-
1751
-						elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190))
1752
-							$data[1] = '0 2px 1px';
1753
-
1754
-						elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280))
1755
-							$data[1] = '-2px 0 1px';
1756
-
1757
-						else
1758
-							$data[1] = '1px 1px 1px';
1820
+						if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50)) {
1821
+													$data[1] = '0 -2px 1px';
1822
+						} elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100)) {
1823
+													$data[1] = '2px 0 1px';
1824
+						} elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190)) {
1825
+													$data[1] = '0 2px 1px';
1826
+						} elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280)) {
1827
+													$data[1] = '-2px 0 1px';
1828
+						} else {
1829
+													$data[1] = '1px 1px 1px';
1830
+						}
1759 1831
 					},
1760 1832
 			),
1761 1833
 			array(
@@ -1811,10 +1883,11 @@  discard block
 block discarded – undo
1811 1883
 				'content' => '$1',
1812 1884
 				'validate' => function (&$tag, &$data, $disabled)
1813 1885
 				{
1814
-					if (is_numeric($data))
1815
-						$data = timeformat($data);
1816
-					else
1817
-						$tag['content'] = '[time]$1[/time]';
1886
+					if (is_numeric($data)) {
1887
+											$data = timeformat($data);
1888
+					} else {
1889
+											$tag['content'] = '[time]$1[/time]';
1890
+					}
1818 1891
 				},
1819 1892
 			),
1820 1893
 			array(
@@ -1846,8 +1919,9 @@  discard block
 block discarded – undo
1846 1919
 				{
1847 1920
 					$data = strtr($data, array('<br>' => ''));
1848 1921
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1849
-					if (empty($scheme))
1850
-						$data = '//' . ltrim($data, ':/');
1922
+					if (empty($scheme)) {
1923
+											$data = '//' . ltrim($data, ':/');
1924
+					}
1851 1925
 				},
1852 1926
 			),
1853 1927
 			array(
@@ -1859,8 +1933,9 @@  discard block
 block discarded – undo
1859 1933
 				'validate' => function (&$tag, &$data, $disabled)
1860 1934
 				{
1861 1935
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1862
-					if (empty($scheme))
1863
-						$data = '//' . ltrim($data, ':/');
1936
+					if (empty($scheme)) {
1937
+											$data = '//' . ltrim($data, ':/');
1938
+					}
1864 1939
 				},
1865 1940
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1866 1941
 				'disabled_after' => ' ($1)',
@@ -1887,12 +1962,13 @@  discard block
 block discarded – undo
1887 1962
 		);
1888 1963
 
1889 1964
 		// Handle legacy bbc codes.
1890
-		foreach ($context['legacy_bbc'] as $bbc)
1891
-			$codes[] = array(
1965
+		foreach ($context['legacy_bbc'] as $bbc) {
1966
+					$codes[] = array(
1892 1967
 				'tag' => $bbc,
1893 1968
 				'before' => '',
1894 1969
 				'after' => '',
1895 1970
 			);
1971
+		}
1896 1972
 
1897 1973
 		// Let mods add new BBC without hassle.
1898 1974
 		call_integration_hook('integrate_bbc_codes', array(&$codes, &$no_autolink_tags));
@@ -1900,8 +1976,9 @@  discard block
 block discarded – undo
1900 1976
 		// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.
1901 1977
 		if ($message === false)
1902 1978
 		{
1903
-			if (isset($temp_bbc))
1904
-				$bbc_codes = $temp_bbc;
1979
+			if (isset($temp_bbc)) {
1980
+							$bbc_codes = $temp_bbc;
1981
+			}
1905 1982
 			usort($codes, function ($a, $b) {
1906 1983
 				return strcmp($a['tag'], $b['tag']);
1907 1984
 			});
@@ -1921,8 +1998,9 @@  discard block
 block discarded – undo
1921 1998
 		);
1922 1999
 		if (!isset($disabled['li']) && !isset($disabled['list']))
1923 2000
 		{
1924
-			foreach ($itemcodes as $c => $dummy)
1925
-				$bbc_codes[$c] = array();
2001
+			foreach ($itemcodes as $c => $dummy) {
2002
+							$bbc_codes[$c] = array();
2003
+			}
1926 2004
 		}
1927 2005
 
1928 2006
 		// Shhhh!
@@ -1943,12 +2021,14 @@  discard block
 block discarded – undo
1943 2021
 		foreach ($codes as $code)
1944 2022
 		{
1945 2023
 			// Make it easier to process parameters later
1946
-			if (!empty($code['parameters']))
1947
-				ksort($code['parameters'], SORT_STRING);
2024
+			if (!empty($code['parameters'])) {
2025
+							ksort($code['parameters'], SORT_STRING);
2026
+			}
1948 2027
 
1949 2028
 			// If we are not doing every tag only do ones we are interested in.
1950
-			if (empty($parse_tags) || in_array($code['tag'], $parse_tags))
1951
-				$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
2029
+			if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) {
2030
+							$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
2031
+			}
1952 2032
 		}
1953 2033
 		$codes = null;
1954 2034
 	}
@@ -1959,8 +2039,9 @@  discard block
 block discarded – undo
1959 2039
 		// It's likely this will change if the message is modified.
1960 2040
 		$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']);
1961 2041
 
1962
-		if (($temp = cache_get_data($cache_key, 240)) != null)
1963
-			return $temp;
2042
+		if (($temp = cache_get_data($cache_key, 240)) != null) {
2043
+					return $temp;
2044
+		}
1964 2045
 
1965 2046
 		$cache_t = microtime();
1966 2047
 	}
@@ -1992,8 +2073,9 @@  discard block
 block discarded – undo
1992 2073
 		$disabled['flash'] = true;
1993 2074
 
1994 2075
 		// @todo Change maybe?
1995
-		if (!isset($_GET['images']))
1996
-			$disabled['img'] = true;
2076
+		if (!isset($_GET['images'])) {
2077
+					$disabled['img'] = true;
2078
+		}
1997 2079
 
1998 2080
 		// @todo Interface/setting to add more?
1999 2081
 	}
@@ -2004,8 +2086,9 @@  discard block
 block discarded – undo
2004 2086
 	$alltags = array();
2005 2087
 	foreach ($bbc_codes as $section)
2006 2088
 	{
2007
-		foreach ($section as $code)
2008
-			$alltags[] = $code['tag'];
2089
+		foreach ($section as $code) {
2090
+					$alltags[] = $code['tag'];
2091
+		}
2009 2092
 	}
2010 2093
 	$alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b';
2011 2094
 
@@ -2017,8 +2100,9 @@  discard block
 block discarded – undo
2017 2100
 		$pos = isset($matches[0][1]) ? $matches[0][1] : false;
2018 2101
 
2019 2102
 		// Failsafe.
2020
-		if ($pos === false || $last_pos > $pos)
2021
-			$pos = strlen($message) + 1;
2103
+		if ($pos === false || $last_pos > $pos) {
2104
+					$pos = strlen($message) + 1;
2105
+		}
2022 2106
 
2023 2107
 		// Can't have a one letter smiley, URL, or email! (sorry.)
2024 2108
 		if ($last_pos < $pos - 1)
@@ -2036,8 +2120,9 @@  discard block
 block discarded – undo
2036 2120
 
2037 2121
 				// <br> should be empty.
2038 2122
 				$empty_tags = array('br', 'hr');
2039
-				foreach ($empty_tags as $tag)
2040
-					$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . '>', $data);
2123
+				foreach ($empty_tags as $tag) {
2124
+									$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . '>', $data);
2125
+				}
2041 2126
 
2042 2127
 				// b, u, i, s, pre... basic tags.
2043 2128
 				$closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong');
@@ -2046,8 +2131,9 @@  discard block
 block discarded – undo
2046 2131
 					$diff = substr_count($data, '&lt;' . $tag . '&gt;') - substr_count($data, '&lt;/' . $tag . '&gt;');
2047 2132
 					$data = strtr($data, array('&lt;' . $tag . '&gt;' => '<' . $tag . '>', '&lt;/' . $tag . '&gt;' => '</' . $tag . '>'));
2048 2133
 
2049
-					if ($diff > 0)
2050
-						$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
2134
+					if ($diff > 0) {
2135
+											$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
2136
+					}
2051 2137
 				}
2052 2138
 
2053 2139
 				// Do <img ...> - with security... action= -> action-.
@@ -2060,8 +2146,9 @@  discard block
 block discarded – undo
2060 2146
 						$alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^&quot;|&quot;$~', '', $matches[3][$match]);
2061 2147
 
2062 2148
 						// Remove action= from the URL - no funny business, now.
2063
-						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0)
2064
-							$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
2149
+						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) {
2150
+													$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
2151
+						}
2065 2152
 
2066 2153
 						$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
2067 2154
 					}
@@ -2076,16 +2163,18 @@  discard block
 block discarded – undo
2076 2163
 				$no_autolink_area = false;
2077 2164
 				if (!empty($open_tags))
2078 2165
 				{
2079
-					foreach ($open_tags as $open_tag)
2080
-						if (in_array($open_tag['tag'], $no_autolink_tags))
2166
+					foreach ($open_tags as $open_tag) {
2167
+											if (in_array($open_tag['tag'], $no_autolink_tags))
2081 2168
 							$no_autolink_area = true;
2169
+					}
2082 2170
 				}
2083 2171
 
2084 2172
 				// Don't go backwards.
2085 2173
 				// @todo Don't think is the real solution....
2086 2174
 				$lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0;
2087
-				if ($pos < $lastAutoPos)
2088
-					$no_autolink_area = true;
2175
+				if ($pos < $lastAutoPos) {
2176
+									$no_autolink_area = true;
2177
+				}
2089 2178
 				$lastAutoPos = $pos;
2090 2179
 
2091 2180
 				if (!$no_autolink_area)
@@ -2190,29 +2279,33 @@  discard block
 block discarded – undo
2190 2279
 							$url = array_shift($matches);
2191 2280
 
2192 2281
 							// If this isn't a clean URL, bail out
2193
-							if ($url != sanitize_iri($url))
2194
-								return $url;
2282
+							if ($url != sanitize_iri($url)) {
2283
+															return $url;
2284
+							}
2195 2285
 
2196 2286
 							$scheme = parse_url($url, PHP_URL_SCHEME);
2197 2287
 
2198 2288
 							if ($scheme == 'mailto')
2199 2289
 							{
2200 2290
 								$email_address = str_replace('mailto:', '', $url);
2201
-								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false)
2202
-									return '[email=' . $email_address . ']' . $url . '[/email]';
2203
-								else
2204
-									return $url;
2291
+								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) {
2292
+																	return '[email=' . $email_address . ']' . $url . '[/email]';
2293
+								} else {
2294
+																	return $url;
2295
+								}
2205 2296
 							}
2206 2297
 
2207 2298
 							// Are we linking a schemeless URL or naked domain name (e.g. "example.com")?
2208
-							if (empty($scheme))
2209
-								$fullUrl = '//' . ltrim($url, ':/');
2210
-							else
2211
-								$fullUrl = $url;
2299
+							if (empty($scheme)) {
2300
+															$fullUrl = '//' . ltrim($url, ':/');
2301
+							} else {
2302
+															$fullUrl = $url;
2303
+							}
2212 2304
 
2213 2305
 							// Make sure that $fullUrl really is valid
2214
-							if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false)
2215
-								return $url;
2306
+							if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) {
2307
+															return $url;
2308
+							}
2216 2309
 
2217 2310
 							return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
2218 2311
 						}, $data);
@@ -2261,22 +2354,25 @@  discard block
 block discarded – undo
2261 2354
 		}
2262 2355
 
2263 2356
 		// Are we there yet?  Are we there yet?
2264
-		if ($pos >= strlen($message) - 1)
2265
-			break;
2357
+		if ($pos >= strlen($message) - 1) {
2358
+					break;
2359
+		}
2266 2360
 
2267 2361
 		$tags = strtolower($message[$pos + 1]);
2268 2362
 
2269 2363
 		if ($tags == '/' && !empty($open_tags))
2270 2364
 		{
2271 2365
 			$pos2 = strpos($message, ']', $pos + 1);
2272
-			if ($pos2 == $pos + 2)
2273
-				continue;
2366
+			if ($pos2 == $pos + 2) {
2367
+							continue;
2368
+			}
2274 2369
 
2275 2370
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2276 2371
 
2277 2372
 			// A closing tag that doesn't match any open tags? Skip it.
2278
-			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags)))
2279
-				continue;
2373
+			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) {
2374
+							continue;
2375
+			}
2280 2376
 
2281 2377
 			$to_close = array();
2282 2378
 			$block_level = null;
@@ -2284,8 +2380,9 @@  discard block
 block discarded – undo
2284 2380
 			do
2285 2381
 			{
2286 2382
 				$tag = array_pop($open_tags);
2287
-				if (!$tag)
2288
-					break;
2383
+				if (!$tag) {
2384
+									break;
2385
+				}
2289 2386
 
2290 2387
 				if (!empty($tag['block_level']))
2291 2388
 				{
@@ -2299,10 +2396,11 @@  discard block
 block discarded – undo
2299 2396
 					// The idea is, if we are LOOKING for a block level tag, we can close them on the way.
2300 2397
 					if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]]))
2301 2398
 					{
2302
-						foreach ($bbc_codes[$look_for[0]] as $temp)
2303
-							if ($temp['tag'] == $look_for)
2399
+						foreach ($bbc_codes[$look_for[0]] as $temp) {
2400
+													if ($temp['tag'] == $look_for)
2304 2401
 							{
2305 2402
 								$block_level = !empty($temp['block_level']);
2403
+						}
2306 2404
 								break;
2307 2405
 							}
2308 2406
 					}
@@ -2324,15 +2422,15 @@  discard block
 block discarded – undo
2324 2422
 			{
2325 2423
 				$open_tags = $to_close;
2326 2424
 				continue;
2327
-			}
2328
-			elseif (!empty($to_close) && $tag['tag'] != $look_for)
2425
+			} elseif (!empty($to_close) && $tag['tag'] != $look_for)
2329 2426
 			{
2330 2427
 				if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]]))
2331 2428
 				{
2332
-					foreach ($bbc_codes[$look_for[0]] as $temp)
2333
-						if ($temp['tag'] == $look_for)
2429
+					foreach ($bbc_codes[$look_for[0]] as $temp) {
2430
+											if ($temp['tag'] == $look_for)
2334 2431
 						{
2335 2432
 							$block_level = !empty($temp['block_level']);
2433
+					}
2336 2434
 							break;
2337 2435
 						}
2338 2436
 				}
@@ -2340,8 +2438,9 @@  discard block
 block discarded – undo
2340 2438
 				// We're not looking for a block level tag (or maybe even a tag that exists...)
2341 2439
 				if (!$block_level)
2342 2440
 				{
2343
-					foreach ($to_close as $tag)
2344
-						array_push($open_tags, $tag);
2441
+					foreach ($to_close as $tag) {
2442
+											array_push($open_tags, $tag);
2443
+					}
2345 2444
 					continue;
2346 2445
 				}
2347 2446
 			}
@@ -2354,14 +2453,17 @@  discard block
 block discarded – undo
2354 2453
 
2355 2454
 				// See the comment at the end of the big loop - just eating whitespace ;).
2356 2455
 				$whitespace_regex = '';
2357
-				if (!empty($tag['block_level']))
2358
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2456
+				if (!empty($tag['block_level'])) {
2457
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2458
+				}
2359 2459
 				// Trim one line of whitespace after unnested tags, but all of it after nested ones
2360
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2361
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2460
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2461
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2462
+				}
2362 2463
 
2363
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2364
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2464
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2465
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2466
+				}
2365 2467
 			}
2366 2468
 
2367 2469
 			if (!empty($to_close))
@@ -2374,8 +2476,9 @@  discard block
 block discarded – undo
2374 2476
 		}
2375 2477
 
2376 2478
 		// No tags for this character, so just keep going (fastest possible course.)
2377
-		if (!isset($bbc_codes[$tags]))
2378
-			continue;
2479
+		if (!isset($bbc_codes[$tags])) {
2480
+					continue;
2481
+		}
2379 2482
 
2380 2483
 		$inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1];
2381 2484
 		$tag = null;
@@ -2384,48 +2487,57 @@  discard block
 block discarded – undo
2384 2487
 			$pt_strlen = strlen($possible['tag']);
2385 2488
 
2386 2489
 			// Not a match?
2387
-			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag'])
2388
-				continue;
2490
+			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) {
2491
+							continue;
2492
+			}
2389 2493
 
2390 2494
 			$next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : '';
2391 2495
 
2392 2496
 			// A tag is the last char maybe
2393
-			if ($next_c == '')
2394
-				break;
2497
+			if ($next_c == '') {
2498
+							break;
2499
+			}
2395 2500
 
2396 2501
 			// A test validation?
2397
-			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0)
2398
-				continue;
2502
+			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) {
2503
+							continue;
2504
+			}
2399 2505
 			// Do we want parameters?
2400 2506
 			elseif (!empty($possible['parameters']))
2401 2507
 			{
2402
-				if ($next_c != ' ')
2403
-					continue;
2404
-			}
2405
-			elseif (isset($possible['type']))
2508
+				if ($next_c != ' ') {
2509
+									continue;
2510
+				}
2511
+			} elseif (isset($possible['type']))
2406 2512
 			{
2407 2513
 				// Do we need an equal sign?
2408
-				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
2409
-					continue;
2514
+				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') {
2515
+									continue;
2516
+				}
2410 2517
 				// Maybe we just want a /...
2411
-				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]')
2412
-					continue;
2518
+				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') {
2519
+									continue;
2520
+				}
2413 2521
 				// An immediate ]?
2414
-				if ($possible['type'] == 'unparsed_content' && $next_c != ']')
2415
-					continue;
2522
+				if ($possible['type'] == 'unparsed_content' && $next_c != ']') {
2523
+									continue;
2524
+				}
2416 2525
 			}
2417 2526
 			// No type means 'parsed_content', which demands an immediate ] without parameters!
2418
-			elseif ($next_c != ']')
2419
-				continue;
2527
+			elseif ($next_c != ']') {
2528
+							continue;
2529
+			}
2420 2530
 
2421 2531
 			// Check allowed tree?
2422
-			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents'])))
2423
-				continue;
2424
-			elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children']))
2425
-				continue;
2532
+			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) {
2533
+							continue;
2534
+			} elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) {
2535
+							continue;
2536
+			}
2426 2537
 			// If this is in the list of disallowed child tags, don't parse it.
2427
-			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children']))
2428
-				continue;
2538
+			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) {
2539
+							continue;
2540
+			}
2429 2541
 
2430 2542
 			$pos1 = $pos + 1 + $pt_strlen + 1;
2431 2543
 
@@ -2437,8 +2549,9 @@  discard block
 block discarded – undo
2437 2549
 				foreach ($open_tags as $open_quote)
2438 2550
 				{
2439 2551
 					// Every parent quote this quote has flips the styling
2440
-					if ($open_quote['tag'] == 'quote')
2441
-						$quote_alt = !$quote_alt;
2552
+					if ($open_quote['tag'] == 'quote') {
2553
+											$quote_alt = !$quote_alt;
2554
+					}
2442 2555
 				}
2443 2556
 				// Add a class to the quote to style alternating blockquotes
2444 2557
 				$possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">'));
@@ -2449,8 +2562,9 @@  discard block
 block discarded – undo
2449 2562
 			{
2450 2563
 				// Build a regular expression for each parameter for the current tag.
2451 2564
 				$preg = array();
2452
-				foreach ($possible['parameters'] as $p => $info)
2453
-					$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2565
+				foreach ($possible['parameters'] as $p => $info) {
2566
+									$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2567
+				}
2454 2568
 
2455 2569
 				// Extract the string that potentially holds our parameters.
2456 2570
 				$blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos));
@@ -2469,24 +2583,27 @@  discard block
 block discarded – undo
2469 2583
 
2470 2584
 					$match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0;
2471 2585
 
2472
-					if ($match)
2473
-						$blob_counter = count($blobs) + 1;
2586
+					if ($match) {
2587
+											$blob_counter = count($blobs) + 1;
2588
+					}
2474 2589
 				}
2475 2590
 
2476 2591
 				// Didn't match our parameter list, try the next possible.
2477
-				if (!$match)
2478
-					continue;
2592
+				if (!$match) {
2593
+									continue;
2594
+				}
2479 2595
 
2480 2596
 				$params = array();
2481 2597
 				for ($i = 1, $n = count($matches); $i < $n; $i += 2)
2482 2598
 				{
2483 2599
 					$key = strtok(ltrim($matches[$i]), '=');
2484
-					if (isset($possible['parameters'][$key]['value']))
2485
-						$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2486
-					elseif (isset($possible['parameters'][$key]['validate']))
2487
-						$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2488
-					else
2489
-						$params['{' . $key . '}'] = $matches[$i + 1];
2600
+					if (isset($possible['parameters'][$key]['value'])) {
2601
+											$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2602
+					} elseif (isset($possible['parameters'][$key]['validate'])) {
2603
+											$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2604
+					} else {
2605
+											$params['{' . $key . '}'] = $matches[$i + 1];
2606
+					}
2490 2607
 
2491 2608
 					// Just to make sure: replace any $ or { so they can't interpolate wrongly.
2492 2609
 					$params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '&#036;', '{' => '&#123;'));
@@ -2494,23 +2611,26 @@  discard block
 block discarded – undo
2494 2611
 
2495 2612
 				foreach ($possible['parameters'] as $p => $info)
2496 2613
 				{
2497
-					if (!isset($params['{' . $p . '}']))
2498
-						$params['{' . $p . '}'] = '';
2614
+					if (!isset($params['{' . $p . '}'])) {
2615
+											$params['{' . $p . '}'] = '';
2616
+					}
2499 2617
 				}
2500 2618
 
2501 2619
 				$tag = $possible;
2502 2620
 
2503 2621
 				// Put the parameters into the string.
2504
-				if (isset($tag['before']))
2505
-					$tag['before'] = strtr($tag['before'], $params);
2506
-				if (isset($tag['after']))
2507
-					$tag['after'] = strtr($tag['after'], $params);
2508
-				if (isset($tag['content']))
2509
-					$tag['content'] = strtr($tag['content'], $params);
2622
+				if (isset($tag['before'])) {
2623
+									$tag['before'] = strtr($tag['before'], $params);
2624
+				}
2625
+				if (isset($tag['after'])) {
2626
+									$tag['after'] = strtr($tag['after'], $params);
2627
+				}
2628
+				if (isset($tag['content'])) {
2629
+									$tag['content'] = strtr($tag['content'], $params);
2630
+				}
2510 2631
 
2511 2632
 				$pos1 += strlen($given_param_string);
2512
-			}
2513
-			else
2633
+			} else
2514 2634
 			{
2515 2635
 				$tag = $possible;
2516 2636
 				$params = array();
@@ -2521,8 +2641,9 @@  discard block
 block discarded – undo
2521 2641
 		// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
2522 2642
 		if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li']))
2523 2643
 		{
2524
-			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>')))
2525
-				continue;
2644
+			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) {
2645
+							continue;
2646
+			}
2526 2647
 
2527 2648
 			$tag = $itemcodes[$message[$pos + 1]];
2528 2649
 
@@ -2543,9 +2664,9 @@  discard block
 block discarded – undo
2543 2664
 			{
2544 2665
 				array_pop($open_tags);
2545 2666
 				$code = '</li>';
2667
+			} else {
2668
+							$code = '';
2546 2669
 			}
2547
-			else
2548
-				$code = '';
2549 2670
 
2550 2671
 			// Now we open a new tag.
2551 2672
 			$open_tags[] = array(
@@ -2592,12 +2713,14 @@  discard block
 block discarded – undo
2592 2713
 		}
2593 2714
 
2594 2715
 		// No tag?  Keep looking, then.  Silly people using brackets without actual tags.
2595
-		if ($tag === null)
2596
-			continue;
2716
+		if ($tag === null) {
2717
+					continue;
2718
+		}
2597 2719
 
2598 2720
 		// Propagate the list to the child (so wrapping the disallowed tag won't work either.)
2599
-		if (isset($inside['disallow_children']))
2600
-			$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2721
+		if (isset($inside['disallow_children'])) {
2722
+					$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2723
+		}
2601 2724
 
2602 2725
 		// Is this tag disabled?
2603 2726
 		if (isset($disabled[$tag['tag']]))
@@ -2607,14 +2730,13 @@  discard block
 block discarded – undo
2607 2730
 				$tag['before'] = !empty($tag['block_level']) ? '<div>' : '';
2608 2731
 				$tag['after'] = !empty($tag['block_level']) ? '</div>' : '';
2609 2732
 				$tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1');
2610
-			}
2611
-			elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2733
+			} elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2612 2734
 			{
2613 2735
 				$tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : '');
2614 2736
 				$tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : '');
2737
+			} else {
2738
+							$tag['content'] = $tag['disabled_content'];
2615 2739
 			}
2616
-			else
2617
-				$tag['content'] = $tag['disabled_content'];
2618 2740
 		}
2619 2741
 
2620 2742
 		// we use this a lot
@@ -2624,8 +2746,9 @@  discard block
 block discarded – undo
2624 2746
 		if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level']))
2625 2747
 		{
2626 2748
 			$n = count($open_tags) - 1;
2627
-			while (empty($open_tags[$n]['block_level']) && $n >= 0)
2628
-				$n--;
2749
+			while (empty($open_tags[$n]['block_level']) && $n >= 0) {
2750
+							$n--;
2751
+			}
2629 2752
 
2630 2753
 			// Close all the non block level tags so this tag isn't surrounded by them.
2631 2754
 			for ($i = count($open_tags) - 1; $i > $n; $i--)
@@ -2637,12 +2760,15 @@  discard block
 block discarded – undo
2637 2760
 
2638 2761
 				// Trim or eat trailing stuff... see comment at the end of the big loop.
2639 2762
 				$whitespace_regex = '';
2640
-				if (!empty($tag['block_level']))
2641
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2642
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2643
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2644
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2645
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2763
+				if (!empty($tag['block_level'])) {
2764
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2765
+				}
2766
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2767
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2768
+				}
2769
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2770
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2771
+				}
2646 2772
 
2647 2773
 				array_pop($open_tags);
2648 2774
 			}
@@ -2663,16 +2789,19 @@  discard block
 block discarded – undo
2663 2789
 		elseif ($tag['type'] == 'unparsed_content')
2664 2790
 		{
2665 2791
 			$pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1);
2666
-			if ($pos2 === false)
2667
-				continue;
2792
+			if ($pos2 === false) {
2793
+							continue;
2794
+			}
2668 2795
 
2669 2796
 			$data = substr($message, $pos1, $pos2 - $pos1);
2670 2797
 
2671
-			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>')
2672
-				$data = substr($data, 4);
2798
+			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') {
2799
+							$data = substr($data, 4);
2800
+			}
2673 2801
 
2674
-			if (isset($tag['validate']))
2675
-				$tag['validate']($tag, $data, $disabled, $params);
2802
+			if (isset($tag['validate'])) {
2803
+							$tag['validate']($tag, $data, $disabled, $params);
2804
+			}
2676 2805
 
2677 2806
 			$code = strtr($tag['content'], array('$1' => $data));
2678 2807
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen);
@@ -2687,34 +2816,40 @@  discard block
 block discarded – undo
2687 2816
 			if (isset($tag['quoted']))
2688 2817
 			{
2689 2818
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2690
-				if ($tag['quoted'] != 'optional' && !$quoted)
2691
-					continue;
2819
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2820
+									continue;
2821
+				}
2692 2822
 
2693
-				if ($quoted)
2694
-					$pos1 += 6;
2823
+				if ($quoted) {
2824
+									$pos1 += 6;
2825
+				}
2826
+			} else {
2827
+							$quoted = false;
2695 2828
 			}
2696
-			else
2697
-				$quoted = false;
2698 2829
 
2699 2830
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2700
-			if ($pos2 === false)
2701
-				continue;
2831
+			if ($pos2 === false) {
2832
+							continue;
2833
+			}
2702 2834
 
2703 2835
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2704
-			if ($pos3 === false)
2705
-				continue;
2836
+			if ($pos3 === false) {
2837
+							continue;
2838
+			}
2706 2839
 
2707 2840
 			$data = array(
2708 2841
 				substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))),
2709 2842
 				substr($message, $pos1, $pos2 - $pos1)
2710 2843
 			);
2711 2844
 
2712
-			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>')
2713
-				$data[0] = substr($data[0], 4);
2845
+			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') {
2846
+							$data[0] = substr($data[0], 4);
2847
+			}
2714 2848
 
2715 2849
 			// Validation for my parking, please!
2716
-			if (isset($tag['validate']))
2717
-				$tag['validate']($tag, $data, $disabled, $params);
2850
+			if (isset($tag['validate'])) {
2851
+							$tag['validate']($tag, $data, $disabled, $params);
2852
+			}
2718 2853
 
2719 2854
 			$code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));
2720 2855
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
@@ -2731,23 +2866,27 @@  discard block
 block discarded – undo
2731 2866
 		elseif ($tag['type'] == 'unparsed_commas_content')
2732 2867
 		{
2733 2868
 			$pos2 = strpos($message, ']', $pos1);
2734
-			if ($pos2 === false)
2735
-				continue;
2869
+			if ($pos2 === false) {
2870
+							continue;
2871
+			}
2736 2872
 
2737 2873
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2738
-			if ($pos3 === false)
2739
-				continue;
2874
+			if ($pos3 === false) {
2875
+							continue;
2876
+			}
2740 2877
 
2741 2878
 			// We want $1 to be the content, and the rest to be csv.
2742 2879
 			$data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1));
2743 2880
 			$data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1);
2744 2881
 
2745
-			if (isset($tag['validate']))
2746
-				$tag['validate']($tag, $data, $disabled, $params);
2882
+			if (isset($tag['validate'])) {
2883
+							$tag['validate']($tag, $data, $disabled, $params);
2884
+			}
2747 2885
 
2748 2886
 			$code = $tag['content'];
2749
-			foreach ($data as $k => $d)
2750
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2887
+			foreach ($data as $k => $d) {
2888
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2889
+			}
2751 2890
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
2752 2891
 			$pos += strlen($code) - 1 + 2;
2753 2892
 		}
@@ -2755,24 +2894,28 @@  discard block
 block discarded – undo
2755 2894
 		elseif ($tag['type'] == 'unparsed_commas')
2756 2895
 		{
2757 2896
 			$pos2 = strpos($message, ']', $pos1);
2758
-			if ($pos2 === false)
2759
-				continue;
2897
+			if ($pos2 === false) {
2898
+							continue;
2899
+			}
2760 2900
 
2761 2901
 			$data = explode(',', substr($message, $pos1, $pos2 - $pos1));
2762 2902
 
2763
-			if (isset($tag['validate']))
2764
-				$tag['validate']($tag, $data, $disabled, $params);
2903
+			if (isset($tag['validate'])) {
2904
+							$tag['validate']($tag, $data, $disabled, $params);
2905
+			}
2765 2906
 
2766 2907
 			// Fix after, for disabled code mainly.
2767
-			foreach ($data as $k => $d)
2768
-				$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2908
+			foreach ($data as $k => $d) {
2909
+							$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2910
+			}
2769 2911
 
2770 2912
 			$open_tags[] = $tag;
2771 2913
 
2772 2914
 			// Replace them out, $1, $2, $3, $4, etc.
2773 2915
 			$code = $tag['before'];
2774
-			foreach ($data as $k => $d)
2775
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2916
+			foreach ($data as $k => $d) {
2917
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2918
+			}
2776 2919
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1);
2777 2920
 			$pos += strlen($code) - 1 + 2;
2778 2921
 		}
@@ -2783,28 +2926,33 @@  discard block
 block discarded – undo
2783 2926
 			if (isset($tag['quoted']))
2784 2927
 			{
2785 2928
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2786
-				if ($tag['quoted'] != 'optional' && !$quoted)
2787
-					continue;
2929
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2930
+									continue;
2931
+				}
2788 2932
 
2789
-				if ($quoted)
2790
-					$pos1 += 6;
2933
+				if ($quoted) {
2934
+									$pos1 += 6;
2935
+				}
2936
+			} else {
2937
+							$quoted = false;
2791 2938
 			}
2792
-			else
2793
-				$quoted = false;
2794 2939
 
2795 2940
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2796
-			if ($pos2 === false)
2797
-				continue;
2941
+			if ($pos2 === false) {
2942
+							continue;
2943
+			}
2798 2944
 
2799 2945
 			$data = substr($message, $pos1, $pos2 - $pos1);
2800 2946
 
2801 2947
 			// Validation for my parking, please!
2802
-			if (isset($tag['validate']))
2803
-				$tag['validate']($tag, $data, $disabled, $params);
2948
+			if (isset($tag['validate'])) {
2949
+							$tag['validate']($tag, $data, $disabled, $params);
2950
+			}
2804 2951
 
2805 2952
 			// For parsed content, we must recurse to avoid security problems.
2806
-			if ($tag['type'] != 'unparsed_equals')
2807
-				$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2953
+			if ($tag['type'] != 'unparsed_equals') {
2954
+							$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2955
+			}
2808 2956
 
2809 2957
 			$tag['after'] = strtr($tag['after'], array('$1' => $data));
2810 2958
 
@@ -2816,34 +2964,40 @@  discard block
 block discarded – undo
2816 2964
 		}
2817 2965
 
2818 2966
 		// If this is block level, eat any breaks after it.
2819
-		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>')
2820
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2967
+		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') {
2968
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2969
+		}
2821 2970
 
2822 2971
 		// Are we trimming outside this tag?
2823
-		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0)
2824
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2972
+		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0) {
2973
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2974
+		}
2825 2975
 	}
2826 2976
 
2827 2977
 	// Close any remaining tags.
2828
-	while ($tag = array_pop($open_tags))
2829
-		$message .= "\n" . $tag['after'] . "\n";
2978
+	while ($tag = array_pop($open_tags)) {
2979
+			$message .= "\n" . $tag['after'] . "\n";
2980
+	}
2830 2981
 
2831 2982
 	// Parse the smileys within the parts where it can be done safely.
2832 2983
 	if ($smileys === true)
2833 2984
 	{
2834 2985
 		$message_parts = explode("\n", $message);
2835
-		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2)
2836
-			parsesmileys($message_parts[$i]);
2986
+		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) {
2987
+					parsesmileys($message_parts[$i]);
2988
+		}
2837 2989
 
2838 2990
 		$message = implode('', $message_parts);
2839 2991
 	}
2840 2992
 
2841 2993
 	// No smileys, just get rid of the markers.
2842
-	else
2843
-		$message = strtr($message, array("\n" => ''));
2994
+	else {
2995
+			$message = strtr($message, array("\n" => ''));
2996
+	}
2844 2997
 
2845
-	if ($message !== '' && $message[0] === ' ')
2846
-		$message = '&nbsp;' . substr($message, 1);
2998
+	if ($message !== '' && $message[0] === ' ') {
2999
+			$message = '&nbsp;' . substr($message, 1);
3000
+	}
2847 3001
 
2848 3002
 	// Cleanup whitespace.
2849 3003
 	$message = strtr($message, array('  ' => ' &nbsp;', "\r" => '', "\n" => '<br>', '<br> ' => '<br>&nbsp;', '&#13;' => "\n"));
@@ -2852,15 +3006,16 @@  discard block
 block discarded – undo
2852 3006
 	call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
2853 3007
 
2854 3008
 	// Cache the output if it took some time...
2855
-	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05)
2856
-		cache_put_data($cache_key, $message, 240);
3009
+	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) {
3010
+			cache_put_data($cache_key, $message, 240);
3011
+	}
2857 3012
 
2858 3013
 	// If this was a force parse revert if needed.
2859 3014
 	if (!empty($parse_tags))
2860 3015
 	{
2861
-		if (empty($temp_bbc))
2862
-			$bbc_codes = array();
2863
-		else
3016
+		if (empty($temp_bbc)) {
3017
+					$bbc_codes = array();
3018
+		} else
2864 3019
 		{
2865 3020
 			$bbc_codes = $temp_bbc;
2866 3021
 			unset($temp_bbc);
@@ -2887,8 +3042,9 @@  discard block
 block discarded – undo
2887 3042
 	static $smileyPregSearch = null, $smileyPregReplacements = array();
2888 3043
 
2889 3044
 	// No smiley set at all?!
2890
-	if ($user_info['smiley_set'] == 'none' || trim($message) == '')
2891
-		return;
3045
+	if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
3046
+			return;
3047
+	}
2892 3048
 
2893 3049
 	// Maybe a mod wants to implement an alternative method (e.g. emojis instead of images)
2894 3050
 	call_integration_hook('integrate_smileys', array(&$smileyPregSearch, &$smileyPregReplacements));
@@ -2902,8 +3058,7 @@  discard block
 block discarded – undo
2902 3058
 			$smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', 'O:-)');
2903 3059
 			$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');
2904 3060
 			$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'], '', '', '', '');
2905
-		}
2906
-		else
3061
+		} else
2907 3062
 		{
2908 3063
 			// Load the smileys in reverse order by length so they don't get parsed wrong.
2909 3064
 			if (($temp = cache_get_data('parsing_smileys', 480)) == null)
@@ -2927,9 +3082,9 @@  discard block
 block discarded – undo
2927 3082
 				$smcFunc['db_free_result']($result);
2928 3083
 
2929 3084
 				cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
3085
+			} else {
3086
+							list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2930 3087
 			}
2931
-			else
2932
-				list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2933 3088
 		}
2934 3089
 
2935 3090
 		// The non-breaking-space is a complex thing...
@@ -2951,16 +3106,18 @@  discard block
 block discarded – undo
2951 3106
 				$alt_images = glob($smileys_dir . $fname .  '.{' . (implode(',', $exts)) . '}', GLOB_BRACE);
2952 3107
 				if (!empty($alt_images))
2953 3108
 				{
2954
-					foreach ($exts as $ext)
2955
-						if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images))
3109
+					foreach ($exts as $ext) {
3110
+											if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images))
2956 3111
 						{
2957 3112
 							$smileysto[$i] = $fname . '.' . $ext;
3113
+					}
2958 3114
 							break;
2959 3115
 						}
2960 3116
 				}
2961 3117
 				// If we have no image, just leave the text version in place
2962
-				else
2963
-					continue;
3118
+				else {
3119
+									continue;
3120
+				}
2964 3121
 			}
2965 3122
 
2966 3123
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
@@ -3036,12 +3193,14 @@  discard block
 block discarded – undo
3036 3193
 	global $boardurl, $image_proxy_enabled, $image_proxy_secret;
3037 3194
 
3038 3195
 	// Only use the proxy if enabled and necessary
3039
-	if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https')
3040
-		return $url;
3196
+	if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') {
3197
+			return $url;
3198
+	}
3041 3199
 
3042 3200
 	// We don't need to proxy our own resources
3043
-	if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0)
3044
-		return strtr($url, array('http://' => 'https://'));
3201
+	if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) {
3202
+			return strtr($url, array('http://' => 'https://'));
3203
+	}
3045 3204
 
3046 3205
 	// By default, use SMF's own image proxy script
3047 3206
 	$proxied_url = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($url) . '&hash=' . md5($url . $image_proxy_secret);
@@ -3066,35 +3225,41 @@  discard block
 block discarded – undo
3066 3225
 	global $scripturl, $context, $modSettings, $db_show_debug, $db_cache;
3067 3226
 
3068 3227
 	// In case we have mail to send, better do that - as obExit doesn't always quite make it...
3069
-	if (!empty($context['flush_mail']))
3070
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3228
+	if (!empty($context['flush_mail'])) {
3229
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3071 3230
 		AddMailQueue(true);
3231
+	}
3072 3232
 
3073 3233
 	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
3074 3234
 
3075
-	if ($add)
3076
-		$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
3235
+	if ($add) {
3236
+			$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
3237
+	}
3077 3238
 
3078 3239
 	// Put the session ID in.
3079
-	if (defined('SID') && SID != '')
3080
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
3240
+	if (defined('SID') && SID != '') {
3241
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
3242
+	}
3081 3243
 	// Keep that debug in their for template debugging!
3082
-	elseif (isset($_GET['debug']))
3083
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
3244
+	elseif (isset($_GET['debug'])) {
3245
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
3246
+	}
3084 3247
 
3085 3248
 	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'])))
3086 3249
 	{
3087
-		if (defined('SID') && SID != '')
3088
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
3250
+		if (defined('SID') && SID != '') {
3251
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
3089 3252
 				function ($m) use ($scripturl)
3090 3253
 				{
3091 3254
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
3255
+		}
3092 3256
 				}, $setLocation);
3093
-		else
3094
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
3257
+		else {
3258
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
3095 3259
 				function ($m) use ($scripturl)
3096 3260
 				{
3097 3261
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
3262
+		}
3098 3263
 				}, $setLocation);
3099 3264
 	}
3100 3265
 
@@ -3105,8 +3270,9 @@  discard block
 block discarded – undo
3105 3270
 	header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302);
3106 3271
 
3107 3272
 	// Debugging.
3108
-	if (isset($db_show_debug) && $db_show_debug === true)
3109
-		$_SESSION['debug_redirect'] = $db_cache;
3273
+	if (isset($db_show_debug) && $db_show_debug === true) {
3274
+			$_SESSION['debug_redirect'] = $db_cache;
3275
+	}
3110 3276
 
3111 3277
 	obExit(false);
3112 3278
 }
@@ -3125,51 +3291,60 @@  discard block
 block discarded – undo
3125 3291
 
3126 3292
 	// Attempt to prevent a recursive loop.
3127 3293
 	++$level;
3128
-	if ($level > 1 && !$from_fatal_error && !$has_fatal_error)
3129
-		exit;
3130
-	if ($from_fatal_error)
3131
-		$has_fatal_error = true;
3294
+	if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
3295
+			exit;
3296
+	}
3297
+	if ($from_fatal_error) {
3298
+			$has_fatal_error = true;
3299
+	}
3132 3300
 
3133 3301
 	// Clear out the stat cache.
3134 3302
 	trackStats();
3135 3303
 
3136 3304
 	// If we have mail to send, send it.
3137
-	if (!empty($context['flush_mail']))
3138
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3305
+	if (!empty($context['flush_mail'])) {
3306
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3139 3307
 		AddMailQueue(true);
3308
+	}
3140 3309
 
3141 3310
 	$do_header = $header === null ? !$header_done : $header;
3142
-	if ($do_footer === null)
3143
-		$do_footer = $do_header;
3311
+	if ($do_footer === null) {
3312
+			$do_footer = $do_header;
3313
+	}
3144 3314
 
3145 3315
 	// Has the template/header been done yet?
3146 3316
 	if ($do_header)
3147 3317
 	{
3148 3318
 		// Was the page title set last minute? Also update the HTML safe one.
3149
-		if (!empty($context['page_title']) && empty($context['page_title_html_safe']))
3150
-			$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3319
+		if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
3320
+					$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3321
+		}
3151 3322
 
3152 3323
 		// Start up the session URL fixer.
3153 3324
 		ob_start('ob_sessrewrite');
3154 3325
 
3155
-		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers']))
3156
-			$buffers = explode(',', $settings['output_buffers']);
3157
-		elseif (!empty($settings['output_buffers']))
3158
-			$buffers = $settings['output_buffers'];
3159
-		else
3160
-			$buffers = array();
3326
+		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
3327
+					$buffers = explode(',', $settings['output_buffers']);
3328
+		} elseif (!empty($settings['output_buffers'])) {
3329
+					$buffers = $settings['output_buffers'];
3330
+		} else {
3331
+					$buffers = array();
3332
+		}
3161 3333
 
3162
-		if (isset($modSettings['integrate_buffer']))
3163
-			$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3334
+		if (isset($modSettings['integrate_buffer'])) {
3335
+					$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3336
+		}
3164 3337
 
3165
-		if (!empty($buffers))
3166
-			foreach ($buffers as $function)
3338
+		if (!empty($buffers)) {
3339
+					foreach ($buffers as $function)
3167 3340
 			{
3168 3341
 				$call = call_helper($function, true);
3342
+		}
3169 3343
 
3170 3344
 				// Is it valid?
3171
-				if (!empty($call))
3172
-					ob_start($call);
3345
+				if (!empty($call)) {
3346
+									ob_start($call);
3347
+				}
3173 3348
 			}
3174 3349
 
3175 3350
 		// Display the screen in the logical order.
@@ -3181,8 +3356,9 @@  discard block
 block discarded – undo
3181 3356
 		loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
3182 3357
 
3183 3358
 		// Anything special to put out?
3184
-		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml']))
3185
-			echo $context['insert_after_template'];
3359
+		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
3360
+					echo $context['insert_after_template'];
3361
+		}
3186 3362
 
3187 3363
 		// Just so we don't get caught in an endless loop of errors from the footer...
3188 3364
 		if (!$footer_done)
@@ -3191,14 +3367,16 @@  discard block
 block discarded – undo
3191 3367
 			template_footer();
3192 3368
 
3193 3369
 			// (since this is just debugging... it's okay that it's after </html>.)
3194
-			if (!isset($_REQUEST['xml']))
3195
-				displayDebug();
3370
+			if (!isset($_REQUEST['xml'])) {
3371
+							displayDebug();
3372
+			}
3196 3373
 		}
3197 3374
 	}
3198 3375
 
3199 3376
 	// Remember this URL in case someone doesn't like sending HTTP_REFERER.
3200
-	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false)
3201
-		$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3377
+	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
3378
+			$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3379
+	}
3202 3380
 
3203 3381
 	// For session check verification.... don't switch browsers...
3204 3382
 	$_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
@@ -3207,9 +3385,10 @@  discard block
 block discarded – undo
3207 3385
 	call_integration_hook('integrate_exit', array($do_footer));
3208 3386
 
3209 3387
 	// Don't exit if we're coming from index.php; that will pass through normally.
3210
-	if (!$from_index)
3211
-		exit;
3212
-}
3388
+	if (!$from_index) {
3389
+			exit;
3390
+	}
3391
+	}
3213 3392
 
3214 3393
 /**
3215 3394
  * Get the size of a specified image with better error handling.
@@ -3228,8 +3407,9 @@  discard block
 block discarded – undo
3228 3407
 	$url = str_replace(' ', '%20', $url);
3229 3408
 
3230 3409
 	// Can we pull this from the cache... please please?
3231
-	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null)
3232
-		return $temp;
3410
+	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) {
3411
+			return $temp;
3412
+	}
3233 3413
 	$t = microtime();
3234 3414
 
3235 3415
 	// Get the host to pester...
@@ -3239,12 +3419,10 @@  discard block
 block discarded – undo
3239 3419
 	if ($url == '' || $url == 'http://' || $url == 'https://')
3240 3420
 	{
3241 3421
 		return false;
3242
-	}
3243
-	elseif (!isset($match[1]))
3422
+	} elseif (!isset($match[1]))
3244 3423
 	{
3245 3424
 		$size = @getimagesize($url);
3246
-	}
3247
-	else
3425
+	} else
3248 3426
 	{
3249 3427
 		// Try to connect to the server... give it half a second.
3250 3428
 		$temp = 0;
@@ -3281,12 +3459,14 @@  discard block
 block discarded – undo
3281 3459
 	}
3282 3460
 
3283 3461
 	// If we didn't get it, we failed.
3284
-	if (!isset($size))
3285
-		$size = false;
3462
+	if (!isset($size)) {
3463
+			$size = false;
3464
+	}
3286 3465
 
3287 3466
 	// If this took a long time, we may never have to do it again, but then again we might...
3288
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8)
3289
-		cache_put_data('url_image_size-' . md5($url), $size, 240);
3467
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) {
3468
+			cache_put_data('url_image_size-' . md5($url), $size, 240);
3469
+	}
3290 3470
 
3291 3471
 	// Didn't work.
3292 3472
 	return $size;
@@ -3304,8 +3484,9 @@  discard block
 block discarded – undo
3304 3484
 
3305 3485
 	// Under SSI this function can be called more then once.  That can cause some problems.
3306 3486
 	//   So only run the function once unless we are forced to run it again.
3307
-	if ($loaded && !$forceload)
3308
-		return;
3487
+	if ($loaded && !$forceload) {
3488
+			return;
3489
+	}
3309 3490
 
3310 3491
 	$loaded = true;
3311 3492
 
@@ -3317,14 +3498,16 @@  discard block
 block discarded – undo
3317 3498
 	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
3318 3499
 	for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++)
3319 3500
 	{
3320
-		if (trim($context['news_lines'][$i]) == '')
3321
-			continue;
3501
+		if (trim($context['news_lines'][$i]) == '') {
3502
+					continue;
3503
+		}
3322 3504
 
3323 3505
 		// Clean it up for presentation ;).
3324 3506
 		$context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i);
3325 3507
 	}
3326
-	if (!empty($context['news_lines']))
3327
-		$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3508
+	if (!empty($context['news_lines'])) {
3509
+			$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3510
+	}
3328 3511
 
3329 3512
 	if (!$user_info['is_guest'])
3330 3513
 	{
@@ -3333,40 +3516,48 @@  discard block
 block discarded – undo
3333 3516
 		$context['user']['alerts'] = &$user_info['alerts'];
3334 3517
 
3335 3518
 		// Personal message popup...
3336
-		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0))
3337
-			$context['user']['popup_messages'] = true;
3338
-		else
3339
-			$context['user']['popup_messages'] = false;
3519
+		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) {
3520
+					$context['user']['popup_messages'] = true;
3521
+		} else {
3522
+					$context['user']['popup_messages'] = false;
3523
+		}
3340 3524
 		$_SESSION['unread_messages'] = $user_info['unread_messages'];
3341 3525
 
3342
-		if (allowedTo('moderate_forum'))
3343
-			$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3526
+		if (allowedTo('moderate_forum')) {
3527
+					$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3528
+		}
3344 3529
 
3345 3530
 		$context['user']['avatar'] = array();
3346 3531
 
3347 3532
 		// Check for gravatar first since we might be forcing them...
3348 3533
 		if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride']))
3349 3534
 		{
3350
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11)
3351
-				$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3352
-			else
3353
-				$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3535
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) {
3536
+							$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3537
+			} else {
3538
+							$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3539
+			}
3354 3540
 		}
3355 3541
 		// Uploaded?
3356
-		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
3357
-			$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';
3542
+		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) {
3543
+					$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';
3544
+		}
3358 3545
 		// Full URL?
3359
-		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0)
3360
-			$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3546
+		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) {
3547
+					$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3548
+		}
3361 3549
 		// Otherwise we assume it's server stored.
3362
-		elseif ($user_info['avatar']['url'] != '')
3363
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3550
+		elseif ($user_info['avatar']['url'] != '') {
3551
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3552
+		}
3364 3553
 		// No avatar at all? Fine, we have a big fat default avatar ;)
3365
-		else
3366
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3554
+		else {
3555
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3556
+		}
3367 3557
 
3368
-		if (!empty($context['user']['avatar']))
3369
-			$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3558
+		if (!empty($context['user']['avatar'])) {
3559
+					$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3560
+		}
3370 3561
 
3371 3562
 		// Figure out how long they've been logged in.
3372 3563
 		$context['user']['total_time_logged_in'] = array(
@@ -3374,8 +3565,7 @@  discard block
 block discarded – undo
3374 3565
 			'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600),
3375 3566
 			'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60)
3376 3567
 		);
3377
-	}
3378
-	else
3568
+	} else
3379 3569
 	{
3380 3570
 		$context['user']['messages'] = 0;
3381 3571
 		$context['user']['unread_messages'] = 0;
@@ -3383,12 +3573,14 @@  discard block
 block discarded – undo
3383 3573
 		$context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0);
3384 3574
 		$context['user']['popup_messages'] = false;
3385 3575
 
3386
-		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1)
3387
-			$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3576
+		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) {
3577
+					$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3578
+		}
3388 3579
 
3389 3580
 		// If we've upgraded recently, go easy on the passwords.
3390
-		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime']))
3391
-			$context['disable_login_hashing'] = true;
3581
+		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) {
3582
+					$context['disable_login_hashing'] = true;
3583
+		}
3392 3584
 	}
3393 3585
 
3394 3586
 	// Setup the main menu items.
@@ -3401,8 +3593,8 @@  discard block
 block discarded – undo
3401 3593
 	$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');
3402 3594
 
3403 3595
 	// 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array.
3404
-	if ($context['show_pm_popup'])
3405
-		addInlineJavaScript('
3596
+	if ($context['show_pm_popup']) {
3597
+			addInlineJavaScript('
3406 3598
 		jQuery(document).ready(function($) {
3407 3599
 			new smc_Popup({
3408 3600
 				heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ',
@@ -3410,24 +3602,28 @@  discard block
 block discarded – undo
3410 3602
 				icon_class: \'generic_icons mail_new\'
3411 3603
 			});
3412 3604
 		});');
3605
+	}
3413 3606
 
3414 3607
 	// Add a generic "Are you sure?" confirmation message.
3415 3608
 	addInlineJavaScript('
3416 3609
 	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3417 3610
 
3418 3611
 	// Now add the capping code for avatars.
3419
-	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')
3420
-		addInlineCss('
3612
+	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') {
3613
+			addInlineCss('
3421 3614
 	img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }');
3615
+	}
3422 3616
 
3423 3617
 	// Add max image limits
3424
-	if (!empty($modSettings['max_image_width']))
3425
-		addInlineCss('
3618
+	if (!empty($modSettings['max_image_width'])) {
3619
+			addInlineCss('
3426 3620
 	.postarea .bbc_img { max-width: ' . $modSettings['max_image_width'] . 'px; }');
3621
+	}
3427 3622
 
3428
-	if (!empty($modSettings['max_image_height']))
3429
-		addInlineCss('
3623
+	if (!empty($modSettings['max_image_height'])) {
3624
+			addInlineCss('
3430 3625
 	.postarea .bbc_img { max-height: ' . $modSettings['max_image_height'] . 'px; }');
3626
+	}
3431 3627
 
3432 3628
 	// This looks weird, but it's because BoardIndex.php references the variable.
3433 3629
 	$context['common_stats']['latest_member'] = array(
@@ -3444,11 +3640,13 @@  discard block
 block discarded – undo
3444 3640
 	);
3445 3641
 	$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']);
3446 3642
 
3447
-	if (empty($settings['theme_version']))
3448
-		addJavaScriptVar('smf_scripturl', $scripturl);
3643
+	if (empty($settings['theme_version'])) {
3644
+			addJavaScriptVar('smf_scripturl', $scripturl);
3645
+	}
3449 3646
 
3450
-	if (!isset($context['page_title']))
3451
-		$context['page_title'] = '';
3647
+	if (!isset($context['page_title'])) {
3648
+			$context['page_title'] = '';
3649
+	}
3452 3650
 
3453 3651
 	// Set some specific vars.
3454 3652
 	$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
@@ -3458,21 +3656,23 @@  discard block
 block discarded – undo
3458 3656
 	$context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']);
3459 3657
 	$context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']);
3460 3658
 
3461
-	if (!empty($context['meta_keywords']))
3462
-		$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3659
+	if (!empty($context['meta_keywords'])) {
3660
+			$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3661
+	}
3463 3662
 
3464
-	if (!empty($context['canonical_url']))
3465
-		$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3663
+	if (!empty($context['canonical_url'])) {
3664
+			$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3665
+	}
3466 3666
 
3467
-	if (!empty($settings['og_image']))
3468
-		$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3667
+	if (!empty($settings['og_image'])) {
3668
+			$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3669
+	}
3469 3670
 
3470 3671
 	if (!empty($context['meta_description']))
3471 3672
 	{
3472 3673
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']);
3473 3674
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']);
3474
-	}
3475
-	else
3675
+	} else
3476 3676
 	{
3477 3677
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']);
3478 3678
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']);
@@ -3497,8 +3697,9 @@  discard block
 block discarded – undo
3497 3697
 	$memory_needed = memoryReturnBytes($needed);
3498 3698
 
3499 3699
 	// should we account for how much is currently being used?
3500
-	if ($in_use)
3501
-		$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3700
+	if ($in_use) {
3701
+			$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3702
+	}
3502 3703
 
3503 3704
 	// if more is needed, request it
3504 3705
 	if ($memory_current < $memory_needed)
@@ -3521,8 +3722,9 @@  discard block
 block discarded – undo
3521 3722
  */
3522 3723
 function memoryReturnBytes($val)
3523 3724
 {
3524
-	if (is_integer($val))
3525
-		return $val;
3725
+	if (is_integer($val)) {
3726
+			return $val;
3727
+	}
3526 3728
 
3527 3729
 	// Separate the number from the designator
3528 3730
 	$val = trim($val);
@@ -3558,10 +3760,11 @@  discard block
 block discarded – undo
3558 3760
 		header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
3559 3761
 
3560 3762
 		// Are we debugging the template/html content?
3561
-		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie'))
3562
-			header('content-type: application/xhtml+xml');
3563
-		elseif (!isset($_REQUEST['xml']))
3564
-			header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3763
+		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) {
3764
+					header('content-type: application/xhtml+xml');
3765
+		} elseif (!isset($_REQUEST['xml'])) {
3766
+					header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3767
+		}
3565 3768
 	}
3566 3769
 
3567 3770
 	header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
@@ -3570,8 +3773,9 @@  discard block
 block discarded – undo
3570 3773
 	if ($context['in_maintenance'] && $context['user']['is_admin'])
3571 3774
 	{
3572 3775
 		$position = array_search('body', $context['template_layers']);
3573
-		if ($position === false)
3574
-			$position = array_search('main', $context['template_layers']);
3776
+		if ($position === false) {
3777
+					$position = array_search('main', $context['template_layers']);
3778
+		}
3575 3779
 
3576 3780
 		if ($position !== false)
3577 3781
 		{
@@ -3599,23 +3803,25 @@  discard block
 block discarded – undo
3599 3803
 
3600 3804
 			foreach ($securityFiles as $i => $securityFile)
3601 3805
 			{
3602
-				if (!file_exists($boarddir . '/' . $securityFile))
3603
-					unset($securityFiles[$i]);
3806
+				if (!file_exists($boarddir . '/' . $securityFile)) {
3807
+									unset($securityFiles[$i]);
3808
+				}
3604 3809
 			}
3605 3810
 
3606 3811
 			// We are already checking so many files...just few more doesn't make any difference! :P
3607
-			if (!empty($modSettings['currentAttachmentUploadDir']))
3608
-				$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3609
-
3610
-			else
3611
-				$path = $modSettings['attachmentUploadDir'];
3812
+			if (!empty($modSettings['currentAttachmentUploadDir'])) {
3813
+							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3814
+			} else {
3815
+							$path = $modSettings['attachmentUploadDir'];
3816
+			}
3612 3817
 
3613 3818
 			secureDirectory($path, true);
3614 3819
 			secureDirectory($cachedir);
3615 3820
 
3616 3821
 			// If agreement is enabled, at least the english version shall exists
3617
-			if ($modSettings['requireAgreement'])
3618
-				$agreement = !file_exists($boarddir . '/agreement.txt');
3822
+			if ($modSettings['requireAgreement']) {
3823
+							$agreement = !file_exists($boarddir . '/agreement.txt');
3824
+			}
3619 3825
 
3620 3826
 			if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement))
3621 3827
 			{
@@ -3630,18 +3836,21 @@  discard block
 block discarded – undo
3630 3836
 					echo '
3631 3837
 				', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>';
3632 3838
 
3633
-					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~')
3634
-						echo '
3839
+					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') {
3840
+											echo '
3635 3841
 				', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>';
3842
+					}
3636 3843
 				}
3637 3844
 
3638
-				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir))
3639
-					echo '
3845
+				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) {
3846
+									echo '
3640 3847
 				<strong>', $txt['cache_writable'], '</strong><br>';
3848
+				}
3641 3849
 
3642
-				if (!empty($agreement))
3643
-					echo '
3850
+				if (!empty($agreement)) {
3851
+									echo '
3644 3852
 				<strong>', $txt['agreement_missing'], '</strong><br>';
3853
+				}
3645 3854
 
3646 3855
 				echo '
3647 3856
 			</p>
@@ -3656,16 +3865,18 @@  discard block
 block discarded – undo
3656 3865
 				<div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;">
3657 3866
 					', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']);
3658 3867
 
3659
-			if (!empty($_SESSION['ban']['cannot_post']['reason']))
3660
-				echo '
3868
+			if (!empty($_SESSION['ban']['cannot_post']['reason'])) {
3869
+							echo '
3661 3870
 					<div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>';
3871
+			}
3662 3872
 
3663
-			if (!empty($_SESSION['ban']['expire_time']))
3664
-				echo '
3873
+			if (!empty($_SESSION['ban']['expire_time'])) {
3874
+							echo '
3665 3875
 					<div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>';
3666
-			else
3667
-				echo '
3876
+			} else {
3877
+							echo '
3668 3878
 					<div>', $txt['your_ban_expires_never'], '</div>';
3879
+			}
3669 3880
 
3670 3881
 			echo '
3671 3882
 				</div>';
@@ -3681,8 +3892,9 @@  discard block
 block discarded – undo
3681 3892
 	global $forum_copyright, $software_year, $forum_version;
3682 3893
 
3683 3894
 	// Don't display copyright for things like SSI.
3684
-	if (!isset($forum_version) || !isset($software_year))
3685
-		return;
3895
+	if (!isset($forum_version) || !isset($software_year)) {
3896
+			return;
3897
+	}
3686 3898
 
3687 3899
 	// Put in the version...
3688 3900
 	printf($forum_copyright, $forum_version, $software_year);
@@ -3700,9 +3912,10 @@  discard block
 block discarded – undo
3700 3912
 	$context['load_time'] = round(microtime(true) - $time_start, 3);
3701 3913
 	$context['load_queries'] = $db_count;
3702 3914
 
3703
-	foreach (array_reverse($context['template_layers']) as $layer)
3704
-		loadSubTemplate($layer . '_below', true);
3705
-}
3915
+	foreach (array_reverse($context['template_layers']) as $layer) {
3916
+			loadSubTemplate($layer . '_below', true);
3917
+	}
3918
+	}
3706 3919
 
3707 3920
 /**
3708 3921
  * Output the Javascript files
@@ -3736,8 +3949,7 @@  discard block
 block discarded – undo
3736 3949
 			{
3737 3950
 				echo '
3738 3951
 		var ', $key, ';';
3739
-			}
3740
-			else
3952
+			} else
3741 3953
 			{
3742 3954
 				echo '
3743 3955
 		var ', $key, ' = ', $value, ';';
@@ -3756,27 +3968,29 @@  discard block
 block discarded – undo
3756 3968
 		foreach ($context['javascript_files'] as $id => $js_file)
3757 3969
 		{
3758 3970
 			// Last minute call! allow theme authors to disable single files.
3759
-			if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3760
-				continue;
3971
+			if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3972
+							continue;
3973
+			}
3761 3974
 
3762 3975
 			// By default files don't get minimized unless the file explicitly says so!
3763 3976
 			if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files']))
3764 3977
 			{
3765
-				if (!empty($js_file['options']['async']))
3766
-					$toMinify['async'][] = $js_file;
3767
-				elseif (!empty($js_file['options']['defer']))
3768
-					$toMinify['defer'][] = $js_file;
3769
-				else
3770
-					$toMinify['standard'][] = $js_file;
3978
+				if (!empty($js_file['options']['async'])) {
3979
+									$toMinify['async'][] = $js_file;
3980
+				} elseif (!empty($js_file['options']['defer'])) {
3981
+									$toMinify['defer'][] = $js_file;
3982
+				} else {
3983
+									$toMinify['standard'][] = $js_file;
3984
+				}
3771 3985
 
3772 3986
 				// Grab a random seed.
3773
-				if (!isset($minSeed) && isset($js_file['options']['seed']))
3774
-					$minSeed = $js_file['options']['seed'];
3775
-			}
3776
-
3777
-			else
3778
-				echo '
3987
+				if (!isset($minSeed) && isset($js_file['options']['seed'])) {
3988
+									$minSeed = $js_file['options']['seed'];
3989
+				}
3990
+			} else {
3991
+							echo '
3779 3992
 	<script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async' : '', !empty($js_file['options']['defer']) ? ' defer' : '', '></script>';
3993
+			}
3780 3994
 		}
3781 3995
 
3782 3996
 		foreach ($toMinify as $js_files)
@@ -3787,9 +4001,10 @@  discard block
 block discarded – undo
3787 4001
 
3788 4002
 				$minSuccessful = array_keys($result) === array('smf_minified');
3789 4003
 
3790
-				foreach ($result as $minFile)
3791
-					echo '
4004
+				foreach ($result as $minFile) {
4005
+									echo '
3792 4006
 	<script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async' : '', !empty($minFile['options']['defer']) ? ' defer' : '', '></script>';
4007
+				}
3793 4008
 			}
3794 4009
 		}
3795 4010
 	}
@@ -3803,8 +4018,9 @@  discard block
 block discarded – undo
3803 4018
 <script>
3804 4019
 window.addEventListener("DOMContentLoaded", function() {';
3805 4020
 
3806
-			foreach ($context['javascript_inline']['defer'] as $js_code)
3807
-				echo $js_code;
4021
+			foreach ($context['javascript_inline']['defer'] as $js_code) {
4022
+							echo $js_code;
4023
+			}
3808 4024
 
3809 4025
 			echo '
3810 4026
 });
@@ -3816,8 +4032,9 @@  discard block
 block discarded – undo
3816 4032
 			echo '
3817 4033
 	<script>';
3818 4034
 
3819
-			foreach ($context['javascript_inline']['standard'] as $js_code)
3820
-				echo $js_code;
4035
+			foreach ($context['javascript_inline']['standard'] as $js_code) {
4036
+							echo $js_code;
4037
+			}
3821 4038
 
3822 4039
 			echo '
3823 4040
 	</script>';
@@ -3845,23 +4062,26 @@  discard block
 block discarded – undo
3845 4062
 	foreach ($context['css_files'] as $id => $file)
3846 4063
 	{
3847 4064
 		// Last minute call! allow theme authors to disable single files.
3848
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3849
-			continue;
4065
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
4066
+					continue;
4067
+		}
3850 4068
 
3851 4069
 		// Files are minimized unless they explicitly opt out.
3852
-		if (!isset($file['options']['minimize']))
3853
-			$file['options']['minimize'] = true;
4070
+		if (!isset($file['options']['minimize'])) {
4071
+					$file['options']['minimize'] = true;
4072
+		}
3854 4073
 
3855 4074
 		if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files']) && !isset($_REQUEST['normalcss']))
3856 4075
 		{
3857 4076
 			$toMinify[] = $file;
3858 4077
 
3859 4078
 			// Grab a random seed.
3860
-			if (!isset($minSeed) && isset($file['options']['seed']))
3861
-				$minSeed = $file['options']['seed'];
4079
+			if (!isset($minSeed) && isset($file['options']['seed'])) {
4080
+							$minSeed = $file['options']['seed'];
4081
+			}
4082
+		} else {
4083
+					$normal[] = $file['fileUrl'];
3862 4084
 		}
3863
-		else
3864
-			$normal[] = $file['fileUrl'];
3865 4085
 	}
3866 4086
 
3867 4087
 	if (!empty($toMinify))
@@ -3870,23 +4090,26 @@  discard block
 block discarded – undo
3870 4090
 
3871 4091
 		$minSuccessful = array_keys($result) === array('smf_minified');
3872 4092
 
3873
-		foreach ($result as $minFile)
3874
-			echo '
4093
+		foreach ($result as $minFile) {
4094
+					echo '
3875 4095
 	<link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">';
4096
+		}
3876 4097
 	}
3877 4098
 
3878 4099
 	// Print the rest after the minified files.
3879
-	if (!empty($normal))
3880
-		foreach ($normal as $nf)
4100
+	if (!empty($normal)) {
4101
+			foreach ($normal as $nf)
3881 4102
 			echo '
3882 4103
 	<link rel="stylesheet" href="', $nf ,'">';
4104
+	}
3883 4105
 
3884 4106
 	if ($db_show_debug === true)
3885 4107
 	{
3886 4108
 		// Try to keep only what's useful.
3887 4109
 		$repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => '');
3888
-		foreach ($context['css_files'] as $file)
3889
-			$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
4110
+		foreach ($context['css_files'] as $file) {
4111
+					$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
4112
+		}
3890 4113
 	}
3891 4114
 
3892 4115
 	if (!empty($context['css_header']))
@@ -3894,9 +4117,10 @@  discard block
 block discarded – undo
3894 4117
 		echo '
3895 4118
 	<style>';
3896 4119
 
3897
-		foreach ($context['css_header'] as $css)
3898
-			echo $css .'
4120
+		foreach ($context['css_header'] as $css) {
4121
+					echo $css .'
3899 4122
 	';
4123
+		}
3900 4124
 
3901 4125
 		echo'
3902 4126
 	</style>';
@@ -3919,8 +4143,9 @@  discard block
 block discarded – undo
3919 4143
 	$type = !empty($type) && in_array($type, $types) ? $type : false;
3920 4144
 	$data = is_array($data) ? $data : array();
3921 4145
 
3922
-	if (empty($type) || empty($data))
3923
-		return $data;
4146
+	if (empty($type) || empty($data)) {
4147
+			return $data;
4148
+	}
3924 4149
 
3925 4150
 	// Different pages include different files, so we use a hash to label the different combinations
3926 4151
 	$hash = md5(implode(' ', array_map(function($file) { return $file['filePath'] . (int) @filesize($file['filePath']) . (int) @filemtime($file['filePath']); }, $data)));
@@ -3929,13 +4154,14 @@  discard block
 block discarded – undo
3929 4154
 	list($toCache, $async, $defer) = array_pad((array) cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400), 3, null);
3930 4155
 
3931 4156
 	// Already done?
3932
-	if (!empty($toCache))
3933
-		return array('smf_minified' => array(
4157
+	if (!empty($toCache)) {
4158
+			return array('smf_minified' => array(
3934 4159
 			'fileUrl' => $settings['theme_url'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/' . basename($toCache),
3935 4160
 			'filePath' => $toCache,
3936 4161
 			'fileName' => basename($toCache),
3937 4162
 			'options' => array('async' => !empty($async), 'defer' => !empty($defer)),
3938 4163
 		));
4164
+	}
3939 4165
 
3940 4166
 
3941 4167
 	// No namespaces, sorry!
@@ -3965,9 +4191,9 @@  discard block
 block discarded – undo
3965 4191
 
3966 4192
 	foreach ($data as $id => $file)
3967 4193
 	{
3968
-		if (empty($file['filePath']))
3969
-			$toAdd = false;
3970
-		else
4194
+		if (empty($file['filePath'])) {
4195
+					$toAdd = false;
4196
+		} else
3971 4197
 		{
3972 4198
 			$seed = isset($file['options']['seed']) ? $file['options']['seed'] : '';
3973 4199
 			$tempFile = str_replace($seed, '', $file['filePath']);
@@ -3975,12 +4201,14 @@  discard block
 block discarded – undo
3975 4201
 		}
3976 4202
 
3977 4203
 		// A minified script should only be loaded asynchronously if all its components wanted to be.
3978
-		if (empty($file['options']['async']))
3979
-			$async = false;
4204
+		if (empty($file['options']['async'])) {
4205
+					$async = false;
4206
+		}
3980 4207
 
3981 4208
 		// A minified script should only be deferred if all its components wanted to be.
3982
-		if (empty($file['options']['defer']))
3983
-			$defer = false;
4209
+		if (empty($file['options']['defer'])) {
4210
+					$defer = false;
4211
+		}
3984 4212
 
3985 4213
 		// The file couldn't be located so it won't be added. Log this error.
3986 4214
 		if (empty($toAdd))
@@ -4046,12 +4274,14 @@  discard block
 block discarded – undo
4046 4274
 			foreach (glob(rtrim($theme['dir'], '/') . '/' . ($type == 'css' ? 'css' : 'scripts') . '/minified*.' . $type) as $filename)
4047 4275
 			{
4048 4276
 				// Remove the cache entry
4049
-				if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches))
4050
-					cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null);
4277
+				if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) {
4278
+									cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null);
4279
+				}
4051 4280
 
4052 4281
 				// Try to delete the file. Add it to our error list if it fails.
4053
-				if (!@unlink($filename))
4054
-					$not_deleted[] = $filename;
4282
+				if (!@unlink($filename)) {
4283
+									$not_deleted[] = $filename;
4284
+				}
4055 4285
 			}
4056 4286
 		}
4057 4287
 	}
@@ -4083,8 +4313,9 @@  discard block
 block discarded – undo
4083 4313
 	global $modSettings, $smcFunc;
4084 4314
 
4085 4315
 	// Just make up a nice hash...
4086
-	if ($new)
4087
-		return sha1(md5($filename . time()) . mt_rand());
4316
+	if ($new) {
4317
+			return sha1(md5($filename . time()) . mt_rand());
4318
+	}
4088 4319
 
4089 4320
 	// Just make sure that attachment id is only a int
4090 4321
 	$attachment_id = (int) $attachment_id;
@@ -4101,23 +4332,25 @@  discard block
 block discarded – undo
4101 4332
 				'id_attach' => $attachment_id,
4102 4333
 			));
4103 4334
 
4104
-		if ($smcFunc['db_num_rows']($request) === 0)
4105
-			return false;
4335
+		if ($smcFunc['db_num_rows']($request) === 0) {
4336
+					return false;
4337
+		}
4106 4338
 
4107 4339
 		list ($file_hash) = $smcFunc['db_fetch_row']($request);
4108 4340
 		$smcFunc['db_free_result']($request);
4109 4341
 	}
4110 4342
 
4111 4343
 	// Still no hash? mmm...
4112
-	if (empty($file_hash))
4113
-		$file_hash = sha1(md5($filename . time()) . mt_rand());
4344
+	if (empty($file_hash)) {
4345
+			$file_hash = sha1(md5($filename . time()) . mt_rand());
4346
+	}
4114 4347
 
4115 4348
 	// Are we using multiple directories?
4116
-	if (is_array($modSettings['attachmentUploadDir']))
4117
-		$path = $modSettings['attachmentUploadDir'][$dir];
4118
-
4119
-	else
4120
-		$path = $modSettings['attachmentUploadDir'];
4349
+	if (is_array($modSettings['attachmentUploadDir'])) {
4350
+			$path = $modSettings['attachmentUploadDir'][$dir];
4351
+	} else {
4352
+			$path = $modSettings['attachmentUploadDir'];
4353
+	}
4121 4354
 
4122 4355
 	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
4123 4356
 }
@@ -4132,8 +4365,9 @@  discard block
 block discarded – undo
4132 4365
 function ip2range($fullip)
4133 4366
 {
4134 4367
 	// Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.)
4135
-	if ($fullip == 'unknown')
4136
-		$fullip = '255.255.255.255';
4368
+	if ($fullip == 'unknown') {
4369
+			$fullip = '255.255.255.255';
4370
+	}
4137 4371
 
4138 4372
 	$ip_parts = explode('-', $fullip);
4139 4373
 	$ip_array = array();
@@ -4157,10 +4391,11 @@  discard block
 block discarded – undo
4157 4391
 		$ip_array['low'] = $ip_parts[0];
4158 4392
 		$ip_array['high'] = $ip_parts[1];
4159 4393
 		return $ip_array;
4160
-	}
4161
-	elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.*
4394
+	} elseif (count($ip_parts) == 2) {
4395
+		// if ip 22.22.*-22.22.*
4162 4396
 	{
4163 4397
 		$valid_low = isValidIP($ip_parts[0]);
4398
+	}
4164 4399
 		$valid_high = isValidIP($ip_parts[1]);
4165 4400
 		$count = 0;
4166 4401
 		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
@@ -4175,7 +4410,9 @@  discard block
 block discarded – undo
4175 4410
 				$ip_parts[0] .= $mode . $min;
4176 4411
 				$valid_low = isValidIP($ip_parts[0]);
4177 4412
 				$count++;
4178
-				if ($count > 9) break;
4413
+				if ($count > 9) {
4414
+					break;
4415
+				}
4179 4416
 			}
4180 4417
 		}
4181 4418
 
@@ -4189,7 +4426,9 @@  discard block
 block discarded – undo
4189 4426
 				$ip_parts[1] .= $mode . $max;
4190 4427
 				$valid_high = isValidIP($ip_parts[1]);
4191 4428
 				$count++;
4192
-				if ($count > 9) break;
4429
+				if ($count > 9) {
4430
+					break;
4431
+				}
4193 4432
 			}
4194 4433
 		}
4195 4434
 
@@ -4213,46 +4452,54 @@  discard block
 block discarded – undo
4213 4452
 {
4214 4453
 	global $modSettings;
4215 4454
 
4216
-	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null)
4217
-		return $host;
4455
+	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) {
4456
+			return $host;
4457
+	}
4218 4458
 	$t = microtime();
4219 4459
 
4220 4460
 	// Try the Linux host command, perhaps?
4221 4461
 	if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1)
4222 4462
 	{
4223
-		if (!isset($modSettings['host_to_dis']))
4224
-			$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
4225
-		else
4226
-			$test = @shell_exec('host ' . @escapeshellarg($ip));
4463
+		if (!isset($modSettings['host_to_dis'])) {
4464
+					$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
4465
+		} else {
4466
+					$test = @shell_exec('host ' . @escapeshellarg($ip));
4467
+		}
4227 4468
 
4228 4469
 		// Did host say it didn't find anything?
4229
-		if (strpos($test, 'not found') !== false)
4230
-			$host = '';
4470
+		if (strpos($test, 'not found') !== false) {
4471
+					$host = '';
4472
+		}
4231 4473
 		// Invalid server option?
4232
-		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis']))
4233
-			updateSettings(array('host_to_dis' => 1));
4474
+		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) {
4475
+					updateSettings(array('host_to_dis' => 1));
4476
+		}
4234 4477
 		// Maybe it found something, after all?
4235
-		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1)
4236
-			$host = $match[1];
4478
+		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) {
4479
+					$host = $match[1];
4480
+		}
4237 4481
 	}
4238 4482
 
4239 4483
 	// This is nslookup; usually only Windows, but possibly some Unix?
4240 4484
 	if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
4241 4485
 	{
4242 4486
 		$test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip));
4243
-		if (strpos($test, 'Non-existent domain') !== false)
4244
-			$host = '';
4245
-		elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1)
4246
-			$host = $match[1];
4487
+		if (strpos($test, 'Non-existent domain') !== false) {
4488
+					$host = '';
4489
+		} elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) {
4490
+					$host = $match[1];
4491
+		}
4247 4492
 	}
4248 4493
 
4249 4494
 	// This is the last try :/.
4250
-	if (!isset($host) || $host === false)
4251
-		$host = @gethostbyaddr($ip);
4495
+	if (!isset($host) || $host === false) {
4496
+			$host = @gethostbyaddr($ip);
4497
+	}
4252 4498
 
4253 4499
 	// It took a long time, so let's cache it!
4254
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5)
4255
-		cache_put_data('hostlookup-' . $ip, $host, 600);
4500
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) {
4501
+			cache_put_data('hostlookup-' . $ip, $host, 600);
4502
+	}
4256 4503
 
4257 4504
 	return $host;
4258 4505
 }
@@ -4288,20 +4535,21 @@  discard block
 block discarded – undo
4288 4535
 			{
4289 4536
 				$encrypted = substr(crypt($word, 'uk'), 2, $max_chars);
4290 4537
 				$total = 0;
4291
-				for ($i = 0; $i < $max_chars; $i++)
4292
-					$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4538
+				for ($i = 0; $i < $max_chars; $i++) {
4539
+									$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4540
+				}
4293 4541
 				$returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total;
4294 4542
 			}
4295 4543
 		}
4296 4544
 		return array_unique($returned_ints);
4297
-	}
4298
-	else
4545
+	} else
4299 4546
 	{
4300 4547
 		// Trim characters before and after and add slashes for database insertion.
4301 4548
 		$returned_words = array();
4302
-		foreach ($words as $word)
4303
-			if (($word = trim($word, '-_\'')) !== '')
4549
+		foreach ($words as $word) {
4550
+					if (($word = trim($word, '-_\'')) !== '')
4304 4551
 				$returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars);
4552
+		}
4305 4553
 
4306 4554
 		// Filter out all words that occur more than once.
4307 4555
 		return array_unique($returned_words);
@@ -4323,16 +4571,18 @@  discard block
 block discarded – undo
4323 4571
 	global $settings, $txt;
4324 4572
 
4325 4573
 	// Does the current loaded theme have this and we are not forcing the usage of this function?
4326
-	if (function_exists('template_create_button') && !$force_use)
4327
-		return template_create_button($name, $alt, $label = '', $custom = '');
4574
+	if (function_exists('template_create_button') && !$force_use) {
4575
+			return template_create_button($name, $alt, $label = '', $custom = '');
4576
+	}
4328 4577
 
4329
-	if (!$settings['use_image_buttons'])
4330
-		return $txt[$alt];
4331
-	elseif (!empty($settings['use_buttons']))
4332
-		return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4333
-	else
4334
-		return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4335
-}
4578
+	if (!$settings['use_image_buttons']) {
4579
+			return $txt[$alt];
4580
+	} elseif (!empty($settings['use_buttons'])) {
4581
+			return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4582
+	} else {
4583
+			return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4584
+	}
4585
+	}
4336 4586
 
4337 4587
 /**
4338 4588
  * Sets up all of the top menu buttons
@@ -4375,9 +4625,10 @@  discard block
 block discarded – undo
4375 4625
 	var user_menus = new smc_PopupMenu();
4376 4626
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4377 4627
 	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4378
-		if ($context['allow_pm'])
4379
-			addInlineJavaScript('
4628
+		if ($context['allow_pm']) {
4629
+					addInlineJavaScript('
4380 4630
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
4631
+		}
4381 4632
 
4382 4633
 		if (!empty($modSettings['enable_ajax_alerts']))
4383 4634
 		{
@@ -4537,88 +4788,96 @@  discard block
 block discarded – undo
4537 4788
 
4538 4789
 		// Now we put the buttons in the context so the theme can use them.
4539 4790
 		$menu_buttons = array();
4540
-		foreach ($buttons as $act => $button)
4541
-			if (!empty($button['show']))
4791
+		foreach ($buttons as $act => $button) {
4792
+					if (!empty($button['show']))
4542 4793
 			{
4543 4794
 				$button['active_button'] = false;
4795
+		}
4544 4796
 
4545 4797
 				// This button needs some action.
4546
-				if (isset($button['action_hook']))
4547
-					$needs_action_hook = true;
4798
+				if (isset($button['action_hook'])) {
4799
+									$needs_action_hook = true;
4800
+				}
4548 4801
 
4549 4802
 				// Make sure the last button truly is the last button.
4550 4803
 				if (!empty($button['is_last']))
4551 4804
 				{
4552
-					if (isset($last_button))
4553
-						unset($menu_buttons[$last_button]['is_last']);
4805
+					if (isset($last_button)) {
4806
+											unset($menu_buttons[$last_button]['is_last']);
4807
+					}
4554 4808
 					$last_button = $act;
4555 4809
 				}
4556 4810
 
4557 4811
 				// Go through the sub buttons if there are any.
4558
-				if (!empty($button['sub_buttons']))
4559
-					foreach ($button['sub_buttons'] as $key => $subbutton)
4812
+				if (!empty($button['sub_buttons'])) {
4813
+									foreach ($button['sub_buttons'] as $key => $subbutton)
4560 4814
 					{
4561 4815
 						if (empty($subbutton['show']))
4562 4816
 							unset($button['sub_buttons'][$key]);
4817
+				}
4563 4818
 
4564 4819
 						// 2nd level sub buttons next...
4565 4820
 						if (!empty($subbutton['sub_buttons']))
4566 4821
 						{
4567 4822
 							foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
4568 4823
 							{
4569
-								if (empty($sub_button2['show']))
4570
-									unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4824
+								if (empty($sub_button2['show'])) {
4825
+																	unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4826
+								}
4571 4827
 							}
4572 4828
 						}
4573 4829
 					}
4574 4830
 
4575 4831
 				// Does this button have its own icon?
4576
-				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon']))
4577
-					$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4578
-				elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon']))
4579
-					$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4580
-				elseif (isset($button['icon']))
4581
-					$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4582
-				else
4583
-					$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4832
+				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) {
4833
+									$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4834
+				} elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) {
4835
+									$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4836
+				} elseif (isset($button['icon'])) {
4837
+									$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4838
+				} else {
4839
+									$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4840
+				}
4584 4841
 
4585 4842
 				$menu_buttons[$act] = $button;
4586 4843
 			}
4587 4844
 
4588
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
4589
-			cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4845
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
4846
+					cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4847
+		}
4590 4848
 	}
4591 4849
 
4592 4850
 	$context['menu_buttons'] = $menu_buttons;
4593 4851
 
4594 4852
 	// Logging out requires the session id in the url.
4595
-	if (isset($context['menu_buttons']['logout']))
4596
-		$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4853
+	if (isset($context['menu_buttons']['logout'])) {
4854
+			$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4855
+	}
4597 4856
 
4598 4857
 	// Figure out which action we are doing so we can set the active tab.
4599 4858
 	// Default to home.
4600 4859
 	$current_action = 'home';
4601 4860
 
4602
-	if (isset($context['menu_buttons'][$context['current_action']]))
4603
-		$current_action = $context['current_action'];
4604
-	elseif ($context['current_action'] == 'search2')
4605
-		$current_action = 'search';
4606
-	elseif ($context['current_action'] == 'theme')
4607
-		$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4608
-	elseif ($context['current_action'] == 'register2')
4609
-		$current_action = 'register';
4610
-	elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
4611
-		$current_action = 'login';
4612
-	elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
4613
-		$current_action = 'moderate';
4861
+	if (isset($context['menu_buttons'][$context['current_action']])) {
4862
+			$current_action = $context['current_action'];
4863
+	} elseif ($context['current_action'] == 'search2') {
4864
+			$current_action = 'search';
4865
+	} elseif ($context['current_action'] == 'theme') {
4866
+			$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4867
+	} elseif ($context['current_action'] == 'register2') {
4868
+			$current_action = 'register';
4869
+	} elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) {
4870
+			$current_action = 'login';
4871
+	} elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) {
4872
+			$current_action = 'moderate';
4873
+	}
4614 4874
 
4615 4875
 	// There are certain exceptions to the above where we don't want anything on the menu highlighted.
4616 4876
 	if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner']))
4617 4877
 	{
4618 4878
 		$current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile';
4619 4879
 		$context[$current_action] = true;
4620
-	}
4621
-	elseif ($context['current_action'] == 'pm')
4880
+	} elseif ($context['current_action'] == 'pm')
4622 4881
 	{
4623 4882
 		$current_action = 'self_pm';
4624 4883
 		$context['self_pm'] = true;
@@ -4681,12 +4940,14 @@  discard block
 block discarded – undo
4681 4940
 	}
4682 4941
 
4683 4942
 	// Not all actions are simple.
4684
-	if (!empty($needs_action_hook))
4685
-		call_integration_hook('integrate_current_action', array(&$current_action));
4943
+	if (!empty($needs_action_hook)) {
4944
+			call_integration_hook('integrate_current_action', array(&$current_action));
4945
+	}
4686 4946
 
4687
-	if (isset($context['menu_buttons'][$current_action]))
4688
-		$context['menu_buttons'][$current_action]['active_button'] = true;
4689
-}
4947
+	if (isset($context['menu_buttons'][$current_action])) {
4948
+			$context['menu_buttons'][$current_action]['active_button'] = true;
4949
+	}
4950
+	}
4690 4951
 
4691 4952
 /**
4692 4953
  * Generate a random seed and ensure it's stored in settings.
@@ -4710,30 +4971,35 @@  discard block
 block discarded – undo
4710 4971
 	global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug;
4711 4972
 	global $context, $txt;
4712 4973
 
4713
-	if ($db_show_debug === true)
4714
-		$context['debug']['hooks'][] = $hook;
4974
+	if ($db_show_debug === true) {
4975
+			$context['debug']['hooks'][] = $hook;
4976
+	}
4715 4977
 
4716 4978
 	// Need to have some control.
4717
-	if (!isset($context['instances']))
4718
-		$context['instances'] = array();
4979
+	if (!isset($context['instances'])) {
4980
+			$context['instances'] = array();
4981
+	}
4719 4982
 
4720 4983
 	$results = array();
4721
-	if (empty($modSettings[$hook]))
4722
-		return $results;
4984
+	if (empty($modSettings[$hook])) {
4985
+			return $results;
4986
+	}
4723 4987
 
4724 4988
 	$functions = explode(',', $modSettings[$hook]);
4725 4989
 	// Loop through each function.
4726 4990
 	foreach ($functions as $function)
4727 4991
 	{
4728 4992
 		// Hook has been marked as "disabled". Skip it!
4729
-		if (strpos($function, '!') !== false)
4730
-			continue;
4993
+		if (strpos($function, '!') !== false) {
4994
+					continue;
4995
+		}
4731 4996
 
4732 4997
 		$call = call_helper($function, true);
4733 4998
 
4734 4999
 		// Is it valid?
4735
-		if (!empty($call))
4736
-			$results[$function] = call_user_func_array($call, $parameters);
5000
+		if (!empty($call)) {
5001
+					$results[$function] = call_user_func_array($call, $parameters);
5002
+		}
4737 5003
 
4738 5004
 		// Whatever it was suppose to call, it failed :(
4739 5005
 		elseif (!empty($function))
@@ -4749,8 +5015,9 @@  discard block
 block discarded – undo
4749 5015
 			}
4750 5016
 
4751 5017
 			// "Assume" the file resides on $boarddir somewhere...
4752
-			else
4753
-				log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
5018
+			else {
5019
+							log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
5020
+			}
4754 5021
 		}
4755 5022
 	}
4756 5023
 
@@ -4772,12 +5039,14 @@  discard block
 block discarded – undo
4772 5039
 	global $smcFunc, $modSettings;
4773 5040
 
4774 5041
 	// Any objects?
4775
-	if ($object)
4776
-		$function = $function . '#';
5042
+	if ($object) {
5043
+			$function = $function . '#';
5044
+	}
4777 5045
 
4778 5046
 	// Any files  to load?
4779
-	if (!empty($file) && is_string($file))
4780
-		$function = $file . (!empty($function) ? '|' . $function : '');
5047
+	if (!empty($file) && is_string($file)) {
5048
+			$function = $file . (!empty($function) ? '|' . $function : '');
5049
+	}
4781 5050
 
4782 5051
 	// Get the correct string.
4783 5052
 	$integration_call = $function;
@@ -4799,13 +5068,14 @@  discard block
 block discarded – undo
4799 5068
 		if (!empty($current_functions))
4800 5069
 		{
4801 5070
 			$current_functions = explode(',', $current_functions);
4802
-			if (in_array($integration_call, $current_functions))
4803
-				return;
5071
+			if (in_array($integration_call, $current_functions)) {
5072
+							return;
5073
+			}
4804 5074
 
4805 5075
 			$permanent_functions = array_merge($current_functions, array($integration_call));
5076
+		} else {
5077
+					$permanent_functions = array($integration_call);
4806 5078
 		}
4807
-		else
4808
-			$permanent_functions = array($integration_call);
4809 5079
 
4810 5080
 		updateSettings(array($hook => implode(',', $permanent_functions)));
4811 5081
 	}
@@ -4814,8 +5084,9 @@  discard block
 block discarded – undo
4814 5084
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4815 5085
 
4816 5086
 	// Do nothing, if it's already there.
4817
-	if (in_array($integration_call, $functions))
4818
-		return;
5087
+	if (in_array($integration_call, $functions)) {
5088
+			return;
5089
+	}
4819 5090
 
4820 5091
 	$functions[] = $integration_call;
4821 5092
 	$modSettings[$hook] = implode(',', $functions);
@@ -4838,12 +5109,14 @@  discard block
 block discarded – undo
4838 5109
 	global $smcFunc, $modSettings;
4839 5110
 
4840 5111
 	// Any objects?
4841
-	if ($object)
4842
-		$function = $function . '#';
5112
+	if ($object) {
5113
+			$function = $function . '#';
5114
+	}
4843 5115
 
4844 5116
 	// Any files  to load?
4845
-	if (!empty($file) && is_string($file))
4846
-		$function = $file . '|' . $function;
5117
+	if (!empty($file) && is_string($file)) {
5118
+			$function = $file . '|' . $function;
5119
+	}
4847 5120
 
4848 5121
 	// Get the correct string.
4849 5122
 	$integration_call = $function;
@@ -4864,16 +5137,18 @@  discard block
 block discarded – undo
4864 5137
 	{
4865 5138
 		$current_functions = explode(',', $current_functions);
4866 5139
 
4867
-		if (in_array($integration_call, $current_functions))
4868
-			updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
5140
+		if (in_array($integration_call, $current_functions)) {
5141
+					updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
5142
+		}
4869 5143
 	}
4870 5144
 
4871 5145
 	// Turn the function list into something usable.
4872 5146
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4873 5147
 
4874 5148
 	// You can only remove it if it's available.
4875
-	if (!in_array($integration_call, $functions))
4876
-		return;
5149
+	if (!in_array($integration_call, $functions)) {
5150
+			return;
5151
+	}
4877 5152
 
4878 5153
 	$functions = array_diff($functions, array($integration_call));
4879 5154
 	$modSettings[$hook] = implode(',', $functions);
@@ -4894,17 +5169,20 @@  discard block
 block discarded – undo
4894 5169
 	global $context, $smcFunc, $txt, $db_show_debug;
4895 5170
 
4896 5171
 	// Really?
4897
-	if (empty($string))
4898
-		return false;
5172
+	if (empty($string)) {
5173
+			return false;
5174
+	}
4899 5175
 
4900 5176
 	// An array? should be a "callable" array IE array(object/class, valid_callable).
4901 5177
 	// A closure? should be a callable one.
4902
-	if (is_array($string) || $string instanceof Closure)
4903
-		return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
5178
+	if (is_array($string) || $string instanceof Closure) {
5179
+			return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
5180
+	}
4904 5181
 
4905 5182
 	// No full objects, sorry! pass a method or a property instead!
4906
-	if (is_object($string))
4907
-		return false;
5183
+	if (is_object($string)) {
5184
+			return false;
5185
+	}
4908 5186
 
4909 5187
 	// Stay vitaminized my friends...
4910 5188
 	$string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string));
@@ -4913,8 +5191,9 @@  discard block
 block discarded – undo
4913 5191
 	$string = load_file($string);
4914 5192
 
4915 5193
 	// Loaded file failed
4916
-	if (empty($string))
4917
-		return false;
5194
+	if (empty($string)) {
5195
+			return false;
5196
+	}
4918 5197
 
4919 5198
 	// Found a method.
4920 5199
 	if (strpos($string, '::') !== false)
@@ -4935,8 +5214,9 @@  discard block
 block discarded – undo
4935 5214
 				// Add another one to the list.
4936 5215
 				if ($db_show_debug === true)
4937 5216
 				{
4938
-					if (!isset($context['debug']['instances']))
4939
-						$context['debug']['instances'] = array();
5217
+					if (!isset($context['debug']['instances'])) {
5218
+											$context['debug']['instances'] = array();
5219
+					}
4940 5220
 
4941 5221
 					$context['debug']['instances'][$class] = $class;
4942 5222
 				}
@@ -4946,13 +5226,15 @@  discard block
 block discarded – undo
4946 5226
 		}
4947 5227
 
4948 5228
 		// Right then. This is a call to a static method.
4949
-		else
4950
-			$func = array($class, $method);
5229
+		else {
5230
+					$func = array($class, $method);
5231
+		}
4951 5232
 	}
4952 5233
 
4953 5234
 	// Nope! just a plain regular function.
4954
-	else
4955
-		$func = $string;
5235
+	else {
5236
+			$func = $string;
5237
+	}
4956 5238
 
4957 5239
 	// Right, we got what we need, time to do some checks.
4958 5240
 	if (!is_callable($func, false, $callable_name))
@@ -4968,17 +5250,18 @@  discard block
 block discarded – undo
4968 5250
 	else
4969 5251
 	{
4970 5252
 		// What are we gonna do about it?
4971
-		if ($return)
4972
-			return $func;
5253
+		if ($return) {
5254
+					return $func;
5255
+		}
4973 5256
 
4974 5257
 		// If this is a plain function, avoid the heat of calling call_user_func().
4975 5258
 		else
4976 5259
 		{
4977
-			if (is_array($func))
4978
-				call_user_func($func);
4979
-
4980
-			else
4981
-				$func();
5260
+			if (is_array($func)) {
5261
+							call_user_func($func);
5262
+			} else {
5263
+							$func();
5264
+			}
4982 5265
 		}
4983 5266
 	}
4984 5267
 }
@@ -4995,31 +5278,34 @@  discard block
 block discarded – undo
4995 5278
 {
4996 5279
 	global $sourcedir, $txt, $boarddir, $settings;
4997 5280
 
4998
-	if (empty($string))
4999
-		return false;
5281
+	if (empty($string)) {
5282
+			return false;
5283
+	}
5000 5284
 
5001 5285
 	if (strpos($string, '|') !== false)
5002 5286
 	{
5003 5287
 		list ($file, $string) = explode('|', $string);
5004 5288
 
5005 5289
 		// Match the wildcards to their regular vars.
5006
-		if (empty($settings['theme_dir']))
5007
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
5008
-
5009
-		else
5010
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
5290
+		if (empty($settings['theme_dir'])) {
5291
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
5292
+		} else {
5293
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
5294
+		}
5011 5295
 
5012 5296
 		// Load the file if it can be loaded.
5013
-		if (file_exists($absPath))
5014
-			require_once($absPath);
5297
+		if (file_exists($absPath)) {
5298
+					require_once($absPath);
5299
+		}
5015 5300
 
5016 5301
 		// No? try a fallback to $sourcedir
5017 5302
 		else
5018 5303
 		{
5019 5304
 			$absPath = $sourcedir .'/'. $file;
5020 5305
 
5021
-			if (file_exists($absPath))
5022
-				require_once($absPath);
5306
+			if (file_exists($absPath)) {
5307
+							require_once($absPath);
5308
+			}
5023 5309
 
5024 5310
 			// Sorry, can't do much for you at this point.
5025 5311
 			else
@@ -5058,8 +5344,9 @@  discard block
 block discarded – undo
5058 5344
 	preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match);
5059 5345
 
5060 5346
 	// No scheme? No data for you!
5061
-	if (empty($match[1]))
5062
-		return false;
5347
+	if (empty($match[1])) {
5348
+			return false;
5349
+	}
5063 5350
 
5064 5351
 	// An FTP url. We should try connecting and RETRieving it...
5065 5352
 	elseif ($match[1] == 'ftp')
@@ -5069,23 +5356,26 @@  discard block
 block discarded – undo
5069 5356
 
5070 5357
 		// Establish a connection and attempt to enable passive mode.
5071 5358
 		$ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email);
5072
-		if ($ftp->error !== false || !$ftp->passive())
5073
-			return false;
5359
+		if ($ftp->error !== false || !$ftp->passive()) {
5360
+					return false;
5361
+		}
5074 5362
 
5075 5363
 		// I want that one *points*!
5076 5364
 		fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n");
5077 5365
 
5078 5366
 		// Since passive mode worked (or we would have returned already!) open the connection.
5079 5367
 		$fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5);
5080
-		if (!$fp)
5081
-			return false;
5368
+		if (!$fp) {
5369
+					return false;
5370
+		}
5082 5371
 
5083 5372
 		// The server should now say something in acknowledgement.
5084 5373
 		$ftp->check_response(150);
5085 5374
 
5086 5375
 		$data = '';
5087
-		while (!feof($fp))
5088
-			$data .= fread($fp, 4096);
5376
+		while (!feof($fp)) {
5377
+					$data .= fread($fp, 4096);
5378
+		}
5089 5379
 		fclose($fp);
5090 5380
 
5091 5381
 		// All done, right?  Good.
@@ -5097,8 +5387,9 @@  discard block
 block discarded – undo
5097 5387
 	elseif (isset($match[1]) && $match[1] == 'http')
5098 5388
 	{
5099 5389
 		// First try to use fsockopen, because it is fastest.
5100
-		if ($keep_alive && $match[3] == $keep_alive_dom)
5101
-			$fp = $keep_alive_fp;
5390
+		if ($keep_alive && $match[3] == $keep_alive_dom) {
5391
+					$fp = $keep_alive_fp;
5392
+		}
5102 5393
 		if (empty($fp))
5103 5394
 		{
5104 5395
 			// Open the socket on the port we want...
@@ -5118,20 +5409,21 @@  discard block
 block discarded – undo
5118 5409
 				fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n");
5119 5410
 				fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
5120 5411
 				fwrite($fp, 'user-agent: PHP/SMF' . "\r\n");
5121
-				if ($keep_alive)
5122
-					fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n");
5123
-				else
5124
-					fwrite($fp, 'connection: close' . "\r\n\r\n");
5125
-			}
5126
-			else
5412
+				if ($keep_alive) {
5413
+									fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n");
5414
+				} else {
5415
+									fwrite($fp, 'connection: close' . "\r\n\r\n");
5416
+				}
5417
+			} else
5127 5418
 			{
5128 5419
 				fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n");
5129 5420
 				fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
5130 5421
 				fwrite($fp, 'user-agent: PHP/SMF' . "\r\n");
5131
-				if ($keep_alive)
5132
-					fwrite($fp, 'connection: Keep-Alive' . "\r\n");
5133
-				else
5134
-					fwrite($fp, 'connection: close' . "\r\n");
5422
+				if ($keep_alive) {
5423
+									fwrite($fp, 'connection: Keep-Alive' . "\r\n");
5424
+				} else {
5425
+									fwrite($fp, 'connection: close' . "\r\n");
5426
+				}
5135 5427
 				fwrite($fp, 'content-type: application/x-www-form-urlencoded' . "\r\n");
5136 5428
 				fwrite($fp, 'content-length: ' . strlen($post_data) . "\r\n\r\n");
5137 5429
 				fwrite($fp, $post_data);
@@ -5144,30 +5436,33 @@  discard block
 block discarded – undo
5144 5436
 			{
5145 5437
 				$header = '';
5146 5438
 				$location = '';
5147
-				while (!feof($fp) && trim($header = fgets($fp, 4096)) != '')
5148
-					if (strpos($header, 'location:') !== false)
5439
+				while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') {
5440
+									if (strpos($header, 'location:') !== false)
5149 5441
 						$location = trim(substr($header, strpos($header, ':') + 1));
5442
+				}
5150 5443
 
5151
-				if (empty($location))
5152
-					return false;
5153
-				else
5444
+				if (empty($location)) {
5445
+									return false;
5446
+				} else
5154 5447
 				{
5155
-					if (!$keep_alive)
5156
-						fclose($fp);
5448
+					if (!$keep_alive) {
5449
+											fclose($fp);
5450
+					}
5157 5451
 					return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1);
5158 5452
 				}
5159 5453
 			}
5160 5454
 
5161 5455
 			// Make sure we get a 200 OK.
5162
-			elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0)
5163
-				return false;
5456
+			elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) {
5457
+							return false;
5458
+			}
5164 5459
 
5165 5460
 			// Skip the headers...
5166 5461
 			while (!feof($fp) && trim($header = fgets($fp, 4096)) != '')
5167 5462
 			{
5168
-				if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0)
5169
-					$content_length = $match[1];
5170
-				elseif (preg_match('~connection:\s*close~i', $header) != 0)
5463
+				if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) {
5464
+									$content_length = $match[1];
5465
+				} elseif (preg_match('~connection:\s*close~i', $header) != 0)
5171 5466
 				{
5172 5467
 					$keep_alive_dom = null;
5173 5468
 					$keep_alive = false;
@@ -5179,17 +5474,19 @@  discard block
 block discarded – undo
5179 5474
 			$data = '';
5180 5475
 			if (isset($content_length))
5181 5476
 			{
5182
-				while (!feof($fp) && strlen($data) < $content_length)
5183
-					$data .= fread($fp, $content_length - strlen($data));
5184
-			}
5185
-			else
5477
+				while (!feof($fp) && strlen($data) < $content_length) {
5478
+									$data .= fread($fp, $content_length - strlen($data));
5479
+				}
5480
+			} else
5186 5481
 			{
5187
-				while (!feof($fp))
5188
-					$data .= fread($fp, 4096);
5482
+				while (!feof($fp)) {
5483
+									$data .= fread($fp, 4096);
5484
+				}
5189 5485
 			}
5190 5486
 
5191
-			if (!$keep_alive)
5192
-				fclose($fp);
5487
+			if (!$keep_alive) {
5488
+							fclose($fp);
5489
+			}
5193 5490
 		}
5194 5491
 
5195 5492
 		// If using fsockopen didn't work, try to use cURL if available.
@@ -5202,17 +5499,18 @@  discard block
 block discarded – undo
5202 5499
 			$fetch_data->get_url_data($url, $post_data);
5203 5500
 
5204 5501
 			// no errors and a 200 result, then we have a good dataset, well we at least have data. ;)
5205
-			if ($fetch_data->result('code') == 200 && !$fetch_data->result('error'))
5206
-				$data = $fetch_data->result('body');
5207
-			else
5208
-				return false;
5502
+			if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) {
5503
+							$data = $fetch_data->result('body');
5504
+			} else {
5505
+							return false;
5506
+			}
5209 5507
 		}
5210 5508
 
5211 5509
 		// Neither fsockopen nor curl are available. Well, phooey.
5212
-		else
5213
-			return false;
5214
-	}
5215
-	else
5510
+		else {
5511
+					return false;
5512
+		}
5513
+	} else
5216 5514
 	{
5217 5515
 		// Umm, this shouldn't happen?
5218 5516
 		trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE);
@@ -5232,8 +5530,9 @@  discard block
 block discarded – undo
5232 5530
 	global $user_info, $smcFunc;
5233 5531
 
5234 5532
 	// Make sure we have something to work with.
5235
-	if (empty($topic))
5236
-		return array();
5533
+	if (empty($topic)) {
5534
+			return array();
5535
+	}
5237 5536
 
5238 5537
 
5239 5538
 	// We already know the number of likes per message, we just want to know whether the current user liked it or not.
@@ -5256,8 +5555,9 @@  discard block
 block discarded – undo
5256 5555
 				'topic' => $topic,
5257 5556
 			)
5258 5557
 		);
5259
-		while ($row = $smcFunc['db_fetch_assoc']($request))
5260
-			$temp[] = (int) $row['content_id'];
5558
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5559
+					$temp[] = (int) $row['content_id'];
5560
+		}
5261 5561
 
5262 5562
 		cache_put_data($cache_key, $temp, $ttl);
5263 5563
 	}
@@ -5278,8 +5578,9 @@  discard block
 block discarded – undo
5278 5578
 {
5279 5579
 	global $context;
5280 5580
 
5281
-	if (empty($string))
5282
-		return $string;
5581
+	if (empty($string)) {
5582
+			return $string;
5583
+	}
5283 5584
 
5284 5585
 	// UTF-8 occurences of MS special characters
5285 5586
 	$findchars_utf8 = array(
@@ -5320,10 +5621,11 @@  discard block
 block discarded – undo
5320 5621
 		'--',	// &mdash;
5321 5622
 	);
5322 5623
 
5323
-	if ($context['utf8'])
5324
-		$string = str_replace($findchars_utf8, $replacechars, $string);
5325
-	else
5326
-		$string = str_replace($findchars_iso, $replacechars, $string);
5624
+	if ($context['utf8']) {
5625
+			$string = str_replace($findchars_utf8, $replacechars, $string);
5626
+	} else {
5627
+			$string = str_replace($findchars_iso, $replacechars, $string);
5628
+	}
5327 5629
 
5328 5630
 	return $string;
5329 5631
 }
@@ -5342,49 +5644,59 @@  discard block
 block discarded – undo
5342 5644
 {
5343 5645
 	global $context;
5344 5646
 
5345
-	if (!isset($matches[2]))
5346
-		return '';
5647
+	if (!isset($matches[2])) {
5648
+			return '';
5649
+	}
5347 5650
 
5348 5651
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
5349 5652
 
5350 5653
 	// remove left to right / right to left overrides
5351
-	if ($num === 0x202D || $num === 0x202E)
5352
-		return '';
5654
+	if ($num === 0x202D || $num === 0x202E) {
5655
+			return '';
5656
+	}
5353 5657
 
5354 5658
 	// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
5355
-	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E)))
5356
-		return '&#' . $num . ';';
5659
+	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) {
5660
+			return '&#' . $num . ';';
5661
+	}
5357 5662
 
5358 5663
 	if (empty($context['utf8']))
5359 5664
 	{
5360 5665
 		// no control characters
5361
-		if ($num < 0x20)
5362
-			return '';
5666
+		if ($num < 0x20) {
5667
+					return '';
5668
+		}
5363 5669
 		// text is text
5364
-		elseif ($num < 0x80)
5365
-			return chr($num);
5670
+		elseif ($num < 0x80) {
5671
+					return chr($num);
5672
+		}
5366 5673
 		// all others get html-ised
5367
-		else
5368
-			return '&#' . $matches[2] . ';';
5369
-	}
5370
-	else
5674
+		else {
5675
+					return '&#' . $matches[2] . ';';
5676
+		}
5677
+	} else
5371 5678
 	{
5372 5679
 		// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
5373 5680
 		// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
5374
-		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
5375
-			return '';
5681
+		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) {
5682
+					return '';
5683
+		}
5376 5684
 		// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
5377
-		elseif ($num < 0x80)
5378
-			return chr($num);
5685
+		elseif ($num < 0x80) {
5686
+					return chr($num);
5687
+		}
5379 5688
 		// <0x800 (2048)
5380
-		elseif ($num < 0x800)
5381
-			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5689
+		elseif ($num < 0x800) {
5690
+					return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5691
+		}
5382 5692
 		// < 0x10000 (65536)
5383
-		elseif ($num < 0x10000)
5384
-			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5693
+		elseif ($num < 0x10000) {
5694
+					return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5695
+		}
5385 5696
 		// <= 0x10FFFF (1114111)
5386
-		else
5387
-			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5697
+		else {
5698
+					return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5699
+		}
5388 5700
 	}
5389 5701
 }
5390 5702
 
@@ -5400,28 +5712,34 @@  discard block
 block discarded – undo
5400 5712
  */
5401 5713
 function fixchar__callback($matches)
5402 5714
 {
5403
-	if (!isset($matches[1]))
5404
-		return '';
5715
+	if (!isset($matches[1])) {
5716
+			return '';
5717
+	}
5405 5718
 
5406 5719
 	$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];
5407 5720
 
5408 5721
 	// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
5409 5722
 	// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
5410
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
5411
-		return '';
5723
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) {
5724
+			return '';
5725
+	}
5412 5726
 	// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
5413
-	elseif ($num < 0x80)
5414
-		return chr($num);
5727
+	elseif ($num < 0x80) {
5728
+			return chr($num);
5729
+	}
5415 5730
 	// <0x800 (2048)
5416
-	elseif ($num < 0x800)
5417
-		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5731
+	elseif ($num < 0x800) {
5732
+			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5733
+	}
5418 5734
 	// < 0x10000 (65536)
5419
-	elseif ($num < 0x10000)
5420
-		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5735
+	elseif ($num < 0x10000) {
5736
+			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5737
+	}
5421 5738
 	// <= 0x10FFFF (1114111)
5422
-	else
5423
-		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5424
-}
5739
+	else {
5740
+			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5741
+	}
5742
+	}
5425 5743
 
5426 5744
 /**
5427 5745
  * Strips out invalid html entities, replaces others with html style &#123; codes
@@ -5434,17 +5752,19 @@  discard block
 block discarded – undo
5434 5752
  */
5435 5753
 function entity_fix__callback($matches)
5436 5754
 {
5437
-	if (!isset($matches[2]))
5438
-		return '';
5755
+	if (!isset($matches[2])) {
5756
+			return '';
5757
+	}
5439 5758
 
5440 5759
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
5441 5760
 
5442 5761
 	// we don't allow control characters, characters out of range, byte markers, etc
5443
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
5444
-		return '';
5445
-	else
5446
-		return '&#' . $num . ';';
5447
-}
5762
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) {
5763
+			return '';
5764
+	} else {
5765
+			return '&#' . $num . ';';
5766
+	}
5767
+	}
5448 5768
 
5449 5769
 /**
5450 5770
  * Return a Gravatar URL based on
@@ -5468,18 +5788,23 @@  discard block
 block discarded – undo
5468 5788
 		$ratings = array('G', 'PG', 'R', 'X');
5469 5789
 		$defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank');
5470 5790
 		$url_params = array();
5471
-		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings))
5472
-			$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5473
-		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults))
5474
-			$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5475
-		if (!empty($modSettings['avatar_max_width_external']))
5476
-			$size_string = (int) $modSettings['avatar_max_width_external'];
5477
-		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string))
5478
-			if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5791
+		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) {
5792
+					$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5793
+		}
5794
+		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) {
5795
+					$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5796
+		}
5797
+		if (!empty($modSettings['avatar_max_width_external'])) {
5798
+					$size_string = (int) $modSettings['avatar_max_width_external'];
5799
+		}
5800
+		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) {
5801
+					if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5479 5802
 				$size_string = $modSettings['avatar_max_height_external'];
5803
+		}
5480 5804
 
5481
-		if (!empty($size_string))
5482
-			$url_params[] = 's=' . $size_string;
5805
+		if (!empty($size_string)) {
5806
+					$url_params[] = 's=' . $size_string;
5807
+		}
5483 5808
 	}
5484 5809
 	$http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www';
5485 5810
 
@@ -5498,22 +5823,26 @@  discard block
 block discarded – undo
5498 5823
 	static $timezones = null, $lastwhen = null;
5499 5824
 
5500 5825
 	// No point doing this over if we already did it once
5501
-	if (!empty($timezones) && $when == $lastwhen)
5502
-		return $timezones;
5503
-	else
5504
-		$lastwhen = $when;
5826
+	if (!empty($timezones) && $when == $lastwhen) {
5827
+			return $timezones;
5828
+	} else {
5829
+			$lastwhen = $when;
5830
+	}
5505 5831
 
5506 5832
 	// Parseable datetime string?
5507
-	if (is_int($timestamp = strtotime($when)))
5508
-		$when = $timestamp;
5833
+	if (is_int($timestamp = strtotime($when))) {
5834
+			$when = $timestamp;
5835
+	}
5509 5836
 
5510 5837
 	// A Unix timestamp?
5511
-	elseif (is_numeric($when))
5512
-		$when = intval($when);
5838
+	elseif (is_numeric($when)) {
5839
+			$when = intval($when);
5840
+	}
5513 5841
 
5514 5842
 	// Invalid value? Just get current Unix timestamp.
5515
-	else
5516
-		$when = time();
5843
+	else {
5844
+			$when = time();
5845
+	}
5517 5846
 
5518 5847
 	// We'll need these too
5519 5848
 	$date_when = date_create('@' . $when);
@@ -5528,8 +5857,9 @@  discard block
 block discarded – undo
5528 5857
 	foreach ($priority_countries as $country)
5529 5858
 	{
5530 5859
 		$country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country)));
5531
-		if (!empty($country_tzids))
5532
-			$priority_tzids = array_merge($priority_tzids, $country_tzids);
5860
+		if (!empty($country_tzids)) {
5861
+					$priority_tzids = array_merge($priority_tzids, $country_tzids);
5862
+		}
5533 5863
 	}
5534 5864
 
5535 5865
 	// Antarctic research stations should be listed last, unless you're running a penguin forum
@@ -5543,8 +5873,9 @@  discard block
 block discarded – undo
5543 5873
 	foreach ($tzids as $tzid)
5544 5874
 	{
5545 5875
 		// We don't want UTC right now
5546
-		if ($tzid == 'UTC')
5547
-			continue;
5876
+		if ($tzid == 'UTC') {
5877
+					continue;
5878
+		}
5548 5879
 
5549 5880
 		$tz = timezone_open($tzid);
5550 5881
 
@@ -5565,13 +5896,14 @@  discard block
 block discarded – undo
5565 5896
 		}
5566 5897
 
5567 5898
 		// A time zone from a prioritized country?
5568
-		if (in_array($tzid, $priority_tzids))
5569
-			$priority_zones[$tzkey] = true;
5899
+		if (in_array($tzid, $priority_tzids)) {
5900
+					$priority_zones[$tzkey] = true;
5901
+		}
5570 5902
 
5571 5903
 		// Keep track of the location and offset for this tzid
5572
-		if (!empty($txt[$tzid]))
5573
-			$zones[$tzkey]['locations'][] = $txt[$tzid];
5574
-		else
5904
+		if (!empty($txt[$tzid])) {
5905
+					$zones[$tzkey]['locations'][] = $txt[$tzid];
5906
+		} else
5575 5907
 		{
5576 5908
 			$tzid_parts = explode('/', $tzid);
5577 5909
 			$zones[$tzkey]['locations'][] = str_replace(array('St_', '_'), array('St. ', ' '), array_pop($tzid_parts));
@@ -5591,23 +5923,27 @@  discard block
 block discarded – undo
5591 5923
 		date_timezone_set($date_when, timezone_open($tzvalue['tzid']));
5592 5924
 
5593 5925
 		// Use the custom description, if there is one
5594
-		if (!empty($tztxt[$tzvalue['tzid']]))
5595
-			$desc = $tztxt[$tzvalue['tzid']];
5926
+		if (!empty($tztxt[$tzvalue['tzid']])) {
5927
+					$desc = $tztxt[$tzvalue['tzid']];
5928
+		}
5596 5929
 		// Otherwise, use the list of locations (max 5, so things don't get silly)
5597
-		else
5598
-			$desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : '');
5930
+		else {
5931
+					$desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : '');
5932
+		}
5599 5933
 
5600 5934
 		// Show the UTC offset and the abbreviation, if it's something like 'MST' and not '-06'
5601 5935
 		$desc = '[UTC' . date_format($date_when, 'P') . '] - ' . (!strspn($tzvalue['abbr'], '+-') ? $tzvalue['abbr'] . ' - ' : '') . $desc;
5602 5936
 
5603
-		if (isset($priority_zones[$tzkey]))
5604
-			$priority_timezones[$tzvalue['tzid']] = $desc;
5605
-		else
5606
-			$timezones[$tzvalue['tzid']] = $desc;
5937
+		if (isset($priority_zones[$tzkey])) {
5938
+					$priority_timezones[$tzvalue['tzid']] = $desc;
5939
+		} else {
5940
+					$timezones[$tzvalue['tzid']] = $desc;
5941
+		}
5607 5942
 	}
5608 5943
 
5609
-	if (!empty($priority_timezones))
5610
-		$priority_timezones[] = '-----';
5944
+	if (!empty($priority_timezones)) {
5945
+			$priority_timezones[] = '-----';
5946
+	}
5611 5947
 
5612 5948
 	$timezones = array_merge(
5613 5949
 		$priority_timezones,
@@ -5624,8 +5960,9 @@  discard block
 block discarded – undo
5624 5960
  */
5625 5961
 function inet_ptod($ip_address)
5626 5962
 {
5627
-	if (!isValidIP($ip_address))
5628
-		return $ip_address;
5963
+	if (!isValidIP($ip_address)) {
5964
+			return $ip_address;
5965
+	}
5629 5966
 
5630 5967
 	$bin = inet_pton($ip_address);
5631 5968
 	return $bin;
@@ -5637,13 +5974,15 @@  discard block
 block discarded – undo
5637 5974
  */
5638 5975
 function inet_dtop($bin)
5639 5976
 {
5640
-	if(empty($bin))
5641
-		return '';
5977
+	if(empty($bin)) {
5978
+			return '';
5979
+	}
5642 5980
 
5643 5981
 	global $db_type;
5644 5982
 
5645
-	if ($db_type == 'postgresql')
5646
-		return $bin;
5983
+	if ($db_type == 'postgresql') {
5984
+			return $bin;
5985
+	}
5647 5986
 
5648 5987
 	$ip_address = inet_ntop($bin);
5649 5988
 
@@ -5668,26 +6007,32 @@  discard block
 block discarded – undo
5668 6007
  */
5669 6008
 function _safe_serialize($value)
5670 6009
 {
5671
-	if(is_null($value))
5672
-		return 'N;';
6010
+	if(is_null($value)) {
6011
+			return 'N;';
6012
+	}
5673 6013
 
5674
-	if(is_bool($value))
5675
-		return 'b:'. (int) $value .';';
6014
+	if(is_bool($value)) {
6015
+			return 'b:'. (int) $value .';';
6016
+	}
5676 6017
 
5677
-	if(is_int($value))
5678
-		return 'i:'. $value .';';
6018
+	if(is_int($value)) {
6019
+			return 'i:'. $value .';';
6020
+	}
5679 6021
 
5680
-	if(is_float($value))
5681
-		return 'd:'. str_replace(',', '.', $value) .';';
6022
+	if(is_float($value)) {
6023
+			return 'd:'. str_replace(',', '.', $value) .';';
6024
+	}
5682 6025
 
5683
-	if(is_string($value))
5684
-		return 's:'. strlen($value) .':"'. $value .'";';
6026
+	if(is_string($value)) {
6027
+			return 's:'. strlen($value) .':"'. $value .'";';
6028
+	}
5685 6029
 
5686 6030
 	if(is_array($value))
5687 6031
 	{
5688 6032
 		$out = '';
5689
-		foreach($value as $k => $v)
5690
-			$out .= _safe_serialize($k) . _safe_serialize($v);
6033
+		foreach($value as $k => $v) {
6034
+					$out .= _safe_serialize($k) . _safe_serialize($v);
6035
+		}
5691 6036
 
5692 6037
 		return 'a:'. count($value) .':{'. $out .'}';
5693 6038
 	}
@@ -5713,8 +6058,9 @@  discard block
 block discarded – undo
5713 6058
 
5714 6059
 	$out = _safe_serialize($value);
5715 6060
 
5716
-	if (isset($mbIntEnc))
5717
-		mb_internal_encoding($mbIntEnc);
6061
+	if (isset($mbIntEnc)) {
6062
+			mb_internal_encoding($mbIntEnc);
6063
+	}
5718 6064
 
5719 6065
 	return $out;
5720 6066
 }
@@ -5731,8 +6077,9 @@  discard block
 block discarded – undo
5731 6077
 function _safe_unserialize($str)
5732 6078
 {
5733 6079
 	// Input  is not a string.
5734
-	if(empty($str) || !is_string($str))
5735
-		return false;
6080
+	if(empty($str) || !is_string($str)) {
6081
+			return false;
6082
+	}
5736 6083
 
5737 6084
 	$stack = array();
5738 6085
 	$expected = array();
@@ -5748,43 +6095,38 @@  discard block
 block discarded – undo
5748 6095
 	while($state != 1)
5749 6096
 	{
5750 6097
 		$type = isset($str[0]) ? $str[0] : '';
5751
-		if($type == '}')
5752
-			$str = substr($str, 1);
5753
-
5754
-		else if($type == 'N' && $str[1] == ';')
6098
+		if($type == '}') {
6099
+					$str = substr($str, 1);
6100
+		} else if($type == 'N' && $str[1] == ';')
5755 6101
 		{
5756 6102
 			$value = null;
5757 6103
 			$str = substr($str, 2);
5758
-		}
5759
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
6104
+		} else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5760 6105
 		{
5761 6106
 			$value = $matches[1] == '1' ? true : false;
5762 6107
 			$str = substr($str, 4);
5763
-		}
5764
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
6108
+		} else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5765 6109
 		{
5766 6110
 			$value = (int)$matches[1];
5767 6111
 			$str = $matches[2];
5768
-		}
5769
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
6112
+		} else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5770 6113
 		{
5771 6114
 			$value = (float)$matches[1];
5772 6115
 			$str = $matches[3];
5773
-		}
5774
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
6116
+		} else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5775 6117
 		{
5776 6118
 			$value = substr($matches[2], 0, (int)$matches[1]);
5777 6119
 			$str = substr($matches[2], (int)$matches[1] + 2);
5778
-		}
5779
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
6120
+		} else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5780 6121
 		{
5781 6122
 			$expectedLength = (int)$matches[1];
5782 6123
 			$str = $matches[2];
5783 6124
 		}
5784 6125
 
5785 6126
 		// Object or unknown/malformed type.
5786
-		else
5787
-			return false;
6127
+		else {
6128
+					return false;
6129
+		}
5788 6130
 
5789 6131
 		switch($state)
5790 6132
 		{
@@ -5812,8 +6154,9 @@  discard block
 block discarded – undo
5812 6154
 				if($type == '}')
5813 6155
 				{
5814 6156
 					// Array size is less than expected.
5815
-					if(count($list) < end($expected))
5816
-						return false;
6157
+					if(count($list) < end($expected)) {
6158
+											return false;
6159
+					}
5817 6160
 
5818 6161
 					unset($list);
5819 6162
 					$list = &$stack[count($stack)-1];
@@ -5822,8 +6165,9 @@  discard block
 block discarded – undo
5822 6165
 					// Go to terminal state if we're at the end of the root array.
5823 6166
 					array_pop($expected);
5824 6167
 
5825
-					if(count($expected) == 0)
5826
-						$state = 1;
6168
+					if(count($expected) == 0) {
6169
+											$state = 1;
6170
+					}
5827 6171
 
5828 6172
 					break;
5829 6173
 				}
@@ -5831,8 +6175,9 @@  discard block
 block discarded – undo
5831 6175
 				if($type == 'i' || $type == 's')
5832 6176
 				{
5833 6177
 					// Array size exceeds expected length.
5834
-					if(count($list) >= end($expected))
5835
-						return false;
6178
+					if(count($list) >= end($expected)) {
6179
+											return false;
6180
+					}
5836 6181
 
5837 6182
 					$key = $value;
5838 6183
 					$state = 3;
@@ -5866,8 +6211,9 @@  discard block
 block discarded – undo
5866 6211
 	}
5867 6212
 
5868 6213
 	// Trailing data in input.
5869
-	if(!empty($str))
5870
-		return false;
6214
+	if(!empty($str)) {
6215
+			return false;
6216
+	}
5871 6217
 
5872 6218
 	return $data;
5873 6219
 }
@@ -5890,8 +6236,9 @@  discard block
 block discarded – undo
5890 6236
 
5891 6237
 	$out = _safe_unserialize($str);
5892 6238
 
5893
-	if (isset($mbIntEnc))
5894
-		mb_internal_encoding($mbIntEnc);
6239
+	if (isset($mbIntEnc)) {
6240
+			mb_internal_encoding($mbIntEnc);
6241
+	}
5895 6242
 
5896 6243
 	return $out;
5897 6244
 }
@@ -5906,12 +6253,14 @@  discard block
 block discarded – undo
5906 6253
 function smf_chmod($file, $value = 0)
5907 6254
 {
5908 6255
 	// No file? no checks!
5909
-	if (empty($file))
5910
-		return false;
6256
+	if (empty($file)) {
6257
+			return false;
6258
+	}
5911 6259
 
5912 6260
 	// Already writable?
5913
-	if (is_writable($file))
5914
-		return true;
6261
+	if (is_writable($file)) {
6262
+			return true;
6263
+	}
5915 6264
 
5916 6265
 	// Do we have a file or a dir?
5917 6266
 	$isDir = is_dir($file);
@@ -5927,10 +6276,9 @@  discard block
 block discarded – undo
5927 6276
 		{
5928 6277
 			$isWritable = true;
5929 6278
 			break;
6279
+		} else {
6280
+					@chmod($file, $val);
5930 6281
 		}
5931
-
5932
-		else
5933
-			@chmod($file, $val);
5934 6282
 	}
5935 6283
 
5936 6284
 	return $isWritable;
@@ -5949,8 +6297,9 @@  discard block
 block discarded – undo
5949 6297
 	global $txt;
5950 6298
 
5951 6299
 	// Come on...
5952
-	if (empty($json) || !is_string($json))
5953
-		return array();
6300
+	if (empty($json) || !is_string($json)) {
6301
+			return array();
6302
+	}
5954 6303
 
5955 6304
 	$returnArray = @json_decode($json, $returnAsArray);
5956 6305
 
@@ -5988,11 +6337,11 @@  discard block
 block discarded – undo
5988 6337
 		$jsonDebug = $jsonDebug[0];
5989 6338
 		loadLanguage('Errors');
5990 6339
 
5991
-		if (!empty($jsonDebug))
5992
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5993
-
5994
-		else
5995
-			log_error($txt['json_'. $jsonError], 'critical');
6340
+		if (!empty($jsonDebug)) {
6341
+					log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
6342
+		} else {
6343
+					log_error($txt['json_'. $jsonError], 'critical');
6344
+		}
5996 6345
 
5997 6346
 		// Everyone expects an array.
5998 6347
 		return array();
@@ -6026,8 +6375,9 @@  discard block
 block discarded – undo
6026 6375
 	global $db_show_debug, $modSettings;
6027 6376
 
6028 6377
 	// Defensive programming anyone?
6029
-	if (empty($data))
6030
-		return false;
6378
+	if (empty($data)) {
6379
+			return false;
6380
+	}
6031 6381
 
6032 6382
 	// Don't need extra stuff...
6033 6383
 	$db_show_debug = false;
@@ -6035,11 +6385,11 @@  discard block
 block discarded – undo
6035 6385
 	// Kill anything else.
6036 6386
 	ob_end_clean();
6037 6387
 
6038
-	if (!empty($modSettings['CompressedOutput']))
6039
-		@ob_start('ob_gzhandler');
6040
-
6041
-	else
6042
-		ob_start();
6388
+	if (!empty($modSettings['CompressedOutput'])) {
6389
+			@ob_start('ob_gzhandler');
6390
+	} else {
6391
+			ob_start();
6392
+	}
6043 6393
 
6044 6394
 	// Set the header.
6045 6395
 	header($type);
@@ -6071,8 +6421,9 @@  discard block
 block discarded – undo
6071 6421
 	static $done = false;
6072 6422
 
6073 6423
 	// If we don't need to do anything, don't
6074
-	if (!$update && $done)
6075
-		return;
6424
+	if (!$update && $done) {
6425
+			return;
6426
+	}
6076 6427
 
6077 6428
 	// Should we get a new copy of the official list of TLDs?
6078 6429
 	if ($update)
@@ -6084,8 +6435,9 @@  discard block
 block discarded – undo
6084 6435
 		// marauding bandits roaming on the surface. We don't want to waste precious electricity on
6085 6436
 		// pointlessly repeating background tasks, so we'll wait until the next regularly scheduled
6086 6437
 		// update to see if civilization has been restored.
6087
-		if ($tlds === false)
6088
-			$postapocalypticNightmare = true;
6438
+		if ($tlds === false) {
6439
+					$postapocalypticNightmare = true;
6440
+		}
6089 6441
 	}
6090 6442
 	// If we aren't updating and the regex is valid, we're done
6091 6443
 	elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false)
@@ -6100,10 +6452,11 @@  discard block
 block discarded – undo
6100 6452
 		// Clean $tlds and convert it to an array
6101 6453
 		$tlds = array_filter(explode("\n", strtolower($tlds)), function($line) {
6102 6454
 			$line = trim($line);
6103
-			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false)
6104
-				return false;
6105
-			else
6106
-				return true;
6455
+			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) {
6456
+							return false;
6457
+			} else {
6458
+							return true;
6459
+			}
6107 6460
 		});
6108 6461
 
6109 6462
 		// Convert Punycode to Unicode
@@ -6195,8 +6548,7 @@  discard block
 block discarded – undo
6195 6548
 
6196 6549
 		$strlen = 'mb_strlen';
6197 6550
 		$substr = 'mb_substr';
6198
-	}
6199
-	else
6551
+	} else
6200 6552
 	{
6201 6553
 		$strlen = $smcFunc['strlen'];
6202 6554
 		$substr = $smcFunc['substr'];
@@ -6210,20 +6562,21 @@  discard block
 block discarded – undo
6210 6562
 
6211 6563
 		$first = $substr($string, 0, 1);
6212 6564
 
6213
-		if (empty($index[$first]))
6214
-			$index[$first] = array();
6565
+		if (empty($index[$first])) {
6566
+					$index[$first] = array();
6567
+		}
6215 6568
 
6216 6569
 		if ($strlen($string) > 1)
6217 6570
 		{
6218 6571
 			// Sanity check on recursion
6219
-			if ($depth > 99)
6220
-				$index[$first][$substr($string, 1)] = '';
6221
-
6222
-			else
6223
-				$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6572
+			if ($depth > 99) {
6573
+							$index[$first][$substr($string, 1)] = '';
6574
+			} else {
6575
+							$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6576
+			}
6577
+		} else {
6578
+					$index[$first][''] = '';
6224 6579
 		}
6225
-		else
6226
-			$index[$first][''] = '';
6227 6580
 
6228 6581
 		$depth--;
6229 6582
 		return $index;
@@ -6246,9 +6599,9 @@  discard block
 block discarded – undo
6246 6599
 			$key_regex = preg_quote($key, $delim);
6247 6600
 			$new_key = $key;
6248 6601
 
6249
-			if (empty($value))
6250
-				$sub_regex = '';
6251
-			else
6602
+			if (empty($value)) {
6603
+							$sub_regex = '';
6604
+			} else
6252 6605
 			{
6253 6606
 				$sub_regex = $index_to_regex($value, $delim);
6254 6607
 
@@ -6256,22 +6609,22 @@  discard block
 block discarded – undo
6256 6609
 				{
6257 6610
 					$new_key_array = explode('(?'.'>', $sub_regex);
6258 6611
 					$new_key .= $new_key_array[0];
6612
+				} else {
6613
+									$sub_regex = '(?'.'>' . $sub_regex . ')';
6259 6614
 				}
6260
-				else
6261
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
6262 6615
 			}
6263 6616
 
6264
-			if ($depth > 1)
6265
-				$regex[$new_key] = $key_regex . $sub_regex;
6266
-			else
6617
+			if ($depth > 1) {
6618
+							$regex[$new_key] = $key_regex . $sub_regex;
6619
+			} else
6267 6620
 			{
6268 6621
 				if (($length += strlen($key_regex) + 1) < $max_length || empty($regex))
6269 6622
 				{
6270 6623
 					$regex[$new_key] = $key_regex . $sub_regex;
6271 6624
 					unset($index[$key]);
6625
+				} else {
6626
+									break;
6272 6627
 				}
6273
-				else
6274
-					break;
6275 6628
 			}
6276 6629
 		}
6277 6630
 
@@ -6280,10 +6633,11 @@  discard block
 block discarded – undo
6280 6633
 			$l1 = $strlen($k1);
6281 6634
 			$l2 = $strlen($k2);
6282 6635
 
6283
-			if ($l1 == $l2)
6284
-				return strcmp($k1, $k2) > 0 ? 1 : -1;
6285
-			else
6286
-				return $l1 > $l2 ? -1 : 1;
6636
+			if ($l1 == $l2) {
6637
+							return strcmp($k1, $k2) > 0 ? 1 : -1;
6638
+			} else {
6639
+							return $l1 > $l2 ? -1 : 1;
6640
+			}
6287 6641
 		});
6288 6642
 
6289 6643
 		$depth--;
@@ -6294,21 +6648,24 @@  discard block
 block discarded – undo
6294 6648
 	$index = array();
6295 6649
 	$regex = '';
6296 6650
 
6297
-	foreach ($strings as $string)
6298
-		$index = $add_string_to_index($string, $index);
6651
+	foreach ($strings as $string) {
6652
+			$index = $add_string_to_index($string, $index);
6653
+	}
6299 6654
 
6300 6655
 	if ($returnArray === true)
6301 6656
 	{
6302 6657
 		$regex = array();
6303
-		while (!empty($index))
6304
-			$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6658
+		while (!empty($index)) {
6659
+					$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6660
+		}
6661
+	} else {
6662
+			$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6305 6663
 	}
6306
-	else
6307
-		$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6308 6664
 
6309 6665
 	// Restore PHP's internal character encoding to whatever it was originally
6310
-	if (!empty($current_encoding))
6311
-		mb_internal_encoding($current_encoding);
6666
+	if (!empty($current_encoding)) {
6667
+			mb_internal_encoding($current_encoding);
6668
+	}
6312 6669
 
6313 6670
 	return $regex;
6314 6671
 }
@@ -6351,13 +6708,15 @@  discard block
 block discarded – undo
6351 6708
 	// Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't...
6352 6709
 	$url = str_ireplace('https://', 'http://', $url) . '/';
6353 6710
 	$headers = @get_headers($url);
6354
-	if ($headers === false)
6355
-		return false;
6711
+	if ($headers === false) {
6712
+			return false;
6713
+	}
6356 6714
 
6357 6715
 	// Now to see if it came back https...
6358 6716
 	// First check for a redirect status code in first row (301, 302, 307)
6359
-	if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false)
6360
-		return false;
6717
+	if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) {
6718
+			return false;
6719
+	}
6361 6720
 
6362 6721
 	// Search for the location entry to confirm https
6363 6722
 	$result = false;
@@ -6395,8 +6754,7 @@  discard block
 block discarded – undo
6395 6754
 		$is_admin = $user_info['is_admin'];
6396 6755
 		$mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null;
6397 6756
 		$ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null;
6398
-	}
6399
-	else
6757
+	} else
6400 6758
 	{
6401 6759
 		$request = $smcFunc['db_query']('', '
6402 6760
 				SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group
@@ -6410,17 +6768,19 @@  discard block
 block discarded – undo
6410 6768
 
6411 6769
 		$row = $smcFunc['db_fetch_assoc']($request);
6412 6770
 
6413
-		if (empty($row['additional_groups']))
6414
-			$groups = array($row['id_group'], $row['id_post_group']);
6415
-		else
6416
-			$groups = array_merge(
6771
+		if (empty($row['additional_groups'])) {
6772
+					$groups = array($row['id_group'], $row['id_post_group']);
6773
+		} else {
6774
+					$groups = array_merge(
6417 6775
 					array($row['id_group'], $row['id_post_group']),
6418 6776
 					explode(',', $row['additional_groups'])
6419 6777
 			);
6778
+		}
6420 6779
 
6421 6780
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
6422
-		foreach ($groups as $k => $v)
6423
-			$groups[$k] = (int) $v;
6781
+		foreach ($groups as $k => $v) {
6782
+					$groups[$k] = (int) $v;
6783
+		}
6424 6784
 
6425 6785
 		$is_admin = in_array(1, $groups);
6426 6786
 
@@ -6437,8 +6797,9 @@  discard block
 block discarded – undo
6437 6797
 				'current_member' => $userid,
6438 6798
 			)
6439 6799
 		);
6440
-		while ($row = $smcFunc['db_fetch_assoc']($request))
6441
-			$boards_mod[] = $row['id_board'];
6800
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
6801
+					$boards_mod[] = $row['id_board'];
6802
+		}
6442 6803
 		$smcFunc['db_free_result']($request);
6443 6804
 
6444 6805
 		// Can any of the groups they're in moderate any of the boards?
@@ -6450,8 +6811,9 @@  discard block
 block discarded – undo
6450 6811
 				'groups' => $groups,
6451 6812
 			)
6452 6813
 		);
6453
-		while ($row = $smcFunc['db_fetch_assoc']($request))
6454
-			$boards_mod[] = $row['id_board'];
6814
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
6815
+					$boards_mod[] = $row['id_board'];
6816
+		}
6455 6817
 		$smcFunc['db_free_result']($request);
6456 6818
 
6457 6819
 		// Just in case we've got duplicates here...
@@ -6461,21 +6823,25 @@  discard block
 block discarded – undo
6461 6823
 	}
6462 6824
 
6463 6825
 	// Just build this here, it makes it easier to change/use - administrators can see all boards.
6464
-	if ($is_admin)
6465
-		$query_part['query_see_board'] = '1=1';
6826
+	if ($is_admin) {
6827
+			$query_part['query_see_board'] = '1=1';
6828
+	}
6466 6829
 	// Otherwise just the groups in $user_info['groups'].
6467
-	else
6468
-		$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'] : '') . ')';
6830
+	else {
6831
+			$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'] : '') . ')';
6832
+	}
6469 6833
 
6470 6834
 	// Build the list of boards they WANT to see.
6471 6835
 	// This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
6472 6836
 
6473 6837
 	// If they aren't ignoring any boards then they want to see all the boards they can see
6474
-	if (empty($ignoreboards))
6475
-		$query_part['query_wanna_see_board'] = $query_part['query_see_board'];
6838
+	if (empty($ignoreboards)) {
6839
+			$query_part['query_wanna_see_board'] = $query_part['query_see_board'];
6840
+	}
6476 6841
 	// Ok I guess they don't want to see all the boards
6477
-	else
6478
-		$query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))';
6842
+	else {
6843
+			$query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))';
6844
+	}
6479 6845
 
6480 6846
 	return $query_part;
6481 6847
 }
@@ -6489,10 +6855,11 @@  discard block
 block discarded – undo
6489 6855
 {
6490 6856
 	$secure = false;
6491 6857
 
6492
-	if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
6493
-		$secure = true;
6494
-	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')
6495
-		$secure = true;
6858
+	if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
6859
+			$secure = true;
6860
+	} 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') {
6861
+			$secure = true;
6862
+	}
6496 6863
 
6497 6864
 	return $secure;
6498 6865
 }
@@ -6509,11 +6876,12 @@  discard block
 block discarded – undo
6509 6876
 {
6510 6877
 	$url = iri_to_url($iri);
6511 6878
 
6512
-	if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false)
6513
-		return $iri;
6514
-	else
6515
-		return false;
6516
-}
6879
+	if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) {
6880
+			return $iri;
6881
+	} else {
6882
+			return false;
6883
+	}
6884
+	}
6517 6885
 
6518 6886
 /**
6519 6887
  * A wrapper for `filter_var($url, FILTER_SANITIZE_URL)` that can handle URLs
@@ -6556,8 +6924,9 @@  discard block
 block discarded – undo
6556 6924
 
6557 6925
 	$host = parse_url((strpos($iri, '://') === false ? 'http://' : '') . ltrim($iri, ':/'), PHP_URL_HOST);
6558 6926
 
6559
-	if (empty($host))
6560
-		return $iri;
6927
+	if (empty($host)) {
6928
+			return $iri;
6929
+	}
6561 6930
 
6562 6931
 	// Convert the domain using the Punycode algorithm
6563 6932
 	require_once($sourcedir . '/Class-Punycode.php');
@@ -6593,8 +6962,9 @@  discard block
 block discarded – undo
6593 6962
 
6594 6963
 	$host = parse_url((strpos($url, '://') === false ? 'http://' : '') . ltrim($url, ':/'), PHP_URL_HOST);
6595 6964
 
6596
-	if (empty($host))
6597
-		return $url;
6965
+	if (empty($host)) {
6966
+			return $url;
6967
+	}
6598 6968
 
6599 6969
 	// Decode the domain from Punycode
6600 6970
 	require_once($sourcedir . '/Class-Punycode.php');
@@ -6620,8 +6990,9 @@  discard block
 block discarded – undo
6620 6990
 {
6621 6991
 	global $user_info, $modSettings, $smcFunc, $txt;
6622 6992
 
6623
-	if (empty($modSettings['cron_last_checked']))
6624
-		$modSettings['cron_last_checked'] = 0;
6993
+	if (empty($modSettings['cron_last_checked'])) {
6994
+			$modSettings['cron_last_checked'] = 0;
6995
+	}
6625 6996
 
6626 6997
 	if (!empty($modSettings['cron_is_real_cron']) && time() - $modSettings['cron_last_checked'] > 84600)
6627 6998
 	{
@@ -6641,9 +7012,9 @@  discard block
 block discarded – undo
6641 7012
 			loadLanguage('ManageScheduledTasks');
6642 7013
 			log_error($txt['cron_not_working']);
6643 7014
 			updateSettings(array('cron_is_real_cron' => 0));
7015
+		} else {
7016
+					updateSettings(array('cron_last_checked' => time()));
6644 7017
 		}
6645
-		else
6646
-			updateSettings(array('cron_last_checked' => time()));
6647 7018
 	}
6648 7019
 }
6649 7020
 
@@ -6667,10 +7038,11 @@  discard block
 block discarded – undo
6667 7038
 
6668 7039
 	$protocol = preg_match('~^\s*(HTTP/[12]\.\d)\s*$~i', $_SERVER['SERVER_PROTOCOL'], $matches) ? $matches[1] : 'HTTP/1.0';
6669 7040
 
6670
-	if (!isset($statuses[$code]) && empty($status))
6671
-		header($protocol . ' 500 Internal Server Error');
6672
-	else
6673
-		header($protocol . ' ' . $code . ' ' . (!empty($status) ? $status : $statuses[$code]));
6674
-}
7041
+	if (!isset($statuses[$code]) && empty($status)) {
7042
+			header($protocol . ' 500 Internal Server Error');
7043
+	} else {
7044
+			header($protocol . ' ' . $code . ' ' . (!empty($status) ? $status : $statuses[$code]));
7045
+	}
7046
+	}
6675 7047
 
6676 7048
 ?>
6677 7049
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 1 patch
Braces   +403 added lines, -303 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
  * As of SMF 2.1, this is unused. But it is available if any mod wants to use it.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 {
31 32
 	global $modSettings;
32 33
 
33
-	if (!$compat_mode)
34
-		return $text;
34
+	if (!$compat_mode) {
35
+			return $text;
36
+	}
35 37
 
36 38
 	// Turn line breaks back into br's.
37 39
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -48,8 +50,9 @@  discard block
 block discarded – undo
48 50
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
49 51
 			{
50 52
 				// Value of 2 means we're inside the tag.
51
-				if ($i % 4 == 2)
52
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
53
+				if ($i % 4 == 2) {
54
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
55
+				}
53 56
 			}
54 57
 			// Put our humpty dumpty message back together again.
55 58
 			$text = implode('', $parts);
@@ -104,8 +107,9 @@  discard block
 block discarded – undo
104 107
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
105 108
 
106 109
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
107
-	if (isBrowser('webkit'))
108
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
110
+	if (isBrowser('webkit')) {
111
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
112
+	}
109 113
 
110 114
 	// If there's a trailing break get rid of it - Firefox tends to add one.
111 115
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -120,8 +124,9 @@  discard block
 block discarded – undo
120 124
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
121 125
 		{
122 126
 			// Value of 2 means we're inside the tag.
123
-			if ($i % 4 == 2)
124
-				$parts[$i] = strip_tags($parts[$i]);
127
+			if ($i % 4 == 2) {
128
+							$parts[$i] = strip_tags($parts[$i]);
129
+			}
125 130
 		}
126 131
 
127 132
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -147,18 +152,19 @@  discard block
 block discarded – undo
147 152
 			{
148 153
 				$found = array_search($file, $smileysto);
149 154
 				// Note the weirdness here is to stop double spaces between smileys.
150
-				if ($found)
151
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
152
-				else
153
-					$matches[1][$k] = '';
155
+				if ($found) {
156
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
157
+				} else {
158
+									$matches[1][$k] = '';
159
+				}
154 160
 			}
155
-		}
156
-		else
161
+		} else
157 162
 		{
158 163
 			// Load all the smileys.
159 164
 			$names = array();
160
-			foreach ($matches[1] as $file)
161
-				$names[] = $file;
165
+			foreach ($matches[1] as $file) {
166
+							$names[] = $file;
167
+			}
162 168
 			$names = array_unique($names);
163 169
 
164 170
 			if (!empty($names))
@@ -172,13 +178,15 @@  discard block
 block discarded – undo
172 178
 					)
173 179
 				);
174 180
 				$mappings = array();
175
-				while ($row = $smcFunc['db_fetch_assoc']($request))
176
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
181
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
182
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
183
+				}
177 184
 				$smcFunc['db_free_result']($request);
178 185
 
179
-				foreach ($matches[1] as $k => $file)
180
-					if (isset($mappings[$file]))
186
+				foreach ($matches[1] as $k => $file) {
187
+									if (isset($mappings[$file]))
181 188
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
189
+				}
182 190
 			}
183 191
 		}
184 192
 
@@ -190,8 +198,9 @@  discard block
 block discarded – undo
190 198
 	}
191 199
 
192 200
 	// Only try to buy more time if the client didn't quit.
193
-	if (connection_aborted() && $context['server']['is_apache'])
194
-		@apache_reset_timeout();
201
+	if (connection_aborted() && $context['server']['is_apache']) {
202
+			@apache_reset_timeout();
203
+	}
195 204
 
196 205
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
197 206
 	$replacement = '';
@@ -202,9 +211,9 @@  discard block
 block discarded – undo
202 211
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
203 212
 		{
204 213
 			// If it's being closed instantly, we can't deal with it...yet.
205
-			if ($matches[5] === '/')
206
-				continue;
207
-			else
214
+			if ($matches[5] === '/') {
215
+							continue;
216
+			} else
208 217
 			{
209 218
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
210 219
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -220,8 +229,9 @@  discard block
 block discarded – undo
220 229
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
221 230
 
222 231
 					// Something like 'font-weight: bold' is expected here.
223
-					if (strpos($clean_type_value_pair, ':') === false)
224
-						continue;
232
+					if (strpos($clean_type_value_pair, ':') === false) {
233
+											continue;
234
+					}
225 235
 
226 236
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
227 237
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -243,8 +253,7 @@  discard block
 block discarded – undo
243 253
 							{
244 254
 								$curCloseTags .= '[/u]';
245 255
 								$replacement .= '[u]';
246
-							}
247
-							elseif ($style_value == 'line-through')
256
+							} elseif ($style_value == 'line-through')
248 257
 							{
249 258
 								$curCloseTags .= '[/s]';
250 259
 								$replacement .= '[s]';
@@ -256,13 +265,11 @@  discard block
 block discarded – undo
256 265
 							{
257 266
 								$curCloseTags .= '[/left]';
258 267
 								$replacement .= '[left]';
259
-							}
260
-							elseif ($style_value == 'center')
268
+							} elseif ($style_value == 'center')
261 269
 							{
262 270
 								$curCloseTags .= '[/center]';
263 271
 								$replacement .= '[center]';
264
-							}
265
-							elseif ($style_value == 'right')
272
+							} elseif ($style_value == 'right')
266 273
 							{
267 274
 								$curCloseTags .= '[/right]';
268 275
 								$replacement .= '[right]';
@@ -284,8 +291,9 @@  discard block
 block discarded – undo
284 291
 
285 292
 						case 'font-size':
286 293
 							// Sometimes people put decimals where decimals should not be.
287
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
288
-								$style_value = $dec_matches[1] . $dec_matches[2];
294
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
295
+															$style_value = $dec_matches[1] . $dec_matches[2];
296
+							}
289 297
 
290 298
 							$curCloseTags .= '[/size]';
291 299
 							$replacement .= '[size=' . $style_value . ']';
@@ -293,8 +301,9 @@  discard block
 block discarded – undo
293 301
 
294 302
 						case 'font-family':
295 303
 							// Only get the first freaking font if there's a list!
296
-							if (strpos($style_value, ',') !== false)
297
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
304
+							if (strpos($style_value, ',') !== false) {
305
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
306
+							}
298 307
 
299 308
 							$curCloseTags .= '[/font]';
300 309
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -303,13 +312,15 @@  discard block
 block discarded – undo
303 312
 						// This is a hack for images with dimensions embedded.
304 313
 						case 'width':
305 314
 						case 'height':
306
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
307
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
315
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
316
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
317
+							}
308 318
 						break;
309 319
 
310 320
 						case 'list-style-type':
311
-							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)
312
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
321
+							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) {
322
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
323
+							}
313 324
 						break;
314 325
 					}
315 326
 				}
@@ -322,18 +333,17 @@  discard block
 block discarded – undo
322 333
 				}
323 334
 
324 335
 				// If there's something that still needs closing, push it to the stack.
325
-				if (!empty($curCloseTags))
326
-					array_push($stack, array(
336
+				if (!empty($curCloseTags)) {
337
+									array_push($stack, array(
327 338
 							'element' => strtolower($curElement),
328 339
 							'closeTags' => $curCloseTags
329 340
 						)
330 341
 					);
331
-				elseif (!empty($extra_attr))
332
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
342
+				} elseif (!empty($extra_attr)) {
343
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
344
+				}
333 345
 			}
334
-		}
335
-
336
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
346
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
337 347
 		{
338 348
 			// Is this the element that we've been waiting for to be closed?
339 349
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -343,28 +353,32 @@  discard block
 block discarded – undo
343 353
 			}
344 354
 
345 355
 			// Must've been something else.
346
-			else
347
-				$replacement .= $part;
356
+			else {
357
+							$replacement .= $part;
358
+			}
348 359
 		}
349 360
 		// In all other cases, just add the part to the replacement.
350
-		else
351
-			$replacement .= $part;
361
+		else {
362
+					$replacement .= $part;
363
+		}
352 364
 	}
353 365
 
354 366
 	// Now put back the replacement in the text.
355 367
 	$text = $replacement;
356 368
 
357 369
 	// We are not finished yet, request more time.
358
-	if (connection_aborted() && $context['server']['is_apache'])
359
-		@apache_reset_timeout();
370
+	if (connection_aborted() && $context['server']['is_apache']) {
371
+			@apache_reset_timeout();
372
+	}
360 373
 
361 374
 	// Let's pull out any legacy alignments.
362 375
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
363 376
 	{
364 377
 		// Find the position in the text of this tag over again.
365 378
 		$start_pos = strpos($text, $matches[0]);
366
-		if ($start_pos === false)
367
-			break;
379
+		if ($start_pos === false) {
380
+					break;
381
+		}
368 382
 
369 383
 		// End tag?
370 384
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -378,8 +392,7 @@  discard block
 block discarded – undo
378 392
 
379 393
 			// Put the tags back into the body.
380 394
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
381
-		}
382
-		else
395
+		} else
383 396
 		{
384 397
 			// Just get rid of this evil tag.
385 398
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -392,8 +405,9 @@  discard block
 block discarded – undo
392 405
 		// Find the position of this again.
393 406
 		$start_pos = strpos($text, $matches[0]);
394 407
 		$end_pos = false;
395
-		if ($start_pos === false)
396
-			break;
408
+		if ($start_pos === false) {
409
+					break;
410
+		}
397 411
 
398 412
 		// This must have an end tag - and we must find the right one.
399 413
 		$lower_text = strtolower($text);
@@ -426,8 +440,9 @@  discard block
 block discarded – undo
426 440
 				break;
427 441
 			}
428 442
 		}
429
-		if ($end_pos === false)
430
-			break;
443
+		if ($end_pos === false) {
444
+					break;
445
+		}
431 446
 
432 447
 		// Now work out what the attributes are.
433 448
 		$attribs = fetchTagAttributes($matches[1]);
@@ -441,11 +456,11 @@  discard block
 block discarded – undo
441 456
 				$v = (int) trim($v);
442 457
 				$v = empty($v) ? 1 : $v;
443 458
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
459
+			} elseif ($s == 'face') {
460
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
461
+			} elseif ($s == 'color') {
462
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
444 463
 			}
445
-			elseif ($s == 'face')
446
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
447
-			elseif ($s == 'color')
448
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
449 464
 		}
450 465
 
451 466
 		// As before add in our tags.
@@ -453,8 +468,9 @@  discard block
 block discarded – undo
453 468
 		foreach ($tags as $tag)
454 469
 		{
455 470
 			$before .= $tag[0];
456
-			if (isset($tag[1]))
457
-				$after = $tag[1] . $after;
471
+			if (isset($tag[1])) {
472
+							$after = $tag[1] . $after;
473
+			}
458 474
 		}
459 475
 
460 476
 		// Remove the tag so it's never checked again.
@@ -465,8 +481,9 @@  discard block
 block discarded – undo
465 481
 	}
466 482
 
467 483
 	// Almost there, just a little more time.
468
-	if (connection_aborted() && $context['server']['is_apache'])
469
-		@apache_reset_timeout();
484
+	if (connection_aborted() && $context['server']['is_apache']) {
485
+			@apache_reset_timeout();
486
+	}
470 487
 
471 488
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
472 489
 	{
@@ -522,12 +539,13 @@  discard block
 block discarded – undo
522 539
 						{
523 540
 							$inList = true;
524 541
 
525
-							if ($tag === 'ol')
526
-								$listType = 'decimal';
527
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
528
-								$listType = $listTypeMapping[$match[1]];
529
-							else
530
-								$listType = null;
542
+							if ($tag === 'ol') {
543
+															$listType = 'decimal';
544
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
545
+															$listType = $listTypeMapping[$match[1]];
546
+							} else {
547
+															$listType = null;
548
+							}
531 549
 
532 550
 							$listDepth++;
533 551
 
@@ -591,9 +609,7 @@  discard block
 block discarded – undo
591 609
 							$parts[$i + 1] = '';
592 610
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
593 611
 							$parts[$i + 3] = '';
594
-						}
595
-
596
-						else
612
+						} else
597 613
 						{
598 614
 							// We're in a list item.
599 615
 							if ($listDepth > 0)
@@ -630,9 +646,7 @@  discard block
 block discarded – undo
630 646
 							$parts[$i + 1] = '';
631 647
 							$parts[$i + 2] = '';
632 648
 							$parts[$i + 3] = '';
633
-						}
634
-
635
-						else
649
+						} else
636 650
 						{
637 651
 							// Remove the trailing breaks from the list item.
638 652
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -670,8 +684,9 @@  discard block
 block discarded – undo
670 684
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
671 685
 		}
672 686
 
673
-		for ($i = $listDepth; $i > 0; $i--)
674
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
687
+		for ($i = $listDepth; $i > 0; $i--) {
688
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
689
+		}
675 690
 	}
676 691
 
677 692
 	// I love my own image...
@@ -679,8 +694,9 @@  discard block
 block discarded – undo
679 694
 	{
680 695
 		// Find the position of the image.
681 696
 		$start_pos = strpos($text, $matches[0]);
682
-		if ($start_pos === false)
683
-			break;
697
+		if ($start_pos === false) {
698
+					break;
699
+		}
684 700
 		$end_pos = $start_pos + strlen($matches[0]);
685 701
 
686 702
 		$params = '';
@@ -689,12 +705,13 @@  discard block
 block discarded – undo
689 705
 		$attrs = fetchTagAttributes($matches[1]);
690 706
 		foreach ($attrs as $attrib => $value)
691 707
 		{
692
-			if (in_array($attrib, array('width', 'height')))
693
-				$params .= ' ' . $attrib . '=' . (int) $value;
694
-			elseif ($attrib == 'alt' && trim($value) != '')
695
-				$params .= ' alt=' . trim($value);
696
-			elseif ($attrib == 'src')
697
-				$src = trim($value);
708
+			if (in_array($attrib, array('width', 'height'))) {
709
+							$params .= ' ' . $attrib . '=' . (int) $value;
710
+			} elseif ($attrib == 'alt' && trim($value) != '') {
711
+							$params .= ' alt=' . trim($value);
712
+			} elseif ($attrib == 'src') {
713
+							$src = trim($value);
714
+			}
698 715
 		}
699 716
 
700 717
 		$tag = '';
@@ -705,10 +722,11 @@  discard block
 block discarded – undo
705 722
 			{
706 723
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
707 724
 
708
-				if (substr($src, 0, 1) === '/')
709
-					$src = $baseURL . $src;
710
-				else
711
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
725
+				if (substr($src, 0, 1) === '/') {
726
+									$src = $baseURL . $src;
727
+				} else {
728
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
729
+				}
712 730
 			}
713 731
 
714 732
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -886,20 +904,23 @@  discard block
 block discarded – undo
886 904
 		},
887 905
 	);
888 906
 
889
-	foreach ($tags as $tag => $replace)
890
-		$text = preg_replace_callback($tag, $replace, $text);
907
+	foreach ($tags as $tag => $replace) {
908
+			$text = preg_replace_callback($tag, $replace, $text);
909
+	}
891 910
 
892 911
 	// Please give us just a little more time.
893
-	if (connection_aborted() && $context['server']['is_apache'])
894
-		@apache_reset_timeout();
912
+	if (connection_aborted() && $context['server']['is_apache']) {
913
+			@apache_reset_timeout();
914
+	}
895 915
 
896 916
 	// What about URL's - the pain in the ass of the tag world.
897 917
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
898 918
 	{
899 919
 		// Find the position of the URL.
900 920
 		$start_pos = strpos($text, $matches[0]);
901
-		if ($start_pos === false)
902
-			break;
921
+		if ($start_pos === false) {
922
+					break;
923
+		}
903 924
 		$end_pos = $start_pos + strlen($matches[0]);
904 925
 
905 926
 		$tag_type = 'url';
@@ -913,8 +934,9 @@  discard block
 block discarded – undo
913 934
 				$href = trim($value);
914 935
 
915 936
 				// Are we dealing with an FTP link?
916
-				if (preg_match('~^ftps?://~', $href) === 1)
917
-					$tag_type = 'ftp';
937
+				if (preg_match('~^ftps?://~', $href) === 1) {
938
+									$tag_type = 'ftp';
939
+				}
918 940
 
919 941
 				// Or is this a link to an email address?
920 942
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -928,28 +950,31 @@  discard block
 block discarded – undo
928 950
 				{
929 951
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
930 952
 
931
-					if (substr($href, 0, 1) === '/')
932
-						$href = $baseURL . $href;
933
-					else
934
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
953
+					if (substr($href, 0, 1) === '/') {
954
+											$href = $baseURL . $href;
955
+					} else {
956
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
957
+					}
935 958
 				}
936 959
 			}
937 960
 
938 961
 			// External URL?
939 962
 			if ($attrib == 'target' && $tag_type == 'url')
940 963
 			{
941
-				if (trim($value) == '_blank')
942
-					$tag_type == 'iurl';
964
+				if (trim($value) == '_blank') {
965
+									$tag_type == 'iurl';
966
+				}
943 967
 			}
944 968
 		}
945 969
 
946 970
 		$tag = '';
947 971
 		if ($href != '')
948 972
 		{
949
-			if ($matches[2] == $href)
950
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
951
-			else
952
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
973
+			if ($matches[2] == $href) {
974
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
975
+			} else {
976
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
977
+			}
953 978
 		}
954 979
 
955 980
 		// Replace the tag
@@ -985,17 +1010,18 @@  discard block
 block discarded – undo
985 1010
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
986 1011
 		if ($text[$i] == '=')
987 1012
 		{
988
-			if ($tag_state == 0)
989
-				$tag_state = 1;
990
-			elseif ($tag_state == 2)
991
-				$value .= '=';
1013
+			if ($tag_state == 0) {
1014
+							$tag_state = 1;
1015
+			} elseif ($tag_state == 2) {
1016
+							$value .= '=';
1017
+			}
992 1018
 		}
993 1019
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
994 1020
 		elseif ($text[$i] == ' ')
995 1021
 		{
996
-			if ($tag_state == 2)
997
-				$value .= ' ';
998
-			elseif ($tag_state == 1)
1022
+			if ($tag_state == 2) {
1023
+							$value .= ' ';
1024
+			} elseif ($tag_state == 1)
999 1025
 			{
1000 1026
 				$attribs[$key] = $value;
1001 1027
 				$key = $value = '';
@@ -1006,24 +1032,27 @@  discard block
 block discarded – undo
1006 1032
 		elseif ($text[$i] == '"')
1007 1033
 		{
1008 1034
 			// Must be either going into or out of a string.
1009
-			if ($tag_state == 1)
1010
-				$tag_state = 2;
1011
-			else
1012
-				$tag_state = 1;
1035
+			if ($tag_state == 1) {
1036
+							$tag_state = 2;
1037
+			} else {
1038
+							$tag_state = 1;
1039
+			}
1013 1040
 		}
1014 1041
 		// Otherwise it's fine.
1015 1042
 		else
1016 1043
 		{
1017
-			if ($tag_state == 0)
1018
-				$key .= $text[$i];
1019
-			else
1020
-				$value .= $text[$i];
1044
+			if ($tag_state == 0) {
1045
+							$key .= $text[$i];
1046
+			} else {
1047
+							$value .= $text[$i];
1048
+			}
1021 1049
 		}
1022 1050
 	}
1023 1051
 
1024 1052
 	// Anything left?
1025
-	if ($key != '' && $value != '')
1026
-		$attribs[$key] = $value;
1053
+	if ($key != '' && $value != '') {
1054
+			$attribs[$key] = $value;
1055
+	}
1027 1056
 
1028 1057
 	return $attribs;
1029 1058
 }
@@ -1039,8 +1068,9 @@  discard block
 block discarded – undo
1039 1068
 	global $modSettings;
1040 1069
 
1041 1070
 	// Don't care about the texts that are too short.
1042
-	if (strlen($text) < 3)
1043
-		return $text;
1071
+	if (strlen($text) < 3) {
1072
+			return $text;
1073
+	}
1044 1074
 
1045 1075
 	// A list of tags that's disabled by the admin.
1046 1076
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
@@ -1051,10 +1081,12 @@  discard block
 block discarded – undo
1051 1081
 	$self_closing_tags = array();
1052 1082
 	foreach ($all_tags as $tag)
1053 1083
 	{
1054
-		if (!isset($disabled[$tag['tag']]))
1055
-			$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1056
-		if (isset($tag['type']) && $tag['type'] == 'closed')
1057
-			$self_closing_tags[] = $tag['tag'];
1084
+		if (!isset($disabled[$tag['tag']])) {
1085
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1086
+		}
1087
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1088
+					$self_closing_tags[] = $tag['tag'];
1089
+		}
1058 1090
 	}
1059 1091
 
1060 1092
 	// 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!
@@ -1081,16 +1113,19 @@  discard block
 block discarded – undo
1081 1113
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1082 1114
 
1083 1115
 				// We're closing the exact same tag that we opened.
1084
-				if ($isClosingTag && $insideTag === $tagName)
1085
-					$insideTag = null;
1116
+				if ($isClosingTag && $insideTag === $tagName) {
1117
+									$insideTag = null;
1118
+				}
1086 1119
 
1087 1120
 				// We're opening a tag and we're not yet inside one either
1088
-				elseif (!$isClosingTag && $insideTag === null)
1089
-					$insideTag = $tagName;
1121
+				elseif (!$isClosingTag && $insideTag === null) {
1122
+									$insideTag = $tagName;
1123
+				}
1090 1124
 
1091 1125
 				// In all other cases, this tag must be invalid
1092
-				else
1093
-					unset($matches[$i]);
1126
+				else {
1127
+									unset($matches[$i]);
1128
+				}
1094 1129
 			}
1095 1130
 
1096 1131
 			// The next one is gonna be the other one.
@@ -1098,8 +1133,9 @@  discard block
 block discarded – undo
1098 1133
 		}
1099 1134
 
1100 1135
 		// We're still inside a tag and had no chance for closure?
1101
-		if ($insideTag !== null)
1102
-			$matches[] = '[/' . $insideTag . ']';
1136
+		if ($insideTag !== null) {
1137
+					$matches[] = '[/' . $insideTag . ']';
1138
+		}
1103 1139
 
1104 1140
 		// And a complete text string again.
1105 1141
 		$text = implode('', $matches);
@@ -1108,8 +1144,9 @@  discard block
 block discarded – undo
1108 1144
 	// Quickly remove any tags which are back to back.
1109 1145
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1110 1146
 	$lastlen = 0;
1111
-	while (strlen($text) !== $lastlen)
1112
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1147
+	while (strlen($text) !== $lastlen) {
1148
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1149
+	}
1113 1150
 
1114 1151
 	// Need to sort the tags by name length.
1115 1152
 	uksort($valid_tags, function ($a, $b) {
@@ -1148,8 +1185,9 @@  discard block
 block discarded – undo
1148 1185
 			$isCompetingTag = in_array($tag, $competing_tags);
1149 1186
 
1150 1187
 			// Check if this might be one of those cleaned out tags.
1151
-			if ($tag === '')
1152
-				continue;
1188
+			if ($tag === '') {
1189
+							continue;
1190
+			}
1153 1191
 
1154 1192
 			// Special case: inside [code] blocks any code is left untouched.
1155 1193
 			elseif ($tag === 'code')
@@ -1160,8 +1198,9 @@  discard block
 block discarded – undo
1160 1198
 					$inCode = false;
1161 1199
 
1162 1200
 					// Reopen tags that were closed before the code block.
1163
-					if (!empty($inlineElements))
1164
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1201
+					if (!empty($inlineElements)) {
1202
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1203
+					}
1165 1204
 				}
1166 1205
 
1167 1206
 				// We're outside a coding and nobbc block and opening it.
@@ -1190,8 +1229,9 @@  discard block
 block discarded – undo
1190 1229
 					$inNoBbc = false;
1191 1230
 
1192 1231
 					// Some inline elements might've been closed that need reopening.
1193
-					if (!empty($inlineElements))
1194
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1232
+					if (!empty($inlineElements)) {
1233
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1234
+					}
1195 1235
 				}
1196 1236
 
1197 1237
 				// We're outside a nobbc and coding block and opening it.
@@ -1211,8 +1251,9 @@  discard block
 block discarded – undo
1211 1251
 			}
1212 1252
 
1213 1253
 			// So, we're inside one of the special blocks: ignore any tag.
1214
-			elseif ($inCode || $inNoBbc)
1215
-				continue;
1254
+			elseif ($inCode || $inNoBbc) {
1255
+							continue;
1256
+			}
1216 1257
 
1217 1258
 			// We're dealing with an opening tag.
1218 1259
 			if ($isOpeningTag)
@@ -1253,8 +1294,9 @@  discard block
 block discarded – undo
1253 1294
 							if ($parts[$j + 3] === $tag)
1254 1295
 							{
1255 1296
 								// If it's an opening tag, increase the level.
1256
-								if ($parts[$j + 2] === '')
1257
-									$curLevel++;
1297
+								if ($parts[$j + 2] === '') {
1298
+																	$curLevel++;
1299
+								}
1258 1300
 
1259 1301
 								// A closing tag, decrease the level.
1260 1302
 								else
@@ -1277,13 +1319,15 @@  discard block
 block discarded – undo
1277 1319
 					{
1278 1320
 						if ($isCompetingTag)
1279 1321
 						{
1280
-							if (!isset($competingElements[$tag]))
1281
-								$competingElements[$tag] = array();
1322
+							if (!isset($competingElements[$tag])) {
1323
+															$competingElements[$tag] = array();
1324
+							}
1282 1325
 
1283 1326
 							$competingElements[$tag][] = $parts[$i + 4];
1284 1327
 
1285
-							if (count($competingElements[$tag]) > 1)
1286
-								$parts[$i] .= '[/' . $tag . ']';
1328
+							if (count($competingElements[$tag]) > 1) {
1329
+															$parts[$i] .= '[/' . $tag . ']';
1330
+							}
1287 1331
 						}
1288 1332
 
1289 1333
 						$inlineElements[$elementContent] = $tag;
@@ -1303,15 +1347,17 @@  discard block
 block discarded – undo
1303 1347
 						$addClosingTags = array();
1304 1348
 						while ($element = array_pop($blockElements))
1305 1349
 						{
1306
-							if ($element === $tag)
1307
-								break;
1350
+							if ($element === $tag) {
1351
+															break;
1352
+							}
1308 1353
 
1309 1354
 							// Still a block tag was open not equal to this tag.
1310 1355
 							$addClosingTags[] = $element['type'];
1311 1356
 						}
1312 1357
 
1313
-						if (!empty($addClosingTags))
1314
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1358
+						if (!empty($addClosingTags)) {
1359
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1360
+						}
1315 1361
 
1316 1362
 						// Apparently the closing tag was not found on the stack.
1317 1363
 						if (!is_string($element) || $element !== $tag)
@@ -1321,8 +1367,7 @@  discard block
 block discarded – undo
1321 1367
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1322 1368
 							continue;
1323 1369
 						}
1324
-					}
1325
-					else
1370
+					} else
1326 1371
 					{
1327 1372
 						// Get rid of this closing tag!
1328 1373
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1351,53 +1396,62 @@  discard block
 block discarded – undo
1351 1396
 							unset($inlineElements[$tagContentToBeClosed]);
1352 1397
 
1353 1398
 							// Was this the tag we were looking for?
1354
-							if ($tagToBeClosed === $tag)
1355
-								break;
1399
+							if ($tagToBeClosed === $tag) {
1400
+															break;
1401
+							}
1356 1402
 
1357 1403
 							// Nope, close it and look further!
1358
-							else
1359
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1404
+							else {
1405
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1406
+							}
1360 1407
 						}
1361 1408
 
1362 1409
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1363 1410
 						{
1364 1411
 							array_pop($competingElements[$tag]);
1365 1412
 
1366
-							if (count($competingElements[$tag]) > 0)
1367
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1413
+							if (count($competingElements[$tag]) > 0) {
1414
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1415
+							}
1368 1416
 						}
1369 1417
 					}
1370 1418
 
1371 1419
 					// Unexpected closing tag, ex-ter-mi-nate.
1372
-					else
1373
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1420
+					else {
1421
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1422
+					}
1374 1423
 				}
1375 1424
 			}
1376 1425
 		}
1377 1426
 
1378 1427
 		// Close the code tags.
1379
-		if ($inCode)
1380
-			$parts[$i] .= '[/code]';
1428
+		if ($inCode) {
1429
+					$parts[$i] .= '[/code]';
1430
+		}
1381 1431
 
1382 1432
 		// The same for nobbc tags.
1383
-		elseif ($inNoBbc)
1384
-			$parts[$i] .= '[/nobbc]';
1433
+		elseif ($inNoBbc) {
1434
+					$parts[$i] .= '[/nobbc]';
1435
+		}
1385 1436
 
1386 1437
 		// Still inline tags left unclosed? Close them now, better late than never.
1387
-		elseif (!empty($inlineElements))
1388
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1438
+		elseif (!empty($inlineElements)) {
1439
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1440
+		}
1389 1441
 
1390 1442
 		// Now close the block elements.
1391
-		if (!empty($blockElements))
1392
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1443
+		if (!empty($blockElements)) {
1444
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1445
+		}
1393 1446
 
1394 1447
 		$text = implode('', $parts);
1395 1448
 	}
1396 1449
 
1397 1450
 	// Final clean up of back to back tags.
1398 1451
 	$lastlen = 0;
1399
-	while (strlen($text) !== $lastlen)
1400
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1452
+	while (strlen($text) !== $lastlen) {
1453
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1454
+	}
1401 1455
 
1402 1456
 	return $text;
1403 1457
 }
@@ -1414,22 +1468,25 @@  discard block
 block discarded – undo
1414 1468
 	$context['template_layers'] = array();
1415 1469
 	// Lets make sure we aren't going to output anything nasty.
1416 1470
 	@ob_end_clean();
1417
-	if (!empty($modSettings['enableCompressedOutput']))
1418
-		@ob_start('ob_gzhandler');
1419
-	else
1420
-		@ob_start();
1471
+	if (!empty($modSettings['enableCompressedOutput'])) {
1472
+			@ob_start('ob_gzhandler');
1473
+	} else {
1474
+			@ob_start();
1475
+	}
1421 1476
 
1422 1477
 	// If we don't have any locale better avoid broken js
1423
-	if (empty($txt['lang_locale']))
1424
-		die();
1478
+	if (empty($txt['lang_locale'])) {
1479
+			die();
1480
+	}
1425 1481
 
1426 1482
 	$file_data = '(function ($) {
1427 1483
 	\'use strict\';
1428 1484
 
1429 1485
 	$.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {';
1430
-	foreach ($editortxt as $key => $val)
1431
-		$file_data .= '
1486
+	foreach ($editortxt as $key => $val) {
1487
+			$file_data .= '
1432 1488
 		' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ',';
1489
+	}
1433 1490
 
1434 1491
 	$file_data .= '
1435 1492
 		dateFormat: "day.month.year"
@@ -1497,8 +1554,9 @@  discard block
 block discarded – undo
1497 1554
 				)
1498 1555
 			);
1499 1556
 			$icon_data = array();
1500
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1501
-				$icon_data[] = $row;
1557
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1558
+							$icon_data[] = $row;
1559
+			}
1502 1560
 			$smcFunc['db_free_result']($request);
1503 1561
 
1504 1562
 			$icons = array();
@@ -1513,9 +1571,9 @@  discard block
 block discarded – undo
1513 1571
 			}
1514 1572
 
1515 1573
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1574
+		} else {
1575
+					$icons = $temp;
1516 1576
 		}
1517
-		else
1518
-			$icons = $temp;
1519 1577
 	}
1520 1578
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1521 1579
 
@@ -1544,8 +1602,9 @@  discard block
 block discarded – undo
1544 1602
 	{
1545 1603
 		// Some general stuff.
1546 1604
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1547
-		if (!empty($context['drafts_autosave']))
1548
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1605
+		if (!empty($context['drafts_autosave'])) {
1606
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1607
+		}
1549 1608
 
1550 1609
 		// This really has some WYSIWYG stuff.
1551 1610
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1562,8 +1621,9 @@  discard block
 block discarded – undo
1562 1621
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1563 1622
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1564 1623
 		// editor language file
1565
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1566
-			loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1624
+		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') {
1625
+					loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1626
+		}
1567 1627
 
1568 1628
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))];
1569 1629
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
@@ -1572,11 +1632,12 @@  discard block
 block discarded – undo
1572 1632
 			loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck');
1573 1633
 
1574 1634
 			// Some hidden information is needed in order to make the spell checking work.
1575
-			if (!isset($_REQUEST['xml']))
1576
-				$context['insert_after_template'] .= '
1635
+			if (!isset($_REQUEST['xml'])) {
1636
+							$context['insert_after_template'] .= '
1577 1637
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1578 1638
 			<input type="hidden" name="spellstring" value="">
1579 1639
 		</form>';
1640
+			}
1580 1641
 		}
1581 1642
 	}
1582 1643
 
@@ -1768,8 +1829,9 @@  discard block
 block discarded – undo
1768 1829
 
1769 1830
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1770 1831
 		$disabled_tags = array();
1771
-		if (!empty($modSettings['disabledBBC']))
1772
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1832
+		if (!empty($modSettings['disabledBBC'])) {
1833
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1834
+		}
1773 1835
 
1774 1836
 		foreach ($disabled_tags as $tag)
1775 1837
 		{
@@ -1781,9 +1843,10 @@  discard block
 block discarded – undo
1781 1843
 				$context['disabled_tags']['orderedlist'] = true;
1782 1844
 			}
1783 1845
 
1784
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1785
-				if ($tag === $thisTag)
1846
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1847
+							if ($tag === $thisTag)
1786 1848
 					$context['disabled_tags'][$tagNameBBC] = true;
1849
+			}
1787 1850
 
1788 1851
 			$context['disabled_tags'][$tag] = true;
1789 1852
 		}
@@ -1794,8 +1857,9 @@  discard block
 block discarded – undo
1794 1857
 
1795 1858
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1796 1859
 		{
1797
-			if (!isset($context['bbc_toolbar'][$row]))
1798
-				$context['bbc_toolbar'][$row] = array();
1860
+			if (!isset($context['bbc_toolbar'][$row])) {
1861
+							$context['bbc_toolbar'][$row] = array();
1862
+			}
1799 1863
 
1800 1864
 			$tagsRow = array();
1801 1865
 
@@ -1831,20 +1895,21 @@  discard block
 block discarded – undo
1831 1895
 
1832 1896
 					$context['bbcodes_handlers'] .= '
1833 1897
 						});';
1834
-				}
1835
-				else
1898
+				} else
1836 1899
 				{
1837 1900
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1838 1901
 					$tagsRow = array();
1839 1902
 				}
1840 1903
 			}
1841 1904
 
1842
-			if (!empty($tagsRow))
1843
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1905
+			if (!empty($tagsRow)) {
1906
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1907
+			}
1844 1908
 		}
1845 1909
 
1846
-		if (!empty($bbcodes_styles))
1847
-			addInlineCss($bbcodes_styles);
1910
+		if (!empty($bbcodes_styles)) {
1911
+					addInlineCss($bbcodes_styles);
1912
+		}
1848 1913
 	}
1849 1914
 
1850 1915
 	// Initialize smiley array... if not loaded before.
@@ -1856,8 +1921,8 @@  discard block
 block discarded – undo
1856 1921
 		);
1857 1922
 
1858 1923
 		// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
1859
-		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
1860
-			$context['smileys']['postform'][] = array(
1924
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1925
+					$context['smileys']['postform'][] = array(
1861 1926
 				'smileys' => array(
1862 1927
 					array(
1863 1928
 						'code' => ':)',
@@ -1943,7 +2008,7 @@  discard block
 block discarded – undo
1943 2008
 				),
1944 2009
 				'isLast' => true,
1945 2010
 			);
1946
-		elseif ($user_info['smiley_set'] != 'none')
2011
+		} elseif ($user_info['smiley_set'] != 'none')
1947 2012
 		{
1948 2013
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1949 2014
 			{
@@ -1966,17 +2031,19 @@  discard block
 block discarded – undo
1966 2031
 
1967 2032
 				foreach ($context['smileys'] as $section => $smileyRows)
1968 2033
 				{
1969
-					foreach ($smileyRows as $rowIndex => $smileys)
1970
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2034
+					foreach ($smileyRows as $rowIndex => $smileys) {
2035
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2036
+					}
1971 2037
 
1972
-					if (!empty($smileyRows))
1973
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2038
+					if (!empty($smileyRows)) {
2039
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2040
+					}
1974 2041
 				}
1975 2042
 
1976 2043
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2044
+			} else {
2045
+							$context['smileys'] = $temp;
1977 2046
 			}
1978
-			else
1979
-				$context['smileys'] = $temp;
1980 2047
 		}
1981 2048
 	}
1982 2049
 
@@ -1992,12 +2059,15 @@  discard block
 block discarded – undo
1992 2059
 		'plugins' => '',
1993 2060
 		'bbcodeTrim' => true,
1994 2061
 	);
1995
-	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale']))
1996
-		$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
1997
-	if (!empty($context['right_to_left']))
1998
-		$sce_options['rtl'] = true;
1999
-	if ($editorOptions['id'] != 'quickReply')
2000
-		$sce_options['autofocus'] = true;
2062
+	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) {
2063
+			$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2064
+	}
2065
+	if (!empty($context['right_to_left'])) {
2066
+			$sce_options['rtl'] = true;
2067
+	}
2068
+	if ($editorOptions['id'] != 'quickReply') {
2069
+			$sce_options['autofocus'] = true;
2070
+	}
2001 2071
 
2002 2072
 	$sce_options['emoticons'] = array();
2003 2073
 	$sce_options['emoticonsDescriptions'] = array();
@@ -2014,10 +2084,11 @@  discard block
 block discarded – undo
2014 2084
 			$countLocations--;
2015 2085
 
2016 2086
 			unset($smiley_location);
2017
-			if ($location == 'postform')
2018
-				$smiley_location = &$sce_options['emoticons']['dropdown'];
2019
-			elseif ($location == 'popup')
2020
-				$smiley_location = &$sce_options['emoticons']['popup'];
2087
+			if ($location == 'postform') {
2088
+							$smiley_location = &$sce_options['emoticons']['dropdown'];
2089
+			} elseif ($location == 'popup') {
2090
+							$smiley_location = &$sce_options['emoticons']['popup'];
2091
+			}
2021 2092
 
2022 2093
 			$numRows = count($smileyRows);
2023 2094
 
@@ -2031,8 +2102,9 @@  discard block
 block discarded – undo
2031 2102
 					$sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description'];
2032 2103
 				}
2033 2104
 
2034
-				if (empty($smileyRow['isLast']) && $numRows != 1)
2035
-					$smiley_location['-' . $emptyPlaceholder++] = '';
2105
+				if (empty($smileyRow['isLast']) && $numRows != 1) {
2106
+									$smiley_location['-' . $emptyPlaceholder++] = '';
2107
+				}
2036 2108
 			}
2037 2109
 		}
2038 2110
 	}
@@ -2047,8 +2119,9 @@  discard block
 block discarded – undo
2047 2119
 
2048 2120
 			$count_tags--;
2049 2121
 
2050
-			if (!empty($count_tags))
2051
-				$sce_options['toolbar'] .= '||';
2122
+			if (!empty($count_tags)) {
2123
+							$sce_options['toolbar'] .= '||';
2124
+			}
2052 2125
 		}
2053 2126
 	}
2054 2127
 
@@ -2076,8 +2149,9 @@  discard block
 block discarded – undo
2076 2149
 		loadTemplate('GenericControls');
2077 2150
 
2078 2151
 		// Some javascript ma'am?
2079
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2080
-			loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2152
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2153
+					loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2154
+		}
2081 2155
 
2082 2156
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2083 2157
 
@@ -2090,8 +2164,8 @@  discard block
 block discarded – undo
2090 2164
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2091 2165
 
2092 2166
 	// Log this into our collection.
2093
-	if ($isNew)
2094
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2167
+	if ($isNew) {
2168
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2095 2169
 			'id' => $verificationOptions['id'],
2096 2170
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2097 2171
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2102,13 +2176,15 @@  discard block
 block discarded – undo
2102 2176
 			'questions' => array(),
2103 2177
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2104 2178
 		);
2179
+	}
2105 2180
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2106 2181
 
2107 2182
 	// Is there actually going to be anything?
2108
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2109
-		return false;
2110
-	elseif (!$isNew && !$do_test)
2111
-		return true;
2183
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2184
+			return false;
2185
+	} elseif (!$isNew && !$do_test) {
2186
+			return true;
2187
+	}
2112 2188
 
2113 2189
 	// Sanitize reCAPTCHA fields?
2114 2190
 	if ($thisVerification['can_recaptcha'])
@@ -2121,11 +2197,12 @@  discard block
 block discarded – undo
2121 2197
 	}
2122 2198
 
2123 2199
 	// Add javascript for the object.
2124
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2125
-		$context['insert_after_template'] .= '
2200
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2201
+			$context['insert_after_template'] .= '
2126 2202
 			<script>
2127 2203
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2128 2204
 			</script>';
2205
+	}
2129 2206
 
2130 2207
 	// If we want questions do we have a cache of all the IDs?
2131 2208
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2148,8 +2225,9 @@  discard block
 block discarded – undo
2148 2225
 				unset ($row['id_question']);
2149 2226
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2150 2227
 				$row['answers'] = $smcFunc['json_decode']($row['answers'], true);
2151
-				foreach ($row['answers'] as $k => $v)
2152
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2228
+				foreach ($row['answers'] as $k => $v) {
2229
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2230
+				}
2153 2231
 
2154 2232
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2155 2233
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2160,35 +2238,42 @@  discard block
 block discarded – undo
2160 2238
 		}
2161 2239
 	}
2162 2240
 
2163
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2164
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2241
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2242
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2243
+	}
2165 2244
 
2166 2245
 	// Do we need to refresh the verification?
2167
-	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']))
2168
-		$force_refresh = true;
2169
-	else
2170
-		$force_refresh = false;
2246
+	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'])) {
2247
+			$force_refresh = true;
2248
+	} else {
2249
+			$force_refresh = false;
2250
+	}
2171 2251
 
2172 2252
 	// This can also force a fresh, although unlikely.
2173
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2174
-		$force_refresh = true;
2253
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2254
+			$force_refresh = true;
2255
+	}
2175 2256
 
2176 2257
 	$verification_errors = array();
2177 2258
 	// Start with any testing.
2178 2259
 	if ($do_test)
2179 2260
 	{
2180 2261
 		// This cannot happen!
2181
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2182
-			fatal_lang_error('no_access', false);
2262
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2263
+					fatal_lang_error('no_access', false);
2264
+		}
2183 2265
 		// ... nor this!
2184
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2185
-			fatal_lang_error('no_access', false);
2266
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2267
+					fatal_lang_error('no_access', false);
2268
+		}
2186 2269
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2187
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2188
-			fatal_lang_error('no_access', false);
2270
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2271
+					fatal_lang_error('no_access', false);
2272
+		}
2189 2273
 		// While we're here, did the user do something bad?
2190
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2191
-			$verification_errors[] = 'wrong_verification_answer';
2274
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2275
+					$verification_errors[] = 'wrong_verification_answer';
2276
+		}
2192 2277
 
2193 2278
 		if ($thisVerification['can_recaptcha'])
2194 2279
 		{
@@ -2199,22 +2284,25 @@  discard block
 block discarded – undo
2199 2284
 			{
2200 2285
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']);
2201 2286
 
2202
-				if (!$resp->isSuccess())
2203
-					$verification_errors[] = 'wrong_verification_code';
2287
+				if (!$resp->isSuccess()) {
2288
+									$verification_errors[] = 'wrong_verification_code';
2289
+				}
2290
+			} else {
2291
+							$verification_errors[] = 'wrong_verification_code';
2204 2292
 			}
2205
-			else
2206
-				$verification_errors[] = 'wrong_verification_code';
2207 2293
 		}
2208
-		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']))
2209
-			$verification_errors[] = 'wrong_verification_code';
2294
+		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'])) {
2295
+					$verification_errors[] = 'wrong_verification_code';
2296
+		}
2210 2297
 		if ($thisVerification['number_questions'])
2211 2298
 		{
2212 2299
 			$incorrectQuestions = array();
2213 2300
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2214 2301
 			{
2215 2302
 				// We don't have this question any more, thus no answers.
2216
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2217
-					continue;
2303
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2304
+									continue;
2305
+				}
2218 2306
 				// This is quite complex. We have our question but it might have multiple answers.
2219 2307
 				// First, did they actually answer this question?
2220 2308
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2226,24 +2314,28 @@  discard block
 block discarded – undo
2226 2314
 				else
2227 2315
 				{
2228 2316
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2229
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2230
-						$incorrectQuestions[] = $q;
2317
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2318
+											$incorrectQuestions[] = $q;
2319
+					}
2231 2320
 				}
2232 2321
 			}
2233 2322
 
2234
-			if (!empty($incorrectQuestions))
2235
-				$verification_errors[] = 'wrong_verification_answer';
2323
+			if (!empty($incorrectQuestions)) {
2324
+							$verification_errors[] = 'wrong_verification_answer';
2325
+			}
2236 2326
 		}
2237 2327
 	}
2238 2328
 
2239 2329
 	// Any errors means we refresh potentially.
2240 2330
 	if (!empty($verification_errors))
2241 2331
 	{
2242
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2243
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2332
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2333
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2334
+		}
2244 2335
 		// Too many errors?
2245
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2246
-			$force_refresh = true;
2336
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2337
+					$force_refresh = true;
2338
+		}
2247 2339
 
2248 2340
 		// Keep a track of these.
2249 2341
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2276,8 +2368,9 @@  discard block
 block discarded – undo
2276 2368
 			// Are we overriding the range?
2277 2369
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2278 2370
 
2279
-			for ($i = 0; $i < 6; $i++)
2280
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2371
+			for ($i = 0; $i < 6; $i++) {
2372
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2373
+			}
2281 2374
 		}
2282 2375
 
2283 2376
 		// Getting some new questions?
@@ -2285,8 +2378,9 @@  discard block
 block discarded – undo
2285 2378
 		{
2286 2379
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2287 2380
 			$possible_langs = array();
2288
-			if (isset($_SESSION['language']))
2289
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2381
+			if (isset($_SESSION['language'])) {
2382
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2383
+			}
2290 2384
 			if (!empty($user_info['language']));
2291 2385
 			$possible_langs[] = $user_info['language'];
2292 2386
 			$possible_langs[] = $language;
@@ -2305,8 +2399,7 @@  discard block
 block discarded – undo
2305 2399
 				}
2306 2400
 			}
2307 2401
 		}
2308
-	}
2309
-	else
2402
+	} else
2310 2403
 	{
2311 2404
 		// Same questions as before.
2312 2405
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2316,8 +2409,9 @@  discard block
 block discarded – undo
2316 2409
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2317 2410
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2318 2411
 	{
2319
-		if (!isset($context['html_headers']))
2320
-			$context['html_headers'] = '';
2412
+		if (!isset($context['html_headers'])) {
2413
+					$context['html_headers'] = '';
2414
+		}
2321 2415
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2322 2416
 	}
2323 2417
 
@@ -2343,11 +2437,13 @@  discard block
 block discarded – undo
2343 2437
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2344 2438
 
2345 2439
 	// Return errors if we have them.
2346
-	if (!empty($verification_errors))
2347
-		return $verification_errors;
2440
+	if (!empty($verification_errors)) {
2441
+			return $verification_errors;
2442
+	}
2348 2443
 	// If we had a test that one, make a note.
2349
-	elseif ($do_test)
2350
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2444
+	elseif ($do_test) {
2445
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2446
+	}
2351 2447
 
2352 2448
 	// Say that everything went well chaps.
2353 2449
 	return true;
@@ -2372,8 +2468,9 @@  discard block
 block discarded – undo
2372 2468
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2373 2469
 
2374 2470
 	// If we're just checking the callback function is registered return true or false.
2375
-	if ($checkRegistered != null)
2376
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2471
+	if ($checkRegistered != null) {
2472
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2473
+	}
2377 2474
 
2378 2475
 	checkSession('get');
2379 2476
 	loadTemplate('Xml');
@@ -2524,24 +2621,27 @@  discard block
 block discarded – undo
2524 2621
 		foreach ($possible_versions as $ver)
2525 2622
 		{
2526 2623
 			$ver = trim($ver);
2527
-			if (strpos($ver, 'SMF') === 0)
2528
-				$versions[] = $ver;
2624
+			if (strpos($ver, 'SMF') === 0) {
2625
+							$versions[] = $ver;
2626
+			}
2529 2627
 		}
2530 2628
 	}
2531 2629
 	$smcFunc['db_free_result']($request);
2532 2630
 
2533 2631
 	// Just in case we don't have ANYthing.
2534
-	if (empty($versions))
2535
-		$versions = array('SMF 2.0');
2632
+	if (empty($versions)) {
2633
+			$versions = array('SMF 2.0');
2634
+	}
2536 2635
 
2537
-	foreach ($versions as $id => $version)
2538
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2636
+	foreach ($versions as $id => $version) {
2637
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2539 2638
 			$xml_data['items']['children'][] = array(
2540 2639
 				'attributes' => array(
2541 2640
 					'id' => $id,
2542 2641
 				),
2543 2642
 				'value' => $version,
2544 2643
 			);
2644
+	}
2545 2645
 
2546 2646
 	return $xml_data;
2547 2647
 }
Please login to merge, or discard this patch.
Sources/Recent.php 1 patch
Braces   +215 added lines, -176 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
  * Get the latest post made on the system
@@ -44,8 +45,9 @@  discard block
 block discarded – undo
44 45
 			'is_approved' => 1,
45 46
 		)
46 47
 	);
47
-	if ($smcFunc['db_num_rows']($request) == 0)
48
-		return array();
48
+	if ($smcFunc['db_num_rows']($request) == 0) {
49
+			return array();
50
+	}
49 51
 	$row = $smcFunc['db_fetch_assoc']($request);
50 52
 	$smcFunc['db_free_result']($request);
51 53
 
@@ -54,8 +56,9 @@  discard block
 block discarded – undo
54 56
 	censorText($row['body']);
55 57
 
56 58
 	$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => '&#10;')));
57
-	if ($smcFunc['strlen']($row['body']) > 128)
58
-		$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
59
+	if ($smcFunc['strlen']($row['body']) > 128) {
60
+			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
61
+	}
59 62
 
60 63
 	// Send the data.
61 64
 	return array(
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
 
84 87
 	$context['is_redirect'] = false;
85 88
 
86
-	if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95)
87
-		$_REQUEST['start'] = 95;
89
+	if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) {
90
+			$_REQUEST['start'] = 95;
91
+	}
88 92
 
89 93
 	$_REQUEST['start'] = (int) $_REQUEST['start'];
90 94
 
@@ -92,8 +96,9 @@  discard block
 block discarded – undo
92 96
 	if (!empty($_REQUEST['c']) && empty($board))
93 97
 	{
94 98
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
95
-		foreach ($_REQUEST['c'] as $i => $c)
96
-			$_REQUEST['c'][$i] = (int) $c;
99
+		foreach ($_REQUEST['c'] as $i => $c) {
100
+					$_REQUEST['c'][$i] = (int) $c;
101
+		}
97 102
 
98 103
 		if (count($_REQUEST['c']) == 1)
99 104
 		{
@@ -109,8 +114,9 @@  discard block
 block discarded – undo
109 114
 			list ($name) = $smcFunc['db_fetch_row']($request);
110 115
 			$smcFunc['db_free_result']($request);
111 116
 
112
-			if (empty($name))
113
-				fatal_lang_error('no_access', false);
117
+			if (empty($name)) {
118
+							fatal_lang_error('no_access', false);
119
+			}
114 120
 
115 121
 			$context['linktree'][] = array(
116 122
 				'url' => $scripturl . '#c' . (int) $_REQUEST['c'],
@@ -142,8 +148,9 @@  discard block
 block discarded – undo
142 148
 		}
143 149
 		$smcFunc['db_free_result']($request);
144 150
 
145
-		if (empty($boards))
146
-			fatal_lang_error('error_no_boards_selected');
151
+		if (empty($boards)) {
152
+					fatal_lang_error('error_no_boards_selected');
153
+		}
147 154
 
148 155
 		$query_this_board = 'b.id_board IN ({array_int:boards})';
149 156
 		$query_parameters['boards'] = $boards;
@@ -157,12 +164,12 @@  discard block
 block discarded – undo
157 164
 		}
158 165
 
159 166
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false);
160
-	}
161
-	elseif (!empty($_REQUEST['boards']))
167
+	} elseif (!empty($_REQUEST['boards']))
162 168
 	{
163 169
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
164
-		foreach ($_REQUEST['boards'] as $i => $b)
165
-			$_REQUEST['boards'][$i] = (int) $b;
170
+		foreach ($_REQUEST['boards'] as $i => $b) {
171
+					$_REQUEST['boards'][$i] = (int) $b;
172
+		}
166 173
 
167 174
 		$request = $smcFunc['db_query']('', '
168 175
 			SELECT b.id_board, b.num_posts
@@ -186,8 +193,9 @@  discard block
 block discarded – undo
186 193
 		}
187 194
 		$smcFunc['db_free_result']($request);
188 195
 
189
-		if (empty($boards))
190
-			fatal_lang_error('error_no_boards_selected');
196
+		if (empty($boards)) {
197
+					fatal_lang_error('error_no_boards_selected');
198
+		}
191 199
 
192 200
 		$query_this_board = 'b.id_board IN ({array_int:boards})';
193 201
 		$query_parameters['boards'] = $boards;
@@ -201,8 +209,7 @@  discard block
 block discarded – undo
201 209
 		}
202 210
 
203 211
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false);
204
-	}
205
-	elseif (!empty($board))
212
+	} elseif (!empty($board))
206 213
 	{
207 214
 		$request = $smcFunc['db_query']('', '
208 215
 			SELECT num_posts, redirect
@@ -235,8 +242,7 @@  discard block
 block discarded – undo
235 242
 		}
236 243
 
237 244
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true);
238
-	}
239
-	else
245
+	} else
240 246
 	{
241 247
 		$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
242 248
 					AND b.id_board != {int:recycle_board}' : ''). '
@@ -271,8 +277,9 @@  discard block
 block discarded – undo
271 277
 	);
272 278
 
273 279
 	// If you selected a redirection board, don't try getting posts for it...
274
-	if ($context['is_redirect'])
275
-		$messages = 0;
280
+	if ($context['is_redirect']) {
281
+			$messages = 0;
282
+	}
276 283
 
277 284
 	$key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start'];
278 285
 	if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null))
@@ -303,16 +310,18 @@  discard block
 block discarded – undo
303 310
 				$query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board);
304 311
 				$cache_results = true;
305 312
 				unset($query_parameters['max_id_msg']);
313
+			} else {
314
+							$done = true;
306 315
 			}
307
-			else
308
-				$done = true;
309 316
 		}
310 317
 		$messages = array();
311
-		while ($row = $smcFunc['db_fetch_assoc']($request))
312
-			$messages[] = $row['id_msg'];
318
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
319
+					$messages[] = $row['id_msg'];
320
+		}
313 321
 		$smcFunc['db_free_result']($request);
314
-		if (!empty($cache_results))
315
-			cache_put_data($key, $messages, 120);
322
+		if (!empty($cache_results)) {
323
+					cache_put_data($key, $messages, 120);
324
+		}
316 325
 	}
317 326
 
318 327
 	// Nothing here... Or at least, nothing you can see...
@@ -399,8 +408,9 @@  discard block
 block discarded – undo
399 408
 			'css_class' => 'windowbg',
400 409
 		);
401 410
 
402
-		if ($user_info['id'] == $row['id_first_member'])
403
-			$board_ids['own'][$row['id_board']][] = $row['id_msg'];
411
+		if ($user_info['id'] == $row['id_first_member']) {
412
+					$board_ids['own'][$row['id_board']][] = $row['id_msg'];
413
+		}
404 414
 		$board_ids['any'][$row['id_board']][] = $row['id_msg'];
405 415
 	}
406 416
 	$smcFunc['db_free_result']($request);
@@ -426,20 +436,23 @@  discard block
 block discarded – undo
426 436
 			$boards = boardsAllowedTo($permission);
427 437
 
428 438
 			// If 0 is the only thing in the array, they can do it everywhere!
429
-			if (!empty($boards) && $boards[0] == 0)
430
-				$boards = array_keys($board_ids[$type]);
439
+			if (!empty($boards) && $boards[0] == 0) {
440
+							$boards = array_keys($board_ids[$type]);
441
+			}
431 442
 
432 443
 			// Go through the boards, and look for posts they can do this on.
433 444
 			foreach ($boards as $board_id)
434 445
 			{
435 446
 				// Hmm, they have permission, but there are no topics from that board on this page.
436
-				if (!isset($board_ids[$type][$board_id]))
437
-					continue;
447
+				if (!isset($board_ids[$type][$board_id])) {
448
+									continue;
449
+				}
438 450
 
439 451
 				// Okay, looks like they can do it for these posts.
440
-				foreach ($board_ids[$type][$board_id] as $counter)
441
-					if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id'])
452
+				foreach ($board_ids[$type][$board_id] as $counter) {
453
+									if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id'])
442 454
 						$context['posts'][$counter][$allowed] = true;
455
+				}
443 456
 			}
444 457
 		}
445 458
 	}
@@ -482,17 +495,19 @@  discard block
 block discarded – undo
482 495
 	$context['showing_all_topics'] = isset($_GET['all']);
483 496
 	$context['start'] = (int) $_REQUEST['start'];
484 497
 	$context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
485
-	if ($_REQUEST['action'] == 'unread')
486
-		$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
487
-	else
488
-		$context['page_title'] = $txt['unread_replies'];
498
+	if ($_REQUEST['action'] == 'unread') {
499
+			$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
500
+	} else {
501
+			$context['page_title'] = $txt['unread_replies'];
502
+	}
489 503
 
490
-	if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread'])
491
-		fatal_lang_error('loadavg_allunread_disabled', false);
492
-	elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies'])
493
-		fatal_lang_error('loadavg_unreadreplies_disabled', false);
494
-	elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread'])
495
-		fatal_lang_error('loadavg_unread_disabled', false);
504
+	if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) {
505
+			fatal_lang_error('loadavg_allunread_disabled', false);
506
+	} elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) {
507
+			fatal_lang_error('loadavg_unreadreplies_disabled', false);
508
+	} elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) {
509
+			fatal_lang_error('loadavg_unread_disabled', false);
510
+	}
496 511
 
497 512
 	// Parameters for the main query.
498 513
 	$query_parameters = array();
@@ -505,12 +520,14 @@  discard block
 block discarded – undo
505 520
 		if (!empty($_REQUEST['boards']))
506 521
 		{
507 522
 			$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
508
-			foreach ($_REQUEST['boards'] as $b)
509
-				$boards[] = (int) $b;
523
+			foreach ($_REQUEST['boards'] as $b) {
524
+							$boards[] = (int) $b;
525
+			}
510 526
 		}
511 527
 
512
-		if (!empty($board))
513
-			$boards[] = (int) $board;
528
+		if (!empty($board)) {
529
+					$boards[] = (int) $board;
530
+		}
514 531
 
515 532
 		// The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them
516 533
 		$request = $smcFunc['db_query']('', '
@@ -527,30 +544,31 @@  discard block
 block discarded – undo
527 544
 			)
528 545
 		);
529 546
 
530
-		while ($row = $smcFunc['db_fetch_assoc']($request))
531
-			if (in_array($row['id_parent'], $boards))
547
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
548
+					if (in_array($row['id_parent'], $boards))
532 549
 				$boards[] = $row['id_board'];
550
+		}
533 551
 
534 552
 		$smcFunc['db_free_result']($request);
535 553
 
536
-		if (empty($boards))
537
-			fatal_lang_error('error_no_boards_selected');
554
+		if (empty($boards)) {
555
+					fatal_lang_error('error_no_boards_selected');
556
+		}
538 557
 
539 558
 		$query_this_board = 'id_board IN ({array_int:boards})';
540 559
 		$query_parameters['boards'] = $boards;
541 560
 		$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d';
542
-	}
543
-	elseif (!empty($board))
561
+	} elseif (!empty($board))
544 562
 	{
545 563
 		$query_this_board = 'id_board = {int:board}';
546 564
 		$query_parameters['board'] = $board;
547 565
 		$context['querystring_board_limits'] = ';board=' . $board . '.%1$d';
548
-	}
549
-	elseif (!empty($_REQUEST['boards']))
566
+	} elseif (!empty($_REQUEST['boards']))
550 567
 	{
551 568
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
552
-		foreach ($_REQUEST['boards'] as $i => $b)
553
-			$_REQUEST['boards'][$i] = (int) $b;
569
+		foreach ($_REQUEST['boards'] as $i => $b) {
570
+					$_REQUEST['boards'][$i] = (int) $b;
571
+		}
554 572
 
555 573
 		$request = $smcFunc['db_query']('', '
556 574
 			SELECT b.id_board
@@ -562,22 +580,24 @@  discard block
 block discarded – undo
562 580
 			)
563 581
 		);
564 582
 		$boards = array();
565
-		while ($row = $smcFunc['db_fetch_assoc']($request))
566
-			$boards[] = $row['id_board'];
583
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
584
+					$boards[] = $row['id_board'];
585
+		}
567 586
 		$smcFunc['db_free_result']($request);
568 587
 
569
-		if (empty($boards))
570
-			fatal_lang_error('error_no_boards_selected');
588
+		if (empty($boards)) {
589
+					fatal_lang_error('error_no_boards_selected');
590
+		}
571 591
 
572 592
 		$query_this_board = 'id_board IN ({array_int:boards})';
573 593
 		$query_parameters['boards'] = $boards;
574 594
 		$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d';
575
-	}
576
-	elseif (!empty($_REQUEST['c']))
595
+	} elseif (!empty($_REQUEST['c']))
577 596
 	{
578 597
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
579
-		foreach ($_REQUEST['c'] as $i => $c)
580
-			$_REQUEST['c'][$i] = (int) $c;
598
+		foreach ($_REQUEST['c'] as $i => $c) {
599
+					$_REQUEST['c'][$i] = (int) $c;
600
+		}
581 601
 
582 602
 		$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
583 603
 		$request = $smcFunc['db_query']('', '
@@ -590,18 +610,19 @@  discard block
 block discarded – undo
590 610
 			)
591 611
 		);
592 612
 		$boards = array();
593
-		while ($row = $smcFunc['db_fetch_assoc']($request))
594
-			$boards[] = $row['id_board'];
613
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
614
+					$boards[] = $row['id_board'];
615
+		}
595 616
 		$smcFunc['db_free_result']($request);
596 617
 
597
-		if (empty($boards))
598
-			fatal_lang_error('error_no_boards_selected');
618
+		if (empty($boards)) {
619
+					fatal_lang_error('error_no_boards_selected');
620
+		}
599 621
 
600 622
 		$query_this_board = 'id_board IN ({array_int:boards})';
601 623
 		$query_parameters['boards'] = $boards;
602 624
 		$context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d';
603
-	}
604
-	else
625
+	} else
605 626
 	{
606 627
 		$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
607 628
 		// Don't bother to show deleted posts!
@@ -615,12 +636,14 @@  discard block
 block discarded – undo
615 636
 			)
616 637
 		);
617 638
 		$boards = array();
618
-		while ($row = $smcFunc['db_fetch_assoc']($request))
619
-			$boards[] = $row['id_board'];
639
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
640
+					$boards[] = $row['id_board'];
641
+		}
620 642
 		$smcFunc['db_free_result']($request);
621 643
 
622
-		if (empty($boards))
623
-			fatal_lang_error('error_no_boards_available', false);
644
+		if (empty($boards)) {
645
+					fatal_lang_error('error_no_boards_available', false);
646
+		}
624 647
 
625 648
 		$query_this_board = 'id_board IN ({array_int:boards})';
626 649
 		$query_parameters['boards'] = $boards;
@@ -682,13 +705,14 @@  discard block
 block discarded – undo
682 705
 		'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies']
683 706
 	);
684 707
 
685
-	if ($context['showing_all_topics'])
686
-		$context['linktree'][] = array(
708
+	if ($context['showing_all_topics']) {
709
+			$context['linktree'][] = array(
687 710
 			'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'],
688 711
 			'name' => $txt['unread_topics_all']
689 712
 		);
690
-	else
691
-		$txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
713
+	} else {
714
+			$txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
715
+	}
692 716
 
693 717
 	loadTemplate('Recent');
694 718
 	loadTemplate('MessageIndex');
@@ -696,8 +720,9 @@  discard block
 block discarded – undo
696 720
 
697 721
 	// Setup the default topic icons... for checking they exist and the like ;)
698 722
 	$context['icon_sources'] = array();
699
-	foreach ($context['stable_icons'] as $icon)
700
-		$context['icon_sources'][$icon] = 'images_url';
723
+	foreach ($context['stable_icons'] as $icon) {
724
+			$context['icon_sources'][$icon] = 'images_url';
725
+	}
701 726
 
702 727
 	$is_topics = $_REQUEST['action'] == 'unread';
703 728
 
@@ -727,8 +752,7 @@  discard block
 block discarded – undo
727 752
 			);
728 753
 			list ($earliest_msg) = $smcFunc['db_fetch_row']($request);
729 754
 			$smcFunc['db_free_result']($request);
730
-		}
731
-		else
755
+		} else
732 756
 		{
733 757
 			$request = $smcFunc['db_query']('', '
734 758
 				SELECT MIN(lmr.id_msg)
@@ -744,14 +768,14 @@  discard block
 block discarded – undo
744 768
 		}
745 769
 
746 770
 		// This is needed in case of topics marked unread.
747
-		if (empty($earliest_msg))
748
-			$earliest_msg = 0;
749
-		else
771
+		if (empty($earliest_msg)) {
772
+					$earliest_msg = 0;
773
+		} else
750 774
 		{
751 775
 			// Using caching, when possible, to ignore the below slow query.
752
-			if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time())
753
-				$earliest_msg2 = $_SESSION['cached_log_time'][1];
754
-			else
776
+			if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) {
777
+							$earliest_msg2 = $_SESSION['cached_log_time'][1];
778
+			} else
755 779
 			{
756 780
 				// This query is pretty slow, but it's needed to ensure nothing crucial is ignored.
757 781
 				$request = $smcFunc['db_query']('', '
@@ -766,8 +790,9 @@  discard block
 block discarded – undo
766 790
 				$smcFunc['db_free_result']($request);
767 791
 
768 792
 				// In theory this could be zero, if the first ever post is unread, so fudge it ;)
769
-				if ($earliest_msg2 == 0)
770
-					$earliest_msg2 = -1;
793
+				if ($earliest_msg2 == 0) {
794
+									$earliest_msg2 = -1;
795
+				}
771 796
 
772 797
 				$_SESSION['cached_log_time'] = array(time(), $earliest_msg2);
773 798
 			}
@@ -805,9 +830,9 @@  discard block
 block discarded – undo
805 830
 				'db_error_skip' => true,
806 831
 			))
807 832
 		) !== false;
833
+	} else {
834
+			$have_temp_table = false;
808 835
 	}
809
-	else
810
-		$have_temp_table = false;
811 836
 
812 837
 	if ($context['showing_all_topics'] && $have_temp_table)
813 838
 	{
@@ -853,14 +878,15 @@  discard block
 block discarded – undo
853 878
 
854 879
 			$context['topics'] = array();
855 880
 			$context['no_topic_listing'] = true;
856
-			if ($context['querystring_board_limits'] == ';start=%1$d')
857
-				$context['querystring_board_limits'] = '';
858
-			else
859
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
881
+			if ($context['querystring_board_limits'] == ';start=%1$d') {
882
+							$context['querystring_board_limits'] = '';
883
+			} else {
884
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
885
+			}
860 886
 			return;
887
+		} else {
888
+					$min_message = (int) $min_message;
861 889
 		}
862
-		else
863
-			$min_message = (int) $min_message;
864 890
 
865 891
 		$request = $smcFunc['db_query']('substring', '
866 892
 			SELECT ' . $select_clause . '
@@ -889,8 +915,7 @@  discard block
 block discarded – undo
889 915
 				'limit' => $context['topics_per_page'],
890 916
 			))
891 917
 		);
892
-	}
893
-	elseif ($is_topics)
918
+	} elseif ($is_topics)
894 919
 	{
895 920
 		$request = $smcFunc['db_query']('', '
896 921
 			SELECT COUNT(*), MIN(t.id_last_msg)
@@ -941,14 +966,15 @@  discard block
 block discarded – undo
941 966
 
942 967
 			$context['topics'] = array();
943 968
 			$context['no_topic_listing'] = true;
944
-			if ($context['querystring_board_limits'] == ';start=%d')
945
-				$context['querystring_board_limits'] = '';
946
-			else
947
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
969
+			if ($context['querystring_board_limits'] == ';start=%d') {
970
+							$context['querystring_board_limits'] = '';
971
+			} else {
972
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
973
+			}
948 974
 			return;
975
+		} else {
976
+					$min_message = (int) $min_message;
949 977
 		}
950
-		else
951
-			$min_message = (int) $min_message;
952 978
 
953 979
 		$request = $smcFunc['db_query']('substring', '
954 980
 			SELECT ' . $select_clause . '
@@ -978,8 +1004,7 @@  discard block
 block discarded – undo
978 1004
 				'limit' => $context['topics_per_page'],
979 1005
 			))
980 1006
 		);
981
-	}
982
-	else
1007
+	} else
983 1008
 	{
984 1009
 		if ($modSettings['totalMessages'] > 100000)
985 1010
 		{
@@ -1031,8 +1056,8 @@  discard block
 block discarded – undo
1031 1056
 			) !== false;
1032 1057
 
1033 1058
 			// If that worked, create a sample of the log_topics table too.
1034
-			if ($have_temp_table)
1035
-				$have_temp_table = $smcFunc['db_query']('', '
1059
+			if ($have_temp_table) {
1060
+							$have_temp_table = $smcFunc['db_query']('', '
1036 1061
 					CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in (
1037 1062
 						PRIMARY KEY (id_topic)
1038 1063
 					)
@@ -1045,6 +1070,7 @@  discard block
 block discarded – undo
1045 1070
 						'db_error_skip' => true,
1046 1071
 					)
1047 1072
 				) !== false;
1073
+			}
1048 1074
 		}
1049 1075
 
1050 1076
 		if (!empty($have_temp_table))
@@ -1060,8 +1086,7 @@  discard block
 block discarded – undo
1060 1086
 			);
1061 1087
 			list ($num_topics) = $smcFunc['db_fetch_row']($request);
1062 1088
 			$smcFunc['db_free_result']($request);
1063
-		}
1064
-		else
1089
+		} else
1065 1090
 		{
1066 1091
 			$request = $smcFunc['db_query']('unread_fetch_topic_count', '
1067 1092
 				SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg)
@@ -1102,15 +1127,16 @@  discard block
 block discarded – undo
1102 1127
 		{
1103 1128
 			$context['topics'] = array();
1104 1129
 			$context['no_topic_listing'] = true;
1105
-			if ($context['querystring_board_limits'] == ';start=%d')
1106
-				$context['querystring_board_limits'] = '';
1107
-			else
1108
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1130
+			if ($context['querystring_board_limits'] == ';start=%d') {
1131
+							$context['querystring_board_limits'] = '';
1132
+			} else {
1133
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1134
+			}
1109 1135
 			return;
1110 1136
 		}
1111 1137
 
1112
-		if (!empty($have_temp_table))
1113
-			$request = $smcFunc['db_query']('', '
1138
+		if (!empty($have_temp_table)) {
1139
+					$request = $smcFunc['db_query']('', '
1114 1140
 				SELECT t.id_topic
1115 1141
 				FROM {db_prefix}topics_posted_in AS t
1116 1142
 					LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic)
@@ -1124,8 +1150,8 @@  discard block
 block discarded – undo
1124 1150
 					'limit' => $context['topics_per_page'],
1125 1151
 				))
1126 1152
 			);
1127
-		else
1128
-			$request = $smcFunc['db_query']('', '
1153
+		} else {
1154
+					$request = $smcFunc['db_query']('', '
1129 1155
 				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].'
1130 1156
 				FROM {db_prefix}topics AS t
1131 1157
 					INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : '
@@ -1149,10 +1175,12 @@  discard block
 block discarded – undo
1149 1175
 					'sort' => $_REQUEST['sort'],
1150 1176
 				))
1151 1177
 			);
1178
+		}
1152 1179
 
1153 1180
 		$topics = array();
1154
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1155
-			$topics[] = $row['id_topic'];
1181
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1182
+					$topics[] = $row['id_topic'];
1183
+		}
1156 1184
 		$smcFunc['db_free_result']($request);
1157 1185
 
1158 1186
 		// Sanity... where have you gone?
@@ -1160,10 +1188,11 @@  discard block
 block discarded – undo
1160 1188
 		{
1161 1189
 			$context['topics'] = array();
1162 1190
 			$context['no_topic_listing'] = true;
1163
-			if ($context['querystring_board_limits'] == ';start=%d')
1164
-				$context['querystring_board_limits'] = '';
1165
-			else
1166
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1191
+			if ($context['querystring_board_limits'] == ';start=%d') {
1192
+							$context['querystring_board_limits'] = '';
1193
+			} else {
1194
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1195
+			}
1167 1196
 			return;
1168 1197
 		}
1169 1198
 
@@ -1197,8 +1226,9 @@  discard block
 block discarded – undo
1197 1226
 
1198 1227
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1199 1228
 	{
1200
-		if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
1201
-			continue;
1229
+		if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
1230
+					continue;
1231
+		}
1202 1232
 
1203 1233
 		$topic_ids[] = $row['id_topic'];
1204 1234
 
@@ -1206,11 +1236,13 @@  discard block
 block discarded – undo
1206 1236
 		{
1207 1237
 			// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
1208 1238
 			$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
1209
-			if ($smcFunc['strlen']($row['first_body']) > 128)
1210
-				$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1239
+			if ($smcFunc['strlen']($row['first_body']) > 128) {
1240
+							$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1241
+			}
1211 1242
 			$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
1212
-			if ($smcFunc['strlen']($row['last_body']) > 128)
1213
-				$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1243
+			if ($smcFunc['strlen']($row['last_body']) > 128) {
1244
+							$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1245
+			}
1214 1246
 
1215 1247
 			// Censor the subject and message preview.
1216 1248
 			censorText($row['first_subject']);
@@ -1221,23 +1253,22 @@  discard block
 block discarded – undo
1221 1253
 			{
1222 1254
 				$row['last_subject'] = $row['first_subject'];
1223 1255
 				$row['last_body'] = $row['first_body'];
1224
-			}
1225
-			else
1256
+			} else
1226 1257
 			{
1227 1258
 				censorText($row['last_subject']);
1228 1259
 				censorText($row['last_body']);
1229 1260
 			}
1230
-		}
1231
-		else
1261
+		} else
1232 1262
 		{
1233 1263
 			$row['first_body'] = '';
1234 1264
 			$row['last_body'] = '';
1235 1265
 			censorText($row['first_subject']);
1236 1266
 
1237
-			if ($row['id_first_msg'] == $row['id_last_msg'])
1238
-				$row['last_subject'] = $row['first_subject'];
1239
-			else
1240
-				censorText($row['last_subject']);
1267
+			if ($row['id_first_msg'] == $row['id_last_msg']) {
1268
+							$row['last_subject'] = $row['first_subject'];
1269
+			} else {
1270
+							censorText($row['last_subject']);
1271
+			}
1241 1272
 		}
1242 1273
 
1243 1274
 		// Decide how many pages the topic should have.
@@ -1249,29 +1280,32 @@  discard block
 block discarded – undo
1249 1280
 			$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false);
1250 1281
 
1251 1282
 			// If we can use all, show all.
1252
-			if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
1253
-				$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
1283
+			if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) {
1284
+							$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
1285
+			}
1286
+		} else {
1287
+					$pages = '';
1254 1288
 		}
1255 1289
 
1256
-		else
1257
-			$pages = '';
1258
-
1259 1290
 		// We need to check the topic icons exist... you can never be too sure!
1260 1291
 		if (!empty($modSettings['messageIconChecks_enable']))
1261 1292
 		{
1262 1293
 			// First icon first... as you'd expect.
1263
-			if (!isset($context['icon_sources'][$row['first_icon']]))
1264
-				$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1294
+			if (!isset($context['icon_sources'][$row['first_icon']])) {
1295
+							$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1296
+			}
1265 1297
 			// Last icon... last... duh.
1266
-			if (!isset($context['icon_sources'][$row['last_icon']]))
1267
-				$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1268
-		}
1269
-		else
1298
+			if (!isset($context['icon_sources'][$row['last_icon']])) {
1299
+							$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1300
+			}
1301
+		} else
1270 1302
 		{
1271
-			if (!isset($context['icon_sources'][$row['first_icon']]))
1272
-				$context['icon_sources'][$row['first_icon']] = 'images_url';
1273
-			if (!isset($context['icon_sources'][$row['last_icon']]))
1274
-				$context['icon_sources'][$row['last_icon']] = 'images_url';
1303
+			if (!isset($context['icon_sources'][$row['first_icon']])) {
1304
+							$context['icon_sources'][$row['first_icon']] = 'images_url';
1305
+			}
1306
+			if (!isset($context['icon_sources'][$row['last_icon']])) {
1307
+							$context['icon_sources'][$row['last_icon']] = 'images_url';
1308
+			}
1275 1309
 		}
1276 1310
 
1277 1311
 		// Force the recycling icon if appropriate
@@ -1285,12 +1319,14 @@  discard block
 block discarded – undo
1285 1319
 		$colorClass = 'windowbg';
1286 1320
 
1287 1321
 		// Sticky topics should get a different color, too.
1288
-		if ($row['is_sticky'])
1289
-			$colorClass .= ' sticky';
1322
+		if ($row['is_sticky']) {
1323
+					$colorClass .= ' sticky';
1324
+		}
1290 1325
 
1291 1326
 		// Locked topics get special treatment as well.
1292
-		if ($row['locked'])
1293
-			$colorClass .= ' locked';
1327
+		if ($row['locked']) {
1328
+					$colorClass .= ' locked';
1329
+		}
1294 1330
 
1295 1331
 		// And build the array.
1296 1332
 		$context['topics'][$row['id_topic']] = array(
@@ -1387,8 +1423,9 @@  discard block
 block discarded – undo
1387 1423
 		);
1388 1424
 		while ($row = $smcFunc['db_fetch_assoc']($result))
1389 1425
 		{
1390
-			if (empty($context['topics'][$row['id_topic']]['is_posted_in']))
1391
-				$context['topics'][$row['id_topic']]['is_posted_in'] = true;
1426
+			if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) {
1427
+							$context['topics'][$row['id_topic']]['is_posted_in'] = true;
1428
+			}
1392 1429
 		}
1393 1430
 		$smcFunc['db_free_result']($result);
1394 1431
 	}
@@ -1403,28 +1440,30 @@  discard block
 block discarded – undo
1403 1440
 			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'.  $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1404 1441
 		);
1405 1442
 
1406
-		if ($context['showCheckboxes'])
1407
-			$context['recent_buttons']['markselectread'] = array(
1443
+		if ($context['showCheckboxes']) {
1444
+					$context['recent_buttons']['markselectread'] = array(
1408 1445
 				'text' => 'quick_mod_markread',
1409 1446
 				'image' => 'markselectedread.png',
1410 1447
 				'url' => 'javascript:document.quickModForm.submit();',
1411 1448
 			);
1449
+		}
1412 1450
 
1413
-		if (!empty($context['topics']) && !$context['showing_all_topics'])
1414
-			$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
1415
-	}
1416
-	elseif (!$is_topics && isset($context['topics_to_mark']))
1451
+		if (!empty($context['topics']) && !$context['showing_all_topics']) {
1452
+					$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
1453
+		}
1454
+	} elseif (!$is_topics && isset($context['topics_to_mark']))
1417 1455
 	{
1418 1456
 		$context['recent_buttons'] = array(
1419 1457
 			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read']  .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1420 1458
 		);
1421 1459
 
1422
-		if ($context['showCheckboxes'])
1423
-			$context['recent_buttons']['markselectread'] = array(
1460
+		if ($context['showCheckboxes']) {
1461
+					$context['recent_buttons']['markselectread'] = array(
1424 1462
 				'text' => 'quick_mod_markread',
1425 1463
 				'image' => 'markselectedread.png',
1426 1464
 				'url' => 'javascript:document.quickModForm.submit();',
1427 1465
 			);
1466
+		}
1428 1467
 	}
1429 1468
 
1430 1469
 	// Allow mods to add additional buttons here
Please login to merge, or discard this patch.
SSI.php 1 patch
Braces   +430 added lines, -308 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Don't do anything if SMF is already loaded.
15
-if (defined('SMF'))
15
+if (defined('SMF')) {
16 16
 	return true;
17
+}
17 18
 
18 19
 define('SMF', 'SSI');
19 20
 
@@ -28,16 +29,18 @@  discard block
 block discarded – undo
28 29
 $time_start = microtime(true);
29 30
 
30 31
 // Just being safe...
31
-foreach (array('db_character_set', 'cachedir') as $variable)
32
+foreach (array('db_character_set', 'cachedir') as $variable) {
32 33
 	if (isset($GLOBALS[$variable]))
33 34
 		unset($GLOBALS[$variable]);
35
+}
34 36
 
35 37
 // Get the forum's settings for database and file paths.
36 38
 require_once(dirname(__FILE__) . '/Settings.php');
37 39
 
38 40
 // Make absolutely sure the cache directory is defined.
39
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
41
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
40 42
 	$cachedir = $boarddir . '/cache';
43
+}
41 44
 
42 45
 $ssi_error_reporting = error_reporting(E_ALL);
43 46
 /* Set this to one of three values depending on what you want to happen in the case of a fatal error.
@@ -48,12 +51,14 @@  discard block
 block discarded – undo
48 51
 $ssi_on_error_method = false;
49 52
 
50 53
 // Don't do john didley if the forum's been shut down completely.
51
-if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true))
54
+if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) {
52 55
 	die($mmessage);
56
+}
53 57
 
54 58
 // Fix for using the current directory as a path.
55
-if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
59
+if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') {
56 60
 	$sourcedir = dirname(__FILE__) . substr($sourcedir, 1);
61
+}
57 62
 
58 63
 // Load the important includes.
59 64
 require_once($sourcedir . '/QueryString.php');
@@ -78,26 +83,30 @@  discard block
 block discarded – undo
78 83
 cleanRequest();
79 84
 
80 85
 // Seed the random generator?
81
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
86
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
82 87
 	smf_seed_generator();
88
+}
83 89
 
84 90
 // Check on any hacking attempts.
85
-if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']))
91
+if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
86 92
 	die('No direct access...');
87
-elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme)
93
+} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) {
88 94
 	die('No direct access...');
89
-elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme)
95
+} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) {
90 96
 	die('No direct access...');
91
-elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers)
97
+} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) {
92 98
 	die('No direct access...');
93
-if (isset($_REQUEST['context']))
99
+}
100
+if (isset($_REQUEST['context'])) {
94 101
 	die('No direct access...');
102
+}
95 103
 
96 104
 // Gzip output? (because it must be boolean and true, this can't be hacked.)
97
-if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>='))
105
+if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) {
98 106
 	ob_start('ob_gzhandler');
99
-else
107
+} else {
100 108
 	$modSettings['enableCompressedOutput'] = '0';
109
+}
101 110
 
102 111
 /**
103 112
  * An autoloader for certain classes.
@@ -146,9 +155,9 @@  discard block
 block discarded – undo
146 155
 ob_start('ob_sessrewrite');
147 156
 
148 157
 // Start the session... known to scramble SSI includes in cases...
149
-if (!headers_sent())
158
+if (!headers_sent()) {
150 159
 	loadSession();
151
-else
160
+} else
152 161
 {
153 162
 	if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))
154 163
 	{
@@ -182,12 +191,14 @@  discard block
 block discarded – undo
182 191
 loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
183 192
 
184 193
 // @todo: probably not the best place, but somewhere it should be set...
185
-if (!headers_sent())
194
+if (!headers_sent()) {
186 195
 	header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set']));
196
+}
187 197
 
188 198
 // Take care of any banning that needs to be done.
189
-if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
199
+if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) {
190 200
 	is_not_banned();
201
+}
191 202
 
192 203
 // Do we allow guests in here?
193 204
 if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php')
@@ -202,17 +213,19 @@  discard block
 block discarded – undo
202 213
 {
203 214
 	$context['template_layers'] = $ssi_layers;
204 215
 	template_header();
205
-}
206
-else
216
+} else {
207 217
 	setupThemeContext();
218
+}
208 219
 
209 220
 // Make sure they didn't muss around with the settings... but only if it's not cli.
210
-if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '')
221
+if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') {
211 222
 	trigger_error($txt['ssi_session_broken'], E_USER_NOTICE);
223
+}
212 224
 
213 225
 // Without visiting the forum this session variable might not be set on submit.
214
-if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote'))
226
+if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) {
215 227
 	$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
228
+}
216 229
 
217 230
 // Have the ability to easily add functions to SSI.
218 231
 call_integration_hook('integrate_SSI');
@@ -221,11 +234,13 @@  discard block
 block discarded – undo
221 234
 if (basename($_SERVER['PHP_SELF']) == 'SSI.php')
222 235
 {
223 236
 	// You shouldn't just access SSI.php directly by URL!!
224
-	if (!isset($_GET['ssi_function']))
225
-		die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
237
+	if (!isset($_GET['ssi_function'])) {
238
+			die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
239
+	}
226 240
 	// Call a function passed by GET.
227
-	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest']))
228
-		call_user_func('ssi_' . $_GET['ssi_function']);
241
+	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) {
242
+			call_user_func('ssi_' . $_GET['ssi_function']);
243
+	}
229 244
 	exit;
230 245
 }
231 246
 
@@ -242,9 +257,10 @@  discard block
 block discarded – undo
242 257
  */
243 258
 function ssi_shutdown()
244 259
 {
245
-	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown')
246
-		template_footer();
247
-}
260
+	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') {
261
+			template_footer();
262
+	}
263
+	}
248 264
 
249 265
 /**
250 266
  * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new.
@@ -257,15 +273,17 @@  discard block
 block discarded – undo
257 273
 
258 274
 	if ($output_method == 'echo')
259 275
 	{
260
-		if ($context['user']['is_guest'])
261
-			echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
262
-		else
263
-			echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
276
+		if ($context['user']['is_guest']) {
277
+					echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
278
+		} else {
279
+					echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
280
+		}
264 281
 	}
265 282
 	// Don't echo... then do what?!
266
-	else
267
-		return $context['user'];
268
-}
283
+	else {
284
+			return $context['user'];
285
+	}
286
+	}
269 287
 
270 288
 /**
271 289
  * Display a menu bar, like is displayed at the top of the forum.
@@ -276,12 +294,14 @@  discard block
 block discarded – undo
276 294
 {
277 295
 	global $context;
278 296
 
279
-	if ($output_method == 'echo')
280
-		template_menu();
297
+	if ($output_method == 'echo') {
298
+			template_menu();
299
+	}
281 300
 	// What else could this do?
282
-	else
283
-		return $context['menu_buttons'];
284
-}
301
+	else {
302
+			return $context['menu_buttons'];
303
+	}
304
+	}
285 305
 
286 306
 /**
287 307
  * Show a logout link.
@@ -293,20 +313,23 @@  discard block
 block discarded – undo
293 313
 {
294 314
 	global $context, $txt, $scripturl;
295 315
 
296
-	if ($redirect_to != '')
297
-		$_SESSION['logout_url'] = $redirect_to;
316
+	if ($redirect_to != '') {
317
+			$_SESSION['logout_url'] = $redirect_to;
318
+	}
298 319
 
299 320
 	// Guests can't log out.
300
-	if ($context['user']['is_guest'])
301
-		return false;
321
+	if ($context['user']['is_guest']) {
322
+			return false;
323
+	}
302 324
 
303 325
 	$link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>';
304 326
 
305
-	if ($output_method == 'echo')
306
-		echo $link;
307
-	else
308
-		return $link;
309
-}
327
+	if ($output_method == 'echo') {
328
+			echo $link;
329
+	} else {
330
+			return $link;
331
+	}
332
+	}
310 333
 
311 334
 /**
312 335
  * Recent post list:   [board] Subject by Poster    Date
@@ -322,17 +345,17 @@  discard block
 block discarded – undo
322 345
 	global $modSettings, $context;
323 346
 
324 347
 	// Excluding certain boards...
325
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
326
-		$exclude_boards = array($modSettings['recycle_board']);
327
-	else
328
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
348
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
349
+			$exclude_boards = array($modSettings['recycle_board']);
350
+	} else {
351
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
352
+	}
329 353
 
330 354
 	// What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter.
331 355
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
332 356
 	{
333 357
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
334
-	}
335
-	elseif ($include_boards != null)
358
+	} elseif ($include_boards != null)
336 359
 	{
337 360
 		$include_boards = array();
338 361
 	}
@@ -369,8 +392,9 @@  discard block
 block discarded – undo
369 392
 {
370 393
 	global $modSettings;
371 394
 
372
-	if (empty($post_ids))
373
-		return;
395
+	if (empty($post_ids)) {
396
+			return;
397
+	}
374 398
 
375 399
 	// Allow the user to request more than one - why not?
376 400
 	$post_ids = is_array($post_ids) ? $post_ids : array($post_ids);
@@ -405,8 +429,9 @@  discard block
 block discarded – undo
405 429
 	global $scripturl, $txt, $user_info;
406 430
 	global $modSettings, $smcFunc, $context;
407 431
 
408
-	if (!empty($modSettings['enable_likes']))
409
-		$context['can_like'] = allowedTo('likes_like');
432
+	if (!empty($modSettings['enable_likes'])) {
433
+			$context['can_like'] = allowedTo('likes_like');
434
+	}
410 435
 
411 436
 	// Find all the posts. Newer ones will have higher IDs.
412 437
 	$request = $smcFunc['db_query']('substring', '
@@ -472,12 +497,13 @@  discard block
 block discarded – undo
472 497
 		);
473 498
 
474 499
 		// Get the likes for each message.
475
-		if (!empty($modSettings['enable_likes']))
476
-			$posts[$row['id_msg']]['likes'] = array(
500
+		if (!empty($modSettings['enable_likes'])) {
501
+					$posts[$row['id_msg']]['likes'] = array(
477 502
 				'count' => $row['likes'],
478 503
 				'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])),
479 504
 				'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']),
480 505
 			);
506
+		}
481 507
 	}
482 508
 	$smcFunc['db_free_result']($request);
483 509
 
@@ -485,13 +511,14 @@  discard block
 block discarded – undo
485 511
 	call_integration_hook('integrate_ssi_queryPosts', array(&$posts));
486 512
 
487 513
 	// Just return it.
488
-	if ($output_method != 'echo' || empty($posts))
489
-		return $posts;
514
+	if ($output_method != 'echo' || empty($posts)) {
515
+			return $posts;
516
+	}
490 517
 
491 518
 	echo '
492 519
 		<table style="border: none" class="ssi_table">';
493
-	foreach ($posts as $post)
494
-		echo '
520
+	foreach ($posts as $post) {
521
+			echo '
495 522
 			<tr>
496 523
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
497 524
 					[', $post['board']['link'], ']
@@ -505,6 +532,7 @@  discard block
 block discarded – undo
505 532
 					', $post['time'], '
506 533
 				</td>
507 534
 			</tr>';
535
+	}
508 536
 	echo '
509 537
 		</table>';
510 538
 }
@@ -522,25 +550,26 @@  discard block
 block discarded – undo
522 550
 	global $settings, $scripturl, $txt, $user_info;
523 551
 	global $modSettings, $smcFunc, $context;
524 552
 
525
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
526
-		$exclude_boards = array($modSettings['recycle_board']);
527
-	else
528
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
553
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
554
+			$exclude_boards = array($modSettings['recycle_board']);
555
+	} else {
556
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
557
+	}
529 558
 
530 559
 	// Only some boards?.
531 560
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
532 561
 	{
533 562
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
534
-	}
535
-	elseif ($include_boards != null)
563
+	} elseif ($include_boards != null)
536 564
 	{
537 565
 		$output_method = $include_boards;
538 566
 		$include_boards = array();
539 567
 	}
540 568
 
541 569
 	$icon_sources = array();
542
-	foreach ($context['stable_icons'] as $icon)
543
-		$icon_sources[$icon] = 'images_url';
570
+	foreach ($context['stable_icons'] as $icon) {
571
+			$icon_sources[$icon] = 'images_url';
572
+	}
544 573
 
545 574
 	// Find all the posts in distinct topics.  Newer ones will have higher IDs.
546 575
 	$request = $smcFunc['db_query']('substring', '
@@ -565,13 +594,15 @@  discard block
 block discarded – undo
565 594
 		)
566 595
 	);
567 596
 	$topics = array();
568
-	while ($row = $smcFunc['db_fetch_assoc']($request))
569
-		$topics[$row['id_topic']] = $row;
597
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
598
+			$topics[$row['id_topic']] = $row;
599
+	}
570 600
 	$smcFunc['db_free_result']($request);
571 601
 
572 602
 	// Did we find anything? If not, bail.
573
-	if (empty($topics))
574
-		return array();
603
+	if (empty($topics)) {
604
+			return array();
605
+	}
575 606
 
576 607
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
577 608
 
@@ -599,21 +630,24 @@  discard block
 block discarded – undo
599 630
 	while ($row = $smcFunc['db_fetch_assoc']($request))
600 631
 	{
601 632
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
602
-		if ($smcFunc['strlen']($row['body']) > 128)
603
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
633
+		if ($smcFunc['strlen']($row['body']) > 128) {
634
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
635
+		}
604 636
 
605 637
 		// Censor the subject.
606 638
 		censorText($row['subject']);
607 639
 		censorText($row['body']);
608 640
 
609 641
 		// Recycled icon
610
-		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board'])
611
-			$row['icon'] = 'recycled';
642
+		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) {
643
+					$row['icon'] = 'recycled';
644
+		}
612 645
 
613
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
614
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
615
-		elseif (!isset($icon_sources[$row['icon']]))
616
-			$icon_sources[$row['icon']] = 'images_url';
646
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
647
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
648
+		} elseif (!isset($icon_sources[$row['icon']])) {
649
+					$icon_sources[$row['icon']] = 'images_url';
650
+		}
617 651
 
618 652
 		// Build the array.
619 653
 		$posts[] = array(
@@ -652,13 +686,14 @@  discard block
 block discarded – undo
652 686
 	call_integration_hook('integrate_ssi_recentTopics', array(&$posts));
653 687
 
654 688
 	// Just return it.
655
-	if ($output_method != 'echo' || empty($posts))
656
-		return $posts;
689
+	if ($output_method != 'echo' || empty($posts)) {
690
+			return $posts;
691
+	}
657 692
 
658 693
 	echo '
659 694
 		<table style="border: none" class="ssi_table">';
660
-	foreach ($posts as $post)
661
-		echo '
695
+	foreach ($posts as $post) {
696
+			echo '
662 697
 			<tr>
663 698
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
664 699
 					[', $post['board']['link'], ']
@@ -672,6 +707,7 @@  discard block
 block discarded – undo
672 707
 					', $post['time'], '
673 708
 				</td>
674 709
 			</tr>';
710
+	}
675 711
 	echo '
676 712
 		</table>';
677 713
 }
@@ -696,27 +732,30 @@  discard block
 block discarded – undo
696 732
 		)
697 733
 	);
698 734
 	$return = array();
699
-	while ($row = $smcFunc['db_fetch_assoc']($request))
700
-		$return[] = array(
735
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
736
+			$return[] = array(
701 737
 			'id' => $row['id_member'],
702 738
 			'name' => $row['real_name'],
703 739
 			'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
704 740
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
705 741
 			'posts' => $row['posts']
706 742
 		);
743
+	}
707 744
 	$smcFunc['db_free_result']($request);
708 745
 
709 746
 	// If mods want to do somthing with this list of members, let them do that now.
710 747
 	call_integration_hook('integrate_ssi_topPoster', array(&$return));
711 748
 
712 749
 	// Just return all the top posters.
713
-	if ($output_method != 'echo')
714
-		return $return;
750
+	if ($output_method != 'echo') {
751
+			return $return;
752
+	}
715 753
 
716 754
 	// Make a quick array to list the links in.
717 755
 	$temp_array = array();
718
-	foreach ($return as $member)
719
-		$temp_array[] = $member['link'];
756
+	foreach ($return as $member) {
757
+			$temp_array[] = $member['link'];
758
+	}
720 759
 
721 760
 	echo implode(', ', $temp_array);
722 761
 }
@@ -748,8 +787,8 @@  discard block
 block discarded – undo
748 787
 		)
749 788
 	);
750 789
 	$boards = array();
751
-	while ($row = $smcFunc['db_fetch_assoc']($request))
752
-		$boards[] = array(
790
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
791
+			$boards[] = array(
753 792
 			'id' => $row['id_board'],
754 793
 			'num_posts' => $row['num_posts'],
755 794
 			'num_topics' => $row['num_topics'],
@@ -758,14 +797,16 @@  discard block
 block discarded – undo
758 797
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
759 798
 			'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'
760 799
 		);
800
+	}
761 801
 	$smcFunc['db_free_result']($request);
762 802
 
763 803
 	// If mods want to do somthing with this list of boards, let them do that now.
764 804
 	call_integration_hook('integrate_ssi_topBoards', array(&$boards));
765 805
 
766 806
 	// If we shouldn't output or have nothing to output, just jump out.
767
-	if ($output_method != 'echo' || empty($boards))
768
-		return $boards;
807
+	if ($output_method != 'echo' || empty($boards)) {
808
+			return $boards;
809
+	}
769 810
 
770 811
 	echo '
771 812
 		<table class="ssi_table">
@@ -774,13 +815,14 @@  discard block
 block discarded – undo
774 815
 				<th style="text-align: left">', $txt['board_topics'], '</th>
775 816
 				<th style="text-align: left">', $txt['posts'], '</th>
776 817
 			</tr>';
777
-	foreach ($boards as $sBoard)
778
-		echo '
818
+	foreach ($boards as $sBoard) {
819
+			echo '
779 820
 			<tr>
780 821
 				<td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '" class="new_posts">' . $txt['new'] . '</a>' : '', '</td>
781 822
 				<td style="text-align: right">', comma_format($sBoard['num_topics']), '</td>
782 823
 				<td style="text-align: right">', comma_format($sBoard['num_posts']), '</td>
783 824
 			</tr>';
825
+	}
784 826
 	echo '
785 827
 		</table>';
786 828
 }
@@ -813,12 +855,13 @@  discard block
 block discarded – undo
813 855
 			)
814 856
 		);
815 857
 		$topic_ids = array();
816
-		while ($row = $smcFunc['db_fetch_assoc']($request))
817
-			$topic_ids[] = $row['id_topic'];
858
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
859
+					$topic_ids[] = $row['id_topic'];
860
+		}
818 861
 		$smcFunc['db_free_result']($request);
862
+	} else {
863
+			$topic_ids = array();
819 864
 	}
820
-	else
821
-		$topic_ids = array();
822 865
 
823 866
 	$request = $smcFunc['db_query']('', '
824 867
 		SELECT m.subject, m.id_topic, t.num_views, t.num_replies
@@ -857,8 +900,9 @@  discard block
 block discarded – undo
857 900
 	// If mods want to do somthing with this list of topics, let them do that now.
858 901
 	call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type));
859 902
 
860
-	if ($output_method != 'echo' || empty($topics))
861
-		return $topics;
903
+	if ($output_method != 'echo' || empty($topics)) {
904
+			return $topics;
905
+	}
862 906
 
863 907
 	echo '
864 908
 		<table class="ssi_table">
@@ -867,8 +911,8 @@  discard block
 block discarded – undo
867 911
 				<th style="text-align: left">', $txt['views'], '</th>
868 912
 				<th style="text-align: left">', $txt['replies'], '</th>
869 913
 			</tr>';
870
-	foreach ($topics as $sTopic)
871
-		echo '
914
+	foreach ($topics as $sTopic) {
915
+			echo '
872 916
 			<tr>
873 917
 				<td style="text-align: left">
874 918
 					', $sTopic['link'], '
@@ -876,6 +920,7 @@  discard block
 block discarded – undo
876 920
 				<td style="text-align: right">', comma_format($sTopic['num_views']), '</td>
877 921
 				<td style="text-align: right">', comma_format($sTopic['num_replies']), '</td>
878 922
 			</tr>';
923
+	}
879 924
 	echo '
880 925
 		</table>';
881 926
 }
@@ -911,12 +956,13 @@  discard block
 block discarded – undo
911 956
 {
912 957
 	global $txt, $context;
913 958
 
914
-	if ($output_method == 'echo')
915
-		echo '
959
+	if ($output_method == 'echo') {
960
+			echo '
916 961
 	', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>';
917
-	else
918
-		return $context['common_stats']['latest_member'];
919
-}
962
+	} else {
963
+			return $context['common_stats']['latest_member'];
964
+	}
965
+	}
920 966
 
921 967
 /**
922 968
  * Fetches a random member.
@@ -965,8 +1011,9 @@  discard block
 block discarded – undo
965 1011
 	}
966 1012
 
967 1013
 	// Just to be sure put the random generator back to something... random.
968
-	if ($random_type != '')
969
-		mt_srand(time());
1014
+	if ($random_type != '') {
1015
+			mt_srand(time());
1016
+	}
970 1017
 
971 1018
 	return $result;
972 1019
 }
@@ -979,8 +1026,9 @@  discard block
 block discarded – undo
979 1026
  */
980 1027
 function ssi_fetchMember($member_ids = array(), $output_method = 'echo')
981 1028
 {
982
-	if (empty($member_ids))
983
-		return;
1029
+	if (empty($member_ids)) {
1030
+			return;
1031
+	}
984 1032
 
985 1033
 	// Can have more than one member if you really want...
986 1034
 	$member_ids = is_array($member_ids) ? $member_ids : array($member_ids);
@@ -1005,8 +1053,9 @@  discard block
 block discarded – undo
1005 1053
  */
1006 1054
 function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo')
1007 1055
 {
1008
-	if ($group_id === null)
1009
-		return;
1056
+	if ($group_id === null) {
1057
+			return;
1058
+	}
1010 1059
 
1011 1060
 	$query_where = '
1012 1061
 		id_group = {int:id_group}
@@ -1033,8 +1082,9 @@  discard block
 block discarded – undo
1033 1082
 {
1034 1083
 	global $smcFunc, $memberContext;
1035 1084
 
1036
-	if ($query_where === null)
1037
-		return;
1085
+	if ($query_where === null) {
1086
+			return;
1087
+	}
1038 1088
 
1039 1089
 	// Fetch the members in question.
1040 1090
 	$request = $smcFunc['db_query']('', '
@@ -1047,12 +1097,14 @@  discard block
 block discarded – undo
1047 1097
 		))
1048 1098
 	);
1049 1099
 	$members = array();
1050
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1051
-		$members[] = $row['id_member'];
1100
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1101
+			$members[] = $row['id_member'];
1102
+	}
1052 1103
 	$smcFunc['db_free_result']($request);
1053 1104
 
1054
-	if (empty($members))
1055
-		return array();
1105
+	if (empty($members)) {
1106
+			return array();
1107
+	}
1056 1108
 
1057 1109
 	// If mods want to do somthing with this list of members, let them do that now.
1058 1110
 	call_integration_hook('integrate_ssi_queryMembers', array(&$members));
@@ -1061,23 +1113,25 @@  discard block
 block discarded – undo
1061 1113
 	loadMemberData($members);
1062 1114
 
1063 1115
 	// Draw the table!
1064
-	if ($output_method == 'echo')
1065
-		echo '
1116
+	if ($output_method == 'echo') {
1117
+			echo '
1066 1118
 		<table style="border: none" class="ssi_table">';
1119
+	}
1067 1120
 
1068 1121
 	$query_members = array();
1069 1122
 	foreach ($members as $member)
1070 1123
 	{
1071 1124
 		// Load their context data.
1072
-		if (!loadMemberContext($member))
1073
-			continue;
1125
+		if (!loadMemberContext($member)) {
1126
+					continue;
1127
+		}
1074 1128
 
1075 1129
 		// Store this member's information.
1076 1130
 		$query_members[$member] = $memberContext[$member];
1077 1131
 
1078 1132
 		// Only do something if we're echo'ing.
1079
-		if ($output_method == 'echo')
1080
-			echo '
1133
+		if ($output_method == 'echo') {
1134
+					echo '
1081 1135
 			<tr>
1082 1136
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
1083 1137
 					', $query_members[$member]['link'], '
@@ -1085,12 +1139,14 @@  discard block
 block discarded – undo
1085 1139
 					<br>', $query_members[$member]['avatar']['image'], '
1086 1140
 				</td>
1087 1141
 			</tr>';
1142
+		}
1088 1143
 	}
1089 1144
 
1090 1145
 	// End the table if appropriate.
1091
-	if ($output_method == 'echo')
1092
-		echo '
1146
+	if ($output_method == 'echo') {
1147
+			echo '
1093 1148
 		</table>';
1149
+	}
1094 1150
 
1095 1151
 	// Send back the data.
1096 1152
 	return $query_members;
@@ -1105,8 +1161,9 @@  discard block
 block discarded – undo
1105 1161
 {
1106 1162
 	global $txt, $scripturl, $modSettings, $smcFunc;
1107 1163
 
1108
-	if (!allowedTo('view_stats'))
1109
-		return;
1164
+	if (!allowedTo('view_stats')) {
1165
+			return;
1166
+	}
1110 1167
 
1111 1168
 	$totals = array(
1112 1169
 		'members' => $modSettings['totalMembers'],
@@ -1135,8 +1192,9 @@  discard block
 block discarded – undo
1135 1192
 	// If mods want to do somthing with the board stats, let them do that now.
1136 1193
 	call_integration_hook('integrate_ssi_boardStats', array(&$totals));
1137 1194
 
1138
-	if ($output_method != 'echo')
1139
-		return $totals;
1195
+	if ($output_method != 'echo') {
1196
+			return $totals;
1197
+	}
1140 1198
 
1141 1199
 	echo '
1142 1200
 		', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br>
@@ -1165,8 +1223,8 @@  discard block
 block discarded – undo
1165 1223
 	call_integration_hook('integrate_ssi_whosOnline', array(&$return));
1166 1224
 
1167 1225
 	// Add some redundancy for backwards compatibility reasons.
1168
-	if ($output_method != 'echo')
1169
-		return $return + array(
1226
+	if ($output_method != 'echo') {
1227
+			return $return + array(
1170 1228
 			'users' => $return['users_online'],
1171 1229
 			'guests' => $return['num_guests'],
1172 1230
 			'hidden' => $return['num_users_hidden'],
@@ -1174,29 +1232,35 @@  discard block
 block discarded – undo
1174 1232
 			'num_users' => $return['num_users_online'],
1175 1233
 			'total_users' => $return['num_users_online'] + $return['num_guests'],
1176 1234
 		);
1235
+	}
1177 1236
 
1178 1237
 	echo '
1179 1238
 		', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
1180 1239
 
1181 1240
 	$bracketList = array();
1182
-	if (!empty($user_info['buddies']))
1183
-		$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1184
-	if (!empty($return['num_spiders']))
1185
-		$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1186
-	if (!empty($return['num_users_hidden']))
1187
-		$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1241
+	if (!empty($user_info['buddies'])) {
1242
+			$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1243
+	}
1244
+	if (!empty($return['num_spiders'])) {
1245
+			$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1246
+	}
1247
+	if (!empty($return['num_users_hidden'])) {
1248
+			$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1249
+	}
1188 1250
 
1189
-	if (!empty($bracketList))
1190
-		echo ' (' . implode(', ', $bracketList) . ')';
1251
+	if (!empty($bracketList)) {
1252
+			echo ' (' . implode(', ', $bracketList) . ')';
1253
+	}
1191 1254
 
1192 1255
 	echo '<br>
1193 1256
 			', implode(', ', $return['list_users_online']);
1194 1257
 
1195 1258
 	// Showing membergroups?
1196
-	if (!empty($settings['show_group_key']) && !empty($return['membergroups']))
1197
-		echo '<br>
1259
+	if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) {
1260
+			echo '<br>
1198 1261
 			[' . implode(']&nbsp;&nbsp;[', $return['membergroups']) . ']';
1199
-}
1262
+	}
1263
+	}
1200 1264
 
1201 1265
 /**
1202 1266
  * Just like whosOnline except it also logs the online presence.
@@ -1207,11 +1271,12 @@  discard block
 block discarded – undo
1207 1271
 {
1208 1272
 	writeLog();
1209 1273
 
1210
-	if ($output_method != 'echo')
1211
-		return ssi_whosOnline($output_method);
1212
-	else
1213
-		ssi_whosOnline($output_method);
1214
-}
1274
+	if ($output_method != 'echo') {
1275
+			return ssi_whosOnline($output_method);
1276
+	} else {
1277
+			ssi_whosOnline($output_method);
1278
+	}
1279
+	}
1215 1280
 
1216 1281
 // Shows a login box.
1217 1282
 /**
@@ -1224,11 +1289,13 @@  discard block
 block discarded – undo
1224 1289
 {
1225 1290
 	global $scripturl, $txt, $user_info, $context;
1226 1291
 
1227
-	if ($redirect_to != '')
1228
-		$_SESSION['login_url'] = $redirect_to;
1292
+	if ($redirect_to != '') {
1293
+			$_SESSION['login_url'] = $redirect_to;
1294
+	}
1229 1295
 
1230
-	if ($output_method != 'echo' || !$user_info['is_guest'])
1231
-		return $user_info['is_guest'];
1296
+	if ($output_method != 'echo' || !$user_info['is_guest']) {
1297
+			return $user_info['is_guest'];
1298
+	}
1232 1299
 
1233 1300
 	// Create a login token
1234 1301
 	createToken('login');
@@ -1280,8 +1347,9 @@  discard block
 block discarded – undo
1280 1347
 
1281 1348
 	$boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote'));
1282 1349
 
1283
-	if (empty($boardsAllowed))
1284
-		return array();
1350
+	if (empty($boardsAllowed)) {
1351
+			return array();
1352
+	}
1285 1353
 
1286 1354
 	$request = $smcFunc['db_query']('', '
1287 1355
 		SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time
@@ -1314,12 +1382,14 @@  discard block
 block discarded – undo
1314 1382
 	$smcFunc['db_free_result']($request);
1315 1383
 
1316 1384
 	// This user has voted on all the polls.
1317
-	if (empty($row) || !is_array($row))
1318
-		return array();
1385
+	if (empty($row) || !is_array($row)) {
1386
+			return array();
1387
+	}
1319 1388
 
1320 1389
 	// If this is a guest who's voted we'll through ourselves to show poll to show the results.
1321
-	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))))
1322
-		return ssi_showPoll($row['id_topic'], $output_method);
1390
+	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) {
1391
+			return ssi_showPoll($row['id_topic'], $output_method);
1392
+	}
1323 1393
 
1324 1394
 	$request = $smcFunc['db_query']('', '
1325 1395
 		SELECT COUNT(DISTINCT id_member)
@@ -1383,8 +1453,9 @@  discard block
 block discarded – undo
1383 1453
 	// If mods want to do somthing with this list of polls, let them do that now.
1384 1454
 	call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead));
1385 1455
 
1386
-	if ($output_method != 'echo')
1387
-		return $return;
1456
+	if ($output_method != 'echo') {
1457
+			return $return;
1458
+	}
1388 1459
 
1389 1460
 	if ($allow_view_results)
1390 1461
 	{
@@ -1393,19 +1464,20 @@  discard block
 block discarded – undo
1393 1464
 			<strong>', $return['question'], '</strong><br>
1394 1465
 			', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1395 1466
 
1396
-		foreach ($return['options'] as $option)
1397
-			echo '
1467
+		foreach ($return['options'] as $option) {
1468
+					echo '
1398 1469
 			<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1470
+		}
1399 1471
 
1400 1472
 		echo '
1401 1473
 			<input type="submit" value="', $txt['poll_vote'], '" class="button">
1402 1474
 			<input type="hidden" name="poll" value="', $return['id'], '">
1403 1475
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1404 1476
 		</form>';
1477
+	} else {
1478
+			echo $txt['poll_cannot_see'];
1479
+	}
1405 1480
 	}
1406
-	else
1407
-		echo $txt['poll_cannot_see'];
1408
-}
1409 1481
 
1410 1482
 /**
1411 1483
  * Shows the poll from the specified topic
@@ -1419,13 +1491,15 @@  discard block
 block discarded – undo
1419 1491
 
1420 1492
 	$boardsAllowed = boardsAllowedTo('poll_view');
1421 1493
 
1422
-	if (empty($boardsAllowed))
1423
-		return array();
1494
+	if (empty($boardsAllowed)) {
1495
+			return array();
1496
+	}
1424 1497
 
1425
-	if ($topic === null && isset($_REQUEST['ssi_topic']))
1426
-		$topic = (int) $_REQUEST['ssi_topic'];
1427
-	else
1428
-		$topic = (int) $topic;
1498
+	if ($topic === null && isset($_REQUEST['ssi_topic'])) {
1499
+			$topic = (int) $_REQUEST['ssi_topic'];
1500
+	} else {
1501
+			$topic = (int) $topic;
1502
+	}
1429 1503
 
1430 1504
 	$request = $smcFunc['db_query']('', '
1431 1505
 		SELECT
@@ -1446,17 +1520,18 @@  discard block
 block discarded – undo
1446 1520
 	);
1447 1521
 
1448 1522
 	// Either this topic has no poll, or the user cannot view it.
1449
-	if ($smcFunc['db_num_rows']($request) == 0)
1450
-		return array();
1523
+	if ($smcFunc['db_num_rows']($request) == 0) {
1524
+			return array();
1525
+	}
1451 1526
 
1452 1527
 	$row = $smcFunc['db_fetch_assoc']($request);
1453 1528
 	$smcFunc['db_free_result']($request);
1454 1529
 
1455 1530
 	// Check if they can vote.
1456 1531
 	$already_voted = false;
1457
-	if (!empty($row['expire_time']) && $row['expire_time'] < time())
1458
-		$allow_vote = false;
1459
-	elseif ($user_info['is_guest'])
1532
+	if (!empty($row['expire_time']) && $row['expire_time'] < time()) {
1533
+			$allow_vote = false;
1534
+	} elseif ($user_info['is_guest'])
1460 1535
 	{
1461 1536
 		// There's a difference between "allowed to vote" and "already voted"...
1462 1537
 		$allow_vote = $row['guest_vote'];
@@ -1466,10 +1541,9 @@  discard block
 block discarded – undo
1466 1541
 		{
1467 1542
 			$already_voted = true;
1468 1543
 		}
1469
-	}
1470
-	elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board']))
1471
-		$allow_vote = false;
1472
-	else
1544
+	} elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) {
1545
+			$allow_vote = false;
1546
+	} else
1473 1547
 	{
1474 1548
 		$request = $smcFunc['db_query']('', '
1475 1549
 			SELECT id_member
@@ -1551,8 +1625,9 @@  discard block
 block discarded – undo
1551 1625
 	// If mods want to do somthing with this poll, let them do that now.
1552 1626
 	call_integration_hook('integrate_ssi_showPoll', array(&$return));
1553 1627
 
1554
-	if ($output_method != 'echo')
1555
-		return $return;
1628
+	if ($output_method != 'echo') {
1629
+			return $return;
1630
+	}
1556 1631
 
1557 1632
 	if ($return['allow_vote'])
1558 1633
 	{
@@ -1561,17 +1636,17 @@  discard block
 block discarded – undo
1561 1636
 				<strong>', $return['question'], '</strong><br>
1562 1637
 				', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1563 1638
 
1564
-		foreach ($return['options'] as $option)
1565
-			echo '
1639
+		foreach ($return['options'] as $option) {
1640
+					echo '
1566 1641
 				<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1642
+		}
1567 1643
 
1568 1644
 		echo '
1569 1645
 				<input type="submit" value="', $txt['poll_vote'], '" class="button">
1570 1646
 				<input type="hidden" name="poll" value="', $return['id'], '">
1571 1647
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1572 1648
 			</form>';
1573
-	}
1574
-	else
1649
+	} else
1575 1650
 	{
1576 1651
 		echo '
1577 1652
 			<div class="ssi_poll">
@@ -1651,27 +1726,32 @@  discard block
 block discarded – undo
1651 1726
 			'is_approved' => 1,
1652 1727
 		)
1653 1728
 	);
1654
-	if ($smcFunc['db_num_rows']($request) == 0)
1655
-		die;
1729
+	if ($smcFunc['db_num_rows']($request) == 0) {
1730
+			die;
1731
+	}
1656 1732
 	$row = $smcFunc['db_fetch_assoc']($request);
1657 1733
 	$smcFunc['db_free_result']($request);
1658 1734
 
1659
-	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
1660
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1735
+	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
1736
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1737
+	}
1661 1738
 
1662 1739
 	// Too many options checked?
1663
-	if (count($_REQUEST['options']) > $row['max_votes'])
1664
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1740
+	if (count($_REQUEST['options']) > $row['max_votes']) {
1741
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1742
+	}
1665 1743
 
1666 1744
 	// It's a guest who has already voted?
1667 1745
 	if ($user_info['is_guest'])
1668 1746
 	{
1669 1747
 		// Guest voting disabled?
1670
-		if (!$row['guest_vote'])
1671
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1748
+		if (!$row['guest_vote']) {
1749
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1750
+		}
1672 1751
 		// Already voted?
1673
-		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))
1674
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1752
+		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) {
1753
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1754
+		}
1675 1755
 	}
1676 1756
 
1677 1757
 	$sOptions = array();
@@ -1725,11 +1805,13 @@  discard block
 block discarded – undo
1725 1805
 {
1726 1806
 	global $scripturl, $txt, $context;
1727 1807
 
1728
-	if (!allowedTo('search_posts'))
1729
-		return;
1808
+	if (!allowedTo('search_posts')) {
1809
+			return;
1810
+	}
1730 1811
 
1731
-	if ($output_method != 'echo')
1732
-		return $scripturl . '?action=search';
1812
+	if ($output_method != 'echo') {
1813
+			return $scripturl . '?action=search';
1814
+	}
1733 1815
 
1734 1816
 	echo '
1735 1817
 		<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -1751,8 +1833,9 @@  discard block
 block discarded – undo
1751 1833
 	// If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context.
1752 1834
 	call_integration_hook('integrate_ssi_news');
1753 1835
 
1754
-	if ($output_method != 'echo')
1755
-		return $context['random_news_line'];
1836
+	if ($output_method != 'echo') {
1837
+			return $context['random_news_line'];
1838
+	}
1756 1839
 
1757 1840
 	echo $context['random_news_line'];
1758 1841
 }
@@ -1766,8 +1849,9 @@  discard block
 block discarded – undo
1766 1849
 {
1767 1850
 	global $scripturl, $modSettings, $user_info;
1768 1851
 
1769
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view'))
1770
-		return;
1852
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) {
1853
+			return;
1854
+	}
1771 1855
 
1772 1856
 	$eventOptions = array(
1773 1857
 		'include_birthdays' => true,
@@ -1778,13 +1862,15 @@  discard block
 block discarded – undo
1778 1862
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1779 1863
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1780 1864
 
1781
-	if ($output_method != 'echo')
1782
-		return $return['calendar_birthdays'];
1865
+	if ($output_method != 'echo') {
1866
+			return $return['calendar_birthdays'];
1867
+	}
1783 1868
 
1784
-	foreach ($return['calendar_birthdays'] as $member)
1785
-		echo '
1869
+	foreach ($return['calendar_birthdays'] as $member) {
1870
+			echo '
1786 1871
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : '');
1787
-}
1872
+	}
1873
+	}
1788 1874
 
1789 1875
 /**
1790 1876
  * Shows today's holidays.
@@ -1795,8 +1881,9 @@  discard block
 block discarded – undo
1795 1881
 {
1796 1882
 	global $modSettings, $user_info;
1797 1883
 
1798
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1799
-		return;
1884
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1885
+			return;
1886
+	}
1800 1887
 
1801 1888
 	$eventOptions = array(
1802 1889
 		'include_holidays' => true,
@@ -1807,8 +1894,9 @@  discard block
 block discarded – undo
1807 1894
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1808 1895
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1809 1896
 
1810
-	if ($output_method != 'echo')
1811
-		return $return['calendar_holidays'];
1897
+	if ($output_method != 'echo') {
1898
+			return $return['calendar_holidays'];
1899
+	}
1812 1900
 
1813 1901
 	echo '
1814 1902
 		', implode(', ', $return['calendar_holidays']);
@@ -1822,8 +1910,9 @@  discard block
 block discarded – undo
1822 1910
 {
1823 1911
 	global $modSettings, $user_info;
1824 1912
 
1825
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1826
-		return;
1913
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1914
+			return;
1915
+	}
1827 1916
 
1828 1917
 	$eventOptions = array(
1829 1918
 		'include_events' => true,
@@ -1834,14 +1923,16 @@  discard block
 block discarded – undo
1834 1923
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1835 1924
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1836 1925
 
1837
-	if ($output_method != 'echo')
1838
-		return $return['calendar_events'];
1926
+	if ($output_method != 'echo') {
1927
+			return $return['calendar_events'];
1928
+	}
1839 1929
 
1840 1930
 	foreach ($return['calendar_events'] as $event)
1841 1931
 	{
1842
-		if ($event['can_edit'])
1843
-			echo '
1932
+		if ($event['can_edit']) {
1933
+					echo '
1844 1934
 	<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1935
+		}
1845 1936
 		echo '
1846 1937
 	' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1847 1938
 	}
@@ -1856,8 +1947,9 @@  discard block
 block discarded – undo
1856 1947
 {
1857 1948
 	global $modSettings, $txt, $scripturl, $user_info;
1858 1949
 
1859
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1860
-		return;
1950
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1951
+			return;
1952
+	}
1861 1953
 
1862 1954
 	$eventOptions = array(
1863 1955
 		'include_birthdays' => allowedTo('profile_view'),
@@ -1870,19 +1962,22 @@  discard block
 block discarded – undo
1870 1962
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1871 1963
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1872 1964
 
1873
-	if ($output_method != 'echo')
1874
-		return $return;
1965
+	if ($output_method != 'echo') {
1966
+			return $return;
1967
+	}
1875 1968
 
1876
-	if (!empty($return['calendar_holidays']))
1877
-		echo '
1969
+	if (!empty($return['calendar_holidays'])) {
1970
+			echo '
1878 1971
 			<span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>';
1972
+	}
1879 1973
 	if (!empty($return['calendar_birthdays']))
1880 1974
 	{
1881 1975
 		echo '
1882 1976
 			<span class="birthday">' . $txt['birthdays_upcoming'] . '</span> ';
1883
-		foreach ($return['calendar_birthdays'] as $member)
1884
-			echo '
1977
+		foreach ($return['calendar_birthdays'] as $member) {
1978
+					echo '
1885 1979
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : '';
1980
+		}
1886 1981
 		echo '
1887 1982
 			<br>';
1888 1983
 	}
@@ -1892,9 +1987,10 @@  discard block
 block discarded – undo
1892 1987
 			<span class="event">' . $txt['events_upcoming'] . '</span> ';
1893 1988
 		foreach ($return['calendar_events'] as $event)
1894 1989
 		{
1895
-			if ($event['can_edit'])
1896
-				echo '
1990
+			if ($event['can_edit']) {
1991
+							echo '
1897 1992
 			<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1993
+			}
1898 1994
 			echo '
1899 1995
 			' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1900 1996
 		}
@@ -1918,25 +2014,29 @@  discard block
 block discarded – undo
1918 2014
 	loadLanguage('Stats');
1919 2015
 
1920 2016
 	// Must be integers....
1921
-	if ($limit === null)
1922
-		$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1923
-	else
1924
-		$limit = (int) $limit;
1925
-
1926
-	if ($start === null)
1927
-		$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1928
-	else
1929
-		$start = (int) $start;
1930
-
1931
-	if ($board !== null)
1932
-		$board = (int) $board;
1933
-	elseif (isset($_GET['board']))
1934
-		$board = (int) $_GET['board'];
1935
-
1936
-	if ($length === null)
1937
-		$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1938
-	else
1939
-		$length = (int) $length;
2017
+	if ($limit === null) {
2018
+			$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
2019
+	} else {
2020
+			$limit = (int) $limit;
2021
+	}
2022
+
2023
+	if ($start === null) {
2024
+			$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
2025
+	} else {
2026
+			$start = (int) $start;
2027
+	}
2028
+
2029
+	if ($board !== null) {
2030
+			$board = (int) $board;
2031
+	} elseif (isset($_GET['board'])) {
2032
+			$board = (int) $_GET['board'];
2033
+	}
2034
+
2035
+	if ($length === null) {
2036
+			$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
2037
+	} else {
2038
+			$length = (int) $length;
2039
+	}
1940 2040
 
1941 2041
 	$limit = max(0, $limit);
1942 2042
 	$start = max(0, $start);
@@ -1954,17 +2054,19 @@  discard block
 block discarded – undo
1954 2054
 	);
1955 2055
 	if ($smcFunc['db_num_rows']($request) == 0)
1956 2056
 	{
1957
-		if ($output_method == 'echo')
1958
-			die($txt['ssi_no_guests']);
1959
-		else
1960
-			return array();
2057
+		if ($output_method == 'echo') {
2058
+					die($txt['ssi_no_guests']);
2059
+		} else {
2060
+					return array();
2061
+		}
1961 2062
 	}
1962 2063
 	list ($board) = $smcFunc['db_fetch_row']($request);
1963 2064
 	$smcFunc['db_free_result']($request);
1964 2065
 
1965 2066
 	$icon_sources = array();
1966
-	foreach ($context['stable_icons'] as $icon)
1967
-		$icon_sources[$icon] = 'images_url';
2067
+	foreach ($context['stable_icons'] as $icon) {
2068
+			$icon_sources[$icon] = 'images_url';
2069
+	}
1968 2070
 
1969 2071
 	if (!empty($modSettings['enable_likes']))
1970 2072
 	{
@@ -1987,12 +2089,14 @@  discard block
 block discarded – undo
1987 2089
 		)
1988 2090
 	);
1989 2091
 	$posts = array();
1990
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1991
-		$posts[] = $row['id_first_msg'];
2092
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2093
+			$posts[] = $row['id_first_msg'];
2094
+	}
1992 2095
 	$smcFunc['db_free_result']($request);
1993 2096
 
1994
-	if (empty($posts))
1995
-		return array();
2097
+	if (empty($posts)) {
2098
+			return array();
2099
+	}
1996 2100
 
1997 2101
 	// Find the posts.
1998 2102
 	$request = $smcFunc['db_query']('', '
@@ -2022,26 +2126,30 @@  discard block
 block discarded – undo
2022 2126
 			$last_space = strrpos($row['body'], ' ');
2023 2127
 			$last_open = strrpos($row['body'], '<');
2024 2128
 			$last_close = strrpos($row['body'], '>');
2025
-			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6)
2026
-				$cutoff = $last_open;
2027
-			elseif (empty($last_close) || $last_close < $last_open)
2028
-				$cutoff = $last_space;
2129
+			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) {
2130
+							$cutoff = $last_open;
2131
+			} elseif (empty($last_close) || $last_close < $last_open) {
2132
+							$cutoff = $last_space;
2133
+			}
2029 2134
 
2030
-			if ($cutoff !== false)
2031
-				$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2135
+			if ($cutoff !== false) {
2136
+							$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2137
+			}
2032 2138
 			$row['body'] .= '...';
2033 2139
 		}
2034 2140
 
2035 2141
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
2036 2142
 
2037
-		if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
2038
-			$row['icon'] = 'recycled';
2143
+		if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
2144
+					$row['icon'] = 'recycled';
2145
+		}
2039 2146
 
2040 2147
 		// Check that this message icon is there...
2041
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
2042
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2043
-		elseif (!isset($icon_sources[$row['icon']]))
2044
-			$icon_sources[$row['icon']] = 'images_url';
2148
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
2149
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2150
+		} elseif (!isset($icon_sources[$row['icon']])) {
2151
+					$icon_sources[$row['icon']] = 'images_url';
2152
+		}
2045 2153
 
2046 2154
 		censorText($row['subject']);
2047 2155
 		censorText($row['body']);
@@ -2078,16 +2186,18 @@  discard block
 block discarded – undo
2078 2186
 	}
2079 2187
 	$smcFunc['db_free_result']($request);
2080 2188
 
2081
-	if (empty($return))
2082
-		return $return;
2189
+	if (empty($return)) {
2190
+			return $return;
2191
+	}
2083 2192
 
2084 2193
 	$return[count($return) - 1]['is_last'] = true;
2085 2194
 
2086 2195
 	// If mods want to do somthing with this list of posts, let them do that now.
2087 2196
 	call_integration_hook('integrate_ssi_boardNews', array(&$return));
2088 2197
 
2089
-	if ($output_method != 'echo')
2090
-		return $return;
2198
+	if ($output_method != 'echo') {
2199
+			return $return;
2200
+	}
2091 2201
 
2092 2202
 	foreach ($return as $news)
2093 2203
 	{
@@ -2139,9 +2249,10 @@  discard block
 block discarded – undo
2139 2249
 		echo '
2140 2250
 			</div>';
2141 2251
 
2142
-		if (!$news['is_last'])
2143
-			echo '
2252
+		if (!$news['is_last']) {
2253
+					echo '
2144 2254
 			<hr>';
2255
+		}
2145 2256
 	}
2146 2257
 }
2147 2258
 
@@ -2155,8 +2266,9 @@  discard block
 block discarded – undo
2155 2266
 {
2156 2267
 	global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc;
2157 2268
 
2158
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
2159
-		return;
2269
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
2270
+			return;
2271
+	}
2160 2272
 
2161 2273
 	// Find all events which are happening in the near future that the member can see.
2162 2274
 	$request = $smcFunc['db_query']('', '
@@ -2182,20 +2294,23 @@  discard block
 block discarded – undo
2182 2294
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2183 2295
 	{
2184 2296
 		// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
2185
-		if (!empty($duplicates[$row['title'] . $row['id_topic']]))
2186
-			continue;
2297
+		if (!empty($duplicates[$row['title'] . $row['id_topic']])) {
2298
+					continue;
2299
+		}
2187 2300
 
2188 2301
 		// Censor the title.
2189 2302
 		censorText($row['title']);
2190 2303
 
2191
-		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false)))
2192
-			$date = strftime('%Y-%m-%d', forum_time(false));
2193
-		else
2194
-			$date = $row['start_date'];
2304
+		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) {
2305
+					$date = strftime('%Y-%m-%d', forum_time(false));
2306
+		} else {
2307
+					$date = $row['start_date'];
2308
+		}
2195 2309
 
2196 2310
 		// If the topic it is attached to is not approved then don't link it.
2197
-		if (!empty($row['id_first_msg']) && !$row['approved'])
2198
-			$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2311
+		if (!empty($row['id_first_msg']) && !$row['approved']) {
2312
+					$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2313
+		}
2199 2314
 
2200 2315
 		$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
2201 2316
 
@@ -2221,24 +2336,27 @@  discard block
 block discarded – undo
2221 2336
 	}
2222 2337
 	$smcFunc['db_free_result']($request);
2223 2338
 
2224
-	foreach ($return as $mday => $array)
2225
-		$return[$mday][count($array) - 1]['is_last'] = true;
2339
+	foreach ($return as $mday => $array) {
2340
+			$return[$mday][count($array) - 1]['is_last'] = true;
2341
+	}
2226 2342
 
2227 2343
 	// If mods want to do somthing with this list of events, let them do that now.
2228 2344
 	call_integration_hook('integrate_ssi_recentEvents', array(&$return));
2229 2345
 
2230
-	if ($output_method != 'echo' || empty($return))
2231
-		return $return;
2346
+	if ($output_method != 'echo' || empty($return)) {
2347
+			return $return;
2348
+	}
2232 2349
 
2233 2350
 	// Well the output method is echo.
2234 2351
 	echo '
2235 2352
 			<span class="event">' . $txt['events'] . '</span> ';
2236
-	foreach ($return as $mday => $array)
2237
-		foreach ($array as $event)
2353
+	foreach ($return as $mday => $array) {
2354
+			foreach ($array as $event)
2238 2355
 		{
2239 2356
 			if ($event['can_edit'])
2240 2357
 				echo '
2241 2358
 				<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
2359
+	}
2242 2360
 
2243 2361
 			echo '
2244 2362
 				' . $event['link'] . (!$event['is_last'] ? ', ' : '');
@@ -2257,8 +2375,9 @@  discard block
 block discarded – undo
2257 2375
 	global $smcFunc;
2258 2376
 
2259 2377
 	// If $id is null, this was most likely called from a query string and should do nothing.
2260
-	if ($id === null)
2261
-		return;
2378
+	if ($id === null) {
2379
+			return;
2380
+	}
2262 2381
 
2263 2382
 	$request = $smcFunc['db_query']('', '
2264 2383
 		SELECT passwd, member_name, is_activated
@@ -2290,8 +2409,9 @@  discard block
 block discarded – undo
2290 2409
 	$attachments_boards = boardsAllowedTo('view_attachments');
2291 2410
 
2292 2411
 	// No boards?  Adios amigo.
2293
-	if (empty($attachments_boards))
2294
-		return array();
2412
+	if (empty($attachments_boards)) {
2413
+			return array();
2414
+	}
2295 2415
 
2296 2416
 	// Is it an array?
2297 2417
 	$attachment_ext = (array) $attachment_ext;
@@ -2375,8 +2495,9 @@  discard block
 block discarded – undo
2375 2495
 	call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments));
2376 2496
 
2377 2497
 	// So you just want an array?  Here you can have it.
2378
-	if ($output_method == 'array' || empty($attachments))
2379
-		return $attachments;
2498
+	if ($output_method == 'array' || empty($attachments)) {
2499
+			return $attachments;
2500
+	}
2380 2501
 
2381 2502
 	// Give them the default.
2382 2503
 	echo '
@@ -2387,14 +2508,15 @@  discard block
 block discarded – undo
2387 2508
 				<th style="text-align: left; padding: 2">', $txt['downloads'], '</th>
2388 2509
 				<th style="text-align: left; padding: 2">', $txt['filesize'], '</th>
2389 2510
 			</tr>';
2390
-	foreach ($attachments as $attach)
2391
-		echo '
2511
+	foreach ($attachments as $attach) {
2512
+			echo '
2392 2513
 			<tr>
2393 2514
 				<td>', $attach['file']['link'], '</td>
2394 2515
 				<td>', $attach['member']['link'], '</td>
2395 2516
 				<td style="text-align: center">', $attach['file']['downloads'], '</td>
2396 2517
 				<td>', $attach['file']['filesize'], '</td>
2397 2518
 			</tr>';
2519
+	}
2398 2520
 	echo '
2399 2521
 		</table>';
2400 2522
 }
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 1 patch
Braces   +551 added lines, -413 removed lines patch added patch discarded remove patch
@@ -18,23 +18,25 @@  discard block
 block discarded – undo
18 18
 	global $context;
19 19
 
20 20
 	// Prevent Chrome from auto completing fields when viewing/editing other members profiles
21
-	if (isBrowser('is_chrome') && !$context['user']['is_owner'])
22
-		echo '
21
+	if (isBrowser('is_chrome') && !$context['user']['is_owner']) {
22
+			echo '
23 23
 			<script>
24 24
 				disableAutoComplete();
25 25
 			</script>';
26
+	}
26 27
 
27 28
 	// If an error occurred while trying to save previously, give the user a clue!
28 29
 	echo '
29 30
 			', template_error_message();
30 31
 
31 32
 	// If the profile was update successfully, let the user know this.
32
-	if (!empty($context['profile_updated']))
33
-		echo '
33
+	if (!empty($context['profile_updated'])) {
34
+			echo '
34 35
 			<div class="infobox">
35 36
 				', $context['profile_updated'], '
36 37
 			</div>';
37
-}
38
+	}
39
+	}
38 40
 
39 41
 /**
40 42
  * Template for any HTML needed below the profile (closing off divs/tables, etc.)
@@ -99,19 +101,19 @@  discard block
 block discarded – undo
99 101
 		</div>
100 102
 		<div class="alerts_unread">';
101 103
 
102
-	if (empty($context['unread_alerts']))
103
-		template_alerts_all_read();
104
-
105
-	else
104
+	if (empty($context['unread_alerts'])) {
105
+			template_alerts_all_read();
106
+	} else
106 107
 	{
107
-		foreach ($context['unread_alerts'] as $id_alert => $details)
108
-			echo '
108
+		foreach ($context['unread_alerts'] as $id_alert => $details) {
109
+					echo '
109 110
 			<div class="unread">
110 111
 				', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', '
111 112
 				<div class="details">
112 113
 					', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], '
113 114
 				</div>
114 115
 			</div>';
116
+		}
115 117
 	}
116 118
 
117 119
 	echo '
@@ -158,37 +160,41 @@  discard block
 block discarded – undo
158 160
 	if (!empty($context['print_custom_fields']['above_member']))
159 161
 	{
160 162
 		$fields = '';
161
-		foreach ($context['print_custom_fields']['above_member'] as $field)
162
-			if (!empty($field['output_html']))
163
+		foreach ($context['print_custom_fields']['above_member'] as $field) {
164
+					if (!empty($field['output_html']))
163 165
 				$fields .= '
164 166
 					<li>' . $field['output_html'] . '</li>';
167
+		}
165 168
 
166
-		if (!empty($fields))
167
-			echo '
169
+		if (!empty($fields)) {
170
+					echo '
168 171
 			<div class="custom_fields_above_name">
169 172
 				<ul>', $fields, '
170 173
 				</ul>
171 174
 			</div>';
175
+		}
172 176
 	}
173 177
 
174 178
 	echo '
175 179
 			<div class="username clear">
176 180
 				<h4>';
177 181
 
178
-	if (!empty($context['print_custom_fields']['before_member']))
179
-		foreach ($context['print_custom_fields']['before_member'] as $field)
182
+	if (!empty($context['print_custom_fields']['before_member'])) {
183
+			foreach ($context['print_custom_fields']['before_member'] as $field)
180 184
 			if (!empty($field['output_html']))
181 185
 				echo '
182 186
 					<span>', $field['output_html'], '</span>';
187
+	}
183 188
 
184 189
 	echo '
185 190
 					', $context['member']['name'];
186 191
 
187
-	if (!empty($context['print_custom_fields']['after_member']))
188
-		foreach ($context['print_custom_fields']['after_member'] as $field)
192
+	if (!empty($context['print_custom_fields']['after_member'])) {
193
+			foreach ($context['print_custom_fields']['after_member'] as $field)
189 194
 			if (!empty($field['output_html']))
190 195
 				echo '
191 196
 					<span>', $field['output_html'], '</span>';
197
+	}
192 198
 
193 199
 
194 200
 	echo '
@@ -201,39 +207,44 @@  discard block
 block discarded – undo
201 207
 	if (!empty($context['print_custom_fields']['below_avatar']))
202 208
 	{
203 209
 		$fields = '';
204
-		foreach ($context['print_custom_fields']['below_avatar'] as $field)
205
-			if (!empty($field['output_html']))
210
+		foreach ($context['print_custom_fields']['below_avatar'] as $field) {
211
+					if (!empty($field['output_html']))
206 212
 				$fields .= '
207 213
 					<li>' . $field['output_html'] . '</li>';
214
+		}
208 215
 
209
-		if (!empty($fields))
210
-			echo '
216
+		if (!empty($fields)) {
217
+					echo '
211 218
 			<div class="custom_fields_below_avatar">
212 219
 				<ul>', $fields, '
213 220
 				</ul>
214 221
 			</div>';
222
+		}
215 223
 	}
216 224
 
217 225
 	echo '
218 226
 			<ul class="icon_fields clear">';
219 227
 
220 228
 	// Email is only visible if it's your profile or you have the moderate_forum permission
221
-	if ($context['member']['show_email'])
222
-		echo '
229
+	if ($context['member']['show_email']) {
230
+			echo '
223 231
 				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
232
+	}
224 233
 
225 234
 	// Don't show an icon if they haven't specified a website.
226
-	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
227
-		echo '
235
+	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) {
236
+			echo '
228 237
 				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
238
+	}
229 239
 
230 240
 	// Are there any custom profile fields as icons?
231 241
 	if (!empty($context['print_custom_fields']['icons']))
232 242
 	{
233
-		foreach ($context['print_custom_fields']['icons'] as $field)
234
-			if (!empty($field['output_html']))
243
+		foreach ($context['print_custom_fields']['icons'] as $field) {
244
+					if (!empty($field['output_html']))
235 245
 				echo '
236 246
 				<li class="custom_field">', $field['output_html'], '</li>';
247
+		}
237 248
 	}
238 249
 
239 250
 	echo '
@@ -242,24 +253,27 @@  discard block
 block discarded – undo
242 253
 				', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : '';
243 254
 
244 255
 	// Can they add this member as a buddy?
245
-	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
246
-		echo '
256
+	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) {
257
+			echo '
247 258
 				<br>
248 259
 				<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], '</a>';
260
+	}
249 261
 
250 262
 	echo '
251 263
 			</span>';
252 264
 
253
-	if (!$context['user']['is_owner'] && $context['can_send_pm'])
254
-		echo '
265
+	if (!$context['user']['is_owner'] && $context['can_send_pm']) {
266
+			echo '
255 267
 			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
268
+	}
256 269
 
257 270
 	echo '
258 271
 			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
259 272
 
260
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
261
-		echo '
273
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) {
274
+			echo '
262 275
 			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
276
+	}
263 277
 
264 278
 	echo '
265 279
 			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
@@ -268,17 +282,19 @@  discard block
 block discarded – undo
268 282
 	if (!empty($context['print_custom_fields']['bottom_poster']))
269 283
 	{
270 284
 		$fields = '';
271
-		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
272
-			if (!empty($field['output_html']))
285
+		foreach ($context['print_custom_fields']['bottom_poster'] as $field) {
286
+					if (!empty($field['output_html']))
273 287
 				$fields .= '
274 288
 					<li>' . $field['output_html'] . '</li>';
289
+		}
275 290
 
276
-		if (!empty($fields))
277
-			echo '
291
+		if (!empty($fields)) {
292
+					echo '
278 293
 			<div class="custom_fields_bottom">
279 294
 				<ul class="nolist">', $fields, '
280 295
 				</ul>
281 296
 			</div>';
297
+		}
282 298
 	}
283 299
 
284 300
 	echo '
@@ -287,30 +303,35 @@  discard block
 block discarded – undo
287 303
 		<div id="detailedinfo">
288 304
 			<dl class="settings">';
289 305
 
290
-	if ($context['user']['is_owner'] || $context['user']['is_admin'])
291
-		echo '
306
+	if ($context['user']['is_owner'] || $context['user']['is_admin']) {
307
+			echo '
292 308
 				<dt>', $txt['username'], ': </dt>
293 309
 				<dd>', $context['member']['username'], '</dd>';
310
+	}
294 311
 
295
-	if (!isset($context['disabled_fields']['posts']))
296
-		echo '
312
+	if (!isset($context['disabled_fields']['posts'])) {
313
+			echo '
297 314
 				<dt>', $txt['profile_posts'], ': </dt>
298 315
 				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
316
+	}
299 317
 
300
-	if ($context['member']['show_email'])
301
-		echo '
318
+	if ($context['member']['show_email']) {
319
+			echo '
302 320
 				<dt>', $txt['email'], ': </dt>
303 321
 				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
322
+	}
304 323
 
305
-	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
306
-		echo '
324
+	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) {
325
+			echo '
307 326
 				<dt>', $txt['custom_title'], ': </dt>
308 327
 				<dd>', $context['member']['title'], '</dd>';
328
+	}
309 329
 
310
-	if (!empty($context['member']['blurb']))
311
-		echo '
330
+	if (!empty($context['member']['blurb'])) {
331
+			echo '
312 332
 				<dt>', $txt['personal_text'], ': </dt>
313 333
 				<dd>', $context['member']['blurb'], '</dd>';
334
+	}
314 335
 
315 336
 	echo '
316 337
 				<dt>', $txt['age'], ':</dt>
@@ -324,19 +345,21 @@  discard block
 block discarded – undo
324 345
 	{
325 346
 		$fields = array();
326 347
 
327
-		foreach ($context['print_custom_fields']['standard'] as $field)
328
-			if (!empty($field['output_html']))
348
+		foreach ($context['print_custom_fields']['standard'] as $field) {
349
+					if (!empty($field['output_html']))
329 350
 				$fields[] = $field;
351
+		}
330 352
 
331 353
 		if (count($fields) > 0)
332 354
 		{
333 355
 			echo '
334 356
 			<dl class="settings">';
335 357
 
336
-			foreach ($fields as $field)
337
-				echo '
358
+			foreach ($fields as $field) {
359
+							echo '
338 360
 				<dt>', $field['name'], ':</dt>
339 361
 				<dd>', $field['output_html'], '</dd>';
362
+			}
340 363
 
341 364
 			echo '
342 365
 			</dl>';
@@ -355,9 +378,10 @@  discard block
 block discarded – undo
355 378
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
356 379
 
357 380
 		// Can we provide information on what this means?
358
-		if (!empty($context['warning_status']))
359
-			echo '
381
+		if (!empty($context['warning_status'])) {
382
+					echo '
360 383
 					<span class="smalltext">(', $context['warning_status'], ')</span>';
384
+		}
361 385
 
362 386
 		echo '
363 387
 				</dd>';
@@ -367,11 +391,12 @@  discard block
 block discarded – undo
367 391
 	if (!empty($context['activate_message']) || !empty($context['member']['bans']))
368 392
 	{
369 393
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
370
-		if (!empty($context['activate_message']))
371
-			echo '
394
+		if (!empty($context['activate_message'])) {
395
+					echo '
372 396
 				<dt class="clear">
373 397
 					<span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)
374 398
 				</dt>';
399
+		}
375 400
 
376 401
 		// If the current member is banned, show a message and possibly a link to the ban.
377 402
 		if (!empty($context['member']['bans']))
@@ -383,10 +408,11 @@  discard block
 block discarded – undo
383 408
 				<dt class="clear hidden" id="ban_info">
384 409
 					<strong>', $txt['user_banned_by_following'], ':</strong>';
385 410
 
386
-			foreach ($context['member']['bans'] as $ban)
387
-				echo '
411
+			foreach ($context['member']['bans'] as $ban) {
412
+							echo '
388 413
 					<br>
389 414
 					<span class="smalltext">', $ban['explanation'], '</span>';
415
+			}
390 416
 
391 417
 			echo '
392 418
 				</dt>';
@@ -400,30 +426,34 @@  discard block
 block discarded – undo
400 426
 	// If the person looking is allowed, they can check the members IP address and hostname.
401 427
 	if ($context['can_see_ip'])
402 428
 	{
403
-		if (!empty($context['member']['ip']))
404
-		echo '
429
+		if (!empty($context['member']['ip'])) {
430
+				echo '
405 431
 				<dt>', $txt['ip'], ': </dt>
406 432
 				<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
433
+		}
407 434
 
408
-		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
409
-			echo '
435
+		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) {
436
+					echo '
410 437
 				<dt>', $txt['hostname'], ': </dt>
411 438
 				<dd>', $context['member']['hostname'], '</dd>';
439
+		}
412 440
 	}
413 441
 
414 442
 	echo '
415 443
 				<dt>', $txt['local_time'], ':</dt>
416 444
 				<dd>', $context['member']['local_time'], '</dd>';
417 445
 
418
-	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
419
-		echo '
446
+	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) {
447
+			echo '
420 448
 				<dt>', $txt['language'], ':</dt>
421 449
 				<dd>', $context['member']['language'], '</dd>';
450
+	}
422 451
 
423
-	if ($context['member']['show_last_login'])
424
-		echo '
452
+	if ($context['member']['show_last_login']) {
453
+			echo '
425 454
 				<dt>', $txt['lastLoggedIn'], ': </dt>
426 455
 				<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
456
+	}
427 457
 
428 458
 	echo '
429 459
 			</dl>';
@@ -432,42 +462,47 @@  discard block
 block discarded – undo
432 462
 	if (!empty($context['print_custom_fields']['above_signature']))
433 463
 	{
434 464
 		$fields = '';
435
-		foreach ($context['print_custom_fields']['above_signature'] as $field)
436
-			if (!empty($field['output_html']))
465
+		foreach ($context['print_custom_fields']['above_signature'] as $field) {
466
+					if (!empty($field['output_html']))
437 467
 				$fields .= '
438 468
 					<li>' . $field['output_html'] . '</li>';
469
+		}
439 470
 
440
-		if (!empty($fields))
441
-			echo '
471
+		if (!empty($fields)) {
472
+					echo '
442 473
 			<div class="custom_fields_above_signature">
443 474
 				<ul class="nolist">', $fields, '
444 475
 				</ul>
445 476
 			</div>';
477
+		}
446 478
 	}
447 479
 
448 480
 	// Show the users signature.
449
-	if ($context['signature_enabled'] && !empty($context['member']['signature']))
450
-		echo '
481
+	if ($context['signature_enabled'] && !empty($context['member']['signature'])) {
482
+			echo '
451 483
 			<div class="signature">
452 484
 				<h5>', $txt['signature'], ':</h5>
453 485
 				', $context['member']['signature'], '
454 486
 			</div>';
487
+	}
455 488
 
456 489
 	// Are there any custom profile fields for below the signature?
457 490
 	if (!empty($context['print_custom_fields']['below_signature']))
458 491
 	{
459 492
 		$fields = '';
460
-		foreach ($context['print_custom_fields']['below_signature'] as $field)
461
-			if (!empty($field['output_html']))
493
+		foreach ($context['print_custom_fields']['below_signature'] as $field) {
494
+					if (!empty($field['output_html']))
462 495
 				$fields .=  '
463 496
 					<li>' . $field['output_html'] . '</li>';
497
+		}
464 498
 
465
-		if (!empty($fields))
466
-			echo '
499
+		if (!empty($fields)) {
500
+					echo '
467 501
 			<div class="custom_fields_below_signature">
468 502
 				<ul class="nolist">', $fields, '
469 503
 				</ul>
470 504
 			</div>';
505
+		}
471 506
 	}
472 507
 
473 508
 	echo '
@@ -509,62 +544,70 @@  discard block
 block discarded – undo
509 544
 			</div>
510 545
 			<div class="list_posts">';
511 546
 
512
-			if (!$post['approved'])
513
-				echo '
547
+			if (!$post['approved']) {
548
+							echo '
514 549
 				<div class="approve_post">
515 550
 					<em>', $txt['post_awaiting_approval'], '</em>
516 551
 				</div>';
552
+			}
517 553
 
518 554
 			echo '
519 555
 				', $post['body'], '
520 556
 			</div>';
521 557
 
522
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
523
-				echo '
558
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
559
+							echo '
524 560
 			<div class="floatright">
525 561
 				<ul class="quickbuttons">';
562
+			}
526 563
 
527 564
 			// If they *can* reply?
528
-			if ($post['can_reply'])
529
-				echo '
565
+			if ($post['can_reply']) {
566
+							echo '
530 567
 					<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
568
+			}
531 569
 
532 570
 			// If they *can* quote?
533
-			if ($post['can_quote'])
534
-				echo '
571
+			if ($post['can_quote']) {
572
+							echo '
535 573
 					<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
574
+			}
536 575
 
537 576
 			// How about... even... remove it entirely?!
538
-			if ($post['can_delete'])
539
-				echo '
577
+			if ($post['can_delete']) {
578
+							echo '
540 579
 					<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
580
+			}
541 581
 
542
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
543
-				echo '
582
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
583
+							echo '
544 584
 				</ul>
545 585
 			</div><!-- .floatright -->';
586
+			}
546 587
 
547 588
 			echo '
548 589
 		</div><!-- $post[css_class] -->';
549 590
 		}
591
+	} else {
592
+			template_show_list('attachments');
550 593
 	}
551
-	else
552
-		template_show_list('attachments');
553 594
 
554 595
 	// No posts? Just end with a informative message.
555
-	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
556
-		echo '
596
+	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) {
597
+			echo '
557 598
 		<div class="windowbg">
558 599
 			', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
559 600
 		</div>';
601
+	}
560 602
 
561 603
 	// Show more page numbers.
562
-	if (!empty($context['page_index']))
563
-		echo '
604
+	if (!empty($context['page_index'])) {
605
+			echo '
564 606
 		<div class="pagesection">
565 607
 			<div class="pagelinks">', $context['page_index'], '</div>
566 608
 		</div>';
567
-}
609
+	}
610
+	}
568 611
 
569 612
 /**
570 613
  * Template for showing alerts within the alerts popup
@@ -574,11 +617,12 @@  discard block
 block discarded – undo
574 617
 	global $context, $txt, $scripturl;
575 618
 
576 619
 	// Do we have an update message?
577
-	if (!empty($context['update_message']))
578
-		echo '
620
+	if (!empty($context['update_message'])) {
621
+			echo '
579 622
 		<div class="infobox">
580 623
 			', $context['update_message'], '
581 624
 		</div>';
625
+	}
582 626
 
583 627
 	echo '
584 628
 		<div class="cat_bar">
@@ -587,18 +631,18 @@  discard block
 block discarded – undo
587 631
 			</h3>
588 632
 		</div>';
589 633
 
590
-	if (empty($context['alerts']))
591
-		echo '
634
+	if (empty($context['alerts'])) {
635
+			echo '
592 636
 		<div class="information">
593 637
 			', $txt['alerts_none'], '
594 638
 		</div>';
595
-
596
-	else
639
+	} else
597 640
 	{
598 641
 		// Start the form if checkboxes are in use
599
-		if ($context['showCheckboxes'])
600
-			echo '
642
+		if ($context['showCheckboxes']) {
643
+					echo '
601 644
 		<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">';
645
+		}
602 646
 
603 647
 		echo '
604 648
 			<table id="alerts" class="table_grid">';
@@ -617,9 +661,10 @@  discard block
 block discarded – undo
617 661
 							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>
618 662
 							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>';
619 663
 
620
-					if ($context['showCheckboxes'])
621
-						echo '
664
+					if ($context['showCheckboxes']) {
665
+											echo '
622 666
 							<li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>';
667
+					}
623 668
 
624 669
 			echo '
625 670
 						</ul>
@@ -634,8 +679,8 @@  discard block
 block discarded – undo
634 679
 					', $context['pagination'], '
635 680
 				</div>';
636 681
 
637
-		if ($context['showCheckboxes'])
638
-			echo '
682
+		if ($context['showCheckboxes']) {
683
+					echo '
639 684
 				<div class="floatright">
640 685
 					', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all">
641 686
 					<select name="mark_as">
@@ -646,14 +691,16 @@  discard block
 block discarded – undo
646 691
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
647 692
 					<input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure">
648 693
 				</div>';
694
+		}
649 695
 
650 696
 	echo '
651 697
 			</div>';
652 698
 
653
-	if ($context['showCheckboxes'])
654
-		echo '
699
+	if ($context['showCheckboxes']) {
700
+			echo '
655 701
 		</form>';
656 702
 	}
703
+	}
657 704
 }
658 705
 
659 706
 /**
@@ -674,12 +721,12 @@  discard block
 block discarded – undo
674 721
 		</div>' : '';
675 722
 
676 723
 	// No drafts? Just show an informative message.
677
-	if (empty($context['drafts']))
678
-		echo '
724
+	if (empty($context['drafts'])) {
725
+			echo '
679 726
 		<div class="windowbg centertext">
680 727
 			', $txt['draft_none'], '
681 728
 		</div>';
682
-	else
729
+	} else
683 730
 	{
684 731
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
685 732
 		foreach ($context['drafts'] as $draft)
@@ -691,13 +738,15 @@  discard block
 block discarded – undo
691 738
 				<h5>
692 739
 					<strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
693 740
 
694
-			if (!empty($draft['sticky']))
695
-				echo '
741
+			if (!empty($draft['sticky'])) {
742
+							echo '
696 743
 					<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
744
+			}
697 745
 
698
-			if (!empty($draft['locked']))
699
-				echo '
746
+			if (!empty($draft['locked'])) {
747
+							echo '
700 748
 					<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
749
+			}
701 750
 
702 751
 			echo '
703 752
 				</h5>
@@ -730,13 +779,13 @@  discard block
 block discarded – undo
730 779
 {
731 780
 	global $context, $scripturl, $txt;
732 781
 
733
-	if (!empty($context['saved_successful']))
734
-		echo '
782
+	if (!empty($context['saved_successful'])) {
783
+			echo '
735 784
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
736
-
737
-	elseif (!empty($context['saved_failed']))
738
-		echo '
785
+	} elseif (!empty($context['saved_failed'])) {
786
+			echo '
739 787
 	<div class="errorbox">', $context['saved_failed'], '</div>';
788
+	}
740 789
 
741 790
 	echo '
742 791
 	<div id="edit_buddies">
@@ -751,14 +800,16 @@  discard block
 block discarded – undo
751 800
 					<th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th>
752 801
 					<th scope="col" class="buddy_status">', $txt['status'], '</th>';
753 802
 
754
-	if ($context['can_moderate_forum'])
755
-		echo '
803
+	if ($context['can_moderate_forum']) {
804
+			echo '
756 805
 					<th scope="col" class="buddy_email">', $txt['email'], '</th>';
806
+	}
757 807
 
758
-	if (!empty($context['custom_pf']))
759
-		foreach ($context['custom_pf'] as $column)
808
+	if (!empty($context['custom_pf'])) {
809
+			foreach ($context['custom_pf'] as $column)
760 810
 				echo '
761 811
 					<th scope="col" class="buddy_custom_fields">', $column['label'], '</th>';
812
+	}
762 813
 
763 814
 	echo '
764 815
 					<th scope="col" class="buddy_remove">', $txt['remove'], '</th>
@@ -767,13 +818,14 @@  discard block
 block discarded – undo
767 818
 			<tbody>';
768 819
 
769 820
 	// If they don't have any buddies don't list them!
770
-	if (empty($context['buddies']))
771
-		echo '
821
+	if (empty($context['buddies'])) {
822
+			echo '
772 823
 				<tr class="windowbg">
773 824
 					<td colspan="', $context['can_moderate_forum'] ? '10' : '9', '">
774 825
 						<strong>', $txt['no_buddies'], '</strong>
775 826
 					</td>
776 827
 				</tr>';
828
+	}
777 829
 
778 830
 		// Now loop through each buddy showing info on each.
779 831
 	else
@@ -787,17 +839,19 @@  discard block
 block discarded – undo
787 839
 						<a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a>
788 840
 					</td>';
789 841
 
790
-			if ($buddy['show_email'])
791
-				echo '
842
+			if ($buddy['show_email']) {
843
+							echo '
792 844
 					<td class="buddy_email centertext">
793 845
 						<a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>
794 846
 					</td>';
847
+			}
795 848
 
796 849
 			// Show the custom profile fields for this user.
797
-			if (!empty($context['custom_pf']))
798
-				foreach ($context['custom_pf'] as $key => $column)
850
+			if (!empty($context['custom_pf'])) {
851
+							foreach ($context['custom_pf'] as $key => $column)
799 852
 					echo '
800 853
 					<td class="lefttext buddy_custom_fields">', $buddy['options'][$key], '</td>';
854
+			}
801 855
 
802 856
 			echo '
803 857
 					<td class="centertext buddy_remove">
@@ -830,9 +884,10 @@  discard block
 block discarded – undo
830 884
 			</dl>
831 885
 		</div>';
832 886
 
833
-	if (!empty($context['token_check']))
834
-		echo '
887
+	if (!empty($context['token_check'])) {
888
+			echo '
835 889
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
890
+	}
836 891
 
837 892
 	echo '
838 893
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -858,13 +913,13 @@  discard block
 block discarded – undo
858 913
 {
859 914
 	global $context, $scripturl, $txt;
860 915
 
861
-	if (!empty($context['saved_successful']))
862
-		echo '
916
+	if (!empty($context['saved_successful'])) {
917
+			echo '
863 918
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
864
-
865
-	elseif (!empty($context['saved_failed']))
866
-		echo '
919
+	} elseif (!empty($context['saved_failed'])) {
920
+			echo '
867 921
 	<div class="errorbox">', $context['saved_failed'], '</div>';
922
+	}
868 923
 
869 924
 	echo '
870 925
 	<div id="edit_buddies">
@@ -879,9 +934,10 @@  discard block
 block discarded – undo
879 934
 					<th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th>
880 935
 					<th scope="col" class="buddy_status">', $txt['status'], '</th>';
881 936
 
882
-	if ($context['can_moderate_forum'])
883
-		echo '
937
+	if ($context['can_moderate_forum']) {
938
+			echo '
884 939
 					<th scope="col" class="buddy_email">', $txt['email'], '</th>';
940
+	}
885 941
 
886 942
 	echo '
887 943
 					<th scope="col" class="buddy_remove">', $txt['ignore_remove'], '</th>
@@ -890,13 +946,14 @@  discard block
 block discarded – undo
890 946
 			<tbody>';
891 947
 
892 948
 	// If they don't have anyone on their ignore list, don't list it!
893
-	if (empty($context['ignore_list']))
894
-		echo '
949
+	if (empty($context['ignore_list'])) {
950
+			echo '
895 951
 				<tr class="windowbg">
896 952
 					<td colspan="', $context['can_moderate_forum'] ? '4' : '3', '">
897 953
 						<strong>', $txt['no_ignore'], '</strong>
898 954
 					</td>
899 955
 				</tr>';
956
+	}
900 957
 
901 958
 	// Now loop through each buddy showing info on each.
902 959
 	foreach ($context['ignore_list'] as $member)
@@ -908,11 +965,12 @@  discard block
 block discarded – undo
908 965
 						<a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a>
909 966
 					</td>';
910 967
 
911
-		if ($context['can_moderate_forum'])
912
-			echo '
968
+		if ($context['can_moderate_forum']) {
969
+					echo '
913 970
 					<td class="centertext buddy_email">
914 971
 						<a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>
915 972
 					</td>';
973
+		}
916 974
 		echo '
917 975
 					<td class="centertext buddy_remove">
918 976
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a>
@@ -943,9 +1001,10 @@  discard block
 block discarded – undo
943 1001
 			</dl>
944 1002
 		</div>';
945 1003
 
946
-	if (!empty($context['token_check']))
947
-		echo '
1004
+	if (!empty($context['token_check'])) {
1005
+			echo '
948 1006
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1007
+	}
949 1008
 
950 1009
 	echo '
951 1010
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -990,9 +1049,10 @@  discard block
 block discarded – undo
990 1049
 					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
991 1050
 
992 1051
 	// Second address detected?
993
-	if (!empty($context['last_ip2']))
994
-		echo '
1052
+	if (!empty($context['last_ip2'])) {
1053
+			echo '
995 1054
 					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
1055
+	}
996 1056
 
997 1057
 	echo '
998 1058
 				</dd>';
@@ -1058,9 +1118,10 @@  discard block
 block discarded – undo
1058 1118
 		</div>
1059 1119
 		<div class="windowbg">';
1060 1120
 
1061
-		foreach ($context['whois_servers'] as $server)
1062
-			echo '
1121
+		foreach ($context['whois_servers'] as $server) {
1122
+					echo '
1063 1123
 			<a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>';
1124
+		}
1064 1125
 		echo '
1065 1126
 		</div>
1066 1127
 		<br>';
@@ -1072,13 +1133,12 @@  discard block
 block discarded – undo
1072 1133
 			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1073 1134
 		</div>';
1074 1135
 
1075
-	if (empty($context['ips']))
1076
-		echo '
1136
+	if (empty($context['ips'])) {
1137
+			echo '
1077 1138
 		<p class="windowbg description">
1078 1139
 			<em>', $txt['no_members_from_ip'], '</em>
1079 1140
 		</p>';
1080
-
1081
-	else
1141
+	} else
1082 1142
 	{
1083 1143
 		echo '
1084 1144
 		<table class="table_grid">
@@ -1091,12 +1151,13 @@  discard block
 block discarded – undo
1091 1151
 			<tbody>';
1092 1152
 
1093 1153
 		// Loop through each of the members and display them.
1094
-		foreach ($context['ips'] as $ip => $memberlist)
1095
-			echo '
1154
+		foreach ($context['ips'] as $ip => $memberlist) {
1155
+					echo '
1096 1156
 				<tr class="windowbg">
1097 1157
 					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1098 1158
 					<td>', implode(', ', $memberlist), '</td>
1099 1159
 				</tr>';
1160
+		}
1100 1161
 
1101 1162
 		echo '
1102 1163
 			</tbody>
@@ -1138,11 +1199,10 @@  discard block
 block discarded – undo
1138 1199
 			</h3>
1139 1200
 		</div>';
1140 1201
 
1141
-	if ($context['member']['has_all_permissions'])
1142
-		echo '
1202
+	if ($context['member']['has_all_permissions']) {
1203
+			echo '
1143 1204
 		<div class="information">', $txt['showPermissions_all'], '</div>';
1144
-
1145
-	else
1205
+	} else
1146 1206
 	{
1147 1207
 		echo '
1148 1208
 		<div class="information">',$txt['showPermissions_help'], '</div>
@@ -1157,9 +1217,10 @@  discard block
 block discarded – undo
1157 1217
 			<div class="windowbg smalltext">
1158 1218
 				', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1159 1219
 
1160
-			foreach ($context['no_access_boards'] as $no_access_board)
1161
-				echo '
1220
+			foreach ($context['no_access_boards'] as $no_access_board) {
1221
+							echo '
1162 1222
 				<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1223
+			}
1163 1224
 			echo '
1164 1225
 			</div>';
1165 1226
 		}
@@ -1191,12 +1252,13 @@  discard block
 block discarded – undo
1191 1252
 							</td>
1192 1253
 							<td class="smalltext">';
1193 1254
 
1194
-				if ($permission['is_denied'])
1195
-					echo '
1255
+				if ($permission['is_denied']) {
1256
+									echo '
1196 1257
 								<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1197
-				else
1198
-					echo '
1258
+				} else {
1259
+									echo '
1199 1260
 								', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1261
+				}
1200 1262
 
1201 1263
 				echo '
1202 1264
 							</td>
@@ -1207,10 +1269,10 @@  discard block
 block discarded – undo
1207 1269
 				</table>
1208 1270
 			</div><!-- .tborder -->
1209 1271
 			<br>';
1210
-		}
1211
-		else
1212
-			echo '
1272
+		} else {
1273
+					echo '
1213 1274
 			<p class="windowbg">', $txt['showPermissions_none_general'], '</p>';
1275
+		}
1214 1276
 
1215 1277
 		// Board permission section.
1216 1278
 		echo '
@@ -1221,14 +1283,16 @@  discard block
 block discarded – undo
1221 1283
 						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1222 1284
 							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>';
1223 1285
 
1224
-		if (!empty($context['boards']))
1225
-			echo '
1286
+		if (!empty($context['boards'])) {
1287
+					echo '
1226 1288
 							<option value="" disabled>---------------------------</option>';
1289
+		}
1227 1290
 
1228 1291
 		// Fill the box with any local permission boards.
1229
-		foreach ($context['boards'] as $board)
1230
-			echo '
1292
+		foreach ($context['boards'] as $board) {
1293
+					echo '
1231 1294
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1295
+		}
1232 1296
 
1233 1297
 		echo '
1234 1298
 						</select>
@@ -1257,13 +1321,13 @@  discard block
 block discarded – undo
1257 1321
 						</td>
1258 1322
 						<td class="smalltext">';
1259 1323
 
1260
-				if ($permission['is_denied'])
1261
-					echo '
1324
+				if ($permission['is_denied']) {
1325
+									echo '
1262 1326
 							<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1263
-
1264
-				else
1265
-					echo '
1327
+				} else {
1328
+									echo '
1266 1329
 							', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1330
+				}
1267 1331
 
1268 1332
 				echo '
1269 1333
 						</td>
@@ -1272,10 +1336,10 @@  discard block
 block discarded – undo
1272 1336
 			echo '
1273 1337
 				</tbody>
1274 1338
 			</table>';
1275
-		}
1276
-		else
1277
-			echo '
1339
+		} else {
1340
+					echo '
1278 1341
 			<p class="windowbg">', $txt['showPermissions_none_board'], '</p>';
1342
+		}
1279 1343
 	echo '
1280 1344
 		</div><!-- #permissions -->';
1281 1345
 	}
@@ -1299,12 +1363,13 @@  discard block
 block discarded – undo
1299 1363
 		echo '
1300 1364
 				<dt>', $txt['statPanel_' . $key], '</dt>';
1301 1365
 
1302
-		if (!empty($stat['url']))
1303
-			echo '
1366
+		if (!empty($stat['url'])) {
1367
+					echo '
1304 1368
 				<dd><a href="', $stat['url'], '">', $stat['text'], '</a></dd>';
1305
-		else
1306
-			echo '
1369
+		} else {
1370
+					echo '
1307 1371
 				<dd>', $stat['text'], '</dd>';
1372
+		}
1308 1373
 	}
1309 1374
 
1310 1375
 	echo '
@@ -1321,9 +1386,10 @@  discard block
 block discarded – undo
1321 1386
 			</div>';
1322 1387
 
1323 1388
 	// If they haven't post at all, don't draw the graph.
1324
-	if (empty($context['posts_by_time']))
1325
-		echo '
1389
+	if (empty($context['posts_by_time'])) {
1390
+			echo '
1326 1391
 			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1392
+	}
1327 1393
 
1328 1394
 	// Otherwise do!
1329 1395
 	else
@@ -1332,8 +1398,8 @@  discard block
 block discarded – undo
1332 1398
 			<ul class="activity_stats flow_hidden">';
1333 1399
 
1334 1400
 		// The labels.
1335
-		foreach ($context['posts_by_time'] as $time_of_day)
1336
-			echo '
1401
+		foreach ($context['posts_by_time'] as $time_of_day) {
1402
+					echo '
1337 1403
 				<li>
1338 1404
 					<div class="generic_bar vertical">
1339 1405
 						<div class="bar" style="height: ', (int) $time_of_day['relative_percent'], '%;">
@@ -1342,6 +1408,7 @@  discard block
 block discarded – undo
1342 1408
 					</div>
1343 1409
 					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1344 1410
 				</li>';
1411
+		}
1345 1412
 
1346 1413
 		echo '
1347 1414
 			</ul>';
@@ -1360,11 +1427,10 @@  discard block
 block discarded – undo
1360 1427
 					</h3>
1361 1428
 				</div>';
1362 1429
 
1363
-	if (empty($context['popular_boards']))
1364
-		echo '
1430
+	if (empty($context['popular_boards'])) {
1431
+			echo '
1365 1432
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1366
-
1367
-	else
1433
+	} else
1368 1434
 	{
1369 1435
 		echo '
1370 1436
 				<dl class="stats">';
@@ -1394,10 +1460,10 @@  discard block
 block discarded – undo
1394 1460
 					</h3>
1395 1461
 				</div>';
1396 1462
 
1397
-	if (empty($context['board_activity']))
1398
-		echo '
1463
+	if (empty($context['board_activity'])) {
1464
+			echo '
1399 1465
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1400
-	else
1466
+	} else
1401 1467
 	{
1402 1468
 		echo '
1403 1469
 				<dl class="stats">';
@@ -1448,90 +1514,97 @@  discard block
 block discarded – undo
1448 1514
 				<h3 class="catbg profile_hd">';
1449 1515
 
1450 1516
 		// Don't say "Profile" if this isn't the profile...
1451
-		if (!empty($context['profile_header_text']))
1452
-			echo '
1517
+		if (!empty($context['profile_header_text'])) {
1518
+					echo '
1453 1519
 					', $context['profile_header_text'];
1454
-		else
1455
-			echo '
1520
+		} else {
1521
+					echo '
1456 1522
 					', $txt['profile'];
1523
+		}
1457 1524
 
1458 1525
 		echo '
1459 1526
 				</h3>
1460 1527
 			</div>';
1461 1528
 
1462 1529
 	// Have we some description?
1463
-	if ($context['page_desc'])
1464
-		echo '
1530
+	if ($context['page_desc']) {
1531
+			echo '
1465 1532
 			<p class="information">', $context['page_desc'], '</p>';
1533
+	}
1466 1534
 
1467 1535
 	echo '
1468 1536
 			<div class="roundframe">';
1469 1537
 
1470 1538
 	// Any bits at the start?
1471
-	if (!empty($context['profile_prehtml']))
1472
-		echo '
1539
+	if (!empty($context['profile_prehtml'])) {
1540
+			echo '
1473 1541
 				<div>', $context['profile_prehtml'], '</div>';
1542
+	}
1474 1543
 
1475
-	if (!empty($context['profile_fields']))
1476
-		echo '
1544
+	if (!empty($context['profile_fields'])) {
1545
+			echo '
1477 1546
 				<dl class="settings">';
1547
+	}
1478 1548
 
1479 1549
 	// Start the big old loop 'of love.
1480 1550
 	$lastItem = 'hr';
1481 1551
 	foreach ($context['profile_fields'] as $key => $field)
1482 1552
 	{
1483 1553
 		// We add a little hack to be sure we never get more than one hr in a row!
1484
-		if ($lastItem == 'hr' && $field['type'] == 'hr')
1485
-			continue;
1554
+		if ($lastItem == 'hr' && $field['type'] == 'hr') {
1555
+					continue;
1556
+		}
1486 1557
 
1487 1558
 		$lastItem = $field['type'];
1488
-		if ($field['type'] == 'hr')
1489
-			echo '
1559
+		if ($field['type'] == 'hr') {
1560
+					echo '
1490 1561
 				</dl>
1491 1562
 				<hr>
1492 1563
 				<dl class="settings">';
1493
-
1494
-		elseif ($field['type'] == 'callback')
1564
+		} elseif ($field['type'] == 'callback')
1495 1565
 		{
1496 1566
 			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1497 1567
 			{
1498 1568
 				$callback_func = 'template_profile_' . $field['callback_func'];
1499 1569
 				$callback_func();
1500 1570
 			}
1501
-		}
1502
-		else
1571
+		} else
1503 1572
 		{
1504 1573
 			echo '
1505 1574
 					<dt>
1506 1575
 						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1507 1576
 
1508 1577
 			// Does it have any subtext to show?
1509
-			if (!empty($field['subtext']))
1510
-				echo '
1578
+			if (!empty($field['subtext'])) {
1579
+							echo '
1511 1580
 						<br>
1512 1581
 						<span class="smalltext">', $field['subtext'], '</span>';
1582
+			}
1513 1583
 
1514 1584
 			echo '
1515 1585
 					</dt>
1516 1586
 					<dd>';
1517 1587
 
1518 1588
 			// Want to put something infront of the box?
1519
-			if (!empty($field['preinput']))
1520
-				echo '
1589
+			if (!empty($field['preinput'])) {
1590
+							echo '
1521 1591
 						', $field['preinput'];
1592
+			}
1522 1593
 
1523 1594
 			// What type of data are we showing?
1524
-			if ($field['type'] == 'label')
1525
-				echo '
1595
+			if ($field['type'] == 'label') {
1596
+							echo '
1526 1597
 						', $field['value'];
1598
+			}
1527 1599
 
1528 1600
 			// Maybe it's a text box - very likely!
1529 1601
 			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1530 1602
 			{
1531
-				if ($field['type'] == 'int' || $field['type'] == 'float')
1532
-					$type = 'number';
1533
-				else
1534
-					$type = $field['type'];
1603
+				if ($field['type'] == 'int' || $field['type'] == 'float') {
1604
+									$type = 'number';
1605
+				} else {
1606
+									$type = $field['type'];
1607
+				}
1535 1608
 				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1536 1609
 
1537 1610
 
@@ -1539,10 +1612,11 @@  discard block
 block discarded – undo
1539 1612
 						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1540 1613
 			}
1541 1614
 			// You "checking" me out? ;)
1542
-			elseif ($field['type'] == 'check')
1543
-				echo '
1615
+			elseif ($field['type'] == 'check') {
1616
+							echo '
1544 1617
 						<input type="hidden" name="', $key, '" value="0">
1545 1618
 						<input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1619
+			}
1546 1620
 
1547 1621
 			// Always fun - select boxes!
1548 1622
 			elseif ($field['type'] == 'select')
@@ -1553,14 +1627,16 @@  discard block
 block discarded – undo
1553 1627
 				if (isset($field['options']))
1554 1628
 				{
1555 1629
 					// Is this some code to generate the options?
1556
-					if (!is_array($field['options']))
1557
-						$field['options'] = $field['options']();
1630
+					if (!is_array($field['options'])) {
1631
+											$field['options'] = $field['options']();
1632
+					}
1558 1633
 
1559 1634
 					// Assuming we now have some!
1560
-					if (is_array($field['options']))
1561
-						foreach ($field['options'] as $value => $name)
1635
+					if (is_array($field['options'])) {
1636
+											foreach ($field['options'] as $value => $name)
1562 1637
 							echo '
1563 1638
 							<option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>';
1639
+					}
1564 1640
 				}
1565 1641
 
1566 1642
 				echo '
@@ -1568,31 +1644,34 @@  discard block
 block discarded – undo
1568 1644
 			}
1569 1645
 
1570 1646
 			// Something to end with?
1571
-			if (!empty($field['postinput']))
1572
-				echo '
1647
+			if (!empty($field['postinput'])) {
1648
+							echo '
1573 1649
 						', $field['postinput'];
1650
+			}
1574 1651
 
1575 1652
 			echo '
1576 1653
 					</dd>';
1577 1654
 		}
1578 1655
 	}
1579 1656
 
1580
-	if (!empty($context['profile_fields']))
1581
-		echo '
1657
+	if (!empty($context['profile_fields'])) {
1658
+			echo '
1582 1659
 				</dl>';
1660
+	}
1583 1661
 
1584 1662
 	// Are there any custom profile fields - if so print them!
1585 1663
 	if (!empty($context['custom_fields']))
1586 1664
 	{
1587
-		if ($lastItem != 'hr')
1588
-			echo '
1665
+		if ($lastItem != 'hr') {
1666
+					echo '
1589 1667
 				<hr>';
1668
+		}
1590 1669
 
1591 1670
 		echo '
1592 1671
 				<dl class="settings">';
1593 1672
 
1594
-		foreach ($context['custom_fields'] as $field)
1595
-			echo '
1673
+		foreach ($context['custom_fields'] as $field) {
1674
+					echo '
1596 1675
 					<dt>
1597 1676
 						<strong>', $field['name'], ': </strong><br>
1598 1677
 						<span class="smalltext">', $field['desc'], '</span>
@@ -1600,19 +1679,21 @@  discard block
 block discarded – undo
1600 1679
 					<dd>
1601 1680
 						', $field['input_html'], '
1602 1681
 					</dd>';
1682
+		}
1603 1683
 
1604 1684
 		echo '
1605 1685
 				</dl>';
1606 1686
 	}
1607 1687
 
1608 1688
 	// Any closing HTML?
1609
-	if (!empty($context['profile_posthtml']))
1610
-		echo '
1689
+	if (!empty($context['profile_posthtml'])) {
1690
+			echo '
1611 1691
 				<div>', $context['profile_posthtml'], '</div>';
1692
+	}
1612 1693
 
1613 1694
 	// Only show the password box if it's actually needed.
1614
-	if ($context['require_password'])
1615
-		echo '
1695
+	if ($context['require_password']) {
1696
+			echo '
1616 1697
 				<dl class="settings">
1617 1698
 					<dt>
1618 1699
 						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
@@ -1622,18 +1703,21 @@  discard block
 block discarded – undo
1622 1703
 						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1623 1704
 					</dd>
1624 1705
 				</dl>';
1706
+	}
1625 1707
 
1626 1708
 	// The button shouldn't say "Change profile" unless we're changing the profile...
1627
-	if (!empty($context['submit_button_text']))
1628
-		echo '
1709
+	if (!empty($context['submit_button_text'])) {
1710
+			echo '
1629 1711
 				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">';
1630
-	else
1631
-		echo '
1712
+	} else {
1713
+			echo '
1632 1714
 				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">';
1715
+	}
1633 1716
 
1634
-	if (!empty($context['token_check']))
1635
-		echo '
1717
+	if (!empty($context['token_check'])) {
1718
+			echo '
1636 1719
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1720
+	}
1637 1721
 
1638 1722
 	echo '
1639 1723
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1643,10 +1727,11 @@  discard block
 block discarded – undo
1643 1727
 		</form>';
1644 1728
 
1645 1729
 	// Any final spellchecking stuff?
1646
-	if (!empty($context['show_spellchecking']))
1647
-		echo '
1730
+	if (!empty($context['show_spellchecking'])) {
1731
+			echo '
1648 1732
 		<form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>';
1649
-}
1733
+	}
1734
+	}
1650 1735
 
1651 1736
 /**
1652 1737
  * Personal Message settings.
@@ -1683,10 +1768,11 @@  discard block
 block discarded – undo
1683 1768
 						<select name="pm_receive_from" id="pm_receive_from">
1684 1769
 							<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1685 1770
 
1686
-	if (!empty($modSettings['enable_buddylist']))
1687
-		echo '
1771
+	if (!empty($modSettings['enable_buddylist'])) {
1772
+			echo '
1688 1773
 							<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1689 1774
 							<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1775
+	}
1690 1776
 
1691 1777
 	echo '
1692 1778
 							<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
@@ -1729,11 +1815,12 @@  discard block
 block discarded – undo
1729 1815
 		if (empty($setting) || !is_array($setting))
1730 1816
 		{
1731 1817
 			// Insert a separator (unless this is the first item in the list)
1732
-			if ($i !== $first_option_key)
1733
-				echo '
1818
+			if ($i !== $first_option_key) {
1819
+							echo '
1734 1820
 				</dl>
1735 1821
 				<hr>
1736 1822
 				<dl class="settings">';
1823
+			}
1737 1824
 
1738 1825
 			// Should we give a name to this section?
1739 1826
 			if (is_string($setting) && !empty($setting))
@@ -1742,51 +1829,55 @@  discard block
 block discarded – undo
1742 1829
 				echo '
1743 1830
 					<dt><strong>' . $setting . '</strong></dt>
1744 1831
 					<dd></dd>';
1832
+			} else {
1833
+							$titled_section = false;
1745 1834
 			}
1746
-			else
1747
-				$titled_section = false;
1748 1835
 
1749 1836
 			continue;
1750 1837
 		}
1751 1838
 
1752 1839
 		// Is this disabled?
1753
-		if (isset($setting['enabled']) && $setting['enabled'] === false)
1754
-			continue;
1840
+		if (isset($setting['enabled']) && $setting['enabled'] === false) {
1841
+					continue;
1842
+		}
1755 1843
 
1756 1844
 		// Some of these may not be set...  Set to defaults here
1757 1845
 		$opts = array('calendar_start_day', 'topics_per_page', 'messages_per_page', 'display_quick_mod');
1758
-		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1759
-			$context['member']['options'][$setting['id']] = 0;
1760
-
1761
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
1762
-			$setting['type'] = 'checkbox';
1763
-
1764
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1765
-			$setting['type'] = 'number';
1846
+		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) {
1847
+					$context['member']['options'][$setting['id']] = 0;
1848
+		}
1766 1849
 
1767
-		elseif ($setting['type'] == 'string')
1768
-			$setting['type'] = 'text';
1850
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
1851
+					$setting['type'] = 'checkbox';
1852
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
1853
+					$setting['type'] = 'number';
1854
+		} elseif ($setting['type'] == 'string') {
1855
+					$setting['type'] = 'text';
1856
+		}
1769 1857
 
1770
-		if (isset($setting['options']))
1771
-			$setting['type'] = 'list';
1858
+		if (isset($setting['options'])) {
1859
+					$setting['type'] = 'list';
1860
+		}
1772 1861
 
1773 1862
 		echo '
1774 1863
 					<dt>
1775 1864
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1776 1865
 
1777
-		if (isset($setting['description']))
1778
-			echo '
1866
+		if (isset($setting['description'])) {
1867
+					echo '
1779 1868
 						<br>
1780 1869
 						<span class="smalltext">', $setting['description'], '</span>';
1870
+		}
1781 1871
 		echo '
1782 1872
 					</dt>
1783 1873
 					<dd>';
1784 1874
 
1785 1875
 		// Display checkbox options
1786
-		if ($setting['type'] == 'checkbox')
1787
-			echo '
1876
+		if ($setting['type'] == 'checkbox') {
1877
+					echo '
1788 1878
 						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1789 1879
 						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">';
1880
+		}
1790 1881
 
1791 1882
 		// How about selection lists, we all love them
1792 1883
 		elseif ($setting['type'] == 'list')
@@ -1794,9 +1885,10 @@  discard block
 block discarded – undo
1794 1885
 			echo '
1795 1886
 						<select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1796 1887
 
1797
-			foreach ($setting['options'] as $value => $label)
1798
-				echo '
1888
+			foreach ($setting['options'] as $value => $label) {
1889
+							echo '
1799 1890
 							<option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1891
+			}
1800 1892
 
1801 1893
 			echo '
1802 1894
 						</select>';
@@ -1812,14 +1904,13 @@  discard block
 block discarded – undo
1812 1904
 
1813 1905
 				echo '
1814 1906
 						<input type="number"', $min . $max . $step;
1815
-			}
1816
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
1817
-				echo'
1907
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
1908
+							echo'
1818 1909
 						<input type="url"';
1819
-
1820
-			else
1821
-				echo '
1910
+			} else {
1911
+							echo '
1822 1912
 						<input type="text"';
1913
+			}
1823 1914
 
1824 1915
 			echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>';
1825 1916
 		}
@@ -1856,8 +1947,8 @@  discard block
 block discarded – undo
1856 1947
 				<dl class="settings">';
1857 1948
 
1858 1949
 	// Allow notification on announcements to be disabled?
1859
-	if (!empty($modSettings['allow_disableAnnounce']))
1860
-		echo '
1950
+	if (!empty($modSettings['allow_disableAnnounce'])) {
1951
+			echo '
1861 1952
 					<dt>
1862 1953
 						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1863 1954
 					</dt>
@@ -1865,15 +1956,17 @@  discard block
 block discarded – undo
1865 1956
 						<input type="hidden" name="notify_announcements" value="0">
1866 1957
 						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1867 1958
 					</dd>';
1959
+	}
1868 1960
 
1869
-	if (!empty($modSettings['enable_ajax_alerts']))
1870
-		echo '
1961
+	if (!empty($modSettings['enable_ajax_alerts'])) {
1962
+			echo '
1871 1963
 					<dt>
1872 1964
 						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1873 1965
 					</dt>
1874 1966
 					<dd>
1875 1967
 						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1876 1968
 					</dd>';
1969
+	}
1877 1970
 
1878 1971
 	echo '
1879 1972
 				</dl>
@@ -1905,9 +1998,10 @@  discard block
 block discarded – undo
1905 1998
 
1906 1999
 				$label = $txt['alert_opt_' . $opts[1]];
1907 2000
 				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1908
-				if ($label_pos == 'before')
1909
-					echo '
2001
+				if ($label_pos == 'before') {
2002
+									echo '
1910 2003
 						<label for="opt_', $opts[1], '">', $label, '</label>';
2004
+				}
1911 2005
 
1912 2006
 				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1913 2007
 				switch ($opts[0])
@@ -1921,17 +2015,19 @@  discard block
 block discarded – undo
1921 2015
 						echo '
1922 2016
 						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1923 2017
 
1924
-						foreach ($opts['opts'] as $k => $v)
1925
-							echo '
2018
+						foreach ($opts['opts'] as $k => $v) {
2019
+													echo '
1926 2020
 							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
2021
+						}
1927 2022
 						echo '
1928 2023
 						</select>';
1929 2024
 						break;
1930 2025
 				}
1931 2026
 
1932
-				if ($label_pos == 'after')
1933
-					echo '
2027
+				if ($label_pos == 'after') {
2028
+									echo '
1934 2029
 						<label for="opt_', $opts[1], '">', $label, '</label>';
2030
+				}
1935 2031
 
1936 2032
 				echo '
1937 2033
 					</td>
@@ -2048,11 +2144,12 @@  discard block
 block discarded – undo
2048 2144
 			<p class="information">', $txt['groupMembership_info'], '</p>';
2049 2145
 
2050 2146
 	// Do we have an update message?
2051
-	if (!empty($context['update_message']))
2052
-		echo '
2147
+	if (!empty($context['update_message'])) {
2148
+			echo '
2053 2149
 			<div class="infobox">
2054 2150
 				', $context['update_message'], '.
2055 2151
 			</div>';
2152
+	}
2056 2153
 
2057 2154
 	echo '
2058 2155
 			<div id="groups">';
@@ -2074,8 +2171,7 @@  discard block
 block discarded – undo
2074 2171
 						</div>
2075 2172
 					</div>
2076 2173
 				</div><!-- .groupmembership -->';
2077
-	}
2078
-	else
2174
+	} else
2079 2175
 	{
2080 2176
 		echo '
2081 2177
 				<div class="title_bar">
@@ -2087,27 +2183,30 @@  discard block
 block discarded – undo
2087 2183
 			echo '
2088 2184
 				<div class="windowbg" id="primdiv_', $group['id'], '">';
2089 2185
 
2090
-				if ($context['can_edit_primary'])
2091
-					echo '
2186
+				if ($context['can_edit_primary']) {
2187
+									echo '
2092 2188
 					<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>';
2189
+				}
2093 2190
 
2094 2191
 				echo '
2095 2192
 					<label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>';
2096 2193
 
2097 2194
 				// Can they leave their group?
2098
-				if ($group['can_leave'])
2099
-					echo '
2195
+				if ($group['can_leave']) {
2196
+									echo '
2100 2197
 					<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
2198
+				}
2101 2199
 
2102 2200
 				echo '
2103 2201
 				</div><!-- .windowbg -->';
2104 2202
 		}
2105 2203
 
2106
-		if ($context['can_edit_primary'])
2107
-			echo '
2204
+		if ($context['can_edit_primary']) {
2205
+					echo '
2108 2206
 				<div class="padding righttext">
2109 2207
 					<input type="submit" value="', $txt['make_primary'], '" class="button">
2110 2208
 				</div>';
2209
+		}
2111 2210
 
2112 2211
 		// Any groups they can join?
2113 2212
 		if (!empty($context['groups']['available']))
@@ -2123,17 +2222,16 @@  discard block
 block discarded – undo
2123 2222
 				<div class="windowbg">
2124 2223
 					<strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '';
2125 2224
 
2126
-				if ($group['type'] == 3)
2127
-					echo '
2225
+				if ($group['type'] == 3) {
2226
+									echo '
2128 2227
 					<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2129
-
2130
-				elseif ($group['type'] == 2 && $group['pending'])
2131
-					echo '
2228
+				} elseif ($group['type'] == 2 && $group['pending']) {
2229
+									echo '
2132 2230
 					<span class="floatright">', $txt['approval_pending'], '</span>';
2133
-
2134
-				elseif ($group['type'] == 2)
2135
-					echo '
2231
+				} elseif ($group['type'] == 2) {
2232
+									echo '
2136 2233
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2234
+				}
2137 2235
 
2138 2236
 				echo '
2139 2237
 				</div><!-- .windowbg -->';
@@ -2156,9 +2254,10 @@  discard block
 block discarded – undo
2156 2254
 
2157 2255
 						prevDiv.className = "windowbg";
2158 2256
 					}';
2159
-		if (isset($context['groups']['member'][$context['primary_group']]))
2160
-			echo '
2257
+		if (isset($context['groups']['member'][$context['primary_group']])) {
2258
+					echo '
2161 2259
 					highlightSelected("primdiv_' . $context['primary_group'] . '");';
2260
+		}
2162 2261
 
2163 2262
 		echo '
2164 2263
 				</script>';
@@ -2167,9 +2266,10 @@  discard block
 block discarded – undo
2167 2266
 	echo '
2168 2267
 			</div><!-- #groups -->';
2169 2268
 
2170
-	if (!empty($context['token_check']))
2171
-		echo '
2269
+	if (!empty($context['token_check'])) {
2270
+			echo '
2172 2271
 			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2272
+	}
2173 2273
 
2174 2274
 	echo '
2175 2275
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2247,10 +2347,11 @@  discard block
 block discarded – undo
2247 2347
 
2248 2348
 	// Work out the starting warning.
2249 2349
 	$context['current_warning_mode'] = $context['warning_mode'][0];
2250
-	foreach ($context['warning_mode'] as $limit => $warning)
2251
-		if ($context['member']['warning'] >= $limit)
2350
+	foreach ($context['warning_mode'] as $limit => $warning) {
2351
+			if ($context['member']['warning'] >= $limit)
2252 2352
 			$context['current_warning_mode'] = $warning;
2253
-}
2353
+	}
2354
+	}
2254 2355
 
2255 2356
 // Show all warnings of a user?
2256 2357
 function template_viewWarning()
@@ -2285,14 +2386,15 @@  discard block
 block discarded – undo
2285 2386
 				</dd>';
2286 2387
 
2287 2388
 	// There's some impact of this?
2288
-	if (!empty($context['level_effects'][$context['current_level']]))
2289
-		echo '
2389
+	if (!empty($context['level_effects'][$context['current_level']])) {
2390
+			echo '
2290 2391
 				<dt>
2291 2392
 					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2292 2393
 				</dt>
2293 2394
 				<dd>
2294 2395
 					', $context['level_effects'][$context['current_level']], '
2295 2396
 				</dd>';
2397
+	}
2296 2398
 
2297 2399
 	echo '
2298 2400
 			</dl>
@@ -2330,10 +2432,11 @@  discard block
 block discarded – undo
2330 2432
 
2331 2433
 			// Otherwise see what we can do...';
2332 2434
 
2333
-	foreach ($context['notification_templates'] as $k => $type)
2334
-		echo '
2435
+	foreach ($context['notification_templates'] as $k => $type) {
2436
+			echo '
2335 2437
 			if (index == ', $k, ')
2336 2438
 				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2439
+	}
2337 2440
 
2338 2441
 	echo '
2339 2442
 		}
@@ -2343,10 +2446,11 @@  discard block
 block discarded – undo
2343 2446
 			// Also set the right effect.
2344 2447
 			effectText = "";';
2345 2448
 
2346
-	foreach ($context['level_effects'] as $limit => $text)
2347
-		echo '
2449
+	foreach ($context['level_effects'] as $limit => $text) {
2450
+			echo '
2348 2451
 			if (slideAmount >= ', $limit, ')
2349 2452
 				effectText = "', $text, '";';
2453
+	}
2350 2454
 
2351 2455
 	echo '
2352 2456
 			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
@@ -2361,32 +2465,35 @@  discard block
 block discarded – undo
2361 2465
 			</h3>
2362 2466
 		</div>';
2363 2467
 
2364
-	if (!$context['user']['is_owner'])
2365
-		echo '
2468
+	if (!$context['user']['is_owner']) {
2469
+			echo '
2366 2470
 		<p class="information">', $txt['profile_warning_desc'], '</p>';
2471
+	}
2367 2472
 
2368 2473
 	echo '
2369 2474
 		<div class="windowbg">
2370 2475
 			<dl class="settings">';
2371 2476
 
2372
-	if (!$context['user']['is_owner'])
2373
-		echo '
2477
+	if (!$context['user']['is_owner']) {
2478
+			echo '
2374 2479
 				<dt>
2375 2480
 					<strong>', $txt['profile_warning_name'], ':</strong>
2376 2481
 				</dt>
2377 2482
 				<dd>
2378 2483
 					<strong>', $context['member']['name'], '</strong>
2379 2484
 				</dd>';
2485
+	}
2380 2486
 
2381 2487
 	echo '
2382 2488
 				<dt>
2383 2489
 					<strong>', $txt['profile_warning_level'], ':</strong>';
2384 2490
 
2385 2491
 	// Is there only so much they can apply?
2386
-	if ($context['warning_limit'])
2387
-		echo '
2492
+	if ($context['warning_limit']) {
2493
+			echo '
2388 2494
 					<br>
2389 2495
 					<span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2496
+	}
2390 2497
 
2391 2498
 	echo '
2392 2499
 				</dt>
@@ -2441,9 +2548,10 @@  discard block
 block discarded – undo
2441 2548
 						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2442 2549
 						<option value="-1" disabled>------------------------------</option>';
2443 2550
 
2444
-		foreach ($context['notification_templates'] as $id_template => $template)
2445
-			echo '
2551
+		foreach ($context['notification_templates'] as $id_template => $template) {
2552
+					echo '
2446 2553
 						<option value="', $id_template, '">', $template['title'], '</option>';
2554
+		}
2447 2555
 
2448 2556
 		echo '
2449 2557
 					</select>
@@ -2456,9 +2564,10 @@  discard block
 block discarded – undo
2456 2564
 			</dl>
2457 2565
 			<div class="righttext">';
2458 2566
 
2459
-	if (!empty($context['token_check']))
2460
-		echo '
2567
+	if (!empty($context['token_check'])) {
2568
+			echo '
2461 2569
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2570
+	}
2462 2571
 
2463 2572
 	echo '
2464 2573
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2474,8 +2583,8 @@  discard block
 block discarded – undo
2474 2583
 	echo '
2475 2584
 	<script>';
2476 2585
 
2477
-	if (!$context['user']['is_owner'])
2478
-		echo '
2586
+	if (!$context['user']['is_owner']) {
2587
+			echo '
2479 2588
 		modifyWarnNotify();
2480 2589
 		$(document).ready(function() {
2481 2590
 			$("#preview_button").click(function() {
@@ -2514,6 +2623,7 @@  discard block
 block discarded – undo
2514 2623
 			});
2515 2624
 			return false;
2516 2625
 		}';
2626
+	}
2517 2627
 
2518 2628
 	echo '
2519 2629
 	</script>';
@@ -2536,17 +2646,19 @@  discard block
 block discarded – undo
2536 2646
 			</div>';
2537 2647
 
2538 2648
 	// If deleting another account give them a lovely info box.
2539
-	if (!$context['user']['is_owner'])
2540
-		echo '
2649
+	if (!$context['user']['is_owner']) {
2650
+			echo '
2541 2651
 			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2652
+	}
2542 2653
 
2543 2654
 	echo '
2544 2655
 			<div class="windowbg">';
2545 2656
 
2546 2657
 	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2547
-	if ($context['needs_approval'])
2548
-		echo '
2658
+	if ($context['needs_approval']) {
2659
+			echo '
2549 2660
 				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2661
+	}
2550 2662
 
2551 2663
 	// If the user is deleting their own account warn them first - and require a password!
2552 2664
 	if ($context['user']['is_owner'])
@@ -2558,9 +2670,10 @@  discard block
 block discarded – undo
2558 2670
 					<input type="password" name="oldpasswrd" size="20">
2559 2671
 					<input type="submit" value="', $txt['yes'], '" class="button">';
2560 2672
 
2561
-		if (!empty($context['token_check']))
2562
-			echo '
2673
+		if (!empty($context['token_check'])) {
2674
+					echo '
2563 2675
 					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2676
+		}
2564 2677
 
2565 2678
 		echo '
2566 2679
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2590,10 +2703,11 @@  discard block
 block discarded – undo
2590 2703
 						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2591 2704
 					</select>';
2592 2705
 
2593
-			if ($context['show_perma_delete'])
2594
-				echo '
2706
+			if ($context['show_perma_delete']) {
2707
+							echo '
2595 2708
 					<br>
2596 2709
 					<label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2710
+			}
2597 2711
 
2598 2712
 			echo '
2599 2713
 				</div>';
@@ -2606,9 +2720,10 @@  discard block
 block discarded – undo
2606 2720
 				<div>
2607 2721
 					<input type="submit" value="', $txt['delete'], '" class="button">';
2608 2722
 
2609
-		if (!empty($context['token_check']))
2610
-			echo '
2723
+		if (!empty($context['token_check'])) {
2724
+					echo '
2611 2725
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2726
+		}
2612 2727
 
2613 2728
 		echo '
2614 2729
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2634,8 +2749,8 @@  discard block
 block discarded – undo
2634 2749
 					<hr>';
2635 2750
 
2636 2751
 	// Only show the password box if it's actually needed.
2637
-	if ($context['require_password'])
2638
-		echo '
2752
+	if ($context['require_password']) {
2753
+			echo '
2639 2754
 					<dl class="settings">
2640 2755
 						<dt>
2641 2756
 							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
@@ -2645,13 +2760,15 @@  discard block
 block discarded – undo
2645 2760
 							<input type="password" name="oldpasswrd" size="20">
2646 2761
 						</dd>
2647 2762
 					</dl>';
2763
+	}
2648 2764
 
2649 2765
 	echo '
2650 2766
 					<div class="righttext">';
2651 2767
 
2652
-	if (!empty($context['token_check']))
2653
-		echo '
2768
+	if (!empty($context['token_check'])) {
2769
+			echo '
2654 2770
 						<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2771
+	}
2655 2772
 
2656 2773
 	echo '
2657 2774
 						<input type="submit" value="', $txt['change_profile'], '" class="button">
@@ -2678,9 +2795,10 @@  discard block
 block discarded – undo
2678 2795
 			<ul id="list_errors">';
2679 2796
 
2680 2797
 		// Cycle through each error and display an error message.
2681
-		foreach ($context['post_errors'] as $error)
2682
-			echo '
2798
+		foreach ($context['post_errors'] as $error) {
2799
+					echo '
2683 2800
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2801
+		}
2684 2802
 
2685 2803
 		echo '
2686 2804
 			</ul>';
@@ -2706,12 +2824,13 @@  discard block
 block discarded – undo
2706 2824
 								<select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 &amp;&amp; !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>';
2707 2825
 
2708 2826
 	// Fill the select box with all primary member groups that can be assigned to a member.
2709
-	foreach ($context['member_groups'] as $member_group)
2710
-		if (!empty($member_group['can_be_primary']))
2827
+	foreach ($context['member_groups'] as $member_group) {
2828
+			if (!empty($member_group['can_be_primary']))
2711 2829
 			echo '
2712 2830
 									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2713 2831
 										', $member_group['name'], '
2714 2832
 									</option>';
2833
+	}
2715 2834
 
2716 2835
 	echo '
2717 2836
 								</select>
@@ -2724,10 +2843,11 @@  discard block
 block discarded – undo
2724 2843
 									<input type="hidden" name="additional_groups[]" value="0">';
2725 2844
 
2726 2845
 	// For each membergroup show a checkbox so members can be assigned to more than one group.
2727
-	foreach ($context['member_groups'] as $member_group)
2728
-		if ($member_group['can_be_additional'])
2846
+	foreach ($context['member_groups'] as $member_group) {
2847
+			if ($member_group['can_be_additional'])
2729 2848
 			echo '
2730 2849
 									<label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>';
2850
+	}
2731 2851
 
2732 2852
 	echo '
2733 2853
 								</span>
@@ -2787,9 +2907,10 @@  discard block
 block discarded – undo
2787 2907
 								<span class="smalltext">', $txt['sig_info'], '</span><br>
2788 2908
 								<br>';
2789 2909
 
2790
-	if ($context['show_spellchecking'])
2791
-		echo '
2910
+	if ($context['show_spellchecking']) {
2911
+			echo '
2792 2912
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2913
+	}
2793 2914
 
2794 2915
 	echo '
2795 2916
 							</dt>
@@ -2797,17 +2918,20 @@  discard block
 block discarded – undo
2797 2918
 								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2798 2919
 
2799 2920
 	// If there is a limit at all!
2800
-	if (!empty($context['signature_limits']['max_length']))
2801
-		echo '
2921
+	if (!empty($context['signature_limits']['max_length'])) {
2922
+			echo '
2802 2923
 								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2924
+	}
2803 2925
 
2804
-	if (!empty($context['show_preview_button']))
2805
-		echo '
2926
+	if (!empty($context['show_preview_button'])) {
2927
+			echo '
2806 2928
 								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">';
2929
+	}
2807 2930
 
2808
-	if ($context['signature_warning'])
2809
-		echo '
2931
+	if ($context['signature_warning']) {
2932
+			echo '
2810 2933
 								<span class="smalltext">', $context['signature_warning'], '</span>';
2934
+	}
2811 2935
 
2812 2936
 	// Some javascript used to count how many characters have been used so far in the signature.
2813 2937
 	echo '
@@ -2838,38 +2962,43 @@  discard block
 block discarded – undo
2838 2962
 									<label for="avatar_upload_box">', $txt['personal_picture'], '</label>
2839 2963
 								</strong>';
2840 2964
 
2841
-	if (empty($modSettings['gravatarOverride']))
2842
-		echo '
2965
+	if (empty($modSettings['gravatarOverride'])) {
2966
+			echo '
2843 2967
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_none" value="none"' . ($context['member']['avatar']['choice'] == 'none' ? ' checked="checked"' : '') . '>
2844 2968
 								<label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2845 2969
 									' . $txt['no_avatar'] . '
2846 2970
 								</label><br>';
2971
+	}
2847 2972
 
2848
-	if (!empty($context['member']['avatar']['allow_server_stored']))
2849
-		echo '
2973
+	if (!empty($context['member']['avatar']['allow_server_stored'])) {
2974
+			echo '
2850 2975
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_server_stored" value="server_stored"' . ($context['member']['avatar']['choice'] == 'server_stored' ? ' checked="checked"' : '') . '>
2851 2976
 								<label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2852 2977
 									', $txt['choose_avatar_gallery'], '
2853 2978
 								</label><br>';
2979
+	}
2854 2980
 
2855
-	if (!empty($context['member']['avatar']['allow_external']))
2856
-		echo '
2981
+	if (!empty($context['member']['avatar']['allow_external'])) {
2982
+			echo '
2857 2983
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_external" value="external"' . ($context['member']['avatar']['choice'] == 'external' ? ' checked="checked"' : '') . '>
2858 2984
 								<label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2859 2985
 									', $txt['my_own_pic'], '
2860 2986
 								</label><br>';
2987
+	}
2861 2988
 
2862
-	if (!empty($context['member']['avatar']['allow_upload']))
2863
-		echo '
2989
+	if (!empty($context['member']['avatar']['allow_upload'])) {
2990
+			echo '
2864 2991
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_upload" value="upload"' . ($context['member']['avatar']['choice'] == 'upload' ? ' checked="checked"' : '') . '>
2865 2992
 								<label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2866 2993
 									', $txt['avatar_will_upload'], '
2867 2994
 								</label><br>';
2995
+	}
2868 2996
 
2869
-	if (!empty($context['member']['avatar']['allow_gravatar']))
2870
-		echo '
2997
+	if (!empty($context['member']['avatar']['allow_gravatar'])) {
2998
+			echo '
2871 2999
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"' . ($context['member']['avatar']['choice'] == 'gravatar' ? ' checked="checked"' : '') . '>
2872 3000
 								<label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>';
3001
+	}
2873 3002
 
2874 3003
 	echo '
2875 3004
 							</dt>
@@ -2884,9 +3013,10 @@  discard block
 block discarded – undo
2884 3013
 										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2885 3014
 
2886 3015
 		// This lists all the file categories.
2887
-		foreach ($context['avatars'] as $avatar)
2888
-			echo '
3016
+		foreach ($context['avatars'] as $avatar) {
3017
+					echo '
2889 3018
 											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
3019
+		}
2890 3020
 
2891 3021
 		echo '
2892 3022
 										</select>
@@ -2918,20 +3048,22 @@  discard block
 block discarded – undo
2918 3048
 	}
2919 3049
 
2920 3050
 	// If the user can link to an off server avatar, show them a box to input the address.
2921
-	if (!empty($context['member']['avatar']['allow_external']))
2922
-		echo '
3051
+	if (!empty($context['member']['avatar']['allow_external'])) {
3052
+			echo '
2923 3053
 								<div id="avatar_external">
2924 3054
 									<div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', '
2925 3055
 									<input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);">
2926 3056
 								</div>';
3057
+	}
2927 3058
 
2928 3059
 	// If the user is able to upload avatars to the server show them an upload box.
2929
-	if (!empty($context['member']['avatar']['allow_upload']))
2930
-		echo '
3060
+	if (!empty($context['member']['avatar']['allow_upload'])) {
3061
+			echo '
2931 3062
 								<div id="avatar_upload">
2932 3063
 									<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)"  onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
2933 3064
 									', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
2934 3065
 								</div>';
3066
+	}
2935 3067
 
2936 3068
 	// if the user is able to use Gravatar avatars show then the image preview
2937 3069
 	if (!empty($context['member']['avatar']['allow_gravatar']))
@@ -2940,16 +3072,17 @@  discard block
 block discarded – undo
2940 3072
 								<div id="avatar_gravatar">
2941 3073
 									<img src="' . $context['member']['avatar']['href'] . '" alt="">';
2942 3074
 
2943
-		if (empty($modSettings['gravatarAllowExtraEmail']))
2944
-			echo '
3075
+		if (empty($modSettings['gravatarAllowExtraEmail'])) {
3076
+					echo '
2945 3077
 									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2946
-		else
3078
+		} else
2947 3079
 		{
2948 3080
 			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2949
-			if ($context['member']['avatar']['external'] == $context['member']['email'])
2950
-				$textbox_value = '';
2951
-			else
2952
-				$textbox_value = $context['member']['avatar']['external'];
3081
+			if ($context['member']['avatar']['external'] == $context['member']['email']) {
3082
+							$textbox_value = '';
3083
+			} else {
3084
+							$textbox_value = $context['member']['avatar']['external'];
3085
+			}
2953 3086
 
2954 3087
 			echo '
2955 3088
 									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
@@ -3021,8 +3154,9 @@  discard block
 block discarded – undo
3021 3154
 	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
3022 3155
 
3023 3156
 	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
3024
-	if (empty($suffix))
3025
-		return;
3157
+	if (empty($suffix)) {
3158
+			return;
3159
+	}
3026 3160
 
3027 3161
 	echo '
3028 3162
 								<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
@@ -3047,9 +3181,10 @@  discard block
 block discarded – undo
3047 3181
 								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
3048 3182
 
3049 3183
 	// Help the user by showing a list of common time formats.
3050
-	foreach ($context['easy_timeformats'] as $time_format)
3051
-		echo '
3184
+	foreach ($context['easy_timeformats'] as $time_format) {
3185
+			echo '
3052 3186
 									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3187
+	}
3053 3188
 
3054 3189
 	echo '
3055 3190
 								</select>
@@ -3087,9 +3222,10 @@  discard block
 block discarded – undo
3087 3222
 							<dd>
3088 3223
 								<select name="smiley_set" id="smiley_set">';
3089 3224
 
3090
-	foreach ($context['smiley_sets'] as $set)
3091
-		echo '
3225
+	foreach ($context['smiley_sets'] as $set) {
3226
+			echo '
3092 3227
 									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3228
+	}
3093 3229
 
3094 3230
 	echo '
3095 3231
 								</select>
@@ -3111,17 +3247,17 @@  discard block
 block discarded – undo
3111 3247
 			<div class="roundframe">
3112 3248
 				<div>';
3113 3249
 
3114
-	if (!empty($context['tfa_backup']))
3115
-		echo '
3250
+	if (!empty($context['tfa_backup'])) {
3251
+			echo '
3116 3252
 					<div class="smalltext error">
3117 3253
 						', $txt['tfa_backup_used_desc'], '
3118 3254
 					</div>';
3119
-
3120
-	elseif ($modSettings['tfa_mode'] == 2)
3121
-		echo '
3255
+	} elseif ($modSettings['tfa_mode'] == 2) {
3256
+			echo '
3122 3257
 					<div class="smalltext">
3123 3258
 						<strong>', $txt['tfa_forced_desc'], '</strong>
3124 3259
 					</div>';
3260
+	}
3125 3261
 
3126 3262
 	echo '
3127 3263
 					<div class="smalltext">
@@ -3132,11 +3268,12 @@  discard block
 block discarded – undo
3132 3268
 							<div class="block">
3133 3269
 								<strong>', $txt['tfa_step1'], '</strong><br>';
3134 3270
 
3135
-	if (!empty($context['tfa_pass_error']))
3136
-		echo '
3271
+	if (!empty($context['tfa_pass_error'])) {
3272
+			echo '
3137 3273
 								<div class="error smalltext">
3138 3274
 									', $txt['tfa_pass_invalid'], '
3139 3275
 								</div>';
3276
+	}
3140 3277
 
3141 3278
 	echo '
3142 3279
 								<input type="password" name="passwd" size="25"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '>
@@ -3149,11 +3286,12 @@  discard block
 block discarded – undo
3149 3286
 							<div class="block">
3150 3287
 								<strong>', $txt['tfa_step3'], '</strong><br>';
3151 3288
 
3152
-	if (!empty($context['tfa_error']))
3153
-		echo '
3289
+	if (!empty($context['tfa_error'])) {
3290
+			echo '
3154 3291
 								<div class="error smalltext">
3155 3292
 									', $txt['tfa_code_invalid'], '
3156 3293
 								</div>';
3294
+	}
3157 3295
 
3158 3296
 	echo '
3159 3297
 								<input type="text" name="tfa_code" size="25"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '>
@@ -3167,10 +3305,11 @@  discard block
 block discarded – undo
3167 3305
 						<img src="', $context['tfa_qr_url'], '" alt="">
3168 3306
 					</div>';
3169 3307
 
3170
-	if (!empty($context['from_ajax']))
3171
-		echo '
3308
+	if (!empty($context['from_ajax'])) {
3309
+			echo '
3172 3310
 					<br>
3173 3311
 					<a href="javascript:self.close();"></a>';
3312
+	}
3174 3313
 
3175 3314
 	echo '
3176 3315
 				</div>
@@ -3210,17 +3349,16 @@  discard block
 block discarded – undo
3210 3349
 							</dt>
3211 3350
 							<dd>';
3212 3351
 
3213
-	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3214
-		echo '
3352
+	if (!$context['tfa_enabled'] && $context['user']['is_owner']) {
3353
+			echo '
3215 3354
 								<a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3216
-
3217
-	elseif (!$context['tfa_enabled'])
3218
-		echo '
3355
+	} elseif (!$context['tfa_enabled']) {
3356
+			echo '
3219 3357
 								', $txt['tfa_profile_disabled'];
3220
-
3221
-	else
3222
-		echo '
3358
+	} else {
3359
+			echo '
3223 3360
 								', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3361
+	}
3224 3362
 
3225 3363
 	echo '
3226 3364
 							</dd>';
Please login to merge, or discard this patch.
Themes/default/ReportToMod.template.php 1 patch
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,16 +62,17 @@
 block discarded – undo
62 62
 				<div id="error_box" class="errorbox">
63 63
 					<ul id="error_list">';
64 64
 
65
-		foreach ($context['post_errors'] as $key => $error)
66
-			echo '
65
+		foreach ($context['post_errors'] as $key => $error) {
66
+					echo '
67 67
 						<li id="error_', $key, '" class="error">', $error, '</li>';
68
+		}
68 69
 
69 70
 		echo '
70 71
 					</ul>';
71
-	}
72
-	else
73
-		echo '
72
+	} else {
73
+			echo '
74 74
 				<div id="error_box" class="errorbox hidden">';
75
+	}
75 76
 
76 77
 	echo '
77 78
 				</div>';
Please login to merge, or discard this patch.
Themes/default/Packages.template.php 1 patch
Braces   +175 added lines, -128 removed lines patch added patch discarded remove patch
@@ -30,25 +30,27 @@  discard block
 block discarded – undo
30 30
 		</div>
31 31
 		<div class="information">';
32 32
 
33
-	if ($context['is_installed'])
34
-		echo '
33
+	if ($context['is_installed']) {
34
+			echo '
35 35
 			<strong>', $txt['package_installed_warning1'], '</strong><br>
36 36
 			<br>
37 37
 			', $txt['package_installed_warning2'], '<br>
38 38
 			<br>';
39
+	}
39 40
 
40 41
 	echo $txt['package_installed_warning3'], '
41 42
 		</div>
42 43
 		<br>';
43 44
 
44 45
 	// Do errors exist in the install? If so light them up like a christmas tree.
45
-	if ($context['has_failure'])
46
-		echo '
46
+	if ($context['has_failure']) {
47
+			echo '
47 48
 		<div class="errorbox">
48 49
 			', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br>
49 50
 			', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]),
50 51
 			!empty($context['failure_details']) ? '<br><br><strong>' . $context['failure_details'] . '</strong>' : '', '
51 52
 		</div>';
53
+	}
52 54
 
53 55
 	// Display the package readme if one exists
54 56
 	if (isset($context['package_readme']))
@@ -62,9 +64,10 @@  discard block
 block discarded – undo
62 64
 			<span class="floatright">', $txt['package_available_readme_language'], '
63 65
 				<select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">';
64 66
 
65
-		foreach ($context['readmes'] as $a => $b)
66
-			echo '
67
+		foreach ($context['readmes'] as $a => $b) {
68
+					echo '
67 69
 					<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>';
70
+		}
68 71
 
69 72
 		echo '
70 73
 				</select>
@@ -85,9 +88,10 @@  discard block
 block discarded – undo
85 88
 			<span class="floatright">', $txt['package_available_license_language'], '
86 89
 				<select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">';
87 90
 
88
-		foreach ($context['licenses'] as $a => $b)
89
-			echo '
91
+		foreach ($context['licenses'] as $a => $b) {
92
+					echo '
90 93
 					<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>';
94
+		}
91 95
 		echo '
92 96
 				</select>
93 97
 			</span>
@@ -114,9 +118,10 @@  discard block
 block discarded – undo
114 118
 					', $txt['package_db_uninstall_actions'], ':
115 119
 					<ul>';
116 120
 
117
-		foreach ($context['database_changes'] as $change)
118
-			echo '
121
+		foreach ($context['database_changes'] as $change) {
122
+					echo '
119 123
 						<li>', $change, '</li>';
124
+		}
120 125
 
121 126
 		echo '
122 127
 					</ul>
@@ -127,14 +132,14 @@  discard block
 block discarded – undo
127 132
 	echo '
128 133
 			<div class="information">';
129 134
 
130
-	if (empty($context['actions']) && empty($context['database_changes']))
131
-		echo '
135
+	if (empty($context['actions']) && empty($context['database_changes'])) {
136
+			echo '
132 137
 				<br>
133 138
 				<div class="errorbox">
134 139
 					', $txt['corrupt_compatible'], '
135 140
 				</div>
136 141
 			</div><!-- .information -->';
137
-	else
142
+	} else
138 143
 	{
139 144
 		echo '
140 145
 				', $txt['perform_actions'], '
@@ -238,9 +243,10 @@  discard block
 block discarded – undo
238 243
 						<td></td>
239 244
 						<td>';
240 245
 
241
-				if (!empty($context['themes_locked']))
242
-					echo '
246
+				if (!empty($context['themes_locked'])) {
247
+									echo '
243 248
 							<input type="hidden" name="custom_theme[]" value="', $id, '">';
249
+				}
244 250
 				echo '
245 251
 							<input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '>
246 252
 						</td>
@@ -306,21 +312,23 @@  discard block
 block discarded – undo
306 312
 	}
307 313
 
308 314
 	// Are we effectively ready to install?
309
-	if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes'])))
310
-		echo '
315
+	if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) {
316
+			echo '
311 317
 			<div class="righttext padding">
312 318
 				<input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) &amp;&amp; confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button">
313 319
 			</div>';
320
+	}
314 321
 
315 322
 	// If we need ftp information then demand it!
316
-	elseif ($context['ftp_needed'])
317
-		echo '
323
+	elseif ($context['ftp_needed']) {
324
+			echo '
318 325
 			<div class="cat_bar">
319 326
 				<h3 class="catbg">', $txt['package_ftp_necessary'], '</h3>
320 327
 			</div>
321 328
 			<div>
322 329
 				', template_control_chmod(), '
323 330
 			</div>';
331
+	}
324 332
 
325 333
 	echo '
326 334
 
@@ -336,8 +344,8 @@  discard block
 block discarded – undo
336 344
 	// Operations.
337 345
 	if (!empty($js_operations))
338 346
 	{
339
-		foreach ($js_operations as $key => $operation)
340
-			echo '
347
+		foreach ($js_operations as $key => $operation) {
348
+					echo '
341 349
 		aOperationElements[', $key, '] = new smc_Toggle({
342 350
 			bToggleEnabled: true,
343 351
 			bNoAnimate: true,
@@ -355,6 +363,7 @@  discard block
 block discarded – undo
355 363
 				}
356 364
 			]
357 365
 		});';
366
+		}
358 367
 	}
359 368
 
360 369
 	echo '
@@ -376,14 +385,15 @@  discard block
 block discarded – undo
376 385
 	</script>';
377 386
 
378 387
 	// And a bit more for database changes.
379
-	if (!empty($context['database_changes']))
380
-		echo '
388
+	if (!empty($context['database_changes'])) {
389
+			echo '
381 390
 	<script>
382 391
 		var database_changes_area = document.getElementById(\'db_changes_div\');
383 392
 		var db_vis = false;
384 393
 		database_changes_area.classList.add(\'hidden\');
385 394
 	</script>';
386
-}
395
+	}
396
+	}
387 397
 
388 398
 /**
389 399
  * Extract package contents
@@ -392,8 +402,8 @@  discard block
 block discarded – undo
392 402
 {
393 403
 	global $context, $txt, $scripturl;
394 404
 
395
-	if (!empty($context['redirect_url']))
396
-		echo '
405
+	if (!empty($context['redirect_url'])) {
406
+			echo '
397 407
 	<script>
398 408
 		setTimeout("doRedirect();", ', empty($context['redirect_timeout']) ? '5000' : $context['redirect_timeout'], ');
399 409
 
@@ -402,49 +412,48 @@  discard block
 block discarded – undo
402 412
 			window.location = "', $context['redirect_url'], '";
403 413
 		}
404 414
 	</script>';
415
+	}
405 416
 
406
-	if (empty($context['redirect_url']))
407
-		echo '
417
+	if (empty($context['redirect_url'])) {
418
+			echo '
408 419
 		<div class="cat_bar">
409 420
 			<h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3>
410 421
 		</div>
411 422
 		<div class="information">', $txt['package_installed_extract'], '</div>';
412
-	else
413
-		echo '
423
+	} else {
424
+			echo '
414 425
 		<div class="cat_bar">
415 426
 			<h3 class="catbg">', $txt['package_installed_redirecting'], '</h3>
416 427
 		</div>';
428
+	}
417 429
 
418 430
 	echo '
419 431
 		<div class="windowbg">';
420 432
 
421 433
 	// If we are going to redirect we have a slightly different agenda.
422
-	if (!empty($context['redirect_url']))
423
-		echo '
434
+	if (!empty($context['redirect_url'])) {
435
+			echo '
424 436
 			', $context['redirect_text'], '<br><br>
425 437
 			<a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>';
426
-
427
-	elseif ($context['uninstalling'])
428
-		echo '
438
+	} elseif ($context['uninstalling']) {
439
+			echo '
429 440
 			', $txt['package_uninstall_done'];
430
-
431
-	elseif ($context['install_finished'])
441
+	} elseif ($context['install_finished'])
432 442
 	{
433
-		if ($context['extract_type'] == 'avatar')
434
-			echo '
443
+		if ($context['extract_type'] == 'avatar') {
444
+					echo '
435 445
 			', $txt['avatars_extracted'];
436
-
437
-		elseif ($context['extract_type'] == 'language')
438
-			echo '
446
+		} elseif ($context['extract_type'] == 'language') {
447
+					echo '
439 448
 			', $txt['language_extracted'];
440
-
441
-		else
442
-			echo '
449
+		} else {
450
+					echo '
443 451
 			', $txt['package_installed_done'];
444
-	}
445
-	else
446
-		echo '
452
+		}
453
+	} else {
454
+			echo '
447 455
 			', $txt['corrupt_compatible'];
456
+	}
448 457
 
449 458
 	echo '
450 459
 		</div><!-- .windowbg -->';
@@ -474,9 +483,10 @@  discard block
 block discarded – undo
474 483
 		<div class="windowbg">
475 484
 			<ol>';
476 485
 
477
-	foreach ($context['files'] as $fileinfo)
478
-		echo '
486
+	foreach ($context['files'] as $fileinfo) {
487
+			echo '
479 488
 				<li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>';
489
+	}
480 490
 
481 491
 	echo '
482 492
 			</ol>
@@ -536,9 +546,10 @@  discard block
 block discarded – undo
536 546
 			</script>
537 547
 			<div id="yourVersion" style="display:none">', $context['forum_version'], '</div>';
538 548
 
539
-	if (empty($modSettings['disable_smf_js']))
540
-		echo '
549
+	if (empty($modSettings['disable_smf_js'])) {
550
+			echo '
541 551
 			<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
552
+	}
542 553
 
543 554
 	// This sets the announcements and current versions themselves ;).
544 555
 	echo '
@@ -576,12 +587,13 @@  discard block
 block discarded – undo
576 587
 		}
577 588
 	}
578 589
 
579
-	if (!$mods_available)
580
-		echo '
590
+	if (!$mods_available) {
591
+			echo '
581 592
 		<div class="noticebox">', $txt['no_packages'], '</div>';
582
-	else
583
-		echo '
593
+	} else {
594
+			echo '
584 595
 		<br>';
596
+	}
585 597
 
586 598
 	// The advanced (emulation) box, collapsed by default
587 599
 	echo '
@@ -608,9 +620,10 @@  discard block
 block discarded – undo
608 620
 							<a id="revert" name="revert"></a>
609 621
 							<select name="version_emulate" id="ve">';
610 622
 
611
-	foreach ($context['emulation_versions'] as $version)
612
-		echo '
623
+	foreach ($context['emulation_versions'] as $version) {
624
+			echo '
613 625
 								<option value="', $version, '"', ($version == $context['selected_version'] ? ' selected="selected"' : ''), '>', $version, '</option>';
626
+	}
614 627
 
615 628
 	echo '
616 629
 							</select>
@@ -665,11 +678,12 @@  discard block
 block discarded – undo
665 678
 {
666 679
 	global $context, $txt, $scripturl;
667 680
 
668
-	if (!empty($context['package_ftp']['error']))
669
-		echo '
681
+	if (!empty($context['package_ftp']['error'])) {
682
+			echo '
670 683
 	<div class="errorbox">
671 684
 		<pre>', $context['package_ftp']['error'], '</pre>
672 685
 	</div>';
686
+	}
673 687
 
674 688
 	echo '
675 689
 	<div id="admin_form_wrapper">
@@ -752,13 +766,14 @@  discard block
 block discarded – undo
752 766
 					<legend>' . $txt['package_servers'] . '</legend>
753 767
 					<ul class="package_servers">';
754 768
 
755
-	foreach ($context['servers'] as $server)
756
-		echo '
769
+	foreach ($context['servers'] as $server) {
770
+			echo '
757 771
 						<li class="flow_auto">
758 772
 							<span class="floatleft">' . $server['name'] . '</span>
759 773
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span>
760 774
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span>
761 775
 						</li>';
776
+	}
762 777
 	echo '
763 778
 					</ul>
764 779
 				</fieldset>
@@ -842,11 +857,12 @@  discard block
 block discarded – undo
842 857
 		<div class="windowbg">';
843 858
 
844 859
 	// No packages, as yet.
845
-	if (empty($context['package_list']))
846
-		echo '
860
+	if (empty($context['package_list'])) {
861
+			echo '
847 862
 			<ul>
848 863
 				<li>', $txt['no_packages'], '</li>
849 864
 			</ul>';
865
+	}
850 866
 
851 867
 	// List out the packages...
852 868
 	else
@@ -860,11 +876,12 @@  discard block
 block discarded – undo
860 876
 				<li>
861 877
 					<strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>';
862 878
 
863
-			if (!empty($packageSection['text']))
864
-				echo '
879
+			if (!empty($packageSection['text'])) {
880
+							echo '
865 881
 					<div class="sub_bar">
866 882
 						<h3 class="subbg">', $packageSection['text'], '</h3>
867 883
 					</div>';
884
+			}
868 885
 
869 886
 			echo '
870 887
 					<', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
@@ -875,24 +892,28 @@  discard block
 block discarded – undo
875 892
 						<li>';
876 893
 
877 894
 				// Textual message. Could be empty just for a blank line...
878
-				if ($package['is_text'])
879
-					echo '
895
+				if ($package['is_text']) {
896
+									echo '
880 897
 							', empty($package['name']) ? '&nbsp;' : $package['name'];
898
+				}
881 899
 
882 900
 				// This is supposed to be a rule..
883
-				elseif ($package['is_line'])
884
-					echo '
901
+				elseif ($package['is_line']) {
902
+									echo '
885 903
 							<hr>';
904
+				}
886 905
 
887 906
 				// A remote link.
888
-				elseif ($package['is_remote'])
889
-					echo '
907
+				elseif ($package['is_remote']) {
908
+									echo '
890 909
 							<strong>', $package['link'], '</strong>';
910
+				}
891 911
 
892 912
 				// A title?
893
-				elseif ($package['is_heading'] || $package['is_title'])
894
-					echo '
913
+				elseif ($package['is_heading'] || $package['is_title']) {
914
+									echo '
895 915
 							<strong>', $package['name'], '</strong>';
916
+				}
896 917
 
897 918
 				// Otherwise, it's a package.
898 919
 				else
@@ -903,32 +924,36 @@  discard block
 block discarded – undo
903 924
 						<ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
904 925
 
905 926
 					// Show the mod type?
906
-					if ($package['type'] != '')
907
-						echo '
927
+					if ($package['type'] != '') {
928
+											echo '
908 929
 							<li class="package_section">
909 930
 								', $txt['package_type'], ':&nbsp; ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '
910 931
 							</li>';
932
+					}
911 933
 
912 934
 					// Show the version number?
913
-					if ($package['version'] != '')
914
-						echo '
935
+					if ($package['version'] != '') {
936
+											echo '
915 937
 							<li class="package_section">
916 938
 								', $txt['mod_version'], ':&nbsp; ', $package['version'], '
917 939
 							</li>';
940
+					}
918 941
 
919 942
 					// How 'bout the author?
920
-					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link']))
921
-						echo '
943
+					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) {
944
+											echo '
922 945
 							<li class="package_section">
923 946
 								', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '
924 947
 							</li>';
948
+					}
925 949
 
926 950
 					// The homepage...
927
-					if ($package['author']['website']['link'] != '')
928
-						echo '
951
+					if ($package['author']['website']['link'] != '') {
952
+											echo '
929 953
 							<li class="package_section">
930 954
 								', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '
931 955
 							</li>';
956
+					}
932 957
 
933 958
 					// Description: bleh bleh!
934 959
 					// Location of file: http://someplace/.
@@ -986,8 +1011,8 @@  discard block
 block discarded – undo
986 1011
 
987 1012
 			foreach ($ps['items'] as $id => $package)
988 1013
 			{
989
-				if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote'])
990
-					echo '
1014
+				if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) {
1015
+									echo '
991 1016
 		var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({
992 1017
 			bToggleEnabled: true,
993 1018
 			bCurrentlyCollapsed: true,
@@ -1002,6 +1027,7 @@  discard block
 block discarded – undo
1002 1027
 				}
1003 1028
 			]
1004 1029
 		});';
1030
+				}
1005 1031
 			}
1006 1032
 		}
1007 1033
 
@@ -1044,9 +1070,10 @@  discard block
 block discarded – undo
1044 1070
 {
1045 1071
 	global $context, $txt, $scripturl;
1046 1072
 
1047
-	if (!empty($context['saved_successful']))
1048
-		echo '
1073
+	if (!empty($context['saved_successful'])) {
1074
+			echo '
1049 1075
 	<div class="infobox">', $txt['settings_saved'], '</div>';
1076
+	}
1050 1077
 
1051 1078
 	echo '
1052 1079
 		<div class="cat_bar">
@@ -1106,8 +1133,9 @@  discard block
 block discarded – undo
1106 1133
 	global $context, $txt;
1107 1134
 
1108 1135
 	// Nothing to do? Brilliant!
1109
-	if (empty($context['package_ftp']))
1110
-		return false;
1136
+	if (empty($context['package_ftp'])) {
1137
+			return false;
1138
+	}
1111 1139
 
1112 1140
 	if (empty($context['package_ftp']['form_elements_only']))
1113 1141
 	{
@@ -1117,19 +1145,21 @@  discard block
 block discarded – undo
1117 1145
 					', $txt['package_ftp_why_file_list'], '
1118 1146
 					<ul style="display: inline;">';
1119 1147
 
1120
-		if (!empty($context['notwritable_files']))
1121
-			foreach ($context['notwritable_files'] as $file)
1148
+		if (!empty($context['notwritable_files'])) {
1149
+					foreach ($context['notwritable_files'] as $file)
1122 1150
 				echo '
1123 1151
 						<li>', $file, '</li>';
1152
+		}
1124 1153
 
1125 1154
 		echo '
1126 1155
 					</ul>';
1127 1156
 
1128
-		if (!$context['server']['is_windows'])
1129
-			echo '
1157
+		if (!$context['server']['is_windows']) {
1158
+					echo '
1130 1159
 					<hr>
1131 1160
 					', $txt['package_chmod_linux'], '<br>
1132 1161
 					<samp># chmod a+w ', implode(' ', $context['notwritable_files']), '</samp>';
1162
+		}
1133 1163
 
1134 1164
 		echo '
1135 1165
 				</div><!-- #need_writable_list -->';
@@ -1142,9 +1172,10 @@  discard block
 block discarded – undo
1142 1172
 					</div>
1143 1173
 				</div>';
1144 1174
 
1145
-	if (!empty($context['package_ftp']['destination']))
1146
-		echo '
1175
+	if (!empty($context['package_ftp']['destination'])) {
1176
+			echo '
1147 1177
 				<form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '">';
1178
+	}
1148 1179
 
1149 1180
 	echo '
1150 1181
 					<fieldset>
@@ -1178,24 +1209,27 @@  discard block
 block discarded – undo
1178 1209
 					</dl>
1179 1210
 					</fieldset>';
1180 1211
 
1181
-	if (empty($context['package_ftp']['form_elements_only']))
1182
-		echo '
1212
+	if (empty($context['package_ftp']['form_elements_only'])) {
1213
+			echo '
1183 1214
 					<div class="righttext" style="margin: 1ex;">
1184 1215
 						<span id="test_ftp_placeholder_full"></span>
1185 1216
 						<input type="submit" value="', $txt['package_proceed'], '" class="button">
1186 1217
 					</div>';
1218
+	}
1187 1219
 
1188
-	if (!empty($context['package_ftp']['destination']))
1189
-		echo '
1220
+	if (!empty($context['package_ftp']['destination'])) {
1221
+			echo '
1190 1222
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1191 1223
 				</form>';
1224
+	}
1192 1225
 
1193 1226
 	// Hide the details of the list.
1194
-	if (empty($context['package_ftp']['form_elements_only']))
1195
-		echo '
1227
+	if (empty($context['package_ftp']['form_elements_only'])) {
1228
+			echo '
1196 1229
 				<script>
1197 1230
 					document.getElementById(\'need_writable_list\').style.display = \'none\';
1198 1231
 				</script>';
1232
+	}
1199 1233
 
1200 1234
 	// Quick generate the test button.
1201 1235
 	echo '
@@ -1552,9 +1586,10 @@  discard block
 block discarded – undo
1552 1586
 					<td width="30%">
1553 1587
 						<strong>';
1554 1588
 
1555
-		if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1556
-			echo '
1589
+		if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1590
+					echo '
1557 1591
 							<span class="generic_icons folder"></span>';
1592
+		}
1558 1593
 
1559 1594
 		echo '
1560 1595
 							', $name, '
@@ -1581,8 +1616,9 @@  discard block
 block discarded – undo
1581 1616
 					</td>
1582 1617
 				</tr>';
1583 1618
 
1584
-		if (!empty($dir['contents']))
1585
-			template_permission_show_contents($name, $dir['contents'], 1);
1619
+		if (!empty($dir['contents'])) {
1620
+					template_permission_show_contents($name, $dir['contents'], 1);
1621
+		}
1586 1622
 	}
1587 1623
 
1588 1624
 	echo '
@@ -1618,13 +1654,14 @@  discard block
 block discarded – undo
1618 1654
 			</fieldset>';
1619 1655
 
1620 1656
 	// Likely to need FTP?
1621
-	if (empty($context['ftp_connected']))
1622
-		echo '
1657
+	if (empty($context['ftp_connected'])) {
1658
+			echo '
1623 1659
 			<p>
1624 1660
 				', $txt['package_file_perms_ftp_details'], ':
1625 1661
 			</p>
1626 1662
 			', template_control_chmod(), '
1627 1663
 			<div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>';
1664
+	}
1628 1665
 
1629 1666
 	echo '
1630 1667
 			<span id="test_ftp_placeholder_full"></span>
@@ -1633,9 +1670,10 @@  discard block
 block discarded – undo
1633 1670
 		</div><!-- .windowbg -->';
1634 1671
 
1635 1672
 	// Any looks fors we've already done?
1636
-	foreach ($context['look_for'] as $path)
1637
-		echo '
1673
+	foreach ($context['look_for'] as $path) {
1674
+			echo '
1638 1675
 		<input type="hidden" name="back_look[]" value="', $path, '">';
1676
+	}
1639 1677
 
1640 1678
 	echo '
1641 1679
 	</form>
@@ -1677,9 +1715,10 @@  discard block
 block discarded – undo
1677 1715
 					<td class="smalltext" width="30%">' . str_repeat('&nbsp;', $level * 5), '
1678 1716
 					', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : '';
1679 1717
 
1680
-			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1681
-				echo '
1718
+			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1719
+							echo '
1682 1720
 						<span class="generic_icons folder"></span>';
1721
+			}
1683 1722
 
1684 1723
 			echo '
1685 1724
 						', $name, '
@@ -1697,34 +1736,38 @@  discard block
 block discarded – undo
1697 1736
 				</tr>
1698 1737
 				<tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>';
1699 1738
 
1700
-			if (!empty($dir['contents']))
1701
-				template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files']));
1739
+			if (!empty($dir['contents'])) {
1740
+							template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files']));
1741
+			}
1702 1742
 		}
1703 1743
 	}
1704 1744
 
1705 1745
 	// We have more files to show?
1706
-	if ($has_more)
1707
-		echo '
1746
+	if ($has_more) {
1747
+			echo '
1708 1748
 				<tr class="windowbg" id="content_', $js_ident, '_more">
1709 1749
 					<td class="smalltext" width="40%">' . str_repeat('&nbsp;', $level * 5), '
1710 1750
 						&#171; <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> &#187;
1711 1751
 					</td>
1712 1752
 					<td colspan="6"></td>
1713 1753
 				</tr>';
1754
+	}
1714 1755
 
1715 1756
 	if ($drawn_div)
1716 1757
 	{
1717 1758
 		// Hide anything too far down the tree.
1718 1759
 		$isFound = false;
1719
-		foreach ($context['look_for'] as $tree)
1720
-			if (substr($tree, 0, strlen($ident)) == $ident)
1760
+		foreach ($context['look_for'] as $tree) {
1761
+					if (substr($tree, 0, strlen($ident)) == $ident)
1721 1762
 				$isFound = true;
1763
+		}
1722 1764
 
1723
-		if ($level > 1 && !$isFound)
1724
-			echo '
1765
+		if ($level > 1 && !$isFound) {
1766
+					echo '
1725 1767
 		<script>
1726 1768
 			expandFolder(\'', $js_ident, '\', \'\');
1727 1769
 		</script>';
1770
+		}
1728 1771
 	}
1729 1772
 }
1730 1773
 
@@ -1743,11 +1786,12 @@  discard block
 block discarded – undo
1743 1786
 				<h3 class="catbg">', $txt['package_file_perms_applying'], '</h3>
1744 1787
 			</div>';
1745 1788
 
1746
-	if (!empty($context['skip_ftp']))
1747
-		echo '
1789
+	if (!empty($context['skip_ftp'])) {
1790
+			echo '
1748 1791
 			<div class="errorbox">
1749 1792
 				', $txt['package_file_perms_skipping_ftp'], '
1750 1793
 			</div>';
1794
+	}
1751 1795
 
1752 1796
 	// How many have we done?
1753 1797
 	$remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']);
@@ -1785,28 +1829,31 @@  discard block
 block discarded – undo
1785 1829
 				<br>';
1786 1830
 
1787 1831
 	// Put out the right hidden data.
1788
-	if ($context['method'] == 'individual')
1789
-		echo '
1832
+	if ($context['method'] == 'individual') {
1833
+			echo '
1790 1834
 				<input type="hidden" name="custom_value" value="', $context['custom_value'], '">
1791 1835
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1792 1836
 				<input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">';
1793
-	else
1794
-		echo '
1837
+	} else {
1838
+			echo '
1795 1839
 				<input type="hidden" name="predefined" value="', $context['predefined_type'], '">
1796 1840
 				<input type="hidden" name="fileOffset" value="', $context['file_offset'], '">
1797 1841
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1798 1842
 				<input type="hidden" name="dirList" value="', $context['directory_list_encode'], '">
1799 1843
 				<input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">';
1844
+	}
1800 1845
 
1801 1846
 	// Are we not using FTP for whatever reason.
1802
-	if (!empty($context['skip_ftp']))
1803
-		echo '
1847
+	if (!empty($context['skip_ftp'])) {
1848
+			echo '
1804 1849
 				<input type="hidden" name="skip_ftp" value="1">';
1850
+	}
1805 1851
 
1806 1852
 	// Retain state.
1807
-	foreach ($context['back_look_data'] as $path)
1808
-		echo '
1853
+	foreach ($context['back_look_data'] as $path) {
1854
+			echo '
1809 1855
 				<input type="hidden" name="back_look[]" value="', $path, '">';
1856
+	}
1810 1857
 
1811 1858
 	echo '
1812 1859
 				<input type="hidden" name="method" value="', $context['method'], '">
Please login to merge, or discard this patch.