Completed
Push — release-2.1 ( 61d523...503c62 )
by Colin
17:13 queued 08:20
created
Sources/Groups.php 1 patch
Braces   +80 added lines, -59 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
  * Entry point function, permission checks, admin bars, etc.
@@ -99,27 +100,27 @@  discard block
 block discarded – undo
99 100
 					'function' => function($rowData) use ($scripturl)
100 101
 					{
101 102
 						// Since the moderator group has no explicit members, no link is needed.
102
-						if ($rowData['id_group'] == 3)
103
-							$group_name = $rowData['group_name'];
104
-						else
103
+						if ($rowData['id_group'] == 3) {
104
+													$group_name = $rowData['group_name'];
105
+						} else
105 106
 						{
106 107
 							$color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']);
107 108
 
108 109
 							if (allowedTo('manage_membergroups'))
109 110
 							{
110 111
 								$group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']);
111
-							}
112
-							else
112
+							} else
113 113
 							{
114 114
 								$group_name = sprintf('<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']);
115 115
 							}
116 116
 						}
117 117
 
118 118
 						// Add a help option for moderator and administrator.
119
-						if ($rowData['id_group'] == 1)
120
-							$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
121
-						elseif ($rowData['id_group'] == 3)
122
-							$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
119
+						if ($rowData['id_group'] == 1) {
120
+													$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
121
+						} elseif ($rowData['id_group'] == 3) {
122
+													$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
123
+						}
123 124
 
124 125
 						return $group_name;
125 126
 					},
@@ -198,8 +199,9 @@  discard block
 block discarded – undo
198 199
 	$_REQUEST['group'] = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0;
199 200
 
200 201
 	// No browsing of guests, membergroup 0 or moderators.
201
-	if (in_array($_REQUEST['group'], array(-1, 0, 3)))
202
-		fatal_lang_error('membergroup_does_not_exist', false);
202
+	if (in_array($_REQUEST['group'], array(-1, 0, 3))) {
203
+			fatal_lang_error('membergroup_does_not_exist', false);
204
+	}
203 205
 
204 206
 	// Load up the group details.
205 207
 	$request = $smcFunc['db_query']('', '
@@ -214,8 +216,9 @@  discard block
 block discarded – undo
214 216
 		)
215 217
 	);
216 218
 	// Doesn't exist?
217
-	if ($smcFunc['db_num_rows']($request) == 0)
218
-		fatal_lang_error('membergroup_does_not_exist', false);
219
+	if ($smcFunc['db_num_rows']($request) == 0) {
220
+			fatal_lang_error('membergroup_does_not_exist', false);
221
+	}
219 222
 	$context['group'] = $smcFunc['db_fetch_assoc']($request);
220 223
 	$smcFunc['db_free_result']($request);
221 224
 
@@ -248,21 +251,25 @@  discard block
 block discarded – undo
248 251
 			'name' => $row['real_name']
249 252
 		);
250 253
 
251
-		if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1)
252
-			$context['group']['can_moderate'] = true;
254
+		if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) {
255
+					$context['group']['can_moderate'] = true;
256
+		}
253 257
 	}
254 258
 	$smcFunc['db_free_result']($request);
255 259
 
256 260
 	// If this group is hidden then it can only "exists" if the user can moderate it!
257
-	if ($context['group']['hidden'] && !$context['group']['can_moderate'])
258
-		fatal_lang_error('membergroup_does_not_exist', false);
261
+	if ($context['group']['hidden'] && !$context['group']['can_moderate']) {
262
+			fatal_lang_error('membergroup_does_not_exist', false);
263
+	}
259 264
 
260 265
 	// You can only assign membership if you are the moderator and/or can manage groups!
261
-	if (!$context['group']['can_moderate'])
262
-		$context['group']['assignable'] = 0;
266
+	if (!$context['group']['can_moderate']) {
267
+			$context['group']['assignable'] = 0;
268
+	}
263 269
 	// Non-admins cannot assign admins.
264
-	elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum'))
265
-		$context['group']['assignable'] = 0;
270
+	elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) {
271
+			$context['group']['assignable'] = 0;
272
+	}
266 273
 
267 274
 	// Removing member from group?
268 275
 	if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable'])
@@ -271,8 +278,9 @@  discard block
 block discarded – undo
271 278
 		validateToken('mod-mgm');
272 279
 
273 280
 		// Make sure we're dealing with integers only.
274
-		foreach ($_REQUEST['rem'] as $key => $group)
275
-			$_REQUEST['rem'][$key] = (int) $group;
281
+		foreach ($_REQUEST['rem'] as $key => $group) {
282
+					$_REQUEST['rem'][$key] = (int) $group;
283
+		}
276 284
 
277 285
 		require_once($sourcedir . '/Subs-Membergroups.php');
278 286
 		removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group'], true);
@@ -295,16 +303,18 @@  discard block
 block discarded – undo
295 303
 		{
296 304
 			$member_names[$index] = trim($smcFunc['strtolower']($member_names[$index]));
297 305
 
298
-			if (strlen($member_names[$index]) == 0)
299
-				unset($member_names[$index]);
306
+			if (strlen($member_names[$index]) == 0) {
307
+							unset($member_names[$index]);
308
+			}
300 309
 		}
301 310
 
302 311
 		// Any passed by ID?
303 312
 		$member_ids = array();
304
-		if (!empty($_REQUEST['member_add']))
305
-			foreach ($_REQUEST['member_add'] as $id)
313
+		if (!empty($_REQUEST['member_add'])) {
314
+					foreach ($_REQUEST['member_add'] as $id)
306 315
 				if ($id > 0)
307 316
 					$member_ids[] = (int) $id;
317
+		}
308 318
 
309 319
 		// Construct the query pelements.
310 320
 		if (!empty($member_ids))
@@ -332,8 +342,9 @@  discard block
 block discarded – undo
332 342
 					'id_group' => $_REQUEST['group'],
333 343
 				))
334 344
 			);
335
-			while ($row = $smcFunc['db_fetch_assoc']($request))
336
-				$members[] = $row['id_member'];
345
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
346
+							$members[] = $row['id_member'];
347
+			}
337 348
 			$smcFunc['db_free_result']($request);
338 349
 		}
339 350
 
@@ -372,10 +383,11 @@  discard block
 block discarded – undo
372 383
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
373 384
 
374 385
 	// The where on the query is interesting. Non-moderators should only see people who are in this group as primary.
375
-	if ($context['group']['can_moderate'])
376
-		$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0';
377
-	else
378
-		$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}';
386
+	if ($context['group']['can_moderate']) {
387
+			$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0';
388
+	} else {
389
+			$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}';
390
+	}
379 391
 
380 392
 	// Count members of the group.
381 393
 	$request = $smcFunc['db_query']('', '
@@ -416,8 +428,9 @@  discard block
 block discarded – undo
416 428
 		$last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']);
417 429
 
418 430
 		// Italicize the online note if they aren't activated.
419
-		if ($row['is_activated'] % 10 != 1)
420
-			$last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>';
431
+		if ($row['is_activated'] % 10 != 1) {
432
+					$last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>';
433
+		}
421 434
 
422 435
 		$context['members'][] = array(
423 436
 			'id' => $row['id_member'],
@@ -437,9 +450,10 @@  discard block
 block discarded – undo
437 450
 	$context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name'];
438 451
 	createToken('mod-mgm');
439 452
 
440
-	if ($context['group']['assignable'])
441
-		loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest');
442
-}
453
+	if ($context['group']['assignable']) {
454
+			loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest');
455
+	}
456
+	}
443 457
 
