Completed
Pull Request — release-2.1 (#4670)
by Fran
13:14
created
Themes/default/MoveTopic.template.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
 		foreach ($category['boards'] as $board)
41 41
 			echo '
42
-									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
42
+									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt; ' : '', $board['name'], '</option>';
43 43
 		echo '
44 44
 								</optgroup>';
45 45
 	}
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	// Stick our "create a redirection topic" template in here...
64 64
 	template_redirect_options('move');
65 65
 
66
-    echo '
66
+	echo '
67 67
 					<input type="submit" value="', $txt['move_topic'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button">
68 68
 				</div><!-- .move_topic -->
69 69
 			</div><!-- .windowbg -->';
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function template_redirect_options($type)
88 88
 {
89
-    global $txt, $context, $modSettings;
89
+	global $txt, $context, $modSettings;
90 90
 
91
-    echo '
91
+	echo '
92 92
 					<label for="postRedirect">
93 93
 						<input type="checkbox" name="postRedirect" id="postRedirect"', $context['is_approved'] ? ' checked' : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt[$type . '_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';"> ', $txt['post_redirection'], '.
94 94
 					</label>
Please login to merge, or discard this patch.
Braces   +32 added lines, -23 removed lines patch added patch discarded remove patch
@@ -37,9 +37,10 @@  discard block
 block discarded – undo
37 37
 		echo '
38 38
 								<optgroup label="', $category['name'], '">';
39 39
 
40
-		foreach ($category['boards'] as $board)
41
-			echo '
40
+		foreach ($category['boards'] as $board) {
41
+					echo '
42 42
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
43
+		}
43 44
 		echo '
44 45
 								</optgroup>';
45 46
 	}
@@ -70,9 +71,10 @@  discard block
 block discarded – undo
70 71
 				</div><!-- .move_topic -->
71 72
 			</div><!-- .windowbg -->';
72 73
 
73
-	if ($context['back_to_topic'])
74
-		echo '
74
+	if ($context['back_to_topic']) {
75
+			echo '
75 76
 			<input type="hidden" name="goback" value="1">';
77
+	}
76 78
 
77 79
 	echo '
78 80
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -125,10 +127,10 @@  discard block
 block discarded – undo
125 127
 									<option value="86400">', $txt['two_months'], '</option>
126 128
 								</select>
127 129
 							</dd>';
128
-	}
129
-	else
130
-		echo '
130
+	} else {
131
+			echo '
131 132
 							<input type="hidden" name="redirect_expires" value="0">';
133
+	}
132 134
 
133 135
 	echo '
134 136
 						</dl>
@@ -207,9 +209,10 @@  discard block
 block discarded – undo
207 209
 			echo '
208 210
 							<optgroup label="', $cat['name'], '">';
209 211
 
210
-			foreach ($cat['boards'] as $board)
211
-				echo '
212
+			foreach ($cat['boards'] as $board) {
213
+							echo '
212 214
 								<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
215
+			}
213 216
 
214 217
 			echo '
215 218
 							</optgroup>';
@@ -219,9 +222,9 @@  discard block
 block discarded – undo
219 222
 						<input type="hidden" name="from" value="' . $context['origin_topic'] . '">
220 223
 						<input type="submit" value="', $txt['go'], '" class="button">
221 224
 					</form>';
225
+	} else {
226
+			echo $txt['target_below'];
222 227
 	}
223
-	else
224
-		echo $txt['target_below'];
225 228
 
226 229
 	echo '		</h4>
227 230
 			</div><!-- .title_bar -->
@@ -239,12 +242,13 @@  discard block
 block discarded – undo
239 242
 
240 243
 		$merge_button = create_button('merge', 'merge', '');
241 244
 
242
-		foreach ($context['topics'] as $topic)
243
-			echo '
245
+		foreach ($context['topics'] as $topic) {
246
+					echo '
244 247
 						<li>
245 248
 							<a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a>
246 249
 							<a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
247 250
 						</li>';
251
+		}
248 252
 
249 253
 		echo '
250 254
 					</ul>
@@ -255,9 +259,10 @@  discard block
 block discarded – undo
255 259
 				</div>';
256 260
 	}
257 261
 	// Just a nice "There aren't any topics" message
258
-	else
259
-		echo '
262
+	else {
263
+			echo '
260 264
 				<div class="windowbg2">', $txt['topic_alert_none'], '</div>';
265
+	}
261 266
 
262 267
 	echo '
263 268
 				<br>
@@ -307,8 +312,8 @@  discard block
 block discarded – undo
307 312
 				</thead>
308 313
 				<tbody>';
309 314
 
310
-	foreach ($context['topics'] as $topic)
311
-		echo '
315
+	foreach ($context['topics'] as $topic) {
316
+			echo '
312 317
 					<tr class="windowbg">
313 318
 						<td>
314 319
 							<input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked>
@@ -328,6 +333,7 @@  discard block
 block discarded – undo
328 333
 							<input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked>
329 334
 						</td>
330 335
 					</tr>';
336
+	}
331 337
 	echo '
332 338
 				</tbody>
333 339
 			</table>
@@ -337,9 +343,10 @@  discard block
 block discarded – undo
337 343
 					<legend>', $txt['merge_select_subject'], '</legend>
338 344
 					<select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
339 345
 
340
-	foreach ($context['topics'] as $topic)
341
-		echo '
346
+	foreach ($context['topics'] as $topic) {
347
+			echo '
342 348
 						<option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>';
349
+	}
343 350
 	echo '
344 351
 						<option value="0">', $txt['merge_custom_subject'], ':</option>
345 352
 					</select>
@@ -358,11 +365,12 @@  discard block
 block discarded – undo
358 365
 					<legend>', $txt['merge_select_target_board'], '</legend>
359 366
 					<ul>';
360 367
 
361
-		foreach ($context['boards'] as $board)
362
-			echo '
368
+		foreach ($context['boards'] as $board) {
369
+					echo '
363 370
 						<li>
364 371
 							<input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . '
365 372
 						</li>';
373
+		}
366 374
 		echo '
367 375
 					</ul>
368 376
 				</fieldset>';
@@ -374,11 +382,12 @@  discard block
 block discarded – undo
374 382
 					<legend>' . $txt['merge_select_poll'] . '</legend>
375 383
 					<ul>';
376 384
 
377
-		foreach ($context['polls'] as $poll)
378
-			echo '
385
+		foreach ($context['polls'] as $poll) {
386
+					echo '
379 387
 						<li>
380 388
 							<input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>)
381 389
 						</li>';
390
+		}
382 391
 		echo '
383 392
 						<li>
384 393
 							<input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ')
Please login to merge, or discard this patch.
Themes/default/GenericList.template.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -220,7 +220,7 @@
 block discarded – undo
220 220
 				),
221 221
 			),
222 222
 		);
223
-	*/
223
+	 */
224 224
 
225 225
 	// Are we using right-to-left orientation?
226 226
 	$first = $context['right_to_left'] ? 'last' : 'first';
Please login to merge, or discard this patch.
Braces   +65 added lines, -46 removed lines patch added patch discarded remove patch
@@ -22,27 +22,31 @@  discard block
 block discarded – undo
22 22
 	// Get a shortcut to the current list.
23 23
 	$list_id = $list_id === null ? (!empty($context['default_list']) ? $context['default_list'] : '') : $list_id;
24 24
 
25
-	if (empty($list_id) || empty($context[$list_id]))
26
-		return;
25
+	if (empty($list_id) || empty($context[$list_id])) {
26
+			return;
27
+	}
27 28
 
28 29
 	$cur_list = &$context[$list_id];
29 30
 
30 31
 	// These are the main tabs that is used all around the template.
31
-	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top'))
32
-		template_create_list_menu($cur_list['list_menu'], 'top');
32
+	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) {
33
+			template_create_list_menu($cur_list['list_menu'], 'top');
34
+	}
33 35
 
34
-	if (isset($cur_list['form']))
35
-		echo '
36
+	if (isset($cur_list['form'])) {
37
+			echo '
36 38
 	<form action="', $cur_list['form']['href'], '" method="post"', empty($cur_list['form']['name']) ? '' : ' name="' . $cur_list['form']['name'] . '" id="' . $cur_list['form']['name'] . '"', ' accept-charset="', $context['character_set'], '">';
39
+	}
37 40
 
38 41
 	// Show the title of the table (if any).
39
-	if (!empty($cur_list['title']))
40
-		echo '
42
+	if (!empty($cur_list['title'])) {
43
+			echo '
41 44
 		<div class="cat_bar">
42 45
 			<h3 class="catbg">
43 46
 				', $cur_list['title'], '
44 47
 			</h3>
45 48
 		</div>';
49
+	}
46 50
 
47 51
 	if (isset($cur_list['additional_rows']['after_title']))
48 52
 	{
@@ -55,20 +59,23 @@  discard block
 block discarded – undo
55 59
 		</div>';
56 60
 	}
57 61
 
58
-	if (isset($cur_list['additional_rows']['top_of_list']))
59
-		template_additional_rows('top_of_list', $cur_list);
62
+	if (isset($cur_list['additional_rows']['top_of_list'])) {
63
+			template_additional_rows('top_of_list', $cur_list);
64
+	}
60 65
 
61 66
 	if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['above_column_headers']))
62 67
 	{
63 68
 		// Show the page index (if this list doesn't intend to show all items).
64
-		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index']))
65
-			echo '
69
+		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) {
70
+					echo '
66 71
 		<div class="floatleft">
67 72
 			<div class="pagesection">', $cur_list['page_index'], '</div>
68 73
 		</div>';
74
+		}
69 75
 
70
-		if (isset($cur_list['additional_rows']['above_column_headers']))
71
-			template_additional_rows('above_column_headers', $cur_list);
76
+		if (isset($cur_list['additional_rows']['above_column_headers'])) {
77
+					template_additional_rows('above_column_headers', $cur_list);
78
+		}
72 79
 	}
73 80
 
74 81
 	echo '
@@ -83,11 +90,12 @@  discard block
 block discarded – undo
83 90
 				<tr class="title_bar">';
84 91
 
85 92
 		// Loop through each column and add a table header.
86
-		foreach ($cur_list['headers'] as $col_header)
87
-			echo '
93
+		foreach ($cur_list['headers'] as $col_header) {
94
+					echo '
88 95
 					<th scope="col" id="header_', $list_id, '_', $col_header['id'], '"', empty($col_header['class']) ? '' : ' class="' . $col_header['class'] . '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '>
89 96
 						', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? '' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <span class="generic_icons sort_' . $col_header['sort_image'] . '"></span></a>'), '
90 97
 					</th>';
98
+		}
91 99
 
92 100
 		echo '
93 101
 				</tr>
@@ -98,13 +106,14 @@  discard block
 block discarded – undo
98 106
 			<tbody>';
99 107
 
100 108
 	// Show a nice message informing there are no items in this list.
101
-	if (empty($cur_list['rows']) && !empty($cur_list['no_items_label']))
102
-		echo '
109
+	if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) {
110
+			echo '
103 111
 				<tr class="windowbg">
104 112
 					<td colspan="', $cur_list['num_columns'], '" class="', !empty($cur_list['no_items_align']) ? $cur_list['no_items_align'] : 'centertext', '">
105 113
 						', $cur_list['no_items_label'], '
106 114
 					</td>
107 115
 				</tr>';
116
+	}
108 117
 
109 118
 	// Show the list rows.
110 119
 	elseif (!empty($cur_list['rows']))
@@ -114,12 +123,13 @@  discard block
 block discarded – undo
114 123
 			echo '
115 124
 				<tr class="windowbg', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', ' id="list_', $list_id, '_', $id, '">';
116 125
 
117
-			if (!empty($row['data']))
118
-				foreach ($row['data'] as $row_data)
126
+			if (!empty($row['data'])) {
127
+							foreach ($row['data'] as $row_data)
119 128
 					echo '
120 129
 					<td', empty($row_data['class']) ? '' : ' class="' . $row_data['class'] . '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '>
121 130
 						', $row_data['value'], '
122 131
 					</td>';
132
+			}
123 133
 
124 134
 			echo '
125 135
 				</tr>';
@@ -136,46 +146,53 @@  discard block
 block discarded – undo
136 146
 		<div class="flow_auto">';
137 147
 
138 148
 		// Show the page index (if this list doesn't intend to show all items).
139
-		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index']))
140
-			echo '
149
+		if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) {
150
+					echo '
141 151
 			<div class="floatleft">
142 152
 				<div class="pagesection">', $cur_list['page_index'], '</div>
143 153
 			</div>';
154
+		}
144 155
 
145
-		if (isset($cur_list['additional_rows']['below_table_data']))
146
-			template_additional_rows('below_table_data', $cur_list);
156
+		if (isset($cur_list['additional_rows']['below_table_data'])) {
157
+					template_additional_rows('below_table_data', $cur_list);
158
+		}
147 159
 
148 160
 		echo '
149 161
 		</div>';
150 162
 	}
151 163
 
152
-	if (isset($cur_list['additional_rows']['bottom_of_list']))
153
-		template_additional_rows('bottom_of_list', $cur_list);
164
+	if (isset($cur_list['additional_rows']['bottom_of_list'])) {
165
+			template_additional_rows('bottom_of_list', $cur_list);
166
+	}
154 167
 
155 168
 	if (isset($cur_list['form']))
156 169
 	{
157
-		foreach ($cur_list['form']['hidden_fields'] as $name => $value)
158
-			echo '
170
+		foreach ($cur_list['form']['hidden_fields'] as $name => $value) {
171
+					echo '
159 172
 		<input type="hidden" name="', $name, '" value="', $value, '">';
173
+		}
160 174
 
161
-		if (isset($cur_list['form']['token']))
162
-			echo '
175
+		if (isset($cur_list['form']['token'])) {
176
+					echo '
163 177
 		<input type="hidden" name="', $context[$cur_list['form']['token'] . '_token_var'], '" value="', $context[$cur_list['form']['token'] . '_token'], '">';
178
+		}
164 179
 
165 180
 		echo '
166 181
 	</form>';
167 182
 	}
168 183
 
169 184
 	// Tabs at the bottom.  Usually bottom aligned.
170
-	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom'))
171
-		template_create_list_menu($cur_list['list_menu'], 'bottom');
185
+	if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom')) {
186
+			template_create_list_menu($cur_list['list_menu'], 'bottom');
187
+	}
172 188
 
173
-	if (isset($cur_list['javascript']))
174
-		echo '
189
+	if (isset($cur_list['javascript'])) {
190
+			echo '
175 191
 	<script>
176 192
 		', $cur_list['javascript'], '
177 193
 	</script>';
178
-}
194
+	}
195
+	}
179 196
 
180 197
 /**
181 198
  * This template displays additional rows above or below the list.
@@ -185,12 +202,13 @@  discard block
 block discarded – undo
185 202
  */
186 203
 function template_additional_rows($row_position, $cur_list)
187 204
 {
188
-	foreach ($cur_list['additional_rows'][$row_position] as $row)
189
-		echo '
205
+	foreach ($cur_list['additional_rows'][$row_position] as $row) {
206
+			echo '
190 207
 			<div class="additional_row', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '>
191 208
 				', $row['value'], '
192 209
 			</div>';
193
-}
210
+	}
211
+	}
194 212
 
