Completed
Push — release-2.1 ( bcefe7...327bb3 )
by Jeremy
07:48
created
Themes/default/Recent.template.php 1 patch
Braces   +77 added lines, -54 removed lines patch added patch discarded remove patch
@@ -26,9 +26,10 @@  discard block
 block discarded – undo
26 26
 		</div>
27 27
 		<div class="pagesection">', $context['page_index'], '</div>';
28 28
 
29
-	if (empty($context['posts']))
30
-		echo '
29
+	if (empty($context['posts'])) {
30
+			echo '
31 31
 		<div class="windowbg">', $txt['no_messages'], '</div>';
32
+	}
32 33
 
33 34
 	foreach ($context['posts'] as $post)
34 35
 	{
@@ -41,28 +42,33 @@  discard block
 block discarded – undo
41 42
 			</div>
42 43
 			<div class="list_posts">', $post['message'], '</div>';
43 44
 
44
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
45
-			echo '
45
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
46
+					echo '
46 47
 			<ul class="quickbuttons">';
48
+		}
47 49
 
48 50
 		// If they *can* reply?
49
-		if ($post['can_reply'])
50
-			echo '
51
+		if ($post['can_reply']) {
52
+					echo '
51 53
 				<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
54
+		}
52 55
 
53 56
 		// If they *can* quote?
54
-		if ($post['can_quote'])
55
-			echo '
57
+		if ($post['can_quote']) {
58
+					echo '
56 59
 				<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>';
60
+		}
57 61
 
58 62
 		// How about... even... remove it entirely?!
59
-		if ($post['can_delete'])
60
-			echo '
63
+		if ($post['can_delete']) {
64
+					echo '
61 65
 				<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
66
+		}
62 67
 
63
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
64
-			echo '
68
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
69
+					echo '
65 70
 			</ul>';
71
+		}
66 72
 
67 73
 		echo '
68 74
 		</div><!-- $post[css_class] -->';
@@ -83,12 +89,13 @@  discard block
 block discarded – undo
83 89
 	echo '
84 90
 	<div id="recent" class="main_content">';
85 91
 
86
-	if ($context['showCheckboxes'])
87
-		echo '
92
+	if ($context['showCheckboxes']) {
93
+			echo '
88 94
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
89 95
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
90 96
 			<input type="hidden" name="qaction" value="markread">
91 97
 			<input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
98
+	}
92 99
 
93 100
 	if (!empty($context['topics']))
94 101
 	{
@@ -117,11 +124,12 @@  discard block
 block discarded – undo
117 124
 					</div>';
118 125
 
119 126
 		// Show a "select all" box for quick moderation?
120
-		if ($context['showCheckboxes'])
121
-			echo '
127
+		if ($context['showCheckboxes']) {
128
+					echo '
122 129
 					<div class="moderation">
123 130
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
124 131
 					</div>';
132
+		}
125 133
 
126 134
 		echo '
127 135
 				</div><!-- #topic_header -->
@@ -141,17 +149,20 @@  discard block
 block discarded – undo
141 149
 			echo '
142 150
 							<div class="icons floatright">';
143 151
 
144
-			if ($topic['is_locked'])
145
-				echo '
152
+			if ($topic['is_locked']) {
153
+							echo '
146 154
 								<span class="generic_icons lock"></span>';
155
+			}
147 156
 
148
-			if ($topic['is_sticky'])
149
-				echo '
157
+			if ($topic['is_sticky']) {
158
+							echo '
150 159
 								<span class="generic_icons sticky"></span>';
160
+			}
151 161
 
152
-			if ($topic['is_poll'])
153
-				echo '
162
+			if ($topic['is_poll']) {
163
+							echo '
154 164
 								<span class="generic_icons poll"></span>';
165
+			}
155 166
 
156 167
 			echo '
157 168
 							</div>';
@@ -177,19 +188,21 @@  discard block
 block discarded – undo
177 188
 							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
178 189
 						</div>';
179 190
 
180
-			if ($context['showCheckboxes'])
181
-				echo '
191
+			if ($context['showCheckboxes']) {
192
+							echo '
182 193
 						<div class="moderation">
183 194
 							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
184 195
 						</div>';
196
+			}
185 197
 
186 198
 			echo '
187 199
 					</div><!-- $topic[css_class] -->';
188 200
 		}
189 201
 
190
-		if (empty($context['topics']))
191
-			echo '
202
+		if (empty($context['topics'])) {
203
+					echo '
192 204
 					<div style="display: none;"></div>';
205
+		}
193 206
 
194 207
 		echo '
195 208
 				</div><!-- #topic_container -->
@@ -204,25 +217,27 @@  discard block
 block discarded – undo
204 217
 					', $context['page_index'], '
205 218
 				</div>
206 219
 			</div>';
207
-	}
208
-	else
209
-		echo '
220
+	} else {
221
+			echo '
210 222
 			<div class="cat_bar">
211 223
 				<h3 class="catbg centertext">
212 224
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
213 225
 				</h3>
214 226
 			</div>';
227
+	}
215 228
 
216
-	if ($context['showCheckboxes'])
217
-		echo '
229
+	if ($context['showCheckboxes']) {
230
+			echo '
218 231
 		</form>';
232
+	}
219 233
 
220 234
 	echo '
221 235
 	</div><!-- #recent -->';
222 236
 
223
-	if (empty($context['no_topic_listing']))
224
-		template_topic_legend();
225
-}
237
+	if (empty($context['no_topic_listing'])) {
238
+			template_topic_legend();
239
+	}
240
+	}
226 241
 
227 242
 /**
228 243
  * Template for showing unread replies (eg new replies to topics you've posted in)
@@ -234,12 +249,13 @@  discard block
 block discarded – undo
234 249
 	echo '
235 250
 	<div id="recent">';
236 251
 
237
-	if ($context['showCheckboxes'])
238
-		echo '
252
+	if ($context['showCheckboxes']) {
253
+			echo '
239 254
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
240 255
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
241 256
 			<input type="hidden" name="qaction" value="markread">
242 257
 			<input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
258
+	}
243 259
 
244 260
 	if (!empty($context['topics']))
245 261
 	{
@@ -268,11 +284,12 @@  discard block
 block discarded – undo
268 284
 					</div>';
269 285
 
270 286
 		// Show a "select all" box for quick moderation?
271
-		if ($context['showCheckboxes'])
272
-			echo '
287
+		if ($context['showCheckboxes']) {
288
+					echo '
273 289
 					<div class="moderation">
274 290
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
275 291
 					</div>';
292
+		}
276 293
 
277 294
 		echo '
278 295
 				</div><!-- #topic_header -->
@@ -292,17 +309,20 @@  discard block
 block discarded – undo
292 309
 			echo '
293 310
 							<div class="icons floatright">';
294 311
 
295
-			if ($topic['is_locked'])
296
-				echo '
312
+			if ($topic['is_locked']) {
313
+							echo '
297 314
 								<span class="generic_icons lock"></span>';
315
+			}
298 316
 
299
-			if ($topic['is_sticky'])
300
-				echo '
317
+			if ($topic['is_sticky']) {
318
+							echo '
301 319
 								<span class="generic_icons sticky"></span>';
320
+			}
302 321
 
303
-			if ($topic['is_poll'])
304
-				echo '
322
+			if ($topic['is_poll']) {
323
+							echo '
305 324
 								<span class="generic_icons poll"></span>';
325
+			}
306 326
 
307 327
 			echo '
308 328
 							</div>';
@@ -328,11 +348,12 @@  discard block
 block discarded – undo
328 348
 							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
329 349
 						</div>';
330 350
 
331
-			if ($context['showCheckboxes'])
332
-				echo '
351
+			if ($context['showCheckboxes']) {
352
+							echo '
333 353
 						<div class="moderation">
334 354
 							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
335 355
 						</div>';
356
+			}
336 357
 
337 358
 			echo '
338 359
 					</div><!-- $topic[css_class] -->';
@@ -349,24 +370,26 @@  discard block
 block discarded – undo
349 370
 					', $context['page_index'], '
350 371
 				</div>
351 372
 			</div>';
352
-	}
353
-	else
354
-		echo '
373
+	} else {
374
+			echo '
355 375
 			<div class="cat_bar">
356 376
 				<h3 class="catbg centertext">
357 377
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['updated_topics_visit_none'], '
358 378
 				</h3>
359 379
 			</div>';
380
+	}
360 381
 
361
-	if ($context['showCheckboxes'])
362
-		echo '
382
+	if ($context['showCheckboxes']) {
383
+			echo '
363 384
 		</form>';
385
+	}
364 386
 
365 387
 	echo '
366 388
 	</div><!-- #recent -->';
367 389
 
368
-	if (empty($context['no_topic_listing']))
369
-		template_topic_legend();
370
-}
390
+	if (empty($context['no_topic_listing'])) {
391
+			template_topic_legend();
392
+	}
393
+	}
371 394
 
372 395
 ?>
373 396
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Attachments.php 1 patch
Braces   +297 added lines, -224 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
  * Check if the current directory is still valid or not.
@@ -28,22 +29,24 @@  discard block
 block discarded – undo
28 29
 	global $smcFunc, $boarddir, $modSettings, $context;
29 30
 
30 31
 	// Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found.
31
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin')
32
-		$doit = true;
33
-	elseif (empty($modSettings['automanage_attachments']))
34
-		return;
35
-	elseif (!isset($_FILES))
36
-		return;
37
-	elseif (isset($_FILES['attachment']))
38
-		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
32
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') {
33
+			$doit = true;
34
+	} elseif (empty($modSettings['automanage_attachments'])) {
35
+			return;
36
+	} elseif (!isset($_FILES)) {
37
+			return;
38
+	} elseif (isset($_FILES['attachment'])) {
39
+			foreach ($_FILES['attachment']['tmp_name'] as $dummy)
39 40
 			if (!empty($dummy))
40 41
 			{
41 42
 				$doit = true;
43
+	}
42 44
 				break;
43 45
 			}
44 46
 
45
-	if (!isset($doit))
46
-		return;
47
+	if (!isset($doit)) {
48
+			return;
49
+	}
47 50
 
48 51
 	$year = date('Y');
49 52
 	$month = date('m');
@@ -54,21 +57,25 @@  discard block
 block discarded – undo
54 57
 
55 58
 	if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments']))
56 59
 	{
57
-			if (!is_array($modSettings['attachment_basedirectories']))
58
-				$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
60
+			if (!is_array($modSettings['attachment_basedirectories'])) {
61
+							$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
62
+			}
59 63
 			$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
64
+	} else {
65
+			$base_dir = 0;
60 66
 	}
61
-	else
62
-		$base_dir = 0;
63 67
 
64 68
 	if ($modSettings['automanage_attachments'] == 1)
65 69
 	{
66
-		if (!isset($modSettings['last_attachments_directory']))
67
-			$modSettings['last_attachments_directory'] = array();
68
-		if (!is_array($modSettings['last_attachments_directory']))
69
-			$modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true);
70
-		if (!isset($modSettings['last_attachments_directory'][$base_dir]))
71
-			$modSettings['last_attachments_directory'][$base_dir] = 0;
70
+		if (!isset($modSettings['last_attachments_directory'])) {
71
+					$modSettings['last_attachments_directory'] = array();
72
+		}
73
+		if (!is_array($modSettings['last_attachments_directory'])) {
74
+					$modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true);
75
+		}
76
+		if (!isset($modSettings['last_attachments_directory'][$base_dir])) {
77
+					$modSettings['last_attachments_directory'][$base_dir] = 0;
78
+		}
72 79
 	}
73 80
 
74 81
 	$basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
@@ -97,12 +104,14 @@  discard block
 block discarded – undo
97 104
 			$updir = '';
98 105
 	}
99 106
 
100
-	if (!is_array($modSettings['attachmentUploadDir']))
101
-		$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
102
-	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir))
103
-		$outputCreation = automanage_attachments_create_directory($updir);
104
-	elseif (in_array($updir, $modSettings['attachmentUploadDir']))
105
-		$outputCreation = true;
107
+	if (!is_array($modSettings['attachmentUploadDir'])) {
108
+			$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
109
+	}
110
+	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) {
111
+			$outputCreation = automanage_attachments_create_directory($updir);
112
+	} elseif (in_array($updir, $modSettings['attachmentUploadDir'])) {
113
+			$outputCreation = true;
114
+	}
106 115
 
107 116
 	if ($outputCreation)
108 117
 	{
@@ -139,8 +148,9 @@  discard block
 block discarded – undo
139 148
 		$count = count($tree);
140 149
 
141 150
 		$directory = attachments_init_dir($tree, $count);
142
-		if ($directory === false)
143
-			return false;
151
+		if ($directory === false) {
152
+					return false;
153
+		}
144 154
 	}
145 155
 
146 156
 	$directory .= DIRECTORY_SEPARATOR . array_shift($tree);
@@ -168,8 +178,9 @@  discard block
 block discarded – undo
168 178
 	}
169 179
 
170 180
 	// Everything seems fine...let's create the .htaccess
171
-	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess'))
172
-		secureDirectory($updir, true);
181
+	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) {
182
+			secureDirectory($updir, true);
183
+	}
173 184
 
174 185
 	$sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR;
175 186
 	$updir = rtrim($updir, $sep);
@@ -201,8 +212,9 @@  discard block
 block discarded – undo
201 212
 {
202 213
 	global $smcFunc, $modSettings, $boarddir;
203 214
 
204
-	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1))
205
-		return;
215
+	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) {
216
+			return;
217
+	}
206 218
 
207 219
 	$basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir;
208 220
 	// Just to be sure: I don't want directory separators at the end
@@ -214,13 +226,14 @@  discard block
 block discarded – undo
214 226
 	{
215 227
 		$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
216 228
 		$base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0;
229
+	} else {
230
+			$base_dir = 0;
217 231
 	}
218
-	else
219
-		$base_dir = 0;
220 232
 
221 233
 	// Get the last attachment directory for that base directory
222
-	if (empty($modSettings['last_attachments_directory'][$base_dir]))
223
-		$modSettings['last_attachments_directory'][$base_dir] = 0;
234
+	if (empty($modSettings['last_attachments_directory'][$base_dir])) {
235
+			$modSettings['last_attachments_directory'][$base_dir] = 0;
236
+	}
224 237
 	// And increment it.
225 238
 	$modSettings['last_attachments_directory'][$base_dir]++;
226 239
 
@@ -235,10 +248,10 @@  discard block
 block discarded – undo
235 248
 		$modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true);
236 249
 
237 250
 		return true;
251
+	} else {
252
+			return false;
253
+	}
238 254
 	}
239
-	else
240
-		return false;
241
-}
242 255
 
243 256
 /**
244 257
  * Split a path into a list of all directories and subdirectories
@@ -256,12 +269,13 @@  discard block
 block discarded – undo
256 269
 			* in Windows we need to explode for both \ and /
257 270
 			* while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR)
258 271
 	*/
259
-	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
260
-		$tree = preg_split('#[\\\/]#', $directory);
261
-	else
272
+	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
273
+			$tree = preg_split('#[\\\/]#', $directory);
274
+	} else
262 275
 	{
263
-		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR)
264
-			return false;
276
+		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) {
277
+					return false;
278
+		}
265 279
 
266 280
 		$tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR));
267 281
 	}
@@ -285,10 +299,11 @@  discard block
 block discarded – undo
285 299
 		 //Better be sure that the first part of the path is actually a drive letter...
286 300
 		 //...even if, I should check this in the admin page...isn't it?
287 301
 		 //...NHAAA Let's leave space for users' complains! :P
288
-		if (preg_match('/^[a-z]:$/i', $tree[0]))
289
-			$directory = array_shift($tree);
290
-		else
291
-			return false;
302
+		if (preg_match('/^[a-z]:$/i', $tree[0])) {
303
+					$directory = array_shift($tree);
304
+		} else {
305
+					return false;
306
+		}
292 307
 
293 308
 		$count--;
294 309
 	}
@@ -303,18 +318,20 @@  discard block
 block discarded – undo
303 318
 	global $context, $modSettings, $smcFunc, $txt, $user_info;
304 319
 
305 320
 	// Make sure we're uploading to the right place.
306
-	if (!empty($modSettings['automanage_attachments']))
307
-		automanage_attachments_check_directory();
321
+	if (!empty($modSettings['automanage_attachments'])) {
322
+			automanage_attachments_check_directory();
323
+	}
308 324
 
309
-	if (!is_array($modSettings['attachmentUploadDir']))
310
-		$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
325
+	if (!is_array($modSettings['attachmentUploadDir'])) {
326
+			$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
327
+	}
311 328
 
312 329
 	$context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
313 330
 
314 331
 	// Is the attachments folder actualy there?
315
-	if (!empty($context['dir_creation_error']))
316
-		$initial_error = $context['dir_creation_error'];
317
-	elseif (!is_dir($context['attach_dir']))
332
+	if (!empty($context['dir_creation_error'])) {
333
+			$initial_error = $context['dir_creation_error'];
334
+	} elseif (!is_dir($context['attach_dir']))
318 335
 	{
319 336
 		$initial_error = 'attach_folder_warning';
320 337
 		log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical');
@@ -337,12 +354,12 @@  discard block
 block discarded – undo
337 354
 			);
338 355
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
339 356
 			$smcFunc['db_free_result']($request);
340
-		}
341
-		else
342
-			$context['attachments'] = array(
357
+		} else {
358
+					$context['attachments'] = array(
343 359
 				'quantity' => 0,
344 360
 				'total_size' => 0,
345 361
 			);
362
+		}
346 363
 	}
347 364
 
348 365
 	// Hmm. There are still files in session.
@@ -352,39 +369,44 @@  discard block
 block discarded – undo
352 369
 		// Let's try to keep them. But...
353 370
 		$ignore_temp = true;
354 371
 		// If new files are being added. We can't ignore those
355
-		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
356
-			if (!empty($dummy))
372
+		foreach ($_FILES['attachment']['tmp_name'] as $dummy) {
373
+					if (!empty($dummy))
357 374
 			{
358 375
 				$ignore_temp = false;
376
+		}
359 377
 				break;
360 378
 			}
361 379
 
362 380
 		// Need to make space for the new files. So, bye bye.
363 381
 		if (!$ignore_temp)
364 382
 		{
365
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
366
-				if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
383
+			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
384
+							if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
367 385
 					unlink($attachment['tmp_name']);
386
+			}
368 387
 
369 388
 			$context['we_are_history'] = $txt['error_temp_attachments_flushed'];
370 389
 			$_SESSION['temp_attachments'] = array();
371 390
 		}
372 391
 	}
373 392
 
374
-	if (!isset($_FILES['attachment']['name']))
375
-		$_FILES['attachment']['tmp_name'] = array();
393
+	if (!isset($_FILES['attachment']['name'])) {
394
+			$_FILES['attachment']['tmp_name'] = array();
395
+	}
376 396
 
377
-	if (!isset($_SESSION['temp_attachments']))
378
-		$_SESSION['temp_attachments'] = array();
397
+	if (!isset($_SESSION['temp_attachments'])) {
398
+			$_SESSION['temp_attachments'] = array();
399
+	}
379 400
 
380 401
 	// Remember where we are at. If it's anywhere at all.
381
-	if (!$ignore_temp)
382
-		$_SESSION['temp_attachments']['post'] = array(
402
+	if (!$ignore_temp) {
403
+			$_SESSION['temp_attachments']['post'] = array(
383 404
 			'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0,
384 405
 			'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0,
385 406
 			'topic' => !empty($topic) ? $topic : 0,
386 407
 			'board' => !empty($board) ? $board : 0,
387 408
 		);
409
+	}
388 410
 
389 411
 	// If we have an initial error, lets just display it.
390 412
 	if (!empty($initial_error))
@@ -392,9 +414,10 @@  discard block
 block discarded – undo
392 414
 		$_SESSION['temp_attachments']['initial_error'] = $initial_error;
393 415
 
394 416
 		// And delete the files 'cos they ain't going nowhere.
395
-		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
396
-			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
417
+		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
418
+					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
397 419
 				unlink($_FILES['attachment']['tmp_name'][$n]);
420
+		}
398 421
 
399 422
 		$_FILES['attachment']['tmp_name'] = array();
400 423
 	}
@@ -402,21 +425,24 @@  discard block
 block discarded – undo
402 425
 	// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
403 426
 	foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
404 427
 	{
405
-		if ($_FILES['attachment']['name'][$n] == '')
406
-			continue;
428
+		if ($_FILES['attachment']['name'][$n] == '') {
429
+					continue;
430
+		}
407 431
 
408 432
 		// First, let's first check for PHP upload errors.
409 433
 		$errors = array();
410 434
 		if (!empty($_FILES['attachment']['error'][$n]))
411 435
 		{
412
-			if ($_FILES['attachment']['error'][$n] == 2)
413
-				$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
414
-			elseif ($_FILES['attachment']['error'][$n] == 6)
415
-				log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
416
-			else
417
-				log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
418
-			if (empty($errors))
419
-				$errors[] = 'attach_php_error';
436
+			if ($_FILES['attachment']['error'][$n] == 2) {
437
+							$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
438
+			} elseif ($_FILES['attachment']['error'][$n] == 6) {
439
+							log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
440
+			} else {
441
+							log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
442
+			}
443
+			if (empty($errors)) {
444
+							$errors[] = 'attach_php_error';
445
+			}
420 446
 		}
421 447
 
422 448
 		// Try to move and rename the file before doing any more checks on it.
@@ -426,8 +452,9 @@  discard block
 block discarded – undo
426 452
 		{
427 453
 			// The reported MIME type of the attachment might not be reliable.
428 454
 			// Fortunately, PHP 5.3+ lets us easily verify the real MIME type.
429
-			if (function_exists('mime_content_type'))
430
-				$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
455
+			if (function_exists('mime_content_type')) {
456
+							$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
457
+			}
431 458
 
432 459
 			$_SESSION['temp_attachments'][$attachID] = array(
433 460
 				'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -439,16 +466,16 @@  discard block
 block discarded – undo
439 466
 			);
440 467
 
441 468
 			// Move the file to the attachments folder with a temp name for now.
442
-			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
443
-				smf_chmod($destName, 0644);
444
-			else
469
+			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
470
+							smf_chmod($destName, 0644);
471
+			} else
445 472
 			{
446 473
 				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
447
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
448
-					unlink($_FILES['attachment']['tmp_name'][$n]);
474
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
475
+									unlink($_FILES['attachment']['tmp_name'][$n]);
476
+				}
449 477
 			}
450
-		}
451
-		else
478
+		} else
452 479
 		{
453 480
 			$_SESSION['temp_attachments'][$attachID] = array(
454 481
 				'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -456,12 +483,14 @@  discard block
 block discarded – undo
456 483
 				'errors' => $errors,
457 484
 			);
458 485
 
459
-			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
460
-				unlink($_FILES['attachment']['tmp_name'][$n]);
486
+			if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
487
+							unlink($_FILES['attachment']['tmp_name'][$n]);
488
+			}
461 489
 		}
462 490
 		// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
463
-		if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
464
-			attachmentChecks($attachID);
491
+		if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
492
+					attachmentChecks($attachID);
493
+		}
465 494
 	}
466 495
 	// Mod authors, finally a hook to hang an alternate attachment upload system upon
467 496
 	// Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand())
@@ -488,21 +517,20 @@  discard block
 block discarded – undo
488 517
 	global $modSettings, $context, $sourcedir, $smcFunc;
489 518
 
490 519
 	// No data or missing data .... Not necessarily needed, but in case a mod author missed something.
491
-	if (empty($_SESSION['temp_attachments'][$attachID]))
492
-		$error = '$_SESSION[\'temp_attachments\'][$attachID]';
493
-
494
-	elseif (empty($attachID))
495
-		$error = '$attachID';
496
-
497
-	elseif (empty($context['attachments']))
498
-		$error = '$context[\'attachments\']';
499
-
500
-	elseif (empty($context['attach_dir']))
501
-		$error = '$context[\'attach_dir\']';
520
+	if (empty($_SESSION['temp_attachments'][$attachID])) {
521
+			$error = '$_SESSION[\'temp_attachments\'][$attachID]';
522
+	} elseif (empty($attachID)) {
523
+			$error = '$attachID';
524
+	} elseif (empty($context['attachments'])) {
525
+			$error = '$context[\'attachments\']';
526
+	} elseif (empty($context['attach_dir'])) {
527
+			$error = '$context[\'attach_dir\']';
528
+	}
502 529
 
503 530
 	// Let's get their attention.
504
-	if (!empty($error))
505
-		fatal_lang_error('attach_check_nag', 'debug', array($error));
531
+	if (!empty($error)) {
532
+			fatal_lang_error('attach_check_nag', 'debug', array($error));
533
+	}
506 534
 
507 535
 	// Just in case this slipped by the first checks, we stop it here and now
508 536
 	if ($_SESSION['temp_attachments'][$attachID]['size'] == 0)
@@ -531,8 +559,9 @@  discard block
 block discarded – undo
531 559
 			$size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']);
532 560
 			if (!(empty($size)) && ($size[2] != $old_format))
533 561
 			{
534
-				if (isset($context['valid_image_types'][$size[2]]))
535
-					$_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]];
562
+				if (isset($context['valid_image_types'][$size[2]])) {
563
+									$_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]];
564
+				}
536 565
 			}
537 566
 		}
538 567
 	}
@@ -586,42 +615,48 @@  discard block
 block discarded – undo
586 615
 				// Or, let the user know that it ain't gonna happen.
587 616
 				else
588 617
 				{
589
-					if (isset($context['dir_creation_error']))
590
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
591
-					else
592
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
618
+					if (isset($context['dir_creation_error'])) {
619
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
620
+					} else {
621
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
622
+					}
593 623
 				}
624
+			} else {
625
+							$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
594 626
 			}
595
-			else
596
-				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
597 627
 		}
598 628
 	}
599 629
 
600 630
 	// Is the file too big?
601 631
 	$context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size'];
602
-	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024)
603
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
632
+	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) {
633
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
634
+	}
604 635
 
605 636
 	// Check the total upload size for this post...
606
-	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024)
607
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
637
+	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) {
638
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
639
+	}
608 640
 
609 641
 	// Have we reached the maximum number of files we are allowed?
610 642
 	$context['attachments']['quantity']++;
611 643
 
612 644
 	// Set a max limit if none exists
613
-	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50)
614
-		$modSettings['attachmentNumPerPostLimit'] = 50;
645
+	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) {
646
+			$modSettings['attachmentNumPerPostLimit'] = 50;
647
+	}
615 648
 
616
-	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit'])
617
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
649
+	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) {
650
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
651
+	}
618 652
 
619 653
 	// File extension check
620 654
 	if (!empty($modSettings['attachmentCheckExtensions']))
621 655
 	{
622 656
 		$allowed = explode(',', strtolower($modSettings['attachmentExtensions']));
623
-		foreach ($allowed as $k => $dummy)
624
-			$allowed[$k] = trim($dummy);
657
+		foreach ($allowed as $k => $dummy) {
658
+					$allowed[$k] = trim($dummy);
659
+		}
625 660
 
626 661
 		if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed))
627 662
 		{
@@ -633,10 +668,12 @@  discard block
 block discarded – undo
633 668
 	// Undo the math if there's an error
634 669
 	if (!empty($_SESSION['temp_attachments'][$attachID]['errors']))
635 670
 	{
636
-		if (isset($context['dir_size']))
637
-			$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
638
-		if (isset($context['dir_files']))
639
-			$context['dir_files']--;
671
+		if (isset($context['dir_size'])) {
672
+					$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
673
+		}
674
+		if (isset($context['dir_files'])) {
675
+					$context['dir_files']--;
676
+		}
640 677
 		$context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
641 678
 		$context['attachments']['quantity']--;
642 679
 		return false;
@@ -668,12 +705,14 @@  discard block
 block discarded – undo
668 705
 	if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width'])
669 706
 	{
670 707
 		// Got a proper mime type?
671
-		if (!empty($size['mime']))
672
-			$attachmentOptions['mime_type'] = $size['mime'];
708
+		if (!empty($size['mime'])) {
709
+					$attachmentOptions['mime_type'] = $size['mime'];
710
+		}
673 711
 
674 712
 		// Otherwise a valid one?
675
-		elseif (isset($context['valid_image_types'][$size[2]]))
676
-			$attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]];
713
+		elseif (isset($context['valid_image_types'][$size[2]])) {
714
+					$attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]];
715
+		}
677 716
 	}
678 717
 
679 718
 	// It is possible we might have a MIME type that isn't actually an image but still have a size.
@@ -685,15 +724,17 @@  discard block
 block discarded – undo
685 724
 	}
686 725
 
687 726
 	// Get the hash if no hash has been given yet.
688
-	if (empty($attachmentOptions['file_hash']))
689
-		$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);
727
+	if (empty($attachmentOptions['file_hash'])) {
728
+			$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);
729
+	}
690 730
 
691 731
 	// Assuming no-one set the extension let's take a look at it.
692 732
 	if (empty($attachmentOptions['fileext']))
693 733
 	{
694 734
 		$attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : '');
695
-		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name'])
696
-			$attachmentOptions['fileext'] = '';
735
+		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) {
736
+					$attachmentOptions['fileext'] = '';
737
+		}
697 738
 	}
698 739
 
699 740
 	// Last chance to change stuff!
@@ -702,8 +743,9 @@  discard block
 block discarded – undo
702 743
 	// Make sure the folder is valid...
