Completed
Pull Request — release-2.1 (#4156)
by 01
13:04 queued 03:20
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 4
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/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 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Handles showing the post screen, loading the post to be modified, and loading any post quoted.
@@ -35,12 +36,14 @@  discard block
 block discarded – undo
35 36
 	global $sourcedir, $smcFunc, $language;
36 37
 
37 38
 	loadLanguage('Post');
38
-	if (!empty($modSettings['drafts_post_enabled']))
39
-		loadLanguage('Drafts');
39
+	if (!empty($modSettings['drafts_post_enabled'])) {
40
+			loadLanguage('Drafts');
41
+	}
40 42
 
41 43
 	// You can't reply with a poll... hacker.
42
-	if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg']))
43
-		unset($_REQUEST['poll']);
44
+	if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) {
45
+			unset($_REQUEST['poll']);
46
+	}
44 47
 
45 48
 	// Posting an event?
46 49
 	$context['make_event'] = isset($_REQUEST['calendar']);
@@ -54,8 +57,9 @@  discard block
 block discarded – undo
54 57
 	$context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']);
55 58
 
56 59
 	// You must be posting to *some* board.
57
-	if (empty($board) && !$context['make_event'])
58
-		fatal_lang_error('no_board', false);
60
+	if (empty($board) && !$context['make_event']) {
61
+			fatal_lang_error('no_board', false);
62
+	}
59 63
 
60 64
 	require_once($sourcedir . '/Subs-Post.php');
61 65
 
@@ -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.
@@ -1340,8 +1397,9 @@  discard block
 block discarded – undo
1340 1397
 
1341 1398
 
1342 1399
 	// Finally, load the template.
1343
-	if (!isset($_REQUEST['xml']))
1344
-		loadTemplate('Post');
1400
+	if (!isset($_REQUEST['xml'])) {
1401
+			loadTemplate('Post');
1402
+	}
1345 1403
 
1346 1404
 	call_integration_hook('integrate_post_end');
1347 1405
 }
@@ -1362,13 +1420,14 @@  discard block
 block discarded – undo
1362 1420
 	// Sneaking off, are we?
1363 1421
 	if (empty($_POST) && empty($topic))
1364 1422
 	{
1365
-		if (empty($_SERVER['CONTENT_LENGTH']))
1366
-			redirectexit('action=post;board=' . $board . '.0');
1367
-		else
1368
-			fatal_lang_error('post_upload_error', false);
1423
+		if (empty($_SERVER['CONTENT_LENGTH'])) {
1424
+					redirectexit('action=post;board=' . $board . '.0');
1425
+		} else {
1426
+					fatal_lang_error('post_upload_error', false);
1427
+		}
1428
+	} elseif (empty($_POST) && !empty($topic)) {
1429
+			redirectexit('action=post;topic=' . $topic . '.0');
1369 1430
 	}
1370
-	elseif (empty($_POST) && !empty($topic))
1371
-		redirectexit('action=post;topic=' . $topic . '.0');
1372 1431
 
1373 1432
 	// No need!
1374 1433
 	$context['robot_no_index'] = true;
@@ -1380,8 +1439,9 @@  discard block
 block discarded – undo
1380 1439
 	$post_errors = array();
1381 1440
 
1382 1441
 	// If the session has timed out, let the user re-submit their form.
1383
-	if (checkSession('post', '', false) != '')
1384
-		$post_errors[] = 'session_timeout';
1442
+	if (checkSession('post', '', false) != '') {
1443
+			$post_errors[] = 'session_timeout';
1444
+	}
1385 1445
 
1386 1446
 	// Wrong verification code?
1387 1447
 	if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)))
@@ -1391,33 +1451,38 @@  discard block
 block discarded – undo
1391 1451
 			'id' => 'post',
1392 1452
 		);
1393 1453
 		$context['require_verification'] = create_control_verification($verificationOptions, true);
1394
-		if (is_array($context['require_verification']))
1395
-			$post_errors = array_merge($post_errors, $context['require_verification']);
1454
+		if (is_array($context['require_verification'])) {
1455
+					$post_errors = array_merge($post_errors, $context['require_verification']);
1456
+		}
1396 1457
 	}
1397 1458
 
1398 1459
 	require_once($sourcedir . '/Subs-Post.php');
1399 1460
 	loadLanguage('Post');
1400 1461
 
1401 1462
 	// Drafts enabled and needed?
1402
-	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
1403
-		require_once($sourcedir . '/Drafts.php');
1463
+	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) {
1464
+			require_once($sourcedir . '/Drafts.php');
1465
+	}
1404 1466
 
1405 1467
 	// First check to see if they are trying to delete any current attachments.
1406 1468
 	if (isset($_POST['attach_del']))
1407 1469
 	{
1408 1470
 		$keep_temp = array();
1409 1471
 		$keep_ids = array();
1410
-		foreach ($_POST['attach_del'] as $dummy)
1411
-			if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1472
+		foreach ($_POST['attach_del'] as $dummy) {
1473
+					if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1412 1474
 				$keep_temp[] = $dummy;
1413
-			else
1414
-				$keep_ids[] = (int) $dummy;
1475
+		}
1476
+			else {
1477
+							$keep_ids[] = (int) $dummy;
1478
+			}
1415 1479
 
1416
-		if (isset($_SESSION['temp_attachments']))
1417
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1480
+		if (isset($_SESSION['temp_attachments'])) {
1481
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1418 1482
 			{
1419 1483
 				if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1420 1484
 					continue;
1485
+		}
1421 1486
 
1422 1487
 				unset($_SESSION['temp_attachments'][$attachID]);
1423 1488
 				unlink($attachment['tmp_name']);
@@ -1459,24 +1524,28 @@  discard block
 block discarded – undo
1459 1524
 		$smcFunc['db_free_result']($request);
1460 1525
 
1461 1526
 		// Though the topic should be there, it might have vanished.
1462
-		if (!is_array($topic_info))
1463
-			fatal_lang_error('topic_doesnt_exist', 404);
1527
+		if (!is_array($topic_info)) {
1528
+					fatal_lang_error('topic_doesnt_exist', 404);
1529
+		}
1464 1530
 
1465 1531
 		// Did this topic suddenly move? Just checking...
1466
-		if ($topic_info['id_board'] != $board)
1467
-			fatal_lang_error('not_a_topic');
1532
+		if ($topic_info['id_board'] != $board) {
1533
+					fatal_lang_error('not_a_topic');
1534
+		}
1468 1535
 	}
1469 1536
 
1470 1537
 	// Replying to a topic?
1471 1538
 	if (!empty($topic) && !isset($_REQUEST['msg']))
1472 1539
 	{
1473 1540
 		// Don't allow a post if it's locked.
1474
-		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board'))
1475
-			fatal_lang_error('topic_locked', false);
1541
+		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) {
1542
+					fatal_lang_error('topic_locked', false);
1543
+		}
1476 1544
 
1477 1545
 		// Sorry, multiple polls aren't allowed... yet.  You should stop giving me ideas :P.
1478
-		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0)
1479
-			unset($_REQUEST['poll']);
1546
+		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) {
1547
+					unset($_REQUEST['poll']);
1548
+		}
1480 1549
 
1481 1550
 		// Do the permissions and approval stuff...
1482 1551
 		$becomesApproved = true;
@@ -1492,44 +1561,43 @@  discard block
 block discarded – undo
1492 1561
 
1493 1562
 			// Set a nice session var...
1494 1563
 			$_SESSION['becomesUnapproved'] = true;
1495
-		}
1496
-
1497
-		elseif ($topic_info['id_member_started'] != $user_info['id'])
1564
+		} elseif ($topic_info['id_member_started'] != $user_info['id'])
1498 1565
 		{
1499
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
1500
-				$becomesApproved = false;
1501
-
1502
-			else
1503
-				isAllowedTo('post_reply_any');
1504
-		}
1505
-		elseif (!allowedTo('post_reply_any'))
1566
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
1567
+							$becomesApproved = false;
1568
+			} else {
1569
+							isAllowedTo('post_reply_any');
1570
+			}
1571
+		} elseif (!allowedTo('post_reply_any'))
1506 1572
 		{
1507
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own'))
1508
-				$becomesApproved = false;
1509
-
1510
-			else
1511
-				isAllowedTo('post_reply_own');
1573
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) {
1574
+							$becomesApproved = false;
1575
+			} else {
1576
+							isAllowedTo('post_reply_own');
1577
+			}
1512 1578
 		}
1513 1579
 
1514 1580
 		if (isset($_POST['lock']))
1515 1581
 		{
1516 1582
 			// Nothing is changed to the lock.
1517
-			if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1518
-				unset($_POST['lock']);
1583
+			if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1584
+							unset($_POST['lock']);
1585
+			}
1519 1586
 
1520 1587
 			// You're have no permission to lock this topic.
1521
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1522
-				unset($_POST['lock']);
1588
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1589
+							unset($_POST['lock']);
1590
+			}
1523 1591
 
1524 1592
 			// You are allowed to (un)lock your own topic only.
1525 1593
 			elseif (!allowedTo('lock_any'))
1526 1594
 			{
1527 1595
 				// You cannot override a moderator lock.
1528
-				if ($topic_info['locked'] == 1)
1529
-					unset($_POST['lock']);
1530
-
1531
-				else
1532
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1596
+				if ($topic_info['locked'] == 1) {
1597
+									unset($_POST['lock']);
1598
+				} else {
1599
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1600
+				}
1533 1601
 			}
1534 1602
 			// Hail mighty moderator, (un)lock this topic immediately.
1535 1603
 			else
@@ -1537,19 +1605,21 @@  discard block
 block discarded – undo
1537 1605
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1538 1606
 
1539 1607
 				// Did someone (un)lock this while you were posting?
1540
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1541
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1608
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1609
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1610
+				}
1542 1611
 			}
1543 1612
 		}
1544 1613
 
1545 1614
 		// So you wanna (un)sticky this...let's see.
1546
-		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky')))
1547
-			unset($_POST['sticky']);
1548
-		elseif (isset($_POST['sticky']))
1615
+		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) {
1616
+					unset($_POST['sticky']);
1617
+		} elseif (isset($_POST['sticky']))
1549 1618
 		{
1550 1619
 			// Did someone (un)sticky this while you were posting?
1551
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1552
-				$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1620
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1621
+							$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1622
+			}
1553 1623
 		}
1554 1624
 
1555 1625
 		// If drafts are enabled, then pass this off
@@ -1576,26 +1646,31 @@  discard block
 block discarded – undo
1576 1646
 
1577 1647
 		// Do like, the permissions, for safety and stuff...
1578 1648
 		$becomesApproved = true;
1579
-		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
1580
-			$becomesApproved = false;
1581
-		else
1582
-			isAllowedTo('post_new');
1649
+		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) {
1650
+					$becomesApproved = false;
1651
+		} else {
1652
+					isAllowedTo('post_new');
1653
+		}
1583 1654
 
1584 1655
 		if (isset($_POST['lock']))
1585 1656
 		{
1586 1657
 			// New topics are by default not locked.
1587
-			if (empty($_POST['lock']))
1588
-				unset($_POST['lock']);
1658
+			if (empty($_POST['lock'])) {
1659
+							unset($_POST['lock']);
1660
+			}
1589 1661
 			// Besides, you need permission.
1590
-			elseif (!allowedTo(array('lock_any', 'lock_own')))
1591
-				unset($_POST['lock']);
1662
+			elseif (!allowedTo(array('lock_any', 'lock_own'))) {
1663
+							unset($_POST['lock']);
1664
+			}
1592 1665
 			// A moderator-lock (1) can override a user-lock (2).
1593
-			else
1594
-				$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1666
+			else {
1667
+							$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1668
+			}
1595 1669
 		}
1596 1670
 
1597
-		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky')))
1598
-			unset($_POST['sticky']);
1671
+		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) {
1672
+					unset($_POST['sticky']);
1673
+		}
1599 1674
 
1600 1675
 		// Saving your new topic as a draft first?
1601 1676
 		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
@@ -1620,31 +1695,37 @@  discard block
 block discarded – undo
1620 1695
 				'id_msg' => $_REQUEST['msg'],
1621 1696
 			)
1622 1697
 		);
1623
-		if ($smcFunc['db_num_rows']($request) == 0)
1624
-			fatal_lang_error('cant_find_messages', false);
1698
+		if ($smcFunc['db_num_rows']($request) == 0) {
1699
+					fatal_lang_error('cant_find_messages', false);
1700
+		}
1625 1701
 		$row = $smcFunc['db_fetch_assoc']($request);
1626 1702
 		$smcFunc['db_free_result']($request);
1627 1703
 
1628
-		if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
1629
-			fatal_lang_error('topic_locked', false);
1704
+		if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) {
1705
+					fatal_lang_error('topic_locked', false);
1706
+		}
1630 1707
 
1631 1708
 		if (isset($_POST['lock']))
1632 1709
 		{
1633 1710
 			// Nothing changes to the lock status.
1634
-			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1635
-				unset($_POST['lock']);
1711
+			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1712
+							unset($_POST['lock']);
1713
+			}
1636 1714
 			// You're simply not allowed to (un)lock this.
1637
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1638
-				unset($_POST['lock']);
1715
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1716
+							unset($_POST['lock']);
1717
+			}
1639 1718
 			// You're only allowed to lock your own topics.
1640 1719
 			elseif (!allowedTo('lock_any'))
1641 1720
 			{
1642 1721
 				// You're not allowed to break a moderator's lock.
1643
-				if ($topic_info['locked'] == 1)
1644
-					unset($_POST['lock']);
1722
+				if ($topic_info['locked'] == 1) {
1723
+									unset($_POST['lock']);
1724
+				}
1645 1725
 				// Lock it with a soft lock or unlock it.
1646
-				else
1647
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1726
+				else {
1727
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1728
+				}
1648 1729
 			}
1649 1730
 			// You must be the moderator.
1650 1731
 			else
@@ -1652,44 +1733,46 @@  discard block
 block discarded – undo
1652 1733
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1653 1734
 
1654 1735
 				// Did someone (un)lock this while you were posting?
1655
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1656
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1736
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1737
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1738
+				}
1657 1739
 			}
1658 1740
 		}
1659 1741
 
1660 1742
 		// Change the sticky status of this topic?
1661
-		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky']))
1662
-			unset($_POST['sticky']);
1663
-		elseif (isset($_POST['sticky']))
1743
+		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) {
1744
+					unset($_POST['sticky']);
1745
+		} elseif (isset($_POST['sticky']))
1664 1746
 		{
1665 1747
 			// Did someone (un)sticky this while you were posting?
1666
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1667
-				$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1748
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1749
+							$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1750
+			}
1668 1751
 		}
1669 1752
 
1670 1753
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
1671 1754
 		{
1672
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
1673
-				fatal_lang_error('modify_post_time_passed', false);
1674
-			elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
1675
-				isAllowedTo('modify_replies');
1676
-			else
1677
-				isAllowedTo('modify_own');
1678
-		}
1679
-		elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1755
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
1756
+							fatal_lang_error('modify_post_time_passed', false);
1757
+			} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
1758
+							isAllowedTo('modify_replies');
1759
+			} else {
1760
+							isAllowedTo('modify_own');
1761
+			}
1762
+		} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1680 1763
 		{
1681 1764
 			isAllowedTo('modify_replies');
1682 1765
 
1683 1766
 			// If you're modifying a reply, I say it better be logged...
1684 1767
 			$moderationAction = true;
1685
-		}
1686
-		else
1768
+		} else
1687 1769
 		{
1688 1770
 			isAllowedTo('modify_any');
1689 1771
 
1690 1772
 			// Log it, assuming you're not modifying your own post.
1691
-			if ($row['id_member'] != $user_info['id'])
1692
-				$moderationAction = true;
1773
+			if ($row['id_member'] != $user_info['id']) {
1774
+							$moderationAction = true;
1775
+			}
1693 1776
 		}
1694 1777
 
1695 1778
 		// If drafts are enabled, then lets send this off to save
@@ -1726,20 +1809,24 @@  discard block
 block discarded – undo
1726 1809
 		$_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']);
1727 1810
 		$_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
1728 1811
 
1729
-		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_')
1730
-			$post_errors[] = 'no_name';
1731
-		if ($smcFunc['strlen']($_POST['guestname']) > 25)
1732
-			$post_errors[] = 'long_name';
1812
+		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') {
1813
+					$post_errors[] = 'no_name';
1814
+		}
1815
+		if ($smcFunc['strlen']($_POST['guestname']) > 25) {
1816
+					$post_errors[] = 'long_name';
1817
+		}
1733 1818
 
1734 1819
 		if (empty($modSettings['guest_post_no_email']))
1735 1820
 		{
1736 1821
 			// Only check if they changed it!
1737 1822
 			if (!isset($row) || $row['poster_email'] != $_POST['email'])
1738 1823
 			{
1739
-				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == ''))
1740
-					$post_errors[] = 'no_email';
1741
-				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
1742
-					$post_errors[] = 'bad_email';
1824
+				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) {
1825
+									$post_errors[] = 'no_email';
1826
+				}
1827
+				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
1828
+									$post_errors[] = 'bad_email';
1829
+				}
1743 1830
 			}
1744 1831
 
1745 1832
 			// Now make sure this email address is not banned from posting.
@@ -1755,75 +1842,89 @@  discard block
 block discarded – undo
1755 1842
 	}
1756 1843
 
1757 1844
 	// Coming from the quickReply?
1758
-	if (isset($_POST['quickReply']))
1759
-		$_POST['message'] = $_POST['quickReply'];
1845
+	if (isset($_POST['quickReply'])) {
1846
+			$_POST['message'] = $_POST['quickReply'];
1847
+	}
1760 1848
 
1761 1849
 	// Check the subject and message.
1762
-	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '')
1763
-		$post_errors[] = 'no_subject';
1764
-	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '')
1765
-		$post_errors[] = 'no_message';
1766
-	elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
1767
-		$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1768
-	else
1850
+	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') {
1851
+			$post_errors[] = 'no_subject';
1852
+	}
1853
+	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') {
1854
+			$post_errors[] = 'no_message';
1855
+	} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) {
1856
+			$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1857
+	} else
1769 1858
 	{
1770 1859
 		// Prepare the message a bit for some additional testing.
1771 1860
 		$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
1772 1861
 
1773 1862
 		// Preparse code. (Zef)
1774
-		if ($user_info['is_guest'])
1775
-			$user_info['name'] = $_POST['guestname'];
1863
+		if ($user_info['is_guest']) {
1864
+					$user_info['name'] = $_POST['guestname'];
1865
+		}
1776 1866
 		preparsecode($_POST['message']);
1777 1867
 
1778 1868
 		// Let's see if there's still some content left without the tags.
1779
-		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
1780
-			$post_errors[] = 'no_message';
1869
+		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) {
1870
+					$post_errors[] = 'no_message';
1871
+		}
1872
+	}
1873
+	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') {
1874
+			$post_errors[] = 'no_event';
1781 1875
 	}
1782
-	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '')
1783
-		$post_errors[] = 'no_event';
1784 1876
 	// You are not!
1785
-	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin'])
1786
-		fatal_error('Knave! Masquerader! Charlatan!', false);
1877
+	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) {
1878
+			fatal_error('Knave! Masquerader! Charlatan!', false);
1879
+	}
1787 1880
 
1788 1881
 	// Validate the poll...
1789 1882
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
1790 1883
 	{
1791
-		if (!empty($topic) && !isset($_REQUEST['msg']))
1792
-			fatal_lang_error('no_access', false);
1884
+		if (!empty($topic) && !isset($_REQUEST['msg'])) {
1885
+					fatal_lang_error('no_access', false);
1886
+		}
1793 1887
 
1794 1888
 		// This is a new topic... so it's a new poll.
1795
-		if (empty($topic))
1796
-			isAllowedTo('poll_post');
1889
+		if (empty($topic)) {
1890
+					isAllowedTo('poll_post');
1891
+		}
1797 1892
 		// Can you add to your own topics?
1798
-		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any'))
1799
-			isAllowedTo('poll_add_own');
1893
+		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) {
1894
+					isAllowedTo('poll_add_own');
1895
+		}
1800 1896
 		// Can you add polls to any topic, then?
1801
-		else
1802
-			isAllowedTo('poll_add_any');
1897
+		else {
1898
+					isAllowedTo('poll_add_any');
1899
+		}
1803 1900
 
1804
-		if (!isset($_POST['question']) || trim($_POST['question']) == '')
1805
-			$post_errors[] = 'no_question';
1901
+		if (!isset($_POST['question']) || trim($_POST['question']) == '') {
1902
+					$post_errors[] = 'no_question';
1903
+		}
1806 1904
 
1807 1905
 		$_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']);
1808 1906
 
1809 1907
 		// Get rid of empty ones.
1810
-		foreach ($_POST['options'] as $k => $option)
1811
-			if ($option == '')
1908
+		foreach ($_POST['options'] as $k => $option) {
1909
+					if ($option == '')
1812 1910
 				unset($_POST['options'][$k], $_POST['options'][$k]);
1911
+		}
1813 1912
 
1814 1913
 		// What are you going to vote between with one choice?!?
1815
-		if (count($_POST['options']) < 2)
1816
-			$post_errors[] = 'poll_few';
1817
-		elseif (count($_POST['options']) > 256)
1818
-			$post_errors[] = 'poll_many';
1914
+		if (count($_POST['options']) < 2) {
1915
+					$post_errors[] = 'poll_few';
1916
+		} elseif (count($_POST['options']) > 256) {
1917
+					$post_errors[] = 'poll_many';
1918
+		}
1819 1919
 	}
1820 1920
 
1821 1921
 	if ($posterIsGuest)
1822 1922
 	{
1823 1923
 		// If user is a guest, make sure the chosen name isn't taken.
1824 1924
 		require_once($sourcedir . '/Subs-Members.php');
1825
-		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name']))
1826
-			$post_errors[] = 'bad_name';
1925
+		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) {
1926
+					$post_errors[] = 'bad_name';
1927
+		}
1827 1928
 	}
1828 1929
 	// If the user isn't a guest, get his or her name and email.
1829 1930
 	elseif (!isset($_REQUEST['msg']))
@@ -1854,8 +1955,9 @@  discard block
 block discarded – undo
1854 1955
 	}
1855 1956
 
1856 1957
 	// Make sure the user isn't spamming the board.
1857
-	if (!isset($_REQUEST['msg']))
1858
-		spamProtection('post');
1958
+	if (!isset($_REQUEST['msg'])) {
1959
+			spamProtection('post');
1960
+	}
1859 1961
 
1860 1962
 	// At about this point, we're posting and that's that.
1861 1963
 	ignore_user_abort(true);
@@ -1868,32 +1970,36 @@  discard block
 block discarded – undo
1868 1970
 	$_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
1869 1971
 
1870 1972
 	// At this point, we want to make sure the subject isn't too long.
1871
-	if ($smcFunc['strlen']($_POST['subject']) > 100)
1872
-		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
1973
+	if ($smcFunc['strlen']($_POST['subject']) > 100) {
1974
+			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
1975
+	}
1873 1976
 
1874 1977
 	// Same with the "why did you edit this" text.
1875
-	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
1876
-		$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
1978
+	if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
1979
+			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
1980
+	}
1877 1981
 
1878 1982
 	// Make the poll...
1879 1983
 	if (isset($_REQUEST['poll']))
1880 1984
 	{
1881 1985
 		// Make sure that the user has not entered a ridiculous number of options..
1882
-		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
1883
-			$_POST['poll_max_votes'] = 1;
1884
-		elseif ($_POST['poll_max_votes'] > count($_POST['options']))
1885
-			$_POST['poll_max_votes'] = count($_POST['options']);
1886
-		else
1887
-			$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
1986
+		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) {
1987
+					$_POST['poll_max_votes'] = 1;
1988
+		} elseif ($_POST['poll_max_votes'] > count($_POST['options'])) {
1989
+					$_POST['poll_max_votes'] = count($_POST['options']);
1990
+		} else {
1991
+					$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
1992
+		}
1888 1993
 
1889 1994
 		$_POST['poll_expire'] = (int) $_POST['poll_expire'];
1890 1995
 		$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
1891 1996
 
1892 1997
 		// Just set it to zero if it's not there..
1893
-		if (!isset($_POST['poll_hide']))
1894
-			$_POST['poll_hide'] = 0;
1895
-		else
1896
-			$_POST['poll_hide'] = (int) $_POST['poll_hide'];
1998
+		if (!isset($_POST['poll_hide'])) {
1999
+					$_POST['poll_hide'] = 0;
2000
+		} else {
2001
+					$_POST['poll_hide'] = (int) $_POST['poll_hide'];
2002
+		}
1897 2003
 		$_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0;
1898 2004
 
