Completed
Pull Request — release-2.1 (#4398)
by Colin
07:12
created
Themes/default/Reports.template.php 1 patch
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,9 +29,10 @@  discard block
 block discarded – undo
29 29
 	// Go through each type of report they can run.
30 30
 	foreach ($context['report_types'] as $type)
31 31
 	{
32
-		if (isset($type['description']))
33
-			echo '
32
+		if (isset($type['description'])) {
33
+					echo '
34 34
 					<dt>', $type['description'], '</dt>';
35
+		}
35 36
 		echo '
36 37
 					<dd>
37 38
 						<input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', '>
@@ -61,8 +62,9 @@  discard block
 block discarded – undo
61 62
 		</div>
62 63
 		<div id="report_buttons">';
63 64
 
64
-	if (!empty($context['report_buttons']))
65
-		template_button_strip($context['report_buttons'], 'right');
65
+	if (!empty($context['report_buttons'])) {
66
+			template_button_strip($context['report_buttons'], 'right');
67
+	}
66 68
 
67 69
 	echo '
68 70
 		</div>';
@@ -73,25 +75,27 @@  discard block
 block discarded – undo
73 75
 		echo '
74 76
 		<table class="table_grid report_results">';
75 77
 
76
-		if (!empty($table['title']))
77
-			echo '
78
+		if (!empty($table['title'])) {
79
+					echo '
78 80
 			<thead>
79 81
 				<tr class="title_bar">
80 82
 					<th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th>
81 83
 				</tr>
82 84
 			</thead>
83 85
 			<tbody>';
86
+		}
84 87
 
85 88
 		// Now do each row!
86 89
 		$row_number = 0;
87 90
 		foreach ($table['data'] as $row)
88 91
 		{
89
-			if ($row_number == 0 && !empty($table['shading']['top']))
90
-				echo '
92
+			if ($row_number == 0 && !empty($table['shading']['top'])) {
93
+							echo '
91 94
 				<tr class="windowbg table_caption">';
92
-			else
93
-				echo '
95
+			} else {
96
+							echo '
94 97
 				<tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">';
98
+			}
95 99
 
96 100
 			// Now do each column.
97 101
 			$column_number = 0;
@@ -109,16 +113,17 @@  discard block
 block discarded – undo
109 113
 				}
110 114
 
111 115
 				// Shaded?
112
-				if ($column_number == 0 && !empty($table['shading']['left']))
113
-					echo '
116
+				if ($column_number == 0 && !empty($table['shading']['left'])) {
117
+									echo '
114 118
 					<td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '>
115 119
 						', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), '
116 120
 					</td>';
117
-				else
118
-					echo '
121
+				} else {
122
+									echo '
119 123
 					<td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '>
120 124
 						', $data['v'], '
121 125
 					</td>';
126
+				}
122 127
 
123 128
 				$column_number++;
124 129
 			}
@@ -167,24 +172,26 @@  discard block
 block discarded – undo
167 172
 		<div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '">
168 173
 			<table class="bordercolor">';
169 174
 
170
-		if (!empty($table['title']))
171
-			echo '
175
+		if (!empty($table['title'])) {
176
+					echo '
172 177
 				<tr class="title_bar">
173 178
 					<td colspan="', $table['column_count'], '">
174 179
 						', $table['title'], '
175 180
 					</td>
176 181
 				</tr>';
182
+		}
177 183
 
178 184
 		// Now do each row!
179 185
 		$row_number = 0;
180 186
 		foreach ($table['data'] as $row)
181 187
 		{
182
-			if ($row_number == 0 && !empty($table['shading']['top']))
183
-				echo '
188
+			if ($row_number == 0 && !empty($table['shading']['top'])) {
189
+							echo '
184 190
 				<tr class="titlebg">';
185
-			else
186
-				echo '
191
+			} else {
192
+							echo '
187 193
 				<tr class="windowbg">';
194
+			}
188 195
 
189 196
 			// Now do each column!!
190 197
 			$column_number = 0;
@@ -201,16 +208,17 @@  discard block
 block discarded – undo
201 208
 				}
202 209
 
203 210
 				// Shaded?
204
-				if ($column_number == 0 && !empty($table['shading']['left']))
205
-					echo '
211
+				if ($column_number == 0 && !empty($table['shading']['left'])) {
212
+									echo '
206 213
 					<td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '>
207 214
 						', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), '
208 215
 					</td>';
209
-				else
210
-					echo '
216
+				} else {
217
+									echo '
211 218
 					<td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '>
212 219
 						', $data['v'], '
213 220
 					</td>';
221
+				}
214 222
 
215 223
 				$column_number++;
216 224
 			}
Please login to merge, or discard this patch.
Sources/ManageNews.php 1 patch
Braces   +140 added lines, -102 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 news dispatcher; doesn't do anything, just delegates.
@@ -67,8 +68,9 @@  discard block
 block discarded – undo
67 68
 	);
68 69
 
69 70
 	// Force the right area...
70
-	if (substr($_REQUEST['sa'], 0, 7) == 'mailing')
71
-		$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
71
+	if (substr($_REQUEST['sa'], 0, 7) == 'mailing') {
72
+			$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
73
+	}
72 74
 
73 75
 	call_helper($subActions[$_REQUEST['sa']][0]);
74 76
 }
@@ -99,9 +101,10 @@  discard block
 block discarded – undo
99 101
 		$temp_news = explode("\n", $modSettings['news']);
100 102
 
101 103
 		// Remove the items that were selected.
102
-		foreach ($temp_news as $i => $news)
103
-			if (in_array($i, $_POST['remove']))
104
+		foreach ($temp_news as $i => $news) {
105
+					if (in_array($i, $_POST['remove']))
104 106
 				unset($temp_news[$i]);
107
+		}
105 108
 
106 109
 		// Update the database.
107 110
 		updateSettings(array('news' => implode("\n", $temp_news)));
@@ -117,9 +120,9 @@  discard block
 block discarded – undo
117 120
 
118 121
 		foreach ($_POST['news'] as $i => $news)
119 122
 		{
120
-			if (trim($news) == '')
121
-				unset($_POST['news'][$i]);
122
-			else
123
+			if (trim($news) == '') {
124
+							unset($_POST['news'][$i]);
125
+			} else
123 126
 			{
124 127
 				$_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES);
125 128
 				preparsecode($_POST['news'][$i]);
@@ -154,11 +157,12 @@  discard block
 block discarded – undo
154 157
 				'data' => array(
155 158
 					'function' => function($news)
156 159
 					{
157
-						if (is_numeric($news['id']))
158
-							return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea>
160
+						if (is_numeric($news['id'])) {
161
+													return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea>
159 162
 							<div class="floatleft" id="preview_' . $news['id'] . '"></div>';
160
-						else
161
-							return $news['unparsed'];
163
+						} else {
164
+													return $news['unparsed'];
165
+						}
162 166
 					},
163 167
 					'style' => 'width: 50%;',
164 168
 				),
@@ -183,10 +187,11 @@  discard block
 block discarded – undo
183 187
 				'data' => array(
184 188
 					'function' => function($news)
185 189
 					{
186
-						if (is_numeric($news['id']))
187
-							return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">';
188
-						else
189
-							return '';
190
+						if (is_numeric($news['id'])) {
191
+													return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">';
192
+						} else {
193
+													return '';
194
+						}
190 195
 					},
191 196
 					'class' => 'centercol',
192 197
 				),
@@ -280,12 +285,13 @@  discard block
 block discarded – undo
280 285
 
281 286
 	$admin_current_news = array();
282 287
 	// Ready the current news.
283
-	foreach (explode("\n", $modSettings['news']) as $id => $line)
284
-		$admin_current_news[$id] = array(
288
+	foreach (explode("\n", $modSettings['news']) as $id => $line) {
289
+			$admin_current_news[$id] = array(
285 290
 			'id' => $id,
286 291
 			'unparsed' => un_preparsecode($line),
287 292
 			'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext">&lt;$1form&gt;</em>', parse_bbc($line)),
288 293
 		);
294
+	}
289 295
 
290 296
 	$admin_current_news['last'] = array(
291 297
 		'id' => 'last',
@@ -352,10 +358,11 @@  discard block
 block discarded – undo
352 358
 			'member_count' => 0,
353 359
 		);
354 360
 
355
-		if ($row['min_posts'] == -1)
356
-			$normalGroups[$row['id_group']] = $row['id_group'];
357
-		else
358
-			$postGroups[$row['id_group']] = $row['id_group'];
361
+		if ($row['min_posts'] == -1) {
362
+					$normalGroups[$row['id_group']] = $row['id_group'];
363
+		} else {
364
+					$postGroups[$row['id_group']] = $row['id_group'];
365
+		}
359 366
 	}
360 367
 	$smcFunc['db_free_result']($request);
361 368
 
@@ -371,8 +378,9 @@  discard block
 block discarded – undo
371 378
 				'post_group_list' => $postGroups,
372 379
 			)
373 380
 		);
374
-		while ($row = $smcFunc['db_fetch_assoc']($query))
375
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
381
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
382
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
383
+		}
376 384
 		$smcFunc['db_free_result']($query);
377 385
 	}
378 386
 
@@ -388,8 +396,9 @@  discard block
 block discarded – undo
388 396
 				'normal_group_list' => $normalGroups,
389 397
 			)
390 398
 		);
391
-		while ($row = $smcFunc['db_fetch_assoc']($query))
392
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
399
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
400
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
401
+		}
393 402
 		$smcFunc['db_free_result']($query);
394 403
 
395 404
 		// Also do those who have it as an additional membergroup - this ones more yucky...
@@ -406,8 +415,9 @@  discard block
 block discarded – undo
406 415
 				'blank_string' => '',
407 416
 			)
408 417
 		);
409
-		while ($row = $smcFunc['db_fetch_assoc']($query))
410
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
418
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
419
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
420
+		}
411 421
 		$smcFunc['db_free_result']($query);
412 422
 	}
413 423
 
@@ -458,10 +468,11 @@  discard block
 block discarded – undo
458 468
 	{
459 469
 		$context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : '';
460 470
 
461
-		if (empty($context[$key]) && empty($_REQUEST['xml']))
462
-			$context['post_error']['messages'][] = $txt['error_no_' . $post];
463
-		elseif (!empty($_REQUEST['xml']))
464
-			continue;
471
+		if (empty($context[$key]) && empty($_REQUEST['xml'])) {
472
+					$context['post_error']['messages'][] = $txt['error_no_' . $post];
473
+		} elseif (!empty($_REQUEST['xml'])) {
474
+					continue;
475
+		}
465 476
 
466 477
 		preparsecode($context[$key]);
467 478
 		if ($html)
@@ -540,10 +551,12 @@  discard block
 block discarded – undo
540 551
 
541 552
 	// Start by finding any members!
542 553
 	$toClean = array();
543
-	if (!empty($_POST['members']))
544
-		$toClean[] = 'members';
545
-	if (!empty($_POST['exclude_members']))
546
-		$toClean[] = 'exclude_members';
554
+	if (!empty($_POST['members'])) {
555
+			$toClean[] = 'members';
556
+	}
557
+	if (!empty($_POST['exclude_members'])) {
558
+			$toClean[] = 'exclude_members';
559
+	}
547 560
 	if (!empty($toClean))
548 561
 	{
549 562
 		require_once($sourcedir . '/Subs-Auth.php');
@@ -555,11 +568,13 @@  discard block
 block discarded – undo
555 568
 			preg_match_all('~"([^"]+)"~', $_POST[$type], $matches);
556 569
 			$_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type]))));
557 570
 
558
-			foreach ($_POST[$type] as $index => $member)
559
-				if (strlen(trim($member)) > 0)
571
+			foreach ($_POST[$type] as $index => $member) {
572
+							if (strlen(trim($member)) > 0)
560 573
 					$_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member)));
561
-				else
562
-					unset($_POST[$type][$index]);
574
+			}
575
+				else {
576
+									unset($_POST[$type][$index]);
577
+				}
563 578
 
564 579
 			// Find the members
565 580
 			$_POST[$type] = implode(',', array_keys(findMembers($_POST[$type])));
@@ -569,16 +584,18 @@  discard block
 block discarded – undo
569 584
 	if (isset($_POST['member_list']) && is_array($_POST['member_list']))
570 585
 	{
571 586
 		$members = array();
572
-		foreach ($_POST['member_list'] as $member_id)
573
-			$members[] = (int) $member_id;
587
+		foreach ($_POST['member_list'] as $member_id) {
588
+					$members[] = (int) $member_id;
589
+		}
574 590
 		$_POST['members'] = implode(',', $members);
575 591
 	}
576 592
 
577 593
 	if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list']))
578 594
 	{
579 595
 		$members = array();
580
-		foreach ($_POST['exclude_member_list'] as $member_id)
581
-			$members[] = (int) $member_id;
596
+		foreach ($_POST['exclude_member_list'] as $member_id) {
597
+					$members[] = (int) $member_id;
598
+		}
582 599
 		$_POST['exclude_members'] = implode(',', $members);
583 600
 	}
584 601
 
@@ -602,8 +619,9 @@  discard block
 block discarded – undo
602 619
 			'current_time' => time(),
603 620
 		)
604 621
 	);
605
-	while ($row = $smcFunc['db_fetch_assoc']($request))
606
-		$context['recipients']['exclude_members'][] = $row['id_member'];
622
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
623
+			$context['recipients']['exclude_members'][] = $row['id_member'];
624
+	}
607 625
 	$smcFunc['db_free_result']($request);
608 626
 
609 627
 	$request = $smcFunc['db_query']('', '
@@ -638,8 +656,9 @@  discard block
 block discarded – undo
638 656
 			WHERE email_address IN(' . implode(', ', $condition_array) . ')',
639 657
 			$condition_array_params
640 658
 		);
641
-		while ($row = $smcFunc['db_fetch_assoc']($request))
642
-			$context['recipients']['exclude_members'][] = $row['id_member'];
659
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
660
+					$context['recipients']['exclude_members'][] = $row['id_member'];
661
+		}
643 662
 		$smcFunc['db_free_result']($request);
644 663
 	}
645 664
 
@@ -657,10 +676,11 @@  discard block
 block discarded – undo
657 676
 		);
658 677
 		while ($row = $smcFunc['db_fetch_assoc']($request))
659 678
 		{
660
-			if (in_array(3, $context['recipients']))
661
-				$context['recipients']['exclude_members'][] = $row['identifier'];
662
-			else
663
-				$context['recipients']['members'][] = $row['identifier'];
679
+			if (in_array(3, $context['recipients'])) {
680
+							$context['recipients']['exclude_members'][] = $row['identifier'];
681
+			} else {
682
+							$context['recipients']['members'][] = $row['identifier'];
683
+			}
664 684
 		}
665 685
 		$smcFunc['db_free_result']($request);
666 686
 	}
@@ -707,8 +727,9 @@  discard block
 block discarded – undo
707 727
 	$num_at_once = 1000;
708 728
 
709 729
 	// If by PM's I suggest we half the above number.
710
-	if (!empty($_POST['send_pm']))
711
-		$num_at_once /= 2;
730
+	if (!empty($_POST['send_pm'])) {
731
+			$num_at_once /= 2;
732
+	}
712 733
 
713 734
 	checkSession();
714 735
 
@@ -731,8 +752,7 @@  discard block
 block discarded – undo
731 752
 		);
732 753
 		list ($context['total_members']) = $smcFunc['db_fetch_row']($request);
733 754
 		$smcFunc['db_free_result']($request);
734
-	}
735
-	else
755
+	} else
736 756
 	{
737 757
 		$context['total_members'] = (int) $_REQUEST['total_members'];
738 758
 	}
@@ -750,32 +770,35 @@  discard block
 block discarded – undo
750 770
 	if (!empty($_POST['exclude_members']))
751 771
 	{
752 772
 		$members = explode(',', $_POST['exclude_members']);
753
-		foreach ($members as $member)
754
-			if ($member >= $context['start'])
773
+		foreach ($members as $member) {
774
+					if ($member >= $context['start'])
755 775
 				$context['recipients']['exclude_members'][] = (int) $member;
776
+		}
756 777
 	}
757 778
 
758 779
 	// What about members we *must* do?
759 780
 	if (!empty($_POST['members']))
760 781
 	{
761 782
 		$members = explode(',', $_POST['members']);
762
-		foreach ($members as $member)
763
-			if ($member >= $context['start'])
783
+		foreach ($members as $member) {
784
+					if ($member >= $context['start'])
764 785
 				$context['recipients']['members'][] = (int) $member;
786
+		}
765 787
 	}
766 788
 	// Cleaning groups is simple - although deal with both checkbox and commas.
767 789
 	if (isset($_POST['groups']))
768 790
 	{
769 791
 		if (is_array($_POST['groups']))
770 792
 		{
771
-			foreach ($_POST['groups'] as $group => $dummy)
772
-				$context['recipients']['groups'][] = (int) $group;
773
-		}
774
-		else
793
+			foreach ($_POST['groups'] as $group => $dummy) {
794
+							$context['recipients']['groups'][] = (int) $group;
795
+			}
796
+		} else
775 797
 		{
776 798
 			$groups = explode(',', $_POST['groups']);
777
-			foreach ($groups as $group)
778
-				$context['recipients']['groups'][] = (int) $group;
799
+			foreach ($groups as $group) {
800
+							$context['recipients']['groups'][] = (int) $group;
801
+			}
779 802
 		}
780 803
 	}
781 804
 	// Same for excluded groups
@@ -783,15 +806,17 @@  discard block
 block discarded – undo
783 806
 	{
784 807
 		if (is_array($_POST['exclude_groups']))
785 808
 		{
786
-			foreach ($_POST['exclude_groups'] as $group => $dummy)
787
-				$context['recipients']['exclude_groups'][] = (int) $group;
809
+			foreach ($_POST['exclude_groups'] as $group => $dummy) {
810
+							$context['recipients']['exclude_groups'][] = (int) $group;
811
+			}
788 812
 		}
789 813
 		// Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected
790 814
 		elseif ($_POST['exclude_groups'] != '')
791 815
 		{
792 816
 			$groups = explode(',', $_POST['exclude_groups']);
793
-			foreach ($groups as $group)
794
-				$context['recipients']['exclude_groups'][] = (int) $group;
817
+			foreach ($groups as $group) {
818
+							$context['recipients']['exclude_groups'][] = (int) $group;
819
+			}
795 820
 		}
796 821
 	}
797 822
 	// Finally - emails!
@@ -801,14 +826,16 @@  discard block
 block discarded – undo
801 826
 		foreach ($addressed as $curmem)
802 827
 		{
803 828
 			$curmem = trim($curmem);
804
-			if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL))
805
-				$context['recipients']['emails'][$curmem] = $curmem;
829
+			if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) {
830
+							$context['recipients']['emails'][$curmem] = $curmem;
831
+			}
806 832
 		}
807 833
 	}
808 834
 
809 835
 	// If we're only cleaning drop out here.
810
-	if ($clean_only)
811
-		return;
836
+	if ($clean_only) {
837
+			return;
838
+	}
812 839
 
813 840
 	require_once($sourcedir . '/Subs-Post.php');
814 841
 
@@ -824,16 +851,18 @@  discard block
 block discarded – undo
824 851
 	if (!$context['send_pm'] && !empty($_POST['send_html']))
825 852
 	{
826 853
 		// Prepare the message for HTML.
827
-		if (!empty($_POST['parse_html']))
828
-			$_POST['message'] = str_replace(array("\n", '  '), array('<br>' . "\n", '&nbsp; '), $_POST['message']);
854
+		if (!empty($_POST['parse_html'])) {
855
+					$_POST['message'] = str_replace(array("\n", '  '), array('<br>' . "\n", '&nbsp; '), $_POST['message']);
856
+		}
829 857
 
830 858
 		// This is here to prevent spam filters from tagging this as spam.
831 859
 		if (preg_match('~\<html~i', $_POST['message']) == 0)
832 860
 		{
833
-			if (preg_match('~\<body~i', $_POST['message']) == 0)
834
-				$_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>';
835
-			else
836
-				$_POST['message'] = '<html>' . $_POST['message'] . '</html>';
861
+			if (preg_match('~\<body~i', $_POST['message']) == 0) {
862
+							$_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>';
863
+			} else {
864
+							$_POST['message'] = '<html>' . $_POST['message'] . '</html>';
865
+			}
837 866
 		}
838 867
 	}
839 868
 
@@ -887,15 +916,17 @@  discard block
 block discarded – undo
887 916
 	foreach ($context['recipients']['emails'] as $k => $email)
888 917
 	{
889 918
 		// Done as many as we can?
890
-		if ($i >= $num_at_once)
891
-			break;
919
+		if ($i >= $num_at_once) {
920
+					break;
921
+		}
892 922
 
893 923
 		// Don't sent it twice!
894 924
 		unset($context['recipients']['emails'][$k]);
895 925
 
896 926
 		// Dammit - can't PM emails!
897
-		if ($context['send_pm'])
898
-			continue;
927
+		if ($context['send_pm']) {
928
+					continue;
929
+		}
899 930
 
900 931
 		$to_member = array(
901 932
 			$email,
@@ -929,8 +960,9 @@  discard block
 block discarded – undo
929 960
 					$queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}';
930 961
 				}
931 962
 			}
932
-			if (!empty($queryBuild))
933
-			$sendQuery .= implode(' OR ', $queryBuild);
963
+			if (!empty($queryBuild)) {
964
+						$sendQuery .= implode(' OR ', $queryBuild);
965
+			}
934 966
 		}
935 967
 		if (!empty($context['recipients']['members']))
936 968
 		{
@@ -949,8 +981,9 @@  discard block
 block discarded – undo
949 981
 		}
950 982
 
951 983
 		// Anything to exclude?
952
-		if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups']))
953
-			$sendQuery .= ' AND mem.id_group != {int:regular_group}';
984
+		if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) {
985
+					$sendQuery .= ' AND mem.id_group != {int:regular_group}';
986
+		}
954 987
 		if (!empty($context['recipients']['exclude_members']))
955 988
 		{
956 989
 			$sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})';
@@ -986,21 +1019,24 @@  discard block
 block discarded – undo
986 1019
 		foreach ($rows as $row)
987 1020
 		{
988 1021
 			// Force them to have it?
989
-			if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements']))
990
-				continue;
1022
+			if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) {
1023
+							continue;
1024
+			}
991 1025
 
992 1026
 			// What groups are we looking at here?
993
-			if (empty($row['additional_groups']))
994
-				$groups = array($row['id_group'], $row['id_post_group']);
995
-			else
996
-				$groups = array_merge(
1027
+			if (empty($row['additional_groups'])) {
1028
+							$groups = array($row['id_group'], $row['id_post_group']);
1029
+			} else {
1030
+							$groups = array_merge(
997 1031
 					array($row['id_group'], $row['id_post_group']),
998 1032
 					explode(',', $row['additional_groups'])
999 1033
 				);
1034
+			}
1000 1035
 
1001 1036
 			// Excluded groups?
1002
-			if (array_intersect($groups, $context['recipients']['exclude_groups']))
1003
-				continue;
1037
+			if (array_intersect($groups, $context['recipients']['exclude_groups'])) {
1038
+							continue;
1039
+			}
1004 1040
 
1005 1041
 			// We might need this
1006 1042
 			$cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name'];
@@ -1023,10 +1059,11 @@  discard block
 block discarded – undo
1023 1059
 				), $_POST['subject']);
1024 1060
 
1025 1061
 			// Send the actual email - or a PM!
1026
-			if (!$context['send_pm'])
1027
-				sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5);
1028
-			else
1029
-				sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);
1062
+			if (!$context['send_pm']) {
1063
+							sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5);
1064
+			} else {
1065
+							sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);
1066
+			}
1030 1067
 		}
1031 1068
 	}
1032 1069
 
@@ -1076,8 +1113,9 @@  discard block
 block discarded – undo
1076 1113
 
1077 1114
 	call_integration_hook('integrate_modify_news_settings', array(&$config_vars));
1078 1115
 
1079
-	if ($return_config)
1080
-		return $config_vars;
1116
+	if ($return_config) {
1117
+			return $config_vars;
1118
+	}
1081 1119
 
1082 1120
 	$context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings'];
1083 1121
 	$context['sub_template'] = 'show_settings';
Please login to merge, or discard this patch.
Sources/Post.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
257 257
 
258 258
 		$js_time_string = str_replace(
259
-			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
260
-			array('H',  'G',  'h',  'g',  'i',  'A',  'a',  'h:i:s A', 'H:i', 's',  'H:i:s', 'H:i:s'),
259
+			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'),
260
+			array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'),
261 261
 			$time_string
262 262
 		);