703 744
 	$tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
704 745
 	$folders = array_keys($tmp);
705
-	if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders))
706
-		$attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir'];
746
+	if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) {
747
+			$attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir'];
748
+	}
707 749
 
708 750
 	$attachmentOptions['id'] = $smcFunc['db_insert']('',
709 751
 		'{db_prefix}attachments',
@@ -734,8 +776,8 @@  discard block
 block discarded – undo
734 776
 	rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']);
735 777
 
736 778
 	// If it's not approved then add to the approval queue.
737
-	if (!$attachmentOptions['approved'])
738
-		$smcFunc['db_insert']('',
779
+	if (!$attachmentOptions['approved']) {
780
+			$smcFunc['db_insert']('',
739 781
 			'{db_prefix}approval_queue',
740 782
 			array(
741 783
 				'id_attach' => 'int', 'id_msg' => 'int',
@@ -745,9 +787,11 @@  discard block
 block discarded – undo
745 787
 			),
746 788
 			array()
747 789
 		);
790
+	}
748 791
 
749
-	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height'])))
750
-		return true;
792
+	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) {
793
+			return true;
794
+	}
751 795
 
752 796
 	// Like thumbnails, do we?
753 797
 	if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight']))
@@ -758,13 +802,15 @@  discard block
 block discarded – undo
758 802
 			$size = @getimagesize($attachmentOptions['destination'] . '_thumb');
759 803
 			list ($thumb_width, $thumb_height) = $size;
760 804
 
761
-			if (!empty($size['mime']))
762
-				$thumb_mime = $size['mime'];
763
-			elseif (isset($context['valid_image_types'][$size[2]]))
764
-				$thumb_mime = 'image/' . $context['valid_image_types'][$size[2]];
805
+			if (!empty($size['mime'])) {
806
+							$thumb_mime = $size['mime'];
807
+			} elseif (isset($context['valid_image_types'][$size[2]])) {
808
+							$thumb_mime = 'image/' . $context['valid_image_types'][$size[2]];
809
+			}
765 810
 			// Lord only knows how this happened...
766
-			else
767
-				$thumb_mime = '';
811
+			else {
812
+							$thumb_mime = '';
813
+			}
768 814
 
769 815
 			$thumb_filename = $attachmentOptions['name'] . '_thumb';
770 816
 			$thumb_size = filesize($attachmentOptions['destination'] . '_thumb');
@@ -844,15 +890,17 @@  discard block
 block discarded – undo
844 890
 	global $smcFunc;
845 891
 
846 892
 	// Oh, come on!
847
-	if (empty($attachIDs) || empty($msgID))
848
-		return false;
893
+	if (empty($attachIDs) || empty($msgID)) {
894
+			return false;
895
+	}
849 896
 
850 897
 	// "I see what is right and approve, but I do what is wrong."
851 898
 	call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID));
852 899
 
853 900
 	// One last check
854
-	if (empty($attachIDs))
855
-		return false;
901
+	if (empty($attachIDs)) {
902
+			return false;
903
+	}
856 904
 
857 905
 	// Perform.
858 906
 	$smcFunc['db_query']('', '
@@ -880,8 +928,9 @@  discard block
 block discarded – undo
880 928
 	global $board, $modSettings, $context, $scripturl, $smcFunc;
881 929
 
882 930
 	// Meh...
883
-	if (empty($attachID))
884
-		return 'attachments_no_data_loaded';
931
+	if (empty($attachID)) {
932
+			return 'attachments_no_data_loaded';
933
+	}
885 934
 
886 935
 	// Make it easy.
887 936
 	$msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0;
@@ -890,20 +939,23 @@  discard block
 block discarded – undo
890 939
 	$externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID));
891 940
 
892 941
 	// "I am innocent of the blood of this just person: see ye to it."
893
-	if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse)))
894
-		return $externalParse;
942
+	if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) {
943
+			return $externalParse;
944
+	}
895 945
 
896 946
 	//Are attachments enable?
897
-	if (empty($modSettings['attachmentEnable']))
898
-		return 'attachments_not_enable';
947
+	if (empty($modSettings['attachmentEnable'])) {
948
+			return 'attachments_not_enable';
949
+	}
899 950
 
900 951
 	// Previewing much? no msg ID has been set yet.
901 952
 	if (!empty($context['preview_message']))
902 953
 	{
903 954
 		$allAttachments = getAttachsByMsg(0);
904 955
 
905
-		if (empty($allAttachments[0][$attachID]))
906
-			return 'attachments_no_data_loaded';
956
+		if (empty($allAttachments[0][$attachID])) {
957
+					return 'attachments_no_data_loaded';
958
+		}
907 959
 
908 960
 		$attachLoaded = loadAttachmentContext(0, $allAttachments);
909 961
 
@@ -915,57 +967,66 @@  discard block
 block discarded – undo
915 967
 		$attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>';
916 968
 
917 969
 		// Fix the thumbnail too, if the image has one.
918
-		if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb']))
919
-			$attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview';
970
+		if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) {
971
+					$attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview';
972
+		}
920 973
 
921 974
 		return $attachContext;
922 975
 	}
923 976
 
924 977
 	// There is always the chance someone else has already done our dirty work...
925 978
 	// If so, all pertinent checks were already done. Hopefully...
926
-	if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID]))
927
-		return $context['current_attachments'][$attachID];
979
+	if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) {
980
+			return $context['current_attachments'][$attachID];
981
+	}
928 982
 
929 983
 	// If we are lucky enough to be in $board's scope then check it!
930
-	if (!empty($board) && !allowedTo('view_attachments', $board))
931
-		return 'attachments_not_allowed_to_see';
984
+	if (!empty($board) && !allowedTo('view_attachments', $board)) {
985
+			return 'attachments_not_allowed_to_see';
986
+	}
932 987
 
933 988
 	// Get the message info associated with this particular attach ID.
934 989
 	$attachInfo = getAttachMsgInfo($attachID);
935 990
 
936 991
 	// There is always the chance this attachment no longer exists or isn't associated to a message anymore...
937
-	if (empty($attachInfo) || empty($attachInfo['msg']))
938
-		return 'attachments_no_msg_associated';
992
+	if (empty($attachInfo) || empty($attachInfo['msg'])) {
993
+			return 'attachments_no_msg_associated';
994
+	}
939 995
 
940 996
 	// Hold it! got the info now check if you can see this attachment.
941
-	if (!allowedTo('view_attachments', $attachInfo['board']))
942
-		return 'attachments_not_allowed_to_see';
997
+	if (!allowedTo('view_attachments', $attachInfo['board'])) {
998
+			return 'attachments_not_allowed_to_see';
999
+	}
943 1000
 
944 1001
 	$allAttachments = getAttachsByMsg($attachInfo['msg']);
945 1002
 	$attachContext = $allAttachments[$attachInfo['msg']][$attachID];
946 1003
 
947 1004
 	// No point in keep going further.
948
-	if (!allowedTo('view_attachments', $attachContext['board']))
949
-		return 'attachments_not_allowed_to_see';
1005
+	if (!allowedTo('view_attachments', $attachContext['board'])) {
1006
+			return 'attachments_not_allowed_to_see';
1007
+	}
950 1008
 
951 1009
 	// Load this particular attach's context.
952
-	if (!empty($attachContext))
953
-		$attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments);
1010
+	if (!empty($attachContext)) {
1011
+			$attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments);
1012
+	}
954 1013
 
955 1014
 	// One last check, you know, gotta be paranoid...
956
-	else
957
-		return 'attachments_no_data_loaded';
1015
+	else {
1016
+			return 'attachments_no_data_loaded';
1017
+	}
958 1018
 
959 1019
 	// This is the last "if" I promise!
960
-	if (empty($attachLoaded))
961
-		return 'attachments_no_data_loaded';
962
-
963
-	else
964
-		$attachContext = $attachLoaded[$attachID];
1020
+	if (empty($attachLoaded)) {
1021
+			return 'attachments_no_data_loaded';
1022
+	} else {
1023
+			$attachContext = $attachLoaded[$attachID];
1024
+	}
965 1025
 
966 1026
 	// You may or may not want to show this under the post.
967
-	if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID]))
968
-		$context['show_attach_under_post'][$attachID] = $attachID;
1027
+	if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) {
1028
+			$context['show_attach_under_post'][$attachID] = $attachID;
1029
+	}
969 1030
 
970 1031
 	// Last minute changes?
971 1032
 	call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext));
@@ -985,8 +1046,9 @@  discard block
 block discarded – undo
985 1046
 {
986 1047
 	global $smcFunc, $modSettings;
987 1048
 
988
-	if (empty($attachIDs))
989
-		return array();
1049
+	if (empty($attachIDs)) {
1050
+			return array();
1051
+	}
990 1052
 
991 1053
 	$return = array();
992 1054
 
@@ -1002,11 +1064,12 @@  discard block
 block discarded – undo
1002 1064
 		)
1003 1065
 	);
1004 1066
 
1005
-	if ($smcFunc['db_num_rows']($request) != 1)
1006
-		return array();
1067
+	if ($smcFunc['db_num_rows']($request) != 1) {
1068
+			return array();
1069
+	}
1007 1070
 
1008
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1009
-		$return[$row['id_attach']] = array(
1071
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1072
+			$return[$row['id_attach']] = array(
1010 1073
 			'name' => $smcFunc['htmlspecialchars']($row['filename']),
1011 1074
 			'size' => $row['size'],
1012 1075
 			'attachID' => $row['id_attach'],
@@ -1015,6 +1078,7 @@  discard block
 block discarded – undo
1015 1078
 			'mime_type' => $row['mime_type'],
1016 1079
 			'thumb' => $row['id_thumb'],
1017 1080
 		);
1081
+	}
1018 1082
 	$smcFunc['db_free_result']($request);
1019 1083
 
1020 1084
 	return $return;
@@ -1031,8 +1095,9 @@  discard block
 block discarded – undo
1031 1095
 {
1032 1096
 	global $smcFunc;
1033 1097
 
1034
-	if (empty($attachID))
1035
-		return array();
1098
+	if (empty($attachID)) {
1099
+			return array();
1100
+	}
1036 1101
 
1037 1102
 	$request = $smcFunc['db_query']('', '
1038 1103
 		SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board
@@ -1045,8 +1110,9 @@  discard block
 block discarded – undo
1045 1110
 		)
1046 1111
 	);
1047 1112
 
1048
-	if ($smcFunc['db_num_rows']($request) != 1)
1049
-		return array();
1113
+	if ($smcFunc['db_num_rows']($request) != 1) {
1114
+			return array();
1115
+	}
1050 1116
 
1051 1117
 	$row = $smcFunc['db_fetch_assoc']($request);
1052 1118
 	$smcFunc['db_free_result']($request);
@@ -1087,8 +1153,9 @@  discard block
 block discarded – undo
1087 1153
 		$temp = array();
1088 1154
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1089 1155
 		{
1090
-			if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1091
-				continue;
1156
+			if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1157
+							continue;
1158
+			}
1092 1159
 
1093 1160
 			$temp[$row['id_attach']] = $row;
1094 1161
 		}
@@ -1117,8 +1184,9 @@  discard block
 block discarded – undo
1117 1184
 {
1118 1185
 	global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc;
1119 1186
 
1120
-	if (empty($attachments) || empty($attachments[$id_msg]))
1121
-		return array();
1187
+	if (empty($attachments) || empty($attachments[$id_msg])) {
1188
+			return array();
1189
+	}
1122 1190
 
1123 1191
 	// Set up the attachment info - based on code by Meriadoc.
1124 1192
 	$attachmentData = array();
@@ -1142,11 +1210,13 @@  discard block
 block discarded – undo
1142 1210
 			);
1143 1211
 
1144 1212
 			// If something is unapproved we'll note it so we can sort them.
1145
-			if (!$attachment['approved'])
1146
-				$have_unapproved = true;
1213
+			if (!$attachment['approved']) {
1214
+							$have_unapproved = true;
1215
+			}
1147 1216
 
1148
-			if (!$attachmentData[$i]['is_image'])
1149
-				continue;
1217
+			if (!$attachmentData[$i]['is_image']) {
1218
+							continue;
1219
+			}
1150 1220
 
1151 1221
 			$attachmentData[$i]['real_width'] = $attachment['width'];
1152 1222
 			$attachmentData[$i]['width'] = $attachment['width'];
@@ -1167,11 +1237,11 @@  discard block
 block discarded – undo
1167 1237
 						// So what folder are we putting this image in?
1168 1238
 						if (!empty($modSettings['currentAttachmentUploadDir']))
1169 1239
 						{
1170
-							if (!is_array($modSettings['attachmentUploadDir']))
1171
-								$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1240
+							if (!is_array($modSettings['attachmentUploadDir'])) {
1241
+															$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1242
+							}
1172 1243
 							$id_folder_thumb = $modSettings['currentAttachmentUploadDir'];
1173
-						}
1174
-						else
1244
+						} else
1175 1245
 						{
1176 1246
 							$id_folder_thumb = 1;
1177 1247
 						}
@@ -1185,10 +1255,11 @@  discard block
 block discarded – undo
1185 1255
 						$thumb_ext = isset($context['valid_image_types'][$size[2]]) ? $context['valid_image_types'][$size[2]] : '';
1186 1256
 
1187 1257
 						// Figure out the mime type.
1188
-						if (!empty($size['mime']))
1189
-							$thumb_mime = $size['mime'];
1190
-						else
1191
-							$thumb_mime = 'image/' . $thumb_ext;
1258
+						if (!empty($size['mime'])) {
1259
+													$thumb_mime = $size['mime'];
1260
+						} else {
1261
+													$thumb_mime = 'image/' . $thumb_ext;
1262
+						}
1192 1263
 
1193 1264
 						$thumb_filename = $attachment['filename'] . '_thumb';
1194 1265
 						$thumb_hash = getAttachmentFilename($thumb_filename, false, null, true);
@@ -1236,11 +1307,12 @@  discard block
 block discarded – undo
1236 1307
 				}
1237 1308
 			}
1238 1309
 
1239
-			if (!empty($attachment['id_thumb']))
1240
-				$attachmentData[$i]['thumbnail'] = array(
1310
+			if (!empty($attachment['id_thumb'])) {
1311
+							$attachmentData[$i]['thumbnail'] = array(
1241 1312
 					'id' => $attachment['id_thumb'],
1242 1313
 					'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image',
1243 1314
 				);
1315
+			}
1244 1316
 			$attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']);
1245 1317
 
1246 1318
 			// If thumbnails are disabled, check the maximum size of the image.
@@ -1250,30 +1322,31 @@  discard block
 block discarded – undo
1250 1322
 				{
1251 1323
 					$attachmentData[$i]['width'] = $modSettings['max_image_width'];
1252 1324
 					$attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']);
1253
-				}
1254
-				elseif (!empty($modSettings['max_image_width']))
1325
+				} elseif (!empty($modSettings['max_image_width']))
1255 1326
 				{
1256 1327
 					$attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']);
1257 1328
 					$attachmentData[$i]['height'] = $modSettings['max_image_height'];
1258 1329
 				}
1259
-			}
1260
-			elseif ($attachmentData[$i]['thumbnail']['has_thumb'])
1330
+			} elseif ($attachmentData[$i]['thumbnail']['has_thumb'])
1261 1331
 			{
1262 1332
 				// If the image is too large to show inline, make it a popup.
1263
-				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height'])))
1264
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
1265
-				else
1266
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
1333
+				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) {
1334
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
1335
+				} else {
1336
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
1337
+				}
1267 1338
 			}
1268 1339
 
1269
-			if (!$attachmentData[$i]['thumbnail']['has_thumb'])
1270
-				$attachmentData[$i]['downloads']++;
1340
+			if (!$attachmentData[$i]['thumbnail']['has_thumb']) {
1341
+							$attachmentData[$i]['downloads']++;
1342
+			}
1271 1343
 		}
1272 1344
 	}
1273 1345
 
1274 1346
 	// Do we need to instigate a sort?
1275
-	if ($have_unapproved)
1276
-		usort($attachmentData, 'approved_attach_sort');
1347
+	if ($have_unapproved) {
1348
+			usort($attachmentData, 'approved_attach_sort');
1349
+	}
1277 1350
 
1278 1351
 	return $attachmentData;
1279 1352
 }
Please login to merge, or discard this patch.
Themes/default/GenericList.template.php 1 patch
Braces   +65 added lines, -46 removed lines patch added patch discarded remove patch
@@ -22,27 +22,31 @@  discard block
 block discarded – undo
22 22
 	// Get a shortcut to the current list.
23 23
 	$list_id = $list_id === null ? (!empty($context['default_list']) ? $context['default_list'] : '') : $list_id;
24 24
 
25
-	if (empty($list_id) || empty($context[$list_id]))
26
-		return;
25
+	if (empty($list_id) || empty($context[$list_id])) {
26
+			return;
27
+	}
27 28
 
28 29
 	$cur_list = &$context[$list_id];
29 30
 
30 31
 	// These are the main tabs that is used all around the template.
31
-	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top'))
32
-		template_create_list_menu($cur_list['list_menu'], 'top');
32
+	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) {
33
+			template_create_list_menu($cur_list['list_menu'], 'top');
34
+	}
33 35
 
34
-	if (isset($cur_list['form']))
35
-		echo '
36
+	if (isset($cur_list['form'])) {
37
+			echo '
36 38
 	<form action="', $cur_list['form']['href'], '" method="post"', empty($cur_list['form']['name']) ? '' : ' name="' . $cur_list['form']['name'] . '" id="' . $cur_list['form']['name'] . '"', ' accept-charset="', $context['character_set'], '">';
39
+	}
37 40
 
38 41
 	// Show the title of the table (if any).
39
-	if (!empty($cur_list['title']))
40
-		echo '
42
+	if (!empty($cur_list['title'])) {
43
+			echo '
41 44
 		<div class="cat_bar">
42 45
 			<h3 class="catbg">
43 46
 				', $cur_list['title'], '
44 47
 			</h3>
45 48
 		</div>';
49
+	}
46 50
 
47 51
 	if (isset($cur_list['additional_rows']['after_title']))
48 52
 	{
@@ -55,20 +59,23 @@  discard block
 block discarded – undo
55 59
 		</div>';
56 60
 	}
57 61
 
58
-	if (isset($cur_list['additional_rows']['top_of_list']))
59
-		template_additional_rows('top_of_list', $cur_list);
62
+	if (isset($cur_list['additional_rows']['top_of_list'])) {
63
+			template_additional_rows('top_of_list', $cur_list);
64
+	}
60 65
 
61 66
 	if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['above_column_headers']))
62 67
 	{
63 68
 		// Show the page index (if this list doesn't intend to show all items).
64
-		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index']))
65
-			echo '
69
+		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) {
70
+					echo '
66 71
 		<div class="floatleft">
67 72
 			<div class="pagesection">', $cur_list['page_index'], '</div>
68 73
 		</div>';
74
+		}
69 75
 
70
-		if (isset($cur_list['additional_rows']['above_column_headers']))
71
-			template_additional_rows('above_column_headers', $cur_list);
76
+		if (isset($cur_list['additional_rows']['above_column_headers'])) {
77
+					template_additional_rows('above_column_headers', $cur_list);
78
+		}
72 79
 	}
73 80
 
74 81
 	echo '
@@ -83,11 +90,12 @@  discard block
 block discarded – undo
83 90
 				<tr class="title_bar">';
84 91
 
85 92
 		// Loop through each column and add a table header.
86
-		foreach ($cur_list['headers'] as $col_header)
87
-			echo '
93
+		foreach ($cur_list['headers'] as $col_header) {
94
+					echo '
88 95
 					<th scope="col" id="header_', $list_id, '_', $col_header['id'], '" class="' , $col_header['id'], empty($col_header['class']) ? '' : ' '.$col_header['class'] , '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '>
89 96
 						', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? '' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <span class="generic_icons sort_' . $col_header['sort_image'] . '"></span></a>'), '
90 97
 					</th>';
98
+		}
91 99
 
92 100
 		echo '
93 101
 				</tr>
@@ -98,13 +106,14 @@  discard block
 block discarded – undo
98 106
 			<tbody>';
99 107
 
100 108
 	// Show a nice message informing there are no items in this list.
101
-	if (empty($cur_list['rows']) && !empty($cur_list['no_items_label']))
102
-		echo '
109
+	if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) {
110
+			echo '
103 111
 				<tr class="windowbg">
104 112
 					<td colspan="', $cur_list['num_columns'], '" class="', !empty($cur_list['no_items_align']) ? $cur_list['no_items_align'] : 'centertext', '">
105 113
 						', $cur_list['no_items_label'], '
106 114
 					</td>
107 115
 				</tr>';
116
+	}
108 117
 
109 118
 	// Show the list rows.
110 119
 	elseif (!empty($cur_list['rows']))
@@ -114,12 +123,13 @@  discard block
 block discarded – undo
114 123
 			echo '
115 124
 				<tr class="windowbg', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', ' id="list_', $list_id, '_', $id, '">';
116 125
 
117
-			if (!empty($row['data']))
118
-				foreach ($row['data'] as $row_id => $row_data)
126
+			if (!empty($row['data'])) {
127
+							foreach ($row['data'] as $row_id => $row_data)
119 128
 					echo '
120 129
 					<td class="', $row_id, empty($row_data['class']) ? '' : ' ' . $row_data['class'] .'', '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '>
121 130
 						', $row_data['value'], '
122 131
 					</td>';
132
+			}
123 133
 
124 134
 			echo '
125 135
 				</tr>';
@@ -136,46 +146,53 @@  discard block
 block discarded – undo
136 146
 		<div class="flow_auto">';
137 147
 
138 148
 		// Show the page index (if this list doesn't intend to show all items).
139
-		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index']))
140
-			echo '
149
+		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) {
150
+					echo '
141 151
 			<div class="floatleft">
142 152
 				<div class="pagesection">', $cur_list['page_index'], '</div>
143 153
 			</div>';
154
+		}
144 155
 
145
-		if (isset($cur_list['additional_rows']['below_table_data']))
146
-			template_additional_rows('below_table_data', $cur_list);
156
+		if (isset($cur_list['additional_rows']['below_table_data'])) {
157
+					template_additional_rows('below_table_data', $cur_list);
158
+		}
147 159
 
148 160
 		echo '
149 161
 		</div>';
150 162
 	}
151 163
 
152
-	if (isset($cur_list['additional_rows']['bottom_of_list']))
153
-		template_additional_rows('bottom_of_list', $cur_list);
164
+	if (isset($cur_list['additional_rows']['bottom_of_list'])) {
165
+			template_additional_rows('bottom_of_list', $cur_list);
166
+	}
154 167
 
155 168
 	if (isset($cur_list['form']))
156 169
 	{
157
-		foreach ($cur_list['form']['hidden_fields'] as $name => $value)
158
-			echo '
170
+		foreach ($cur_list['form']['hidden_fields'] as $name => $value) {
171
+					echo '
159 172
 		<input type="hidden" name="', $name, '" value="', $value, '">';
173
+		}
160 174
 
161
-		if (isset($cur_list['form']['token']))
162
-			echo '
175
+		if (isset($cur_list['form']['token'])) {
176
+					echo '
163 177
 		<input type="hidden" name="', $context[$cur_list['form']['token'] . '_token_var'], '" value="', $context[$cur_list['form']['token'] . '_token'], '">';
178
+		}
164 179
 
165 180
 		echo '
166 181
 	</form>';
167 182
 	}
168 183
 
169 184
 	// Tabs at the bottom.  Usually bottom aligned.
170
-	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom'))
171
-		template_create_list_menu($cur_list['list_menu'], 'bottom');
185
+	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom')) {
186
+			template_create_list_menu($cur_list['list_menu'], 'bottom');
187
+	}
172 188
 
173
-	if (isset($cur_list['javascript']))
174
-		echo '
189
+	if (isset($cur_list['javascript'])) {
190
+			echo '
175 191
 	<script>
176 192
 		', $cur_list['javascript'], '
177 193
 	</script>';
178
-}
194
+	}
195
+	}
179 196
 
180 197
 /**
181 198
  * This template displays additional rows above or below the list.
@@ -185,12 +202,13 @@  discard block
 block discarded – undo
185 202
  */
186 203
 function template_additional_rows($row_position, $cur_list)
187 204
 {
188
-	foreach ($cur_list['additional_rows'][$row_position] as $row)
189
-		echo '
205
+	foreach ($cur_list['additional_rows'][$row_position] as $row) {
206
+			echo '
190 207
 			<div class="additional_row', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '>
191 208
 				', $row['value'], '
192 209
 			</div>';
193
-}
210
+	}
211
+	}
194 212
 