1899 2005
 		$_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0;
@@ -1902,16 +2008,19 @@  discard block
 block discarded – undo
1902 2008
 		{
1903 2009
 			require_once($sourcedir . '/Subs-Members.php');
1904 2010
 			$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
1905
-			if (!in_array(-1, $allowedVoteGroups['allowed']))
1906
-				$_POST['poll_guest_vote'] = 0;
2011
+			if (!in_array(-1, $allowedVoteGroups['allowed'])) {
2012
+							$_POST['poll_guest_vote'] = 0;
2013
+			}
1907 2014
 		}
1908 2015
 
1909 2016
 		// If the user tries to set the poll too far in advance, don't let them.
1910
-		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1)
1911
-			fatal_lang_error('poll_range_error', false);
2017
+		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) {
2018
+					fatal_lang_error('poll_range_error', false);
2019
+		}
1912 2020
 		// Don't allow them to select option 2 for hidden results if it's not time limited.
1913
-		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
1914
-			$_POST['poll_hide'] = 1;
2021
+		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
2022
+					$_POST['poll_hide'] = 1;
2023
+		}
1915 2024
 
1916 2025
 		// Clean up the question and answers.
1917 2026
 		$_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']);
@@ -1925,13 +2034,15 @@  discard block
 block discarded – undo
1925 2034
 	{
1926 2035
 		$attachIDs = array();
1927 2036
 		$attach_errors = array();
1928
-		if (!empty($context['we_are_history']))
1929
-			$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2037
+		if (!empty($context['we_are_history'])) {
2038
+					$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2039
+		}
1930 2040
 
1931 2041
 		foreach ($_SESSION['temp_attachments'] as  $attachID => $attachment)
1932 2042
 		{
1933
-			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1934
-				continue;
2043
+			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
2044
+							continue;
2045
+			}
1935 2046
 
1936 2047
 			// If there was an initial error just show that message.
1937 2048
 			if ($attachID == 'initial_error')
@@ -1960,12 +2071,13 @@  discard block
 block discarded – undo
1960 2071
 				if (createAttachment($attachmentOptions))
1961 2072
 				{
1962 2073
 					$attachIDs[] = $attachmentOptions['id'];
1963
-					if (!empty($attachmentOptions['thumb']))
1964
-						$attachIDs[] = $attachmentOptions['thumb'];
2074
+					if (!empty($attachmentOptions['thumb'])) {
2075
+											$attachIDs[] = $attachmentOptions['thumb'];
2076
+					}
1965 2077
 				}
2078
+			} else {
2079
+							$attach_errors[] = '<dt>&nbsp;</dt>';
1966 2080
 			}
1967
-			else
1968
-				$attach_errors[] = '<dt>&nbsp;</dt>';
1969 2081
 
1970 2082
 			if (!empty($attachmentOptions['errors']))
1971 2083
 			{
@@ -1977,14 +2089,16 @@  discard block
 block discarded – undo
1977 2089
 					if (!is_array($error))
1978 2090
 					{
1979 2091
 						$attach_errors[] = '<dd>' . $txt[$error] . '</dd>';
1980
-						if (in_array($error, $log_these))
1981
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2092
+						if (in_array($error, $log_these)) {
2093
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2094
+						}
2095
+					} else {
2096
+											$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
1982 2097
 					}
1983
-					else
1984
-						$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
1985 2098
 				}
1986
-				if (file_exists($attachment['tmp_name']))
1987
-					unlink($attachment['tmp_name']);
2099
+				if (file_exists($attachment['tmp_name'])) {
2100
+									unlink($attachment['tmp_name']);
2101
+				}
1988 2102
 			}
1989 2103
 		}
1990 2104
 		unset($_SESSION['temp_attachments']);
@@ -2025,24 +2139,24 @@  discard block
 block discarded – undo
2025 2139
 		);
2026 2140
 
2027 2141
 		call_integration_hook('integrate_poll_add_edit', array($id_poll, false));
2142
+	} else {
2143
+			$id_poll = 0;
2028 2144
 	}
2029
-	else
2030
-		$id_poll = 0;
2031 2145
 
2032 2146
 	// Creating a new topic?
2033 2147
 	$newTopic = empty($_REQUEST['msg']) && empty($topic);
2034 2148
 
2035 2149
 	// Check the icon.
2036
-	if (!isset($_POST['icon']))
2037
-		$_POST['icon'] = 'xx';
2038
-
2039
-	else
2150
+	if (!isset($_POST['icon'])) {
2151
+			$_POST['icon'] = 'xx';
2152
+	} else
2040 2153
 	{
2041 2154
 		$_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']);
2042 2155
 
2043 2156
 		// Need to figure it out if this is a valid icon name.
2044
-		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')))
2045
-			$_POST['icon'] = 'xx';
2157
+		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) {
2158
+					$_POST['icon'] = 'xx';
2159
+		}
2046 2160
 	}
2047 2161
 
2048 2162
 	// Collect all parameters for the creation or modification of a post.
@@ -2083,8 +2197,9 @@  discard block
 block discarded – undo
2083 2197
 		}
2084 2198
 
2085 2199
 		// This will save some time...
2086
-		if (empty($approve_has_changed))
2087
-			unset($msgOptions['approved']);
2200
+		if (empty($approve_has_changed)) {
2201
+					unset($msgOptions['approved']);
2202
+		}
2088 2203
 
2089 2204
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2090 2205
 	}
@@ -2093,8 +2208,9 @@  discard block
 block discarded – undo
2093 2208
 	{
2094 2209
 		createPost($msgOptions, $topicOptions, $posterOptions);
2095 2210
 
2096
-		if (isset($topicOptions['id']))
2097
-			$topic = $topicOptions['id'];
2211
+		if (isset($topicOptions['id'])) {
2212
+					$topic = $topicOptions['id'];
2213
+		}
2098 2214
 	}
2099 2215
 
2100 2216
 	// Assign the previously uploaded attachments to the brand new message.
@@ -2106,8 +2222,9 @@  discard block
 block discarded – undo
2106 2222
 	}
2107 2223
 
2108 2224
 	// If we had a draft for this, its time to remove it since it was just posted
2109
-	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft']))
2110
-		DeleteDraft($_POST['id_draft']);
2225
+	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) {
2226
+			DeleteDraft($_POST['id_draft']);
2227
+	}
2111 2228
 
2112 2229
 	// Editing or posting an event?
2113 2230
 	if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1))
@@ -2126,8 +2243,7 @@  discard block
 block discarded – undo
2126 2243
 			'member' => $user_info['id'],
2127 2244
 		);
2128 2245
 		insertEvent($eventOptions);
2129
-	}
2130
-	elseif (isset($_POST['calendar']))
2246
+	} elseif (isset($_POST['calendar']))
2131 2247
 	{
2132 2248
 		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
2133 2249
 
@@ -2155,14 +2271,15 @@  discard block
 block discarded – undo
2155 2271
 		}
2156 2272
 
2157 2273
 		// Delete it?
2158
-		if (isset($_REQUEST['deleteevent']))
2159
-			$smcFunc['db_query']('', '
2274
+		if (isset($_REQUEST['deleteevent'])) {
2275
+					$smcFunc['db_query']('', '
2160 2276
 				DELETE FROM {db_prefix}calendar
2161 2277
 				WHERE id_event = {int:id_event}',
2162 2278
 				array(
2163 2279
 					'id_event' => $_REQUEST['eventid'],
2164 2280
 				)
2165 2281
 			);
2282
+		}
2166 2283
 		// ... or just update it?
2167 2284
 		else
2168 2285
 		{
@@ -2204,9 +2321,8 @@  discard block
 block discarded – undo
2204 2321
 			array($user_info['id'], $topic, 0),
2205 2322
 			array('id_member', 'id_topic', 'id_board')
2206 2323
 		);
2207
-	}
2208
-	elseif (!$newTopic)
2209
-		$smcFunc['db_query']('', '
2324
+	} elseif (!$newTopic) {
2325
+			$smcFunc['db_query']('', '
2210 2326
 			DELETE FROM {db_prefix}log_notify
2211 2327
 			WHERE id_member = {int:current_member}
2212 2328
 				AND id_topic = {int:current_topic}',
@@ -2215,16 +2331,20 @@  discard block
 block discarded – undo
2215 2331
 				'current_topic' => $topic,
2216 2332
 			)
2217 2333
 		);
2334
+	}
2218 2335
 
2219 2336
 	// Log an act of moderation - modifying.
2220
-	if (!empty($moderationAction))
2221
-		logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2337
+	if (!empty($moderationAction)) {
2338
+			logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2339
+	}
2222 2340
 
2223
-	if (isset($_POST['lock']) && $_POST['lock'] != 2)
2224
-		logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2341
+	if (isset($_POST['lock']) && $_POST['lock'] != 2) {
2342
+			logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2343
+	}
2225 2344
 
2226
-	if (isset($_POST['sticky']))
2227
-		logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2345
+	if (isset($_POST['sticky'])) {
2346
+			logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2347
+	}
2228 2348
 
2229 2349
 	// Returning to the topic?
2230 2350
 	if (!empty($_REQUEST['goback']))
@@ -2243,26 +2363,31 @@  discard block
 block discarded – undo
2243 2363
 		);
2244 2364
 	}
2245 2365
 
2246
-	if ($board_info['num_topics'] == 0)
2247
-		cache_put_data('board-' . $board, null, 120);
2366
+	if ($board_info['num_topics'] == 0) {
2367
+			cache_put_data('board-' . $board, null, 120);
2368
+	}
2248 2369
 
2249 2370
 	call_integration_hook('integrate_post2_end');
2250 2371
 
2251
-	if (!empty($_POST['announce_topic']))
2252
-		redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2372
+	if (!empty($_POST['announce_topic'])) {
2373
+			redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2374
+	}
2253 2375
 
2254
-	if (!empty($_POST['move']) && allowedTo('move_any'))
2255
-		redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2376
+	if (!empty($_POST['move']) && allowedTo('move_any')) {
2377
+			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2378
+	}
2256 2379
 
2257 2380
 	// Return to post if the mod is on.
2258
-	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback']))
2259
-		redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2260
-	elseif (!empty($_REQUEST['goback']))
2261
-		redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2381
+	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) {
2382
+			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2383
+	} elseif (!empty($_REQUEST['goback'])) {
2384
+			redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2385
+	}
2262 2386
 	// Dut-dut-duh-duh-DUH-duh-dut-duh-duh!  *dances to the Final Fantasy Fanfare...*
2263
-	else
2264
-		redirectexit('board=' . $board . '.0');
2265
-}
2387
+	else {
2388
+			redirectexit('board=' . $board . '.0');
2389
+	}
2390
+	}
2266 2391
 
2267 2392
 /**
2268 2393
  * Handle the announce topic function (action=announce).
@@ -2280,8 +2405,9 @@  discard block
 block discarded – undo
2280 2405
 
2281 2406
 	validateSession();
2282 2407
 
2283
-	if (empty($topic))
2284
-		fatal_lang_error('topic_gone', false);
2408
+	if (empty($topic)) {
2409
+			fatal_lang_error('topic_gone', false);
2410
+	}
2285 2411
 
2286 2412
 	loadLanguage('Post');
2287 2413
 	loadTemplate('Post');
@@ -2308,8 +2434,9 @@  discard block
 block discarded – undo
2308 2434
 	global $txt, $context, $topic, $board_info, $smcFunc;
2309 2435
 
2310 2436
 	$groups = array_merge($board_info['groups'], array(1));
2311
-	foreach ($groups as $id => $group)
2312
-		$groups[$id] = (int) $group;
2437
+	foreach ($groups as $id => $group) {
2438
+			$groups[$id] = (int) $group;
2439
+	}
2313 2440
 
2314 2441
 	$context['groups'] = array();
2315 2442
 	if (in_array(0, $groups))
@@ -2352,8 +2479,9 @@  discard block
 block discarded – undo
2352 2479
 			'group_list' => $groups,
2353 2480
 		)
2354 2481
 	);
2355
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2356
-		$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2482
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2483
+			$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2484
+	}
2357 2485
 	$smcFunc['db_free_result']($request);
2358 2486
 
2359 2487
 	// Get the subject of the topic we're about to announce.
@@ -2395,16 +2523,19 @@  discard block
 block discarded – undo
2395 2523
 	$context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
2396 2524
 	$groups = array_merge($board_info['groups'], array(1));
2397 2525
 
2398
-	if (isset($_POST['membergroups']))
2399
-		$_POST['who'] = explode(',', $_POST['membergroups']);
2526
+	if (isset($_POST['membergroups'])) {
2527
+			$_POST['who'] = explode(',', $_POST['membergroups']);
2528
+	}
2400 2529
 
2401 2530
 	// Check whether at least one membergroup was selected.
2402
-	if (empty($_POST['who']))
2403
-		fatal_lang_error('no_membergroup_selected');
2531
+	if (empty($_POST['who'])) {
2532
+			fatal_lang_error('no_membergroup_selected');
2533
+	}
2404 2534
 
2405 2535
 	// Make sure all membergroups are integers and can access the board of the announcement.
2406
-	foreach ($_POST['who'] as $id => $mg)
2407
-		$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2536
+	foreach ($_POST['who'] as $id => $mg) {
2537
+			$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2538
+	}
2408 2539
 
2409 2540
 	// Get the topic subject and censor it.
2410 2541
 	$request = $smcFunc['db_query']('', '
@@ -2450,12 +2581,13 @@  discard block
 block discarded – undo
2450 2581
 	if ($smcFunc['db_num_rows']($request) == 0)
2451 2582
 	{
2452 2583
 		logAction('announce_topic', array('topic' => $topic), 'user');
2453
-		if (!empty($_REQUEST['move']) && allowedTo('move_any'))
2454
-			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2455
-		elseif (!empty($_REQUEST['goback']))
2456
-			redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2457
-		else
2458
-			redirectexit('board=' . $board . '.0');
2584
+		if (!empty($_REQUEST['move']) && allowedTo('move_any')) {
2585
+					redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2586
+		} elseif (!empty($_REQUEST['goback'])) {
2587
+					redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2588
+		} else {
2589
+					redirectexit('board=' . $board . '.0');
2590
+		}
2459 2591
 	}
2460 2592
 
2461 2593
 	$announcements = array();
@@ -2474,8 +2606,9 @@  discard block
 block discarded – undo
2474 2606
 	foreach ($rows as $row)
2475 2607
 	{
2476 2608
 		// Force them to have it?
2477
-		if (empty($prefs[$row['id_member']]['announcements']))
2478
-			continue;
2609
+		if (empty($prefs[$row['id_member']]['announcements'])) {
2610
+					continue;
2611
+		}
2479 2612
 
2480 2613
 		$cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
2481 2614
 
@@ -2503,8 +2636,9 @@  discard block
 block discarded – undo
2503 2636
 	}
2504 2637
 
2505 2638
 	// For each language send a different mail - low priority...
2506
-	foreach ($announcements as $lang => $mail)
2507
-		sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2639
+	foreach ($announcements as $lang => $mail) {
2640
+			sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2641
+	}
2508 2642
 
2509 2643
 	$context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1);
2510 2644
 
@@ -2514,9 +2648,10 @@  discard block
 block discarded – undo
2514 2648
 	$context['sub_template'] = 'announcement_send';
2515 2649
 
2516 2650
 	// Go back to the correct language for the user ;).
2517
-	if (!empty($modSettings['userLanguage']))
2518
-		loadLanguage('Post');
2519
-}
2651
+	if (!empty($modSettings['userLanguage'])) {
2652
+			loadLanguage('Post');
2653
+	}
2654
+	}
2520 2655
 
2521 2656
 /**
2522 2657
  * Get the topic for display purposes.
@@ -2529,12 +2664,13 @@  discard block
 block discarded – undo
2529 2664
 {
2530 2665
 	global $topic, $modSettings, $context, $smcFunc, $counter, $options;
2531 2666
 
2532
-	if (isset($_REQUEST['xml']))
2533
-		$limit = '
2667
+	if (isset($_REQUEST['xml'])) {
2668
+			$limit = '
2534 2669
 		LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']);
2535
-	else
2536
-		$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2670
+	} else {
2671
+			$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2537 2672
 		LIMIT ' . (int) $modSettings['topicSummaryPosts'];
2673
+	}
2538 2674
 
2539 2675
 	// If you're modifying, get only those posts before the current one. (otherwise get all.)
2540 2676
 	$request = $smcFunc['db_query']('', '
@@ -2572,8 +2708,9 @@  discard block
 block discarded – undo
2572 2708
 			'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']),
2573 2709
 		);
2574 2710
 
2575
-		if (!empty($context['new_replies']))
2576
-			$context['new_replies']--;
2711
+		if (!empty($context['new_replies'])) {
2712
+					$context['new_replies']--;
2713
+		}
2577 2714
 	}
2578 2715
 	$smcFunc['db_free_result']($request);
2579 2716
 }
@@ -2590,8 +2727,9 @@  discard block
 block discarded – undo
2590 2727
 	global $sourcedir, $smcFunc;
2591 2728
 
2592 2729
 	loadLanguage('Post');
2593
-	if (!isset($_REQUEST['xml']))
2594
-		loadTemplate('Post');
2730
+	if (!isset($_REQUEST['xml'])) {
2731
+			loadTemplate('Post');
2732
+	}
2595 2733
 
2596 2734
 	include_once($sourcedir . '/Subs-Post.php');
2597 2735
 
@@ -2622,8 +2760,9 @@  discard block
 block discarded – undo
2622 2760
 	$smcFunc['db_free_result']($request);
2623 2761
 
2624 2762
 	$context['sub_template'] = 'quotefast';
2625
-	if (!empty($row))
2626
-		$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2763
+	if (!empty($row)) {
2764
+			$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2765
+	}
2627 2766
 
2628 2767
 	if (!empty($can_view_post))
2629 2768
 	{
@@ -2656,8 +2795,9 @@  discard block
 block discarded – undo
2656 2795
 		}
2657 2796
 
2658 2797
 		// Remove any nested quotes.
2659
-		if (!empty($modSettings['removeNestedQuotes']))
2660
-			$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2798
+		if (!empty($modSettings['removeNestedQuotes'])) {
2799
+					$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2800
+		}
2661 2801
 
2662 2802
 		$lb = "\n";
2663 2803
 
@@ -2683,14 +2823,14 @@  discard block
 block discarded – undo
2683 2823
 				'time' => '',
2684 2824
 			),
2685 2825
 		);
2686
-	}
2687
-	else
2688
-		$context['quote'] = array(
2826
+	} else {
2827
+			$context['quote'] = array(
2689 2828
 			'xml' => '',
2690 2829
 			'mozilla' => '',
2691 2830
 			'text' => '',
2692 2831
 		);
2693
-}
2832
+	}
2833
+	}
2694 2834
 
2695 2835
 /**
2696 2836
  * Used to edit the body or subject of a message inline
@@ -2702,8 +2842,9 @@  discard block
 block discarded – undo
2702 2842
 	global $user_info, $context, $smcFunc, $language, $board_info;
2703 2843
 
2704 2844
 	// We have to have a topic!
2705
-	if (empty($topic))
2706
-		obExit(false);
2845
+	if (empty($topic)) {
2846
+			obExit(false);
2847
+	}
2707 2848
 
2708 2849
 	checkSession('get');
2709 2850
 	require_once($sourcedir . '/Subs-Post.php');
@@ -2729,31 +2870,35 @@  discard block
 block discarded – undo
2729 2870
 			'guest_id' => 0,
2730 2871
 		)
2731 2872
 	);
2732
-	if ($smcFunc['db_num_rows']($request) == 0)
2733
-		fatal_lang_error('no_board', false);
2873
+	if ($smcFunc['db_num_rows']($request) == 0) {
2874
+			fatal_lang_error('no_board', false);
2875
+	}
2734 2876
 	$row = $smcFunc['db_fetch_assoc']($request);
2735 2877
 	$smcFunc['db_free_result']($request);
2736 2878
 
2737 2879
 	// Change either body or subject requires permissions to modify messages.
2738 2880
 	if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon']))
2739 2881
 	{
2740
-		if (!empty($row['locked']))
2741
-			isAllowedTo('moderate_board');
2882
+		if (!empty($row['locked'])) {
2883
+					isAllowedTo('moderate_board');
2884
+		}
2742 2885
 
2743 2886
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
2744 2887
 		{
2745
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
2746
-				fatal_lang_error('modify_post_time_passed', false);
2747
-			elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
2748
-				isAllowedTo('modify_replies');
2749
-			else
2750
-				isAllowedTo('modify_own');
2888
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
2889
+							fatal_lang_error('modify_post_time_passed', false);
2890
+			} elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
2891
+							isAllowedTo('modify_replies');
2892
+			} else {
2893
+							isAllowedTo('modify_own');
2894
+			}
2751 2895
 		}
2752 2896
 		// Otherwise, they're locked out; someone who can modify the replies is needed.
2753
-		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
2754
-			isAllowedTo('modify_replies');
2755
-		else
2756
-			isAllowedTo('modify_any');
2897
+		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) {
2898
+					isAllowedTo('modify_replies');
2899
+		} else {
2900
+					isAllowedTo('modify_any');
2901
+		}
2757 2902
 
2758 2903
 		// Only log this action if it wasn't your message.
2759 2904
 		$moderationAction = $row['id_member'] != $user_info['id'];
@@ -2765,10 +2910,10 @@  discard block
 block discarded – undo
2765 2910
 		$_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
2766 2911
 
2767 2912
 		// Maximum number of characters.
2768
-		if ($smcFunc['strlen']($_POST['subject']) > 100)
2769
-			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2770
-	}
2771
-	elseif (isset($_POST['subject']))
2913
+		if ($smcFunc['strlen']($_POST['subject']) > 100) {
2914
+					$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2915
+		}
2916
+	} elseif (isset($_POST['subject']))
2772 2917
 	{
2773 2918
 		$post_errors[] = 'no_subject';
2774 2919
 		unset($_POST['subject']);
@@ -2780,13 +2925,11 @@  discard block
 block discarded – undo
2780 2925
 		{
2781 2926
 			$post_errors[] = 'no_message';
2782 2927
 			unset($_POST['message']);
2783
-		}
2784
-		elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
2928
+		} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
2785 2929
 		{
2786 2930
 			$post_errors[] = 'long_message';
2787 2931
 			unset($_POST['message']);
2788
-		}
2789
-		else
2932
+		} else
2790 2933
 		{
2791 2934
 			$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
2792 2935
 
@@ -2802,31 +2945,34 @@  discard block
 block discarded – undo
2802 2945
 
2803 2946
 	if (isset($_POST['lock']))
2804 2947
 	{
2805
-		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member']))
2806
-			unset($_POST['lock']);
2807
-		elseif (!allowedTo('lock_any'))
2948
+		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) {
2949
+					unset($_POST['lock']);
2950
+		} elseif (!allowedTo('lock_any'))
2808 2951
 		{
2809
-			if ($row['locked'] == 1)
2810
-				unset($_POST['lock']);
2811
-			else
2812
-				$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
2952
+			if ($row['locked'] == 1) {
2953
+							unset($_POST['lock']);
2954
+			} else {
2955
+							$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
2956
+			}
2957
+		} elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) {
2958
+					unset($_POST['lock']);
2959
+		} else {
2960
+					$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2813 2961
 		}
2814
-		elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked'])
2815
-			unset($_POST['lock']);
2816
-		else
2817
-			$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2818 2962
 	}
2819 2963
 
2820
-	if (isset($_POST['sticky']) && !allowedTo('make_sticky'))
2821
-		unset($_POST['sticky']);
2964
+	if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
2965
+			unset($_POST['sticky']);
2966
+	}
2822 2967
 
2823 2968
 	if (isset($_POST['modify_reason']))
2824 2969
 	{
2825 2970
 		$_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
2826 2971
 
2827 2972
 		// Maximum number of characters.
2828
-		if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
2829
-			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2973
+		if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
2974
+					$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2975
+		}
2830 2976
 	}
2831 2977
 
2832 2978
 	if (empty($post_errors))
@@ -2863,8 +3009,9 @@  discard block
 block discarded – undo
2863 3009
 			}
2864 3010
 		}
2865 3011
 		// If nothing was changed there's no need to add an entry to the moderation log.
2866
-		else
2867
-			$moderationAction = false;
3012
+		else {
3013
+					$moderationAction = false;
3014
+		}
2868 3015
 
2869 3016
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2870 3017
 
@@ -2882,9 +3029,9 @@  discard block
 block discarded – undo
2882 3029
 			// Get the proper (default language) response prefix first.
2883 3030
 			if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
2884 3031
 			{
2885
-				if ($language === $user_info['language'])
2886
-					$context['response_prefix'] = $txt['response_prefix'];
2887
-				else
3032
+				if ($language === $user_info['language']) {
3033
+									$context['response_prefix'] = $txt['response_prefix'];
3034
+				} else
2888 3035
 				{
2889 3036
 					loadLanguage('index', $language, false);
2890 3037
 					$context['response_prefix'] = $txt['response_prefix'];
@@ -2906,8 +3053,9 @@  discard block
 block discarded – undo
2906 3053
 			);
2907 3054
 		}
2908 3055
 
2909
-		if (!empty($moderationAction))
2910
-			logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3056
+		if (!empty($moderationAction)) {
3057
+					logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3058
+		}
2911 3059
 	}
2912 3060
 
2913 3061
 	if (isset($_REQUEST['xml']))
@@ -2948,8 +3096,7 @@  discard block
 block discarded – undo
2948 3096
 			);
2949 3097
 
2950 3098
 			censorText($context['message']['subject']);
2951
-		}
2952
-		else
3099
+		} else
2953 3100
 		{
2954 3101
 			$context['message'] = array(
2955 3102
 				'id' => $row['id_msg'],
@@ -2961,15 +3108,16 @@  discard block
 block discarded – undo
2961 3108
 			loadLanguage('Errors');
2962 3109
 			foreach ($post_errors as $post_error)
2963 3110
 			{
2964
-				if ($post_error == 'long_message')
2965
-					$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
2966
-				else
2967
-					$context['message']['errors'][] = $txt['error_' . $post_error];
3111
+				if ($post_error == 'long_message') {
3112
+									$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
3113
+				} else {
3114
+									$context['message']['errors'][] = $txt['error_' . $post_error];
3115
+				}
2968 3116
 			}
2969 3117
 		}
3118
+	} else {
3119
+			obExit(false);
3120
+	}
2970 3121
 	}
2971
-	else
2972
-		obExit(false);
2973
-}
2974 3122
 
2975 3123
 ?>
2976 3124
\ 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/Subs-Package.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  * @param bool $single_file If true returns the contents of the file specified by destination if it exists
29 29
  * @param bool $overwrite Whether to overwrite existing files
30 30
  * @param null|array $files_to_extract Specific files to extract
31
- * @return array|false An array of information about extracted files or false on failure
31
+ * @return string An array of information about extracted files or false on failure
32 32
  */