263 263
 
@@ -1305,14 +1305,14 @@  discard block
 block discarded – undo
1305 1305
 	if (isset($context['name']) && isset($context['email']))
1306 1306
 	{
1307 1307
 		$context['posting_fields']['guestname'] = array(
1308
-			'dt' => '<span id="caption_guestname"' .  (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>',
1308
+			'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>',
1309 1309
 			'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" required>',
1310 1310
 		);
1311 1311
 
1312 1312
 		if (empty($modSettings['guest_post_no_email']))
1313 1313
 		{
1314 1314
 			$context['posting_fields']['email'] = array(
1315
-				'dt' => '<span id="caption_email"' .  (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>',
1315
+				'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>',
1316 1316
 				'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" required>',
1317 1317
 			);
1318 1318
 		}
Please login to merge, or discard this patch.
Braces   +656 added lines, -509 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
  * Handles showing the post screen, loading the post to be modified, and loading any post quoted.
@@ -35,12 +36,14 @@  discard block
 block discarded – undo
35 36
 	global $sourcedir, $smcFunc, $language;
36 37
 
37 38
 	loadLanguage('Post');
38
-	if (!empty($modSettings['drafts_post_enabled']))
39
-		loadLanguage('Drafts');
39
+	if (!empty($modSettings['drafts_post_enabled'])) {
40
+			loadLanguage('Drafts');
41
+	}
40 42
 
41 43
 	// You can't reply with a poll... hacker.
42
-	if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg']))
43
-		unset($_REQUEST['poll']);
44
+	if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) {
45
+			unset($_REQUEST['poll']);
46
+	}
44 47
 
45 48
 	// Posting an event?
46 49
 	$context['make_event'] = isset($_REQUEST['calendar']);
@@ -54,8 +57,9 @@  discard block
 block discarded – undo
54 57
 	$context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']);
55 58
 
56 59
 	// You must be posting to *some* board.
57
-	if (empty($board) && !$context['make_event'])
58
-		fatal_lang_error('no_board', false);
60
+	if (empty($board) && !$context['make_event']) {
61
+			fatal_lang_error('no_board', false);
62
+	}
59 63
 
60 64
 	require_once($sourcedir . '/Subs-Post.php');
61 65
 
@@ -80,9 +84,9 @@  discard block
 block discarded – undo
80 84
 		));
81 85
 		if ($smcFunc['db_num_rows']($request) != 1) {
82 86
 			unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
87
+		} else {
88
+					list ($topic) = $smcFunc['db_fetch_row']($request);
83 89
 		}
84
-		else
85
-			list ($topic) = $smcFunc['db_fetch_row']($request);
86 90
 		$smcFunc['db_free_result']($request);
87 91
 	}
88 92
 
@@ -109,33 +113,36 @@  discard block
 block discarded – undo
109 113
 		$smcFunc['db_free_result']($request);
110 114
 
111 115
 		// If this topic already has a poll, they sure can't add another.
112
-		if (isset($_REQUEST['poll']) && $pollID > 0)
113
-			unset($_REQUEST['poll']);
116
+		if (isset($_REQUEST['poll']) && $pollID > 0) {
117
+					unset($_REQUEST['poll']);
118
+		}
114 119
 
115 120
 		if (empty($_REQUEST['msg']))
116 121
 		{
117
-			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any')))
118
-				is_not_guest();
122
+			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) {
123
+							is_not_guest();
124
+			}
119 125
 
120 126
 			// By default the reply will be approved...
121 127
 			$context['becomes_approved'] = true;
122 128
 			if ($id_member_poster != $user_info['id'] || $user_info['is_guest'])
123 129
 			{
124
-				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
125
-					$context['becomes_approved'] = false;
126
-				else
127
-					isAllowedTo('post_reply_any');
128
-			}
129
-			elseif (!allowedTo('post_reply_any'))
130
+				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
131
+									$context['becomes_approved'] = false;
132
+				} else {
133
+									isAllowedTo('post_reply_any');
134
+				}
135
+			} elseif (!allowedTo('post_reply_any'))
130 136
 			{
131
-				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any')))
132
-					$context['becomes_approved'] = false;
133
-				else
134
-					isAllowedTo('post_reply_own');
137
+				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) {
138
+									$context['becomes_approved'] = false;
139
+				} else {
140
+									isAllowedTo('post_reply_own');
141
+				}
135 142
 			}
143
+		} else {
144
+					$context['becomes_approved'] = true;
136 145
 		}
137
-		else
138
-			$context['becomes_approved'] = true;
139 146
 
140 147
 		$context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own'));
141 148
 		$context['can_sticky'] = allowedTo('make_sticky');
@@ -147,18 +154,19 @@  discard block
 block discarded – undo
147 154
 		$context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky;
148 155
 
149 156
 		// Check whether this is a really old post being bumped...
150
-		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject']))
151
-			$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
152
-	}
153
-	else
157
+		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) {
158
+					$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
159
+		}
160
+	} else
154 161
 	{
155 162
 		$context['becomes_approved'] = true;
156 163
 		if ((!$context['make_event'] || !empty($board)))
157 164
 		{
158
-			if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
159
-				$context['becomes_approved'] = false;
160
-			else
161
-				isAllowedTo('post_new');
165
+			if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) {
166
+							$context['becomes_approved'] = false;
167
+			} else {
168
+							isAllowedTo('post_new');
169
+			}
162 170
 		}
163 171
 
164 172
 		$locked = 0;
@@ -194,20 +202,24 @@  discard block
 block discarded – undo
194 202
 	}
195 203
 
196 204
 	// Don't allow a post if it's locked and you aren't all powerful.
197
-	if ($locked && !allowedTo('moderate_board'))
198
-		fatal_lang_error('topic_locked', false);
205
+	if ($locked && !allowedTo('moderate_board')) {
206
+			fatal_lang_error('topic_locked', false);
207
+	}
199 208
 	// Check the users permissions - is the user allowed to add or post a poll?
200 209
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
201 210
 	{
202 211
 		// New topic, new poll.
203
-		if (empty($topic))
204
-			isAllowedTo('poll_post');
212
+		if (empty($topic)) {
213
+					isAllowedTo('poll_post');
214
+		}
205 215
 		// This is an old topic - but it is yours!  Can you add to it?
206
-		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any'))
207
-			isAllowedTo('poll_add_own');
216
+		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) {
217
+					isAllowedTo('poll_add_own');
218
+		}
208 219
 		// If you're not the owner, can you add to any poll?
209
-		else
210
-			isAllowedTo('poll_add_any');
220
+		else {
221
+					isAllowedTo('poll_add_any');
222
+		}
211 223
 
212 224
 		require_once($sourcedir . '/Subs-Members.php');
213 225
 		$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
@@ -236,8 +248,9 @@  discard block
 block discarded – undo
236 248
 	if ($context['make_event'])
237 249
 	{
238 250
 		// They might want to pick a board.
239
-		if (!isset($context['current_board']))
240
-			$context['current_board'] = 0;
251
+		if (!isset($context['current_board'])) {
252
+					$context['current_board'] = 0;
253
+		}
241 254
 
242 255
 		// Start loading up the event info.
243 256
 		$context['event'] = array();
@@ -251,10 +264,11 @@  discard block
 block discarded – undo
251 264
 		isAllowedTo('calendar_post');
252 265
 
253 266
 		// We want a fairly compact version of the time, but as close as possible to the user's settings.
254
-		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
255
-			$time_string = '%k:%M';
256
-		else
257
-			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
267
+		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
268
+					$time_string = '%k:%M';
269
+		} else {
270
+					$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
271
+		}
258 272
 
259 273
 		$js_time_string = str_replace(
260 274
 			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -276,8 +290,7 @@  discard block
 block discarded – undo
276 290
 			require_once($sourcedir . '/Subs-Calendar.php');
277 291
 			$eventProperties = getEventProperties($context['event']['id']);
278 292
 			$context['event'] = array_merge($context['event'], $eventProperties);
279
-		}
280
-		else
293
+		} else
281 294
 		{
282 295
 			// Get the current event information.
283 296
 			require_once($sourcedir . '/Subs-Calendar.php');
@@ -285,15 +298,18 @@  discard block
 block discarded – undo
285 298
 			$context['event'] = array_merge($context['event'], $eventProperties);
286 299
 
287 300
 			// Make sure the year and month are in the valid range.
288
-			if ($context['event']['month'] < 1 || $context['event']['month'] > 12)
289
-				fatal_lang_error('invalid_month', false);
290
-			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear'])
291
-				fatal_lang_error('invalid_year', false);
301
+			if ($context['event']['month'] < 1 || $context['event']['month'] > 12) {
302
+							fatal_lang_error('invalid_month', false);
303
+			}
304
+			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) {
305
+							fatal_lang_error('invalid_year', false);
306
+			}
292 307
 
293 308
 			// Get a list of boards they can post in.
294 309
 			$boards = boardsAllowedTo('post_new');
295
-			if (empty($boards))
296
-				fatal_lang_error('cannot_post_new', 'user');
310
+			if (empty($boards)) {
311
+							fatal_lang_error('cannot_post_new', 'user');
312
+			}
297 313
 
298 314
 			// Load a list of boards for this event in the context.
299 315
 			require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -412,10 +428,11 @@  discard block
 block discarded – undo
412 428
 
413 429
 			if (!empty($context['new_replies']))
414 430
 			{
415
-				if ($context['new_replies'] == 1)
416
-					$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
417
-				else
418
-					$txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
431
+				if ($context['new_replies'] == 1) {
432
+									$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
433
+				} else {
434
+									$txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
435
+				}
419 436
 
420 437
 				$post_errors[] = 'new_replies';
421 438
 
@@ -427,9 +444,9 @@  discard block
 block discarded – undo
427 444
 	// Get a response prefix (like 'Re:') in the default forum language.
428 445
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
429 446
 	{
430
-		if ($language === $user_info['language'])
431
-			$context['response_prefix'] = $txt['response_prefix'];
432
-		else
447
+		if ($language === $user_info['language']) {
448
+					$context['response_prefix'] = $txt['response_prefix'];
449
+		} else
433 450
 		{
434 451
 			loadLanguage('index', $language, false);
435 452
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -442,8 +459,9 @@  discard block
 block discarded – undo
442 459
 	// Do we have a body, but an error happened.
443 460
 	if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error']))
444 461
 	{
445
-		if (isset($_REQUEST['quickReply']))
446
-			$_REQUEST['message'] = $_REQUEST['quickReply'];
462
+		if (isset($_REQUEST['quickReply'])) {
463
+					$_REQUEST['message'] = $_REQUEST['quickReply'];
464
+		}
447 465
 
448 466
 		// Validate inputs.
449 467
 		if (empty($context['post_error']))
@@ -451,15 +469,17 @@  discard block
 block discarded – undo
451 469
 			// This means they didn't click Post and get an error.
452 470
 			$really_previewing = true;
453 471
 
454
-		}
455
-		else
472
+		} else
456 473
 		{
457
-			if (!isset($_REQUEST['subject']))
458
-				$_REQUEST['subject'] = '';
459
-			if (!isset($_REQUEST['message']))
460
-				$_REQUEST['message'] = '';
461
-			if (!isset($_REQUEST['icon']))
462
-				$_REQUEST['icon'] = 'xx';
474
+			if (!isset($_REQUEST['subject'])) {
475
+							$_REQUEST['subject'] = '';
476
+			}
477
+			if (!isset($_REQUEST['message'])) {
478
+							$_REQUEST['message'] = '';
479
+			}
480
+			if (!isset($_REQUEST['icon'])) {
481
+							$_REQUEST['icon'] = 'xx';
482
+			}
463 483
 
464 484
 			// They are previewing if they asked to preview (i.e. came from quick reply).
465 485
 			$really_previewing = !empty($_POST['preview']);
@@ -475,8 +495,9 @@  discard block
 block discarded – undo
475 495
 		$form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES);
476 496
 
477 497
 		// Make sure the subject isn't too long - taking into account special characters.
478
-		if ($smcFunc['strlen']($form_subject) > 100)
479
-			$form_subject = $smcFunc['substr']($form_subject, 0, 100);
498
+		if ($smcFunc['strlen']($form_subject) > 100) {
499
+					$form_subject = $smcFunc['substr']($form_subject, 0, 100);
500
+		}
480 501
 
481 502
 		if (isset($_REQUEST['poll']))
482 503
 		{
@@ -488,8 +509,9 @@  discard block
 block discarded – undo
488 509
 			$_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']);
489 510
 			foreach ($_POST['options'] as $option)
490 511
 			{
491
-				if (trim($option) == '')
492
-					continue;
512
+				if (trim($option) == '') {
513
+									continue;
514
+				}
493 515
 
494 516
 				$context['choices'][] = array(
495 517
 					'id' => $choice_id++,
@@ -551,13 +573,14 @@  discard block
 block discarded – undo
551 573
 				$context['preview_subject'] = $form_subject;
552 574
 
553 575
 				censorText($context['preview_subject']);
576
+			} else {
577
+							$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
554 578
 			}
555
-			else
556
-				$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
557 579
 
558 580
 			// Protect any CDATA blocks.
559
-			if (isset($_REQUEST['xml']))
560
-				$context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
581
+			if (isset($_REQUEST['xml'])) {
582
+							$context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
583
+			}
561 584
 		}
562 585
 
563 586
 		// Set up the checkboxes.
@@ -596,29 +619,32 @@  discard block
 block discarded – undo
596 619
 			);
597 620
 			// The message they were trying to edit was most likely deleted.
598 621
 			// @todo Change this error message?
599
-			if ($smcFunc['db_num_rows']($request) == 0)
600
-				fatal_lang_error('no_board', false);
622
+			if ($smcFunc['db_num_rows']($request) == 0) {
623
+							fatal_lang_error('no_board', false);
624
+			}
601 625
 			$row = $smcFunc['db_fetch_assoc']($request);
602 626
 
603 627
 			$attachment_stuff = array($row);
604
-			while ($row2 = $smcFunc['db_fetch_assoc']($request))
605
-				$attachment_stuff[] = $row2;
628
+			while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
629
+							$attachment_stuff[] = $row2;
630
+			}
606 631
 			$smcFunc['db_free_result']($request);
607 632
 
608 633
 			if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
609 634
 			{
610 635
 				// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
611
-				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
612
-					fatal_lang_error('modify_post_time_passed', false);
613
-				elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
614
-					isAllowedTo('modify_replies');
615
-				else
616
-					isAllowedTo('modify_own');
636
+				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
637
+									fatal_lang_error('modify_post_time_passed', false);
638
+				} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) {
639
+									isAllowedTo('modify_replies');
640
+				} else {
641
+									isAllowedTo('modify_own');
642
+				}
643
+			} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) {
644
+							isAllowedTo('modify_replies');
645
+			} else {
646
+							isAllowedTo('modify_any');
617 647
 			}
618
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
619
-				isAllowedTo('modify_replies');
620
-			else
621
-				isAllowedTo('modify_any');
622 648
 
623 649
 			if ($context['can_announce'] && !empty($row['id_action']))
624 650
 			{
@@ -642,8 +668,9 @@  discard block
 block discarded – undo
642 668
 
643 669
 				while ($row = $smcFunc['db_fetch_assoc']($request))
644 670
 				{
645
-					if ($row['filesize'] <= 0)
646
-						continue;
671
+					if ($row['filesize'] <= 0) {
672
+											continue;
673
+					}
647 674
 					$context['current_attachments'][$row['id_attach']] = array(
648 675
 						'name' => $smcFunc['htmlspecialchars']($row['filename']),
649 676
 						'size' => $row['filesize'],
@@ -713,29 +740,32 @@  discard block
 block discarded – undo
713 740
 			)
714 741
 		);
715 742
 		// The message they were trying to edit was most likely deleted.
716
-		if ($smcFunc['db_num_rows']($request) == 0)
717
-			fatal_lang_error('no_message', false);
743
+		if ($smcFunc['db_num_rows']($request) == 0) {
744
+					fatal_lang_error('no_message', false);
745
+		}
718 746
 		$row = $smcFunc['db_fetch_assoc']($request);
719 747
 
720 748
 		$attachment_stuff = array($row);
721
-		while ($row2 = $smcFunc['db_fetch_assoc']($request))
722
-			$attachment_stuff[] = $row2;
749
+		while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
750
+					$attachment_stuff[] = $row2;
751
+		}
723 752
 		$smcFunc['db_free_result']($request);
724 753
 
725 754
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
726 755
 		{
727 756
 			// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
728
-			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
729
-				fatal_lang_error('modify_post_time_passed', false);
730
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
731
-				isAllowedTo('modify_replies');
732
-			else
733
-				isAllowedTo('modify_own');
757
+			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
758
+							fatal_lang_error('modify_post_time_passed', false);
759
+			} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) {
760
+							isAllowedTo('modify_replies');
761
+			} else {
762
+							isAllowedTo('modify_own');
763
+			}
764
+		} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) {
765
+					isAllowedTo('modify_replies');
766
+		} else {
767
+					isAllowedTo('modify_any');
734 768
 		}
735
-		elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
736
-			isAllowedTo('modify_replies');
737
-		else
738
-			isAllowedTo('modify_any');
739 769
 
740 770
 		if ($context['can_announce'] && !empty($row['id_action']))
741 771
 		{
@@ -762,15 +792,17 @@  discard block
 block discarded – undo
762 792
 		$context['icon'] = $row['icon'];
763 793
 
764 794
 		// Show an "approve" box if the user can approve it, and the message isn't approved.
765
-		if (!$row['approved'] && !$context['show_approval'])
766
-			$context['show_approval'] = allowedTo('approve_posts');
795
+		if (!$row['approved'] && !$context['show_approval']) {
796
+					$context['show_approval'] = allowedTo('approve_posts');
797
+		}
767 798
 
768 799
 		// Sort the attachments so they are in the order saved
769 800
 		$temp = array();
770 801
 		foreach ($attachment_stuff as $attachment)
771 802
 		{
772
-			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable']))
773
-				$temp[$attachment['id_attach']] = $attachment;
803
+			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) {
804
+							$temp[$attachment['id_attach']] = $attachment;
805
+			}
774 806
 
775 807
 		}
776 808
 		ksort($temp);
@@ -832,14 +864,16 @@  discard block
 block discarded – undo
832 864
 					'is_approved' => 1,
833 865
 				)
834 866
 			);
835
-			if ($smcFunc['db_num_rows']($request) == 0)
836
-				fatal_lang_error('quoted_post_deleted', false);
867
+			if ($smcFunc['db_num_rows']($request) == 0) {
868
+							fatal_lang_error('quoted_post_deleted', false);
869
+			}
837 870
 			list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request);
838 871
 			$smcFunc['db_free_result']($request);
839 872
 
840 873
 			// Add 'Re: ' to the front of the quoted subject.
841
-			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
842
-				$form_subject = $context['response_prefix'] . $form_subject;
874
+			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
875
+							$form_subject = $context['response_prefix'] . $form_subject;
876
+			}
843 877
 
844 878
 			// Censor the message and subject.
845 879
 			censorText($form_message);
@@ -852,10 +886,11 @@  discard block
 block discarded – undo
852 886
 				for ($i = 0, $n = count($parts); $i < $n; $i++)
853 887
 				{
854 888
 					// It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
855
-					if ($i % 4 == 0)
856
-						$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
889
+					if ($i % 4 == 0) {
890
+											$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
857 891
 						{
858 892
 							return '[html]' . preg_replace('~<br\s?/?' . '>~i', '&lt;br /&gt;<br>', "$m[1]") . '[/html]';
893
+					}
859 894
 						}, $parts[$i]);
860 895
 				}
861 896
 				$form_message = implode('', $parts);
@@ -864,8 +899,9 @@  discard block
 block discarded – undo
864 899
 			$form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message);
865 900
 
866 901
 			// Remove any nested quotes, if necessary.
867
-			if (!empty($modSettings['removeNestedQuotes']))
868
-				$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
902
+			if (!empty($modSettings['removeNestedQuotes'])) {
903
+							$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
904
+			}
869 905
 
870 906
 			// Add a quote string on the front and end.
871 907
 			$form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]';
@@ -877,15 +913,15 @@  discard block
 block discarded – undo
877 913
 			$form_subject = $first_subject;
878 914
 
879 915
 			// Add 'Re: ' to the front of the subject.
880
-			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
881
-				$form_subject = $context['response_prefix'] . $form_subject;
916
+			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
917
+							$form_subject = $context['response_prefix'] . $form_subject;
918
+			}
882 919
 
883 920
 			// Censor the subject.
884 921
 			censorText($form_subject);
885 922
 
886 923
 			$form_message = '';
887
-		}
888
-		else
924
+		} else
889 925
 		{
890 926
 			$form_subject = isset($_GET['subject']) ? $_GET['subject'] : '';
891 927
 			$form_message = '';
@@ -903,13 +939,15 @@  discard block
 block discarded – undo
903 939
 		if (isset($_REQUEST['msg']))
904 940
 		{
905 941
 			$context['attachments']['quantity'] = count($context['current_attachments']);
906
-			foreach ($context['current_attachments'] as $attachment)
907
-				$context['attachments']['total_size'] += $attachment['size'];
942
+			foreach ($context['current_attachments'] as $attachment) {
943
+							$context['attachments']['total_size'] += $attachment['size'];
944
+			}
908 945
 		}
909 946
 
910 947
 		// A bit of house keeping first.
911
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
912
-			unset($_SESSION['temp_attachments']);
948
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
949
+					unset($_SESSION['temp_attachments']);
950
+		}
913 951
 
914 952
 		if (!empty($_SESSION['temp_attachments']))
915 953
 		{
@@ -918,9 +956,10 @@  discard block
 block discarded – undo
918 956
 			{
919 957
 				foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
920 958
 				{
921
-					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
922
-						if (file_exists($attachment['tmp_name']))
959
+					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) {
960
+											if (file_exists($attachment['tmp_name']))
923 961
 							unlink($attachment['tmp_name']);
962
+					}
924 963
 				}
925 964
 				$post_errors[] = 'temp_attachments_gone';
926 965
 				$_SESSION['temp_attachments'] = array();
@@ -934,8 +973,9 @@  discard block
 block discarded – undo
934 973
 					// See if any files still exist before showing the warning message and the files attached.
935 974
 					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
936 975
 					{
937
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
938
-							continue;
976
+						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
977
+													continue;
978
+						}
939 979
 
940 980
 						if (file_exists($attachment['tmp_name']))
941 981
 						{
@@ -945,20 +985,21 @@  discard block
 block discarded – undo
945 985
 							break;
946 986
 						}
947 987
 					}
948
-				}
949
-				else
988
+				} else
950 989
 				{
951 990
 					// Since, they don't belong here. Let's inform the user that they exist..
952
-					if (!empty($topic))
953
-						$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
954
-					else
955
-						$delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp';
991
+					if (!empty($topic)) {
992
+											$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
993
+					} else {
994
+											$delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp';
995
+					}
956 996
 
957 997
 					// Compile a list of the files to show the user.
958 998
 					$file_list = array();
959
-					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
960
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
999
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
1000
+											if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
961 1001
 							$file_list[] = $attachment['name'];
1002
+					}
962 1003
 
963 1004
 					$_SESSION['temp_attachments']['post']['files'] = $file_list;
964 1005
 					$file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>';
@@ -970,8 +1011,7 @@  discard block
 block discarded – undo
970 1011
 
971 1012
 						$post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list));
972 1013
 						$context['ignore_temp_attachments'] = true;
973
-					}
974
-					else
1014
+					} else
975 1015
 					{
976 1016
 						$post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list));
977 1017
 						$context['ignore_temp_attachments'] = true;
@@ -979,16 +1019,19 @@  discard block
 block discarded – undo
979 1019
 				}
980 1020
 			}
981 1021
 
982
-			if (!empty($context['we_are_history']))
983
-				$post_errors[] = $context['we_are_history'];
1022
+			if (!empty($context['we_are_history'])) {
1023
+							$post_errors[] = $context['we_are_history'];
1024
+			}
984 1025
 
985 1026
 			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
986 1027
 			{
987
-				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files']))
988
-					break;
1028
+				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) {
1029
+									break;
1030
+				}
989 1031
 
990
-				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
991
-					continue;
1032
+				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
1033
+									continue;
1034
+				}
992 1035
 
993 1036
 				if ($attachID == 'initial_error')