444 458
 /**
445 459
  * Show and manage all group requests.
@@ -453,16 +467,18 @@  discard block
 block discarded – undo
453 467
 	$context['sub_template'] = 'show_list';
454 468
 
455 469
 	// Verify we can be here.
456
-	if ($user_info['mod_cache']['gq'] == '0=1')
457
-		isAllowedTo('manage_membergroups');
470
+	if ($user_info['mod_cache']['gq'] == '0=1') {
471
+			isAllowedTo('manage_membergroups');
472
+	}
458 473
 
459 474
 	// Normally, we act normally...
460 475
 	$where = ($user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']);
461 476
 
462
-	if (isset($_GET['closed']))
463
-		$where .= ' AND lgr.status != {int:status_open}';
464
-	else
465
-		$where .= ' AND lgr.status = {int:status_open}';
477
+	if (isset($_GET['closed'])) {
478
+			$where .= ' AND lgr.status != {int:status_open}';
479
+	} else {
480
+			$where .= ' AND lgr.status = {int:status_open}';
481
+	}
466 482
 
467 483
 	$where_parameters = array(
468 484
 		'status_open' => 0,
@@ -475,8 +491,9 @@  discard block
 block discarded – undo
475 491
 		validateToken('mod-gr');
476 492
 
477 493
 		// Clean the values.
478
-		foreach ($_POST['groupr'] as $k => $request)
479
-			$_POST['groupr'][$k] = (int) $request;
494
+		foreach ($_POST['groupr'] as $k => $request) {
495
+					$_POST['groupr'][$k] = (int) $request;
496
+		}
480 497
 
481 498
 		$log_changes = array();
482 499
 
@@ -513,8 +530,8 @@  discard block
 block discarded – undo
513 530
 			$request_list = array();
514 531
 			while ($row = $smcFunc['db_fetch_assoc']($request))
515 532
 			{
516
-				if (!isset($log_changes[$row['id_request']]))
517
-					$log_changes[$row['id_request']] = array(
533
+				if (!isset($log_changes[$row['id_request']])) {
534
+									$log_changes[$row['id_request']] = array(
518 535
 						'id_request' => $row['id_request'],
519 536
 						'status' => $_POST['req_action'] == 'approve' ? 1 : 2, // 1 = approved, 2 = rejected
520 537
 						'id_member_acted' => $user_info['id'],
@@ -522,6 +539,7 @@  discard block
 block discarded – undo
522 539
 						'time_acted' => time(),
523 540
 						'act_reason' => $_POST['req_action'] != 'approve' && !empty($_POST['groupreason']) && !empty($_POST['groupreason'][$row['id_request']]) ? $smcFunc['htmlspecialchars']($_POST['groupreason'][$row['id_request']], ENT_QUOTES) : '',
524 541
 					);
542
+				}
525 543
 				$request_list[] = $row['id_request'];
526 544
 			}
527 545
 			$smcFunc['db_free_result']($request);
@@ -744,21 +762,24 @@  discard block
 block discarded – undo
744 762
 	$group_requests = array();
745 763
 	while ($row = $smcFunc['db_fetch_assoc']($request))
746 764
 	{
747
-		if (empty($row['reason']))
748
-			$reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>';
749
-		else
750
-			$reason = censorText($row['reason']);
765
+		if (empty($row['reason'])) {
766
+					$reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>';
767
+		} else {
768
+					$reason = censorText($row['reason']);
769
+		}
751 770
 
752 771
 		if (isset($_GET['closed']))
753 772
 		{
754
-			if ($row['status'] == 1)
755
-				$reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>';
756
-			elseif ($row['status'] == 2)
757
-				$reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>';
773
+			if ($row['status'] == 1) {
774
+							$reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>';
775
+			} elseif ($row['status'] == 2) {
776
+							$reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>';
777
+			}
758 778
 
759 779
 				$reason .= ' (' . timeformat($row['time_acted']) . ')';
760
-			if (!empty($row['act_reason']))
761
-				$reason .= '<br><br>' . censorText($row['act_reason']);
780
+			if (!empty($row['act_reason'])) {
781
+							$reason .= '<br><br>' . censorText($row['act_reason']);
782
+			}
762 783
 		}
763 784
 
764 785
 		$group_requests[] = array(
Please login to merge, or discard this patch.
Sources/ManageBoards.php 1 patch
Braces   +147 added lines, -114 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 dispatcher; doesn't do anything, just delegates.
@@ -92,18 +93,19 @@  discard block
 block discarded – undo
92 93
 		checkSession('get');
93 94
 		validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request');
94 95
 
95
-		if ($_REQUEST['move_to'] === 'top')
96
-			$boardOptions = array(
96
+		if ($_REQUEST['move_to'] === 'top') {
97
+					$boardOptions = array(
97 98
 				'move_to' => $_REQUEST['move_to'],
98 99
 				'target_category' => (int) $_REQUEST['target_cat'],
99 100
 				'move_first_child' => true,
100 101
 			);
101
-		else
102
-			$boardOptions = array(
102
+		} else {
103
+					$boardOptions = array(
103 104
 				'move_to' => $_REQUEST['move_to'],
104 105
 				'target_board' => (int) $_REQUEST['target_board'],
105 106
 				'move_first_child' => true,
106 107
 			);
108
+		}
107 109
 		modifyBoard((int) $_REQUEST['src_board'], $boardOptions);
108 110
 	}
109 111
 
@@ -148,15 +150,16 @@  discard block
 block discarded – undo
148 150
 			$security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token'];
149 151
 			foreach ($boardList[$catid] as $boardid)
150 152
 			{
151
-				if (!isset($context['categories'][$catid]['move_link']))
152
-					$context['categories'][$catid]['move_link'] = array(
153
+				if (!isset($context['categories'][$catid]['move_link'])) {
154
+									$context['categories'][$catid]['move_link'] = array(
153 155
 						'child_level' => 0,
154 156
 						'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'',
155 157
 						'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security,
156 158
 					);
159
+				}
157 160
 
158
-				if (!$context['categories'][$catid]['boards'][$boardid]['move'])
159
-				$context['categories'][$catid]['boards'][$boardid]['move_links'] = array(
161
+				if (!$context['categories'][$catid]['boards'][$boardid]['move']) {
162
+								$context['categories'][$catid]['boards'][$boardid]['move_links'] = array(
160 163
 					array(
161 164
 						'child_level' => $boards[$boardid]['level'],
162 165
 						'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'',
@@ -170,34 +173,39 @@  discard block
 block discarded – undo
170 173
 						'class' => 'here',
171 174
 					),
172 175
 				);
176
+				}
173 177
 
174 178
 				$difference = $boards[$boardid]['level'] - $prev_child_level;
175
-				if ($difference == 1)
176
-					array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null);
177
-				elseif ($difference < 0)
179
+				if ($difference == 1) {
180
+									array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null);
181
+				} elseif ($difference < 0)
178 182
 				{
179
-					if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links']))
180
-						$context['categories'][$catid]['boards'][$prev_board]['move_links'] = array();
181
-					for ($i = 0; $i < -$difference; $i++)
182
-						if (($temp = array_pop($stack)) != null)
183
+					if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) {
184
+											$context['categories'][$catid]['boards'][$prev_board]['move_links'] = array();
185
+					}
186
+					for ($i = 0; $i < -$difference; $i++) {
187
+											if (($temp = array_pop($stack)) != null)
183 188
 							array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp);
189
+					}
184 190
 				}
185 191
 
186 192
 				$prev_board = $boardid;
187 193
 				$prev_child_level = $boards[$boardid]['level'];
188 194
 
189 195
 			}
190
-			if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']))
191
-				$context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']);
192
-			elseif (!empty($stack))
193
-				$context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack;
196
+			if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) {
197
+							$context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']);
198
+			} elseif (!empty($stack)) {
199
+							$context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack;
200
+			}
194 201
 
195
-			if (empty($boardList[$catid]))
196
-				$context['categories'][$catid]['move_link'] = array(
202
+			if (empty($boardList[$catid])) {
203
+							$context['categories'][$catid]['move_link'] = array(
197 204
 					'child_level' => 0,
198 205
 					'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'',
199 206
 					'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security,
200 207
 				);
208
+			}
201 209
 		}
202 210
 	}
203 211
 
@@ -253,9 +261,9 @@  discard block
 block discarded – undo
253 261
 		);
254 262
 	}
255 263
 	// Category doesn't exist, man... sorry.
256
-	elseif (!isset($cat_tree[$_REQUEST['cat']]))
257
-		redirectexit('action=admin;area=manageboards');
258
-	else
264
+	elseif (!isset($cat_tree[$_REQUEST['cat']])) {
265
+			redirectexit('action=admin;area=manageboards');
266
+	} else
259 267
 	{
260 268
 		$context['category'] = array(
261 269
 			'id' => $_REQUEST['cat'],
@@ -267,30 +275,31 @@  discard block
 block discarded – undo
267 275
 			'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children'])
268 276
 		);
269 277
 
270
-		foreach ($boardList[$_REQUEST['cat']] as $child_board)
271
-			$context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name'];
278
+		foreach ($boardList[$_REQUEST['cat']] as $child_board) {
279
+					$context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name'];
280
+		}
272 281
 	}
273 282
 
274 283
 	$prevCat = 0;
275 284
 	foreach ($cat_tree as $catid => $tree)
276 285
 	{
277
-		if ($catid == $_REQUEST['cat'] && $prevCat > 0)
278
-			$context['category_order'][$prevCat]['selected'] = true;
279
-		elseif ($catid != $_REQUEST['cat'])
280
-			$context['category_order'][$catid] = array(
286
+		if ($catid == $_REQUEST['cat'] && $prevCat > 0) {
287
+					$context['category_order'][$prevCat]['selected'] = true;
288
+		} elseif ($catid != $_REQUEST['cat']) {
289
+					$context['category_order'][$catid] = array(
281 290
 				'id' => $catid,
282 291
 				'name' => $txt['mboards_order_after'] . $tree['node']['name'],
283 292
 				'selected' => false,
284 293
 				'true_name' => $tree['node']['name']
285 294
 			);
295
+		}
286 296
 		$prevCat = $catid;
287 297
 	}
288 298
 	if (!isset($_REQUEST['delete']))
289 299
 	{
290 300
 		$context['sub_template'] = 'modify_category';
291 301
 		$context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit'];
292
-	}
293
-	else
302
+	} else
294 303
 	{
295 304
 		$context['sub_template'] = 'confirm_category_delete';
296 305
 		$context['page_title'] = $txt['mboards_delete_cat'];
@@ -327,8 +336,9 @@  discard block
 block discarded – undo
327 336
 	{
328 337
 		$catOptions = array();
329 338
 
330
-		if (isset($_POST['cat_order']))
331
-			$catOptions['move_after'] = (int) $_POST['cat_order'];
339
+		if (isset($_POST['cat_order'])) {
340
+					$catOptions['move_after'] = (int) $_POST['cat_order'];
341
+		}
332 342
 
333 343
 		// Change "This & That" to "This &amp; That" but don't change "&cent" to "&amp;cent;"...
334 344
 		$catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']);
@@ -336,10 +346,11 @@  discard block
 block discarded – undo
336 346
 
337 347
 		$catOptions['is_collapsible'] = isset($_POST['collapse']);
338 348
 
339
-		if (isset($_POST['add']))
340
-			createCategory($catOptions);
341
-		else
342
-			modifyCategory($_POST['cat'], $catOptions);
349
+		if (isset($_POST['add'])) {
350
+					createCategory($catOptions);
351
+		} else {
352
+					modifyCategory($_POST['cat'], $catOptions);
353
+		}
343 354
 	}
344 355
 	// If they want to delete - first give them confirmation.
345 356
 	elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty']))
@@ -353,13 +364,14 @@  discard block
 block discarded – undo
353 364
 		// First off - check if we are moving all the current boards first - before we start deleting!
354 365
 		if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1)
355 366
 		{
356
-			if (empty($_POST['cat_to']))
357
-				fatal_lang_error('mboards_delete_error');
367
+			if (empty($_POST['cat_to'])) {
368
+							fatal_lang_error('mboards_delete_error');
369
+			}
358 370
 
359 371
 			deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']);
372
+		} else {
373
+					deleteCategories(array($_POST['cat']));
360 374
 		}
361
-		else
362
-			deleteCategories(array($_POST['cat']));
363 375
 	}
364 376
 
365 377
 	redirectexit('action=admin;area=manageboards');
@@ -404,8 +416,9 @@  discard block
 block discarded – undo
404 416
 	if ($_REQUEST['sa'] == 'newboard')
405 417
 	{
406 418
 		// Category doesn't exist, man... sorry.
407
-		if (empty($_REQUEST['cat']))
408
-			redirectexit('action=admin;area=manageboards');
419
+		if (empty($_REQUEST['cat'])) {
420
+					redirectexit('action=admin;area=manageboards');
421
+		}
409 422
 
410 423
 		// Some things that need to be setup for a new board.
411 424
 		$curBoard = array(
@@ -429,8 +442,7 @@  discard block
 block discarded – undo
429 442
 			'category' => (int) $_REQUEST['cat'],
430 443
 			'no_children' => true,
431 444
 		);
432
-	}
433
-	else
445
+	} else
434 446
 	{
435 447
 		// Just some easy shortcuts.
436 448
 		$curBoard = &$boards[$_REQUEST['boardid']];
@@ -478,8 +490,9 @@  discard block
 block discarded – undo
478 490
 	);
479 491
 	while ($row = $smcFunc['db_fetch_assoc']($request))
480 492
 	{
481
-		if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1)
482
-			$curBoard['member_groups'][] = $row['id_group'];
493
+		if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) {
494
+					$curBoard['member_groups'][] = $row['id_group'];
495
+		}
483 496
 
484 497
 		$context['groups'][(int) $row['id_group']] = array(
485 498
 			'id' => $row['id_group'],
@@ -492,8 +505,9 @@  discard block
 block discarded – undo
492 505
 	$smcFunc['db_free_result']($request);
493 506
 
494 507
 	// Category doesn't exist, man... sorry.
495
-	if (!isset($boardList[$curBoard['category']]))
496
-		redirectexit('action=admin;area=manageboards');
508
+	if (!isset($boardList[$curBoard['category']])) {
509
+			redirectexit('action=admin;area=manageboards');
510
+	}
497 511
 
498 512
 	foreach ($boardList[$curBoard['category']] as $boardid)
499 513
 	{
@@ -507,8 +521,7 @@  discard block
 block discarded – undo
507 521
 				'is_child' => false,
508 522
 				'selected' => true
509 523
 			);
510
-		}
511
-		else
524
+		} else
512 525
 		{
513 526
 			$context['board_order'][] = array(
514 527
 				'id' => $boardid,
@@ -525,19 +538,21 @@  discard block
 block discarded – undo
525 538
 		$context['can_move_children'] = false;
526 539
 		$context['children'] = $boards[$_REQUEST['boardid']]['tree']['children'];
527 540
 
528
-		foreach ($context['board_order'] as $lBoard)
529
-			if ($lBoard['is_child'] == false && $lBoard['selected'] == false)
541
+		foreach ($context['board_order'] as $lBoard) {
542
+					if ($lBoard['is_child'] == false && $lBoard['selected'] == false)
530 543
 				$context['can_move_children'] = true;
544
+		}
531 545
 	}
532 546
 
533 547
 	// Get other available categories.
534 548
 	$context['categories'] = array();
535
-	foreach ($cat_tree as $catID => $tree)
536
-		$context['categories'][] = array(
549
+	foreach ($cat_tree as $catID => $tree) {
550
+			$context['categories'][] = array(
537 551
 			'id' => $catID == $curBoard['category'] ? 0 : $catID,
538 552
 			'name' => $tree['node']['name'],
539 553
 			'selected' => $catID == $curBoard['category']
540 554
 		);
555
+	}
541 556
 
542 557
 	$request = $smcFunc['db_query']('', '
543 558
 		SELECT mem.id_member, mem.real_name
@@ -549,14 +564,16 @@  discard block
 block discarded – undo
549 564
 		)
550 565
 	);
551 566
 	$context['board']['moderators'] = array();
552
-	while ($row = $smcFunc['db_fetch_assoc']($request))
553
-		$context['board']['moderators'][$row['id_member']] = $row['real_name'];
567
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
568
+			$context['board']['moderators'][$row['id_member']] = $row['real_name'];
569
+	}
554 570
 	$smcFunc['db_free_result']($request);
555 571
 
556 572
 	$context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '&quot;' . implode('&quot;, &quot;', $context['board']['moderators']) . '&quot;';
557 573
 
558
-	if (!empty($context['board']['moderators']))
559
-		list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1);
574
+	if (!empty($context['board']['moderators'])) {
575
+			list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1);
576
+	}
560 577
 
561 578
 	// Get all the groups assigned as moderators
562 579
 	$request = $smcFunc['db_query']('', '
@@ -568,14 +585,16 @@  discard block
 block discarded – undo
568 585
 		)
569 586
 	);
570 587
 	$context['board']['moderator_groups'] = array();
571
-	while ($row = $smcFunc['db_fetch_assoc']($request))
572
-		$context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name'];
588
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
589
+			$context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name'];
590
+	}
573 591
 	$smcFunc['db_free_result']($request);
574 592
 
575 593
 	$context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '&quot;' . implode('&quot;, &qout;', $context['board']['moderator_groups']) . '&quot;';
576 594
 
577
-	if (!empty($context['board']['moderator_groups']))
578
-		list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1);
595
+	if (!empty($context['board']['moderator_groups'])) {
596
+			list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1);
597
+	}
579 598
 
580 599
 	// Get all the themes...
581 600
 	$request = $smcFunc['db_query']('', '
@@ -587,8 +606,9 @@  discard block
 block discarded – undo
587 606
 		)
588 607
 	);
589 608
 	$context['themes'] = array();
590
-	while ($row = $smcFunc['db_fetch_assoc']($request))
591
-		$context['themes'][] = $row;
609
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
610
+			$context['themes'][] = $row;
611
+	}
592 612
 	$smcFunc['db_free_result']($request);
593 613
 
594 614
 	if (!isset($_REQUEST['delete']))
@@ -596,8 +616,7 @@  discard block
 block discarded – undo
596 616
 		$context['sub_template'] = 'modify_board';
597 617
 		$context['page_title'] = $txt['boardsEdit'];
598 618
 		loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest');
599
-	}
600
-	else
619
+	} else
601 620
 	{
602 621
 		$context['sub_template'] = 'confirm_board_delete';
603 622
 		$context['page_title'] = $txt['mboards_delete_board'];
@@ -641,8 +660,9 @@  discard block
 block discarded – undo
641 660
 		// Change the boardorder of this board?
642 661
 		elseif (!empty($_POST['placement']) && !empty($_POST['board_order']))
643 662
 		{
644
-			if (!in_array($_POST['placement'], array('before', 'after', 'child')))
645
-				fatal_lang_error('mangled_post', false);
663
+			if (!in_array($_POST['placement'], array('before', 'after', 'child'))) {
664
+							fatal_lang_error('mangled_post', false);
665
+			}
646 666
 
647 667
 			$boardOptions['move_to'] = $_POST['placement'];
648 668
 			$boardOptions['target_board'] = (int) $_POST['board_order'];
@@ -655,13 +675,14 @@  discard block
 block discarded – undo
655 675
 		$boardOptions['access_groups'] = array();
656 676
 		$boardOptions['deny_groups'] = array();
657 677
 
658
-		if (!empty($_POST['groups']))
659
-			foreach ($_POST['groups'] as $group => $action)
678
+		if (!empty($_POST['groups'])) {
679
+					foreach ($_POST['groups'] as $group => $action)
660 680
 			{
661 681
 				if ($action == 'allow')
662 682
 					$boardOptions['access_groups'][] = (int) $group;
663
-				elseif ($action == 'deny')
664
-					$boardOptions['deny_groups'][] = (int) $group;
683
+		} elseif ($action == 'deny') {
684
+									$boardOptions['deny_groups'][] = (int) $group;
685
+				}
665 686
 			}
666 687
 
667 688
 		// People with manage-boards are special.
@@ -673,8 +694,9 @@  discard block
 block discarded – undo
673 694
 		// Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded.
674 695
 		$boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers));
675 696
 
676
-		if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255)
677
-			fatal_lang_error('too_many_groups', false);
697
+		if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) {
698
+					fatal_lang_error('too_many_groups', false);
699
+		}
678 700
 
679 701
 		// Do not allow HTML tags. Parse the string.
680 702
 		$boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']);
@@ -685,8 +707,9 @@  discard block
 block discarded – undo
685 707
 		if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list']))
686 708
 		{
687 709
 			$moderators = array();
688
-			foreach ($_POST['moderator_list'] as $moderator)
689
-				$moderators[(int) $moderator] = (int) $moderator;
710
+			foreach ($_POST['moderator_list'] as $moderator) {
711
+							$moderators[(int) $moderator] = (int) $moderator;
712
+			}
690 713
 			$boardOptions['moderators'] = $moderators;
691 714
 		}
692 715
 
@@ -695,8 +718,9 @@  discard block
 block discarded – undo
695 718
 		if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list']))
696 719
 		{
697 720
 			$moderator_groups = array();
698
-			foreach ($_POST['moderator_group_list'] as $moderator_group)
699
-				$moderator_groups[(int) $moderator_group] = (int) $moderator_group;
721
+			foreach ($_POST['moderator_group_list'] as $moderator_group) {
722
+							$moderator_groups[(int) $moderator_group] = (int) $moderator_group;
723
+			}
700 724
 			$boardOptions['moderator_groups'] = $moderator_groups;
701 725
 		}
702 726
 
@@ -722,56 +746,62 @@  discard block
 block discarded – undo
722 746
 			$smcFunc['db_free_result']($request);
723 747
 
724 748
 			// If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board.
725
-			if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts)
726
-				unset($boardOptions['redirect']);
749
+			if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) {
750
+							unset($boardOptions['redirect']);
751
+			}
727 752
 			// Reset the redirection count when switching on/off.
728
-			elseif (empty($boardOptions['redirect']) != empty($oldRedirect))
729
-				$boardOptions['num_posts'] = 0;
753
+			elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) {
754
+							$boardOptions['num_posts'] = 0;
755
+			}
730 756
 			// Resetting the count?
731
-			elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect']))
732
-				$boardOptions['num_posts'] = 0;
757
+			elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) {
758
+							$boardOptions['num_posts'] = 0;
759
+			}
733 760
 		}
734 761
 
735 762
 		// Create a new board...
736 763
 		if (isset($_POST['add']))
737 764
 		{
738 765
 			// New boards by default go to the bottom of the category.
739
-			if (empty($_POST['new_cat']))
740
-				$boardOptions['target_category'] = (int) $_POST['cur_cat'];
741
-			if (!isset($boardOptions['move_to']))
742
-				$boardOptions['move_to'] = 'bottom';
766
+			if (empty($_POST['new_cat'])) {
767
+							$boardOptions['target_category'] = (int) $_POST['cur_cat'];
768
+			}
769
+			if (!isset($boardOptions['move_to'])) {
770
+							$boardOptions['move_to'] = 'bottom';
771
+			}
743 772
 
744 773
 			createBoard($boardOptions);
745 774
 		}
746 775
 
747 776
 		// ...or update an existing board.
748
-		else
749
-			modifyBoard($_POST['boardid'], $boardOptions);
750
-	}
751
-	elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children']))
777
+		else {
778
+					modifyBoard($_POST['boardid'], $boardOptions);
779
+		}
780
+	} elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children']))
752 781
 	{
753 782
 		EditBoard();
754 783
 		return;
755
-	}
756
-	elseif (isset($_POST['delete']))
784
+	} elseif (isset($_POST['delete']))
757 785
 	{
758 786
 		// First off - check if we are moving all the current child boards first - before we start deleting!
759 787
 		if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1)
760 788
 		{
761
-			if (empty($_POST['board_to']))
762
-				fatal_lang_error('mboards_delete_board_error');
789
+			if (empty($_POST['board_to'])) {
790
+							fatal_lang_error('mboards_delete_board_error');
791
+			}
763 792
 
764 793
 			deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']);
794
+		} else {
795
+					deleteBoards(array($_POST['boardid']), 0);
765 796
 		}
766
-		else
767
-			deleteBoards(array($_POST['boardid']), 0);
768 797
 	}
769 798
 
770
-	if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions')
771
-		redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']);
772
-	else
773
-		redirectexit('action=admin;area=manageboards');
774
-}
799
+	if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') {
800
+			redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']);
801
+	} else {
802
+			redirectexit('action=admin;area=manageboards');
803
+	}
804
+	}
775 805
 
776 806
 /**
777 807
  * Used to retrieve data for modifying a board category
@@ -808,8 +838,9 @@  discard block
 block discarded – undo
808 838
 	$smcFunc['db_free_result']($request);
809 839
 
810 840
 	// This would probably never happen, but just to be sure.
811
-	if ($cat .= $allowed_sa[1])
812
-		die(str_replace(',', ' to', $cat));
841
+	if ($cat .= $allowed_sa[1]) {
842
+			die(str_replace(',', ' to', $cat));
843
+	}
813 844
 
814 845
 	redirectexit();
815 846
 }
@@ -835,8 +866,9 @@  discard block
 block discarded – undo
835 866
 			'empty_string' => '',
836 867
 		)
837 868
 	);
838
-	while ($row = $smcFunc['db_fetch_assoc']($request))
839
-		$recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
869
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
870
+			$recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
871
+	}
840 872
 	$smcFunc['db_free_result']($request);
841 873
 
842 874
 	if (!empty($recycle_boards))
@@ -844,9 +876,9 @@  discard block
 block discarded – undo
844 876
 		require_once($sourcedir . '/Subs-Boards.php');
845 877
 		sortBoards($recycle_boards);
846 878
 		$recycle_boards = array('') + $recycle_boards;
879
+	} else {
880
+			$recycle_boards = array('');
847 881
 	}
848
-	else
849
-		$recycle_boards = array('');
850 882
 
851 883
 	// Here and the board settings...
852 884
 	$config_vars = array(
@@ -864,8 +896,9 @@  discard block
 block discarded – undo
864 896
 
865 897
 	call_integration_hook('integrate_modify_board_settings', array(&$config_vars));
866 898
 
867
-	if ($return_config)
868
-		return $config_vars;
899
+	if ($return_config) {
900
+			return $config_vars;
901
+	}
869 902
 
870 903
 	// Needed for the settings template.
871 904
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.
Sources/Admin.php 1 patch
Braces   +75 added lines, -52 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 admin handling function.<br>
@@ -444,8 +445,9 @@  discard block
 block discarded – undo
444 445
 		foreach ($admin_includes as $include)
445 446
 		{
446 447
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
447
-			if (file_exists($include))
448
-				require_once($include);
448
+			if (file_exists($include)) {
449
+							require_once($include);
450
+			}
449 451
 		}
450 452
 	}
451 453
 
@@ -457,24 +459,27 @@  discard block
 block discarded – undo
457 459
 	unset($admin_areas);
458 460
 
459 461
 	// Nothing valid?
460
-	if ($admin_include_data == false)
461
-		fatal_lang_error('no_access', false);
462
+	if ($admin_include_data == false) {
463
+			fatal_lang_error('no_access', false);
464
+	}
462 465
 
463 466
 	// Build the link tree.
464 467
 	$context['linktree'][] = array(
465 468
 		'url' => $scripturl . '?action=admin',
466 469
 		'name' => $txt['admin_center'],
467 470
 	);
468
-	if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index')
469
-		$context['linktree'][] = array(
471
+	if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') {
472
+			$context['linktree'][] = array(
470 473
 			'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'],
471 474
 			'name' => $admin_include_data['label'],
472 475
 		);
473
-	if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label'])
474
-		$context['linktree'][] = array(
476
+	}
477
+	if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) {
478
+			$context['linktree'][] = array(
475 479
 			'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'],
476 480
 			'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0],
477 481
 		);
482
+	}
478 483
 
479 484
 	// Make a note of the Unique ID for this menu.
480 485
 	$context['admin_menu_id'] = $context['max_menu_id'];
@@ -484,16 +489,18 @@  discard block
 block discarded – undo
484 489
 	$context['admin_area'] = $admin_include_data['current_area'];
485 490
 
486 491
 	// Now - finally - call the right place!
487
-	if (isset($admin_include_data['file']))
488
-		require_once($sourcedir . '/' . $admin_include_data['file']);
492
+	if (isset($admin_include_data['file'])) {
493
+			require_once($sourcedir . '/' . $admin_include_data['file']);
494
+	}
489 495
 
490 496
 	// Get the right callable.
491 497
 	$call = call_helper($admin_include_data['function'], true);
492 498
 
493 499
 	// Is it valid?
494
-	if (!empty($call))
495
-		call_user_func($call);
496
-}
500
+	if (!empty($call)) {
501
+			call_user_func($call);
502
+	}
503
+	}
497 504
 
498 505
 /**
499 506
  * The main administration section.
@@ -547,13 +554,14 @@  discard block
 block discarded – undo
547 554
 
548 555
 	$context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin';
549 556
 	$context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center'];
550
-	if ($context['admin_area'] != 'credits')
551
-		$context[$context['admin_menu_name']]['tab_data'] = array(
557
+	if ($context['admin_area'] != 'credits') {
558
+			$context[$context['admin_menu_name']]['tab_data'] = array(
552 559
 			'title' => $txt['admin_center'],
553 560
 			'help' => '',
554 561
 			'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong>
555 562
 						' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']),
556 563
 		);
564
+	}
557 565
 
558 566
 	// Lastly, fill in the blanks in the support resources paragraphs.
559 567
 	$txt['support_resources_p1'] = sprintf($txt['support_resources_p1'],
@@ -571,9 +579,10 @@  discard block
 block discarded – undo
571 579
 		'https://www.simplemachines.org/redirect/customize_support'
572 580
 	);
573 581
 
574
-	if ($context['admin_area'] == 'admin')
575
-		loadJavaScriptFile('admin.js', array('defer' => false, 'minimize' => true), 'smf_admin');
576
-}
582
+	if ($context['admin_area'] == 'admin') {
583
+			loadJavaScriptFile('admin.js', array('defer' => false, 'minimize' => true), 'smf_admin');
584
+	}
585
+	}
577 586
 
578 587
 /**
579 588
  * Get one of the admin information files from Simple Machines.
@@ -584,8 +593,9 @@  discard block
 block discarded – undo
584 593
 
585 594
 	setMemoryLimit('32M');
586 595
 
587
-	if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename']))
588
-		fatal_lang_error('no_access', false);
596
+	if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) {
597
+			fatal_lang_error('no_access', false);
598
+	}
589 599
 
590 600
 	// Strip off the forum cache part or we won't find it...
591 601
 	$_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']);
@@ -600,27 +610,30 @@  discard block
 block discarded – undo
600 610
 		)
601 611
 	);
602 612
 
603
-	if ($smcFunc['db_num_rows']($request) == 0)
604
-		fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404);
613
+	if ($smcFunc['db_num_rows']($request) == 0) {
614
+			fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404);
615
+	}
605 616
 
606 617
 	list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request);
607 618
 	$smcFunc['db_free_result']($request);
608 619
 
609 620
 	// @todo Temp
610 621
 	// Figure out if sesc is still being used.
611
-	if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript')
612
-		$file_data = '
622
+	if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') {
623
+			$file_data = '
613 624
 if (!(\'smfForum_sessionvar\' in window))
614 625
 	window.smfForum_sessionvar = \'sesc\';
615 626
 ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'='));
627
+	}
616 628
 
617 629
 	$context['template_layers'] = array();
618 630
 	// Lets make sure we aren't going to output anything nasty.
619 631
 	@ob_end_clean();
620
-	if (!empty($modSettings['enableCompressedOutput']))
621
-		@ob_start('ob_gzhandler');
622
-	else
623
-		@ob_start();
632
+	if (!empty($modSettings['enableCompressedOutput'])) {
633
+			@ob_start('ob_gzhandler');
634
+	} else {
635
+			@ob_start();
636
+	}
624 637
 
625 638
 	// Make sure they know what type of file we are.
626 639
 	header('content-type: ' . $filetype);
@@ -660,11 +673,12 @@  discard block
 block discarded – undo
660 673
 		updateAdminPreferences();
661 674
 	}
662 675
 
663
-	if (trim($context['search_term']) == '')
664
-		$context['search_results'] = array();
665
-	else
666
-		call_helper($subActions[$context['search_type']]);
667
-}
676
+	if (trim($context['search_term']) == '') {
677
+			$context['search_results'] = array();
678
+	} else {
679
+			call_helper($subActions[$context['search_type']]);
680
+	}
681
+	}
668 682
 
669 683
 /**
670 684
  * A complicated but relatively quick internal search.
@@ -728,8 +742,9 @@  discard block
 block discarded – undo
728 742
 
729 743
 	loadLanguage(implode('+', $language_files));
730 744
 
731
-	foreach ($include_files as $file)
732
-		require_once($sourcedir . '/' . $file . '.php');
745
+	foreach ($include_files as $file) {
746
+			require_once($sourcedir . '/' . $file . '.php');
747
+	}
733 748
 
734 749
 	/* This is the huge array that defines everything... it's a huge array of items formatted as follows:
735 750
 		0 = Language index (Can be array of indexes) to search through for this setting.
@@ -753,11 +768,12 @@  discard block
 block discarded – undo
753 768
 		foreach ($section['areas'] as $menu_key => $menu_item)
754 769
 		{
755 770
 			$search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key);
756
-			if (!empty($menu_item['subsections']))
757
-				foreach ($menu_item['subsections'] as $key => $sublabel)
771
+			if (!empty($menu_item['subsections'])) {
772
+							foreach ($menu_item['subsections'] as $key => $sublabel)
758 773
 				{
759 774
 					if (isset($sublabel['label']))
760 775
 						$search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key);
776
+			}
761 777
 				}
762 778
 		}
763 779
 	}
@@ -767,9 +783,10 @@  discard block
 block discarded – undo
767 783
 		// Get a list of their variables.
768 784
 		$config_vars = $setting_area[0](true);
769 785
 
770
-		foreach ($config_vars as $var)
771
-			if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc')))
786
+		foreach ($config_vars as $var) {
787
+					if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc')))
772 788
 				$search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && in_array($var[2], array('file', 'db'))) || isset($var[3]) ? (in_array($var[2], array('file', 'db')) ? $var[1] : $var[3]) : '');
789
+		}
773 790
 	}
774 791
 
775 792
 	$context['page_title'] = $txt['admin_search_results'];
@@ -782,8 +799,9 @@  discard block
 block discarded – undo
782 799
 		foreach ($data as $item)
783 800
 		{
784 801
 			$found = false;
785
-			if (!is_array($item[0]))
786
-				$item[0] = array($item[0]);
802
+			if (!is_array($item[0])) {
803
+							$item[0] = array($item[0]);
804
+			}
787 805
 			foreach ($item[0] as $term)
788 806
 			{
789 807
 				if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false))
@@ -841,8 +859,9 @@  discard block
 block discarded – undo
841 859
 	$postVars = explode(' ', $context['search_term']);
842 860
 
843 861
 	// Encode the search data.
844
-	foreach ($postVars as $k => $v)
845
-		$postVars[$k] = urlencode($v);
862
+	foreach ($postVars as $k => $v) {
863
+			$postVars[$k] = urlencode($v);
864
+	}
846 865
 
847 866
 	// This is what we will send.
848 867
 	$postVars = implode('+', $postVars);
@@ -853,8 +872,9 @@  discard block
 block discarded – undo
853 872
 	$search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars);
854 873
 
855 874
 	// If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded?
856
-	if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true)
857
-		fatal_lang_error('cannot_connect_doc_site');
875
+	if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) {
876
+			fatal_lang_error('cannot_connect_doc_site');
877
+	}
858 878
 
859 879
 	$search_results = $matches[1];
860 880
 
@@ -866,8 +886,9 @@  discard block
 block discarded – undo
866 886
 	$results = new xmlArray($search_results, false);
867 887
 
868 888
 	// Move through the api layer.
869
-	if (!$results->exists('api'))
870
-		fatal_lang_error('cannot_connect_doc_site');
889
+	if (!$results->exists('api')) {
890
+			fatal_lang_error('cannot_connect_doc_site');
891
+	}
871 892
 
872 893
 	// Are there actually some results?
873 894
 	if ($results->exists('api/query/search/p'))
@@ -903,8 +924,9 @@  discard block
 block discarded – undo
903 924
 	);
904 925
 
905 926
 	// If it's not got a sa set it must have come here for first time, pretend error log should be reversed.
906
-	if (!isset($_REQUEST['sa']))
907
-		$_REQUEST['desc'] = true;
927
+	if (!isset($_REQUEST['sa'])) {
928
+			$_REQUEST['desc'] = true;
929
+	}
908 930
 
909 931
 	// Setup some tab stuff.
910 932
 	$context[$context['admin_menu_name']]['tab_data'] = array(
@@ -954,9 +976,10 @@  discard block
 block discarded – undo
954 976
 	unset($_SESSION['admin_time']);
955 977
 
956 978
 	// Clean any admin tokens as well.
957
-	foreach ($_SESSION['token'] as $key => $token)
958
-		if (strpos($key, '-admin') !== false)
979
+	foreach ($_SESSION['token'] as $key => $token) {
980
+			if (strpos($key, '-admin') !== false)
959 981
 			unset($_SESSION['token'][$key]);
982
+	}
960 983
 
961 984
 	redirectexit();
962 985
 }
Please login to merge, or discard this patch.
Sources/Profile.php 1 patch
Braces   +158 added lines, -120 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
  * The main designating function for modifying profiles. Loads up info, determins what to do, etc.
@@ -29,18 +30,21 @@  discard block
 block discarded – undo
29 30
 	global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc;
30 31
 
31 32
 	// Don't reload this as we may have processed error strings.
32
-	if (empty($post_errors))
33
-		loadLanguage('Profile+Drafts');
33
+	if (empty($post_errors)) {
34
+			loadLanguage('Profile+Drafts');
35
+	}
34 36
 	loadTemplate('Profile');
35 37
 
36 38
 	require_once($sourcedir . '/Subs-Menu.php');
37 39
 
38 40
 	// Did we get the user by name...
39
-	if (isset($_REQUEST['user']))
40
-		$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
41
+	if (isset($_REQUEST['user'])) {
42
+			$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
43
+	}
41 44
 	// ... or by id_member?
42
-	elseif (!empty($_REQUEST['u']))
43
-		$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
45
+	elseif (!empty($_REQUEST['u'])) {
46
+			$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
47
+	}
44 48
 	// If it was just ?action=profile, edit your own profile, but only if you're not a guest.
45 49
 	else
46 50
 	{
@@ -50,8 +54,9 @@  discard block
 block discarded – undo
50 54
 	}
51 55
 
52 56
 	// Check if loadMemberData() has returned a valid result.
53
-	if (!$memberResult)
54
-		fatal_lang_error('not_a_user', false, 404);
57
+	if (!$memberResult) {
58
+			fatal_lang_error('not_a_user', false, 404);
59
+	}
55 60
 
56 61
 	// If all went well, we have a valid member ID!
57 62
 	list ($memID) = $memberResult;
@@ -67,8 +72,9 @@  discard block
 block discarded – undo
67 72
 
68 73
 	// Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission.
69 74
 	// And we care about what the current user can do, not what the user whose profile it is.
70
-	if ($user_info['mod_cache']['gq'] != '0=1')
71
-		$user_info['permissions'][] = 'approve_group_requests';
75
+	if ($user_info['mod_cache']['gq'] != '0=1') {
76
+			$user_info['permissions'][] = 'approve_group_requests';
77
+	}
72 78
 
73 79
 	// If paid subscriptions are enabled, make sure we actually have at least one subscription available...
74 80
 	$context['subs_available'] = false;
@@ -436,21 +442,25 @@  discard block
 block discarded – undo
436 442
 		foreach ($section['areas'] as $area_id => $area)
437 443
 		{
438 444
 			// If it said no permissions that meant it wasn't valid!
439
-			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any']))
440
-				$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
445
+			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) {
446
+							$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
447
+			}
441 448
 			// Otherwise pick the right set.
442
-			else
443
-				$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
449
+			else {
450
+							$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
451
+			}
444 452
 
445 453
 			// Password required in most cases
446
-			if (!empty($area['password']))
447
-				$context['password_areas'][] = $area_id;
454
+			if (!empty($area['password'])) {
455
+							$context['password_areas'][] = $area_id;
456
+			}
448 457
 		}
449 458
 	}
450 459
 
451 460
 	// Is there an updated message to show?
452
-	if (isset($_GET['updated']))
453
-		$context['profile_updated'] = $txt['profile_updated_own'];
461
+	if (isset($_GET['updated'])) {
462
+			$context['profile_updated'] = $txt['profile_updated_own'];
463
+	}
454 464
 
455 465
 	// Set a few options for the menu.
456 466
 	$menuOptions = array(
@@ -465,8 +475,9 @@  discard block
 block discarded – undo
465 475
 	$profile_include_data = createMenu($profile_areas, $menuOptions);
466 476
 
467 477
 	// No menu means no access.
468
-	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession()))
469
-		fatal_lang_error('no_access', false);
478
+	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) {
479
+			fatal_lang_error('no_access', false);
480
+	}
470 481
 
471 482
 	// Make a note of the Unique ID for this menu.
472 483
 	$context['profile_menu_id'] = $context['max_menu_id'];
@@ -492,8 +503,9 @@  discard block
 block discarded – undo
492 503
 			if ($current_area == $area_id)
493 504
 			{
494 505
 				// This can't happen - but is a security check.
495
-				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false))
496
-					fatal_lang_error('no_access', false);
506
+				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) {
507
+									fatal_lang_error('no_access', false);
508
+				}
497 509
 
498 510
 				// Are we saving data in a valid area?
499 511
 				if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview']))
@@ -512,12 +524,14 @@  discard block
 block discarded – undo
512 524
 				}
513 525
 
514 526
 				// Does this require session validating?
515
-				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner']))
516
-					$security_checks['validate'] = true;
527
+				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) {
528
+									$security_checks['validate'] = true;
529
+				}
517 530
 
518 531
 				// Permissions for good measure.
519
-				if (!empty($profile_include_data['permission']))
520
-					$security_checks['permission'] = $profile_include_data['permission'];
532
+				if (!empty($profile_include_data['permission'])) {
533
+									$security_checks['permission'] = $profile_include_data['permission'];
534
+				}
521 535
 
522 536
 				// Either way got something.
523 537
 				$found_area = true;
@@ -526,21 +540,26 @@  discard block
 block discarded – undo
526 540
 	}
527 541
 
528 542
 	// Oh dear, some serious security lapse is going on here... we'll put a stop to that!
529
-	if (!$found_area)
530
-		fatal_lang_error('no_access', false);
543
+	if (!$found_area) {
544
+			fatal_lang_error('no_access', false);
545
+	}
531 546
 
532 547
 	// Release this now.
533 548
 	unset($profile_areas);
534 549
 
535 550
 	// Now the context is setup have we got any security checks to carry out additional to that above?
536
-	if (isset($security_checks['session']))
537
-		checkSession($security_checks['session']);
538
-	if (isset($security_checks['validate']))
539
-		validateSession();
540
-	if (isset($security_checks['validateToken']))
541
-		validateToken($token_name, $token_type);
542
-	if (isset($security_checks['permission']))
543
-		isAllowedTo($security_checks['permission']);
551
+	if (isset($security_checks['session'])) {
552
+			checkSession($security_checks['session']);
553
+	}
554
+	if (isset($security_checks['validate'])) {
555
+			validateSession();
556
+	}
557
+	if (isset($security_checks['validateToken'])) {
558
+			validateToken($token_name, $token_type);
559
+	}
560
+	if (isset($security_checks['permission'])) {
561
+			isAllowedTo($security_checks['permission']);
562
+	}
544 563
 
545 564
 	// Create a token if needed.
546 565
 	if (isset($security_checks['needsToken']) || isset($security_checks['validateToken']))
@@ -550,8 +569,9 @@  discard block
 block discarded – undo
550 569
 	}
551 570
 
552 571
 	// File to include?
553
-	if (isset($profile_include_data['file']))
554
-		require_once($sourcedir . '/' . $profile_include_data['file']);
572
+	if (isset($profile_include_data['file'])) {
573
+			require_once($sourcedir . '/' . $profile_include_data['file']);
574
+	}
555 575
 
556 576
 	// Build the link tree.
557 577
 	$context['linktree'][] = array(
@@ -559,17 +579,19 @@  discard block
 block discarded – undo
559 579
 		'name' => sprintf($txt['profile_of_username'], $context['member']['name']),
560 580
 	);
561 581
 
562
-	if (!empty($profile_include_data['label']))
563
-		$context['linktree'][] = array(
582
+	if (!empty($profile_include_data['label'])) {
583
+			$context['linktree'][] = array(
564 584
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'],
565 585
 			'name' => $profile_include_data['label'],
566 586
 		);
587
+	}
567 588
 
568
-	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label'])
569
-		$context['linktree'][] = array(
589
+	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) {
590
+			$context['linktree'][] = array(
570 591
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'],
571 592
 			'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0],
572 593
 		);
594
+	}
573 595
 
574 596
 	// Set the template for this area and add the profile layer.
575 597
 	$context['sub_template'] = $profile_include_data['function'];
@@ -595,12 +617,14 @@  discard block
 block discarded – undo
595 617
 		if ($check_password)
596 618
 		{
597 619
 			// Check to ensure we're forcing SSL for authentication
598
-			if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
599
-				fatal_lang_error('login_ssl_required');
620
+			if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
621
+							fatal_lang_error('login_ssl_required');
622
+			}
600 623
 
601 624
 			// You didn't even enter a password!
602
-			if (trim($_POST['oldpasswrd']) == '')
603
-				$post_errors[] = 'no_password';
625
+			if (trim($_POST['oldpasswrd']) == '') {
626
+							$post_errors[] = 'no_password';
627
+			}
604 628
 
605 629
 			// Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password
606 630
 			$_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']);
@@ -609,42 +633,43 @@  discard block
 block discarded – undo
609 633
 			$good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true);
610 634
 
611 635
 			// Bad password!!!
612
-			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd']))
613
-				$post_errors[] = 'bad_password';
636
+			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) {
637
+							$post_errors[] = 'bad_password';
638
+			}
614 639
 
615 640
 			// Warn other elements not to jump the gun and do custom changes!
616
-			if (in_array('bad_password', $post_errors))
617
-				$context['password_auth_failed'] = true;
641
+			if (in_array('bad_password', $post_errors)) {
642
+							$context['password_auth_failed'] = true;
643
+			}
618 644
 		}
619 645
 
620 646
 		// Change the IP address in the database.
621
-		if ($context['user']['is_owner'])
622
-			$profile_vars['member_ip'] = $user_info['ip'];
647
+		if ($context['user']['is_owner']) {
648
+					$profile_vars['member_ip'] = $user_info['ip'];
649
+		}
623 650
 
624 651
 		// Now call the sub-action function...
625 652
 		if ($current_area == 'activateaccount')
626 653
 		{
627
-			if (empty($post_errors))
628
-				activateAccount($memID);
629
-		}
630
-		elseif ($current_area == 'deleteaccount')
654
+			if (empty($post_errors)) {
655
+							activateAccount($memID);
656
+			}
657
+		} elseif ($current_area == 'deleteaccount')
631 658
 		{
632 659
 			if (empty($post_errors))
633 660
 			{
634 661
 				deleteAccount2($memID);
635 662
 				redirectexit();
636 663
 			}
637
-		}
638
-		elseif ($current_area == 'groupmembership' && empty($post_errors))
664
+		} elseif ($current_area == 'groupmembership' && empty($post_errors))
639 665
 		{
640 666
 			$msg = groupMembership2($profile_vars, $post_errors, $memID);
641 667
 
642 668
 			// Whatever we've done, we have nothing else to do here...
643 669
 			redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : ''));
644
-		}
645
-		elseif (in_array($current_area, array('account', 'forumprofile', 'theme')))
646
-			saveProfileFields();
647
-		else
670
+		} elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) {
671
+					saveProfileFields();
672
+		} else
648 673
 		{
649 674
 			$force_redirect = true;
650 675
 			// Ensure we include this.
@@ -660,34 +685,36 @@  discard block
 block discarded – undo
660 685
 			// Load the language file so we can give a nice explanation of the errors.
661 686
 			loadLanguage('Errors');
662 687
 			$context['post_errors'] = $post_errors;
663
-		}
664
-		elseif (!empty($profile_vars))
688
+		} elseif (!empty($profile_vars))
665 689
 		{
666 690
 			// If we've changed the password, notify any integration that may be listening in.
667
-			if (isset($profile_vars['passwd']))
668
-				call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
691
+			if (isset($profile_vars['passwd'])) {
692
+							call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
693
+			}
669 694
 
670 695
 			updateMemberData($memID, $profile_vars);
671 696
 
672 697
 			// What if this is the newest member?
673
-			if ($modSettings['latestMember'] == $memID)
674
-				updateStats('member');
675
-			elseif (isset($profile_vars['real_name']))
676
-				updateSettings(array('memberlist_updated' => time()));
698
+			if ($modSettings['latestMember'] == $memID) {
699
+							updateStats('member');
700
+			} elseif (isset($profile_vars['real_name'])) {
701
+							updateSettings(array('memberlist_updated' => time()));
702
+			}
677 703
 
678 704
 			// If the member changed his/her birthdate, update calendar statistics.
679
-			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name']))
680
-				updateSettings(array(
705
+			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) {
706
+							updateSettings(array(
681 707
 					'calendar_updated' => time(),
682 708
 				));
709
+			}
683 710
 
684 711
 			// Anything worth logging?
685 712
 			if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled']))
686 713
 			{
687 714
 				$log_changes = array();
688 715
 				require_once($sourcedir . '/Logging.php');
689
-				foreach ($context['log_changes'] as $k => $v)
690
-					$log_changes[] = array(
716
+				foreach ($context['log_changes'] as $k => $v) {
717
+									$log_changes[] = array(
691 718
 						'action' => $k,
692 719
 						'log_type' => 'user',
693 720
 						'extra' => array_merge($v, array(
@@ -695,14 +722,16 @@  discard block
 block discarded – undo
695 722
 							'member_affected' => $memID,
696 723
 						)),
697 724
 					);
725
+				}
698 726
 
699 727
 				logActions($log_changes);
700 728
 			}
701 729
 
702 730
 			// Have we got any post save functions to execute?
703
-			if (!empty($context['profile_execute_on_save']))
704
-				foreach ($context['profile_execute_on_save'] as $saveFunc)
731
+			if (!empty($context['profile_execute_on_save'])) {
732
+							foreach ($context['profile_execute_on_save'] as $saveFunc)
705 733
 					$saveFunc();
734
+			}
706 735
 
707 736
 			// Let them know it worked!
708 737
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']);
@@ -716,27 +745,31 @@  discard block
 block discarded – undo
716 745
 	if (!empty($post_errors))
717 746
 	{
718 747
 		// Set all the errors so the template knows what went wrong.
719
-		foreach ($post_errors as $error_type)
720
-			$context['modify_error'][$error_type] = true;
748
+		foreach ($post_errors as $error_type) {
749
+					$context['modify_error'][$error_type] = true;
750
+		}
721 751
 	}
722 752
 	// If it's you then we should redirect upon save.
723
-	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview'])
724
-		redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
725
-	elseif (!empty($force_redirect))
726
-		redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
753
+	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) {
754
+			redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
755
+	} elseif (!empty($force_redirect)) {
756
+			redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
757
+	}
727 758
 
728 759
 
729 760
 	// Get the right callable.
730 761
 	$call = call_helper($profile_include_data['function'], true);
731 762
 
732 763
 	// Is it valid?
733
-	if (!empty($call))
734
-		call_user_func($call, $memID);
764
+	if (!empty($call)) {
765
+			call_user_func($call, $memID);
766
+	}
735 767
 
736 768
 	// Set the page title if it's not already set...
737
-	if (!isset($context['page_title']))
738
-		$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
739
-}
769
+	if (!isset($context['page_title'])) {
770
+			$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
771
+	}
772
+	}
740 773
 
741 774
 /**
742 775
  * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user.
@@ -859,16 +892,18 @@  discard block
 block discarded – undo
859 892
 	if (!allowedTo('admin_forum') && $area != 'register')
860 893
 	{
861 894
 		// If it's the owner they can see two types of private fields, regardless.
862
-		if ($memID == $user_info['id'])
863
-			$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
864
-		else
865
-			$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
895
+		if ($memID == $user_info['id']) {
896
+					$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
897
+		} else {
898
+					$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
899
+		}
866 900
 	}
867 901
 
868
-	if ($area == 'register')
869
-		$where .= ' AND show_reg != 0';
870
-	elseif ($area != 'summary')
871
-		$where .= ' AND show_profile = {string:area}';
902
+	if ($area == 'register') {
903
+			$where .= ' AND show_reg != 0';
904
+	} elseif ($area != 'summary') {
905
+			$where .= ' AND show_profile = {string:area}';
906
+	}
872 907
 
873 908
 	// Load all the relevant fields - and data.
874 909
 	$request = $smcFunc['db_query']('', '
@@ -893,8 +928,9 @@  discard block
 block discarded – undo
893 928
 			$fieldOptions = explode(',', $row['field_options']);
894 929
 			foreach ($fieldOptions as $k => $v)
895 930
 			{
896
-				if (empty($currentKey))
897
-					$currentKey = $v === $value ? $k : 0;
931
+				if (empty($currentKey)) {
932
+									$currentKey = $v === $value ? $k : 0;
933
+				}
898 934
 			}
899 935
 		}
900 936
 
@@ -906,13 +942,15 @@  discard block
 block discarded – undo
906 942
 		if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']]))
907 943
 		{
908 944
 			$value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]);
909
-			if (in_array($row['field_type'], array('select', 'radio')))
910
-					$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
945
+			if (in_array($row['field_type'], array('select', 'radio'))) {
946
+								$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
947
+			}
911 948
 		}
912 949
 
913 950
 		// Don't show the "disabled" option for the "gender" field if we are on the "summary" area.
914
-		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None')
915
-			continue;
951
+		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') {
952
+					continue;
953
+		}
916 954
 
917 955
 		// HTML for the input form.
918 956
 		$output_html = $value;
@@ -921,8 +959,7 @@  discard block
 block discarded – undo
921 959
 			$true = (!$exists && $row['default_value']) || $value;
922 960
 			$input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>';
923 961
 			$output_html = $true ? $txt['yes'] : $txt['no'];
924
-		}
925
-		elseif ($row['field_type'] == 'select')
962
+		} elseif ($row['field_type'] == 'select')
926 963
 		{
927 964
 			$input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>';
928 965
 			$options = explode(',', $row['field_options']);
@@ -930,13 +967,13 @@  discard block
 block discarded – undo
930 967
 			{
931 968
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
932 969
 				$input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>';
933
-				if ($true)
934
-					$output_html = $v;
970
+				if ($true) {
971
+									$output_html = $v;
972
+				}
935 973
 			}
936 974
 
937 975
 			$input_html .= '</select>';
938
-		}
939
-		elseif ($row['field_type'] == 'radio')
976
+		} elseif ($row['field_type'] == 'radio')
940 977
 		{
941 978
 			$input_html = '<fieldset>';
942 979
 			$options = explode(',', $row['field_options']);
@@ -944,37 +981,38 @@  discard block
 block discarded – undo
944 981
 			{
945 982
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
946 983
 				$input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>';
947
-				if ($true)
948
-					$output_html = $v;
984
+				if ($true) {
985
+									$output_html = $v;
986
+				}
949 987
 			}
950 988
 			$input_html .= '</fieldset>';
951
-		}
952
-		elseif ($row['field_type'] == 'text')
989
+		} elseif ($row['field_type'] == 'text')
953 990
 		{
954 991
 			$input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>';
955
-		}
956
-		else
992
+		} else
957 993
 		{
958 994
 			@list ($rows, $cols) = @explode(',', $row['default_value']);
959 995
 			$input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>';
960 996
 		}
961 997
 
962 998
 		// Parse BBCode
963
-		if ($row['bbc'])
964
-			$output_html = parse_bbc($output_html);
965
-		elseif ($row['field_type'] == 'textarea')
966
-			// Allow for newlines at least
999
+		if ($row['bbc']) {
1000
+					$output_html = parse_bbc($output_html);
1001
+		} elseif ($row['field_type'] == 'textarea') {
1002
+					// Allow for newlines at least
967 1003
 			$output_html = strtr($output_html, array("\n" => '<br>'));
1004
+		}
968 1005
 
969 1006
 		// Enclosing the user input within some other text?
970
-		if (!empty($row['enclose']) && !empty($output_html))
971
-			$output_html = strtr($row['enclose'], array(
1007
+		if (!empty($row['enclose']) && !empty($output_html)) {
1008
+					$output_html = strtr($row['enclose'], array(
972 1009
 				'{SCRIPTURL}' => $scripturl,
973 1010
 				'{IMAGES_URL}' => $settings['images_url'],
974 1011
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
975 1012
 				'{INPUT}' => un_htmlspecialchars($output_html),
976 1013
 				'{KEY}' => $currentKey
977 1014
 			));
1015
+		}
978 1016
 
979 1017
 		$context['custom_fields'][] = array(
980 1018
 			'name' => $row['field_name'],
Please login to merge, or discard this patch.
Sources/ManageSettings.php 1 patch
Braces   +276 added lines, -201 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
  * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or.
@@ -206,16 +207,18 @@  discard block
 block discarded – undo
206 207
 	{
207 208
 		$all_zones = timezone_identifiers_list();
208 209
 		// Make sure we set the value to the same as the printed value.
209
-		foreach ($all_zones as $zone)
210
-			$config_vars['default_timezone'][2][$zone] = $zone;
210
+		foreach ($all_zones as $zone) {
211
+					$config_vars['default_timezone'][2][$zone] = $zone;
212
+		}
213
+	} else {
214
+			unset($config_vars['default_timezone']);
211 215
 	}
212
-	else
213
-		unset($config_vars['default_timezone']);
214 216
 
215 217
 	call_integration_hook('integrate_modify_basic_settings', array(&$config_vars));
216 218
 
217
-	if ($return_config)
218
-		return $config_vars;
219
+	if ($return_config) {
220
+			return $config_vars;
221
+	}
219 222
 
220 223
 	// Saving?
221 224
 	if (isset($_GET['save']))
@@ -223,8 +226,9 @@  discard block
 block discarded – undo
223 226
 		checkSession();
224 227
 
225 228
 		// Prevent absurd boundaries here - make it a day tops.
226
-		if (isset($_POST['lastActive']))
227
-			$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
229
+		if (isset($_POST['lastActive'])) {
230
+					$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
231
+		}
228 232
 
229 233
 		call_integration_hook('integrate_save_basic_settings');
230 234
 
@@ -232,8 +236,9 @@  discard block
 block discarded – undo
232 236
 		$_SESSION['adm-save'] = true;
233 237
 
234 238
 		// Do a bit of housekeeping
235
-		if (empty($_POST['minimize_files']))
236
-			deleteAllMinified();
239
+		if (empty($_POST['minimize_files'])) {
240
+					deleteAllMinified();
241
+		}
237 242
 
238 243
 		writeLog();
239 244
 		redirectexit('action=admin;area=featuresettings;sa=basic');
@@ -273,8 +278,9 @@  discard block
 block discarded – undo
273 278
 
274 279
 	call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars));
275 280
 
276
-	if ($return_config)
277
-		return $config_vars;
281
+	if ($return_config) {
282
+			return $config_vars;
283
+	}
278 284
 
279 285
 	// Setup the template.
280 286
 	require_once($sourcedir . '/ManageServer.php');
@@ -291,13 +297,15 @@  discard block
 block discarded – undo
291 297
 
292 298
 		// Clean up the tags.
293 299
 		$bbcTags = array();
294
-		foreach (parse_bbc(false) as $tag)
295
-			$bbcTags[] = $tag['tag'];
300
+		foreach (parse_bbc(false) as $tag) {
301
+					$bbcTags[] = $tag['tag'];
302
+		}
296 303
 
297
-		if (!isset($_POST['disabledBBC_enabledTags']))
298
-			$_POST['disabledBBC_enabledTags'] = array();
299
-		elseif (!is_array($_POST['disabledBBC_enabledTags']))
300
-			$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
304
+		if (!isset($_POST['disabledBBC_enabledTags'])) {
305
+					$_POST['disabledBBC_enabledTags'] = array();
306
+		} elseif (!is_array($_POST['disabledBBC_enabledTags'])) {
307
+					$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
308
+		}
301 309
 		// Work out what is actually disabled!
302 310
 		$_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
303 311
 
@@ -341,8 +349,9 @@  discard block
 block discarded – undo
341 349
 
342 350
 	call_integration_hook('integrate_layout_settings', array(&$config_vars));
343 351
 
344
-	if ($return_config)
345
-		return $config_vars;
352
+	if ($return_config) {
353
+			return $config_vars;
354
+	}
346 355
 
347 356
 	// Saving?
348 357
 	if (isset($_GET['save']))
@@ -382,8 +391,9 @@  discard block
 block discarded – undo
382 391
 
383 392
 	call_integration_hook('integrate_likes_settings', array(&$config_vars));
384 393
 
385
-	if ($return_config)
386
-		return $config_vars;
394
+	if ($return_config) {
395
+			return $config_vars;
396
+	}
387 397
 
388 398
 	// Saving?
389 399
 	if (isset($_GET['save']))
@@ -421,8 +431,9 @@  discard block
 block discarded – undo
421 431
 
422 432
 	call_integration_hook('integrate_mentions_settings', array(&$config_vars));
423 433
 
424
-	if ($return_config)
425
-		return $config_vars;
434
+	if ($return_config) {
435
+			return $config_vars;
436
+	}
426 437
 
427 438
 	// Saving?
428 439
 	if (isset($_GET['save']))
@@ -466,8 +477,8 @@  discard block
 block discarded – undo
466 477
 			'enable' => array('check', 'warning_enable'),
467 478
 	);
468 479
 
469
-	if (!empty($modSettings['warning_settings']) && $currently_enabled)
470
-		$config_vars += array(
480
+	if (!empty($modSettings['warning_settings']) && $currently_enabled) {
481
+			$config_vars += array(
471 482
 			'',
472 483
 				array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']),
473 484
 				'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']),
@@ -476,15 +487,18 @@  discard block
 block discarded – undo
476 487
 				'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']),
477 488
 				array('permissions', 'view_warning'),
478 489
 		);
490
+	}
479 491
 
480 492
 	call_integration_hook('integrate_warning_settings', array(&$config_vars));
481 493
 
482
-	if ($return_config)
483
-		return $config_vars;
494
+	if ($return_config) {
495
+			return $config_vars;
496
+	}
484 497
 
485 498
 	// Cannot use moderation if post moderation is not enabled.
486
-	if (!$modSettings['postmod_active'])
487
-		unset($config_vars['moderate']);
499
+	if (!$modSettings['postmod_active']) {
500
+			unset($config_vars['moderate']);
501
+	}
488 502
 
489 503
 	// Will need the utility functions from here.
490 504
 	require_once($sourcedir . '/ManageServer.php');
@@ -509,16 +523,16 @@  discard block
 block discarded – undo
509 523
 				'warning_watch' => 10,
510 524
 				'warning_mute' => 60,
511 525
 			);
512
-			if ($modSettings['postmod_active'])
513
-				$vars['warning_moderate'] = 35;
526
+			if ($modSettings['postmod_active']) {
527
+							$vars['warning_moderate'] = 35;
528
+			}
514 529
 
515 530
 			foreach ($vars as $var => $value)
516 531
 			{
517 532
 				$config_vars[] = array('int', $var);
518 533
 				$_POST[$var] = $value;
519 534
 			}
520
-		}
521
-		else
535
+		} else
522 536
 		{
523 537
 			$_POST['warning_watch'] = min($_POST['warning_watch'], 100);
524 538
 			$_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0;
@@ -606,8 +620,9 @@  discard block
 block discarded – undo
606 620
 
607 621
 	call_integration_hook('integrate_spam_settings', array(&$config_vars));
608 622
 
609
-	if ($return_config)
610
-		return $config_vars;
623
+	if ($return_config) {
624
+			return $config_vars;
625
+	}
611 626
 
612 627
 	// You need to be an admin to edit settings!
613 628
 	isAllowedTo('admin_forum');
@@ -641,8 +656,9 @@  discard block
 block discarded – undo
641 656
 
642 657
 	if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers']))
643 658
 	{
644
-		if (empty($context['settings_insert_above']))
645
-			$context['settings_insert_above'] = '';
659
+		if (empty($context['settings_insert_above'])) {
660
+					$context['settings_insert_above'] = '';
661
+		}
646 662
 
647 663
 		$context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>';
648 664
 	}
@@ -685,8 +701,9 @@  discard block
 block discarded – undo
685 701
 		$_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
686 702
 
687 703
 		// Hack in guest requiring verification!
688
-		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha']))
689
-			$_POST['posts_require_captcha'] = -1;
704
+		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) {
705
+					$_POST['posts_require_captcha'] = -1;
706
+		}
690 707
 
691 708
 		$save_vars = $config_vars;
692 709
 		unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']);
@@ -703,14 +720,16 @@  discard block
 block discarded – undo
703 720
 		foreach ($context['qa_languages'] as $lang_id => $dummy)
704 721
 		{
705 722
 			// If we had some questions for this language before, but don't now, delete everything from that language.
706
-			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id]))
707
-				$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
723
+			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) {
724
+							$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
725
+			}
708 726
 
709 727
 			// Now step through and see if any existing questions no longer exist.
710
-			if (!empty($context['qa_by_lang'][$lang_id]))
711
-				foreach ($context['qa_by_lang'][$lang_id] as $q_id)
728
+			if (!empty($context['qa_by_lang'][$lang_id])) {
729
+							foreach ($context['qa_by_lang'][$lang_id] as $q_id)
712 730
 					if (empty($_POST['question'][$lang_id][$q_id]))
713 731
 						$changes['delete'][] = $q_id;
732
+			}
714 733
 
715 734
 			// Now let's see if there are new questions or ones that need updating.
716 735
 			if (isset($_POST['question'][$lang_id]))
@@ -719,14 +738,16 @@  discard block
 block discarded – undo
719 738
 				{
720 739
 					// Ignore junky ids.
721 740
 					$q_id = (int) $q_id;
722
-					if ($q_id <= 0)
723
-						continue;
741
+					if ($q_id <= 0) {
742
+											continue;
743
+					}
724 744
 
725 745
 					// Check the question isn't empty (because they want to delete it?)
726 746
 					if (empty($question) || trim($question) == '')
727 747
 					{
728
-						if (isset($context['question_answers'][$q_id]))
729
-							$changes['delete'][] = $q_id;
748
+						if (isset($context['question_answers'][$q_id])) {
749
+													$changes['delete'][] = $q_id;
750
+						}
730 751
 						continue;
731 752
 					}
732 753
 					$question = $smcFunc['htmlspecialchars'](trim($question));
@@ -734,19 +755,22 @@  discard block
 block discarded – undo
734 755
 					// Get the answers. Firstly check there actually might be some.
735 756
 					if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id]))
736 757
 					{
737
-						if (isset($context['question_answers'][$q_id]))
738
-							$changes['delete'][] = $q_id;
758
+						if (isset($context['question_answers'][$q_id])) {
759
+													$changes['delete'][] = $q_id;
760
+						}
739 761
 						continue;
740 762
 					}
741 763
 					// Now get them and check that they might be viable.
742 764
 					$answers = array();
743
-					foreach ($_POST['answer'][$lang_id][$q_id] as $answer)
744
-						if (!empty($answer) && trim($answer) !== '')
765
+					foreach ($_POST['answer'][$lang_id][$q_id] as $answer) {
766
+											if (!empty($answer) && trim($answer) !== '')
745 767
 							$answers[] = $smcFunc['htmlspecialchars'](trim($answer));
768
+					}
746 769
 					if (empty($answers))
747 770
 					{
748
-						if (isset($context['question_answers'][$q_id]))
749
-							$changes['delete'][] = $q_id;
771
+						if (isset($context['question_answers'][$q_id])) {
772
+													$changes['delete'][] = $q_id;
773
+						}
750 774
 						continue;
751 775
 					}
752 776
 					$answers = $smcFunc['json_encode']($answers);
@@ -756,16 +780,17 @@  discard block
 block discarded – undo
756 780
 					{
757 781
 						// New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids.
758 782
 						$changes['insert'][] = array($lang_id, $question, $answers);
759
-					}
760
-					else
783
+					} else
761 784
 					{
762 785
 						// It's an existing question. Let's see what's changed, if anything.
763
-						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers'])
764
-							$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
786
+						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) {
787
+													$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
788
+						}
765 789
 					}
766 790
 
767
-					if (!isset($qs_per_lang[$lang_id]))
768
-						$qs_per_lang[$lang_id] = 0;
791
+					if (!isset($qs_per_lang[$lang_id])) {
792
+											$qs_per_lang[$lang_id] = 0;
793
+					}
769 794
 					$qs_per_lang[$lang_id]++;
770 795
 				}
771 796
 			}
@@ -815,8 +840,9 @@  discard block
 block discarded – undo
815 840
 
816 841
 		// Lastly, the count of messages needs to be no more than the lowest number of questions for any one language.
817 842
 		$count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang);
818
-		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions)
819
-			$_POST['qa_verification_number'] = $count_questions;
843
+		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) {
844
+					$_POST['qa_verification_number'] = $count_questions;
845
+		}
820 846
 
821 847
 		call_integration_hook('integrate_save_spam_settings', array(&$save_vars));
822 848
 
@@ -831,24 +857,27 @@  discard block
 block discarded – undo
831 857
 
832 858
 	$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
833 859
 	$_SESSION['visual_verification_code'] = '';
834
-	for ($i = 0; $i < 6; $i++)
835
-		$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
860
+	for ($i = 0; $i < 6; $i++) {
861
+			$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
862
+	}
836 863
 
837 864
 	// Some javascript for CAPTCHA.
838 865
 	$context['settings_post_javascript'] = '';
839
-	if ($context['use_graphic_library'])
840
-		$context['settings_post_javascript'] .= '
866
+	if ($context['use_graphic_library']) {
867
+			$context['settings_post_javascript'] .= '
841 868
 		function refreshImages()
842 869
 		{
843 870
 			var imageType = document.getElementById(\'visual_verification_type\').value;
844 871
 			document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType;
845 872
 		}';
873
+	}
846 874
 
847 875
 	// Show the image itself, or text saying we can't.
848
-	if ($context['use_graphic_library'])
849
-		$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
850
-	else
851
-		$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
876
+	if ($context['use_graphic_library']) {
877
+			$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
878
+	} else {
879
+			$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
880
+	}
852 881
 
853 882
 	// Hack for PM spam settings.
854 883
 	list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
@@ -858,9 +887,10 @@  discard block
 block discarded – undo
858 887
 	$modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha'];
859 888
 
860 889
 	// Some minor javascript for the guest post setting.
861
-	if ($modSettings['posts_require_captcha'])
862
-		$context['settings_post_javascript'] .= '
890
+	if ($modSettings['posts_require_captcha']) {
891
+			$context['settings_post_javascript'] .= '
863 892
 		document.getElementById(\'guests_require_captcha\').disabled = true;';
893
+	}
864 894
 
865 895
 	// And everything else.
866 896
 	$context['post_url'] = $scripturl . '?action=admin;area=antispam;save';
@@ -907,8 +937,9 @@  discard block
 block discarded – undo
907 937
 
908 938
 	call_integration_hook('integrate_signature_settings', array(&$config_vars));
909 939
 
910
-	if ($return_config)
911
-		return $config_vars;
940
+	if ($return_config) {
941
+			return $config_vars;
942
+	}
912 943
 
913 944
 	// Setup the template.
914 945
 	$context['page_title'] = $txt['signature_settings'];
@@ -963,8 +994,9 @@  discard block
 block discarded – undo
963 994
 				$sig = strtr($row['signature'], array('<br>' => "\n"));
964 995
 
965 996
 				// Max characters...
966
-				if (!empty($sig_limits[1]))
967
-					$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
997
+				if (!empty($sig_limits[1])) {
998
+									$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
999
+				}
968 1000
 				// Max lines...
969 1001
 				if (!empty($sig_limits[2]))
970 1002
 				{
@@ -974,8 +1006,9 @@  discard block
 block discarded – undo
974 1006
 						if ($sig[$i] == "\n")
975 1007
 						{
976 1008
 							$count++;
977
-							if ($count >= $sig_limits[2])
978
-								$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
1009
+							if ($count >= $sig_limits[2]) {
1010
+															$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
1011
+							}
979 1012
 						}
980 1013
 					}
981 1014
 				}
@@ -986,17 +1019,19 @@  discard block
 block discarded – undo
986 1019
 					{
987 1020
 						$limit_broke = 0;
988 1021
 						// Attempt to allow all sizes of abuse, so to speak.
989
-						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
990
-							$limit_broke = $sig_limits[7] . 'px';
991
-						elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
992
-							$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
993
-						elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
994
-							$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
995
-						elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
996
-							$limit_broke = 'large';
997
-
998
-						if ($limit_broke)
999
-							$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1022
+						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
1023
+													$limit_broke = $sig_limits[7] . 'px';
1024
+						} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
1025
+													$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
1026
+						} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
1027
+													$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
1028
+						} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
1029
+													$limit_broke = 'large';
1030
+						}
1031
+
1032
+						if ($limit_broke) {
1033
+													$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1034
+						}
1000 1035
 					}
1001 1036
 				}
1002 1037
 
@@ -1052,32 +1087,34 @@  discard block
 block discarded – undo
1052 1087
 											$img_offset = false;
1053 1088
 										}
1054 1089
 									}
1090
+								} else {
1091
+																	$replaces[$image] = '';
1055 1092
 								}
1056
-								else
1057
-									$replaces[$image] = '';
1058 1093
 
1059 1094
 								continue;
1060 1095
 							}
1061 1096
 
1062 1097
 							// Does it have predefined restraints? Width first.
1063
-							if ($matches[6][$key])
1064
-								$matches[2][$key] = $matches[6][$key];
1098
+							if ($matches[6][$key]) {
1099
+															$matches[2][$key] = $matches[6][$key];
1100
+							}
1065 1101
 							if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
1066 1102
 							{
1067 1103
 								$width = $sig_limits[5];
1068 1104
 								$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
1105
+							} elseif ($matches[2][$key]) {
1106
+															$width = $matches[2][$key];
1069 1107
 							}
1070
-							elseif ($matches[2][$key])
1071
-								$width = $matches[2][$key];
1072 1108
 							// ... and height.
1073 1109
 							if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
1074 1110
 							{
1075 1111
 								$height = $sig_limits[6];
1076
-								if ($width != -1)
1077
-									$width = $width * ($height / $matches[4][$key]);
1112
+								if ($width != -1) {
1113
+																	$width = $width * ($height / $matches[4][$key]);
1114
+								}
1115
+							} elseif ($matches[4][$key]) {
1116
+															$height = $matches[4][$key];
1078 1117
 							}
1079
-							elseif ($matches[4][$key])
1080
-								$height = $matches[4][$key];
1081 1118
 
1082 1119
 							// If the dimensions are still not fixed - we need to check the actual image.
1083 1120
 							if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -1095,12 +1132,13 @@  discard block
 block discarded – undo
1095 1132
 									if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
1096 1133
 									{
1097 1134
 										$height = $sig_limits[6];
1098
-										if ($width == -1)
1099
-											$width = $sizes[0];
1135
+										if ($width == -1) {
1136
+																					$width = $sizes[0];
1137
+										}
1100 1138
 										$width = $width * ($height / $sizes[1]);
1139
+									} elseif ($width != -1) {
1140
+																			$height = $sizes[1];
1101 1141
 									}
1102
-									elseif ($width != -1)
1103
-										$height = $sizes[1];
1104 1142
 								}
1105 1143
 							}
1106 1144
 
@@ -1113,8 +1151,9 @@  discard block
 block discarded – undo
1113 1151
 							// Record that we got one.
1114 1152
 							$image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
1115 1153
 						}
1116
-						if (!empty($replaces))
1117
-							$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1154
+						if (!empty($replaces)) {
1155
+													$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1156
+						}
1118 1157
 					}
1119 1158
 				}
1120 1159
 				// Try to fix disabled tags.
@@ -1126,18 +1165,20 @@  discard block
 block discarded – undo
1126 1165
 
1127 1166
 				$sig = strtr($sig, array("\n" => '<br>'));
1128 1167
 				call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags));
1129
-				if ($sig != $row['signature'])
1130
-					$changes[$row['id_member']] = $sig;
1168
+				if ($sig != $row['signature']) {
1169
+									$changes[$row['id_member']] = $sig;
1170
+				}
1171
+			}
1172
+			if ($smcFunc['db_num_rows']($request) == 0) {
1173
+							$done = true;
1131 1174
 			}
1132
-			if ($smcFunc['db_num_rows']($request) == 0)
1133
-				$done = true;
1134 1175
 			$smcFunc['db_free_result']($request);
1135 1176
 
1136 1177
 			// Do we need to delete what we have?
1137 1178
 			if (!empty($changes))
1138 1179
 			{
1139
-				foreach ($changes as $id => $sig)
1140
-					$smcFunc['db_query']('', '
1180
+				foreach ($changes as $id => $sig) {
1181
+									$smcFunc['db_query']('', '
1141 1182
 						UPDATE {db_prefix}members
1142 1183
 						SET signature = {string:signature}
1143 1184
 						WHERE id_member = {int:id_member}',
@@ -1146,11 +1187,13 @@  discard block
 block discarded – undo
1146 1187
 							'signature' => $sig,
1147 1188
 						)
1148 1189
 					);
1190
+				}
1149 1191
 			}
1150 1192
 
1151 1193
 			$_GET['step'] += 50;
1152
-			if (!$done)
1153
-				pauseSignatureApplySettings();
1194
+			if (!$done) {
1195
+							pauseSignatureApplySettings();
1196
+			}
1154 1197
 		}
1155 1198
 		$settings_applied = true;
1156 1199
 	}
@@ -1168,8 +1211,9 @@  discard block
 block discarded – undo
1168 1211
 	);
1169 1212
 
1170 1213
 	// Temporarily make each setting a modSetting!
1171
-	foreach ($context['signature_settings'] as $key => $value)
1172
-		$modSettings['signature_' . $key] = $value;
1214
+	foreach ($context['signature_settings'] as $key => $value) {
1215
+			$modSettings['signature_' . $key] = $value;
1216
+	}
1173 1217
 
1174 1218
 	// Make sure we check the right tags!
1175 1219
 	$modSettings['bbc_disabled_signature_bbc'] = $disabledTags;
@@ -1181,23 +1225,26 @@  discard block
 block discarded – undo
1181 1225
 
1182 1226
 		// Clean up the tag stuff!
1183 1227
 		$bbcTags = array();
1184
-		foreach (parse_bbc(false) as $tag)
1185
-			$bbcTags[] = $tag['tag'];
1228
+		foreach (parse_bbc(false) as $tag) {
1229
+					$bbcTags[] = $tag['tag'];
1230
+		}
1186 1231
 
1187
-		if (!isset($_POST['signature_bbc_enabledTags']))
1188
-			$_POST['signature_bbc_enabledTags'] = array();
1189
-		elseif (!is_array($_POST['signature_bbc_enabledTags']))
1190
-			$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1232
+		if (!isset($_POST['signature_bbc_enabledTags'])) {
1233
+					$_POST['signature_bbc_enabledTags'] = array();
1234
+		} elseif (!is_array($_POST['signature_bbc_enabledTags'])) {
1235
+					$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1236
+		}
1191 1237
 
1192 1238
 		$sig_limits = array();
1193 1239
 		foreach ($context['signature_settings'] as $key => $value)
1194 1240
 		{
1195
-			if ($key == 'allow_smileys')
1196
-				continue;
1197
-			elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys']))
1198
-				$sig_limits[] = -1;
1199
-			else
1200
-				$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1241
+			if ($key == 'allow_smileys') {
1242
+							continue;
1243
+			} elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) {
1244
+							$sig_limits[] = -1;
1245
+			} else {
1246
+							$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1247
+			}
1201 1248
 		}
1202 1249
 
1203 1250
 		call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags));
@@ -1230,12 +1277,14 @@  discard block
 block discarded – undo
1230 1277
 
1231 1278
 	// Try get more time...
1232 1279
 	@set_time_limit(600);
1233
-	if (function_exists('apache_reset_timeout'))
1234
-		@apache_reset_timeout();
1280
+	if (function_exists('apache_reset_timeout')) {
1281
+			@apache_reset_timeout();
1282
+	}
1235 1283
 
1236 1284
 	// Have we exhausted all the time we allowed?
1237
-	if (time() - array_sum(explode(' ', $sig_start)) < 3)
1238
-		return;
1285
+	if (time() - array_sum(explode(' ', $sig_start)) < 3) {
1286
+			return;
1287
+	}
1239 1288
 
1240 1289
 	$context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1241 1290
 	$context['page_title'] = $txt['not_done_title'];
@@ -1281,9 +1330,10 @@  discard block
 block discarded – undo
1281 1330
 		$disable_fields = array_flip($standard_fields);
1282 1331
 		if (!empty($_POST['active']))
1283 1332
 		{
1284
-			foreach ($_POST['active'] as $value)
1285
-				if (isset($disable_fields[$value]))
1333
+			foreach ($_POST['active'] as $value) {
1334
+							if (isset($disable_fields[$value]))
1286 1335
 					unset($disable_fields[$value]);
1336
+			}
1287 1337
 		}
1288 1338
 		// What we have left!
1289 1339
 		$changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields));
@@ -1292,16 +1342,18 @@  discard block
 block discarded – undo
1292 1342
 		$reg_fields = array();
1293 1343
 		if (!empty($_POST['reg']))
1294 1344
 		{
1295
-			foreach ($_POST['reg'] as $value)
1296
-				if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1345
+			foreach ($_POST['reg'] as $value) {
1346
+							if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1297 1347
 					$reg_fields[] = $value;
1348
+			}
1298 1349
 		}
1299 1350
 		// What we have left!
1300 1351
 		$changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields);
1301 1352
 
1302 1353
 		$_SESSION['adm-save'] = true;
1303
-		if (!empty($changes))
1304
-			updateSettings($changes);
1354
+		if (!empty($changes)) {
1355
+					updateSettings($changes);
1356
+		}
1305 1357
 	}
1306 1358
 
1307 1359
 	createToken('admin-scp');
@@ -1404,11 +1456,13 @@  discard block
 block discarded – undo
1404 1456
 					{
1405 1457
 						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>';
1406 1458
 
1407
-						if ($rowData['field_order'] > 1)
1408
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1459
+						if ($rowData['field_order'] > 1) {
1460
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1461
+						}
1409 1462
 
1410
-						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1411
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1463
+						if ($rowData['field_order'] < $context['custFieldsMaxOrder']) {
1464
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1465
+						}
1412 1466
 
1413 1467
 						$return .= '</p>';
1414 1468
 
@@ -1546,16 +1600,16 @@  discard block
 block discarded – undo
1546 1600
 		$disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
1547 1601
 		$registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
1548 1602
 
1549
-		foreach ($standard_fields as $field)
1550
-			$list[] = array(
1603
+		foreach ($standard_fields as $field) {
1604
+					$list[] = array(
1551 1605
 				'id' => $field,
1552 1606
 				'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field),
1553 1607
 				'disabled' => in_array($field, $disabled_fields),
1554 1608
 				'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration),
1555 1609
 				'can_show_register' => !in_array($field, $fields_no_registration),
1556 1610
 			);
1557
-	}
1558
-	else
1611
+		}
1612
+	} else
1559 1613
 	{
1560 1614
 		// Load all the fields.
1561 1615
 		$request = $smcFunc['db_query']('', '
@@ -1569,8 +1623,9 @@  discard block
 block discarded – undo
1569 1623
 				'items_per_page' => $items_per_page,
1570 1624
 			)
1571 1625
 		);
1572
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1573
-			$list[] = $row;
1626
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1627
+					$list[] = $row;
1628
+		}
1574 1629
 		$smcFunc['db_free_result']($request);
1575 1630
 	}
1576 1631
 
@@ -1636,9 +1691,9 @@  discard block
 block discarded – undo
1636 1691
 		$context['field'] = array();
1637 1692
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1638 1693
 		{
1639
-			if ($row['field_type'] == 'textarea')
1640
-				@list ($rows, $cols) = @explode(',', $row['default_value']);
1641
-			else
1694
+			if ($row['field_type'] == 'textarea') {
1695
+							@list ($rows, $cols) = @explode(',', $row['default_value']);
1696
+			} else
1642 1697
 			{
1643 1698
 				$rows = 3;
1644 1699
 				$cols = 30;
@@ -1674,8 +1729,8 @@  discard block
 block discarded – undo
1674 1729
 	}
1675 1730
 
1676 1731
 	// Setup the default values as needed.
1677
-	if (empty($context['field']))
1678
-		$context['field'] = array(
1732
+	if (empty($context['field'])) {
1733
+			$context['field'] = array(
1679 1734
 			'name' => '',
1680 1735
 			'col_name' => '???',
1681 1736
 			'desc' => '',
@@ -1700,6 +1755,7 @@  discard block
 block discarded – undo
1700 1755
 			'enclose' => '',
1701 1756
 			'placement' => 0,
1702 1757
 		);
1758
+	}
1703 1759
 
1704 1760
 	// Are we moving it?
1705 1761
 	if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to))
@@ -1708,8 +1764,10 @@  discard block
 block discarded – undo
1708 1764
 		$new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1));
1709 1765
 
1710 1766
 		// Is this a valid position?
1711
-		if ($new_order <= 0 || $new_order > $order_count)
1712
-			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1767
+		if ($new_order <= 0 || $new_order > $order_count) {
1768
+					redirectexit('action=admin;area=featuresettings;sa=profile');
1769
+		}
1770
+		// @todo implement an error handler
1713 1771
 
1714 1772
 		// All good, proceed.
1715 1773
 		$smcFunc['db_query']('','
@@ -1740,12 +1798,14 @@  discard block
 block discarded – undo
1740 1798
 		validateToken('admin-ecp');
1741 1799
 
1742 1800
 		// Everyone needs a name - even the (bracket) unknown...
1743
-		if (trim($_POST['field_name']) == '')
1744
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1801
+		if (trim($_POST['field_name']) == '') {
1802
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1803
+		}
1745 1804
 
1746 1805
 		// Regex you say?  Do a very basic test to see if the pattern is valid
1747
-		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false)
1748
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1806
+		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) {
1807
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1808
+		}
1749 1809
 
1750 1810
 		$_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);
1751 1811
 		$_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']);
@@ -1762,8 +1822,9 @@  discard block
 block discarded – undo
1762 1822
 
1763 1823
 		// Some masking stuff...
1764 1824
 		$mask = isset($_POST['mask']) ? $_POST['mask'] : '';
1765
-		if ($mask == 'regex' && isset($_POST['regex']))
1766
-			$mask .= $_POST['regex'];
1825
+		if ($mask == 'regex' && isset($_POST['regex'])) {
1826
+					$mask .= $_POST['regex'];
1827
+		}
1767 1828
 
1768 1829
 		$field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255;
1769 1830
 		$enclose = isset($_POST['enclose']) ? $_POST['enclose'] : '';
@@ -1782,8 +1843,9 @@  discard block
 block discarded – undo
1782 1843
 				$v = strtr($v, array(',' => ''));
1783 1844
 
1784 1845
 				// Nada, zip, etc...
1785
-				if (trim($v) == '')
1786
-					continue;
1846
+				if (trim($v) == '') {
1847
+									continue;
1848
+				}
1787 1849
 
1788 1850
 				// Otherwise, save it boy.
1789 1851
 				$field_options .= $v . ',';
@@ -1791,15 +1853,17 @@  discard block
 block discarded – undo
1791 1853
 				$newOptions[$k] = $v;
1792 1854
 
1793 1855
 				// Is it default?
1794
-				if (isset($_POST['default_select']) && $_POST['default_select'] == $k)
1795
-					$default = $v;
1856
+				if (isset($_POST['default_select']) && $_POST['default_select'] == $k) {
1857
+									$default = $v;
1858
+				}
1796 1859
 			}
1797 1860
 			$field_options = substr($field_options, 0, -1);
1798 1861
 		}
1799 1862
 
1800 1863
 		// Text area has default has dimensions
1801
-		if ($_POST['field_type'] == 'textarea')
1802
-			$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1864
+		if ($_POST['field_type'] == 'textarea') {
1865
+					$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1866
+		}
1803 1867
 
1804 1868
 		// Come up with the unique name?
1805 1869
 		if (empty($context['fid']))
@@ -1808,32 +1872,36 @@  discard block
 block discarded – undo
1808 1872
 			preg_match('~([\w\d_-]+)~', $col_name, $matches);
1809 1873
 
1810 1874
 			// If there is nothing to the name, then let's start out own - for foreign languages etc.
1811
-			if (isset($matches[1]))
1812
-				$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1813
-			else
1814
-				$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1875
+			if (isset($matches[1])) {
1876
+							$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1877
+			} else {
1878
+							$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1879
+			}
1815 1880
 
1816 1881
 			// Make sure this is unique.
1817 1882
 			$current_fields = array();
1818 1883
 			$request = $smcFunc['db_query']('', '
1819 1884
 				SELECT id_field, col_name
1820 1885
 				FROM {db_prefix}custom_fields');
1821
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1822
-				$current_fields[$row['id_field']] = $row['col_name'];
1886
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1887
+							$current_fields[$row['id_field']] = $row['col_name'];
1888
+			}
1823 1889
 			$smcFunc['db_free_result']($request);
1824 1890
 
1825 1891
 			$unique = false;
1826 1892
 			for ($i = 0; !$unique && $i < 9; $i ++)
1827 1893
 			{
1828
-				if (!in_array($col_name, $current_fields))
1829
-					$unique = true;
1830
-				else
1831
-					$col_name = $initial_col_name . $i;
1894
+				if (!in_array($col_name, $current_fields)) {
1895
+									$unique = true;
1896
+				} else {
1897
+									$col_name = $initial_col_name . $i;
1898
+				}
1832 1899
 			}
1833 1900
 
1834 1901
 			// Still not a unique column name? Leave it up to the user, then.
1835
-			if (!$unique)
1836
-				fatal_lang_error('custom_option_not_unique');
1902
+			if (!$unique) {
1903
+							fatal_lang_error('custom_option_not_unique');
1904
+			}
1837 1905
 		}
1838 1906
 		// Work out what to do with the user data otherwise...
1839 1907
 		else
@@ -1861,8 +1929,9 @@  discard block
 block discarded – undo
1861 1929
 				// Work out what's changed!
1862 1930
 				foreach ($context['field']['options'] as $k => $option)
1863 1931
 				{
1864
-					if (trim($option) == '')
1865
-						continue;
1932
+					if (trim($option) == '') {
1933
+											continue;
1934
+					}
1866 1935
 
1867 1936
 					// Still exists?
1868 1937
 					if (in_array($option, $newOptions))
@@ -1876,8 +1945,8 @@  discard block
 block discarded – undo
1876 1945
 				foreach ($optionChanges as $k => $option)
1877 1946
 				{
1878 1947
 					// Just been renamed?
1879
-					if (!in_array($k, $takenKeys) && !empty($newOptions[$k]))
1880
-						$smcFunc['db_query']('', '
1948
+					if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) {
1949
+											$smcFunc['db_query']('', '
1881 1950
 							UPDATE {db_prefix}themes
1882 1951
 							SET value = {string:new_value}
1883 1952
 							WHERE variable = {string:current_column}
@@ -1890,6 +1959,7 @@  discard block
 block discarded – undo
1890 1959
 								'old_value' => $option,
1891 1960
 							)
1892 1961
 						);
1962
+					}
1893 1963
 				}
1894 1964
 			}
1895 1965
 			// @todo Maybe we should adjust based on new text length limits?
@@ -1932,8 +2002,8 @@  discard block
 block discarded – undo
1932 2002
 			);
1933 2003
 
1934 2004
 			// Just clean up any old selects - these are a pain!
1935
-			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions))
1936
-				$smcFunc['db_query']('', '
2005
+			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) {
2006
+							$smcFunc['db_query']('', '
1937 2007
 					DELETE FROM {db_prefix}themes
1938 2008
 					WHERE variable = {string:current_column}
1939 2009
 						AND value NOT IN ({array_string:new_option_values})
@@ -1944,8 +2014,8 @@  discard block
 block discarded – undo
1944 2014
 						'current_column' => $context['field']['col_name'],
1945 2015
 					)
1946 2016
 				);
1947
-		}
1948
-		else
2017
+			}
2018
+		} else
1949 2019
 		{
1950 2020
 			// Gotta figure it out the order.
1951 2021
 			$new_order = $order_count > 1 ? ($order_count + 1) : 1;
@@ -2120,11 +2190,13 @@  discard block
 block discarded – undo
2120 2190
 	call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false));
2121 2191
 
2122 2192
 	$prune_toggle_dt = array();
2123
-	foreach ($prune_toggle as $item)
2124
-		$prune_toggle_dt[] = 'setting_' . $item;
2193
+	foreach ($prune_toggle as $item) {
2194
+			$prune_toggle_dt[] = 'setting_' . $item;
2195
+	}
2125 2196
 
2126
-	if ($return_config)
2127
-		return $config_vars;
2197
+	if ($return_config) {
2198
+			return $config_vars;
2199
+	}
2128 2200
 
2129 2201
 	addInlineJavaScript('
2130 2202
 	function togglePruned()
@@ -2162,15 +2234,16 @@  discard block
 block discarded – undo
2162 2234
 			$vals = array();
2163 2235
 			foreach ($config_vars as $index => $dummy)
2164 2236
 			{
2165
-				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle))
2166
-					continue;
2237
+				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) {
2238
+									continue;
2239
+				}
2167 2240
 
2168 2241
 				$vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
2169 2242
 			}
2170 2243
 			$_POST['pruningOptions'] = implode(',', $vals);
2244
+		} else {
2245
+					$_POST['pruningOptions'] = '';
2171 2246
 		}
2172
-		else
2173
-			$_POST['pruningOptions'] = '';
2174 2247
 
2175 2248
 		saveDBSettings($savevar);
2176 2249
 		$_SESSION['adm-save'] = true;
@@ -2182,10 +2255,11 @@  discard block
 block discarded – undo
2182 2255
 	$context['sub_template'] = 'show_settings';
2183 2256
 
2184 2257
 	// Get the actual values
2185
-	if (!empty($modSettings['pruningOptions']))
2186
-		@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2187
-	else
2188
-		$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2258
+	if (!empty($modSettings['pruningOptions'])) {
2259
+			@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2260
+	} else {
2261
+			$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2262
+	}
2189 2263
 
2190 2264
 	prepareDBSettingContext($config_vars);
2191 2265
 }
@@ -2207,8 +2281,9 @@  discard block
 block discarded – undo
2207 2281
 	// Make it even easier to add new settings.
2208 2282
 	call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
2209 2283
 
2210
-	if ($return_config)
2211
-		return $config_vars;
2284
+	if ($return_config) {
2285
+			return $config_vars;
2286
+	}
2212 2287
 
2213 2288
 	$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general';
2214 2289
 	$context['settings_title'] = $txt['mods_cat_modifications_misc'];
Please login to merge, or discard this patch.
Sources/ScheduledTasks.php 1 patch
Braces   +280 added lines, -203 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
  * This function works out what to do!
@@ -24,9 +25,9 @@  discard block
 block discarded – undo
24 25
 	global $time_start, $smcFunc;
25 26
 
26 27
 	// Special case for doing the mail queue.
27
-	if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq')
28
-		ReduceMailQueue();
29
-	else
28
+	if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') {
29
+			ReduceMailQueue();
30
+	} else
30 31
 	{
31 32
 		$task_string = '';
32 33
 
@@ -53,18 +54,20 @@  discard block
 block discarded – undo
53 54
 
54 55
 			// How long in seconds it the gap?
55 56
 			$duration = $row['time_regularity'];
56
-			if ($row['time_unit'] == 'm')
57
-				$duration *= 60;
58
-			elseif ($row['time_unit'] == 'h')
59
-				$duration *= 3600;
60
-			elseif ($row['time_unit'] == 'd')
61
-				$duration *= 86400;
62
-			elseif ($row['time_unit'] == 'w')
63
-				$duration *= 604800;
57
+			if ($row['time_unit'] == 'm') {
58
+							$duration *= 60;
59
+			} elseif ($row['time_unit'] == 'h') {
60
+							$duration *= 3600;
61
+			} elseif ($row['time_unit'] == 'd') {
62
+							$duration *= 86400;
63
+			} elseif ($row['time_unit'] == 'w') {
64
+							$duration *= 604800;
65
+			}
64 66
 
65 67
 			// If we were really late running this task actually skip the next one.
66
-			if (time() + ($duration / 2) > $next_time)
67
-				$next_time += $duration;
68
+			if (time() + ($duration / 2) > $next_time) {
69
+							$next_time += $duration;
70
+			}
68 71
 
69 72
 			// Update it now, so no others run this!
70 73
 			$smcFunc['db_query']('', '
@@ -81,16 +84,19 @@  discard block
 block discarded – undo
81 84
 			$affected_rows = $smcFunc['db_affected_rows']();
82 85
 
83 86
 			// What kind of task are we handling?
84
-			if (!empty($row['callable']))
85
-				$task_string = $row['callable'];
87
+			if (!empty($row['callable'])) {
88
+							$task_string = $row['callable'];
89
+			}
86 90
 
87 91
 			// Default SMF task or old mods?
88
-			elseif (function_exists('scheduled_' . $row['task']))
89
-				$task_string = 'scheduled_' . $row['task'];
92
+			elseif (function_exists('scheduled_' . $row['task'])) {
93
+							$task_string = 'scheduled_' . $row['task'];
94
+			}
90 95
 
91 96
 			// One last resource, the task name.
92
-			elseif (!empty($row['task']))
93
-				$task_string = $row['task'];
97
+			elseif (!empty($row['task'])) {
98
+							$task_string = $row['task'];
99
+			}
94 100
 
95 101
 			// The function must exist or we are wasting our time, plus do some timestamp checking, and database check!
96 102
 			if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows)
@@ -101,11 +107,11 @@  discard block
 block discarded – undo
101 107
 				$callable_task = call_helper($task_string, true);
102 108
 
103 109
 				// Perform the task.
104
-				if (!empty($callable_task))
105
-					$completed = call_user_func($callable_task);
106
-
107
-				else
108
-					$completed = false;
110
+				if (!empty($callable_task)) {
111
+									$completed = call_user_func($callable_task);
112
+				} else {
113
+									$completed = false;
114
+				}
109 115
 
110 116
 				// Log that we did it ;)
111 117
 				if ($completed)
@@ -138,18 +144,20 @@  discard block
 block discarded – undo
138 144
 			)
139 145
 		);
140 146
 		// No new task scheduled yet?
141
-		if ($smcFunc['db_num_rows']($request) === 0)
142
-			$nextEvent = time() + 86400;
143
-		else
144
-			list ($nextEvent) = $smcFunc['db_fetch_row']($request);
147
+		if ($smcFunc['db_num_rows']($request) === 0) {
148
+					$nextEvent = time() + 86400;
149
+		} else {
150
+					list ($nextEvent) = $smcFunc['db_fetch_row']($request);
151
+		}
145 152
 		$smcFunc['db_free_result']($request);
146 153
 
147 154
 		updateSettings(array('next_task_time' => $nextEvent));
148 155
 	}
149 156
 
150 157
 	// Shall we return?
151
-	if (!isset($_GET['scheduled']))
152
-		return true;
158
+	if (!isset($_GET['scheduled'])) {
159
+			return true;
160
+	}
153 161
 
154 162
 	// Finally, send some stuff...
155 163
 	header('expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -181,16 +189,18 @@  discard block
 block discarded – undo
181 189
 	while ($row = $smcFunc['db_fetch_assoc']($request))
182 190
 	{
183 191
 		// If this is no longer around we'll ignore it.
184
-		if (empty($row['id_topic']))
185
-			continue;
192
+		if (empty($row['id_topic'])) {
193
+					continue;
194
+		}
186 195
 
187 196
 		// What type is it?
188
-		if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg'])
189
-			$type = 'topic';
190
-		elseif ($row['id_attach'])
191
-			$type = 'attach';
192
-		else
193
-			$type = 'msg';
197
+		if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) {
198
+					$type = 'topic';
199
+		} elseif ($row['id_attach']) {
200
+					$type = 'attach';
201
+		} else {
202
+					$type = 'msg';
203
+		}
194 204
 
195 205
 		// Add it to the array otherwise.
196 206
 		$notices[$row['id_board']][$type][] = array(
@@ -211,8 +221,9 @@  discard block
 block discarded – undo
211 221
 	);
212 222
 
213 223
 	// If nothing quit now.
214
-	if (empty($notices))
215
-		return true;
224
+	if (empty($notices)) {
225
+			return true;
226
+	}
216 227
 
217 228
 	// Now we need to think about finding out *who* can approve - this is hard!
218 229
 
@@ -231,14 +242,16 @@  discard block
 block discarded – undo
231 242
 	while ($row = $smcFunc['db_fetch_assoc']($request))
232 243
 	{
233 244
 		// Sorry guys, but we have to ignore guests AND members - it would be too many otherwise.
234
-		if ($row['id_group'] < 2)
235
-			continue;
245
+		if ($row['id_group'] < 2) {
246
+					continue;
247
+		}
236 248
 
237 249
 		$perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group'];
238 250
 
239 251
 		// Anyone who can access has to be considered.
240
-		if ($row['add_deny'])
241
-			$addGroups[] = $row['id_group'];
252
+		if ($row['add_deny']) {
253
+					$addGroups[] = $row['id_group'];
254
+		}
242 255
 	}
243 256
 	$smcFunc['db_free_result']($request);
244 257
 
@@ -283,8 +296,9 @@  discard block
 block discarded – undo
283 296
 		if (!empty($row['mod_prefs']))
284 297
 		{
285 298
 			list(,, $pref_binary) = explode('|', $row['mod_prefs']);
286
-			if (!($pref_binary & 4))
287
-				continue;
299
+			if (!($pref_binary & 4)) {
300
+							continue;
301
+			}
288 302
 		}
289 303
 
290 304
 		$members[$row['id_member']] = array(
@@ -309,8 +323,9 @@  discard block
 block discarded – undo
309 323
 		$emailbody = '';
310 324
 
311 325
 		// Load the language file as required.
312
-		if (empty($current_language) || $current_language != $member['language'])
313
-			$current_language = loadLanguage('EmailTemplates', $member['language'], false);
326
+		if (empty($current_language) || $current_language != $member['language']) {
327
+					$current_language = loadLanguage('EmailTemplates', $member['language'], false);
328
+		}
314 329
 
315 330
 		// Loop through each notice...
316 331
 		foreach ($notices as $board => $notice)
@@ -318,29 +333,34 @@  discard block
 block discarded – undo
318 333
 			$access = false;
319 334
 
320 335
 			// Can they mod in this board?
321
-			if (isset($mods[$id][$board]))
322
-				$access = true;
336
+			if (isset($mods[$id][$board])) {
337
+							$access = true;
338
+			}
323 339
 
324 340
 			// Do the group check...
325 341
 			if (!$access && isset($perms[$profiles[$board]]['add']))
326 342
 			{
327 343
 				// They can access?!
328
-				if (array_intersect($perms[$profiles[$board]]['add'], $member['groups']))
329
-					$access = true;
344
+				if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) {
345
+									$access = true;
346
+				}
330 347
 
331 348
 				// If they have deny rights don't consider them!
332
-				if (isset($perms[$profiles[$board]]['deny']))
333
-					if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups']))
349
+				if (isset($perms[$profiles[$board]]['deny'])) {
350
+									if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups']))
334 351
 						$access = false;
352
+				}
335 353
 			}
336 354
 
337 355
 			// Finally, fix it for admins!
338
-			if (in_array(1, $member['groups']))
339
-				$access = true;
356
+			if (in_array(1, $member['groups'])) {
357
+							$access = true;
358
+			}
340 359
 
341 360
 			// If they can't access it then give it a break!
342
-			if (!$access)
343
-				continue;
361
+			if (!$access) {
362
+							continue;
363
+			}
344 364
 
345 365
 			foreach ($notice as $type => $items)
346 366
 			{
@@ -348,15 +368,17 @@  discard block
 block discarded – undo
348 368
 				$emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" .
349 369
 					'------------------------------------------------------' . "\n";
350 370
 
351
-				foreach ($items as $item)
352
-					$emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n";
371
+				foreach ($items as $item) {
372
+									$emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n";
373
+				}
353 374
 
354 375
 				$emailbody .= "\n";
355 376
 			}
356 377
 		}
357 378
 
358
-		if ($emailbody == '')
359
-			continue;
379
+		if ($emailbody == '') {
380
+					continue;
381
+		}
360 382
 
361 383
 		$replacements = array(
362 384
 			'REALNAME' => $member['name'],
@@ -397,8 +419,9 @@  discard block
 block discarded – undo
397 419
 			)
398 420
 		);
399 421
 		$members = array();
400
-		while ($row = $smcFunc['db_fetch_assoc']($request))
401
-			$members[$row['id_member']] = $row['warning'];
422
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
423
+					$members[$row['id_member']] = $row['warning'];
424
+		}
402 425
 		$smcFunc['db_free_result']($request);
403 426
 
404 427
 		// Have some members to check?
@@ -420,17 +443,18 @@  discard block
 block discarded – undo
420 443
 			while ($row = $smcFunc['db_fetch_assoc']($request))
421 444
 			{
422 445
 				// More than 24 hours ago?
423
-				if ($row['last_warning'] <= time() - 86400)
424
-					$member_changes[] = array(
446
+				if ($row['last_warning'] <= time() - 86400) {
447
+									$member_changes[] = array(
425 448
 						'id' => $row['id_recipient'],
426 449
 						'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0,
427 450
 					);
451
+				}
428 452
 			}
429 453
 			$smcFunc['db_free_result']($request);
430 454
 
431 455
 			// Have some members to change?
432
-			if (!empty($member_changes))
433
-				foreach ($member_changes as $change)
456
+			if (!empty($member_changes)) {
457
+							foreach ($member_changes as $change)
434 458
 					$smcFunc['db_query']('', '
435 459
 						UPDATE {db_prefix}members
436 460
 						SET warning = {int:warning}
@@ -440,6 +464,7 @@  discard block
 block discarded – undo
440 464
 							'id_member' => $change['id'],
441 465
 						)
442 466
 					);
467
+			}
443 468
 		}
444 469
 	}
445 470
 
@@ -519,15 +544,17 @@  discard block
 block discarded – undo
519 544
 
520 545
 		// Store this useful data!
521 546
 		$boards[$row['id_board']] = $row['id_board'];
522
-		if ($row['id_topic'])
523
-			$notify['topics'][$row['id_topic']][] = $row['id_member'];
524
-		else
525
-			$notify['boards'][$row['id_board']][] = $row['id_member'];
547
+		if ($row['id_topic']) {
548
+					$notify['topics'][$row['id_topic']][] = $row['id_member'];
549
+		} else {
550
+					$notify['boards'][$row['id_board']][] = $row['id_member'];
551
+		}
526 552
 	}
527 553
 	$smcFunc['db_free_result']($request);
528 554
 
529
-	if (empty($boards))
530
-		return true;
555
+	if (empty($boards)) {
556
+			return true;
557
+	}
531 558
 
532 559
 	// Just get the board names.
533 560
 	$request = $smcFunc['db_query']('', '
@@ -539,12 +566,14 @@  discard block
 block discarded – undo
539 566
 		)
540 567
 	);
541 568
 	$boards = array();
542
-	while ($row = $smcFunc['db_fetch_assoc']($request))
543
-		$boards[$row['id_board']] = $row['name'];
569
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
570
+			$boards[$row['id_board']] = $row['name'];
571
+	}
544 572
 	$smcFunc['db_free_result']($request);
545 573
 
546
-	if (empty($boards))
547
-		return true;
574
+	if (empty($boards)) {
575
+			return true;
576
+	}
548 577
 
549 578
 	// Get the actual topics...
550 579
 	$request = $smcFunc['db_query']('', '
@@ -564,52 +593,57 @@  discard block
 block discarded – undo
564 593
 	$types = array();
565 594
 	while ($row = $smcFunc['db_fetch_assoc']($request))
566 595
 	{
567
-		if (!isset($types[$row['note_type']][$row['id_board']]))
568
-			$types[$row['note_type']][$row['id_board']] = array(
596
+		if (!isset($types[$row['note_type']][$row['id_board']])) {
597
+					$types[$row['note_type']][$row['id_board']] = array(
569 598
 				'lines' => array(),
570 599
 				'name' => $row['board_name'],
571 600
 				'id' => $row['id_board'],
572 601
 			);
602
+		}
573 603
 
574 604
 		if ($row['note_type'] == 'reply')
575 605
 		{
576
-			if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
577
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
578
-			else
579
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
606
+			if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
607
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
608
+			} else {
609
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
580 610
 					'id' => $row['id_topic'],
581 611
 					'subject' => un_htmlspecialchars($row['subject']),
582 612
 					'count' => 1,
583 613
 				);
584
-		}
585
-		elseif ($row['note_type'] == 'topic')
614
+			}
615
+		} elseif ($row['note_type'] == 'topic')
586 616
 		{
587
-			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
588
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
617
+			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
618
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
589 619
 					'id' => $row['id_topic'],
590 620
 					'subject' => un_htmlspecialchars($row['subject']),
591 621
 				);
592
-		}
593
-		else
622
+			}
623
+		} else
594 624
 		{
595
-			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
596
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
625
+			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
626
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
597 627
 					'id' => $row['id_topic'],
598 628
 					'subject' => un_htmlspecialchars($row['subject']),
599 629
 					'starter' => $row['id_member_started'],
600 630
 				);
631
+			}
601 632
 		}
602 633
 
603 634
 		$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array();
604
-		if (!empty($notify['topics'][$row['id_topic']]))
605
-			$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]);
606
-		if (!empty($notify['boards'][$row['id_board']]))
607
-			$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]);
635
+		if (!empty($notify['topics'][$row['id_topic']])) {
636
+					$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]);
637
+		}
638
+		if (!empty($notify['boards'][$row['id_board']])) {
639
+					$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]);
640
+		}
608 641
 	}
609 642
 	$smcFunc['db_free_result']($request);
610 643
 
611
-	if (empty($types))
612
-		return true;
644
+	if (empty($types)) {
645
+			return true;
646
+	}
613 647
 
614 648
 	// Let's load all the languages into a cache thingy.
615 649
 	$langtxt = array();
@@ -650,8 +684,9 @@  discard block
 block discarded – undo
650 684
 		$notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1;
651 685
 
652 686
 		// Did they not elect to choose this?
653
-		if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4)
654
-			continue;
687
+		if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) {
688
+					continue;
689
+		}
655 690
 
656 691
 		// Right character set!
657 692
 		$context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set'];
@@ -667,39 +702,43 @@  discard block
 block discarded – undo
667 702
 		if (isset($types['topic']))
668 703
 		{
669 704
 			$titled = false;
670
-			foreach ($types['topic'] as $id => $board)
671
-				foreach ($board['lines'] as $topic)
705
+			foreach ($types['topic'] as $id => $board) {
706
+							foreach ($board['lines'] as $topic)
672 707
 					if (in_array($mid, $topic['members']))
673 708
 					{
674 709
 						if (!$titled)
675 710
 						{
676 711
 							$email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------';
712
+			}
677 713
 							$titled = true;
678 714
 						}
679 715
 						$email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']);
680 716
 					}
681
-			if ($titled)
682
-				$email['body'] .= "\n";
717
+			if ($titled) {
718
+							$email['body'] .= "\n";
719
+			}
683 720
 		}
684 721
 
685 722
 		// What about replies?
686 723
 		if (isset($types['reply']))
687 724
 		{
688 725
 			$titled = false;
689
-			foreach ($types['reply'] as $id => $board)
690
-				foreach ($board['lines'] as $topic)
726
+			foreach ($types['reply'] as $id => $board) {
727
+							foreach ($board['lines'] as $topic)
691 728
 					if (in_array($mid, $topic['members']))
692 729
 					{
693 730
 						if (!$titled)
694 731
 						{
695 732
 							$email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------';
733
+			}
696 734
 							$titled = true;
697 735
 						}
698 736
 						$email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject']));
699 737
 					}
700 738
 
701
-			if ($titled)
702
-				$email['body'] .= "\n";
739
+			if ($titled) {
740
+							$email['body'] .= "\n";
741
+			}
703 742
 		}
704 743
 
705 744
 		// Finally, moderation actions!
@@ -708,24 +747,27 @@  discard block
 block discarded – undo
708 747
 			$titled = false;
709 748
 			foreach ($types as $note_type => $type)
710 749
 			{
711
-				if ($note_type == 'topic' || $note_type == 'reply')
712
-					continue;
750
+				if ($note_type == 'topic' || $note_type == 'reply') {
751
+									continue;
752
+				}
713 753
 
714
-				foreach ($type as $id => $board)
715
-					foreach ($board['lines'] as $topic)
754
+				foreach ($type as $id => $board) {
755
+									foreach ($board['lines'] as $topic)
716 756
 						if (in_array($mid, $topic['members']))
717 757
 						{
718 758
 							if (!$titled)
719 759
 							{
720 760
 								$email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------';
761
+				}
721 762
 								$titled = true;
722 763
 							}
723 764
 							$email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']);
724 765
 						}
725 766
 			}
726 767
 		}
727
-		if ($titled)
728
-			$email['body'] .= "\n";
768
+		if ($titled) {
769
+					$email['body'] .= "\n";
770
+		}
729 771
 
730 772
 		// Then just say our goodbyes!
731 773
 		$email['body'] .= "\n\n" . $txt['regards_team'];
@@ -753,8 +795,7 @@  discard block
 block discarded – undo
753 795
 				'not_daily' => 0,
754 796
 			)
755 797
 		);
756
-	}
757
-	else
798
+	} else
758 799
 	{
759 800
 		// Clear any only weekly ones, and stop us from sending daily again.
760 801
 		$smcFunc['db_query']('', '
@@ -816,16 +857,19 @@  discard block
 block discarded – undo
816 857
 	global $modSettings, $smcFunc, $sourcedir;
817 858
 
818 859
 	// Are we intending another script to be sending out the queue?
819
-	if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send))
820
-		return false;
860
+	if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) {
861
+			return false;
862
+	}
821 863
 
822 864
 	// By default send 5 at once.
823
-	if (!$number)
824
-		$number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
865
+	if (!$number) {
866
+			$number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
867
+	}
825 868
 
826 869
 	// If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us.
827
-	if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send))
828
-		return false;
870
+	if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) {
871
+			return false;
872
+	}
829 873
 
830 874
 	// By default move the next sending on by 10 seconds, and require an affected row.
831 875
 	if (!$override_limit)
@@ -842,8 +886,9 @@  discard block
 block discarded – undo
842 886
 				'last_send' => $modSettings['mail_next_send'],
843 887
 			)
844 888
 		);
845
-		if ($smcFunc['db_affected_rows']() == 0)
846
-			return false;
889
+		if ($smcFunc['db_affected_rows']() == 0) {
890
+					return false;
891
+		}
847 892
 		$modSettings['mail_next_send'] = time() + $delay;
848 893
 	}
849 894
 
@@ -864,8 +909,9 @@  discard block
 block discarded – undo
864 909
 			$mn += $number;
865 910
 		}
866 911
 		// No more I'm afraid, return!
867
-		else
868
-			return false;
912
+		else {
913
+					return false;
914
+		}
869 915
 
870 916
 		// Reflect that we're about to send some, do it now to be safe.
871 917
 		updateSettings(array('mail_recent' => $mt . '|' . $mn));
@@ -900,14 +946,15 @@  discard block
 block discarded – undo
900 946
 	$smcFunc['db_free_result']($request);
901 947
 
902 948
 	// Delete, delete, delete!!!
903
-	if (!empty($ids))
904
-		$smcFunc['db_query']('', '
949
+	if (!empty($ids)) {
950
+			$smcFunc['db_query']('', '
905 951
 			DELETE FROM {db_prefix}mail_queue
906 952
 			WHERE id_mail IN ({array_int:mail_list})',
907 953
 			array(
908 954
 				'mail_list' => $ids,
909 955
 			)
910 956
 		);
957
+	}
911 958
 
912 959
 	// Don't believe we have any left?
913 960
 	if (count($ids) < $number)
@@ -925,11 +972,13 @@  discard block
 block discarded – undo
925 972
 		);
926 973
 	}
927 974
 
928
-	if (empty($ids))
929
-		return false;
975
+	if (empty($ids)) {
976
+			return false;
977
+	}
930 978
 
931
-	if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '')
932
-		require_once($sourcedir . '/Subs-Post.php');
979
+	if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') {
980
+			require_once($sourcedir . '/Subs-Post.php');
981
+	}
933 982
 
934 983
 	// Send each email, yea!
935 984
 	$failed_emails = array();
@@ -949,15 +998,17 @@  discard block
 block discarded – undo
949 998
 
950 999
 			// Try to stop a timeout, this would be bad...
951 1000
 			@set_time_limit(300);
952
-			if (function_exists('apache_reset_timeout'))
953
-				@apache_reset_timeout();
1001
+			if (function_exists('apache_reset_timeout')) {
1002
+							@apache_reset_timeout();
1003
+			}
1004
+		} else {
1005
+					$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']);
954 1006
 		}
955
-		else
956
-			$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']);
957 1007
 
958 1008
 		// Hopefully it sent?
959
-		if (!$result)
960
-			$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
1009
+		if (!$result) {
1010
+					$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
1011
+		}
961 1012
 	}
962 1013
 
963 1014
 	// Any emails that didn't send?
@@ -972,8 +1023,8 @@  discard block
 block discarded – undo
972 1023
 		);
973 1024
 
974 1025
 		// If we have failed to many times, tell mail to wait a bit and try again.
975
-		if ($modSettings['mail_failed_attempts'] > 5)
976
-			$smcFunc['db_query']('', '
1026
+		if ($modSettings['mail_failed_attempts'] > 5) {
1027
+					$smcFunc['db_query']('', '
977 1028
 				UPDATE {db_prefix}settings
978 1029
 				SET value = {string:next_mail_send}
979 1030
 				WHERE variable = {literal:mail_next_send}
@@ -982,6 +1033,7 @@  discard block
 block discarded – undo
982 1033
 					'next_mail_send' => time() + 60,
983 1034
 					'last_send' => $modSettings['mail_next_send'],
984 1035
 			));
1036
+		}
985 1037
 
986 1038
 		// Add our email back to the queue, manually.
987 1039
 		$smcFunc['db_insert']('insert',
@@ -994,8 +1046,8 @@  discard block
 block discarded – undo
994 1046
 		return false;
995 1047
 	}
996 1048
 	// We where unable to send the email, clear our failed attempts.
997
-	elseif (!empty($modSettings['mail_failed_attempts']))
998
-		$smcFunc['db_query']('', '
1049
+	elseif (!empty($modSettings['mail_failed_attempts'])) {
1050
+			$smcFunc['db_query']('', '
999 1051
 			UPDATE {db_prefix}settings
1000 1052
 			SET value = {string:zero}
1001 1053
 			WHERE variable = {string:mail_failed_attempts}',
@@ -1003,6 +1055,7 @@  discard block
 block discarded – undo
1003 1055
 				'zero' => '0',
1004 1056
 				'mail_failed_attempts' => 'mail_failed_attempts',
1005 1057
 		));
1058
+	}
1006 1059
 
1007 1060
 	// Had something to send...
1008 1061
 	return true;
@@ -1019,16 +1072,18 @@  discard block
 block discarded – undo
1019 1072
 	global $modSettings, $smcFunc;
1020 1073
 
1021 1074
 	$task_query = '';
1022
-	if (!is_array($tasks))
1023
-		$tasks = array($tasks);
1075
+	if (!is_array($tasks)) {
1076
+			$tasks = array($tasks);
1077
+	}
1024 1078
 
1025 1079
 	// Actually have something passed?
1026 1080
 	if (!empty($tasks))
1027 1081
 	{
1028
-		if (!isset($tasks[0]) || is_numeric($tasks[0]))
1029
-			$task_query = ' AND id_task IN ({array_int:tasks})';
1030
-		else
1031
-			$task_query = ' AND task IN ({array_string:tasks})';
1082
+		if (!isset($tasks[0]) || is_numeric($tasks[0])) {
1083
+					$task_query = ' AND id_task IN ({array_int:tasks})';
1084
+		} else {
1085
+					$task_query = ' AND task IN ({array_string:tasks})';
1086
+		}
1032 1087
 	}
1033 1088
 	$nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time'];
1034 1089
 
@@ -1049,20 +1104,22 @@  discard block
 block discarded – undo
1049 1104
 		$next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']);
1050 1105
 
1051 1106
 		// Only bother moving the task if it's out of place or we're forcing it!
1052
-		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time())
1053
-			$tasks[$row['id_task']] = $next_time;
1054
-		else
1055
-			$next_time = $row['next_time'];
1107
+		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) {
1108
+					$tasks[$row['id_task']] = $next_time;
1109
+		} else {
1110
+					$next_time = $row['next_time'];
1111
+		}
1056 1112
 
1057 1113
 		// If this is sooner than the current next task, make this the next task.
1058
-		if ($next_time < $nextTaskTime)
1059
-			$nextTaskTime = $next_time;
1114
+		if ($next_time < $nextTaskTime) {
1115
+					$nextTaskTime = $next_time;
1116
+		}
1060 1117
 	}
1061 1118
 	$smcFunc['db_free_result']($request);
1062 1119
 
1063 1120
 	// Now make the changes!
1064
-	foreach ($tasks as $id => $time)
1065
-		$smcFunc['db_query']('', '
1121
+	foreach ($tasks as $id => $time) {
1122
+			$smcFunc['db_query']('', '
1066 1123
 			UPDATE {db_prefix}scheduled_tasks
1067 1124
 			SET next_time = {int:next_time}
1068 1125
 			WHERE id_task = {int:id_task}',
@@ -1071,11 +1128,13 @@  discard block
 block discarded – undo
1071 1128
 				'id_task' => $id,
1072 1129
 			)
1073 1130
 		);
1131
+	}
1074 1132
 
1075 1133
 	// If the next task is now different update.
1076
-	if ($modSettings['next_task_time'] != $nextTaskTime)
1077
-		updateSettings(array('next_task_time' => $nextTaskTime));
1078
-}
1134
+	if ($modSettings['next_task_time'] != $nextTaskTime) {
1135
+			updateSettings(array('next_task_time' => $nextTaskTime));
1136
+	}
1137
+	}
1079 1138
 
1080 1139
 /**
1081 1140
  * Simply returns a time stamp of the next instance of these time parameters.
@@ -1088,8 +1147,9 @@  discard block
 block discarded – undo
1088 1147
 function next_time($regularity, $unit, $offset)
1089 1148
 {
1090 1149
 	// Just in case!
1091
-	if ($regularity == 0)
1092
-		$regularity = 2;
1150
+	if ($regularity == 0) {
1151
+			$regularity = 2;
1152
+	}
1093 1153
 
1094 1154
 	$curMin = date('i', time());
1095 1155
 
@@ -1099,15 +1159,16 @@  discard block
 block discarded – undo
1099 1159
 		$off = date('i', $offset);
1100 1160
 
1101 1161
 		// If it's now just pretend it ain't,
1102
-		if ($off == $curMin)
1103
-			$next_time = time() + $regularity;
1104
-		else
1162
+		if ($off == $curMin) {
1163
+					$next_time = time() + $regularity;
1164
+		} else
1105 1165
 		{
1106 1166
 			// Make sure that the offset is always in the past.
1107 1167
 			$off = $off > $curMin ? $off - 60 : $off;
1108 1168
 
1109
-			while ($off <= $curMin)
1110
-				$off += $regularity;
1169
+			while ($off <= $curMin) {
1170
+							$off += $regularity;
1171
+			}
1111 1172
 
1112 1173
 			// Now we know when the time should be!
1113 1174
 			$next_time = time() + 60 * ($off - $curMin);
@@ -1127,11 +1188,13 @@  discard block
 block discarded – undo
1127 1188
 		// Default we'll jump in hours.
1128 1189
 		$applyOffset = 3600;
1129 1190
 		// 24 hours = 1 day.
1130
-		if ($unit == 'd')
1131
-			$applyOffset = 86400;
1191
+		if ($unit == 'd') {
1192
+					$applyOffset = 86400;
1193
+		}
1132 1194
 		// Otherwise a week.
1133
-		if ($unit == 'w')
1134
-			$applyOffset = 604800;
1195
+		if ($unit == 'w') {
1196
+					$applyOffset = 604800;
1197
+		}
1135 1198
 
1136 1199
 		$applyOffset *= $regularity;
1137 1200
 
@@ -1168,8 +1231,9 @@  discard block
 block discarded – undo
1168 1231
 		$settings[$row['variable']] = $row['value'];
1169 1232
 
1170 1233
 		// Is this the default theme?
1171
-		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1')
1172
-			$settings['default_' . $row['variable']] = $row['value'];
1234
+		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') {
1235
+					$settings['default_' . $row['variable']] = $row['value'];
1236
+		}
1173 1237
 	}
1174 1238
 	$smcFunc['db_free_result']($result);
1175 1239
 
@@ -1179,12 +1243,14 @@  discard block
 block discarded – undo
1179 1243
 		$settings['template_dirs'] = array($settings['theme_dir']);
1180 1244
 
1181 1245
 		// Based on theme (if there is one).
1182
-		if (!empty($settings['base_theme_dir']))
1183
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1246
+		if (!empty($settings['base_theme_dir'])) {
1247
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1248
+		}
1184 1249
 
1185 1250
 		// Lastly the default theme.
1186
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1187
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1251
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1252
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1253
+		}
1188 1254
 	}
1189 1255
 
1190 1256
 	// Assume we want this.
@@ -1328,8 +1394,9 @@  discard block
 block discarded – undo
1328 1394
 	// Ok should we prune the logs?
1329 1395
 	if (!empty($modSettings['pruningOptions']))
1330 1396
 	{
1331
-		if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false)
1332
-			list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
1397
+		if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) {
1398
+					list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
1399
+		}
1333 1400
 
1334 1401
 		if (!empty($modSettings['pruneErrorLog']))
1335 1402
 		{
@@ -1395,8 +1462,9 @@  discard block
 block discarded – undo
1395 1462
 				)
1396 1463
 			);
1397 1464
 
1398
-			while ($row = $smcFunc['db_fetch_row']($result))
1399
-				$reports[] = $row[0];
1465
+			while ($row = $smcFunc['db_fetch_row']($result)) {
1466
+							$reports[] = $row[0];
1467
+			}
1400 1468
 
1401 1469
 			$smcFunc['db_free_result']($result);
1402 1470
 
@@ -1481,8 +1549,9 @@  discard block
 block discarded – undo
1481 1549
 	);
1482 1550
 
1483 1551
 	// Run Cache housekeeping
1484
-	if (!empty($cache_enable) && !empty($cacheAPI))
1485
-		$cacheAPI->housekeeping();
1552
+	if (!empty($cache_enable) && !empty($cacheAPI)) {
1553
+			$cacheAPI->housekeeping();
1554
+	}
1486 1555
 
1487 1556
 	// Prevent stale minimized CSS and JavaScript from cluttering up the theme directories
1488 1557
 	deleteAllMinified();
@@ -1565,8 +1634,9 @@  discard block
 block discarded – undo
1565 1634
 		$emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
1566 1635
 
1567 1636
 		// Send the actual email.
1568
-		if ($notifyPrefs[$row['id_member']] & 0x02)
1569
-			sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
1637
+		if ($notifyPrefs[$row['id_member']] & 0x02) {
1638
+					sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
1639
+		}
1570 1640
 
1571 1641
 		if ($notifyPrefs[$row['id_member']] & 0x01)
1572 1642
 		{
@@ -1589,18 +1659,19 @@  discard block
 block discarded – undo
1589 1659
 	}
1590 1660
 
1591 1661
 	// Insert the alerts if any
1592
-	if (!empty($alert_rows))
1593
-		$smcFunc['db_insert']('',
1662
+	if (!empty($alert_rows)) {
1663
+			$smcFunc['db_insert']('',
1594 1664
 			'{db_prefix}user_alerts',
1595 1665
 			array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
1596 1666
 				'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
1597 1667
 			$alert_rows,
1598 1668
 			array()
1599 1669
 		);
1670
+	}
1600 1671
 
1601 1672
 	// Mark the reminder as sent.
1602
-	if (!empty($subs_reminded))
1603
-		$smcFunc['db_query']('', '
1673
+	if (!empty($subs_reminded)) {
1674
+			$smcFunc['db_query']('', '
1604 1675
 			UPDATE {db_prefix}log_subscribed
1605 1676
 			SET reminder_sent = {int:reminder_sent}
1606 1677
 			WHERE id_sublog IN ({array_int:subscription_list})',
@@ -1609,6 +1680,7 @@  discard block
 block discarded – undo
1609 1680
 				'reminder_sent' => 1,
1610 1681
 			)
1611 1682
 		);
1683
+	}
1612 1684
 
1613 1685
 	return true;
1614 1686
 }
@@ -1624,13 +1696,13 @@  discard block
 block discarded – undo
1624 1696
 	// We need to know where this thing is going.
1625 1697
 	if (!empty($modSettings['currentAttachmentUploadDir']))
1626 1698
 	{
1627
-		if (!is_array($modSettings['attachmentUploadDir']))
1628
-			$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1699
+		if (!is_array($modSettings['attachmentUploadDir'])) {
1700
+					$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1701
+		}
1629 1702
 
1630 1703
 		// Just use the current path for temp files.
1631 1704
 		$attach_dirs = $modSettings['attachmentUploadDir'];
1632
-	}
1633
-	else
1705
+	} else
1634 1706
 	{
1635 1707
 		$attach_dirs = array($modSettings['attachmentUploadDir']);
1636 1708
 	}
@@ -1649,14 +1721,16 @@  discard block
 block discarded – undo
1649 1721
 
1650 1722
 		while ($file = readdir($dir))
1651 1723
 		{
1652
-			if ($file == '.' || $file == '..')
1653
-				continue;
1724
+			if ($file == '.' || $file == '..') {
1725
+							continue;
1726
+			}
1654 1727
 
1655 1728
 			if (strpos($file, 'post_tmp_') !== false)
1656 1729
 			{
1657 1730
 				// Temp file is more than 5 hours old!
1658
-				if (filemtime($attach_dir . '/' . $file) < time() - 18000)
1659
-					@unlink($attach_dir . '/' . $file);
1731
+				if (filemtime($attach_dir . '/' . $file) < time() - 18000) {
1732
+									@unlink($attach_dir . '/' . $file);
1733
+				}
1660 1734
 			}
1661 1735
 		}
1662 1736
 		closedir($dir);
@@ -1689,8 +1763,9 @@  discard block
 block discarded – undo
1689 1763
 		)
1690 1764
 	);
1691 1765
 
1692
-	while ($row = $smcFunc['db_fetch_row']($request))
1693
-		$topics[] = $row[0];
1766
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1767
+			$topics[] = $row[0];
1768
+	}
1694 1769
 	$smcFunc['db_free_result']($request);
1695 1770
 
1696 1771
 	// Zap, your gone
@@ -1710,8 +1785,9 @@  discard block
 block discarded – undo
1710 1785
 {
1711 1786
 	global $smcFunc, $sourcedir, $modSettings;
1712 1787
 
1713
-	if (empty($modSettings['drafts_keep_days']))
1714
-		return true;
1788
+	if (empty($modSettings['drafts_keep_days'])) {
1789
+			return true;
1790
+	}
1715 1791
 
1716 1792
 	// init
1717 1793
 	$drafts = array();
@@ -1729,8 +1805,9 @@  discard block
 block discarded – undo
1729 1805
 		)
1730 1806
 	);
1731 1807
 
1732
-	while ($row = $smcFunc['db_fetch_row']($request))
1733
-		$drafts[] = (int) $row[0];
1808
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1809
+			$drafts[] = (int) $row[0];
1810
+	}
1734 1811
 	$smcFunc['db_free_result']($request);
1735 1812
 
1736 1813
 	// If we have old one, remove them
Please login to merge, or discard this patch.
proxy.php 1 patch
Braces   +35 added lines, -23 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
 	define('SMF', 'proxy');
18
+}
18 19
 
19 20
 global $proxyhousekeeping;
20 21
 
@@ -68,33 +69,38 @@  discard block
 block discarded – undo
68 69
 	 */