195 213
 /**
196 214
  * This function creates a menu
@@ -249,18 +267,19 @@  discard block
 block discarded – undo
249 267
 
250 268
 		foreach ($list_menu['links'] as $link)
251 269
 		{
252
-			if ($link['is_selected'])
253
-				echo '
270
+			if ($link['is_selected']) {
271
+							echo '
254 272
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $first, '"></td>
255 273
 							<td class="', $direction == 'top' ? 'mirrortab' : 'maintab', '_active_back">
256 274
 								<a href="', $link['href'], '">', $link['label'], '</a>
257 275
 							</td>
258 276
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $last, '"></td>';
259
-			else
260
-				echo '
277
+			} else {
278
+							echo '
261 279
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back">
262 280
 								<a href="', $link['href'], '">', $link['label'], '</a>
263 281
 							</td>';
282
+			}
264 283
 		}
265 284
 
266 285
 		echo '
@@ -271,12 +290,12 @@  discard block
 block discarded – undo
271 290
 				<td></td>' : '', '
272 291
 			</tr>
273 292
 		</table>';
274
-	}
275
-	elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons')
293
+	} elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons')
276 294
 	{
277 295
 		$links = array();
278
-		foreach ($list_menu['links'] as $link)
279
-			$links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';
296
+		foreach ($list_menu['links'] as $link) {
297
+					$links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';
298
+		}
280 299
 
281 300
 		echo '
282 301
 		<table style="margin-', $list_menu['position'], ': 10px; width: 100%;">
Please login to merge, or discard this patch.
Themes/default/Search.template.php 1 patch
Braces   +75 added lines, -55 removed lines patch added patch discarded remove patch
@@ -20,17 +20,19 @@  discard block
 block discarded – undo
20 20
 	echo '
21 21
 	<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">';
22 22
 
23
-	if (!empty($context['search_errors']))
24
-		echo '
23
+	if (!empty($context['search_errors'])) {
24
+			echo '
25 25
 		<div class="errorbox">
26 26
 			', implode('<br>', $context['search_errors']['messages']), '
27 27
 		</div>';
28
+	}
28 29
 
29
-	if (!empty($context['search_ignored']))
30
-		echo '
30
+	if (!empty($context['search_ignored'])) {
31
+			echo '
31 32
 		<div class="noticebox">
32 33
 			', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
33 34
 		</div>';
35
+	}
34 36
 
35 37
 	echo '
36 38
 		<div class="cat_bar">
@@ -48,9 +50,10 @@  discard block
 block discarded – undo
48 50
 				<dd>
49 51
 					<input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">';
50 52
 
51
-	if (empty($modSettings['search_simple_fulltext']))
52
-		echo '
53
+	if (empty($modSettings['search_simple_fulltext'])) {
54
+			echo '
53 55
 					<br><em class="smalltext">', $txt['search_example'], '</em>';
56
+	}
54 57
 
55 58
 	echo '
56 59
 				</dd>
@@ -114,21 +117,23 @@  discard block
 block discarded – undo
114 117
 			<input type="hidden" name="advanced" value="1">';
115 118
 
116 119
 	// Require an image to be typed to save spamming?
117
-	if ($context['require_verification'])
118
-		echo '
120
+	if ($context['require_verification']) {
121
+			echo '
119 122
 			<p>
120 123
 				<strong>', $txt['verification'], ':</strong>
121 124
 				', template_control_verification($context['visual_verification_id'], 'all'), '
122 125
 			</p>';
126
+	}
123 127
 
124 128
 	// If $context['search_params']['topic'] is set, that means we're searching just one topic.
125
-	if (!empty($context['search_params']['topic']))
126
-		echo '
129
+	if (!empty($context['search_params']['topic'])) {
130
+			echo '
127 131
 			<p>
128 132
 				', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.
129 133
 			</p>
130 134
 			<input type="hidden" name="topic" value="', $context['search_topic']['id'], '">
131 135
 			<input type="submit" name="b_search" value="', $txt['search'], '" class="button">';
136
+	}
132 137
 
133 138
 	echo '
134 139
 		</div>';
@@ -238,17 +243,19 @@  discard block
 block discarded – undo
238 243
 		<div class="roundframe">';
239 244
 
240 245
 		// Did they make any typos or mistakes, perhaps?
241
-		if (isset($context['did_you_mean']))
242
-			echo '
246
+		if (isset($context['did_you_mean'])) {
247
+					echo '
243 248
 			<p>
244 249
 				', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.
245 250
 			</p>';
251
+		}
246 252
 
247
-		if (!empty($context['search_ignored']))
248
-			echo '
253
+		if (!empty($context['search_ignored'])) {
254
+					echo '
249 255
 			<p>
250 256
 				', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
251 257
 			</p>';
258
+		}
252 259
 
253 260
 		echo '
254 261
 			<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -271,10 +278,11 @@  discard block
 block discarded – undo
271 278
 					<input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '">
272 279
 				</div>';
273 280
 
274
-		if (!empty($context['search_params']['brd']))
275
-			foreach ($context['search_params']['brd'] as $board_id)
281
+		if (!empty($context['search_params']['brd'])) {
282
+					foreach ($context['search_params']['brd'] as $board_id)
276 283
 				echo '
277 284
 				<input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">';
285
+		}
278 286
 
279 287
 		echo '
280 288
 			</form>
@@ -285,18 +293,20 @@  discard block
 block discarded – undo
285 293
 	if ($context['compact'])
286 294
 	{
287 295
 		// Quick moderation set to checkboxes? Oh, how fun :/
288
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
289
-			echo '
296
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
297
+					echo '
290 298
 	<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">';
299
+		}
291 300
 
292 301
 		echo '
293 302
 		<div class="cat_bar">
294 303
 			<h3 class="catbg">
295 304
 				<span class="floatright">';
296 305
 
297
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
298
-			echo '
306
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
307
+					echo '
299 308
 					<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">';
309
+		}
300 310
 		echo '
301 311
 				</span>
302 312
 				<span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], '
@@ -304,15 +314,15 @@  discard block
 block discarded – undo
304 314
 		</div>';
305 315
 
306 316
 		// Was anything even found?
307
-		if (!empty($context['topics']))
308
-			echo '
317
+		if (!empty($context['topics'])) {
318
+					echo '
309 319
 		<div class="pagesection">
310 320
 			<span>', $context['page_index'], '</span>
311 321
 		</div>';
312
-
313
-		else
314
-			echo '
322
+		} else {
323
+					echo '
315 324
 		<div class="roundframe noup">', $txt['find_no_results'], '</div>';
325
+		}
316 326
 
317 327
 		// While we have results to show ...
318 328
 		while ($topic = $context['get_topics']())
@@ -335,31 +345,35 @@  discard block
 block discarded – undo
335 345
 					echo '
336 346
 				<span class="floatright">';
337 347
 
338
-					if ($options['display_quick_mod'] == 1)
339
-						echo '
348
+					if ($options['display_quick_mod'] == 1) {
349
+											echo '
340 350
 					<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
341
-
342
-					else
351
+					} else
343 352
 					{
344
-						if ($topic['quick_mod']['remove'])
345
-							echo '
353
+						if ($topic['quick_mod']['remove']) {
354
+													echo '
346 355
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
356
+						}
347 357
 
348
-						if ($topic['quick_mod']['lock'])
349
-							echo '
358
+						if ($topic['quick_mod']['lock']) {
359
+													echo '
350 360
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
361
+						}
351 362
 
352
-						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
353
-							echo '
363
+						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
364
+													echo '
354 365
 					<br>';
366
+						}
355 367
 
356
-						if ($topic['quick_mod']['sticky'])
357
-							echo '
368
+						if ($topic['quick_mod']['sticky']) {
369
+													echo '
358 370
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
371
+						}
359 372
 
360
-						if ($topic['quick_mod']['move'])
361
-							echo '
373
+						if ($topic['quick_mod']['move']) {
374
+													echo '
362 375
 					<a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
376
+						}
363 377
 					}
364 378
 
365 379
 					echo '
@@ -369,20 +383,22 @@  discard block
 block discarded – undo
369 383
 			echo '
370 384
 			</div><!-- .block -->';
371 385
 
372
-				if ($message['body_highlighted'] != '')
373
-					echo '
386
+				if ($message['body_highlighted'] != '') {
387
+									echo '
374 388
 				<div class="list_posts double_height">', $message['body_highlighted'], '</div>';
389
+				}
375 390
 			}
376 391
 
377 392
 			echo '
378 393
 		</div><!-- $topic[css_class] -->';
379 394
 		}
380 395
 
381
-		if (!empty($context['topics']))
382
-			echo '
396
+		if (!empty($context['topics'])) {
397
+					echo '
383 398
 		<div class="pagesection">
384 399
 			<span>', $context['page_index'], '</span>
385 400
 		</div>';
401
+		}
386 402
 
387 403
 		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
388 404
 		{
@@ -391,17 +407,19 @@  discard block
 block discarded – undo
391 407
 			<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
392 408
 				<option value="">--------</option>';
393 409
 
394
-			foreach ($context['qmod_actions'] as $qmod_action)
395
-				if ($context['can_' . $qmod_action])
410
+			foreach ($context['qmod_actions'] as $qmod_action) {
411
+							if ($context['can_' . $qmod_action])
396 412
 					echo '
397 413
 				<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
414
+			}
398 415
 
399 416
 			echo '
400 417
 			</select>';
401 418
 
402
-			if ($context['can_move'])
403
-				echo '
419
+			if ($context['can_move']) {
420
+							echo '
404 421
 			<span id="quick_mod_jump_to"></span>';
422
+			}
405 423
 
406 424
 			echo '
407 425
 			<input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '">
@@ -410,12 +428,12 @@  discard block
 block discarded – undo
410 428
 		}
411 429
 
412 430
 
413
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
414
-			echo '
431
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) {
432
+					echo '
415 433
 		<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
416 434
 	</form>';
417
-	}
418
-	else
435
+		}
436
+	} else
419 437
 	{
420 438
 		echo '
421 439
 	<div class="cat_bar">
@@ -427,9 +445,10 @@  discard block
 block discarded – undo
427 445
 		<span>', $context['page_index'], '</span>
428 446
 	</div>';
429 447
 
430
-		if (empty($context['topics']))
431
-			echo '
448
+		if (empty($context['topics'])) {
449
+					echo '
432 450
 	<div class="information">(', $txt['search_no_results'], ')</div>';
451
+		}
433 452
 
434 453
 		while ($topic = $context['get_topics']())
435 454
 		{
@@ -464,8 +483,8 @@  discard block
 block discarded – undo
464 483
 	<div class="smalltext righttext" id="search_jump_to"></div>
465 484
 	<script>';
466 485
 
467
-	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
468
-		echo '
486
+	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
487
+			echo '
469 488
 		if (typeof(window.XMLHttpRequest) != "undefined")
470 489
 			aJumpTo[aJumpTo.length] = new JumpTo({
471 490
 				sContainerId: "quick_mod_jump_to",
@@ -480,6 +499,7 @@  discard block
 block discarded – undo
480 499
 				bDisabled: true,
481 500
 				sCustomName: "move_to"
482 501
 			});';
502
+	}
483 503
 
484 504
 	echo '
485 505
 		if (typeof(window.XMLHttpRequest) != "undefined")
Please login to merge, or discard this patch.
Sources/Profile-Modify.php 1 patch
Braces   +710 added lines, -533 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * This defines every profile field known to man.
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $sourcedir, $profile_vars;
30 31
 
31 32
 	// Don't load this twice!
32
-	if (!empty($profile_fields) && !$force_reload)
33
-		return;
33
+	if (!empty($profile_fields) && !$force_reload) {
34
+			return;
35
+	}
34 36
 
35 37
 	/* This horrific array defines all the profile fields in the whole world!
36 38
 		In general each "field" has one array - the key of which is the database column name associated with said field. Each item
@@ -103,13 +105,14 @@  discard block
 block discarded – undo
103 105
 				if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0)
104 106
 				{
105 107
 					// Set to blank?
106
-					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1)
107
-						$value = '1004-01-01';
108
-					else
109
-						$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
108
+					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) {
109
+											$value = '1004-01-01';
110
+					} else {
111
+											$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
112
+					}
113
+				} else {
114
+									$value = '1004-01-01';
110 115
 				}
111
-				else
112
-					$value = '1004-01-01';
113 116
 
114 117
 				$profile_vars['birthdate'] = $value;
115 118
 				$cur_profile['birthdate'] = $value;
@@ -127,8 +130,7 @@  discard block
 block discarded – undo
127 130
 				{
128 131
 					$value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01';
129 132
 					return true;
130
-				}
131
-				else
133
+				} else
132 134
 				{
133 135
 					$value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate'];
134 136
 					return false;
@@ -150,10 +152,11 @@  discard block
 block discarded – undo
150 152
 					return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false));
151 153
 				}
152 154
 				// As long as it doesn't equal "N/A"...
153
-				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600)))
154
-					$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
155
-				else
156
-					$value = $cur_profile['date_registered'];
155
+				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) {
156
+									$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
157
+				} else {
158
+									$value = $cur_profile['date_registered'];
159
+				}
157 160
 
158 161
 				return true;
159 162
 			},
@@ -177,8 +180,9 @@  discard block
 block discarded – undo
177 180
 			{
178 181
 				global $context, $old_profile, $profile_vars, $sourcedir, $modSettings;
179 182
 
180
-				if (strtolower($value) == strtolower($old_profile['email_address']))
181
-					return false;
183
+				if (strtolower($value) == strtolower($old_profile['email_address'])) {
184
+									return false;
185
+				}
182 186
 
183 187
 				$isValid = profileValidateEmail($value, $context['id_member']);
184 188
 
@@ -254,11 +258,11 @@  discard block
 block discarded – undo
254 258
 
255 259
 				if (isset($context['profile_languages'][$value]))
256 260
 				{
257
-					if ($context['user']['is_owner'] && empty($context['password_auth_failed']))
258
-						$_SESSION['language'] = $value;
261
+					if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) {
262
+											$_SESSION['language'] = $value;
263
+					}
259 264
 					return true;
260
-				}
261
-				else
265
+				} else
262 266
 				{
263 267
 					$value = $cur_profile['lngfile'];
264 268
 					return false;
@@ -282,13 +286,14 @@  discard block
 block discarded – undo
282 286
 
283 287
 					// Maybe they are trying to change their password as well?
284 288
 					$resetPassword = true;
285
-					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null)
286
-						$resetPassword = false;
289
+					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) {
290
+											$resetPassword = false;
291
+					}
287 292
 
288 293
 					// Do the reset... this will send them an email too.
289
-					if ($resetPassword)
290
-						resetPassword($context['id_member'], $value);
291
-					elseif ($value !== null)
294
+					if ($resetPassword) {
295
+											resetPassword($context['id_member'], $value);
296
+					} elseif ($value !== null)
292 297
 					{
293 298
 						validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)));
294 299
 						updateMemberData($context['id_member'], array('member_name' => $value));
@@ -312,20 +317,23 @@  discard block
 block discarded – undo
312 317
 			'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile)
313 318
 			{
314 319
 				// If we didn't try it then ignore it!
315
-				if ($value == '')
316
-					return false;
320
+				if ($value == '') {
321
+									return false;
322
+				}
317 323
 
318 324
 				// Do the two entries for the password even match?
319
-				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2'])
320
-					return 'bad_new_password';
325
+				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) {
326
+									return 'bad_new_password';
327
+				}
321 328
 
322 329
 				// Let's get the validation function into play...
323 330
 				require_once($sourcedir . '/Subs-Auth.php');
324 331
 				$passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email']));
325 332
 
326 333
 				// Were there errors?
327
-				if ($passwordErrors != null)
328
-					return 'password_' . $passwordErrors;
334
+				if ($passwordErrors != null) {
335
+									return 'password_' . $passwordErrors;
336
+				}
329 337
 
330 338
 				// Set up the new password variable... ready for storage.
331 339
 				$value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value));
@@ -350,8 +358,9 @@  discard block
 block discarded – undo
350 358
 			'permission' => 'profile_blurb',
351 359
 			'input_validate' => function(&$value) use ($smcFunc)
352 360
 			{
353
-				if ($smcFunc['strlen']($value) > 50)
354
-					return 'personal_text_too_long';
361
+				if ($smcFunc['strlen']($value) > 50) {
362
+									return 'personal_text_too_long';
363
+				}
355 364
 
356 365
 				return true;
357 366
 			},
@@ -386,10 +395,11 @@  discard block
 block discarded – undo
386 395
 			'permission' => 'moderate_forum',
387 396
 			'input_validate' => function(&$value)
388 397
 			{
389
-				if (!is_numeric($value))
390
-					return 'digits_only';
391
-				else
392
-					$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
398
+				if (!is_numeric($value)) {
399
+									return 'digits_only';
400
+				} else {
401
+									$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
402
+				}
393 403
 				return true;
394 404
 			},
395 405
 		),
@@ -405,15 +415,16 @@  discard block
 block discarded – undo
405 415
 			{
406 416
 				$value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value));
407 417
 
408
-				if (trim($value) == '')
409
-					return 'no_name';
410
-				elseif ($smcFunc['strlen']($value) > 60)
411
-					return 'name_too_long';
412
-				elseif ($cur_profile['real_name'] != $value)
418
+				if (trim($value) == '') {
419
+									return 'no_name';
420
+				} elseif ($smcFunc['strlen']($value) > 60) {
421
+									return 'name_too_long';
422
+				} elseif ($cur_profile['real_name'] != $value)
413 423
 				{
414 424
 					require_once($sourcedir . '/Subs-Members.php');
415
-					if (isReservedName($value, $context['id_member']))
416
-						return 'name_taken';
425
+					if (isReservedName($value, $context['id_member'])) {
426
+											return 'name_taken';
427
+					}
417 428
 				}
418 429
 				return true;
419 430
 			},
@@ -471,8 +482,9 @@  discard block
 block discarded – undo
471 482
 						'selected' => $set == $context['member']['smiley_set']['id']
472 483
 					);
473 484
 
474
-					if ($context['smiley_sets'][$i]['selected'])
475
-						$context['member']['smiley_set']['name'] = $set_names[$i];
485
+					if ($context['smiley_sets'][$i]['selected']) {
486
+											$context['member']['smiley_set']['name'] = $set_names[$i];
487
+					}
476 488
 				}
477 489
 				return true;
478 490
 			},
@@ -481,8 +493,9 @@  discard block
 block discarded – undo
481 493
 				global $modSettings;
482 494
 
483 495
 				$smiley_sets = explode(',', $modSettings['smiley_sets_known']);
484
-				if (!in_array($value, $smiley_sets) && $value != 'none')
485
-					$value = '';
496
+				if (!in_array($value, $smiley_sets) && $value != 'none') {
497
+									$value = '';
498
+				}
486 499
 				return true;
487 500
 			},
488 501
 		),
@@ -497,8 +510,9 @@  discard block
 block discarded – undo
497 510
 				loadLanguage('Settings');
498 511
 
499 512
 				$context['allow_no_censored'] = false;
500
-				if ($user_info['is_admin'] || $context['user']['is_owner'])
501
-					$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
513
+				if ($user_info['is_admin'] || $context['user']['is_owner']) {
514
+									$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
515
+				}
502 516
 
503 517
 				return true;
504 518
 			},
@@ -545,8 +559,9 @@  discard block
 block discarded – undo
545 559
 			'input_validate' => function($value)
546 560
 			{
547 561
 				$tz = smf_list_timezones();
548
-				if (!isset($tz[$value]))
549
-					return 'bad_timezone';
562
+				if (!isset($tz[$value])) {
563
+									return 'bad_timezone';
564
+				}
550 565
 
551 566
 				return true;
552 567
 			},
@@ -561,8 +576,9 @@  discard block
 block discarded – undo
561 576
 			'enabled' => !empty($modSettings['titlesEnable']),
562 577
 			'input_validate' => function(&$value) use ($smcFunc)
563 578
 			{
564
-				if ($smcFunc['strlen']($value) > 50)
565
-					return 'user_title_too_long';
579
+				if ($smcFunc['strlen']($value) > 50) {
580
+									return 'user_title_too_long';
581
+				}
566 582
 
567 583
 				return true;
568 584
 			},
@@ -584,10 +600,12 @@  discard block
 block discarded – undo
584 600
 			// Fix the URL...
585 601
 			'input_validate' => function(&$value)
586 602
 			{
587
-				if (strlen(trim($value)) > 0 && strpos($value, '://') === false)
588
-					$value = 'http://' . $value;
589
-				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://'))
590
-					$value = '';
603
+				if (strlen(trim($value)) > 0 && strpos($value, '://') === false) {
604
+									$value = 'http://' . $value;
605
+				}
606
+				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) {
607
+									$value = '';
608
+				}
591 609
 				$value = (string) validate_iri(sanitize_iri($value));
592 610
 				return true;
593 611
 			},
@@ -602,16 +620,19 @@  discard block
 block discarded – undo
602 620
 	foreach ($profile_fields as $key => $field)
603 621
 	{
604 622
 		// Do we have permission to do this?
605
-		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission']))
606
-			unset($profile_fields[$key]);
623
+		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) {
624
+					unset($profile_fields[$key]);
625
+		}
607 626
 
608 627
 		// Is it enabled?
609
-		if (isset($field['enabled']) && !$field['enabled'])
610
-			unset($profile_fields[$key]);
628
+		if (isset($field['enabled']) && !$field['enabled']) {
629
+					unset($profile_fields[$key]);
630
+		}
611 631
 
612 632
 		// Is it specifically disabled?
613
-		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields)))
614
-			unset($profile_fields[$key]);
633
+		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) {
634
+					unset($profile_fields[$key]);
635
+		}
615 636
 	}
616 637
 }
617 638
 
@@ -636,9 +657,10 @@  discard block
 block discarded – undo
636 657
 	loadProfileFields(true);
637 658
 
638 659
 	// First check for any linked sets.
639
-	foreach ($profile_fields as $key => $field)
640
-		if (isset($field['link_with']) && in_array($field['link_with'], $fields))
660
+	foreach ($profile_fields as $key => $field) {
661
+			if (isset($field['link_with']) && in_array($field['link_with'], $fields))
641 662
 			$fields[] = $key;
663
+	}
642 664
 
643 665
 	$i = 0;
644 666
 	$last_type = '';
@@ -650,38 +672,46 @@  discard block
 block discarded – undo
650 672
 			$cur_field = &$profile_fields[$field];
651 673
 
652 674
 			// Does it have a preload and does that preload succeed?
653
-			if (isset($cur_field['preload']) && !$cur_field['preload']())
654
-				continue;
675
+			if (isset($cur_field['preload']) && !$cur_field['preload']()) {
676
+							continue;
677
+			}
655 678
 
656 679
 			// If this is anything but complex we need to do more cleaning!
657 680
 			if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden')
658 681
 			{
659
-				if (!isset($cur_field['label']))
660
-					$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
682
+				if (!isset($cur_field['label'])) {
683
+									$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
684
+				}
661 685
 
662 686
 				// Everything has a value!
663
-				if (!isset($cur_field['value']))
664
-					$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
687
+				if (!isset($cur_field['value'])) {
688
+									$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
689
+				}
665 690
 
666 691
 				// Any input attributes?
667 692
 				$cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : '';
668 693
 			}
669 694
 
670 695
 			// Was there an error with this field on posting?
671
-			if (isset($context['profile_errors'][$field]))
672
-				$cur_field['is_error'] = true;
696
+			if (isset($context['profile_errors'][$field])) {
697
+							$cur_field['is_error'] = true;
698
+			}
673 699
 
674 700
 			// Any javascript stuff?
675
-			if (!empty($cur_field['js_submit']))
676
-				$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
677
-			if (!empty($cur_field['js']))
678
-				$context['profile_javascript'] .= $cur_field['js'];
701
+			if (!empty($cur_field['js_submit'])) {
702
+							$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
703
+			}
704
+			if (!empty($cur_field['js'])) {
705
+							$context['profile_javascript'] .= $cur_field['js'];
706
+			}
679 707
 
680 708
 			// Any template stuff?
681
-			if (!empty($cur_field['prehtml']))
682
-				$context['profile_prehtml'] .= $cur_field['prehtml'];
683
-			if (!empty($cur_field['posthtml']))
684
-				$context['profile_posthtml'] .= $cur_field['posthtml'];
709
+			if (!empty($cur_field['prehtml'])) {
710
+							$context['profile_prehtml'] .= $cur_field['prehtml'];
711
+			}
712
+			if (!empty($cur_field['posthtml'])) {
713
+							$context['profile_posthtml'] .= $cur_field['posthtml'];
714
+			}
685 715
 
686 716
 			// Finally put it into context?
687 717
 			if ($cur_field['type'] != 'hidden')
@@ -714,12 +744,14 @@  discard block
 block discarded – undo
714 744
 	}, false);' : ''), true);
715 745
 
716 746
 	// Any onsubmit javascript?
717
-	if (!empty($context['profile_onsubmit_javascript']))
718
-		addInlineJavaScript($context['profile_onsubmit_javascript'], true);
747
+	if (!empty($context['profile_onsubmit_javascript'])) {
748
+			addInlineJavaScript($context['profile_onsubmit_javascript'], true);
749
+	}
719 750
 
720 751
 	// Any totally custom stuff?
721
-	if (!empty($context['profile_javascript']))
722
-		addInlineJavaScript($context['profile_javascript'], true);
752
+	if (!empty($context['profile_javascript'])) {
753
+			addInlineJavaScript($context['profile_javascript'], true);
754
+	}
723 755
 
724 756
 	// Free up some memory.
725 757
 	unset($profile_fields);
@@ -740,8 +772,9 @@  discard block
 block discarded – undo
740 772
 
741 773
 	// This allows variables to call activities when they save - by default just to reload their settings
742 774
 	$context['profile_execute_on_save'] = array();
743
-	if ($context['user']['is_owner'])
744
-		$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
775
+	if ($context['user']['is_owner']) {
776
+			$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
777
+	}
745 778
 
746 779
 	// Assume we log nothing.
747 780
 	$context['log_changes'] = array();
@@ -749,8 +782,9 @@  discard block
 block discarded – undo
749 782
 	// Cycle through the profile fields working out what to do!
750 783
 	foreach ($profile_fields as $key => $field)
751 784
 	{
752
-		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature'))
753
-			continue;
785
+		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) {
786
+					continue;
787
+		}
754 788
 
755 789
 		// What gets updated?
756 790
 		$db_key = isset($field['save_key']) ? $field['save_key'] : $key;
@@ -778,12 +812,13 @@  discard block
 block discarded – undo
778 812
 		$field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type'];
779 813
 
780 814
 		// Finally, clean up certain types.
781
-		if ($field['cast_type'] == 'int')
782
-			$_POST[$key] = (int) $_POST[$key];
783
-		elseif ($field['cast_type'] == 'float')
784
-			$_POST[$key] = (float) $_POST[$key];
785
-		elseif ($field['cast_type'] == 'check')
786
-			$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
815
+		if ($field['cast_type'] == 'int') {
816
+					$_POST[$key] = (int) $_POST[$key];
817
+		} elseif ($field['cast_type'] == 'float') {
818
+					$_POST[$key] = (float) $_POST[$key];
819
+		} elseif ($field['cast_type'] == 'check') {
820
+					$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
821
+		}
787 822
 
788 823
 		// If we got here we're doing OK.
789 824
 		if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key]))
@@ -794,11 +829,12 @@  discard block
 block discarded – undo
794 829
 			$cur_profile[$key] = $_POST[$key];
795 830
 
796 831
 			// Are we logging it?
797
-			if (!empty($field['log_change']) && isset($old_profile[$key]))
798
-				$context['log_changes'][$key] = array(
832
+			if (!empty($field['log_change']) && isset($old_profile[$key])) {
833
+							$context['log_changes'][$key] = array(
799 834
 					'previous' => $old_profile[$key],
800 835
 					'new' => $_POST[$key],
801 836
 				);
837
+			}
802 838
 		}
803 839
 
804 840
 		// Logging group changes are a bit different...
@@ -831,10 +867,11 @@  discard block
 block discarded – undo
831 867
 				{
832 868
 					foreach ($groups as $id => $group)
833 869
 					{
834
-						if (isset($context['member_groups'][$group]))
835
-							$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
836
-						else
837
-							unset($additional_groups[$type][$id]);
870
+						if (isset($context['member_groups'][$group])) {
871
+													$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
872
+						} else {
873
+													unset($additional_groups[$type][$id]);
874
+						}
838 875
 					}
839 876
 					$additional_groups[$type] = implode(', ', $additional_groups[$type]);
840 877
 				}
@@ -845,10 +882,11 @@  discard block
 block discarded – undo
845 882
 	}
846 883
 
847 884
 	// @todo Temporary
848
-	if ($context['user']['is_owner'])
849
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
850
-	else
851
-		$changeOther = allowedTo('profile_extra_any');
885
+	if ($context['user']['is_owner']) {
886
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
887
+	} else {
888
+			$changeOther = allowedTo('profile_extra_any');
889
+	}
852 890
 	if ($changeOther && empty($post_errors))
853 891
 	{
854 892
 		makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
@@ -856,8 +894,9 @@  discard block
 block discarded – undo
856 894
 		{
857 895
 			$custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true);
858 896
 
859
-			if (!empty($custom_fields_errors))
860
-				$post_errors = array_merge($post_errors, $custom_fields_errors);
897
+			if (!empty($custom_fields_errors)) {
898
+							$post_errors = array_merge($post_errors, $custom_fields_errors);
899
+			}
861 900
 		}
862 901
 	}
863 902
 
@@ -883,9 +922,9 @@  discard block
 block discarded – undo
883 922
 	if ($context['user']['is_owner'])
884 923
 	{
885 924
 		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own'));
925
+	} else {
926
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
886 927
 	}
887
-	else
888
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
889 928
 
890 929
 	// Arrays of all the changes - makes things easier.
891 930
 	$profile_bools = array();
@@ -896,22 +935,25 @@  discard block
 block discarded – undo
896 935
 		'ignore_boards',
897 936
 	);
898 937
 
899
-	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd']))
900
-		$_POST['ignore_brd'] = array();
938
+	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) {
939
+			$_POST['ignore_brd'] = array();
940
+	}
901 941
 
902 942
 	unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing.  Kinda like our minds.
903 943
 	if (isset($_POST['ignore_brd']))
904 944
 	{
905
-		if (!is_array($_POST['ignore_brd']))
906
-			$_POST['ignore_brd'] = array($_POST['ignore_brd']);
945
+		if (!is_array($_POST['ignore_brd'])) {
946
+					$_POST['ignore_brd'] = array($_POST['ignore_brd']);
947
+		}
907 948
 
908 949
 		foreach ($_POST['ignore_brd'] as $k => $d)
909 950
 		{
910 951
 			$d = (int) $d;
911
-			if ($d != 0)
912
-				$_POST['ignore_brd'][$k] = $d;
913
-			else
914
-				unset($_POST['ignore_brd'][$k]);
952
+			if ($d != 0) {
953
+							$_POST['ignore_brd'][$k] = $d;
954
+			} else {
955
+							unset($_POST['ignore_brd'][$k]);
956
+			}
915 957
 		}
916 958
 		$_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']);
917 959
 		unset($_POST['ignore_brd']);
@@ -923,21 +965,26 @@  discard block
 block discarded – undo
923 965
 		makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
924 966
 		//makeAvatarChanges($memID, $post_errors);
925 967
 
926
-		if (!empty($_REQUEST['sa']))
927
-			makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
968
+		if (!empty($_REQUEST['sa'])) {
969
+					makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
970
+		}
928 971
 
929
-		foreach ($profile_bools as $var)
930
-			if (isset($_POST[$var]))
972
+		foreach ($profile_bools as $var) {
973
+					if (isset($_POST[$var]))
931 974
 				$profile_vars[$var] = empty($_POST[$var]) ? '0' : '1';
932
-		foreach ($profile_ints as $var)
933
-			if (isset($_POST[$var]))
975
+		}
976
+		foreach ($profile_ints as $var) {
977
+					if (isset($_POST[$var]))
934 978
 				$profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : '';
935
-		foreach ($profile_floats as $var)
936
-			if (isset($_POST[$var]))
979
+		}
980
+		foreach ($profile_floats as $var) {
981
+					if (isset($_POST[$var]))
937 982
 				$profile_vars[$var] = (float) $_POST[$var];
938
-		foreach ($profile_strings as $var)
939
-			if (isset($_POST[$var]))
983
+		}
984
+		foreach ($profile_strings as $var) {
985
+					if (isset($_POST[$var]))
940 986
 				$profile_vars[$var] = $_POST[$var];
987
+		}
941 988
 	}
942 989
 }
943 990
 
@@ -971,8 +1018,9 @@  discard block
 block discarded – undo
971 1018
 	);
972 1019
 
973 1020
 	// Can't change reserved vars.
974
-	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0))
975
-		fatal_lang_error('no_access', false);
1021
+	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) {
1022
+			fatal_lang_error('no_access', false);
1023
+	}
976 1024
 
977 1025
 	// Don't allow any overriding of custom fields with default or non-default options.
978 1026
 	$request = $smcFunc['db_query']('', '
@@ -984,8 +1032,9 @@  discard block
 block discarded – undo
984 1032
 		)
985 1033
 	);
986 1034
 	$custom_fields = array();
987
-	while ($row = $smcFunc['db_fetch_assoc']($request))
988
-		$custom_fields[] = $row['col_name'];
1035
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1036
+			$custom_fields[] = $row['col_name'];
1037
+	}
989 1038
 	$smcFunc['db_free_result']($request);
990 1039
 
991 1040
 	// These are the theme changes...
@@ -994,33 +1043,39 @@  discard block
 block discarded – undo
994 1043
 	{
995 1044
 		foreach ($_POST['options'] as $opt => $val)
996 1045
 		{
997
-			if (in_array($opt, $custom_fields))
998
-				continue;
1046
+			if (in_array($opt, $custom_fields)) {
1047
+							continue;
1048
+			}
999 1049
 
1000 1050
 			// These need to be controlled.
1001
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1002
-				$val = max(0, min($val, 50));
1051
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1052
+							$val = max(0, min($val, 50));
1053
+			}
1003 1054
 			// We don't set this per theme anymore.
1004
-			elseif ($opt == 'allow_no_censored')
1005
-				continue;
1055
+			elseif ($opt == 'allow_no_censored') {
1056
+							continue;
1057
+			}
1006 1058
 
1007 1059
 			$themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val);
1008 1060
 		}
1009 1061
 	}
1010 1062
 
1011 1063
 	$erase_options = array();
1012
-	if (isset($_POST['default_options']) && is_array($_POST['default_options']))
1013
-		foreach ($_POST['default_options'] as $opt => $val)
1064
+	if (isset($_POST['default_options']) && is_array($_POST['default_options'])) {
1065
+			foreach ($_POST['default_options'] as $opt => $val)
1014 1066
 		{
1015 1067
 			if (in_array($opt, $custom_fields))
1016 1068
 				continue;
1069
+	}
1017 1070
 
1018 1071
 			// These need to be controlled.
1019
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1020
-				$val = max(0, min($val, 50));
1072
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1073
+							$val = max(0, min($val, 50));
1074
+			}
1021 1075
 			// Only let admins and owners change the censor.
1022
-			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner'])
1023
-					continue;
1076
+			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) {
1077
+								continue;
1078
+			}
1024 1079
 
1025 1080
 			$themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val);
1026 1081
 			$erase_options[] = $opt;
@@ -1056,8 +1111,9 @@  discard block
 block discarded – undo
1056 1111
 
1057 1112
 		// Admins can choose any theme, even if it's not enabled...
1058 1113
 		$themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']);
1059
-		foreach ($themes as $t)
1060
-			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1114
+		foreach ($themes as $t) {
1115
+					cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1116
+		}
1061 1117
 	}
1062 1118
 }
1063 1119
 
@@ -1076,8 +1132,9 @@  discard block
 block discarded – undo
1076 1132
 	if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards']))
1077 1133
 	{
1078 1134
 		// Make sure only integers are deleted.
1079
-		foreach ($_POST['notify_boards'] as $index => $id)
1080
-			$_POST['notify_boards'][$index] = (int) $id;
1135
+		foreach ($_POST['notify_boards'] as $index => $id) {
1136
+					$_POST['notify_boards'][$index] = (int) $id;
1137
+		}
1081 1138
 
1082 1139
 		// id_board = 0 is reserved for topic notifications.
1083 1140
 		$_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0));
@@ -1096,8 +1153,9 @@  discard block
 block discarded – undo
1096 1153
 	// We are editing topic notifications......
1097 1154
 	elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics']))
1098 1155
 	{
1099
-		foreach ($_POST['notify_topics'] as $index => $id)
1100
-			$_POST['notify_topics'][$index] = (int) $id;
1156
+		foreach ($_POST['notify_topics'] as $index => $id) {
1157
+					$_POST['notify_topics'][$index] = (int) $id;
1158
+		}
1101 1159
 
1102 1160
 		// Make sure there are no zeros left.
1103 1161
 		$_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0));
@@ -1111,16 +1169,18 @@  discard block
 block discarded – undo
1111 1169
 				'selected_member' => $memID,
1112 1170
 			)
1113 1171
 		);
1114
-		foreach ($_POST['notify_topics'] as $topic)
1115
-			setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1172
+		foreach ($_POST['notify_topics'] as $topic) {
1173
+					setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1174
+		}
1116 1175
 	}
1117 1176
 
1118 1177
 	// We are removing topic preferences
1119 1178
 	elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics']))
1120 1179
 	{
1121 1180
 		$prefs = array();
1122
-		foreach ($_POST['notify_topics'] as $topic)
1123
-			$prefs[] = 'topic_notify_' . $topic;
1181
+		foreach ($_POST['notify_topics'] as $topic) {
1182
+					$prefs[] = 'topic_notify_' . $topic;
1183
+		}
1124 1184
 		deleteNotifyPrefs($memID, $prefs);
1125 1185
 	}
1126 1186
 
@@ -1128,8 +1188,9 @@  discard block
 block discarded – undo
1128 1188
 	elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards']))
1129 1189
 	{
1130 1190
 		$prefs = array();
1131
-		foreach ($_POST['notify_boards'] as $board)
1132
-			$prefs[] = 'board_notify_' . $board;
1191
+		foreach ($_POST['notify_boards'] as $board) {
1192
+					$prefs[] = 'board_notify_' . $board;
1193
+		}
1133 1194
 		deleteNotifyPrefs($memID, $prefs);
1134 1195
 	}
1135 1196
 }
@@ -1150,8 +1211,9 @@  discard block
 block discarded – undo
1150 1211
 
1151 1212
 	$errors = array();
1152 1213
 
1153
-	if ($sanitize && isset($_POST['customfield']))
1154
-		$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1214
+	if ($sanitize && isset($_POST['customfield'])) {
1215
+			$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1216
+	}
1155 1217
 
1156 1218
 	$where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}';
1157 1219
 
@@ -1177,26 +1239,29 @@  discard block
 block discarded – undo
1177 1239
 			- The data is not invisible to users but editable by the owner (or if it is the user is not the owner)
1178 1240
 			- The area isn't registration, and if it is that the field is not supposed to be shown there.
1179 1241
 		*/