994 1037
 				{
@@ -1003,15 +1046,17 @@  discard block
 block discarded – undo
1003 1046
 				{
1004 1047
 					$txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : '';
1005 1048
 					$txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">';
1006
-					foreach ($attachment['errors'] as $error)
1007
-						$txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >';
1049
+					foreach ($attachment['errors'] as $error) {
1050
+											$txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >';
1051
+					}
1008 1052
 					$txt['error_attach_errors'] .= '</div>';
1009 1053
 					$post_errors[] = 'attach_errors';
1010 1054
 
1011 1055
 					// Take out the trash.
1012 1056
 					unset($_SESSION['temp_attachments'][$attachID]);
1013
-					if (file_exists($attachment['tmp_name']))
1014
-						unlink($attachment['tmp_name']);
1057
+					if (file_exists($attachment['tmp_name'])) {
1058
+											unlink($attachment['tmp_name']);
1059
+					}
1015 1060
 					continue;
1016 1061
 				}
1017 1062
 
@@ -1024,8 +1069,9 @@  discard block
 block discarded – undo
1024 1069
 
1025 1070
 				$context['attachments']['quantity']++;
1026 1071
 				$context['attachments']['total_size'] += $attachment['size'];
1027
-				if (!isset($context['files_in_session_warning']))
1028
-					$context['files_in_session_warning'] = $txt['attached_files_in_session'];
1072
+				if (!isset($context['files_in_session_warning'])) {
1073
+									$context['files_in_session_warning'] = $txt['attached_files_in_session'];
1074
+				}
1029 1075
 
1030 1076
 				$context['current_attachments'][$attachID] = array(
1031 1077
 					'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>',
@@ -1053,8 +1099,9 @@  discard block
 block discarded – undo
1053 1099
 	}
1054 1100
 
1055 1101
 	// If they came from quick reply, and have to enter verification details, give them some notice.
1056
-	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification']))
1057
-		$post_errors[] = 'need_qr_verification';
1102
+	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) {
1103
+			$post_errors[] = 'need_qr_verification';
1104
+	}
1058 1105
 