33 33
 function read_tgz_file($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
34 34
 {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  * @param bool $single_file Whether to only extract a single file
60 60
  * @param bool $overwrite Whether to overwrite existing data
61 61
  * @param null|array $files_to_extract If set, only extracts the specified files
62
- * @return array|false An array of information about the extracted files or false on failure
62
+ * @return string An array of information about the extracted files or false on failure
63 63
  */
64 64
 function read_tgz_data($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
65 65
 {
@@ -3255,7 +3255,7 @@  discard block
 block discarded – undo
3255 3255
 	 * https://php.net/crc32#79567
3256 3256
 	 *
3257 3257
 	 * @param string $number
3258
-	 * @return string The crc32
3258
+	 * @return integer The crc32
3259 3259
 	 */
3260 3260
 	function smf_crc32($number)
3261 3261
 	{
Please login to merge, or discard this patch.
Braces   +853 added lines, -669 removed lines patch added patch discarded remove patch
@@ -16,8 +16,9 @@  discard block
 block discarded – undo
16 16
  * @version 2.1 Beta 4
17 17
  */
18 18
 
19
-if (!defined('SMF'))
19
+if (!defined('SMF')) {
20 20
 	die('No direct access...');
21
+}
21 22
 
22 23
 /**
23 24
  * Reads a .tar.gz file, filename, in and extracts file(s) from it.
@@ -67,47 +68,53 @@  discard block
 block discarded – undo
67 68
 	loadLanguage('Packages');
68 69
 
69 70
 	// This function sorta needs gzinflate!
70
-	if (!function_exists('gzinflate'))
71
-		fatal_lang_error('package_no_zlib', 'critical');
71
+	if (!function_exists('gzinflate')) {
72
+			fatal_lang_error('package_no_zlib', 'critical');
73
+	}
72 74
 
73 75
 	if (substr($gzfilename, 0, 7) == 'http://' || substr($gzfilename, 0, 8) == 'https://')
74 76
 	{
75 77
 		$data = fetch_web_data($gzfilename);
76 78
 
77
-		if ($data === false)
78
-			return false;
79
-	}
80
-	else
79
+		if ($data === false) {
80
+					return false;
81
+		}
82
+	} else
81 83
 	{
82 84
 		$data = @file_get_contents($gzfilename);
83 85
 
84
-		if ($data === false)
85
-			return false;
86
+		if ($data === false) {
87
+					return false;
88
+		}
86 89
 	}
87 90
 
88 91
 	umask(0);
89
-	if (!$single_file && $destination !== null && !file_exists($destination))
90
-		mktree($destination, 0777);
92
+	if (!$single_file && $destination !== null && !file_exists($destination)) {
93
+			mktree($destination, 0777);
94
+	}
91 95
 
92 96
 	// No signature?
93
-	if (strlen($data) < 2)
94
-		return false;
97
+	if (strlen($data) < 2) {
98
+			return false;
99
+	}
95 100
 
96 101
 	$id = unpack('H2a/H2b', substr($data, 0, 2));
97 102
 	if (strtolower($id['a'] . $id['b']) != '1f8b')
98 103
 	{
99 104
 		// Okay, this ain't no tar.gz, but maybe it's a zip file.
100
-		if (substr($data, 0, 2) == 'PK')
101
-			return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract);
102
-		else
103
-			return false;
105
+		if (substr($data, 0, 2) == 'PK') {
106
+					return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract);
107
+		} else {
108
+					return false;
109
+		}
104 110
 	}
105 111
 
106 112
 	$flags = unpack('Ct/Cf', substr($data, 2, 2));
107 113
 
108 114
 	// Not deflate!
109
-	if ($flags['t'] != 8)
110
-		return false;
115
+	if ($flags['t'] != 8) {
116
+			return false;
117
+	}
111 118
 	$flags = $flags['f'];
112 119
 
113 120
 	$offset = 10;
@@ -117,18 +124,21 @@  discard block
 block discarded – undo
117 124
 	// @todo Might be mussed.
118 125
 	if ($flags & 12)
119 126
 	{
120
-		while ($flags & 8 && $data{$offset++} != "\0")
121
-			continue;
122
-		while ($flags & 4 && $data{$offset++} != "\0")
123
-			continue;
127
+		while ($flags & 8 && $data{$offset++} != "\0") {
128
+					continue;
129
+		}
130
+		while ($flags & 4 && $data{$offset++} != "\0") {
131
+					continue;
132
+		}
124 133
 	}
125 134
 
126 135
 	$crc = unpack('Vcrc32/Visize', substr($data, strlen($data) - 8, 8));
127 136
 	$data = @gzinflate(substr($data, $offset, strlen($data) - 8 - $offset));
128 137
 
129 138
 	// smf_crc32 and crc32 may not return the same results, so we accept either.
130
-	if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data))
131
-		return false;
139
+	if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data)) {
140
+			return false;
141
+	}
132 142
 
133 143
 	$blocks = strlen($data) / 512 - 1;
134 144
 	$offset = 0;
@@ -149,83 +159,98 @@  discard block
 block discarded – undo
149 159
 
150 160
 		foreach ($current as $k => $v)
151 161
 		{
152
-			if (in_array($k, $octdec))
153
-				$current[$k] = octdec(trim($v));
154
-			else
155
-				$current[$k] = trim($v);
162
+			if (in_array($k, $octdec)) {
163
+							$current[$k] = octdec(trim($v));
164
+			} else {
165
+							$current[$k] = trim($v);
166
+			}
156 167
 		}
157 168
 
158
-		if ($current['type'] == 5 && substr($current['filename'], -1) != '/')
159
-			$current['filename'] .= '/';
169
+		if ($current['type'] == 5 && substr($current['filename'], -1) != '/') {
170
+					$current['filename'] .= '/';
171
+		}
160 172
 
161 173
 		$checksum = 256;
162
-		for ($i = 0; $i < 148; $i++)
163
-			$checksum += ord($header{$i});
164
-		for ($i = 156; $i < 512; $i++)
165
-			$checksum += ord($header{$i});
174
+		for ($i = 0; $i < 148; $i++) {
175
+					$checksum += ord($header{$i});
176
+		}
177
+		for ($i = 156; $i < 512; $i++) {
178
+					$checksum += ord($header{$i});
179
+		}
166 180
 
167
-		if ($current['checksum'] != $checksum)
168
-			break;
181
+		if ($current['checksum'] != $checksum) {
182
+					break;
183
+		}
169 184
 
170 185
 		$size = ceil($current['size'] / 512);
171 186
 		$current['data'] = substr($data, ++$offset << 9, $current['size']);
172 187
 		$offset += $size;
173 188
 
174 189
 		// Not a directory and doesn't exist already...
175
-		if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename']))
176
-			$write_this = true;
190
+		if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename'])) {
191
+					$write_this = true;
192
+		}
177 193
 		// File exists... check if it is newer.
178
-		elseif (substr($current['filename'], -1, 1) != '/')
179
-			$write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime'];
194
+		elseif (substr($current['filename'], -1, 1) != '/') {
195
+					$write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime'];
196
+		}
180 197
 		// Folder... create.
181 198
 		elseif ($destination !== null && !$single_file)
182 199
 		{
183 200
 			// Protect from accidental parent directory writing...
184 201
 			$current['filename'] = strtr($current['filename'], array('../' => '', '/..' => ''));
185 202
 
186
-			if (!file_exists($destination . '/' . $current['filename']))
187
-				mktree($destination . '/' . $current['filename'], 0777);
203
+			if (!file_exists($destination . '/' . $current['filename'])) {
204
+							mktree($destination . '/' . $current['filename'], 0777);
205
+			}
188 206
 			$write_this = false;
207
+		} else {
208
+					$write_this = false;
189 209
 		}
190
-		else
191
-			$write_this = false;
192 210
 
193 211
 		if ($write_this && $destination !== null)
194 212
 		{
195
-			if (strpos($current['filename'], '/') !== false && !$single_file)
196
-				mktree($destination . '/' . dirname($current['filename']), 0777);
213
+			if (strpos($current['filename'], '/') !== false && !$single_file) {
214
+							mktree($destination . '/' . dirname($current['filename']), 0777);
215
+			}
197 216
 
198 217
 			// Is this the file we're looking for?
199
-			if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename'])))
200
-				return $current['data'];
218
+			if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename']))) {
219
+							return $current['data'];
220
+			}
201 221
 			// If we're looking for another file, keep going.
202
-			elseif ($single_file)
203
-				continue;
222
+			elseif ($single_file) {
223
+							continue;
224
+			}
204 225
 			// Looking for restricted files?
205
-			elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract))
206
-				continue;
226
+			elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract)) {
227
+							continue;
228
+			}
207 229
 
208 230
 			package_put_contents($destination . '/' . $current['filename'], $current['data']);
209 231
 		}
210 232
 
211
-		if (substr($current['filename'], -1, 1) != '/')
212
-			$return[] = array(
233
+		if (substr($current['filename'], -1, 1) != '/') {
234
+					$return[] = array(
213 235
 				'filename' => $current['filename'],
214 236
 				'md5' => md5($current['data']),
215 237
 				'preview' => substr($current['data'], 0, 100),
216 238
 				'size' => $current['size'],
217 239
 				'skipped' => false
218 240
 			);
241
+		}
219 242
 	}
220 243
 
221
-	if ($destination !== null && !$single_file)
222
-		package_flush_cache();
244
+	if ($destination !== null && !$single_file) {
245
+			package_flush_cache();
246
+	}
223 247
 
224
-	if ($single_file)
225
-		return false;
226
-	else
227
-		return $return;
228
-}
248
+	if ($single_file) {
249
+			return false;
250
+	} else {
251
+			return $return;
252
+	}
253
+	}
229 254
 
230 255
 /**
231 256
  * Extract zip data. A functional copy of {@list read_zip_data()}.
@@ -254,65 +279,74 @@  discard block
 block discarded – undo
254 279
 			{
255 280
 				$i = $iterator->getSubPathname();
256 281
 				// If this is a file, and it doesn't exist.... happy days!
257
-				if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i))
258
-					$write_this = true;
282
+				if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i)) {
283
+									$write_this = true;
284
+				}
259 285
 				// If the file exists, we may not want to overwrite it.
260
-				elseif (substr($i, -1) != '/')
261
-					$write_this = $overwrite;
262
-				else
263
-					$write_this = false;
286
+				elseif (substr($i, -1) != '/') {
287
+									$write_this = $overwrite;
288
+				} else {
289
+									$write_this = false;
290
+				}
264 291
 
265 292
 				// Get the actual compressed data.
266
-				if (!$file_info->isDir())
267
-					$file_data = file_get_contents($file_info);
268
-				elseif ($destination !== null && !$single_file)
293
+				if (!$file_info->isDir()) {
294
+									$file_data = file_get_contents($file_info);
295
+				} elseif ($destination !== null && !$single_file)
269 296
 				{
270 297
 					// Folder... create.
271
-					if (!file_exists($destination . '/' . $i))
272
-						mktree($destination . '/' . $i, 0777);
298
+					if (!file_exists($destination . '/' . $i)) {
299
+											mktree($destination . '/' . $i, 0777);
300
+					}
273 301
 					$file_data = null;
302
+				} else {
303
+									$file_data = null;
274 304
 				}
275
-				else
276
-					$file_data = null;
277 305
 
278 306
 				// Okay!  We can write this file, looks good from here...
279 307
 				if ($write_this && $destination !== null)
280 308
 				{
281
-					if (!$single_file && !is_dir($destination . '/' . dirname($i)))
282
-						mktree($destination . '/' . dirname($i), 0777);
309
+					if (!$single_file && !is_dir($destination . '/' . dirname($i))) {
310
+											mktree($destination . '/' . dirname($i), 0777);
311
+					}
283 312
 
284 313
 					// If we're looking for a specific file, and this is it... ka-bam, baby.
285
-					if ($single_file && ($destination == $i || $destination == '*/' . basename($i)))
286
-						return $file_data;
314
+					if ($single_file && ($destination == $i || $destination == '*/' . basename($i))) {
315
+											return $file_data;
316
+					}
287 317
 					// Oh?  Another file.  Fine.  You don't like this file, do you?  I know how it is.  Yeah... just go away.  No, don't apologize.  I know this file's just not *good enough* for you.
288
-					elseif ($single_file)
289
-						continue;
318
+					elseif ($single_file) {
319
+											continue;
320
+					}
290 321
 					// Don't really want this?
291
-					elseif ($files_to_extract !== null && !in_array($i, $files_to_extract))
292
-						continue;
322
+					elseif ($files_to_extract !== null && !in_array($i, $files_to_extract)) {
323
+											continue;
324
+					}
293 325
 
294 326
 					package_put_contents($destination . '/' . $i, $file_data);
295 327
 				}
296 328
 
297
-				if (substr($i, -1, 1) != '/')
298
-					$return[] = array(
329
+				if (substr($i, -1, 1) != '/') {
330
+									$return[] = array(
299 331
 						'filename' => $i,
300 332
 						'md5' => md5($file_data),
301 333
 						'preview' => substr($file_data, 0, 100),
302 334
 						'size' => strlen($file_data),
303 335
 						'skipped' => false
304 336
 					);
337
+				}
305 338
 			}
306 339
 
307
-		if ($destination !== null && !$single_file)
308
-			package_flush_cache();
340
+		if ($destination !== null && !$single_file) {
341
+					package_flush_cache();
342
+		}
309 343
 
310
-		if ($single_file)
311
-			return false;
312
-		else
313
-			return $return;
314
-	}
315
-	catch (Exception $e)
344
+		if ($single_file) {
345
+					return false;
346
+		} else {
347
+					return $return;
348
+		}
349
+	} catch (Exception $e)
316 350
 	{
317 351
 		return false;
318 352
 	}
@@ -334,13 +368,15 @@  discard block
 block discarded – undo
334 368
 function read_zip_data($data, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
335 369
 {
336 370
 	umask(0);
337
-	if ($destination !== null && !file_exists($destination) && !$single_file)
338
-		mktree($destination, 0777);
371
+	if ($destination !== null && !file_exists($destination) && !$single_file) {
372
+			mktree($destination, 0777);
373
+	}
339 374
 
340 375
 	// Look for the end of directory signature 0x06054b50
341 376
 	$data_ecr = explode("\x50\x4b\x05\x06", $data);
342
-	if (!isset($data_ecr[1]))
343
-		return false;
377
+	if (!isset($data_ecr[1])) {
378
+			return false;
379
+	}
344 380
 
345 381
 	$return = array();
346 382
 
@@ -355,8 +391,9 @@  discard block
 block discarded – undo
355 391
 	array_shift($file_sections);
356 392
 
357 393
 	// sections and count from the signature must match or the zip file is bad
358
-	if (count($file_sections) != $zip_info['files'])
359
-		return false;
394
+	if (count($file_sections) != $zip_info['files']) {
395
+			return false;
396
+	}
360 397
 
361 398
 	// go though each file in the archive
362 399
 	foreach ($file_sections as $data)
@@ -378,68 +415,79 @@  discard block
 block discarded – undo
378 415
 		}
379 416
 
380 417
 		// If this is a file, and it doesn't exist.... happy days!
381
-		if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename']))
382
-			$write_this = true;
418
+		if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename'])) {
419
+					$write_this = true;
420
+		}
383 421
 		// If the file exists, we may not want to overwrite it.
384
-		elseif (substr($file_info['filename'], -1) != '/')
385
-			$write_this = $overwrite;
422
+		elseif (substr($file_info['filename'], -1) != '/') {
423
+					$write_this = $overwrite;
424
+		}
386 425
 		// This is a directory, so we're gonna want to create it. (probably...)
387 426
 		elseif ($destination !== null && !$single_file)
388 427
 		{
389 428
 			// Just a little accident prevention, don't mind me.
390 429
 			$file_info['filename'] = strtr($file_info['filename'], array('../' => '', '/..' => ''));
391 430
 
392
-			if (!file_exists($destination . '/' . $file_info['filename']))
393
-				mktree($destination . '/' . $file_info['filename'], 0777);
431
+			if (!file_exists($destination . '/' . $file_info['filename'])) {
432
+							mktree($destination . '/' . $file_info['filename'], 0777);
433
+			}
394 434
 			$write_this = false;
435
+		} else {
436
+					$write_this = false;
395 437
 		}
396
-		else
397
-			$write_this = false;
398 438
 
399 439
 		// Get the actual compressed data.
400 440
 		$file_info['data'] = substr($data, 26 + $file_info['filename_length'] + $file_info['extrafield_length']);
401 441
 
402 442
 		// Only inflate it if we need to ;)
403
-		if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size']))
404
-			$file_info['data'] = gzinflate($file_info['data']);
443
+		if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size'])) {
444
+					$file_info['data'] = gzinflate($file_info['data']);
445
+		}
405 446
 
406 447
 		// Okay!  We can write this file, looks good from here...
407 448
 		if ($write_this && $destination !== null)
408 449
 		{
409
-			if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir'])))
410
-				mktree($file_info['dir'], 0777);
450
+			if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir']))) {
451
+							mktree($file_info['dir'], 0777);
452
+			}
411 453
 
412 454
 			// If we're looking for a specific file, and this is it... ka-bam, baby.
413
-			if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename'])))
414
-				return $file_info['data'];
455
+			if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename']))) {
456
+							return $file_info['data'];
457
+			}
415 458
 			// Oh?  Another file.  Fine.  You don't like this file, do you?  I know how it is.  Yeah... just go away.  No, don't apologize.  I know this file's just not *good enough* for you.
416
-			elseif ($single_file)
417
-				continue;
459
+			elseif ($single_file) {
460
+							continue;
461
+			}
418 462
 			// Don't really want this?
419
-			elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract))
420
-				continue;
463
+			elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract)) {
464
+							continue;
465
+			}
421 466
 
422 467
 			package_put_contents($destination . '/' . $file_info['filename'], $file_info['data']);
423 468
 		}
424 469
 
425
-		if (substr($file_info['filename'], -1, 1) != '/')
426
-			$return[] = array(
470
+		if (substr($file_info['filename'], -1, 1) != '/') {
471
+					$return[] = array(
427 472
 				'filename' => $file_info['filename'],
428 473
 				'md5' => md5($file_info['data']),
429 474
 				'preview' => substr($file_info['data'], 0, 100),
430 475
 				'size' => $file_info['size'],
431 476
 				'skipped' => false
432 477
 			);
478
+		}
433 479
 	}
434 480
 
435
-	if ($destination !== null && !$single_file)
436
-		package_flush_cache();
481
+	if ($destination !== null && !$single_file) {
482
+			package_flush_cache();
483
+	}
437 484
 
438
-	if ($single_file)
439
-		return false;
440
-	else
441
-		return $return;
442
-}
485
+	if ($single_file) {
486
+			return false;
487
+	} else {
488
+			return $return;
489
+	}
490
+	}
443 491
 
444 492
 /**
445 493
  * Checks the existence of a remote file since file_exists() does not do remote.
@@ -451,14 +499,16 @@  discard block
 block discarded – undo
451 499
 {
452 500
 	$a_url = parse_url($url);
453 501
 
454
-	if (!isset($a_url['scheme']))
455
-		return false;
502
+	if (!isset($a_url['scheme'])) {
503
+			return false;
504
+	}
456 505
 
457 506
 	// Attempt to connect...
458 507
 	$temp = '';
459 508
 	$fid = fsockopen($a_url['host'], !isset($a_url['port']) ? 80 : $a_url['port'], $temp, $temp, 8);
460
-	if (!$fid)
461
-		return false;
509
+	if (!$fid) {
510
+			return false;
511
+	}
462 512
 
463 513
 	fputs($fid, 'HEAD ' . $a_url['path'] . ' HTTP/1.0' . "\r\n" . 'Host: ' . $a_url['host'] . "\r\n\r\n");
464 514
 	$head = fread($fid, 1024);
@@ -493,8 +543,9 @@  discard block
 block discarded – undo
493 543
 	while ($row = $smcFunc['db_fetch_assoc']($request))
494 544
 	{
495 545
 		// Already found this? If so don't add it twice!
496
-		if (in_array($row['package_id'], $found))
497
-			continue;
546
+		if (in_array($row['package_id'], $found)) {
547
+					continue;
548
+		}
498 549
 
499 550
 		$found[] = $row['package_id'];
500 551
 
@@ -529,19 +580,21 @@  discard block
 block discarded – undo
529 580
 	global $sourcedir, $packagesdir;
530 581
 
531 582
 	// Extract package-info.xml from downloaded file. (*/ is used because it could be in any directory.)
532
-	if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false)
533
-		$packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true);
534
-	else
583
+	if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false) {
584
+			$packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true);
585
+	} else
535 586
 	{
536
-		if (!file_exists($packagesdir . '/' . $gzfilename))
537
-			return 'package_get_error_not_found';
587
+		if (!file_exists($packagesdir . '/' . $gzfilename)) {
588
+					return 'package_get_error_not_found';
589
+		}
538 590
 
539
-		if (is_file($packagesdir . '/' . $gzfilename))
540
-			$packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true);
541
-		elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml'))
542
-			$packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml');
543
-		else
544
-			return 'package_get_error_missing_xml';
591
+		if (is_file($packagesdir . '/' . $gzfilename)) {
592
+					$packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true);
593
+		} elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml')) {
594
+					$packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml');
595
+		} else {
596
+					return 'package_get_error_missing_xml';
597
+		}
545 598
 	}
546 599
 
547 600
 	// Nothing?
@@ -549,10 +602,11 @@  discard block
 block discarded – undo
549 602
 	{
550 603
 		// Perhaps they are trying to install a theme, lets tell them nicely this is the wrong function
551 604
 		$packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/theme_info.xml', true);
552
-		if (!empty($packageInfo))
553
-			return 'package_get_error_is_theme';
554
-		else
555
-			return 'package_get_error_is_zero';
605
+		if (!empty($packageInfo)) {
606
+					return 'package_get_error_is_theme';
607
+		} else {
608
+					return 'package_get_error_is_zero';
609
+		}
556 610
 	}
557 611
 
558 612
 	// Parse package-info.xml into an xmlArray.
@@ -560,8 +614,9 @@  discard block
 block discarded – undo
560 614
 	$packageInfo = new xmlArray($packageInfo);
561 615
 
562 616
 	// @todo Error message of some sort?
563
-	if (!$packageInfo->exists('package-info[0]'))
564
-		return 'package_get_error_packageinfo_corrupt';
617
+	if (!$packageInfo->exists('package-info[0]')) {
618
+			return 'package_get_error_packageinfo_corrupt';
619
+	}
565 620
 