69 70
 	public function checkRequest()
70 71
 	{
71
-		if (!$this->enabled)
72
-			return false;
72
+		if (!$this->enabled) {
73
+					return false;
74
+		}
73 75
 
74 76
 		// Try to create the image cache directory if it doesn't exist
75
-		if (!file_exists($this->cache))
76
-			if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
77
+		if (!file_exists($this->cache)) {
78
+					if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
77 79
 				return false;
80
+		}
78 81
 
79 82
 		// Basic sanity check
80 83
 		$_GET['request'] = validate_iri($_GET['request']);
81 84
 
82 85
 		// We aren't going anywhere without these
83
-		if (empty($_GET['hash']) || empty($_GET['request']))
84
-			return false;
86
+		if (empty($_GET['hash']) || empty($_GET['request'])) {
87
+					return false;
88
+		}
85 89
 
86 90
 		$hash = $_GET['hash'];
87 91
 		$request = $_GET['request'];
88 92
 
89
-		if (md5($request . $this->secret) != $hash)
90
-			return false;
93
+		if (md5($request . $this->secret) != $hash) {
94
+					return false;
95
+		}
91 96
 
92 97
 		// Ensure any non-ASCII characters in the URL are encoded correctly
93 98
 		$request = iri_to_url($request);
94 99
 
95 100
 		// Attempt to cache the request if it doesn't exist
96
-		if (!$this->isCached($request))
97
-			return $this->cacheImage($request);
101
+		if (!$this->isCached($request)) {
102
+					return $this->cacheImage($request);
103
+		}
98 104
 
99 105
 		return true;
100 106
 	}