195 213
 /**
196 214
  * This function creates a menu
@@ -249,18 +267,19 @@  discard block
 block discarded – undo
249 267
 
250 268
 		foreach ($list_menu['links'] as $link)
251 269
 		{
252
-			if ($link['is_selected'])
253
-				echo '
270
+			if ($link['is_selected']) {
271
+							echo '
254 272
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $first, '"></td>
255 273
 							<td class="', $direction == 'top' ? 'mirrortab' : 'maintab', '_active_back">
256 274
 								<a href="', $link['href'], '">', $link['label'], '</a>
257 275
 							</td>
258 276
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $last, '"></td>';
259
-			else
260
-				echo '
277
+			} else {
278
+							echo '
261 279
 							<td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back">
262 280
 								<a href="', $link['href'], '">', $link['label'], '</a>
263 281
 							</td>';
282
+			}
264 283
 		}
265 284
 
266 285
 		echo '
@@ -271,12 +290,12 @@  discard block
 block discarded – undo
271 290
 				<td></td>' : '', '
272 291
 			</tr>
273 292
 		</table>';
274
-	}
275
-	elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons')
293
+	} elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons')
276 294
 	{
277 295
 		$links = array();
278
-		foreach ($list_menu['links'] as $link)
279
-			$links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';
296
+		foreach ($list_menu['links'] as $link) {
297
+					$links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';
298
+		}
280 299
 
281 300
 		echo '
282 301
 		<table style="margin-', $list_menu['position'], ': 10px; width: 100%;">
Please login to merge, or discard this patch.
Themes/default/Help.template.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 		<meta charset="', $context['character_set'], '">
25 25
 		<meta name="robots" content="noindex">
26 26
 		<title>', $context['page_title'], '</title>
27
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
28
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
27
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
28
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
29 29
 	</head>
30 30
 	<body id="help_popup">
31 31
 		<div class="windowbg description">
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 		<title>', $txt['find_members'], '</title>
51 51
 		<meta charset="', $context['character_set'], '">
52 52
 		<meta name="robots" content="noindex">
53
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
54
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
53
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
54
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
55 55
 		<script>
56 56
 			var membersAdded = [];
57 57
 			function addMember(name)
Please login to merge, or discard this patch.
Braces   +21 added lines, -16 removed lines patch added patch discarded remove patch
@@ -86,11 +86,12 @@  discard block
 block discarded – undo
86 86
 					<span class="smalltext"><em>', $txt['find_wildcards'], '</em></span><br>';
87 87
 
88 88
 	// Only offer to search for buddies if we have some!
89
-	if (!empty($context['show_buddies']))
90
-		echo '
89
+	if (!empty($context['show_buddies'])) {
90
+			echo '
91 91
 					<span class="smalltext">
92 92
 						<label for="buddies"><input type="checkbox" name="buddies" id="buddies"', !empty($context['buddy_search']) ? ' checked' : '', '> ', $txt['find_buddies'], '</label>
93 93
 					</span><br>';
94
+	}
94 95
 
95 96
 	echo '
96 97
 					<div class="padding righttext">
@@ -105,20 +106,21 @@  discard block
 block discarded – undo
105 106
 					<h3 class="catbg">', $txt['find_results'], '</h3>
106 107
 				</div>';
107 108
 
108
-	if (empty($context['results']))
109
-		echo '
109
+	if (empty($context['results'])) {
110
+			echo '
110 111
 				<p class="error">', $txt['find_no_results'], '</p>';
111
-	else
112
+	} else
112 113
 	{
113 114
 		echo '
114 115
 				<ul class="padding">';
115 116
 
116
-		foreach ($context['results'] as $result)
117
-			echo '
117
+		foreach ($context['results'] as $result) {
118
+					echo '
118 119
 					<li class="windowbg">
119 120
 						<a href="', $result['href'], '" target="_blank" rel="noopener"> <span class="generic_icons profile_sm"></span>
120 121
 						<a href="javascript:void(0);" onclick="addMember(this.innerHTML); return false;">', $result['name'], '</a>
121 122
 					</li>';
123
+		}
122 124
 
123 125
 		echo '
124 126
 				</ul>
@@ -134,11 +136,12 @@  discard block
 block discarded – undo
134 136
 			<input type="hidden" name="quote" value="', $context['quote_results'] ? '1' : '0', '">
135 137
 		</form>';
136 138
 
137
-	if (empty($context['results']))
138
-		echo '
139
+	if (empty($context['results'])) {
140
+			echo '
139 141
 		<script>
140 142
 			document.getElementById("search").focus();
141 143
 		</script>';
144
+	}
142 145
 
143 146
 	echo '
144 147
 	</body>
@@ -162,9 +165,10 @@  discard block
 block discarded – undo
162 165
 					<p>', $txt['manual_introduction'], '</p>
163 166
 					<ul>';
164 167
 
165
-	foreach ($context['manual_sections'] as $section_id => $wiki_id)
166
-		echo '
168
+	foreach ($context['manual_sections'] as $section_id => $wiki_id) {
169
+			echo '
167 170
 						<li><a href="', $context['wiki_url'], '/', $context['wiki_prefix'], $wiki_id, ($txt['lang_dictionary'] != 'en' ? '/' . $txt['lang_dictionary'] : ''), '" target="_blank" rel="noopener">', $txt['manual_section_' . $section_id . '_title'], '</a> - ', $txt['manual_section_' . $section_id . '_desc'], '</li>';
171
+	}
168 172
 
169 173
 	echo '
170 174
 					</ul>
@@ -180,8 +184,8 @@  discard block
 block discarded – undo
180 184
 {
181 185
 	global $txt, $context, $modSettings;
182 186
 
183
-	if (!empty($modSettings['requireAgreement']))
184
-		echo '
187
+	if (!empty($modSettings['requireAgreement'])) {
188
+			echo '
185 189
 			<div class="cat_bar">
186 190
 				<h3 class="catbg">
187 191
 					', $txt['terms_and_rules'], ' - ', $context['forum_name_html_safe'], '
@@ -190,11 +194,12 @@  discard block
 block discarded – undo
190 194
 			<div class="roundframe">
191 195
 				', $context['agreement'], '
192 196
 			</div>';
193
-	else
194
-		echo '
197
+	} else {
198
+			echo '
195 199
 			<div class="noticebox">
196 200
 				', $txt['agreement_disabled'], '
197 201
 			</div>';
198
-}
202
+	}
203
+	}
199 204
 
200 205
 ?>
201 206
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/SplitTopics.template.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 				</div>
102 102
 				<ul id="messages_not_selected" class="split_messages smalltext">';
103 103
 
104
-	foreach ($context['not_selected']['messages'] as $message)
105
-		echo '
104
+	foreach ($context['not_selected']['messages'] as $message) {
105
+			echo '
106 106
 					<li class="windowbg" id="not_selected_', $message['id'], '">
107 107
 						<div class="message_header">
108 108
 							<a class="split_icon floatright" href="', $scripturl, '?action=splittopics;sa=selectTopics;subname=', $context['topic']['subject'], ';topic=', $context['topic']['id'], '.', $context['not_selected']['start'], ';start2=', $context['selected']['start'], ';move=down;msg=', $message['id'], '" onclick="return select(\'down\', ', $message['id'], ');"><span class="generic_icons split_sel" title="-&gt;"></span></a>
@@ -111,6 +111,7 @@  discard block
 block discarded – undo
111 111
 						</div>
112 112
 						<div class="post">', $message['body'], '</div>
113 113
 					</li>';
114
+	}
114 115
 
115 116
 	echo '
116 117
 					<li class="dummy">
@@ -130,8 +131,8 @@  discard block
 block discarded – undo
130 131
 				</div>
131 132
 				<ul id="messages_selected" class="split_messages smalltext">';
132 133
 
133
-	if (!empty($context['selected']['messages']))
134
-		foreach ($context['selected']['messages'] as $message)
134
+	if (!empty($context['selected']['messages'])) {
135
+			foreach ($context['selected']['messages'] as $message)
135 136
 			echo '
136 137
 					<li class="windowbg" id="selected_', $message['id'], '">
137 138
 						<div class="message_header">
@@ -141,6 +142,7 @@  discard block
 block discarded – undo
141 142
 						</div>
142 143
 						<div class="post">', $message['body'], '</div>
143 144
 					</li>';
145
+	}
144 146
 
145 147
 	echo '
146 148
 					<li class="dummy">
Please login to merge, or discard this patch.
Sources/Search.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 
660 660
 	// Remove the phrase parts and extract the words.
661 661
 	$wordArray = preg_replace('~(?:^|\s)(?:[-]?)"(?:[^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), ' ', $search_params['search']);
662
-	$wordArray = explode(' ',  $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES));
662
+	$wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES));
663 663
 
664 664
 	// A minus sign in front of a word excludes the word.... so...
665 665
 	$excludedWords = array();
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 						SELECT
1105 1105
 							{int:id_search},
1106 1106
 							t.id_topic,
1107
-							' . $relevance. ',
1107
+							' . $relevance . ',
1108 1108
 							' . (empty($userQuery) ? 't.id_first_msg' : 'm.id_msg') . ',
1109 1109
 							1
1110 1110
 						FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : '
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 						if (empty($subject_query['where']))
1340 1340
 							continue;
1341 1341
 
1342
-						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( '
1342
+						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ('
1343 1343
 							INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics
1344 1344
 								(' . ($createTemporary ? '' : 'id_search, ') . 'id_topic)') : '') . '
1345 1345
 							SELECT ' . ($createTemporary ? '' : $_SESSION['search_cache']['id_search'] . ', ') . 't.id_topic
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
 					}
1569 1569
 					$main_query['select']['relevance'] = substr($relevance, 0, -3) . ') / ' . $new_weight_total . ' AS relevance';
1570 1570
 
1571
-					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ( '
1571
+					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ('
1572 1572
 						INSERT IGNORE INTO ' . '{db_prefix}log_search_results
1573 1573
 							(' . implode(', ', array_keys($main_query['select'])) . ')') : '') . '
1574 1574
 						SELECT
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
1637 1637
 
1638 1638
 					$usedIDs = array_flip(empty($inserts) ? array() : array_keys($inserts));
1639
-					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ( '
1639
+					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ('
1640 1640
 						INSERT IGNORE INTO {db_prefix}log_search_results
1641 1641
 							(id_search, id_topic, relevance, id_msg, num_matches)') : '') . '
1642 1642
 						SELECT
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
 		$query = trim($query, "\*+");
2103 2103
 		$query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\''));
2104 2104
 
2105
-		$body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m)
2105
+		$body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function($m)
2106 2106
 		{
2107 2107
 			return isset($m[2]) && "$m[2]" == "$m[1]" ? stripslashes("$m[1]") : "<strong class=\"highlight\">$m[1]</strong>";
2108 2108
 		}, $body_highlighted);
Please login to merge, or discard this patch.
Braces   +414 added lines, -307 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
 // This defines two version types for checking the API's are compatible with this version of SMF.
20 21
 $GLOBALS['search_versions'] = array(
@@ -39,8 +40,9 @@  discard block
 block discarded – undo
39 40
 	global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir;
40 41
 
41 42
 	// Is the load average too high to allow searching just now?
42
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
43
-		fatal_lang_error('loadavg_search_disabled', false);
43
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
44
+			fatal_lang_error('loadavg_search_disabled', false);
45
+	}
44 46
 
45 47
 	loadLanguage('Search');
46 48
 	// Don't load this in XML mode.
@@ -88,23 +90,30 @@  discard block
 block discarded – undo
88 90
 			@list ($k, $v) = explode('|\'|', $data);
89 91
 			$context['search_params'][$k] = $v;
90 92
 		}
91
-		if (isset($context['search_params']['brd']))
92
-			$context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']);
93
+		if (isset($context['search_params']['brd'])) {
94
+					$context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']);
95
+		}
93 96
 	}
94 97
 
95
-	if (isset($_REQUEST['search']))
96
-		$context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);
98
+	if (isset($_REQUEST['search'])) {
99
+			$context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);
100
+	}
97 101
 
98
-	if (isset($context['search_params']['search']))
99
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
100
-	if (isset($context['search_params']['userspec']))
101
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
102
-	if (!empty($context['search_params']['searchtype']))
103
-		$context['search_params']['searchtype'] = 2;
104
-	if (!empty($context['search_params']['minage']))
105
-		$context['search_params']['minage'] = (int) $context['search_params']['minage'];
106
-	if (!empty($context['search_params']['maxage']))
107
-		$context['search_params']['maxage'] = (int) $context['search_params']['maxage'];
102
+	if (isset($context['search_params']['search'])) {
103
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
104
+	}
105
+	if (isset($context['search_params']['userspec'])) {
106
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
107
+	}
108
+	if (!empty($context['search_params']['searchtype'])) {
109
+			$context['search_params']['searchtype'] = 2;
110
+	}
111
+	if (!empty($context['search_params']['minage'])) {
112
+			$context['search_params']['minage'] = (int) $context['search_params']['minage'];
113
+	}
114
+	if (!empty($context['search_params']['maxage'])) {
115
+			$context['search_params']['maxage'] = (int) $context['search_params']['maxage'];
116
+	}
108 117
 
109 118
 	$context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']);
110 119
 	$context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']);
@@ -116,11 +125,13 @@  discard block
 block discarded – undo
116 125
 		$context['search_errors']['messages'] = array();
117 126
 		foreach ($context['search_errors'] as $search_error => $dummy)
118 127
 		{
119
-			if ($search_error === 'messages')
120
-				continue;
128
+			if ($search_error === 'messages') {
129
+							continue;
130
+			}
121 131
 
122
-			if ($search_error == 'string_too_long')
123
-				$txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);
132
+			if ($search_error == 'string_too_long') {
133
+							$txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);
134
+			}
124 135
 
125 136
 			$context['search_errors']['messages'][] = $txt['error_' . $search_error];
126 137
 		}
@@ -143,12 +154,13 @@  discard block
 block discarded – undo
143 154
 	while ($row = $smcFunc['db_fetch_assoc']($request))
144 155
 	{
145 156
 		// This category hasn't been set up yet..
146
-		if (!isset($context['categories'][$row['id_cat']]))
147
-			$context['categories'][$row['id_cat']] = array(
157
+		if (!isset($context['categories'][$row['id_cat']])) {
158
+					$context['categories'][$row['id_cat']] = array(
148 159
 				'id' => $row['id_cat'],
149 160
 				'name' => $row['cat_name'],
150 161
 				'boards' => array()
151 162
 			);
163
+		}
152 164
 
153 165
 		// Set this board up, and let the template know when it's a child.  (indent them..)
154 166
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -159,8 +171,9 @@  discard block
 block discarded – undo
159 171
 		);
160 172
 
161 173
 		// If a board wasn't checked that probably should have been ensure the board selection is selected, yo!
162
-		if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board']))
163
-			$context['boards_check_all'] = false;
174
+		if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) {
175
+					$context['boards_check_all'] = false;
176
+		}
164 177
 	}
165 178
 	$smcFunc['db_free_result']($request);
166 179
 
@@ -182,18 +195,20 @@  discard block
 block discarded – undo
182 195
 	}
183 196
 
184 197
 	$max_boards = ceil(count($temp_boards) / 2);
185
-	if ($max_boards == 1)
186
-		$max_boards = 2;
198
+	if ($max_boards == 1) {
199
+			$max_boards = 2;
200
+	}
187 201
 
188 202
 	// Now, alternate them so they can be shown left and right ;).
189 203
 	$context['board_columns'] = array();
190 204
 	for ($i = 0; $i < $max_boards; $i++)
191 205
 	{
192 206
 		$context['board_columns'][] = $temp_boards[$i];
193
-		if (isset($temp_boards[$i + $max_boards]))
194
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
195
-		else
196
-			$context['board_columns'][] = array();
207
+		if (isset($temp_boards[$i + $max_boards])) {
208
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
209
+		} else {
210
+					$context['board_columns'][] = array();
211
+		}
197 212
 	}
198 213
 
199 214
 	if (!empty($_REQUEST['topic']))
@@ -225,8 +240,9 @@  discard block
 block discarded – undo
225 240
 			)
226 241
 		);
227 242
 
228
-		if ($smcFunc['db_num_rows']($request) == 0)
229
-			fatal_lang_error('topic_gone', false);
243
+		if ($smcFunc['db_num_rows']($request) == 0) {
244
+					fatal_lang_error('topic_gone', false);
245
+		}
230 246
 
231 247
 		list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request);
232 248
 		$smcFunc['db_free_result']($request);
@@ -256,11 +272,13 @@  discard block
 block discarded – undo
256 272
 	global $excludedWords, $participants, $smcFunc;
257 273
 
258 274
 	// if comming from the quick search box, and we want to search on members, well we need to do that ;)
259
-	if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members')
260
-		redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search']));
275
+	if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') {
276
+			redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search']));
277
+	}
261 278
 
262
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
263
-		fatal_lang_error('loadavg_search_disabled', false);
279
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
280
+			fatal_lang_error('loadavg_search_disabled', false);
281
+	}
264 282
 
265 283
 	// No, no, no... this is a bit hard on the server, so don't you go prefetching it!
266 284
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -307,8 +325,9 @@  discard block
 block discarded – undo
307 325
 	}
308 326
 
309 327
 	// Zero weight.  Weightless :P.
310
-	if (empty($weight_total))
311
-		fatal_lang_error('search_invalid_weights');
328
+	if (empty($weight_total)) {
329
+			fatal_lang_error('search_invalid_weights');
330
+	}
312 331
 
313 332
 	// These vars don't require an interface, they're just here for tweaking.
314 333
 	$recentPercentage = 0.30;
@@ -326,11 +345,13 @@  discard block
 block discarded – undo
326 345
 	$context['search_string_limit'] = 100;
327 346
 
328 347
 	loadLanguage('Search');
329
-	if (!isset($_REQUEST['xml']))
330
-		loadTemplate('Search');
348
+	if (!isset($_REQUEST['xml'])) {
349
+			loadTemplate('Search');
350
+	}
331 351
 	//If we're doing XML we need to use the results template regardless really.
332
-	else
333
-		$context['sub_template'] = 'results';
352
+	else {
353
+			$context['sub_template'] = 'results';
354
+	}
334 355
 
335 356
 	// Are you allowed?
336 357
 	isAllowedTo('search_posts');
@@ -363,34 +384,39 @@  discard block
 block discarded – undo
363 384
 			$search_params[$k] = $v;
364 385
 		}
365 386
 
366
-		if (isset($search_params['brd']))
367
-			$search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
387
+		if (isset($search_params['brd'])) {
388
+					$search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
389
+		}
368 390
 	}
369 391
 
370 392
 	// Store whether simple search was used (needed if the user wants to do another query).
371
-	if (!isset($search_params['advanced']))
372
-		$search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
393
+	if (!isset($search_params['advanced'])) {
394
+			$search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
395
+	}
373 396
 
374 397
 	// 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
375
-	if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2))
376
-		$search_params['searchtype'] = 2;
398
+	if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) {
399
+			$search_params['searchtype'] = 2;
400
+	}
377 401
 
378 402
 	// Minimum age of messages. Default to zero (don't set param in that case).
379
-	if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0))
380
-		$search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
403
+	if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) {
404
+			$search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
405
+	}
381 406
 
382 407
 	// Maximum age of messages. Default to infinite (9999 days: param not set).
383
-	if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999))
384
-		$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
408
+	if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) {
409
+			$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
410
+	}
385 411
 
386 412
 	// Searching a specific topic?
387 413
 	if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic'))
388 414
 	{
389 415
 		$search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : '');
390 416
 		$search_params['show_complete'] = true;
417
+	} elseif (!empty($search_params['topic'])) {
418
+			$search_params['topic'] = (int) $search_params['topic'];
391 419
 	}
392
-	elseif (!empty($search_params['topic']))
393
-		$search_params['topic'] = (int) $search_params['topic'];
394 420
 
395 421
 	if (!empty($search_params['minage']) || !empty($search_params['maxage']))
396 422
 	{
@@ -408,19 +434,21 @@  discard block
 block discarded – undo
408 434
 			)
409 435
 		);
410 436
 		list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request);
411
-		if ($minMsgID < 0 || $maxMsgID < 0)
412
-			$context['search_errors']['no_messages_in_time_frame'] = true;
437
+		if ($minMsgID < 0 || $maxMsgID < 0) {
438
+					$context['search_errors']['no_messages_in_time_frame'] = true;
439
+		}
413 440
 		$smcFunc['db_free_result']($request);
414 441
 	}
415 442
 
416 443
 	// Default the user name to a wildcard matching every user (*).
417
-	if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*'))
418
-		$search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
444
+	if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) {
445
+			$search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
446
+	}
419 447
 
420 448
 	// If there's no specific user, then don't mention it in the main query.
421
-	if (empty($search_params['userspec']))
422
-		$userQuery = '';
423
-	else
449
+	if (empty($search_params['userspec'])) {
450
+			$userQuery = '';
451
+	} else
424 452
 	{
425 453
 		$userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('&quot;' => '"'));
426 454
 		$userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'));
@@ -432,19 +460,21 @@  discard block
 block discarded – undo
432 460
 		{
433 461
 			$possible_users[$k] = trim($possible_users[$k]);
434 462
 
435
-			if (strlen($possible_users[$k]) == 0)
436
-				unset($possible_users[$k]);
463
+			if (strlen($possible_users[$k]) == 0) {
464
+							unset($possible_users[$k]);
465
+			}
437 466
 		}
438 467
 
439 468
 		// Create a list of database-escaped search names.
440 469
 		$realNameMatches = array();
441
-		foreach ($possible_users as $possible_user)
442
-			$realNameMatches[] = $smcFunc['db_quote'](
470
+		foreach ($possible_users as $possible_user) {
471
+					$realNameMatches[] = $smcFunc['db_quote'](
443 472
 				'{string:possible_user}',
444 473
 				array(
445 474
 					'possible_user' => $possible_user
446 475
 				)
447 476
 			);
477
+		}
448 478
 
449 479
 		// Retrieve a list of possible members.
450 480
 		$request = $smcFunc['db_query']('', '
@@ -456,9 +486,9 @@  discard block
 block discarded – undo
456 486
 			)
457 487
 		);
458 488
 		// Simply do nothing if there're too many members matching the criteria.
459
-		if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch)
460
-			$userQuery = '';
461
-		elseif ($smcFunc['db_num_rows']($request) == 0)
489
+		if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) {
490
+					$userQuery = '';
491
+		} elseif ($smcFunc['db_num_rows']($request) == 0)
462 492
 		{
463 493
 			$userQuery = $smcFunc['db_quote'](
464 494
 				'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})',
@@ -467,12 +497,12 @@  discard block
 block discarded – undo
467 497
 					'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches),
468 498
 				)
469 499
 			);
470
-		}
471
-		else
500
+		} else
472 501
 		{
473 502
 			$memberlist = array();
474
-			while ($row = $smcFunc['db_fetch_assoc']($request))
475
-				$memberlist[] = $row['id_member'];
503
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
504
+							$memberlist[] = $row['id_member'];
505
+			}
476 506
 			$userQuery = $smcFunc['db_quote'](
477 507
 				'(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))',
478 508
 				array(
@@ -486,22 +516,25 @@  discard block
 block discarded – undo
486 516
 	}
487 517
 
488 518
 	// If the boards were passed by URL (params=), temporarily put them back in $_REQUEST.
489
-	if (!empty($search_params['brd']) && is_array($search_params['brd']))
490
-		$_REQUEST['brd'] = $search_params['brd'];
519
+	if (!empty($search_params['brd']) && is_array($search_params['brd'])) {
520
+			$_REQUEST['brd'] = $search_params['brd'];
521
+	}
491 522
 
492 523
 	// Ensure that brd is an array.
493 524
 	if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board'))
494 525
 	{
495
-		if (!empty($_REQUEST['brd']))
496
-			$_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']);
497
-		else
498
-			$_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array();
526
+		if (!empty($_REQUEST['brd'])) {
527
+					$_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']);
528
+		} else {
529
+					$_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array();
530
+		}
499 531
 	}
500 532
 
501 533
 	// Make sure all boards are integers.
502
-	if (!empty($_REQUEST['brd']))
503
-		foreach ($_REQUEST['brd'] as $id => $brd)
534
+	if (!empty($_REQUEST['brd'])) {
535
+			foreach ($_REQUEST['brd'] as $id => $brd)
504 536
 			$_REQUEST['brd'][$id] = (int) $brd;
537
+	}
505 538
 
506 539
 	// Special case for boards: searching just one topic?
507 540
 	if (!empty($search_params['topic']))
@@ -520,17 +553,18 @@  discard block
 block discarded – undo
520 553
 			)
521 554
 		);
522 555
 
523
-		if ($smcFunc['db_num_rows']($request) == 0)
524
-			fatal_lang_error('topic_gone', false);
556
+		if ($smcFunc['db_num_rows']($request) == 0) {
557
+					fatal_lang_error('topic_gone', false);
558
+		}
525 559
 
526 560
 		$search_params['brd'] = array();
527 561
 		list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request);
528 562
 		$smcFunc['db_free_result']($request);
529 563
 	}
530 564
 	// Select all boards you've selected AND are allowed to see.
531
-	elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd'])))
532
-		$search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'];
533
-	else
565
+	elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) {
566
+			$search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'];
567
+	} else
534 568
 	{
535 569
 		$see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board';
536 570
 		$request = $smcFunc['db_query']('', '
@@ -548,19 +582,22 @@  discard block
 block discarded – undo
548 582
 			)
549 583
 		);
550 584
 		$search_params['brd'] = array();
551
-		while ($row = $smcFunc['db_fetch_assoc']($request))
552
-			$search_params['brd'][] = $row['id_board'];
585
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
586
+					$search_params['brd'][] = $row['id_board'];
587
+		}
553 588
 		$smcFunc['db_free_result']($request);
554 589
 
555 590
 		// This error should pro'bly only happen for hackers.
556
-		if (empty($search_params['brd']))
557
-			$context['search_errors']['no_boards_selected'] = true;
591
+		if (empty($search_params['brd'])) {
592
+					$context['search_errors']['no_boards_selected'] = true;
593
+		}
558 594
 	}
559 595
 
560 596
 	if (count($search_params['brd']) != 0)
561 597
 	{
562
-		foreach ($search_params['brd'] as $k => $v)
563
-			$search_params['brd'][$k] = (int) $v;
598
+		foreach ($search_params['brd'] as $k => $v) {
599
+					$search_params['brd'][$k] = (int) $v;
600
+		}
564 601
 
565 602
 		// If we've selected all boards, this parameter can be left empty.
566 603
 		$request = $smcFunc['db_query']('', '
@@ -574,15 +611,16 @@  discard block
 block discarded – undo
574 611
 		list ($num_boards) = $smcFunc['db_fetch_row']($request);
575 612
 		$smcFunc['db_free_result']($request);
576 613
 
577
-		if (count($search_params['brd']) == $num_boards)
614
+		if (count($search_params['brd']) == $num_boards) {
615
+					$boardQuery = '';
616
+		} elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) {
617
+					$boardQuery = '!= ' . $modSettings['recycle_board'];
618
+		} else {
619
+					$boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')';
620
+		}
621
+	} else {
578 622
 			$boardQuery = '';
579
-		elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd']))
580
-			$boardQuery = '!= ' . $modSettings['recycle_board'];
581
-		else
582
-			$boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')';
583 623
 	}
584
-	else
585
-		$boardQuery = '';
586 624
 
587 625
 	$search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']);
588 626
 	$search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']);
@@ -596,11 +634,13 @@  discard block
 block discarded – undo
596 634
 		'id_msg',
597 635
 	);
598 636
 	call_integration_hook('integrate_search_sort_columns', array(&$sort_columns));
599
-	if (empty($search_params['sort']) && !empty($_REQUEST['sort']))
600
-		list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
637
+	if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) {
638
+			list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
639
+	}
601 640
 	$search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance';
602
-	if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies')
603
-		$search_params['sort'] = 'id_msg';
641
+	if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') {
642
+			$search_params['sort'] = 'id_msg';
643
+	}
604 644
 
605 645
 	// Sorting direction: descending unless stated otherwise.
606 646
 	$search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc';
@@ -624,17 +664,19 @@  discard block
 block discarded – undo
624 664
 	// What are we searching for?
625 665
 	if (empty($search_params['search']))
626 666
 	{
627
-		if (isset($_GET['search']))
628
-			$search_params['search'] = un_htmlspecialchars($_GET['search']);
629
-		elseif (isset($_POST['search']))
630
-			$search_params['search'] = $_POST['search'];
631
-		else
632
-			$search_params['search'] = '';
667
+		if (isset($_GET['search'])) {
668
+					$search_params['search'] = un_htmlspecialchars($_GET['search']);
669
+		} elseif (isset($_POST['search'])) {
670
+					$search_params['search'] = $_POST['search'];
671
+		} else {
672
+					$search_params['search'] = '';
673
+		}
633 674
 	}
634 675
 
635 676
 	// Nothing??
636
-	if (!isset($search_params['search']) || $search_params['search'] == '')
637
-		$context['search_errors']['invalid_search_string'] = true;
677
+	if (!isset($search_params['search']) || $search_params['search'] == '') {
678
+			$context['search_errors']['invalid_search_string'] = true;
679
+	}
638 680
 	// Too long?
639 681
 	elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit'])
640 682
 	{
@@ -648,8 +690,9 @@  discard block
 block discarded – undo
648 690
 	$stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query));
649 691
 
650 692
 	// This (hidden) setting will do fulltext searching in the most basic way.
651
-	if (!empty($modSettings['search_simple_fulltext']))
652
-		$stripped_query = strtr($stripped_query, array('"' => ''));
693
+	if (!empty($modSettings['search_simple_fulltext'])) {
694
+			$stripped_query = strtr($stripped_query, array('"' => ''));
695
+	}
653 696
 
654 697
 	$no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1;
655 698
 
@@ -672,8 +715,9 @@  discard block
 block discarded – undo
672 715
 	{
673 716
 		if ($word === '-')
674 717
 		{
675
-			if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words))
676
-				$excludedWords[] = $word;
718
+			if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) {
719
+							$excludedWords[] = $word;
720
+			}
677 721
 			unset($phraseArray[$index]);
678 722
 		}
679 723
 	}
@@ -683,8 +727,9 @@  discard block
 block discarded – undo
683 727
 	{
684 728
 		if (strpos(trim($word), '-') === 0)
685 729
 		{
686
-			if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words))
687
-				$excludedWords[] = $word;
730
+			if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) {
731
+							$excludedWords[] = $word;
732
+			}
688 733
 			unset($wordArray[$index]);
689 734
 		}
690 735
 	}
@@ -697,8 +742,9 @@  discard block
 block discarded – undo
697 742
 	foreach ($searchArray as $index => $value)
698 743
 	{
699 744
 		// Skip anything practically empty.
700
-		if (($searchArray[$index] = trim($value, '-_\' ')) === '')
701
-			unset($searchArray[$index]);
745
+		if (($searchArray[$index] = trim($value, '-_\' ')) === '') {
746
+					unset($searchArray[$index]);
747
+		}
702 748
 		// Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing.
703 749
 		elseif (in_array($searchArray[$index], $blacklisted_words))
704 750
 		{
@@ -716,31 +762,37 @@  discard block
 block discarded – undo
716 762
 
717 763
 	// Create an array of replacements for highlighting.
718 764
 	$context['mark'] = array();
719
-	foreach ($searchArray as $word)
720
-		$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
765
+	foreach ($searchArray as $word) {
766
+			$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
767
+	}
721 768
 
722 769
 	// Initialize two arrays storing the words that have to be searched for.
723 770
 	$orParts = array();
724 771
 	$searchWords = array();
725 772
 
726 773
 	// Make sure at least one word is being searched for.
727
-	if (empty($searchArray))
728
-		$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
774
+	if (empty($searchArray)) {
775
+			$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
776
+	}
729 777
 	// All words/sentences must match.
730
-	elseif (empty($search_params['searchtype']))
731
-		$orParts[0] = $searchArray;
778
+	elseif (empty($search_params['searchtype'])) {
779
+			$orParts[0] = $searchArray;
780
+	}
732 781
 	// Any word/sentence must match.
733
-	else
734
-		foreach ($searchArray as $index => $value)
782
+	else {
783
+			foreach ($searchArray as $index => $value)
735 784
 			$orParts[$index] = array($value);
785
+	}
736 786
 
737 787
 	// Don't allow duplicate error messages if one string is too short.
738
-	if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string']))
739
-		unset($context['search_errors']['invalid_search_string']);
788
+	if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) {
789
+			unset($context['search_errors']['invalid_search_string']);
790
+	}
740 791
 	// Make sure the excluded words are in all or-branches.
741
-	foreach ($orParts as $orIndex => $andParts)
742
-		foreach ($excludedWords as $word)
792
+	foreach ($orParts as $orIndex => $andParts) {
793
+			foreach ($excludedWords as $word)
743 794
 			$orParts[$orIndex][] = $word;
795
+	}
744 796
 
745 797
 	// Determine the or-branches and the fulltext search words.
746 798
 	foreach ($orParts as $orIndex => $andParts)
@@ -754,8 +806,9 @@  discard block
 block discarded – undo
754 806
 		);
755 807
 
756 808
 		// Sort the indexed words (large words -> small words -> excluded words).
757
-		if ($searchAPI->supportsMethod('searchSort'))
758
-			usort($orParts[$orIndex], 'searchSort');
809
+		if ($searchAPI->supportsMethod('searchSort')) {
810
+					usort($orParts[$orIndex], 'searchSort');
811
+		}
759 812
 
760 813
 		foreach ($orParts[$orIndex] as $word)
761 814
 		{
@@ -767,15 +820,17 @@  discard block
 block discarded – undo
767 820
 			if (!$is_excluded || count($subjectWords) === 1)
768 821
 			{
769 822
 				$searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords);
770
-				if ($is_excluded)
771
-					$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
823
+				if ($is_excluded) {
824
+									$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
825
+				}
826
+			} else {
827
+							$excludedPhrases[] = $word;
772 828
 			}
773
-			else
774
-				$excludedPhrases[] = $word;
775 829
 
776 830
 			// Have we got indexes to prepare?
777
-			if ($searchAPI->supportsMethod('prepareIndexes'))
778
-				$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
831
+			if ($searchAPI->supportsMethod('prepareIndexes')) {
832
+							$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
833
+			}
779 834
 		}
780 835
 
781 836
 		// Search_force_index requires all AND parts to have at least one fulltext word.
@@ -783,8 +838,7 @@  discard block
 block discarded – undo
783 838
 		{
784 839
 			$context['search_errors']['query_not_specific_enough'] = true;
785 840
 			break;
786
-		}
787
-		elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
841
+		} elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
788 842
 		{
789 843
 			$context['search_errors']['query_not_specific_enough'] = true;
790 844
 			break;
@@ -812,8 +866,9 @@  discard block
 block discarded – undo
812 866
 		$found_misspelling = false;
813 867
 		foreach ($searchArray as $word)
814 868
 		{
815
-			if (empty($link))
816
-				continue;
869
+			if (empty($link)) {
870
+							continue;
871
+			}
817 872
 
818 873
 			// Don't check phrases.
819 874
 			if (preg_match('~^\w+$~', $word) === 0)
@@ -828,8 +883,7 @@  discard block
 block discarded – undo
828 883
 				$did_you_mean['search'][] = $word;
829 884
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
830 885
 				continue;
831
-			}
832
-			elseif (spell_check($link, $word))
886
+			} elseif (spell_check($link, $word))
833 887
 			{
834 888
 				$did_you_mean['search'][] = $word;
835 889
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
@@ -840,11 +894,13 @@  discard block
 block discarded – undo
840 894
 			foreach ($suggestions as $i => $s)
841 895
 			{
842 896
 				// Search is case insensitive.
843
-				if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word))
844
-					unset($suggestions[$i]);
897
+				if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) {
898
+									unset($suggestions[$i]);
899
+				}
845 900
 				// Plus, don't suggest something the user thinks is rude!
846
-				elseif ($suggestions[$i] != censorText($s))
847
-					unset($suggestions[$i]);
901
+				elseif ($suggestions[$i] != censorText($s)) {
902
+									unset($suggestions[$i]);
903
+				}
848 904
 			}
849 905
 
850 906
 			// Anything found?  If so, correct it!
@@ -854,8 +910,7 @@  discard block
 block discarded – undo
854 910
 				$did_you_mean['search'][] = $suggestions[0];
855 911
 				$did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>';
856 912
 				$found_misspelling = true;
857
-			}
858
-			else
913
+			} else
859 914
 			{
860 915
 				$did_you_mean['search'][] = $word;
861 916
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
@@ -872,8 +927,7 @@  discard block
 block discarded – undo
872 927
 				{
873 928
 					$temp_excluded['search'][] = '-"' . $word . '"';
874 929
 					$temp_excluded['display'][] = '-&quot;' . $smcFunc['htmlspecialchars']($word) . '&quot;';
875
-				}
876
-				else
930
+				} else
877 931
 				{
878 932
 					$temp_excluded['search'][] = '-' . $word;
879 933
 					$temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word);
@@ -885,11 +939,13 @@  discard block
 block discarded – undo
885 939
 
886 940
 			$temp_params = $search_params;
887 941
 			$temp_params['search'] = implode(' ', $did_you_mean['search']);
888
-			if (isset($temp_params['brd']))
889
-				$temp_params['brd'] = implode(',', $temp_params['brd']);
942
+			if (isset($temp_params['brd'])) {
943
+							$temp_params['brd'] = implode(',', $temp_params['brd']);
944
+			}
890 945
 			$context['params'] = array();
891
-			foreach ($temp_params as $k => $v)
892
-				$context['did_you_mean_params'][] = $k . '|\'|' . $v;
946
+			foreach ($temp_params as $k => $v) {
947
+							$context['did_you_mean_params'][] = $k . '|\'|' . $v;
948
+			}
893 949
 			$context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params']));
894 950
 			$context['did_you_mean'] = implode(' ', $did_you_mean['display']);
895 951
 		}
@@ -897,18 +953,20 @@  discard block
 block discarded – undo
897 953
 
898 954
 	// Let the user adjust the search query, should they wish?
899 955
 	$context['search_params'] = $search_params;
900
-	if (isset($context['search_params']['search']))
901
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
902
-	if (isset($context['search_params']['userspec']))
903
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
956
+	if (isset($context['search_params']['search'])) {
957
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
958
+	}
959
+	if (isset($context['search_params']['userspec'])) {
960
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
961
+	}
904 962
 
905 963
 	// Do we have captcha enabled?
906 964
 	if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']))
907 965
 	{
908 966
 		// If we come from another search box tone down the error...
909
-		if (!isset($_REQUEST['search_vv']))
910
-			$context['search_errors']['need_verification_code'] = true;
911
-		else
967
+		if (!isset($_REQUEST['search_vv'])) {
968
+					$context['search_errors']['need_verification_code'] = true;
969
+		} else
912 970
 		{
913 971
 			require_once($sourcedir . '/Subs-Editor.php');
914 972
 			$verificationOptions = array(
@@ -918,12 +976,14 @@  discard block
 block discarded – undo
918 976
 
919 977
 			if (is_array($context['require_verification']))
920 978
 			{
921
-				foreach ($context['require_verification'] as $error)
922
-					$context['search_errors'][$error] = true;
979
+				foreach ($context['require_verification'] as $error) {
980
+									$context['search_errors'][$error] = true;
981
+				}
923 982
 			}
924 983
 			// Don't keep asking for it - they've proven themselves worthy.
925
-			else
926
-				$_SESSION['ss_vv_passed'] = true;
984
+			else {
985
+							$_SESSION['ss_vv_passed'] = true;
986
+			}
927 987
 		}
928 988
 	}
929 989
 
@@ -931,19 +991,22 @@  discard block
 block discarded – undo
931 991
 
932 992
 	// All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below.
933 993
 	$temp_params = $search_params;
934
-	if (isset($temp_params['brd']))
935
-		$temp_params['brd'] = implode(',', $temp_params['brd']);
994
+	if (isset($temp_params['brd'])) {
995
+			$temp_params['brd'] = implode(',', $temp_params['brd']);
996
+	}
936 997
 	$context['params'] = array();
937
-	foreach ($temp_params as $k => $v)
938
-		$context['params'][] = $k . '|\'|' . $v;
998
+	foreach ($temp_params as $k => $v) {
999
+			$context['params'][] = $k . '|\'|' . $v;
1000
+	}
939 1001
 
940 1002
 	if (!empty($context['params']))
941 1003
 	{
942 1004
 		// Due to old IE's 2083 character limit, we have to compress long search strings
943 1005
 		$params = @gzcompress(implode('|"|', $context['params']));
944 1006
 		// Gzcompress failed, use try non-gz
945
-		if (empty($params))
946
-			$params = implode('|"|', $context['params']);
1007
+		if (empty($params)) {
1008
+					$params = implode('|"|', $context['params']);
1009
+		}
947 1010
 		// Base64 encode, then replace +/= with uri safe ones that can be reverted
948 1011
 		$context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params));
949 1012
 	}
@@ -969,8 +1032,9 @@  discard block
 block discarded – undo
969 1032
 	}
970 1033
 
971 1034
 	// Spam me not, Spam-a-lot?
972
-	if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])
973
-		spamProtection('search');
1035
+	if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) {
1036
+			spamProtection('search');
1037
+	}
974 1038
 	// Store the last search string to allow pages of results to be browsed.
975 1039
 	$_SESSION['last_ss'] = $search_params['search'];
976 1040
 
@@ -1030,8 +1094,9 @@  discard block
 block discarded – undo
1030 1094
 						'where' => array(),
1031 1095
 					);
1032 1096
 
1033
-					if ($modSettings['postmod_active'])
1034
-						$subject_query['where'][] = 't.approved = {int:is_approved}';
1097
+					if ($modSettings['postmod_active']) {
1098
+											$subject_query['where'][] = 't.approved = {int:is_approved}';
1099
+					}
1035 1100
 
1036 1101
 					$numTables = 0;
1037 1102
 					$prev_join = 0;
@@ -1043,8 +1108,7 @@  discard block
 block discarded – undo
1043 1108
 						{
1044 1109
 							$subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)';
1045 1110
 							$subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
1046
-						}
1047
-						else
1111
+						} else
1048 1112
 						{
1049 1113
 							$subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)';
1050 1114
 							$subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}');
@@ -1062,14 +1126,18 @@  discard block
 block discarded – undo
1062 1126
 						}
1063 1127
 						$subject_query['where'][] = $userQuery;
1064 1128
 					}
1065
-					if (!empty($search_params['topic']))
1066
-						$subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
1067
-					if (!empty($minMsgID))
1068
-						$subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
1069
-					if (!empty($maxMsgID))
1070
-						$subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
1071
-					if (!empty($boardQuery))
1072
-						$subject_query['where'][] = 't.id_board ' . $boardQuery;
1129
+					if (!empty($search_params['topic'])) {
1130
+											$subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
1131
+					}
1132
+					if (!empty($minMsgID)) {
1133
+											$subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
1134
+					}
1135
+					if (!empty($maxMsgID)) {
1136
+											$subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
1137
+					}
1138
+					if (!empty($boardQuery)) {
1139
+											$subject_query['where'][] = 't.id_board ' . $boardQuery;
1140
+					}
1073 1141
 					if (!empty($excludedPhrases))
1074 1142
 					{
1075 1143
 						if ($subject_query['from'] != '{db_prefix}messages AS m')
@@ -1089,8 +1157,9 @@  discard block
 block discarded – undo
1089 1157
 					foreach ($weight_factors as $type => $value)
1090 1158
 					{
1091 1159
 						$relevance .= $weight[$type];
1092
-						if (!empty($value['results']))
1093
-							$relevance .= ' * ' . $value['results'];
1160
+						if (!empty($value['results'])) {
1161
+													$relevance .= ' * ' . $value['results'];
1162
+						}
1094 1163
 						$relevance .= ' + ';
1095 1164
 					}
1096 1165
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
@@ -1128,20 +1197,23 @@  discard block
 block discarded – undo
1128 1197
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1129 1198
 						{
1130 1199
 							// No duplicates!
1131
-							if (isset($inserts[$row[1]]))
1132
-								continue;
1200
+							if (isset($inserts[$row[1]])) {
1201
+															continue;
1202
+							}
1133 1203
 
1134
-							foreach ($row as $key => $value)
1135
-								$inserts[$row[1]][] = (int) $row[$key];
1204
+							foreach ($row as $key => $value) {
1205
+															$inserts[$row[1]][] = (int) $row[$key];
1206
+							}
1136 1207
 						}
1137 1208
 						$smcFunc['db_free_result']($ignoreRequest);
1138 1209
 						$numSubjectResults = count($inserts);
1210
+					} else {
1211
+											$numSubjectResults += $smcFunc['db_affected_rows']();
1139 1212
 					}
1140
-					else
1141
-						$numSubjectResults += $smcFunc['db_affected_rows']();
1142 1213
 
1143
-					if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
1144
-						break;
1214
+					if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) {
1215
+											break;
1216
+					}
1145 1217
 				}
1146 1218
 
1147 1219
 				// If there's data to be inserted for non-IGNORE databases do it here!
@@ -1156,8 +1228,7 @@  discard block
 block discarded – undo
1156 1228
 				}
1157 1229
 
1158 1230
 				$_SESSION['search_cache']['num_results'] = $numSubjectResults;
1159
-			}
1160
-			else
1231
+			} else
1161 1232
 			{
1162 1233
 				$main_query = array(
1163 1234
 					'select' => array(
@@ -1189,8 +1260,7 @@  discard block
 block discarded – undo
1189 1260
 					$main_query['weights'] = $weight_factors;
1190 1261
 
1191 1262
 					$main_query['group_by'][] = 't.id_topic';
1192
-				}
1193
-				else
1263
+				} else
1194 1264
 				{
1195 1265
 					// This is outrageous!
1196 1266
 					$main_query['select']['id_topic'] = 'm.id_msg AS id_topic';
@@ -1211,8 +1281,9 @@  discard block
 block discarded – undo
1211 1281
 						$main_query['where'][] = 't.id_topic = {int:topic}';
1212 1282
 						$main_query['parameters']['topic'] = $search_params['topic'];
1213 1283
 					}
1214
-					if (!empty($search_params['show_complete']))
1215
-						$main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
1284
+					if (!empty($search_params['show_complete'])) {
1285
+											$main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
1286
+					}
1216 1287
 				}
1217 1288
 
1218 1289
 				// *** Get the subject results.
@@ -1239,14 +1310,15 @@  discard block
 block discarded – undo
1239 1310
 					) !== false;
1240 1311
 
1241 1312
 					// Clean up some previous cache.
1242
-					if (!$createTemporary)
1243
-						$smcFunc['db_search_query']('delete_log_search_topics', '
1313
+					if (!$createTemporary) {
1314
+											$smcFunc['db_search_query']('delete_log_search_topics', '
1244 1315
 							DELETE FROM {db_prefix}log_search_topics
1245 1316
 							WHERE id_search = {int:search_id}',
1246 1317
 							array(
1247 1318
 								'search_id' => $_SESSION['search_cache']['id_search'],
1248 1319
 							)
1249 1320
 						);
1321
+					}
1250 1322
 
1251 1323
 					foreach ($searchWords as $orIndex => $words)
1252 1324
 					{
@@ -1278,8 +1350,7 @@  discard block
 block discarded – undo
1278 1350
 								$subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
1279 1351
 								$subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}';
1280 1352
 								$subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]';
1281
-							}
1282
-							else
1353
+							} else
1283 1354
 							{
1284 1355
 								$subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)';
1285 1356
 								$subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}';
@@ -1334,8 +1405,9 @@  discard block
 block discarded – undo
1334 1405
 						call_integration_hook('integrate_subject_search_query', array(&$subject_query));
1335 1406
 
1336 1407
 						// Nothing to search for?
1337
-						if (empty($subject_query['where']))
1338
-							continue;
1408
+						if (empty($subject_query['where'])) {
1409
+													continue;
1410
+						}
1339 1411
 
1340 1412
 						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( '
1341 1413
 							INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics
@@ -1358,19 +1430,21 @@  discard block
 block discarded – undo
1358 1430
 							{
1359 1431
 								$ind = $createTemporary ? 0 : 1;
1360 1432
 								// No duplicates!
1361
-								if (isset($inserts[$row[$ind]]))
1362
-									continue;
1433
+								if (isset($inserts[$row[$ind]])) {
1434
+																	continue;
1435
+								}
1363 1436
 
1364 1437
 								$inserts[$row[$ind]] = $row;
1365 1438
 							}
1366 1439
 							$smcFunc['db_free_result']($ignoreRequest);
1367 1440
 							$numSubjectResults = count($inserts);
1441
+						} else {
1442
+													$numSubjectResults += $smcFunc['db_affected_rows']();
1368 1443
 						}
1369
-						else
1370
-							$numSubjectResults += $smcFunc['db_affected_rows']();
1371 1444
 
1372
-						if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
1373
-							break;
1445
+						if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) {
1446
+													break;
1447
+						}
1374 1448
 					}
1375 1449
 
1376 1450
 					// Got some non-MySQL data to plonk in?
@@ -1388,8 +1462,9 @@  discard block
 block discarded – undo
1388 1462
 					{
1389 1463
 						$main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END';
1390 1464
 						$main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)';
1391
-						if (!$createTemporary)
1392
-							$main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
1465
+						if (!$createTemporary) {
1466
+													$main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
1467
+						}
1393 1468
 					}
1394 1469
 				}
1395 1470
 
@@ -1417,14 +1492,15 @@  discard block
 block discarded – undo
1417 1492
 					) !== false;
1418 1493
 
1419 1494
 					// Clear, all clear!
1420
-					if (!$createTemporary)
1421
-						$smcFunc['db_search_query']('delete_log_search_messages', '
1495
+					if (!$createTemporary) {
1496
+											$smcFunc['db_search_query']('delete_log_search_messages', '
1422 1497
 							DELETE FROM {db_prefix}log_search_messages
1423 1498
 							WHERE id_search = {int:id_search}',
1424 1499
 							array(
1425 1500
 								'id_search' => $_SESSION['search_cache']['id_search'],
1426 1501
 							)
1427 1502
 						);
1503
+					}
1428 1504
 
1429 1505
 					foreach ($searchWords as $orIndex => $words)
1430 1506
 					{
@@ -1458,19 +1534,21 @@  discard block
 block discarded – undo
1458 1534
 								while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1459 1535
 								{
1460 1536
 									// No duplicates!
1461
-									if (isset($inserts[$row[0]]))
1462
-										continue;
1537
+									if (isset($inserts[$row[0]])) {
1538
+																			continue;
1539
+									}
1463 1540
 
1464 1541
 									$inserts[$row[0]] = $row;
1465 1542
 								}
1466 1543
 								$smcFunc['db_free_result']($ignoreRequest);
1467 1544
 								$indexedResults = count($inserts);
1545
+							} else {
1546
+															$indexedResults += $smcFunc['db_affected_rows']();
1468 1547
 							}
1469
-							else
1470
-								$indexedResults += $smcFunc['db_affected_rows']();
1471 1548
 
1472
-							if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults)
1473
-								break;
1549
+							if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) {
1550
+															break;
1551
+							}
1474 1552
 						}
1475 1553
 					}
1476 1554
 
@@ -1490,8 +1568,7 @@  discard block
 block discarded – undo
1490 1568
 						$context['search_errors']['query_not_specific_enough'] = true;
1491 1569
 						$_REQUEST['params'] = $context['params'];
1492 1570
 						return PlushSearch1();
1493
-					}
1494
-					elseif (!empty($indexedResults))
1571
+					} elseif (!empty($indexedResults))
1495 1572
 					{
1496 1573
 						$main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)';
1497 1574
 						if (!$createTemporary)
@@ -1513,15 +1590,18 @@  discard block
 block discarded – undo
1513 1590
 						foreach ($words['all_words'] as $regularWord)
1514 1591
 						{
1515 1592
 							$where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1516
-							if (in_array($regularWord, $excludedWords))
1517
-								$where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1593
+							if (in_array($regularWord, $excludedWords)) {
1594
+															$where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1595
+							}
1518 1596
 							$main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
1519 1597
 						}
1520
-						if (!empty($where))
1521
-							$orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
1598
+						if (!empty($where)) {
1599
+													$orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
1600
+						}
1601
+					}
1602
+					if (!empty($orWhere)) {
1603
+											$main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];
1522 1604
 					}
1523
-					if (!empty($orWhere))
1524
-						$main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];
1525 1605
 
1526 1606
 					if (!empty($userQuery))
1527 1607
 					{
@@ -1559,8 +1639,9 @@  discard block
 block discarded – undo
1559 1639
 					foreach ($main_query['weights'] as $type => $value)
1560 1640
 					{
1561 1641
 						$relevance .= $weight[$type];
1562
-						if (!empty($value['search']))
1563
-							$relevance .= ' * ' . $value['search'];
1642
+						if (!empty($value['search'])) {
1643
+													$relevance .= ' * ' . $value['search'];
1644
+						}
1564 1645
 						$relevance .= ' + ';
1565 1646
 						$new_weight_total += $weight[$type];
1566 1647
 					}
@@ -1591,11 +1672,13 @@  discard block
 block discarded – undo
1591 1672
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1592 1673
 						{
1593 1674
 							// No duplicates!
1594
-							if (isset($inserts[$row[2]]))
1595
-								continue;
1675
+							if (isset($inserts[$row[2]])) {
1676
+															continue;
1677
+							}
1596 1678
 
1597
-							foreach ($row as $key => $value)
1598
-								$inserts[$row[2]][] = (int) $row[$key];
1679
+							foreach ($row as $key => $value) {
1680
+															$inserts[$row[2]][] = (int) $row[$key];
1681
+							}
1599 1682
 						}
1600 1683
 						$smcFunc['db_free_result']($ignoreRequest);
1601 1684
 
@@ -1603,8 +1686,9 @@  discard block
 block discarded – undo
1603 1686
 						if (!empty($inserts))
1604 1687
 						{
1605 1688
 							$query_columns = array();
1606
-							foreach ($main_query['select'] as $k => $v)
1607
-								$query_columns[$k] = 'int';
1689
+							foreach ($main_query['select'] as $k => $v) {
1690
+															$query_columns[$k] = 'int';
1691
+							}
1608 1692
 
1609 1693
 							$smcFunc['db_insert']('',
1610 1694
 								'{db_prefix}log_search_results',
@@ -1614,21 +1698,23 @@  discard block
 block discarded – undo
1614 1698
 							);
1615 1699
 						}
1616 1700
 						$_SESSION['search_cache']['num_results'] += count($inserts);
1701
+					} else {
1702
+											$_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
1617 1703
 					}
1618
-					else
1619
-						$_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
1620 1704
 				}
1621 1705
 
1622 1706
 				// Insert subject-only matches.
1623 1707
 				if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0)
1624 1708
 				{
1625 1709
 					$relevance = '1000 * (';
1626
-					foreach ($weight_factors as $type => $value)
1627
-						if (isset($value['results']))
1710
+					foreach ($weight_factors as $type => $value) {
1711
+											if (isset($value['results']))
1628 1712
 						{
1629 1713
 							$relevance .= $weight[$type];
1630
-							if (!empty($value['results']))
1631
-								$relevance .= ' * ' . $value['results'];
1714
+					}
1715
+							if (!empty($value['results'])) {
1716
+															$relevance .= ' * ' . $value['results'];
1717
+							}
1632 1718
 							$relevance .= ' + ';
1633 1719
 						}
1634 1720
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
@@ -1662,8 +1748,9 @@  discard block
 block discarded – undo
1662 1748
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1663 1749
 						{
1664 1750
 							// No duplicates!
1665
-							if (isset($usedIDs[$row[1]]))
1666
-								continue;
1751
+							if (isset($usedIDs[$row[1]])) {
1752
+															continue;
1753
+							}
1667 1754
 
1668 1755
 							$usedIDs[$row[1]] = true;
1669 1756
 							$inserts[] = $row;
@@ -1681,12 +1768,12 @@  discard block
 block discarded – undo
1681 1768
 							);
1682 1769
 						}
1683 1770
 						$_SESSION['search_cache']['num_results'] += count($inserts);
1771
+					} else {
1772
+											$_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
1684 1773
 					}
1685
-					else
1686
-						$_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
1774
+				} elseif ($_SESSION['search_cache']['num_results'] == -1) {
1775
+									$_SESSION['search_cache']['num_results'] = 0;
1687 1776
 				}
1688
-				elseif ($_SESSION['search_cache']['num_results'] == -1)
1689
-					$_SESSION['search_cache']['num_results'] = 0;
1690 1777
 			}
1691 1778
 		}
1692 1779
 
@@ -1756,14 +1843,16 @@  discard block
 block discarded – undo
1756 1843
 			)
1757 1844
 		);
1758 1845
 		$posters = array();
1759
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1760
-			$posters[] = $row['id_member'];
1846
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1847
+					$posters[] = $row['id_member'];
1848
+		}
1761 1849
 		$smcFunc['db_free_result']($request);
1762 1850
 
1763 1851
 		call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters));
1764 1852
 
1765
-		if (!empty($posters))
1766
-			loadMemberData(array_unique($posters));
1853
+		if (!empty($posters)) {
1854
+					loadMemberData(array_unique($posters));
1855
+		}
1767 1856
 
1768 1857
 		// Get the messages out for the callback - select enough that it can be made to look just like Display.
1769 1858
 		$messages_request = $smcFunc['db_query']('', '
@@ -1797,8 +1886,9 @@  discard block
 block discarded – undo
1797 1886
 		);
1798 1887
 
1799 1888
 		// If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore.
1800
-		if ($smcFunc['db_num_rows']($messages_request) == 0)
1801
-			$context['topics'] = array();
1889
+		if ($smcFunc['db_num_rows']($messages_request) == 0) {
1890
+					$context['topics'] = array();
1891
+		}
1802 1892
 
1803 1893
 		// If we want to know who participated in what then load this now.
1804 1894
 		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'])
@@ -1816,8 +1906,9 @@  discard block
 block discarded – undo
1816 1906
 					'limit' => count($participants),
1817 1907
 				)
1818 1908
 			);
1819
-			while ($row = $smcFunc['db_fetch_assoc']($result))
1820
-				$participants[$row['id_topic']] = true;
1909
+			while ($row = $smcFunc['db_fetch_assoc']($result)) {
1910
+							$participants[$row['id_topic']] = true;
1911
+			}
1821 1912
 			$smcFunc['db_free_result']($result);
1822 1913
 		}
1823 1914
 	}
@@ -1826,15 +1917,17 @@  discard block
 block discarded – undo
1826 1917
 	$context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false);
1827 1918
 
1828 1919
 	// Consider the search complete!
1829
-	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1830
-		cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);
1920
+	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1921
+			cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);
1922
+	}
1831 1923
 
1832 1924
 	$context['key_words'] = &$searchArray;
1833 1925
 
1834 1926
 	// Setup the default topic icons... for checking they exist and the like!
1835 1927
 	$context['icon_sources'] = array();
1836
-	foreach ($context['stable_icons'] as $icon)
1837
-		$context['icon_sources'][$icon] = 'images_url';
1928
+	foreach ($context['stable_icons'] as $icon) {
1929
+			$context['icon_sources'][$icon] = 'images_url';
1930
+	}
1838 1931
 
1839 1932
 	$context['sub_template'] = 'results';
1840 1933
 	$context['page_title'] = $txt['search_results'];
@@ -1865,26 +1958,31 @@  discard block
 block discarded – undo
1865 1958
 	global $boards_can, $participants, $smcFunc;
1866 1959
 	static $recycle_board = null;
1867 1960
 
1868
-	if ($recycle_board === null)
1869
-		$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
1961
+	if ($recycle_board === null) {
1962
+			$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
1963
+	}
1870 1964
 
1871 1965
 	// Remember which message this is.  (ie. reply #83)
1872 1966
 	static $counter = null;
1873
-	if ($counter == null || $reset)
1874
-		$counter = $_REQUEST['start'] + 1;
1967
+	if ($counter == null || $reset) {
1968
+			$counter = $_REQUEST['start'] + 1;
1969
+	}
1875 1970
 
1876 1971
 	// If the query returned false, bail.
1877
-	if ($messages_request == false)
1878
-		return false;
1972
+	if ($messages_request == false) {
1973
+			return false;
1974
+	}
1879 1975
 
1880 1976
 	// Start from the beginning...
1881
-	if ($reset)
1882
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1977
+	if ($reset) {
1978
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1979
+	}
1883 1980
 
1884 1981
 	// Attempt to get the next message.
1885 1982
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
1886
-	if (!$message)
1887
-		return false;
1983
+	if (!$message) {
1984
+			return false;
1985
+	}
1888 1986
 
1889 1987
 	// Can't have an empty subject can we?
1890 1988
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1923,9 +2021,9 @@  discard block
 block discarded – undo
1923 2021
 
1924 2022
 		if ($smcFunc['strlen']($message['body']) > $charLimit)
1925 2023
 		{
1926
-			if (empty($context['key_words']))
1927
-				$message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
1928
-			else
2024
+			if (empty($context['key_words'])) {
2025
+							$message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
2026
+			} else
1929 2027
 			{
1930 2028
 				$matchString = '';
1931 2029
 				$force_partial_word = false;
@@ -1934,18 +2032,20 @@  discard block
 block discarded – undo
1934 2032
 					$keyword = un_htmlspecialchars($keyword);
1935 2033
 					$keyword = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&amp;')));
1936 2034
 
1937
-					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0)
1938
-						$force_partial_word = true;
2035
+					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) {
2036
+											$force_partial_word = true;
2037
+					}
1939 2038
 					$matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|';
1940 2039
 				}
1941 2040
 				$matchString = un_htmlspecialchars(substr($matchString, 0, -1));
1942 2041
 
1943 2042
 				$message['body'] = un_htmlspecialchars(strtr($message['body'], array('&nbsp;' => ' ', '<br>' => "\n", '&#91;' => '[', '&#93;' => ']', '&#58;' => ':', '&#64;' => '@')));
1944 2043
 
1945
-				if (empty($modSettings['search_method']) || $force_partial_word)
1946
-					preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
1947
-				else
1948
-					preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2044
+				if (empty($modSettings['search_method']) || $force_partial_word) {
2045
+									preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2046
+				} else {
2047
+									preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2048
+				}
1949 2049
 
1950 2050
 				$message['body'] = '';
1951 2051
 				foreach ($matches[0] as $index => $match)
@@ -1958,8 +2058,7 @@  discard block
 block discarded – undo
1958 2058
 			// Re-fix the international characters.
1959 2059
 			$message['body'] = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']);
1960 2060
 		}
1961
-	}
1962
-	else
2061
+	} else
1963 2062
 	{
1964 2063
 		// Run BBC interpreter on the message.
1965 2064
 		$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
@@ -1978,21 +2077,26 @@  discard block
 block discarded – undo
1978 2077
 	// Sadly, we need to check the icon ain't broke.
1979 2078
 	if (!empty($modSettings['messageIconChecks_enable']))
1980 2079
 	{
1981
-		if (!isset($context['icon_sources'][$message['first_icon']]))
1982
-			$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1983
-		if (!isset($context['icon_sources'][$message['last_icon']]))
1984
-			$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1985
-		if (!isset($context['icon_sources'][$message['icon']]))
1986
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1987
-	}
1988
-	else
2080
+		if (!isset($context['icon_sources'][$message['first_icon']])) {
2081
+					$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
2082
+		}
2083
+		if (!isset($context['icon_sources'][$message['last_icon']])) {
2084
+					$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
2085
+		}
2086
+		if (!isset($context['icon_sources'][$message['icon']])) {
2087
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
2088
+		}
2089
+	} else
1989 2090
 	{
1990
-		if (!isset($context['icon_sources'][$message['first_icon']]))
1991
-			$context['icon_sources'][$message['first_icon']] = 'images_url';
1992
-		if (!isset($context['icon_sources'][$message['last_icon']]))
1993
-			$context['icon_sources'][$message['last_icon']] = 'images_url';
1994
-		if (!isset($context['icon_sources'][$message['icon']]))
1995
-			$context['icon_sources'][$message['icon']] = 'images_url';
2091
+		if (!isset($context['icon_sources'][$message['first_icon']])) {
2092
+					$context['icon_sources'][$message['first_icon']] = 'images_url';
2093
+		}
2094
+		if (!isset($context['icon_sources'][$message['last_icon']])) {
2095
+					$context['icon_sources'][$message['last_icon']] = 'images_url';
2096
+		}
2097
+		if (!isset($context['icon_sources'][$message['icon']])) {
2098
+					$context['icon_sources'][$message['icon']] = 'images_url';
2099
+		}
1996 2100
 	}
1997 2101
 
1998 2102
 	// Do we have quote tag enabled?
@@ -2002,12 +2106,14 @@  discard block
 block discarded – undo
2002 2106
 	$colorClass = 'windowbg';
2003 2107
 
2004 2108
 	// Sticky topics should get a different color, too.
2005
-	if ($message['is_sticky'])
2006
-		$colorClass .= ' sticky';
2109
+	if ($message['is_sticky']) {
2110
+			$colorClass .= ' sticky';
2111
+	}
2007 2112
 
2008 2113
 	// Locked topics get special treatment as well.
2009
-	if ($message['locked'])
2010
-		$colorClass .= ' locked';
2114
+	if ($message['locked']) {
2115
+			$colorClass .= ' locked';
2116
+	}
2011 2117
 
2012 2118
 	$output = array_merge($context['topics'][$message['id_msg']], array(
2013 2119
 		'id' => $message['id_topic'],
@@ -2151,8 +2257,9 @@  discard block
 block discarded – undo
2151 2257
 
2152 2258
 	// Load up the search API we are going to use.
2153 2259
 	$modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
2154
-	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'))
2155
-		fatal_lang_error('search_api_missing');
2260
+	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) {
2261
+			fatal_lang_error('search_api_missing');
2262
+	}
2156 2263
 	require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
2157 2264
 
2158 2265
 	// Create an instance of the search API and check it is valid for this version of SMF.
Please login to merge, or discard this patch.
Sources/Class-Package.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 		if (!$this->connection)
794 794
 		{
795 795
 			$this->error = 'bad_server';
796
-            		$this->last_message = 'Invalid Server';
796
+					$this->last_message = 'Invalid Server';
797 797
 			return;
798 798
 		}
799 799
 
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 		if (!$this->check_response(220))
802 802
 		{
803 803
 			$this->error = 'bad_response';
804
-		        $this->last_message = 'Bad Response';
804
+				$this->last_message = 'Bad Response';
805 805
 			return;
806 806
 		}
807 807
 
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * of elements, an array of xmlArray's is returned for use with foreach.
258 258
 	 * Example use:
259 259
 	 *  foreach ($xml->set('html/body/p') as $p)
260
-	 * @param $path string The path to search for.
260
+	 * @param string $path string The path to search for.
261 261
 	 * @return xmlArray[] An array of xmlArray objects
262 262
 	 */