566 621
 	$packageInfo = $packageInfo->path('package-info[0]');
567 622
 
@@ -580,8 +635,9 @@  discard block
 block discarded – undo
580 635
 		}
581 636
 	}
582 637
 
583
-	if (!isset($package['type']))
584
-		$package['type'] = 'modification';
638
+	if (!isset($package['type'])) {
639
+			$package['type'] = 'modification';
640
+	}
585 641
 
586 642
 	return $package;
587 643
 }
@@ -634,15 +690,14 @@  discard block
 block discarded – undo
634 690
 					{
635 691
 						$ftp_file = strtr($file, array($_SESSION['pack_ftp']['root'] => ''));
636 692
 						$package_ftp->chmod($ftp_file, $perms);
693
+					} else {
694
+											smf_chmod($file, $perms);
637 695
 					}
638
-					else
639
-						smf_chmod($file, $perms);
640 696
 
641 697
 					$new_permissions = @fileperms($file);
642 698
 					$result = $new_permissions == $perms ? 'success' : 'failure';
643 699
 					unset($_SESSION['pack_ftp']['original_perms'][$file]);
644
-				}
645
-				elseif ($do_change)
700
+				} elseif ($do_change)
646 701
 				{
647 702
 					$new_permissions = '';
648 703
 					$result = 'skipped';
@@ -758,8 +813,7 @@  discard block
 block discarded – undo
758 813
 
759 814
 			$context['sub_template'] = 'show_list';
760 815
 			$context['default_list'] = 'restore_file_permissions';
761
-		}
762
-		else
816
+		} else
763 817
 		{
764 818
 			unset($listOptions['columns']['result']);
765 819
 		}
@@ -769,12 +823,14 @@  discard block
 block discarded – undo
769 823
 		createList($listOptions);
770 824
 
771 825
 		// If we just restored permissions then whereever we are, we are now done and dusted.
772
-		if (!empty($_POST['restore_perms']))
773
-			obExit();
826
+		if (!empty($_POST['restore_perms'])) {
827
+					obExit();
828
+		}
774 829
 	}
775 830
 	// Otherwise, it's entirely irrelevant?
776
-	elseif ($restore_write_status)
777
-		return true;
831
+	elseif ($restore_write_status) {
832
+			return true;
833
+	}
778 834
 
779 835
 	// This is where we report what we got up to.
780 836
 	$return_data = array(
@@ -812,11 +868,12 @@  discard block
 block discarded – undo
812 868
 			if (!in_array($_POST['ftp_path'], array('', '/')))
813 869
 			{
814 870
 				$ftp_root = strtr($boarddir, array($_POST['ftp_path'] => ''));
815
-				if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/'))
816
-					$ftp_root = substr($ftp_root, 0, -1);
871
+				if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) {
872
+									$ftp_root = substr($ftp_root, 0, -1);
873
+				}
874
+			} else {
875
+							$ftp_root = $boarddir;
817 876
 			}
818
-			else
819
-				$ftp_root = $boarddir;
820 877
 
821 878
 			$_SESSION['pack_ftp'] = array(
822 879
 				'server' => $_POST['ftp_server'],
@@ -828,8 +885,9 @@  discard block
 block discarded – undo
828 885
 				'connected' => true,
829 886
 			);
830 887
 
831
-			if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path'])
832
-				updateSettings(array('package_path' => $_POST['ftp_path']));
888
+			if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) {
889
+							updateSettings(array('package_path' => $_POST['ftp_path']));
890
+			}
833 891
 
834 892
 			// This is now the primary connection.
835 893
 			$package_ftp = $ftp;
@@ -842,12 +900,13 @@  discard block
 block discarded – undo
842 900
 		foreach ($chmodFiles as $k => $file)
843 901
 		{
844 902
 			// Sometimes this can somehow happen maybe?
845
-			if (empty($file))
846
-				unset($chmodFiles[$k]);
903
+			if (empty($file)) {
904
+							unset($chmodFiles[$k]);
905
+			}
847 906
 			// Already writable?
848
-			elseif (@is_writable($file))
849
-				$return_data['files']['writable'][] = $file;
850
-			else
907
+			elseif (@is_writable($file)) {
908
+							$return_data['files']['writable'][] = $file;
909
+			} else
851 910
 			{
852 911
 				// Now try to change that.
853 912
 				$return_data['files'][package_chmod($file, 'writable', true) ? 'writable' : 'notwritable'][] = $file;
@@ -864,19 +923,21 @@  discard block
 block discarded – undo
864 923
 			{
865 924
 				require_once($sourcedir . '/Class-Package.php');
866 925
 				$ftp = new ftp_connection(null);
926
+			} elseif ($ftp->error !== false && !isset($ftp_error)) {
927
+							$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
867 928
 			}
868
-			elseif ($ftp->error !== false && !isset($ftp_error))
869
-				$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
870 929
 
871 930
 			list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
872 931
 
873
-			if ($found_path)
874
-				$_POST['ftp_path'] = $detect_path;
875
-			elseif (!isset($_POST['ftp_path']))
876
-				$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
932
+			if ($found_path) {
933
+							$_POST['ftp_path'] = $detect_path;
934
+			} elseif (!isset($_POST['ftp_path'])) {
935
+							$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
936
+			}
877 937
 
878
-			if (!isset($_POST['ftp_username']))
879
-				$_POST['ftp_username'] = $username;
938
+			if (!isset($_POST['ftp_username'])) {
939
+							$_POST['ftp_username'] = $username;
940
+			}
880 941
 		}
881 942
 
882 943
 		$context['package_ftp'] = array(
@@ -889,8 +950,9 @@  discard block
 block discarded – undo
889 950
 		);
890 951
 
891 952
 		// Which files failed?
892
-		if (!isset($context['notwritable_files']))
893
-			$context['notwritable_files'] = array();
953
+		if (!isset($context['notwritable_files'])) {
954
+					$context['notwritable_files'] = array();
955
+		}
894 956
 		$context['notwritable_files'] = array_merge($context['notwritable_files'], $return_data['files']['notwritable']);
895 957
 
896 958
 		// Sent here to die?
@@ -923,40 +985,48 @@  discard block
 block discarded – undo
923 985
 		foreach ($files as $k => $file)
924 986
 		{
925 987
 			// If this file doesn't exist, then we actually want to look at the directory, no?
926
-			if (!file_exists($file))
927
-				$file = dirname($file);
988
+			if (!file_exists($file)) {
989
+							$file = dirname($file);
990
+			}
928 991
 
929 992
 			// This looks odd, but it's an attempt to work around PHP suExec.
930
-			if (!@is_writable($file))
931
-				smf_chmod($file, 0755);
932
-			if (!@is_writable($file))
933
-				smf_chmod($file, 0777);
934
-			if (!@is_writable(dirname($file)))
935
-				smf_chmod($file, 0755);
936
-			if (!@is_writable(dirname($file)))
937
-				smf_chmod($file, 0777);
993
+			if (!@is_writable($file)) {
994
+							smf_chmod($file, 0755);
995
+			}
996
+			if (!@is_writable($file)) {
997
+							smf_chmod($file, 0777);
998
+			}
999
+			if (!@is_writable(dirname($file))) {
1000
+							smf_chmod($file, 0755);
1001
+			}
1002
+			if (!@is_writable(dirname($file))) {
1003
+							smf_chmod($file, 0777);
1004
+			}
938 1005
 
939 1006
 			$fp = is_dir($file) ? @opendir($file) : @fopen($file, 'rb');
940 1007
 			if (@is_writable($file) && $fp)
941 1008
 			{
942 1009
 				unset($files[$k]);
943
-				if (!is_dir($file))
944
-					fclose($fp);
945
-				else
946
-					closedir($fp);
1010
+				if (!is_dir($file)) {
1011
+									fclose($fp);
1012
+				} else {
1013
+									closedir($fp);
1014
+				}
947 1015
 			}
948 1016
 		}
949 1017
 
950 1018
 		// No FTP required!
951
-		if (empty($files))
952
-			return array();
1019
+		if (empty($files)) {
1020
+					return array();
1021
+		}
953 1022
 	}
954 1023
 
955 1024
 	// They've opted to not use FTP, and try anyway.
956 1025
 	if (isset($_SESSION['pack_ftp']) && $_SESSION['pack_ftp'] == false)
957 1026
 	{
958
-		if ($files === null)
959
-			return array();
1027
+		if ($files === null) {
1028
+					return array();
1029
+		}
960 1030
 
961 1031
 		foreach ($files as $k => $file)
962 1032
 		{
@@ -968,26 +1038,29 @@  discard block
 block discarded – undo
968 1038
 				smf_chmod($file, 0755);
969 1039
 			}
970 1040
 
971
-			if (!@is_writable($file))
972
-				smf_chmod($file, 0777);
973
-			if (!@is_writable(dirname($file)))
974
-				smf_chmod(dirname($file), 0777);
1041
+			if (!@is_writable($file)) {
1042
+							smf_chmod($file, 0777);
1043
+			}
1044
+			if (!@is_writable(dirname($file))) {
1045
+							smf_chmod(dirname($file), 0777);
1046
+			}
975 1047
 
976
-			if (@is_writable($file))
977
-				unset($files[$k]);
1048
+			if (@is_writable($file)) {
1049
+							unset($files[$k]);
1050
+			}
978 1051
 		}
979 1052
 
980 1053
 		return $files;
981
-	}
982
-	elseif (isset($_SESSION['pack_ftp']))
1054
+	} elseif (isset($_SESSION['pack_ftp']))
983 1055
 	{
984 1056
 		// Load the file containing the ftp_connection class.
985 1057
 		require_once($sourcedir . '/Class-Package.php');
986 1058
 
987 1059
 		$package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password']));
988 1060
 
989
-		if ($files === null)
990
-			return array();
1061
+		if ($files === null) {
1062
+					return array();
1063
+		}
991 1064
 
992 1065
 		foreach ($files as $k => $file)
993 1066
 		{
@@ -1001,13 +1074,16 @@  discard block
 block discarded – undo
1001 1074
 				$package_ftp->chmod($ftp_file, 0755);
1002 1075
 			}
1003 1076
 
1004
-			if (!@is_writable($file))
1005
-				$package_ftp->chmod($ftp_file, 0777);
1006
-			if (!@is_writable(dirname($file)))
1007
-				$package_ftp->chmod(dirname($ftp_file), 0777);
1077
+			if (!@is_writable($file)) {
1078
+							$package_ftp->chmod($ftp_file, 0777);
1079
+			}
1080
+			if (!@is_writable(dirname($file))) {
1081
+							$package_ftp->chmod(dirname($ftp_file), 0777);
1082
+			}
1008 1083
 
1009
-			if (@is_writable($file))
1010
-				unset($files[$k]);
1084
+			if (@is_writable($file)) {
1085
+							unset($files[$k]);
1086
+			}
1011 1087
 		}
1012 1088
 
1013 1089
 		return $files;
@@ -1019,8 +1095,7 @@  discard block
 block discarded – undo
1019 1095
 
1020 1096
 		$files = packageRequireFTP($destination_url, $files, $return);
1021 1097
 		return $files;
1022
-	}
1023
-	elseif (isset($_POST['ftp_username']))
1098
+	} elseif (isset($_POST['ftp_username']))
1024 1099
 	{
1025 1100
 		require_once($sourcedir . '/Class-Package.php');
1026 1101
 		$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
@@ -1042,19 +1117,21 @@  discard block
 block discarded – undo
1042 1117
 		{
1043 1118
 			require_once($sourcedir . '/Class-Package.php');
1044 1119
 			$ftp = new ftp_connection(null);
1120
+		} elseif ($ftp->error !== false && !isset($ftp_error)) {
1121
+					$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
1045 1122
 		}
1046
-		elseif ($ftp->error !== false && !isset($ftp_error))
1047
-			$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
1048 1123
 
1049 1124
 		list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
1050 1125
 
1051
-		if ($found_path)
1052
-			$_POST['ftp_path'] = $detect_path;
1053
-		elseif (!isset($_POST['ftp_path']))
1054
-			$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
1126
+		if ($found_path) {
1127
+					$_POST['ftp_path'] = $detect_path;
1128
+		} elseif (!isset($_POST['ftp_path'])) {
1129
+					$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
1130
+		}
1055 1131
 
1056
-		if (!isset($_POST['ftp_username']))
1057
-			$_POST['ftp_username'] = $username;
1132
+		if (!isset($_POST['ftp_username'])) {
1133
+					$_POST['ftp_username'] = $username;
1134
+		}
1058 1135
 
1059 1136
 		$context['package_ftp'] = array(
1060 1137
 			'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'),
@@ -1066,23 +1143,24 @@  discard block
 block discarded – undo
1066 1143
 		);
1067 1144
 
1068 1145
 		// If we're returning dump out here.
1069
-		if ($return)
1070
-			return $files;
1146
+		if ($return) {
1147
+					return $files;
1148
+		}
1071 1149
 
1072 1150
 		$context['page_title'] = $txt['package_ftp_necessary'];
1073 1151
 		$context['sub_template'] = 'ftp_required';
1074 1152
 		obExit();
1075
-	}
1076
-	else
1153
+	} else
1077 1154
 	{
1078 1155
 		if (!in_array($_POST['ftp_path'], array('', '/')))
1079 1156
 		{
1080 1157
 			$ftp_root = strtr($boarddir, array($_POST['ftp_path'] => ''));
1081
-			if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/'))
1082
-				$ftp_root = substr($ftp_root, 0, -1);
1158
+			if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) {
1159
+							$ftp_root = substr($ftp_root, 0, -1);
1160
+			}
1161
+		} else {
1162
+					$ftp_root = $boarddir;
1083 1163
 		}
1084
-		else
1085
-			$ftp_root = $boarddir;
1086 1164
 
1087 1165
 		$_SESSION['pack_ftp'] = array(
1088 1166
 			'server' => $_POST['ftp_server'],
@@ -1093,8 +1171,9 @@  discard block
 block discarded – undo
1093 1171
 			'root' => $ftp_root,
1094 1172
 		);
1095 1173
 
1096
-		if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path'])
1097
-			updateSettings(array('package_path' => $_POST['ftp_path']));
1174
+		if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) {
1175
+					updateSettings(array('package_path' => $_POST['ftp_path']));
1176
+		}
1098 1177
 
1099 1178
 		$files = packageRequireFTP($destination_url, $files, $return);
1100 1179
 	}
@@ -1122,16 +1201,18 @@  discard block
 block discarded – undo
1122 1201
 	global $packagesdir, $forum_version, $context, $temp_path, $language, $smcFunc;
1123 1202
 
1124 1203
 	// Mayday!  That action doesn't exist!!
1125
-	if (empty($packageXML) || !$packageXML->exists($method))
1126
-		return array();
1204
+	if (empty($packageXML) || !$packageXML->exists($method)) {
1205
+			return array();
1206
+	}
1127 1207
 
1128 1208
 	// We haven't found the package script yet...
1129 1209
 	$script = false;
1130 1210
 	$the_version = strtr($forum_version, array('SMF ' => ''));
1131 1211
 
1132 1212
 	// Emulation support...
1133
-	if (!empty($_SESSION['version_emulate']))
1134
-		$the_version = $_SESSION['version_emulate'];
1213
+	if (!empty($_SESSION['version_emulate'])) {
1214
+			$the_version = $_SESSION['version_emulate'];
1215
+	}
1135 1216
 
1136 1217
 	// Single package emulation
1137 1218
 	if (!empty($_REQUEST['ve']) && !empty($_REQUEST['package']))
@@ -1139,8 +1220,9 @@  discard block
 block discarded – undo
1139 1220
 		$the_version = $_REQUEST['ve'];
1140 1221
 		$_SESSION['single_version_emulate'][$_REQUEST['package']] = $the_version;
1141 1222
 	}
1142
-	if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']])))
1143
-		$the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']];
1223
+	if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) {
1224
+			$the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']];
1225
+	}
1144 1226
 
1145 1227
 	// Get all the versions of this method and find the right one.
1146 1228
 	$these_methods = $packageXML->set($method);
@@ -1150,16 +1232,18 @@  discard block
 block discarded – undo
1150 1232
 		if ($this_method->exists('@for'))
1151 1233
 		{
1152 1234
 			// Don't keep going if this won't work for this version of SMF.
1153
-			if (!matchPackageVersion($the_version, $this_method->fetch('@for')))
1154
-				continue;
1235
+			if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) {
1236
+							continue;
1237
+			}
1155 1238
 		}
1156 1239
 
1157 1240
 		// Upgrades may go from a certain old version of the mod.
1158 1241
 		if ($method == 'upgrade' && $this_method->exists('@from'))
1159 1242
 		{
1160 1243
 			// Well, this is for the wrong old version...
1161
-			if (!matchPackageVersion($previous_version, $this_method->fetch('@from')))
1162
-				continue;
1244
+			if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) {
1245
+							continue;
1246
+			}
1163 1247
 		}
1164 1248
 
1165 1249
 		// We've found it!
@@ -1168,8 +1252,9 @@  discard block
 block discarded – undo
1168 1252
 	}
1169 1253
 
1170 1254
 	// Bad news, a matching script wasn't found!
1171
-	if (!($script instanceof xmlArray))
1172
-		return array();
1255
+	if (!($script instanceof xmlArray)) {
1256
+			return array();
1257
+	}
1173 1258
 
1174 1259
 	// Find all the actions in this method - in theory, these should only be allowed actions. (* means all.)
1175 1260
 	$actions = $script->set('*');
@@ -1198,12 +1283,12 @@  discard block
 block discarded – undo
1198 1283
 					if ((isset($_REQUEST['readme']) && $action->fetch('@lang') == $_REQUEST['readme']) || (isset($_REQUEST['license']) && $action->fetch('@lang') == $_REQUEST['license']) || (!isset($_REQUEST['readme']) && $action->fetch('@lang') == $language) || (!isset($_REQUEST['license']) && $action->fetch('@lang') == $language))
1199 1284
 					{
1200 1285
 						// In case the user put the blocks in the wrong order.
1201
-						if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default')
1202
-							$context[$type][] = 'default';
1286
+						if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') {
1287
+													$context[$type][] = 'default';
1288
+						}
1203 1289
 
1204 1290
 						$context[$type]['selected'] = $smcFunc['htmlspecialchars']($action->fetch('@lang'));
1205
-					}
1206
-					else
1291
+					} else
1207 1292
 					{
1208 1293
 						// We don't want this now, but we'll allow the user to select to read it.
1209 1294
 						$context[$type][] = $smcFunc['htmlspecialchars']($action->fetch('@lang'));
@@ -1218,9 +1303,9 @@  discard block
 block discarded – undo
1218 1303
 					{
1219 1304
 						$context[$type][] = 'default';
1220 1305
 						continue;
1306
+					} else {
1307
+											$context[$type]['selected'] = 'default';
1221 1308
 					}
1222
-					else
1223
-						$context[$type]['selected'] = 'default';
1224 1309
 				}
1225 1310
 			}
1226 1311
 
@@ -1230,9 +1315,9 @@  discard block
 block discarded – undo
1230 1315
 				$filename = $temp_path . '$auto_' . $temp_auto++ . (in_array($actionType, array('readme', 'redirect', 'license')) ? '.txt' : ($actionType == 'code' || $actionType == 'database' ? '.php' : '.mod'));
1231 1316
 				package_put_contents($filename, $action->fetch('.'));
1232 1317
 				$filename = strtr($filename, array($temp_path => ''));
1318
+			} else {
1319
+							$filename = $action->fetch('.');
1233 1320
 			}
1234
-			else
1235
-				$filename = $action->fetch('.');
1236 1321
 
1237 1322
 			$return[] = array(
1238 1323
 				'type' => $actionType,
@@ -1247,8 +1332,7 @@  discard block
 block discarded – undo
1247 1332
 			);
1248 1333
 
1249 1334
 			continue;
1250
-		}
1251
-		elseif ($actionType == 'hook')
1335
+		} elseif ($actionType == 'hook')
1252 1336
 		{
1253 1337
 			$return[] = array(
1254 1338
 				'type' => $actionType,
@@ -1260,16 +1344,16 @@  discard block
 block discarded – undo
1260 1344
 				'description' => '',
1261 1345
 			);
1262 1346
 			continue;
1263
-		}
1264
-		elseif ($actionType == 'credits')
1347
+		} elseif ($actionType == 'credits')
1265 1348
 		{
1266 1349
 			// quick check of any supplied url
1267 1350
 			$url = $action->exists('@url') ? $action->fetch('@url') : '';
1268 1351
 			if (strlen(trim($url)) > 0 && substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')
1269 1352
 			{
1270 1353
 				$url = 'http://' . $url;
1271
-				if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://'))
1272
-					$url = '';
1354
+				if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')) {
1355
+									$url = '';
1356
+				}
1273 1357
 			}
1274 1358
 
1275 1359
 			$return[] = array(
@@ -1281,8 +1365,7 @@  discard block
 block discarded – undo
1281 1365
 				'title' => $action->fetch('.'),
1282 1366
 			);
1283 1367
 			continue;
1284
-		}
1285
-		elseif ($actionType == 'requires')
1368
+		} elseif ($actionType == 'requires')
1286 1369
 		{
1287 1370
 			$return[] = array(
1288 1371
 				'type' => $actionType,
@@ -1291,14 +1374,12 @@  discard block
 block discarded – undo
1291 1374
 				'description' => '',
1292 1375
 			);
1293 1376
 			continue;
1294
-		}
1295
-		elseif ($actionType == 'error')
1377
+		} elseif ($actionType == 'error')
1296 1378
 		{
1297 1379
 			$return[] = array(
1298 1380
 				'type' => 'error',
1299 1381
 			);
1300
-		}
1301
-		elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir')))
1382
+		} elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir')))
1302 1383
 		{
1303 1384
 			$this_action = &$return[];
1304 1385
 			$this_action = array(
@@ -1312,8 +1393,7 @@  discard block
 block discarded – undo
1312 1393
 			{
1313 1394
 				$this_action['unparsed_destination'] = $action->fetch('@destination');
1314 1395
 				$this_action['destination'] = parse_path($action->fetch('@destination')) . '/' . basename($this_action['filename']);
1315
-			}
1316
-			else
1396
+			} else
1317 1397
 			{
1318 1398
 				$this_action['unparsed_filename'] = $this_action['filename'];
1319 1399
 				$this_action['filename'] = parse_path($this_action['filename']);
@@ -1322,10 +1402,11 @@  discard block
 block discarded – undo
1322 1402
 			// If we're moving or requiring (copying) a file.
1323 1403
 			if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require')
1324 1404
 			{
1325
-				if ($action->exists('@from'))
1326
-					$this_action['source'] = parse_path($action->fetch('@from'));
1327
-				else
1328
-					$this_action['source'] = $temp_path . $this_action['filename'];
1405
+				if ($action->exists('@from')) {
1406
+									$this_action['source'] = parse_path($action->fetch('@from'));
1407
+				} else {
1408
+									$this_action['source'] = $temp_path . $this_action['filename'];
1409
+				}
1329 1410
 			}
1330 1411
 
1331 1412
 			// Check if these things can be done. (chmod's etc.)
@@ -1334,22 +1415,23 @@  discard block
 block discarded – undo
1334 1415
 				if (!mktree($this_action['destination'], false))
1335 1416
 				{
1336 1417
 					$temp = $this_action['destination'];
1337
-					while (!file_exists($temp) && strlen($temp) > 1)
1338
-						$temp = dirname($temp);
1418
+					while (!file_exists($temp) && strlen($temp) > 1) {
1419
+											$temp = dirname($temp);
1420
+					}
1339 1421
 
1340 1422
 					$return[] = array(
1341 1423
 						'type' => 'chmod',
1342 1424
 						'filename' => $temp
1343 1425
 					);
1344 1426
 				}
1345
-			}
1346
-			elseif ($actionType == 'create-file')
1427
+			} elseif ($actionType == 'create-file')
1347 1428
 			{
1348 1429
 				if (!mktree(dirname($this_action['destination']), false))
1349 1430
 				{
1350 1431
 					$temp = dirname($this_action['destination']);
1351
-					while (!file_exists($temp) && strlen($temp) > 1)
1352
-						$temp = dirname($temp);
1432
+					while (!file_exists($temp) && strlen($temp) > 1) {
1433
+											$temp = dirname($temp);
1434
+					}
1353 1435
 
1354 1436
 					$return[] = array(
1355 1437
 						'type' => 'chmod',
@@ -1357,36 +1439,38 @@  discard block
 block discarded – undo
1357 1439
 					);
1358 1440
 				}
1359 1441
 
1360
-				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination']))))
1361
-					$return[] = array(
1442
+				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) {
1443
+									$return[] = array(
1362 1444
 						'type' => 'chmod',
1363 1445
 						'filename' => $this_action['destination']
1364 1446
 					);
1365
-			}
1366
-			elseif ($actionType == 'require-dir')
1447
+				}
1448
+			} elseif ($actionType == 'require-dir')
1367 1449
 			{
1368 1450
 				if (!mktree($this_action['destination'], false))
1369 1451
 				{
1370 1452
 					$temp = $this_action['destination'];
1371
-					while (!file_exists($temp) && strlen($temp) > 1)
1372
-						$temp = dirname($temp);
1453
+					while (!file_exists($temp) && strlen($temp) > 1) {
1454
+											$temp = dirname($temp);
1455
+					}
1373 1456
 
1374 1457
 					$return[] = array(
1375 1458
 						'type' => 'chmod',
1376 1459
 						'filename' => $temp
1377 1460
 					);
1378 1461
 				}
1379
-			}
1380
-			elseif ($actionType == 'require-file')
1462
+			} elseif ($actionType == 'require-file')
1381 1463
 			{
1382
-				if ($action->exists('@theme'))
1383
-					$this_action['theme_action'] = $action->fetch('@theme');
1464
+				if ($action->exists('@theme')) {
1465
+									$this_action['theme_action'] = $action->fetch('@theme');
1466
+				}
1384 1467
 
1385 1468
 				if (!mktree(dirname($this_action['destination']), false))
1386 1469
 				{
1387 1470
 					$temp = dirname($this_action['destination']);
1388
-					while (!file_exists($temp) && strlen($temp) > 1)
1389
-						$temp = dirname($temp);
1471
+					while (!file_exists($temp) && strlen($temp) > 1) {
1472
+											$temp = dirname($temp);
1473
+					}
1390 1474
 
1391 1475
 					$return[] = array(
1392 1476
 						'type' => 'chmod',
@@ -1394,19 +1478,20 @@  discard block
 block discarded – undo
1394 1478
 					);
1395 1479
 				}
1396 1480
 
1397
-				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination']))))
1398
-					$return[] = array(
1481
+				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) {
1482
+									$return[] = array(
1399 1483
 						'type' => 'chmod',
1400 1484
 						'filename' => $this_action['destination']
1401 1485
 					);
1402
-			}
1403
-			elseif ($actionType == 'move-dir' || $actionType == 'move-file')
1486
+				}
1487
+			} elseif ($actionType == 'move-dir' || $actionType == 'move-file')
1404 1488
 			{
1405 1489
 				if (!mktree(dirname($this_action['destination']), false))
1406 1490
 				{
1407 1491
 					$temp = dirname($this_action['destination']);
1408
-					while (!file_exists($temp) && strlen($temp) > 1)
1409
-						$temp = dirname($temp);
1492
+					while (!file_exists($temp) && strlen($temp) > 1) {
1493
+											$temp = dirname($temp);
1494
+					}
1410 1495
 
1411 1496
 					$return[] = array(
1412 1497
 						'type' => 'chmod',
@@ -1414,30 +1499,30 @@  discard block
 block discarded – undo
1414 1499
 					);
1415 1500
 				}
1416 1501
 
1417
-				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination']))))
1418
-					$return[] = array(
1502
+				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) {
1503
+									$return[] = array(
1419 1504
 						'type' => 'chmod',
1420 1505
 						'filename' => $this_action['destination']
1421 1506
 					);
1422
-			}
1423
-			elseif ($actionType == 'remove-dir')
1507
+				}
1508
+			} elseif ($actionType == 'remove-dir')
1424 1509
 			{
1425
-				if (!is_writable($this_action['filename']) && file_exists($this_action['filename']))
1426
-					$return[] = array(
1510
+				if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) {
1511
+									$return[] = array(
1427 1512
 						'type' => 'chmod',
1428 1513
 						'filename' => $this_action['filename']
1429 1514
 					);
1430
-			}
1431
-			elseif ($actionType == 'remove-file')
1515
+				}
1516
+			} elseif ($actionType == 'remove-file')
1432 1517
 			{
1433
-				if (!is_writable($this_action['filename']) && file_exists($this_action['filename']))
1434
-					$return[] = array(
1518
+				if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) {
1519
+									$return[] = array(
1435 1520
 						'type' => 'chmod',
1436 1521
 						'filename' => $this_action['filename']
1437 1522
 					);
1523
+				}
1438 1524
 			}