@@ -131,8 +137,9 @@  discard block
 block discarded – undo
131 137
 		if (!$cached || $time - $cached['time'] > ($this->maxDays * 86400))
132 138
 		{
133 139
 			@unlink($cached_file);
134
-			if ($this->checkRequest())
135
-				$this->serve();
140
+			if ($this->checkRequest()) {
141
+							$this->serve();
142
+			}
136 143
 			$this::redirectexit($request);
137 144
 		}
138 145
 
@@ -145,8 +152,9 @@  discard block
 block discarded – undo
145 152
 
146 153
 		// Make sure we're serving an image
147 154
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
148
-		if ($contentParts[0] != 'image')
149
-			exit;
155
+		if ($contentParts[0] != 'image') {
156
+					exit;
157
+		}
150 158
 
151 159
 		$max_age = $time - $cached['time'] + (5 * 86400);
152 160
 		header('content-type: ' . $cached['content_type']);
@@ -196,25 +204,29 @@  discard block
 block discarded – undo
196 204
 		$image = fetch_web_data($request);
197 205
 
198 206
 		// Looks like nobody was home
199
-		if (empty($image))
200
-			return -1;
207
+		if (empty($image)) {
208
+					return -1;
209
+		}
201 210
 
202 211
 		// What kind of file did they give us?