263 263
 	public function set($path)
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 	 * Changes a files atrributes (chmod)
856 856
 	 *
857 857
 	 * @param string $ftp_file The file to CHMOD
858
-	 * @param int|string $chmod The value for the CHMOD operation
858
+	 * @param integer $chmod The value for the CHMOD operation
859 859
 	 * @return boolean Whether or not the operation was successful
860 860
 	 */
861 861
 	public function chmod($ftp_file, $chmod)
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 	 *
1026 1026
 	 * @param string $ftp_path The path to the directory
1027 1027
 	 * @param bool $search Whether or not to get a recursive directory listing
1028
-	 * @return string|boolean The results of the command or false if unsuccessful
1028
+	 * @return false|string The results of the command or false if unsuccessful
1029 1029
 	 */
1030 1030
 	public function list_dir($ftp_path = '', $search = false)
1031 1031
 	{
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 	 *
1071 1071
 	 * @param string $file The name of a file
1072 1072
 	 * @param string $listing A directory listing or null to generate one
1073
-	 * @return string|boolean The name of the file or false if it wasn't found
1073
+	 * @return string|false The name of the file or false if it wasn't found
1074 1074
 	 */
1075 1075
 	public function locate($file, $listing = null)
1076 1076
 	{
Please login to merge, or discard this patch.
Braces   +266 added lines, -199 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Class xmlArray
@@ -65,8 +66,9 @@  discard block
 block discarded – undo
65 66
 		}
66 67
 
67 68
 		// Is the input an array? (ie. passed from file()?)
68
-		if (is_array($data))
69
-			$data = implode('', $data);
69
+		if (is_array($data)) {
70
+					$data = implode('', $data);
71
+		}
70 72
 
71 73
 		// Remove any xml declaration or doctype, and parse out comments and CDATA.
72 74
 		$data = preg_replace('/<!--.*?-->/s', '', $this->_to_cdata(preg_replace(array('/^<\?xml.+?\?' . '>/is', '/<!DOCTYPE[^>]+?' . '>/s'), '', $data)));
@@ -101,8 +103,9 @@  discard block
 block discarded – undo
101 103
 		// Get the element, in array form.
102 104
 		$array = $this->path($path);
103 105
 
104
-		if ($array === false)
105
-			return false;
106
+		if ($array === false) {
107
+					return false;
108
+		}
106 109
 
107 110
 		// Getting elements into this is a bit complicated...
108 111
 		if ($get_elements && !is_string($array))
@@ -113,8 +116,9 @@  discard block
 block discarded – undo
113 116
 			foreach ($array->array as $val)
114 117
 			{
115 118
 				// Skip the name and any attributes.
116
-				if (is_array($val))
117
-					$temp .= $this->_xml($val, null);
119
+				if (is_array($val)) {
120
+									$temp .= $this->_xml($val, null);
121
+				}
118 122
 			}
119 123
 
120 124
 			// Just get the XML data and then take out the CDATAs.
@@ -156,32 +160,35 @@  discard block
 block discarded – undo
156 160
 			elseif (substr($el, 0, 1) == '@')
157 161
 			{
158 162
 				// It simplifies things if the attribute is already there ;).
159
-				if (isset($array[$el]))
160
-					return $array[$el];
161
-				else
163
+				if (isset($array[$el])) {
164
+									return $array[$el];
165
+				} else
162 166
 				{
163 167
 					$trace = debug_backtrace();
164 168
 					$i = 0;
165
-					while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this))
166
-						$i++;
169
+					while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) {
170
+											$i++;
171
+					}
167 172
 					$debug = ' (from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'] . ')';
