Completed
Pull Request — release-2.1 (#4090)
by Rick
08:07
created
Sources/SearchAPI-Fulltext.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 		if (!empty($modSettings['search_simple_fulltext']))
208 208
 		{
209
-			if($smcFunc['db_title'] == "PostgreSQL")
209
+			if ($smcFunc['db_title'] == "PostgreSQL")
210 210
 			{
211 211
 				$language_ftx = $smcFunc['db_search_language']();
212 212
 				
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 			// remove any indexed words that are used in the complex body search terms
225 225
 			$words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']);
226 226
 
227
-			if($smcFunc['db_title'] == "PostgreSQL"){
227
+			if ($smcFunc['db_title'] == "PostgreSQL") {
228 228
 				$row = 0;
229 229
 				foreach ($words['indexed_words'] as $fulltextWord) {
230 230
 					$query_params['boolean_match'] .= ($row <> 0 ? '&' : '');
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
 			// if we have bool terms to search, add them in
242 242
 			if ($query_params['boolean_match']) {
243
-				if($smcFunc['db_title'] == "PostgreSQL")
243
+				if ($smcFunc['db_title'] == "PostgreSQL")
244 244
 				{
245 245
 					$language_ftx = $smcFunc['db_search_language']();
246 246
 					
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 
254 254
 		}
255 255
 
256
-		$ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( '
256
+		$ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ('
257 257
 			INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . '
258 258
 				(' . implode(', ', array_keys($query_select)) . ')') : '') . '
259 259
 			SELECT ' . implode(', ', $query_select) . '
Please login to merge, or discard this patch.
Braces   +44 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Class fulltext_search
@@ -98,8 +99,9 @@  discard block
 block discarded – undo
98 99
 			$smcFunc['db_free_result']($request);
99 100
 		}
100 101
 		// 4 is the MySQL default...
101
-		else
102
-			$min_word_length = 4;
102
+		else {
103
+					$min_word_length = 4;
104
+		}
103 105
 
104 106
 		return $min_word_length;
105 107
 	}
@@ -138,8 +140,7 @@  discard block
 block discarded – undo
138 140
 					$wordsSearch['words'][] = trim($word, "/*- ");
139 141
 					$wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"';
140 142
 				}
141
-			}
142
-			elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length)
143
+			} elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length)
143 144
 			{
144 145
 				// short words have feelings too
145 146
 				$wordsSearch['words'][] = trim($word, "/*- ");
@@ -149,8 +150,9 @@  discard block
 block discarded – undo
149 150
 
150 151
 		$fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"';
151 152
 		$wordsSearch['indexed_words'][] = $fulltextWord;
152
-		if ($isExcluded)
153
-			$wordsExclude[] = $fulltextWord;
153
+		if ($isExcluded) {
154
+					$wordsExclude[] = $fulltextWord;
155
+		}
154 156
 	}
155 157
 
156 158
 	/**
@@ -166,41 +168,50 @@  discard block
 block discarded – undo
166 168
 		$query_where = array();
167 169
 		$query_params = $search_data['params'];
168 170
 
169
-		if ($query_params['id_search'])
170
-			$query_select['id_search'] = '{int:id_search}';
171
+		if ($query_params['id_search']) {
172
+					$query_select['id_search'] = '{int:id_search}';
173
+		}
171 174
 
172 175
 		$count = 0;
173
-		if (empty($modSettings['search_simple_fulltext']))
174
-			foreach ($words['words'] as $regularWord)
176
+		if (empty($modSettings['search_simple_fulltext'])) {
177
+					foreach ($words['words'] as $regularWord)
175 178
 			{
176 179
 				$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}';
180
+		}
177 181
 				$query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
178 182
 			}
179 183
 
180
-		if ($query_params['user_query'])
181
-			$query_where[] = '{raw:user_query}';
182
-		if ($query_params['board_query'])
183
-			$query_where[] = 'm.id_board {raw:board_query}';
184
+		if ($query_params['user_query']) {
185
+					$query_where[] = '{raw:user_query}';
186
+		}
187
+		if ($query_params['board_query']) {
188
+					$query_where[] = 'm.id_board {raw:board_query}';
189
+		}
184 190
 
185
-		if ($query_params['topic'])
186
-			$query_where[] = 'm.id_topic = {int:topic}';
187
-		if ($query_params['min_msg_id'])
188
-			$query_where[] = 'm.id_msg >= {int:min_msg_id}';
189
-		if ($query_params['max_msg_id'])
190
-			$query_where[] = 'm.id_msg <= {int:max_msg_id}';
191
+		if ($query_params['topic']) {
192
+					$query_where[] = 'm.id_topic = {int:topic}';
193
+		}
194
+		if ($query_params['min_msg_id']) {
195
+					$query_where[] = 'm.id_msg >= {int:min_msg_id}';
196
+		}
197
+		if ($query_params['max_msg_id']) {
198
+					$query_where[] = 'm.id_msg <= {int:max_msg_id}';
199
+		}
191 200
 
192 201
 		$count = 0;
193
-		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index']))
194
-			foreach ($query_params['excluded_phrases'] as $phrase)
202
+		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) {
203
+					foreach ($query_params['excluded_phrases'] as $phrase)
195 204
 			{
196 205
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}';
206
+		}
197 207
 				$query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
198 208
 			}
199 209
 		$count = 0;
200
-		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index']))
201
-			foreach ($query_params['excluded_subject_words'] as $excludedWord)
210
+		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) {
211
+					foreach ($query_params['excluded_subject_words'] as $excludedWord)
202 212
 			{
203 213
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}';
214
+		}
204 215
 				$query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]';
205 216
 			}
206 217
 
@@ -212,12 +223,11 @@  discard block
 block discarded – undo
212 223
 				
213 224
 				$query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:body_match})';
214 225
 				$query_params['language_ftx'] = $language_ftx;
226
+			} else {
227
+							$query_where[] = 'MATCH (body) AGAINST ({string:body_match})';
215 228
 			}
216
-			else
217
-				$query_where[] = 'MATCH (body) AGAINST ({string:body_match})';
218 229
 			$query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words']));
219
-		}
220
-		else
230
+		} else
221 231
 		{
222 232
 			$query_params['boolean_match'] = '';
223 233
 
@@ -231,10 +241,10 @@  discard block
 block discarded – undo
231 241
 					$query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' ';
232 242
 					$row++;
233 243
 				}
234
-			}
235
-			else
236
-				foreach ($words['indexed_words'] as $fulltextWord)
244
+			} else {
245
+							foreach ($words['indexed_words'] as $fulltextWord)
237 246
 					$query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' ';
247
+			}
238 248
 
239 249
 			$query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1);
240 250
 
@@ -246,9 +256,9 @@  discard block
 block discarded – undo
246 256
 					
247 257
 					$query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:boolean_match})';
248 258
 					$query_params['language_ftx'] = $language_ftx;
259
+				} else {
260
+									$query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)';
249 261
 				}
250
-				else
251
-					$query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)';
252 262
 			}
253 263
 
254 264
 		}
Please login to merge, or discard this patch.
Sources/DbSearch-postgresql.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	$version = $smcFunc['db_get_version']();
39 39
 	// if we got a Beta Version
40 40
 	if (stripos($version, 'beta') !== false)
41
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
41
+		$version = substr($version, 0, stripos($version, 'beta')) . '.0';
42 42
 	// or RC
43 43
 	if (stripos($version, 'rc') !== false)
44
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
44
+		$version = substr($version, 0, stripos($version, 'rc')) . '.0';
45 45
 
46
-	if (version_compare($version,'9.5.0','>='))
46
+	if (version_compare($version, '9.5.0', '>='))
47 47
 		$smcFunc['db_support_ignore'] = true;
48 48
 }
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function smf_db_search_support($search_type)
57 57
 {
58
-	$supported_types = array('custom','fulltext');
58
+	$supported_types = array('custom', 'fulltext');
59 59
 
60 60
 	return in_array($search_type, $supported_types);
61 61
 }
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
110 110
 	{
111 111
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
112
-		if ($smcFunc['db_support_ignore']){
112
+		if ($smcFunc['db_support_ignore']) {
113 113
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
114
-			$db_string = $db_string.' ON CONFLICT DO NOTHING';
114
+			$db_string = $db_string . ' ON CONFLICT DO NOTHING';
115 115
 		}
116 116
 		else
117 117
 		{
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$language_ftx = $modSettings['search_language'];
169 169
 	else
170 170
 	{
171
-		$request = $smcFunc['db_query']('','
171
+		$request = $smcFunc['db_query']('', '
172 172
 			SHOW default_text_search_config',
173 173
 			array()
174 174
 		);
Please login to merge, or discard this patch.
Braces   +25 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  *  Add the file functions to the $smcFunc array.
@@ -23,29 +24,33 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_search_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => false,
32 33
 			'db_search_language' => 'smf_db_search_language',
33 34
 		);
35
+	}
34 36
 
35 37
 	db_extend();
36 38
 
37 39
 	//pg 9.5 got ignore support
38 40
 	$version = $smcFunc['db_get_version']();
39 41
 	// if we got a Beta Version
40
-	if (stripos($version, 'beta') !== false)
41
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
42
+	if (stripos($version, 'beta') !== false) {
43
+			$version = substr($version, 0, stripos($version, 'beta')).'.0';
44
+	}
42 45
 	// or RC
43
-	if (stripos($version, 'rc') !== false)
44
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
46
+	if (stripos($version, 'rc') !== false) {
47
+			$version = substr($version, 0, stripos($version, 'rc')).'.0';
48
+	}
45 49
 
46
-	if (version_compare($version,'9.5.0','>='))
47
-		$smcFunc['db_support_ignore'] = true;
48
-}
50
+	if (version_compare($version,'9.5.0','>=')) {
51
+			$smcFunc['db_support_ignore'] = true;
52
+	}
53
+	}
49 54
 
50 55
 /**
51 56
  * This function will tell you whether this database type supports this search type.
@@ -104,16 +109,16 @@  discard block
 block discarded – undo
104 109
 		),
105 110
 	);
106 111
 
107
-	if (isset($replacements[$identifier]))
108
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
112
+	if (isset($replacements[$identifier])) {
113
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
114
+	}
109 115
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
110 116
 	{
111 117
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
112 118
 		if ($smcFunc['db_support_ignore']){
113 119
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
114 120
 			$db_string = $db_string.' ON CONFLICT DO NOTHING';
115
-		}
116
-		else
121
+		} else
117 122
 		{
118 123
 			// Don't error on multi-insert.
119 124
 			$db_values['db_error_skip'] = true;
@@ -121,8 +126,9 @@  discard block
 block discarded – undo
121 126
 	}
122 127
 	
123 128
 	//fix double quotes
124
-	if ($identifier == 'insert_into_log_messages_fulltext')
125
-		$db_values = str_replace('"', "'", $db_values);
129
+	if ($identifier == 'insert_into_log_messages_fulltext') {
130
+			$db_values = str_replace('"', "'", $db_values);
131
+	}
126 132
 
127 133
 	$return = $smcFunc['db_query']('', $db_string,
128 134
 		$db_values, $connection
@@ -164,9 +170,9 @@  discard block
 block discarded – undo
164 170
 	
165 171
 	$language_ftx = 'english';
166 172
 	
167
-	if (!empty($modSettings['search_language']))
168
-		$language_ftx = $modSettings['search_language'];
169
-	else
173
+	if (!empty($modSettings['search_language'])) {
174
+			$language_ftx = $modSettings['search_language'];
175
+	} else
170 176
 	{
171 177
 		$request = $smcFunc['db_query']('','
172 178
 			SHOW default_text_search_config',
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
 
@@ -1306,14 +1306,14 @@  discard block
 block discarded – undo
1306 1306
 	if (isset($context['name']) && isset($context['email']))
1307 1307
 	{
1308 1308
 		$context['posting_fields']['guestname'] = array(
1309
-			'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
+			'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>',
1310 1310
 			'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" class="input_text" required>',
1311 1311
 		);
1312 1312
 
1313 1313
 		if (empty($modSettings['guest_post_no_email']))
1314 1314
 		{
1315 1315
 			$context['posting_fields']['email'] = array(
1316
-				'dt' => '<span id="caption_email"' .  (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>',
1316
+				'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>',
1317 1317
 				'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" class="input_text" required>',
1318 1318
 			);
1319 1319
 		}
Please login to merge, or discard this patch.
Braces   +659 added lines, -511 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
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
 
@@ -78,10 +82,11 @@  discard block
 block discarded – undo
78 82
 			array(
79 83
 				'msg' => (int) $_REQUEST['msg'],
80 84
 		));
81
-		if ($smcFunc['db_num_rows']($request) != 1)
82
-			unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
83
-		else
84
-			list ($topic) = $smcFunc['db_fetch_row']($request);
85
+		if ($smcFunc['db_num_rows']($request) != 1) {
86
+					unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
87
+		} else {
88
+					list ($topic) = $smcFunc['db_fetch_row']($request);
89
+		}
85 90
 		$smcFunc['db_free_result']($request);
86 91
 	}
87 92
 
@@ -108,33 +113,36 @@  discard block
 block discarded – undo
108 113
 		$smcFunc['db_free_result']($request);
109 114
 
110 115
 		// If this topic already has a poll, they sure can't add another.
111
-		if (isset($_REQUEST['poll']) && $pollID > 0)
112
-			unset($_REQUEST['poll']);
116
+		if (isset($_REQUEST['poll']) && $pollID > 0) {
117
+					unset($_REQUEST['poll']);
118
+		}
113 119
 
114 120
 		if (empty($_REQUEST['msg']))
115 121
 		{
116
-			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any')))
117
-				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
+			}
118 125
 
119 126
 			// By default the reply will be approved...
120 127
 			$context['becomes_approved'] = true;
121 128
 			if ($id_member_poster != $user_info['id'] || $user_info['is_guest'])
122 129
 			{
123
-				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
124
-					$context['becomes_approved'] = false;
125
-				else
126
-					isAllowedTo('post_reply_any');
127
-			}
128
-			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'))
129 136
 			{
130
-				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any')))
131
-					$context['becomes_approved'] = false;
132
-				else
133
-					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
+				}
134 142
 			}
143
+		} else {
144
+					$context['becomes_approved'] = true;
135 145
 		}
136
-		else
137
-			$context['becomes_approved'] = true;
138 146
 
139 147
 		$context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own'));
140 148
 		$context['can_sticky'] = allowedTo('make_sticky');
@@ -146,18 +154,19 @@  discard block
 block discarded – undo
146 154
 		$context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky;
147 155
 
148 156
 		// Check whether this is a really old post being bumped...
149
-		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject']))
150
-			$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
151
-	}
152
-	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
153 161
 	{
154 162
 		$context['becomes_approved'] = true;
155 163
 		if ((!$context['make_event'] || !empty($board)))
156 164
 		{
157
-			if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
158
-				$context['becomes_approved'] = false;
159
-			else
160
-				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
+			}
161 170
 		}
162 171
 
163 172
 		$locked = 0;
@@ -193,20 +202,24 @@  discard block
 block discarded – undo
193 202
 	}
194 203
 
195 204
 	// Don't allow a post if it's locked and you aren't all powerful.
196
-	if ($locked && !allowedTo('moderate_board'))
197
-		fatal_lang_error('topic_locked', false);
205
+	if ($locked && !allowedTo('moderate_board')) {
206
+			fatal_lang_error('topic_locked', false);
207
+	}
198 208
 	// Check the users permissions - is the user allowed to add or post a poll?
199 209
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
200 210
 	{
201 211
 		// New topic, new poll.
202
-		if (empty($topic))
203
-			isAllowedTo('poll_post');
212
+		if (empty($topic)) {
213
+					isAllowedTo('poll_post');
214
+		}
204 215
 		// This is an old topic - but it is yours!  Can you add to it?
205
-		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any'))
206
-			isAllowedTo('poll_add_own');
216
+		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) {
217
+					isAllowedTo('poll_add_own');
218
+		}
207 219
 		// If you're not the owner, can you add to any poll?
208
-		else
209
-			isAllowedTo('poll_add_any');
220
+		else {
221
+					isAllowedTo('poll_add_any');
222
+		}
210 223
 
211 224
 		require_once($sourcedir . '/Subs-Members.php');
212 225
 		$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
@@ -235,8 +248,9 @@  discard block
 block discarded – undo
235 248
 	if ($context['make_event'])
236 249
 	{
237 250
 		// They might want to pick a board.
238
-		if (!isset($context['current_board']))
239
-			$context['current_board'] = 0;
251
+		if (!isset($context['current_board'])) {
252
+					$context['current_board'] = 0;
253
+		}
240 254
 
241 255
 		// Start loading up the event info.
242 256
 		$context['event'] = array();
@@ -250,10 +264,11 @@  discard block
 block discarded – undo
250 264
 		isAllowedTo('calendar_post');
251 265
 
252 266
 		// We want a fairly compact version of the time, but as close as possible to the user's settings.
253
-		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
254
-			$time_string = '%k:%M';
255
-		else
256
-			$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
+		}
257 272
 
258 273
 		$js_time_string = str_replace(
259 274
 			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -275,8 +290,7 @@  discard block
 block discarded – undo
275 290
 			require_once($sourcedir . '/Subs-Calendar.php');
276 291
 			$eventProperties = getEventProperties($context['event']['id']);
277 292
 			$context['event'] = array_merge($context['event'], $eventProperties);
278
-		}
279
-		else
293
+		} else
280 294
 		{
281 295
 			// Get the current event information.
282 296
 			require_once($sourcedir . '/Subs-Calendar.php');
@@ -284,15 +298,18 @@  discard block
 block discarded – undo
284 298
 			$context['event'] = array_merge($context['event'], $eventProperties);
285 299
 
286 300
 			// Make sure the year and month are in the valid range.
287
-			if ($context['event']['month'] < 1 || $context['event']['month'] > 12)
288
-				fatal_lang_error('invalid_month', false);
289
-			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear'])
290
-				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
+			}
291 307
 
292 308
 			// Get a list of boards they can post in.
293 309
 			$boards = boardsAllowedTo('post_new');
294
-			if (empty($boards))
295
-				fatal_lang_error('cannot_post_new', 'user');
310
+			if (empty($boards)) {
311
+							fatal_lang_error('cannot_post_new', 'user');
312
+			}
296 313
 
297 314
 			// Load a list of boards for this event in the context.
298 315
 			require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -411,10 +428,11 @@  discard block
 block discarded – undo
411 428
 
412 429
 			if (!empty($context['new_replies']))
413 430
 			{
414
-				if ($context['new_replies'] == 1)
415
-					$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
416
-				else
417
-					$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
+				}
418 436
 
419 437
 				$post_errors[] = 'new_replies';
420 438
 
@@ -426,9 +444,9 @@  discard block
 block discarded – undo
426 444
 	// Get a response prefix (like 'Re:') in the default forum language.
427 445
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
428 446
 	{
429
-		if ($language === $user_info['language'])
430
-			$context['response_prefix'] = $txt['response_prefix'];
431
-		else
447
+		if ($language === $user_info['language']) {
448
+					$context['response_prefix'] = $txt['response_prefix'];
449
+		} else
432 450
 		{
433 451
 			loadLanguage('index', $language, false);
434 452
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -441,8 +459,9 @@  discard block
 block discarded – undo
441 459
 	// Do we have a body, but an error happened.
442 460
 	if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error']))
443 461
 	{
444
-		if (isset($_REQUEST['quickReply']))
445
-			$_REQUEST['message'] = $_REQUEST['quickReply'];
462
+		if (isset($_REQUEST['quickReply'])) {
463
+					$_REQUEST['message'] = $_REQUEST['quickReply'];
464
+		}
446 465
 
447 466
 		// Validate inputs.
448 467
 		if (empty($context['post_error']))
@@ -450,15 +469,17 @@  discard block
 block discarded – undo
450 469
 			// This means they didn't click Post and get an error.
451 470
 			$really_previewing = true;
452 471
 
453
-		}
454
-		else
472
+		} else
455 473
 		{
456
-			if (!isset($_REQUEST['subject']))
457
-				$_REQUEST['subject'] = '';
458
-			if (!isset($_REQUEST['message']))
459
-				$_REQUEST['message'] = '';
460
-			if (!isset($_REQUEST['icon']))
461
-				$_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
+			}
462 483
 
463 484
 			// They are previewing if they asked to preview (i.e. came from quick reply).
464 485
 			$really_previewing = !empty($_POST['preview']);
@@ -474,8 +495,9 @@  discard block
 block discarded – undo
474 495
 		$form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES);
475 496
 
476 497
 		// Make sure the subject isn't too long - taking into account special characters.
477
-		if ($smcFunc['strlen']($form_subject) > 100)
478
-			$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
+		}
479 501
 
480 502
 		if (isset($_REQUEST['poll']))
481 503
 		{
@@ -487,8 +509,9 @@  discard block
 block discarded – undo
487 509
 			$_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']);
488 510
 			foreach ($_POST['options'] as $option)
489 511
 			{
490
-				if (trim($option) == '')
491
-					continue;
512
+				if (trim($option) == '') {
513
+									continue;
514
+				}
492 515
 
493 516
 				$context['choices'][] = array(
494 517
 					'id' => $choice_id++,
@@ -550,13 +573,14 @@  discard block
 block discarded – undo
550 573
 				$context['preview_subject'] = $form_subject;
551 574
 
552 575
 				censorText($context['preview_subject']);
576
+			} else {
577
+							$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
553 578
 			}
554
-			else
555
-				$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
556 579
 
557 580
 			// Protect any CDATA blocks.
558
-			if (isset($_REQUEST['xml']))
559
-				$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
+			}
560 584
 		}
561 585
 
562 586
 		// Set up the checkboxes.
@@ -595,29 +619,32 @@  discard block
 block discarded – undo
595 619
 			);
596 620
 			// The message they were trying to edit was most likely deleted.
597 621
 			// @todo Change this error message?
598
-			if ($smcFunc['db_num_rows']($request) == 0)
599
-				fatal_lang_error('no_board', false);
622
+			if ($smcFunc['db_num_rows']($request) == 0) {
623
+							fatal_lang_error('no_board', false);
624
+			}
600 625
 			$row = $smcFunc['db_fetch_assoc']($request);
601 626
 
602 627
 			$attachment_stuff = array($row);
603
-			while ($row2 = $smcFunc['db_fetch_assoc']($request))
604
-				$attachment_stuff[] = $row2;
628
+			while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
629
+							$attachment_stuff[] = $row2;
630
+			}
605 631
 			$smcFunc['db_free_result']($request);
606 632
 
607 633
 			if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
608 634
 			{
609 635
 				// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
610
-				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
611
-					fatal_lang_error('modify_post_time_passed', false);
612
-				elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
613
-					isAllowedTo('modify_replies');
614
-				else
615
-					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');
616 647
 			}
617
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
618
-				isAllowedTo('modify_replies');
619
-			else
620
-				isAllowedTo('modify_any');
621 648
 
622 649
 			if ($context['can_announce'] && !empty($row['id_action']))
623 650
 			{
@@ -641,8 +668,9 @@  discard block
 block discarded – undo
641 668
 
642 669
 				while ($row = $smcFunc['db_fetch_assoc']($request))
643 670
 				{
644
-					if ($row['filesize'] <= 0)
645
-						continue;
671
+					if ($row['filesize'] <= 0) {
672
+											continue;
673
+					}
646 674
 					$context['current_attachments'][$row['id_attach']] = array(
647 675
 						'name' => $smcFunc['htmlspecialchars']($row['filename']),
648 676
 						'size' => $row['filesize'],
@@ -712,29 +740,32 @@  discard block
 block discarded – undo
712 740
 			)
713 741
 		);
714 742
 		// The message they were trying to edit was most likely deleted.
715
-		if ($smcFunc['db_num_rows']($request) == 0)
716
-			fatal_lang_error('no_message', false);
743
+		if ($smcFunc['db_num_rows']($request) == 0) {
744
+					fatal_lang_error('no_message', false);
745
+		}
717 746
 		$row = $smcFunc['db_fetch_assoc']($request);
718 747
 
719 748
 		$attachment_stuff = array($row);
720
-		while ($row2 = $smcFunc['db_fetch_assoc']($request))
721
-			$attachment_stuff[] = $row2;
749
+		while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
750
+					$attachment_stuff[] = $row2;
751
+		}
722 752
 		$smcFunc['db_free_result']($request);
723 753
 
724 754
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
725 755
 		{
726 756
 			// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
727
-			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
728
-				fatal_lang_error('modify_post_time_passed', false);
729
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
730
-				isAllowedTo('modify_replies');
731
-			else
732
-				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');
733 768
 		}
734
-		elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
735
-			isAllowedTo('modify_replies');
736
-		else
737
-			isAllowedTo('modify_any');
738 769
 
739 770
 		if ($context['can_announce'] && !empty($row['id_action']))
740 771
 		{
@@ -761,15 +792,17 @@  discard block
 block discarded – undo
761 792
 		$context['icon'] = $row['icon'];
762 793
 
763 794
 		// Show an "approve" box if the user can approve it, and the message isn't approved.
764
-		if (!$row['approved'] && !$context['show_approval'])
765
-			$context['show_approval'] = allowedTo('approve_posts');
795
+		if (!$row['approved'] && !$context['show_approval']) {
796
+					$context['show_approval'] = allowedTo('approve_posts');
797
+		}
766 798
 
767 799
 		// Sort the attachments so they are in the order saved
768 800
 		$temp = array();
769 801
 		foreach ($attachment_stuff as $attachment)
770 802
 		{
771
-			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable']))
772
-				$temp[$attachment['id_attach']] = $attachment;
803
+			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) {
804
+							$temp[$attachment['id_attach']] = $attachment;
805
+			}
773 806
 
774 807
 		}
775 808
 		ksort($temp);
@@ -831,14 +864,16 @@  discard block
 block discarded – undo
831 864
 					'is_approved' => 1,
832 865
 				)
833 866
 			);
834
-			if ($smcFunc['db_num_rows']($request) == 0)
835
-				fatal_lang_error('quoted_post_deleted', false);
867
+			if ($smcFunc['db_num_rows']($request) == 0) {
868
+							fatal_lang_error('quoted_post_deleted', false);
869
+			}
836 870
 			list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request);
837 871
 			$smcFunc['db_free_result']($request);
838 872
 
839 873
 			// Add 'Re: ' to the front of the quoted subject.
840
-			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
841
-				$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
+			}
842 877
 
843 878
 			// Censor the message and subject.
844 879
 			censorText($form_message);
@@ -851,10 +886,11 @@  discard block
 block discarded – undo
851 886
 				for ($i = 0, $n = count($parts); $i < $n; $i++)
852 887
 				{
853 888
 					// It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
854
-					if ($i % 4 == 0)
855
-						$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)
856 891
 						{
857 892
 							return '[html]' . preg_replace('~<br\s?/?' . '>~i', '&lt;br /&gt;<br>', "$m[1]") . '[/html]';
893
+					}
858 894
 						}, $parts[$i]);
859 895
 				}
860 896
 				$form_message = implode('', $parts);
@@ -863,8 +899,9 @@  discard block
 block discarded – undo
863 899
 			$form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message);
864 900
 
865 901
 			// Remove any nested quotes, if necessary.
866
-			if (!empty($modSettings['removeNestedQuotes']))
867
-				$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
+			}
868 905
 
869 906
 			// Add a quote string on the front and end.
870 907
 			$form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]';
@@ -876,15 +913,15 @@  discard block
 block discarded – undo
876 913
 			$form_subject = $first_subject;
877 914
 
878 915
 			// Add 'Re: ' to the front of the subject.
879
-			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
880
-				$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
+			}
881 919
 
882 920
 			// Censor the subject.
883 921
 			censorText($form_subject);
884 922
 
885 923
 			$form_message = '';
886
-		}
887
-		else
924
+		} else
888 925
 		{
889 926
 			$form_subject = isset($_GET['subject']) ? $_GET['subject'] : '';
890 927
 			$form_message = '';
@@ -902,13 +939,15 @@  discard block
 block discarded – undo
902 939
 		if (isset($_REQUEST['msg']))
903 940
 		{
904 941
 			$context['attachments']['quantity'] = count($context['current_attachments']);
905
-			foreach ($context['current_attachments'] as $attachment)
906
-				$context['attachments']['total_size'] += $attachment['size'];
942
+			foreach ($context['current_attachments'] as $attachment) {
943
+							$context['attachments']['total_size'] += $attachment['size'];
944
+			}
907 945
 		}
908 946
 
909 947
 		// A bit of house keeping first.
910
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
911
-			unset($_SESSION['temp_attachments']);
948
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
949
+					unset($_SESSION['temp_attachments']);
950
+		}
912 951
 
913 952
 		if (!empty($_SESSION['temp_attachments']))
914 953
 		{
@@ -917,9 +956,10 @@  discard block
 block discarded – undo
917 956
 			{
918 957
 				foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
919 958
 				{
920
-					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
921
-						if (file_exists($attachment['tmp_name']))
959
+					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) {
960
+											if (file_exists($attachment['tmp_name']))
922 961
 							unlink($attachment['tmp_name']);
962
+					}
923 963
 				}
924 964
 				$post_errors[] = 'temp_attachments_gone';
925 965
 				$_SESSION['temp_attachments'] = array();
@@ -933,8 +973,9 @@  discard block
 block discarded – undo
933 973
 					// See if any files still exist before showing the warning message and the files attached.
934 974
 					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
935 975
 					{
936
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
937
-							continue;
976
+						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
977
+													continue;
978
+						}
938 979
 
939 980
 						if (file_exists($attachment['tmp_name']))
940 981
 						{
@@ -944,20 +985,21 @@  discard block
 block discarded – undo
944 985
 							break;
945 986
 						}
946 987
 					}
947
-				}
948
-				else
988
+				} else
949 989
 				{
950 990
 					// Since, they don't belong here. Let's inform the user that they exist..
951
-					if (!empty($topic))
952
-						$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
953
-					else
954
-						$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
+					}
955 996
 
956 997
 					// Compile a list of the files to show the user.
957 998
 					$file_list = array();
958
-					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
959
-						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)
960 1001
 							$file_list[] = $attachment['name'];
1002
+					}
961 1003
 
962 1004
 					$_SESSION['temp_attachments']['post']['files'] = $file_list;
963 1005
 					$file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>';
@@ -969,8 +1011,7 @@  discard block
 block discarded – undo
969 1011
 
970 1012
 						$post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list));
971 1013
 						$context['ignore_temp_attachments'] = true;
972
-					}
973
-					else
1014
+					} else
974 1015
 					{
975 1016
 						$post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list));
976 1017
 						$context['ignore_temp_attachments'] = true;
@@ -978,16 +1019,19 @@  discard block
 block discarded – undo
978 1019
 				}
979 1020
 			}
980 1021
 
981
-			if (!empty($context['we_are_history']))
982
-				$post_errors[] = $context['we_are_history'];
1022
+			if (!empty($context['we_are_history'])) {
1023
+							$post_errors[] = $context['we_are_history'];
1024
+			}
983 1025
 
984 1026
 			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
985 1027
 			{
986
-				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files']))
987
-					break;
1028
+				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) {
1029
+									break;
1030
+				}
988 1031
 
989
-				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
990
-					continue;
1032
+				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
1033
+									continue;
1034
+				}
991 1035
 
992 1036
 				if ($attachID == 'initial_error')
993 1037
 				{
@@ -1002,15 +1046,17 @@  discard block
 block discarded – undo
1002 1046
 				{
1003 1047
 					$txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : '';
1004 1048
 					$txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">';
1005
-					foreach ($attachment['errors'] as $error)
1006
-						$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
+					}
1007 1052
 					$txt['error_attach_errors'] .= '</div>';
1008 1053
 					$post_errors[] = 'attach_errors';
1009 1054
 
1010 1055
 					// Take out the trash.
1011 1056
 					unset($_SESSION['temp_attachments'][$attachID]);
1012
-					if (file_exists($attachment['tmp_name']))
1013
-						unlink($attachment['tmp_name']);
1057
+					if (file_exists($attachment['tmp_name'])) {
1058
+											unlink($attachment['tmp_name']);
1059
+					}
1014 1060
 					continue;
1015 1061
 				}
1016 1062
 
@@ -1023,8 +1069,9 @@  discard block
 block discarded – undo
1023 1069
 
1024 1070
 				$context['attachments']['quantity']++;
1025 1071
 				$context['attachments']['total_size'] += $attachment['size'];
1026
-				if (!isset($context['files_in_session_warning']))
1027
-					$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
+				}
1028 1075
 
1029 1076
 				$context['current_attachments'][$attachID] = array(
1030 1077
 					'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>',
@@ -1052,8 +1099,9 @@  discard block
 block discarded – undo
1052 1099
 	}
1053 1100
 
1054 1101
 	// If they came from quick reply, and have to enter verification details, give them some notice.
1055
-	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification']))
1056
-		$post_errors[] = 'need_qr_verification';
1102
+	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) {
1103
+			$post_errors[] = 'need_qr_verification';
1104
+	}
1057 1105
 
1058 1106
 	/*
1059 1107
 	 * There are two error types: serious and minor. Serious errors
@@ -1070,52 +1118,56 @@  discard block
 block discarded – undo
1070 1118
 	{
1071 1119
 		loadLanguage('Errors');
1072 1120
 		$context['error_type'] = 'minor';
1073
-		foreach ($post_errors as $post_error)
1074
-			if (is_array($post_error))
1121
+		foreach ($post_errors as $post_error) {
1122
+					if (is_array($post_error))
1075 1123
 			{
1076 1124
 				$post_error_id = $post_error[0];
1125
+		}
1077 1126
 				$context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]);
1078 1127
 
1079 1128
 				// If it's not a minor error flag it as such.
1080
-				if (!in_array($post_error_id, $minor_errors))
1081
-					$context['error_type'] = 'serious';
1082
-			}
1083
-			else
1129
+				if (!in_array($post_error_id, $minor_errors)) {
1130
+									$context['error_type'] = 'serious';
1131
+				}
1132
+			} else
1084 1133
 			{
1085 1134
 				$context['post_error'][$post_error] = $txt['error_' . $post_error];
1086 1135
 
1087 1136
 				// If it's not a minor error flag it as such.
1088
-				if (!in_array($post_error, $minor_errors))
1089
-					$context['error_type'] = 'serious';
1137
+				if (!in_array($post_error, $minor_errors)) {
1138
+									$context['error_type'] = 'serious';
1139
+				}
1090 1140
 			}
1091 1141
 	}
1092 1142
 
1093 1143
 	// What are you doing? Posting a poll, modifying, previewing, new post, or reply...
1094
-	if (isset($_REQUEST['poll']))
1095
-		$context['page_title'] = $txt['new_poll'];
1096
-	elseif ($context['make_event'])
1097
-		$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1098
-	elseif (isset($_REQUEST['msg']))
1099
-		$context['page_title'] = $txt['modify_msg'];
1100
-	elseif (isset($_REQUEST['subject'], $context['preview_subject']))
1101
-		$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1102
-	elseif (empty($topic))
1103
-		$context['page_title'] = $txt['start_new_topic'];
1104
-	else
1105
-		$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
+	}
1106 1157
 
1107 1158
 	// Build the link tree.
1108
-	if (empty($topic))
1109
-		$context['linktree'][] = array(
1159
+	if (empty($topic)) {
1160
+			$context['linktree'][] = array(
1110 1161
 			'name' => '<em>' . $txt['start_new_topic'] . '</em>'
1111 1162
 		);
1112
-	else
1113
-		$context['linktree'][] = array(
1163
+	} else {
1164
+			$context['linktree'][] = array(
1114 1165
 			'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'],
1115 1166
 			'name' => $form_subject,
1116 1167
 			'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>',
1117 1168
 			'extra_after' => '<span><strong class="nav">)</strong></span>'
1118 1169
 		);
1170
+	}
1119 1171
 
1120 1172
 	$context['subject'] = addcslashes($form_subject, '"');
1121 1173
 	$context['message'] = str_replace(array('"', '<', '>', '&nbsp;'), array('&quot;', '&lt;', '&gt;', ' '), $form_message);
@@ -1159,8 +1211,9 @@  discard block
 block discarded – undo
1159 1211
 	// Message icons - customized icons are off?
1160 1212
 	$context['icons'] = getMessageIcons($board);
1161 1213
 
1162
-	if (!empty($context['icons']))
1163
-		$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
+	}
1164 1217
 
1165 1218
 	// Are we starting a poll? if set the poll icon as selected if its available
1166 1219
 	if (isset($_REQUEST['poll']))
@@ -1180,8 +1233,9 @@  discard block
 block discarded – undo
1180 1233
 	for ($i = 0, $n = count($context['icons']); $i < $n; $i++)
1181 1234
 	{
1182 1235
 		$context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value'];
1183
-		if ($context['icons'][$i]['selected'])
1184
-			$context['icon_url'] = $context['icons'][$i]['url'];
1236
+		if ($context['icons'][$i]['selected']) {
1237
+					$context['icon_url'] = $context['icons'][$i]['url'];
1238
+		}
1185 1239
 	}
1186 1240
 	if (empty($context['icon_url']))
1187 1241
 	{
@@ -1195,8 +1249,9 @@  discard block
 block discarded – undo
1195 1249
 		));
1196 1250
 	}
1197 1251
 
1198
-	if (!empty($topic) && !empty($modSettings['topicSummaryPosts']))
1199
-		getTopic();
1252
+	if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) {
1253
+			getTopic();
1254
+	}
1200 1255
 
1201 1256
 	// If the user can post attachments prepare the warning labels.
1202 1257
 	if ($context['can_post_attachment'])
@@ -1207,12 +1262,13 @@  discard block
 block discarded – undo
1207 1262
 		$context['attachment_restrictions'] = array();
1208 1263
 		$context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', '));
1209 1264
 		$attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit');
1210
-		foreach ($attachmentRestrictionTypes as $type)
1211
-			if (!empty($modSettings[$type]))
1265
+		foreach ($attachmentRestrictionTypes as $type) {
1266
+					if (!empty($modSettings[$type]))
1212 1267
 			{
1213 1268
 				// Show the max number of attachments if not 0.
1214 1269
 				if ($type == 'attachmentNumPerPostLimit')
1215 1270
 					$context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']);
1271
+		}
1216 1272
 			}
1217 1273
 	}
1218 1274
 
@@ -1246,8 +1302,8 @@  discard block
 block discarded – undo
1246 1302
 
1247 1303
 	if (!empty($context['current_attachments']))
1248 1304
 	{
1249
-		foreach ($context['current_attachments'] as $key => $mock)
1250
-			addInlineJavaScript('
1305
+		foreach ($context['current_attachments'] as $key => $mock) {
1306
+					addInlineJavaScript('
1251 1307
 	current_attachments.push({
1252 1308
 		name: '. JavaScriptEscape($mock['name']) . ',
1253 1309
 		size: '. $mock['size'] . ',
@@ -1256,6 +1312,7 @@  discard block
 block discarded – undo
1256 1312
 		type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ',
1257 1313
 		thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . '
1258 1314
 	});', true);
1315
+		}
1259 1316
 	}
1260 1317
 
1261 1318
 	// File Upload.
@@ -1341,8 +1398,9 @@  discard block
 block discarded – undo
1341 1398
 
1342 1399
 
1343 1400
 	// Finally, load the template.
1344
-	if (!isset($_REQUEST['xml']))
1345
-		loadTemplate('Post');
1401
+	if (!isset($_REQUEST['xml'])) {
1402
+			loadTemplate('Post');
1403
+	}
1346 1404
 
1347 1405
 	call_integration_hook('integrate_post_end');
1348 1406
 }
@@ -1363,13 +1421,14 @@  discard block
 block discarded – undo
1363 1421
 	// Sneaking off, are we?
1364 1422
 	if (empty($_POST) && empty($topic))
1365 1423
 	{
1366
-		if (empty($_SERVER['CONTENT_LENGTH']))
1367
-			redirectexit('action=post;board=' . $board . '.0');
1368
-		else
1369
-			fatal_lang_error('post_upload_error', false);
1424
+		if (empty($_SERVER['CONTENT_LENGTH'])) {
1425
+					redirectexit('action=post;board=' . $board . '.0');
1426
+		} else {
1427
+					fatal_lang_error('post_upload_error', false);
1428
+		}
1429
+	} elseif (empty($_POST) && !empty($topic)) {
1430
+			redirectexit('action=post;topic=' . $topic . '.0');
1370 1431
 	}
1371
-	elseif (empty($_POST) && !empty($topic))
1372
-		redirectexit('action=post;topic=' . $topic . '.0');
1373 1432
 
1374 1433
 	// No need!
1375 1434
 	$context['robot_no_index'] = true;
@@ -1381,8 +1440,9 @@  discard block
 block discarded – undo
1381 1440
 	$post_errors = array();
1382 1441
 
1383 1442
 	// If the session has timed out, let the user re-submit their form.
1384
-	if (checkSession('post', '', false) != '')
1385
-		$post_errors[] = 'session_timeout';
1443
+	if (checkSession('post', '', false) != '') {
1444
+			$post_errors[] = 'session_timeout';
1445
+	}
1386 1446
 
1387 1447
 	// Wrong verification code?
1388 1448
 	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 +1452,38 @@  discard block
 block discarded – undo
1392 1452
 			'id' => 'post',
1393 1453
 		);
1394 1454
 		$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']);
1455
+		if (is_array($context['require_verification'])) {
1456
+					$post_errors = array_merge($post_errors, $context['require_verification']);
1457
+		}
1397 1458
 	}
1398 1459
 
1399 1460
 	require_once($sourcedir . '/Subs-Post.php');
1400 1461
 	loadLanguage('Post');
1401 1462
 
1402 1463
 	// 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');
1464
+	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) {
1465
+			require_once($sourcedir . '/Drafts.php');
1466
+	}
1405 1467
 
1406 1468
 	// First check to see if they are trying to delete any current attachments.
1407 1469
 	if (isset($_POST['attach_del']))
1408 1470
 	{
1409 1471
 		$keep_temp = array();
1410 1472
 		$keep_ids = array();
1411
-		foreach ($_POST['attach_del'] as $dummy)
1412
-			if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1473
+		foreach ($_POST['attach_del'] as $dummy) {
1474
+					if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1413 1475
 				$keep_temp[] = $dummy;
1414
-			else
1415
-				$keep_ids[] = (int) $dummy;
1476
+		}
1477
+			else {
1478
+							$keep_ids[] = (int) $dummy;
1479
+			}
1416 1480
 
1417
-		if (isset($_SESSION['temp_attachments']))
1418
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1481
+		if (isset($_SESSION['temp_attachments'])) {
1482
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1419 1483
 			{
1420 1484
 				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 1485
 					continue;
1486
+		}
1422 1487
 
1423 1488
 				unset($_SESSION['temp_attachments'][$attachID]);
1424 1489
 				unlink($attachment['tmp_name']);
@@ -1460,24 +1525,28 @@  discard block
 block discarded – undo
1460 1525
 		$smcFunc['db_free_result']($request);
1461 1526
 
1462 1527
 		// Though the topic should be there, it might have vanished.
1463
-		if (!is_array($topic_info))
1464
-			fatal_lang_error('topic_doesnt_exist', 404);
1528
+		if (!is_array($topic_info)) {
1529
+					fatal_lang_error('topic_doesnt_exist', 404);
1530
+		}
1465 1531
 
1466 1532
 		// Did this topic suddenly move? Just checking...
1467
-		if ($topic_info['id_board'] != $board)
1468
-			fatal_lang_error('not_a_topic');
1533
+		if ($topic_info['id_board'] != $board) {
1534
+					fatal_lang_error('not_a_topic');
1535
+		}
1469 1536
 	}
1470 1537
 
1471 1538
 	// Replying to a topic?
1472 1539
 	if (!empty($topic) && !isset($_REQUEST['msg']))
1473 1540
 	{
1474 1541
 		// Don't allow a post if it's locked.
1475
-		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board'))
1476
-			fatal_lang_error('topic_locked', false);
1542
+		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) {
1543
+					fatal_lang_error('topic_locked', false);
1544
+		}
1477 1545
 
1478 1546
 		// Sorry, multiple polls aren't allowed... yet.  You should stop giving me ideas :P.
1479
-		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0)
1480
-			unset($_REQUEST['poll']);
1547
+		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) {
1548
+					unset($_REQUEST['poll']);
1549
+		}
1481 1550
 
1482 1551
 		// Do the permissions and approval stuff...
1483 1552
 		$becomesApproved = true;
@@ -1493,44 +1562,43 @@  discard block
 block discarded – undo
1493 1562
 
1494 1563
 			// Set a nice session var...
1495 1564
 			$_SESSION['becomesUnapproved'] = true;
1496
-		}
1497
-
1498
-		elseif ($topic_info['id_member_started'] != $user_info['id'])
1565
+		} elseif ($topic_info['id_member_started'] != $user_info['id'])
1499 1566
 		{
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'))
1567
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
1568
+							$becomesApproved = false;
1569
+			} else {
1570
+							isAllowedTo('post_reply_any');
1571
+			}
1572
+		} elseif (!allowedTo('post_reply_any'))
1507 1573
 		{
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');
1574
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) {
1575
+							$becomesApproved = false;
1576
+			} else {
1577
+							isAllowedTo('post_reply_own');
1578
+			}
1513 1579
 		}
1514 1580
 
1515 1581
 		if (isset($_POST['lock']))
1516 1582
 		{
1517 1583
 			// 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']);
1584
+			if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1585
+							unset($_POST['lock']);
1586
+			}
1520 1587
 
1521 1588
 			// 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']);
1589
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1590
+							unset($_POST['lock']);
1591
+			}
1524 1592
 
1525 1593
 			// You are allowed to (un)lock your own topic only.
1526 1594
 			elseif (!allowedTo('lock_any'))
1527 1595
 			{
1528 1596
 				// 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;
1597
+				if ($topic_info['locked'] == 1) {
1598
+									unset($_POST['lock']);
1599
+				} else {
1600
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1601
+				}
1534 1602
 			}
1535 1603
 			// Hail mighty moderator, (un)lock this topic immediately.
1536 1604
 			else
@@ -1538,19 +1606,21 @@  discard block
 block discarded – undo
1538 1606
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1539 1607
 
1540 1608
 				// 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';
1609
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1610
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1611
+				}
1543 1612
 			}
1544 1613
 		}
1545 1614
 
1546 1615
 		// 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']))
1616
+		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) {
1617
+					unset($_POST['sticky']);
1618
+		} elseif (isset($_POST['sticky']))
1550 1619
 		{
1551 1620
 			// 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';
1621
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1622
+							$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1623
+			}
1554 1624
 		}
1555 1625
 
1556 1626
 		// If drafts are enabled, then pass this off
@@ -1577,26 +1647,31 @@  discard block
 block discarded – undo
1577 1647
 
1578 1648
 		// Do like, the permissions, for safety and stuff...
1579 1649
 		$becomesApproved = true;
1580
-		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
1581
-			$becomesApproved = false;
1582
-		else
1583
-			isAllowedTo('post_new');
1650
+		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) {
1651
+					$becomesApproved = false;
1652
+		} else {
1653
+					isAllowedTo('post_new');
1654
+		}
1584 1655
 
1585 1656
 		if (isset($_POST['lock']))
1586 1657
 		{
1587 1658
 			// New topics are by default not locked.
1588
-			if (empty($_POST['lock']))
1589
-				unset($_POST['lock']);
1659
+			if (empty($_POST['lock'])) {
1660
+							unset($_POST['lock']);
1661
+			}
1590 1662
 			// Besides, you need permission.
1591
-			elseif (!allowedTo(array('lock_any', 'lock_own')))
1592
-				unset($_POST['lock']);
1663
+			elseif (!allowedTo(array('lock_any', 'lock_own'))) {
1664
+							unset($_POST['lock']);
1665
+			}
1593 1666
 			// A moderator-lock (1) can override a user-lock (2).
1594
-			else
1595
-				$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1667
+			else {
1668
+							$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1669
+			}
1596 1670
 		}
1597 1671
 
1598
-		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky')))
1599
-			unset($_POST['sticky']);
1672
+		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) {
1673
+					unset($_POST['sticky']);
1674
+		}
1600 1675
 
1601 1676
 		// Saving your new topic as a draft first?
1602 1677
 		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
@@ -1621,31 +1696,37 @@  discard block
 block discarded – undo
1621 1696
 				'id_msg' => $_REQUEST['msg'],
1622 1697
 			)
1623 1698
 		);
1624
-		if ($smcFunc['db_num_rows']($request) == 0)
1625
-			fatal_lang_error('cant_find_messages', false);
1699
+		if ($smcFunc['db_num_rows']($request) == 0) {
1700
+					fatal_lang_error('cant_find_messages', false);
1701
+		}
1626 1702
 		$row = $smcFunc['db_fetch_assoc']($request);
1627 1703
 		$smcFunc['db_free_result']($request);
1628 1704
 
1629
-		if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
1630
-			fatal_lang_error('topic_locked', false);
1705
+		if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) {
1706
+					fatal_lang_error('topic_locked', false);
1707
+		}
1631 1708
 
1632 1709
 		if (isset($_POST['lock']))
1633 1710
 		{
1634 1711
 			// 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']);
1712
+			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1713
+							unset($_POST['lock']);
1714
+			}
1637 1715
 			// 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']);
1716
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1717
+							unset($_POST['lock']);
1718
+			}
1640 1719
 			// You're only allowed to lock your own topics.
1641 1720
 			elseif (!allowedTo('lock_any'))
1642 1721
 			{
1643 1722
 				// You're not allowed to break a moderator's lock.
1644
-				if ($topic_info['locked'] == 1)
1645
-					unset($_POST['lock']);
1723
+				if ($topic_info['locked'] == 1) {
1724
+									unset($_POST['lock']);
1725
+				}
1646 1726
 				// Lock it with a soft lock or unlock it.
1647
-				else
1648
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1727
+				else {
1728
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1729
+				}
1649 1730
 			}
1650 1731
 			// You must be the moderator.
1651 1732
 			else
@@ -1653,44 +1734,46 @@  discard block
 block discarded – undo
1653 1734
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1654 1735
 
1655 1736
 				// 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';
1737
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1738
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1739
+				}
1658 1740
 			}
1659 1741
 		}
1660 1742
 
1661 1743
 		// 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']))
1744
+		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) {
1745
+					unset($_POST['sticky']);
1746
+		} elseif (isset($_POST['sticky']))
1665 1747
 		{
1666 1748
 			// 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';
1749
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1750
+							$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1751
+			}
1669 1752
 		}
1670 1753
 
1671 1754
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
1672 1755
 		{
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'))
1756
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
1757
+							fatal_lang_error('modify_post_time_passed', false);
1758
+			} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
1759
+							isAllowedTo('modify_replies');
1760
+			} else {
1761
+							isAllowedTo('modify_own');
1762
+			}
1763
+		} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1681 1764
 		{
1682 1765
 			isAllowedTo('modify_replies');
1683 1766
 
1684 1767
 			// If you're modifying a reply, I say it better be logged...
1685 1768
 			$moderationAction = true;
1686
-		}
1687
-		else
1769
+		} else
1688 1770
 		{
1689 1771
 			isAllowedTo('modify_any');
1690 1772
 
1691 1773
 			// Log it, assuming you're not modifying your own post.
1692
-			if ($row['id_member'] != $user_info['id'])
1693
-				$moderationAction = true;
1774
+			if ($row['id_member'] != $user_info['id']) {
1775
+							$moderationAction = true;
1776
+			}
1694 1777
 		}
1695 1778
 
1696 1779
 		// If drafts are enabled, then lets send this off to save
@@ -1727,20 +1810,24 @@  discard block
 block discarded – undo
1727 1810
 		$_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']);
1728 1811
 		$_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
1729 1812
 
1730
-		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_')
1731
-			$post_errors[] = 'no_name';
1732
-		if ($smcFunc['strlen']($_POST['guestname']) > 25)
1733
-			$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
+		}
1734 1819
 
1735 1820
 		if (empty($modSettings['guest_post_no_email']))
1736 1821
 		{
1737 1822
 			// Only check if they changed it!
1738 1823
 			if (!isset($row) || $row['poster_email'] != $_POST['email'])
1739 1824
 			{
1740
-				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == ''))
1741
-					$post_errors[] = 'no_email';
1742
-				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
1743
-					$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
+				}
1744 1831
 			}
1745 1832
 
1746 1833
 			// Now make sure this email address is not banned from posting.
@@ -1756,75 +1843,89 @@  discard block
 block discarded – undo
1756 1843
 	}
1757 1844
 
1758 1845
 	// Coming from the quickReply?
1759
-	if (isset($_POST['quickReply']))
1760
-		$_POST['message'] = $_POST['quickReply'];
1846
+	if (isset($_POST['quickReply'])) {
1847
+			$_POST['message'] = $_POST['quickReply'];
1848
+	}
1761 1849
 
1762 1850
 	// Check the subject and message.
1763
-	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '')
1764
-		$post_errors[] = 'no_subject';
1765
-	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '')
1766
-		$post_errors[] = 'no_message';
1767
-	elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
1768
-		$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1769
-	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
1770 1859
 	{
1771 1860
 		// Prepare the message a bit for some additional testing.
1772 1861
 		$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
1773 1862
 
1774 1863
 		// Preparse code. (Zef)
1775
-		if ($user_info['is_guest'])
1776
-			$user_info['name'] = $_POST['guestname'];
1864
+		if ($user_info['is_guest']) {
1865
+					$user_info['name'] = $_POST['guestname'];
1866
+		}
1777 1867
 		preparsecode($_POST['message']);
1778 1868
 
1779 1869
 		// Let's see if there's still some content left without the tags.
1780
-		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
1781
-			$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';
1782 1876
 	}
1783
-	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '')
1784
-		$post_errors[] = 'no_event';
1785 1877
 	// You are not!
1786
-	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin'])
1787
-		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
+	}
1788 1881
 
1789 1882
 	// Validate the poll...
1790 1883
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
1791 1884
 	{
1792
-		if (!empty($topic) && !isset($_REQUEST['msg']))
1793
-			fatal_lang_error('no_access', false);
1885
+		if (!empty($topic) && !isset($_REQUEST['msg'])) {
1886
+					fatal_lang_error('no_access', false);
1887
+		}
1794 1888
 
1795 1889
 		// This is a new topic... so it's a new poll.
1796
-		if (empty($topic))
1797
-			isAllowedTo('poll_post');
1890
+		if (empty($topic)) {
1891
+					isAllowedTo('poll_post');
1892
+		}
1798 1893
 		// Can you add to your own topics?
1799
-		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any'))
1800
-			isAllowedTo('poll_add_own');
1894
+		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) {
1895
+					isAllowedTo('poll_add_own');
1896
+		}
1801 1897
 		// Can you add polls to any topic, then?
1802
-		else
1803
-			isAllowedTo('poll_add_any');
1898
+		else {
1899
+					isAllowedTo('poll_add_any');
1900
+		}
1804 1901
 
1805
-		if (!isset($_POST['question']) || trim($_POST['question']) == '')
1806
-			$post_errors[] = 'no_question';
1902
+		if (!isset($_POST['question']) || trim($_POST['question']) == '') {
1903
+					$post_errors[] = 'no_question';
1904
+		}
1807 1905
 
1808 1906
 		$_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']);
1809 1907
 
1810 1908
 		// Get rid of empty ones.
1811
-		foreach ($_POST['options'] as $k => $option)
1812
-			if ($option == '')
1909
+		foreach ($_POST['options'] as $k => $option) {
1910
+					if ($option == '')
1813 1911
 				unset($_POST['options'][$k], $_POST['options'][$k]);
1912
+		}
1814 1913
 
1815 1914
 		// What are you going to vote between with one choice?!?
1816
-		if (count($_POST['options']) < 2)
1817
-			$post_errors[] = 'poll_few';
1818
-		elseif (count($_POST['options']) > 256)
1819
-			$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
+		}
1820 1920
 	}
1821 1921
 
1822 1922
 	if ($posterIsGuest)
1823 1923
 	{
1824 1924
 		// If user is a guest, make sure the chosen name isn't taken.
1825 1925
 		require_once($sourcedir . '/Subs-Members.php');
1826
-		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name']))
1827
-			$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
+		}
1828 1929
 	}
1829 1930
 	// If the user isn't a guest, get his or her name and email.
1830 1931
 	elseif (!isset($_REQUEST['msg']))
@@ -1855,8 +1956,9 @@  discard block
 block discarded – undo
1855 1956
 	}
1856 1957
 
1857 1958
 	// Make sure the user isn't spamming the board.
1858
-	if (!isset($_REQUEST['msg']))
1859
-		spamProtection('post');
1959
+	if (!isset($_REQUEST['msg'])) {
1960
+			spamProtection('post');
1961
+	}
1860 1962
 
1861 1963
 	// At about this point, we're posting and that's that.
1862 1964
 	ignore_user_abort(true);
@@ -1869,32 +1971,36 @@  discard block
 block discarded – undo
1869 1971
 	$_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
1870 1972
 
1871 1973
 	// At this point, we want to make sure the subject isn't too long.
1872
-	if ($smcFunc['strlen']($_POST['subject']) > 100)
1873
-		$_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
+	}
1874 1977
 
1875 1978
 	// Same with the "why did you edit this" text.
1876
-	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
1877
-		$_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
+	}
1878 1982
 
1879 1983
 	// Make the poll...
1880 1984
 	if (isset($_REQUEST['poll']))
1881 1985
 	{
1882 1986
 		// Make sure that the user has not entered a ridiculous number of options..
1883
-		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
1884
-			$_POST['poll_max_votes'] = 1;
1885
-		elseif ($_POST['poll_max_votes'] > count($_POST['options']))
1886
-			$_POST['poll_max_votes'] = count($_POST['options']);
1887
-		else
1888
-			$_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
+		}
1889 1994
 
1890 1995
 		$_POST['poll_expire'] = (int) $_POST['poll_expire'];
1891 1996
 		$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
1892 1997
 
1893 1998
 		// Just set it to zero if it's not there..
1894
-		if (!isset($_POST['poll_hide']))
1895
-			$_POST['poll_hide'] = 0;
1896
-		else
1897
-			$_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
+		}
1898 2004
 		$_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0;
1899 2005
 
1900 2006
 		$_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0;
@@ -1903,16 +2009,19 @@  discard block
 block discarded – undo
1903 2009
 		{
1904 2010
 			require_once($sourcedir . '/Subs-Members.php');
1905 2011
 			$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
1906
-			if (!in_array(-1, $allowedVoteGroups['allowed']))
1907
-				$_POST['poll_guest_vote'] = 0;
2012
+			if (!in_array(-1, $allowedVoteGroups['allowed'])) {
2013
+							$_POST['poll_guest_vote'] = 0;
2014
+			}
1908 2015
 		}
1909 2016
 
1910 2017
 		// If the user tries to set the poll too far in advance, don't let them.
1911
-		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1)
1912
-			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
+		}
1913 2021
 		// Don't allow them to select option 2 for hidden results if it's not time limited.
1914
-		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
1915
-			$_POST['poll_hide'] = 1;
2022
+		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
2023
+					$_POST['poll_hide'] = 1;
2024
+		}
1916 2025
 
1917 2026
 		// Clean up the question and answers.
1918 2027
 		$_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']);
@@ -1926,13 +2035,15 @@  discard block
 block discarded – undo
1926 2035
 	{
1927 2036
 		$attachIDs = array();
1928 2037
 		$attach_errors = array();
1929
-		if (!empty($context['we_are_history']))
1930
-			$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
+		}
1931 2041
 
1932 2042
 		foreach ($_SESSION['temp_attachments'] as  $attachID => $attachment)
1933 2043
 		{
1934
-			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1935
-				continue;
2044
+			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
2045
+							continue;
2046
+			}
1936 2047
 
1937 2048
 			// If there was an initial error just show that message.
1938 2049
 			if ($attachID == 'initial_error')
@@ -1961,12 +2072,13 @@  discard block
 block discarded – undo
1961 2072
 				if (createAttachment($attachmentOptions))
1962 2073
 				{
1963 2074
 					$attachIDs[] = $attachmentOptions['id'];
1964
-					if (!empty($attachmentOptions['thumb']))
1965
-						$attachIDs[] = $attachmentOptions['thumb'];
2075
+					if (!empty($attachmentOptions['thumb'])) {
2076
+											$attachIDs[] = $attachmentOptions['thumb'];
2077
+					}
1966 2078
 				}
2079
+			} else {
2080
+							$attach_errors[] = '<dt>&nbsp;</dt>';
1967 2081
 			}
1968
-			else
1969
-				$attach_errors[] = '<dt>&nbsp;</dt>';
1970 2082
 
1971 2083
 			if (!empty($attachmentOptions['errors']))
1972 2084
 			{
@@ -1978,14 +2090,16 @@  discard block
 block discarded – undo
1978 2090
 					if (!is_array($error))
1979 2091
 					{
1980 2092
 						$attach_errors[] = '<dd>' . $txt[$error] . '</dd>';
1981
-						if (in_array($error, $log_these))
1982
-							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>';
1983 2098
 					}
1984
-					else
1985
-						$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
1986 2099
 				}
1987
-				if (file_exists($attachment['tmp_name']))
1988
-					unlink($attachment['tmp_name']);
2100
+				if (file_exists($attachment['tmp_name'])) {
2101
+									unlink($attachment['tmp_name']);
2102
+				}
1989 2103
 			}
1990 2104
 		}
1991 2105
 		unset($_SESSION['temp_attachments']);
@@ -2026,24 +2140,24 @@  discard block
 block discarded – undo
2026 2140
 		);
2027 2141
 
2028 2142
 		call_integration_hook('integrate_poll_add_edit', array($id_poll, false));
2143
+	} else {
2144
+			$id_poll = 0;
2029 2145
 	}
2030
-	else
2031
-		$id_poll = 0;
2032 2146
 
2033 2147
 	// Creating a new topic?
2034 2148
 	$newTopic = empty($_REQUEST['msg']) && empty($topic);
2035 2149
 
2036 2150
 	// Check the icon.
2037
-	if (!isset($_POST['icon']))
2038
-		$_POST['icon'] = 'xx';
2039
-
2040
-	else
2151
+	if (!isset($_POST['icon'])) {
2152
+			$_POST['icon'] = 'xx';
2153
+	} else
2041 2154
 	{
2042 2155
 		$_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']);
2043 2156
 
2044 2157
 		// Need to figure it out if this is a valid icon name.
2045
-		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')))
2046
-			$_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
+		}
2047 2161
 	}
2048 2162
 
2049 2163
 	// Collect all parameters for the creation or modification of a post.
@@ -2084,8 +2198,9 @@  discard block
 block discarded – undo
2084 2198
 		}
2085 2199
 
2086 2200
 		// This will save some time...
2087
-		if (empty($approve_has_changed))
2088
-			unset($msgOptions['approved']);
2201
+		if (empty($approve_has_changed)) {
2202
+					unset($msgOptions['approved']);
2203
+		}
2089 2204
 
2090 2205
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2091 2206
 	}
@@ -2094,8 +2209,9 @@  discard block
 block discarded – undo
2094 2209
 	{
2095 2210
 		createPost($msgOptions, $topicOptions, $posterOptions);
2096 2211
 
2097
-		if (isset($topicOptions['id']))
2098
-			$topic = $topicOptions['id'];
2212
+		if (isset($topicOptions['id'])) {
2213
+					$topic = $topicOptions['id'];
2214
+		}
2099 2215
 	}
2100 2216
 
2101 2217
 	// Assign the previously uploaded attachments to the brand new message.
@@ -2107,8 +2223,9 @@  discard block
 block discarded – undo
2107 2223
 	}
2108 2224
 
2109 2225
 	// If we had a draft for this, its time to remove it since it was just posted
2110
-	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft']))
2111
-		DeleteDraft($_POST['id_draft']);
2226
+	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) {
2227
+			DeleteDraft($_POST['id_draft']);
2228
+	}
2112 2229
 
2113 2230
 	// Editing or posting an event?
2114 2231
 	if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1))
@@ -2127,8 +2244,7 @@  discard block
 block discarded – undo
2127 2244
 			'member' => $user_info['id'],
2128 2245
 		);
2129 2246
 		insertEvent($eventOptions);
2130
-	}
2131
-	elseif (isset($_POST['calendar']))
2247
+	} elseif (isset($_POST['calendar']))
2132 2248
 	{
2133 2249
 		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
2134 2250
 
@@ -2156,14 +2272,15 @@  discard block
 block discarded – undo
2156 2272
 		}
2157 2273
 
2158 2274
 		// Delete it?
2159
-		if (isset($_REQUEST['deleteevent']))
2160
-			$smcFunc['db_query']('', '
2275
+		if (isset($_REQUEST['deleteevent'])) {
2276
+					$smcFunc['db_query']('', '
2161 2277
 				DELETE FROM {db_prefix}calendar
2162 2278
 				WHERE id_event = {int:id_event}',
2163 2279
 				array(
2164 2280
 					'id_event' => $_REQUEST['eventid'],
2165 2281
 				)
2166 2282
 			);
2283
+		}
2167 2284
 		// ... or just update it?
2168 2285
 		else
2169 2286
 		{
@@ -2205,9 +2322,8 @@  discard block
 block discarded – undo
2205 2322
 			array($user_info['id'], $topic, 0),
2206 2323
 			array('id_member', 'id_topic', 'id_board')
2207 2324
 		);
2208
-	}
2209
-	elseif (!$newTopic)
2210
-		$smcFunc['db_query']('', '
2325
+	} elseif (!$newTopic) {
2326
+			$smcFunc['db_query']('', '
2211 2327
 			DELETE FROM {db_prefix}log_notify
2212 2328
 			WHERE id_member = {int:current_member}
2213 2329
 				AND id_topic = {int:current_topic}',
@@ -2216,16 +2332,20 @@  discard block
 block discarded – undo
2216 2332
 				'current_topic' => $topic,
2217 2333
 			)
2218 2334
 		);
2335
+	}
2219 2336
 
2220 2337
 	// Log an act of moderation - modifying.
2221
-	if (!empty($moderationAction))
2222
-		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
+	}
2223 2341
 
2224
-	if (isset($_POST['lock']) && $_POST['lock'] != 2)
2225
-		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
+	}
2226 2345
 
2227
-	if (isset($_POST['sticky']))
2228
-		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
+	}
2229 2349
 
2230 2350
 	// Returning to the topic?
2231 2351
 	if (!empty($_REQUEST['goback']))
@@ -2244,26 +2364,31 @@  discard block
 block discarded – undo
2244 2364
 		);
2245 2365
 	}
2246 2366
 
2247
-	if ($board_info['num_topics'] == 0)
2248
-		cache_put_data('board-' . $board, null, 120);
2367
+	if ($board_info['num_topics'] == 0) {
2368
+			cache_put_data('board-' . $board, null, 120);
2369
+	}
2249 2370
 
2250 2371
 	call_integration_hook('integrate_post2_end');
2251 2372
 
2252
-	if (!empty($_POST['announce_topic']))
2253
-		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
+	}
2254 2376
 
2255
-	if (!empty($_POST['move']) && allowedTo('move_any'))
2256
-		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
+	}
2257 2380
 
2258 2381
 	// Return to post if the mod is on.
2259
-	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback']))
2260
-		redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2261
-	elseif (!empty($_REQUEST['goback']))
2262
-		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
+	}
2263 2387
 	// Dut-dut-duh-duh-DUH-duh-dut-duh-duh!  *dances to the Final Fantasy Fanfare...*
2264
-	else
2265
-		redirectexit('board=' . $board . '.0');
2266
-}
2388
+	else {
2389
+			redirectexit('board=' . $board . '.0');
2390
+	}
2391
+	}
2267 2392
 
2268 2393
 /**
2269 2394
  * Handle the announce topic function (action=announce).
@@ -2281,8 +2406,9 @@  discard block
 block discarded – undo
2281 2406
 
2282 2407
 	validateSession();
2283 2408
 
2284
-	if (empty($topic))
2285
-		fatal_lang_error('topic_gone', false);
2409
+	if (empty($topic)) {
2410
+			fatal_lang_error('topic_gone', false);
2411
+	}
2286 2412
 
2287 2413
 	loadLanguage('Post');
2288 2414
 	loadTemplate('Post');
@@ -2309,8 +2435,9 @@  discard block
 block discarded – undo
2309 2435
 	global $txt, $context, $topic, $board_info, $smcFunc;
2310 2436
 
2311 2437
 	$groups = array_merge($board_info['groups'], array(1));
2312
-	foreach ($groups as $id => $group)
2313
-		$groups[$id] = (int) $group;
2438
+	foreach ($groups as $id => $group) {
2439
+			$groups[$id] = (int) $group;
2440
+	}
2314 2441
 
2315 2442
 	$context['groups'] = array();
2316 2443
 	if (in_array(0, $groups))
@@ -2353,8 +2480,9 @@  discard block
 block discarded – undo
2353 2480
 			'group_list' => $groups,
2354 2481
 		)
2355 2482
 	);
2356
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2357
-		$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
+	}
2358 2486
 	$smcFunc['db_free_result']($request);
2359 2487
 
2360 2488
 	// Get the subject of the topic we're about to announce.
@@ -2396,16 +2524,19 @@  discard block
 block discarded – undo
2396 2524
 	$context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
2397 2525
 	$groups = array_merge($board_info['groups'], array(1));
2398 2526
 
2399
-	if (isset($_POST['membergroups']))
2400
-		$_POST['who'] = explode(',', $_POST['membergroups']);
2527
+	if (isset($_POST['membergroups'])) {
2528
+			$_POST['who'] = explode(',', $_POST['membergroups']);
2529
+	}
2401 2530
 
2402 2531
 	// Check whether at least one membergroup was selected.
2403
-	if (empty($_POST['who']))
2404
-		fatal_lang_error('no_membergroup_selected');
2532
+	if (empty($_POST['who'])) {
2533
+			fatal_lang_error('no_membergroup_selected');
2534
+	}
2405 2535
 
2406 2536
 	// Make sure all membergroups are integers and can access the board of the announcement.
2407
-	foreach ($_POST['who'] as $id => $mg)
2408
-		$_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
+	}
2409 2540
 
2410 2541
 	// Get the topic subject and censor it.
2411 2542
 	$request = $smcFunc['db_query']('', '
@@ -2451,12 +2582,13 @@  discard block
 block discarded – undo
2451 2582
 	if ($smcFunc['db_num_rows']($request) == 0)
2452 2583
 	{
2453 2584
 		logAction('announce_topic', array('topic' => $topic), 'user');
2454
-		if (!empty($_REQUEST['move']) && allowedTo('move_any'))
2455
-			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2456
-		elseif (!empty($_REQUEST['goback']))
2457
-			redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2458
-		else
2459
-			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
+		}
2460 2592
 	}
2461 2593
 
2462 2594
 	$announcements = array();
@@ -2475,8 +2607,9 @@  discard block
 block discarded – undo
2475 2607
 	foreach ($rows as $row)
2476 2608
 	{
2477 2609
 		// Force them to have it?
2478
-		if (empty($prefs[$row['id_member']]['announcements']))
2479
-			continue;
2610
+		if (empty($prefs[$row['id_member']]['announcements'])) {
2611
+					continue;
2612
+		}
2480 2613
 
2481 2614
 		$cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
2482 2615
 
@@ -2504,8 +2637,9 @@  discard block
 block discarded – undo
2504 2637
 	}
2505 2638
 
2506 2639
 	// For each language send a different mail - low priority...
2507
-	foreach ($announcements as $lang => $mail)
2508
-		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
+	}
2509 2643
 
2510 2644
 	$context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1);
2511 2645
 
@@ -2515,9 +2649,10 @@  discard block
 block discarded – undo
2515 2649
 	$context['sub_template'] = 'announcement_send';
2516 2650
 
2517 2651
 	// Go back to the correct language for the user ;).
2518
-	if (!empty($modSettings['userLanguage']))
2519
-		loadLanguage('Post');
2520
-}
2652
+	if (!empty($modSettings['userLanguage'])) {
2653
+			loadLanguage('Post');
2654
+	}
2655
+	}
2521 2656
 
2522 2657
 /**
2523 2658
  * Get the topic for display purposes.
@@ -2530,12 +2665,13 @@  discard block
 block discarded – undo
2530 2665
 {
2531 2666
 	global $topic, $modSettings, $context, $smcFunc, $counter, $options;
2532 2667
 
2533
-	if (isset($_REQUEST['xml']))
2534
-		$limit = '
2668
+	if (isset($_REQUEST['xml'])) {
2669
+			$limit = '
2535 2670
 		LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']);
2536
-	else
2537
-		$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2671
+	} else {
2672
+			$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2538 2673
 		LIMIT ' . (int) $modSettings['topicSummaryPosts'];
2674
+	}
2539 2675
 
2540 2676
 	// If you're modifying, get only those posts before the current one. (otherwise get all.)
2541 2677
 	$request = $smcFunc['db_query']('', '
@@ -2573,8 +2709,9 @@  discard block
 block discarded – undo
2573 2709
 			'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']),
2574 2710
 		);
2575 2711
 
2576
-		if (!empty($context['new_replies']))
2577
-			$context['new_replies']--;
2712
+		if (!empty($context['new_replies'])) {
2713
+					$context['new_replies']--;
2714
+		}
2578 2715
 	}
2579 2716
 	$smcFunc['db_free_result']($request);
2580 2717
 }
@@ -2591,8 +2728,9 @@  discard block
 block discarded – undo
2591 2728
 	global $sourcedir, $smcFunc;
2592 2729
 
2593 2730
 	loadLanguage('Post');
2594
-	if (!isset($_REQUEST['xml']))
2595
-		loadTemplate('Post');
2731
+	if (!isset($_REQUEST['xml'])) {
2732
+			loadTemplate('Post');
2733
+	}
2596 2734
 
2597 2735
 	include_once($sourcedir . '/Subs-Post.php');
2598 2736
 
@@ -2623,8 +2761,9 @@  discard block
 block discarded – undo
2623 2761
 	$smcFunc['db_free_result']($request);
2624 2762
 
2625 2763
 	$context['sub_template'] = 'quotefast';
2626
-	if (!empty($row))
2627
-		$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
+	}
2628 2767
 
2629 2768
 	if (!empty($can_view_post))
2630 2769
 	{
@@ -2657,8 +2796,9 @@  discard block
 block discarded – undo
2657 2796
 		}
2658 2797
 
2659 2798
 		// Remove any nested quotes.
2660
-		if (!empty($modSettings['removeNestedQuotes']))
2661
-			$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
+		}
2662 2802
 
2663 2803
 		$lb = "\n";
2664 2804
 
@@ -2684,14 +2824,14 @@  discard block
 block discarded – undo
2684 2824
 				'time' => '',
2685 2825
 			),
2686 2826
 		);
2687
-	}
2688
-	else
2689
-		$context['quote'] = array(
2827
+	} else {
2828
+			$context['quote'] = array(
2690 2829
 			'xml' => '',
2691 2830
 			'mozilla' => '',
2692 2831
 			'text' => '',
2693 2832
 		);
2694
-}
2833
+	}
2834
+	}
2695 2835
 
2696 2836
 /**
2697 2837
  * Used to edit the body or subject of a message inline
@@ -2703,8 +2843,9 @@  discard block
 block discarded – undo
2703 2843
 	global $user_info, $context, $smcFunc, $language, $board_info;
2704 2844
 
2705 2845
 	// We have to have a topic!
2706
-	if (empty($topic))
2707
-		obExit(false);
2846
+	if (empty($topic)) {
2847
+			obExit(false);
2848
+	}
2708 2849
 
2709 2850
 	checkSession('get');
2710 2851
 	require_once($sourcedir . '/Subs-Post.php');
@@ -2730,31 +2871,35 @@  discard block
 block discarded – undo
2730 2871
 			'guest_id' => 0,
2731 2872
 		)
2732 2873
 	);
2733
-	if ($smcFunc['db_num_rows']($request) == 0)
2734
-		fatal_lang_error('no_board', false);
2874
+	if ($smcFunc['db_num_rows']($request) == 0) {
2875
+			fatal_lang_error('no_board', false);
2876
+	}
2735 2877
 	$row = $smcFunc['db_fetch_assoc']($request);
2736 2878
 	$smcFunc['db_free_result']($request);
2737 2879
 
2738 2880
 	// Change either body or subject requires permissions to modify messages.
2739 2881
 	if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon']))
2740 2882
 	{
2741
-		if (!empty($row['locked']))
2742
-			isAllowedTo('moderate_board');
2883
+		if (!empty($row['locked'])) {
2884
+					isAllowedTo('moderate_board');
2885
+		}
2743 2886
 
2744 2887
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
2745 2888
 		{
2746
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
2747
-				fatal_lang_error('modify_post_time_passed', false);
2748
-			elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
2749
-				isAllowedTo('modify_replies');
2750
-			else
2751
-				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
+			}
2752 2896
 		}
2753 2897
 		// Otherwise, they're locked out; someone who can modify the replies is needed.
2754
-		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
2755
-			isAllowedTo('modify_replies');
2756
-		else
2757
-			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
+		}
2758 2903
 
2759 2904
 		// Only log this action if it wasn't your message.
2760 2905
 		$moderationAction = $row['id_member'] != $user_info['id'];
@@ -2766,10 +2911,10 @@  discard block
 block discarded – undo
2766 2911
 		$_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
2767 2912
 
2768 2913
 		// Maximum number of characters.
2769
-		if ($smcFunc['strlen']($_POST['subject']) > 100)
2770
-			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2771
-	}
2772
-	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']))
2773 2918
 	{
2774 2919
 		$post_errors[] = 'no_subject';
2775 2920
 		unset($_POST['subject']);
@@ -2781,13 +2926,11 @@  discard block
 block discarded – undo
2781 2926
 		{
2782 2927
 			$post_errors[] = 'no_message';
2783 2928
 			unset($_POST['message']);
2784
-		}
2785
-		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'])
2786 2930
 		{
2787 2931
 			$post_errors[] = 'long_message';
2788 2932
 			unset($_POST['message']);
2789
-		}
2790
-		else
2933
+		} else
2791 2934
 		{
2792 2935
 			$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
2793 2936
 
@@ -2803,31 +2946,34 @@  discard block
 block discarded – undo
2803 2946
 
2804 2947
 	if (isset($_POST['lock']))
2805 2948
 	{
2806
-		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member']))
2807
-			unset($_POST['lock']);
2808
-		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'))
2809 2952
 		{
2810
-			if ($row['locked'] == 1)
2811
-				unset($_POST['lock']);
2812
-			else
2813
-				$_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;
2814 2962
 		}
2815
-		elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked'])
2816
-			unset($_POST['lock']);
2817
-		else
2818
-			$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2819 2963
 	}
2820 2964
 
2821
-	if (isset($_POST['sticky']) && !allowedTo('make_sticky'))
2822
-		unset($_POST['sticky']);
2965
+	if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
2966
+			unset($_POST['sticky']);
2967
+	}
2823 2968
 
2824 2969
 	if (isset($_POST['modify_reason']))
2825 2970
 	{
2826 2971
 		$_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
2827 2972
 
2828 2973
 		// Maximum number of characters.
2829
-		if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
2830
-			$_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
+		}
2831 2977
 	}
2832 2978
 
2833 2979
 	if (empty($post_errors))
@@ -2864,8 +3010,9 @@  discard block
 block discarded – undo
2864 3010
 			}
2865 3011
 		}
2866 3012
 		// If nothing was changed there's no need to add an entry to the moderation log.
2867
-		else
2868
-			$moderationAction = false;
3013
+		else {
3014
+					$moderationAction = false;
3015
+		}
2869 3016
 
2870 3017
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2871 3018
 
@@ -2883,9 +3030,9 @@  discard block
 block discarded – undo
2883 3030
 			// Get the proper (default language) response prefix first.
2884 3031
 			if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
2885 3032
 			{
2886
-				if ($language === $user_info['language'])
2887
-					$context['response_prefix'] = $txt['response_prefix'];
2888
-				else
3033
+				if ($language === $user_info['language']) {
3034
+									$context['response_prefix'] = $txt['response_prefix'];
3035
+				} else
2889 3036
 				{
2890 3037
 					loadLanguage('index', $language, false);
2891 3038
 					$context['response_prefix'] = $txt['response_prefix'];
@@ -2907,8 +3054,9 @@  discard block
 block discarded – undo
2907 3054
 			);
2908 3055
 		}
2909 3056
 
2910
-		if (!empty($moderationAction))
2911
-			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
+		}
2912 3060
 	}
2913 3061
 
2914 3062
 	if (isset($_REQUEST['xml']))
@@ -2949,8 +3097,7 @@  discard block
 block discarded – undo
2949 3097
 			);
2950 3098
 
2951 3099
 			censorText($context['message']['subject']);
2952
-		}
2953
-		else
3100
+		} else
2954 3101
 		{
2955 3102
 			$context['message'] = array(
2956 3103
 				'id' => $row['id_msg'],
@@ -2962,15 +3109,16 @@  discard block
 block discarded – undo
2962 3109
 			loadLanguage('Errors');
2963 3110
 			foreach ($post_errors as $post_error)
2964 3111
 			{
2965
-				if ($post_error == 'long_message')
2966
-					$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
2967
-				else
2968
-					$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
+				}
2969 3117
 			}
2970 3118
 		}
3119
+	} else {
3120
+			obExit(false);
3121
+	}
2971 3122
 	}
2972
-	else
2973
-		obExit(false);
2974
-}
2975 3123
 
2976 3124
 ?>
2977 3125
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/ManageBoards.template.php 1 patch
Braces   +99 added lines, -68 removed lines patch added patch discarded remove patch
@@ -25,18 +25,20 @@  discard block
 block discarded – undo
25 25
 		</div>
26 26
 		<div class="windowbg2 noup">';
27 27
 
28
-	if (!empty($context['move_board']))
29
-		echo '
28
+	if (!empty($context['move_board'])) {
29
+			echo '
30 30
 		<div class="noticebox">
31 31
 			', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', '
32 32
 		</div>';
33
+	}
33 34
 
34 35
 	// No categories so show a label.
35
-	if (empty($context['categories']))
36
-		echo '
36
+	if (empty($context['categories'])) {
37
+			echo '
37 38
 		<div class="windowbg centertext">
38 39
 			', $txt['mboards_no_cats'], '
39 40
 		</div>';
41
+	}
40 42
 
41 43
 	// Loop through every category, listing the boards in each as we go.
42 44
 	foreach ($context['categories'] as $category)
@@ -54,9 +56,10 @@  discard block
 block discarded – undo
54 56
 		<form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '">
55 57
 				<ul id="category_', $category['id'], '" class="nolist">';
56 58
 
57
-		if (!empty($category['move_link']))
58
-			echo '
59
+		if (!empty($category['move_link'])) {
60
+					echo '
59 61
 					<li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>';
62
+		}
60 63
 
61 64
 		$recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>';
62 65
 		$redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">';
@@ -81,9 +84,10 @@  discard block
 block discarded – undo
81 84
 				echo '
82 85
 					<li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">';
83 86
 
84
-				foreach ($board['move_links'] as $link)
85
-					echo '
87
+				foreach ($board['move_links'] as $link) {
88
+									echo '
86 89
 						<a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>';
90
+				}
87 91
 
88 92
 				echo '
89 93
 					</li>';
@@ -132,9 +136,10 @@  discard block
 block discarded – undo
132 136
 						<select name="cat_order">';
133 137
 
134 138
 		// Print every existing category into a select box.
135
-		foreach ($context['category_order'] as $order)
136
-			echo '
139
+		foreach ($context['category_order'] as $order) {
140
+					echo '
137 141
 							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
142
+		}
138 143
 		echo '
139 144
 						</select>
140 145
 					</dd>';
@@ -169,14 +174,15 @@  discard block
 block discarded – undo
169 174
 	{
170 175
 		foreach ($context['custom_category_settings'] as $catset_id => $catset)
171 176
 		{
172
-			if (!empty($catset['dt']) && !empty($catset['dd']))
173
-				echo '
177
+			if (!empty($catset['dt']) && !empty($catset['dd'])) {
178
+							echo '
174 179
 						<dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '">
175 180
 							', $catset['dt'], '
176 181
 						</dt>
177 182
 						<dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '>
178 183
 							', $catset['dd'], '
179 184
 						</dd>';
185
+			}
180 186
 		}
181 187
 	}
182 188
 
@@ -184,21 +190,23 @@  discard block
 block discarded – undo
184 190
 	echo '
185 191
 				</dl>';
186 192
 
187
-	if (isset($context['category']['is_new']))
188
-		echo '
193
+	if (isset($context['category']['is_new'])) {
194
+			echo '
189 195
 					<input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit">';
190
-	else
191
-		echo '
196
+	} else {
197
+			echo '
192 198
 					<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit">
193 199
 					<input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button_submit you_sure">';
200
+	}
194 201
 	echo '
195 202
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
196 203
 					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
197 204
 
198 205
 	// If this category is empty we don't bother with the next confirmation screen.
199
-	if ($context['category']['is_empty'])
200
-		echo '
206
+	if ($context['category']['is_empty']) {
207
+			echo '
201 208
 					<input type="hidden" name="empty" value="1">';
209
+	}
202 210
 
203 211
 	echo '
204 212
 			</div>
@@ -225,9 +233,10 @@  discard block
 block discarded – undo
225 233
 				<p>', $txt['mboards_delete_cat_contains'], ':</p>
226 234
 				<ul>';
227 235
 
228
-	foreach ($context['category']['children'] as $child)
229
-		echo '
236
+	foreach ($context['category']['children'] as $child) {
237
+			echo '
230 238
 					<li>', $child, '</li>';
239
+	}
231 240
 
232 241
 	echo '
233 242
 				</ul>
@@ -241,10 +250,11 @@  discard block
 block discarded – undo
241 250
 					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>:
242 251
 					<select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>';
243 252
 
244
-	foreach ($context['category_order'] as $cat)
245
-		if ($cat['id'] != 0)
253
+	foreach ($context['category_order'] as $cat) {
254
+			if ($cat['id'] != 0)
246 255
 			echo '
247 256
 						<option value="', $cat['id'], '">', $cat['true_name'], '</option>';
257
+	}
248 258
 
249 259
 	echo '
250 260
 					</select>
@@ -288,9 +298,10 @@  discard block
 block discarded – undo
288 298
 					</dt>
289 299
 					<dd>
290 300
 						<select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">';
291
-		foreach ($context['categories'] as $category)
292
-			echo '
301
+		foreach ($context['categories'] as $category) {
302
+					echo '
293 303
 							<option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>';
304
+		}
294 305
 		echo '
295 306
 						</select>
296 307
 					</dd>';
@@ -317,9 +328,10 @@  discard block
 block discarded – undo
317 328
 	echo '
318 329
 						<select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '>
319 330
 							', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '';
320
-	foreach ($context['board_order'] as $order)
321
-		echo '
331
+	foreach ($context['board_order'] as $order) {
332
+			echo '
322 333
 							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
334
+	}
323 335
 	echo '
324 336
 						</select>
325 337
 					</dd>';
@@ -348,13 +360,15 @@  discard block
 block discarded – undo
348 360
 					<dd>
349 361
 						<select name="profile">';
350 362
 
351
-	if (isset($context['board']['is_new']))
352
-		echo '
363
+	if (isset($context['board']['is_new'])) {
364
+			echo '
353 365
 							<option value="-1">[', $txt['permission_profile_inherit'], ']</option>';
366
+	}
354 367
 
355
-	foreach ($context['profiles'] as $id => $profile)
356
-		echo '
368
+	foreach ($context['profiles'] as $id => $profile) {
369
+			echo '
357 370
 							<option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
371
+	}
358 372
 
359 373
 	echo '
360 374
 						</select>
@@ -367,8 +381,8 @@  discard block
 block discarded – undo
367 381
 					</dt>
368 382
 					<dd>';
369 383
 
370
-	if (!empty($modSettings['deny_boards_access']))
371
-		echo '
384
+	if (!empty($modSettings['deny_boards_access'])) {
385
+			echo '
372 386
 						<table>
373 387
 							<tr>
374 388
 								<td></td>
@@ -376,10 +390,11 @@  discard block
 block discarded – undo
376 390
 								<th>', $txt['permissions_option_off'], '</th>
377 391
 								<th>', $txt['permissions_option_deny'], '</th>
378 392
 							</tr>';
393
+	}
379 394
 
380 395
 	// List all the membergroups so the user can choose who may access this board.
381
-	foreach ($context['groups'] as $group)
382
-		if (empty($modSettings['deny_boards_access']))
396
+	foreach ($context['groups'] as $group) {
397
+			if (empty($modSettings['deny_boards_access']))
383 398
 			echo '
384 399
 						<label for="groups_', $group['id'], '">
385 400
 							<input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), ' class="input_check">
@@ -387,8 +402,9 @@  discard block
 block discarded – undo
387 402
 								', $group['name'], '
388 403
 							</span>
389 404
 						</label><br>';
390
-		else
391
-			echo '
405
+	}
406
+		else {
407
+					echo '
392 408
 							<tr>
393 409
 								<td>
394 410
 									<label for="groups_', $group['id'], '_a">
@@ -408,16 +424,17 @@  discard block
 block discarded – undo
408 424
 								</td>
409 425
 								<td></td>
410 426
 							</tr>';
427
+		}
411 428
 
412
-	if (empty($modSettings['deny_boards_access']))
413
-		echo '
429
+	if (empty($modSettings['deny_boards_access'])) {
430
+			echo '
414 431
 						<span class="select_all_box">
415 432
 							<em>', $txt['check_all'], '</em> <input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'groups[\');">
416 433
 						</span>
417 434
 						<br><br>
418 435
 					</dd>';
419
-	else
420
-		echo '
436
+	} else {
437
+			echo '
421 438
 							<tr class="select_all_box">
422 439
 								<td>
423 440
 								</td>
@@ -436,6 +453,7 @@  discard block
 block discarded – undo
436 453
 							</tr>
437 454
 						</table>
438 455
 					</dd>';
456
+	}
439 457
 
440 458
 	// Options to choose moderators, specify as announcement board and choose whether to count posts here.
441 459
 	echo '
@@ -490,8 +508,8 @@  discard block
 block discarded – undo
490 508
 					</dl>
491 509
 				</div>';
492 510
 
493
-		if ($context['board']['redirect'])
494
-			echo '
511
+		if ($context['board']['redirect']) {
512
+					echo '
495 513
 				<div id="reset_redirect_div">
496 514
 					<dl class="settings">
497 515
 						<dt>
@@ -504,6 +522,7 @@  discard block
 block discarded – undo
504 522
 						</dd>
505 523
 					</dl>
506 524
 				</div>';
525
+		}
507 526
 	}
508 527
 
509 528
 	echo '
@@ -531,9 +550,10 @@  discard block
 block discarded – undo
531 550
 							<select name="boardtheme" id="boardtheme" onchange="refreshOptions();">
532 551
 								<option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>';
533 552
 
534
-	foreach ($context['themes'] as $theme)
535
-		echo '
553
+	foreach ($context['themes'] as $theme) {
554
+			echo '
536 555
 									<option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
556
+	}
537 557
 
538 558
 	echo '
539 559
 							</select>
@@ -562,14 +582,15 @@  discard block
 block discarded – undo
562 582
 
563 583
 		foreach ($context['custom_board_settings'] as $cbs_id => $cbs)
564 584
 		{
565
-			if (!empty($cbs['dt']) && !empty($cbs['dd']))
566
-				echo '
585
+			if (!empty($cbs['dt']) && !empty($cbs['dd'])) {
586
+							echo '
567 587
 						<dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '">
568 588
 							', $cbs['dt'], '
569 589
 						</dt>
570 590
 						<dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '>
571 591
 							', $cbs['dd'], '
572 592
 						</dd>';
593
+			}
573 594
 		}
574 595
 
575 596
 		echo '
@@ -577,9 +598,10 @@  discard block
 block discarded – undo
577 598
 				</div>';
578 599
 	}
579 600
 
580
-	if (!empty($context['board']['is_recycle']))
581
-		echo '
601
+	if (!empty($context['board']['is_recycle'])) {
602
+			echo '
582 603
 				<div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>';
604
+	}
583 605
 
584 606
 	echo '
585 607
 				<input type="hidden" name="rid" value="', $context['redirect_location'], '">
@@ -587,21 +609,24 @@  discard block
 block discarded – undo
587 609
 				<input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">';
588 610
 
589 611
 	// If this board has no children don't bother with the next confirmation screen.
590
-	if ($context['board']['no_children'])
591
-		echo '
612
+	if ($context['board']['no_children']) {
613
+			echo '
592 614
 				<input type="hidden" name="no_children" value="1">';
615
+	}
593 616
 
594
-	if (isset($context['board']['is_new']))
595
-		echo '
617
+	if (isset($context['board']['is_new'])) {
618
+			echo '
596 619
 				<input type="hidden" name="cur_cat" value="', $context['board']['category'], '">
597 620
 				<input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">';
598
-	else
599
-		echo '
621
+	} else {
622
+			echo '
600 623
 				<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">';
624
+	}
601 625
 
602
-	if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle']))
603
-		echo '
626
+	if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) {
627
+			echo '
604 628
 				<input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button_submit you_sure">';
629
+	}
605 630
 	echo '
606 631
 			</div>
607 632
 		</form>
@@ -622,12 +647,13 @@  discard block
 block discarded – undo
622 647
 		sItemListContainerId: \'moderator_container\',
623 648
 		aListItems: [';
624 649
 
625
-	foreach ($context['board']['moderators'] as $id_member => $member_name)
626
-		echo '
650
+	foreach ($context['board']['moderators'] as $id_member => $member_name) {
651
+			echo '
627 652
 					{
628 653
 						sItemId: ', JavaScriptEscape($id_member), ',
629 654
 						sItemName: ', JavaScriptEscape($member_name), '
630 655
 					}', $id_member == $context['board']['last_moderator_id'] ? '' : ',';
656
+	}
631 657
 
632 658
 	echo '
633 659
 		]
@@ -647,12 +673,13 @@  discard block
 block discarded – undo
647 673
 		sItemListContainerId: \'moderator_group_container\',
648 674
 		aListItems: [';
649 675
 
650
-	foreach ($context['board']['moderator_groups'] as $id_group => $group_name)
651
-		echo '
676
+	foreach ($context['board']['moderator_groups'] as $id_group => $group_name) {
677
+			echo '
652 678
 					{
653 679
 						sItemId: ', JavaScriptEscape($id_group), ',
654 680
 						sItemName: ', JavaScriptEscape($group_name), '
655 681
 					}', $id_group == $context['board']['last_moderator_group_id'] ? '' : ',';
682
+	}
656 683
 
657 684
 		echo '
658 685
 			]
@@ -678,17 +705,19 @@  discard block
 block discarded – undo
678 705
 		echo '
679 706
 			document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";';
680 707
 
681
-		if ($context['board']['redirect'])
682
-			echo '
708
+		if ($context['board']['redirect']) {
709
+					echo '
683 710
 			document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";';
711
+		}
684 712
 	}
685 713
 
686 714
 	// Include any JavaScript added by mods using the 'integrate_edit_board' hook.
687 715
 	if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions']))
688 716
 	{
689
-		foreach ($context['custom_refreshOptions'] as $refreshOption)
690
-			echo '
717
+		foreach ($context['custom_refreshOptions'] as $refreshOption) {
718
+					echo '
691 719
 			', $refreshOption;
720
+		}
692 721
 	}
693 722
 
694 723
 	echo '
@@ -717,9 +746,10 @@  discard block
 block discarded – undo
717 746
 				<p>', $txt['mboards_delete_board_contains'], '</p>
718 747
 					<ul>';
719 748
 
720
-	foreach ($context['children'] as $child)
721
-		echo '
749
+	foreach ($context['children'] as $child) {
750
+			echo '
722 751
 						<li>', $child['node']['name'], '</li>';
752
+	}
723 753
 
724 754
 	echo '
725 755
 					</ul>
@@ -733,10 +763,11 @@  discard block
 block discarded – undo
733 763
 					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>:
734 764
 					<select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>';
735 765
 
736
-	foreach ($context['board_order'] as $board)
737
-		if ($board['id'] != $context['board']['id'] && empty($board['is_child']))
766
+	foreach ($context['board_order'] as $board) {
767
+			if ($board['id'] != $context['board']['id'] && empty($board['is_child']))
738 768
 			echo '
739 769
 						<option value="', $board['id'], '">', $board['name'], '</option>';
770
+	}
740 771
 
741 772
 	echo '
742 773
 					</select>
Please login to merge, or discard this patch.
Themes/default/Display.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -670,7 +670,7 @@
 block discarded – undo
670 670
 	// Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified!
671 671
 	// Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it.
672 672
 	echo '
673
-									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
673
+									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '', '" id="modified_', $message['id'], '">';
674 674
 
675 675
 	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
676 676
 		echo
Please login to merge, or discard this patch.
Braces   +221 added lines, -151 removed lines patch added patch discarded remove patch
@@ -51,11 +51,13 @@  discard block
 block discarded – undo
51 51
 				<p>';
52 52
 
53 53
 		// Show just numbers...?
54
-		if ($settings['display_who_viewing'] == 1)
55
-				echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
54
+		if ($settings['display_who_viewing'] == 1) {
55
+						echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
56
+		}
56 57
 		// Or show the actual people viewing the topic?
57
-		else
58
-			echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
58
+		else {
59
+					echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
60
+		}
59 61
 
60 62
 		// Now show how many guests are here too.
61 63
 		echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
@@ -93,10 +95,11 @@  discard block
 block discarded – undo
93 95
 						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
94 96
 						<dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">';
95 97
 
96
-				if ($context['allow_results_view'])
97
-					echo '
98
+				if ($context['allow_results_view']) {
99
+									echo '
98 100
 							', $option['bar_ndt'], '
99 101
 							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
102
+				}
100 103
 
101 104
 				echo '
102 105
 						</dd>';
@@ -105,9 +108,10 @@  discard block
 block discarded – undo
105 108
 			echo '
106 109
 					</dl>';
107 110
 
108
-			if ($context['allow_results_view'])
109
-				echo '
111
+			if ($context['allow_results_view']) {
112
+							echo '
110 113
 						<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
114
+			}
111 115
 		}
112 116
 		// They are allowed to vote! Go to it!
113 117
 		else
@@ -116,17 +120,19 @@  discard block
 block discarded – undo
116 120
 						<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
117 121
 
118 122
 			// Show a warning if they are allowed more than one option.
119
-			if ($context['poll']['allowed_warning'])
120
-				echo '
123
+			if ($context['poll']['allowed_warning']) {
124
+							echo '
121 125
 							<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
126
+			}
122 127
 
123 128
 			echo '
124 129
 							<ul class="options">';
125 130
 
126 131
 			// Show each option with its button - a radio likely.
127
-			foreach ($context['poll']['options'] as $option)
128
-				echo '
132
+			foreach ($context['poll']['options'] as $option) {
133
+							echo '
129 134
 								<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
135
+			}
130 136
 
131 137
 			echo '
132 138
 							</ul>
@@ -138,9 +144,10 @@  discard block
 block discarded – undo
138 144
 		}
139 145
 
140 146
 		// Is the clock ticking?
141
-		if (!empty($context['poll']['expire_time']))
142
-			echo '
147
+		if (!empty($context['poll']['expire_time'])) {
148
+					echo '
143 149
 						<p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
150
+		}
144 151
 
145 152
 		echo '
146 153
 					</div>
@@ -170,11 +177,13 @@  discard block
 block discarded – undo
170 177
 					<li>
171 178
 						<b class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></b>';
172 179
 
173
-			if ($event['can_edit'])
174
-				echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
180
+			if ($event['can_edit']) {
181
+							echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
182
+			}
175 183
 
176
-			if ($event['can_export'])
177
-				echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
184
+			if ($event['can_export']) {
185
+							echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
186
+			}
178 187
 
179 188
 			echo '
180 189
 						<br>';
@@ -182,14 +191,14 @@  discard block
 block discarded – undo
182 191
 			if (!empty($event['allday']))
183 192
 			{
184 193
 				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
185
-			}
186
-			else
194
+			} else
187 195
 			{
188 196
 				// Display event info relative to user's local timezone
189 197
 				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
190 198
 
191
-				if ($event['start_date_local'] != $event['end_date_local'])
192
-					echo trim($event['end_date_local']) . ', ';
199
+				if ($event['start_date_local'] != $event['end_date_local']) {
200
+									echo trim($event['end_date_local']) . ', ';
201
+				}
193 202
 
194 203
 				echo trim($event['end_time_local']);
195 204
 
@@ -198,23 +207,27 @@  discard block
 block discarded – undo
198 207
 				{
199 208
 					echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
200 209
 
201
-					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
202
-						echo trim($event['start_date_orig']), ', ';
210
+					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
211
+											echo trim($event['start_date_orig']), ', ';
212
+					}
203 213
 
204 214
 					echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
205 215
 
206
-					if ($event['start_date_orig'] != $event['end_date_orig'])
207
-						echo trim($event['end_date_orig']) . ', ';
216
+					if ($event['start_date_orig'] != $event['end_date_orig']) {
217
+											echo trim($event['end_date_orig']) . ', ';
218
+					}
208 219
 
209 220
 					echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
210 221
 				}
211 222
 				// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
212
-				else
213
-					echo ' ', $event['tz_abbrev'], '</time>';
223
+				else {
224
+									echo ' ', $event['tz_abbrev'], '</time>';
225
+				}
214 226
 			}
215 227
 
216
-			if (!empty($event['location']))
217
-				echo '<br>', $event['location'];
228
+			if (!empty($event['location'])) {
229
+							echo '<br>', $event['location'];
230
+			}
218 231
 
219 232
 			echo '
220 233
 					</li>';
@@ -252,8 +265,9 @@  discard block
 block discarded – undo
252 265
 	$context['removableMessageIDs'] = array();
253 266
 
254 267
 	// Get all the messages...
255
-	while ($message = $context['get_message']())
256
-		template_single_post($message);
268
+	while ($message = $context['get_message']()) {
269
+			template_single_post($message);
270
+	}
257 271
 
258 272
 	echo '
259 273
 				</form>
@@ -290,8 +304,9 @@  discard block
 block discarded – undo
290 304
 			<div id="display_jump_to">&nbsp;</div>';
291 305
 
292 306
 	// Show quickreply
293
-	if ($context['can_reply'])
294
-	template_quickreply();
307
+	if ($context['can_reply']) {
308
+		template_quickreply();
309
+	}
295 310
 
296 311
 	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
297 312
 	echo '
@@ -304,8 +319,8 @@  discard block
 block discarded – undo
304 319
 			</div>';
305 320
 
306 321
 	// Show the moderation button & pop only if user can moderate
307
-	if ($context['can_moderate_forum'] || $context['user']['is_mod'])
308
-		echo '
322
+	if ($context['can_moderate_forum'] || $context['user']['is_mod']) {
323
+			echo '
309 324
 			<div id="mobile_moderation" class="popup_container">
310 325
 				<div class="popup_window description">
311 326
 					<div class="popup_heading">', $txt['mobile_moderation'], '
@@ -315,6 +330,7 @@  discard block
 block discarded – undo
315 330
 					</div>
316 331
 				</div>
317 332
 			</div>';
333
+	}
318 334
 
319 335
 		echo '
320 336
 				<script>';
@@ -438,9 +454,10 @@  discard block
 block discarded – undo
438 454
 						});
439 455
 					}';
440 456
 
441
-	if (!empty($context['ignoredMsgs']))
442
-		echo '
457
+	if (!empty($context['ignoredMsgs'])) {
458
+			echo '
443 459
 					ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
460
+	}
444 461
 
445 462
 	echo '
446 463
 				</script>';
@@ -457,8 +474,9 @@  discard block
 block discarded – undo
457 474
 
458 475
 	$ignoring = false;
459 476
 
460
-	if ($message['can_remove'])
461
-		$context['removableMessageIDs'][] = $message['id'];
477
+	if ($message['can_remove']) {
478
+			$context['removableMessageIDs'][] = $message['id'];
479
+	}
462 480
 
463 481
 	// Are we ignoring this message?
464 482
 	if (!empty($message['is_ignored']))
@@ -484,9 +502,10 @@  discard block
 block discarded – undo
484 502
 							<div class="custom_fields_above_member">
485 503
 								<ul class="nolist">';
486 504
 
487
-		foreach ($message['custom_fields']['above_member'] as $custom)
488
-			echo '
505
+		foreach ($message['custom_fields']['above_member'] as $custom) {
506
+					echo '
489 507
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
508
+		}
490 509
 
491 510
 		echo '
492 511
 								</ul>
@@ -497,9 +516,10 @@  discard block
 block discarded – undo
497 516
 									<h4>';
498 517
 
499 518
 	// Show online and offline buttons?
500
-	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
501
-		echo '
519
+	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
520
+			echo '
502 521
 								', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : '';
522
+	}
503 523
 
504 524
 
505 525
 	// Show a link to the member's profile.
@@ -512,51 +532,59 @@  discard block
 block discarded – undo
512 532
 
513 533
 
514 534
 	// Show the user's avatar.
515
-	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
516
-		echo '
535
+	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
536
+			echo '
517 537
 								<li class="avatar">
518 538
 									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
519 539
 								</li>';
540
+	}
520 541
 
521 542
 	// Are there any custom fields below the avatar?
522
-	if (!empty($message['custom_fields']['below_avatar']))
523
-		foreach ($message['custom_fields']['below_avatar'] as $custom)
543
+	if (!empty($message['custom_fields']['below_avatar'])) {
544
+			foreach ($message['custom_fields']['below_avatar'] as $custom)
524 545
 			echo '
525 546
 								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
547
+	}
526 548
 
527 549
 	// Show the post group icons, but not for guests.
528
-	if (!$message['member']['is_guest'])
529
-		echo '
550
+	if (!$message['member']['is_guest']) {
551
+			echo '
530 552
 								<li class="icons">', $message['member']['group_icons'], '</li>';
553
+	}
531 554
 
532 555
 	// Show the member's primary group (like 'Administrator') if they have one.
533
-	if (!empty($message['member']['group']))
534
-		echo '
556
+	if (!empty($message['member']['group'])) {
557
+			echo '
535 558
 								<li class="membergroup">', $message['member']['group'], '</li>';
559
+	}
536 560
 
537 561
 	// Show the member's custom title, if they have one.
538
-	if (!empty($message['member']['title']))
539
-		echo '
562
+	if (!empty($message['member']['title'])) {
563
+			echo '
540 564
 								<li class="title">', $message['member']['title'], '</li>';
565
+	}
541 566
 
542 567
 	// Don't show these things for guests.
543 568
 	if (!$message['member']['is_guest'])
544 569
 	{
545 570
 
546 571
 		// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
547
-		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
548
-			echo '
572
+		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) {
573
+					echo '
549 574
 								<li class="postgroup">', $message['member']['post_group'], '</li>';
575
+		}
550 576
 
551 577
 		// Show how many posts they have made.
552
-		if (!isset($context['disabled_fields']['posts']))
553
-			echo '
578
+		if (!isset($context['disabled_fields']['posts'])) {
579
+					echo '
554 580
 								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
581
+		}
555 582
 
556 583
 		// Show their personal text?
557
-		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
558
-			echo '
584
+		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) {
585
+					echo '
559 586
 								<li class="blurb">', $message['member']['blurb'], '</li>';
587
+		}
560 588
 
561 589
 		// Any custom fields to show as icons?
562 590
 		if (!empty($message['custom_fields']['icons']))
@@ -565,9 +593,10 @@  discard block
 block discarded – undo
565 593
 								<li class="im_icons">
566 594
 									<ol>';
567 595
 
568
-			foreach ($message['custom_fields']['icons'] as $custom)
569
-				echo '
596
+			foreach ($message['custom_fields']['icons'] as $custom) {
597
+							echo '
570 598
 										<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
599
+			}
571 600
 
572 601
 			echo '
573 602
 									</ol>
@@ -582,19 +611,22 @@  discard block
 block discarded – undo
582 611
 									<ol class="profile_icons">';
583 612
 
584 613
 			// Don't show an icon if they haven't specified a website.
585
-			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
586
-				echo '
614
+			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) {
615
+							echo '
587 616
 										<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
617
+			}
588 618
 
589 619
 			// Since we know this person isn't a guest, you *can* message them.
590
-			if ($context['can_send_pm'])
591
-				echo '
620
+			if ($context['can_send_pm']) {
621
+							echo '
592 622
 										<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
623
+			}
593 624
 
594 625
 			// Show the email if necessary
595
-			if (!empty($message['member']['email']) && $message['member']['show_email'])
596
-				echo '
626
+			if (!empty($message['member']['email']) && $message['member']['show_email']) {
627
+							echo '
597 628
 										<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
629
+			}
598 630
 
599 631
 				echo '
600 632
 									</ol>
@@ -602,48 +634,56 @@  discard block
 block discarded – undo
602 634
 		}
603 635
 
604 636
 		// Any custom fields for standard placement?
605
-		if (!empty($message['custom_fields']['standard']))
606
-			foreach ($message['custom_fields']['standard'] as $custom)
637
+		if (!empty($message['custom_fields']['standard'])) {
638
+					foreach ($message['custom_fields']['standard'] as $custom)
607 639
 				echo '
608 640
 								<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
641
+		}
609 642
 
610 643
 	}
611 644
 	// Otherwise, show the guest's email.
612
-	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
613
-		echo '
645
+	elseif (!empty($message['member']['email']) && $message['member']['show_email']) {
646
+			echo '
614 647
 								<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
648
+	}
615 649
 
616 650
 	// Show the IP to this user for this post - because you can moderate?
617
-	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
618
-		echo '
651
+	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
652
+			echo '
619 653
 								<li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
654
+	}
620 655
 
621 656
 	// Or, should we show it because this is you?
622
-	elseif ($message['can_see_ip'])
623
-		echo '
657
+	elseif ($message['can_see_ip']) {
658
+			echo '
624 659
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
660
+	}
625 661
 
626 662
 	// Okay, are you at least logged in? Then we can show something about why IPs are logged...
627
-	elseif (!$context['user']['is_guest'])
628
-		echo '
663
+	elseif (!$context['user']['is_guest']) {
664
+			echo '
629 665
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
666
+	}
630 667
 
631 668
 	// Otherwise, you see NOTHING!
632
-	else
633
-		echo '
669
+	else {
670
+			echo '
634 671
 								<li class="poster_ip">', $txt['logged'], '</li>';
672
+	}
635 673
 
636 674
 	// Are we showing the warning status?
637 675
 	// Don't show these things for guests.
638
-	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
639
-		echo '
676
+	if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
677
+			echo '
640 678
 								<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
679
+	}
641 680
 
642 681
 	// Are there any custom fields to show at the bottom of the poster info?
643
-	if (!empty($message['custom_fields']['bottom_poster']))
644
-		foreach ($message['custom_fields']['bottom_poster'] as $custom)
682
+	if (!empty($message['custom_fields']['bottom_poster'])) {
683
+			foreach ($message['custom_fields']['bottom_poster'] as $custom)
645 684
 			echo '
646 685
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
686
+	}
647 687
 
648 688
 	// Poster info ends.
649 689
 	echo '
@@ -672,9 +712,10 @@  discard block
 block discarded – undo
672 712
 	echo '
673 713
 									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
674 714
 
675
-	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
676
-		echo
715
+	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) {
716
+			echo
677 717
 										$message['modified']['last_edit_text'];
718
+	}
678 719
 
679 720
 	echo '
680 721
 									</span>
@@ -683,22 +724,24 @@  discard block
 block discarded – undo
683 724
 							</div>';
684 725
 
685 726
 	// Ignoring this user? Hide the post.
686
-	if ($ignoring)
687
-		echo '
727
+	if ($ignoring) {
728
+			echo '
688 729
 							<div id="msg_', $message['id'], '_ignored_prompt">
689 730
 								', $txt['ignoring_user'], '
690 731
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
691 732
 							</div>';
733
+	}
692 734
 
693 735
 	// Show the post itself, finally!
694 736
 	echo '
695 737
 							<div class="post">';
696 738
 
697
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
698
-		echo '
739
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
740
+			echo '
699 741
 								<div class="approve_post">
700 742
 									', $txt['post_awaiting_approval'], '
701 743
 								</div>';
744
+	}
702 745
 	echo '
703 746
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div>
704 747
 							</div>';
@@ -715,9 +758,9 @@  discard block
 block discarded – undo
715 758
 		foreach ($message['attachment'] as $attachment)
716 759
 		{
717 760
 			// Do we want this attachment to not be showed here?
718
-			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
719
-				continue;
720
-			elseif (!$div_output)
761
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
762
+							continue;
763
+			} elseif (!$div_output)
721 764
 			{
722 765
 				$div_output = true;
723 766
 
@@ -733,9 +776,10 @@  discard block
 block discarded – undo
733 776
 								<fieldset>
734 777
 									<legend>', $txt['attach_awaiting_approve'];
735 778
 
736
-				if ($context['can_approve'])
737
-					echo '
779
+				if ($context['can_approve']) {
780
+									echo '
738 781
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
782
+				}
739 783
 
740 784
 				echo '
741 785
 									</legend>';
@@ -749,12 +793,13 @@  discard block
 block discarded – undo
749 793
 				echo '
750 794
 										<div class="attachments_top">';
751 795
 
752
-				if ($attachment['thumbnail']['has_thumb'])
753
-					echo '
796
+				if ($attachment['thumbnail']['has_thumb']) {
797
+									echo '
754 798
 											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>';
755
-				else
756
-					echo '
799
+				} else {
800
+									echo '
757 801
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
802
+				}
758 803
 
759 804
 				echo '
760 805
 										</div>';
@@ -764,9 +809,10 @@  discard block
 block discarded – undo
764 809
 										<div class="attachments_bot">
765 810
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
766 811
 
767
-			if (!$attachment['is_approved'] && $context['can_approve'])
768
-				echo '
812
+			if (!$attachment['is_approved'] && $context['can_approve']) {
813
+							echo '
769 814
 											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
815
+			}
770 816
 			echo '
771 817
 											<br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), '
772 818
 										</div>';
@@ -775,33 +821,38 @@  discard block
 block discarded – undo
775 821
 									</div>';
776 822
 
777 823
 			// Next attachment line ?
778
-			if (++$i % $attachments_per_line === 0)
779
-				echo '
824
+			if (++$i % $attachments_per_line === 0) {
825
+							echo '
780 826
 									<br>';
827
+			}
781 828
 		}
782 829
 
783 830
 		// If we had unapproved attachments clean up.
784
-		if ($last_approved_state == 0)
785
-			echo '
831
+		if ($last_approved_state == 0) {
832
+					echo '
786 833
 								</fieldset>';
834
+		}
787 835
 
788 836
 		// Only do this if we output a div above - otherwise it'll break things
789
-		if ($div_output)
790
-			echo '
837
+		if ($div_output) {
838
+					echo '
791 839
 							</div>';
840
+		}
792 841
 	}
793 842
 
794 843
 	// And stuff below the attachments.
795
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
796
-	echo '
844
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
845
+		echo '
797 846
 							<div class="under_message">';
847
+	}
798 848
 
799 849
 	// Maybe they want to report this post to the moderator(s)?
800
-	if ($context['can_report_moderator'])
801
-		echo '
850
+	if ($context['can_report_moderator']) {
851
+			echo '
802 852
 								<ul class="floatright smalltext">
803 853
 									<li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>
804 854
 								</ul>';
855
+	}
805 856
 
806 857
 	// What about likes?
807 858
 	if (!empty($modSettings['enable_likes']))
@@ -842,78 +893,91 @@  discard block
 block discarded – undo
842 893
 								<ul class="quickbuttons">';
843 894
 
844 895
 		// Can they quote? if so they can select and quote as well!
845
-		if ($context['can_quote'])
846
-			echo '
896
+		if ($context['can_quote']) {
897
+					echo '
847 898
 									<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>
848 899
 									<li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>';
900
+		}
849 901
 
850 902
 		// Can the user modify the contents of this post? Show the modify inline image.
851
-		if ($message['can_modify'])
852
-			echo '
903
+		if ($message['can_modify']) {
904
+					echo '
853 905
 									<li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>';
906
+		}
854 907
 
855
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
856
-			echo '
908
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
909
+					echo '
857 910
 									<li class="post_options">', $txt['post_options'];
911
+		}
858 912
 
859 913
 		echo '
860 914
 										<ul>';
861 915
 
862 916
 		// Can the user modify the contents of this post?
863
-		if ($message['can_modify'])
864
-			echo '
917
+		if ($message['can_modify']) {
918
+					echo '
865 919
 											<li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>';
920
+		}
866 921
 
867 922
 		// How about... even... remove it entirely?!
868
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
869
-			echo '
923
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
924
+					echo '
870 925
 											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>';
871
-		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
872
-			echo '
926
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
927
+					echo '
873 928
 											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
929
+		}
874 930
 
875 931
 		// What about splitting it off the rest of the topic?
876
-		if ($context['can_split'] && !empty($context['real_num_replies']))
877
-			echo '
932
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
933
+					echo '
878 934
 											<li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>';
935
+		}
879 936
 
880 937
 		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
881
-		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
882
-			echo '
938
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
939
+					echo '
883 940
 											<li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>';
941
+		}
884 942
 
885 943
 		// Can we restore topics?
886
-		if ($context['can_restore_msg'])
887
-			echo '
944
+		if ($context['can_restore_msg']) {
945
+					echo '
888 946
 											<li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>';
947
+		}
889 948
 
890 949
 		// Maybe we can approve it, maybe we should?
891
-		if ($message['can_approve'])
892
-			echo '
950
+		if ($message['can_approve']) {
951
+					echo '
893 952
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>';
953
+		}
894 954
 
895 955
 		// Maybe we can unapprove it?
896
-		if ($message['can_unapprove'])
897
-			echo '
956
+		if ($message['can_unapprove']) {
957
+					echo '
898 958
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>';
959
+		}
899 960
 
900 961
 		echo '
901 962
 										</ul>
902 963
 									</li>';
903 964
 
904 965
 		// Show a checkbox for quick moderation?
905
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
906
-			echo '
966
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
967
+					echo '
907 968
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
969
+		}
908 970
 
909
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
910
-			echo '
971
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
972
+					echo '
911 973
 								</ul>';
974
+		}
912 975
 	}
913 976
 
914
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
915
-	echo '
977
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
978
+		echo '
916 979
 							</div>';
980
+	}
917 981
 
918 982
 	echo '
919 983
 						</div>
@@ -926,9 +990,10 @@  discard block
 block discarded – undo
926 990
 							<div class="custom_fields_above_signature">
927 991
 								<ul class="nolist">';
928 992
 
929
-		foreach ($message['custom_fields']['above_signature'] as $custom)
930
-			echo '
993
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
994
+					echo '
931 995
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
996
+		}
932 997
 
933 998
 		echo '
934 999
 								</ul>
@@ -936,9 +1001,10 @@  discard block
 block discarded – undo
936 1001
 	}
937 1002
 
938 1003
 	// Show the member's signature?
939
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
940
-		echo '
1004
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
1005
+			echo '
941 1006
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>';
1007
+	}
942 1008
 
943 1009
 
944 1010
 	// Are there any custom profile fields for below the signature?
@@ -948,9 +1014,10 @@  discard block
 block discarded – undo
948 1014
 							<div class="custom_fields_below_signature">
949 1015
 								<ul class="nolist">';
950 1016
 
951
-		foreach ($message['custom_fields']['below_signature'] as $custom)
952
-			echo '
1017
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
1018
+					echo '
953 1019
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
1020
+		}
954 1021
 
955 1022
 		echo '
956 1023
 								</ul>
@@ -998,8 +1065,8 @@  discard block
 block discarded – undo
998 1065
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
999 1066
 
1000 1067
 		// Guests just need more.
1001
-		if ($context['user']['is_guest'])
1002
-			echo '
1068
+		if ($context['user']['is_guest']) {
1069
+					echo '
1003 1070
 						<dl id="post_header">
1004 1071
 							<dt>
1005 1072
 								', $txt['name'], ':
@@ -1014,6 +1081,7 @@  discard block
 block discarded – undo
1014 1081
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required>
1015 1082
 							</dd>
1016 1083
 						</dl>';
1084
+		}
1017 1085
 
1018 1086
 		echo '
1019 1087
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1061,8 +1129,8 @@  discard block
 block discarded – undo
1061 1129
 		<br class="clear">';
1062 1130
 
1063 1131
 	// draft autosave available and the user has it enabled?
1064
-	if (!empty($context['drafts_autosave']))
1065
-		echo '
1132
+	if (!empty($context['drafts_autosave'])) {
1133
+			echo '
1066 1134
 			<script>
1067 1135
 				var oDraftAutoSave = new smf_DraftAutoSave({
1068 1136
 					sSelf: \'oDraftAutoSave\',
@@ -1074,10 +1142,12 @@  discard block
 block discarded – undo
1074 1142
 					iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1075 1143
 				});
1076 1144
 			</script>';
1145
+	}
1077 1146
 
1078
-	if ($context['show_spellchecking'])
1079
-		echo '
1147
+	if ($context['show_spellchecking']) {
1148
+			echo '
1080 1149
 			<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>';
1150
+	}
1081 1151
 
1082 1152
 	echo '
1083 1153
 				<script>
Please login to merge, or discard this patch.
proxy.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@
 block discarded – undo
118 118
 
119 119
 		// Right, image not cached? Simply redirect, then.
120 120
 		if (!$response)
121
-		    redirectexit($request);
121
+			redirectexit($request);
122 122
 
123 123
 		// Make sure we're serving an image
124 124
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
Please login to merge, or discard this patch.
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -63,26 +63,31 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function checkRequest()
65 65
 	{
66
-		if (!$this->enabled)
67
-			return false;
66
+		if (!$this->enabled) {
67
+					return false;
68
+		}
68 69
 
69 70
 		// Try to create the image cache directory if it doesn't exist
70
-		if (!file_exists($this->cache))
71
-			if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
71
+		if (!file_exists($this->cache)) {
72
+					if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
72 73
 				return false;
74
+		}
73 75
 
74
-		if (empty($_GET['hash']) || empty($_GET['request']))
75
-			return false;
76
+		if (empty($_GET['hash']) || empty($_GET['request'])) {
77
+					return false;
78
+		}
76 79
 
77 80
 		$hash = $_GET['hash'];
78 81
 		$request = $_GET['request'];
79 82
 
80
-		if (md5($request . $this->secret) != $hash)
81
-			return false;
83
+		if (md5($request . $this->secret) != $hash) {
84
+					return false;
85
+		}
82 86
 
83 87
 		// Attempt to cache the request if it doesn't exist
84
-		if (!$this->isCached($request))
85
-			return $this->cacheImage($request);
88
+		if (!$this->isCached($request)) {
89
+					return $this->cacheImage($request);
90
+		}
86 91
 
87 92
 		return true;
88 93
 	}
@@ -111,19 +116,22 @@  discard block
 block discarded – undo
111 116
 		if (!$cached || time() - $cached['time'] > (5 * 86400))
112 117
 		{
113 118
 			@unlink($cached_file);
114
-			if ($this->checkRequest())
115
-				$this->serve();
119
+			if ($this->checkRequest()) {
120
+							$this->serve();
121
+			}
116 122
 			redirectexit($request);
117 123
 		}
118 124
 
119 125
 		// Right, image not cached? Simply redirect, then.
120
-		if (!$response)
121
-		    redirectexit($request);
126
+		if (!$response) {
127
+				    redirectexit($request);
128
+		}
122 129
 
123 130
 		// Make sure we're serving an image
124 131
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
125
-		if ($contentParts[0] != 'image')
126
-			exit;
132
+		if ($contentParts[0] != 'image') {
133
+					exit;
134
+		}
127 135
 
128 136
 		header('Content-type: ' . $cached['content_type']);
129 137
 		header('Content-length: ' . $cached['size']);
@@ -170,8 +178,9 @@  discard block
 block discarded – undo
170 178
 		$responseCode = $request->result('code');
171 179
 		$response = $request->result();
172 180
 
173
-		if (empty($response))
174
-			return false;
181
+		if (empty($response)) {
182
+					return false;
183
+		}
175 184
 		
176 185
 		if ($responseCode != 200) {
177 186
 			return $request->result('code');
@@ -181,12 +190,14 @@  discard block
 block discarded – undo
181 190
 
182 191
 		// Make sure the url is returning an image
183 192
 		$contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : '');
184
-		if ($contentParts[0] != 'image')
185
-			return false;
193
+		if ($contentParts[0] != 'image') {
194
+					return false;
195
+		}
186 196
 
187 197
 		// Validate the filesize
188
-		if ($response['size'] > ($this->maxSize * 1024))
189
-			return false;
198
+		if ($response['size'] > ($this->maxSize * 1024)) {
199
+					return false;
200
+		}
190 201
 
191 202
 		return file_put_contents($dest, json_encode(array(
192 203
 			'content_type' => $headers['content-type'],
Please login to merge, or discard this patch.
Sources/ShowAttachments.php 1 patch
Braces   +59 added lines, -52 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  * Shows an avatar based on $_GET['attach']
@@ -35,11 +36,11 @@  discard block
 block discarded – undo
35 36
 
36 37
 	if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0)
37 38
 	{
38
-		if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler')
39
-			$modSettings['enableCompressedOutput'] = 0;
40
-
41
-		else
42
-			ob_start('ob_gzhandler');
39
+		if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') {
40
+					$modSettings['enableCompressedOutput'] = 0;
41
+		} else {
42
+					ob_start('ob_gzhandler');
43
+		}
43 44
 	}
44 45
 
45 46
 	if (empty($modSettings['enableCompressedOutput']))
@@ -71,8 +72,9 @@  discard block
 block discarded – undo
71 72
 	}
72 73
 
73 74
 	// Use cache when possible.
74
-	if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null)
75
-		list($file, $thumbFile) = $cache;
75
+	if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) {
76
+			list($file, $thumbFile) = $cache;
77
+	}
76 78
 
77 79
 	// Get the info from the DB.
78 80
 	if (empty($file) || empty($thumbFile) && !empty($file['id_thumb']))
@@ -80,10 +82,9 @@  discard block
 block discarded – undo
80 82
 		// Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request.
81 83
 		$attachRequest = null;
82 84
 		call_integration_hook('integrate_download_request', array(&$attachRequest));
83
-		if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest))
84
-			$request = $attachRequest;
85
-
86
-		else
85
+		if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) {
86
+					$request = $attachRequest;
87
+		} else
87 88
 		{
88 89
 			// Make sure this attachment is on this board and load its info while we are at it.
89 90
 			$request = $smcFunc['db_query']('', '
@@ -176,13 +177,15 @@  discard block
 block discarded – undo
176 177
 		}
177 178
 
178 179
 		// Cache it.
179
-		if (!empty($file) || !empty($thumbFile))
180
-			cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900));
180
+		if (!empty($file) || !empty($thumbFile)) {
181
+					cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900));
182
+		}
181 183
 	}
182 184
 
183 185
 	// Replace the normal file with its thumbnail if it has one!
184
-	if (!empty($showThumb) && !empty($thumbFile))
185
-		$file = $thumbFile;
186
+	if (!empty($showThumb) && !empty($thumbFile)) {
187
+			$file = $thumbFile;
188
+	}
186 189
 
187 190
 	// No point in a nicer message, because this is supposed to be an attachment anyway...
188 191
 	if (!file_exists($file['filePath']))
@@ -232,8 +235,8 @@  discard block
 block discarded – undo
232 235
 	}
233 236
 
234 237
 	// Update the download counter (unless it's a thumbnail or resuming an incomplete download).
235
-	if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0)
236
-		$smcFunc['db_query']('attach_download_increase', '
238
+	if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) {
239
+			$smcFunc['db_query']('attach_download_increase', '
237 240
 			UPDATE LOW_PRIORITY {db_prefix}attachments
238 241
 			SET downloads = downloads + 1
239 242
 			WHERE id_attach = {int:id_attach}',
@@ -241,12 +244,14 @@  discard block
 block discarded – undo
241 244
 				'id_attach' => $attachId,
242 245
 			)
243 246
 		);
247
+	}
244 248
 
245 249
 	// Send the attachment headers.
246 250
 	header('Pragma: ');
247 251
 
248
-	if (!isBrowser('gecko'))
249
-		header('Content-Transfer-Encoding: binary');
252
+	if (!isBrowser('gecko')) {
253
+			header('Content-Transfer-Encoding: binary');
254
+	}
250 255
 
251 256
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
252 257
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT');
@@ -255,18 +260,19 @@  discard block
 block discarded – undo
255 260
 	header('ETag: ' . $eTag);
256 261
 
257 262
 	// Make sure the mime type warrants an inline display.
258
-	if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0)
259
-		unset($_REQUEST['image']);
263
+	if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) {
264
+			unset($_REQUEST['image']);
265
+	}
260 266
 
261 267
 	// Does this have a mime type?
262
-	elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff'))))
263
-		header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp')));
264
-
265
-	else
268
+	elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) {
269
+			header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp')));
270
+	} else
266 271
 	{
267 272
 		header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
268
-		if (isset($_REQUEST['image']))
269
-			unset($_REQUEST['image']);
273
+		if (isset($_REQUEST['image'])) {
274
+					unset($_REQUEST['image']);
275
+		}
270 276
 	}
271 277
 
272 278
 	// Convert the file to UTF-8, cuz most browsers dig that.
@@ -274,24 +280,22 @@  discard block
 block discarded – undo
274 280
 	$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
275 281
 
276 282
 	// Different browsers like different standards...
277
-	if (isBrowser('firefox'))
278
-		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
279
-
280
-	elseif (isBrowser('opera'))
281
-		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
282
-
283
-	elseif (isBrowser('ie'))
284
-		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
285
-
286
-	else
287
-		header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
283
+	if (isBrowser('firefox')) {
284
+			header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
285
+	} elseif (isBrowser('opera')) {
286
+			header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
287
+	} elseif (isBrowser('ie')) {
288
+			header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
289
+	} else {
290
+			header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
291
+	}
288 292
 
289 293
 	// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
290
-	if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff')))
291
-		header('Cache-Control: no-cache');
292
-
293
-	else
294
-		header('Cache-Control: max-age=' . (525600 * 60) . ', private');
294
+	if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) {
295
+			header('Cache-Control: no-cache');
296
+	} else {
297
+			header('Cache-Control: max-age=' . (525600 * 60) . ', private');
298
+	}
295 299
 
296 300
 	// Multipart and resuming support
297 301
 	if (isset($_SERVER['HTTP_RANGE']))
@@ -299,9 +303,9 @@  discard block
 block discarded – undo
299 303
 		header("HTTP/1.1 206 Partial Content");
300 304
 		header("Content-Length: $new_length");
301 305
 		header("Content-Range: bytes $range-$range_end/$size");
306
+	} else {
307
+			header("Content-Length: " . $size);
302 308
 	}
303
-	else
304
-		header("Content-Length: " . $size);
305 309
 
306 310
 
307 311
 	// Try to buy some time...
@@ -310,8 +314,9 @@  discard block
 block discarded – undo
310 314
 	// For multipart/resumable downloads, send the requested chunk(s) of the file
311 315
 	if (isset($_SERVER['HTTP_RANGE']))
312 316
 	{
313
-		while (@ob_get_level() > 0)
314
-			@ob_end_clean();
317
+		while (@ob_get_level() > 0) {
318
+					@ob_end_clean();
319
+		}
315 320
 
316 321
 		// 40 kilobytes is a good-ish amount
317 322
 		$chunksize = 40 * 1024;
@@ -335,8 +340,9 @@  discard block
 block discarded – undo
335 340
 	elseif ($size > 4194304)
336 341
 	{
337 342
 		// Forcibly end any output buffering going on.
338
-		while (@ob_get_level() > 0)
339
-			@ob_end_clean();
343
+		while (@ob_get_level() > 0) {
344
+					@ob_end_clean();
345
+		}
340 346
 
341 347
 		$fp = fopen($file['filePath'], 'rb');
342 348
 		while (!feof($fp))
@@ -348,8 +354,9 @@  discard block
 block discarded – undo
348 354
 	}
349 355
 
350 356
 	// On some of the less-bright hosts, readfile() is disabled.  It's just a faster, more byte safe, version of what's in the if.
351
-	elseif (@readfile($file['filePath']) === null)
352
-		echo file_get_contents($file['filePath']);
357
+	elseif (@readfile($file['filePath']) === null) {
358
+			echo file_get_contents($file['filePath']);
359
+	}
353 360
 
354 361
 	die();
355 362
 }
Please login to merge, or discard this patch.
Sources/ManageLanguages.php 1 patch
Braces   +190 added lines, -142 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * This is the main function for the languages area.
@@ -153,11 +154,11 @@  discard block
 block discarded – undo
153 154
 	$language_list = new xmlArray(fetch_web_data($url), true);
154 155
 
155 156
 	// Check that the site responded and that the language exists.
156
-	if (!$language_list->exists('languages'))
157
-		$context['smf_error'] = 'no_response';
158
-	elseif (!$language_list->exists('languages/language'))
159
-		$context['smf_error'] = 'no_files';
160
-	else
157
+	if (!$language_list->exists('languages')) {
158
+			$context['smf_error'] = 'no_response';
159
+	} elseif (!$language_list->exists('languages/language')) {
160
+			$context['smf_error'] = 'no_files';
161
+	} else
161 162
 	{
162 163
 		$language_list = $language_list->path('languages[0]');
163 164
 		$lang_files = $language_list->set('language');
@@ -165,8 +166,9 @@  discard block
 block discarded – undo
165 166
 		foreach ($lang_files as $file)
166 167
 		{
167 168
 			// Were we searching?
168
-			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false)
169
-				continue;
169
+			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) {
170
+							continue;
171
+			}
170 172
 
171 173
 			$smf_languages[] = array(
172 174
 				'id' => $file->fetch('id'),
@@ -177,10 +179,11 @@  discard block
 block discarded – undo
177 179
 				'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>',
178 180
 			);
179 181
 		}
180
-		if (empty($smf_languages))
181
-			$context['smf_error'] = 'no_files';
182
-		else
183
-			return $smf_languages;
182
+		if (empty($smf_languages)) {
183
+					$context['smf_error'] = 'no_files';
184
+		} else {
185
+					return $smf_languages;
186
+		}
184 187
 	}
185 188
 }
186 189
 
@@ -202,8 +205,9 @@  discard block
 block discarded – undo
202 205
 	require_once($sourcedir . '/Subs-Package.php');
203 206
 
204 207
 	// Clearly we need to know what to request.
205
-	if (!isset($_GET['did']))
206
-		fatal_lang_error('no_access', false);
208
+	if (!isset($_GET['did'])) {
209
+			fatal_lang_error('no_access', false);
210
+	}
207 211
 
208 212
 	// Some lovely context.
209 213
 	$context['download_id'] = $_GET['did'];
@@ -223,8 +227,9 @@  discard block
 block discarded – undo
223 227
 		foreach ($_POST['copy_file'] as $file)
224 228
 		{
225 229
 			// Check it's not very bad.
226
-			if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file)))
227
-				fatal_error($txt['languages_download_illegal_paths']);
230
+			if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) {
231
+							fatal_error($txt['languages_download_illegal_paths']);
232
+			}
228 233
 
229 234
 			$chmod_files[] = $boarddir . '/' . $file;
230 235
 			$install_files[] = $file;
@@ -235,8 +240,9 @@  discard block
 block discarded – undo
235 240
 		$files_left = $file_status['files']['notwritable'];
236 241
 
237 242
 		// Something not writable?
238
-		if (!empty($files_left))
239
-			$context['error_message'] = $txt['languages_download_not_chmod'];
243
+		if (!empty($files_left)) {
244
+					$context['error_message'] = $txt['languages_download_not_chmod'];
245
+		}
240 246
 		// Otherwise, go go go!
241 247
 		elseif (!empty($install_files))
242 248
 		{
@@ -251,11 +257,13 @@  discard block
 block discarded – undo
251 257
 	}
252 258
 
253 259
 	// Open up the old china.
254
-	if (!isset($archive_content))
255
-		$archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null);
260
+	if (!isset($archive_content)) {
261
+			$archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null);
262
+	}
256 263
 
257
-	if (empty($archive_content))
258
-		fatal_error($txt['add_language_error_no_response']);
264
+	if (empty($archive_content)) {
265
+			fatal_error($txt['add_language_error_no_response']);
266
+	}
259 267
 
260 268
 	// Now for each of the files, let's do some *stuff*
261 269
 	$context['files'] = array(
@@ -270,8 +278,9 @@  discard block
 block discarded – undo
270 278
 		$extension = substr($filename, strrpos($filename, '.') + 1);
271 279
 
272 280
 		// Don't do anything with files we don't understand.
273
-		if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt')))
274
-			continue;
281
+		if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) {
282
+					continue;
283
+		}
275 284
 
276 285
 		// Basic data.
277 286
 		$context_data = array(
@@ -290,8 +299,9 @@  discard block
 block discarded – undo
290 299
 		// Does the file exist, is it different and can we overwrite?
291 300
 		if (file_exists($boarddir . '/' . $file['filename']))
292 301
 		{
293
-			if (is_writable($boarddir . '/' . $file['filename']))
294
-				$context_data['writable'] = true;
302
+			if (is_writable($boarddir . '/' . $file['filename'])) {
303
+							$context_data['writable'] = true;
304
+			}
295 305
 
296 306
 			// Finally, do we actually think the content has changed?
297 307
 			if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename']))
@@ -304,16 +314,17 @@  discard block
 block discarded – undo
304 314
 			{
305 315
 				$context_data['exists'] = 'same';
306 316
 				$context_data['default_copy'] = false;
317
+			} else {
318
+							$context_data['exists'] = 'different';
307 319
 			}
308
-			else
309
-				$context_data['exists'] = 'different';
310 320
 		}
311 321
 		// No overwrite?
312 322
 		else
313 323
 		{
314 324
 			// Can we at least stick it in the directory...
315
-			if (is_writable($boarddir . '/' . $dirname))
316
-				$context_data['writable'] = true;
325
+			if (is_writable($boarddir . '/' . $dirname)) {
326
+							$context_data['writable'] = true;
327
+			}
317 328
 		}
318 329
 
319 330
 		// I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin...
@@ -328,8 +339,9 @@  discard block
 block discarded – undo
328 339
 			list ($name, $language) = explode('.', $filename);
329 340
 
330 341
 			// Let's get the new version, I like versions, they tell me that I'm up to date.
331
-			if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1)
332
-				$context_data['version'] = $match[1];
342
+			if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) {
343
+							$context_data['version'] = $match[1];
344
+			}
333 345
 
334 346
 			// Now does the old file exist - if so what is it's version?
335 347
 			if (file_exists($boarddir . '/' . $file['filename']))
@@ -345,34 +357,35 @@  discard block
 block discarded – undo
345 357
 					$context_data['cur_version'] = $match[1];
346 358
 
347 359
 					// How does this compare?
348
-					if ($context_data['cur_version'] == $context_data['version'])
349
-						$context_data['version_compare'] = 'same';
350
-					elseif ($context_data['cur_version'] > $context_data['version'])
351
-						$context_data['version_compare'] = 'older';
360
+					if ($context_data['cur_version'] == $context_data['version']) {
361
+											$context_data['version_compare'] = 'same';
362
+					} elseif ($context_data['cur_version'] > $context_data['version']) {
363
+											$context_data['version_compare'] = 'older';
364
+					}
352 365
 
353 366
 					// Don't recommend copying if the version is the same.
354
-					if ($context_data['version_compare'] != 'newer')
355
-						$context_data['default_copy'] = false;
367
+					if ($context_data['version_compare'] != 'newer') {
368
+											$context_data['default_copy'] = false;
369
+					}
356 370
 				}
357 371
 			}
358 372
 
359 373
 			// Add the context data to the main set.
360 374
 			$context['files']['lang'][] = $context_data;
361
-		}
362
-		elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false)
375
+		} elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false)
363 376
 		{
364 377
 			// Registration agreement is a primary file
365 378
 			$context['files']['lang'][] = $context_data;
366
-		}
367
-		else
379
+		} else
368 380
 		{
369 381
 			// There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future
370 382
 			$context['files']['other'][] = $context_data;
371 383
 		}
372 384
 
373 385
 		// Collect together all non-writable areas.
374
-		if (!$context_data['writable'])
375
-			$context['make_writable'][] = $context_data['destination'];
386
+		if (!$context_data['writable']) {
387
+					$context['make_writable'][] = $context_data['destination'];
388
+		}
376 389
 	}
377 390
 
378 391
 	// Before we go to far can we make anything writable, eh, eh?
@@ -387,22 +400,24 @@  discard block
 block discarded – undo
387 400
 		{
388 401
 			if ($type == 'lang')
389 402
 			{
390
-				foreach ($data as $k => $file)
391
-					if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
403
+				foreach ($data as $k => $file) {
404
+									if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
392 405
 						$context['files'][$type][$k]['writable'] = true;
393
-			}
394
-			else
406
+				}
407
+			} else
395 408
 			{
396
-				foreach ($data as $theme => $files)
397
-					foreach ($files as $k => $file)
409
+				foreach ($data as $theme => $files) {
410
+									foreach ($files as $k => $file)
398 411
 						if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
399 412
 							$context['files'][$type][$theme][$k]['writable'] = true;
413
+				}
400 414
 			}
401 415
 		}
402 416
 
403 417
 		// Are we going to need more language stuff?
404
-		if (!empty($context['still_not_writable']))
405
-			loadLanguage('Packages');
418
+		if (!empty($context['still_not_writable'])) {
419
+					loadLanguage('Packages');
420
+		}
406 421
 	}
407 422
 
408 423
 	// This is the list for the main files.
@@ -615,12 +630,13 @@  discard block
 block discarded – undo
615 630
 	highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true);
616 631
 
617 632
 	// Display a warning if we cannot edit the default setting.
618
-	if (!is_writable($boarddir . '/Settings.php'))
619
-		$listOptions['additional_rows'][] = array(
633
+	if (!is_writable($boarddir . '/Settings.php')) {
634
+			$listOptions['additional_rows'][] = array(
620 635
 				'position' => 'after_title',
621 636
 				'value' => $txt['language_settings_writable'],
622 637
 				'class' => 'smalltext alert',
623 638
 			);
639
+	}
624 640
 
625 641
 	require_once($sourcedir . '/Subs-List.php');
626 642
 	createList($listOptions);
@@ -662,10 +678,11 @@  discard block
 block discarded – undo
662 678
 
663 679
 	// Put them back.
664 680
 	$settings['actual_theme_dir'] = $backup_actual_theme_dir;
665
-	if (!empty($backup_base_theme_dir))
666
-		$settings['base_theme_dir'] = $backup_base_theme_dir;
667
-	else
668
-		unset($settings['base_theme_dir']);
681
+	if (!empty($backup_base_theme_dir)) {
682
+			$settings['base_theme_dir'] = $backup_base_theme_dir;
683
+	} else {
684
+			unset($settings['base_theme_dir']);
685
+	}
669 686
 
670 687
 	// Get the language files and data...
671 688
 	foreach ($context['languages'] as $lang)
@@ -694,13 +711,15 @@  discard block
 block discarded – undo
694 711
 	while ($row = $smcFunc['db_fetch_assoc']($request))
695 712
 	{
696 713
 		// Default?
697
-		if (empty($row['lngfile']) || !isset($languages[$row['lngfile']]))
698
-			$row['lngfile'] = $language;
714
+		if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) {
715
+					$row['lngfile'] = $language;
716
+		}
699 717
 
700
-		if (!isset($languages[$row['lngfile']]) && isset($languages['english']))
701
-			$languages['english']['count'] += $row['num_users'];
702
-		elseif (isset($languages[$row['lngfile']]))
703
-			$languages[$row['lngfile']]['count'] += $row['num_users'];
718
+		if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) {
719
+					$languages['english']['count'] += $row['num_users'];
720
+		} elseif (isset($languages[$row['lngfile']])) {
721
+					$languages[$row['lngfile']]['count'] += $row['num_users'];
722
+		}
704 723
 	}
705 724
 	$smcFunc['db_free_result']($request);
706 725
 
@@ -740,13 +759,15 @@  discard block
 block discarded – undo
740 759
 
741 760
 	call_integration_hook('integrate_language_settings', array(&$config_vars));
742 761
 
743
-	if ($return_config)
744
-		return $config_vars;
762
+	if ($return_config) {
763
+			return $config_vars;
764
+	}
745 765
 
746 766
 	// Get our languages. No cache
747 767
 	getLanguages(false);
748
-	foreach ($context['languages'] as $lang)
749
-		$config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);
768
+	foreach ($context['languages'] as $lang) {
769
+			$config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);
770
+	}
750 771
 
751 772
 	// Saving settings?
752 773
 	if (isset($_REQUEST['save']))
@@ -756,8 +777,9 @@  discard block
 block discarded – undo
756 777
 		call_integration_hook('integrate_save_language_settings', array(&$config_vars));
757 778
 
758 779
 		saveSettings($config_vars);
759
-		if (!$settings_not_writable && !$settings_backup_fail)
760
-			$_SESSION['adm-save'] = true;
780
+		if (!$settings_not_writable && !$settings_backup_fail) {
781
+					$_SESSION['adm-save'] = true;
782
+		}
761 783
 		redirectexit('action=admin;area=languages;sa=settings');
762 784
 	}
763 785
 
@@ -766,10 +788,11 @@  discard block
 block discarded – undo
766 788
 	$context['settings_title'] = $txt['language_settings'];
767 789
 	$context['save_disabled'] = $settings_not_writable;
768 790
 
769
-	if ($settings_not_writable)
770
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
771
-	elseif ($settings_backup_fail)
772
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
791
+	if ($settings_not_writable) {
792
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
793
+	} elseif ($settings_backup_fail) {
794
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
795
+	}
773 796
 
774 797
 	// Fill the config array.
775 798
 	prepareServerSettingsContext($config_vars);
@@ -816,8 +839,9 @@  discard block
 block discarded – undo
816 839
 			'theme_dir' => $settings['default_theme_dir'],
817 840
 		),
818 841
 	);
819
-	while ($row = $smcFunc['db_fetch_assoc']($request))
820
-		$themes[$row['id_theme']][$row['variable']] = $row['value'];
842
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
843
+			$themes[$row['id_theme']][$row['variable']] = $row['value'];
844
+	}
821 845
 	$smcFunc['db_free_result']($request);
822 846
 
823 847
 	// This will be where we look
@@ -829,14 +853,16 @@  discard block
 block discarded – undo
829 853
 	// Check we have themes with a path and a name - just in case - and add the path.
830 854
 	foreach ($themes as $id => $data)
831 855
 	{
832
-		if (count($data) != 2)
833
-			unset($themes[$id]);
834
-		elseif (is_dir($data['theme_dir'] . '/languages'))
835
-			$lang_dirs[$id] = $data['theme_dir'] . '/languages';
856
+		if (count($data) != 2) {
857
+					unset($themes[$id]);
858
+		} elseif (is_dir($data['theme_dir'] . '/languages')) {
859
+					$lang_dirs[$id] = $data['theme_dir'] . '/languages';
860
+		}
836 861
 
837 862
 		// How about image directories?
838
-		if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id']))
839
-			$images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
863
+		if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) {
864
+					$images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
865
+		}
840 866
 	}
841 867
 
842 868
 	$current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : '';
@@ -850,15 +876,17 @@  discard block
 block discarded – undo
850 876
 		while ($entry = $dir->read())
851 877
 		{
852 878
 			// We're only after the files for this language.
853
-			if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0)
854
-				continue;
879
+			if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) {
880
+							continue;
881
+			}
855 882
 
856
-			if (!isset($context['possible_files'][$theme]))
857
-				$context['possible_files'][$theme] = array(
883
+			if (!isset($context['possible_files'][$theme])) {
884
+							$context['possible_files'][$theme] = array(
858 885
 					'id' => $theme,
859 886
 					'name' => $themes[$theme]['name'],
860 887
 					'files' => array(),
861 888
 				);
889
+			}
862 890
 
863 891
 			$context['possible_files'][$theme]['files'][] = array(
864 892
 				'id' => $matches[1],
@@ -887,31 +915,36 @@  discard block
 block discarded – undo
887 915
 		{
888 916
 			$_SESSION['last_backup_for'] = $context['lang_id'] . '$$$';
889 917
 			$result = package_create_backup('backup_lang_' . $context['lang_id']);
890
-			if (!$result)
891
-				fatal_lang_error('could_not_language_backup', false);
918
+			if (!$result) {
919
+							fatal_lang_error('could_not_language_backup', false);
920
+			}
892 921
 		}
893 922
 
894 923
 		// Second, loop through the array to remove the files.
895 924
 		foreach ($lang_dirs as $curPath)
896 925
 		{
897
-			foreach ($context['possible_files'][1]['files'] as $lang)
898
-				if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
926
+			foreach ($context['possible_files'][1]['files'] as $lang) {
927
+							if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
899 928
 					unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php');
929
+			}
900 930
 
901 931
 			// Check for the email template.
902
-			if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'))
903
-				unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
932
+			if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) {
933
+							unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
934
+			}
904 935
 		}
905 936
 
906 937
 		// Third, the agreement file.
907
-		if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt'))
908
-			unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
938
+		if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) {
939
+					unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
940
+		}
909 941
 
910 942
 		// Fourth, a related images folder, if it exists...
911
-		if (!empty($images_dirs))
912
-			foreach ($images_dirs as $curPath)
943
+		if (!empty($images_dirs)) {
944
+					foreach ($images_dirs as $curPath)
913 945
 				if (is_dir($curPath))
914 946
 					deltree($curPath);
947
+		}
915 948
 
916 949
 		// Members can no longer use this language.
917 950
 		$smcFunc['db_query']('', '
@@ -995,8 +1028,9 @@  discard block
 block discarded – undo
995 1028
 		foreach ($_POST['entry'] as $k => $v)
996 1029
 		{
997 1030
 			// Only try to save if it's changed!
998
-			if ($_POST['entry'][$k] != $_POST['comp'][$k])
999
-				$save_strings[$k] = cleanLangString($v, false);
1031
+			if ($_POST['entry'][$k] != $_POST['comp'][$k]) {
1032
+							$save_strings[$k] = cleanLangString($v, false);
1033
+			}
1000 1034
 		}
1001 1035
 	}
1002 1036
 
@@ -1030,12 +1064,13 @@  discard block
 block discarded – undo
1030 1064
 		if ($multiline_cache)
1031 1065
 		{
1032 1066
 			preg_match('~\$(helptxt|txt|editortxt)\[\'(.+)\'\]\s?=\s?(.+);~ms', strtr($multiline_cache, array("\r" => '')), $matches);
1033
-			if (!empty($matches[3]))
1034
-				$entries[$matches[2]] = array(
1067
+			if (!empty($matches[3])) {
1068
+							$entries[$matches[2]] = array(
1035 1069
 					'type' => $matches[1],
1036 1070
 					'full' => $matches[0],
1037 1071
 					'entry' => $matches[3],
1038 1072
 				);
1073
+			}
1039 1074
 		}
1040 1075
 
1041 1076
 		// These are the entries we can definitely save.
@@ -1046,8 +1081,9 @@  discard block
 block discarded – undo
1046 1081
 		{
1047 1082
 			// Ignore some things we set separately.
1048 1083
 			$ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl');
1049
-			if (in_array($entryKey, $ignore_files))
1050
-				continue;
1084
+			if (in_array($entryKey, $ignore_files)) {
1085
+							continue;
1086
+			}
1051 1087
 
1052 1088
 			// These are arrays that need breaking out.
1053 1089
 			$arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short', 'happy_birthday_author', 'karlbenson1_author', 'nite0859_author', 'zwaldowski_author', 'geezmo_author', 'karlbenson2_author');
@@ -1080,9 +1116,9 @@  discard block
 block discarded – undo
1080 1116
 					{
1081 1117
 						$save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => ''));
1082 1118
 						$save_cache['enabled'] = true;
1119
+					} else {
1120
+											$save_cache['entries'][$cur_index] = $subValue;
1083 1121
 					}
1084
-					else
1085
-						$save_cache['entries'][$cur_index] = $subValue;
1086 1122
 
1087 1123
 					$context['file_entries'][] = array(
1088 1124
 						'key' => $entryKey . '-+- ' . $cur_index,
@@ -1105,9 +1141,9 @@  discard block
 block discarded – undo
1105 1141
 						{
1106 1142
 							$items[] = $k2 . ' => \'' . $v2 . '\'';
1107 1143
 							$cur_index = $k2;
1144
+						} else {
1145
+													$items[] = '\'' . $v2 . '\'';
1108 1146
 						}
1109
-						else
1110
-							$items[] = '\'' . $v2 . '\'';
1111 1147
 
1112 1148
 						$cur_index++;
1113 1149
 					}
@@ -1117,15 +1153,15 @@  discard block
 block discarded – undo
1117 1153
 						'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');',
1118 1154
 					);
1119 1155
 				}
1120
-			}
1121
-			else
1156
+			} else
1122 1157
 			{
1123 1158
 				// Saving?
1124 1159
 				if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry'])
1125 1160
 				{
1126 1161
 					// @todo Fix this properly.
1127
-					if ($save_strings[$entryKey] == '')
1128
-						$save_strings[$entryKey] = '\'\'';
1162
+					if ($save_strings[$entryKey] == '') {
1163
+											$save_strings[$entryKey] = '\'\'';
1164
+					}
1129 1165
 
1130 1166
 					// Set the new value.
1131 1167
 					$entryValue['entry'] = $save_strings[$entryKey];
@@ -1151,8 +1187,9 @@  discard block
 block discarded – undo
1151 1187
 			checkSession();
1152 1188
 
1153 1189
 			$file_contents = implode('', file($current_file));
1154
-			foreach ($final_saves as $save)
1155
-				$file_contents = strtr($file_contents, array($save['find'] => $save['replace']));
1190
+			foreach ($final_saves as $save) {
1191
+							$file_contents = strtr($file_contents, array($save['find'] => $save['replace']));
1192
+			}
1156 1193
 
1157 1194
 			// Save the actual changes.
1158 1195
 			$fp = fopen($current_file, 'w+');
@@ -1167,8 +1204,9 @@  discard block
 block discarded – undo
1167 1204
 	}
1168 1205
 
1169 1206
 	// If we saved, redirect.
1170
-	if ($madeSave)
1171
-		redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']);
1207
+	if ($madeSave) {
1208
+			redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']);
1209
+	}
1172 1210
 
1173 1211
 	createToken('admin-mlang');
1174 1212
 }
@@ -1200,8 +1238,9 @@  discard block
 block discarded – undo
1200 1238
 				// Toggle the escape.
1201 1239
 				$is_escape = !$is_escape;
1202 1240
 				// If we're now escaped don't add this string.
1203
-				if ($is_escape)
1204
-					continue;
1241
+				if ($is_escape) {
1242
+									continue;
1243
+				}
1205 1244
 			}
1206 1245
 			// Special case - parsed string with line break etc?
1207 1246
 			elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape)
@@ -1218,11 +1257,13 @@  discard block
 block discarded – undo
1218 1257
 				if ($in_string != 2 && ($in_string != 1 || !$is_escape))
1219 1258
 				{
1220 1259
 					// Is it the end of a single quote string?
1221
-					if ($in_string == 1)
1222
-						$in_string = 0;
1260
+					if ($in_string == 1) {
1261
+											$in_string = 0;
1262
+					}
1223 1263
 					// Otherwise it's the start!
1224
-					else
1225
-						$in_string = 1;
1264
+					else {
1265
+											$in_string = 1;
1266
+					}
1226 1267
 
1227 1268
 					// Don't actually include this character!
1228 1269
 					continue;
@@ -1235,19 +1276,22 @@  discard block
 block discarded – undo
1235 1276
 				if ($in_string != 1 && ($in_string != 2 || !$is_escape))
1236 1277
 				{
1237 1278
 					// Is it the end of a double quote string?
1238
-					if ($in_string == 2)
1239
-						$in_string = 0;
1279
+					if ($in_string == 2) {
1280
+											$in_string = 0;
1281
+					}
1240 1282
 					// Otherwise it's the start!
1241
-					else
1242
-						$in_string = 2;
1283
+					else {
1284
+											$in_string = 2;
1285
+					}
1243 1286
 
1244 1287
 					// Don't actually include this character!
1245 1288
 					continue;
1246 1289
 				}
1247 1290
 			}
1248 1291
 			// A join/space outside of a string is simply removed.
1249
-			elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.'))
1250
-				continue;
1292
+			elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) {
1293
+							continue;
1294
+			}
1251 1295
 			// Start of a variable?
1252 1296
 			elseif ($in_string == 0 && $string{$i} == '$')
1253 1297
 			{
@@ -1281,8 +1325,7 @@  discard block
 block discarded – undo
1281 1325
 
1282 1326
 		// Unhtml then rehtml the whole thing!
1283 1327
 		$new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string));
1284
-	}
1285
-	else
1328
+	} else
1286 1329
 	{
1287 1330
 		// Keep track of what we're doing...
1288 1331
 		$in_string = 0;
@@ -1311,10 +1354,11 @@  discard block
 block discarded – undo
1311 1354
 				preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches);
1312 1355
 				if (!empty($matches[1]))
1313 1356
 				{
1314
-					if ($in_string == 1)
1315
-						$new_string .= '\' . ';
1316
-					elseif ($new_string)
1317
-						$new_string .= ' . ';
1357
+					if ($in_string == 1) {
1358
+											$new_string .= '\' . ';
1359
+					} elseif ($new_string) {
1360
+											$new_string .= ' . ';
1361
+					}
1318 1362
 
1319 1363
 					$new_string .= $matches[1];
1320 1364
 					$i += strlen($matches[1]) + 3;
@@ -1327,8 +1371,9 @@  discard block
 block discarded – undo
1327 1371
 			elseif ($string{$i} == '<')
1328 1372
 			{
1329 1373
 				// Probably HTML?
1330
-				if ($string{$i + 1} != ' ')
1331
-					$in_html = true;
1374
+				if ($string{$i + 1} != ' ') {
1375
+									$in_html = true;
1376
+				}
1332 1377
 				// Assume we need an entity...
1333 1378
 				else
1334 1379
 				{
@@ -1340,8 +1385,9 @@  discard block
 block discarded – undo
1340 1385
 			elseif ($string{$i} == '>')
1341 1386
 			{
1342 1387
 				// Will it be HTML?
1343
-				if ($in_html)
1344
-					$in_html = false;
1388
+				if ($in_html) {
1389
+									$in_html = false;
1390
+				}
1345 1391
 				// Otherwise we need an entity...
1346 1392
 				else
1347 1393
 				{
@@ -1350,8 +1396,9 @@  discard block
 block discarded – undo
1350 1396
 				}
1351 1397
 			}
1352 1398
 			// Is it a slash? If so escape it...
1353
-			if ($string{$i} == '\\')
1354
-				$new_string .= '\\';
1399
+			if ($string{$i} == '\\') {
1400
+							$new_string .= '\\';
1401
+			}
1355 1402
 			// The infamous double quote?
1356 1403
 			elseif ($string{$i} == '"')
1357 1404
 			{
@@ -1374,10 +1421,11 @@  discard block
 block discarded – undo
1374 1421
 		}
1375 1422
 
1376 1423
 		// If we ended as a string then close it off.
1377
-		if ($in_string == 1)
1378
-			$new_string .= '\'';
1379
-		elseif ($in_string == 2)
1380
-			$new_string .= '"';
1424
+		if ($in_string == 1) {
1425
+					$new_string .= '\'';
1426
+		} elseif ($in_string == 2) {
1427
+					$new_string .= '"';
1428
+		}
1381 1429
 	}
1382 1430
 
1383 1431
 	return $new_string;
Please login to merge, or discard this patch.
Sources/Admin.php 1 patch
Braces   +75 added lines, -52 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main admin handling function.<br>
@@ -444,8 +445,9 @@  discard block
 block discarded – undo
444 445
 		foreach ($admin_includes as $include)
445 446
 		{
446 447
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
447
-			if (file_exists($include))
448
-				require_once($include);
448
+			if (file_exists($include)) {
449
+							require_once($include);
450
+			}
449 451
 		}
450 452
 	}
451 453
 
@@ -457,24 +459,27 @@  discard block
 block discarded – undo
457 459
 	unset($admin_areas);
458 460
 
459 461
 	// Nothing valid?
460
-	if ($admin_include_data == false)
461
-		fatal_lang_error('no_access', false);
462
+	if ($admin_include_data == false) {
463
+			fatal_lang_error('no_access', false);
464
+	}
462 465
 
463 466
 	// Build the link tree.
464 467
 	$context['linktree'][] = array(
465 468
 		'url' => $scripturl . '?action=admin',
466 469
 		'name' => $txt['admin_center'],
467 470
 	);
468
-	if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index')
469
-		$context['linktree'][] = array(
471
+	if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') {
472
+			$context['linktree'][] = array(
470 473
 			'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'],
471 474
 			'name' => $admin_include_data['label'],
472 475
 		);
473
-	if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label'])
474
-		$context['linktree'][] = array(
476
+	}
477
+	if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) {
478
+			$context['linktree'][] = array(
475 479
 			'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'],
476 480
 			'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0],
477 481
 		);
482
+	}
478 483
 
479 484
 	// Make a note of the Unique ID for this menu.
480 485
 	$context['admin_menu_id'] = $context['max_menu_id'];
@@ -484,16 +489,18 @@  discard block
 block discarded – undo
484 489
 	$context['admin_area'] = $admin_include_data['current_area'];
485 490
 
486 491
 	// Now - finally - call the right place!
487
-	if (isset($admin_include_data['file']))
488
-		require_once($sourcedir . '/' . $admin_include_data['file']);
492
+	if (isset($admin_include_data['file'])) {
493
+			require_once($sourcedir . '/' . $admin_include_data['file']);
494
+	}
489 495
 
490 496
 	// Get the right callable.
491 497
 	$call = call_helper($admin_include_data['function'], true);
492 498
 
493 499
 	// Is it valid?
494
-	if (!empty($call))
495
-		call_user_func($call);
496
-}
500
+	if (!empty($call)) {
501
+			call_user_func($call);
502
+	}
503
+	}
497 504
 
498 505
 /**
499 506
  * The main administration section.
@@ -547,13 +554,14 @@  discard block
 block discarded – undo
547 554
 
548 555
 	$context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin';
549 556
 	$context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center'];
550
-	if ($context['admin_area'] != 'credits')
551
-		$context[$context['admin_menu_name']]['tab_data'] = array(
557
+	if ($context['admin_area'] != 'credits') {
558
+			$context[$context['admin_menu_name']]['tab_data'] = array(
552 559
 			'title' => $txt['admin_center'],
553 560
 			'help' => '',
554 561
 			'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong>
555 562
 						' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']),
556 563
 		);
564
+	}
557 565
 
558 566
 	// Lastly, fill in the blanks in the support resources paragraphs.
559 567
 	$txt['support_resources_p1'] = sprintf($txt['support_resources_p1'],
@@ -571,9 +579,10 @@  discard block
 block discarded – undo
571 579
 		'https://www.simplemachines.org/redirect/customize_support'
572 580
 	);
573 581
 
574
-	if ($context['admin_area'] == 'admin')
575
-		loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin');
576
-}
582
+	if ($context['admin_area'] == 'admin') {
583
+			loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin');
584
+	}
585
+	}
577 586
 
578 587
 /**
579 588
  * Get one of the admin information files from Simple Machines.
@@ -584,8 +593,9 @@  discard block
 block discarded – undo
584 593
 
585 594
 	setMemoryLimit('32M');
586 595
 
587
-	if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename']))
588
-		fatal_lang_error('no_access', false);
596
+	if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) {
597
+			fatal_lang_error('no_access', false);
598
+	}
589 599
 
590 600
 	// Strip off the forum cache part or we won't find it...
591 601
 	$_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']);
@@ -600,27 +610,30 @@  discard block
 block discarded – undo
600 610
 		)
601 611
 	);
602 612
 
603
-	if ($smcFunc['db_num_rows']($request) == 0)
604
-		fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404);
613
+	if ($smcFunc['db_num_rows']($request) == 0) {
614
+			fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404);
615
+	}
605 616
 
606 617
 	list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request);
607 618
 	$smcFunc['db_free_result']($request);
608 619
 
609 620
 	// @todo Temp
610 621
 	// Figure out if sesc is still being used.
611
-	if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript')
612
-		$file_data = '
622
+	if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') {
623
+			$file_data = '
613 624
 if (!(\'smfForum_sessionvar\' in window))
614 625
 	window.smfForum_sessionvar = \'sesc\';
615 626
 ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'='));
627
+	}
616 628
 
617 629
 	$context['template_layers'] = array();
618 630
 	// Lets make sure we aren't going to output anything nasty.
619 631
 	@ob_end_clean();
620
-	if (!empty($modSettings['enableCompressedOutput']))
621
-		@ob_start('ob_gzhandler');
622
-	else
623
-		@ob_start();
632
+	if (!empty($modSettings['enableCompressedOutput'])) {
633
+			@ob_start('ob_gzhandler');
634
+	} else {
635
+			@ob_start();
636
+	}
624 637
 
625 638
 	// Make sure they know what type of file we are.
626 639
 	header('Content-Type: ' . $filetype);
@@ -660,11 +673,12 @@  discard block
 block discarded – undo
660 673
 		updateAdminPreferences();
661 674
 	}
662 675
 
663
-	if (trim($context['search_term']) == '')
664
-		$context['search_results'] = array();
665
-	else
666
-		call_helper($subActions[$context['search_type']]);
667
-}
676
+	if (trim($context['search_term']) == '') {
677
+			$context['search_results'] = array();
678
+	} else {
679
+			call_helper($subActions[$context['search_type']]);
680
+	}
681
+	}
668 682
 
669 683
 /**
670 684
  * A complicated but relatively quick internal search.
@@ -728,8 +742,9 @@  discard block
 block discarded – undo
728 742
 
729 743
 	loadLanguage(implode('+', $language_files));
730 744
 
731
-	foreach ($include_files as $file)
732
-		require_once($sourcedir . '/' . $file . '.php');
745
+	foreach ($include_files as $file) {
746
+			require_once($sourcedir . '/' . $file . '.php');
747
+	}
733 748
 
734 749
 	/* This is the huge array that defines everything... it's a huge array of items formatted as follows:
735 750
 		0 = Language index (Can be array of indexes) to search through for this setting.
@@ -753,11 +768,12 @@  discard block
 block discarded – undo
753 768
 		foreach ($section['areas'] as $menu_key => $menu_item)
754 769
 		{
755 770
 			$search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key);
756
-			if (!empty($menu_item['subsections']))
757
-				foreach ($menu_item['subsections'] as $key => $sublabel)
771
+			if (!empty($menu_item['subsections'])) {
772
+							foreach ($menu_item['subsections'] as $key => $sublabel)
758 773
 				{
759 774
 					if (isset($sublabel['label']))
760 775
 						$search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key);
776
+			}
761 777
 				}
762 778
 		}
763 779
 	}
@@ -767,9 +783,10 @@  discard block
 block discarded – undo
767 783
 		// Get a list of their variables.
768 784
 		$config_vars = $setting_area[0](true);
769 785
 
770
-		foreach ($config_vars as $var)
771
-			if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc')))
786
+		foreach ($config_vars as $var) {
787
+					if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc')))
772 788
 				$search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1]);
789
+		}
773 790
 	}
774 791
 
775 792
 	$context['page_title'] = $txt['admin_search_results'];
@@ -782,8 +799,9 @@  discard block
 block discarded – undo
782 799
 		foreach ($data as $item)
783 800
 		{
784 801
 			$found = false;
785
-			if (!is_array($item[0]))
786
-				$item[0] = array($item[0]);
802
+			if (!is_array($item[0])) {
803
+							$item[0] = array($item[0]);
804
+			}
787 805
 			foreach ($item[0] as $term)
788 806
 			{
789 807
 				if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false))
@@ -841,8 +859,9 @@  discard block
 block discarded – undo
841 859
 	$postVars = explode(' ', $context['search_term']);
842 860
 
843 861
 	// Encode the search data.
844
-	foreach ($postVars as $k => $v)
845
-		$postVars[$k] = urlencode($v);
862
+	foreach ($postVars as $k => $v) {
863
+			$postVars[$k] = urlencode($v);
864
+	}
846 865
 
847 866
 	// This is what we will send.
848 867
 	$postVars = implode('+', $postVars);
@@ -854,8 +873,9 @@  discard block
 block discarded – undo
854 873
 	$search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars);
855 874
 
856 875
 	// If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded?
857
-	if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true)
858
-		fatal_lang_error('cannot_connect_doc_site');
876
+	if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) {
877
+			fatal_lang_error('cannot_connect_doc_site');
878
+	}
859 879
 
860 880
 	$search_results = $matches[1];
861 881
 
@@ -867,8 +887,9 @@  discard block
 block discarded – undo
867 887
 	$results = new xmlArray($search_results, false);
868 888
 
869 889
 	// Move through the api layer.
870
-	if (!$results->exists('api'))
871
-		fatal_lang_error('cannot_connect_doc_site');
890
+	if (!$results->exists('api')) {
891
+			fatal_lang_error('cannot_connect_doc_site');
892
+	}
872 893
 
873 894
 	// Are there actually some results?
874 895
 	if ($results->exists('api/query/search/p'))
@@ -904,8 +925,9 @@  discard block
 block discarded – undo
904 925
 	);
905 926
 
906 927
 	// If it's not got a sa set it must have come here for first time, pretend error log should be reversed.
907
-	if (!isset($_REQUEST['sa']))
908
-		$_REQUEST['desc'] = true;
928
+	if (!isset($_REQUEST['sa'])) {
929
+			$_REQUEST['desc'] = true;
930
+	}
909 931
 
910 932
 	// Setup some tab stuff.
911 933
 	$context[$context['admin_menu_name']]['tab_data'] = array(
@@ -955,9 +977,10 @@  discard block
 block discarded – undo
955 977
 	unset($_SESSION['admin_time']);
956 978
 
957 979
 	// Clean any admin tokens as well.
958
-	foreach ($_SESSION['token'] as $key => $token)
959
-		if (strpos($key, '-admin') !== false)
980
+	foreach ($_SESSION['token'] as $key => $token) {
981
+			if (strpos($key, '-admin') !== false)
960 982
 			unset($_SESSION['token'][$key]);
983
+	}
961 984
 
962 985
 	redirectexit();
963 986
 }
Please login to merge, or discard this patch.