203 212
 		$finfo = finfo_open(FILEINFO_MIME_TYPE);
204 213
 		$mime_type = finfo_buffer($finfo, $image);
205 214
 
206 215
 		// SVG needs a little extra care
207
-		if ($ext == 'svg' && $mime_type == 'text/plain')
208
-			$mime_type = 'image/svg+xml';
216
+		if ($ext == 'svg' && $mime_type == 'text/plain') {
217
+					$mime_type = 'image/svg+xml';
218
+		}
209 219
 
210 220
 		// Make sure the url is returning an image
211
-		if (strpos($mime_type, 'image/') !== 0)
212
-			return -1;
221
+		if (strpos($mime_type, 'image/') !== 0) {
222
+					return -1;
223
+		}
213 224
 
214 225
 		// Validate the filesize
215 226
 		$size = strlen($image);
216
-		if ($size > ($this->maxSize * 1024))
217
-			return 0;
227
+		if ($size > ($this->maxSize * 1024)) {
228
+					return 0;
229
+		}
218 230
 
219 231
 		// Cache it for later
220 232
 		return file_put_contents($dest, json_encode(array(
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']);
@@ -924,21 +966,26 @@  discard block
 block discarded – undo
924 966
 		makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
925 967
 		//makeAvatarChanges($memID, $post_errors);
926 968
 
927
-		if (!empty($_REQUEST['sa']))
928
-			makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
969
+		if (!empty($_REQUEST['sa'])) {
970
+					makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
971
+		}
929 972
 
930
-		foreach ($profile_bools as $var)
931
-			if (isset($_POST[$var]))
973
+		foreach ($profile_bools as $var) {
974
+					if (isset($_POST[$var]))
932 975
 				$profile_vars[$var] = empty($_POST[$var]) ? '0' : '1';
933
-		foreach ($profile_ints as $var)
934
-			if (isset($_POST[$var]))
976
+		}
977
+		foreach ($profile_ints as $var) {
978
+					if (isset($_POST[$var]))
935 979
 				$profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : '';
936
-		foreach ($profile_floats as $var)
937
-			if (isset($_POST[$var]))
980
+		}
981
+		foreach ($profile_floats as $var) {
982
+					if (isset($_POST[$var]))
938 983
 				$profile_vars[$var] = (float) $_POST[$var];
939
-		foreach ($profile_strings as $var)
940
-			if (isset($_POST[$var]))
984
+		}
985
+		foreach ($profile_strings as $var) {
986
+					if (isset($_POST[$var]))
941 987
 				$profile_vars[$var] = $_POST[$var];
988
+		}
942 989
 	}
943 990
 }
944 991
 
@@ -972,8 +1019,9 @@  discard block
 block discarded – undo
972 1019
 	);