168 173
 
169 174
 					// Cause an error.
170
-					if ($this->debug_level & E_NOTICE)
171
-						trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE);
175
+					if ($this->debug_level & E_NOTICE) {
176
+											trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE);
177
+					}
172 178
 					return false;
173 179
 				}
180
+			} else {
181
+							$lvl = null;
174 182
 			}
175
-			else
176
-				$lvl = null;
177 183
 
178 184
 			// Find this element.
179 185
 			$array = $this->_path($array, $el, $lvl);
180 186
 		}
181 187
 
182 188
 		// Clean up after $lvl, for $return_full.
183
-		if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']'))
184
-			$array = array('name' => $el . '[]', $array);
189
+		if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']')) {
190
+					$array = array('name' => $el . '[]', $array);
191
+		}
185 192
 
186 193
 		// Create the right type of class...
187 194
 		$newClass = get_class($this);
@@ -216,10 +223,11 @@  discard block
 block discarded – undo
216 223
 				$el = substr($el, 0, strpos($el, '['));
217 224
 			}
218 225
 			// Find an attribute.
219
-			elseif (substr($el, 0, 1) == '@')
220
-				return isset($array[$el]);
221
-			else
222
-				$lvl = null;
226
+			elseif (substr($el, 0, 1) == '@') {
227
+							return isset($array[$el]);
228
+			} else {
229
+							$lvl = null;
230
+			}
223 231
 
224 232
 			// Find this element.
225 233
 			$array = $this->_path($array, $el, $lvl, true);
@@ -244,8 +252,9 @@  discard block
 block discarded – undo
244 252
 		$i = 0;
245 253
 		foreach ($temp->array as $item)
246 254
 		{
247
-			if (is_array($item))
248
-				$i++;
255
+			if (is_array($item)) {
256
+							$i++;
257
+			}
249 258
 		}
250 259
 
251 260
 		return $i;
@@ -269,8 +278,9 @@  discard block
 block discarded – undo
269 278
 		foreach ($xml->array as $val)
270 279
 		{
271 280
 			// Skip these, they aren't elements.
272
-			if (!is_array($val) || $val['name'] == '!')
273
-				continue;
281
+			if (!is_array($val) || $val['name'] == '!') {
282
+							continue;
283
+			}
274 284
 
275 285
 			// Create the right type of class...
276 286
 			$newClass = get_class($this);
@@ -297,14 +307,16 @@  discard block
 block discarded – undo
297 307
 			$path = $this->path($path);
298 308
 
299 309
 			// The path was not found
300
-			if ($path === false)
301
-				return false;
310
+			if ($path === false) {
311
+							return false;
312
+			}
302 313
 
303 314
 			$path = $path->array;
304 315
 		}
305 316
 		// Just use the current array.
306
-		else
307
-			$path = $this->array;
317
+		else {
318
+					$path = $this->array;
319
+		}
308 320
 
309 321
 		// Add the xml declaration to the front.
310 322
 		return '<?xml version="1.0"?' . '>' . $this->_xml($path, 0);
@@ -326,14 +338,16 @@  discard block
 block discarded – undo
326 338
 			$path = $this->path($path);
327 339
 
328 340
 			// The path was not found
329
-			if ($path === false)
330
-				return false;
341
+			if ($path === false) {
342
+							return false;
343
+			}
331 344
 
332 345
 			$path = $path->array;
333 346
 		}
334 347
 		// No, so just use the current array.
335
-		else
336
-			$path = $this->array;
348
+		else {
349
+					$path = $this->array;
350
+		}
337 351
 
338 352
 		return $this->_array($path);
339 353
 	}
@@ -355,8 +369,9 @@  discard block
 block discarded – undo
355 369
 		{
356 370
 			// Find and remove the next tag.
357 371
 			preg_match('/\A<([\w\-:]+)((?:\s+.+?)?)([\s]?\/)?' . '>/', $data, $match);
358
-			if (isset($match[0]))
359
-				$data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1);
372
+			if (isset($match[0])) {
373
+							$data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1);
374
+			}
360 375
 
361 376
 			// Didn't find a tag?  Keep looping....
362 377
 			if (!isset($match[1]) || $match[1] == '')
@@ -367,11 +382,12 @@  discard block
 block discarded – undo
367 382
 					$text_value = $this->_from_cdata($data);
368 383
 					$data = '';
369 384
 
370
-					if ($text_value != '')
371
-						$current[] = array(
385
+					if ($text_value != '') {
386
+											$current[] = array(
372 387
 							'name' => '!',
373 388
 							'value' => $text_value
374 389
 						);
390
+					}
375 391
 				}
376 392
 				// If the < isn't immediately next to the current position... more data.
377 393
 				elseif (strpos($data, '<') > 0)
@@ -379,11 +395,12 @@  discard block
 block discarded – undo
379 395
 					$text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<')));
380 396
 					$data = substr($data, strpos($data, '<'));