1439
-		}
1440
-		else
1525
+		} else
1441 1526
 		{
1442 1527
 			$return[] = array(
1443 1528
 				'type' => 'error',
@@ -1448,8 +1533,9 @@  discard block
 block discarded – undo
1448 1533
 	}
1449 1534
 
1450 1535
 	// Only testing - just return a list of things to be done.
1451
-	if ($testing_only)
1452
-		return $return;
1536
+	if ($testing_only) {
1537
+			return $return;
1538
+	}
1453 1539
 
1454 1540
 	umask(0);
1455 1541
 
@@ -1457,78 +1543,81 @@  discard block
 block discarded – undo
1457 1543
 	$not_done = array(array('type' => '!'));
1458 1544
 	foreach ($return as $action)
1459 1545
 	{
1460
-		if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits')))
1461
-			$not_done[] = $action;
1546
+		if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) {
1547
+					$not_done[] = $action;
1548
+		}
1462 1549
 
1463 1550
 		if ($action['type'] == 'create-dir')
1464 1551
 		{
1465
-			if (!mktree($action['destination'], 0755) || !is_writable($action['destination']))
1466
-				$failure |= !mktree($action['destination'], 0777);
1467
-		}
1468
-		elseif ($action['type'] == 'create-file')
1552
+			if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) {
1553
+							$failure |= !mktree($action['destination'], 0777);
1554
+			}
1555
+		} elseif ($action['type'] == 'create-file')
1469 1556
 		{
1470
-			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination'])))
1471
-				$failure |= !mktree(dirname($action['destination']), 0777);
1557
+			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) {
1558
+							$failure |= !mktree(dirname($action['destination']), 0777);
1559
+			}
1472 1560
 
1473 1561
 			// Create an empty file.
1474 1562
 			package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only);
1475 1563
 
1476
-			if (!file_exists($action['destination']))
1477
-				$failure = true;
1478
-		}
1479
-		elseif ($action['type'] == 'require-dir')
1564
+			if (!file_exists($action['destination'])) {
1565
+							$failure = true;
1566
+			}
1567
+		} elseif ($action['type'] == 'require-dir')
1480 1568
 		{
1481 1569
 			copytree($action['source'], $action['destination']);
1482 1570
 			// Any other theme folders?
1483
-			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']]))
1484
-				foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination)
1571
+			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) {
1572
+							foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination)
1485 1573
 					copytree($action['source'], $theme_destination);
1486
-		}
1487
-		elseif ($action['type'] == 'require-file')
1574
+			}
1575
+		} elseif ($action['type'] == 'require-file')
1488 1576
 		{
1489
-			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination'])))
1490
-				$failure |= !mktree(dirname($action['destination']), 0777);
1577
+			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) {
1578
+							$failure |= !mktree(dirname($action['destination']), 0777);
1579
+			}
1491 1580
 
1492 1581
 			package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only);
1493 1582
 
1494 1583
 			$failure |= !copy($action['source'], $action['destination']);
1495 1584
 
1496 1585
 			// Any other theme files?
1497
-			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']]))
1498
-				foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination)
1586
+			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) {
1587
+							foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination)
1499 1588
 				{
1500 1589
 					if (!mktree(dirname($theme_destination), 0755) || !is_writable(dirname($theme_destination)))
1501 1590
 						$failure |= !mktree(dirname($theme_destination), 0777);
1591
+			}
1502 1592
 
1503 1593
 					package_put_contents($theme_destination, package_get_contents($action['source']), $testing_only);
1504 1594
 
1505 1595
 					$failure |= !copy($action['source'], $theme_destination);
1506 1596
 				}
1507
-		}
1508
-		elseif ($action['type'] == 'move-file')
1597
+		} elseif ($action['type'] == 'move-file')
1509 1598
 		{
1510
-			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination'])))
1511
-				$failure |= !mktree(dirname($action['destination']), 0777);
1599
+			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) {
1600
+							$failure |= !mktree(dirname($action['destination']), 0777);
1601
+			}
1512 1602
 
1513 1603
 			$failure |= !rename($action['source'], $action['destination']);
1514
-		}
1515
-		elseif ($action['type'] == 'move-dir')
1604
+		} elseif ($action['type'] == 'move-dir')
1516 1605
 		{
1517
-			if (!mktree($action['destination'], 0755) || !is_writable($action['destination']))
1518
-				$failure |= !mktree($action['destination'], 0777);
1606
+			if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) {
1607
+							$failure |= !mktree($action['destination'], 0777);
1608
+			}
1519 1609
 
1520 1610
 			$failure |= !rename($action['source'], $action['destination']);
1521
-		}
1522
-		elseif ($action['type'] == 'remove-dir')
1611
+		} elseif ($action['type'] == 'remove-dir')
1523 1612
 		{
1524 1613
 			deltree($action['filename']);
1525 1614
 
1526 1615
 			// Any other theme folders?
1527
-			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']]))
1528
-				foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination)
1616
+			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) {
1617
+							foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination)
1529 1618
 					deltree($theme_destination);
1530
-		}
1531
-		elseif ($action['type'] == 'remove-file')
1619
+			}
1620
+		} elseif ($action['type'] == 'remove-file')
1532 1621
 		{
1533 1622
 			// Make sure the file exists before deleting it.
1534 1623
 			if (file_exists($action['filename']))
@@ -1537,16 +1626,18 @@  discard block
 block discarded – undo
1537 1626
 				$failure |= !unlink($action['filename']);
1538 1627
 			}
1539 1628
 			// The file that was supposed to be deleted couldn't be found.
1540
-			else
1541
-				$failure = true;
1629
+			else {
1630
+							$failure = true;
1631
+			}
1542 1632
 
1543 1633
 			// Any other theme folders?
1544
-			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']]))
1545
-				foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination)
1634
+			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) {
1635
+							foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination)
1546 1636
 					if (file_exists($theme_destination))
1547 1637
 						$failure |= !unlink($theme_destination);
1548
-					else
1549
-						$failure = true;
1638
+			} else {
1639
+											$failure = true;
1640
+					}
1550 1641
 		}
1551 1642
 	}
1552 1643
 
@@ -1568,8 +1659,9 @@  discard block
 block discarded – undo
1568 1659
 {
1569 1660
 	static $near_version = 0;
1570 1661
 
1571
-	if ($reset)
1572
-		$near_version = 0;
1662
+	if ($reset) {
1663
+			$near_version = 0;
1664
+	}
1573 1665
 
1574 1666
 	// Normalize the $versions while we remove our previous Doh!
1575 1667
 	$versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions)));
@@ -1578,16 +1670,19 @@  discard block
 block discarded – undo
1578 1670
 	foreach ($versions as $for)
1579 1671
 	{
1580 1672
 		// Adjust for those wild cards
1581
-		if (strpos($for, '*') !== false)
1582
-			$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);
1673
+		if (strpos($for, '*') !== false) {
1674
+					$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);
1675
+		}
1583 1676
 
1584 1677
 		// If we have a range, grab the lower value, done this way so it looks normal-er to the user e.g. 2.0 vs 2.0.99
1585
-		if (strpos($for, '-') !== false)
1586
-			list ($for, $higher) = explode('-', $for);
1678
+		if (strpos($for, '-') !== false) {
1679
+					list ($for, $higher) = explode('-', $for);
1680
+		}
1587 1681
 
1588 1682
 		// Do the compare, if the for is greater, than what we have but not greater than what we are running .....
1589
-		if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1)
1590
-			$near_version = $for;
1683
+		if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) {
1684
+					$near_version = $for;
1685
+		}
1591 1686
 	}
1592 1687
 
1593 1688
 	return !empty($near_version) ? $near_version : false;
@@ -1610,15 +1705,17 @@  discard block
 block discarded – undo
1610 1705
 	$versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions)));
1611 1706
 
1612 1707
 	// Perhaps we do accept anything?
1613
-	if (in_array('all', $versions))
1614
-		return true;
1708
+	if (in_array('all', $versions)) {
1709
+			return true;
1710
+	}
1615 1711
 
1616 1712
 	// Loop through each version.
1617 1713
 	foreach ($versions as $for)
1618 1714
 	{
1619 1715
 		// Wild card spotted?
1620
-		if (strpos($for, '*') !== false)
1621
-			$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);
1716
+		if (strpos($for, '*') !== false) {
1717
+					$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);
1718
+		}
1622 1719
 
1623 1720
 		// Do we have a range?
1624 1721
 		if (strpos($for, '-') !== false)
@@ -1626,12 +1723,14 @@  discard block
 block discarded – undo
1626 1723
 			list ($lower, $upper) = explode('-', $for);
1627 1724
 
1628 1725
 			// Compare the version against lower and upper bounds.
1629
-			if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1)
1630
-				return true;
1726
+			if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) {
1727
+							return true;
1728
+			}
1631 1729
 		}
1632 1730
 		// Otherwise check if they are equal...
1633
-		elseif (compareVersions($version, $for) === 0)
1634
-			return true;
1731
+		elseif (compareVersions($version, $for) === 0) {
1732
+					return true;
1733
+		}
1635 1734
 	}
1636 1735
 
1637 1736
 	return false;
@@ -1671,12 +1770,14 @@  discard block
 block discarded – undo
1671 1770
 	}
1672 1771
 
1673 1772
 	// Are they the same, perhaps?
1674
-	if ($versions[1] === $versions[2])
1675
-		return 0;
1773
+	if ($versions[1] === $versions[2]) {
1774
+			return 0;
1775
+	}
1676 1776
 
1677 1777
 	// Get version numbering categories...
1678
-	if (!isset($categories))
1679
-		$categories = array_keys($versions[1]);
1778
+	if (!isset($categories)) {
1779
+			$categories = array_keys($versions[1]);
1780
+	}
1680 1781
 
1681 1782
 	// Loop through each category.
1682 1783
 	foreach ($categories as $category)
@@ -1686,13 +1787,15 @@  discard block
 block discarded – undo
1686 1787
 		{
1687 1788
 			// Dev builds are a problematic exception.
1688 1789
 			// (stable) dev < (stable) but (unstable) dev = (unstable)
1689
-			if ($category == 'type')
1690
-				return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1);
1691
-			elseif ($category == 'dev')
1692
-				return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0);
1790
+			if ($category == 'type') {
1791
+							return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1);
1792
+			} elseif ($category == 'dev') {
1793
+							return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0);
1794
+			}
1693 1795
 			// Otherwise a simple comparison.
1694
-			else
1695
-				return $versions[1][$category] > $versions[2][$category] ? 1 : -1;
1796
+			else {
1797
+							return $versions[1][$category] > $versions[2][$category] ? 1 : -1;
1798
+			}
1696 1799
 		}
1697 1800
 	}
1698 1801
 
@@ -1726,11 +1829,13 @@  discard block
 block discarded – undo
1726 1829
 	);
1727 1830
 
1728 1831
 	// do we parse in a package directory?
1729
-	if (!empty($temp_path))
1730
-		$dirs['$package'] = $temp_path;
1832
+	if (!empty($temp_path)) {
1833
+			$dirs['$package'] = $temp_path;
1834
+	}
1731 1835
 
1732
-	if (strlen($path) == 0)
1733
-		trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR);
1836
+	if (strlen($path) == 0) {
1837
+			trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR);
1838
+	}
1734 1839
 
1735 1840
 	return strtr($path, $dirs);
1736 1841
 }
@@ -1747,8 +1852,9 @@  discard block
 block discarded – undo
1747 1852
 	/** @var ftp_connection $package_ftp */
1748 1853
 	global $package_ftp;
1749 1854
 
1750
-	if (!file_exists($dir))
1751
-		return;
1855
+	if (!file_exists($dir)) {
1856
+			return;
1857
+	}
1752 1858
 
1753 1859
 	$current_dir = @opendir($dir);
1754 1860
 	if ($current_dir == false)
@@ -1756,8 +1862,9 @@  discard block
 block discarded – undo
1756 1862
 		if ($delete_dir && isset($package_ftp))
1757 1863
 		{
1758 1864
 			$ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => ''));
1759
-			if (!is_dir($dir))
1760
-				$package_ftp->chmod($ftp_file, 0777);
1865
+			if (!is_dir($dir)) {
1866
+							$package_ftp->chmod($ftp_file, 0777);
1867
+			}
1761 1868
 			$package_ftp->unlink($ftp_file);
1762 1869
 		}
1763 1870
 
@@ -1766,26 +1873,28 @@  discard block
 block discarded – undo
1766 1873
 
1767 1874
 	while ($entryname = readdir($current_dir))
1768 1875
 	{
1769
-		if (in_array($entryname, array('.', '..')))
1770
-			continue;
1876
+		if (in_array($entryname, array('.', '..'))) {
1877
+					continue;
1878
+		}
1771 1879
 
1772
-		if (is_dir($dir . '/' . $entryname))
1773
-			deltree($dir . '/' . $entryname);
1774
-		else
1880
+		if (is_dir($dir . '/' . $entryname)) {
1881
+					deltree($dir . '/' . $entryname);
1882
+		} else
1775 1883
 		{
1776 1884
 			// Here, 755 doesn't really matter since we're deleting it anyway.
1777 1885
 			if (isset($package_ftp))
1778 1886
 			{
1779 1887
 				$ftp_file = strtr($dir . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => ''));
1780 1888
 
1781
-				if (!is_writable($dir . '/' . $entryname))
1782
-					$package_ftp->chmod($ftp_file, 0777);
1889
+				if (!is_writable($dir . '/' . $entryname)) {
1890
+									$package_ftp->chmod($ftp_file, 0777);
1891
+				}
1783 1892
 				$package_ftp->unlink($ftp_file);
1784
-			}
1785
-			else
1893
+			} else
1786 1894
 			{
1787
-				if (!is_writable($dir . '/' . $entryname))
1788
-					smf_chmod($dir . '/' . $entryname, 0777);
1895
+				if (!is_writable($dir . '/' . $entryname)) {
1896
+									smf_chmod($dir . '/' . $entryname, 0777);
1897
+				}
1789 1898
 				unlink($dir . '/' . $entryname);
1790 1899
 			}
1791 1900
 		}
@@ -1798,14 +1907,15 @@  discard block
 block discarded – undo
1798 1907
 		if (isset($package_ftp))
1799 1908
 		{
1800 1909
 			$ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => ''));
1801
-			if (!is_writable($dir . '/' . $entryname))
1802
-				$package_ftp->chmod($ftp_file, 0777);
1910
+			if (!is_writable($dir . '/' . $entryname)) {
1911
+							$package_ftp->chmod($ftp_file, 0777);
1912
+			}
1803 1913
 			$package_ftp->unlink($ftp_file);
1804
-		}
1805
-		else
1914
+		} else
1806 1915
 		{
1807
-			if (!is_writable($dir))
1808
-				smf_chmod($dir, 0777);
1916
+			if (!is_writable($dir)) {
1917
+							smf_chmod($dir, 0777);
1918
+			}
1809 1919
 			@rmdir($dir);
1810 1920
 		}
1811 1921
 	}
@@ -1828,10 +1938,11 @@  discard block
 block discarded – undo
1828 1938
 	{
1829 1939
 		if (!is_writable($strPath) && $mode !== false)
1830 1940
 		{
1831
-			if (isset($package_ftp))
1832
-				$package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode);
1833
-			else
1834
-				smf_chmod($strPath, $mode);
1941
+			if (isset($package_ftp)) {
1942
+							$package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode);
1943
+			} else {
1944
+							smf_chmod($strPath, $mode);
1945
+			}
1835 1946
 		}
1836 1947
 
1837 1948
 		$test = @opendir($strPath);
@@ -1839,36 +1950,37 @@  discard block
 block discarded – undo
1839 1950
 		{
1840 1951
 			closedir($test);
1841 1952
 			return is_writable($strPath);
1953
+		} else {
1954
+					return false;
1842 1955
 		}
1843
-		else
1844
-			return false;
1845 1956
 	}
1846 1957
 	// Is this an invalid path and/or we can't make the directory?
1847
-	if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode))
1848
-		return false;
1958
+	if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) {
1959
+			return false;
1960
+	}
1849 1961
 
1850 1962
 	if (!is_writable(dirname($strPath)) && $mode !== false)
1851 1963
 	{
1852
-		if (isset($package_ftp))
1853
-			$package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode);
1854
-		else
1855
-			smf_chmod(dirname($strPath), $mode);
1964
+		if (isset($package_ftp)) {
1965
+					$package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode);
1966
+		} else {
1967
+					smf_chmod(dirname($strPath), $mode);
1968
+		}
1856 1969
 	}
1857 1970
 
1858
-	if ($mode !== false && isset($package_ftp))
1859
-		return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')));
1860
-	elseif ($mode === false)
1971
+	if ($mode !== false && isset($package_ftp)) {
1972
+			return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')));
1973
+	} elseif ($mode === false)
1861 1974
 	{
1862 1975
 		$test = @opendir(dirname($strPath));
1863 1976
 		if ($test)
1864 1977
 		{
1865 1978
 			closedir($test);
1866 1979
 			return true;
1980
+		} else {
1981
+					return false;
1867 1982
 		}
1868
-		else
1869
-			return false;
1870
-	}
1871
-	else
1983
+	} else
1872 1984
 	{
1873 1985
 		@mkdir($strPath, $mode);
1874 1986
 		$test = @opendir($strPath);
@@ -1876,9 +1988,9 @@  discard block
 block discarded – undo
1876 1988
 		{
1877 1989
 			closedir($test);
1878 1990
 			return true;
1991
+		} else {
1992
+					return false;
1879 1993
 		}
1880
-		else
1881
-			return false;
1882 1994
 	}
1883 1995
 }
1884 1996
 
@@ -1894,39 +2006,46 @@  discard block
 block discarded – undo
1894 2006
 	/** @var ftp_connection $package_ftp */
1895 2007
 	global $package_ftp;
1896 2008
 
1897
-	if (!file_exists($destination) || !is_writable($destination))
1898
-		mktree($destination, 0755);
1899
-	if (!is_writable($destination))
1900
-		mktree($destination, 0777);
2009
+	if (!file_exists($destination) || !is_writable($destination)) {
2010
+			mktree($destination, 0755);
2011
+	}
2012
+	if (!is_writable($destination)) {
2013
+			mktree($destination, 0777);
2014
+	}
1901 2015
 
1902 2016
 	$current_dir = opendir($source);
1903
-	if ($current_dir == false)
1904
-		return;
2017
+	if ($current_dir == false) {
2018
+			return;
2019
+	}
1905 2020
 
1906 2021
 	while ($entryname = readdir($current_dir))
1907 2022
 	{
1908
-		if (in_array($entryname, array('.', '..')))
1909
-			continue;
2023
+		if (in_array($entryname, array('.', '..'))) {
2024
+					continue;
2025
+		}
1910 2026
 
1911
-		if (isset($package_ftp))
1912
-			$ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => ''));
2027
+		if (isset($package_ftp)) {
2028
+					$ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => ''));
2029
+		}
1913 2030
 
1914 2031
 		if (is_file($source . '/' . $entryname))
1915 2032
 		{
1916
-			if (isset($package_ftp) && !file_exists($destination . '/' . $entryname))
1917
-				$package_ftp->create_file($ftp_file);
1918
-			elseif (!file_exists($destination . '/' . $entryname))
1919
-				@touch($destination . '/' . $entryname);
2033
+			if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) {
2034
+							$package_ftp->create_file($ftp_file);
2035
+			} elseif (!file_exists($destination . '/' . $entryname)) {
2036
+							@touch($destination . '/' . $entryname);
2037
+			}
1920 2038
 		}
1921 2039
 
1922 2040
 		package_chmod($destination . '/' . $entryname);
1923 2041
 
1924
-		if (is_dir($source . '/' . $entryname))
1925
-			copytree($source . '/' . $entryname, $destination . '/' . $entryname);
1926
-		elseif (file_exists($destination . '/' . $entryname))
1927
-			package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname));
1928
-		else
1929
-			copy($source . '/' . $entryname, $destination . '/' . $entryname);
2042
+		if (is_dir($source . '/' . $entryname)) {
2043
+					copytree($source . '/' . $entryname, $destination . '/' . $entryname);
2044
+		} elseif (file_exists($destination . '/' . $entryname)) {
2045
+					package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname));
2046
+		} else {
2047
+					copy($source . '/' . $entryname, $destination . '/' . $entryname);
2048
+		}
1930 2049
 	}
1931 2050
 