973 1020
 
974 1021
 	// Can't change reserved vars.
975
-	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))
976
-		fatal_lang_error('no_access', false);
1022
+	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)) {
1023
+			fatal_lang_error('no_access', false);
1024
+	}
977 1025
 
978 1026
 	// Don't allow any overriding of custom fields with default or non-default options.
979 1027
 	$request = $smcFunc['db_query']('', '
@@ -985,8 +1033,9 @@  discard block
 block discarded – undo
985 1033
 		)
986 1034
 	);
987 1035
 	$custom_fields = array();
988
-	while ($row = $smcFunc['db_fetch_assoc']($request))
989
-		$custom_fields[] = $row['col_name'];
1036
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1037
+			$custom_fields[] = $row['col_name'];
1038
+	}
990 1039
 	$smcFunc['db_free_result']($request);
991 1040
 
992 1041
 	// These are the theme changes...
@@ -995,33 +1044,39 @@  discard block
 block discarded – undo
995 1044
 	{
996 1045
 		foreach ($_POST['options'] as $opt => $val)
997 1046
 		{
998
-			if (in_array($opt, $custom_fields))
999
-				continue;
1047
+			if (in_array($opt, $custom_fields)) {
1048
+							continue;
1049
+			}
1000 1050
 
1001 1051
 			// These need to be controlled.
1002
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1003
-				$val = max(0, min($val, 50));
1052
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1053
+							$val = max(0, min($val, 50));
1054
+			}
1004 1055
 			// We don't set this per theme anymore.
1005
-			elseif ($opt == 'allow_no_censored')
1006
-				continue;
1056
+			elseif ($opt == 'allow_no_censored') {
1057
+							continue;
1058
+			}
1007 1059
 
1008 1060
 			$themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val);
1009 1061
 		}
1010 1062
 	}
1011 1063
 
1012 1064
 	$erase_options = array();
1013
-	if (isset($_POST['default_options']) && is_array($_POST['default_options']))
1014
-		foreach ($_POST['default_options'] as $opt => $val)
1065
+	if (isset($_POST['default_options']) && is_array($_POST['default_options'])) {
1066
+			foreach ($_POST['default_options'] as $opt => $val)
1015 1067
 		{
1016 1068
 			if (in_array($opt, $custom_fields))
1017 1069
 				continue;
1070
+	}
1018 1071
 
1019 1072
 			// These need to be controlled.
1020
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1021
-				$val = max(0, min($val, 50));
1073
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1074
+							$val = max(0, min($val, 50));
1075
+			}
1022 1076
 			// Only let admins and owners change the censor.
1023
-			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner'])
1024
-					continue;
1077
+			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) {
1078
+								continue;
1079
+			}
1025 1080
 
1026 1081
 			$themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val);
1027 1082
 			$erase_options[] = $opt;
@@ -1057,8 +1112,9 @@  discard block
 block discarded – undo
1057 1112
 
1058 1113
 		// Admins can choose any theme, even if it's not enabled...
1059 1114
 		$themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']);
1060
-		foreach ($themes as $t)
1061
-			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1115
+		foreach ($themes as $t) {
1116
+					cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1117
+		}
1062 1118
 	}
1063 1119
 }
1064 1120
 
@@ -1077,8 +1133,9 @@  discard block
 block discarded – undo
1077 1133
 	if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards']))
1078 1134
 	{
1079 1135
 		// Make sure only integers are deleted.
1080
-		foreach ($_POST['notify_boards'] as $index => $id)
1081
-			$_POST['notify_boards'][$index] = (int) $id;
1136
+		foreach ($_POST['notify_boards'] as $index => $id) {
1137
+					$_POST['notify_boards'][$index] = (int) $id;
1138
+		}
1082 1139
 
1083 1140
 		// id_board = 0 is reserved for topic notifications.
1084 1141
 		$_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0));
@@ -1097,8 +1154,9 @@  discard block
 block discarded – undo
1097 1154
 	// We are editing topic notifications......
1098 1155
 	elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics']))
1099 1156
 	{
1100
-		foreach ($_POST['notify_topics'] as $index => $id)
1101
-			$_POST['notify_topics'][$index] = (int) $id;
1157
+		foreach ($_POST['notify_topics'] as $index => $id) {
1158
+					$_POST['notify_topics'][$index] = (int) $id;
1159
+		}
1102 1160
 
1103 1161
 		// Make sure there are no zeros left.
1104 1162
 		$_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0));
@@ -1112,16 +1170,18 @@  discard block
 block discarded – undo
1112 1170
 				'selected_member' => $memID,
1113 1171
 			)
1114 1172
 		);
1115
-		foreach ($_POST['notify_topics'] as $topic)
1116
-			setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1173
+		foreach ($_POST['notify_topics'] as $topic) {
1174
+					setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1175
+		}
1117 1176
 	}
1118 1177
 
1119 1178
 	// We are removing topic preferences
1120 1179
 	elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics']))
1121 1180
 	{
1122 1181
 		$prefs = array();
1123
-		foreach ($_POST['notify_topics'] as $topic)
1124
-			$prefs[] = 'topic_notify_' . $topic;
1182
+		foreach ($_POST['notify_topics'] as $topic) {
1183
+					$prefs[] = 'topic_notify_' . $topic;
1184
+		}
1125 1185
 		deleteNotifyPrefs($memID, $prefs);
1126 1186
 	}
1127 1187
 
@@ -1129,8 +1189,9 @@  discard block
 block discarded – undo
1129 1189
 	elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards']))
1130 1190
 	{
1131 1191
 		$prefs = array();
1132
-		foreach ($_POST['notify_boards'] as $board)
1133
-			$prefs[] = 'board_notify_' . $board;
1192
+		foreach ($_POST['notify_boards'] as $board) {
1193
+					$prefs[] = 'board_notify_' . $board;
1194
+		}
1134 1195
 		deleteNotifyPrefs($memID, $prefs);
1135 1196
 	}
1136 1197
 }
@@ -1151,8 +1212,9 @@  discard block
 block discarded – undo
1151 1212
 
1152 1213
 	$errors = array();
1153 1214
 
1154
-	if ($sanitize && isset($_POST['customfield']))
1155
-		$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1215
+	if ($sanitize && isset($_POST['customfield'])) {
1216
+			$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1217
+	}
1156 1218
 
1157 1219
 	$where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}';
1158 1220
 
@@ -1178,26 +1240,29 @@  discard block
 block discarded – undo
1178 1240
 			- The data is not invisible to users but editable by the owner (or if it is the user is not the owner)
1179 1241
 			- The area isn't registration, and if it is that the field is not supposed to be shown there.
1180 1242
 		*/
1181
-		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0))
1182
-			continue;
1243
+		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) {
1244
+					continue;
1245
+		}
1183 1246
 
1184 1247
 		// Validate the user data.
1185
-		if ($row['field_type'] == 'check')
1186
-			$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1187
-		elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1248
+		if ($row['field_type'] == 'check') {
1249
+					$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1250
+		} elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1188 1251
 		{
1189 1252
 			$value = $row['default_value'];
1190
-			foreach (explode(',', $row['field_options']) as $k => $v)
1191
-				if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1253
+			foreach (explode(',', $row['field_options']) as $k => $v) {
1254
+							if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1192 1255
 					$value = $v;
1256
+			}
1193 1257
 		}
1194 1258
 		// Otherwise some form of text!
1195 1259
 		else
1196 1260
 		{
1197 1261
 			$value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : '';
1198 1262
 
1199
-			if ($row['field_length'])
1200
-				$value = $smcFunc['substr']($value, 0, $row['field_length']);
1263
+			if ($row['field_length']) {
1264
+							$value = $smcFunc['substr']($value, 0, $row['field_length']);
1265
+			}
1201 1266
 
1202 1267
 			// Any masks?
1203 1268
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
@@ -1206,36 +1271,34 @@  discard block
 block discarded – undo
1206 1271
 				$valueReference = un_htmlspecialchars($value);
1207 1272
 
1208 1273
 				// Try and avoid some checks. '0' could be a valid non-empty value.
1209
-				if (empty($value) && !is_numeric($value))
1210
-					$value = '';
1274
+				if (empty($value) && !is_numeric($value)) {
1275
+									$value = '';
1276
+				}
1211 1277
 
1212 1278
 				if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference)))
1213 1279
 				{
1214
-					if ($returnErrors)
1215
-						$errors[] = 'custom_field_nohtml_fail';
1216
-
1217
-					else
1218
-						$value = '';
1219
-				}
1220
-				elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1280
+					if ($returnErrors) {
1281
+											$errors[] = 'custom_field_nohtml_fail';
1282
+					} else {
1283
+											$value = '';
1284
+					}
1285
+				} elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1221 1286
 				{
1222
-					if ($returnErrors)
1223
-						$errors[] = 'custom_field_mail_fail';
1224
-
1225
-					else
1226
-						$value = '';
1227
-				}
1228
-				elseif ($row['mask'] == 'number')
1287
+					if ($returnErrors) {
1288
+											$errors[] = 'custom_field_mail_fail';
1289
+					} else {
1290
+											$value = '';
1291
+					}
1292
+				} elseif ($row['mask'] == 'number')
1229 1293
 				{
1230 1294
 					$value = (int) $value;
1231
-				}
1232
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1295
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1233 1296
 				{
1234
-					if ($returnErrors)
1235
-						$errors[] = 'custom_field_regex_fail';
1236
-
1237
-					else
1238
-						$value = '';
1297
+					if ($returnErrors) {
1298
+											$errors[] = 'custom_field_regex_fail';
1299
+					} else {
1300
+											$value = '';
1301
+					}
1239 1302
 				}
1240 1303
 
1241 1304
 				unset($valueReference);
@@ -1259,8 +1322,7 @@  discard block
 block discarded – undo
1259 1322
 			{
1260 1323
 				$deletes = array('id_theme' => 1 , 'variable' => $row['col_name'], 'id_member' => $memID);
1261 1324
 				unset($user_profile[$memID]['options'][$row['col_name']]);
1262
-			}
1263
-			else
1325
+			} else
1264 1326
 			{
1265 1327
 				$changes[] = array(1, $row['col_name'], $value, $memID);
1266 1328
 				$user_profile[$memID]['options'][$row['col_name']] = $value;
@@ -1271,27 +1333,30 @@  discard block
 block discarded – undo
1271 1333
 
1272 1334
 	$hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize, &$deletes));
1273 1335
 
1274
-	if (!empty($hook_errors) && is_array($hook_errors))
1275
-		$errors = array_merge($errors, $hook_errors);
1336
+	if (!empty($hook_errors) && is_array($hook_errors)) {
1337
+			$errors = array_merge($errors, $hook_errors);
1338
+	}
1276 1339
 
1277 1340
 	// Make those changes!
1278 1341
 	if ((!empty($changes) || !empty($deletes)) && empty($context['password_auth_failed']) && empty($errors))
1279 1342
 	{
1280
-		if (!empty($changes))
1281
-			$smcFunc['db_insert']('replace',
1343
+		if (!empty($changes)) {
1344
+					$smcFunc['db_insert']('replace',
1282 1345
 				'{db_prefix}themes',
1283 1346
 				array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534', 'id_member' => 'int'),
1284 1347
 				$changes,
1285 1348
 				array('id_theme', 'variable', 'id_member')
1286 1349
 			);
1287
-		if (!empty($deletes))
1288
-			$smcFunc['db_query']('','
1350
+		}
1351
+		if (!empty($deletes)) {
1352
+					$smcFunc['db_query']('','
1289 1353
 				DELETE FROM {db_prefix}themes
1290 1354
 				WHERE id_theme = {int:id_theme} AND
1291 1355
 						variable = {string:variable} AND
1292 1356
 						id_member = {int:id_member}',
1293 1357
 				$deletes
1294 1358
 				);
1359
+		}
1295 1360
 		if (!empty($log_changes) && !empty($modSettings['modlog_enabled']))
1296 1361
 		{
1297 1362
 			require_once($sourcedir . '/Logging.php');
@@ -1299,9 +1364,10 @@  discard block
 block discarded – undo
1299 1364
 		}
1300 1365
 	}
1301 1366
 
1302
-	if ($returnErrors)
1303
-		return $errors;
1304
-}
1367
+	if ($returnErrors) {
1368
+			return $errors;
1369
+	}
1370
+	}
1305 1371
 