1059 1106
 	/*
1060 1107
 	 * There are two error types: serious and minor. Serious errors
@@ -1071,52 +1118,56 @@  discard block
 block discarded – undo
1071 1118
 	{
1072 1119
 		loadLanguage('Errors');
1073 1120
 		$context['error_type'] = 'minor';
1074
-		foreach ($post_errors as $post_error)
1075
-			if (is_array($post_error))
1121
+		foreach ($post_errors as $post_error) {
1122
+					if (is_array($post_error))
1076 1123
 			{
1077 1124
 				$post_error_id = $post_error[0];
1125
+		}
1078 1126
 				$context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]);
1079 1127
 
1080 1128
 				// If it's not a minor error flag it as such.
1081
-				if (!in_array($post_error_id, $minor_errors))
1082
-					$context['error_type'] = 'serious';
1083
-			}
1084
-			else
1129
+				if (!in_array($post_error_id, $minor_errors)) {
1130
+									$context['error_type'] = 'serious';
1131
+				}
1132
+			} else
1085 1133
 			{
1086 1134
 				$context['post_error'][$post_error] = $txt['error_' . $post_error];
1087 1135
 
1088 1136
 				// If it's not a minor error flag it as such.
1089
-				if (!in_array($post_error, $minor_errors))
1090
-					$context['error_type'] = 'serious';
1137
+				if (!in_array($post_error, $minor_errors)) {
1138
+									$context['error_type'] = 'serious';
1139
+				}
1091 1140
 			}
1092 1141
 	}
1093 1142
 
1094 1143
 	// What are you doing? Posting a poll, modifying, previewing, new post, or reply...
1095
-	if (isset($_REQUEST['poll']))
1096
-		$context['page_title'] = $txt['new_poll'];
1097
-	elseif ($context['make_event'])
1098
-		$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1099
-	elseif (isset($_REQUEST['msg']))
1100
-		$context['page_title'] = $txt['modify_msg'];
1101
-	elseif (isset($_REQUEST['subject'], $context['preview_subject']))
1102
-		$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1103
-	elseif (empty($topic))
1104
-		$context['page_title'] = $txt['start_new_topic'];
1105
-	else
1106
-		$context['page_title'] = $txt['post_reply'];
1144
+	if (isset($_REQUEST['poll'])) {
1145
+			$context['page_title'] = $txt['new_poll'];
1146
+	} elseif ($context['make_event']) {
1147
+			$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1148
+	} elseif (isset($_REQUEST['msg'])) {
1149
+			$context['page_title'] = $txt['modify_msg'];
1150
+	} elseif (isset($_REQUEST['subject'], $context['preview_subject'])) {
1151
+			$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1152
+	} elseif (empty($topic)) {
1153
+			$context['page_title'] = $txt['start_new_topic'];
1154
+	} else {
1155
+			$context['page_title'] = $txt['post_reply'];
1156
+	}
1107 1157
 
1108 1158
 	// Build the link tree.
1109
-	if (empty($topic))
1110
-		$context['linktree'][] = array(
1159
+	if (empty($topic)) {
1160
+			$context['linktree'][] = array(
1111 1161
 			'name' => '<em>' . $txt['start_new_topic'] . '</em>'
1112 1162
 		);
1113
-	else
1114
-		$context['linktree'][] = array(
1163
+	} else {
1164
+			$context['linktree'][] = array(
1115 1165
 			'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'],
1116 1166
 			'name' => $form_subject,
1117 1167
 			'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>',
1118 1168
 			'extra_after' => '<span><strong class="nav">)</strong></span>'
1119 1169
 		);
1170
+	}
1120 1171
 
1121 1172
 	$context['subject'] = addcslashes($form_subject, '"');
1122 1173
 	$context['message'] = str_replace(array('"', '<', '>', '&nbsp;'), array('&quot;', '&lt;', '&gt;', ' '), $form_message);
@@ -1160,8 +1211,9 @@  discard block
 block discarded – undo
1160 1211
 	// Message icons - customized icons are off?
1161 1212
 	$context['icons'] = getMessageIcons($board);
1162 1213
 
1163
-	if (!empty($context['icons']))
1164
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1214
+	if (!empty($context['icons'])) {
1215
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1216
+	}
1165 1217
 
1166 1218
 	// Are we starting a poll? if set the poll icon as selected if its available
1167 1219
 	if (isset($_REQUEST['poll']))
@@ -1181,8 +1233,9 @@  discard block
 block discarded – undo
1181 1233
 	for ($i = 0, $n = count($context['icons']); $i < $n; $i++)
1182 1234
 	{
1183 1235
 		$context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value'];
1184
-		if ($context['icons'][$i]['selected'])
1185
-			$context['icon_url'] = $context['icons'][$i]['url'];
1236
+		if ($context['icons'][$i]['selected']) {
1237
+					$context['icon_url'] = $context['icons'][$i]['url'];
1238
+		}
1186 1239
 	}
1187 1240
 	if (empty($context['icon_url']))
1188 1241
 	{
@@ -1196,8 +1249,9 @@  discard block
 block discarded – undo
1196 1249
 		));
1197 1250
 	}
1198 1251
 
1199
-	if (!empty($topic) && !empty($modSettings['topicSummaryPosts']))
1200
-		getTopic();
1252
+	if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) {
1253
+			getTopic();
1254
+	}
1201 1255
 
1202 1256
 	// If the user can post attachments prepare the warning labels.
1203 1257
 	if ($context['can_post_attachment'])
@@ -1208,12 +1262,13 @@  discard block
 block discarded – undo
1208 1262
 		$context['attachment_restrictions'] = array();
1209 1263
 		$context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', '));
1210 1264
 		$attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit');
1211
-		foreach ($attachmentRestrictionTypes as $type)
1212
-			if (!empty($modSettings[$type]))
1265
+		foreach ($attachmentRestrictionTypes as $type) {
1266
+					if (!empty($modSettings[$type]))
1213 1267
 			{
1214 1268
 				// Show the max number of attachments if not 0.
1215 1269
 				if ($type == 'attachmentNumPerPostLimit')
1216 1270
 					$context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']);
1271
+		}
1217 1272
 			}
1218 1273
 	}
1219 1274
 
@@ -1247,8 +1302,8 @@  discard block
 block discarded – undo
1247 1302
 
1248 1303
 	if (!empty($context['current_attachments']))
1249 1304
 	{
1250
-		foreach ($context['current_attachments'] as $key => $mock)
1251
-			addInlineJavaScript('
1305
+		foreach ($context['current_attachments'] as $key => $mock) {
1306
+					addInlineJavaScript('
1252 1307
 	current_attachments.push({
1253 1308
 		name: '. JavaScriptEscape($mock['name']) . ',
1254 1309
 		size: '. $mock['size'] . ',
@@ -1257,6 +1312,7 @@  discard block
 block discarded – undo
1257 1312
 		type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ',
1258 1313
 		thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . '
1259 1314
 	});', true);
1315
+		}
1260 1316
 	}
1261 1317
 
1262 1318
 	// File Upload.
@@ -1341,8 +1397,9 @@  discard block
 block discarded – undo
1341 1397
 
1342 1398
 
1343 1399
 	// Finally, load the template.
1344
-	if (!isset($_REQUEST['xml']))
1345
-		loadTemplate('Post');
1400
+	if (!isset($_REQUEST['xml'])) {
1401
+			loadTemplate('Post');
1402
+	}
1346 1403
 
1347 1404
 	call_integration_hook('integrate_post_end');
1348 1405
 }
@@ -1363,13 +1420,14 @@  discard block
 block discarded – undo
1363 1420
 	// Sneaking off, are we?
1364 1421
 	if (empty($_POST) && empty($topic))
1365 1422
 	{
1366
-		if (empty($_SERVER['CONTENT_LENGTH']))
1367
-			redirectexit('action=post;board=' . $board . '.0');
1368
-		else
1369
-			fatal_lang_error('post_upload_error', false);
1423
+		if (empty($_SERVER['CONTENT_LENGTH'])) {
1424
+					redirectexit('action=post;board=' . $board . '.0');
1425
+		} else {
1426
+					fatal_lang_error('post_upload_error', false);
1427
+		}
1428
+	} elseif (empty($_POST) && !empty($topic)) {
1429
+			redirectexit('action=post;topic=' . $topic . '.0');
1370 1430
 	}
1371
-	elseif (empty($_POST) && !empty($topic))
1372
-		redirectexit('action=post;topic=' . $topic . '.0');
1373 1431
 
1374 1432
 	// No need!
1375 1433
 	$context['robot_no_index'] = true;
@@ -1381,8 +1439,9 @@  discard block
 block discarded – undo
1381 1439
 	$post_errors = array();
1382 1440
 
1383 1441
 	// If the session has timed out, let the user re-submit their form.
1384
-	if (checkSession('post', '', false) != '')
1385
-		$post_errors[] = 'session_timeout';
1442
+	if (checkSession('post', '', false) != '') {
1443
+			$post_errors[] = 'session_timeout';
1444
+	}
1386 1445
 
1387 1446
 	// Wrong verification code?
1388 1447
 	if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)))
@@ -1392,33 +1451,38 @@  discard block
 block discarded – undo
1392 1451
 			'id' => 'post',
1393 1452
 		);
1394 1453
 		$context['require_verification'] = create_control_verification($verificationOptions, true);
1395
-		if (is_array($context['require_verification']))
1396
-			$post_errors = array_merge($post_errors, $context['require_verification']);
1454
+		if (is_array($context['require_verification'])) {
1455
+					$post_errors = array_merge($post_errors, $context['require_verification']);
1456
+		}
1397 1457
 	}
1398 1458
 
1399 1459
 	require_once($sourcedir . '/Subs-Post.php');
1400 1460
 	loadLanguage('Post');
1401 1461
 
1402 1462
 	// Drafts enabled and needed?
1403
-	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
1404
-		require_once($sourcedir . '/Drafts.php');
1463
+	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) {
1464
+			require_once($sourcedir . '/Drafts.php');
1465
+	}
1405 1466
 
1406 1467
 	// First check to see if they are trying to delete any current attachments.
1407 1468
 	if (isset($_POST['attach_del']))
1408 1469
 	{
1409 1470
 		$keep_temp = array();
1410 1471
 		$keep_ids = array();
1411
-		foreach ($_POST['attach_del'] as $dummy)
1412
-			if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1472
+		foreach ($_POST['attach_del'] as $dummy) {
1473
+					if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1413 1474
 				$keep_temp[] = $dummy;
1414
-			else
1415
-				$keep_ids[] = (int) $dummy;
1475
+		}
1476
+			else {
1477
+							$keep_ids[] = (int) $dummy;
1478
+			}
1416 1479
 
1417
-		if (isset($_SESSION['temp_attachments']))
1418
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1480
+		if (isset($_SESSION['temp_attachments'])) {
1481
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1419 1482
 			{
1420 1483
 				if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1421 1484
 					continue;
1485
+		}
1422 1486
 
1423 1487
 				unset($_SESSION['temp_attachments'][$attachID]);
1424 1488
 				unlink($attachment['tmp_name']);
@@ -1460,12 +1524,14 @@  discard block
 block discarded – undo
1460 1524
 		$smcFunc['db_free_result']($request);
1461 1525
 
1462 1526
 		// Though the topic should be there, it might have vanished.
1463
-		if (!is_array($topic_info))
1464
-			fatal_lang_error('topic_doesnt_exist', 404);
1527
+		if (!is_array($topic_info)) {
1528
+					fatal_lang_error('topic_doesnt_exist', 404);
1529
+		}
1465 1530
 
1466 1531
 		// Did this topic suddenly move? Just checking...
1467
-		if ($topic_info['id_board'] != $board)
1468
-			fatal_lang_error('not_a_topic');
1532
+		if ($topic_info['id_board'] != $board) {
1533
+					fatal_lang_error('not_a_topic');
1534
+		}
1469 1535
 
1470 1536
 		// Do the permissions and approval stuff...
1471 1537
 		$becomesApproved = true;
@@ -1488,49 +1554,50 @@  discard block
 block discarded – undo
1488 1554
 	if (!empty($topic) && !isset($_REQUEST['msg']))
1489 1555
 	{
1490 1556
 		// Don't allow a post if it's locked.
1491
-		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board'))
1492
-			fatal_lang_error('topic_locked', false);
1557
+		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) {
1558
+					fatal_lang_error('topic_locked', false);
1559
+		}
1493 1560
 
1494 1561
 		// Sorry, multiple polls aren't allowed... yet.  You should stop giving me ideas :P.
1495
-		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0)
1496
-			unset($_REQUEST['poll']);
1497
-
1498
-		elseif ($topic_info['id_member_started'] != $user_info['id'])
1499
-		{
1500
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
1501
-				$becomesApproved = false;
1502
-
1503
-			else
1504
-				isAllowedTo('post_reply_any');
1505
-		}
1506
-		elseif (!allowedTo('post_reply_any'))
1562
+		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) {
1563
+					unset($_REQUEST['poll']);
1564
+		} elseif ($topic_info['id_member_started'] != $user_info['id'])
1565
+		{
1566
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
1567
+							$becomesApproved = false;
1568
+			} else {
1569
+							isAllowedTo('post_reply_any');
1570
+			}
1571
+		} elseif (!allowedTo('post_reply_any'))
1507 1572
 		{
1508
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own'))
1509
-				$becomesApproved = false;
1510
-
1511
-			else
1512
-				isAllowedTo('post_reply_own');
1573
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) {
1574
+							$becomesApproved = false;
1575
+			} else {
1576
+							isAllowedTo('post_reply_own');
1577
+			}
1513 1578
 		}
1514 1579
 
1515 1580
 		if (isset($_POST['lock']))
1516 1581
 		{
1517 1582
 			// Nothing is changed to the lock.
1518
-			if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1519
-				unset($_POST['lock']);
1583
+			if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1584
+							unset($_POST['lock']);
1585
+			}
1520 1586
 
1521 1587
 			// You're have no permission to lock this topic.
1522
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1523
-				unset($_POST['lock']);
1588
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1589
+							unset($_POST['lock']);
1590
+			}
1524 1591
 
1525 1592
 			// You are allowed to (un)lock your own topic only.
1526 1593
 			elseif (!allowedTo('lock_any'))
1527 1594
 			{
1528 1595
 				// You cannot override a moderator lock.
1529
-				if ($topic_info['locked'] == 1)
1530
-					unset($_POST['lock']);
1531
-
1532
-				else
1533
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1596
+				if ($topic_info['locked'] == 1) {
1597
+									unset($_POST['lock']);
1598
+				} else {
1599
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1600
+				}
1534 1601
 			}
1535 1602
 			// Hail mighty moderator, (un)lock this topic immediately.
1536 1603
 			else
@@ -1538,19 +1605,21 @@  discard block
 block discarded – undo
1538 1605
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1539 1606
 
1540 1607
 				// Did someone (un)lock this while you were posting?
1541
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1542
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1608
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1609
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1610
+				}
1543 1611
 			}
1544 1612
 		}
1545 1613
 
1546 1614
 		// So you wanna (un)sticky this...let's see.
1547
-		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky')))
1548
-			unset($_POST['sticky']);
1549
-		elseif (isset($_POST['sticky']))
1615
+		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) {
1616
+					unset($_POST['sticky']);
1617
+		} elseif (isset($_POST['sticky']))
1550 1618
 		{
1551 1619
 			// Did someone (un)sticky this while you were posting?
1552
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1553
-				$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1620
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1621
+							$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1622
+			}
1554 1623
 		}
1555 1624
 
1556 1625
 		// If drafts are enabled, then pass this off
@@ -1577,26 +1646,31 @@  discard block
 block discarded – undo
1577 1646
 
1578 1647
 		// Do like, the permissions, for safety and stuff...
1579 1648
 		$becomesApproved = true;
1580
-		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
1581
-			$becomesApproved = false;
1582
-		else
1583
-			isAllowedTo('post_new');
1649
+		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) {
1650
+					$becomesApproved = false;
1651
+		} else {
1652
+					isAllowedTo('post_new');
1653
+		}
1584 1654
 
1585 1655
 		if (isset($_POST['lock']))
1586 1656
 		{
1587 1657
 			// New topics are by default not locked.
1588
-			if (empty($_POST['lock']))
1589
-				unset($_POST['lock']);
1658
+			if (empty($_POST['lock'])) {
1659
+							unset($_POST['lock']);
1660
+			}
1590 1661
 			// Besides, you need permission.
1591
-			elseif (!allowedTo(array('lock_any', 'lock_own')))
1592
-				unset($_POST['lock']);
1662
+			elseif (!allowedTo(array('lock_any', 'lock_own'))) {
1663
+							unset($_POST['lock']);
1664
+			}
1593 1665
 			// A moderator-lock (1) can override a user-lock (2).
1594
-			else
1595
-				$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1666
+			else {
1667
+							$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1668
+			}
1596 1669
 		}
1597 1670
 
1598
-		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky')))
1599
-			unset($_POST['sticky']);
1671
+		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) {
1672
+					unset($_POST['sticky']);
1673
+		}
1600 1674
 
1601 1675
 		// Saving your new topic as a draft first?
1602 1676
 		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
@@ -1621,31 +1695,37 @@  discard block
 block discarded – undo
1621 1695
 				'id_msg' => $_REQUEST['msg'],
1622 1696
 			)
1623 1697
 		);
1624
-		if ($smcFunc['db_num_rows']($request) == 0)
1625
-			fatal_lang_error('cant_find_messages', false);
1698
+		if ($smcFunc['db_num_rows']($request) == 0) {
1699
+					fatal_lang_error('cant_find_messages', false);
1700
+		}
1626 1701
 		$row = $smcFunc['db_fetch_assoc']($request);
1627 1702
 		$smcFunc['db_free_result']($request);
1628 1703
 
1629
-		if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
1630
-			fatal_lang_error('topic_locked', false);
1704
+		if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) {
1705
+					fatal_lang_error('topic_locked', false);
1706
+		}
1631 1707
 
1632 1708
 		if (isset($_POST['lock']))
1633 1709
 		{
1634 1710
 			// Nothing changes to the lock status.
1635
-			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1636
-				unset($_POST['lock']);
1711
+			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1712
+							unset($_POST['lock']);
1713
+			}
1637 1714
 			// You're simply not allowed to (un)lock this.
1638
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1639
-				unset($_POST['lock']);
1715
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1716
+							unset($_POST['lock']);
1717
+			}
1640 1718
 			// You're only allowed to lock your own topics.
1641 1719
 			elseif (!allowedTo('lock_any'))
1642 1720
 			{
1643 1721
 				// You're not allowed to break a moderator's lock.
1644
-				if ($topic_info['locked'] == 1)
1645
-					unset($_POST['lock']);
1722
+				if ($topic_info['locked'] == 1) {
1723
+									unset($_POST['lock']);
1724
+				}
1646 1725
 				// Lock it with a soft lock or unlock it.
1647
-				else
1648
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1726
+				else {
1727
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1728
+				}
1649 1729
 			}
1650 1730
 			// You must be the moderator.
1651 1731
 			else
@@ -1653,44 +1733,46 @@  discard block
 block discarded – undo
1653 1733
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1654 1734
 
1655 1735
 				// Did someone (un)lock this while you were posting?
1656
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1657
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1736
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1737
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1738
+				}
1658 1739
 			}
1659 1740
 		}
1660 1741
 
1661 1742
 		// Change the sticky status of this topic?
1662
-		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky']))
1663
-			unset($_POST['sticky']);
1664
-		elseif (isset($_POST['sticky']))
1743
+		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) {
1744
+					unset($_POST['sticky']);
1745
+		} elseif (isset($_POST['sticky']))
1665 1746
 		{
1666 1747
 			// Did someone (un)sticky this while you were posting?
1667
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1668
-				$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1748
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1749
+							$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1750
+			}
1669 1751
 		}
1670 1752
 
1671 1753
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
1672 1754
 		{
1673
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
1674
-				fatal_lang_error('modify_post_time_passed', false);
1675
-			elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
1676
-				isAllowedTo('modify_replies');
1677
-			else
1678
-				isAllowedTo('modify_own');
1679
-		}
1680
-		elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1755
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
1756
+							fatal_lang_error('modify_post_time_passed', false);
1757
+			} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
1758
+							isAllowedTo('modify_replies');
1759
+			} else {
1760
+							isAllowedTo('modify_own');
1761
+			}
1762
+		} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1681 1763
 		{
1682 1764
 			isAllowedTo('modify_replies');
1683 1765
 
1684 1766
 			// If you're modifying a reply, I say it better be logged...
1685 1767
 			$moderationAction = true;
1686
-		}
1687
-		else
1768
+		} else
1688 1769
 		{
1689 1770
 			isAllowedTo('modify_any');
1690 1771
 
1691 1772
 			// Log it, assuming you're not modifying your own post.
1692
-			if ($row['id_member'] != $user_info['id'])
1693
-				$moderationAction = true;
1773
+			if ($row['id_member'] != $user_info['id']) {
1774
+							$moderationAction = true;
1775
+			}
1694 1776
 		}
1695 1777
 
1696 1778
 		// If drafts are enabled, then lets send this off to save
@@ -1728,20 +1810,24 @@  discard block
 block discarded – undo
1728 1810
 		$_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']);
1729 1811
 		$_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
1730 1812
 
1731
-		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_')
1732
-			$post_errors[] = 'no_name';
1733
-		if ($smcFunc['strlen']($_POST['guestname']) > 25)
1734
-			$post_errors[] = 'long_name';
1813
+		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') {
1814
+					$post_errors[] = 'no_name';
1815
+		}
1816
+		if ($smcFunc['strlen']($_POST['guestname']) > 25) {
1817
+					$post_errors[] = 'long_name';
1818
+		}
1735 1819
 
1736 1820
 		if (empty($modSettings['guest_post_no_email']))
1737 1821
 		{
1738 1822
 			// Only check if they changed it!
1739 1823
 			if (!isset($row) || $row['poster_email'] != $_POST['email'])
1740 1824
 			{
1741
-				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == ''))
1742
-					$post_errors[] = 'no_email';
1743
-				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
1744
-					$post_errors[] = 'bad_email';
1825
+				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) {
1826
+									$post_errors[] = 'no_email';
1827
+				}
1828
+				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
1829
+									$post_errors[] = 'bad_email';
1830
+				}
1745 1831
 			}
1746 1832
 
1747 1833
 			// Now make sure this email address is not banned from posting.
@@ -1757,75 +1843,89 @@  discard block
 block discarded – undo
1757 1843
 	}
1758 1844
 
1759 1845
 	// Coming from the quickReply?
1760
-	if (isset($_POST['quickReply']))
1761
-		$_POST['message'] = $_POST['quickReply'];
1846
+	if (isset($_POST['quickReply'])) {
1847
+			$_POST['message'] = $_POST['quickReply'];
1848
+	}
1762 1849
 
1763 1850
 	// Check the subject and message.
1764
-	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '')
1765
-		$post_errors[] = 'no_subject';
1766
-	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '')
1767
-		$post_errors[] = 'no_message';
1768
-	elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
1769
-		$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1770
-	else
1851
+	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') {
1852
+			$post_errors[] = 'no_subject';
1853
+	}
1854
+	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') {
1855
+			$post_errors[] = 'no_message';
1856
+	} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) {
1857
+			$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1858
+	} else
1771 1859
 	{
1772 1860
 		// Prepare the message a bit for some additional testing.
1773 1861
 		$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
1774 1862
 
1775 1863
 		// Preparse code. (Zef)
1776
-		if ($user_info['is_guest'])
1777
-			$user_info['name'] = $_POST['guestname'];
1864
+		if ($user_info['is_guest']) {
1865
+					$user_info['name'] = $_POST['guestname'];
1866
+		}
1778 1867
 		preparsecode($_POST['message']);
1779 1868
 
1780 1869
 		// Let's see if there's still some content left without the tags.
1781
-		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
1782
-			$post_errors[] = 'no_message';
1870
+		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) {
1871
+					$post_errors[] = 'no_message';
1872
+		}
1873
+	}
1874
+	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') {
1875
+			$post_errors[] = 'no_event';
1783 1876
 	}
1784
-	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '')
1785
-		$post_errors[] = 'no_event';
1786 1877
 	// You are not!
1787
-	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin'])
1788
-		fatal_error('Knave! Masquerader! Charlatan!', false);
1878
+	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) {
1879
+			fatal_error('Knave! Masquerader! Charlatan!', false);
1880
+	}
1789 1881
 
1790 1882
 	// Validate the poll...
1791 1883
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
1792 1884
 	{
1793
-		if (!empty($topic) && !isset($_REQUEST['msg']))
1794
-			fatal_lang_error('no_access', false);
1885
+		if (!empty($topic) && !isset($_REQUEST['msg'])) {
1886
+					fatal_lang_error('no_access', false);
1887
+		}
1795 1888
 
1796 1889
 		// This is a new topic... so it's a new poll.
1797
-		if (empty($topic))
1798
-			isAllowedTo('poll_post');
1890
+		if (empty($topic)) {
1891
+					isAllowedTo('poll_post');
1892
+		}
1799 1893
 		// Can you add to your own topics?
1800
-		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any'))
1801
-			isAllowedTo('poll_add_own');
1894
+		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) {
1895
+					isAllowedTo('poll_add_own');
1896
+		}
1802 1897
 		// Can you add polls to any topic, then?
1803
-		else
1804
-			isAllowedTo('poll_add_any');
1898
+		else {
1899
+					isAllowedTo('poll_add_any');
1900
+		}
1805 1901
 
1806
-		if (!isset($_POST['question']) || trim($_POST['question']) == '')
1807
-			$post_errors[] = 'no_question';
1902
+		if (!isset($_POST['question']) || trim($_POST['question']) == '') {
1903
+					$post_errors[] = 'no_question';
1904
+		}
1808 1905
 
1809 1906
 		$_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']);
1810 1907
 
1811 1908
 		// Get rid of empty ones.
1812
-		foreach ($_POST['options'] as $k => $option)
1813
-			if ($option == '')
1909
+		foreach ($_POST['options'] as $k => $option) {
1910
+					if ($option == '')
1814 1911
 				unset($_POST['options'][$k], $_POST['options'][$k]);
1912
+		}
1815 1913
 
1816 1914
 		// What are you going to vote between with one choice?!?
1817
-		if (count($_POST['options']) < 2)
1818
-			$post_errors[] = 'poll_few';
1819
-		elseif (count($_POST['options']) > 256)
1820
-			$post_errors[] = 'poll_many';
1915
+		if (count($_POST['options']) < 2) {
1916
+					$post_errors[] = 'poll_few';
1917
+		} elseif (count($_POST['options']) > 256) {
1918
+					$post_errors[] = 'poll_many';
1919
+		}
1821 1920
 	}
1822 1921
 
1823 1922
 	if ($posterIsGuest)
1824 1923
 	{
1825 1924
 		// If user is a guest, make sure the chosen name isn't taken.
1826 1925
 		require_once($sourcedir . '/Subs-Members.php');
1827
-		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name']))
1828
-			$post_errors[] = 'bad_name';
1926
+		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) {
1927
+					$post_errors[] = 'bad_name';
1928
+		}
1829 1929
 	}
1830 1930
 	// If the user isn't a guest, get his or her name and email.
1831 1931
 	elseif (!isset($_REQUEST['msg']))
@@ -1856,8 +1956,9 @@  discard block
 block discarded – undo
1856 1956
 	}
1857 1957
 
1858 1958
 	// Make sure the user isn't spamming the board.
1859
-	if (!isset($_REQUEST['msg']))
1860
-		spamProtection('post');
1959
+	if (!isset($_REQUEST['msg'])) {
1960
+			spamProtection('post');
1961
+	}
1861 1962
 
1862 1963
 	// At about this point, we're posting and that's that.
1863 1964
 	ignore_user_abort(true);
@@ -1870,32 +1971,36 @@  discard block
 block discarded – undo
1870 1971
 	$_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
1871 1972
 
1872 1973
 	// At this point, we want to make sure the subject isn't too long.
1873
-	if ($smcFunc['strlen']($_POST['subject']) > 100)
1874
-		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
1974
+	if ($smcFunc['strlen']($_POST['subject']) > 100) {
1975
+			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
1976
+	}
1875 1977
 
1876 1978
 	// Same with the "why did you edit this" text.
1877
-	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
1878
-		$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
1979
+	if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
1980
+			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
1981
+	}
1879 1982
 
1880 1983
 	// Make the poll...
1881 1984
 	if (isset($_REQUEST['poll']))
1882 1985
 	{
1883 1986
 		// Make sure that the user has not entered a ridiculous number of options..
1884
-		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
1885
-			$_POST['poll_max_votes'] = 1;
1886
-		elseif ($_POST['poll_max_votes'] > count($_POST['options']))
1887
-			$_POST['poll_max_votes'] = count($_POST['options']);
1888
-		else
1889
-			$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
1987
+		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) {
1988
+					$_POST['poll_max_votes'] = 1;
1989
+		} elseif ($_POST['poll_max_votes'] > count($_POST['options'])) {
1990
+					$_POST['poll_max_votes'] = count($_POST['options']);
1991
+		} else {
1992
+					$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
1993
+		}
1890 1994
 
1891 1995
 		$_POST['poll_expire'] = (int) $_POST['poll_expire'];
1892 1996
 		$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
1893 1997
 
1894 1998
 		// Just set it to zero if it's not there..
1895
-		if (!isset($_POST['poll_hide']))
1896
-			$_POST['poll_hide'] = 0;
1897
-		else
1898
-			$_POST['poll_hide'] = (int) $_POST['poll_hide'];
1999
+		if (!isset($_POST['poll_hide'])) {
2000
+					$_POST['poll_hide'] = 0;
2001
+		} else {
2002
+					$_POST['poll_hide'] = (int) $_POST['poll_hide'];
2003
+		}
1899 2004
 		$_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0;
1900 2005
 
1901 2006
 		$_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0;
@@ -1904,16 +2009,19 @@  discard block
 block discarded – undo
1904 2009
 		{
1905 2010
 			require_once($sourcedir . '/Subs-Members.php');
1906 2011
 			$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
1907
-			if (!in_array(-1, $allowedVoteGroups['allowed']))
1908
-				$_POST['poll_guest_vote'] = 0;
2012
+			if (!in_array(-1, $allowedVoteGroups['allowed'])) {
2013
+							$_POST['poll_guest_vote'] = 0;
2014
+			}
1909 2015
 		}
1910 2016
 
1911 2017
 		// If the user tries to set the poll too far in advance, don't let them.
1912
-		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1)
1913
-			fatal_lang_error('poll_range_error', false);
2018
+		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) {
2019
+					fatal_lang_error('poll_range_error', false);
2020
+		}
1914 2021
 		// Don't allow them to select option 2 for hidden results if it's not time limited.
1915
-		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
1916
-			$_POST['poll_hide'] = 1;
2022
+		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
2023
+					$_POST['poll_hide'] = 1;
2024
+		}
1917 2025
 
1918 2026
 		// Clean up the question and answers.
1919 2027
 		$_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']);
@@ -1927,13 +2035,15 @@  discard block
 block discarded – undo
1927 2035
 	{
1928 2036
 		$attachIDs = array();
1929 2037
 		$attach_errors = array();
1930
-		if (!empty($context['we_are_history']))
1931
-			$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2038
+		if (!empty($context['we_are_history'])) {
2039
+					$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2040
+		}
1932 2041
 
1933 2042
 		foreach ($_SESSION['temp_attachments'] as  $attachID => $attachment)
1934 2043
 		{
1935
-			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1936
-				continue;
2044
+			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
2045
+							continue;
2046
+			}
1937 2047
 
1938 2048
 			// If there was an initial error just show that message.
1939 2049
 			if ($attachID == 'initial_error')
@@ -1962,12 +2072,13 @@  discard block
 block discarded – undo
1962 2072
 				if (createAttachment($attachmentOptions))
1963 2073
 				{
1964 2074
 					$attachIDs[] = $attachmentOptions['id'];
1965
-					if (!empty($attachmentOptions['thumb']))
1966
-						$attachIDs[] = $attachmentOptions['thumb'];
2075
+					if (!empty($attachmentOptions['thumb'])) {
2076
+											$attachIDs[] = $attachmentOptions['thumb'];
2077
+					}
1967 2078
 				}
2079
+			} else {
2080
+							$attach_errors[] = '<dt>&nbsp;</dt>';
1968 2081
 			}
1969
-			else
1970
-				$attach_errors[] = '<dt>&nbsp;</dt>';
1971 2082
 
1972 2083
 			if (!empty($attachmentOptions['errors']))
1973 2084
 			{
@@ -1979,14 +2090,16 @@  discard block
 block discarded – undo
1979 2090
 					if (!is_array($error))
1980 2091
 					{
1981 2092
 						$attach_errors[] = '<dd>' . $txt[$error] . '</dd>';
1982
-						if (in_array($error, $log_these))
1983
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2093
+						if (in_array($error, $log_these)) {
2094
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2095
+						}
2096
+					} else {
2097
+											$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
1984 2098
 					}
1985
-					else
1986
-						$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
1987 2099
 				}
1988
-				if (file_exists($attachment['tmp_name']))
1989
-					unlink($attachment['tmp_name']);
2100
+				if (file_exists($attachment['tmp_name'])) {
2101
+									unlink($attachment['tmp_name']);
2102
+				}
1990 2103
 			}
1991 2104
 		}
1992 2105
 		unset($_SESSION['temp_attachments']);
@@ -2027,24 +2140,24 @@  discard block
 block discarded – undo
2027 2140
 		);
2028 2141
 
2029 2142
 		call_integration_hook('integrate_poll_add_edit', array($id_poll, false));
2143
+	} else {
2144
+			$id_poll = 0;
2030 2145
 	}
2031
-	else
2032
-		$id_poll = 0;
2033 2146
 
2034 2147
 	// Creating a new topic?
2035 2148
 	$newTopic = empty($_REQUEST['msg']) && empty($topic);
2036 2149
 
2037 2150
 	// Check the icon.
2038
-	if (!isset($_POST['icon']))
2039
-		$_POST['icon'] = 'xx';
2040
-
2041
-	else
2151
+	if (!isset($_POST['icon'])) {
2152
+			$_POST['icon'] = 'xx';
2153
+	} else
2042 2154
 	{
2043 2155
 		$_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']);
2044 2156
 
2045 2157
 		// Need to figure it out if this is a valid icon name.
2046
-		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')))
2047
-			$_POST['icon'] = 'xx';
2158
+		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) {
2159
+					$_POST['icon'] = 'xx';
2160
+		}
2048 2161
 	}
2049 2162
 
2050 2163
 	// Collect all parameters for the creation or modification of a post.
@@ -2085,8 +2198,9 @@  discard block
 block discarded – undo
2085 2198
 		}
2086 2199
 
2087 2200
 		// This will save some time...
2088
-		if (empty($approve_has_changed))
2089
-			unset($msgOptions['approved']);
2201
+		if (empty($approve_has_changed)) {
2202
+					unset($msgOptions['approved']);
2203
+		}
2090 2204
 
2091 2205
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2092 2206
 	}
@@ -2095,8 +2209,9 @@  discard block
 block discarded – undo
2095 2209
 	{
2096 2210
 		createPost($msgOptions, $topicOptions, $posterOptions);
2097 2211
 
2098
-		if (isset($topicOptions['id']))
2099
-			$topic = $topicOptions['id'];
2212
+		if (isset($topicOptions['id'])) {
2213
+					$topic = $topicOptions['id'];
2214
+		}
2100 2215
 	}
2101 2216
 
2102 2217
 	// Assign the previously uploaded attachments to the brand new message.
@@ -2108,8 +2223,9 @@  discard block
 block discarded – undo
2108 2223
 	}
2109 2224
 
2110 2225
 	// If we had a draft for this, its time to remove it since it was just posted
2111
-	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft']))
2112
-		DeleteDraft($_POST['id_draft']);
2226
+	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) {
2227
+			DeleteDraft($_POST['id_draft']);
2228
+	}
2113 2229
 
2114 2230
 	// Editing or posting an event?
2115 2231
 	if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1))
@@ -2128,8 +2244,7 @@  discard block
 block discarded – undo
2128 2244
 			'member' => $user_info['id'],
2129 2245
 		);
2130 2246
 		insertEvent($eventOptions);
2131
-	}
2132
-	elseif (isset($_POST['calendar']))
2247
+	} elseif (isset($_POST['calendar']))
2133 2248
 	{
2134 2249
 		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
2135 2250
 
@@ -2157,14 +2272,15 @@  discard block
 block discarded – undo
2157 2272
 		}
2158 2273
 
2159 2274
 		// Delete it?
2160
-		if (isset($_REQUEST['deleteevent']))
2161
-			$smcFunc['db_query']('', '
2275
+		if (isset($_REQUEST['deleteevent'])) {
2276
+					$smcFunc['db_query']('', '
2162 2277
 				DELETE FROM {db_prefix}calendar
2163 2278
 				WHERE id_event = {int:id_event}',
2164 2279
 				array(
2165 2280
 					'id_event' => $_REQUEST['eventid'],
2166 2281
 				)
2167 2282
 			);
2283
+		}
2168 2284
 		// ... or just update it?
2169 2285
 		else
2170 2286
 		{
@@ -2206,9 +2322,8 @@  discard block
 block discarded – undo
2206 2322
 			array($user_info['id'], $topic, 0),
2207 2323
 			array('id_member', 'id_topic', 'id_board')
2208 2324
 		);
2209
-	}
2210
-	elseif (!$newTopic)
2211
-		$smcFunc['db_query']('', '
2325
+	} elseif (!$newTopic) {
2326
+			$smcFunc['db_query']('', '
2212 2327
 			DELETE FROM {db_prefix}log_notify
2213 2328
 			WHERE id_member = {int:current_member}
2214 2329
 				AND id_topic = {int:current_topic}',
@@ -2217,16 +2332,20 @@  discard block
 block discarded – undo
2217 2332
 				'current_topic' => $topic,
2218 2333
 			)
2219 2334
 		);
2335
+	}
2220 2336
 
2221 2337
 	// Log an act of moderation - modifying.
2222
-	if (!empty($moderationAction))
2223
-		logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2338
+	if (!empty($moderationAction)) {
2339
+			logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2340
+	}
2224 2341
 
2225
-	if (isset($_POST['lock']) && $_POST['lock'] != 2)
2226
-		logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2342
+	if (isset($_POST['lock']) && $_POST['lock'] != 2) {
2343
+			logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2344
+	}
2227 2345
 
2228
-	if (isset($_POST['sticky']))
2229
-		logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2346
+	if (isset($_POST['sticky'])) {
2347
+			logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2348
+	}
2230 2349
 
2231 2350
 	// Returning to the topic?
2232 2351
 	if (!empty($_REQUEST['goback']))
@@ -2245,26 +2364,31 @@  discard block
 block discarded – undo
2245 2364
 		);
2246 2365
 	}
2247 2366
 
2248
-	if ($board_info['num_topics'] == 0)
2249
-		cache_put_data('board-' . $board, null, 120);
2367
+	if ($board_info['num_topics'] == 0) {
2368
+			cache_put_data('board-' . $board, null, 120);
2369
+	}
2250 2370
 
2251 2371
 	call_integration_hook('integrate_post2_end');
2252 2372
 
2253
-	if (!empty($_POST['announce_topic']))
2254
-		redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2373
+	if (!empty($_POST['announce_topic'])) {
2374
+			redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2375
+	}
2255 2376
 
2256
-	if (!empty($_POST['move']) && allowedTo('move_any'))
2257
-		redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2377
+	if (!empty($_POST['move']) && allowedTo('move_any')) {
2378
+			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2379
+	}
2258 2380
 
2259 2381
 	// Return to post if the mod is on.
2260
-	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback']))
2261
-		redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2262
-	elseif (!empty($_REQUEST['goback']))
2263
-		redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2382
+	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) {
2383
+			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2384
+	} elseif (!empty($_REQUEST['goback'])) {
2385
+			redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2386
+	}
2264 2387
 	// Dut-dut-duh-duh-DUH-duh-dut-duh-duh!  *dances to the Final Fantasy Fanfare...*
2265
-	else
2266
-		redirectexit('board=' . $board . '.0');
2267
-}
2388
+	else {
2389
+			redirectexit('board=' . $board . '.0');
2390
+	}
2391
+	}
2268 2392
 
2269 2393
 /**
2270 2394
  * Handle the announce topic function (action=announce).
@@ -2282,8 +2406,9 @@  discard block
 block discarded – undo
2282 2406
 
2283 2407
 	validateSession();
2284 2408
 
2285
-	if (empty($topic))
2286
-		fatal_lang_error('topic_gone', false);
2409
+	if (empty($topic)) {
2410
+			fatal_lang_error('topic_gone', false);
2411
+	}
2287 2412
 
2288 2413
 	loadLanguage('Post');
2289 2414
 	loadTemplate('Post');
@@ -2310,8 +2435,9 @@  discard block
 block discarded – undo
2310 2435
 	global $txt, $context, $topic, $board_info, $smcFunc;
2311 2436
 
2312 2437
 	$groups = array_merge($board_info['groups'], array(1));
2313
-	foreach ($groups as $id => $group)
2314
-		$groups[$id] = (int) $group;
2438
+	foreach ($groups as $id => $group) {
2439
+			$groups[$id] = (int) $group;
2440
+	}
2315 2441
 
2316 2442
 	$context['groups'] = array();
2317 2443
 	if (in_array(0, $groups))
@@ -2354,8 +2480,9 @@  discard block
 block discarded – undo
2354 2480
 			'group_list' => $groups,
2355 2481
 		)
2356 2482
 	);
2357
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2358
-		$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2483
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2484
+			$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2485
+	}
2359 2486
 	$smcFunc['db_free_result']($request);
2360 2487
 
2361 2488
 	// Get the subject of the topic we're about to announce.
@@ -2397,16 +2524,19 @@  discard block
 block discarded – undo
2397 2524
 	$context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
2398 2525
 	$groups = array_merge($board_info['groups'], array(1));
2399 2526
 
2400
-	if (isset($_POST['membergroups']))
2401
-		$_POST['who'] = explode(',', $_POST['membergroups']);
2527
+	if (isset($_POST['membergroups'])) {
2528
+			$_POST['who'] = explode(',', $_POST['membergroups']);
2529
+	}
2402 2530
 
2403 2531
 	// Check whether at least one membergroup was selected.
2404
-	if (empty($_POST['who']))
2405
-		fatal_lang_error('no_membergroup_selected');
2532
+	if (empty($_POST['who'])) {
2533
+			fatal_lang_error('no_membergroup_selected');
2534
+	}
2406 2535
 
2407 2536
 	// Make sure all membergroups are integers and can access the board of the announcement.
2408
-	foreach ($_POST['who'] as $id => $mg)
2409
-		$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2537
+	foreach ($_POST['who'] as $id => $mg) {
2538
+			$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2539
+	}
2410 2540
 
2411 2541
 	// Get the topic subject and censor it.
2412 2542
 	$request = $smcFunc['db_query']('', '
@@ -2452,12 +2582,13 @@  discard block
 block discarded – undo
2452 2582
 	if ($smcFunc['db_num_rows']($request) == 0)
2453 2583
 	{
2454 2584
 		logAction('announce_topic', array('topic' => $topic), 'user');
2455
-		if (!empty($_REQUEST['move']) && allowedTo('move_any'))
2456
-			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2457
-		elseif (!empty($_REQUEST['goback']))
2458
-			redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2459
-		else
2460
-			redirectexit('board=' . $board . '.0');
2585
+		if (!empty($_REQUEST['move']) && allowedTo('move_any')) {
2586
+					redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2587
+		} elseif (!empty($_REQUEST['goback'])) {
2588
+					redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2589
+		} else {
2590
+					redirectexit('board=' . $board . '.0');
2591
+		}
2461 2592
 	}
2462 2593
 
2463 2594
 	$announcements = array();
@@ -2476,8 +2607,9 @@  discard block
 block discarded – undo
2476 2607
 	foreach ($rows as $row)
2477 2608
 	{
2478 2609
 		// Force them to have it?
2479
-		if (empty($prefs[$row['id_member']]['announcements']))
2480
-			continue;
2610
+		if (empty($prefs[$row['id_member']]['announcements'])) {
2611
+					continue;
2612
+		}
2481 2613
 
2482 2614
 		$cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
2483 2615
 
@@ -2505,8 +2637,9 @@  discard block
 block discarded – undo
2505 2637
 	}
2506 2638
 
2507 2639
 	// For each language send a different mail - low priority...
2508
-	foreach ($announcements as $lang => $mail)
2509
-		sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2640
+	foreach ($announcements as $lang => $mail) {
2641
+			sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2642
+	}
2510 2643
 
2511 2644
 	$context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1);
2512 2645
 
@@ -2516,9 +2649,10 @@  discard block
 block discarded – undo
2516 2649
 	$context['sub_template'] = 'announcement_send';
2517 2650
 
2518 2651
 	// Go back to the correct language for the user ;).
2519
-	if (!empty($modSettings['userLanguage']))
2520
-		loadLanguage('Post');
2521
-}
2652
+	if (!empty($modSettings['userLanguage'])) {
2653
+			loadLanguage('Post');
2654
+	}
2655
+	}
2522 2656
 
2523 2657
 /**
2524 2658
  * Get the topic for display purposes.
@@ -2531,12 +2665,13 @@  discard block
 block discarded – undo
2531 2665
 {
2532 2666
 	global $topic, $modSettings, $context, $smcFunc, $counter, $options;
2533 2667
 
2534
-	if (isset($_REQUEST['xml']))
2535
-		$limit = '
2668
+	if (isset($_REQUEST['xml'])) {
2669
+			$limit = '
2536 2670
 		LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']);
2537
-	else
2538
-		$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2671
+	} else {
2672
+			$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2539 2673
 		LIMIT ' . (int) $modSettings['topicSummaryPosts'];
2674
+	}
2540 2675
 
2541 2676
 	// If you're modifying, get only those posts before the current one. (otherwise get all.)
2542 2677
 	$request = $smcFunc['db_query']('', '
@@ -2574,8 +2709,9 @@  discard block
 block discarded – undo
2574 2709
 			'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']),
2575 2710
 		);
2576 2711
 
2577
-		if (!empty($context['new_replies']))
2578
-			$context['new_replies']--;
2712
+		if (!empty($context['new_replies'])) {
2713
+					$context['new_replies']--;
2714
+		}
2579 2715
 	}
2580 2716
 	$smcFunc['db_free_result']($request);
2581 2717
 }
@@ -2592,8 +2728,9 @@  discard block
 block discarded – undo
2592 2728
 	global $sourcedir, $smcFunc;
2593 2729
 
2594 2730
 	loadLanguage('Post');
2595
-	if (!isset($_REQUEST['xml']))
2596
-		loadTemplate('Post');
2731
+	if (!isset($_REQUEST['xml'])) {
2732
+			loadTemplate('Post');
2733
+	}
2597 2734
 
2598 2735
 	include_once($sourcedir . '/Subs-Post.php');
2599 2736
 
@@ -2624,8 +2761,9 @@  discard block
 block discarded – undo
2624 2761
 	$smcFunc['db_free_result']($request);
2625 2762
 
2626 2763
 	$context['sub_template'] = 'quotefast';
2627
-	if (!empty($row))
2628
-		$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2764
+	if (!empty($row)) {
2765
+			$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2766
+	}
2629 2767
 
2630 2768
 	if (!empty($can_view_post))
2631 2769
 	{
@@ -2658,8 +2796,9 @@  discard block
 block discarded – undo
2658 2796
 		}
2659 2797
 
2660 2798
 		// Remove any nested quotes.
2661
-		if (!empty($modSettings['removeNestedQuotes']))
2662
-			$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2799
+		if (!empty($modSettings['removeNestedQuotes'])) {
2800
+					$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2801
+		}
2663 2802
 
2664 2803
 		$lb = "\n";
2665 2804
 
@@ -2685,14 +2824,14 @@  discard block
 block discarded – undo
2685 2824
 				'time' => '',
2686 2825
 			),
2687 2826
 		);
2688
-	}
2689
-	else
2690
-		$context['quote'] = array(
2827
+	} else {
2828
+			$context['quote'] = array(
2691 2829
 			'xml' => '',
2692 2830
 			'mozilla' => '',
2693 2831
 			'text' => '',
2694 2832
 		);
2695
-}
2833
+	}
2834
+	}
2696 2835
 
2697 2836
 /**
2698 2837
  * Used to edit the body or subject of a message inline
@@ -2704,8 +2843,9 @@  discard block
 block discarded – undo
2704 2843
 	global $user_info, $context, $smcFunc, $language, $board_info;
2705 2844
 
2706 2845
 	// We have to have a topic!
2707
-	if (empty($topic))
2708
-		obExit(false);
2846
+	if (empty($topic)) {
2847
+			obExit(false);
2848
+	}
2709 2849
 
2710 2850
 	checkSession('get');
2711 2851
 	require_once($sourcedir . '/Subs-Post.php');
@@ -2731,31 +2871,35 @@  discard block
 block discarded – undo
2731 2871
 			'guest_id' => 0,
2732 2872
 		)
2733 2873
 	);
2734
-	if ($smcFunc['db_num_rows']($request) == 0)
2735
-		fatal_lang_error('no_board', false);
2874
+	if ($smcFunc['db_num_rows']($request) == 0) {
2875
+			fatal_lang_error('no_board', false);
2876
+	}
2736 2877
 	$row = $smcFunc['db_fetch_assoc']($request);
2737 2878
 	$smcFunc['db_free_result']($request);
2738 2879
 
2739 2880
 	// Change either body or subject requires permissions to modify messages.
2740 2881
 	if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon']))
2741 2882
 	{
2742
-		if (!empty($row['locked']))
2743
-			isAllowedTo('moderate_board');
2883
+		if (!empty($row['locked'])) {
2884
+					isAllowedTo('moderate_board');
2885
+		}
2744 2886
 
2745 2887
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
2746 2888
 		{
2747
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
2748
-				fatal_lang_error('modify_post_time_passed', false);
2749
-			elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
2750
-				isAllowedTo('modify_replies');
2751
-			else
2752
-				isAllowedTo('modify_own');
2889
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
2890
+							fatal_lang_error('modify_post_time_passed', false);
2891
+			} elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
2892
+							isAllowedTo('modify_replies');
2893
+			} else {
2894
+							isAllowedTo('modify_own');
2895
+			}
2753 2896
 		}
2754 2897
 		// Otherwise, they're locked out; someone who can modify the replies is needed.
2755
-		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
2756
-			isAllowedTo('modify_replies');
2757
-		else
2758
-			isAllowedTo('modify_any');
2898
+		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) {
2899
+					isAllowedTo('modify_replies');
2900
+		} else {
2901
+					isAllowedTo('modify_any');
2902
+		}
2759 2903
 
2760 2904
 		// Only log this action if it wasn't your message.
2761 2905
 		$moderationAction = $row['id_member'] != $user_info['id'];
@@ -2767,10 +2911,10 @@  discard block
 block discarded – undo
2767 2911
 		$_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
2768 2912
 
2769 2913
 		// Maximum number of characters.
2770
-		if ($smcFunc['strlen']($_POST['subject']) > 100)
2771
-			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2772
-	}
2773
-	elseif (isset($_POST['subject']))
2914
+		if ($smcFunc['strlen']($_POST['subject']) > 100) {
2915
+					$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2916
+		}
2917
+	} elseif (isset($_POST['subject']))
2774 2918
 	{
2775 2919
 		$post_errors[] = 'no_subject';
2776 2920
 		unset($_POST['subject']);
@@ -2782,13 +2926,11 @@  discard block
 block discarded – undo
2782 2926
 		{
2783 2927
 			$post_errors[] = 'no_message';
2784 2928
 			unset($_POST['message']);
2785
-		}
2786
-		elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
2929
+		} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
2787 2930
 		{
2788 2931
 			$post_errors[] = 'long_message';
2789 2932
 			unset($_POST['message']);
2790
-		}
2791
-		else
2933
+		} else
2792 2934
 		{
2793 2935
 			$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
2794 2936
 
@@ -2804,31 +2946,34 @@  discard block
 block discarded – undo
2804 2946
 
2805 2947
 	if (isset($_POST['lock']))
2806 2948
 	{
2807
-		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member']))
2808
-			unset($_POST['lock']);
2809
-		elseif (!allowedTo('lock_any'))
2949
+		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) {
2950
+					unset($_POST['lock']);
2951
+		} elseif (!allowedTo('lock_any'))
2810 2952
 		{
2811
-			if ($row['locked'] == 1)
2812
-				unset($_POST['lock']);
2813
-			else
2814
-				$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
2953
+			if ($row['locked'] == 1) {
2954
+							unset($_POST['lock']);
2955
+			} else {
2956
+							$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
2957
+			}
2958
+		} elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) {
2959
+					unset($_POST['lock']);
2960
+		} else {
2961
+					$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2815 2962
 		}
2816
-		elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked'])
2817
-			unset($_POST['lock']);
2818
-		else
2819
-			$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2820 2963
 	}
2821 2964
 
2822
-	if (isset($_POST['sticky']) && !allowedTo('make_sticky'))
2823
-		unset($_POST['sticky']);
2965
+	if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
2966
+			unset($_POST['sticky']);
2967
+	}
2824 2968
 
2825 2969
 	if (isset($_POST['modify_reason']))
2826 2970
 	{
2827 2971
 		$_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
2828 2972
 
2829 2973
 		// Maximum number of characters.
2830
-		if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
2831
-			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2974
+		if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
2975
+					$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2976
+		}
2832 2977
 	}
2833 2978
 
2834 2979
 	if (empty($post_errors))
@@ -2865,8 +3010,9 @@  discard block
 block discarded – undo
2865 3010
 			}
2866 3011
 		}
2867 3012
 		// If nothing was changed there's no need to add an entry to the moderation log.
2868
-		else
2869
-			$moderationAction = false;
3013
+		else {
3014
+					$moderationAction = false;
3015
+		}
2870 3016
 
2871 3017
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2872 3018
 
@@ -2884,9 +3030,9 @@  discard block
 block discarded – undo
2884 3030
 			// Get the proper (default language) response prefix first.
2885 3031
 			if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
2886 3032
 			{
2887
-				if ($language === $user_info['language'])
2888
-					$context['response_prefix'] = $txt['response_prefix'];
2889
-				else
3033
+				if ($language === $user_info['language']) {
3034
+									$context['response_prefix'] = $txt['response_prefix'];
3035
+				} else
2890 3036
 				{
2891 3037
 					loadLanguage('index', $language, false);
2892 3038
 					$context['response_prefix'] = $txt['response_prefix'];
@@ -2908,8 +3054,9 @@  discard block
 block discarded – undo
2908 3054
 			);
2909 3055
 		}
2910 3056
 
2911
-		if (!empty($moderationAction))
2912
-			logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3057
+		if (!empty($moderationAction)) {
3058
+					logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3059
+		}
2913 3060
 	}
2914 3061
 
2915 3062
 	if (isset($_REQUEST['xml']))
@@ -2950,8 +3097,7 @@  discard block
 block discarded – undo
2950 3097
 			);
2951 3098
 
2952 3099
 			censorText($context['message']['subject']);
2953
-		}
2954
-		else
3100
+		} else
2955 3101
 		{
2956 3102
 			$context['message'] = array(
2957 3103
 				'id' => $row['id_msg'],
@@ -2963,15 +3109,16 @@  discard block
 block discarded – undo
2963 3109
 			loadLanguage('Errors');
2964 3110
 			foreach ($post_errors as $post_error)
2965 3111
 			{
2966
-				if ($post_error == 'long_message')
2967
-					$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
2968
-				else
2969
-					$context['message']['errors'][] = $txt['error_' . $post_error];
3112
+				if ($post_error == 'long_message') {
3113
+									$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
3114
+				} else {
3115
+									$context['message']['errors'][] = $txt['error_' . $post_error];
3116
+				}
2970 3117
 			}
2971 3118
 		}
3119
+	} else {
3120
+			obExit(false);
3121
+	}
2972 3122
 	}
2973
-	else
2974
-		obExit(false);
2975
-}
2976 3123
 
2977 3124
 ?>
2978 3125
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Modlog.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 					'class' => 'centercol',
257 257
 				),
258 258
 				'data' => array(
259
-					'function' => function ($entry)
259
+					'function' => function($entry)
260 260
 					{
261 261
 						return '<input type="checkbox" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>';
262 262
 					},
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 		if (empty($entries[$k]['action_text']))
639 639
 			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
640 640
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
641
-			function ($matches) use ($entries, $k)
641
+			function($matches) use ($entries, $k)
642 642
 			{
643 643
 				return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : '';
644 644
 			}, $entries[$k]['action_text']);
Please login to merge, or discard this patch.
Braces   +99 added lines, -75 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
  * Prepares the information from the moderation log for viewing.
@@ -32,14 +33,16 @@  discard block
 block discarded – undo
32 33
 
33 34
 	// Are we looking at the moderation log or the administration log.
34 35
 	$context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1;
35
-	if ($context['log_type'] == 3)
36
-		isAllowedTo('admin_forum');
36
+	if ($context['log_type'] == 3) {
37
+			isAllowedTo('admin_forum');
38
+	}
37 39
 
38 40
 	// These change dependant on whether we are viewing the moderation or admin log.
39
-	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin')
40
-		$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
41
-	else
42
-		$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
41
+	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') {
42
+			$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
43
+	} else {
44
+			$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
45
+	}
43 46
 
44 47
 	$context['can_delete'] = allowedTo('admin_forum');
45 48
 
@@ -67,8 +70,7 @@  discard block
 block discarded – undo
67 70
 		$log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate';
68 71
 		logAction('clearlog_' . $log_type, array(), $log_type);
69 72
 
70
-	}
71
-	elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
73
+	} elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
72 74
 	{
73 75
 		checkSession();
74 76
 		validateToken('mod-ml');
@@ -114,15 +116,17 @@  discard block
 block discarded – undo
114 116
 		'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip'])
115 117
 	);
116 118
 
117
-	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']))
118
-		$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
119
-	else
120
-		$search_params_string = $search_params['string'];
119
+	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) {
120
+			$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
121
+	} else {
122
+			$search_params_string = $search_params['string'];
123
+	}
121 124
 
122
-	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']]))
123
-		$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
124
-	else
125
-		$search_params_type = $search_params['type'];
125
+	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) {
126
+			$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
127
+	} else {
128
+			$search_params_type = $search_params['type'];
129
+	}
126 130
 
127 131
 	$search_params_column = $searchTypes[$search_params_type]['sql'];
128 132
 	$search_params = array(
@@ -301,15 +305,16 @@  discard block
 block discarded – undo
301 305
 	$context['default_list'] = 'moderation_log_list';
302 306
 
303 307
 	// If a hook has changed this, respect it.
304
-	if (!empty($moderation_menu_name))
305
-		$context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name;
306
-	elseif (isset($context['moderation_menu_name']))
307
-		$context[$context['moderation_menu_name']]['tab_data'] = array(
308
+	if (!empty($moderation_menu_name)) {
309
+			$context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name;
310
+	} elseif (isset($context['moderation_menu_name'])) {
311
+			$context[$context['moderation_menu_name']]['tab_data'] = array(
308 312
 			'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'],
309 313
 			'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog',
310 314
 			'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc']
311 315
 		);
312
-}
316
+	}
317
+	}
313 318
 
314 319
 /**
315 320
  * Get the number of mod log entries.
@@ -413,30 +418,35 @@  discard block
 block discarded – undo
413 418
 		// Add on some of the column stuff info
414 419
 		if (!empty($row['id_board']))
415 420
 		{
416
-			if ($row['action'] == 'move')
417
-				$row['extra']['board_to'] = $row['id_board'];
418
-			else
419
-				$row['extra']['board'] = $row['id_board'];
421
+			if ($row['action'] == 'move') {
422
+							$row['extra']['board_to'] = $row['id_board'];
423
+			} else {
424
+							$row['extra']['board'] = $row['id_board'];
425
+			}
420 426
 		}
421 427
 
422
-		if (!empty($row['id_topic']))
423
-			$row['extra']['topic'] = $row['id_topic'];
424
-		if (!empty($row['id_msg']))
425
-			$row['extra']['message'] = $row['id_msg'];
428
+		if (!empty($row['id_topic'])) {
429
+					$row['extra']['topic'] = $row['id_topic'];
430
+		}
431
+		if (!empty($row['id_msg'])) {
432
+					$row['extra']['message'] = $row['id_msg'];
433
+		}
426 434
 
427 435
 		// Is this associated with a topic?
428
-		if (isset($row['extra']['topic']))
429
-			$topics[(int) $row['extra']['topic']][] = $row['id_action'];
430
-		if (isset($row['extra']['new_topic']))
431
-			$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
436
+		if (isset($row['extra']['topic'])) {
437
+					$topics[(int) $row['extra']['topic']][] = $row['id_action'];
438
+		}
439
+		if (isset($row['extra']['new_topic'])) {
440
+					$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
441
+		}
432 442
 
433 443
 		// How about a member?
434 444
 		if (isset($row['extra']['member']))
435 445
 		{
436 446
 			// Guests don't have names!
437
-			if (empty($row['extra']['member']))
438
-				$row['extra']['member'] = $txt['modlog_parameter_guest'];
439
-			else
447
+			if (empty($row['extra']['member'])) {
448
+							$row['extra']['member'] = $txt['modlog_parameter_guest'];
449
+			} else
440 450
 			{
441 451
 				// Try to find it...
442 452
 				$members[(int) $row['extra']['member']][] = $row['id_action'];
@@ -444,35 +454,42 @@  discard block
 block discarded – undo
444 454
 		}
445 455
 
446 456
 		// Associated with a board?
447
-		if (isset($row['extra']['board_to']))
448
-			$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
449
-		if (isset($row['extra']['board_from']))
450
-			$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
451
-		if (isset($row['extra']['board']))
452
-			$boards[(int) $row['extra']['board']][] = $row['id_action'];
457
+		if (isset($row['extra']['board_to'])) {
458
+					$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
459
+		}
460
+		if (isset($row['extra']['board_from'])) {
461
+					$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
462
+		}
463
+		if (isset($row['extra']['board'])) {
464
+					$boards[(int) $row['extra']['board']][] = $row['id_action'];
465
+		}
453 466
 
454 467
 		// A message?
455
-		if (isset($row['extra']['message']))
456
-			$messages[(int) $row['extra']['message']][] = $row['id_action'];
468
+		if (isset($row['extra']['message'])) {
469
+					$messages[(int) $row['extra']['message']][] = $row['id_action'];
470
+		}
457 471
 
458 472
 		// IP Info?
459
-		if (isset($row['extra']['ip_range']))
460
-			if ($seeIP)
473
+		if (isset($row['extra']['ip_range'])) {
474
+					if ($seeIP)
461 475
 				$row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
462
-			else
463
-				$row['extra']['ip_range'] = $txt['logged'];
476
+		} else {
477
+							$row['extra']['ip_range'] = $txt['logged'];
478
+			}
464 479
 
465 480
 		// Email?
466
-		if (isset($row['extra']['email']))
467
-			$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
481
+		if (isset($row['extra']['email'])) {
482
+					$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
483
+		}
468 484
 
469 485
 		// Bans are complex.
470 486
 		if ($row['action'] == 'ban' || $row['action'] == 'banremove')
471 487
 		{
472 488
 			$row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')];
473
-			foreach (array('member', 'email', 'ip_range', 'hostname') as $type)
474
-				if (isset($row['extra'][$type]))
489
+			foreach (array('member', 'email', 'ip_range', 'hostname') as $type) {
490
+							if (isset($row['extra'][$type]))
475 491
 					$row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type];
492
+			}
476 493
 		}
477 494
 
478 495
 		// The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details.
@@ -508,12 +525,13 @@  discard block
 block discarded – undo
508 525
 			foreach ($boards[$row['id_board']] as $action)
509 526
 			{
510 527
 				// Make the board number into a link - dealing with moving too.
511
-				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board'])
512
-					$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
513
-				elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board'])
514
-					$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
515
-				elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board'])
516
-					$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
528
+				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) {
529
+									$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
530
+				} elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) {
531
+									$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
532
+				} elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) {
533
+									$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
534
+				}
517 535
 			}
518 536
 		}
519 537
 		$smcFunc['db_free_result']($request);
@@ -547,10 +565,11 @@  discard block
 block discarded – undo
547 565
 				);
548 566
 
549 567
 				// Make the topic number into a link - dealing with splitting too.
550
-				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic'])
551
-					$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
552
-				elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic'])
553
-					$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
568
+				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) {
569
+									$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
570
+				} elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) {
571
+									$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
572
+				}
554 573
 			}
555 574
 		}
556 575
 		$smcFunc['db_free_result']($request);
@@ -583,8 +602,9 @@  discard block
 block discarded – undo
583 602
 				);
584 603
 
585 604
 				// Make the message number into a link.
586
-				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg'])
587
-					$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
605
+				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) {
606
+									$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
607
+				}
588 608
 			}
589 609
 		}
590 610
 		$smcFunc['db_free_result']($request);
@@ -624,25 +644,29 @@  discard block
 block discarded – undo
624 644
 	foreach ($entries as $k => $entry)
625 645
 	{
626 646
 		// Make any message info links so its easier to go find that message.
627
-		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id'])))
628
-			$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
647
+		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) {
648
+					$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
649
+		}
629 650
 
630 651
 		// Mark up any deleted members, topics and boards.
631
-		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type)
632
-			if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
652
+		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) {
653
+					if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
633 654
 				$entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]);
655
+		}
634 656
 
635 657
 		if (isset($entry['extra']['report']))
636 658
 		{
637 659
 			// Member profile reports go in a different area
638
-			if (stristr($entry['action'], 'user_report'))
639
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
640
-			else
641
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
660
+			if (stristr($entry['action'], 'user_report')) {
661
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
662
+			} else {
663
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
664
+			}
642 665
 		}
643 666
 
644
-		if (empty($entries[$k]['action_text']))
645
-			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
667
+		if (empty($entries[$k]['action_text'])) {
668
+					$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
669
+		}
646 670
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
647 671
 			function ($matches) use ($entries, $k)
648 672
 			{
Please login to merge, or discard this patch.
Sources/Profile.php 1 patch
Braces   +155 added lines, -118 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) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
599
-				fatal_lang_error('login_ssl_required');
620
+			if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
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']('', '
@@ -894,13 +929,15 @@  discard block
 block discarded – undo
894 929
 		if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']]))
895 930
 		{
896 931
 			$value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]);
897
-			if (in_array($row['field_type'], array('select', 'radio')))
898
-					$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
932
+			if (in_array($row['field_type'], array('select', 'radio'))) {
933
+								$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
934
+			}
899 935
 		}
900 936
 
901 937
 		// Don't show the "disabled" option for the "gender" field if we are on the "summary" area.
902
-		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled')
903
-			continue;
938
+		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') {
939
+					continue;
940
+		}
904 941
 
905 942
 		// HTML for the input form.
906 943
 		$output_html = $value;
@@ -909,8 +946,7 @@  discard block
 block discarded – undo
909 946
 			$true = (!$exists && $row['default_value']) || $value;
910 947
 			$input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>';
911 948
 			$output_html = $true ? $txt['yes'] : $txt['no'];
912
-		}
913
-		elseif ($row['field_type'] == 'select')
949
+		} elseif ($row['field_type'] == 'select')
914 950
 		{
915 951
 			$input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>';
916 952
 			$options = explode(',', $row['field_options']);
@@ -918,13 +954,13 @@  discard block
 block discarded – undo
918 954
 			{
919 955
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
920 956
 				$input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>';
921
-				if ($true)
922
-					$output_html = $v;
957
+				if ($true) {
958
+									$output_html = $v;
959
+				}
923 960
 			}
924 961
 
925 962
 			$input_html .= '</select>';
926
-		}
927
-		elseif ($row['field_type'] == 'radio')
963
+		} elseif ($row['field_type'] == 'radio')
928 964
 		{
929 965
 			$input_html = '<fieldset>';
930 966
 			$options = explode(',', $row['field_options']);
@@ -932,36 +968,37 @@  discard block
 block discarded – undo
932 968
 			{
933 969
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
934 970
 				$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>';
935
-				if ($true)
936
-					$output_html = $v;
971
+				if ($true) {
972
+									$output_html = $v;
973
+				}
937 974
 			}
938 975
 			$input_html .= '</fieldset>';
939
-		}
940
-		elseif ($row['field_type'] == 'text')
976
+		} elseif ($row['field_type'] == 'text')
941 977
 		{
942 978
 			$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' : '') . '>';
943
-		}
944
-		else
979
+		} else
945 980
 		{
946 981
 			@list ($rows, $cols) = @explode(',', $row['default_value']);
947 982
 			$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>';
948 983
 		}
949 984
 
950 985
 		// Parse BBCode
951
-		if ($row['bbc'])
952
-			$output_html = parse_bbc($output_html);
953
-		elseif ($row['field_type'] == 'textarea')
954
-			// Allow for newlines at least
986
+		if ($row['bbc']) {
987
+					$output_html = parse_bbc($output_html);
988
+		} elseif ($row['field_type'] == 'textarea') {
989
+					// Allow for newlines at least
955 990
 			$output_html = strtr($output_html, array("\n" => '<br>'));
991
+		}
956 992
 
957 993
 		// Enclosing the user input within some other text?
958
-		if (!empty($row['enclose']) && !empty($output_html))
959
-			$output_html = strtr($row['enclose'], array(
994
+		if (!empty($row['enclose']) && !empty($output_html)) {
995
+					$output_html = strtr($row['enclose'], array(
960 996
 				'{SCRIPTURL}' => $scripturl,
961 997
 				'{IMAGES_URL}' => $settings['images_url'],
962 998
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
963 999
 				'{INPUT}' => un_htmlspecialchars($output_html),
964 1000
 			));
1001
+		}
965 1002
 
966 1003
 		$context['custom_fields'][] = array(
967 1004
 			'name' => $row['field_name'],
Please login to merge, or discard this patch.
Sources/LogInOut.php 1 patch
Braces   +158 added lines, -124 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
  * Ask them for their login information. (shows a page for the user to type
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $txt, $context, $scripturl, $user_info;
30 31
 
31 32
 	// You are already logged in, go take a tour of the boards
32
-	if (!empty($user_info['id']))
33
-		redirectexit();
33
+	if (!empty($user_info['id'])) {
34
+			redirectexit();
35
+	}
34 36
 
35 37
 	// We need to load the Login template/language file.
36 38
 	loadLanguage('Login');
@@ -57,10 +59,11 @@  discard block
 block discarded – undo
57 59
 	);
58 60
 
59 61
 	// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
60
-	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
61
-		$_SESSION['login_url'] = $_SESSION['old_url'];
62
-	elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false)
63
-		unset($_SESSION['login_url']);
62
+	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
63
+			$_SESSION['login_url'] = $_SESSION['old_url'];
64
+	} elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) {
65
+			unset($_SESSION['login_url']);
66
+	}
64 67
 
65 68
 	// Create a one time token.
66 69
 	createToken('login');
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
 	global $cookiename, $modSettings, $context, $sourcedir, $maintenance;
84 87
 
85 88
 	// Check to ensure we're forcing SSL for authentication
86
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
87
-		fatal_lang_error('login_ssl_required');
89
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
90
+			fatal_lang_error('login_ssl_required');
91
+	}
88 92
 
89 93
 	// Load cookie authentication stuff.
90 94
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -102,19 +106,20 @@  discard block
 block discarded – undo
102 106
 			list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
103 107
 
104 108
 			// That didn't work... Maybe it's using serialize?
105
-			if (is_null($timeout))
106
-				list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
107
-		}
108
-		elseif (isset($_SESSION['login_' . $cookiename]))
109
+			if (is_null($timeout)) {
110
+							list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
111
+			}
112
+		} elseif (isset($_SESSION['login_' . $cookiename]))
109 113
 		{
110 114
 			list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
111 115
 
112 116
 			// Try for old format
113
-			if (is_null($timeout))
114
-				list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
117
+			if (is_null($timeout)) {
118
+							list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
119
+			}
120
+		} else {
121
+					trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
115 122
 		}
116
-		else
117
-			trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
118 123
 
119 124
 		$user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
120 125
 		updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
@@ -127,10 +132,11 @@  discard block
 block discarded – undo
127 132
 			list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata;
128 133
 
129 134
 			// If we're preserving the cookie, reset it with updated salt
130
-			if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp)
131
-				setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true);
132
-			else
133
-				setTFACookie(-3600, 0, '');
135
+			if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) {
136
+							setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true);
137
+			} else {
138
+							setTFACookie(-3600, 0, '');
139
+			}
134 140
 		}
135 141
 
136 142
 		setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
@@ -141,20 +147,20 @@  discard block
 block discarded – undo
141 147
 	elseif (isset($_GET['sa']) && $_GET['sa'] == 'check')
142 148
 	{
143 149
 		// Strike!  You're outta there!
144
-		if ($_GET['member'] != $user_info['id'])
145
-			fatal_lang_error('login_cookie_error', false);
150
+		if ($_GET['member'] != $user_info['id']) {
151
+					fatal_lang_error('login_cookie_error', false);
152
+		}
146 153
 
147 154
 		$user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']))));
148 155
 
149 156
 		// Some whitelisting for login_url...
150
-		if (empty($_SESSION['login_url']))
151
-			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
152
-		elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
157
+		if (empty($_SESSION['login_url'])) {
158
+					redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
159
+		} elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
153 160
 		{
154 161
 			unset ($_SESSION['login_url']);
155 162
 			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
156
-		}
157
-		else
163
+		} else
158 164
 		{
159 165
 			// Best not to clutter the session data too much...
160 166
 			$temp = $_SESSION['login_url'];
@@ -165,8 +171,9 @@  discard block
 block discarded – undo
165 171
 	}
166 172
 
167 173
 	// Beyond this point you are assumed to be a guest trying to login.
168
-	if (!$user_info['is_guest'])
169
-		redirectexit();
174
+	if (!$user_info['is_guest']) {
175
+			redirectexit();
176
+	}
170 177
 
171 178
 	// Are you guessing with a script?
172 179
 	checkSession();
@@ -174,18 +181,21 @@  discard block
 block discarded – undo
174 181
 	spamProtection('login');
175 182
 
176 183
 	// Set the login_url if it's not already set (but careful not to send us to an attachment).
177
-	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false))
178
-		$_SESSION['login_url'] = $_SESSION['old_url'];
184
+	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) {
185
+			$_SESSION['login_url'] = $_SESSION['old_url'];
186
+	}
179 187
 
180 188
 	// Been guessing a lot, haven't we?
181
-	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3)
182
-		fatal_lang_error('login_threshold_fail', 'login');
189
+	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) {
190
+			fatal_lang_error('login_threshold_fail', 'login');
191
+	}
183 192
 
184 193
 	// Set up the cookie length.  (if it's invalid, just fall through and use the default.)
185
-	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1))
186
-		$modSettings['cookieTime'] = 3153600;
187
-	elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600))
188
-		$modSettings['cookieTime'] = (int) $_POST['cookielength'];
194
+	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) {
195
+			$modSettings['cookieTime'] = 3153600;
196
+	} elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) {
197
+			$modSettings['cookieTime'] = (int) $_POST['cookielength'];
198
+	}
189 199
 
190 200
 	loadLanguage('Login');
191 201
 	// Load the template stuff.
@@ -305,8 +315,9 @@  discard block
 block discarded – undo
305 315
 			$other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd']));
306 316
 
307 317
 			// Snitz style - SHA-256.  Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway.
308
-			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256'))
309
-				$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
318
+			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) {
319
+							$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
320
+			}
310 321
 
311 322
 			// phpBB3 users new hashing.  We now support it as well ;).
312 323
 			$other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']);
@@ -326,27 +337,29 @@  discard block
 block discarded – undo
326 337
 			// Some common md5 ones.
327 338
 			$other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']);
328 339
 			$other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']);
329
-		}
330
-		elseif (strlen($user_settings['passwd']) == 40)
340
+		} elseif (strlen($user_settings['passwd']) == 40)
331 341
 		{
332 342
 			// Maybe they are using a hash from before the password fix.
333 343
 			// This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1
334 344
 			$other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
335 345
 
336 346
 			// BurningBoard3 style of hashing.
337
-			if (!empty($modSettings['enable_password_conversion']))
338
-				$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
347
+			if (!empty($modSettings['enable_password_conversion'])) {
348
+							$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
349
+			}
339 350
 
340 351
 			// Perhaps we converted to UTF-8 and have a valid password being hashed differently.
341 352
 			if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
342 353
 			{
343 354
 				// Try iconv first, for no particular reason.
344
-				if (function_exists('iconv'))
345
-					$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
355
+				if (function_exists('iconv')) {
356
+									$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
357
+				}
346 358
 
347 359
 				// Say it aint so, iconv failed!
348
-				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
349
-					$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
360
+				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) {
361
+									$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
362
+				}
350 363
 			}
351 364
 		}
352 365
 
@@ -376,8 +389,9 @@  discard block
 block discarded – undo
376 389
 			$_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1;
377 390
 
378 391
 			// Hmm... don't remember it, do you?  Here, try the password reminder ;).
379
-			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
380
-				redirectexit('action=reminder');
392
+			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) {
393
+							redirectexit('action=reminder');
394
+			}
381 395
 			// We'll give you another chance...
382 396
 			else
383 397
 			{
@@ -388,8 +402,7 @@  discard block
 block discarded – undo
388 402
 				return;
389 403
 			}
390 404
 		}
391
-	}
392
-	elseif (!empty($user_settings['passwd_flood']))
405
+	} elseif (!empty($user_settings['passwd_flood']))
393 406
 	{
394 407
 		// Let's be sure they weren't a little hacker.
395 408
 		validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true);
@@ -406,8 +419,9 @@  discard block
 block discarded – undo
406 419
 	}
407 420
 
408 421
 	// Check their activation status.
409
-	if (!checkActivation())
410
-		return;
422
+	if (!checkActivation()) {
423
+			return;
424
+	}
411 425
 
412 426
 	DoLogin();
413 427
 }
@@ -419,8 +433,9 @@  discard block
 block discarded – undo
419 433
 {
420 434
 	global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl;
421 435
 
422
-	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode']))
423
-		fatal_lang_error('no_access', false);
436
+	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) {
437
+			fatal_lang_error('no_access', false);
438
+	}
424 439
 
425 440
 	loadLanguage('Profile');
426 441
 	require_once($sourcedir . '/Class-TOTP.php');
@@ -428,8 +443,9 @@  discard block
 block discarded – undo
428 443
 	$member = $context['tfa_member'];
429 444
 
430 445
 	// Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA
431
-	if (time() - $member['last_login'] < 120)
432
-		fatal_lang_error('tfa_wait', false);
446
+	if (time() - $member['last_login'] < 120) {
447
+			fatal_lang_error('tfa_wait', false);
448
+	}
433 449
 
434 450
 	$totp = new \TOTP\Auth($member['tfa_secret']);
435 451
 	$totp->setRange(1);
@@ -443,8 +459,9 @@  discard block
 block discarded – undo
443 459
 	if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup']))
444 460
 	{
445 461
 		// Check to ensure we're forcing SSL for authentication
446
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
447
-			fatal_lang_error('login_ssl_required');
462
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
463
+					fatal_lang_error('login_ssl_required');
464
+		}
448 465
 
449 466
 		$code = $_POST['tfa_code'];
450 467
 
@@ -454,20 +471,19 @@  discard block
 block discarded – undo
454 471
 
455 472
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve']));
456 473
 			redirectexit();
457
-		}
458
-		else
474
+		} else
459 475
 		{
460 476
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
461 477
 
462 478
 			$context['tfa_error'] = true;
463 479
 			$context['tfa_value'] = $_POST['tfa_code'];
464 480
 		}
465
-	}
466
-	elseif (!empty($_POST['tfa_backup']))
481
+	} elseif (!empty($_POST['tfa_backup']))
467 482
 	{
468 483
 		// Check to ensure we're forcing SSL for authentication
469
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
470
-			fatal_lang_error('login_ssl_required');
484
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
485
+					fatal_lang_error('login_ssl_required');
486
+		}
471 487
 
472 488
 		$backup = $_POST['tfa_backup'];
473 489
 
@@ -481,8 +497,7 @@  discard block
 block discarded – undo
481 497
 			));
482 498
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
483 499
 			redirectexit('action=profile;area=tfasetup;backup');
484
-		}
485
-		else
500
+		} else
486 501
 		{
487 502
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
488 503
 
@@ -505,8 +520,9 @@  discard block
 block discarded – undo
505 520
 {
506 521
 	global $context, $txt, $scripturl, $user_settings, $modSettings;
507 522
 
508
-	if (!isset($context['login_errors']))
509
-		$context['login_errors'] = array();
523
+	if (!isset($context['login_errors'])) {
524
+			$context['login_errors'] = array();
525
+	}
510 526
 
511 527
 	// What is the true activation status of this account?
512 528
 	$activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated'];
@@ -518,8 +534,9 @@  discard block
 block discarded – undo
518 534
 		return false;
519 535
 	}
520 536
 	// Awaiting approval still?
521
-	elseif ($activation_status == 3)
522
-		fatal_lang_error('still_awaiting_approval', 'user');
537
+	elseif ($activation_status == 3) {
538
+			fatal_lang_error('still_awaiting_approval', 'user');
539
+	}
523 540
 	// Awaiting deletion, changed their mind?
524 541
 	elseif ($activation_status == 4)
525 542
 	{
@@ -527,8 +544,7 @@  discard block
 block discarded – undo
527 544
 		{
528 545
 			updateMemberData($user_settings['id_member'], array('is_activated' => 1));
529 546
 			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0)));
530
-		}
531
-		else
547
+		} else
532 548
 		{
533 549
 			$context['disable_login_hashing'] = true;
534 550
 			$context['login_errors'][] = $txt['awaiting_delete_account'];
@@ -568,8 +584,9 @@  discard block
 block discarded – undo
568 584
 	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
569 585
 
570 586
 	// Reset the login threshold.
571
-	if (isset($_SESSION['failed_login']))
572
-		unset($_SESSION['failed_login']);
587
+	if (isset($_SESSION['failed_login'])) {
588
+			unset($_SESSION['failed_login']);
589
+	}
573 590
 
574 591
 	$user_info['is_guest'] = false;
575 592
 	$user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']);
@@ -591,16 +608,18 @@  discard block
 block discarded – undo
591 608
 			'id_member' => $user_info['id'],
592 609
 		)
593 610
 	);
594
-	if ($smcFunc['db_num_rows']($request) == 1)
595
-		$_SESSION['first_login'] = true;
596
-	else
597
-		unset($_SESSION['first_login']);
611
+	if ($smcFunc['db_num_rows']($request) == 1) {
612
+			$_SESSION['first_login'] = true;
613
+	} else {
614
+			unset($_SESSION['first_login']);
615
+	}
598 616
 	$smcFunc['db_free_result']($request);
599 617
 
600 618
 	// You've logged in, haven't you?
601 619
 	$update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']);
602
-	if (empty($user_settings['tfa_secret']))
603
-		$update['last_login'] = time();
620
+	if (empty($user_settings['tfa_secret'])) {
621
+			$update['last_login'] = time();
622
+	}
604 623
 	updateMemberData($user_info['id'], $update);
605 624
 
606 625
 	// Get rid of the online entry for that old guest....
@@ -614,8 +633,8 @@  discard block
 block discarded – undo
614 633
 	$_SESSION['log_time'] = 0;
615 634
 
616 635
 	// Log this entry, only if we have it enabled.
617
-	if (!empty($modSettings['loginHistoryDays']))
618
-		$smcFunc['db_insert']('insert',
636
+	if (!empty($modSettings['loginHistoryDays'])) {
637
+			$smcFunc['db_insert']('insert',
619 638
 			'{db_prefix}member_logins',
620 639
 			array(
621 640
 				'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet',
@@ -627,13 +646,15 @@  discard block
 block discarded – undo
627 646
 				'id_member', 'time'
628 647
 			)
629 648
 		);
649
+	}
630 650
 
631 651
 	// Just log you back out if it's in maintenance mode and you AREN'T an admin.
632
-	if (empty($maintenance) || allowedTo('admin_forum'))
633
-		redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
634
-	else
635
-		redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
636
-}
652
+	if (empty($maintenance) || allowedTo('admin_forum')) {
653
+			redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
654
+	} else {
655
+			redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
656
+	}
657
+	}
637 658
 
638 659
 /**
639 660
  * Logs the current user out of their account.
@@ -649,13 +670,15 @@  discard block
 block discarded – undo
649 670
 	global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings;
650 671
 
651 672
 	// Make sure they aren't being auto-logged out.
652
-	if (!$internal)
653
-		checkSession('get');
673
+	if (!$internal) {
674
+			checkSession('get');
675
+	}
654 676
 
655 677
 	require_once($sourcedir . '/Subs-Auth.php');
656 678
 
657
-	if (isset($_SESSION['pack_ftp']))
658
-		$_SESSION['pack_ftp'] = null;
679
+	if (isset($_SESSION['pack_ftp'])) {
680
+			$_SESSION['pack_ftp'] = null;
681
+	}
659 682
 
660 683
 	// It won't be first login anymore.
661 684
 	unset($_SESSION['first_login']);
@@ -683,8 +706,9 @@  discard block
 block discarded – undo
683 706
 
684 707
 	// And some other housekeeping while we're at it.
685 708
 	$salt = substr(md5(mt_rand()), 0, 4);
686
-	if (!empty($user_info['id']))
687
-		updateMemberData($user_info['id'], array('password_salt' => $salt));
709
+	if (!empty($user_info['id'])) {
710
+			updateMemberData($user_info['id'], array('password_salt' => $salt));
711
+	}
688 712
 
689 713
 	if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa']))
690 714
 	{
@@ -693,10 +717,11 @@  discard block
 block discarded – undo
693 717
 		list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata;
694 718
 
695 719
 		// If we're preserving the cookie, reset it with updated salt
696
-		if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp)
697
-			setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true);
698
-		else
699
-			setTFACookie(-3600, 0, '');
720
+		if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) {
721
+					setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true);
722
+		} else {
723
+					setTFACookie(-3600, 0, '');
724
+		}
700 725
 	}
701 726
 
702 727
 	session_destroy();
@@ -704,14 +729,13 @@  discard block
 block discarded – undo
704 729
 	// Off to the merry board index we go!
705 730
 	if ($redirect)
706 731
 	{
707
-		if (empty($_SESSION['logout_url']))
708
-			redirectexit('', $context['server']['needs_login_fix']);
709
-		elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
732
+		if (empty($_SESSION['logout_url'])) {
733
+					redirectexit('', $context['server']['needs_login_fix']);
734
+		} elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
710 735
 		{
711 736
 			unset ($_SESSION['logout_url']);
712 737
 			redirectexit();
713
-		}
714
-		else
738
+		} else
715 739
 		{
716 740
 			$temp = $_SESSION['logout_url'];
717 741
 			unset($_SESSION['logout_url']);
@@ -744,8 +768,9 @@  discard block
 block discarded – undo
744 768
 function phpBB3_password_check($passwd, $passwd_hash)
745 769
 {
746 770
 	// Too long or too short?
747
-	if (strlen($passwd_hash) != 34)
748
-		return;
771
+	if (strlen($passwd_hash) != 34) {
772
+			return;
773
+	}
749 774
 
750 775
 	// Range of characters allowed.
751 776
 	$range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -756,8 +781,9 @@  discard block
 block discarded – undo
756 781
 	$salt = substr($passwd_hash, 4, 8);
757 782
 
758 783
 	$hash = md5($salt . $passwd, true);
759
-	for (; $count != 0; --$count)
760
-		$hash = md5($hash . $passwd, true);
784
+	for (; $count != 0; --$count) {
785
+			$hash = md5($hash . $passwd, true);
786
+	}
761 787
 
762 788
 	$output = substr($passwd_hash, 0, 12);
763 789
 	$i = 0;
@@ -766,21 +792,25 @@  discard block
 block discarded – undo
766 792
 		$value = ord($hash[$i++]);
767 793
 		$output .= $range[$value & 0x3f];
768 794
 
769
-		if ($i < 16)
770
-			$value |= ord($hash[$i]) << 8;
795
+		if ($i < 16) {
796
+					$value |= ord($hash[$i]) << 8;
797
+		}
771 798
 
772 799
 		$output .= $range[($value >> 6) & 0x3f];
773 800
 
774
-		if ($i++ >= 16)
775
-			break;
801
+		if ($i++ >= 16) {
802
+					break;
803
+		}
776 804
 
777
-		if ($i < 16)
778
-			$value |= ord($hash[$i]) << 16;
805
+		if ($i < 16) {
806
+					$value |= ord($hash[$i]) << 16;
807
+		}
779 808
 
780 809
 		$output .= $range[($value >> 12) & 0x3f];
781 810
 
782
-		if ($i++ >= 16)
783
-			break;
811
+		if ($i++ >= 16) {
812
+					break;
813
+		}
784 814
 
785 815
 		$output .= $range[($value >> 18) & 0x3f];
786 816
 	}
@@ -812,8 +842,9 @@  discard block
 block discarded – undo
812 842
 		require_once($sourcedir . '/Subs-Auth.php');
813 843
 		setLoginCookie(-3600, 0);
814 844
 
815
-		if (isset($_SESSION['login_' . $cookiename]))
816
-			unset($_SESSION['login_' . $cookiename]);
845
+		if (isset($_SESSION['login_' . $cookiename])) {
846
+					unset($_SESSION['login_' . $cookiename]);
847
+		}
817 848
 	}
818 849
 
819 850
 	// We need a member!
@@ -827,8 +858,9 @@  discard block
 block discarded – undo
827 858
 	}
828 859
 
829 860
 	// Right, have we got a flood value?
830
-	if ($password_flood_value !== false)
831
-		@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
861
+	if ($password_flood_value !== false) {
862
+			@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
863
+	}
832 864
 
833 865
 	// Timestamp or number of tries invalid?
834 866
 	if (empty($number_tries) || empty($time_stamp))
@@ -844,15 +876,17 @@  discard block
 block discarded – undo
844 876
 		$number_tries = $time_stamp < time() - 20 ? 2 : $number_tries;
845 877
 
846 878
 		// They are trying too fast, make them wait longer
847
-		if ($time_stamp < time() - 10)
848
-			$time_stamp = time();
879
+		if ($time_stamp < time() - 10) {
880
+					$time_stamp = time();
881
+		}
849 882
 	}
850 883
 
851 884
 	$number_tries++;
852 885
 
853 886
 	// Broken the law?
854
-	if ($number_tries > 5)
855
-		fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
887
+	if ($number_tries > 5) {
888
+			fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
889
+	}
856 890
 
857 891
 	// Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it!
858 892
 	updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries));
Please login to merge, or discard this patch.
Sources/Profile-Actions.php 1 patch
Braces   +117 added lines, -86 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
  * Activate an account.
@@ -48,8 +49,9 @@  discard block
 block discarded – undo
48 49
 		logAction('approve_member', array('member' => $memID), 'admin');
49 50
 
50 51
 		// If we are doing approval, update the stats for the member just in case.
51
-		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15)))
52
-			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
52
+		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) {
53
+					updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
54
+		}
53 55
 
54 56
 		// Make sure we update the stats too.
55 57
 		updateStats('member', false);
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
 	$issueErrors = array();
77 79
 
78 80
 	// Doesn't hurt to be overly cautious.
79
-	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning'))
80
-		fatal_lang_error('no_access', false);
81
+	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) {
82
+			fatal_lang_error('no_access', false);
83
+	}
81 84
 
82 85
 	// Get the base (errors related) stuff done.
83 86
 	loadLanguage('Errors');
@@ -135,16 +138,18 @@  discard block
 block discarded – undo
135 138
 
136 139
 		// This cannot be empty!
137 140
 		$_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : '';
138
-		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner'])
139
-			$issueErrors[] = 'warning_no_reason';
141
+		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) {
142
+					$issueErrors[] = 'warning_no_reason';
143
+		}
140 144
 		$_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']);
141 145
 
142 146
 		$_POST['warning_level'] = (int) $_POST['warning_level'];
143 147
 		$_POST['warning_level'] = max(0, min(100, $_POST['warning_level']));
144
-		if ($_POST['warning_level'] < $context['min_allowed'])
145
-			$_POST['warning_level'] = $context['min_allowed'];
146
-		elseif ($_POST['warning_level'] > $context['max_allowed'])
147
-			$_POST['warning_level'] = $context['max_allowed'];
148
+		if ($_POST['warning_level'] < $context['min_allowed']) {
149
+					$_POST['warning_level'] = $context['min_allowed'];
150
+		} elseif ($_POST['warning_level'] > $context['max_allowed']) {
151
+					$_POST['warning_level'] = $context['max_allowed'];
152
+		}
148 153
 
149 154
 		// Do we actually have to issue them with a PM?
150 155
 		$id_notice = 0;
@@ -152,8 +157,9 @@  discard block
 block discarded – undo
152 157
 		{
153 158
 			$_POST['warn_sub'] = trim($_POST['warn_sub']);
154 159
 			$_POST['warn_body'] = trim($_POST['warn_body']);
155
-			if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
156
-				$issueErrors[] = 'warning_notify_blank';
160
+			if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
161
+							$issueErrors[] = 'warning_notify_blank';
162
+			}
157 163
 			// Send the PM?
158 164
 			else
159 165
 			{
@@ -190,8 +196,8 @@  discard block
 block discarded – undo
190 196
 		if (empty($issueErrors))
191 197
 		{
192 198
 			// Log what we've done!
193
-			if (!$context['user']['is_owner'])
194
-				$smcFunc['db_insert']('',
199
+			if (!$context['user']['is_owner']) {
200
+							$smcFunc['db_insert']('',
195 201
 					'{db_prefix}log_comments',
196 202
 					array(
197 203
 						'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255',
@@ -203,14 +209,14 @@  discard block
 block discarded – undo
203 209
 					),
204 210
 					array('id_comment')
205 211
 				);
212
+			}
206 213
 
207 214
 			// Make the change.
208 215
 			updateMemberData($memID, array('warning' => $_POST['warning_level']));
209 216
 
210 217
 			// Leave a lovely message.
211 218
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success'];
212
-		}
213
-		else
219
+		} else
214 220
 		{
215 221
 			// Try to remember some bits.
216 222
 			$context['warning_data'] = array(
@@ -229,8 +235,9 @@  discard block
 block discarded – undo
229 235
 	{
230 236
 		$warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : '';
231 237
 		$context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : '';
232
-		if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
233
-			$issueErrors[] = 'warning_notify_blank';
238
+		if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
239
+					$issueErrors[] = 'warning_notify_blank';
240
+		}
234 241
 
235 242
 		if (!empty($_POST['warn_body']))
236 243
 		{
@@ -254,8 +261,9 @@  discard block
 block discarded – undo
254 261
 	{
255 262
 		// Fill in the suite of errors.
256 263
 		$context['post_errors'] = array();
257
-		foreach ($issueErrors as $error)
258
-			$context['post_errors'][] = $txt[$error];
264
+		foreach ($issueErrors as $error) {
265
+					$context['post_errors'][] = $txt[$error];
266
+		}
259 267
 	}
260 268
 
261 269
 
@@ -272,9 +280,10 @@  discard block
 block discarded – undo
272 280
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_mute'],
273 281
 	);
274 282
 	$context['current_level'] = 0;
275
-	foreach ($context['level_effects'] as $limit => $dummy)
276
-		if ($context['member']['warning'] >= $limit)
283
+	foreach ($context['level_effects'] as $limit => $dummy) {
284
+			if ($context['member']['warning'] >= $limit)
277 285
 			$context['current_level'] = $limit;
286
+	}
278 287
 
279 288
 	$listOptions = array(
280 289
 		'id' => 'view_warnings',
@@ -337,11 +346,12 @@  discard block
 block discarded – undo
337 346
 							' . $warning['reason'] . '
338 347
 						</div>';
339 348
 
340
-						if (!empty($warning['id_notice']))
341
-							$ret .= '
349
+						if (!empty($warning['id_notice'])) {
350
+													$ret .= '
342 351
 						<div class="floatright">
343 352
 							<a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>
344 353
 						</div>';
354
+						}
345 355
 
346 356
 						return $ret;
347 357
 					},
@@ -413,8 +423,9 @@  discard block
 block discarded – undo
413 423
 	while ($row = $smcFunc['db_fetch_assoc']($request))
414 424
 	{
415 425
 		// If we're not warning for a message skip any that are.
416
-		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false)
417
-			continue;
426
+		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) {
427
+					continue;
428
+		}
418 429
 
419 430
 		$context['notification_templates'][] = array(
420 431
 			'title' => $row['template_title'],
@@ -424,16 +435,18 @@  discard block
 block discarded – undo
424 435
 	$smcFunc['db_free_result']($request);
425 436
 
426 437
 	// Setup the "default" templates.
427
-	foreach (array('spamming', 'offence', 'insulting') as $type)
428
-		$context['notification_templates'][] = array(
438
+	foreach (array('spamming', 'offence', 'insulting') as $type) {
439
+			$context['notification_templates'][] = array(
429 440
 			'title' => $txt['profile_warning_notify_title_' . $type],
430 441
 			'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]),
431 442
 		);
443
+	}
432 444
 
433 445
 	// Replace all the common variables in the templates.
434
-	foreach ($context['notification_templates'] as $k => $name)
435
-		$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
436
-}
446
+	foreach ($context['notification_templates'] as $k => $name) {
447
+			$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
448
+	}
449
+	}
437 450
 
438 451
 /**
439 452
  * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning()
@@ -517,10 +530,11 @@  discard block
 block discarded – undo
517 530
 {
518 531
 	global $txt, $context, $modSettings, $cur_profile;
519 532
 
520
-	if (!$context['user']['is_owner'])
521
-		isAllowedTo('profile_remove_any');
522
-	elseif (!allowedTo('profile_remove_any'))
523
-		isAllowedTo('profile_remove_own');
533
+	if (!$context['user']['is_owner']) {
534
+			isAllowedTo('profile_remove_any');
535
+	} elseif (!allowedTo('profile_remove_any')) {
536
+			isAllowedTo('profile_remove_own');
537
+	}
524 538
 
525 539
 	// Permissions for removing stuff...
526 540
 	$context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum');
@@ -547,10 +561,11 @@  discard block
 block discarded – undo
547 561
 
548 562
 	// @todo Add a way to delete pms as well?
549 563
 
550
-	if (!$context['user']['is_owner'])
551
-		isAllowedTo('profile_remove_any');
552
-	elseif (!allowedTo('profile_remove_any'))
553
-		isAllowedTo('profile_remove_own');
564
+	if (!$context['user']['is_owner']) {
565
+			isAllowedTo('profile_remove_any');
566
+	} elseif (!allowedTo('profile_remove_any')) {
567
+			isAllowedTo('profile_remove_own');
568
+	}
554 569
 
555 570
 	checkSession();
556 571
 
@@ -576,8 +591,9 @@  discard block
 block discarded – undo
576 591
 		list ($another) = $smcFunc['db_fetch_row']($request);
577 592
 		$smcFunc['db_free_result']($request);
578 593
 
579
-		if (empty($another))
580
-			fatal_lang_error('at_least_one_admin', 'critical');
594
+		if (empty($another)) {
595
+					fatal_lang_error('at_least_one_admin', 'critical');
596
+		}
581 597
 	}
582 598
 
583 599
 	// This file is needed for the deleteMembers function.
@@ -656,8 +672,9 @@  discard block
 block discarded – undo
656 672
 					)
657 673
 				);
658 674
 				$topicIDs = array();
659
-				while ($row = $smcFunc['db_fetch_assoc']($request))
660
-					$topicIDs[] = $row['id_topic'];
675
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
676
+									$topicIDs[] = $row['id_topic'];
677
+				}
661 678
 				$smcFunc['db_free_result']($request);
662 679
 
663 680
 				// Actually remove the topics. Ignore recycling if we want to perma-delete things...
@@ -680,8 +697,9 @@  discard block
 block discarded – undo
680 697
 			// This could take a while... but ya know it's gonna be worth it in the end.
681 698
 			while ($row = $smcFunc['db_fetch_assoc']($request))
682 699
 			{
683
-				if (function_exists('apache_reset_timeout'))
684
-					@apache_reset_timeout();
700
+				if (function_exists('apache_reset_timeout')) {
701
+									@apache_reset_timeout();
702
+				}
685 703
 
686 704
 				removeMessage($row['id_msg']);
687 705
 			}
@@ -689,8 +707,9 @@  discard block
 block discarded – undo
689 707
 		}
690 708
 
691 709
 		// Only delete this poor members account if they are actually being booted out of camp.
692
-		if (isset($_POST['deleteAccount']))
693
-			deleteMembers($memID);
710
+		if (isset($_POST['deleteAccount'])) {
711
+					deleteMembers($memID);
712
+		}
694 713
 	}
695 714
 	// Do they need approval to delete?
696 715
 	elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum'))
@@ -741,18 +760,18 @@  discard block
 block discarded – undo
741 760
 		{
742 761
 			foreach ($costs as $duration => $cost)
743 762
 			{
744
-				if ($cost != 0)
745
-					$cost_array[$duration] = $cost;
763
+				if ($cost != 0) {
764
+									$cost_array[$duration] = $cost;
765
+				}
746 766
 			}
747
-		}
748
-		else
767
+		} else
749 768
 		{
750 769
 			$cost_array['fixed'] = $costs['fixed'];
751 770
 		}
752 771
 
753
-		if (empty($cost_array))
754
-			unset($context['subscriptions'][$id]);
755
-		else
772
+		if (empty($cost_array)) {
773
+					unset($context['subscriptions'][$id]);
774
+		} else
756 775
 		{
757 776
 			$context['subscriptions'][$id]['member'] = 0;
758 777
 			$context['subscriptions'][$id]['subscribed'] = false;
@@ -765,13 +784,15 @@  discard block
 block discarded – undo
765 784
 	foreach ($gateways as $id => $gateway)
766 785
 	{
767 786
 		$gateways[$id] = new $gateway['display_class']();
768
-		if (!$gateways[$id]->gatewayEnabled())
769
-			unset($gateways[$id]);
787
+		if (!$gateways[$id]->gatewayEnabled()) {
788
+					unset($gateways[$id]);
789
+		}
770 790
 	}
771 791
 
772 792
 	// No gateways yet?
773
-	if (empty($gateways))
774
-		fatal_error($txt['paid_admin_not_setup_gateway']);
793
+	if (empty($gateways)) {
794
+			fatal_error($txt['paid_admin_not_setup_gateway']);
795
+	}
775 796
 
776 797
 	// Get the current subscriptions.
777 798
 	$request = $smcFunc['db_query']('', '
@@ -786,8 +807,9 @@  discard block
 block discarded – undo
786 807
 	while ($row = $smcFunc['db_fetch_assoc']($request))
787 808
 	{
788 809
 		// The subscription must exist!
789
-		if (!isset($context['subscriptions'][$row['id_subscribe']]))
790
-			continue;
810
+		if (!isset($context['subscriptions'][$row['id_subscribe']])) {
811
+					continue;
812
+		}
791 813
 
792 814
 		$context['current'][$row['id_subscribe']] = array(
793 815
 			'id' => $row['id_sublog'],
@@ -801,8 +823,9 @@  discard block
 block discarded – undo
801 823
 			'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'],
802 824
 		);
803 825
 
804
-		if ($row['status'] == 1)
805
-			$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
826
+		if ($row['status'] == 1) {
827
+					$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
828
+		}
806 829
 	}
807 830
 	$smcFunc['db_free_result']($request);
808 831
 
@@ -853,21 +876,25 @@  discard block
 block discarded – undo
853 876
 	if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id']))
854 877
 	{
855 878
 		// Hopefully just one.
856
-		foreach ($_POST['sub_id'] as $k => $v)
857
-			$ID_SUB = (int) $k;
879
+		foreach ($_POST['sub_id'] as $k => $v) {
880
+					$ID_SUB = (int) $k;
881
+		}
858 882
 
859
-		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0)
860
-			fatal_lang_error('paid_sub_not_active');
883
+		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) {
884
+					fatal_lang_error('paid_sub_not_active');
885
+		}
861 886
 
862 887
 		// Simplify...
863 888
 		$context['sub'] = $context['subscriptions'][$ID_SUB];
864 889
 		$period = 'xx';
865
-		if ($context['sub']['flexible'])
866
-			$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
890
+		if ($context['sub']['flexible']) {
891
+					$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
892
+		}
867 893
 
868 894
 		// Check we have a valid cost.
869
-		if ($context['sub']['flexible'] && $period == 'xx')
870
-			fatal_lang_error('paid_sub_not_active');
895
+		if ($context['sub']['flexible'] && $period == 'xx') {
896
+					fatal_lang_error('paid_sub_not_active');
897
+		}
871 898
 
872 899
 		// Sort out the cost/currency.
873 900
 		$context['currency'] = $modSettings['paid_currency_code'];
@@ -880,8 +907,7 @@  discard block
 block discarded – undo
880 907
 			$context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]];
881 908
 			// The period value for paypal.
882 909
 			$context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1));
883
-		}
884
-		else
910
+		} else
885 911
 		{
886 912
 			// Real cost...
887 913
 			$context['value'] = $context['sub']['costs']['fixed'];
@@ -898,13 +924,15 @@  discard block
 block discarded – undo
898 924
 		foreach ($gateways as $id => $gateway)
899 925
 		{
900 926
 			$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done');
901
-			if (!empty($fields['form']))
902
-				$context['gateways'][] = $fields;
927
+			if (!empty($fields['form'])) {
928
+							$context['gateways'][] = $fields;
929
+			}
903 930
 		}
904 931
 
905 932
 		// Bugger?!
906
-		if (empty($context['gateways']))
907
-			fatal_error($txt['paid_admin_not_setup_gateway']);
933
+		if (empty($context['gateways'])) {
934
+					fatal_error($txt['paid_admin_not_setup_gateway']);
935
+		}
908 936
 
909 937
 		// Now we are going to assume they want to take this out ;)
910 938
 		$new_data = array($context['sub']['id'], $context['value'], $period, 'prepay');
@@ -912,16 +940,19 @@  discard block
 block discarded – undo
912 940
 		{
913 941
 			// What are the details like?
914 942
 			$current_pending = array();
915
-			if ($context['current'][$context['sub']['id']]['pending_details'] != '')
916
-				$current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true);
943
+			if ($context['current'][$context['sub']['id']]['pending_details'] != '') {
944
+							$current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true);
945
+			}
917 946
 			// Don't get silly.
918
-			if (count($current_pending) > 9)
919
-				$current_pending = array();
947
+			if (count($current_pending) > 9) {
948
+							$current_pending = array();
949
+			}
920 950
 			$pending_count = 0;
921 951
 			// Only record real pending payments as will otherwise confuse the admin!
922
-			foreach ($current_pending as $pending)
923
-				if ($pending[3] == 'payback')
952
+			foreach ($current_pending as $pending) {
953
+							if ($pending[3] == 'payback')
924 954
 					$pending_count++;
955
+			}
925 956
 
926 957
 			if (!in_array($new_data, $current_pending))
927 958
 			{
@@ -966,9 +997,9 @@  discard block
 block discarded – undo
966 997
 
967 998
 		// Quit.
968 999
 		return;
1000
+	} else {
1001
+			$context['sub_template'] = 'user_subscription';
1002
+	}
969 1003
 	}
970
-	else
971
-		$context['sub_template'] = 'user_subscription';
972
-}
973 1004
 
974 1005
 ?>
975 1006
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ManageMembers.php 1 patch
Braces   +158 added lines, -116 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main entrance point for the Manage Members screen.
@@ -62,16 +63,18 @@  discard block
 block discarded – undo
62 63
 	$context['activation_numbers'] = array();
63 64
 	$context['awaiting_activation'] = 0;
64 65
 	$context['awaiting_approval'] = 0;
65
-	while ($row = $smcFunc['db_fetch_assoc']($request))
66
-		$context['activation_numbers'][$row['is_activated']] = $row['total_members'];
66
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
67
+			$context['activation_numbers'][$row['is_activated']] = $row['total_members'];
68
+	}
67 69
 	$smcFunc['db_free_result']($request);
68 70
 
69 71
 	foreach ($context['activation_numbers'] as $activation_type => $total_members)
70 72
 	{
71
-		if (in_array($activation_type, array(0, 2)))
72
-			$context['awaiting_activation'] += $total_members;
73
-		elseif (in_array($activation_type, array(3, 4, 5)))
74
-			$context['awaiting_approval'] += $total_members;
73
+		if (in_array($activation_type, array(0, 2))) {
74
+					$context['awaiting_activation'] += $total_members;
75
+		} elseif (in_array($activation_type, array(3, 4, 5))) {
76
+					$context['awaiting_approval'] += $total_members;
77
+		}
75 78
 	}
76 79
 
77 80
 	// For the page header... do we show activation?
@@ -124,8 +127,9 @@  discard block
 block discarded – undo
124 127
 	}
125 128
 	if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve'))
126 129
 	{
127
-		if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate'))
128
-			$context['tabs']['search']['is_last'] = true;
130
+		if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) {
131
+					$context['tabs']['search']['is_last'] = true;
132
+		}
129 133
 		unset($context['tabs']['approve']);
130 134
 	}
131 135
 
@@ -157,8 +161,9 @@  discard block
 block discarded – undo
157 161
 		foreach ($_POST['delete'] as $key => $value)
158 162
 		{
159 163
 			// Don't delete yourself, idiot.
160
-			if ($value != $user_info['id'])
161
-				$delete[$key] = (int) $value;
164
+			if ($value != $user_info['id']) {
165
+							$delete[$key] = (int) $value;
166
+			}
162 167
 		}
163 168
 
164 169
 		if (!empty($delete))
@@ -194,17 +199,18 @@  discard block
 block discarded – undo
194 199
 		);
195 200
 		while ($row = $smcFunc['db_fetch_assoc']($request))
196 201
 		{
197
-			if ($row['min_posts'] == -1)
198
-				$context['membergroups'][] = array(
202
+			if ($row['min_posts'] == -1) {
203
+							$context['membergroups'][] = array(
199 204
 					'id' => $row['id_group'],
200 205
 					'name' => $row['group_name'],
201 206
 					'can_be_additional' => true
202 207
 				);
203
-			else
204
-				$context['postgroups'][] = array(
208
+			} else {
209
+							$context['postgroups'][] = array(
205 210
 					'id' => $row['id_group'],
206 211
 					'name' => $row['group_name']
207 212
 				);
213
+			}
208 214
 		}
209 215
 		$smcFunc['db_free_result']($request);
210 216
 
@@ -268,14 +274,15 @@  discard block
 block discarded – undo
268 274
 		call_integration_hook('integrate_view_members_params', array(&$params));
269 275
 
270 276
 		$search_params = array();
271
-		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types']))
272
-			$search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true);
273
-		elseif (!empty($_POST))
277
+		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) {
278
+					$search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true);
279
+		} elseif (!empty($_POST))
274 280
 		{
275 281
 			$search_params['types'] = $_POST['types'];
276
-			foreach ($params as $param_name => $param_info)
277
-				if (isset($_POST[$param_name]))
282
+			foreach ($params as $param_name => $param_info) {
283
+							if (isset($_POST[$param_name]))
278 284
 					$search_params[$param_name] = $_POST[$param_name];
285
+			}
279 286
 		}
280 287
 
281 288
 		$search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null;
@@ -288,18 +295,21 @@  discard block
 block discarded – undo
288 295
 		foreach ($params as $param_name => $param_info)
289 296
 		{
290 297
 			// Not filled in?
291
-			if (!isset($search_params[$param_name]) || $search_params[$param_name] === '')
292
-				continue;
298
+			if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') {
299
+							continue;
300
+			}
293 301
 
294 302
 			// Make sure numeric values are really numeric.
295
-			if (in_array($param_info['type'], array('int', 'age')))
296
-				$search_params[$param_name] = (int) $search_params[$param_name];
303
+			if (in_array($param_info['type'], array('int', 'age'))) {
304
+							$search_params[$param_name] = (int) $search_params[$param_name];
305
+			}
297 306
 			// Date values have to match the specified format.
298 307
 			elseif ($param_info['type'] == 'date')
299 308
 			{
300 309
 				// Check if this date format is valid.
301
-				if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0)
302
-					continue;
310
+				if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) {
311
+									continue;
312
+				}
303 313
 
304 314
 				$search_params[$param_name] = strtotime($search_params[$param_name]);
305 315
 			}
@@ -308,8 +318,9 @@  discard block
 block discarded – undo
308 318
 			if (!empty($param_info['range']))
309 319
 			{
310 320
 				// Default to '=', just in case...
311
-				if (empty($range_trans[$search_params['types'][$param_name]]))
312
-					$search_params['types'][$param_name] = '=';
321
+				if (empty($range_trans[$search_params['types'][$param_name]])) {
322
+									$search_params['types'][$param_name] = '=';
323
+				}
313 324
 
314 325
 				// Handle special case 'age'.
315 326
 				if ($param_info['type'] == 'age')
@@ -337,29 +348,30 @@  discard block
 block discarded – undo
337 348
 				elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=')
338 349
 				{
339 350
 					$query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400);
351
+				} else {
352
+									$query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name];
340 353
 				}
341
-				else
342
-					$query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name];
343 354
 			}
344 355
 			// Checkboxes.
345 356
 			elseif ($param_info['type'] == 'checkbox')
346 357
 			{
347 358
 				// Each checkbox or no checkbox at all is checked -> ignore.
348
-				if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values']))
349
-					continue;
359
+				if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) {
360
+									continue;
361
+				}
350 362
 
351 363
 				$query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})';
352 364
 				$where_params[$param_name . '_check'] = $search_params[$param_name];
353
-			}
354
-			else
365
+			} else
355 366
 			{
356 367
 				// Replace the wildcard characters ('*' and '?') into MySQL ones.
357 368
 				$parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')));
358 369
 
359
-				if ($smcFunc['db_case_sensitive'])
360
-					$query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
361
-				else
362
-					$query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
370
+				if ($smcFunc['db_case_sensitive']) {
371
+									$query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
372
+				} else {
373
+									$query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
374
+				}
363 375
 				$where_params[$param_name . '_normal'] = '%' . $parameter . '%';
364 376
 			}
365 377
 		}
@@ -375,16 +387,18 @@  discard block
 block discarded – undo
375 387
 		}
376 388
 
377 389
 		// Additional membergroups (these are only relevant if not all primary groups where selected!).
378
-		if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1])))
379
-			foreach ($search_params['membergroups'][2] as $mg)
390
+		if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) {
391
+					foreach ($search_params['membergroups'][2] as $mg)
380 392
 			{
381 393
 				$mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0';
394
+		}
382 395
 				$where_params['add_group_' . $mg] = $mg;
383 396
 			}
384 397
 
385 398
 		// Combine the one or two membergroup parts into one query part linked with an OR.
386
-		if (!empty($mg_query_parts))
387
-			$query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')';
399
+		if (!empty($mg_query_parts)) {
400
+					$query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')';
401
+		}
388 402
 
389 403
 		// Get all selected post count related membergroups.
390 404
 		if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups']))
@@ -396,9 +410,9 @@  discard block
 block discarded – undo
396 410
 		// Construct the where part of the query.
397 411
 		$where = empty($query_parts) ? '1=1' : implode('
398 412
 			AND ', $query_parts);
413
+	} else {
414
+			$search_url_params = null;
399 415
 	}
400
-	else
401
-		$search_url_params = null;
402 416
 
403 417
 	// Construct the additional URL part with the query info in it.
404 418
 	$context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : '';
@@ -521,28 +535,32 @@  discard block
 block discarded – undo
521 535
 					'function' => function($rowData) use ($txt)
522 536
 					{
523 537
 						// Calculate number of days since last online.
524
-						if (empty($rowData['last_login']))
525
-							$difference = $txt['never'];
526
-						else
538
+						if (empty($rowData['last_login'])) {
539
+													$difference = $txt['never'];
540
+						} else
527 541
 						{
528 542
 							$num_days_difference = jeffsdatediff($rowData['last_login']);
529 543
 
530 544
 							// Today.
531
-							if (empty($num_days_difference))
532
-								$difference = $txt['viewmembers_today'];
545
+							if (empty($num_days_difference)) {
546
+															$difference = $txt['viewmembers_today'];
547
+							}
533 548
 
534 549
 							// Yesterday.
535
-							elseif ($num_days_difference == 1)
536
-								$difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']);
550
+							elseif ($num_days_difference == 1) {
551
+															$difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']);
552
+							}
537 553
 
538 554
 							// X days ago.
539
-							else
540
-								$difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']);
555
+							else {
556
+															$difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']);
557
+							}
541 558
 						}
542 559
 
543 560
 						// Show it in italics if they're not activated...
544
-						if ($rowData['is_activated'] % 10 != 1)
545
-							$difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference);
561
+						if ($rowData['is_activated'] % 10 != 1) {
562
+													$difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference);
563
+						}
546 564
 
547 565
 						return $difference;
548 566
 					},
@@ -594,8 +612,9 @@  discard block
 block discarded – undo
594 612
 	);
595 613
 
596 614
 	// Without enough permissions, don't show 'delete members' checkboxes.
597
-	if (!allowedTo('profile_remove_any'))
598
-		unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
615
+	if (!allowedTo('profile_remove_any')) {
616
+			unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
617
+	}
599 618
 
600 619
 	require_once($sourcedir . '/Subs-List.php');
601 620
 	createList($listOptions);
@@ -638,17 +657,18 @@  discard block
 block discarded – undo
638 657
 	);
639 658
 	while ($row = $smcFunc['db_fetch_assoc']($request))
640 659
 	{
641
-		if ($row['min_posts'] == -1)
642
-			$context['membergroups'][] = array(
660
+		if ($row['min_posts'] == -1) {
661
+					$context['membergroups'][] = array(
643 662
 				'id' => $row['id_group'],
644 663
 				'name' => $row['group_name'],
645 664
 				'can_be_additional' => true
646 665
 			);
647
-		else
648
-			$context['postgroups'][] = array(
666
+		} else {
667
+					$context['postgroups'][] = array(
649 668
 				'id' => $row['id_group'],
650 669
 				'name' => $row['group_name']
651 670
 			);
671
+		}
652 672
 	}
653 673
 	$smcFunc['db_free_result']($request);
654 674
 
@@ -675,8 +695,9 @@  discard block
 block discarded – undo
675 695
 	$context['page_title'] = $txt['admin_members'];
676 696
 	$context['sub_template'] = 'admin_browse';
677 697
 	$context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve');
678
-	if (isset($context['tabs'][$context['browse_type']]))
679
-		$context['tabs'][$context['browse_type']]['is_selected'] = true;
698
+	if (isset($context['tabs'][$context['browse_type']])) {
699
+			$context['tabs'][$context['browse_type']]['is_selected'] = true;
700
+	}
680 701
 
681 702
 	// Allowed filters are those we can have, in theory.
682 703
 	$context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2);
@@ -687,18 +708,20 @@  discard block
 block discarded – undo
687 708
 	foreach ($context['activation_numbers'] as $type => $amount)
688 709
 	{
689 710
 		// We have some of these...
690
-		if (in_array($type, $context['allowed_filters']) && $amount > 0)
691
-			$context['available_filters'][] = array(
711
+		if (in_array($type, $context['allowed_filters']) && $amount > 0) {
712
+					$context['available_filters'][] = array(
692 713
 				'type' => $type,
693 714
 				'amount' => $amount,
694 715
 				'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?',
695 716
 				'selected' => $type == $context['current_filter']
696 717
 			);
718
+		}
697 719
 	}
698 720
 
699 721
 	// If the filter was not sent, set it to whatever has people in it!
700
-	if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount']))
701
-		$context['current_filter'] = $context['available_filters'][0]['type'];
722
+	if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) {
723
+			$context['current_filter'] = $context['available_filters'][0]['type'];
724
+	}
702 725
 
703 726
 	// This little variable is used to determine if we should flag where we are looking.
704 727
 	$context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1;
@@ -713,44 +736,47 @@  discard block
 block discarded – undo
713 736
 	);
714 737
 
715 738
 	// Are we showing duplicate information?
716
-	if (isset($_GET['showdupes']))
717
-		$_SESSION['showdupes'] = (int) $_GET['showdupes'];
739
+	if (isset($_GET['showdupes'])) {
740
+			$_SESSION['showdupes'] = (int) $_GET['showdupes'];
741
+	}
718 742
 	$context['show_duplicates'] = !empty($_SESSION['showdupes']);
719 743
 
720 744
 	// Determine which actions we should allow on this page.
721 745
 	if ($context['browse_type'] == 'approve')
722 746
 	{
723 747
 		// If we are approving deleted accounts we have a slightly different list... actually a mirror ;)
724
-		if ($context['current_filter'] == 4)
725
-			$context['allowed_actions'] = array(
748
+		if ($context['current_filter'] == 4) {
749
+					$context['allowed_actions'] = array(
726 750
 				'reject' => $txt['admin_browse_w_approve_deletion'],
727 751
 				'ok' => $txt['admin_browse_w_reject'],
728 752
 			);
729
-		else
730
-			$context['allowed_actions'] = array(
753
+		} else {
754
+					$context['allowed_actions'] = array(
731 755
 				'ok' => $txt['admin_browse_w_approve'],
732 756
 				'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'],
733 757
 				'require_activation' => $txt['admin_browse_w_approve_require_activate'],
734 758
 				'reject' => $txt['admin_browse_w_reject'],
735 759
 				'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'],
736 760
 			);
737
-	}
738
-	elseif ($context['browse_type'] == 'activate')
739
-		$context['allowed_actions'] = array(
761
+		}
762
+	} elseif ($context['browse_type'] == 'activate') {
763
+			$context['allowed_actions'] = array(
740 764
 			'ok' => $txt['admin_browse_w_activate'],
741 765
 			'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'],
742 766
 			'delete' => $txt['admin_browse_w_delete'],
743 767
 			'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'],
744 768
 			'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'],
745 769
 		);
770
+	}
746 771
 
747 772
 	// Create an option list for actions allowed to be done with selected members.
748 773
 	$allowed_actions = '
749 774
 			<option selected value="">' . $txt['admin_browse_with_selected'] . ':</option>
750 775
 			<option value="" disabled>-----------------------------</option>';
751
-	foreach ($context['allowed_actions'] as $key => $desc)
752
-		$allowed_actions .= '
776
+	foreach ($context['allowed_actions'] as $key => $desc) {
777
+			$allowed_actions .= '
753 778
 			<option value="' . $key . '">' . $desc . '</option>';
779
+	}
754 780
 
755 781
 	// Setup the Javascript function for selecting an action for the list.
756 782
 	$javascript = '
@@ -762,15 +788,16 @@  discard block
 block discarded – undo
762 788
 			var message = "";';
763 789
 
764 790
 	// We have special messages for approving deletion of accounts - it's surprisingly logical - honest.
765
-	if ($context['current_filter'] == 4)
766
-		$javascript .= '
791
+	if ($context['current_filter'] == 4) {
792
+			$javascript .= '
767 793
 			if (document.forms.postForm.todo.value.indexOf("reject") != -1)
768 794
 				message = "' . $txt['admin_browse_w_delete'] . '";
769 795
 			else
770 796
 				message = "' . $txt['admin_browse_w_reject'] . '";';
797
+	}
771 798
 	// Otherwise a nice standard message.
772
-	else
773
-		$javascript .= '
799
+	else {
800
+			$javascript .= '
774 801
 			if (document.forms.postForm.todo.value.indexOf("delete") != -1)
775 802
 				message = "' . $txt['admin_browse_w_delete'] . '";
776 803
 			else if (document.forms.postForm.todo.value.indexOf("reject") != -1)
@@ -779,6 +806,7 @@  discard block
 block discarded – undo
779 806
 				message = "' . $txt['admin_browse_w_remind'] . '";
780 807
 			else
781 808
 				message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";';
809
+	}
782 810
 	$javascript .= '
783 811
 			if (confirm(message + " ' . $txt['admin_browse_warn'] . '"))
784 812
 				document.forms.postForm.submit();
@@ -911,10 +939,11 @@  discard block
 block discarded – undo
911 939
 						$member_links = array();
912 940
 						foreach ($rowData['duplicate_members'] as $member)
913 941
 						{
914
-							if ($member['id'])
915
-								$member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>';
916
-							else
917
-								$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
942
+							if ($member['id']) {
943
+															$member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>';
944
+							} else {
945
+															$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
946
+							}
918 947
 						}
919 948
 						return implode(', ', $member_links);
920 949
 					},
@@ -963,14 +992,16 @@  discard block
 block discarded – undo
963 992
 	);
964 993
 
965 994
 	// Pick what column to actually include if we're showing duplicates.
966
-	if ($context['show_duplicates'])
967
-		unset($listOptions['columns']['email']);
968
-	else
969
-		unset($listOptions['columns']['duplicates']);
995
+	if ($context['show_duplicates']) {
996
+			unset($listOptions['columns']['email']);
997
+	} else {
998
+			unset($listOptions['columns']['duplicates']);
999
+	}
970 1000
 
971 1001
 	// Only show hostname on duplicates as it takes a lot of time.
972
-	if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup']))
973
-		unset($listOptions['columns']['hostname']);
1002
+	if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) {
1003
+			unset($listOptions['columns']['hostname']);
1004
+	}
974 1005
 
975 1006
 	// Is there any need to show filters?
976 1007
 	if (isset($context['available_filters']) && count($context['available_filters']) > 1)
@@ -978,9 +1009,10 @@  discard block
 block discarded – undo
978 1009
 		$filterOptions = '
979 1010
 			<strong>' . $txt['admin_browse_filter_by'] . ':</strong>
980 1011
 			<select name="filter" onchange="this.form.submit();">';
981
-		foreach ($context['available_filters'] as $filter)
982
-			$filterOptions .= '
1012
+		foreach ($context['available_filters'] as $filter) {
1013
+					$filterOptions .= '
983 1014
 				<option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>';
1015
+		}
984 1016
 		$filterOptions .= '
985 1017
 			</select>
986 1018
 			<noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>';
@@ -992,12 +1024,13 @@  discard block
 block discarded – undo
992 1024
 	}
993 1025
 
994 1026
 	// What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at.
995
-	if (!empty($context['show_filter']) && !empty($context['available_filters']))
996
-		$listOptions['additional_rows'][] = array(
1027
+	if (!empty($context['show_filter']) && !empty($context['available_filters'])) {
1028
+			$listOptions['additional_rows'][] = array(
997 1029
 			'position' => 'above_column_headers',
998 1030
 			'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'],
999 1031
 			'class' => 'smalltext floatright',
1000 1032
 		);
1033
+	}
1001 1034
 
1002 1035
 	// Now that we have all the options, create the list.
1003 1036
 	require_once($sourcedir . '/Subs-List.php');
@@ -1027,12 +1060,14 @@  discard block
 block discarded – undo
1027 1060
 	$current_filter = (int) $_REQUEST['orig_filter'];
1028 1061
 
1029 1062
 	// If we are applying a filter do just that - then redirect.
1030
-	if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter'])
1031
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']);
1063
+	if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) {
1064
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']);
1065
+	}
1032 1066
 
1033 1067
 	// Nothing to do?
1034
-	if (!isset($_POST['todoAction']) && !isset($_POST['time_passed']))
1035
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1068
+	if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) {
1069
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1070
+	}
1036 1071
 
1037 1072
 	// Are we dealing with members who have been waiting for > set amount of time?
1038 1073
 	if (isset($_POST['time_passed']))
@@ -1045,8 +1080,9 @@  discard block
 block discarded – undo
1045 1080
 	else
1046 1081
 	{
1047 1082
 		$members = array();
1048
-		foreach ($_POST['todoAction'] as $id)
1049
-			$members[] = (int) $id;
1083
+		foreach ($_POST['todoAction'] as $id) {
1084
+					$members[] = (int) $id;
1085
+		}
1050 1086
 		$condition = '
1051 1087
 			AND id_member IN ({array_int:members})';
1052 1088
 	}
@@ -1067,8 +1103,9 @@  discard block
 block discarded – undo
1067 1103
 	$member_count = $smcFunc['db_num_rows']($request);
1068 1104
 
1069 1105
 	// If no results then just return!
1070
-	if ($member_count == 0)
1071
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1106
+	if ($member_count == 0) {
1107
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1108
+	}
1072 1109
 
1073 1110
 	$member_info = array();
1074 1111
 	$members = array();
@@ -1107,8 +1144,9 @@  discard block
 block discarded – undo
1107 1144
 		// Do we have to let the integration code know about the activations?
1108 1145
 		if (!empty($modSettings['integrate_activate']))
1109 1146
 		{
1110
-			foreach ($member_info as $member)
1111
-				call_integration_hook('integrate_activate', array($member['username']));
1147
+			foreach ($member_info as $member) {
1148
+							call_integration_hook('integrate_activate', array($member['username']));
1149
+			}
1112 1150
 		}
1113 1151
 
1114 1152
 		// Check for email.
@@ -1238,20 +1276,23 @@  discard block
 block discarded – undo
1238 1276
 		$log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member';
1239 1277
 
1240 1278
 		require_once($sourcedir . '/Logging.php');
1241
-		foreach ($member_info as $member)
1242
-			logAction($log_action, array('member' => $member['id']), 'admin');
1279
+		foreach ($member_info as $member) {
1280
+					logAction($log_action, array('member' => $member['id']), 'admin');
1281
+		}
1243 1282
 	}
1244 1283
 
1245 1284
 	// Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers).
1246
-	if (in_array($current_filter, array(3, 4, 5)))
1247
-		updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0)));
1285
+	if (in_array($current_filter, array(3, 4, 5))) {
1286
+			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0)));
1287
+	}
1248 1288
 
1249 1289
 	// Update the member's stats. (but, we know the member didn't change their name.)
1250 1290
 	updateStats('member', false);
1251 1291
 
1252 1292
 	// If they haven't been deleted, update the post group statistics on them...
1253
-	if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind')))
1254
-		updateStats('postgroups', $members);
1293
+	if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) {
1294
+			updateStats('postgroups', $members);
1295
+	}
1255 1296
 
1256 1297
 	redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1257 1298
 }
@@ -1276,10 +1317,11 @@  discard block
 block discarded – undo
1276 1317
 	$dis = time() - $old;
1277 1318
 
1278 1319
 	// Before midnight?
1279
-	if ($dis < $sinceMidnight)
1280
-		return 0;
1281
-	else
1282
-		$dis -= $sinceMidnight;
1320
+	if ($dis < $sinceMidnight) {
1321
+			return 0;
1322
+	} else {
1323
+			$dis -= $sinceMidnight;
1324
+	}
1283 1325
 
1284 1326
 	// Divide out the seconds in a day to get the number of days.
1285 1327
 	return ceil($dis / (24 * 60 * 60));
Please login to merge, or discard this patch.
Sources/Likes.php 1 patch
Braces   +103 added lines, -75 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
  * Class Likes
@@ -106,8 +107,9 @@  discard block
 block discarded – undo
106 107
 		$this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false;
107 108
 
108 109
 		// We do not want to output debug information here.
109
-		if ($this->_js)
110
-			$db_show_debug = false;
110
+		if ($this->_js) {
111
+					$db_show_debug = false;
112
+		}
111 113
 	}
112 114
 
113 115
 	/**
@@ -141,8 +143,9 @@  discard block
 block discarded – undo
141 143
 			$call = $this->_sa;
142 144
 
143 145
 			// Guest can only view likes.
144
-			if ($call != 'view')
145
-				is_not_guest();
146
+			if ($call != 'view') {
147
+							is_not_guest();
148
+			}
146 149
 
147 150
 			checkSession('get');
148 151
 
@@ -180,15 +183,17 @@  discard block
 block discarded – undo
180 183
 		global $smcFunc, $modSettings;
181 184
 
182 185
 		// This feature is currently disable.
183
-		if (empty($modSettings['enable_likes']))
184
-			return $this->_error = 'like_disable';
186
+		if (empty($modSettings['enable_likes'])) {
187
+					return $this->_error = 'like_disable';
188
+		}
185 189
 
186 190
 		// Zerothly, they did indicate some kind of content to like, right?
187 191
 		preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches);
188 192
 		$this->_type = isset($matches[1]) ? $matches[1] : '';
189 193
 
190
-		if ($this->_type == '' || $this->_content <= 0)
191
-			return $this->_error = 'cannot_';
194
+		if ($this->_type == '' || $this->_content <= 0) {
195
+					return $this->_error = 'cannot_';
196
+		}
192 197
 
193 198
 		// First we need to verify if the user can see the type of content or not. This is set up to be extensible,
194 199
 		// so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks.
@@ -207,12 +212,14 @@  discard block
 block discarded – undo
207 212
 					'msg' => $this->_content,
208 213
 				)
209 214
 			);
210
-			if ($smcFunc['db_num_rows']($request) == 1)
211
-				list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
215
+			if ($smcFunc['db_num_rows']($request) == 1) {
216
+							list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
217
+			}
212 218
 
213 219
 			$smcFunc['db_free_result']($request);
214
-			if (empty($this->_idTopic))
215
-				return $this->_error = 'cannot_';
220
+			if (empty($this->_idTopic)) {
221
+							return $this->_error = 'cannot_';
222
+			}
216 223
 
217 224
 			// So we know what topic it's in and more importantly we know the user can see it.
218 225
 			// If we're not viewing, we need some info set up.
@@ -221,9 +228,7 @@  discard block
 block discarded – undo
221 228
 			$this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content;
222 229
 
223 230
 			$this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content'));
224
-		}
225
-
226
-		else
231
+		} else
227 232
 		{
228 233
 			// Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1
229 234
 			// When you hook this, check $this->_type first. If it is not something your mod worries about, return false.
@@ -241,8 +246,9 @@  discard block
 block discarded – undo
241 246
 					if ($result !== false)
242 247
 					{
243 248
 						// Match the type with what we already have.
244
-						if (!isset($result['type']) || $result['type'] != $this->_type)
245
-							return $this->_error = 'not_valid_like_type';
249
+						if (!isset($result['type']) || $result['type'] != $this->_type) {
250
+													return $this->_error = 'not_valid_like_type';
251
+						}
246 252
 
247 253
 						// Fill out the rest.
248 254
 						$this->_type = $result['type'];
@@ -253,13 +259,15 @@  discard block
 block discarded – undo
253 259
 				}
254 260
 			}
255 261
 
256
-			if (!$found)
257
-				return $this->_error = 'cannot_';
262
+			if (!$found) {
263
+							return $this->_error = 'cannot_';
264
+			}
258 265
 		}
259 266
 
260 267
 		// Does the user can like this? Viewing a list of likes doesn't require this permission.
261
-			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like']))
262
-				return $this->_error = $this->_validLikes['can_like'];
268
+			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) {
269
+							return $this->_error = $this->_validLikes['can_like'];
270
+			}
263 271
 	}
264 272
 
265 273
 	/**
@@ -284,8 +292,9 @@  discard block
 block discarded – undo
284 292
 		);
285 293
 
286 294
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
287
-		if ($this->_sa == __FUNCTION__)
288
-			$this->_data = __FUNCTION__;
295
+		if ($this->_sa == __FUNCTION__) {
296
+					$this->_data = __FUNCTION__;
297
+		}
289 298
 	}
290 299
 
291 300
 	/**
@@ -315,8 +324,8 @@  discard block
 block discarded – undo
315 324
 
316 325
 		// Add a background task to process sending alerts.
317 326
 		// Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this.
318
-		if ($this->_type == 'msg')
319
-			$smcFunc['db_insert']('insert',
327
+		if ($this->_type == 'msg') {
328
+					$smcFunc['db_insert']('insert',
320 329
 				'{db_prefix}background_tasks',
321 330
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
322 331
 				array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array(
@@ -328,10 +337,12 @@  discard block
 block discarded – undo
328 337
 				)), 0),
329 338
 				array('id_task')
330 339
 			);
340
+		}
331 341
 
332 342
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
333
-		if ($this->_sa == __FUNCTION__)
334
-			$this->_data = __FUNCTION__;
343
+		if ($this->_sa == __FUNCTION__) {
344
+					$this->_data = __FUNCTION__;
345
+		}
335 346
 	}
336 347
 
337 348
 	/**
@@ -357,8 +368,9 @@  discard block
 block discarded – undo
357 368
 		$smcFunc['db_free_result']($request);
358 369
 
359 370
 		// If you want to call this directly, fill out _data property too.
360
-		if ($this->_sa == __FUNCTION__)
361
-			$this->_data = $this->_numLikes;
371
+		if ($this->_sa == __FUNCTION__) {
372
+					$this->_data = $this->_numLikes;
373
+		}
362 374
 	}
363 375
 
364 376
 	/**
@@ -371,8 +383,9 @@  discard block
 block discarded – undo
371 383
 		global $smcFunc;
372 384
 
373 385
 		// Safety first!
374
-		if (empty($this->_type) || empty($this->_content))
375
-			return $this->_error = 'cannot_';
386
+		if (empty($this->_type) || empty($this->_content)) {
387
+					return $this->_error = 'cannot_';
388
+		}
376 389
 
377 390
 		// Do we already like this?
378 391
 		$request = $smcFunc['db_query']('', '
@@ -390,26 +403,28 @@  discard block
 block discarded – undo
390 403
 		$this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0;
391 404
 		$smcFunc['db_free_result']($request);
392 405
 
393
-		if ($this->_alreadyLiked)
394
-			$this->delete();
395
-
396
-		else
397
-			$this->insert();
406
+		if ($this->_alreadyLiked) {
407
+					$this->delete();
408
+		} else {
409
+					$this->insert();
410
+		}
398 411
 
399 412
 		// Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable.
400 413
 		$this->_count();
401 414
 
402 415
 		// Update the likes count for messages.
403
-		if ($this->_type == 'msg')
404
-			$this->msgIssueLike();
416
+		if ($this->_type == 'msg') {
417
+					$this->msgIssueLike();
418
+		}
405 419
 
406 420
 		// Any callbacks?
407 421
 		elseif (!empty($this->_validLikes['callback']))
408 422
 		{
409 423
 			$call = call_helper($this->_validLikes['callback'], true);
410 424
 
411
-			if (!empty($call))
412
-				call_user_func_array($call, array($this));
425
+			if (!empty($call)) {
426
+							call_user_func_array($call, array($this));
427
+			}
413 428
 		}
414 429
 
415 430
 		// Sometimes there might be other things that need updating after we do this like.
@@ -418,8 +433,9 @@  discard block
 block discarded – undo
418 433
 		// Now some clean up. This is provided here for any like handlers that want to do any cache flushing.
419 434
 		// This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so
420 435
 		// in integrate_valid_likes where it absolutely has to exist.
421
-		if (!empty($this->_validLikes['flush_cache']))
422
-			cache_put_data($this->_validLikes['flush_cache'], null);
436
+		if (!empty($this->_validLikes['flush_cache'])) {
437
+					cache_put_data($this->_validLikes['flush_cache'], null);
438
+		}
423 439
 
424 440
 		// All done, start building the data to pass as response.
425 441
 		$this->_data = array(
@@ -442,8 +458,9 @@  discard block
 block discarded – undo
442 458
 	{
443 459
 		global $smcFunc;
444 460
 
445
-		if ($this->_type !== 'msg')
446
-			return;
461
+		if ($this->_type !== 'msg') {
462
+					return;
463
+		}
447 464
 
448 465
 		$smcFunc['db_query']('', '
449 466
 			UPDATE {db_prefix}messages
@@ -484,8 +501,9 @@  discard block
 block discarded – undo
484 501
 				'like_type' => $this->_type,
485 502
 			)
486 503
 		);
487
-		while ($row = $smcFunc['db_fetch_assoc']($request))
488
-			$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
504
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
505
+					$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
506
+		}
489 507
 
490 508
 		// Now to get member data, including avatars and so on.
491 509
 		$members = array_keys($context['likers']);
@@ -493,8 +511,9 @@  discard block
 block discarded – undo
493 511
 		if (count($loaded) != count($members))
494 512
 		{
495 513
 			$members = array_diff($members, $loaded);
496
-			foreach ($members as $not_loaded)
497
-				unset ($context['likers'][$not_loaded]);
514
+			foreach ($members as $not_loaded) {
515
+							unset ($context['likers'][$not_loaded]);
516
+			}
498 517
 		}
499 518
 
500 519
 		foreach ($context['likers'] as $liker => $dummy)
@@ -536,12 +555,14 @@  discard block
 block discarded – undo
536 555
 		global $context, $txt;
537 556
 
538 557
 		// Don't do anything if someone else has already take care of the response.
539
-		if (!$this->_setResponse)
540
-			return;
558
+		if (!$this->_setResponse) {
559
+					return;
560
+		}
541 561
 
542 562
 		// Want a json response huh?
543
-		if ($this->_validLikes['json'])
544
-			return $this->jsonResponse();
563
+		if ($this->_validLikes['json']) {
564
+					return $this->jsonResponse();
565
+		}
545 566
 
546 567
 		// Set everything up for display.
547 568
 		loadTemplate('Likes');
@@ -551,8 +572,9 @@  discard block
 block discarded – undo
551 572
 		if ($this->_error)
552 573
 		{
553 574
 			// If this is a generic error, set it up good.
554
-			if ($this->_error == 'cannot_')
555
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
575
+			if ($this->_error == 'cannot_') {
576
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
577
+			}
556 578
 
557 579
 			// Is this request coming from an ajax call?
558 580
 			if ($this->_js)
@@ -562,8 +584,9 @@  discard block
 block discarded – undo
562 584
 			}
563 585
 
564 586
 			// Nope?  then just do a redirect to whatever URL was provided.
565
-			else
566
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : '');
587
+			else {
588
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : '');
589
+			}
567 590
 
568 591
 			return;
569 592
 		}
@@ -572,8 +595,9 @@  discard block
 block discarded – undo
572 595
 		else
573 596
 		{
574 597
 			// Not an ajax request so send the user back to the previous location or the main page.
575
-			if (!$this->_js)
576
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
598
+			if (!$this->_js) {
599
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
600
+			}
577 601
 
578 602
 			// These fine gentlemen all share the same template.
579 603
 			$generic = array('delete', 'insert', '_count');
@@ -606,8 +630,9 @@  discard block
 block discarded – undo
606 630
 		// If there is an error, send it.
607 631
 		if ($this->_error)
608 632
 		{
609
-			if ($this->_error == 'cannot_')
610
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
633
+			if ($this->_error == 'cannot_') {
634
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
635
+			}
611 636
 
612 637
 			$print['error'] = $this->_error;
613 638
 		}
@@ -643,33 +668,36 @@  discard block
 block discarded – undo
643 668
 	<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
644 669
 		<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
645 670
 
646
-	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2'))
647
-		$_GET['verse'] = '4:16';
671
+	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) {
672
+			$_GET['verse'] = '4:16';
673
+	}
648 674
 
649
-	if ($_GET['verse'] == '2:18')
650
-		echo '
675
+	if ($_GET['verse'] == '2:18') {
676
+			echo '
651 677
 			Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
652
-	elseif ($_GET['verse'] == '4:16')
653
-		echo '
678
+	} elseif ($_GET['verse'] == '4:16') {
679
+			echo '
654 680
 			And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together.&nbsp; Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
655
-	elseif ($_GET['verse'] == '22:1-2')
656
-		echo '
681
+	} elseif ($_GET['verse'] == '22:1-2') {
682
+			echo '
657 683
 			<p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer.&nbsp; Alas, it needed more than <em>only one</em>, but yet even thought otherwise.&nbsp; It became that the opposition <em>rumored</em> and lied, but still to no avail.&nbsp; Their match, though not <em>perfect</em>, had them outdone.</p>
658 684
 			<p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue.&nbsp; <em>The end</em>.</p>';
685
+	}
659 686
 
660 687
 	echo '
661 688
 		</div>
662 689
 		<div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
663 690
 
664
-	if ($_GET['verse'] == '2:18')
665
-		echo '
691
+	if ($_GET['verse'] == '2:18') {
692
+			echo '
666 693
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
667
-	elseif ($_GET['verse'] == '4:16')
668
-		echo '
694
+	} elseif ($_GET['verse'] == '4:16') {
695
+			echo '
669 696
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
670
-	elseif ($_GET['verse'] == '22:1-2')
671
-		echo '
697
+	} elseif ($_GET['verse'] == '22:1-2') {
698
+			echo '
672 699
 			from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>';
700
+	}
673 701
 
674 702
 	echo '
675 703
 		</div>
Please login to merge, or discard this patch.