1932 2051
 	closedir($current_dir);
@@ -1944,21 +2063,24 @@  discard block
 block discarded – undo
1944 2063
 	$data = array();
1945 2064
 
1946 2065
 	$dir = @dir($path . $sub_path);
1947
-	if (!$dir)
1948
-		return array();
2066
+	if (!$dir) {
2067
+			return array();
2068
+	}
1949 2069
 	while ($entry = $dir->read())
1950 2070
 	{
1951
-		if ($entry == '.' || $entry == '..')
1952
-			continue;
2071
+		if ($entry == '.' || $entry == '..') {
2072
+					continue;
2073
+		}
1953 2074
 
1954
-		if (is_dir($path . $sub_path . '/' . $entry))
1955
-			$data = array_merge($data, listtree($path, $sub_path . '/' . $entry));
1956
-		else
1957
-			$data[] = array(
2075
+		if (is_dir($path . $sub_path . '/' . $entry)) {
2076
+					$data = array_merge($data, listtree($path, $sub_path . '/' . $entry));
2077
+		} else {
2078
+					$data[] = array(
1958 2079
 				'filename' => $sub_path == '' ? $entry : $sub_path . '/' . $entry,
1959 2080
 				'size' => filesize($path . $sub_path . '/' . $entry),
1960 2081
 				'skipped' => false,
1961 2082
 			);
2083
+		}
1962 2084
 	}
1963 2085
 	$dir->close();
1964 2086
 
@@ -2013,8 +2135,9 @@  discard block
 block discarded – undo
2013 2135
 		{
2014 2136
 			// If this filename is relative, if so take a guess at what it should be.
2015 2137
 			$real_filename = $filename;
2016
-			if (strpos($filename, 'Themes') === 0)
2017
-				$real_filename = $boarddir . '/' . $filename;
2138
+			if (strpos($filename, 'Themes') === 0) {
2139
+							$real_filename = $boarddir . '/' . $filename;
2140
+			}
2018 2141
 
2019 2142
 			if (strpos($real_filename, $theme['theme_dir']) === 0)
2020 2143
 			{
@@ -2033,8 +2156,9 @@  discard block
 block discarded – undo
2033 2156
 		foreach ($theme_paths as $id => $theme)
2034 2157
 		{
2035 2158
 			// Default is getting done anyway, so no need for involvement here.
2036
-			if ($id == 1)
2037
-				continue;
2159
+			if ($id == 1) {
2160
+							continue;
2161
+			}
2038 2162
 
2039 2163
 			// For every template, do we want it? Yea, no, maybe?
2040 2164
 			foreach ($template_changes[1] as $index => $template_file)
@@ -2057,8 +2181,9 @@  discard block
 block discarded – undo
2057 2181
 		);
2058 2182
 
2059 2183
 		// Sometimes though, we have some additional files for other themes, if we have add them to the mix.
2060
-		if (isset($custom_themes_add[$files_to_change[1]]))
2061
-			$files_to_change += $custom_themes_add[$files_to_change[1]];
2184
+		if (isset($custom_themes_add[$files_to_change[1]])) {
2185
+					$files_to_change += $custom_themes_add[$files_to_change[1]];
2186
+		}
2062 2187
 
2063 2188
 		// Now, loop through all the files we're changing, and, well, change them ;)
2064 2189
 		foreach ($files_to_change as $theme => $working_file)
@@ -2092,11 +2217,13 @@  discard block
 block discarded – undo
2092 2217
 				continue;
2093 2218
 			}
2094 2219
 			// Okay, we're creating this file then...?
2095
-			elseif (!file_exists($working_file))
2096
-				$working_data = '';
2220
+			elseif (!file_exists($working_file)) {
2221
+							$working_data = '';
2222
+			}
2097 2223
 			// Phew, it exists!  Load 'er up!
2098
-			else
2099
-				$working_data = str_replace("\r", '', package_get_contents($working_file));
2224
+			else {
2225
+							$working_data = str_replace("\r", '', package_get_contents($working_file));
2226
+			}
2100 2227
 
2101 2228
 			$actions[] = array(
2102 2229
 				'type' => 'opened',
@@ -2117,8 +2244,8 @@  discard block
 block discarded – undo
2117 2244
 
2118 2245
 				// Grab all search items of this operation (in most cases just 1).
2119 2246
 				$searches = $operation->set('search');
2120
-				foreach ($searches as $i => $search)
2121
-					$actual_operation['searches'][] = array(
2247
+				foreach ($searches as $i => $search) {
2248
+									$actual_operation['searches'][] = array(
2122 2249
 						'position' => $search->exists('@position') && in_array(trim($search->fetch('@position')), array('before', 'after', 'replace', 'end')) ? trim($search->fetch('@position')) : 'replace',
2123 2250
 						'is_reg_exp' => $search->exists('@regexp') && trim($search->fetch('@regexp')) === 'true',
2124 2251
 						'loose_whitespace' => $search->exists('@whitespace') && trim($search->fetch('@whitespace')) === 'loose',
@@ -2127,6 +2254,7 @@  discard block
 block discarded – undo
2127 2254
 						'preg_search' => '',
2128 2255
 						'preg_replace' => '',
2129 2256
 					);
2257
+				}
2130 2258
 
2131 2259
 				// At least one search should be defined.
2132 2260
 				if (empty($actual_operation['searches']))
@@ -2151,30 +2279,32 @@  discard block
 block discarded – undo
2151 2279
 						// Reverse modification of regular expressions are not allowed.
2152 2280
 						if ($search['is_reg_exp'])
2153 2281
 						{
2154
-							if ($actual_operation['error'] === 'fatal')
2155
-								$actions[] = array(
2282
+							if ($actual_operation['error'] === 'fatal') {
2283
+															$actions[] = array(
2156 2284
 									'type' => 'failure',
2157 2285
 									'filename' => $working_file,
2158 2286
 									'search' => $search['search'],
2159 2287
 									'is_custom' => $theme > 1 ? $theme : 0,
2160 2288
 								);
2289
+							}
2161 2290
 
2162 2291
 							// Continue to the next operation.
2163 2292
 							continue 2;
2164 2293
 						}
2165 2294
 
2166 2295
 						// The replacement is now the search subject...
2167
-						if ($search['position'] === 'replace' || $search['position'] === 'end')
2168
-							$actual_operation['searches'][$i]['search'] = $search['add'];
2169
-						else
2296
+						if ($search['position'] === 'replace' || $search['position'] === 'end') {
2297
+													$actual_operation['searches'][$i]['search'] = $search['add'];
2298
+						} else
2170 2299
 						{
2171 2300
 							// Reversing a before/after modification becomes a replacement.
2172 2301
 							$actual_operation['searches'][$i]['position'] = 'replace';
2173 2302
 
2174
-							if ($search['position'] === 'before')
2175
-								$actual_operation['searches'][$i]['search'] .= $search['add'];
2176
-							elseif ($search['position'] === 'after')
2177
-								$actual_operation['searches'][$i]['search'] = $search['add'] . $search['search'];
2303
+							if ($search['position'] === 'before') {
2304
+															$actual_operation['searches'][$i]['search'] .= $search['add'];
2305
+							} elseif ($search['position'] === 'after') {
2306
+															$actual_operation['searches'][$i]['search'] = $search['add'] . $search['search'];
2307
+							}
2178 2308
 						}
2179 2309
 
2180 2310
 						// ...and the search subject is now the replacement.
@@ -2202,16 +2332,17 @@  discard block
 block discarded – undo
2202 2332
 				foreach ($actual_operation['searches'] as $i => $search)
2203 2333
 				{
2204 2334
 					// Not much needed if the search subject is already a regexp.
2205
-					if ($search['is_reg_exp'])
2206
-						$actual_operation['searches'][$i]['preg_search'] = $search['search'];
2207
-					else
2335
+					if ($search['is_reg_exp']) {
2336
+											$actual_operation['searches'][$i]['preg_search'] = $search['search'];
2337
+					} else
2208 2338
 					{
2209 2339
 						// Make the search subject fit into a regular expression.
2210 2340
 						$actual_operation['searches'][$i]['preg_search'] = preg_quote($search['search'], '~');
2211 2341
 
2212 2342
 						// Using 'loose', a random amount of tabs and spaces may be used.
2213
-						if ($search['loose_whitespace'])
2214
-							$actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']);
2343
+						if ($search['loose_whitespace']) {
2344
+													$actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']);
2345
+						}
2215 2346
 					}
2216 2347
 
2217 2348
 					// Shuzzup.  This is done so we can safely use a regular expression. ($0 is bad!!)
@@ -2237,8 +2368,7 @@  discard block
 block discarded – undo
2237 2368
 						if ($undo)
2238 2369
 						{
2239 2370
 							$actual_operation['searches'][$i]['preg_replace'] = '';
2240
-						}
2241
-						else
2371
+						} else
2242 2372
 						{
2243 2373
 							$actual_operation['searches'][$i]['preg_search'] = '(\\n\\?\\>)?$';
2244 2374
 							$actual_operation['searches'][$i]['preg_replace'] .= '$1';
@@ -2285,8 +2415,9 @@  discard block
 block discarded – undo
2285 2415
 					}
2286 2416
 
2287 2417
 					// Replace it into nothing? That's not an option...unless it's an undoing end.
2288
-					if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo))
2289
-						continue;
2418
+					if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) {
2419
+											continue;
2420
+					}
2290 2421
 
2291 2422
 					// Finally, we're doing some replacements.
2292 2423
 					$working_data = preg_replace('~' . $actual_operation['searches'][$i]['preg_search'] . '~s', $actual_operation['searches'][$i]['preg_replace'], $working_data, 1);
@@ -2311,22 +2442,25 @@  discard block
 block discarded – undo
2311 2442
 
2312 2443
 			package_chmod($working_file);
2313 2444
 
2314
-			if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file))))
2315
-				$actions[] = array(
2445
+			if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) {
2446
+							$actions[] = array(
2316 2447
 					'type' => 'chmod',
2317 2448
 					'filename' => $working_file
2318 2449
 				);
2450
+			}
2319 2451
 
2320
-			if (basename($working_file) == 'Settings_bak.php')
2321
-				continue;
2452
+			if (basename($working_file) == 'Settings_bak.php') {
2453
+							continue;
2454
+			}
2322 2455
 
2323 2456
 			if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file))
2324 2457
 			{
2325 2458
 				// No, no, not Settings.php!
2326
-				if (basename($working_file) == 'Settings.php')
2327
-					@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2328
-				else
2329
-					@copy($working_file, $working_file . '~');
2459
+				if (basename($working_file) == 'Settings.php') {
2460
+									@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2461
+				} else {
2462
+									@copy($working_file, $working_file . '~');
2463
+				}
2330 2464
 			}
2331 2465
 
2332 2466
 			// Always call this, even if in testing, because it won't really be written in testing mode.
@@ -2393,8 +2527,9 @@  discard block
 block discarded – undo
2393 2527
 		if ($code_match[1] != 'edit file' && $code_match[1] != 'file')
2394 2528
 		{
2395 2529
 			// It's a step, let's add that to the current steps.
2396
-			if (isset($temp_changes[$step_counter]))
2397
-				$temp_changes[$step_counter]['changes'][] = $code_match[0];
2530
+			if (isset($temp_changes[$step_counter])) {
2531
+							$temp_changes[$step_counter]['changes'][] = $code_match[0];
2532
+			}
2398 2533
 			continue;
2399 2534
 		}
2400 2535
 
@@ -2411,11 +2546,13 @@  discard block
 block discarded – undo
2411 2546
 		foreach ($theme_paths as $id => $theme)
2412 2547
 		{
2413 2548
 			// If this filename is relative, if so take a guess at what it should be.
2414
-			if (strpos($filename, 'Themes') === 0)
2415
-				$filename = $boarddir . '/' . $filename;
2549
+			if (strpos($filename, 'Themes') === 0) {
2550
+							$filename = $boarddir . '/' . $filename;
2551
+			}
2416 2552
 
2417
-			if (strpos($filename, $theme['theme_dir']) === 0)
2418
-				$template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1);
2553
+			if (strpos($filename, $theme['theme_dir']) === 0) {
2554
+							$template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1);
2555
+			}
2419 2556
 		}
2420 2557
 	}
2421 2558
 
@@ -2428,8 +2565,9 @@  discard block
 block discarded – undo
2428 2565
 		foreach ($theme_paths as $id => $theme)
2429 2566
 		{
2430 2567
 			// Don't do default, it means nothing to me.
2431
-			if ($id == 1)
2432
-				continue;
2568
+			if ($id == 1) {
2569
+							continue;
2570
+			}
2433 2571
 
2434 2572
 			// Now, for each file do we need to edit it?
2435 2573
 			foreach ($template_changes[1] as $pos => $template_file)
@@ -2465,32 +2603,36 @@  discard block
 block discarded – undo
2465 2603
 				package_chmod($working_file);
2466 2604
 
2467 2605
 				// Don't even dare.
2468
-				if (basename($working_file) == 'Settings_bak.php')
2469
-					continue;
2606
+				if (basename($working_file) == 'Settings_bak.php') {
2607
+									continue;
2608
+				}
2470 2609
 
2471
-				if (!is_writable($working_file))
2472
-					$actions[] = array(
2610
+				if (!is_writable($working_file)) {
2611
+									$actions[] = array(
2473 2612
 						'type' => 'chmod',
2474 2613
 						'filename' => $working_file
2475 2614
 					);
2615
+				}
2476 2616
 
2477 2617
 				if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file))
2478 2618
 				{
2479
-					if (basename($working_file) == 'Settings.php')
2480
-						@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2481
-					else
2482
-						@copy($working_file, $working_file . '~');
2619
+					if (basename($working_file) == 'Settings.php') {
2620
+											@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2621
+					} else {
2622
+											@copy($working_file, $working_file . '~');
2623
+					}
2483 2624
 				}
2484 2625
 
2485 2626
 				package_put_contents($working_file, $working_data, $testing);
2486 2627
 			}
2487 2628
 
2488
-			if ($working_file !== null)
2489
-				$actions[] = array(
2629
+			if ($working_file !== null) {
2630
+							$actions[] = array(
2490 2631
 					'type' => 'saved',
2491 2632
 					'filename' => $working_file,
2492 2633
 					'is_custom' => $is_custom,
2493 2634
 				);
2635
+			}
2494 2636
 
2495 2637
 			// Is this "now working on" file a theme specific one?
2496 2638
 			$is_custom = isset($theme_id_ref[$counter - 1]) ? $theme_id_ref[$counter - 1] : 0;
@@ -2509,10 +2651,11 @@  discard block
 block discarded – undo
2509 2651
 			{
2510 2652
 				$places_to_check = array($boarddir, $sourcedir, $settings['default_theme_dir'], $settings['default_theme_dir'] . '/languages');
2511 2653
 
2512
-				foreach ($places_to_check as $place)
2513
-					if (file_exists($place . '/' . $working_file))
2654
+				foreach ($places_to_check as $place) {
2655
+									if (file_exists($place . '/' . $working_file))
2514 2656
 					{
2515 2657
 						$working_file = $place . '/' . $working_file;
2658
+				}
2516 2659
 						break;
2517 2660
 					}
2518 2661
 			}
@@ -2526,8 +2669,7 @@  discard block
 block discarded – undo
2526 2669
 					'type' => 'opened',
2527 2670
 					'filename' => $working_file
2528 2671
 				);
2529
-			}
2530
-			else
2672
+			} else
2531 2673
 			{
2532 2674
 				$actions[] = array(
2533 2675
 					'type' => 'missing',
@@ -2563,11 +2705,13 @@  discard block
 block discarded – undo
2563 2705
 			$replace_with = $code_match[2];
2564 2706
 
2565 2707
 			// Add this afterward...
2566
-			if ($code_match[1] == 'add' || $code_match[1] == 'add after')
2567
-				$replace_with = $working_search . "\n" . $replace_with;
2708
+			if ($code_match[1] == 'add' || $code_match[1] == 'add after') {
2709
+							$replace_with = $working_search . "\n" . $replace_with;
2710
+			}
2568 2711
 			// Add this beforehand.
2569
-			elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above')
2570
-				$replace_with .= "\n" . $working_search;
2712
+			elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above') {
2713
+							$replace_with .= "\n" . $working_search;
2714
+			}
2571 2715
 			// Otherwise.. replace with $replace_with ;).
2572 2716
 		}
2573 2717
 
@@ -2630,29 +2774,32 @@  discard block
 block discarded – undo
2630 2774
 	{
2631 2775
 		package_chmod($working_file);
2632 2776
 
2633
-		if (!is_writable($working_file))
2634
-			$actions[] = array(
2777
+		if (!is_writable($working_file)) {
2778
+					$actions[] = array(
2635 2779
 				'type' => 'chmod',
2636 2780
 				'filename' => $working_file
2637 2781
 			);
2782
+		}
2638 2783
 
2639 2784
 		if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file))
2640 2785
 		{
2641
-			if (basename($working_file) == 'Settings.php')
2642
-				@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2643
-			else
2644
-				@copy($working_file, $working_file . '~');
2786
+			if (basename($working_file) == 'Settings.php') {
2787
+							@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2788
+			} else {
2789
+							@copy($working_file, $working_file . '~');
2790
+			}
2645 2791
 		}
2646 2792
 
2647 2793
 		package_put_contents($working_file, $working_data, $testing);
2648 2794
 	}
2649 2795
 
2650
-	if ($working_file !== null)
2651
-		$actions[] = array(
2796
+	if ($working_file !== null) {
2797
+			$actions[] = array(
2652 2798
 			'type' => 'saved',
2653 2799
 			'filename' => $working_file,
2654 2800
 			'is_custom' => $is_custom,
2655 2801
 		);
2802
+	}
2656 2803
 
2657 2804
 	$actions[] = array(
2658 2805
 		'type' => 'result',
@@ -2678,17 +2825,19 @@  discard block
 block discarded – undo
2678 2825
 		$mem_check = setMemoryLimit('128M');
2679 2826
 
2680 2827
 		// Windows doesn't seem to care about the memory_limit.
2681
-		if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false)
2682
-			$package_cache = array();
2683
-		else
2684
-			$package_cache = false;
2828
+		if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) {
2829
+					$package_cache = array();
2830
+		} else {
2831
+					$package_cache = false;
2832
+		}
2685 2833
 	}
2686 2834
 
2687
-	if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename]))
2688
-		return file_get_contents($filename);
2689
-	else
2690
-		return $package_cache[$filename];
2691
-}
2835
+	if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) {
2836
+			return file_get_contents($filename);
2837
+	} else {
2838
+			return $package_cache[$filename];
2839
+	}
2840
+	}
2692 2841
 
2693 2842
 /**
2694 2843
  * Writes data to a file, almost exactly like the file_put_contents() function.
@@ -2712,19 +2861,22 @@  discard block
 block discarded – undo
2712 2861
 		// Try to increase the memory limit - we don't want to run out of ram!
2713 2862
 		$mem_check = setMemoryLimit('128M');
2714 2863
 
2715
-		if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false)
2716
-			$package_cache = array();
2717
-		else
2718
-			$package_cache = false;
2864
+		if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) {
2865
+					$package_cache = array();
2866
+		} else {
2867
+					$package_cache = false;
2868
+		}
2719 2869
 	}
2720 2870
 
2721
-	if (isset($package_ftp))
2722
-		$ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => ''));
2871
+	if (isset($package_ftp)) {
2872
+			$ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => ''));
2873
+	}
2723 2874
 
2724
-	if (!file_exists($filename) && isset($package_ftp))
2725
-		$package_ftp->create_file($ftp_file);
2726
-	elseif (!file_exists($filename))
2727
-		@touch($filename);
2875
+	if (!file_exists($filename) && isset($package_ftp)) {
2876
+			$package_ftp->create_file($ftp_file);
2877
+	} elseif (!file_exists($filename)) {
2878
+			@touch($filename);
2879
+	}
2728 2880
 
2729 2881
 	package_chmod($filename);
2730 2882
 
@@ -2733,22 +2885,23 @@  discard block
 block discarded – undo
2733 2885
 		$fp = @fopen($filename, in_array(substr($filename, -3), $text_filetypes) ? 'w' : 'wb');
2734 2886
 
2735 2887
 		// We should show an error message or attempt a rollback, no?
2736
-		if (!$fp)
2737
-			return false;
2888
+		if (!$fp) {
2889
+					return false;
2890
+		}
2738 2891
 
2739 2892
 		fwrite($fp, $data);
2740 2893
 		fclose($fp);
2741
-	}
2742
-	elseif (strpos($filename, 'Packages/') !== false || $package_cache === false)
2743
-		return strlen($data);
2744
-	else
2894
+	} elseif (strpos($filename, 'Packages/') !== false || $package_cache === false) {
2895
+			return strlen($data);
2896
+	} else
2745 2897
 	{
2746 2898
 		$package_cache[$filename] = $data;
2747 2899
 
2748 2900
 		// Permission denied, eh?
2749 2901
 		$fp = @fopen($filename, 'r+');
2750
-		if (!$fp)
2751
-			return false;
2902
+		if (!$fp) {
2903
+					return false;
2904
+		}
2752 2905
 		fclose($fp);
2753 2906
 	}
2754 2907
 
@@ -2766,19 +2919,22 @@  discard block
 block discarded – undo
2766 2919
 	global $package_ftp, $package_cache;
2767 2920
 	static $text_filetypes = array('php', 'txt', '.js', 'css', 'vbs', 'tml', 'htm');
2768 2921
 
2769
-	if (empty($package_cache))
2770
-		return;
2922
+	if (empty($package_cache)) {
2923
+			return;
2924
+	}
2771 2925
 
2772 2926
 	// First, let's check permissions!
2773 2927
 	foreach ($package_cache as $filename => $data)
2774 2928
 	{
2775
-		if (isset($package_ftp))
2776
-			$ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => ''));
2929
+		if (isset($package_ftp)) {
2930
+					$ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => ''));
2931
+		}
2777 2932
 
2778
-		if (!file_exists($filename) && isset($package_ftp))
2779
-			$package_ftp->create_file($ftp_file);
2780
-		elseif (!file_exists($filename))
2781
-			@touch($filename);
2933
+		if (!file_exists($filename) && isset($package_ftp)) {
2934
+					$package_ftp->create_file($ftp_file);
2935
+		} elseif (!file_exists($filename)) {
2936
+					@touch($filename);
2937
+		}
2782 2938
 
2783 2939
 		$result = package_chmod($filename);
2784 2940
 
@@ -2832,8 +2988,9 @@  discard block
 block discarded – undo
2832 2988
 	/** @var ftp_connection $package_ftp */
2833 2989
 	global $package_ftp;
2834 2990
 
2835
-	if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable')
2836
-		return true;
2991
+	if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') {
2992
+			return true;
2993
+	}
2837 2994
 
2838 2995
 	// Start off checking without FTP.
2839 2996
 	if (!isset($package_ftp) || $package_ftp === false)
@@ -2855,8 +3012,7 @@  discard block
 block discarded – undo
2855 3012
 
2856 3013
 				// Keep track of the writable status here.
2857 3014
 				$file_permissions = @fileperms($chmod_file);
2858
-			}
2859
-			else
3015
+			} else
2860 3016
 			{
2861 3017
 				// This looks odd, but it's an attempt to work around PHP suExec.
2862 3018
 				if (!file_exists($chmod_file) && $perm_state == 'writable')
@@ -2866,24 +3022,28 @@  discard block
 block discarded – undo
2866 3022
 					mktree(dirname($chmod_file), 0755);
2867 3023
 					@touch($chmod_file);
2868 3024
 					smf_chmod($chmod_file, 0755);
3025
+				} else {
3026
+									$file_permissions = @fileperms($chmod_file);
2869 3027
 				}
2870
-				else
2871
-					$file_permissions = @fileperms($chmod_file);
2872 3028
 			}
2873 3029
 
2874 3030
 			// This looks odd, but it's another attempt to work around PHP suExec.
2875
-			if ($perm_state != 'writable')
2876
-				smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644);
2877
-			else
3031
+			if ($perm_state != 'writable') {
3032
+							smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644);
3033
+			} else
2878 3034
 			{
2879
-				if (!@is_writable($chmod_file))
2880
-					smf_chmod($chmod_file, 0755);
2881
-				if (!@is_writable($chmod_file))
2882
-					smf_chmod($chmod_file, 0777);
2883
-				if (!@is_writable(dirname($chmod_file)))
2884
-					smf_chmod($chmod_file, 0755);
2885
-				if (!@is_writable(dirname($chmod_file)))
2886
-					smf_chmod($chmod_file, 0777);
3035
+				if (!@is_writable($chmod_file)) {
3036
+									smf_chmod($chmod_file, 0755);
3037
+				}
3038
+				if (!@is_writable($chmod_file)) {
3039
+									smf_chmod($chmod_file, 0777);
3040
+				}
3041
+				if (!@is_writable(dirname($chmod_file))) {
3042
+									smf_chmod($chmod_file, 0755);
3043
+				}
3044
+				if (!@is_writable(dirname($chmod_file))) {
3045
+									smf_chmod($chmod_file, 0777);
3046
+				}
2887 3047
 			}