1180
-		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0))
1181
-			continue;
1242
+		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) {
1243
+					continue;
1244
+		}
1182 1245
 
1183 1246
 		// Validate the user data.
1184
-		if ($row['field_type'] == 'check')
1185
-			$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1186
-		elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1247
+		if ($row['field_type'] == 'check') {
1248
+					$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1249
+		} elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1187 1250
 		{
1188 1251
 			$value = $row['default_value'];
1189
-			foreach (explode(',', $row['field_options']) as $k => $v)
1190
-				if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1252
+			foreach (explode(',', $row['field_options']) as $k => $v) {
1253
+							if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1191 1254
 					$value = $v;
1255
+			}
1192 1256
 		}
1193 1257
 		// Otherwise some form of text!
1194 1258
 		else
1195 1259
 		{
1196 1260
 			$value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : '';
1197 1261
 
1198
-			if ($row['field_length'])
1199
-				$value = $smcFunc['substr']($value, 0, $row['field_length']);
1262
+			if ($row['field_length']) {
1263
+							$value = $smcFunc['substr']($value, 0, $row['field_length']);
1264
+			}
1200 1265
 
1201 1266
 			// Any masks?
1202 1267
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
@@ -1205,36 +1270,34 @@  discard block
 block discarded – undo
1205 1270
 				$valueReference = un_htmlspecialchars($value);
1206 1271
 
1207 1272
 				// Try and avoid some checks. '0' could be a valid non-empty value.
1208
-				if (empty($value) && !is_numeric($value))
1209
-					$value = '';
1273
+				if (empty($value) && !is_numeric($value)) {
1274
+									$value = '';
1275
+				}
1210 1276
 
1211 1277
 				if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference)))
1212 1278
 				{
1213
-					if ($returnErrors)
1214
-						$errors[] = 'custom_field_nohtml_fail';
1215
-
1216
-					else
1217
-						$value = '';
1218
-				}
1219
-				elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1279
+					if ($returnErrors) {
1280
+											$errors[] = 'custom_field_nohtml_fail';
1281
+					} else {
1282
+											$value = '';
1283
+					}
1284
+				} elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1220 1285
 				{
1221
-					if ($returnErrors)
1222
-						$errors[] = 'custom_field_mail_fail';
1223
-
1224
-					else
1225
-						$value = '';
1226
-				}
1227
-				elseif ($row['mask'] == 'number')
1286
+					if ($returnErrors) {
1287
+											$errors[] = 'custom_field_mail_fail';
1288
+					} else {
1289
+											$value = '';
1290
+					}
1291
+				} elseif ($row['mask'] == 'number')
1228 1292
 				{
1229 1293
 					$value = (int) $value;
1230
-				}
1231
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1294
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1232 1295
 				{
1233
-					if ($returnErrors)
1234
-						$errors[] = 'custom_field_regex_fail';
1235
-
1236
-					else
1237
-						$value = '';
1296
+					if ($returnErrors) {
1297
+											$errors[] = 'custom_field_regex_fail';
1298
+					} else {
1299
+											$value = '';
1300
+					}
1238 1301
 				}
1239 1302
 
1240 1303
 				unset($valueReference);
@@ -1258,8 +1321,7 @@  discard block
 block discarded – undo
1258 1321
 			{
1259 1322
 				$deletes = array('id_theme' => 1 , 'variable' => $row['col_name'], 'id_member' => $memID);
1260 1323
 				unset($user_profile[$memID]['options'][$row['col_name']]);
1261
-			}
1262
-			else
1324
+			} else
1263 1325
 			{
1264 1326
 				$changes[] = array(1, $row['col_name'], $value, $memID);
1265 1327
 				$user_profile[$memID]['options'][$row['col_name']] = $value;
@@ -1270,27 +1332,30 @@  discard block
 block discarded – undo
1270 1332
 
1271 1333
 	$hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize, &$deletes));
1272 1334
 
1273
-	if (!empty($hook_errors) && is_array($hook_errors))
1274
-		$errors = array_merge($errors, $hook_errors);
1335
+	if (!empty($hook_errors) && is_array($hook_errors)) {
1336
+			$errors = array_merge($errors, $hook_errors);
1337
+	}
1275 1338
 
1276 1339
 	// Make those changes!
1277 1340
 	if ((!empty($changes) || !empty($deletes)) && empty($context['password_auth_failed']) && empty($errors))
1278 1341
 	{
1279
-		if (!empty($changes))
1280
-			$smcFunc['db_insert']('replace',
1342
+		if (!empty($changes)) {
1343
+					$smcFunc['db_insert']('replace',
1281 1344
 				'{db_prefix}themes',
1282 1345
 				array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534', 'id_member' => 'int'),
1283 1346
 				$changes,
1284 1347
 				array('id_theme', 'variable', 'id_member')
1285 1348
 			);
1286
-		if (!empty($deletes))
1287
-			$smcFunc['db_query']('','
1349
+		}
1350
+		if (!empty($deletes)) {
1351
+					$smcFunc['db_query']('','
1288 1352
 				DELETE FROM {db_prefix}themes
1289 1353
 				WHERE id_theme = {int:id_theme} AND
1290 1354
 						variable = {string:variable} AND
1291 1355
 						id_member = {int:id_member}',
1292 1356
 				$deletes
1293 1357
 				);
1358
+		}
1294 1359
 		if (!empty($log_changes) && !empty($modSettings['modlog_enabled']))
1295 1360
 		{
1296 1361
 			require_once($sourcedir . '/Logging.php');
@@ -1298,9 +1363,10 @@  discard block
 block discarded – undo
1298 1363
 		}
1299 1364
 	}
1300 1365
 
1301
-	if ($returnErrors)
1302
-		return $errors;
1303
-}
1366
+	if ($returnErrors) {
1367
+			return $errors;
1368
+	}
1369
+	}
1304 1370
 