381 397
 
382
-					if ($text_value != '')
383
-						$current[] = array(
398
+					if ($text_value != '') {
399
+											$current[] = array(
384 400
 							'name' => '!',
385 401
 							'value' => $text_value
386 402
 						);
403
+					}
387 404
 				}
388 405
 				// If we're looking at a </something> with no start, kill it.
389 406
 				elseif (strpos($data, '<') !== false && strpos($data, '<') == 0)
@@ -393,22 +410,23 @@  discard block
 block discarded – undo
393 410
 						$text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<', 1)));
394 411
 						$data = substr($data, strpos($data, '<', 1));
395 412
 
396
-						if ($text_value != '')
397
-							$current[] = array(
413
+						if ($text_value != '') {
414
+													$current[] = array(
398 415
 								'name' => '!',
399 416
 								'value' => $text_value
400 417
 							);
401
-					}
402
-					else
418
+						}
419
+					} else
403 420
 					{
404 421
 						$text_value = $this->_from_cdata($data);
405 422
 						$data = '';
406 423
 
407
-						if ($text_value != '')
408
-							$current[] = array(
424
+						if ($text_value != '') {
425
+													$current[] = array(
409 426
 								'name' => '!',
410 427
 								'value' => $text_value
411 428
 							);
429
+						}
412 430
 					}
413 431
 				}
414 432
 
@@ -425,8 +443,9 @@  discard block
 block discarded – undo
425 443
 			{
426 444
 				// Because PHP 5.2.0+ seems to croak using regex, we'll have to do this the less fun way.
427 445
 				$last_tag_end = strpos($data, '</' . $match[1] . '>');
428
-				if ($last_tag_end === false)
429
-					continue;
446
+				if ($last_tag_end === false) {
447
+									continue;
448
+				}
430 449
 
431 450
 				$offset = 0;
432 451
 				while (1 == 1)
@@ -434,16 +453,17 @@  discard block
 block discarded – undo
434 453
 					// Where is the next start tag?
435 454
 					$next_tag_start = strpos($data, '<' . $match[1], $offset);
436 455
 					// If the next start tag is after the last end tag then we've found the right close.
437
-					if ($next_tag_start === false || $next_tag_start > $last_tag_end)
438
-						break;
456
+					if ($next_tag_start === false || $next_tag_start > $last_tag_end) {
457
+											break;
458
+					}
439 459
 
440 460
 					// If not then find the next ending tag.
441 461
 					$next_tag_end = strpos($data, '</' . $match[1] . '>', $offset);
442 462
 
443 463
 					// Didn't find one? Then just use the last and sod it.
444
-					if ($next_tag_end === false)
445
-						break;
446
-					else
464
+					if ($next_tag_end === false) {
465
+											break;
466
+					} else
447 467
 					{
448 468
 						$last_tag_end = $next_tag_end;
449 469
 						$offset = $next_tag_start + 1;
@@ -457,16 +477,17 @@  discard block
 block discarded – undo
457 477
 				if (!empty($inner_match))
458 478
 				{
459 479
 					// Parse the inner data.
460
-					if (strpos($inner_match, '<') !== false)
461
-						$el += $this->_parse($inner_match);
462
-					elseif (trim($inner_match) != '')
480
+					if (strpos($inner_match, '<') !== false) {
481
+											$el += $this->_parse($inner_match);
482
+					} elseif (trim($inner_match) != '')
463 483
 					{
464 484
 						$text_value = $this->_from_cdata($inner_match);
465
-						if ($text_value != '')
466
-							$el[] = array(
485
+						if ($text_value != '') {
486
+													$el[] = array(
467 487
 								'name' => '!',
468 488
 								'value' => $text_value
469 489
 							);
490
+						}
470 491
 					}
471 492
 				}
472 493
 			}
@@ -478,8 +499,9 @@  discard block
 block discarded – undo
478 499
 				preg_match_all('/([\w:]+)="(.+?)"/', $match[2], $attr, PREG_SET_ORDER);
479 500
 
480 501
 				// Set them as @attribute-name.
481
-				foreach ($attr as $match_attr)
482
-					$el['@' . $match_attr[1]] = $match_attr[2];
502
+				foreach ($attr as $match_attr) {
503
+									$el['@' . $match_attr[1]] = $match_attr[2];
504
+				}
483 505
 			}
484 506
 		}
485 507
 
@@ -503,16 +525,18 @@  discard block
 block discarded – undo
503 525
 		if (is_array($array) && !isset($array['name']))
504 526
 		{
505 527
 			$temp = '';
506
-			foreach ($array as $val)
507
-				$temp .= $this->_xml($val, $indent);
528
+			foreach ($array as $val) {
529
+							$temp .= $this->_xml($val, $indent);
530
+			}
508 531
 			return $temp;
509 532
 		}
510 533
 
511 534
 		// This is just text!
512
-		if ($array['name'] == '!')
513
-			return $indentation . '<![CDATA[' . $array['value'] . ']]>';
514
-		elseif (substr($array['name'], -2) == '[]')
515
-			$array['name'] = substr($array['name'], 0, -2);
535
+		if ($array['name'] == '!') {
536
+					return $indentation . '<![CDATA[' . $array['value'] . ']]>';
537
+		} elseif (substr($array['name'], -2) == '[]') {
538
+					$array['name'] = substr($array['name'], 0, -2);
539
+		}
516 540
 
517 541
 		// Start the element.
518 542
 		$output = $indentation . '<' . $array['name'];
@@ -523,9 +547,9 @@  discard block
 block discarded – undo
523 547
 		// Run through and recursively output all the elements or attrbutes inside this.
524 548
 		foreach ($array as $k => $v)
525 549
 		{
526
-			if (substr($k, 0, 1) == '@')
527
-				$output .= ' ' . substr($k, 1) . '="' . $v . '"';
528
-			elseif (is_array($v))
550
+			if (substr($k, 0, 1) == '@') {
551
+							$output .= ' ' . substr($k, 1) . '="' . $v . '"';
552
+			} elseif (is_array($v))
529 553
 			{
530 554
 				$output_el .= $this->_xml($v, $indent === null ? null : $indent + 1);
531 555
 				$inside_elements = true;
@@ -533,10 +557,11 @@  discard block
 block discarded – undo
533 557
 		}
534 558
 
535 559
 		// Indent, if necessary.... then close the tag.
536
-		if ($inside_elements)
537
-			$output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>';
538
-		else
539
-			$output .= ' />';
560
+		if ($inside_elements) {
561
+					$output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>';
562
+		} else {
563
+					$output .= ' />';
564
+		}
540 565
 
541 566
 		return $output;
542 567
 	}
@@ -553,19 +578,22 @@  discard block
 block discarded – undo
553 578
 		$text = '';
554 579
 		foreach ($array as $value)
555 580
 		{
556
-			if (!is_array($value) || !isset($value['name']))
557
-				continue;
581
+			if (!is_array($value) || !isset($value['name'])) {
582
+							continue;
583
+			}
558 584
 
559
-			if ($value['name'] == '!')
560
-				$text .= $value['value'];
561
-			else
562
-				$return[$value['name']] = $this->_array($value);
585
+			if ($value['name'] == '!') {
586
+							$text .= $value['value'];
587
+			} else {
588
+							$return[$value['name']] = $this->_array($value);
589
+			}
563 590
 		}
564 591
 
565
-		if (empty($return))
566
-			return $text;
567
-		else
568
-			return $return;
592
+		if (empty($return)) {
593
+					return $text;
594
+		} else {
595
+					return $return;
596
+		}
569 597
 	}
570 598
 
571 599
 	/**
@@ -583,24 +611,28 @@  discard block
 block discarded – undo
583 611
 		foreach ($parts as $part)
584 612
 		{
585 613
 			// Handle XML comments.
586
-			if (!$inCdata && $part === '<!--')
587
-				$inComment = true;
588
-			if ($inComment && $part === '-->')
589
-				$inComment = false;
590
-			elseif ($inComment)
591
-				continue;
614
+			if (!$inCdata && $part === '<!--') {
615
+							$inComment = true;
616
+			}
617
+			if ($inComment && $part === '-->') {
618
+							$inComment = false;
619
+			} elseif ($inComment) {
620
+							continue;
621
+			}
592 622
 
593 623
 			// Handle Cdata blocks.
594
-			elseif (!$inComment && $part === '<![CDATA[')
595
-				$inCdata = true;
596
-			elseif ($inCdata && $part === ']]>')
597
-				$inCdata = false;
598
-			elseif ($inCdata)
599
-				$output .= htmlentities($part, ENT_QUOTES);
624
+			elseif (!$inComment && $part === '<![CDATA[') {
625
+							$inCdata = true;
626
+			} elseif ($inCdata && $part === ']]>') {
627
+							$inCdata = false;
628
+			} elseif ($inCdata) {
629
+							$output .= htmlentities($part, ENT_QUOTES);
630
+			}
600 631
 
601 632
 			// Everything else is kept as is.
602
-			else
603
-				$output .= $part;
633
+			else {
634
+							$output .= $part;
635
+			}
604 636
 		}
605 637
 
606 638
 		return $output;
@@ -635,22 +667,26 @@  discard block
 block discarded – undo
635 667
 	protected function _fetch($array)
636 668
 	{
637 669
 		// Don't return anything if this is just a string.
638
-		if (is_string($array))
639
-			return '';
670
+		if (is_string($array)) {
671
+					return '';
672
+		}
640 673
 
641 674
 		$temp = '';
642 675
 		foreach ($array as $text)
643 676
 		{
644 677
 			// This means it's most likely an attribute or the name itself.
645
-			if (!isset($text['name']))
646
-				continue;
678
+			if (!isset($text['name'])) {
679
+							continue;
680
+			}
647 681
 
648 682
 			// This is text!
649
-			if ($text['name'] == '!')
650
-				$temp .= $text['value'];
683
+			if ($text['name'] == '!') {
684
+							$temp .= $text['value'];
685
+			}
651 686
 			// Another element - dive in ;).
652
-			else
653
-				$temp .= $this->_fetch($text);
687
+			else {
688
+							$temp .= $this->_fetch($text);
689
+			}
654 690
 		}
655 691
 
656 692
 		// Return all the bits and pieces we've put together.
@@ -669,12 +705,14 @@  discard block
 block discarded – undo
669 705
 	protected function _path($array, $path, $level, $no_error = false)
670 706
 	{
671 707
 		// Is $array even an array?  It might be false!
672
-		if (!is_array($array))
673
-			return false;
708
+		if (!is_array($array)) {
709
+					return false;
710
+		}
674 711
 
675 712
 		// Asking for *no* path?
676
-		if ($path == '' || $path == '.')
677
-			return $array;
713
+		if ($path == '' || $path == '.') {
714
+					return $array;
715
+		}
678 716
 		$paths = explode('|', $path);
679 717
 
680 718
 		// A * means all elements of any name.
@@ -685,16 +723,18 @@  discard block
 block discarded – undo
685 723
 		// Check each element.
686 724
 		foreach ($array as $value)
687 725
 		{
688
-			if (!is_array($value) || $value['name'] === '!')
689
-				continue;
726
+			if (!is_array($value) || $value['name'] === '!') {
727
+							continue;
728
+			}
690 729
 
691 730
 			if ($show_all || in_array($value['name'], $paths))
692 731
 			{
693 732
 				// Skip elements before "the one".
694
-				if ($level !== null && $level > 0)
695
-					$level--;
696
-				else
697
-					$results[] = $value;
733
+				if ($level !== null && $level > 0) {
734
+									$level--;
735
+				} else {
736
+									$results[] = $value;
737
+				}
698 738
 			}
699 739
 		}
700 740
 
@@ -703,21 +743,25 @@  discard block
 block discarded – undo
703 743
 		{
704 744
 			$trace = debug_backtrace();
705 745
 			$i = 0;
706
-			while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this))
707
-				$i++;
746
+			while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) {
747
+							$i++;
748
+			}
708 749
 			$debug = ' from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'];
709 750
 
710 751
 			// Cause an error.
711
-			if ($this->debug_level & E_NOTICE && !$no_error)
712
-				trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE);
752
+			if ($this->debug_level & E_NOTICE && !$no_error) {
753
+							trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE);
754
+			}
713 755
 			return false;
714 756
 		}
715 757
 		// Only one result.
716
-		elseif (count($results) == 1 || $level !== null)
717
-			return $results[0];
758
+		elseif (count($results) == 1 || $level !== null) {
759
+					return $results[0];
760
+		}
718 761
 		// Return the result set.
719
-		else
720
-			return $results + array('name' => $path . '[]');
762
+		else {
763
+					return $results + array('name' => $path . '[]');
764
+		}
721 765
 	}
722 766
 }
723 767
 
@@ -764,8 +808,9 @@  discard block
 block discarded – undo
764 808
 		$this->error = false;
765 809
 		$this->pasv = array();
766 810
 
767
-		if ($ftp_server !== null)
768
-			$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
811
+		if ($ftp_server !== null) {
812
+					$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
813
+		}
769 814
 	}
770 815
 
771 816
 	/**
@@ -778,14 +823,16 @@  discard block
 block discarded – undo
778 823
 	 */
779 824
 	public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
780 825
 	{
781
-		if (strpos($ftp_server, 'ftp://') === 0)
782
-			$ftp_server = substr($ftp_server, 6);
783
-		elseif (strpos($ftp_server, 'ftps://') === 0)
784
-			$ftp_server = 'ssl://' . substr($ftp_server, 7);
785
-		if (strpos($ftp_server, 'http://') === 0)
786
-			$ftp_server = substr($ftp_server, 7);
787
-		elseif (strpos($ftp_server, 'https://') === 0)
788
-			$ftp_server = substr($ftp_server, 8);
826
+		if (strpos($ftp_server, 'ftp://') === 0) {
827
+					$ftp_server = substr($ftp_server, 6);
828
+		} elseif (strpos($ftp_server, 'ftps://') === 0) {
829
+					$ftp_server = 'ssl://' . substr($ftp_server, 7);
830
+		}
831
+		if (strpos($ftp_server, 'http://') === 0) {
832
+					$ftp_server = substr($ftp_server, 7);
833
+		} elseif (strpos($ftp_server, 'https://') === 0) {
834
+					$ftp_server = substr($ftp_server, 8);
835
+		}
789 836
 		$ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => ''));
790 837
 
791 838
 		// Connect to the FTP server.
@@ -834,12 +881,14 @@  discard block
 block discarded – undo
834 881
 	 */
835 882
 	public function chdir($ftp_path)
836 883
 	{
837
-		if (!is_resource($this->connection))
838
-			return false;
884
+		if (!is_resource($this->connection)) {
885
+					return false;
886
+		}
839 887
 
840 888
 		// No slash on the end, please...
841
-		if ($ftp_path !== '/' && substr($ftp_path, -1) === '/')
842
-			$ftp_path = substr($ftp_path, 0, -1);
889
+		if ($ftp_path !== '/' && substr($ftp_path, -1) === '/') {
890
+					$ftp_path = substr($ftp_path, 0, -1);
891
+		}
843 892
 
844 893
 		fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n");
845 894
 		if (!$this->check_response(250))
@@ -860,11 +909,13 @@  discard block
 block discarded – undo
860 909
 	 */
861 910
 	public function chmod($ftp_file, $chmod)
862 911
 	{
863
-		if (!is_resource($this->connection))
864
-			return false;
912
+		if (!is_resource($this->connection)) {
913
+					return false;
914
+		}
865 915
 
866
-		if ($ftp_file == '')
867
-			$ftp_file = '.';
916
+		if ($ftp_file == '') {
917
+					$ftp_file = '.';
918
+		}
868 919
 
869 920
 		// Do we have a file or a dir?
870 921
 		$is_dir = is_dir($ftp_file);
@@ -880,9 +931,7 @@  discard block
 block discarded – undo
880 931
 			{
881 932
 				$is_writable = true;
882 933
 				break;
883
-			}
884
-
885
-			else
934
+			} else
886 935
 			{
887 936
 				// Convert the chmod value from octal (0777) to text ("777").
888 937
 				fwrite($this->connection, 'SITE CHMOD ' . decoct($val) . ' ' . $ftp_file . "\r\n");
@@ -905,8 +954,9 @@  discard block
 block discarded – undo
905 954
 	public function unlink($ftp_file)
906 955
 	{
907 956
 		// We are actually connected, right?
908
-		if (!is_resource($this->connection))
909
-			return false;
957
+		if (!is_resource($this->connection)) {
958
+					return false;
959
+		}
910 960
 
911 961
 		// Delete file X.
912 962
 		fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n");
@@ -935,9 +985,9 @@  discard block
 block discarded – undo
935 985
 	{
936 986
 		// Wait for a response that isn't continued with -, but don't wait too long.
937 987
 		$time = time();
938
-		do
939
-			$this->last_message = fgets($this->connection, 1024);
940
-		while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5);
988
+		do {
989
+					$this->last_message = fgets($this->connection, 1024);
990
+		} while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5);
941 991
 
942 992
 		// Was the desired response returned?
943 993
 		return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
@@ -951,15 +1001,16 @@  discard block
 block discarded – undo
951 1001
 	public function passive()
952 1002
 	{
953 1003
 		// We can't create a passive data connection without a primary one first being there.
954
-		if (!is_resource($this->connection))
955
-			return false;
1004
+		if (!is_resource($this->connection)) {
1005
+					return false;
1006
+		}
956 1007
 
957 1008
 		// Request a passive connection - this means, we'll talk to you, you don't talk to us.
958 1009
 		@fwrite($this->connection, 'PASV' . "\r\n");
959 1010
 		$time = time();
960
-		do
961
-			$response = fgets($this->connection, 1024);
962
-		while (strpos($response, ' ', 3) !== 3 && time() - $time < 5);
1011
+		do {
1012
+					$response = fgets($this->connection, 1024);
1013
+		} while (strpos($response, ' ', 3) !== 3 && time() - $time < 5);
963 1014
 
964 1015
 		// If it's not 227, we weren't given an IP and port, which means it failed.
965 1016
 		if (strpos($response, '227 ') !== 0)
@@ -990,12 +1041,14 @@  discard block
 block discarded – undo
990 1041
 	public function create_file($ftp_file)
991 1042
 	{
992 1043
 		// First, we have to be connected... very important.
993
-		if (!is_resource($this->connection))
994
-			return false;
1044
+		if (!is_resource($this->connection)) {
1045
+					return false;
1046
+		}
995 1047
 
996 1048
 		// I'd like one passive mode, please!
997
-		if (!$this->passive())
998
-			return false;
1049
+		if (!$this->passive()) {
1050
+					return false;
1051
+		}
999 1052
 
1000 1053
 		// Seems logical enough, so far...
1001 1054
 		fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n");
@@ -1030,12 +1083,14 @@  discard block
 block discarded – undo
1030 1083
 	public function list_dir($ftp_path = '', $search = false)
1031 1084
 	{
1032 1085
 		// Are we even connected...?
1033
-		if (!is_resource($this->connection))
1034
-			return false;
1086
+		if (!is_resource($this->connection)) {
1087
+					return false;
1088
+		}
1035 1089
 
1036 1090
 		// Passive... non-agressive...
1037
-		if (!$this->passive())
1038
-			return false;
1091
+		if (!$this->passive()) {
1092
+					return false;
1093
+		}
1039 1094
 
1040 1095
 		// Get the listing!
1041 1096
 		fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n");
@@ -1051,8 +1106,9 @@  discard block
 block discarded – undo
1051 1106
 
1052 1107
 		// Read in the file listing.
1053 1108
 		$data = '';
1054
-		while (!feof($fp))
1055
-			$data .= fread($fp, 4096);
1109
+		while (!feof($fp)) {
1110
+					$data .= fread($fp, 4096);
1111
+		}
1056 1112
 		fclose($fp);
1057 1113
 
1058 1114
 		// Everything go okay?
@@ -1074,21 +1130,23 @@  discard block
 block discarded – undo
1074 1130
 	 */
1075 1131
 	public function locate($file, $listing = null)
1076 1132
 	{
1077
-		if ($listing === null)
1078
-			$listing = $this->list_dir('', true);
1133
+		if ($listing === null) {
1134
+					$listing = $this->list_dir('', true);
1135
+		}
1079 1136
 		$listing = explode("\n", $listing);
1080 1137
 
1081 1138
 		@fwrite($this->connection, 'PWD' . "\r\n");
1082 1139
 		$time = time();
1083
-		do
1084
-			$response = fgets($this->connection, 1024);
1085
-		while ($response[3] != ' ' && time() - $time < 5);
1140
+		do {
1141
+					$response = fgets($this->connection, 1024);
1142
+		} while ($response[3] != ' ' && time() - $time < 5);
1086 1143
 
1087 1144
 		// Check for 257!
1088
-		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
1089
-			$current_dir = strtr($match[1], array('""' => '"'));
1090
-		else
1091
-			$current_dir = '';
1145
+		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) {
1146
+					$current_dir = strtr($match[1], array('""' => '"'));
1147
+		} else {
1148
+					$current_dir = '';
1149
+		}
1092 1150
 
1093 1151
 		for ($i = 0, $n = count($listing); $i < $n; $i++)
1094 1152
 		{
@@ -1101,12 +1159,15 @@  discard block
 block discarded – undo
1101 1159
 			// Okay, this file's name is:
1102 1160
 			$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
1103 1161
 
1104
-			if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
1105
-				return $listing[$i];
1106
-			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
1107
-				return $listing[$i];
1108
-			if (basename($listing[$i]) == $file || $listing[$i] == $file)
1109
-				return $listing[$i];
1162
+			if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) {
1163
+							return $listing[$i];
1164
+			}
1165
+			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) {
1166
+							return $listing[$i];
1167
+			}
1168
+			if (basename($listing[$i]) == $file || $listing[$i] == $file) {
1169
+							return $listing[$i];
1170
+			}
1110 1171
 		}
1111 1172
 
1112 1173
 		return false;
@@ -1121,8 +1182,9 @@  discard block
 block discarded – undo
1121 1182
 	public function create_dir($ftp_dir)
1122 1183
 	{
1123 1184
 		// We must be connected to the server to do something.
1124
-		if (!is_resource($this->connection))
1125
-			return false;
1185
+		if (!is_resource($this->connection)) {
1186
+					return false;
1187
+		}
1126 1188
 
1127 1189
 		// Make this new beautiful directory!
1128 1190
 		fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n");
@@ -1154,35 +1216,40 @@  discard block
 block discarded – undo
1154 1216
 
1155 1217
 				$path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => ''));
1156 1218
 
1157
-				if (substr($path, -1) == '/')
1158
-					$path = substr($path, 0, -1);
1219
+				if (substr($path, -1) == '/') {
1220
+									$path = substr($path, 0, -1);
1221
+				}
1159 1222
 
1160
-				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1)
1161
-					$path .= dirname($_SERVER['PHP_SELF']);
1223
+				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) {
1224
+									$path .= dirname($_SERVER['PHP_SELF']);
1225
+				}
1226
+			} elseif (strpos($filesystem_path, '/var/www/') === 0) {
1227
+							$path = substr($filesystem_path, 8);
1228
+			} else {
1229
+							$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1162 1230
 			}