2888 3048
 
2889 3049
 			// The ultimate writable test.
@@ -2892,20 +3052,22 @@  discard block
 block discarded – undo
2892 3052
 				$fp = is_dir($chmod_file) ? @opendir($chmod_file) : @fopen($chmod_file, 'rb');
2893 3053
 				if (@is_writable($chmod_file) && $fp)
2894 3054
 				{
2895
-					if (!is_dir($chmod_file))
2896
-						fclose($fp);
2897
-					else
2898
-						closedir($fp);
3055
+					if (!is_dir($chmod_file)) {
3056
+											fclose($fp);
3057
+					} else {
3058
+											closedir($fp);
3059
+					}
2899 3060
 
2900 3061
 					// It worked!
2901
-					if ($track_change)
2902
-						$_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions;
3062
+					if ($track_change) {
3063
+											$_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions;
3064
+					}
2903 3065
 
2904 3066
 					return true;
2905 3067
 				}
3068
+			} elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) {
3069
+							unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]);
2906 3070
 			}
2907
-			elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file]))
2908
-				unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]);
2909 3071
 		}
2910 3072
 
2911 3073
 		// If we're here we're a failure.
@@ -2924,31 +3086,33 @@  discard block
 block discarded – undo
2924 3086
 			mktree(dirname($filename), 0755);
2925 3087
 			$package_ftp->create_file($ftp_file);
2926 3088
 			$package_ftp->chmod($ftp_file, 0755);
3089
+		} else {
3090
+					$file_permissions = @fileperms($filename);
2927 3091
 		}
2928
-		else
2929
-			$file_permissions = @fileperms($filename);
2930 3092
 
2931 3093
 		if ($perm_state != 'writable')
2932 3094
 		{
2933 3095
 			$package_ftp->chmod($ftp_file, $perm_state == 'execute' ? 0755 : 0644);
2934
-		}
2935
-		else
3096
+		} else
2936 3097
 		{
2937
-			if (!@is_writable($filename))
2938
-				$package_ftp->chmod($ftp_file, 0777);
2939
-			if (!@is_writable(dirname($filename)))
2940
-				$package_ftp->chmod(dirname($ftp_file), 0777);
3098
+			if (!@is_writable($filename)) {
3099
+							$package_ftp->chmod($ftp_file, 0777);
3100
+			}
3101
+			if (!@is_writable(dirname($filename))) {
3102
+							$package_ftp->chmod(dirname($ftp_file), 0777);
3103
+			}
2941 3104
 		}
2942 3105
 
2943 3106
 		if (@is_writable($filename))
2944 3107
 		{
2945
-			if ($track_change)
2946
-				$_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions;
3108
+			if ($track_change) {
3109
+							$_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions;
3110
+			}
2947 3111
 
2948 3112
 			return true;
3113
+		} elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) {
3114
+					unset($_SESSION['pack_ftp']['original_perms'][$filename]);
2949 3115
 		}
2950
-		elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename]))
2951
-			unset($_SESSION['pack_ftp']['original_perms'][$filename]);
2952 3116
 	}
2953 3117
 
2954 3118
 	// Oh dear, we failed if we get here.
@@ -2966,11 +3130,13 @@  discard block
 block discarded – undo
2966 3130
 	$n = strlen($pass);
2967 3131
 
2968 3132
 	$salt = session_id();
2969
-	while (strlen($salt) < $n)
2970
-		$salt .= session_id();
3133
+	while (strlen($salt) < $n) {
3134
+			$salt .= session_id();
3135
+	}
2971 3136
 
2972
-	for ($i = 0; $i < $n; $i++)
2973
-		$pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32));
3137
+	for ($i = 0; $i < $n; $i++) {
3138
+			$pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32));
3139
+	}
2974 3140
 
2975 3141
 	return $pass;
2976 3142
 }
@@ -2989,8 +3155,9 @@  discard block
 block discarded – undo
2989 3155
 	$base_files = array('index.php', 'SSI.php', 'agreement.txt', 'cron.php', 'ssi_examples.php', 'ssi_examples.shtml', 'subscriptions.php');
2990 3156
 	foreach ($base_files as $file)
2991 3157
 	{
2992
-		if (file_exists($boarddir . '/' . $file))
2993
-			$files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file;
3158
+		if (file_exists($boarddir . '/' . $file)) {
3159
+					$files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file;
3160
+		}
2994 3161
 	}
2995 3162
 
2996 3163
 	$dirs = array(
@@ -3007,8 +3174,9 @@  discard block
 block discarded – undo
3007 3174
 			'theme_dir' => 'theme_dir',
3008 3175
 		)
3009 3176
 	);
3010
-	while ($row = $smcFunc['db_fetch_assoc']($request))
3011
-		$dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/');
3177
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
3178
+			$dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/');
3179
+	}
3012 3180
 	$smcFunc['db_free_result']($request);
3013 3181
 
3014 3182
 	try
@@ -3023,11 +3191,13 @@  discard block
 block discarded – undo
3023 3191
 
3024 3192
 			foreach ($iter as $entry => $dir)
3025 3193
 			{
3026
-				if ($dir->isDir())
3027
-					continue;
3194
+				if ($dir->isDir()) {
3195
+									continue;
3196
+				}
3028 3197
 
3029
-				if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0)
3030
-					continue;
3198
+				if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) {
3199
+									continue;
3200
+				}
3031 3201
 
3032 3202
 				$files[empty($_REQUEST['use_full_paths']) ? str_replace(realpath($boarddir), '', $entry) : $entry] = $entry;
3033 3203
 			}
@@ -3035,10 +3205,12 @@  discard block
 block discarded – undo
3035 3205
 		$obj = new ArrayObject($files);
3036 3206
 		$iterator = $obj->getIterator();
3037 3207
 
3038
-		if (!file_exists($packagesdir . '/backups'))
3039
-			mktree($packagesdir . '/backups', 0777);
3040
-		if (!is_writable($packagesdir . '/backups'))
3041
-			package_chmod($packagesdir . '/backups');
3208
+		if (!file_exists($packagesdir . '/backups')) {
3209
+					mktree($packagesdir . '/backups', 0777);
3210
+		}
3211
+		if (!is_writable($packagesdir . '/backups')) {
3212
+					package_chmod($packagesdir . '/backups');
3213
+		}
3042 3214
 		$output_file = $packagesdir . '/backups/' . strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id);
3043 3215
 		$output_ext = '.tar';
3044 3216
 		$output_ext_target = '.tar.gz';
@@ -3046,16 +3218,18 @@  discard block
 block discarded – undo
3046 3218
 		if (file_exists($output_file . $output_ext_target))
3047 3219
 		{
3048 3220
 			$i = 2;
3049
-			while (file_exists($output_file . '_' . $i . $output_ext_target))
3050
-				$i++;
3221
+			while (file_exists($output_file . '_' . $i . $output_ext_target)) {
3222
+							$i++;
3223
+			}
3051 3224
 			$output_file = $output_file . '_' . $i . $output_ext;
3225
+		} else {
3226
+					$output_file .= $output_ext;
3052 3227
 		}
3053
-		else
3054
-			$output_file .= $output_ext;
3055 3228
 
3056 3229
 		@set_time_limit(300);
3057
-		if (function_exists('apache_reset_timeout'))
3058
-			@apache_reset_timeout();
3230
+		if (function_exists('apache_reset_timeout')) {
3231
+					@apache_reset_timeout();
3232
+		}
3059 3233
 
3060 3234
 		$a = new PharData($output_file);
3061 3235
 		$a->buildFromIterator($iterator);
@@ -3067,8 +3241,7 @@  discard block
 block discarded – undo
3067 3241
 		 */
3068 3242
 		unset($a);
3069 3243
 		unlink($output_file);
3070
-	}
3071
-	catch (Exception $e)
3244
+	} catch (Exception $e)
3072 3245
 	{
3073 3246
 		log_error($e->getMessage(), 'backup');
3074 3247
 
@@ -3100,32 +3273,35 @@  discard block
 block discarded – undo
3100 3273
 	preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match);
3101 3274
 
3102 3275
 	// An FTP url. We should try connecting and RETRieving it...
3103
-	if (empty($match[1]))
3104
-		return false;
3105
-	elseif ($match[1] == 'ftp')
3276
+	if (empty($match[1])) {
3277
+			return false;
3278
+	} elseif ($match[1] == 'ftp')
3106 3279
 	{
3107 3280
 		// Include the file containing the ftp_connection class.
3108 3281
 		require_once($sourcedir . '/Class-Package.php');
3109 3282
 
3110 3283
 		// Establish a connection and attempt to enable passive mode.
3111 3284
 		$ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email);
3112
-		if ($ftp->error !== false || !$ftp->passive())
3113
-			return false;
3285
+		if ($ftp->error !== false || !$ftp->passive()) {
3286
+					return false;
3287
+		}
3114 3288
 
3115 3289
 		// I want that one *points*!
3116 3290
 		fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n");
3117 3291
 
3118 3292
 		// Since passive mode worked (or we would have returned already!) open the connection.
3119 3293
 		$fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5);
3120
-		if (!$fp)
3121
-			return false;
3294
+		if (!$fp) {
3295
+					return false;
3296
+		}
3122 3297
 
3123 3298
 		// The server should now say something in acknowledgement.
3124 3299
 		$ftp->check_response(150);
3125 3300
 
3126 3301
 		$data = '';
3127
-		while (!feof($fp))
3128
-			$data .= fread($fp, 4096);
3302
+		while (!feof($fp)) {
3303
+					$data .= fread($fp, 4096);
3304
+		}
3129 3305
 		fclose($fp);
3130 3306
 
3131 3307
 		// All done, right?  Good.
@@ -3142,22 +3318,25 @@  discard block
 block discarded – undo
3142 3318
 		$fetch_data->get_url_data($url, $post_data);
3143 3319
 
3144 3320
 		// no errors and a 200 result, then we have a good dataset, well we at least have data ;)
3145
-		if ($fetch_data->result('code') == 200 && !$fetch_data->result('error'))
3146
-			$data = $fetch_data->result('body');
3147
-		else
3148
-			return false;
3321
+		if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) {
3322
+					$data = $fetch_data->result('body');
3323
+		} else {
3324
+					return false;
3325
+		}
3149 3326
 	}
3150 3327
 	// This is more likely; a standard HTTP URL.
3151 3328
 	elseif (isset($match[1]) && $match[1] == 'http')
3152 3329
 	{
3153
-		if ($keep_alive && $match[3] == $keep_alive_dom)
3154
-			$fp = $keep_alive_fp;
3330
+		if ($keep_alive && $match[3] == $keep_alive_dom) {
3331
+					$fp = $keep_alive_fp;
3332
+		}
3155 3333
 		if (empty($fp))
3156 3334
 		{
3157 3335
 			// Open the socket on the port we want...
3158 3336
 			$fp = @fsockopen(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? ($match[2] ? 443 : 80) : $match[5], $err, $err, 5);
3159
-			if (!$fp)
3160
-				return false;
3337
+			if (!$fp) {
3338
+							return false;
3339
+			}
3161 3340
 		}
3162 3341
 
3163 3342
 		if ($keep_alive)
@@ -3172,20 +3351,21 @@  discard block
 block discarded – undo
3172 3351
 			fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n");
3173 3352
 			fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
3174 3353
 			fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n");
3175
-			if ($keep_alive)
3176
-				fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n");
3177
-			else
3178
-				fwrite($fp, 'Connection: close' . "\r\n\r\n");
3179
-		}
3180
-		else
3354
+			if ($keep_alive) {
3355
+							fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n");
3356
+			} else {
3357
+							fwrite($fp, 'Connection: close' . "\r\n\r\n");
3358
+			}
3359
+		} else
3181 3360
 		{
3182 3361
 			fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n");
3183 3362
 			fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
3184 3363
 			fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n");
3185
-			if ($keep_alive)
3186
-				fwrite($fp, 'Connection: Keep-Alive' . "\r\n");
3187
-			else
3188
-				fwrite($fp, 'Connection: close' . "\r\n");
3364
+			if ($keep_alive) {
3365
+							fwrite($fp, 'Connection: Keep-Alive' . "\r\n");
3366
+			} else {
3367
+							fwrite($fp, 'Connection: close' . "\r\n");
3368
+			}
3189 3369
 			fwrite($fp, 'Content-Type: application/x-www-form-urlencoded' . "\r\n");
3190 3370
 			fwrite($fp, 'Content-Length: ' . strlen($post_data) . "\r\n\r\n");
3191 3371
 			fwrite($fp, $post_data);
@@ -3198,30 +3378,33 @@  discard block
 block discarded – undo
3198 3378
 		{
3199 3379
 			$header = '';
3200 3380
 			$location = '';
3201
-			while (!feof($fp) && trim($header = fgets($fp, 4096)) != '')
3202
-				if (strpos($header, 'Location:') !== false)
3381
+			while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') {
3382
+							if (strpos($header, 'Location:') !== false)
3203 3383
 					$location = trim(substr($header, strpos($header, ':') + 1));
3384
+			}
3204 3385
 
3205
-			if (empty($location))
3206
-				return false;
3207
-			else
3386
+			if (empty($location)) {
3387
+							return false;
3388
+			} else
3208 3389
 			{
3209
-				if (!$keep_alive)
3210
-					fclose($fp);
3390
+				if (!$keep_alive) {
3391
+									fclose($fp);
3392
+				}
3211 3393
 				return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1);
3212 3394
 			}
3213 3395
 		}
3214 3396
 
3215 3397
 		// Make sure we get a 200 OK.
3216
-		elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0)
3217
-			return false;
3398
+		elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) {
3399
+					return false;
3400
+		}
3218 3401
 
3219 3402
 		// Skip the headers...
3220 3403
 		while (!feof($fp) && trim($header = fgets($fp, 4096)) != '')
3221 3404
 		{
3222
-			if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0)
3223
-				$content_length = $match[1];
3224
-			elseif (preg_match('~connection:\s*close~i', $header) != 0)
3405
+			if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) {
3406
+							$content_length = $match[1];
3407
+			} elseif (preg_match('~connection:\s*close~i', $header) != 0)
3225 3408
 			{
3226 3409
 				$keep_alive_dom = null;
3227 3410
 				$keep_alive = false;
@@ -3233,19 +3416,20 @@  discard block
 block discarded – undo
3233 3416
 		$data = '';
3234 3417
 		if (isset($content_length))
3235 3418
 		{
3236
-			while (!feof($fp) && strlen($data) < $content_length)
3237
-				$data .= fread($fp, $content_length - strlen($data));
3238
-		}
3239
-		else
3419
+			while (!feof($fp) && strlen($data) < $content_length) {
3420
+							$data .= fread($fp, $content_length - strlen($data));
3421
+			}
3422
+		} else
3240 3423
 		{
3241
-			while (!feof($fp))
3242
-				$data .= fread($fp, 4096);
3424
+			while (!feof($fp)) {
3425
+							$data .= fread($fp, 4096);
3426
+			}
3243 3427
 		}
3244 3428
 
3245
-		if (!$keep_alive)
3246
-			fclose($fp);
3247
-	}
3248
-	else
3429
+		if (!$keep_alive) {
3430
+					fclose($fp);
3431
+		}
3432
+	} else
3249 3433
 	{
3250 3434
 		// Umm, this shouldn't happen?
3251 3435
 		trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE);
Please login to merge, or discard this patch.
Sources/ReCaptcha/RequestMethod/Curl.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -32,43 +32,43 @@
 block discarded – undo
32 32
 class Curl
33 33
 {
34 34
 
35
-    /**
36
-     * @see https://php.net/curl_init
37
-     * @param string $url
38
-     * @return resource cURL handle
39
-     */
40
-    public function init($url = null)
41
-    {
42
-        return curl_init($url);
43
-    }
35
+	/**
36
+	 * @see https://php.net/curl_init
37
+	 * @param string $url
38
+	 * @return resource cURL handle
39
+	 */
40
+	public function init($url = null)
41
+	{
42
+		return curl_init($url);
43
+	}
44 44
 
45
-    /**
46
-     * @see https://php.net/curl_setopt_array
47
-     * @param resource $ch
48
-     * @param array $options
49
-     * @return bool
50
-     */
51
-    public function setoptArray($ch, array $options)
52
-    {
53
-        return curl_setopt_array($ch, $options);
54
-    }
45
+	/**
46
+	 * @see https://php.net/curl_setopt_array
47
+	 * @param resource $ch
48
+	 * @param array $options
49
+	 * @return bool
50
+	 */
51
+	public function setoptArray($ch, array $options)
52
+	{
53
+		return curl_setopt_array($ch, $options);
54
+	}
55 55
 
56
-    /**
57
-     * @see https://php.net/curl_exec
58
-     * @param resource $ch
59
-     * @return mixed
60
-     */
61
-    public function exec($ch)
62
-    {
63
-        return curl_exec($ch);
64
-    }
56
+	/**
57
+	 * @see https://php.net/curl_exec
58
+	 * @param resource $ch
59
+	 * @return mixed
60
+	 */
61
+	public function exec($ch)
62
+	{
63
+		return curl_exec($ch);
64
+	}
65 65
 
66
-    /**
67
-     * @see https://php.net/curl_close
68
-     * @param resource $ch
69
-     */
70
-    public function close($ch)
71
-    {
72
-        curl_close($ch);
73
-    }
66
+	/**
67
+	 * @see https://php.net/curl_close
68
+	 * @param resource $ch
69
+	 */
70
+	public function close($ch)
71
+	{
72
+		curl_close($ch);
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Themes/default/Post.template.php 2 patches
Braces   +89 added lines, -61 removed lines patch added patch discarded remove patch
@@ -22,22 +22,24 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32
-	foreach ($context['icons'] as $icon)
33
-		echo '
33
+	foreach ($context['icons'] as $icon) {
34
+			echo '
34 35
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
36
+	}
35 37
 	echo '
36 38
 			};';
37 39
 
38 40
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
39
-	if ($context['make_poll'])
40
-		echo '
41
+	if ($context['make_poll']) {
42
+			echo '
41 43
 			var pollOptionNum = 0, pollTabIndex;
42 44
 			var pollOptionId = ', $context['last_choice_id'], ';
43 45
 			function addPollOption()
@@ -56,11 +58,13 @@  discard block
 block discarded – undo
56 58
 
57 59
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('" class="input_text"></dd><p id="pollMoreOptions"></p>'), ');
58 60
 			}';
61
+	}
59 62
 
60 63
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
61
-	if ($context['make_event'])
62
-		echo '
64
+	if ($context['make_event']) {
65
+			echo '
63 66
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
67
+	}
64 68
 
65 69
 	// End of the javascript, start the form and display the link tree.
66 70
 	echo '
@@ -80,9 +84,10 @@  discard block
 block discarded – undo
80 84
 				</div>
81 85
 			</div><br>';
82 86
 
83
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
84
-		echo '
87
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
88
+			echo '
85 89
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
90
+	}
86 91
 
87 92
 	// Start the main table.
88 93
 	echo '
@@ -117,18 +122,20 @@  discard block
 block discarded – undo
117 122
 	}
118 123
 
119 124
 	// If it's locked, show a message to warn the replier.
120
-	if (!empty($context['locked']))
121
-	echo '
125
+	if (!empty($context['locked'])) {
126
+		echo '
122 127
 					<p class="errorbox">
123 128
 						', $txt['topic_locked_no_reply'], '
124 129
 					</p>';
130
+	}
125 131
 
126
-	if (!empty($modSettings['drafts_post_enabled']))
127
-		echo '
132
+	if (!empty($modSettings['drafts_post_enabled'])) {
133
+			echo '
128 134
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
129 135
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
130 136
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
131 137
 					</div>';
138
+	}
132 139
 
133 140
 	// The post header... important stuff
134 141
 	echo '
@@ -180,9 +187,10 @@  discard block
 block discarded – undo
180 187
 				{
181 188
 					echo '
182 189
 										<optgroup label="', $category['name'], '">';
183
-					foreach ($category['boards'] as $board)
184
-						echo '
190
+					foreach ($category['boards'] as $board) {
191
+											echo '
185 192
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
193
+					}
186 194
 					echo '
187 195
 										</optgroup>';
188 196
 				}
@@ -218,9 +226,10 @@  discard block
 block discarded – undo
218 226
 									<span class="label">', $txt['calendar_timezone'], '</span>
219 227
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
220 228
 
221
-			foreach ($context['all_timezones'] as $tz => $tzname)
222
-				echo '
229
+			foreach ($context['all_timezones'] as $tz => $tzname) {
230
+							echo '
223 231
 										<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
232
+			}
224 233
 
225 234
 			echo '
226 235
 									</select>
@@ -286,14 +295,15 @@  discard block
 block discarded – undo
286 295
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', ' class="input_check">
287 296
 								</dd>';
288 297
 
289
-		if ($context['poll_options']['guest_vote_enabled'])
290
-			echo '
298
+		if ($context['poll_options']['guest_vote_enabled']) {
299
+					echo '
291 300
 								<dt>
292 301
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
293 302
 								</dt>
294 303
 								<dd>
295 304
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', ' class="input_check">
296 305
 								</dd>';
306
+		}
297 307
 
298 308
 		echo '
299 309
 								<dt>
@@ -314,8 +324,8 @@  discard block
 block discarded – undo
314 324
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
315 325
 
316 326
 	// If we're editing and displaying edit details, show a box where they can say why
317
-	if (isset($context['editing']) && $modSettings['show_modify'])
318
-		echo '
327
+	if (isset($context['editing']) && $modSettings['show_modify']) {
328
+			echo '
319 329
 					<dl>
320 330
 						<dt class="clear">
321 331
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -324,20 +334,23 @@  discard block
 block discarded – undo
324 334
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text">
325 335
 						</dd>
326 336
 					</dl>';
337
+	}
327 338
 
328 339
 	// If this message has been edited in the past - display when it was.
329
-	if (isset($context['last_modified']))
330
-		echo '
340
+	if (isset($context['last_modified'])) {
341
+			echo '
331 342
 					<div class="padding smalltext">
332 343
 						', $context['last_modified_text'], '
333 344
 					</div>';
345
+	}
334 346
 
335 347
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
336
-	if (!empty($modSettings['additional_options_collapsable']))
337
-		echo '
348
+	if (!empty($modSettings['additional_options_collapsable'])) {
349
+			echo '
338 350
 					<div id="postAdditionalOptionsHeader">
339 351
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
340 352
 					</div>';
353
+	}
341 354
 
342 355
 	echo '
343 356
 					<div id="postAdditionalOptions">';
@@ -369,19 +382,21 @@  discard block
 block discarded – undo
369 382
 								<input type="hidden" name="attach_del[]" value="0">
370 383
 								', $txt['uncheck_unwatchd_attach'], ':
371 384
 							</dd>';
372
-		foreach ($context['current_attachments'] as $attachment)
373
-			echo '
385
+		foreach ($context['current_attachments'] as $attachment) {
386
+					echo '
374 387
 							<dd class="smalltext">
375 388
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', ' class="input_check"> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
376 389
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0)) : '', '</label>
377 390
 							</dd>';
391
+		}
378 392
 
379 393
 		echo '
380 394
 						</dl>';
381 395
 
382
-		if (!empty($context['files_in_session_warning']))
383
-			echo '
396
+		if (!empty($context['files_in_session_warning'])) {
397
+					echo '
384 398
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
399
+		}
385 400
 	}
386 401
 
387 402
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -434,8 +449,8 @@  discard block
 block discarded – undo
434 449
 								', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '">');
435 450
 
436 451
 		// Show more boxes if they aren't approaching that limit.
437
-		if ($context['num_allowed_attachments'] > 1)
438
-			echo '
452
+		if ($context['num_allowed_attachments'] > 1) {
453
+					echo '
439 454
 										<script>
440 455
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
441 456
 											var current_attachment = 1;
@@ -456,9 +471,10 @@  discard block
 block discarded – undo
456 471
 									</div>
457 472
 								</div>
458 473
 							</dd>';
459
-		else
460
-			echo '
474
+		} else {
475
+					echo '
461 476
 							</dd>';
477
+		}
462 478
 
463 479
 		// Add any template changes for an alternative upload system here.
464 480
 		call_integration_hook('integrate_upload_template');
@@ -467,21 +483,25 @@  discard block
 block discarded – undo
467 483
 							<dd class="smalltext">';