1305 1371
 /**
1306 1372
  * Show all the users buddies, as well as a add/delete interface.
@@ -1312,8 +1378,9 @@  discard block
 block discarded – undo
1312 1378
 	global $context, $txt, $modSettings;
1313 1379
 
1314 1380
 	// Do a quick check to ensure people aren't getting here illegally!
1315
-	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist']))
1316
-		fatal_lang_error('no_access', false);
1381
+	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) {
1382
+			fatal_lang_error('no_access', false);
1383
+	}
1317 1384
 
1318 1385
 	// Can we email the user direct?
1319 1386
 	$context['can_moderate_forum'] = allowedTo('moderate_forum');
@@ -1343,9 +1410,10 @@  discard block
 block discarded – undo
1343 1410
 	$context['sub_template'] = $subActions[$context['list_area']][0];
1344 1411
 	$call = call_helper($subActions[$context['list_area']][0], true);
1345 1412
 
1346
-	if (!empty($call))
1347
-		call_user_func($call, $memID);
1348
-}
1413
+	if (!empty($call)) {
1414
+			call_user_func($call, $memID);
1415
+	}
1416
+	}
1349 1417
 
1350 1418
 /**
1351 1419
  * Show all the users buddies, as well as a add/delete interface.
@@ -1359,9 +1427,10 @@  discard block
 block discarded – undo
1359 1427
 
1360 1428
 	// For making changes!
1361 1429
 	$buddiesArray = explode(',', $user_profile[$memID]['buddy_list']);
1362
-	foreach ($buddiesArray as $k => $dummy)
1363
-		if ($dummy == '')
1430
+	foreach ($buddiesArray as $k => $dummy) {
1431
+			if ($dummy == '')
1364 1432
 			unset($buddiesArray[$k]);
1433
+	}
1365 1434
 
1366 1435
 	// Removing a buddy?
1367 1436
 	if (isset($_GET['remove']))
@@ -1373,10 +1442,11 @@  discard block
 block discarded – undo
1373 1442
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1374 1443
 
1375 1444
 		// Heh, I'm lazy, do it the easy way...
1376
-		foreach ($buddiesArray as $key => $buddy)
1377
-			if ($buddy == (int) $_GET['remove'])
1445
+		foreach ($buddiesArray as $key => $buddy) {
1446
+					if ($buddy == (int) $_GET['remove'])
1378 1447
 			{
1379 1448
 				unset($buddiesArray[$key]);
1449
+		}
1380 1450
 				$_SESSION['prf-save'] = true;
1381 1451
 			}
1382 1452
 
@@ -1386,8 +1456,7 @@  discard block
 block discarded – undo
1386 1456
 
1387 1457
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1388 1458
 		redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID);
1389
-	}
1390
-	elseif (isset($_POST['new_buddy']))
1459
+	} elseif (isset($_POST['new_buddy']))
1391 1460
 	{
1392 1461
 		checkSession();
1393 1462
 
@@ -1400,8 +1469,9 @@  discard block
 block discarded – undo
1400 1469
 		{
1401 1470
 			$new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => '&#039;'));
1402 1471
 
1403
-			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1404
-				unset($new_buddies[$k]);
1472
+			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1473
+							unset($new_buddies[$k]);
1474
+			}
1405 1475
 		}
1406 1476
 
1407 1477
 		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies));
@@ -1421,16 +1491,18 @@  discard block
 block discarded – undo
1421 1491
 				)
1422 1492
 			);
1423 1493
 
1424
-			if ($smcFunc['db_num_rows']($request) != 0)
1425
-				$_SESSION['prf-save'] = true;
1494
+			if ($smcFunc['db_num_rows']($request) != 0) {
1495
+							$_SESSION['prf-save'] = true;
1496
+			}
1426 1497
 
1427 1498
 			// Add the new member to the buddies array.
1428 1499
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1429 1500
 			{
1430
-				if (in_array($row['id_member'], $buddiesArray))
1431
-					continue;
1432
-				else
1433
-					$buddiesArray[] = (int) $row['id_member'];
1501
+				if (in_array($row['id_member'], $buddiesArray)) {
1502
+									continue;
1503
+				} else {
1504
+									$buddiesArray[] = (int) $row['id_member'];
1505
+				}
1434 1506
 			}
1435 1507
 			$smcFunc['db_free_result']($request);
1436 1508
 
@@ -1460,18 +1532,20 @@  discard block
 block discarded – undo
1460 1532
 
1461 1533
 	$context['custom_pf'] = array();
1462 1534
 	$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
1463
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1464
-		if (!isset($disabled_fields[$row['col_name']]))
1535
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1536
+			if (!isset($disabled_fields[$row['col_name']]))
1465 1537
 			$context['custom_pf'][$row['col_name']] = array(
1466 1538
 				'label' => $row['field_name'],
1467 1539
 				'type' => $row['field_type'],
1468 1540
 				'bbc' => !empty($row['bbc']),
1469 1541
 				'enclose' => $row['enclose'],
1470 1542
 			);
1543
+	}
1471 1544
 
1472 1545
 	// Gotta disable the gender option.
1473
-	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None')
1474
-		unset($context['custom_pf']['cust_gender']);
1546
+	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') {
1547
+			unset($context['custom_pf']['cust_gender']);
1548
+	}
1475 1549
 
1476 1550
 	$smcFunc['db_free_result']($request);
1477 1551
 
@@ -1488,8 +1562,9 @@  discard block
 block discarded – undo
1488 1562
 				'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1,
1489 1563
 			)
1490 1564
 		);
1491
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1492
-			$buddies[] = $row['id_member'];
1565
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1566
+					$buddies[] = $row['id_member'];
1567
+		}
1493 1568
 		$smcFunc['db_free_result']($result);
1494 1569
 	}
1495 1570
 
@@ -1517,30 +1592,32 @@  discard block
 block discarded – undo
1517 1592
 					continue;
1518 1593
 				}
1519 1594
 
1520
-				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key]))
1521
-					$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1522
-
1523
-				elseif ($column['type'] == 'check')
1524
-					$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1595
+				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) {
1596
+									$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1597
+				} elseif ($column['type'] == 'check') {
1598
+									$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1599
+				}
1525 1600
 
1526 1601
 				// Enclosing the user input within some other text?
1527
-				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key]))
1528
-					$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1602
+				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) {
1603
+									$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1529 1604
 						'{SCRIPTURL}' => $scripturl,
1530 1605
 						'{IMAGES_URL}' => $settings['images_url'],
1531 1606
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1532 1607
 						'{INPUT}' => $context['buddies'][$buddy]['options'][$key],
1533 1608
 					));
1609
+				}
1534 1610
 			}
1535 1611
 		}
1536 1612
 	}
1537 1613
 
1538 1614
 	if (isset($_SESSION['prf-save']))
1539 1615
 	{
1540
-		if ($_SESSION['prf-save'] === true)
1541
-			$context['saved_successful'] = true;
1542
-		else
1543
-			$context['saved_failed'] = $_SESSION['prf-save'];
1616
+		if ($_SESSION['prf-save'] === true) {
1617
+					$context['saved_successful'] = true;
1618
+		} else {
1619
+					$context['saved_failed'] = $_SESSION['prf-save'];
1620
+		}
1544 1621
 
1545 1622
 		unset($_SESSION['prf-save']);
1546 1623
 	}
@@ -1560,9 +1637,10 @@  discard block
 block discarded – undo
1560 1637
 
1561 1638
 	// For making changes!
1562 1639
 	$ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']);
1563
-	foreach ($ignoreArray as $k => $dummy)
1564
-		if ($dummy == '')
1640
+	foreach ($ignoreArray as $k => $dummy) {
1641
+			if ($dummy == '')
1565 1642
 			unset($ignoreArray[$k]);
1643
+	}
1566 1644
 
1567 1645
 	// Removing a member from the ignore list?
1568 1646
 	if (isset($_GET['remove']))
@@ -1572,10 +1650,11 @@  discard block
 block discarded – undo
1572 1650
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1573 1651
 
1574 1652
 		// Heh, I'm lazy, do it the easy way...
1575
-		foreach ($ignoreArray as $key => $id_remove)
1576
-			if ($id_remove == (int) $_GET['remove'])
1653
+		foreach ($ignoreArray as $key => $id_remove) {
1654
+					if ($id_remove == (int) $_GET['remove'])
1577 1655
 			{
1578 1656
 				unset($ignoreArray[$key]);
1657
+		}
1579 1658
 				$_SESSION['prf-save'] = true;
1580 1659
 			}
1581 1660
 
@@ -1585,8 +1664,7 @@  discard block
 block discarded – undo
1585 1664
 
1586 1665
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1587 1666
 		redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID);
1588
-	}
1589
-	elseif (isset($_POST['new_ignore']))
1667
+	} elseif (isset($_POST['new_ignore']))
1590 1668
 	{
1591 1669
 		checkSession();
1592 1670
 		// Prepare the string for extraction...
@@ -1598,8 +1676,9 @@  discard block
 block discarded – undo
1598 1676
 		{
1599 1677
 			$new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => '&#039;'));
1600 1678
 
1601
-			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1602
-				unset($new_entries[$k]);
1679
+			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1680
+							unset($new_entries[$k]);
1681
+			}
1603 1682
 		}
1604 1683
 
1605 1684
 		$_SESSION['prf-save'] = $txt['could_not_add_person'];
@@ -1617,16 +1696,18 @@  discard block
 block discarded – undo
1617 1696
 				)
1618 1697
 			);
1619 1698
 
1620
-			if ($smcFunc['db_num_rows']($request) != 0)
1621
-				$_SESSION['prf-save'] = true;
1699
+			if ($smcFunc['db_num_rows']($request) != 0) {
1700
+							$_SESSION['prf-save'] = true;
1701
+			}
1622 1702
 
1623 1703
 			// Add the new member to the buddies array.
1624 1704
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1625 1705
 			{
1626
-				if (in_array($row['id_member'], $ignoreArray))
1627
-					continue;
1628
-				else
1629
-					$ignoreArray[] = (int) $row['id_member'];
1706
+				if (in_array($row['id_member'], $ignoreArray)) {
1707
+									continue;
1708
+				} else {
1709
+									$ignoreArray[] = (int) $row['id_member'];
1710
+				}
1630 1711
 			}
1631 1712
 			$smcFunc['db_free_result']($request);
1632 1713
 
@@ -1655,8 +1736,9 @@  discard block
 block discarded – undo
1655 1736
 				'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1,
1656 1737
 			)
1657 1738
 		);
1658
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1659
-			$ignored[] = $row['id_member'];
1739
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1740
+					$ignored[] = $row['id_member'];
1741
+		}
1660 1742
 		$smcFunc['db_free_result']($result);
1661 1743
 	}
1662 1744
 
@@ -1675,10 +1757,11 @@  discard block
 block discarded – undo
1675 1757
 
1676 1758
 	if (isset($_SESSION['prf-save']))
1677 1759
 	{
1678
-		if ($_SESSION['prf-save'] === true)
1679
-			$context['saved_successful'] = true;
1680
-		else
1681
-			$context['saved_failed'] = $_SESSION['prf-save'];
1760
+		if ($_SESSION['prf-save'] === true) {
1761
+					$context['saved_successful'] = true;
1762
+		} else {
1763
+					$context['saved_failed'] = $_SESSION['prf-save'];
1764
+		}
1682 1765
 
1683 1766
 		unset($_SESSION['prf-save']);
1684 1767
 	}
@@ -1694,8 +1777,9 @@  discard block
 block discarded – undo
1694 1777
 	global $context, $txt;
1695 1778
 
1696 1779
 	loadThemeOptions($memID);
1697
-	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any')))
1698
-		loadCustomFields($memID, 'account');
1780
+	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) {
1781
+			loadCustomFields($memID, 'account');
1782
+	}
1699 1783
 
1700 1784
 	$context['sub_template'] = 'edit_options';
1701 1785
 	$context['page_desc'] = $txt['account_info'];
@@ -1722,8 +1806,9 @@  discard block
 block discarded – undo
1722 1806
 	global $context, $txt;
1723 1807
 
1724 1808
 	loadThemeOptions($memID);
1725
-	if (allowedTo(array('profile_forum_own', 'profile_forum_any')))
1726
-		loadCustomFields($memID, 'forumprofile');
1809
+	if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) {
1810
+			loadCustomFields($memID, 'forumprofile');
1811
+	}
1727 1812
 
1728 1813
 	$context['sub_template'] = 'edit_options';
1729 1814
 	$context['page_desc'] = $txt['forumProfile_info'];
@@ -1756,18 +1841,21 @@  discard block
 block discarded – undo
1756 1841
 	$dirs = array();
1757 1842
 	$files = array();
1758 1843
 
1759
-	if (!$dir)
1760
-		return array();
1844
+	if (!$dir) {
1845
+			return array();
1846
+	}
1761 1847
 
1762 1848
 	while ($line = $dir->read())
1763 1849
 	{
1764
-		if (in_array($line, array('.', '..', 'blank.png', 'index.php')))
1765
-			continue;
1850
+		if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) {
1851
+					continue;
1852
+		}
1766 1853
 
1767
-		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
1768
-			$dirs[] = $line;
1769
-		else
1770
-			$files[] = $line;
1854
+		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) {
1855
+					$dirs[] = $line;
1856
+		} else {
1857
+					$files[] = $line;
1858
+		}
1771 1859
 	}
1772 1860
 	$dir->close();
1773 1861
 
@@ -1788,14 +1876,15 @@  discard block
 block discarded – undo
1788 1876
 	foreach ($dirs as $line)
1789 1877
 	{
1790 1878
 		$tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
1791
-		if (!empty($tmp))
1792
-			$result[] = array(
1879
+		if (!empty($tmp)) {
1880
+					$result[] = array(
1793 1881
 				'filename' => $smcFunc['htmlspecialchars']($line),
1794 1882
 				'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
1795 1883
 				'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']',
1796 1884
 				'is_dir' => true,
1797 1885
 				'files' => $tmp
1798 1886
 		);
1887
+		}
1799 1888
 		unset($tmp);
1800 1889
 	}
1801 1890
 
@@ -1805,8 +1894,9 @@  discard block
 block discarded – undo
1805 1894
 		$extension = substr(strrchr($line, '.'), 1);
1806 1895
 
1807 1896
 		// Make sure it is an image.
1808
-		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
1809
-			continue;
1897
+		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) {
1898
+					continue;
1899
+		}
1810 1900
 
1811 1901
 		$result[] = array(
1812 1902
 			'filename' => $smcFunc['htmlspecialchars']($line),
@@ -1814,8 +1904,9 @@  discard block
 block discarded – undo
1814 1904
 			'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)),
1815 1905
 			'is_dir' => false
1816 1906
 		);
1817
-		if ($level == 1)
1818
-			$context['avatar_list'][] = $directory . '/' . $line;
1907
+		if ($level == 1) {
1908
+					$context['avatar_list'][] = $directory . '/' . $line;
1909
+		}
1819 1910
 	}
1820 1911
 
1821 1912
 	return $result;
@@ -1837,8 +1928,9 @@  discard block
 block discarded – undo
1837 1928
 	call_integration_hook('integrate_theme_options');
1838 1929
 
1839 1930
 	loadThemeOptions($memID);
1840
-	if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
1841
-		loadCustomFields($memID, 'theme');
1931
+	if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) {
1932
+			loadCustomFields($memID, 'theme');
1933
+	}
1842 1934
 
1843 1935
 	$context['sub_template'] = 'edit_options';
1844 1936
 	$context['page_desc'] = $txt['theme_info'];
@@ -1892,16 +1984,19 @@  discard block
 block discarded – undo
1892 1984
 {
1893 1985
 	global $txt, $context, $modSettings, $smcFunc, $sourcedir;
1894 1986
 
1895
-	if (!isset($context['token_check']))
1896
-		$context['token_check'] = 'profile-nt' . $memID;
1987
+	if (!isset($context['token_check'])) {
1988
+			$context['token_check'] = 'profile-nt' . $memID;
1989
+	}
1897 1990
 
1898 1991
 	is_not_guest();
1899
-	if (!$context['user']['is_owner'])
1900
-		isAllowedTo('profile_extra_any');
1992
+	if (!$context['user']['is_owner']) {
1993
+			isAllowedTo('profile_extra_any');
1994
+	}
1901 1995
 
1902 1996
 	// Set the post action if we're coming from the profile...
1903
-	if (!isset($context['action']))
1904
-		$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1997
+	if (!isset($context['action'])) {
1998
+			$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1999
+	}
1905 2000
 
1906 2001
 	// What options are set
1907 2002
 	loadThemeOptions($memID);
@@ -1988,28 +2083,34 @@  discard block
 block discarded – undo
1988 2083
 	);
1989 2084
 
1990 2085
 	// There are certain things that are disabled at the group level.
1991
-	if (empty($modSettings['cal_enabled']))
1992
-		unset($alert_types['calendar']);
2086
+	if (empty($modSettings['cal_enabled'])) {
2087
+			unset($alert_types['calendar']);
2088
+	}
1993 2089
 
1994 2090
 	// Disable paid subscriptions at group level if they're disabled
1995
-	if (empty($modSettings['paid_enabled']))
1996
-		unset($alert_types['paidsubs']);
2091
+	if (empty($modSettings['paid_enabled'])) {
2092
+			unset($alert_types['paidsubs']);
2093
+	}
1997 2094
 
1998 2095
 	// Disable membergroup requests at group level if they're disabled
1999
-	if (empty($modSettings['show_group_membership']))
2000
-		unset($alert_types['groupr'], $alert_types['members']['request_group']);
2096
+	if (empty($modSettings['show_group_membership'])) {
2097
+			unset($alert_types['groupr'], $alert_types['members']['request_group']);
2098
+	}
2001 2099
 
2002 2100
 	// Disable mentions if they're disabled
2003
-	if (empty($modSettings['enable_mentions']))
2004
-		unset($alert_types['msg']['msg_mention']);
2101
+	if (empty($modSettings['enable_mentions'])) {
2102
+			unset($alert_types['msg']['msg_mention']);
2103
+	}
2005 2104
 
2006 2105
 	// Disable likes if they're disabled
2007
-	if (empty($modSettings['enable_likes']))
2008
-		unset($alert_types['msg']['msg_like']);
2106
+	if (empty($modSettings['enable_likes'])) {
2107
+			unset($alert_types['msg']['msg_like']);
2108
+	}
2009 2109
 
2010 2110
 	// Disable buddy requests if they're disabled
2011
-	if (empty($modSettings['enable_buddylist']))
2012
-		unset($alert_types['members']['buddy_request']);
2111
+	if (empty($modSettings['enable_buddylist'])) {
2112
+			unset($alert_types['members']['buddy_request']);
2113
+	}
2013 2114
 
2014 2115
 	// Now, now, we could pass this through global but we should really get into the habit of
2015 2116
 	// passing content to hooks, not expecting hooks to splatter everything everywhere.
@@ -2037,15 +2138,17 @@  discard block
 block discarded – undo
2037 2138
 			$perms_cache['manage_membergroups'] = in_array($memID, $members);
2038 2139
 		}
2039 2140
 
2040
-		if (!($perms_cache['manage_membergroups'] || $can_mod != 0))
2041
-			unset($alert_types['members']['request_group']);
2141
+		if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) {
2142
+					unset($alert_types['members']['request_group']);
2143
+		}
2042 2144
 
2043 2145
 		foreach ($alert_types as $group => $items)
2044 2146
 		{
2045 2147
 			foreach ($items as $alert_key => $alert_value)
2046 2148
 			{
2047
-				if (!isset($alert_value['permission']))
2048
-					continue;
2149
+				if (!isset($alert_value['permission'])) {
2150
+									continue;
2151
+				}
2049 2152
 				if (!isset($perms_cache[$alert_value['permission']['name']]))
2050 2153
 				{
2051 2154
 					$in_board = !empty($alert_value['permission']['is_board']) ? 0 : null;
@@ -2053,12 +2156,14 @@  discard block
 block discarded – undo
2053 2156
 					$perms_cache[$alert_value['permission']['name']] = in_array($memID, $members);
2054 2157
 				}
2055 2158
 
2056
-				if (!$perms_cache[$alert_value['permission']['name']])
2057
-					unset ($alert_types[$group][$alert_key]);
2159
+				if (!$perms_cache[$alert_value['permission']['name']]) {
2160
+									unset ($alert_types[$group][$alert_key]);
2161
+				}
2058 2162
 			}
2059 2163
 
2060
-			if (empty($alert_types[$group]))
2061
-				unset ($alert_types[$group]);
2164
+			if (empty($alert_types[$group])) {
2165
+							unset ($alert_types[$group]);
2166
+			}
2062 2167
 		}
2063 2168
 	}
2064 2169
 
@@ -2090,9 +2195,9 @@  discard block
 block discarded – undo
2090 2195
 						$update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0;
2091 2196
 						break;
2092 2197
 					case 'select':
2093
-						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]]))
2094
-							$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2095
-						else
2198
+						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) {
2199
+													$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2200
+						} else
2096 2201
 						{
2097 2202
 							// We didn't have a sane value. Let's grab the first item from the possibles.
2098 2203
 							$keys = array_keys($this_option['opts']);
@@ -2112,23 +2217,28 @@  discard block
 block discarded – undo
2112 2217
 				$this_value = 0;
2113 2218
 				foreach ($context['alert_bits'] as $type => $bitvalue)
2114 2219
 				{
2115
-					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always')
2116
-						$this_value |= $bitvalue;
2220
+					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') {
2221
+											$this_value |= $bitvalue;
2222
+					}
2223
+				}
2224
+				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) {
2225
+									$update_prefs[$item_key] = $this_value;
2117 2226
 				}
2118
-				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value)
2119
-					$update_prefs[$item_key] = $this_value;
2120 2227
 			}
2121 2228
 		}
2122 2229
 
2123
-		if (!empty($_POST['opt_alert_timeout']))
2124
-			$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2230
+		if (!empty($_POST['opt_alert_timeout'])) {
2231
+					$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2232
+		}
2125 2233
 
2126
-		if (!empty($_POST['notify_announcements']))
2127
-			$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2234
+		if (!empty($_POST['notify_announcements'])) {
2235
+					$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2236
+		}
2128 2237
 
2129 2238
 		setNotifyPrefs((int) $memID, $update_prefs);
2130
-		foreach ($update_prefs as $pref => $value)
2131
-			$context['alert_prefs'][$pref] = $value;
2239
+		foreach ($update_prefs as $pref => $value) {
2240
+					$context['alert_prefs'][$pref] = $value;
2241
+		}
2132 2242
 
2133 2243
 		makeNotificationChanges($memID);
2134 2244
 
@@ -2158,8 +2268,9 @@  discard block
 block discarded – undo
2158 2268
 
2159 2269
 	// Now we're all set up.
2160 2270
 	is_not_guest();
2161
-	if (!$context['user']['is_owner'])
2162
-		fatal_error('no_access');
2271
+	if (!$context['user']['is_owner']) {
2272
+			fatal_error('no_access');
2273
+	}
2163 2274
 
2164 2275
 	checkSession('get');
2165 2276
 
@@ -2191,8 +2302,9 @@  discard block
 block discarded – undo
2191 2302
 {
2192 2303
 	global $smcFunc;
2193 2304
 
2194
-	if (empty($toMark) || empty($memID))
2195
-		return false;
2305
+	if (empty($toMark) || empty($memID)) {
2306
+			return false;
2307
+	}
2196 2308
 
2197 2309
 	$toMark = (array) $toMark;
2198 2310
 
@@ -2226,8 +2338,9 @@  discard block
 block discarded – undo
2226 2338
 {
2227 2339
 	global $smcFunc;
2228 2340
 
2229
-	if (empty($toDelete))
2230
-		return false;
2341
+	if (empty($toDelete)) {
2342
+			return false;
2343
+	}
2231 2344
 
2232 2345
 	$toDelete = (array) $toDelete;
2233 2346
 
@@ -2262,8 +2375,9 @@  discard block
 block discarded – undo
2262 2375
 {
2263 2376
 	global $smcFunc;
2264 2377
 
2265
-	if (empty($memID))
2266
-		return false;
2378
+	if (empty($memID)) {
2379
+			return false;
2380
+	}
2267 2381
 
2268 2382
 	$request = $smcFunc['db_query']('', '
2269 2383
 		SELECT id_alert
@@ -2340,8 +2454,9 @@  discard block
 block discarded – undo
2340 2454
 					{
2341 2455
 						$link = $topic['link'];
2342 2456
 
2343
-						if ($topic['new'])
2344
-							$link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2457
+						if ($topic['new']) {
2458
+													$link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2459
+						}
2345 2460
 
2346 2461
 						$link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>';
2347 2462
 
@@ -2492,8 +2607,9 @@  discard block
 block discarded – undo
2492 2607
 					{
2493 2608
 						$link = $board['link'];
2494 2609
 
2495
-						if ($board['new'])
2496
-							$link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2610
+						if ($board['new']) {
2611
+													$link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2612
+						}
2497 2613
 
2498 2614
 						return $link;
2499 2615
 					},
@@ -2693,8 +2809,8 @@  discard block
 block discarded – undo
2693 2809
 		)
2694 2810
 	);
2695 2811
 	$notification_boards = array();
2696
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2697
-		$notification_boards[] = array(
2812
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2813
+			$notification_boards[] = array(
2698 2814
 			'id' => $row['id_board'],
2699 2815
 			'name' => $row['name'],
2700 2816
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
@@ -2702,6 +2818,7 @@  discard block
 block discarded – undo
2702 2818
 			'new' => $row['board_read'] < $row['id_msg_updated'],
2703 2819
 			'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0),
2704 2820
 		);
2821
+	}
2705 2822
 	$smcFunc['db_free_result']($request);
2706 2823
 
2707 2824
 	return $notification_boards;
@@ -2716,17 +2833,18 @@  discard block
 block discarded – undo
2716 2833
 {
2717 2834
 	global $context, $options, $cur_profile, $smcFunc;
2718 2835
 
2719
-	if (isset($_POST['default_options']))
2720
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2836
+	if (isset($_POST['default_options'])) {
2837
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2838
+	}
2721 2839
 
2722 2840
 	if ($context['user']['is_owner'])
2723 2841
 	{
2724 2842
 		$context['member']['options'] = $options;
2725
-		if (isset($_POST['options']) && is_array($_POST['options']))
2726
-			foreach ($_POST['options'] as $k => $v)
2843
+		if (isset($_POST['options']) && is_array($_POST['options'])) {
2844
+					foreach ($_POST['options'] as $k => $v)
2727 2845
 				$context['member']['options'][$k] = $v;
2728
-	}
2729
-	else
2846
+		}
2847
+	} else
2730 2848
 	{
2731 2849
 		$request = $smcFunc['db_query']('', '
2732 2850
 			SELECT id_member, variable, value
@@ -2747,8 +2865,9 @@  discard block
 block discarded – undo
2747 2865
 				continue;
2748 2866
 			}
2749 2867
 
2750
-			if (isset($_POST['options'][$row['variable']]))
2751
-				$row['value'] = $_POST['options'][$row['variable']];
2868
+			if (isset($_POST['options'][$row['variable']])) {
2869
+							$row['value'] = $_POST['options'][$row['variable']];
2870
+			}
2752 2871
 			$context['member']['options'][$row['variable']] = $row['value'];
2753 2872
 		}
2754 2873
 		$smcFunc['db_free_result']($request);
@@ -2756,8 +2875,9 @@  discard block
 block discarded – undo
2756 2875
 		// Load up the default theme options for any missing.
2757 2876
 		foreach ($temp as $k => $v)
2758 2877
 		{
2759
-			if (!isset($context['member']['options'][$k]))
2760
-				$context['member']['options'][$k] = $v;
2878
+			if (!isset($context['member']['options'][$k])) {
2879
+							$context['member']['options'][$k] = $v;
2880
+			}
2761 2881
 		}
2762 2882
 	}
2763 2883
 }
@@ -2772,8 +2892,9 @@  discard block
 block discarded – undo
2772 2892
 	global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir;
2773 2893
 
2774 2894
 	// Have the admins enabled this option?
2775
-	if (empty($modSettings['allow_ignore_boards']))
2776
-		fatal_lang_error('ignoreboards_disallowed', 'user');
2895
+	if (empty($modSettings['allow_ignore_boards'])) {
2896
+			fatal_lang_error('ignoreboards_disallowed', 'user');
2897
+	}
2777 2898
 
2778 2899
 	// Find all the boards this user is allowed to see.
2779 2900
 	$request = $smcFunc['db_query']('order_by_board_order', '
@@ -2793,12 +2914,13 @@  discard block
 block discarded – undo
2793 2914
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2794 2915
 	{
2795 2916
 		// This category hasn't been set up yet..
2796
-		if (!isset($context['categories'][$row['id_cat']]))
2797
-			$context['categories'][$row['id_cat']] = array(
2917
+		if (!isset($context['categories'][$row['id_cat']])) {
2918
+					$context['categories'][$row['id_cat']] = array(
2798 2919
 				'id' => $row['id_cat'],
2799 2920
 				'name' => $row['cat_name'],
2800 2921
 				'boards' => array()
2801 2922
 			);
2923
+		}
2802 2924
 
2803 2925
 		// Set this board up, and let the template know when it's a child.  (indent them..)
2804 2926
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -2828,18 +2950,20 @@  discard block
 block discarded – undo
2828 2950
 	}
2829 2951
 
2830 2952
 	$max_boards = ceil(count($temp_boards) / 2);
2831
-	if ($max_boards == 1)
2832
-		$max_boards = 2;
2953
+	if ($max_boards == 1) {
2954
+			$max_boards = 2;
2955
+	}
2833 2956
 
2834 2957
 	// Now, alternate them so they can be shown left and right ;).
2835 2958
 	$context['board_columns'] = array();
2836 2959
 	for ($i = 0; $i < $max_boards; $i++)
2837 2960
 	{
2838 2961
 		$context['board_columns'][] = $temp_boards[$i];
2839
-		if (isset($temp_boards[$i + $max_boards]))
2840
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
2841
-		else
2842
-			$context['board_columns'][] = array();
2962
+		if (isset($temp_boards[$i + $max_boards])) {
2963
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
2964
+		} else {
2965
+					$context['board_columns'][] = array();
2966
+		}
2843 2967
 	}
2844 2968
 
2845 2969
 	loadThemeOptions($memID);
@@ -2908,8 +3032,9 @@  discard block
 block discarded – undo
2908 3032
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2909 3033
 	{
2910 3034
 		// We should skip the administrator group if they don't have the admin_forum permission!
2911
-		if ($row['id_group'] == 1 && !allowedTo('admin_forum'))
2912
-			continue;
3035
+		if ($row['id_group'] == 1 && !allowedTo('admin_forum')) {
3036
+					continue;
3037
+		}
2913 3038
 
2914 3039
 		$context['member_groups'][$row['id_group']] = array(
2915 3040
 			'id' => $row['id_group'],
@@ -2955,16 +3080,17 @@  discard block
 block discarded – undo
2955 3080
 	$context['max_signature_length'] = $context['signature_limits']['max_length'];
2956 3081
 	// Warning message for signature image limits?
2957 3082
 	$context['signature_warning'] = '';
2958
-	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height'])
2959
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
2960
-	elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height'])
2961
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3083
+	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) {
3084
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
3085
+	} elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) {
3086
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3087
+	}
2962 3088
 
2963 3089
 	$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
2964 3090
 
2965
-	if (empty($context['do_preview']))
2966
-		$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
2967
-	else
3091
+	if (empty($context['do_preview'])) {
3092
+			$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
3093
+	} else
2968 3094
 	{
2969 3095
 		$signature = !empty($_POST['signature']) ? $_POST['signature'] : '';
2970 3096
 		$validation = profileValidateSignature($signature);
@@ -2974,8 +3100,9 @@  discard block
 block discarded – undo
2974 3100
 			$context['post_errors'] = array();
2975 3101
 		}
2976 3102
 		$context['post_errors'][] = 'signature_not_yet_saved';
2977
-		if ($validation !== true && $validation !== false)
2978
-			$context['post_errors'][] = $validation;
3103
+		if ($validation !== true && $validation !== false) {
3104
+					$context['post_errors'][] = $validation;
3105
+		}
2979 3106
 
2980 3107
 		censorText($context['member']['signature']);
2981 3108
 		$context['member']['current_signature'] = $context['member']['signature'];
@@ -2985,8 +3112,9 @@  discard block
 block discarded – undo
2985 3112
 	}
2986 3113
 
2987 3114
 	// Load the spell checker?
2988
-	if ($context['show_spellchecking'])
2989
-		loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3115
+	if ($context['show_spellchecking']) {
3116
+			loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3117
+	}
2990 3118
 
2991 3119
 	return true;
2992 3120
 }
@@ -3020,8 +3148,7 @@  discard block
 block discarded – undo
3020 3148
 			'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11)
3021 3149
 		);
3022 3150
 		$context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']);
3023
-	}
3024
-	elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3151
+	} elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3025 3152
 	{
3026 3153
 		$context['member']['avatar'] += array(
3027 3154
 			'choice' => 'upload',
@@ -3031,33 +3158,34 @@  discard block
 block discarded – undo
3031 3158
 		$context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename'];
3032 3159
 	}
3033 3160
 	// Use "avatar_original" here so we show what the user entered even if the image proxy is enabled
3034
-	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external'])
3035
-		$context['member']['avatar'] += array(
3161
+	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) {
3162
+			$context['member']['avatar'] += array(
3036 3163
 			'choice' => 'external',
3037 3164
 			'server_pic' => 'blank.png',
3038 3165
 			'external' => $cur_profile['avatar_original']
3039 3166
 		);
3040
-	elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored'])
3041
-		$context['member']['avatar'] += array(
3167
+	} elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) {
3168
+			$context['member']['avatar'] += array(
3042 3169
 			'choice' => 'server_stored',
3043 3170
 			'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'],
3044 3171
 			'external' => 'http://'
3045 3172
 		);
3046
-	else
3047
-		$context['member']['avatar'] += array(
3173
+	} else {
3174
+			$context['member']['avatar'] += array(
3048 3175
 			'choice' => 'none',
3049 3176
 			'server_pic' => 'blank.png',
3050 3177
 			'external' => 'http://'
3051 3178
 		);
3179
+	}
3052 3180
 
3053 3181
 	// Get a list of all the avatars.
3054 3182
 	if ($context['member']['avatar']['allow_server_stored'])
3055 3183
 	{
3056 3184
 		$context['avatar_list'] = array();
3057 3185
 		$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array();
3186
+	} else {
3187
+			$context['avatars'] = array();
3058 3188
 	}
3059
-	else
3060
-		$context['avatars'] = array();
3061 3189
 
3062 3190
 	// Second level selected avatar...
3063 3191
 	$context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1);
@@ -3086,19 +3214,22 @@  discard block
 block discarded – undo
3086 3214
 			)
3087 3215
 		);
3088 3216
 		$protected_groups = array(1);
3089
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3090
-			$protected_groups[] = $row['id_group'];
3217
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3218
+					$protected_groups[] = $row['id_group'];
3219
+		}
3091 3220
 		$smcFunc['db_free_result']($request);
3092 3221
 
3093 3222
 		$protected_groups = array_unique($protected_groups);
3094 3223
 	}
3095 3224
 
3096 3225
 	// The account page allows the change of your id_group - but not to a protected group!
3097
-	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0)
3098
-		$value = (int) $value;
3226
+	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) {
3227
+			$value = (int) $value;
3228
+	}
3099 3229
 	// ... otherwise it's the old group sir.
3100
-	else
3101
-		$value = $old_profile['id_group'];
3230
+	else {
3231
+			$value = $old_profile['id_group'];
3232
+	}
3102 3233
 
3103 3234
 	// Find the additional membergroups (if any)
3104 3235
 	if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups']))
@@ -3107,16 +3238,18 @@  discard block
 block discarded – undo
3107 3238
 		foreach ($_POST['additional_groups'] as $group_id)
3108 3239
 		{
3109 3240
 			$group_id = (int) $group_id;
3110
-			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups)))
3111
-				$additional_groups[] = $group_id;
3241
+			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) {
3242
+							$additional_groups[] = $group_id;
3243
+			}
3112 3244
 		}
3113 3245
 
3114 3246
 		// Put the protected groups back in there if you don't have permission to take them away.
3115 3247
 		$old_additional_groups = explode(',', $old_profile['additional_groups']);
3116 3248
 		foreach ($old_additional_groups as $group_id)
3117 3249
 		{
3118
-			if (!empty($protected_groups) && in_array($group_id, $protected_groups))
3119
-				$additional_groups[] = $group_id;
3250
+			if (!empty($protected_groups) && in_array($group_id, $protected_groups)) {
3251
+							$additional_groups[] = $group_id;
3252
+			}
3120 3253
 		}
3121 3254
 
3122 3255
 		if (implode(',', $additional_groups) !== $old_profile['additional_groups'])
@@ -3148,18 +3281,20 @@  discard block
 block discarded – undo
3148 3281
 			list ($another) = $smcFunc['db_fetch_row']($request);
3149 3282
 			$smcFunc['db_free_result']($request);
3150 3283
 
3151
-			if (empty($another))
3152
-				fatal_lang_error('at_least_one_admin', 'critical');
3284
+			if (empty($another)) {
3285
+							fatal_lang_error('at_least_one_admin', 'critical');
3286
+			}
3153 3287
 		}
3154 3288
 	}
3155 3289
 
3156 3290
 	// If we are changing group status, update permission cache as necessary.
3157 3291
 	if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups']))
3158 3292
 	{
3159
-		if ($context['user']['is_owner'])
3160
-			$_SESSION['mc']['time'] = 0;
3161
-		else
3162
-			updateSettings(array('settings_updated' => time()));
3293
+		if ($context['user']['is_owner']) {
3294
+					$_SESSION['mc']['time'] = 0;
3295
+		} else {
3296
+					updateSettings(array('settings_updated' => time()));
3297
+		}
3163 3298
 	}
3164 3299
 
3165 3300
 	// Announce to any hooks that we have changed groups, but don't allow them to change it.
@@ -3180,8 +3315,9 @@  discard block
 block discarded – undo
3180 3315
 	global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;
3181 3316
 
3182 3317
 	$memID = $context['id_member'];
3183
-	if (empty($memID) && !empty($context['password_auth_failed']))
3184
-		return false;
3318
+	if (empty($memID) && !empty($context['password_auth_failed'])) {
3319
+			return false;
3320
+	}
3185 3321
 
3186 3322
 	require_once($sourcedir . '/ManageAttachments.php');
3187 3323
 
@@ -3192,8 +3328,9 @@  discard block
 block discarded – undo
3192 3328
 	$downloadedExternalAvatar = false;
3193 3329
 	if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external']))
3194 3330
 	{
3195
-		if (!is_writable($uploadDir))
3196
-			fatal_lang_error('attachments_no_write', 'critical');
3331
+		if (!is_writable($uploadDir)) {
3332
+					fatal_lang_error('attachments_no_write', 'critical');
3333
+		}
3197 3334
 
3198 3335
 		$url = parse_url($_POST['userpicpersonal']);
3199 3336
 		$contents = fetch_web_data($url['scheme'] . '://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path'])));
@@ -3235,19 +3372,18 @@  discard block
 block discarded – undo
3235 3372
 
3236 3373
 		// Get rid of their old avatar. (if uploaded.)
3237 3374
 		removeAttachments(array('id_member' => $memID));
3238
-	}
3239
-	elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3375
+	} elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3240 3376
 	{
3241 3377
 		// One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar.
3242
-		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL))
3243
-			$profile_vars['avatar'] = 'gravatar://';
3244
-		else
3245
-			$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3378
+		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) {
3379
+					$profile_vars['avatar'] = 'gravatar://';
3380
+		} else {
3381
+					$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3382
+		}
3246 3383
 
3247 3384
 		// Get rid of their old avatar. (if uploaded.)
3248 3385
 		removeAttachments(array('id_member' => $memID));
3249
-	}
3250
-	elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3386
+	} elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3251 3387
 	{
3252 3388
 		// We need these clean...
3253 3389
 		$cur_profile['id_attach'] = 0;
@@ -3259,11 +3395,13 @@  discard block
 block discarded – undo
3259 3395
 
3260 3396
 		$profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']));
3261 3397
 
3262
-		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///')
3263
-			$profile_vars['avatar'] = '';
3398
+		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') {
3399
+					$profile_vars['avatar'] = '';
3400
+		}
3264 3401
 		// Trying to make us do something we'll regret?
3265
-		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://')
3266
-			return 'bad_avatar_invalid_url';
3402
+		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') {
3403
+					return 'bad_avatar_invalid_url';
3404
+		}
3267 3405
 		// Should we check dimensions?
3268 3406
 		elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))
3269 3407
 		{
@@ -3273,9 +3411,9 @@  discard block
 block discarded – undo
3273 3411
 			if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))))
3274 3412
 			{
3275 3413
 				// Houston, we have a problem. The avatar is too large!!
3276
-				if ($modSettings['avatar_action_too_large'] == 'option_refuse')
3277
-					return 'bad_avatar_too_large';
3278
-				elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3414
+				if ($modSettings['avatar_action_too_large'] == 'option_refuse') {
3415
+									return 'bad_avatar_too_large';
3416
+				} elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3279 3417
 				{
3280 3418
 					// @todo remove this if appropriate
3281 3419
 					require_once($sourcedir . '/Subs-Graphics.php');
@@ -3285,26 +3423,27 @@  discard block
 block discarded – undo
3285 3423
 						$cur_profile['id_attach'] = $modSettings['new_avatar_data']['id'];
3286 3424
 						$cur_profile['filename'] = $modSettings['new_avatar_data']['filename'];
3287 3425
 						$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
3426
+					} else {
3427
+											return 'bad_avatar';
3288 3428
 					}
3289
-					else
3290
-						return 'bad_avatar';
3291 3429
 				}
3292 3430
 			}
3293 3431
 		}
3294
-	}
3295
-	elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3432
+	} elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3296 3433
 	{
3297 3434
 		if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar)
3298 3435
 		{
3299 3436
 			// Get the dimensions of the image.
3300 3437
 			if (!$downloadedExternalAvatar)
3301 3438
 			{
3302
-				if (!is_writable($uploadDir))
3303
-					fatal_lang_error('attachments_no_write', 'critical');
3439
+				if (!is_writable($uploadDir)) {
3440
+									fatal_lang_error('attachments_no_write', 'critical');
3441
+				}
3304 3442
 
3305 3443
 				$new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true);
3306
-				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename))
3307
-					fatal_lang_error('attach_timeout', 'critical');
3444
+				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) {
3445
+									fatal_lang_error('attach_timeout', 'critical');
3446
+				}
3308 3447
 
3309 3448
 				$_FILES['attachment']['tmp_name'] = $new_filename;
3310 3449
 			}
@@ -3417,17 +3556,19 @@  discard block
 block discarded – undo
3417 3556
 			$profile_vars['avatar'] = '';
3418 3557
 
3419 3558
 			// Delete any temporary file.
3420
-			if (file_exists($_FILES['attachment']['tmp_name']))
3421
-				@unlink($_FILES['attachment']['tmp_name']);
3559
+			if (file_exists($_FILES['attachment']['tmp_name'])) {
3560
+							@unlink($_FILES['attachment']['tmp_name']);
3561
+			}
3422 3562
 		}
3423 3563
 		// Selected the upload avatar option and had one already uploaded before or didn't upload one.
3424
-		else
3564
+		else {
3565
+					$profile_vars['avatar'] = '';
3566
+		}
3567
+	} elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) {
3568
+			$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3569
+	} else {
3425 3570
 			$profile_vars['avatar'] = '';
3426 3571
 	}
3427
-	elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar'))
3428
-		$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3429
-	else
3430
-		$profile_vars['avatar'] = '';
3431 3572
 
3432 3573
 	// Setup the profile variables so it shows things right on display!
3433 3574
 	$cur_profile['avatar'] = $profile_vars['avatar'];
@@ -3475,9 +3616,9 @@  discard block
 block discarded – undo
3475 3616
 		$smiley_parsed = $unparsed_signature;
3476 3617
 		parsesmileys($smiley_parsed);
3477 3618
 		$smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img');
3478
-		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0)
3479
-			return 'signature_allow_smileys';
3480
-		elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3619
+		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) {
3620
+					return 'signature_allow_smileys';
3621
+		} elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3481 3622
 		{
3482 3623
 			$txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]);
3483 3624
 			return 'signature_max_smileys';
@@ -3490,14 +3631,15 @@  discard block
 block discarded – undo
3490 3631
 			{
3491 3632
 				$limit_broke = 0;
3492 3633
 				// Attempt to allow all sizes of abuse, so to speak.
3493
-				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
3494
-					$limit_broke = $sig_limits[7] . 'px';
3495
-				elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
3496
-					$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3497
-				elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
3498
-					$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3499
-				elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
3500
-					$limit_broke = 'large';
3634
+				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
3635
+									$limit_broke = $sig_limits[7] . 'px';
3636
+				} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
3637
+									$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3638
+				} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
3639
+									$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3640
+				} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
3641
+									$limit_broke = 'large';
3642
+				}
3501 3643
 
3502 3644
 				if ($limit_broke)
3503 3645
 				{
@@ -3539,24 +3681,26 @@  discard block
 block discarded – undo
3539 3681
 					$width = -1; $height = -1;
3540 3682
 
3541 3683
 					// Does it have predefined restraints? Width first.
3542
-					if ($matches[6][$key])
3543
-						$matches[2][$key] = $matches[6][$key];
3684
+					if ($matches[6][$key]) {
3685
+											$matches[2][$key] = $matches[6][$key];
3686
+					}
3544 3687
 					if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
3545 3688
 					{
3546 3689
 						$width = $sig_limits[5];
3547 3690
 						$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
3691
+					} elseif ($matches[2][$key]) {
3692
+											$width = $matches[2][$key];
3548 3693
 					}
3549
-					elseif ($matches[2][$key])
3550
-						$width = $matches[2][$key];
3551 3694
 					// ... and height.
3552 3695
 					if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
3553 3696
 					{
3554 3697
 						$height = $sig_limits[6];
3555
-						if ($width != -1)
3556
-							$width = $width * ($height / $matches[4][$key]);
3698
+						if ($width != -1) {
3699
+													$width = $width * ($height / $matches[4][$key]);
3700
+						}
3701
+					} elseif ($matches[4][$key]) {
3702
+											$height = $matches[4][$key];
3557 3703
 					}
3558
-					elseif ($matches[4][$key])
3559
-						$height = $matches[4][$key];
3560 3704
 
3561 3705
 					// If the dimensions are still not fixed - we need to check the actual image.
3562 3706
 					if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -3574,21 +3718,24 @@  discard block
 block discarded – undo
3574 3718
 							if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
3575 3719
 							{
3576 3720
 								$height = $sig_limits[6];
3577
-								if ($width == -1)
3578
-									$width = $sizes[0];
3721
+								if ($width == -1) {
3722
+																	$width = $sizes[0];
3723
+								}
3579 3724
 								$width = $width * ($height / $sizes[1]);
3725
+							} elseif ($width != -1) {
3726
+															$height = $sizes[1];
3580 3727
 							}
3581
-							elseif ($width != -1)
3582
-								$height = $sizes[1];
3583 3728
 						}
3584 3729
 					}
3585 3730
 
3586 3731
 					// Did we come up with some changes? If so remake the string.
3587
-					if ($width != -1 || $height != -1)
3588
-						$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3732
+					if ($width != -1 || $height != -1) {
3733
+											$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3734
+					}
3735
+				}
3736
+				if (!empty($replaces)) {
3737
+									$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3589 3738
 				}
3590
-				if (!empty($replaces))
3591
-					$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3592 3739
 			}
3593 3740
 		}
3594 3741
 
@@ -3632,10 +3779,12 @@  discard block
 block discarded – undo
3632 3779
 	$email = strtr($email, array('&#039;' => '\''));
3633 3780
 
3634 3781
 	// Check the name and email for validity.
3635
-	if (trim($email) == '')
3636
-		return 'no_email';
3637
-	if (!filter_var($email, FILTER_VALIDATE_EMAIL))
3638
-		return 'bad_email';
3782
+	if (trim($email) == '') {
3783
+			return 'no_email';
3784
+	}
3785
+	if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
3786
+			return 'bad_email';
3787
+	}
3639 3788
 
3640 3789
 	// Email addresses should be and stay unique.
3641 3790
 	$request = $smcFunc['db_query']('', '
@@ -3650,8 +3799,9 @@  discard block
 block discarded – undo
3650 3799
 		)
3651 3800
 	);
3652 3801
 
3653
-	if ($smcFunc['db_num_rows']($request) > 0)
3654
-		return 'email_taken';
3802
+	if ($smcFunc['db_num_rows']($request) > 0) {
3803
+			return 'email_taken';
3804
+	}
3655 3805
 	$smcFunc['db_free_result']($request);
3656 3806
 
3657 3807
 	return true;
@@ -3664,8 +3814,9 @@  discard block
 block discarded – undo
3664 3814
 {
3665 3815
 	global $modSettings, $context, $cur_profile;
3666 3816
 
3667
-	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '')
3668
-		setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3817
+	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') {
3818
+			setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3819
+	}
3669 3820
 
3670 3821
 	loadUserSettings();
3671 3822
 	writeLog();
@@ -3681,8 +3832,9 @@  discard block
 block discarded – undo
3681 3832
 	require_once($sourcedir . '/Subs-Post.php');
3682 3833
 
3683 3834
 	// Shouldn't happen but just in case.
3684
-	if (empty($profile_vars['email_address']))
3685
-		return;
3835
+	if (empty($profile_vars['email_address'])) {
3836
+			return;
3837
+	}
3686 3838
 
3687 3839
 	$replacements = array(
3688 3840
 		'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'],
@@ -3705,8 +3857,9 @@  discard block
 block discarded – undo
3705 3857
 	$_SESSION['log_time'] = 0;
3706 3858
 	$_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0));
3707 3859
 
3708
-	if (isset($_COOKIE[$cookiename]))
3709
-		$_COOKIE[$cookiename] = '';
3860
+	if (isset($_COOKIE[$cookiename])) {
3861
+			$_COOKIE[$cookiename] = '';
3862
+	}
3710 3863
 
3711 3864
 	loadUserSettings();
3712 3865
 
@@ -3739,11 +3892,13 @@  discard block
 block discarded – undo
3739 3892
 	$groups[] = $curMember['id_group'];
3740 3893
 
3741 3894
 	// Ensure the query doesn't croak!
3742
-	if (empty($groups))
3743
-		$groups = array(0);
3895
+	if (empty($groups)) {
3896
+			$groups = array(0);
3897
+	}
3744 3898
 	// Just to be sure...
3745
-	foreach ($groups as $k => $v)
3746
-		$groups[$k] = (int) $v;
3899
+	foreach ($groups as $k => $v) {
3900
+			$groups[$k] = (int) $v;
3901
+	}
3747 3902
 
3748 3903
 	// Get all the membergroups they can join.
3749 3904
 	$request = $smcFunc['db_query']('', '
@@ -3773,12 +3928,14 @@  discard block
 block discarded – undo
3773 3928
 	while ($row = $smcFunc['db_fetch_assoc']($request))
3774 3929
 	{
3775 3930
 		// Can they edit their primary group?
3776
-		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups)))
3777
-			$context['can_edit_primary'] = true;
3931
+		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) {
3932
+					$context['can_edit_primary'] = true;
3933
+		}
3778 3934
 
3779 3935
 		// If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it.
3780
-		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group'])
3781
-			continue;
3936
+		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) {
3937
+					continue;
3938
+		}
3782 3939
 
3783 3940
 		$context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array(
3784 3941
 			'id' => $row['id_group'],
@@ -3807,13 +3964,15 @@  discard block
 block discarded – undo
3807 3964
 	);
3808 3965
 
3809 3966
 	// No changing primary one unless you have enough groups!
3810
-	if (count($context['groups']['member']) < 2)
3811
-		$context['can_edit_primary'] = false;
3967
+	if (count($context['groups']['member']) < 2) {
3968
+			$context['can_edit_primary'] = false;
3969
+	}
3812 3970
 
3813 3971
 	// In the special case that someone is requesting membership of a group, setup some special context vars.
3814
-	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2)
3815
-		$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3816
-}
3972
+	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) {
3973
+			$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3974
+	}
3975
+	}
3817 3976
 
3818 3977
 /**
3819 3978
  * This function actually makes all the group changes
@@ -3828,10 +3987,12 @@  discard block
 block discarded – undo
3828 3987
 	global $user_info, $context, $user_profile, $modSettings, $smcFunc;
3829 3988
 
3830 3989
 	// Let's be extra cautious...
3831
-	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership']))
3832
-		isAllowedTo('manage_membergroups');
3833
-	if (!isset($_REQUEST['gid']) && !isset($_POST['primary']))
3834
-		fatal_lang_error('no_access', false);
3990
+	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) {
3991
+			isAllowedTo('manage_membergroups');
3992
+	}
3993
+	if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) {
3994
+			fatal_lang_error('no_access', false);
3995
+	}
3835 3996
 
3836 3997
 	checkSession(isset($_GET['gid']) ? 'get' : 'post');
3837 3998
 
@@ -3850,8 +4011,9 @@  discard block
 block discarded – undo
3850 4011
 	$foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false;
3851 4012
 
3852 4013
 	// Sanity check!!
3853
-	if ($group_id == 1)
3854
-		isAllowedTo('admin_forum');
4014
+	if ($group_id == 1) {
4015
+			isAllowedTo('admin_forum');
4016
+	}
3855 4017
 	// Protected groups too!
3856 4018
 	else
3857 4019
 	{
@@ -3868,8 +4030,9 @@  discard block
 block discarded – undo
3868 4030
 		list ($is_protected) = $smcFunc['db_fetch_row']($request);
3869 4031
 		$smcFunc['db_free_result']($request);
3870 4032
 
3871
-		if ($is_protected == 1)
3872
-			isAllowedTo('admin_forum');
4033
+		if ($is_protected == 1) {
4034
+					isAllowedTo('admin_forum');
4035
+		}
3873 4036
 	}
3874 4037
 
3875 4038
 	// What ever we are doing, we need to determine if changing primary is possible!
@@ -3891,36 +4054,43 @@  discard block
 block discarded – undo
3891 4054
 			$group_name = $row['group_name'];
3892 4055
 
3893 4056
 			// Does the group type match what we're doing - are we trying to request a non-requestable group?
3894
-			if ($changeType == 'request' && $row['group_type'] != 2)
3895
-				fatal_lang_error('no_access', false);
4057
+			if ($changeType == 'request' && $row['group_type'] != 2) {
4058
+							fatal_lang_error('no_access', false);
4059
+			}
3896 4060
 			// What about leaving a requestable group we are not a member of?
3897
-			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']]))
3898
-				fatal_lang_error('no_access', false);
3899
-			elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2)
3900
-				fatal_lang_error('no_access', false);
4061
+			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) {
4062
+							fatal_lang_error('no_access', false);
4063
+			} elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) {
4064
+							fatal_lang_error('no_access', false);
4065
+			}
3901 4066
 
3902 4067
 			// We can't change the primary group if this is hidden!
3903
-			if ($row['hidden'] == 2)
3904
-				$canChangePrimary = false;
4068
+			if ($row['hidden'] == 2) {
4069
+							$canChangePrimary = false;
4070
+			}
3905 4071
 		}
3906 4072
 
3907 4073
 		// If this is their old primary, can we change it?
3908
-		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false)
3909
-			$canChangePrimary = 1;
4074
+		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) {
4075
+					$canChangePrimary = 1;
4076
+		}
3910 4077
 
3911 4078
 		// If we are not doing a force primary move, don't do it automatically if current primary is not 0.
3912
-		if ($changeType != 'primary' && $old_profile['id_group'] != 0)
3913
-			$canChangePrimary = false;
4079
+		if ($changeType != 'primary' && $old_profile['id_group'] != 0) {
4080
+					$canChangePrimary = false;
4081
+		}
3914 4082
 
3915 4083
 		// If this is the one we are acting on, can we even act?
3916
-		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0))
3917
-			$canChangePrimary = false;
4084
+		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) {
4085
+					$canChangePrimary = false;
4086
+		}
3918 4087
 	}
3919 4088
 	$smcFunc['db_free_result']($request);
3920 4089
 
3921 4090
 	// Didn't find the target?
3922
-	if (!$foundTarget)
3923
-		fatal_lang_error('no_access', false);
4091
+	if (!$foundTarget) {
4092
+			fatal_lang_error('no_access', false);
4093
+	}
3924 4094
 
3925 4095
 	// Final security check, don't allow users to promote themselves to admin.
3926 4096
 	if ($context['can_manage_membergroups'] && !allowedTo('admin_forum'))
@@ -3940,8 +4110,9 @@  discard block
 block discarded – undo
3940 4110
 		list ($disallow) = $smcFunc['db_fetch_row']($request);
3941 4111
 		$smcFunc['db_free_result']($request);
3942 4112
 
3943
-		if ($disallow)
3944
-			isAllowedTo('admin_forum');
4113
+		if ($disallow) {
4114
+					isAllowedTo('admin_forum');
4115
+		}
3945 4116
 	}
3946 4117
 
3947 4118
 	// If we're requesting, add the note then return.
@@ -3959,8 +4130,9 @@  discard block
 block discarded – undo
3959 4130
 				'status_open' => 0,
3960 4131
 			)
3961 4132
 		);
3962
-		if ($smcFunc['db_num_rows']($request) != 0)
3963
-			fatal_lang_error('profile_error_already_requested_group');
4133
+		if ($smcFunc['db_num_rows']($request) != 0) {
4134
+					fatal_lang_error('profile_error_already_requested_group');
4135
+		}
3964 4136
 		$smcFunc['db_free_result']($request);
3965 4137
 
3966 4138
 		// Log the request.
@@ -3994,10 +4166,11 @@  discard block
 block discarded – undo
3994 4166
 		// Are we leaving?
3995 4167
 		if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id]))
3996 4168
 		{
3997
-			if ($old_profile['id_group'] == $group_id)
3998
-				$newPrimary = 0;
3999
-			else
4000
-				unset($addGroups[$group_id]);
4169
+			if ($old_profile['id_group'] == $group_id) {
4170
+							$newPrimary = 0;
4171
+			} else {
4172
+							unset($addGroups[$group_id]);
4173
+			}
4001 4174
 		}
4002 4175
 		// ... if not, must be joining.
4003 4176
 		else
@@ -4005,36 +4178,42 @@  discard block
 block discarded – undo
4005 4178
 			// Can we change the primary, and do we want to?
4006 4179
 			if ($canChangePrimary)
4007 4180
 			{
4008
-				if ($old_profile['id_group'] != 0)
4009
-					$addGroups[$old_profile['id_group']] = -1;
4181
+				if ($old_profile['id_group'] != 0) {
4182
+									$addGroups[$old_profile['id_group']] = -1;
4183
+				}
4010 4184
 				$newPrimary = $group_id;
4011 4185
 			}
4012 4186
 			// Otherwise it's an additional group...
4013
-			else
4014
-				$addGroups[$group_id] = -1;
4187
+			else {
4188
+							$addGroups[$group_id] = -1;
4189
+			}
4015 4190
 		}
4016 4191
 	}
4017 4192
 	// Finally, we must be setting the primary.
4018 4193
 	elseif ($canChangePrimary)
4019 4194
 	{
4020
-		if ($old_profile['id_group'] != 0)
4021
-			$addGroups[$old_profile['id_group']] = -1;
4022
-		if (isset($addGroups[$group_id]))
4023
-			unset($addGroups[$group_id]);
4195
+		if ($old_profile['id_group'] != 0) {
4196
+					$addGroups[$old_profile['id_group']] = -1;
4197
+		}
4198
+		if (isset($addGroups[$group_id])) {
4199
+					unset($addGroups[$group_id]);
4200
+		}
4024 4201
 		$newPrimary = $group_id;
4025 4202
 	}
4026 4203
 
4027 4204
 	// Finally, we can make the changes!
4028
-	foreach ($addGroups as $id => $dummy)
4029
-		if (empty($id))
4205
+	foreach ($addGroups as $id => $dummy) {
4206
+			if (empty($id))
4030 4207
 			unset($addGroups[$id]);
4208
+	}
4031 4209
 	$addGroups = implode(',', array_flip($addGroups));
4032 4210
 
4033 4211
 	// Ensure that we don't cache permissions if the group is changing.
4034
-	if ($context['user']['is_owner'])
4035
-		$_SESSION['mc']['time'] = 0;
4036
-	else
4037
-		updateSettings(array('settings_updated' => time()));
4212
+	if ($context['user']['is_owner']) {
4213
+			$_SESSION['mc']['time'] = 0;
4214
+	} else {
4215
+			updateSettings(array('settings_updated' => time()));
4216
+	}
4038 4217
 
4039 4218
 	updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups));
4040 4219
 
@@ -4057,8 +4236,9 @@  discard block
 block discarded – undo
4057 4236
 	if (empty($user_settings['tfa_secret']) && $context['user']['is_owner'])
4058 4237
 	{
4059 4238
 		// Check to ensure we're forcing SSL for authentication
4060
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
4061
-			fatal_lang_error('login_ssl_required');
4239
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
4240
+					fatal_lang_error('login_ssl_required');
4241
+		}
4062 4242
 
4063 4243
 		// In some cases (forced 2FA or backup code) they would be forced to be redirected here,
4064 4244
 		// we do not want too much AJAX to confuse them.
@@ -4095,8 +4275,7 @@  discard block
 block discarded – undo
4095 4275
 				$context['sub_template'] = 'tfasetup_backup';
4096 4276
 
4097 4277
 				return;
4098
-			}
4099
-			else
4278
+			} else
4100 4279
 			{
4101 4280
 				$context['tfa_secret'] = $_SESSION['tfa_secret'];
4102 4281
 				$context['tfa_error'] = !$valid_code;
@@ -4104,8 +4283,7 @@  discard block
 block discarded – undo
4104 4283
 				$context['tfa_pass_value'] = $_POST['passwd'];
4105 4284
 				$context['tfa_value'] = $_POST['tfa_code'];
4106 4285
 			}
4107
-		}
4108
-		else
4286
+		} else
4109 4287
 		{
4110 4288
 			$totp = new \TOTP\Auth();
4111 4289
 			$secret = $totp->generateCode();
@@ -4115,17 +4293,16 @@  discard block
 block discarded – undo
4115 4293
 		}
4116 4294
 
4117 4295
 		$context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']);
4118
-	}
4119
-	elseif (isset($_REQUEST['disable']))
4296
+	} elseif (isset($_REQUEST['disable']))
4120 4297
 	{
4121 4298
 		updateMemberData($memID, array(
4122 4299
 			'tfa_secret' => '',
4123 4300
 			'tfa_backup' => '',
4124 4301
 		));
4125 4302
 		redirectexit('action=profile;area=account;u=' . $memID);
4303
+	} else {
4304
+			redirectexit('action=profile;area=account;u=' . $memID);
4305
+	}
4126 4306
 	}
4127
-	else
4128
-		redirectexit('action=profile;area=account;u=' . $memID);
4129
-}
4130 4307
 
4131 4308
 ?>
4132 4309
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ManagePosts.php 1 patch
Braces   +39 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main entrance point for the 'Posts and topics' screen.
@@ -98,23 +99,23 @@  discard block
 block discarded – undo
98 99
 		{
99 100
 			$_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
100 101
 
101
-			foreach ($_POST['censortext'] as $c)
102
-				list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
103
-		}
104
-		elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
102
+			foreach ($_POST['censortext'] as $c) {
103
+							list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
104
+			}
105
+		} elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
105 106
 		{
106 107
 			if (is_array($_POST['censor_vulgar']))
107 108
 			{
108 109
 				foreach ($_POST['censor_vulgar'] as $i => $value)
109 110
 				{
110
-					if (trim(strtr($value, '*', ' ')) == '')
111
-						unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
111
+					if (trim(strtr($value, '*', ' ')) == '') {
112
+											unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
113
+					}
112 114
 				}
113 115
 
114 116
 				$censored_vulgar = $_POST['censor_vulgar'];
115 117
 				$censored_proper = $_POST['censor_proper'];
116
-			}
117
-			else
118
+			} else
118 119
 			{
119 120
 				$censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
120 121
 				$censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
@@ -151,12 +152,14 @@  discard block
 block discarded – undo
151 152
 	$context['censored_words'] = array();
152 153
 	for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
153 154
 	{
154
-		if (empty($censor_vulgar[$i]))
155
-			continue;
155
+		if (empty($censor_vulgar[$i])) {
156
+					continue;
157
+		}
156 158
 
157 159
 		// Skip it, it's either spaces or stars only.
158
-		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
159
-			continue;
160
+		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') {
161
+					continue;
162
+		}
160 163
 
161 164
 		$context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : '';
162 165
 	}
@@ -187,10 +190,11 @@  discard block
 block discarded – undo
187 190
 
188 191
 	// Make an inline conditional a little shorter...
189 192
 	$can_spell_check = false;
190
-	if (function_exists('pspell_new'))
191
-		$can_spell_check = true;
192
-	elseif (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv')))
193
-		$can_spell_check = true;
193
+	if (function_exists('pspell_new')) {
194
+			$can_spell_check = true;
195
+	} elseif (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))) {
196
+			$can_spell_check = true;
197
+	}
194 198
 
195 199
 	// All the settings...
196 200
 	$config_vars = array(
@@ -220,8 +224,9 @@  discard block
 block discarded – undo
220 224
 
221 225
 	call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
222 226
 
223
-	if ($return_config)
224
-		return $config_vars;
227
+	if ($return_config) {
228
+			return $config_vars;
229
+	}
225 230
 
226 231
 	// We'll want this for our easy save.
227 232
 	require_once($sourcedir . '/ManageServer.php');
@@ -241,17 +246,20 @@  discard block
 block discarded – undo
241 246
 			db_extend('packages');
242 247
 
243 248
 			$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
244
-			foreach ($colData as $column)
245
-				if ($column['name'] == 'body')
249
+			foreach ($colData as $column) {
250
+							if ($column['name'] == 'body')
246 251
 					$body_type = $column['type'];
252
+			}
247 253
 
248
-			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text')
249
-				fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
254
+			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') {
255
+							fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
256
+			}
250 257
 		}
251 258
 
252 259
 		// If we're changing the post preview length let's check its valid
253
-		if (!empty($_POST['preview_characters']))
254
-			$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
260
+		if (!empty($_POST['preview_characters'])) {
261
+					$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
262
+		}
255 263
 
256 264
 		call_integration_hook('integrate_save_post_settings');
257 265
 
@@ -312,8 +320,9 @@  discard block
 block discarded – undo
312 320
 
313 321
 	call_integration_hook('integrate_modify_topic_settings', array(&$config_vars));
314 322
 
315
-	if ($return_config)
316
-		return $config_vars;
323
+	if ($return_config) {
324
+			return $config_vars;
325
+	}
317 326
 
318 327
 	// Get the settings template ready.
319 328
 	require_once($sourcedir . '/ManageServer.php');
@@ -366,8 +375,9 @@  discard block
 block discarded – undo
366 375
 		array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
367 376
 	);
368 377
 
369
-	if ($return_config)
370
-		return $config_vars;
378
+	if ($return_config) {
379
+			return $config_vars;
380
+	}
371 381
 
372 382
 	// Get the settings template ready.
373 383
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.
Sources/Themes.php 1 patch
Braces   +345 added lines, -269 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
  * @version 2.1 Beta 4
31 31
  */