1163
-			elseif (strpos($filesystem_path, '/var/www/') === 0)
1164
-				$path = substr($filesystem_path, 8);
1165
-			else
1166
-				$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1231
+		} else {
1232
+					$path = '';
1167 1233
 		}
1168
-		else
1169
-			$path = '';
1170 1234
 
1171 1235
 		if (is_resource($this->connection) && $this->list_dir($path) == '')
1172 1236
 		{
1173 1237
 			$data = $this->list_dir('', true);
1174 1238
 
1175
-			if ($lookup_file === null)
1176
-				$lookup_file = $_SERVER['PHP_SELF'];
1239
+			if ($lookup_file === null) {
1240
+							$lookup_file = $_SERVER['PHP_SELF'];
1241
+			}
1177 1242
 
1178 1243
 			$found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data));
1179
-			if ($found_path == false)
1180
-				$found_path = dirname($this->locate(basename($lookup_file)));
1181
-			if ($found_path != false)
1182
-				$path = $found_path;
1244
+			if ($found_path == false) {
1245
+							$found_path = dirname($this->locate(basename($lookup_file)));
1246
+			}
1247
+			if ($found_path != false) {
1248
+							$path = $found_path;
1249
+			}
1250
+		} elseif (is_resource($this->connection)) {
1251
+					$found_path = true;
1183 1252
 		}
1184
-		elseif (is_resource($this->connection))
1185
-			$found_path = true;
1186 1253
 
1187 1254
 		return array($username, $path, isset($found_path));
1188 1255
 	}
Please login to merge, or discard this patch.
Sources/Mentions.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 			)
51 51
 		);
52 52
 		$members = array();
53
-		while ($row = $smcFunc['db_fetch_assoc']($request))
54
-			$members[$row['id_member']] = array(
53
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
54
+					$members[$row['id_member']] = array(
55 55
 				'id' => $row['id_member'],
56 56
 				'real_name' => $row['real_name'],
57 57
 				'email_address' => $row['email_address'],
@@ -62,6 +62,7 @@  discard block
 block discarded – undo
62 62
 				),
63 63
 				'lngfile' => $row['lngfile'],
64 64
 			);
65
+		}
65 66
 		$smcFunc['db_free_result']($request);
66 67
 
67 68
 		return $members;
@@ -83,13 +84,14 @@  discard block
 block discarded – undo
83 84
 
84 85
 		call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members));
85 86
 
86
-		foreach ($members as $member)
87
-			$smcFunc['db_insert']('ignore',
87
+		foreach ($members as $member) {
88
+					$smcFunc['db_insert']('ignore',
88 89
 				'{db_prefix}mentions',
89 90
 				array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'),
90 91
 				array((int) $content_id, $content_type, $id_member, $member['id'], time()),
91 92
 				array('content_id', 'content_type', 'id_mentioned')
92 93
 			);
94
+		}
93 95
 	}
94 96
 
95 97
 	/**
@@ -103,8 +105,9 @@  discard block
 block discarded – undo
103 105
 	 */
104 106
 	public static function getBody($body, array $members)
105 107
 	{
106
-		foreach ($members as $member)
107
-			$body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body);
108
+		foreach ($members as $member) {
109
+					$body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body);
110
+		}
108 111
 
109 112
 		return $body;
110 113
 	}
@@ -123,8 +126,9 @@  discard block
 block discarded – undo
123 126
 
124 127
 		$possible_names = self::getPossibleMentions($body);
125 128
 
126
-		if (empty($possible_names) || !allowedTo('mention'))
127
-			return array();
129
+		if (empty($possible_names) || !allowedTo('mention')) {
130
+					return array();
131
+		}
128 132
 
129 133
 		$request = $smcFunc['db_query']('', '
130 134
 			SELECT id_member, real_name
@@ -140,8 +144,9 @@  discard block
 block discarded – undo
140 144
 		$members = array();
141 145
 		while ($row = $smcFunc['db_fetch_assoc']($request))
142 146
 		{
143
-			if (stripos($body, static::$char . $row['real_name']) === false)
144
-				continue;
147
+			if (stripos($body, static::$char . $row['real_name']) === false) {
148
+							continue;
149
+			}
145 150
 
146 151
 			$members[$row['id_member']] = array(
147 152
 				'id' => $row['id_member'],
@@ -185,8 +190,9 @@  discard block
 block discarded – undo
185 190
 		$body = htmlspecialchars_decode(preg_replace('~<br\s*/?\>~', "\n", str_replace('&nbsp;', ' ', $body)), ENT_QUOTES);
186 191
 
187 192
 		// Remove quotes, we don't want to get double mentions.
188
-		while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body))
189
-			$body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body);
193
+		while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) {
194
+					$body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body);
195
+		}
190 196
 
191 197
 		$matches = array();
192 198
 		$string = str_split($body);
@@ -197,9 +203,9 @@  discard block
 block discarded – undo
197 203
 			{
198 204
 				$depth++;
199 205
 				$matches[] = array();
206
+			} elseif ($char == "\n") {
207
+							$depth = 0;
200 208
 			}
201
-			elseif ($char == "\n")
202
-				$depth = 0;
203 209
 
204 210
 			for ($i = $depth; $i > 0; $i--)
205 211
 			{
@@ -212,8 +218,9 @@  discard block
 block discarded – undo
212 218
 			}
213 219
 		}
214 220
 
215
-		foreach ($matches as $k => $match)
216
-			$matches[$k] = substr(implode('', $match), 1);
221
+		foreach ($matches as $k => $match) {
222
+					$matches[$k] = substr(implode('', $match), 1);
223
+		}
217 224
 
218 225
 		// Names can have spaces, other breaks, or they can't...we try to match every possible
219 226
 		// combination.
@@ -223,8 +230,9 @@  discard block
 block discarded – undo
223 230
 			$match = preg_split('/([^\w])/', $match, -1, PREG_SPLIT_DELIM_CAPTURE);
224 231
 			$count = count($match);
225 232
 			
226
-			for ($i = 1; $i <= $count; $i++)
227
-				$names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i))));
233
+			for ($i = 1; $i <= $count; $i++) {
234
+							$names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i))));
235
+			}
228 236
 		}
229 237
 
230 238
 		$names = array_unique($names);
Please login to merge, or discard this patch.
Sources/Subs-Members.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 		'member_name' => $regOptions['username'],
587 587
 		'email_address' => $regOptions['email'],
588 588
 		'passwd' => hash_password($regOptions['username'], $regOptions['password']),
589
-		'password_salt' => substr(md5(mt_rand()), 0, 4) ,
589
+		'password_salt' => substr(md5(mt_rand()), 0, 4),
590 590
 		'posts' => 0,
591 591
 		'date_registered' => time(),
592 592
 		'member_ip' => $regOptions['interface'] == 'admin' ? '127.0.0.1' : $user_info['ip'],
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 		'time_offset',
677 677
 	);
678 678
 	$knownInets = array(
679
-		'member_ip','member_ip2',
679
+		'member_ip', 'member_ip2',
680 680
 	);
681 681
 
682 682
 	// Call an optional function to validate the users' input.
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 	$checkName = strtr($name, array('_' => '\\_', '%' => '\\%'));
905 905
 
906 906
 	//when we got no wildcard we can use equal -> fast
907
-	$operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '=' );
907
+	$operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '=');
908 908
 
909 909
 	// Make sure they don't want someone else's name.
910 910
 	$request = $smcFunc['db_query']('', '
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 		$user_info['buddies'][] = $userReceiver;
1274 1274
 
1275 1275
 		// And add a nice alert. Don't abuse though!
1276
-		if ((cache_get_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, 86400)) == null)
1276
+		if ((cache_get_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, 86400)) == null)
1277 1277
 		{
1278 1278
 			$smcFunc['db_insert']('insert',
1279 1279
 				'{db_prefix}background_tasks',
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 			);
1289 1289
 
1290 1290
 			// Store this in a cache entry to avoid creating multiple alerts. Give it a long life cycle.
1291
-			cache_put_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, '1', 86400);
1291
+			cache_put_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, '1', 86400);
1292 1292
 		}
1293 1293
 	}
1294 1294
 
Please login to merge, or discard this patch.
Braces   +208 added lines, -151 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
  * Delete one or more members.
@@ -43,30 +44,32 @@  discard block
 block discarded – undo
43 44
 	setMemoryLimit('128M');
44 45
 
45 46
 	// If it's not an array, make it so!
46
-	if (!is_array($users))
47
-		$users = array($users);
48
-	else
49
-		$users = array_unique($users);
47
+	if (!is_array($users)) {
48
+			$users = array($users);
49
+	} else {
50
+			$users = array_unique($users);
51
+	}
50 52
 
51 53
 	// Make sure there's no void user in here.
52 54
 	$users = array_diff($users, array(0));
53 55
 
54 56
 	// How many are they deleting?
55
-	if (empty($users))
56
-		return;
57
-	elseif (count($users) == 1)
57
+	if (empty($users)) {
58
+			return;
59
+	} elseif (count($users) == 1)
58 60
 	{
59 61
 		list ($user) = $users;
60 62
 
61
-		if ($user == $user_info['id'])
62
-			isAllowedTo('profile_remove_own');
63
-		else
64
-			isAllowedTo('profile_remove_any');
65
-	}
66
-	else
63
+		if ($user == $user_info['id']) {
64
+					isAllowedTo('profile_remove_own');
65
+		} else {
66
+					isAllowedTo('profile_remove_any');
67
+		}
68
+	} else
67 69
 	{
68
-		foreach ($users as $k => $v)
69
-			$users[$k] = (int) $v;
70
+		foreach ($users as $k => $v) {
71
+					$users[$k] = (int) $v;
72
+		}
70 73
 
71 74
 		// Deleting more than one?  You can't have more than one account...
72 75
 		isAllowedTo('profile_remove_any');
@@ -88,26 +91,30 @@  discard block
 block discarded – undo
88 91
 	$user_log_details = array();
89 92
 	while ($row = $smcFunc['db_fetch_assoc']($request))
90 93
 	{
91
-		if ($row['is_admin'])
92
-			$admins[] = $row['id_member'];
94
+		if ($row['is_admin']) {
95
+					$admins[] = $row['id_member'];
96
+		}
93 97
 		$user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']);
94 98
 	}
95 99
 	$smcFunc['db_free_result']($request);
96 100
 
97
-	if (empty($user_log_details))
98
-		return;
101
+	if (empty($user_log_details)) {
102
+			return;
103
+	}
99 104
 
100 105
 	// Make sure they aren't trying to delete administrators if they aren't one.  But don't bother checking if it's just themself.
101 106
 	if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id']))))
102 107
 	{
103 108
 		$users = array_diff($users, $admins);
104
-		foreach ($admins as $id)
105
-			unset($user_log_details[$id]);
109
+		foreach ($admins as $id) {
110
+					unset($user_log_details[$id]);
111
+		}
106 112
 	}
107 113
 
108 114
 	// No one left?
109
-	if (empty($users))
110
-		return;
115
+	if (empty($users)) {
116
+			return;
117
+	}
111 118
 
112 119
 	// Log the action - regardless of who is deleting it.
113 120
 	$log_changes = array();
@@ -124,8 +131,9 @@  discard block
 block discarded – undo
124 131
 		);
125 132
 
126 133
 		// Remove any cached data if enabled.
127
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
128
-			cache_put_data('user_settings-' . $user[0], null, 60);
134
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
135
+					cache_put_data('user_settings-' . $user[0], null, 60);
136
+		}
129 137
 	}
130 138
 
131 139
 	// Make these peoples' posts guest posts.
@@ -388,8 +396,8 @@  discard block
 block discarded – undo
388 396
 			'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users),
389 397
 		)
390 398
 	);
391
-	while ($row = $smcFunc['db_fetch_assoc']($request))
392
-		$smcFunc['db_query']('', '
399
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
400
+			$smcFunc['db_query']('', '
393 401
 			UPDATE {db_prefix}members
394 402
 			SET
395 403
 				pm_ignore_list = {string:pm_ignore_list},
@@ -401,6 +409,7 @@  discard block
 block discarded – undo
401 409
 				'buddy_list' => implode(',', array_diff(explode(',', $row['buddy_list']), $users)),
402 410
 			)
403 411
 		);
412
+	}
404 413
 	$smcFunc['db_free_result']($request);
405 414
 
406 415
 	// Make sure no member's birthday is still sticking in the calendar...
@@ -455,29 +464,34 @@  discard block
 block discarded – undo
455 464
 	elseif ($regOptions['interface'] == 'guest')
456 465
 	{
457 466
 		// You cannot register twice...
458
-		if (empty($user_info['is_guest']))
459
-			redirectexit();
467
+		if (empty($user_info['is_guest'])) {
468
+					redirectexit();
469
+		}
460 470
 
461 471
 		// Make sure they didn't just register with this session.
462
-		if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck']))
463
-			fatal_lang_error('register_only_once', false);
472
+		if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) {
473
+					fatal_lang_error('register_only_once', false);
474
+		}
464 475
 	}
465 476
 
466 477
 	// Spaces and other odd characters are evil...
467 478
 	$regOptions['username'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $regOptions['username']));
468 479
 
469 480
 	// @todo Separate the sprintf?
470
-	if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255)
471
-		$reg_errors[] = array('lang', 'profile_error_bad_email');
481
+	if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) {
482
+			$reg_errors[] = array('lang', 'profile_error_bad_email');
483
+	}
472 484
 
473 485
 	$username_validation_errors = validateUsername(0, $regOptions['username'], true, !empty($regOptions['check_reserved_name']));
474
-	if (!empty($username_validation_errors))
475
-		$reg_errors = array_merge($reg_errors, $username_validation_errors);
486
+	if (!empty($username_validation_errors)) {
487
+			$reg_errors = array_merge($reg_errors, $username_validation_errors);
488
+	}
476 489
 
477 490
 	// Generate a validation code if it's supposed to be emailed.
478 491
 	$validation_code = '';
479
-	if ($regOptions['require'] == 'activation')
480
-		$validation_code = generateValidationCode();
492
+	if ($regOptions['require'] == 'activation') {
493
+			$validation_code = generateValidationCode();
494
+	}
481 495
 
482 496
 	// If you haven't put in a password generate one.
483 497
 	if ($regOptions['interface'] == 'admin' && $regOptions['password'] == '')
@@ -487,8 +501,9 @@  discard block
 block discarded – undo
487 501
 		$regOptions['password_check'] = $regOptions['password'];
488 502
 	}
489 503
 	// Does the first password match the second?
490
-	elseif ($regOptions['password'] != $regOptions['password_check'])
491
-		$reg_errors[] = array('lang', 'passwords_dont_match');
504
+	elseif ($regOptions['password'] != $regOptions['password_check']) {
505
+			$reg_errors[] = array('lang', 'passwords_dont_match');
506
+	}
492 507
 
493 508
 	// That's kind of easy to guess...
494 509
 	if ($regOptions['password'] == '')
@@ -502,13 +517,15 @@  discard block
 block discarded – undo
502 517
 		$passwordError = validatePassword($regOptions['password'], $regOptions['username'], array($regOptions['email']));
503 518
 
504 519
 		// Password isn't legal?
505
-		if ($passwordError != null)
506
-			$reg_errors[] = array('lang', 'profile_error_password_' . $passwordError);
520
+		if ($passwordError != null) {
521
+					$reg_errors[] = array('lang', 'profile_error_password_' . $passwordError);
522
+		}
507 523
 	}
508 524
 
509 525
 	// You may not be allowed to register this email.
510
-	if (!empty($regOptions['check_email_ban']))
511
-		isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']);
526
+	if (!empty($regOptions['check_email_ban'])) {
527
+			isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']);
528
+	}
512 529
 
513 530
 	// Check if the email address is in use.
514 531
 	$request = $smcFunc['db_query']('', '
@@ -523,8 +540,9 @@  discard block
 block discarded – undo
523 540
 		)
524 541
 	);
525 542
 	// @todo Separate the sprintf?
526
-	if ($smcFunc['db_num_rows']($request) != 0)
527
-		$reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email'])));
543
+	if ($smcFunc['db_num_rows']($request) != 0) {
544
+			$reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email'])));
545
+	}
528 546
 
529 547
 	$smcFunc['db_free_result']($request);
530 548
 
@@ -539,24 +557,27 @@  discard block
 block discarded – undo
539 557
 			1 = The text/index.
540 558
 			2 = Whether to log.
541 559
 			3 = sprintf data if necessary. */
542
-		if ($error[0] == 'lang')
543
-			loadLanguage('Errors');
560
+		if ($error[0] == 'lang') {
561
+					loadLanguage('Errors');
562
+		}
544 563
 		$message = $error[0] == 'lang' ? (empty($error[3]) ? $txt[$error[1]] : vsprintf($txt[$error[1]], $error[3])) : $error[1];
545 564
 
546 565
 		// What to do, what to do, what to do.
547 566
 		if ($return_errors)
548 567
 		{
549
-			if (!empty($error[2]))
550
-				log_error($message, $error[2]);
568
+			if (!empty($error[2])) {
569
+							log_error($message, $error[2]);
570
+			}
551 571
 			$reg_errors[$key] = $message;
572
+		} else {
573
+					fatal_error($message, empty($error[2]) ? false : $error[2]);
552 574
 		}
553
-		else
554
-			fatal_error($message, empty($error[2]) ? false : $error[2]);
555 575
 	}
556 576
 
557 577
 	// If there's any errors left return them at once!
558
-	if (!empty($reg_errors))
559
-		return $reg_errors;
578
+	if (!empty($reg_errors)) {
579
+			return $reg_errors;
580
+	}
560 581
 
561 582
 	$reservedVars = array(
562 583
 		'actual_theme_url',
@@ -578,8 +599,9 @@  discard block
 block discarded – undo
578 599
 	);
579 600
 
580 601
 	// Can't change reserved vars.
581
-	if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0)
582
-		fatal_lang_error('no_theme');
602
+	if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) {
603
+			fatal_lang_error('no_theme');
604
+	}
583 605
 
584 606
 	// Some of these might be overwritten. (the lower ones that are in the arrays below.)
585 607
 	$regOptions['register_vars'] = array(
@@ -621,14 +643,17 @@  discard block
 block discarded – undo
621 643
 		$regOptions['register_vars']['validation_code'] = '';
622 644
 	}
623 645
 	// Maybe it can be activated right away?
624
-	elseif ($regOptions['require'] == 'nothing')
625
-		$regOptions['register_vars']['is_activated'] = 1;
646
+	elseif ($regOptions['require'] == 'nothing') {
647
+			$regOptions['register_vars']['is_activated'] = 1;
648
+	}
626 649
 	// Maybe it must be activated by email?
627
-	elseif ($regOptions['require'] == 'activation')
628
-		$regOptions['register_vars']['is_activated'] = 0;
650
+	elseif ($regOptions['require'] == 'activation') {
651
+			$regOptions['register_vars']['is_activated'] = 0;
652
+	}
629 653
 	// Otherwise it must be awaiting approval!
630
-	else
631
-		$regOptions['register_vars']['is_activated'] = 3;
654
+	else {
655
+			$regOptions['register_vars']['is_activated'] = 3;
656
+	}
632 657
 
633 658
 	if (isset($regOptions['memberGroup']))
634 659
 	{
@@ -647,24 +672,28 @@  discard block
 block discarded – undo
647 672
 				'is_protected' => 1,
648 673
 			)
649 674
 		);
650
-		while ($row = $smcFunc['db_fetch_assoc']($request))
651
-			$unassignableGroups[] = $row['id_group'];
675
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
676
+					$unassignableGroups[] = $row['id_group'];
677
+		}
652 678
 		$smcFunc['db_free_result']($request);
653 679
 
654
-		if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups))
655
-			$regOptions['register_vars']['id_group'] = 0;
680
+		if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) {
681
+					$regOptions['register_vars']['id_group'] = 0;
682
+		}
656 683
 	}
657 684
 
658 685
 	// Integrate optional member settings to be set.
659
-	if (!empty($regOptions['extra_register_vars']))
660
-		foreach ($regOptions['extra_register_vars'] as $var => $value)
686
+	if (!empty($regOptions['extra_register_vars'])) {
687
+			foreach ($regOptions['extra_register_vars'] as $var => $value)
661 688
 			$regOptions['register_vars'][$var] = $value;
689
+	}
662 690
 
663 691
 	// Integrate optional user theme options to be set.
664 692
 	$theme_vars = array();
665
-	if (!empty($regOptions['theme_vars']))
666
-		foreach ($regOptions['theme_vars'] as $var => $value)
693
+	if (!empty($regOptions['theme_vars'])) {
694
+			foreach ($regOptions['theme_vars'] as $var => $value)
667 695
 			$theme_vars[$var] = $value;
696
+	}
668 697
 
669 698
 	// Right, now let's prepare for insertion.