468 484
 
469 485
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
470
-		if (!empty($modSettings['attachmentCheckExtensions']))
471
-			echo '
486
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
487
+					echo '
472 488
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
489
+		}
473 490
 
474
-		if (!empty($context['attachment_restrictions']))
475
-			echo '
491
+		if (!empty($context['attachment_restrictions'])) {
492
+					echo '
476 493
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
494
+		}
477 495
 
478
-		if ($context['num_allowed_attachments'] == 0)
479
-			echo '
496
+		if ($context['num_allowed_attachments'] == 0) {
497
+					echo '
480 498
 								', $txt['attach_limit_nag'], '<br>';
499
+		}
481 500
 
482
-		if (!$context['can_post_attachment_unapproved'])
483
-			echo '
501
+		if (!$context['can_post_attachment_unapproved']) {
502
+					echo '
484 503
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
504
+		}
485 505
 
486 506
 		echo '
487 507
 							</dd>
@@ -504,10 +524,11 @@  discard block
 block discarded – undo
504 524
 							<dt><strong>', $txt['subject'], '</strong></dt>
505 525
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
506 526
 
507
-		foreach ($context['drafts'] as $draft)
508
-			echo '
527
+		foreach ($context['drafts'] as $draft) {
528
+					echo '
509 529
 							<dt>', $draft['link'], '</dt>
510 530
 							<dd>', $draft['poster_time'], '</dd>';
531
+		}
511 532
 		echo '
512 533
 						</dl>
513 534
 					</div>';
@@ -532,9 +553,10 @@  discard block
 block discarded – undo
532 553
 						', template_control_richedit_buttons($context['post_box_name']);
533 554
 
534 555
 	// Option to delete an event if user is editing one.
535
-	if ($context['make_event'] && !$context['event']['new'])
536
-		echo '
556
+	if ($context['make_event'] && !$context['event']['new']) {
557
+			echo '
537 558
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">';
559
+	}
538 560
 
539 561
 	echo '
540 562
 					</span>
@@ -543,9 +565,10 @@  discard block
 block discarded – undo
543 565
 			<br class="clear">';
544 566
 
545 567
 	// Assuming this isn't a new topic pass across the last message id.
546
-	if (isset($context['topic_last_message']))
547
-		echo '
568
+	if (isset($context['topic_last_message'])) {
569
+			echo '
548 570
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
571
+	}
549 572
 
550 573
 	echo '
551 574
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -687,9 +710,10 @@  discard block
 block discarded – undo
687 710
 
688 711
 						newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \'&nbsp;&#187;</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';';
689 712
 
690
-	if ($context['can_quote'])
691
-		echo '
713
+	if ($context['can_quote']) {
714
+			echo '
692 715
 						newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';';
716
+	}
693 717
 
694 718
 	echo '
695 719
 						newPostsHTML += \'<br class="clear">\';
@@ -732,8 +756,8 @@  discard block
 block discarded – undo
732 756
 			}';
733 757
 
734 758
 	// Code for showing and hiding additional options.
735
-	if (!empty($modSettings['additional_options_collapsable']))
736
-		echo '
759
+	if (!empty($modSettings['additional_options_collapsable'])) {
760
+			echo '
737 761
 			var oSwapAdditionalOptions = new smc_Toggle({
738 762
 				bToggleEnabled: true,
739 763
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -761,10 +785,11 @@  discard block
 block discarded – undo
761 785
 					}
762 786
 				]
763 787
 			});';
788
+	}
764 789
 
765 790
 	// Code for showing and hiding drafts
766
-	if (!empty($context['drafts']))
767
-		echo '
791
+	if (!empty($context['drafts'])) {
792
+			echo '
768 793
 			var oSwapDraftOptions = new smc_Toggle({
769 794
 				bToggleEnabled: true,
770 795
 				bCurrentlyCollapsed: true,
@@ -786,6 +811,7 @@  discard block
 block discarded – undo
786 811
 					}
787 812
 				]
788 813
 			});';
814
+	}
789 815
 
790 816
 	echo '
791 817
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -806,8 +832,9 @@  discard block
 block discarded – undo
806 832
 		foreach ($context['previous_posts'] as $post)
807 833
 		{
808 834
 			$ignoring = false;
809
-			if (!empty($post['is_ignored']))
810
-				$ignored_posts[] = $ignoring = $post['id'];
835
+			if (!empty($post['is_ignored'])) {
836
+							$ignored_posts[] = $ignoring = $post['id'];
837
+			}
811 838
 
812 839
 			echo '
813 840
 			<div class="windowbg">
@@ -990,10 +1017,10 @@  discard block
 block discarded – undo
990 1017
 		<div id="temporary_posting_area" style="display: none;"></div>
991 1018
 		<script>';
992 1019
 
993
-	if ($context['close_window'])
994
-		echo '
1020
+	if ($context['close_window']) {
1021
+			echo '
995 1022
 			window.close();';
996
-	else
1023
+	} else
997 1024
 	{
998 1025
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;).
999 1026
 		echo '
@@ -1047,11 +1074,12 @@  discard block
 block discarded – undo
1047 1074
 				</p>
1048 1075
 				<ul>';
1049 1076
 
1050
-	foreach ($context['groups'] as $group)
1051
-		echo '
1077
+	foreach ($context['groups'] as $group) {
1078
+			echo '
1052 1079
 					<li>
1053 1080
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked class="input_check"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
1054 1081
 					</li>';
1082
+	}
1055 1083
 
1056 1084
 	echo '
1057 1085
 					<li>
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 									</div>
417 417
 									<div class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div>
418 418
 									<div class="attach-ui">
419
-										<a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'] ,'</a>
420
-										<a class="button_submit upload">', $txt['upload'] ,'</a>
419
+										<a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'], '</a>
420
+										<a class="button_submit upload">', $txt['upload'], '</a>
421 421
 									</div>
422 422
 								</div>
423 423
 							</div>
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 							</dt>
436 436
 							<dd class="smalltext fallback">
437 437
 								<div id="attachUpload" class="descbox">
438
-									<h5>', $txt['attach_drop_zone'] ,'</h5>
439
-									<a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'] ,'</a>
440
-									<a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'] ,'</a>
441
-									<a class="button_submit fileinput-button">', $txt['attach_add'] ,'</a>
438
+									<h5>', $txt['attach_drop_zone'], '</h5>
439
+									<a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'], '</a>
440
+									<a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'], '</a>
441
+									<a class="button_submit fileinput-button">', $txt['attach_add'], '</a>
442 442
 									<div id="total-progress" class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div>
443 443
 									<div class="fallback">
444 444
 										<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="input_file fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	// Option to delete an event if user is editing one.
546 546
 	if ($context['make_event'] && !$context['event']['new'])
547 547
 		echo '
548
-						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">';
548
+						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'], '" class="button_submit you_sure">';
549 549
 
550 550
 	echo '
551 551
 					</span>
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 			});';
800 800
 
801 801
 	echo '
802
-			var oEditorID = "', $context['post_box_name'] ,'";
802
+			var oEditorID = "', $context['post_box_name'], '";
803 803
 			var oEditorObject = oEditorHandle_', $context['post_box_name'], ';
804 804
 		</script>';
805 805
 
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 			{
832 832
 				echo '
833 833
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
834
-						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
834
+						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>
835 835
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
836 836
 					</ul>';
837 837
 			}
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 	<head>
919 919
 		<meta charset="', $context['character_set'], '">
920 920
 		<title>', $txt['spell_check'], '</title>
921
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
921
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
922 922
 		<style>
923 923
 			body, td
924 924
 			{
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 			var spell_formname = window.opener.spell_formname;
952 952
 			var spell_fieldname = window.opener.spell_fieldname;
953 953
 		</script>
954
-		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'] ,'"></script>
955
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
954
+		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'], '"></script>
955
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
956 956
 		<script>
957 957
 			', $context['spell_js'], '
958 958
 		</script>
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 	<head>
995 995
 		<meta charset="', $context['character_set'], '">
996 996
 		<title>', $txt['retrieving_quote'], '</title>
997
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
997
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
998 998
 	</head>
999 999
 	<body>
1000 1000
 		', $txt['retrieving_quote'], '
Please login to merge, or discard this patch.
Sources/Logging.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 /**
20 20
  * Truncate the GET array to a specified length
21 21
  * @param array $arr The array to truncate
22
- * @param max_length $max_length The upperbound on the length
22
+ * @param integer $max_length The upperbound on the length
23 23
  *
24 24
  * @return array The truncated array
25 25
  */
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array The truncated array
25 25
  */
26
-function truncateArray($arr, $max_length=1900)
26
+function truncateArray($arr, $max_length = 1900)
27 27
 {
28 28
 	$curr_length = array_sum(array_map("strlen", $arr));
29 29
 	if ($curr_length <= $max_length)
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	else
32 32
 	{
33 33
 		// Truncate each element's value to a reasonable length
34
-		$param_max = floor($max_length/count($arr));
34
+		$param_max = floor($max_length / count($arr));
35 35
 		foreach ($arr as $key => &$value)
36 36
 			$value = substr($value, 0, $param_max - strlen($key) - 5);
37 37
 		return $arr;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change)
198 198
 	{
199 199
 		// Write the change
200
-		$write_db_change =  '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
200
+		$write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
201 201
 		$written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX);
202 202
 
203 203
 		// survey says ...
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br>
271 271
 	', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br>
272 272
 	', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br>
273
-	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
273
+	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), '
274 274
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
275 275
 
276 276
 	if (function_exists('memory_get_peak_usage'))
Please login to merge, or discard this patch.
Braces   +140 added lines, -101 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Truncate the GET array to a specified length
@@ -26,14 +27,15 @@  discard block
 block discarded – undo
26 27
 function truncateArray($arr, $max_length=1900)
27 28
 {
28 29
 	$curr_length = array_sum(array_map("strlen", $arr));
29
-	if ($curr_length <= $max_length)
30
-		return $arr;
31
-	else
30
+	if ($curr_length <= $max_length) {
31
+			return $arr;
32
+	} else
32 33
 	{
33 34
 		// Truncate each element's value to a reasonable length
34 35
 		$param_max = floor($max_length/count($arr));
35
-		foreach ($arr as $key => &$value)
36
-			$value = substr($value, 0, $param_max - strlen($key) - 5);
36
+		foreach ($arr as $key => &$value) {
37
+					$value = substr($value, 0, $param_max - strlen($key) - 5);
38
+		}
37 39
 		return $arr;
38 40
 	}
39 41
 }
@@ -55,8 +57,9 @@  discard block
 block discarded – undo
55 57
 		// Don't update for every page - this isn't wholly accurate but who cares.
56 58
 		if ($topic)
57 59
 		{
58
-			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
59
-				$force = false;
60
+			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
61
+							$force = false;
62
+			}
60 63
 			$_SESSION['last_topic_id'] = $topic;
61 64
 		}
62 65
 	}
@@ -69,22 +72,24 @@  discard block
 block discarded – undo
69 72
 	}
70 73
 
71 74
 	// Don't mark them as online more than every so often.
72
-	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
73
-		return;
75
+	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {
76
+			return;
77
+	}
74 78
 
75 79
 	if (!empty($modSettings['who_enabled']))
76 80
 	{
77 81
 		$serialized = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
78 82
 
79 83
 		// In the case of a dlattach action, session_var may not be set.
80
-		if (!isset($context['session_var']))
81
-			$context['session_var'] = $_SESSION['session_var'];
84
+		if (!isset($context['session_var'])) {
85
+					$context['session_var'] = $_SESSION['session_var'];
86
+		}
82 87
 
83 88
 		unset($serialized['sesc'], $serialized[$context['session_var']]);
84 89
 		$serialized = json_encode($serialized);
90
+	} else {
91
+			$serialized = '';
85 92
 	}
86
-	else
87
-		$serialized = '';
88 93
 
89 94
 	// Guests use 0, members use their session ID.
90 95
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
@@ -124,17 +129,18 @@  discard block
 block discarded – undo
124 129
 		);
125 130
 
126 131
 		// Guess it got deleted.
127
-		if ($smcFunc['db_affected_rows']() == 0)
132
+		if ($smcFunc['db_affected_rows']() == 0) {
133
+					$_SESSION['log_time'] = 0;
134
+		}
135
+	} else {
128 136
 			$_SESSION['log_time'] = 0;
129 137
 	}
130
-	else
131
-		$_SESSION['log_time'] = 0;
132 138
 
133 139
 	// Otherwise, we have to delete and insert.
134 140
 	if (empty($_SESSION['log_time']))
135 141
 	{
136
-		if ($do_delete || !empty($user_info['id']))
137
-			$smcFunc['db_query']('', '
142
+		if ($do_delete || !empty($user_info['id'])) {
143
+					$smcFunc['db_query']('', '
138 144
 				DELETE FROM {db_prefix}log_online
139 145
 				WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'),
140 146
 				array(
@@ -142,6 +148,7 @@  discard block
 block discarded – undo
142 148
 					'log_time' => time() - $modSettings['lastActive'] * 60,
143 149
 				)
144 150
 			);
151
+		}
145 152
 
146 153
 		$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
147 154
 			'{db_prefix}log_online',
@@ -155,21 +162,24 @@  discard block
 block discarded – undo
155 162
 	$_SESSION['log_time'] = time();
156 163
 
157 164
 	// Well, they are online now.
158
-	if (empty($_SESSION['timeOnlineUpdated']))
159
-		$_SESSION['timeOnlineUpdated'] = time();
165
+	if (empty($_SESSION['timeOnlineUpdated'])) {
166
+			$_SESSION['timeOnlineUpdated'] = time();
167
+	}
160 168
 
161 169
 	// Set their login time, if not already done within the last minute.
162 170
 	if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa'))))
163 171
 	{
164 172
 		// Don't count longer than 15 minutes.
165
-		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
166
-			$_SESSION['timeOnlineUpdated'] = time();
173
+		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
174
+					$_SESSION['timeOnlineUpdated'] = time();
175
+		}
167 176
 
168 177
 		$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
169 178
 		updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in']));
170 179
 
171
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
172
-			cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
180
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
181
+					cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
182
+		}
173 183
 
174 184
 		$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
175 185
 		$_SESSION['timeOnlineUpdated'] = time();
@@ -206,8 +216,7 @@  discard block
 block discarded – undo
206 216
 			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
207 217
 			// Copy the file back and run for your life!
208 218
 			@copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php');
209
-		}
210
-		else
219
+		} else
211 220
 		{
212 221
 			@touch($boarddir . '/' . 'Settings.php');
213 222
 			return true;
@@ -227,22 +236,27 @@  discard block
 block discarded – undo
227 236
 	global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt;
228 237
 
229 238
 	// Add to Settings.php if you want to show the debugging information.
230
-	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery'))
231
-		return;
239
+	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) {
240
+			return;
241
+	}
232 242
 
233
-	if (empty($_SESSION['view_queries']))
234
-		$_SESSION['view_queries'] = 0;
235
-	if (empty($context['debug']['language_files']))
236
-		$context['debug']['language_files'] = array();
237
-	if (empty($context['debug']['sheets']))
238
-		$context['debug']['sheets'] = array();
243
+	if (empty($_SESSION['view_queries'])) {
244
+			$_SESSION['view_queries'] = 0;
245
+	}
246
+	if (empty($context['debug']['language_files'])) {
247
+			$context['debug']['language_files'] = array();
248
+	}
249
+	if (empty($context['debug']['sheets'])) {
250
+			$context['debug']['sheets'] = array();
251
+	}
239 252
 
240 253
 	$files = get_included_files();
241 254
 	$total_size = 0;
242 255
 	for ($i = 0, $n = count($files); $i < $n; $i++)
243 256
 	{
244
-		if (file_exists($files[$i]))
245
-			$total_size += filesize($files[$i]);
257
+		if (file_exists($files[$i])) {
258
+					$total_size += filesize($files[$i]);
259
+		}
246 260
 		$files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)'));
247 261
 	}
248 262
 
@@ -251,8 +265,9 @@  discard block
 block discarded – undo
251 265
 	{
252 266
 		foreach ($db_cache as $q => $qq)
253 267
 		{
254
-			if (!empty($qq['w']))
255
-				$warnings += count($qq['w']);
268
+			if (!empty($qq['w'])) {
269
+							$warnings += count($qq['w']);
270
+			}
256 271
 		}
257 272
 
258 273
 		$_SESSION['debug'] = &$db_cache;
@@ -273,12 +288,14 @@  discard block
 block discarded – undo
273 288
 	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
274 289
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
275 290
 
276
-	if (function_exists('memory_get_peak_usage'))
277
-		echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
291
+	if (function_exists('memory_get_peak_usage')) {
292
+			echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
293
+	}
278 294
 
279 295
 	// What tokens are active?
280
-	if (isset($_SESSION['token']))
281
-		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
296
+	if (isset($_SESSION['token'])) {
297
+			echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
298
+	}
282 299
 
283 300
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
284 301
 	{
@@ -292,10 +309,12 @@  discard block
 block discarded – undo
292 309
 			$total_t += $cache_hit['t'];
293 310
 			$total_s += $cache_hit['s'];
294 311
 		}
295
-		if (!isset($cache_misses))
296
-			$cache_misses = array();
297
-		foreach ($cache_misses as $missed)
298
-			$missed_entries[] = $missed['d'] . ' ' . $missed['k'];
312
+		if (!isset($cache_misses)) {
313
+					$cache_misses = array();
314
+		}
315
+		foreach ($cache_misses as $missed) {
316
+					$missed_entries[] = $missed['d'] . ' ' . $missed['k'];
317
+		}
299 318
 
300 319
 		echo '
301 320
 	', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br>
@@ -306,38 +325,44 @@  discard block
 block discarded – undo
306 325
 	<a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br>
307 326
 	<br>';
308 327
 
309
-	if ($_SESSION['view_queries'] == 1 && !empty($db_cache))
310
-		foreach ($db_cache as $q => $qq)
328
+	if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
329
+			foreach ($db_cache as $q => $qq)
311 330
 		{
312 331
 			$is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0;
332
+	}
313 333
 			// Temporary tables created in earlier queries are not explainable.
314 334
 			if ($is_select)
315 335
 			{
316
-				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
317
-					if (strpos(trim($qq['q']), $tmp) !== false)
336
+				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
337
+									if (strpos(trim($qq['q']), $tmp) !== false)
318 338
 					{
319 339
 						$is_select = false;
340
+				}
320 341
 						break;
321 342
 					}
322 343
 			}
323 344
 			// But actual creation of the temporary tables are.
324
-			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0)
325
-				$is_select = true;
345
+			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) {
346
+							$is_select = true;
347
+			}
326 348
 
327 349
 			// Make the filenames look a bit better.
328
-			if (isset($qq['f']))
329
-				$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
350
+			if (isset($qq['f'])) {
351
+							$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
352
+			}
330 353
 
331 354
 			echo '
332 355
 	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br>
333 356
 	&nbsp;&nbsp;&nbsp;';
334
-			if (!empty($qq['f']) && !empty($qq['l']))
335
-				echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
357
+			if (!empty($qq['f']) && !empty($qq['l'])) {
358
+							echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
359
+			}
336 360
 
337
-			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
338
-				echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
339
-			elseif (isset($qq['t']))
340
-				echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
361
+			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) {
362
+							echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
363
+			} elseif (isset($qq['t'])) {
364
+							echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
365
+			}
341 366
 			echo '
342 367
 	<br>';
343 368
 		}
@@ -362,12 +387,14 @@  discard block
 block discarded – undo
362 387
 	global $modSettings, $smcFunc;
363 388
 	static $cache_stats = array();
364 389
 
365
-	if (empty($modSettings['trackStats']))
366
-		return false;
367
-	if (!empty($stats))
368
-		return $cache_stats = array_merge($cache_stats, $stats);
369
-	elseif (empty($cache_stats))
370
-		return false;
390
+	if (empty($modSettings['trackStats'])) {
391
+			return false;
392
+	}
393
+	if (!empty($stats)) {
394
+			return $cache_stats = array_merge($cache_stats, $stats);
395
+	} elseif (empty($cache_stats)) {
396
+			return false;
397
+	}
371 398
 
372 399
 	$setStringUpdate = '';
373 400
 	$insert_keys = array();
@@ -380,10 +407,11 @@  discard block
 block discarded – undo
380 407
 		$setStringUpdate .= '
381 408
 			' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ',';
382 409
 
383
-		if ($change === '+')
384
-			$cache_stats[$field] = 1;
385
-		else
386
-			$update_parameters[$field] = $change;
410
+		if ($change === '+') {
411
+					$cache_stats[$field] = 1;
412
+		} else {
413
+					$update_parameters[$field] = $change;
414
+		}
387 415
 		$insert_keys[$field] = 'int';
388 416
 	}
389 417
 
@@ -447,43 +475,50 @@  discard block
 block discarded – undo
447 475
 	);
448 476
 
449 477
 	// Make sure this particular log is enabled first...
450
-	if (empty($modSettings['modlog_enabled']))
451
-		unset ($log_types['moderate']);
452
-	if (empty($modSettings['userlog_enabled']))
453
-		unset ($log_types['user']);
454
-	if (empty($modSettings['adminlog_enabled']))
455
-		unset ($log_types['admin']);
478
+	if (empty($modSettings['modlog_enabled'])) {
479
+			unset ($log_types['moderate']);
480
+	}
481
+	if (empty($modSettings['userlog_enabled'])) {
482
+			unset ($log_types['user']);
483
+	}
484
+	if (empty($modSettings['adminlog_enabled'])) {
485
+			unset ($log_types['admin']);
486
+	}
456 487
 
457 488
 	call_integration_hook('integrate_log_types', array(&$log_types));
458 489
 
459 490
 	foreach ($logs as $log)
460 491
 	{
461
-		if (!isset($log_types[$log['log_type']]))
462
-			return false;
492
+		if (!isset($log_types[$log['log_type']])) {
493
+					return false;
494
+		}
463 495
 
464
-		if (!is_array($log['extra']))
465
-			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
496
+		if (!is_array($log['extra'])) {
497
+					trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
498
+		}
466 499
 
467 500
 		// Pull out the parts we want to store separately, but also make sure that the data is proper
468 501
 		if (isset($log['extra']['topic']))
469 502
 		{
470
-			if (!is_numeric($log['extra']['topic']))
471
-				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
503
+			if (!is_numeric($log['extra']['topic'])) {
504
+							trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
505
+			}
472 506
 			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
473 507
 			unset($log['extra']['topic']);
508
+		} else {
509
+					$topic_id = 0;
474 510
 		}
475
-		else
476
-			$topic_id = 0;
477 511
 
478 512
 		if (isset($log['extra']['message']))
479 513
 		{
480
-			if (!is_numeric($log['extra']['message']))
481
-				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
514
+			if (!is_numeric($log['extra']['message'])) {
515
+							trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
516
+			}
482 517
 			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
483 518
 			unset($log['extra']['message']);
519
+		} else {
520
+					$msg_id = 0;
484 521
 		}
485
-		else
486
-			$msg_id = 0;
487 522
 
488 523
 		// @todo cache this?
489 524
 		// Is there an associated report on this?
@@ -510,23 +545,26 @@  discard block
 block discarded – undo
510 545
 			$smcFunc['db_free_result']($request);
511 546
 		}
512 547
 
513
-		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
514
-			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
548
+		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) {
549
+					trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
550
+		}
515 551
 
516 552
 		if (isset($log['extra']['board']))
517 553
 		{
518
-			if (!is_numeric($log['extra']['board']))
519
-				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
554
+			if (!is_numeric($log['extra']['board'])) {
555
+							trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
556
+			}
520 557
 			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
521 558
 			unset($log['extra']['board']);
559
+		} else {
560
+					$board_id = 0;
522 561
 		}
523
-		else
524
-			$board_id = 0;
525 562
 
526 563
 		if (isset($log['extra']['board_to']))
527 564
 		{
528
-			if (!is_numeric($log['extra']['board_to']))
529
-				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
565
+			if (!is_numeric($log['extra']['board_to'])) {
566
+							trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
567
+			}
530 568
 			if (empty($board_id))
531 569
 			{
532 570
 				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
@@ -534,10 +572,11 @@  discard block
 block discarded – undo
534 572
 			}
535 573
 		}
536 574
 
537
-		if (isset($log['extra']['member_affected']))
538
-			$memID = $log['extra']['member_affected'];
539
-		else
540
-			$memID = $user_info['id'];
575
+		if (isset($log['extra']['member_affected'])) {
576
+					$memID = $log['extra']['member_affected'];
577
+		} else {
578
+					$memID = $user_info['id'];
579
+		}
541 580
 
542 581
 		$inserts[] = array(
543 582
 			time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'],
Please login to merge, or discard this patch.