32 32
 
33
-if (!defined('SMF'))
33
+if (!defined('SMF')) {
34 34
 	die('No direct access...');
35
+}
35 36
 
36 37
 /**
37 38
  * Subaction handler - manages the action and delegates control to the proper
@@ -103,12 +104,12 @@  discard block
 block discarded – undo
103 104
 	cache_put_data('minimized_css', null);
104 105
 
105 106
 	// Follow the sa or just go to administration.
106
-	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']]))
107
-		call_helper($subActions[$_GET['sa']]);
108
-
109
-	else
110
-		call_helper($subActions['admin']);
111
-}
107
+	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) {
108
+			call_helper($subActions[$_GET['sa']]);
109
+	} else {
110
+			call_helper($subActions['admin']);
111
+	}
112
+	}
112 113
 
113 114
 /**
114 115
  * This function allows administration of themes and their settings,
@@ -130,15 +131,16 @@  discard block
 block discarded – undo
130 131
 		checkSession();
131 132
 		validateToken('admin-tm');
132 133
 
133
-		if (isset($_POST['options']['known_themes']))
134
-			foreach ($_POST['options']['known_themes'] as $key => $id)
134
+		if (isset($_POST['options']['known_themes'])) {
135
+					foreach ($_POST['options']['known_themes'] as $key => $id)
135 136
 				$_POST['options']['known_themes'][$key] = (int) $id;
137
+		} else {
138
+					fatal_lang_error('themes_none_selectable', false);
139
+		}
136 140
 
137
-		else
138
-			fatal_lang_error('themes_none_selectable', false);
139
-
140
-		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes']))
141
-			fatal_lang_error('themes_default_selectable', false);
141
+		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) {
142
+					fatal_lang_error('themes_default_selectable', false);
143
+		}
142 144
 
143 145
 		// Commit the new settings.
144 146
 		updateSettings(array(
@@ -146,8 +148,9 @@  discard block
 block discarded – undo
146 148
 			'theme_guests' => $_POST['options']['theme_guests'],
147 149
 			'knownThemes' => implode(',', $_POST['options']['known_themes']),
148 150
 		));
149
-		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes']))
150
-			updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
151
+		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) {
152
+					updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
153
+		}
151 154
 
152 155
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin');
153 156
 	}
@@ -166,8 +169,9 @@  discard block
 block discarded – undo
166 169
 	// Look for a non existent theme directory. (ie theme87.)
167 170
 	$theme_dir = $boarddir . '/Themes/theme';
168 171
 	$i = 1;
169
-	while (file_exists($theme_dir . $i))
170
-		$i++;
172
+	while (file_exists($theme_dir . $i)) {
173
+			$i++;
174
+	}
171 175
 
172 176
 	$context['new_theme_name'] = 'theme' . $i;
173 177
 
@@ -189,8 +193,9 @@  discard block
 block discarded – undo
189 193
 	loadLanguage('Admin');
190 194
 	isAllowedTo('admin_forum');
191 195
 
192
-	if (isset($_REQUEST['th']))
193
-		return SetThemeSettings();
196
+	if (isset($_REQUEST['th'])) {
197
+			return SetThemeSettings();
198
+	}
194 199
 
195 200
 	if (isset($_POST['save']))
196 201
 	{
@@ -274,12 +279,13 @@  discard block
 block discarded – undo
274 279
 		$context['themes'] = array();
275 280
 		while ($row = $smcFunc['db_fetch_assoc']($request))
276 281
 		{
277
-			if (!isset($context['themes'][$row['id_theme']]))
278
-				$context['themes'][$row['id_theme']] = array(
282
+			if (!isset($context['themes'][$row['id_theme']])) {
283
+							$context['themes'][$row['id_theme']] = array(
279 284
 					'id' => $row['id_theme'],
280 285
 					'num_default_options' => 0,
281 286
 					'num_members' => 0,
282 287
 				);
288
+			}
283 289
 			$context['themes'][$row['id_theme']][$row['variable']] = $row['value'];
284 290
 		}
285 291
 		$smcFunc['db_free_result']($request);
@@ -293,8 +299,9 @@  discard block
 block discarded – undo
293 299
 				'guest_member' => -1,
294 300
 			)
295 301
 		);
296
-		while ($row = $smcFunc['db_fetch_assoc']($request))
297
-			$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
302
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
303
+					$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
304
+		}
298 305
 		$smcFunc['db_free_result']($request);
299 306
 
300 307
 		// Need to make sure we don't do custom fields.
@@ -305,8 +312,9 @@  discard block
 block discarded – undo
305 312
 			)
306 313
 		);
307 314
 		$customFields = array();
308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
309
-			$customFields[] = $row['col_name'];
315
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
316
+					$customFields[] = $row['col_name'];
317
+		}
310 318
 		$smcFunc['db_free_result']($request);
311 319
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
312 320
 
@@ -321,14 +329,16 @@  discard block
 block discarded – undo
321 329
 				'custom_fields' => empty($customFields) ? array() : $customFields,
322 330
 			)
323 331
 		);
324
-		while ($row = $smcFunc['db_fetch_assoc']($request))
325
-			$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
332
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
333
+					$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
334
+		}
326 335
 		$smcFunc['db_free_result']($request);
327 336
 
328 337
 		// There has to be a Settings template!
329
-		foreach ($context['themes'] as $k => $v)
330
-			if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
338
+		foreach ($context['themes'] as $k => $v) {
339
+					if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
331 340
 				unset($context['themes'][$k]);
341
+		}
332 342
 
333 343
 		loadTemplate('Themes');
334 344
 		$context['sub_template'] = 'reset_list';
@@ -343,16 +353,19 @@  discard block
 block discarded – undo
343 353
 		checkSession();
344 354
 		validateToken('admin-sto');
345 355
 
346
-		if (empty($_POST['options']))
347
-			$_POST['options'] = array();
348
-		if (empty($_POST['default_options']))
349
-			$_POST['default_options'] = array();
356
+		if (empty($_POST['options'])) {
357
+					$_POST['options'] = array();
358
+		}
359
+		if (empty($_POST['default_options'])) {
360
+					$_POST['default_options'] = array();
361
+		}
350 362
 
351 363
 		// Set up the sql query.
352 364
 		$setValues = array();
353 365
 
354
-		foreach ($_POST['options'] as $opt => $val)
355
-			$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
366
+		foreach ($_POST['options'] as $opt => $val) {
367
+					$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
368
+		}
356 369
 
357 370
 		$old_settings = array();
358 371
 		foreach ($_POST['default_options'] as $opt => $val)
@@ -366,8 +379,8 @@  discard block
 block discarded – undo
366 379
 		if (!empty($setValues))
367 380
 		{
368 381
 			// Are there options in non-default themes set that should be cleared?
369
-			if (!empty($old_settings))
370
-				$smcFunc['db_query']('', '
382
+			if (!empty($old_settings)) {
383
+							$smcFunc['db_query']('', '
371 384
 					DELETE FROM {db_prefix}themes
372 385
 					WHERE id_theme != {int:default_theme}
373 386
 						AND id_member = {int:guest_member}
@@ -378,6 +391,7 @@  discard block
 block discarded – undo
378 391
 						'old_settings' => $old_settings,
379 392
 					)
380 393
 				);
394
+			}
381 395
 
382 396
 			$smcFunc['db_insert']('replace',
383 397
 				'{db_prefix}themes',
@@ -391,8 +405,7 @@  discard block
 block discarded – undo
391 405
 		cache_put_data('theme_settings-1', null, 90);
392 406
 
393 407
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
394
-	}
395
-	elseif (isset($_POST['submit']) && $_POST['who'] == 1)
408
+	} elseif (isset($_POST['submit']) && $_POST['who'] == 1)
396 409
 	{
397 410
 		checkSession();
398 411
 		validateToken('admin-sto');
@@ -405,9 +418,9 @@  discard block
 block discarded – undo
405 418
 		$old_settings = array();
406 419
 		foreach ($_POST['default_options'] as $opt => $val)
407 420
 		{
408
-			if ($_POST['default_options_master'][$opt] == 0)
409
-				continue;
410
-			elseif ($_POST['default_options_master'][$opt] == 1)
421
+			if ($_POST['default_options_master'][$opt] == 0) {
422
+							continue;
423
+			} elseif ($_POST['default_options_master'][$opt] == 1)
411 424
 			{
412 425
 				// Delete then insert for ease of database compatibility!
413 426
 				$smcFunc['db_query']('substring', '
@@ -433,8 +446,7 @@  discard block
 block discarded – undo
433 446
 				);
434 447
 
435 448
 				$old_settings[] = $opt;
436
-			}
437
-			elseif ($_POST['default_options_master'][$opt] == 2)
449
+			} elseif ($_POST['default_options_master'][$opt] == 2)
438 450
 			{
439 451
 				$smcFunc['db_query']('', '
440 452
 					DELETE FROM {db_prefix}themes
@@ -449,8 +461,8 @@  discard block
 block discarded – undo
449 461
 		}
450 462
 
451 463
 		// Delete options from other themes.
452
-		if (!empty($old_settings))
453
-			$smcFunc['db_query']('', '
464
+		if (!empty($old_settings)) {
465
+					$smcFunc['db_query']('', '
454 466
 				DELETE FROM {db_prefix}themes
455 467
 				WHERE id_theme != {int:default_theme}
456 468
 					AND id_member > {int:no_member}
@@ -461,12 +473,13 @@  discard block
 block discarded – undo
461 473
 					'old_settings' => $old_settings,
462 474
 				)
463 475
 			);
476
+		}
464 477
 
465 478
 		foreach ($_POST['options'] as $opt => $val)
466 479
 		{
467
-			if ($_POST['options_master'][$opt] == 0)
468
-				continue;
469
-			elseif ($_POST['options_master'][$opt] == 1)
480
+			if ($_POST['options_master'][$opt] == 0) {
481
+							continue;
482
+			} elseif ($_POST['options_master'][$opt] == 1)
470 483
 			{
471 484
 				// Delete then insert for ease of database compatibility - again!
472 485
 				$smcFunc['db_query']('substring', '
@@ -491,8 +504,7 @@  discard block
 block discarded – undo
491 504
 						'value' => (is_array($val) ? implode(',', $val) : $val),
492 505
 					)
493 506
 				);
494
-			}
495
-			elseif ($_POST['options_master'][$opt] == 2)
507
+			} elseif ($_POST['options_master'][$opt] == 2)
496 508
 			{
497 509
 				$smcFunc['db_query']('', '
498 510
 					DELETE FROM {db_prefix}themes
@@ -509,8 +521,7 @@  discard block
 block discarded – undo
509 521
 		}
510 522
 
511 523
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
512
-	}
513
-	elseif (!empty($_GET['who']) && $_GET['who'] == 2)
524
+	} elseif (!empty($_GET['who']) && $_GET['who'] == 2)
514 525
 	{
515 526
 		checkSession('get');
516 527
 		validateToken('admin-stor', 'request');
@@ -525,8 +536,9 @@  discard block
 block discarded – undo
525 536
 				)
526 537
 			);
527 538
 			$customFields = array();
528
-			while ($row = $smcFunc['db_fetch_assoc']($request))
529
-				$customFields[] = $row['col_name'];
539
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
540
+							$customFields[] = $row['col_name'];
541
+			}
530 542
 			$smcFunc['db_free_result']($request);
531 543
 		}
532 544
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
@@ -581,13 +593,13 @@  discard block
 block discarded – undo
581 593
 			)
582 594
 		);
583 595
 		$context['theme_options'] = array();
584
-		while ($row = $smcFunc['db_fetch_assoc']($request))
585
-			$context['theme_options'][$row['variable']] = $row['value'];
596
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
597
+					$context['theme_options'][$row['variable']] = $row['value'];
598
+		}
586 599
 		$smcFunc['db_free_result']($request);
587 600
 
588 601
 		$context['theme_options_reset'] = false;
589
-	}
590
-	else
602
+	} else
591 603
 	{
592 604
 		$context['theme_options'] = array();
593 605
 		$context['theme_options_reset'] = true;
@@ -596,8 +608,9 @@  discard block
 block discarded – undo
596 608
 	foreach ($context['options'] as $i => $setting)
597 609
 	{
598 610
 		// Just skip separators
599
-		if (!is_array($setting))
600
-			continue;
611
+		if (!is_array($setting)) {
612
+					continue;
613
+		}
601 614
 
602 615
 		// Is this disabled?
603 616
 		if (isset($setting['enabled']) && $setting['enabled'] === false)
@@ -606,15 +619,17 @@  discard block
 block discarded – undo
606 619
 			continue;
607 620
 		}
608 621
 
609
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
610
-			$context['options'][$i]['type'] = 'checkbox';
611
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
612
-			$context['options'][$i]['type'] = 'number';
613
-		elseif ($setting['type'] == 'string')
614
-			$context['options'][$i]['type'] = 'text';
622
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
623
+					$context['options'][$i]['type'] = 'checkbox';
624
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
625
+					$context['options'][$i]['type'] = 'number';
626
+		} elseif ($setting['type'] == 'string') {
627
+					$context['options'][$i]['type'] = 'text';
628
+		}
615 629
 
616
-		if (isset($setting['options']))
617
-			$context['options'][$i]['type'] = 'list';
630
+		if (isset($setting['options'])) {
631
+					$context['options'][$i]['type'] = 'list';
632
+		}
618 633
 
619 634
 		$context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']];
620 635
 	}
@@ -639,8 +654,9 @@  discard block
 block discarded – undo
639 654
 {
640 655
 	global $txt, $context, $settings, $modSettings, $smcFunc;
641 656
 
642
-	if (empty($_GET['th']) && empty($_GET['id']))
643
-		return ThemeAdmin();
657
+	if (empty($_GET['th']) && empty($_GET['id'])) {
658
+			return ThemeAdmin();
659
+	}
644 660
 
645 661
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
646 662
 
@@ -651,8 +667,9 @@  discard block
 block discarded – undo
651 667
 	isAllowedTo('admin_forum');
652 668
 
653 669
 	// Validate inputs/user.
654
-	if (empty($_GET['th']))
655
-		fatal_lang_error('no_theme', false);
670
+	if (empty($_GET['th'])) {
671
+			fatal_lang_error('no_theme', false);
672
+	}
656 673
 
657 674
 	// Fetch the smiley sets...
658 675
 	$sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
@@ -660,8 +677,9 @@  discard block
 block discarded – undo
660 677
 	$context['smiley_sets'] = array(
661 678
 		'' => $txt['smileys_no_default']
662 679
 	);
663
-	foreach ($sets as $i => $set)
664
-		$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
680
+	foreach ($sets as $i => $set) {
681
+			$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
682
+	}
665 683
 
666 684
 	$old_id = $settings['theme_id'];
667 685
 	$old_settings = $settings;
@@ -686,8 +704,9 @@  discard block
 block discarded – undo
686 704
 	if (file_exists($settings['theme_dir'] . '/index.template.php'))
687 705
 	{
688 706
 		$file_contents = implode('', file($settings['theme_dir'] . '/index.template.php'));
689
-		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches))
690
-				eval('global $settings;' . $matches[0]);
707
+		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) {
708
+						eval('global $settings;' . $matches[0]);
709
+		}
691 710
 	}
692 711
 
693 712
 	// Let mods hook into the theme settings.
@@ -699,37 +718,45 @@  discard block
 block discarded – undo
699 718
 		checkSession();
700 719
 		validateToken('admin-sts');
701 720
 
702
-		if (empty($_POST['options']))
703
-			$_POST['options'] = array();
704
-		if (empty($_POST['default_options']))
705
-			$_POST['default_options'] = array();
721
+		if (empty($_POST['options'])) {
722
+					$_POST['options'] = array();
723
+		}
724
+		if (empty($_POST['default_options'])) {
725
+					$_POST['default_options'] = array();
726
+		}
706 727
 
707 728
 		// Make sure items are cast correctly.
708 729
 		foreach ($context['theme_settings'] as $item)
709 730
 		{
710 731
 			// Disregard this item if this is just a separator.
711
-			if (!is_array($item))
712
-				continue;
732
+			if (!is_array($item)) {
733
+							continue;
734
+			}
713 735
 
714 736
 			foreach (array('options', 'default_options') as $option)
715 737
 			{
716
-				if (!isset($_POST[$option][$item['id']]))
717
-					continue;
738
+				if (!isset($_POST[$option][$item['id']])) {
739
+									continue;
740
+				}
718 741
 				// Checkbox.
719
-				elseif (empty($item['type']))
720
-					$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
742
+				elseif (empty($item['type'])) {
743
+									$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
744
+				}
721 745
 				// Number
722
-				elseif ($item['type'] == 'number')
723
-					$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
746
+				elseif ($item['type'] == 'number') {
747
+									$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
748
+				}
724 749
 			}
725 750
 		}
726 751
 
727 752
 		// Set up the sql query.
728 753
 		$inserts = array();
729
-		foreach ($_POST['options'] as $opt => $val)
730
-			$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
731
-		foreach ($_POST['default_options'] as $opt => $val)
732
-			$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
754
+		foreach ($_POST['options'] as $opt => $val) {
755
+					$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
756
+		}
757
+		foreach ($_POST['default_options'] as $opt => $val) {
758
+					$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
759
+		}
733 760
 		// If we're actually inserting something..
734 761
 		if (!empty($inserts))
735 762
 		{
@@ -755,8 +782,9 @@  discard block
 block discarded – undo
755 782
 
756 783
 	foreach ($settings as $setting => $dummy)
757 784
 	{
758
-		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs')))
759
-			$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
785
+		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
786
+					$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
787
+		}
760 788
 	}
761 789
 
762 790
 	$context['settings'] = $context['theme_settings'];
@@ -765,18 +793,21 @@  discard block
 block discarded – undo
765 793
 	foreach ($context['settings'] as $i => $setting)
766 794
 	{
767 795
 		// Separators are dummies, so leave them alone.
768
-		if (!is_array($setting))
769
-			continue;
796
+		if (!is_array($setting)) {
797
+					continue;
798
+		}
770 799
 
771
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
772
-			$context['settings'][$i]['type'] = 'checkbox';
773
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
774
-			$context['settings'][$i]['type'] = 'number';
775
-		elseif ($setting['type'] == 'string')
776
-			$context['settings'][$i]['type'] = 'text';
800
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
801
+					$context['settings'][$i]['type'] = 'checkbox';
802
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
803
+					$context['settings'][$i]['type'] = 'number';
804
+		} elseif ($setting['type'] == 'string') {
805
+					$context['settings'][$i]['type'] = 'text';
806
+		}
777 807
 
778
-		if (isset($setting['options']))
779
-			$context['settings'][$i]['type'] = 'list';
808
+		if (isset($setting['options'])) {
809
+					$context['settings'][$i]['type'] = 'list';
810
+		}
780 811
 
781 812
 		$context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
782 813
 	}
@@ -829,8 +860,9 @@  discard block
 block discarded – undo
829 860
 	$themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
830 861
 
831 862
 	// You can't delete the default theme!
832
-	if ($themeID == 1)
833
-		fatal_lang_error('no_access', false);
863
+	if ($themeID == 1) {
864
+			fatal_lang_error('no_access', false);
865
+	}
834 866
 
835 867
 	$theme_info = get_single_theme($themeID);
836 868
 
@@ -838,8 +870,9 @@  discard block
 block discarded – undo
838 870
 	remove_theme($themeID);
839 871
 
840 872
 	// And remove all its files and folders too.
841
-	if (!empty($theme_info) && !empty($theme_info['theme_dir']))
842
-		remove_dir($theme_info['theme_dir']);
873
+	if (!empty($theme_info) && !empty($theme_info['theme_dir'])) {
874
+			remove_dir($theme_info['theme_dir']);
875
+	}
843 876
 
844 877
 	// Go back to the list page.
845 878
 	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing');
@@ -864,12 +897,14 @@  discard block
 block discarded – undo
864 897
 	$enableThemes = explode(',', $modSettings['enableThemes']);
865 898
 
866 899
 	// Are we disabling it?
867
-	if (isset($_GET['disabled']))
868
-		$enableThemes = array_diff($enableThemes, array($themeID));
900
+	if (isset($_GET['disabled'])) {
901
+			$enableThemes = array_diff($enableThemes, array($themeID));
902
+	}
869 903
 
870 904
 	// Nope? then enable it!
871
-	else
872
-		$enableThemes[] = (string) $themeID;
905
+	else {
906
+			$enableThemes[] = (string) $themeID;
907
+	}
873 908
 
874 909
 	// Update the setting.
875 910
 	$enableThemes = strtr(implode(',', $enableThemes), array(',,' => ','));
@@ -904,18 +939,21 @@  discard block
 block discarded – undo
904 939
 
905 940
 	$_SESSION['id_theme'] = 0;
906 941
 
907
-	if (isset($_GET['id']))
908
-		$_GET['th'] = $_GET['id'];
942
+	if (isset($_GET['id'])) {
943
+			$_GET['th'] = $_GET['id'];
944
+	}
909 945
 
910 946
 	// Saving a variant cause JS doesn't work - pretend it did ;)
911 947
 	if (isset($_POST['save']))
912 948
 	{
913 949
 		// Which theme?
914
-		foreach ($_POST['save'] as $k => $v)
915
-			$_GET['th'] = (int) $k;
950
+		foreach ($_POST['save'] as $k => $v) {
951
+					$_GET['th'] = (int) $k;
952
+		}
916 953
 
917
-		if (isset($_POST['vrt'][$k]))
918
-			$_GET['vrt'] = $_POST['vrt'][$k];
954
+		if (isset($_POST['vrt'][$k])) {
955
+					$_GET['vrt'] = $_POST['vrt'][$k];
956
+		}
919 957
 	}
920 958
 
921 959
 	// Have we made a decision, or are we just browsing?
@@ -1004,10 +1042,10 @@  discard block
 block discarded – undo
1004 1042
 				);
1005 1043
 				cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90);
1006 1044
 
1007
-				if ($user_info['id'] == $_REQUEST['u'])
1008
-					$_SESSION['id_variant'] = 0;
1009
-			}
1010
-			elseif ($_GET['th'] == 0)
1045
+				if ($user_info['id'] == $_REQUEST['u']) {
1046
+									$_SESSION['id_variant'] = 0;
1047
+				}
1048
+			} elseif ($_GET['th'] == 0)
1011 1049
 			{
1012 1050
 				// Remove any custom variants.
1013 1051
 				$smcFunc['db_query']('', '
@@ -1088,12 +1126,13 @@  discard block
 block discarded – undo
1088 1126
 		);
1089 1127
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1090 1128
 		{
1091
-			if (!isset($context['available_themes'][$row['id_theme']]))
1092
-				$context['available_themes'][$row['id_theme']] = array(
1129
+			if (!isset($context['available_themes'][$row['id_theme']])) {
1130
+							$context['available_themes'][$row['id_theme']] = array(
1093 1131
 					'id' => $row['id_theme'],
1094 1132
 					'selected' => $context['current_theme'] == $row['id_theme'],
1095 1133
 					'num_users' => 0
1096 1134
 				);
1135
+			}
1097 1136
 			$context['available_themes'][$row['id_theme']][$row['variable']] = $row['value'];
1098 1137
 		}
1099 1138
 		$smcFunc['db_free_result']($request);
@@ -1106,9 +1145,9 @@  discard block
 block discarded – undo
1106 1145
 			'num_users' => 0
1107 1146
 		);
1108 1147
 		$guest_theme = 0;
1148
+	} else {
1149
+			$guest_theme = $modSettings['theme_guests'];
1109 1150
 	}
1110
-	else
1111
-		$guest_theme = $modSettings['theme_guests'];
1112 1151
 
1113 1152
 	$request = $smcFunc['db_query']('', '
1114 1153
 		SELECT id_theme, COUNT(*) AS the_count
@@ -1121,15 +1160,17 @@  discard block
 block discarded – undo
1121 1160
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1122 1161
 	{
1123 1162
 		// Figure out which theme it is they are REALLY using.
1124
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes'])))
1125
-			$row['id_theme'] = $guest_theme;
1126
-		elseif (empty($modSettings['theme_allow']))
1127
-			$row['id_theme'] = $guest_theme;
1163
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) {
1164
+					$row['id_theme'] = $guest_theme;
1165
+		} elseif (empty($modSettings['theme_allow'])) {
1166
+					$row['id_theme'] = $guest_theme;
1167
+		}
1128 1168
 
1129
-		if (isset($context['available_themes'][$row['id_theme']]))
1130
-			$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1131
-		else
1132
-			$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1169
+		if (isset($context['available_themes'][$row['id_theme']])) {
1170
+					$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1171
+		} else {
1172
+					$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1173
+		}
1133 1174
 	}
1134 1175
 	$smcFunc['db_free_result']($request);
1135 1176
 
@@ -1148,8 +1189,9 @@  discard block
 block discarded – undo
1148 1189
 				'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
1149 1190
 			)
1150 1191
 		);
1151
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1152
-			$variant_preferences[$row['id_theme']] = $row['value'];
1192
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1193
+					$variant_preferences[$row['id_theme']] = $row['value'];
1194
+		}
1153 1195
 		$smcFunc['db_free_result']($request);
1154 1196
 	}
1155 1197
 
@@ -1160,17 +1202,18 @@  discard block
 block discarded – undo
1160 1202
 	foreach ($context['available_themes'] as $id_theme => $theme_data)
1161 1203
 	{
1162 1204
 		// Don't try to load the forum or board default theme's data... it doesn't have any!
1163
-		if ($id_theme == 0)
1164
-			continue;
1205
+		if ($id_theme == 0) {
1206
+					continue;
1207
+		}
1165 1208
 
1166 1209
 		// The thumbnail needs the correct path.
1167 1210
 		$settings['images_url'] = &$theme_data['images_url'];
1168 1211
 
1169
-		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
1170
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1171
-		elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
1172
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1173
-		else
1212
+		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) {
1213
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1214
+		} elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) {
1215
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1216
+		} else
1174 1217
 		{
1175 1218
 			$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png';
1176 1219
 			$txt['theme_description'] = '';
@@ -1195,15 +1238,17 @@  discard block
 block discarded – undo
1195 1238
 					loadLanguage('Settings');
1196 1239
 
1197 1240
 					$context['available_themes'][$id_theme]['variants'] = array();
1198
-					foreach ($settings['theme_variants'] as $variant)
1199
-						$context['available_themes'][$id_theme]['variants'][$variant] = array(
1241
+					foreach ($settings['theme_variants'] as $variant) {
1242
+											$context['available_themes'][$id_theme]['variants'][$variant] = array(
1200 1243
 							'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant,
1201 1244
 							'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'),
1202 1245
 						);
1246
+					}
1203 1247
 
1204 1248
 					$context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0]));
1205
-					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']))
1206
-						$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1249
+					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) {
1250
+											$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1251
+					}
1207 1252
 
1208 1253
 					$context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'];
1209 1254
 					// Allow themes to override the text.
@@ -1219,8 +1264,9 @@  discard block
 block discarded – undo
1219 1264
 	// As long as we're not doing the default theme...
1220 1265
 	if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
1221 1266
 	{
1222
-		if ($guest_theme != 0)
1223
-			$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1267
+		if ($guest_theme != 0) {
1268
+					$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1269
+		}
1224 1270
 
1225 1271
 		$context['available_themes'][0]['id'] = 0;
1226 1272
 		$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
@@ -1269,14 +1315,16 @@  discard block
 block discarded – undo
1269 1315
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1270 1316
 
1271 1317
 		// Got any info from the specific form?
1272
-		if (!isset($_POST['save_' . $action]))
1273
-			fatal_lang_error('theme_install_no_action', false);
1318
+		if (!isset($_POST['save_' . $action])) {
1319
+					fatal_lang_error('theme_install_no_action', false);
1320
+		}
1274 1321
 
1275 1322
 		validateToken('admin-t-' . $action);
1276 1323
 
1277 1324
 		// Hopefully the themes directory is writable, or we might have a problem.
1278
-		if (!is_writable($themedir))
1279
-			fatal_lang_error('theme_install_write_error', 'critical');
1325
+		if (!is_writable($themedir)) {
1326
+					fatal_lang_error('theme_install_write_error', 'critical');
1327
+		}
1280 1328
 
1281 1329
 		// Call the function and handle the result.
1282 1330
 		$result = $subActions[$action]();
@@ -1291,9 +1339,10 @@  discard block
 block discarded – undo
1291 1339
 	}
1292 1340
 
1293 1341
 	// Nope, show a nice error.
1294
-	else
1295
-		fatal_lang_error('theme_install_no_action', false);
1296
-}
1342
+	else {
1343
+			fatal_lang_error('theme_install_no_action', false);
1344
+	}
1345
+	}
1297 1346
 
1298 1347
 /**
1299 1348
  * Installs a theme from a theme package.
@@ -1309,8 +1358,9 @@  discard block
 block discarded – undo
1309 1358
 	$dirtemp = $themedir . '/temp';
1310 1359
 
1311 1360
 	// Make sure the temp dir doesn't already exist
1312
-	if (file_exists($dirtemp))
1313
-		remove_dir($dirtemp);
1361
+	if (file_exists($dirtemp)) {
1362
+			remove_dir($dirtemp);
1363
+	}
1314 1364
 
1315 1365
 	// Create the temp dir.
1316 1366
 	mkdir($dirtemp, 0777);
@@ -1322,17 +1372,20 @@  discard block
 block discarded – undo
1322 1372
 		smf_chmod($dirtemp, '0755');
1323 1373
 
1324 1374
 		// How about now?
1325
-		if (!is_writable($dirtemp))
1326
-			fatal_lang_error('theme_install_write_error', 'critical');
1375
+		if (!is_writable($dirtemp)) {
1376
+					fatal_lang_error('theme_install_write_error', 'critical');
1377
+		}
1327 1378
 	}
1328 1379
 
1329 1380
 	// This happens when the admin session is gone and the user has to login again.
1330
-	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz']))
1331
-		redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1381
+	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) {
1382
+			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1383
+	}
1332 1384
 
1333 1385
 	// Another error check layer, something went wrong with the upload.
1334
-	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1335
-		fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1386
+	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) {
1387
+			fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1388
+	}
1336 1389
 
1337 1390
 	// Get the theme's name.
1338 1391
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1363,11 +1416,10 @@  discard block
 block discarded – undo
1363 1416
 
1364 1417
 		// return all the info.
1365 1418
 		return $context['to_install'];
1419
+	} else {
1420
+			fatal_lang_error('theme_install_error_title', false);
1421
+	}
1366 1422
 	}
1367
-
1368
-	else
1369
-		fatal_lang_error('theme_install_error_title', false);
1370
-}
1371 1423
 
1372 1424
 /**
1373 1425
  * Makes a copy from the default theme, assigns a name for it and installs it.
@@ -1381,15 +1433,17 @@  discard block
 block discarded – undo
1381 1433
 	global $forum_version;
1382 1434
 
1383 1435
 	// There's gotta be something to work with.
1384
-	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy']))
1385
-		fatal_lang_error('theme_install_error_title', false);
1436
+	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) {
1437
+			fatal_lang_error('theme_install_error_title', false);
1438
+	}
1386 1439
 
1387 1440
 	// Get a cleaner version.
1388 1441
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1389 1442
 
1390 1443
 	// Is there a theme already named like this?
1391
-	if (file_exists($themedir . '/' . $name))
1392
-		fatal_lang_error('theme_install_already_dir', false);
1444
+	if (file_exists($themedir . '/' . $name)) {
1445
+			fatal_lang_error('theme_install_already_dir', false);
1446
+	}
1393 1447
 
1394 1448
 	// This is a brand new theme so set all possible values.
1395 1449
 	$context['to_install'] = array(
@@ -1409,8 +1463,9 @@  discard block
 block discarded – undo
1409 1463
 
1410 1464
 	// Buy some time.
1411 1465
 	@set_time_limit(600);
1412
-	if (function_exists('apache_reset_timeout'))
1413
-		@apache_reset_timeout();
1466
+	if (function_exists('apache_reset_timeout')) {
1467
+			@apache_reset_timeout();
1468
+	}
1414 1469
 
1415 1470
 	// Create subdirectories for css and javascript files.
1416 1471
 	mkdir($context['to_install']['theme_dir'] . '/css', 0777);
@@ -1446,12 +1501,13 @@  discard block
 block discarded – undo
1446 1501
 
1447 1502
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1448 1503
 	{
1449
-		if ($row['variable'] == 'theme_templates')
1450
-			$theme_templates = $row['value'];
1451
-		elseif ($row['variable'] == 'theme_layers')
1452
-			$theme_layers = $row['value'];
1453
-		else
1454
-			continue;
1504
+		if ($row['variable'] == 'theme_templates') {
1505
+					$theme_templates = $row['value'];
1506
+		} elseif ($row['variable'] == 'theme_layers') {
1507
+					$theme_layers = $row['value'];
1508
+		} else {
1509
+					continue;
1510
+		}
1455 1511
 	}
1456 1512
 
1457 1513
 	$smcFunc['db_free_result']($request);
@@ -1510,12 +1566,14 @@  discard block
 block discarded – undo
1510 1566
 	global $themedir, $themeurl, $context;
1511 1567
 
1512 1568
 	// Cannot use the theme dir as a theme dir.
1513
-	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
1514
-		fatal_lang_error('theme_install_invalid_dir', false);
1569
+	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) {
1570
+			fatal_lang_error('theme_install_invalid_dir', false);
1571
+	}
1515 1572
 
1516 1573
 	// Check is there is "something" on the dir.
1517
-	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
1518
-		fatal_lang_error('theme_install_error', false);
1574
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
1575
+			fatal_lang_error('theme_install_error', false);
1576
+	}
1519 1577
 
1520 1578
 	$name = basename($_REQUEST['theme_dir']);
1521 1579
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
@@ -1559,24 +1617,27 @@  discard block
 block discarded – undo
1559 1617
 	}
1560 1618
 
1561 1619
 	// Any special layers?
1562
-	if (isset($settings['catch_action']['layers']))
1563
-		$context['template_layers'] = $settings['catch_action']['layers'];
1620
+	if (isset($settings['catch_action']['layers'])) {
1621
+			$context['template_layers'] = $settings['catch_action']['layers'];
1622
+	}
1564 1623
 
1565 1624
 	// Any function to call?
1566 1625
 	if (isset($settings['catch_action']['function']))
1567 1626
 	{
1568 1627
 		$hook = $settings['catch_action']['function'];
1569 1628
 
1570
-		if (!isset($settings['catch_action']['filename']))
1571
-			$settings['catch_action']['filename'] = '';
1629
+		if (!isset($settings['catch_action']['filename'])) {
1630
+					$settings['catch_action']['filename'] = '';
1631
+		}
1572 1632
 
1573 1633
 		add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false);
1574 1634
 		call_integration_hook('integrate_wrap_action');
1575 1635
 	}
1576 1636
 	// And finally, the main sub template ;).
1577
-	if (isset($settings['catch_action']['sub_template']))
1578
-		$context['sub_template'] = $settings['catch_action']['sub_template'];
1579
-}
1637
+	if (isset($settings['catch_action']['sub_template'])) {
1638
+			$context['sub_template'] = $settings['catch_action']['sub_template'];
1639
+	}
1640
+	}
1580 1641
 
1581 1642
 /**
1582 1643
  * Set an option via javascript.
@@ -1595,12 +1656,14 @@  discard block
 block discarded – undo
1595 1656
 	checkSession('get');
1596 1657
 
1597 1658
 	// This good-for-nothing pixel is being used to keep the session alive.
1598
-	if (empty($_GET['var']) || !isset($_GET['val']))
1599
-		redirectexit($settings['images_url'] . '/blank.png');
1659
+	if (empty($_GET['var']) || !isset($_GET['val'])) {
1660
+			redirectexit($settings['images_url'] . '/blank.png');
1661
+	}
1600 1662
 
1601 1663
 	// Sorry, guests can't go any further than this.
1602
-	if ($user_info['is_guest'] || $user_info['id'] == 0)
1603
-		obExit(false);
1664
+	if ($user_info['is_guest'] || $user_info['id'] == 0) {
1665
+			obExit(false);
1666
+	}
1604 1667
 
1605 1668
 	$reservedVars = array(
1606 1669
 		'actual_theme_url',
@@ -1623,8 +1686,9 @@  discard block
 block discarded – undo
1623 1686
 	);
1624 1687
 
1625 1688
 	// Can't change reserved vars.
1626
-	if (in_array(strtolower($_GET['var']), $reservedVars))
1627
-		redirectexit($settings['images_url'] . '/blank.png');
1689
+	if (in_array(strtolower($_GET['var']), $reservedVars)) {
1690
+			redirectexit($settings['images_url'] . '/blank.png');
1691
+	}
1628 1692
 
1629 1693
 	// Use a specific theme?
1630 1694
 	if (isset($_GET['th']) || isset($_GET['id']))
@@ -1640,8 +1704,9 @@  discard block
 block discarded – undo
1640 1704
 	{
1641 1705
 		$options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array();
1642 1706
 		// New thingy...
1643
-		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5)
1644
-			$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1707
+		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
1708
+					$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1709
+		}
1645 1710
 
1646 1711
 		// Change the value to be something nice,
1647 1712
 		$_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']);
@@ -1671,8 +1736,9 @@  discard block
 block discarded – undo
1671 1736
 	global $context, $scripturl, $boarddir, $smcFunc, $txt;
1672 1737
 
1673 1738
 	// @todo Should this be removed?
1674
-	if (isset($_REQUEST['preview']))
1675
-		die('die() with fire');
1739
+	if (isset($_REQUEST['preview'])) {
1740
+			die('die() with fire');
1741
+	}
1676 1742
 
1677 1743
 	isAllowedTo('admin_forum');
1678 1744
 	loadTemplate('Themes');
@@ -1686,11 +1752,11 @@  discard block
 block discarded – undo
1686 1752
 		foreach ($context['themes'] as $key => $theme)
1687 1753
 		{
1688 1754
 			// There has to be a Settings template!
1689
-			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css'))
1690
-				unset($context['themes'][$key]);
1691
-
1692
-			else
1693
-				$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1755
+			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) {
1756
+							unset($context['themes'][$key]);
1757
+			} else {
1758
+							$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1759
+			}
1694 1760
 		}
1695 1761
 
1696 1762
 		$context['sub_template'] = 'edit_list';
@@ -1705,22 +1771,24 @@  discard block
 block discarded – undo
1705 1771
 	$context['theme_id'] = $currentTheme['id'];
1706 1772
 	$context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']);
1707 1773
 
1708
-	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css'))
1709
-		fatal_lang_error('theme_edit_missing', false);
1774
+	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) {
1775
+			fatal_lang_error('theme_edit_missing', false);
1776
+	}
1710 1777
 
1711 1778
 	if (!isset($_REQUEST['filename']))
1712 1779
 	{
1713 1780
 		if (isset($_GET['directory']))
1714 1781
 		{
1715
-			if (substr($_GET['directory'], 0, 1) == '.')
1716
-				$_GET['directory'] = '';
1717
-			else
1782
+			if (substr($_GET['directory'], 0, 1) == '.') {
1783
+							$_GET['directory'] = '';
1784
+			} else
1718 1785
 			{
1719 1786
 				$_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']);
1720 1787
 
1721 1788
 				$temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']);
1722
-				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1723
-					$_GET['directory'] = '';
1789
+				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1790
+									$_GET['directory'] = '';
1791
+				}
1724 1792
 			}
1725 1793
 		}
1726 1794
 
@@ -1739,37 +1807,39 @@  discard block
 block discarded – undo
1739 1807
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp,
1740 1808
 				'size' => '',
1741 1809
 			));
1810
+		} else {
1811
+					$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1742 1812
 		}
1743
-		else
1744
-			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1813
 
1746 1814
 		$context['sub_template'] = 'edit_browse';
1747 1815
 
1748 1816
 		return;
1749
-	}
1750
-	else
1817
+	} else
1751 1818
 	{
1752
-		if (substr($_REQUEST['filename'], 0, 1) == '.')
1753
-			$_REQUEST['filename'] = '';
1754
-		else
1819
+		if (substr($_REQUEST['filename'], 0, 1) == '.') {
1820
+					$_REQUEST['filename'] = '';
1821
+		} else
1755 1822
 		{
1756 1823
 			$_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']);
1757 1824
 
1758 1825
 			$temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1759
-			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1760
-				$_REQUEST['filename'] = '';
1826
+			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1827
+							$_REQUEST['filename'] = '';
1828
+			}
1761 1829
 		}
1762 1830
 
1763
-		if (empty($_REQUEST['filename']))
1764
-			fatal_lang_error('theme_edit_missing', false);
1831
+		if (empty($_REQUEST['filename'])) {
1832
+					fatal_lang_error('theme_edit_missing', false);
1833
+		}
1765 1834
 	}
1766 1835
 
1767 1836
 	if (isset($_POST['save']))
1768 1837
 	{
1769 1838
 		if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true)
1770 1839
 		{
1771
-			if (is_array($_POST['entire_file']))
1772
-				$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1840
+			if (is_array($_POST['entire_file'])) {
1841
+							$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1842
+			}
1773 1843
 
1774 1844
 			$_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', '   ' => "\t")));
1775 1845
 
@@ -1781,10 +1851,11 @@  discard block
 block discarded – undo
1781 1851
 				fclose($fp);
1782 1852
 
1783 1853
 				$error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php');
1784
-				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0)
1785
-					$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1786
-				else
1787
-					unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1854
+				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) {
1855
+									$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1856
+				} else {
1857
+									unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1858
+				}
1788 1859
 			}
1789 1860
 
1790 1861
 			if (!isset($error_file))
@@ -1805,10 +1876,11 @@  discard block
 block discarded – undo
1805 1876
 			$context['sub_template'] = 'edit_file';
1806 1877
 
1807 1878
 			// Recycle the submitted data.
1808
-			if (is_array($_POST['entire_file']))
1809
-				$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1810
-			else
1811
-				$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1879
+			if (is_array($_POST['entire_file'])) {
1880
+							$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1881
+			} else {
1882
+							$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1883
+			}
1812 1884
 
1813 1885
 			$context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']);
1814 1886
 
@@ -1831,17 +1903,17 @@  discard block
 block discarded – undo
1831 1903
 		$context['sub_template'] = 'edit_style';
1832 1904
 
1833 1905
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => '   ')));
1834
-	}
1835
-	elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1906
+	} elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1836 1907
 	{
1837 1908
 		$context['sub_template'] = 'edit_template';
1838 1909
 
1839
-		if (!isset($error_file))
1840
-			$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1841
-		else
1910
+		if (!isset($error_file)) {
1911
+					$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1912
+		} else
1842 1913
 		{
1843
-			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0)
1844
-				$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1914
+			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) {
1915
+							$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1916
+			}
1845 1917
 			$file_data = file($error_file);
1846 1918
 			unlink($error_file);
1847 1919
 		}
@@ -1855,8 +1927,9 @@  discard block
 block discarded – undo
1855 1927
 				// Try to format the functions a little nicer...
1856 1928
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
1857 1929
 
1858
-				if (empty($context['file_parts'][$j]['lines']))
1859
-					unset($context['file_parts'][$j]);
1930
+				if (empty($context['file_parts'][$j]['lines'])) {
1931
+									unset($context['file_parts'][$j]);
1932
+				}
1860 1933
 				$context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => '');
1861 1934
 			}
1862 1935
 
@@ -1865,8 +1938,7 @@  discard block
 block discarded – undo
1865 1938
 		}
1866 1939
 
1867 1940
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => '   ')));
1868
-	}
1869
-	else
1941
+	} else
1870 1942
 	{
1871 1943
 		$context['sub_template'] = 'edit_file';
1872 1944
 
@@ -1892,8 +1964,9 @@  discard block
 block discarded – undo
1892 1964
 
1893 1965
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
1894 1966
 
1895
-	if (empty($_GET['th']))
1896
-		fatal_lang_error('theme_install_invalid_id');
1967
+	if (empty($_GET['th'])) {
1968
+			fatal_lang_error('theme_install_invalid_id');
1969
+	}
1897 1970
 
1898 1971
 	// Get the theme info.
1899 1972
 	$theme = get_single_theme($_GET['th']);
@@ -1901,25 +1974,24 @@  discard block
 block discarded – undo
1901 1974
 
1902 1975
 	if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0)
1903 1976
 	{
1904
-		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'))
1905
-			$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1906
-
1907
-		else
1908
-			fatal_lang_error('no_access', false);
1977
+		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) {
1978
+					$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1979
+		} else {
1980
+					fatal_lang_error('no_access', false);
1981
+		}
1909 1982
 
1910 1983
 		$fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w');
1911 1984
 		fwrite($fp, file_get_contents($filename));
1912 1985
 		fclose($fp);
1913 1986
 
1914 1987
 		redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy');
1915
-	}
1916
-	elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1988
+	} elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1917 1989
 	{
1918
-		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'))
1919
-			$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1920
-
1921
-		else
1922
-			fatal_lang_error('no_access', false);
1990
+		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) {
1991
+					$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1992
+		} else {
1993
+					fatal_lang_error('no_access', false);
1994
+		}
1923 1995
 
1924 1996
 		$fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w');
1925 1997
 		fwrite($fp, file_get_contents($filename));
@@ -1934,16 +2006,18 @@  discard block
 block discarded – undo
1934 2006
 	$dir = dir($settings['default_theme_dir']);
1935 2007
 	while ($entry = $dir->read())
1936 2008
 	{
1937
-		if (substr($entry, -13) == '.template.php')
1938
-			$templates[] = substr($entry, 0, -13);
2009
+		if (substr($entry, -13) == '.template.php') {
2010
+					$templates[] = substr($entry, 0, -13);
2011
+		}
1939 2012
 	}
1940 2013
 	$dir->close();
1941 2014
 
1942 2015
 	$dir = dir($settings['default_theme_dir'] . '/languages');
1943 2016
 	while ($entry = $dir->read())
1944 2017
 	{
1945
-		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches))
1946
-			$lang_files[] = $matches[1];
2018
+		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) {
2019
+					$lang_files[] = $matches[1];
2020
+		}
1947 2021
 	}
1948 2022
 	$dir->close();
1949 2023
 
@@ -1951,21 +2025,23 @@  discard block
 block discarded – undo
1951 2025
 	natcasesort($lang_files);
1952 2026
 
1953 2027
 	$context['available_templates'] = array();
1954
-	foreach ($templates as $template)
1955
-		$context['available_templates'][$template] = array(
2028
+	foreach ($templates as $template) {
2029
+			$context['available_templates'][$template] = array(
1956 2030
 			'filename' => $template . '.template.php',
1957 2031
 			'value' => $template,
1958 2032
 			'already_exists' => false,
1959 2033
 			'can_copy' => is_writable($theme['theme_dir']),
1960 2034
 		);
2035
+	}
1961 2036
 	$context['available_language_files'] = array();
1962
-	foreach ($lang_files as $file)
1963
-		$context['available_language_files'][$file] = array(
2037
+	foreach ($lang_files as $file) {
2038
+			$context['available_language_files'][$file] = array(
1964 2039
 			'filename' => $file . '.php',
1965 2040
 			'value' => $file,
1966 2041
 			'already_exists' => false,
1967 2042
 			'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']),
1968 2043
 		);
2044
+	}
1969 2045
 
1970 2046
 	$dir = dir($theme['theme_dir']);
1971 2047
 	while ($entry = $dir->read())
Please login to merge, or discard this patch.
Themes/default/Poll.template.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 		}
39 39
 	</script>';
40 40
 
41
-	if (!empty($context['poll_error']['messages']))
42
-		echo '
41
+	if (!empty($context['poll_error']['messages'])) {
42
+			echo '
43 43
 			<div class="errorbox">
44 44
 				<dl class="poll_error">
45 45
 					<dt>
@@ -50,6 +50,7 @@  discard block
 block discarded – undo
50 50
 					</dt>
51 51
 				</dl>
52 52
 			</div>';
53
+	}
53 54
 
54 55
 	// Start the main poll form.
55 56
 	echo '
@@ -79,8 +80,9 @@  discard block
 block discarded – undo
79 80
 								<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" size="80" maxlength="255">';
80 81
 
81 82
 		// Does this option have a vote count yet, or is it new?
82
-		if ($choice['votes'] != -1)
83
-			echo ' (', $choice['votes'], ' ', $txt['votes'], ')';
83
+		if ($choice['votes'] != -1) {
84
+					echo ' (', $choice['votes'], ' ', $txt['votes'], ')';
85
+		}
84 86
 
85 87
 		echo '
86 88
 							</dd>';
@@ -118,14 +120,15 @@  discard block
 block discarded – undo
118 120
 								<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '>
119 121
 							</dd>';
120 122
 
121
-		if ($context['poll']['guest_vote_allowed'])
122
-			echo '
123
+		if ($context['poll']['guest_vote_allowed']) {
124
+					echo '
123 125
 							<dt>
124 126
 								<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
125 127
 							</dt>
126 128
 							<dd>
127 129
 								<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll']['guest_vote']) ? ' checked' : '', '>
128 130
 							</dd>';
131
+		}
129 132
 	}
130 133
 
131 134
 	echo '
@@ -141,12 +144,13 @@  discard block
 block discarded – undo
141 144
 					</fieldset>';
142 145
 
143 146
 	// If this is an edit, we can allow them to reset the vote counts.
144
-	if ($context['is_edit'])
145
-		echo '
147
+	if ($context['is_edit']) {
148
+			echo '
146 149
 					<fieldset id="poll_reset">
147 150
 						<legend>', $txt['reset_votes'], '</legend>
148 151
 						<input type="checkbox" name="resetVoteCount" value="on"> ' . $txt['reset_votes_check'] . '
149 152
 					</fieldset>';
153
+	}
150 154
 	echo '
151 155
 					<input type="submit" name="post" value="', $txt['save'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button">
152 156
 				</div><!-- .roundframe -->
Please login to merge, or discard this patch.
Themes/default/Themes.template.php 1 patch
Braces   +121 added lines, -92 removed lines patch added patch discarded remove patch
@@ -51,9 +51,10 @@  discard block
 block discarded – undo
51 51
 					<dd>
52 52
 						<div id="known_themes_list">';
53 53
 
54
-	foreach ($context['themes'] as $theme)
55
-		echo '
54
+	foreach ($context['themes'] as $theme) {
55
+			echo '
56 56
 							<label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', '> ', $theme['name'], '</label><br>';
57
+	}
57 58
 
58 59
 	echo '
59 60
 						</div>
@@ -70,9 +71,10 @@  discard block
 block discarded – undo
70 71
 						<select name="options[theme_guests]" id="theme_guests">';
71 72
 
72 73
 	// Put an option for each theme in the select box.
73
-	foreach ($context['themes'] as $theme)
74
-		echo '
74
+	foreach ($context['themes'] as $theme) {
75
+			echo '
75 76
 							<option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
77
+	}
76 78
 
77 79
 	echo '
78 80
 						</select>
@@ -87,9 +89,10 @@  discard block
 block discarded – undo
87 89
 							<option value="0">', $txt['theme_forum_default'], '</option>';
88 90
 
89 91
 	// Same thing, this time for changing the theme of everyone.
90
-	foreach ($context['themes'] as $theme)
91
-		echo '
92
+	foreach ($context['themes'] as $theme) {
93
+			echo '
92 94
 							<option value="', $theme['id'], '">', $theme['name'], '</option>';
95
+	}
93 96
 
94 97
 	echo '
95 98
 						</select>
@@ -183,11 +186,12 @@  discard block
 block discarded – undo
183 186
 	global $context, $scripturl, $txt;
184 187
 
185 188
 	// Show a nice confirmation message.
186
-	if (isset($_GET['done']))
187
-		echo '
189
+	if (isset($_GET['done'])) {
190
+			echo '
188 191
 	<div class="infobox">
189 192
 		', $txt['theme_confirmed_' . $_GET['done']], '
190 193
 	</div>';
194
+	}
191 195
 
192 196
 	echo '
193 197
 		<div class="cat_bar">
@@ -344,11 +348,12 @@  discard block
 block discarded – undo
344 348
 		if (empty($setting) || !is_array($setting))
345 349
 		{
346 350
 			// Insert a separator (unless this is the first item in the list)
347
-			if ($i !== $first_option_key)
348
-				echo '
351
+			if ($i !== $first_option_key) {
352
+							echo '
349 353
 				</dl>
350 354
 				<hr>
351 355
 				<dl class="settings">';
356
+			}
352 357
 
353 358
 			// Should we give a name to this section?
354 359
 			if (is_string($setting) && !empty($setting))
@@ -357,9 +362,9 @@  discard block
 block discarded – undo
357 362
 				echo '
358 363
 					<dt><strong>' . $setting . '</strong></dt>
359 364
 					<dd></dd>';
365
+			} else {
366
+							$titled_section = false;
360 367
 			}
361
-			else
362
-				$titled_section = false;
363 368
 
364 369
 			continue;
365 370
 		}
@@ -368,8 +373,8 @@  discard block
 block discarded – undo
368 373
 					<dt>';
369 374
 
370 375
 		// Show the change option box?
371
-		if ($context['theme_options_reset'])
372
-			echo '
376
+		if ($context['theme_options_reset']) {
377
+					echo '
373 378
 						<span class="floatleft">
374 379
 							<select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;">
375 380
 								<option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option>
@@ -377,23 +382,26 @@  discard block
 block discarded – undo
377 382
 								<option value="2">', $txt['themeadmin_reset_options_default'], '</option>
378 383
 							</select>
379 384
 						</span>';
385
+		}
380 386
 
381 387
 		echo '
382 388
 						<label for="options_', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
383 389
 
384
-		if (isset($setting['description']))
385
-			echo '
390
+		if (isset($setting['description'])) {
391
+					echo '
386 392
 						<br>
387 393
 						<span class="smalltext">', $setting['description'], '</span>';
394
+		}
388 395
 		echo '
389 396
 					</dt>';
390 397
 
391 398
 		// Display checkbox options
392
-		if ($setting['type'] == 'checkbox')
393
-			echo '
399
+		if ($setting['type'] == 'checkbox') {
400
+					echo '
394 401
 					<dd>
395 402
 						<input type="hidden" name="' . (!empty($setting['default']) ? 'default_' : '') . 'options[' . $setting['id'] . ']" value="0">
396 403
 						<input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', $context['theme_options_reset'] ? ' disabled' : '', ' value="1" class="floatleft">';
404
+		}
397 405
 
398 406
 		// How about selection lists, we all love them
399 407
 		elseif ($setting['type'] == 'list')
@@ -402,9 +410,10 @@  discard block
 block discarded – undo
402 410
 					<dd>
403 411
 						<select class="floatleft" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '"', $context['theme_options_reset'] ? ' disabled' : '', '>';
404 412
 
405
-			foreach ($setting['options'] as $value => $label)
406
-				echo '
413
+			foreach ($setting['options'] as $value => $label) {
414
+							echo '
407 415
 							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
416
+			}
408 417
 
409 418
 			echo '
410 419
 						</select>';
@@ -423,14 +432,13 @@  discard block
 block discarded – undo
423 432
 
424 433
 				echo '
425 434
 						<input type="number"', $min . $max . $step;
426
-			}
427
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
428
-				echo'
435
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
436
+							echo'
429 437
 						<input type="url"';
430
-
431
-			else
432
-				echo '
438
+			} else {
439
+							echo '
433 440
 						<input type="text"';
441
+			}
434 442
 
435 443
 			echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', $context['theme_options_reset'] ? ' disabled' : '', '>';
436 444
 		}
@@ -468,8 +476,8 @@  discard block
 block discarded – undo
468 476
 			<div class="windowbg">';
469 477
 
470 478
 	// @todo Why can't I edit the default theme popup.
471
-	if ($context['theme_settings']['theme_id'] != 1)
472
-		echo '
479
+	if ($context['theme_settings']['theme_id'] != 1) {
480
+			echo '
473 481
 				<div class="title_bar">
474 482
 					<h3 class="titlebg config_hd">
475 483
 						', $txt['theme_edit'], '
@@ -485,6 +493,7 @@  discard block
 block discarded – undo
485 493
 						</li>
486 494
 					</ul>
487 495
 				</div>';
496
+	}
488 497
 
489 498
 	echo '
490 499
 				<div class="title_bar">
@@ -535,9 +544,10 @@  discard block
 block discarded – undo
535 544
 					<dd>
536 545
 						<select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">';
537 546
 
538
-		foreach ($context['theme_variants'] as $key => $variant)
539
-			echo '
547
+		foreach ($context['theme_variants'] as $key => $variant) {
548
+					echo '
540 549
 							<option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
550
+		}
541 551
 
542 552
 		echo '
543 553
 						</select>
@@ -571,11 +581,12 @@  discard block
 block discarded – undo
571 581
 		if (empty($setting) || !is_array($setting))
572 582
 		{
573 583
 			// We don't need a separator before the first list element
574
-			if ($i !== $first_setting_key)
575
-				echo '
584
+			if ($i !== $first_setting_key) {
585
+							echo '
576 586
 				</dl>
577 587
 				<hr>
578 588
 				<dl class="settings">';
589
+			}
579 590
 
580 591
 			// Add a fake heading?
581 592
 			if (is_string($setting) && !empty($setting))
@@ -584,9 +595,9 @@  discard block
 block discarded – undo
584 595
 				echo '
585 596
 					<dt><strong>' . $setting . '</strong></dt>
586 597
 					<dd></dd>';
598
+			} else {
599
+							$titled_section = false;
587 600
 			}
588
-			else
589
-				$titled_section = false;
590 601
 
591 602
 			continue;
592 603
 		}
@@ -595,20 +606,22 @@  discard block
 block discarded – undo
595 606
 					<dt>
596 607
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>:';
597 608
 
598
-		if (isset($setting['description']))
599
-			echo '<br>
609
+		if (isset($setting['description'])) {
610
+					echo '<br>
600 611
 						<span class="smalltext">', $setting['description'], '</span>';
612
+		}
601 613
 
602 614
 		echo '
603 615
 					</dt>';
604 616
 
605 617
 		// A checkbox?
606
-		if ($setting['type'] == 'checkbox')
607
-			echo '
618
+		if ($setting['type'] == 'checkbox') {
619
+					echo '
608 620
 					<dd>
609 621
 						<input type="hidden" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" value="0">
610 622
 						<input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', ' value="1">
611 623
 					</dd>';
624
+		}
612 625
 
613 626
 		// A list with options?
614 627
 		elseif ($setting['type'] == 'list')
@@ -617,9 +630,10 @@  discard block
 block discarded – undo
617 630
 					<dd>
618 631
 						<select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">';
619 632
 
620
-			foreach ($setting['options'] as $value => $label)
621
-				echo '
633
+			foreach ($setting['options'] as $value => $label) {
634
+							echo '
622 635
 							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
636
+			}
623 637
 
624 638
 			echo '
625 639
 						</select>
@@ -647,14 +661,13 @@  discard block
 block discarded – undo
647 661
 
648 662
 				echo '
649 663
 						<input type="number"', $min . $max . $step;
650
-			}
651
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
652
-				echo'
664
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
665
+							echo'
653 666
 						<input type="url"';
654
-
655
-			else
656
-				echo '
667
+			} else {
668
+							echo '
657 669
 						<input type="text"';
670
+			}
658 671
 
659 672
 			echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : (empty($settings['size']) ? ' size="40"' : ' size="' . $setting['size'] . '"'), '>
660 673
 					</dd>';
@@ -726,9 +739,10 @@  discard block
 block discarded – undo
726 739
 					<label for="variant', $theme['id'], '"><strong>', $theme['pick_label'], '</strong></label>:
727 740
 					<select id="variant', $theme['id'], '" name="vrt[', $theme['id'], ']" onchange="changeVariant', $theme['id'], '(this.value);">';
728 741
 
729
-			foreach ($theme['variants'] as $key => $variant)
730
-				echo '
742
+			foreach ($theme['variants'] as $key => $variant) {
743
+							echo '
731 744
 						<option value="', $key, '"', $theme['selected_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
745
+			}
732 746
 
733 747
 			echo '
734 748
 					</select>
@@ -805,21 +819,23 @@  discard block
 block discarded – undo
805 819
 		<div class="windowbg">';
806 820
 
807 821
 	// Oops! there was an error :(
808
-	if (!empty($context['error_message']))
809
-		echo '
822
+	if (!empty($context['error_message'])) {
823
+			echo '
810 824
 			<p>
811 825
 				', $context['error_message'], '
812 826
 			</p>';
827
+	}
813 828
 
814 829
 	// Not much to show except a link back...
815
-	else
816
-		echo '
830
+	else {
831
+			echo '
817 832
 			<p>
818 833
 				<a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], '
819 834
 			</p>
820 835
 			<p>
821 836
 				<a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a>
822 837
 			</p>';
838
+	}
823 839
 
824 840
 	echo '
825 841
 		</div><!-- .windowbg -->';
@@ -884,11 +900,12 @@  discard block
 block discarded – undo
884 900
 					<span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span>
885 901
 					<span class="floatright">';
886 902
 
887
-		if ($template['can_copy'])
888
-			echo '
903
+		if ($template['can_copy']) {
904
+					echo '
889 905
 						<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
890
-		else
891
-			echo $txt['themeadmin_edit_no_copy'];
906
+		} else {
907
+					echo $txt['themeadmin_edit_no_copy'];
908
+		}
892 909
 
893 910
 		echo '
894 911
 					</span>
@@ -907,11 +924,12 @@  discard block
 block discarded – undo
907 924
 {
908 925
 	global $context, $txt;
909 926
 
910
-	if (!empty($context['browse_title']))
911
-		echo '
927
+	if (!empty($context['browse_title'])) {
928
+			echo '
912 929
 		<div class="cat_bar">
913 930
 			<h3 class="catbg">', $context['browse_title'], '</h3>
914 931
 		</div>';
932
+	}
915 933
 
916 934
 	echo '
917 935
 		<table class="table_grid tborder">
@@ -930,16 +948,15 @@  discard block
 block discarded – undo
930 948
 				<tr class="windowbg">
931 949
 					<td>';
932 950
 
933
-		if ($file['is_editable'])
934
-			echo '
951
+		if ($file['is_editable']) {
952
+					echo '
935 953
 						<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
936
-
937
-		elseif ($file['is_directory'])
938
-			echo '
954
+		} elseif ($file['is_directory']) {
955
+					echo '
939 956
 						<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>';
940
-
941
-		else
942
-			echo $file['filename'];
957
+		} else {
958
+					echo $file['filename'];
959
+		}
943 960
 
944 961
 		echo '
945 962
 					</td>
@@ -960,11 +977,12 @@  discard block
 block discarded – undo
960 977
 {
961 978
 	global $context, $settings, $scripturl, $txt;
962 979
 
963
-	if ($context['session_error'])
964
-		echo '
980
+	if ($context['session_error']) {
981
+			echo '
965 982
 	<div class="errorbox">
966 983
 		', $txt['error_session_timeout'], '
967 984
 	</div>';
985
+	}
968 986
 
969 987
 	// From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com.
970 988
 	echo '
@@ -1027,17 +1045,18 @@  discard block
 block discarded – undo
1027 1045
 					{
1028 1046
 					';
1029 1047
 
1030
-	if (isBrowser('is_ie'))
1031
-		echo '
1048
+	if (isBrowser('is_ie')) {
1049
+			echo '
1032 1050
 						var sheets = frames["css_preview_box"].document.styleSheets;
1033 1051
 						for (var j = 0; j < sheets.length; j++)
1034 1052
 						{
1035 1053
 							if (sheets[j].id == "css_preview_box")
1036 1054
 								sheets[j].cssText = document.forms.stylesheetForm.entire_file.value;
1037 1055
 						}';
1038
-	else
1039
-		echo '
1056
+	} else {
1057
+			echo '
1040 1058
 						setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);';
1059
+	}
1041 1060
 	echo '
1042 1061
 					}
1043 1062
 					catch (e)
@@ -1089,9 +1108,10 @@  discard block
 block discarded – undo
1089 1108
 			</div>
1090 1109
 			<div class="windowbg">';
1091 1110
 
1092
-	if (!$context['allow_save'])
1093
-		echo '
1111
+	if (!$context['allow_save']) {
1112
+			echo '
1094 1113
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1114
+	}
1095 1115
 
1096 1116
 	echo '
1097 1117
 				<textarea class="edit_file" name="entire_file" cols="80" rows="20" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea>
@@ -1105,9 +1125,10 @@  discard block
 block discarded – undo
1105 1125
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1106 1126
 
1107 1127
 	// Hopefully it exists.
1108
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1109
-		echo '
1128
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1129
+			echo '
1110 1130
 			<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1131
+	}
1111 1132
 
1112 1133
 	echo '
1113 1134
 		</form>';
@@ -1120,18 +1141,20 @@  discard block
 block discarded – undo
1120 1141
 {
1121 1142
 	global $context, $scripturl, $txt;
1122 1143
 
1123
-	if ($context['session_error'])
1124
-		echo '
1144
+	if ($context['session_error']) {
1145
+			echo '
1125 1146
 	<div class="errorbox">
1126 1147
 		', $txt['error_session_timeout'], '
1127 1148
 	</div>';
1149
+	}
1128 1150
 
1129
-	if (isset($context['parse_error']))
1130
-		echo '
1151
+	if (isset($context['parse_error'])) {
1152
+			echo '
1131 1153
 	<div class="errorbox">
1132 1154
 		', $txt['themeadmin_edit_error'], '
1133 1155
 		<div><pre>', $context['parse_error'], '</pre></div>
1134 1156
 	</div>';
1157
+	}
1135 1158
 
1136 1159
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1137 1160
 	echo '
@@ -1141,16 +1164,18 @@  discard block
 block discarded – undo
1141 1164
 			</div>
1142 1165
 			<div class="windowbg">';
1143 1166
 
1144
-	if (!$context['allow_save'])
1145
-		echo '
1167
+	if (!$context['allow_save']) {
1168
+			echo '
1146 1169
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1170
+	}
1147 1171
 
1148
-	foreach ($context['file_parts'] as $part)
1149
-		echo '
1172
+	foreach ($context['file_parts'] as $part) {
1173
+			echo '
1150 1174
 				<label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br>
1151 1175
 				<div class="centertext">
1152 1176
 					<textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea>
1153 1177
 				</div>';
1178
+	}
1154 1179
 
1155 1180
 	echo '
1156 1181
 				<div class="padding righttext">
@@ -1159,9 +1184,10 @@  discard block
 block discarded – undo
1159 1184
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1160 1185
 
1161 1186
 	// Hopefully it exists.
1162
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1163
-		echo '
1187
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1188
+			echo '
1164 1189
 					<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1190
+	}
1165 1191
 
1166 1192
 	echo '
1167 1193
 				</div><!-- .righttext -->
@@ -1176,18 +1202,20 @@  discard block
 block discarded – undo
1176 1202
 {
1177 1203
 	global $context, $scripturl, $txt;
1178 1204
 
1179
-	if ($context['session_error'])
1180
-		echo '
1205
+	if ($context['session_error']) {
1206
+			echo '
1181 1207
 	<div class="errorbox">
1182 1208
 		', $txt['error_session_timeout'], '
1183 1209
 	</div>';
1210
+	}
1184 1211
 
1185 1212
 	// Is this file writeable?
1186
-	if (!$context['allow_save'])
1187
-		echo '
1213
+	if (!$context['allow_save']) {
1214
+			echo '
1188 1215
 	<div class="errorbox">
1189 1216
 		', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '
1190 1217
 	</div>';
1218
+	}
1191 1219
 
1192 1220
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1193 1221
 	echo '
@@ -1202,9 +1230,10 @@  discard block
 block discarded – undo
1202 1230
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1203 1231
 
1204 1232
 	// Hopefully it exists.
1205
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1206
-		echo '
1233
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1234
+			echo '
1207 1235
 				<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1236
+	}
1208 1237
 
1209 1238
 	echo '
1210 1239
 			</div><!-- .windowbg -->
Please login to merge, or discard this patch.