670 699
 	$knownInts = array(
@@ -687,14 +716,15 @@  discard block
 block discarded – undo
687 716
 	foreach ($regOptions['register_vars'] as $var => $val)
688 717
 	{
689 718
 		$type = 'string';
690
-		if (in_array($var, $knownInts))
691
-			$type = 'int';
692
-		elseif (in_array($var, $knownFloats))
693
-			$type = 'float';
694
-		elseif (in_array($var, $knownInets))
695
-			$type = 'inet';
696
-		elseif ($var == 'birthdate')
697
-			$type = 'date';
719
+		if (in_array($var, $knownInts)) {
720
+					$type = 'int';
721
+		} elseif (in_array($var, $knownFloats)) {
722
+					$type = 'float';
723
+		} elseif (in_array($var, $knownInets)) {
724
+					$type = 'inet';
725
+		} elseif ($var == 'birthdate') {
726
+					$type = 'date';
727
+		}
698 728
 
699 729
 		$column_names[$var] = $type;
700 730
 		$values[$var] = $val;
@@ -713,17 +743,19 @@  discard block
 block discarded – undo
713 743
 	call_integration_hook('integrate_post_register', array(&$regOptions, &$theme_vars, &$memberID));
714 744
 
715 745
 	// Update the number of members and latest member's info - and pass the name, but remove the 's.
716
-	if ($regOptions['register_vars']['is_activated'] == 1)
717
-		updateStats('member', $memberID, $regOptions['register_vars']['real_name']);
718
-	else
719
-		updateStats('member');
746
+	if ($regOptions['register_vars']['is_activated'] == 1) {
747
+			updateStats('member', $memberID, $regOptions['register_vars']['real_name']);
748
+	} else {
749
+			updateStats('member');
750
+	}
720 751
 
721 752
 	// Theme variables too?
722 753
 	if (!empty($theme_vars))
723 754
 	{
724 755
 		$inserts = array();
725
-		foreach ($theme_vars as $var => $val)
726
-			$inserts[] = array($memberID, $var, $val);
756
+		foreach ($theme_vars as $var => $val) {
757
+					$inserts[] = array($memberID, $var, $val);
758
+		}
727 759
 		$smcFunc['db_insert']('insert',
728 760
 			'{db_prefix}themes',
729 761
 			array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
@@ -738,10 +770,11 @@  discard block
 block discarded – undo
738 770
 	// Administrative registrations are a bit different...
739 771
 	if ($regOptions['interface'] == 'admin')
740 772
 	{
741
-		if ($regOptions['require'] == 'activation')
742
-			$email_message = 'admin_register_activate';
743
-		elseif (!empty($regOptions['send_welcome_email']))
744
-			$email_message = 'admin_register_immediate';
773
+		if ($regOptions['require'] == 'activation') {
774
+					$email_message = 'admin_register_activate';
775
+		} elseif (!empty($regOptions['send_welcome_email'])) {
776
+					$email_message = 'admin_register_immediate';
777
+		}
745 778
 
746 779
 		if (isset($email_message))
747 780
 		{
@@ -792,16 +825,17 @@  discard block
 block discarded – undo
792 825
 			'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder',
793 826
 		);
794 827
 
795
-		if ($regOptions['require'] == 'activation')
796
-			$replacements += array(
828
+		if ($regOptions['require'] == 'activation') {
829
+					$replacements += array(
797 830
 				'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code,
798 831
 				'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID,
799 832
 				'ACTIVATIONCODE' => $validation_code,
800 833
 			);
801
-		else
802
-			$replacements += array(
834
+		} else {
835
+					$replacements += array(
803 836
 				'COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID,
804 837
 			);
838
+		}
805 839
 
806 840
 		$emaildata = loadEmailTemplate('register_' . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements);
807 841
 
@@ -866,39 +900,45 @@  discard block
 block discarded – undo
866 900
 		// Check each name in the list...
867 901
 		foreach ($reservedNames as $reserved)
868 902
 		{
869
-			if ($reserved == '')
870
-				continue;
903
+			if ($reserved == '') {
904
+							continue;
905
+			}
871 906
 
872 907
 			// The admin might've used entities too, level the playing field.
873 908
 			$reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved);
874 909
 
875 910
 			// Case sensitive name?
876
-			if (empty($modSettings['reserveCase']))
877
-				$reservedCheck = $smcFunc['strtolower']($reservedCheck);
911
+			if (empty($modSettings['reserveCase'])) {
912
+							$reservedCheck = $smcFunc['strtolower']($reservedCheck);
913
+			}
878 914
 
879 915
 			// If it's not just entire word, check for it in there somewhere...
880
-			if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord'])))
881
-				if ($fatal)
916
+			if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) {
917
+							if ($fatal)
882 918
 					fatal_lang_error('username_reserved', 'password', array($reserved));
883
-				else
884
-					return true;
919
+			} else {
920
+									return true;
921
+				}
885 922
 		}
886 923
 
887 924
 		$censor_name = $name;
888
-		if (censorText($censor_name) != $name)
889
-			if ($fatal)
925
+		if (censorText($censor_name) != $name) {
926
+					if ($fatal)
890 927
 				fatal_lang_error('name_censored', 'password', array($name));
891
-			else
892
-				return true;
928
+		} else {
929
+							return true;
930
+			}
893 931
 	}
894 932
 
895 933
 	// Characters we just shouldn't allow, regardless.
896
-	foreach (array('*') as $char)
897
-		if (strpos($checkName, $char) !== false)
934
+	foreach (array('*') as $char) {
935
+			if (strpos($checkName, $char) !== false)
898 936
 			if ($fatal)
899 937
 				fatal_lang_error('username_reserved', 'password', array($char));
900
-			else
901
-				return true;
938
+	}
939
+			else {
940
+							return true;
941
+			}
902 942
 
903 943
 	// Get rid of any SQL parts of the reserved name...
904 944
 	$checkName = strtr($name, array('_' => '\\_', '%' => '\\%'));
@@ -980,8 +1020,9 @@  discard block
 block discarded – undo
980 1020
 				'permission' => $permission,
981 1021
 			)
982 1022
 		);
983
-		while ($row = $smcFunc['db_fetch_assoc']($request))
984
-			$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1023
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1024
+					$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1025
+		}
985 1026
 		$smcFunc['db_free_result']($request);
986 1027
 	}
987 1028
 
@@ -989,9 +1030,9 @@  discard block
 block discarded – undo
989 1030
 	else
990 1031
 	{
991 1032
 		// First get the profile of the given board.
992
-		if (isset($board_info['id']) && $board_info['id'] == $board_id)
993
-			$profile_id = $board_info['profile'];
994
-		elseif ($board_id !== 0)
1033
+		if (isset($board_info['id']) && $board_info['id'] == $board_id) {
1034
+					$profile_id = $board_info['profile'];
1035
+		} elseif ($board_id !== 0)
995 1036
 		{
996 1037
 			$request = $smcFunc['db_query']('', '
997 1038
 				SELECT id_profile
@@ -1002,13 +1043,14 @@  discard block
 block discarded – undo
1002 1043
 					'id_board' => $board_id,
1003 1044
 				)
1004 1045
 			);
1005
-			if ($smcFunc['db_num_rows']($request) == 0)
1006
-				fatal_lang_error('no_board');
1046
+			if ($smcFunc['db_num_rows']($request) == 0) {
1047
+							fatal_lang_error('no_board');
1048
+			}
1007 1049
 			list ($profile_id) = $smcFunc['db_fetch_row']($request);
1008 1050
 			$smcFunc['db_free_result']($request);
1051
+		} else {
1052
+					$profile_id = 1;
1009 1053
 		}
1010
-		else
1011
-			$profile_id = 1;
1012 1054
 
1013 1055
 		$request = $smcFunc['db_query']('', '
1014 1056
 			SELECT bp.id_group, bp.add_deny
@@ -1020,8 +1062,9 @@  discard block
 block discarded – undo
1020 1062
 				'permission' => $permission,
1021 1063
 			)
1022 1064
 		);
1023
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1024
-			$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1065
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1066
+					$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1067
+		}
1025 1068
 		$smcFunc['db_free_result']($request);
1026 1069
 
1027 1070
 		$moderator_groups = array();
@@ -1030,8 +1073,7 @@  discard block
 block discarded – undo
1030 1073
 		if (isset($board_info['moderator_groups']))
1031 1074
 		{
1032 1075
 			$moderator_groups = array_keys($board_info['moderator_groups']);
1033
-		}
1034
-		elseif ($board_id !== 0)
1076
+		} elseif ($board_id !== 0)
1035 1077
 		{
1036 1078
 			// Get the groups that can moderate this board
1037 1079
 			$request = $smcFunc['db_query']('', '
@@ -1116,8 +1158,9 @@  discard block
 block discarded – undo
1116 1158
 		)
1117 1159
 	);
1118 1160
 	$members = array();
1119
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1120
-		$members[] = $row['id_member'];
1161
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1162
+			$members[] = $row['id_member'];
1163
+	}
1121 1164
 	$smcFunc['db_free_result']($request);
1122 1165
 
1123 1166
 	return $members;
@@ -1190,10 +1233,12 @@  discard block
 block discarded – undo
1190 1233
 	}
1191 1234
 
1192 1235
 	$query_parts = array();
1193
-	if (!empty($email))
1194
-		$query_parts[] = 'poster_email = {string:email_address}';
1195
-	if (!empty($membername))
1196
-		$query_parts[] = 'poster_name = {string:member_name}';
1236
+	if (!empty($email)) {
1237
+			$query_parts[] = 'poster_email = {string:email_address}';
1238
+	}
1239
+	if (!empty($membername)) {
1240
+			$query_parts[] = 'poster_name = {string:member_name}';
1241
+	}
1197 1242
 	$query = implode(' AND ', $query_parts);
1198 1243
 
1199 1244
 	// Finally, update the posts themselves!
@@ -1260,12 +1305,14 @@  discard block
 block discarded – undo
1260 1305
 
1261 1306
 	$userReceiver = (int) !empty($_REQUEST['u']) ? $_REQUEST['u'] : 0;
1262 1307
 
1263
-	if (empty($userReceiver))
1264
-		fatal_lang_error('no_access', false);
1308
+	if (empty($userReceiver)) {
1309
+			fatal_lang_error('no_access', false);
1310
+	}
1265 1311
 
1266 1312
 	// Remove if it's already there...
1267
-	if (in_array($userReceiver, $user_info['buddies']))
1268
-		$user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver));
1313
+	if (in_array($userReceiver, $user_info['buddies'])) {
1314
+			$user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver));
1315
+	}
1269 1316
 
1270 1317
 	// ...or add if it's not and if it's not you.
1271 1318
 	elseif ($user_info['id'] != $userReceiver)
@@ -1340,8 +1387,9 @@  discard block
 block discarded – undo
1340 1387
 	$smcFunc['db_free_result']($request);
1341 1388
 
1342 1389
 	// If we want duplicates pass the members array off.
1343
-	if ($get_duplicates)
1344
-		populateDuplicateMembers($members);
1390
+	if ($get_duplicates) {
1391
+			populateDuplicateMembers($members);
1392
+	}
1345 1393
 
1346 1394
 	return $members;
1347 1395
 }
@@ -1358,8 +1406,9 @@  discard block
 block discarded – undo
1358 1406
 	global $smcFunc, $modSettings;
1359 1407
 
1360 1408
 	// We know how many members there are in total.
1361
-	if (empty($where) || $where == '1=1')
1362
-		$num_members = $modSettings['totalMembers'];
1409
+	if (empty($where) || $where == '1=1') {
1410
+			$num_members = $modSettings['totalMembers'];
1411
+	}
1363 1412
 
1364 1413
 	// The database knows the amount when there are extra conditions.
1365 1414
 	else
@@ -1395,16 +1444,19 @@  discard block
 block discarded – undo
1395 1444
 		$members[$key]['duplicate_members'] = array();
1396 1445
 
1397 1446
 		// Store the IPs.
1398
-		if (!empty($member['member_ip']))
1399
-			$ips[] = $member['member_ip'];
1400
-		if (!empty($member['member_ip2']))
1401
-			$ips[] = $member['member_ip2'];
1447
+		if (!empty($member['member_ip'])) {
1448
+					$ips[] = $member['member_ip'];
1449
+		}
1450
+		if (!empty($member['member_ip2'])) {
1451
+					$ips[] = $member['member_ip2'];
1452
+		}
1402 1453
 	}
1403 1454
 
1404 1455
 	$ips = array_unique($ips);
1405 1456
 
1406
-	if (empty($ips))
1407
-		return false;
1457
+	if (empty($ips)) {
1458
+			return false;
1459
+	}
1408 1460
 
1409 1461
 	// Fetch all members with this IP address, we'll filter out the current ones in a sec.
1410 1462
 	$request = $smcFunc['db_query']('', '
@@ -1434,10 +1486,12 @@  discard block
 block discarded – undo
1434 1486
 			'ip2' => $row['member_ip2'],
1435 1487
 		);
1436 1488
 
1437
-		if (in_array($row['member_ip'], $ips))
1438
-			$duplicate_members[$row['member_ip']][] = $member_context;
1439
-		if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips))
1440
-			$duplicate_members[$row['member_ip2']][] = $member_context;
1489
+		if (in_array($row['member_ip'], $ips)) {
1490
+					$duplicate_members[$row['member_ip']][] = $member_context;
1491
+		}
1492
+		if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) {
1493
+					$duplicate_members[$row['member_ip2']][] = $member_context;
1494
+		}
1441 1495
 	}
1442 1496
 	$smcFunc['db_free_result']($request);
1443 1497
 
@@ -1462,8 +1516,9 @@  discard block
 block discarded – undo
1462 1516
 		$row['poster_ip'] = inet_dtop($row['poster_ip']);
1463 1517
 
1464 1518
 		// Don't collect lots of the same.
1465
-		if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']]))
1466
-			continue;
1519
+		if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) {
1520
+					continue;
1521
+		}
1467 1522
 		$had_ips[$row['poster_ip']][] = $row['id_member'];
1468 1523
 
1469 1524
 		$duplicate_members[$row['poster_ip']][] = array(
@@ -1478,13 +1533,15 @@  discard block
 block discarded – undo
1478 1533
 	$smcFunc['db_free_result']($request);
1479 1534
 
1480 1535
 	// Now we have all the duplicate members, stick them with their respective member in the list.
1481
-	if (!empty($duplicate_members))
1482
-		foreach ($members as $key => $member)
1536
+	if (!empty($duplicate_members)) {
1537
+			foreach ($members as $key => $member)
1483 1538
 		{
1484 1539
 			if (isset($duplicate_members[$member['member_ip']]))
1485 1540
 				$members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']];
1486
-			if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']]))
1487
-				$members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]);
1541
+	}
1542
+			if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) {
1543
+							$members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]);
1544
+			}
1488 1545
 
1489 1546
 			// Check we don't have lots of the same member.
1490 1547
 			$member_track = array($member['id_member']);
Please login to merge, or discard this patch.
Sources/Recent.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	else
238 238
 	{
239 239
 		$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
240
-					AND b.id_board != {int:recycle_board}' : ''). '
240
+					AND b.id_board != {int:recycle_board}' : '') . '
241 241
 					AND m.id_msg >= {int:max_id_msg}';
242 242
 		$query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 100 - $_REQUEST['start'] * 6);
243 243
 		$query_parameters['recycle_board'] = $modSettings['recycle_board'];
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 			);
1125 1125
 		else
1126 1126
 			$request = $smcFunc['db_query']('', '
1127
-				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].'
1127
+				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'] . '
1128 1128
 				FROM {db_prefix}topics AS t
1129 1129
 					INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : '
1130 1130
 					INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)') . (strpos($_REQUEST['sort'], 'mems.') === false ? '' : '
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 	if ($is_topics)
1392 1392
 	{
1393 1393
 		$context['recent_buttons'] = array(
1394
-			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'.  $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1394
+			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1395 1395
 		);
1396 1396
 
1397 1397
 		if ($context['showCheckboxes'])
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	elseif (!$is_topics && isset($context['topics_to_mark']))
1408 1408
 	{
1409 1409
 		$context['recent_buttons'] = array(
1410
-			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read']  .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1410
+			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1411 1411
 		);
1412 1412
 
1413 1413
 		if ($context['showCheckboxes'])
Please login to merge, or discard this patch.
Braces   +208 added lines, -170 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
  * Get the latest post made on the system
@@ -44,8 +45,9 @@  discard block
 block discarded – undo
44 45
 			'is_approved' => 1,
45 46
 		)
46 47
 	);
47
-	if ($smcFunc['db_num_rows']($request) == 0)
48
-		return array();
48
+	if ($smcFunc['db_num_rows']($request) == 0) {
49
+			return array();
50
+	}
49 51
 	$row = $smcFunc['db_fetch_assoc']($request);
50 52
 	$smcFunc['db_free_result']($request);
51 53
 
@@ -54,8 +56,9 @@  discard block
 block discarded – undo
54 56
 	censorText($row['body']);
55 57
 
56 58
 	$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => '&#10;')));
57
-	if ($smcFunc['strlen']($row['body']) > 128)
58
-		$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
59
+	if ($smcFunc['strlen']($row['body']) > 128) {
60
+			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
61
+	}
59 62
 
60 63
 	// Send the data.
61 64
 	return array(
@@ -83,15 +86,17 @@  discard block
 block discarded – undo
83 86
 
84 87
 	$context['is_redirect'] = false;
85 88
 
86
-	if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95)
87
-		$_REQUEST['start'] = 95;
89
+	if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) {
90
+			$_REQUEST['start'] = 95;
91
+	}
88 92
 
89 93
 	$query_parameters = array();
90 94
 	if (!empty($_REQUEST['c']) && empty($board))
91 95
 	{
92 96
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
93
-		foreach ($_REQUEST['c'] as $i => $c)
94
-			$_REQUEST['c'][$i] = (int) $c;
97
+		foreach ($_REQUEST['c'] as $i => $c) {
98
+					$_REQUEST['c'][$i] = (int) $c;
99
+		}
95 100
 
96 101
 		if (count($_REQUEST['c']) == 1)
97 102
 		{
@@ -107,8 +112,9 @@  discard block
 block discarded – undo
107 112
 			list ($name) = $smcFunc['db_fetch_row']($request);
108 113
 			$smcFunc['db_free_result']($request);
109 114
 
110
-			if (empty($name))
111
-				fatal_lang_error('no_access', false);
115
+			if (empty($name)) {
116
+							fatal_lang_error('no_access', false);
117
+			}
112 118
 
113 119
 			$context['linktree'][] = array(
114 120
 				'url' => $scripturl . '#c' . (int) $_REQUEST['c'],
@@ -140,8 +146,9 @@  discard block
 block discarded – undo
140 146
 		}
141 147
 		$smcFunc['db_free_result']($request);
142 148
 
143
-		if (empty($boards))
144
-			fatal_lang_error('error_no_boards_selected');
149
+		if (empty($boards)) {
150
+					fatal_lang_error('error_no_boards_selected');
151
+		}
145 152
 
146 153
 		$query_this_board = 'b.id_board IN ({array_int:boards})';
147 154
 		$query_parameters['boards'] = $boards;
@@ -155,12 +162,12 @@  discard block
 block discarded – undo
155 162
 		}
156 163
 
157 164
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false);
158
-	}
159
-	elseif (!empty($_REQUEST['boards']))
165
+	} elseif (!empty($_REQUEST['boards']))
160 166
 	{
161 167
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
162
-		foreach ($_REQUEST['boards'] as $i => $b)
163
-			$_REQUEST['boards'][$i] = (int) $b;
168
+		foreach ($_REQUEST['boards'] as $i => $b) {
169
+					$_REQUEST['boards'][$i] = (int) $b;
170
+		}
164 171
 
165 172
 		$request = $smcFunc['db_query']('', '
166 173
 			SELECT b.id_board, b.num_posts
@@ -184,8 +191,9 @@  discard block
 block discarded – undo
184 191
 		}
185 192
 		$smcFunc['db_free_result']($request);
186 193
 
187
-		if (empty($boards))
188
-			fatal_lang_error('error_no_boards_selected');
194
+		if (empty($boards)) {
195
+					fatal_lang_error('error_no_boards_selected');
196
+		}
189 197
 
190 198
 		$query_this_board = 'b.id_board IN ({array_int:boards})';
191 199
 		$query_parameters['boards'] = $boards;
@@ -199,8 +207,7 @@  discard block
 block discarded – undo
199 207
 		}
200 208
 
201 209
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false);
202
-	}
203
-	elseif (!empty($board))
210
+	} elseif (!empty($board))
204 211
 	{
205 212
 		$request = $smcFunc['db_query']('', '
206 213
 			SELECT num_posts, redirect
@@ -233,8 +240,7 @@  discard block
 block discarded – undo
233 240
 		}
234 241
 
235 242
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true);
236
-	}
237
-	else
243
+	} else
238 244
 	{
239 245
 		$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
240 246
 					AND b.id_board != {int:recycle_board}' : ''). '
@@ -269,8 +275,9 @@  discard block
 block discarded – undo
269 275
 	);
270 276
 
271 277
 	// If you selected a redirection board, don't try getting posts for it...
272
-	if ($context['is_redirect'])
273
-		$messages = 0;
278
+	if ($context['is_redirect']) {
279
+			$messages = 0;
280
+	}
274 281
 
275 282
 	$key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start'];
276 283
 	if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null))
@@ -301,16 +308,18 @@  discard block
 block discarded – undo
301 308
 				$query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board);
302 309
 				$cache_results = true;
303 310
 				unset($query_parameters['max_id_msg']);
311
+			} else {
312
+							$done = true;
304 313
 			}
305
-			else
306
-				$done = true;
307 314
 		}
308 315
 		$messages = array();
309
-		while ($row = $smcFunc['db_fetch_assoc']($request))
310
-			$messages[] = $row['id_msg'];
316
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
317
+					$messages[] = $row['id_msg'];
318
+		}
311 319
 		$smcFunc['db_free_result']($request);
312
-		if (!empty($cache_results))
313
-			cache_put_data($key, $messages, 120);
320
+		if (!empty($cache_results)) {
321
+					cache_put_data($key, $messages, 120);
322
+		}
314 323
 	}
315 324
 
316 325
 	// Nothing here... Or at least, nothing you can see...
@@ -397,8 +406,9 @@  discard block
 block discarded – undo
397 406
 			'css_class' => 'windowbg',
398 407
 		);
399 408
 
400
-		if ($user_info['id'] == $row['id_first_member'])
401
-			$board_ids['own'][$row['id_board']][] = $row['id_msg'];
409
+		if ($user_info['id'] == $row['id_first_member']) {
410
+					$board_ids['own'][$row['id_board']][] = $row['id_msg'];
411
+		}
402 412
 		$board_ids['any'][$row['id_board']][] = $row['id_msg'];
403 413
 	}
404 414
 	$smcFunc['db_free_result']($request);
@@ -424,20 +434,23 @@  discard block
 block discarded – undo
424 434
 			$boards = boardsAllowedTo($permission);
425 435
 
426 436
 			// If 0 is the only thing in the array, they can do it everywhere!
427
-			if (!empty($boards) && $boards[0] == 0)
428
-				$boards = array_keys($board_ids[$type]);
437
+			if (!empty($boards) && $boards[0] == 0) {
438
+							$boards = array_keys($board_ids[$type]);
439
+			}
429 440
 
430 441
 			// Go through the boards, and look for posts they can do this on.
431 442
 			foreach ($boards as $board_id)
432 443
 			{
433 444
 				// Hmm, they have permission, but there are no topics from that board on this page.
434
-				if (!isset($board_ids[$type][$board_id]))
435
-					continue;
445
+				if (!isset($board_ids[$type][$board_id])) {
446
+									continue;
447
+				}
436 448
 
437 449
 				// Okay, looks like they can do it for these posts.
438
-				foreach ($board_ids[$type][$board_id] as $counter)
439
-					if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id'])
450
+				foreach ($board_ids[$type][$board_id] as $counter) {
451
+									if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id'])
440 452
 						$context['posts'][$counter][$allowed] = true;
453
+				}
441 454
 			}
442 455
 		}
443 456
 	}
@@ -480,17 +493,19 @@  discard block
 block discarded – undo
480 493
 	$context['showing_all_topics'] = isset($_GET['all']);