1306 1372
 /**
1307 1373
  * Show all the users buddies, as well as a add/delete interface.
@@ -1313,8 +1379,9 @@  discard block
 block discarded – undo
1313 1379
 	global $context, $txt, $modSettings;
1314 1380
 
1315 1381
 	// Do a quick check to ensure people aren't getting here illegally!
1316
-	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist']))
1317
-		fatal_lang_error('no_access', false);
1382
+	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) {
1383
+			fatal_lang_error('no_access', false);
1384
+	}
1318 1385
 
1319 1386
 	// Can we email the user direct?
1320 1387
 	$context['can_moderate_forum'] = allowedTo('moderate_forum');
@@ -1344,9 +1411,10 @@  discard block
 block discarded – undo
1344 1411
 	$context['sub_template'] = $subActions[$context['list_area']][0];
1345 1412
 	$call = call_helper($subActions[$context['list_area']][0], true);
1346 1413
 
1347
-	if (!empty($call))
1348
-		call_user_func($call, $memID);
1349
-}
1414
+	if (!empty($call)) {
1415
+			call_user_func($call, $memID);
1416
+	}
1417
+	}
1350 1418
 
1351 1419
 /**
1352 1420
  * Show all the users buddies, as well as a add/delete interface.
@@ -1360,9 +1428,10 @@  discard block
 block discarded – undo
1360 1428
 
1361 1429
 	// For making changes!
1362 1430
 	$buddiesArray = explode(',', $user_profile[$memID]['buddy_list']);
1363
-	foreach ($buddiesArray as $k => $dummy)
1364
-		if ($dummy == '')
1431
+	foreach ($buddiesArray as $k => $dummy) {
1432
+			if ($dummy == '')
1365 1433
 			unset($buddiesArray[$k]);
1434
+	}
1366 1435
 
1367 1436
 	// Removing a buddy?
1368 1437
 	if (isset($_GET['remove']))
@@ -1374,10 +1443,11 @@  discard block
 block discarded – undo
1374 1443
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1375 1444
 
1376 1445
 		// Heh, I'm lazy, do it the easy way...
1377
-		foreach ($buddiesArray as $key => $buddy)
1378
-			if ($buddy == (int) $_GET['remove'])
1446
+		foreach ($buddiesArray as $key => $buddy) {
1447
+					if ($buddy == (int) $_GET['remove'])
1379 1448
 			{
1380 1449
 				unset($buddiesArray[$key]);
1450
+		}
1381 1451
 				$_SESSION['prf-save'] = true;
1382 1452
 			}
1383 1453
 
@@ -1387,8 +1457,7 @@  discard block
 block discarded – undo
1387 1457
 
1388 1458
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1389 1459
 		redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID);
1390
-	}
1391
-	elseif (isset($_POST['new_buddy']))
1460
+	} elseif (isset($_POST['new_buddy']))
1392 1461
 	{
1393 1462
 		checkSession();
1394 1463
 
@@ -1401,8 +1470,9 @@  discard block
 block discarded – undo
1401 1470
 		{
1402 1471
 			$new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => '&#039;'));
1403 1472
 
1404
-			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1405
-				unset($new_buddies[$k]);
1473
+			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1474
+							unset($new_buddies[$k]);
1475
+			}
1406 1476
 		}
1407 1477
 
1408 1478
 		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies));
@@ -1422,16 +1492,18 @@  discard block
 block discarded – undo
1422 1492
 				)
1423 1493
 			);
1424 1494
 
1425
-			if ($smcFunc['db_num_rows']($request) != 0)
1426
-				$_SESSION['prf-save'] = true;
1495
+			if ($smcFunc['db_num_rows']($request) != 0) {
1496
+							$_SESSION['prf-save'] = true;
1497
+			}
1427 1498
 
1428 1499
 			// Add the new member to the buddies array.
1429 1500
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1430 1501
 			{
1431
-				if (in_array($row['id_member'], $buddiesArray))
1432
-					continue;
1433
-				else
1434
-					$buddiesArray[] = (int) $row['id_member'];
1502
+				if (in_array($row['id_member'], $buddiesArray)) {
1503
+									continue;
1504
+				} else {
1505
+									$buddiesArray[] = (int) $row['id_member'];
1506
+				}
1435 1507
 			}
1436 1508
 			$smcFunc['db_free_result']($request);
1437 1509
 
@@ -1461,18 +1533,20 @@  discard block
 block discarded – undo
1461 1533
 
1462 1534
 	$context['custom_pf'] = array();
1463 1535
 	$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
1464
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1465
-		if (!isset($disabled_fields[$row['col_name']]))
1536
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1537
+			if (!isset($disabled_fields[$row['col_name']]))
1466 1538
 			$context['custom_pf'][$row['col_name']] = array(
1467 1539
 				'label' => $row['field_name'],
1468 1540
 				'type' => $row['field_type'],
1469 1541
 				'bbc' => !empty($row['bbc']),
1470 1542
 				'enclose' => $row['enclose'],
1471 1543
 			);
1544
+	}
1472 1545
 
1473 1546
 	// Gotta disable the gender option.
1474
-	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None')
1475
-		unset($context['custom_pf']['cust_gender']);
1547
+	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') {
1548
+			unset($context['custom_pf']['cust_gender']);
1549
+	}
1476 1550
 
1477 1551
 	$smcFunc['db_free_result']($request);
1478 1552
 
@@ -1489,8 +1563,9 @@  discard block
 block discarded – undo
1489 1563
 				'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1,
1490 1564
 			)
1491 1565
 		);
1492
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1493
-			$buddies[] = $row['id_member'];
1566
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1567
+					$buddies[] = $row['id_member'];
1568
+		}
1494 1569
 		$smcFunc['db_free_result']($result);
1495 1570
 	}
1496 1571
 
@@ -1518,30 +1593,32 @@  discard block
 block discarded – undo
1518 1593
 					continue;
1519 1594
 				}
1520 1595
 
1521
-				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key]))
1522
-					$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1523
-
1524
-				elseif ($column['type'] == 'check')
1525
-					$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1596
+				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) {
1597
+									$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1598
+				} elseif ($column['type'] == 'check') {
1599
+									$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1600
+				}
1526 1601
 
1527 1602
 				// Enclosing the user input within some other text?
1528
-				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key]))
1529
-					$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1603
+				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) {
1604
+									$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1530 1605
 						'{SCRIPTURL}' => $scripturl,
1531 1606
 						'{IMAGES_URL}' => $settings['images_url'],
1532 1607
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1533 1608
 						'{INPUT}' => $context['buddies'][$buddy]['options'][$key],
1534 1609
 					));
1610
+				}
1535 1611
 			}
1536 1612
 		}
1537 1613
 	}
1538 1614
 
1539 1615
 	if (isset($_SESSION['prf-save']))
1540 1616
 	{
1541
-		if ($_SESSION['prf-save'] === true)
1542
-			$context['saved_successful'] = true;
1543
-		else
1544
-			$context['saved_failed'] = $_SESSION['prf-save'];
1617
+		if ($_SESSION['prf-save'] === true) {
1618
+					$context['saved_successful'] = true;
1619
+		} else {
1620
+					$context['saved_failed'] = $_SESSION['prf-save'];
1621
+		}
1545 1622
 
1546 1623
 		unset($_SESSION['prf-save']);
1547 1624
 	}
@@ -1561,9 +1638,10 @@  discard block
 block discarded – undo
1561 1638
 
1562 1639
 	// For making changes!
1563 1640
 	$ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']);
1564
-	foreach ($ignoreArray as $k => $dummy)
1565
-		if ($dummy == '')
1641
+	foreach ($ignoreArray as $k => $dummy) {
1642
+			if ($dummy == '')
1566 1643
 			unset($ignoreArray[$k]);
1644
+	}
1567 1645
 
1568 1646
 	// Removing a member from the ignore list?
1569 1647
 	if (isset($_GET['remove']))
@@ -1573,10 +1651,11 @@  discard block
 block discarded – undo
1573 1651
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1574 1652
 
1575 1653
 		// Heh, I'm lazy, do it the easy way...
1576
-		foreach ($ignoreArray as $key => $id_remove)
1577
-			if ($id_remove == (int) $_GET['remove'])
1654
+		foreach ($ignoreArray as $key => $id_remove) {
1655
+					if ($id_remove == (int) $_GET['remove'])
1578 1656
 			{
1579 1657
 				unset($ignoreArray[$key]);
1658
+		}
1580 1659
 				$_SESSION['prf-save'] = true;
1581 1660
 			}
1582 1661
 
@@ -1586,8 +1665,7 @@  discard block
 block discarded – undo
1586 1665
 
1587 1666
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1588 1667
 		redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID);
1589
-	}
1590
-	elseif (isset($_POST['new_ignore']))
1668
+	} elseif (isset($_POST['new_ignore']))
1591 1669
 	{
1592 1670
 		checkSession();
1593 1671
 		// Prepare the string for extraction...
@@ -1599,8 +1677,9 @@  discard block
 block discarded – undo
1599 1677
 		{
1600 1678
 			$new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => '&#039;'));
1601 1679
 
1602
-			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1603
-				unset($new_entries[$k]);
1680
+			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1681
+							unset($new_entries[$k]);
1682
+			}
1604 1683
 		}
1605 1684
 
1606 1685
 		$_SESSION['prf-save'] = $txt['could_not_add_person'];
@@ -1618,16 +1697,18 @@  discard block
 block discarded – undo
1618 1697
 				)
1619 1698
 			);
1620 1699
 
1621
-			if ($smcFunc['db_num_rows']($request) != 0)
1622
-				$_SESSION['prf-save'] = true;
1700
+			if ($smcFunc['db_num_rows']($request) != 0) {
1701
+							$_SESSION['prf-save'] = true;
1702
+			}
1623 1703
 
1624 1704
 			// Add the new member to the buddies array.
1625 1705
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1626 1706
 			{
1627
-				if (in_array($row['id_member'], $ignoreArray))
1628
-					continue;
1629
-				else
1630
-					$ignoreArray[] = (int) $row['id_member'];
1707
+				if (in_array($row['id_member'], $ignoreArray)) {
1708
+									continue;
1709
+				} else {
1710
+									$ignoreArray[] = (int) $row['id_member'];
1711
+				}
1631 1712
 			}
1632 1713
 			$smcFunc['db_free_result']($request);
1633 1714
 
@@ -1656,8 +1737,9 @@  discard block
 block discarded – undo
1656 1737
 				'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1,
1657 1738
 			)
1658 1739
 		);
1659
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1660
-			$ignored[] = $row['id_member'];
1740
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1741
+					$ignored[] = $row['id_member'];
1742
+		}
1661 1743
 		$smcFunc['db_free_result']($result);
1662 1744
 	}
1663 1745
 
@@ -1676,10 +1758,11 @@  discard block
 block discarded – undo
1676 1758
 
1677 1759
 	if (isset($_SESSION['prf-save']))
1678 1760
 	{
1679
-		if ($_SESSION['prf-save'] === true)
1680
-			$context['saved_successful'] = true;
1681
-		else
1682
-			$context['saved_failed'] = $_SESSION['prf-save'];
1761
+		if ($_SESSION['prf-save'] === true) {
1762
+					$context['saved_successful'] = true;
1763
+		} else {
1764
+					$context['saved_failed'] = $_SESSION['prf-save'];
1765
+		}
1683 1766
 
1684 1767
 		unset($_SESSION['prf-save']);
1685 1768
 	}
@@ -1695,8 +1778,9 @@  discard block
 block discarded – undo
1695 1778
 	global $context, $txt;
1696 1779
 
1697 1780
 	loadThemeOptions($memID);
1698
-	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any')))
1699
-		loadCustomFields($memID, 'account');
1781
+	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) {
1782
+			loadCustomFields($memID, 'account');
1783
+	}
1700 1784
 
1701 1785
 	$context['sub_template'] = 'edit_options';
1702 1786
 	$context['page_desc'] = $txt['account_info'];
@@ -1723,8 +1807,9 @@  discard block
 block discarded – undo
1723 1807
 	global $context, $txt;
1724 1808
 
1725 1809
 	loadThemeOptions($memID);
1726
-	if (allowedTo(array('profile_forum_own', 'profile_forum_any')))
1727
-		loadCustomFields($memID, 'forumprofile');
1810
+	if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) {
1811
+			loadCustomFields($memID, 'forumprofile');
1812
+	}
1728 1813
 
1729 1814
 	$context['sub_template'] = 'edit_options';
1730 1815
 	$context['page_desc'] = $txt['forumProfile_info'];
@@ -1757,18 +1842,21 @@  discard block
 block discarded – undo
1757 1842
 	$dirs = array();
1758 1843
 	$files = array();
1759 1844
 
1760
-	if (!$dir)
1761
-		return array();
1845
+	if (!$dir) {
1846
+			return array();
1847
+	}
1762 1848
 
1763 1849
 	while ($line = $dir->read())
1764 1850
 	{
1765
-		if (in_array($line, array('.', '..', 'blank.png', 'index.php')))
1766
-			continue;
1851
+		if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) {
1852
+					continue;
1853
+		}
1767 1854
 
1768
-		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
1769
-			$dirs[] = $line;
1770
-		else
1771
-			$files[] = $line;
1855
+		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) {
1856
+					$dirs[] = $line;
1857
+		} else {
1858
+					$files[] = $line;
1859
+		}
1772 1860
 	}
1773 1861
 	$dir->close();
1774 1862
 
@@ -1789,14 +1877,15 @@  discard block
 block discarded – undo
1789 1877
 	foreach ($dirs as $line)
1790 1878
 	{
1791 1879
 		$tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
1792
-		if (!empty($tmp))
1793
-			$result[] = array(
1880
+		if (!empty($tmp)) {
1881
+					$result[] = array(
1794 1882
 				'filename' => $smcFunc['htmlspecialchars']($line),
1795 1883
 				'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
1796 1884
 				'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']',
1797 1885
 				'is_dir' => true,
1798 1886
 				'files' => $tmp
1799 1887
 		);
1888
+		}
1800 1889
 		unset($tmp);
1801 1890
 	}
1802 1891
 
@@ -1806,8 +1895,9 @@  discard block
 block discarded – undo
1806 1895
 		$extension = substr(strrchr($line, '.'), 1);
1807 1896
 
1808 1897
 		// Make sure it is an image.
1809
-		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
1810
-			continue;
1898
+		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) {
1899
+					continue;
1900
+		}
1811 1901
 
1812 1902
 		$result[] = array(
1813 1903
 			'filename' => $smcFunc['htmlspecialchars']($line),
@@ -1815,8 +1905,9 @@  discard block
 block discarded – undo
1815 1905
 			'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)),
1816 1906
 			'is_dir' => false
1817 1907
 		);
1818
-		if ($level == 1)
1819
-			$context['avatar_list'][] = $directory . '/' . $line;
1908
+		if ($level == 1) {
1909
+					$context['avatar_list'][] = $directory . '/' . $line;
1910
+		}
1820 1911
 	}
1821 1912
 
1822 1913
 	return $result;
@@ -1838,8 +1929,9 @@  discard block
 block discarded – undo
1838 1929
 	call_integration_hook('integrate_theme_options');
1839 1930
 
1840 1931
 	loadThemeOptions($memID);
1841
-	if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
1842
-		loadCustomFields($memID, 'theme');
1932
+	if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) {
1933
+			loadCustomFields($memID, 'theme');
1934
+	}
1843 1935
 
1844 1936
 	$context['sub_template'] = 'edit_options';
1845 1937
 	$context['page_desc'] = $txt['theme_info'];
@@ -1893,16 +1985,19 @@  discard block
 block discarded – undo
1893 1985
 {
1894 1986
 	global $txt, $context, $modSettings, $smcFunc, $sourcedir;
1895 1987
 
1896
-	if (!isset($context['token_check']))
1897
-		$context['token_check'] = 'profile-nt' . $memID;
1988
+	if (!isset($context['token_check'])) {
1989
+			$context['token_check'] = 'profile-nt' . $memID;
1990
+	}
1898 1991
 
1899 1992
 	is_not_guest();
1900
-	if (!$context['user']['is_owner'])
1901
-		isAllowedTo('profile_extra_any');
1993
+	if (!$context['user']['is_owner']) {
1994
+			isAllowedTo('profile_extra_any');
1995
+	}
1902 1996
 
1903 1997
 	// Set the post action if we're coming from the profile...
1904
-	if (!isset($context['action']))
1905
-		$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1998
+	if (!isset($context['action'])) {
1999
+			$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
2000
+	}
1906 2001
 
1907 2002
 	// What options are set
1908 2003
 	loadThemeOptions($memID);
@@ -1989,28 +2084,34 @@  discard block
 block discarded – undo
1989 2084
 	);
1990 2085
 
1991 2086
 	// There are certain things that are disabled at the group level.
1992
-	if (empty($modSettings['cal_enabled']))
1993
-		unset($alert_types['calendar']);
2087
+	if (empty($modSettings['cal_enabled'])) {
2088
+			unset($alert_types['calendar']);
2089
+	}
1994 2090
 
1995 2091
 	// Disable paid subscriptions at group level if they're disabled
1996
-	if (empty($modSettings['paid_enabled']))
1997
-		unset($alert_types['paidsubs']);
2092
+	if (empty($modSettings['paid_enabled'])) {
2093
+			unset($alert_types['paidsubs']);
2094
+	}
1998 2095
 
1999 2096
 	// Disable membergroup requests at group level if they're disabled
2000
-	if (empty($modSettings['show_group_membership']))
2001
-		unset($alert_types['groupr'], $alert_types['members']['request_group']);
2097
+	if (empty($modSettings['show_group_membership'])) {
2098
+			unset($alert_types['groupr'], $alert_types['members']['request_group']);
2099
+	}
2002 2100
 
2003 2101
 	// Disable mentions if they're disabled
2004
-	if (empty($modSettings['enable_mentions']))
2005
-		unset($alert_types['msg']['msg_mention']);
2102
+	if (empty($modSettings['enable_mentions'])) {
2103
+			unset($alert_types['msg']['msg_mention']);
2104
+	}
2006 2105
 
2007 2106
 	// Disable likes if they're disabled
2008
-	if (empty($modSettings['enable_likes']))
2009
-		unset($alert_types['msg']['msg_like']);
2107
+	if (empty($modSettings['enable_likes'])) {
2108
+			unset($alert_types['msg']['msg_like']);
2109
+	}
2010 2110
 
2011 2111
 	// Disable buddy requests if they're disabled
2012
-	if (empty($modSettings['enable_buddylist']))
2013
-		unset($alert_types['members']['buddy_request']);
2112
+	if (empty($modSettings['enable_buddylist'])) {
2113
+			unset($alert_types['members']['buddy_request']);
2114
+	}
2014 2115
 
2015 2116
 	// Now, now, we could pass this through global but we should really get into the habit of
2016 2117
 	// passing content to hooks, not expecting hooks to splatter everything everywhere.
@@ -2038,15 +2139,17 @@  discard block
 block discarded – undo
2038 2139
 			$perms_cache['manage_membergroups'] = in_array($memID, $members);
2039 2140
 		}
2040 2141
 
2041
-		if (!($perms_cache['manage_membergroups'] || $can_mod != 0))
2042
-			unset($alert_types['members']['request_group']);
2142
+		if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) {
2143
+					unset($alert_types['members']['request_group']);
2144
+		}
2043 2145
 
2044 2146
 		foreach ($alert_types as $group => $items)
2045 2147
 		{
2046 2148
 			foreach ($items as $alert_key => $alert_value)
2047 2149
 			{
2048
-				if (!isset($alert_value['permission']))
2049
-					continue;
2150
+				if (!isset($alert_value['permission'])) {
2151
+									continue;
2152
+				}
2050 2153
 				if (!isset($perms_cache[$alert_value['permission']['name']]))
2051 2154
 				{
2052 2155
 					$in_board = !empty($alert_value['permission']['is_board']) ? 0 : null;
@@ -2054,12 +2157,14 @@  discard block
 block discarded – undo
2054 2157
 					$perms_cache[$alert_value['permission']['name']] = in_array($memID, $members);
2055 2158
 				}
2056 2159
 
2057
-				if (!$perms_cache[$alert_value['permission']['name']])
2058
-					unset ($alert_types[$group][$alert_key]);
2160
+				if (!$perms_cache[$alert_value['permission']['name']]) {
2161
+									unset ($alert_types[$group][$alert_key]);
2162
+				}
2059 2163
 			}
2060 2164
 
2061
-			if (empty($alert_types[$group]))
2062
-				unset ($alert_types[$group]);
2165
+			if (empty($alert_types[$group])) {
2166
+							unset ($alert_types[$group]);
2167
+			}
2063 2168
 		}
2064 2169
 	}
2065 2170
 
@@ -2091,9 +2196,9 @@  discard block
 block discarded – undo
2091 2196
 						$update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0;
2092 2197
 						break;
2093 2198
 					case 'select':
2094
-						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]]))
2095
-							$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2096
-						else
2199
+						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) {
2200
+													$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2201
+						} else
2097 2202
 						{
2098 2203
 							// We didn't have a sane value. Let's grab the first item from the possibles.
2099 2204
 							$keys = array_keys($this_option['opts']);
@@ -2113,23 +2218,28 @@  discard block
 block discarded – undo
2113 2218
 				$this_value = 0;
2114 2219
 				foreach ($context['alert_bits'] as $type => $bitvalue)
2115 2220
 				{
2116
-					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always')
2117
-						$this_value |= $bitvalue;
2221
+					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') {
2222
+											$this_value |= $bitvalue;
2223
+					}
2224
+				}
2225
+				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) {
2226
+									$update_prefs[$item_key] = $this_value;
2118 2227
 				}
2119
-				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value)
2120
-					$update_prefs[$item_key] = $this_value;
2121 2228
 			}
2122 2229
 		}
2123 2230
 
2124
-		if (!empty($_POST['opt_alert_timeout']))
2125
-			$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2231
+		if (!empty($_POST['opt_alert_timeout'])) {
2232
+					$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2233
+		}
2126 2234
 
2127
-		if (!empty($_POST['notify_announcements']))
2128
-			$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2235
+		if (!empty($_POST['notify_announcements'])) {
2236
+					$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2237
+		}
2129 2238
 
2130 2239
 		setNotifyPrefs((int) $memID, $update_prefs);
2131
-		foreach ($update_prefs as $pref => $value)
2132
-			$context['alert_prefs'][$pref] = $value;
2240
+		foreach ($update_prefs as $pref => $value) {
2241
+					$context['alert_prefs'][$pref] = $value;
2242
+		}
2133 2243
 
2134 2244
 		makeNotificationChanges($memID);
2135 2245
 
@@ -2159,8 +2269,9 @@  discard block
 block discarded – undo
2159 2269
 
2160 2270
 	// Now we're all set up.
2161 2271
 	is_not_guest();
2162
-	if (!$context['user']['is_owner'])
2163
-		fatal_error('no_access');
2272
+	if (!$context['user']['is_owner']) {
2273
+			fatal_error('no_access');
2274
+	}
2164 2275
 
2165 2276
 	checkSession('get');
2166 2277
 
@@ -2192,8 +2303,9 @@  discard block
 block discarded – undo
2192 2303
 {
2193 2304
 	global $smcFunc;
2194 2305
 
2195
-	if (empty($toMark) || empty($memID))
2196
-		return false;
2306
+	if (empty($toMark) || empty($memID)) {
2307
+			return false;
2308
+	}
2197 2309
 
2198 2310
 	$toMark = (array) $toMark;
2199 2311
 
@@ -2227,8 +2339,9 @@  discard block
 block discarded – undo
2227 2339
 {
2228 2340
 	global $smcFunc;
2229 2341
 
2230
-	if (empty($toDelete))
2231
-		return false;
2342
+	if (empty($toDelete)) {
2343
+			return false;
2344
+	}
2232 2345
 
2233 2346
 	$toDelete = (array) $toDelete;
2234 2347
 
@@ -2263,8 +2376,9 @@  discard block
 block discarded – undo
2263 2376
 {
2264 2377
 	global $smcFunc;
2265 2378
 
2266
-	if (empty($memID))
2267
-		return false;
2379
+	if (empty($memID)) {
2380
+			return false;
2381
+	}
2268 2382
 
2269 2383
 	$request = $smcFunc['db_query']('', '
2270 2384
 		SELECT id_alert
@@ -2341,8 +2455,9 @@  discard block
 block discarded – undo
2341 2455
 					{
2342 2456
 						$link = $topic['link'];
2343 2457
 
2344
-						if ($topic['new'])
2345
-							$link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>';
2458
+						if ($topic['new']) {
2459
+													$link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>';
2460
+						}
2346 2461
 
2347 2462
 						$link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>';
2348 2463
 
@@ -2493,8 +2608,9 @@  discard block
 block discarded – undo
2493 2608
 					{
2494 2609
 						$link = $board['link'];
2495 2610
 
2496
-						if ($board['new'])
2497
-							$link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>';
2611
+						if ($board['new']) {
2612
+													$link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>';
2613
+						}
2498 2614
 
2499 2615
 						return $link;
2500 2616
 					},
@@ -2694,8 +2810,8 @@  discard block
 block discarded – undo
2694 2810
 		)
2695 2811
 	);
2696 2812
 	$notification_boards = array();
2697
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2698
-		$notification_boards[] = array(
2813
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2814
+			$notification_boards[] = array(
2699 2815
 			'id' => $row['id_board'],
2700 2816
 			'name' => $row['name'],
2701 2817
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
@@ -2703,6 +2819,7 @@  discard block
 block discarded – undo
2703 2819
 			'new' => $row['board_read'] < $row['id_msg_updated'],
2704 2820
 			'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0),
2705 2821
 		);
2822
+	}
2706 2823
 	$smcFunc['db_free_result']($request);
2707 2824
 
2708 2825
 	return $notification_boards;
@@ -2717,17 +2834,18 @@  discard block
 block discarded – undo
2717 2834
 {
2718 2835
 	global $context, $options, $cur_profile, $smcFunc;
2719 2836
 
2720
-	if (isset($_POST['default_options']))
2721
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2837
+	if (isset($_POST['default_options'])) {
2838
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2839
+	}
2722 2840
 
2723 2841
 	if ($context['user']['is_owner'])
2724 2842
 	{
2725 2843
 		$context['member']['options'] = $options;
2726
-		if (isset($_POST['options']) && is_array($_POST['options']))
2727
-			foreach ($_POST['options'] as $k => $v)
2844
+		if (isset($_POST['options']) && is_array($_POST['options'])) {
2845
+					foreach ($_POST['options'] as $k => $v)
2728 2846
 				$context['member']['options'][$k] = $v;
2729
-	}
2730
-	else
2847
+		}
2848
+	} else
2731 2849
 	{
2732 2850
 		$request = $smcFunc['db_query']('', '
2733 2851
 			SELECT id_member, variable, value
@@ -2748,8 +2866,9 @@  discard block
 block discarded – undo
2748 2866
 				continue;
2749 2867
 			}
2750 2868
 
2751
-			if (isset($_POST['options'][$row['variable']]))
2752
-				$row['value'] = $_POST['options'][$row['variable']];
2869
+			if (isset($_POST['options'][$row['variable']])) {
2870
+							$row['value'] = $_POST['options'][$row['variable']];
2871
+			}
2753 2872
 			$context['member']['options'][$row['variable']] = $row['value'];
2754 2873
 		}
2755 2874
 		$smcFunc['db_free_result']($request);
@@ -2757,8 +2876,9 @@  discard block
 block discarded – undo
2757 2876
 		// Load up the default theme options for any missing.
2758 2877
 		foreach ($temp as $k => $v)
2759 2878
 		{
2760
-			if (!isset($context['member']['options'][$k]))
2761
-				$context['member']['options'][$k] = $v;
2879
+			if (!isset($context['member']['options'][$k])) {
2880
+							$context['member']['options'][$k] = $v;
2881
+			}
2762 2882
 		}
2763 2883
 	}
2764 2884
 }
@@ -2773,8 +2893,9 @@  discard block
 block discarded – undo
2773 2893
 	global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir;
2774 2894
 
2775 2895
 	// Have the admins enabled this option?
2776
-	if (empty($modSettings['allow_ignore_boards']))
2777
-		fatal_lang_error('ignoreboards_disallowed', 'user');
2896
+	if (empty($modSettings['allow_ignore_boards'])) {
2897
+			fatal_lang_error('ignoreboards_disallowed', 'user');
2898
+	}
2778 2899
 
2779 2900
 	// Find all the boards this user is allowed to see.
2780 2901
 	$request = $smcFunc['db_query']('order_by_board_order', '
@@ -2794,12 +2915,13 @@  discard block
 block discarded – undo
2794 2915
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2795 2916
 	{
2796 2917
 		// This category hasn't been set up yet..
2797
-		if (!isset($context['categories'][$row['id_cat']]))
2798
-			$context['categories'][$row['id_cat']] = array(
2918
+		if (!isset($context['categories'][$row['id_cat']])) {
2919
+					$context['categories'][$row['id_cat']] = array(
2799 2920
 				'id' => $row['id_cat'],
2800 2921
 				'name' => $row['cat_name'],
2801 2922
 				'boards' => array()
2802 2923
 			);
2924
+		}
2803 2925
 
2804 2926
 		// Set this board up, and let the template know when it's a child.  (indent them..)
2805 2927
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -2829,18 +2951,20 @@  discard block
 block discarded – undo
2829 2951
 	}
2830 2952
 
2831 2953
 	$max_boards = ceil(count($temp_boards) / 2);
2832
-	if ($max_boards == 1)
2833
-		$max_boards = 2;
2954
+	if ($max_boards == 1) {
2955
+			$max_boards = 2;
2956
+	}
2834 2957
 
2835 2958
 	// Now, alternate them so they can be shown left and right ;).
2836 2959
 	$context['board_columns'] = array();
2837 2960
 	for ($i = 0; $i < $max_boards; $i++)
2838 2961
 	{
2839 2962
 		$context['board_columns'][] = $temp_boards[$i];
2840
-		if (isset($temp_boards[$i + $max_boards]))
2841
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
2842
-		else
2843
-			$context['board_columns'][] = array();
2963
+		if (isset($temp_boards[$i + $max_boards])) {
2964
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
2965
+		} else {
2966
+					$context['board_columns'][] = array();
2967
+		}
2844 2968
 	}
2845 2969
 
2846 2970
 	loadThemeOptions($memID);
@@ -2909,8 +3033,9 @@  discard block
 block discarded – undo
2909 3033
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2910 3034
 	{
2911 3035
 		// We should skip the administrator group if they don't have the admin_forum permission!
2912
-		if ($row['id_group'] == 1 && !allowedTo('admin_forum'))
2913
-			continue;
3036
+		if ($row['id_group'] == 1 && !allowedTo('admin_forum')) {
3037
+					continue;
3038
+		}
2914 3039
 
2915 3040
 		$context['member_groups'][$row['id_group']] = array(
2916 3041
 			'id' => $row['id_group'],
@@ -2956,16 +3081,17 @@  discard block
 block discarded – undo
2956 3081
 	$context['max_signature_length'] = $context['signature_limits']['max_length'];
2957 3082
 	// Warning message for signature image limits?
2958 3083
 	$context['signature_warning'] = '';
2959
-	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height'])
2960
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
2961
-	elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height'])
2962
-		$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']);
3084
+	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) {
3085
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
3086
+	} elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) {
3087
+			$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']);
3088
+	}
2963 3089
 
2964 3090
 	$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))));
2965 3091
 
2966
-	if (empty($context['do_preview']))
2967
-		$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
2968
-	else
3092
+	if (empty($context['do_preview'])) {
3093
+			$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
3094
+	} else
2969 3095
 	{
2970 3096
 		$signature = !empty($_POST['signature']) ? $_POST['signature'] : '';
2971 3097
 		$validation = profileValidateSignature($signature);
@@ -2975,8 +3101,9 @@  discard block
 block discarded – undo
2975 3101
 			$context['post_errors'] = array();
2976 3102
 		}
2977 3103
 		$context['post_errors'][] = 'signature_not_yet_saved';
2978
-		if ($validation !== true && $validation !== false)
2979
-			$context['post_errors'][] = $validation;
3104
+		if ($validation !== true && $validation !== false) {
3105
+					$context['post_errors'][] = $validation;
3106
+		}
2980 3107
 
2981 3108
 		censorText($context['member']['signature']);
2982 3109
 		$context['member']['current_signature'] = $context['member']['signature'];
@@ -2986,8 +3113,9 @@  discard block
 block discarded – undo
2986 3113
 	}
2987 3114
 
2988 3115
 	// Load the spell checker?
2989
-	if ($context['show_spellchecking'])
2990
-		loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3116
+	if ($context['show_spellchecking']) {
3117
+			loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3118
+	}
2991 3119
 
2992 3120
 	return true;
2993 3121
 }
@@ -3021,8 +3149,7 @@  discard block
 block discarded – undo
3021 3149
 			'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11)
3022 3150
 		);
3023 3151
 		$context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']);
3024
-	}
3025
-	elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3152
+	} elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3026 3153
 	{
3027 3154
 		$context['member']['avatar'] += array(
3028 3155
 			'choice' => 'upload',
@@ -3032,33 +3159,34 @@  discard block
 block discarded – undo
3032 3159
 		$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'];
3033 3160
 	}
3034 3161
 	// Use "avatar_original" here so we show what the user entered even if the image proxy is enabled
3035
-	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external'])
3036
-		$context['member']['avatar'] += array(
3162
+	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) {
3163
+			$context['member']['avatar'] += array(
3037 3164
 			'choice' => 'external',
3038 3165
 			'server_pic' => 'blank.png',
3039 3166
 			'external' => $cur_profile['avatar_original']
3040 3167
 		);
3041
-	elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored'])
3042
-		$context['member']['avatar'] += array(
3168
+	} elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) {
3169
+			$context['member']['avatar'] += array(
3043 3170
 			'choice' => 'server_stored',
3044 3171
 			'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'],
3045 3172
 			'external' => 'http://'
3046 3173
 		);
3047
-	else
3048
-		$context['member']['avatar'] += array(
3174
+	} else {
3175
+			$context['member']['avatar'] += array(
3049 3176
 			'choice' => 'none',
3050 3177
 			'server_pic' => 'blank.png',
3051 3178
 			'external' => 'http://'
3052 3179
 		);
3180
+	}
3053 3181
 
3054 3182
 	// Get a list of all the avatars.
3055 3183
 	if ($context['member']['avatar']['allow_server_stored'])
3056 3184
 	{
3057 3185
 		$context['avatar_list'] = array();
3058 3186
 		$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array();
3187
+	} else {
3188
+			$context['avatars'] = array();
3059 3189
 	}
3060
-	else
3061
-		$context['avatars'] = array();
3062 3190
 
3063 3191
 	// Second level selected avatar...
3064 3192
 	$context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1);
@@ -3087,19 +3215,22 @@  discard block
 block discarded – undo
3087 3215
 			)
3088 3216
 		);
3089 3217
 		$protected_groups = array(1);
3090
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3091
-			$protected_groups[] = $row['id_group'];
3218
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3219
+					$protected_groups[] = $row['id_group'];
3220
+		}
3092 3221
 		$smcFunc['db_free_result']($request);
3093 3222
 
3094 3223
 		$protected_groups = array_unique($protected_groups);
3095 3224
 	}
3096 3225
 
3097 3226
 	// The account page allows the change of your id_group - but not to a protected group!
3098
-	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0)
3099
-		$value = (int) $value;
3227
+	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) {
3228
+			$value = (int) $value;
3229
+	}
3100 3230
 	// ... otherwise it's the old group sir.
3101
-	else
3102
-		$value = $old_profile['id_group'];
3231
+	else {
3232
+			$value = $old_profile['id_group'];
3233
+	}
3103 3234
 
3104 3235
 	// Find the additional membergroups (if any)
3105 3236
 	if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups']))
@@ -3108,16 +3239,18 @@  discard block
 block discarded – undo
3108 3239
 		foreach ($_POST['additional_groups'] as $group_id)
3109 3240
 		{
3110 3241
 			$group_id = (int) $group_id;
3111
-			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups)))
3112
-				$additional_groups[] = $group_id;
3242
+			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) {
3243
+							$additional_groups[] = $group_id;
3244
+			}
3113 3245
 		}
3114 3246
 
3115 3247
 		// Put the protected groups back in there if you don't have permission to take them away.
3116 3248
 		$old_additional_groups = explode(',', $old_profile['additional_groups']);
3117 3249
 		foreach ($old_additional_groups as $group_id)
3118 3250
 		{
3119
-			if (!empty($protected_groups) && in_array($group_id, $protected_groups))
3120
-				$additional_groups[] = $group_id;
3251
+			if (!empty($protected_groups) && in_array($group_id, $protected_groups)) {
3252
+							$additional_groups[] = $group_id;
3253
+			}
3121 3254
 		}
3122 3255
 
3123 3256
 		if (implode(',', $additional_groups) !== $old_profile['additional_groups'])
@@ -3149,18 +3282,20 @@  discard block
 block discarded – undo
3149 3282
 			list ($another) = $smcFunc['db_fetch_row']($request);
3150 3283
 			$smcFunc['db_free_result']($request);
3151 3284
 
3152
-			if (empty($another))
3153
-				fatal_lang_error('at_least_one_admin', 'critical');
3285
+			if (empty($another)) {
3286
+							fatal_lang_error('at_least_one_admin', 'critical');
3287
+			}
3154 3288
 		}
3155 3289
 	}
3156 3290
 
3157 3291
 	// If we are changing group status, update permission cache as necessary.
3158 3292
 	if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups']))
3159 3293
 	{
3160
-		if ($context['user']['is_owner'])
3161
-			$_SESSION['mc']['time'] = 0;
3162
-		else
3163
-			updateSettings(array('settings_updated' => time()));
3294
+		if ($context['user']['is_owner']) {
3295
+					$_SESSION['mc']['time'] = 0;
3296
+		} else {
3297
+					updateSettings(array('settings_updated' => time()));
3298
+		}
3164 3299
 	}
3165 3300
 
3166 3301
 	// Announce to any hooks that we have changed groups, but don't allow them to change it.
@@ -3181,8 +3316,9 @@  discard block
 block discarded – undo
3181 3316
 	global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;
3182 3317
 
3183 3318
 	$memID = $context['id_member'];
3184
-	if (empty($memID) && !empty($context['password_auth_failed']))
3185
-		return false;
3319
+	if (empty($memID) && !empty($context['password_auth_failed'])) {
3320
+			return false;
3321
+	}
3186 3322
 
3187 3323
 	require_once($sourcedir . '/ManageAttachments.php');
3188 3324
 
@@ -3193,8 +3329,9 @@  discard block
 block discarded – undo
3193 3329
 	$downloadedExternalAvatar = false;
3194 3330
 	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']))
3195 3331
 	{
3196
-		if (!is_writable($uploadDir))
3197
-			fatal_lang_error('attachments_no_write', 'critical');
3332
+		if (!is_writable($uploadDir)) {
3333
+					fatal_lang_error('attachments_no_write', 'critical');
3334
+		}
3198 3335
 
3199 3336
 		$url = parse_url($_POST['userpicpersonal']);
3200 3337
 		$contents = fetch_web_data($url['scheme'] . '://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path'])));
@@ -3236,19 +3373,18 @@  discard block
 block discarded – undo
3236 3373
 
3237 3374
 		// Get rid of their old avatar. (if uploaded.)
3238 3375
 		removeAttachments(array('id_member' => $memID));
3239
-	}
3240
-	elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3376
+	} elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3241 3377
 	{
3242 3378
 		// 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.
3243
-		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL))
3244
-			$profile_vars['avatar'] = 'gravatar://';
3245
-		else
3246
-			$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3379
+		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) {
3380
+					$profile_vars['avatar'] = 'gravatar://';
3381
+		} else {
3382
+					$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3383
+		}
3247 3384
 
3248 3385
 		// Get rid of their old avatar. (if uploaded.)
3249 3386
 		removeAttachments(array('id_member' => $memID));
3250
-	}
3251
-	elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3387
+	} elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3252 3388
 	{
3253 3389
 		// We need these clean...
3254 3390
 		$cur_profile['id_attach'] = 0;
@@ -3260,11 +3396,13 @@  discard block
 block discarded – undo
3260 3396
 
3261 3397
 		$profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']));
3262 3398
 
3263
-		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///')
3264
-			$profile_vars['avatar'] = '';
3399
+		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') {
3400
+					$profile_vars['avatar'] = '';
3401
+		}
3265 3402
 		// Trying to make us do something we'll regret?
3266
-		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://')
3267
-			return 'bad_avatar_invalid_url';
3403
+		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') {
3404
+					return 'bad_avatar_invalid_url';
3405
+		}
3268 3406
 		// Should we check dimensions?
3269 3407
 		elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))
3270 3408
 		{
@@ -3274,9 +3412,9 @@  discard block
 block discarded – undo
3274 3412
 			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']))))
3275 3413
 			{
3276 3414
 				// Houston, we have a problem. The avatar is too large!!
3277
-				if ($modSettings['avatar_action_too_large'] == 'option_refuse')
3278
-					return 'bad_avatar_too_large';
3279
-				elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3415
+				if ($modSettings['avatar_action_too_large'] == 'option_refuse') {
3416
+									return 'bad_avatar_too_large';
3417
+				} elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3280 3418
 				{
3281 3419
 					// @todo remove this if appropriate
3282 3420
 					require_once($sourcedir . '/Subs-Graphics.php');
@@ -3286,26 +3424,27 @@  discard block
 block discarded – undo
3286 3424
 						$cur_profile['id_attach'] = $modSettings['new_avatar_data']['id'];
3287 3425
 						$cur_profile['filename'] = $modSettings['new_avatar_data']['filename'];
3288 3426
 						$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
3427
+					} else {
3428
+											return 'bad_avatar';
3289 3429
 					}
3290
-					else
3291
-						return 'bad_avatar';
3292 3430
 				}
3293 3431
 			}
3294 3432
 		}
3295
-	}
3296
-	elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3433
+	} elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3297 3434
 	{
3298 3435
 		if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar)
3299 3436
 		{
3300 3437
 			// Get the dimensions of the image.
3301 3438
 			if (!$downloadedExternalAvatar)
3302 3439
 			{
3303
-				if (!is_writable($uploadDir))
3304
-					fatal_lang_error('attachments_no_write', 'critical');
3440
+				if (!is_writable($uploadDir)) {
3441
+									fatal_lang_error('attachments_no_write', 'critical');
3442
+				}
3305 3443
 
3306 3444
 				$new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true);
3307
-				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename))
3308
-					fatal_lang_error('attach_timeout', 'critical');
3445
+				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) {
3446
+									fatal_lang_error('attach_timeout', 'critical');
3447
+				}
3309 3448
 
3310 3449
 				$_FILES['attachment']['tmp_name'] = $new_filename;
3311 3450
 			}
@@ -3418,17 +3557,19 @@  discard block
 block discarded – undo
3418 3557
 			$profile_vars['avatar'] = '';
3419 3558
 
3420 3559
 			// Delete any temporary file.
3421
-			if (file_exists($_FILES['attachment']['tmp_name']))
3422
-				@unlink($_FILES['attachment']['tmp_name']);
3560
+			if (file_exists($_FILES['attachment']['tmp_name'])) {
3561
+							@unlink($_FILES['attachment']['tmp_name']);
3562
+			}
3423 3563
 		}
3424 3564
 		// Selected the upload avatar option and had one already uploaded before or didn't upload one.
3425
-		else
3565
+		else {
3566
+					$profile_vars['avatar'] = '';
3567
+		}
3568
+	} elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) {
3569
+			$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3570
+	} else {
3426 3571
 			$profile_vars['avatar'] = '';
3427 3572
 	}
3428
-	elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar'))
3429
-		$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3430
-	else
3431
-		$profile_vars['avatar'] = '';
3432 3573
 
3433 3574
 	// Setup the profile variables so it shows things right on display!
3434 3575
 	$cur_profile['avatar'] = $profile_vars['avatar'];
@@ -3476,9 +3617,9 @@  discard block
 block discarded – undo
3476 3617
 		$smiley_parsed = $unparsed_signature;
3477 3618
 		parsesmileys($smiley_parsed);
3478 3619
 		$smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img');
3479
-		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0)
3480
-			return 'signature_allow_smileys';
3481
-		elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3620
+		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) {
3621
+					return 'signature_allow_smileys';
3622
+		} elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3482 3623
 		{
3483 3624
 			$txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]);
3484 3625
 			return 'signature_max_smileys';
@@ -3491,14 +3632,15 @@  discard block
 block discarded – undo
3491 3632
 			{
3492 3633
 				$limit_broke = 0;
3493 3634
 				// Attempt to allow all sizes of abuse, so to speak.
3494
-				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
3495
-					$limit_broke = $sig_limits[7] . 'px';
3496
-				elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
3497
-					$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3498
-				elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
3499
-					$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3500
-				elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
3501
-					$limit_broke = 'large';
3635
+				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
3636
+									$limit_broke = $sig_limits[7] . 'px';
3637
+				} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
3638
+									$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3639
+				} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
3640
+									$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3641
+				} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
3642
+									$limit_broke = 'large';
3643
+				}
3502 3644
 
3503 3645
 				if ($limit_broke)
3504 3646
 				{
@@ -3540,24 +3682,26 @@  discard block
 block discarded – undo
3540 3682
 					$width = -1; $height = -1;
3541 3683
 
3542 3684
 					// Does it have predefined restraints? Width first.
3543
-					if ($matches[6][$key])
3544
-						$matches[2][$key] = $matches[6][$key];
3685
+					if ($matches[6][$key]) {
3686
+											$matches[2][$key] = $matches[6][$key];
3687
+					}
3545 3688
 					if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
3546 3689
 					{
3547 3690
 						$width = $sig_limits[5];
3548 3691
 						$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
3692
+					} elseif ($matches[2][$key]) {
3693
+											$width = $matches[2][$key];
3549 3694
 					}
3550
-					elseif ($matches[2][$key])
3551
-						$width = $matches[2][$key];
3552 3695
 					// ... and height.
3553 3696
 					if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
3554 3697
 					{
3555 3698
 						$height = $sig_limits[6];
3556
-						if ($width != -1)
3557
-							$width = $width * ($height / $matches[4][$key]);
3699
+						if ($width != -1) {
3700
+													$width = $width * ($height / $matches[4][$key]);
3701
+						}
3702
+					} elseif ($matches[4][$key]) {
3703
+											$height = $matches[4][$key];
3558 3704
 					}
3559
-					elseif ($matches[4][$key])
3560
-						$height = $matches[4][$key];
3561 3705
 
3562 3706
 					// If the dimensions are still not fixed - we need to check the actual image.
3563 3707
 					if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -3575,21 +3719,24 @@  discard block
 block discarded – undo
3575 3719
 							if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
3576 3720
 							{
3577 3721
 								$height = $sig_limits[6];
3578
-								if ($width == -1)
3579
-									$width = $sizes[0];
3722
+								if ($width == -1) {
3723
+																	$width = $sizes[0];
3724
+								}
3580 3725
 								$width = $width * ($height / $sizes[1]);
3726
+							} elseif ($width != -1) {
3727
+															$height = $sizes[1];
3581 3728
 							}
3582
-							elseif ($width != -1)
3583
-								$height = $sizes[1];
3584 3729
 						}
3585 3730
 					}
3586 3731
 
3587 3732
 					// Did we come up with some changes? If so remake the string.
3588
-					if ($width != -1 || $height != -1)
3589
-						$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3733
+					if ($width != -1 || $height != -1) {
3734
+											$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3735
+					}
3736
+				}
3737
+				if (!empty($replaces)) {
3738
+									$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3590 3739
 				}
3591
-				if (!empty($replaces))
3592
-					$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3593 3740
 			}
3594 3741
 		}
3595 3742
 
@@ -3633,10 +3780,12 @@  discard block
 block discarded – undo
3633 3780
 	$email = strtr($email, array('&#039;' => '\''));
3634 3781
 
3635 3782
 	// Check the name and email for validity.
3636
-	if (trim($email) == '')
3637
-		return 'no_email';
3638
-	if (!filter_var($email, FILTER_VALIDATE_EMAIL))
3639
-		return 'bad_email';
3783
+	if (trim($email) == '') {
3784
+			return 'no_email';
3785
+	}
3786
+	if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
3787
+			return 'bad_email';
3788
+	}
3640 3789
 
3641 3790
 	// Email addresses should be and stay unique.
3642 3791
 	$request = $smcFunc['db_query']('', '
@@ -3651,8 +3800,9 @@  discard block
 block discarded – undo
3651 3800
 		)
3652 3801
 	);
3653 3802
 
3654
-	if ($smcFunc['db_num_rows']($request) > 0)
3655
-		return 'email_taken';
3803
+	if ($smcFunc['db_num_rows']($request) > 0) {
3804
+			return 'email_taken';
3805
+	}
3656 3806
 	$smcFunc['db_free_result']($request);
3657 3807
 
3658 3808
 	return true;
@@ -3665,8 +3815,9 @@  discard block
 block discarded – undo
3665 3815
 {
3666 3816
 	global $modSettings, $context, $cur_profile;
3667 3817
 
3668
-	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '')
3669
-		setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3818
+	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') {
3819
+			setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3820
+	}
3670 3821
 
3671 3822
 	loadUserSettings();
3672 3823
 	writeLog();
@@ -3682,8 +3833,9 @@  discard block
 block discarded – undo
3682 3833
 	require_once($sourcedir . '/Subs-Post.php');
3683 3834
 
3684 3835
 	// Shouldn't happen but just in case.
3685
-	if (empty($profile_vars['email_address']))
3686
-		return;
3836
+	if (empty($profile_vars['email_address'])) {
3837
+			return;
3838
+	}
3687 3839
 
3688 3840
 	$replacements = array(
3689 3841
 		'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'],
@@ -3706,8 +3858,9 @@  discard block
 block discarded – undo
3706 3858
 	$_SESSION['log_time'] = 0;
3707 3859
 	$_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0));
3708 3860
 
3709
-	if (isset($_COOKIE[$cookiename]))
3710
-		$_COOKIE[$cookiename] = '';
3861
+	if (isset($_COOKIE[$cookiename])) {
3862
+			$_COOKIE[$cookiename] = '';
3863
+	}
3711 3864
 
3712 3865
 	loadUserSettings();
3713 3866
 
@@ -3740,11 +3893,13 @@  discard block
 block discarded – undo
3740 3893
 	$groups[] = $curMember['id_group'];
3741 3894
 
3742 3895
 	// Ensure the query doesn't croak!
3743
-	if (empty($groups))
3744
-		$groups = array(0);
3896
+	if (empty($groups)) {
3897
+			$groups = array(0);
3898
+	}
3745 3899
 	// Just to be sure...
3746
-	foreach ($groups as $k => $v)
3747
-		$groups[$k] = (int) $v;
3900
+	foreach ($groups as $k => $v) {
3901
+			$groups[$k] = (int) $v;
3902
+	}
3748 3903
 
3749 3904
 	// Get all the membergroups they can join.
3750 3905
 	$request = $smcFunc['db_query']('', '
@@ -3774,12 +3929,14 @@  discard block
 block discarded – undo
3774 3929
 	while ($row = $smcFunc['db_fetch_assoc']($request))
3775 3930
 	{
3776 3931
 		// Can they edit their primary group?
3777
-		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups)))
3778
-			$context['can_edit_primary'] = true;
3932
+		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) {
3933
+					$context['can_edit_primary'] = true;
3934
+		}
3779 3935
 
3780 3936
 		// If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it.
3781
-		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group'])
3782
-			continue;
3937
+		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) {
3938
+					continue;
3939
+		}
3783 3940
 
3784 3941
 		$context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array(
3785 3942
 			'id' => $row['id_group'],
@@ -3808,13 +3965,15 @@  discard block
 block discarded – undo
3808 3965
 	);
3809 3966
 
3810 3967
 	// No changing primary one unless you have enough groups!
3811
-	if (count($context['groups']['member']) < 2)
3812
-		$context['can_edit_primary'] = false;
3968
+	if (count($context['groups']['member']) < 2) {
3969
+			$context['can_edit_primary'] = false;
3970
+	}
3813 3971
 
3814 3972
 	// In the special case that someone is requesting membership of a group, setup some special context vars.
3815
-	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2)
3816
-		$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3817
-}
3973
+	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) {
3974
+			$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3975
+	}
3976
+	}
3818 3977
 
3819 3978
 /**
3820 3979
  * This function actually makes all the group changes
@@ -3829,10 +3988,12 @@  discard block
 block discarded – undo
3829 3988
 	global $user_info, $context, $user_profile, $modSettings, $smcFunc;
3830 3989
 
3831 3990
 	// Let's be extra cautious...
3832
-	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership']))
3833
-		isAllowedTo('manage_membergroups');
3834
-	if (!isset($_REQUEST['gid']) && !isset($_POST['primary']))
3835
-		fatal_lang_error('no_access', false);
3991
+	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) {
3992
+			isAllowedTo('manage_membergroups');
3993
+	}
3994
+	if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) {
3995
+			fatal_lang_error('no_access', false);
3996
+	}
3836 3997
 
3837 3998
 	checkSession(isset($_GET['gid']) ? 'get' : 'post');
3838 3999
 
@@ -3851,8 +4012,9 @@  discard block
 block discarded – undo
3851 4012
 	$foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false;
3852 4013
 
3853 4014
 	// Sanity check!!
3854
-	if ($group_id == 1)
3855
-		isAllowedTo('admin_forum');
4015
+	if ($group_id == 1) {
4016
+			isAllowedTo('admin_forum');
4017
+	}
3856 4018
 	// Protected groups too!
3857 4019
 	else
3858 4020
 	{
@@ -3869,8 +4031,9 @@  discard block
 block discarded – undo
3869 4031
 		list ($is_protected) = $smcFunc['db_fetch_row']($request);
3870 4032
 		$smcFunc['db_free_result']($request);
3871 4033
 
3872
-		if ($is_protected == 1)
3873
-			isAllowedTo('admin_forum');
4034
+		if ($is_protected == 1) {
4035
+					isAllowedTo('admin_forum');
4036
+		}
3874 4037
 	}
3875 4038
 
3876 4039
 	// What ever we are doing, we need to determine if changing primary is possible!
@@ -3892,36 +4055,43 @@  discard block
 block discarded – undo
3892 4055
 			$group_name = $row['group_name'];
3893 4056
 
3894 4057
 			// Does the group type match what we're doing - are we trying to request a non-requestable group?
3895
-			if ($changeType == 'request' && $row['group_type'] != 2)
3896
-				fatal_lang_error('no_access', false);
4058
+			if ($changeType == 'request' && $row['group_type'] != 2) {
4059
+							fatal_lang_error('no_access', false);
4060
+			}
3897 4061
 			// What about leaving a requestable group we are not a member of?
3898
-			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']]))
3899
-				fatal_lang_error('no_access', false);
3900
-			elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2)
3901
-				fatal_lang_error('no_access', false);
4062
+			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) {
4063
+							fatal_lang_error('no_access', false);
4064
+			} elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) {
4065
+							fatal_lang_error('no_access', false);
4066
+			}
3902 4067
 
3903 4068
 			// We can't change the primary group if this is hidden!
3904
-			if ($row['hidden'] == 2)
3905
-				$canChangePrimary = false;
4069
+			if ($row['hidden'] == 2) {
4070
+							$canChangePrimary = false;
4071
+			}
3906 4072
 		}
3907 4073
 
3908 4074
 		// If this is their old primary, can we change it?
3909
-		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false)
3910
-			$canChangePrimary = 1;
4075
+		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) {
4076
+					$canChangePrimary = 1;
4077
+		}
3911 4078
 
3912 4079
 		// If we are not doing a force primary move, don't do it automatically if current primary is not 0.
3913
-		if ($changeType != 'primary' && $old_profile['id_group'] != 0)
3914
-			$canChangePrimary = false;
4080
+		if ($changeType != 'primary' && $old_profile['id_group'] != 0) {
4081
+					$canChangePrimary = false;
4082
+		}
3915 4083
 
3916 4084
 		// If this is the one we are acting on, can we even act?
3917
-		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0))
3918
-			$canChangePrimary = false;
4085
+		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) {
4086
+					$canChangePrimary = false;
4087
+		}
3919 4088
 	}
3920 4089
 	$smcFunc['db_free_result']($request);
3921 4090
 
3922 4091
 	// Didn't find the target?
3923
-	if (!$foundTarget)
3924
-		fatal_lang_error('no_access', false);
4092
+	if (!$foundTarget) {
4093
+			fatal_lang_error('no_access', false);
4094
+	}
3925 4095
 
3926 4096
 	// Final security check, don't allow users to promote themselves to admin.
3927 4097
 	if ($context['can_manage_membergroups'] && !allowedTo('admin_forum'))
@@ -3941,8 +4111,9 @@  discard block
 block discarded – undo
3941 4111
 		list ($disallow) = $smcFunc['db_fetch_row']($request);
3942 4112
 		$smcFunc['db_free_result']($request);
3943 4113
 
3944
-		if ($disallow)
3945
-			isAllowedTo('admin_forum');
4114
+		if ($disallow) {
4115
+					isAllowedTo('admin_forum');
4116
+		}
3946 4117
 	}
3947 4118
 
3948 4119
 	// If we're requesting, add the note then return.
@@ -3960,8 +4131,9 @@  discard block
 block discarded – undo
3960 4131
 				'status_open' => 0,
3961 4132
 			)
3962 4133
 		);
3963
-		if ($smcFunc['db_num_rows']($request) != 0)
3964
-			fatal_lang_error('profile_error_already_requested_group');
4134
+		if ($smcFunc['db_num_rows']($request) != 0) {
4135
+					fatal_lang_error('profile_error_already_requested_group');
4136
+		}
3965 4137
 		$smcFunc['db_free_result']($request);
3966 4138
 
3967 4139
 		// Log the request.
@@ -3995,10 +4167,11 @@  discard block
 block discarded – undo
3995 4167
 		// Are we leaving?
3996 4168
 		if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id]))
3997 4169
 		{
3998
-			if ($old_profile['id_group'] == $group_id)
3999
-				$newPrimary = 0;
4000
-			else
4001
-				unset($addGroups[$group_id]);
4170
+			if ($old_profile['id_group'] == $group_id) {
4171
+							$newPrimary = 0;
4172
+			} else {
4173
+							unset($addGroups[$group_id]);
4174
+			}
4002 4175
 		}
4003 4176
 		// ... if not, must be joining.
4004 4177
 		else
@@ -4006,36 +4179,42 @@  discard block
 block discarded – undo
4006 4179
 			// Can we change the primary, and do we want to?
4007 4180
 			if ($canChangePrimary)
4008 4181
 			{
4009
-				if ($old_profile['id_group'] != 0)
4010
-					$addGroups[$old_profile['id_group']] = -1;
4182
+				if ($old_profile['id_group'] != 0) {
4183
+									$addGroups[$old_profile['id_group']] = -1;
4184
+				}
4011 4185
 				$newPrimary = $group_id;
4012 4186
 			}
4013 4187
 			// Otherwise it's an additional group...
4014
-			else
4015
-				$addGroups[$group_id] = -1;
4188
+			else {
4189
+							$addGroups[$group_id] = -1;
4190
+			}
4016 4191
 		}
4017 4192
 	}
4018 4193
 	// Finally, we must be setting the primary.
4019 4194
 	elseif ($canChangePrimary)
4020 4195
 	{
4021
-		if ($old_profile['id_group'] != 0)
4022
-			$addGroups[$old_profile['id_group']] = -1;
4023
-		if (isset($addGroups[$group_id]))
4024
-			unset($addGroups[$group_id]);
4196
+		if ($old_profile['id_group'] != 0) {
4197
+					$addGroups[$old_profile['id_group']] = -1;
4198
+		}
4199
+		if (isset($addGroups[$group_id])) {
4200
+					unset($addGroups[$group_id]);
4201
+		}
4025 4202
 		$newPrimary = $group_id;
4026 4203
 	}
4027 4204
 
4028 4205
 	// Finally, we can make the changes!
4029
-	foreach ($addGroups as $id => $dummy)
4030
-		if (empty($id))
4206
+	foreach ($addGroups as $id => $dummy) {
4207
+			if (empty($id))
4031 4208
 			unset($addGroups[$id]);
4209
+	}
4032 4210
 	$addGroups = implode(',', array_flip($addGroups));
4033 4211
 
4034 4212
 	// Ensure that we don't cache permissions if the group is changing.
4035
-	if ($context['user']['is_owner'])
4036
-		$_SESSION['mc']['time'] = 0;
4037
-	else
4038
-		updateSettings(array('settings_updated' => time()));
4213
+	if ($context['user']['is_owner']) {
4214
+			$_SESSION['mc']['time'] = 0;
4215
+	} else {
4216
+			updateSettings(array('settings_updated' => time()));
4217
+	}
4039 4218
 
4040 4219
 	updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups));
4041 4220
 
@@ -4058,8 +4237,9 @@  discard block
 block discarded – undo
4058 4237
 	if (empty($user_settings['tfa_secret']) && $context['user']['is_owner'])
4059 4238
 	{
4060 4239
 		// Check to ensure we're forcing SSL for authentication
4061
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
4062
-			fatal_lang_error('login_ssl_required');
4240
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
4241
+					fatal_lang_error('login_ssl_required');
4242
+		}
4063 4243
 
4064 4244
 		// In some cases (forced 2FA or backup code) they would be forced to be redirected here,
4065 4245
 		// we do not want too much AJAX to confuse them.
@@ -4096,8 +4276,7 @@  discard block
 block discarded – undo
4096 4276
 				$context['sub_template'] = 'tfasetup_backup';
4097 4277
 
4098 4278
 				return;
4099
-			}
4100
-			else
4279
+			} else
4101 4280
 			{
4102 4281
 				$context['tfa_secret'] = $_SESSION['tfa_secret'];
4103 4282
 				$context['tfa_error'] = !$valid_code;
@@ -4105,8 +4284,7 @@  discard block
 block discarded – undo
4105 4284
 				$context['tfa_pass_value'] = $_POST['passwd'];
4106 4285
 				$context['tfa_value'] = $_POST['tfa_code'];
4107 4286
 			}
4108
-		}
4109
-		else
4287
+		} else
4110 4288
 		{
4111 4289
 			$totp = new \TOTP\Auth();
4112 4290
 			$secret = $totp->generateCode();
@@ -4116,17 +4294,16 @@  discard block
 block discarded – undo
4116 4294
 		}
4117 4295
 
4118 4296
 		$context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']);
4119
-	}
4120
-	elseif (isset($_REQUEST['disable']))
4297
+	} elseif (isset($_REQUEST['disable']))
4121 4298
 	{
4122 4299
 		updateMemberData($memID, array(
4123 4300
 			'tfa_secret' => '',
4124 4301
 			'tfa_backup' => '',
4125 4302
 		));
4126 4303
 		redirectexit('action=profile;area=account;u=' . $memID);
4304
+	} else {
4305
+			redirectexit('action=profile;area=account;u=' . $memID);
4306
+	}
4127 4307
 	}
4128
-	else
4129
-		redirectexit('action=profile;area=account;u=' . $memID);
4130
-}
4131 4308
 
4132 4309
 ?>
4133 4310
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Class-Punycode.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@
 block discarded – undo
18 18
  * @version 2.1 Beta 4
19 19
  */
20 20
 
21
-if (!defined('SMF'))
21
+if (!defined('SMF')) {
22 22
     die('No direct access...');
23
+}
23 24
 
24 25
 /**
25 26
  * Punycode implementation as described in RFC 3492
Please login to merge, or discard this patch.