481 494
 	$context['start'] = (int) $_REQUEST['start'];
482 495
 	$context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
483
-	if ($_REQUEST['action'] == 'unread')
484
-		$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
485
-	else
486
-		$context['page_title'] = $txt['unread_replies'];
496
+	if ($_REQUEST['action'] == 'unread') {
497
+			$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
498
+	} else {
499
+			$context['page_title'] = $txt['unread_replies'];
500
+	}
487 501
 
488
-	if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread'])
489
-		fatal_lang_error('loadavg_allunread_disabled', false);
490
-	elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies'])
491
-		fatal_lang_error('loadavg_unreadreplies_disabled', false);
492
-	elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread'])
493
-		fatal_lang_error('loadavg_unread_disabled', false);
502
+	if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) {
503
+			fatal_lang_error('loadavg_allunread_disabled', false);
504
+	} elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) {
505
+			fatal_lang_error('loadavg_unreadreplies_disabled', false);
506
+	} elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) {
507
+			fatal_lang_error('loadavg_unread_disabled', false);
508
+	}
494 509
 
495 510
 	// Parameters for the main query.
496 511
 	$query_parameters = array();
@@ -503,12 +518,14 @@  discard block
 block discarded – undo
503 518
 		if (!empty($_REQUEST['boards']))
504 519
 		{
505 520
 			$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
506
-			foreach ($_REQUEST['boards'] as $b)
507
-				$boards[] = (int) $b;
521
+			foreach ($_REQUEST['boards'] as $b) {
522
+							$boards[] = (int) $b;
523
+			}
508 524
 		}
509 525
 
510
-		if (!empty($board))
511
-			$boards[] = (int) $board;
526
+		if (!empty($board)) {
527
+					$boards[] = (int) $board;
528
+		}
512 529
 
513 530
 		// The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them
514 531
 		$request = $smcFunc['db_query']('', '
@@ -525,30 +542,31 @@  discard block
 block discarded – undo
525 542
 			)
526 543
 		);
527 544
 
528
-		while ($row = $smcFunc['db_fetch_assoc']($request))
529
-			if (in_array($row['id_parent'], $boards))
545
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
546
+					if (in_array($row['id_parent'], $boards))
530 547
 				$boards[] = $row['id_board'];
548
+		}
531 549
 
532 550
 		$smcFunc['db_free_result']($request);
533 551
 
534
-		if (empty($boards))
535
-			fatal_lang_error('error_no_boards_selected');
552
+		if (empty($boards)) {
553
+					fatal_lang_error('error_no_boards_selected');
554
+		}
536 555
 
537 556
 		$query_this_board = 'id_board IN ({array_int:boards})';
538 557
 		$query_parameters['boards'] = $boards;
539 558
 		$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d';
540
-	}
541
-	elseif (!empty($board))
559
+	} elseif (!empty($board))
542 560
 	{
543 561
 		$query_this_board = 'id_board = {int:board}';
544 562
 		$query_parameters['board'] = $board;
545 563
 		$context['querystring_board_limits'] = ';board=' . $board . '.%1$d';
546
-	}
547
-	elseif (!empty($_REQUEST['boards']))
564
+	} elseif (!empty($_REQUEST['boards']))
548 565
 	{
549 566
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
550
-		foreach ($_REQUEST['boards'] as $i => $b)
551
-			$_REQUEST['boards'][$i] = (int) $b;
567
+		foreach ($_REQUEST['boards'] as $i => $b) {
568
+					$_REQUEST['boards'][$i] = (int) $b;
569
+		}
552 570
 
553 571
 		$request = $smcFunc['db_query']('', '
554 572
 			SELECT b.id_board
@@ -560,22 +578,24 @@  discard block
 block discarded – undo
560 578
 			)
561 579
 		);
562 580
 		$boards = array();
563
-		while ($row = $smcFunc['db_fetch_assoc']($request))
564
-			$boards[] = $row['id_board'];
581
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
582
+					$boards[] = $row['id_board'];
583
+		}
565 584
 		$smcFunc['db_free_result']($request);
566 585
 
567
-		if (empty($boards))
568
-			fatal_lang_error('error_no_boards_selected');
586
+		if (empty($boards)) {
587
+					fatal_lang_error('error_no_boards_selected');
588
+		}
569 589
 
570 590
 		$query_this_board = 'id_board IN ({array_int:boards})';
571 591
 		$query_parameters['boards'] = $boards;
572 592
 		$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d';
573
-	}
574
-	elseif (!empty($_REQUEST['c']))
593
+	} elseif (!empty($_REQUEST['c']))
575 594
 	{
576 595
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
577
-		foreach ($_REQUEST['c'] as $i => $c)
578
-			$_REQUEST['c'][$i] = (int) $c;
596
+		foreach ($_REQUEST['c'] as $i => $c) {
597
+					$_REQUEST['c'][$i] = (int) $c;
598
+		}
579 599
 
580 600
 		$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
581 601
 		$request = $smcFunc['db_query']('', '
@@ -588,18 +608,19 @@  discard block
 block discarded – undo
588 608
 			)
589 609
 		);
590 610
 		$boards = array();
591
-		while ($row = $smcFunc['db_fetch_assoc']($request))
592
-			$boards[] = $row['id_board'];
611
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
612
+					$boards[] = $row['id_board'];
613
+		}
593 614
 		$smcFunc['db_free_result']($request);
594 615
 
595
-		if (empty($boards))
596
-			fatal_lang_error('error_no_boards_selected');
616
+		if (empty($boards)) {
617
+					fatal_lang_error('error_no_boards_selected');
618
+		}
597 619
 
598 620
 		$query_this_board = 'id_board IN ({array_int:boards})';
599 621
 		$query_parameters['boards'] = $boards;
600 622
 		$context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d';
601
-	}
602
-	else
623
+	} else
603 624
 	{
604 625
 		$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
605 626
 		// Don't bother to show deleted posts!
@@ -613,12 +634,14 @@  discard block
 block discarded – undo
613 634
 			)
614 635
 		);
615 636
 		$boards = array();
616
-		while ($row = $smcFunc['db_fetch_assoc']($request))
617
-			$boards[] = $row['id_board'];
637
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
638
+					$boards[] = $row['id_board'];
639
+		}
618 640
 		$smcFunc['db_free_result']($request);
619 641
 
620
-		if (empty($boards))
621
-			fatal_lang_error('error_no_boards_available', false);
642
+		if (empty($boards)) {
643
+					fatal_lang_error('error_no_boards_available', false);
644
+		}
622 645
 
623 646
 		$query_this_board = 'id_board IN ({array_int:boards})';
624 647
 		$query_parameters['boards'] = $boards;
@@ -680,13 +703,14 @@  discard block
 block discarded – undo
680 703
 		'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies']
681 704
 	);
682 705
 
683
-	if ($context['showing_all_topics'])
684
-		$context['linktree'][] = array(
706
+	if ($context['showing_all_topics']) {
707
+			$context['linktree'][] = array(
685 708
 			'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'],
686 709
 			'name' => $txt['unread_topics_all']
687 710
 		);
688
-	else
689
-		$txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
711
+	} else {
712
+			$txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
713
+	}
690 714
 
691 715
 	loadTemplate('Recent');
692 716
 	loadTemplate('MessageIndex');
@@ -694,8 +718,9 @@  discard block
 block discarded – undo
694 718
 
695 719
 	// Setup the default topic icons... for checking they exist and the like ;)
696 720
 	$context['icon_sources'] = array();
697
-	foreach ($context['stable_icons'] as $icon)
698
-		$context['icon_sources'][$icon] = 'images_url';
721
+	foreach ($context['stable_icons'] as $icon) {
722
+			$context['icon_sources'][$icon] = 'images_url';
723
+	}
699 724
 
700 725
 	$is_topics = $_REQUEST['action'] == 'unread';
701 726
 
@@ -725,8 +750,7 @@  discard block
 block discarded – undo
725 750
 			);
726 751
 			list ($earliest_msg) = $smcFunc['db_fetch_row']($request);
727 752
 			$smcFunc['db_free_result']($request);
728
-		}
729
-		else
753
+		} else
730 754
 		{
731 755
 			$request = $smcFunc['db_query']('', '
732 756
 				SELECT MIN(lmr.id_msg)
@@ -742,14 +766,14 @@  discard block
 block discarded – undo
742 766
 		}
743 767
 
744 768
 		// This is needed in case of topics marked unread.
745
-		if (empty($earliest_msg))
746
-			$earliest_msg = 0;
747
-		else
769
+		if (empty($earliest_msg)) {
770
+					$earliest_msg = 0;
771
+		} else
748 772
 		{
749 773
 			// Using caching, when possible, to ignore the below slow query.
750
-			if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time())
751
-				$earliest_msg2 = $_SESSION['cached_log_time'][1];
752
-			else
774
+			if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) {
775
+							$earliest_msg2 = $_SESSION['cached_log_time'][1];
776
+			} else
753 777
 			{
754 778
 				// This query is pretty slow, but it's needed to ensure nothing crucial is ignored.
755 779
 				$request = $smcFunc['db_query']('', '
@@ -764,8 +788,9 @@  discard block
 block discarded – undo
764 788
 				$smcFunc['db_free_result']($request);
765 789
 
766 790
 				// In theory this could be zero, if the first ever post is unread, so fudge it ;)
767
-				if ($earliest_msg2 == 0)
768
-					$earliest_msg2 = -1;
791
+				if ($earliest_msg2 == 0) {
792
+									$earliest_msg2 = -1;
793
+				}
769 794
 
770 795
 				$_SESSION['cached_log_time'] = array(time(), $earliest_msg2);
771 796
 			}
@@ -803,9 +828,9 @@  discard block
 block discarded – undo
803 828
 				'db_error_skip' => true,
804 829
 			))
805 830
 		) !== false;
831
+	} else {
832
+			$have_temp_table = false;
806 833
 	}
807
-	else
808
-		$have_temp_table = false;
809 834
 
810 835
 	if ($context['showing_all_topics'] && $have_temp_table)
811 836
 	{
@@ -851,14 +876,15 @@  discard block
 block discarded – undo
851 876
 
852 877
 			$context['topics'] = array();
853 878
 			$context['no_topic_listing'] = true;
854
-			if ($context['querystring_board_limits'] == ';start=%1$d')
855
-				$context['querystring_board_limits'] = '';
856
-			else
857
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
879
+			if ($context['querystring_board_limits'] == ';start=%1$d') {
880
+							$context['querystring_board_limits'] = '';
881
+			} else {
882
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
883
+			}
858 884
 			return;
885
+		} else {
886
+					$min_message = (int) $min_message;
859 887
 		}
860
-		else
861
-			$min_message = (int) $min_message;
862 888
 
863 889
 		$request = $smcFunc['db_query']('substring', '
864 890
 			SELECT ' . $select_clause . '
@@ -887,8 +913,7 @@  discard block
 block discarded – undo
887 913
 				'limit' => $context['topics_per_page'],
888 914
 			))
889 915
 		);
890
-	}
891
-	elseif ($is_topics)
916
+	} elseif ($is_topics)
892 917
 	{
893 918
 		$request = $smcFunc['db_query']('', '
894 919
 			SELECT COUNT(*), MIN(t.id_last_msg)
@@ -939,14 +964,15 @@  discard block
 block discarded – undo
939 964
 
940 965
 			$context['topics'] = array();
941 966
 			$context['no_topic_listing'] = true;
942
-			if ($context['querystring_board_limits'] == ';start=%d')
943
-				$context['querystring_board_limits'] = '';
944
-			else
945
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
967
+			if ($context['querystring_board_limits'] == ';start=%d') {
968
+							$context['querystring_board_limits'] = '';
969
+			} else {
970
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
971
+			}
946 972
 			return;
973
+		} else {
974
+					$min_message = (int) $min_message;
947 975
 		}
948
-		else
949
-			$min_message = (int) $min_message;
950 976
 
951 977
 		$request = $smcFunc['db_query']('substring', '
952 978
 			SELECT ' . $select_clause . '
@@ -976,8 +1002,7 @@  discard block
 block discarded – undo
976 1002
 				'limit' => $context['topics_per_page'],
977 1003
 			))
978 1004
 		);
979
-	}
980
-	else
1005
+	} else
981 1006
 	{
982 1007
 		if ($modSettings['totalMessages'] > 100000)
983 1008
 		{
@@ -1029,8 +1054,8 @@  discard block
 block discarded – undo
1029 1054
 			) !== false;
1030 1055
 
1031 1056
 			// If that worked, create a sample of the log_topics table too.
1032
-			if ($have_temp_table)
1033
-				$have_temp_table = $smcFunc['db_query']('', '
1057
+			if ($have_temp_table) {
1058
+							$have_temp_table = $smcFunc['db_query']('', '
1034 1059
 					CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in (
1035 1060
 						PRIMARY KEY (id_topic)
1036 1061
 					)
@@ -1043,6 +1068,7 @@  discard block
 block discarded – undo
1043 1068
 						'db_error_skip' => true,
1044 1069
 					)
1045 1070
 				) !== false;
1071
+			}
1046 1072
 		}
1047 1073
 
1048 1074
 		if (!empty($have_temp_table))
@@ -1058,8 +1084,7 @@  discard block
 block discarded – undo
1058 1084
 			);
1059 1085
 			list ($num_topics) = $smcFunc['db_fetch_row']($request);
1060 1086
 			$smcFunc['db_free_result']($request);
1061
-		}
1062
-		else
1087
+		} else
1063 1088
 		{
1064 1089
 			$request = $smcFunc['db_query']('unread_fetch_topic_count', '
1065 1090
 				SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg)
@@ -1100,15 +1125,16 @@  discard block
 block discarded – undo
1100 1125
 		{
1101 1126
 			$context['topics'] = array();
1102 1127
 			$context['no_topic_listing'] = true;
1103
-			if ($context['querystring_board_limits'] == ';start=%d')
1104
-				$context['querystring_board_limits'] = '';
1105
-			else
1106
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1128
+			if ($context['querystring_board_limits'] == ';start=%d') {
1129
+							$context['querystring_board_limits'] = '';
1130
+			} else {
1131
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1132
+			}
1107 1133
 			return;
1108 1134
 		}
1109 1135
 
1110
-		if (!empty($have_temp_table))
1111
-			$request = $smcFunc['db_query']('', '
1136
+		if (!empty($have_temp_table)) {
1137
+					$request = $smcFunc['db_query']('', '
1112 1138
 				SELECT t.id_topic
1113 1139
 				FROM {db_prefix}topics_posted_in AS t
1114 1140
 					LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic)
@@ -1122,8 +1148,8 @@  discard block
 block discarded – undo
1122 1148
 					'limit' => $context['topics_per_page'],
1123 1149
 				))
1124 1150
 			);
1125
-		else
1126
-			$request = $smcFunc['db_query']('', '
1151
+		} else {
1152
+					$request = $smcFunc['db_query']('', '
1127 1153
 				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].'
1128 1154
 				FROM {db_prefix}topics AS t
1129 1155
 					INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : '
@@ -1147,10 +1173,12 @@  discard block
 block discarded – undo
1147 1173
 					'sort' => $_REQUEST['sort'],
1148 1174
 				))
1149 1175
 			);
1176
+		}
1150 1177
 
1151 1178
 		$topics = array();
1152
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1153
-			$topics[] = $row['id_topic'];
1179
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1180
+					$topics[] = $row['id_topic'];
1181
+		}
1154 1182
 		$smcFunc['db_free_result']($request);
1155 1183
 
1156 1184
 		// Sanity... where have you gone?
@@ -1158,10 +1186,11 @@  discard block
 block discarded – undo
1158 1186
 		{
1159 1187
 			$context['topics'] = array();
1160 1188
 			$context['no_topic_listing'] = true;
1161
-			if ($context['querystring_board_limits'] == ';start=%d')
1162
-				$context['querystring_board_limits'] = '';
1163
-			else
1164
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1189
+			if ($context['querystring_board_limits'] == ';start=%d') {
1190
+							$context['querystring_board_limits'] = '';
1191
+			} else {
1192
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1193
+			}
1165 1194
 			return;
1166 1195
 		}
1167 1196
 
@@ -1195,8 +1224,9 @@  discard block
 block discarded – undo
1195 1224
 
1196 1225
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1197 1226
 	{
1198
-		if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
1199
-			continue;
1227
+		if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
1228
+					continue;
1229
+		}
1200 1230
 
1201 1231
 		$topic_ids[] = $row['id_topic'];
1202 1232
 
@@ -1204,11 +1234,13 @@  discard block
 block discarded – undo
1204 1234
 		{
1205 1235
 			// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
1206 1236
 			$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
1207
-			if ($smcFunc['strlen']($row['first_body']) > 128)
1208
-				$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1237
+			if ($smcFunc['strlen']($row['first_body']) > 128) {
1238
+							$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1239
+			}
1209 1240
 			$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
1210
-			if ($smcFunc['strlen']($row['last_body']) > 128)
1211
-				$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1241
+			if ($smcFunc['strlen']($row['last_body']) > 128) {
1242
+							$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1243
+			}
1212 1244
 
1213 1245
 			// Censor the subject and message preview.
1214 1246
 			censorText($row['first_subject']);
@@ -1219,23 +1251,22 @@  discard block
 block discarded – undo
1219 1251
 			{
1220 1252
 				$row['last_subject'] = $row['first_subject'];
1221 1253
 				$row['last_body'] = $row['first_body'];
1222
-			}
1223
-			else
1254
+			} else
1224 1255
 			{
1225 1256
 				censorText($row['last_subject']);
1226 1257
 				censorText($row['last_body']);
1227 1258
 			}
1228
-		}
1229
-		else
1259
+		} else
1230 1260
 		{
1231 1261
 			$row['first_body'] = '';
1232 1262
 			$row['last_body'] = '';
1233 1263
 			censorText($row['first_subject']);
1234 1264
 
1235
-			if ($row['id_first_msg'] == $row['id_last_msg'])
1236
-				$row['last_subject'] = $row['first_subject'];
1237
-			else
1238
-				censorText($row['last_subject']);
1265
+			if ($row['id_first_msg'] == $row['id_last_msg']) {
1266
+							$row['last_subject'] = $row['first_subject'];
1267
+			} else {
1268
+							censorText($row['last_subject']);
1269
+			}
1239 1270
 		}
1240 1271
 
1241 1272
 		// Decide how many pages the topic should have.
@@ -1247,22 +1278,24 @@  discard block
 block discarded – undo
1247 1278
 			$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false);
1248 1279
 
1249 1280
 			// If we can use all, show all.
1250
-			if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
1251
-				$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
1281
+			if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) {
1282
+							$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
1283
+			}
1284
+		} else {
1285
+					$pages = '';
1252 1286
 		}
1253 1287
 
1254
-		else
1255
-			$pages = '';
1256
-
1257 1288
 		// We need to check the topic icons exist... you can never be too sure!
1258 1289
 		if (!empty($modSettings['messageIconChecks_enable']))
1259 1290
 		{
1260 1291
 			// First icon first... as you'd expect.
1261
-			if (!isset($context['icon_sources'][$row['first_icon']]))
1262
-				$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1292
+			if (!isset($context['icon_sources'][$row['first_icon']])) {
1293
+							$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1294
+			}
1263 1295
 			// Last icon... last... duh.
1264
-			if (!isset($context['icon_sources'][$row['last_icon']]))
1265
-				$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1296
+			if (!isset($context['icon_sources'][$row['last_icon']])) {
1297
+							$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1298
+			}
1266 1299
 		}
1267 1300
 
1268 1301
 		// Force the recycling icon if appropriate
@@ -1276,12 +1309,14 @@  discard block
 block discarded – undo
1276 1309
 		$colorClass = 'windowbg';
1277 1310
 
1278 1311
 		// Sticky topics should get a different color, too.
1279
-		if ($row['is_sticky'])
1280
-			$colorClass .= ' sticky';
1312
+		if ($row['is_sticky']) {
1313
+					$colorClass .= ' sticky';
1314
+		}
1281 1315
 
1282 1316
 		// Locked topics get special treatment as well.
1283
-		if ($row['locked'])
1284
-			$colorClass .= ' locked';
1317
+		if ($row['locked']) {
1318
+					$colorClass .= ' locked';
1319
+		}
1285 1320
 
1286 1321
 		// And build the array.
1287 1322
 		$context['topics'][$row['id_topic']] = array(
@@ -1378,8 +1413,9 @@  discard block
 block discarded – undo
1378 1413
 		);
1379 1414
 		while ($row = $smcFunc['db_fetch_assoc']($result))
1380 1415
 		{
1381
-			if (empty($context['topics'][$row['id_topic']]['is_posted_in']))
1382
-				$context['topics'][$row['id_topic']]['is_posted_in'] = true;
1416
+			if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) {
1417
+							$context['topics'][$row['id_topic']]['is_posted_in'] = true;
1418
+			}
1383 1419
 		}
1384 1420
 		$smcFunc['db_free_result']($result);
1385 1421
 	}
@@ -1394,28 +1430,30 @@  discard block
 block discarded – undo
1394 1430
 			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'.  $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1395 1431
 		);
1396 1432
 
1397
-		if ($context['showCheckboxes'])
1398
-			$context['recent_buttons']['markselectread'] = array(
1433
+		if ($context['showCheckboxes']) {
1434
+					$context['recent_buttons']['markselectread'] = array(
1399 1435
 				'text' => 'quick_mod_markread',
1400 1436
 				'image' => 'markselectedread.png',
1401 1437
 				'url' => 'javascript:document.quickModForm.submit();',
1402 1438
 			);
1439
+		}
1403 1440
 
1404
-		if (!empty($context['topics']) && !$context['showing_all_topics'])
1405
-			$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
1406
-	}
1407
-	elseif (!$is_topics && isset($context['topics_to_mark']))
1441
+		if (!empty($context['topics']) && !$context['showing_all_topics']) {
1442
+					$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
1443
+		}
1444
+	} elseif (!$is_topics && isset($context['topics_to_mark']))
1408 1445
 	{
1409 1446
 		$context['recent_buttons'] = array(
1410 1447
 			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read']  .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1411 1448
 		);
1412 1449
 
1413
-		if ($context['showCheckboxes'])
1414
-			$context['recent_buttons']['markselectread'] = array(
1450
+		if ($context['showCheckboxes']) {
1451
+					$context['recent_buttons']['markselectread'] = array(
1415 1452
 				'text' => 'quick_mod_markread',
1416 1453
 				'image' => 'markselectedread.png',
1417 1454
 				'url' => 'javascript:document.quickModForm.submit();',
1418 1455
 			);
1456
+		}
1419 1457
 	}
1420 1458
 
1421 1459
 	// Allow mods to add additional buttons here
Please login to merge, or discard this patch.