Completed
Push — release-2.1 ( e6c696...22bfba )
by Mathias
07:04
created
Sources/Subs-List.php 1 patch
Braces   +85 added lines, -59 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  * @version 2.1 Beta 3
13 13
  */
14 14
 
15
-if (!defined('SMF'))
15
+if (!defined('SMF')) {
16 16
 	die('No direct access...');
17
+}
17 18
 
18 19
 /**
19 20
  * Create a new list
@@ -41,21 +42,21 @@  discard block
 block discarded – undo
41 42
 	{
42 43
 		$list_context['sort'] = array();
43 44
 		$sort = '1=1';
44
-	}
45
-	else
45
+	} else
46 46
 	{
47 47
 		$request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort';
48 48
 		$request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc';
49
-		if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']))
50
-			$list_context['sort'] = array(
49
+		if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) {
50
+					$list_context['sort'] = array(
51 51
 				'id' => $_REQUEST[$request_var_sort],
52 52
 				'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse']),
53 53
 			);
54
-		else
55
-			$list_context['sort'] = array(
54
+		} else {
55
+					$list_context['sort'] = array(
56 56
 				'id' => $listOptions['default_sort_col'],
57 57
 				'desc' => (!empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc') || (!empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc') ? true : false,
58 58
 			);
59
+		}
59 60
 
60 61
 		// Set the database column sort.
61 62
 		$sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default'];
@@ -72,8 +73,9 @@  discard block
 block discarded – undo
72 73
 	else
73 74
 	{
74 75
 		// First get an impression of how many items to expect.
75
-		if (isset($listOptions['get_count']['file']))
76
-			require_once($listOptions['get_count']['file']);
76
+		if (isset($listOptions['get_count']['file'])) {
77
+					require_once($listOptions['get_count']['file']);
78
+		}
77 79
 
78 80
 		$call = call_helper($listOptions['get_count']['function'], true);
79 81
 		$list_context['total_num_items'] = call_user_func_array($call, empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']);
@@ -83,14 +85,15 @@  discard block
 block discarded – undo
83 85
 		$list_context['items_per_page'] = $listOptions['items_per_page'];
84 86
 
85 87
 		// Then create a page index.
86
-		if ($list_context['total_num_items'] > $list_context['items_per_page'])
87
-			$list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start');
88
+		if ($list_context['total_num_items'] > $list_context['items_per_page']) {
89
+					$list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start');
90
+		}
88 91
 	}
89 92
 
90 93
 	// Prepare the headers of the table.
91 94
 	$list_context['headers'] = array();
92
-	foreach ($listOptions['columns'] as $column_id => $column)
93
-		$list_context['headers'][] = array(
95
+	foreach ($listOptions['columns'] as $column_id => $column) {
96
+			$list_context['headers'][] = array(
94 97
 			'id' => $column_id,
95 98
 			'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''),
96 99
 			'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']),
@@ -99,14 +102,16 @@  discard block
 block discarded – undo
99 102
 			'style' => isset($column['header']['style']) ? $column['header']['style'] : '',
100 103
 			'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : '',
101 104
 		);
105
+	}
102 106
 
103 107
 	// We know the amount of columns, might be useful for the template.
104 108
 	$list_context['num_columns'] = count($listOptions['columns']);
105 109
 	$list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0';
106 110
 
107 111
 	// Get the file with the function for the item list.
108
-	if (isset($listOptions['get_items']['file']))
109
-		require_once($listOptions['get_items']['file']);
112
+	if (isset($listOptions['get_items']['file'])) {
113
+			require_once($listOptions['get_items']['file']);
114
+	}
110 115
 
111 116
 	// Call the function and include which items we want and in what order.
112 117
 	$call = call_helper($listOptions['get_items']['function'], true);
@@ -123,51 +128,61 @@  discard block
 block discarded – undo
123 128
 			$cur_data = array();
124 129
 
125 130
 			// A value straight from the database?
126
-			if (isset($column['data']['db']))
127
-				$cur_data['value'] = $list_item[$column['data']['db']];
131
+			if (isset($column['data']['db'])) {
132
+							$cur_data['value'] = $list_item[$column['data']['db']];
133
+			}
128 134
 
129 135
 			// Take the value from the database and make it HTML safe.
130
-			elseif (isset($column['data']['db_htmlsafe']))
131
-				$cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]);
136
+			elseif (isset($column['data']['db_htmlsafe'])) {
137
+							$cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]);
138
+			}
132 139
 
133 140
 			// Using sprintf is probably the most readable way of injecting data.
134 141
 			elseif (isset($column['data']['sprintf']))
135 142
 			{
136 143
 				$params = array();
137
-				foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe)
138
-					$params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param];
144
+				foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) {
145
+									$params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param];
146
+				}
139 147
 				$cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params);
140 148
 			}
141 149
 
142 150
 			// The most flexible way probably is applying a custom function.
143
-			elseif (isset($column['data']['function']))
144
-				$cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item));
151
+			elseif (isset($column['data']['function'])) {
152
+							$cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item));
153
+			}
145 154
 
146 155
 			// A modified value (inject the database values).
147
-			elseif (isset($column['data']['eval']))
148
-				$cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval']));
156
+			elseif (isset($column['data']['eval'])) {
157
+							$cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval']));
158
+			}
149 159
 
150 160
 			// A literal value.
151
-			elseif (isset($column['data']['value']))
152
-				$cur_data['value'] = $column['data']['value'];
161
+			elseif (isset($column['data']['value'])) {
162
+							$cur_data['value'] = $column['data']['value'];
163
+			}
153 164
 
154 165
 			// Empty value.
155
-			else
156
-				$cur_data['value'] = '';
166
+			else {
167
+							$cur_data['value'] = '';
168
+			}
157 169
 
158 170
 			// Allow for basic formatting.
159
-			if (!empty($column['data']['comma_format']))
160
-				$cur_data['value'] = comma_format($cur_data['value']);
161
-			elseif (!empty($column['data']['timeformat']))
162
-				$cur_data['value'] = timeformat($cur_data['value']);
171
+			if (!empty($column['data']['comma_format'])) {
172
+							$cur_data['value'] = comma_format($cur_data['value']);
173
+			} elseif (!empty($column['data']['timeformat'])) {
174
+							$cur_data['value'] = timeformat($cur_data['value']);
175
+			}
163 176
 
164 177
 			// Set a style class for this column?
165
-			if (isset($column['data']['class']))
166
-				$cur_data['class'] = $column['data']['class'];
178
+			if (isset($column['data']['class'])) {
179
+							$cur_data['class'] = $column['data']['class'];
180
+			}
167 181
 
168 182
 			// Fully customized styling for the cells in this column only.
169
-			if (isset($column['data']['style']))
170
-				$cur_data['style'] = $column['data']['style'];
183
+			if (isset($column['data']['style'])) {
184
+							$cur_data['style'] = $column['data']['style'];
185
+			}
171 186
 
172 187
 			// Add the data cell properties to the current row.
173 188
 			$cur_row[$column_id] = $cur_data;
@@ -176,10 +191,12 @@  discard block
 block discarded – undo
176 191
 		// Maybe we wat set a custom class for the row based on the data in the row itself
177 192
 		if (isset($listOptions['data_check']))
178 193
 		{
179
-			if (isset($listOptions['data_check']['class']))
180
-				$list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item);
181
-			if (isset($listOptions['data_check']['style']))
182
-				$list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item);
194
+			if (isset($listOptions['data_check']['class'])) {
195
+							$list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item);
196
+			}
197
+			if (isset($listOptions['data_check']['style'])) {
198
+							$list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item);
199
+			}
183 200
 		}
184 201
 
185 202
 		// Insert the row into the list.
@@ -187,34 +204,39 @@  discard block
 block discarded – undo
187 204
 	}
188 205
 
189 206
 	// The title is currently optional.
190
-	if (isset($listOptions['title']))
191
-		$list_context['title'] = $listOptions['title'];
207
+	if (isset($listOptions['title'])) {
208
+			$list_context['title'] = $listOptions['title'];
209
+	}
192 210
 
193 211
 	// In case there's a form, share it with the template context.
194 212
 	if (isset($listOptions['form']))
195 213
 	{
196 214
 		$list_context['form'] = $listOptions['form'];
197 215
 
198
-		if (!isset($list_context['form']['hidden_fields']))
199
-			$list_context['form']['hidden_fields'] = array();
216
+		if (!isset($list_context['form']['hidden_fields'])) {
217
+					$list_context['form']['hidden_fields'] = array();
218
+		}
200 219
 
201 220
 		// Always add a session check field.
202 221
 		$list_context['form']['hidden_fields'][$context['session_var']] = $context['session_id'];
203 222
 
204 223
 		// Will this do a token check?
205
-		if (isset($listOptions['form']['token']))
206
-			$list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token'];
224
+		if (isset($listOptions['form']['token'])) {
225
+					$list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token'];
226
+		}
207 227
 
208 228
 		// Include the starting page as hidden field?
209
-		if (!empty($list_context['form']['include_start']) && !empty($list_context['start']))
210
-			$list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start'];
229
+		if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) {
230
+					$list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start'];
231
+		}
211 232
 
212 233
 		// If sorting needs to be the same after submitting, add the parameter.
213 234
 		if (!empty($list_context['form']['include_sort']) && !empty($list_context['sort']))
214 235
 		{
215 236
 			$list_context['form']['hidden_fields']['sort'] = $list_context['sort']['id'];
216
-			if ($list_context['sort']['desc'])
217
-				$list_context['form']['hidden_fields']['desc'] = 1;
237
+			if ($list_context['sort']['desc']) {
238
+							$list_context['form']['hidden_fields']['desc'] = 1;
239
+			}
218 240
 		}
219 241
 	}
220 242
 
@@ -231,24 +253,28 @@  discard block
 block discarded – undo
231 253
 		$list_context['additional_rows'] = array();
232 254
 		foreach ($listOptions['additional_rows'] as $row)
233 255
 		{
234
-			if (empty($row))
235
-				continue;
256
+			if (empty($row)) {
257
+							continue;
258
+			}
236 259
 
237 260
 			// Supported row positions: top_of_list, after_title,
238 261
 			// above_column_headers, below_table_data, bottom_of_list.
239
-			if (!isset($list_context['additional_rows'][$row['position']]))
240
-				$list_context['additional_rows'][$row['position']] = array();
262
+			if (!isset($list_context['additional_rows'][$row['position']])) {
263
+							$list_context['additional_rows'][$row['position']] = array();
264
+			}
241 265
 			$list_context['additional_rows'][$row['position']][] = $row;
242 266
 		}
243 267
 	}
244 268
 
245 269
 	// Add an option for inline JavaScript.
246
-	if (isset($listOptions['javascript']))
247
-		$list_context['javascript'] = $listOptions['javascript'];
270
+	if (isset($listOptions['javascript'])) {
271
+			$list_context['javascript'] = $listOptions['javascript'];
272
+	}
248 273
 
249 274
 	// We want a menu.
250
-	if (isset($listOptions['list_menu']))
251
-		$list_context['list_menu'] = $listOptions['list_menu'];
275
+	if (isset($listOptions['list_menu'])) {
276
+			$list_context['list_menu'] = $listOptions['list_menu'];
277
+	}
252 278
 
253 279
 	// Make sure the template is loaded.
254 280
 	loadTemplate('GenericList');
Please login to merge, or discard this patch.
Sources/Session.php 1 patch
Braces   +31 added lines, -21 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
  * @version 2.1 Beta 3
18 18
  */
19 19
 
20
-if (!defined('SMF'))
20
+if (!defined('SMF')) {
21 21
 	die('No direct access...');
22
+}
22 23
 
23 24
 /**
24 25
  * Attempt to start the session, unless it already has been.
@@ -38,8 +39,9 @@  discard block
 block discarded – undo
38 39
 	{
39 40
 		$parsed_url = parse_url($boardurl);
40 41
 
41
-		if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
42
-			@ini_set('session.cookie_domain', '.' . $parts[1]);
42
+		if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
43
+					@ini_set('session.cookie_domain', '.' . $parts[1]);
44
+		}
43 45
 	}
44 46
 	// @todo Set the session cookie path?
45 47
 
@@ -47,8 +49,9 @@  discard block
 block discarded – undo
47 49
 	if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '')
48 50
 	{
49 51
 		// Attempt to end the already-started session.
50
-		if (ini_get('session.auto_start') == 1)
51
-			session_write_close();
52
+		if (ini_get('session.auto_start') == 1) {
53
+					session_write_close();
54
+		}
52 55
 
53 56
 		// This is here to stop people from using bad junky PHPSESSIDs.
54 57
 		if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()]))
@@ -65,19 +68,21 @@  discard block
 block discarded – undo
65 68
 			@ini_set('session.serialize_handler', 'php');
66 69
 			session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC');
67 70
 			@ini_set('session.gc_probability', '1');
71
+		} elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) {
72
+					@ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60));
68 73
 		}
69
-		elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime']))
70
-			@ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60));
71 74
 
72 75
 		// Use cache setting sessions?
73
-		if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli')
74
-			call_integration_hook('integrate_session_handlers');
76
+		if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') {
77
+					call_integration_hook('integrate_session_handlers');
78
+		}
75 79
 
76 80
 		session_start();
77 81
 
78 82
 		// Change it so the cache settings are a little looser than default.
79
-		if (!empty($modSettings['databaseSession_loose']))
80
-			header('Cache-Control: private');
83
+		if (!empty($modSettings['databaseSession_loose'])) {
84
+					header('Cache-Control: private');
85
+		}
81 86
 	}
82 87
 
83 88
 	// Set the randomly generated code.
@@ -123,8 +128,9 @@  discard block
 block discarded – undo
123 128
 {
124 129
 	global $smcFunc;
125 130
 
126
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
127
-		return '';
131
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
132
+			return '';
133
+	}
128 134
 
129 135
 	// Look for it in the database.
130 136
 	$result = $smcFunc['db_query']('', '
@@ -153,8 +159,9 @@  discard block
 block discarded – undo
153 159
 {
154 160
 	global $smcFunc;
155 161
 
156
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
157
-		return false;
162
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
163
+			return false;
164
+	}
158 165
 
159 166
 	// First try to update an existing row...
160 167
 	$result = $smcFunc['db_query']('', '
@@ -169,13 +176,14 @@  discard block
 block discarded – undo
169 176
 	);
170 177
 
171 178
 	// If that didn't work, try inserting a new one.
172
-	if ($smcFunc['db_affected_rows']() == 0)
173
-		$result = $smcFunc['db_insert']('ignore',
179
+	if ($smcFunc['db_affected_rows']() == 0) {
180
+			$result = $smcFunc['db_insert']('ignore',
174 181
 			'{db_prefix}sessions',
175 182
 			array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'),
176 183
 			array($session_id, $data, time()),
177 184
 			array('session_id')
178 185
 		);
186
+	}
179 187
 
180 188
 	return ($smcFunc['db_affected_rows']() == 0 ? false : true);
181 189
 }
@@ -190,8 +198,9 @@  discard block
 block discarded – undo
190 198
 {
191 199
 	global $smcFunc;
192 200
 
193
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
194
-		return false;
201
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
202
+			return false;
203
+	}
195 204
 
196 205
 	// Just delete the row...
197 206
 	$smcFunc['db_query']('', '
@@ -217,8 +226,9 @@  discard block
 block discarded – undo
217 226
 	global $modSettings, $smcFunc;
218 227
 
219 228
 	// Just set to the default or lower?  Ignore it for a higher value. (hopefully)
220
-	if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime))
221
-		$max_lifetime = max($modSettings['databaseSession_lifetime'], 60);
229
+	if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) {
230
+			$max_lifetime = max($modSettings['databaseSession_lifetime'], 60);
231
+	}
222 232
 
223 233
 	// Clean up after yerself ;).
224 234
 	$smcFunc['db_query']('', '
Please login to merge, or discard this patch.
Sources/MoveTopic.php 1 patch
Braces   +100 added lines, -72 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * This function allows to move a topic, making sure to ask the moderator
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 {
33 34
 	global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir;
34 35
 
35
-	if (empty($topic))
36
-		fatal_lang_error('no_access', false);
36
+	if (empty($topic)) {
37
+			fatal_lang_error('no_access', false);
38
+	}
37 39
 
38 40
 	$request = $smcFunc['db_query']('', '
39 41
 		SELECT t.id_member_started, ms.subject, t.approved
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
 	$smcFunc['db_free_result']($request);
50 52
 
51 53
 	// Can they see it - if not approved?
52
-	if ($modSettings['postmod_active'] && !$context['is_approved'])
53
-		isAllowedTo('approve_posts');
54
+	if ($modSettings['postmod_active'] && !$context['is_approved']) {
55
+			isAllowedTo('approve_posts');
56
+	}
54 57
 
55 58
 	// Permission check!
56 59
 	// @todo
@@ -59,9 +62,9 @@  discard block
 block discarded – undo
59 62
 		if ($id_member_started == $user_info['id'])
60 63
 		{
61 64
 			isAllowedTo('move_own');
65
+		} else {
66
+					isAllowedTo('move_any');
62 67
 		}
63
-		else
64
-			isAllowedTo('move_any');
65 68
 	}
66 69
 
67 70
 	$context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any'];
@@ -83,11 +86,13 @@  discard block
 block discarded – undo
83 86
 		'not_redirection' => true,
84 87
 	);
85 88
 
86
-	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board)
87
-		$options['selected_board'] = $_SESSION['move_to_topic'];
89
+	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) {
90
+			$options['selected_board'] = $_SESSION['move_to_topic'];
91
+	}
88 92
 
89
-	if (!$context['move_any'])
90
-		$options['included_boards'] = $boards;
93
+	if (!$context['move_any']) {
94
+			$options['included_boards'] = $boards;
95
+	}
91 96
 
92 97
 	require_once($sourcedir . '/Subs-MessageIndex.php');
93 98
 	$context['categories'] = getBoardList($options);
@@ -138,12 +143,14 @@  discard block
 block discarded – undo
138 143
 	global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context;
139 144
 	global $board, $language, $user_info, $smcFunc;
140 145
 
141
-	if (empty($topic))
142
-		fatal_lang_error('no_access', false);
146
+	if (empty($topic)) {
147
+			fatal_lang_error('no_access', false);
148
+	}
143 149
 
144 150
 	// You can't choose to have a redirection topic and use an empty reason.
145
-	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == ''))
146
-		fatal_lang_error('movetopic_no_reason', false);
151
+	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) {
152
+			fatal_lang_error('movetopic_no_reason', false);
153
+	}
147 154
 
148 155
 	moveTopicConcurrence();
149 156
 
@@ -163,8 +170,9 @@  discard block
 block discarded – undo
163 170
 	$smcFunc['db_free_result']($request);
164 171
 
165 172
 	// Can they see it?
166
-	if (!$context['is_approved'])
167
-		isAllowedTo('approve_posts');
173
+	if (!$context['is_approved']) {
174
+			isAllowedTo('approve_posts');
175
+	}
168 176
 
169 177
 	// Can they move topics on this board?
170 178
 	if (!allowedTo('move_any'))
@@ -173,12 +181,12 @@  discard block
 block discarded – undo
173 181
 		{
174 182
 			isAllowedTo('move_own');
175 183
 			$boards = array_merge(boardsAllowedTo('move_own'), boardsAllowedTo('move_any'));
184
+		} else {
185
+					isAllowedTo('move_any');
176 186
 		}
177
-		else
178
-			isAllowedTo('move_any');
187
+	} else {
188
+			$boards = boardsAllowedTo('move_any');
179 189
 	}
180
-	else
181
-		$boards = boardsAllowedTo('move_any');
182 190
 
183 191
 	// If this topic isn't approved don't let them move it if they can't approve it!
184 192
 	if ($modSettings['postmod_active'] && !$context['is_approved'] && !allowedTo('approve_posts'))
@@ -210,8 +218,9 @@  discard block
 block discarded – undo
210 218
 			'blank_redirect' => '',
211 219
 		)
212 220
 	);
213
-	if ($smcFunc['db_num_rows']($request) == 0)
214
-		fatal_lang_error('no_board');
221
+	if ($smcFunc['db_num_rows']($request) == 0) {
222
+			fatal_lang_error('no_board');
223
+	}
215 224
 	list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request);
216 225
 	$smcFunc['db_free_result']($request);
217 226
 
@@ -223,8 +232,9 @@  discard block
 block discarded – undo
223 232
 	{
224 233
 		$_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
225 234
 		// Keep checking the length.
226
-		if ($smcFunc['strlen']($_POST['custom_subject']) > 100)
227
-			$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
235
+		if ($smcFunc['strlen']($_POST['custom_subject']) > 100) {
236
+					$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
237
+		}
228 238
 
229 239
 		// If it's still valid move onwards and upwards.
230 240
 		if ($_POST['custom_subject'] != '')
@@ -234,9 +244,9 @@  discard block
 block discarded – undo
234 244
 				// Get a response prefix, but in the forum's default language.
235 245
 				if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
236 246
 				{
237
-					if ($language === $user_info['language'])
238
-						$context['response_prefix'] = $txt['response_prefix'];
239
-					else
247
+					if ($language === $user_info['language']) {
248
+											$context['response_prefix'] = $txt['response_prefix'];
249
+					} else
240 250
 					{
241 251
 						loadLanguage('index', $language, false);
242 252
 						$context['response_prefix'] = $txt['response_prefix'];
@@ -276,8 +286,9 @@  discard block
 block discarded – undo
276 286
 	if (isset($_POST['postRedirect']))
277 287
 	{
278 288
 		// Should be in the boardwide language.
279
-		if ($user_info['language'] != $language)
280
-			loadLanguage('index', $language);
289
+		if ($user_info['language'] != $language) {
290
+					loadLanguage('index', $language);
291
+		}
281 292
 
282 293
 		$_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES);
283 294
 		preparsecode($_POST['reason']);
@@ -341,8 +352,9 @@  discard block
 block discarded – undo
341 352
 		$posters = array();
342 353
 		while ($row = $smcFunc['db_fetch_assoc']($request))
343 354
 		{
344
-			if (!isset($posters[$row['id_member']]))
345
-				$posters[$row['id_member']] = 0;
355
+			if (!isset($posters[$row['id_member']])) {
356
+							$posters[$row['id_member']] = 0;
357
+			}
346 358
 
347 359
 			$posters[$row['id_member']]++;
348 360
 		}
@@ -351,11 +363,13 @@  discard block
 block discarded – undo
351 363
 		foreach ($posters as $id_member => $posts)
352 364
 		{
353 365
 			// The board we're moving from counted posts, but not to.
354
-			if (empty($pcounter_from))
355
-				updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
366
+			if (empty($pcounter_from)) {
367
+							updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
368
+			}
356 369
 			// The reverse: from didn't, to did.
357
-			else
358
-				updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
370
+			else {
371
+							updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
372
+			}
359 373
 		}
360 374
 	}
361 375
 
@@ -363,17 +377,19 @@  discard block
 block discarded – undo
363 377
 	moveTopics($topic, $_POST['toboard']);
364 378
 
365 379
 	// Log that they moved this topic.
366
-	if (!allowedTo('move_own') || $id_member_started != $user_info['id'])
367
-		logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
380
+	if (!allowedTo('move_own') || $id_member_started != $user_info['id']) {
381
+			logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
382
+	}
368 383
 	// Notify people that this topic has been moved?
369 384
 	sendNotifications($topic, 'move');
370 385
 
371 386
 	// Why not go back to the original board in case they want to keep moving?
372
-	if (!isset($_REQUEST['goback']))
373
-		redirectexit('board=' . $board . '.0');
374
-	else
375
-		redirectexit('topic=' . $topic . '.0');
376
-}
387
+	if (!isset($_REQUEST['goback'])) {
388
+			redirectexit('board=' . $board . '.0');
389
+	} else {
390
+			redirectexit('topic=' . $topic . '.0');
391
+	}
392
+	}
377 393
 
378 394
 /**
379 395
  * Moves one or more topics to a specific board. (doesn't check permissions.)
@@ -389,18 +405,21 @@  discard block
 block discarded – undo
389 405
 	global $sourcedir, $user_info, $modSettings, $smcFunc;
390 406
 
391 407
 	// Empty array?
392
-	if (empty($topics))
393
-		return;
408
+	if (empty($topics)) {
409
+			return;
410
+	}
394 411
 
395 412
 	// Only a single topic.
396
-	if (is_numeric($topics))
397
-		$topics = array($topics);
413
+	if (is_numeric($topics)) {
414
+			$topics = array($topics);
415
+	}
398 416
 	$num_topics = count($topics);
399 417
 	$fromBoards = array();
400 418
 
401 419
 	// Destination board empty or equal to 0?
402
-	if (empty($toBoard))
403
-		return;
420
+	if (empty($toBoard)) {
421
+			return;
422
+	}
404 423
 
405 424
 	// Are we moving to the recycle board?
406 425
 	$isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard;
@@ -408,8 +427,9 @@  discard block
 block discarded – undo
408 427
 	// Callback for search APIs to do their thing
409 428
 	require_once($sourcedir . '/Search.php');
410 429
 	$searchAPI = findSearchAPI();
411
-	if ($searchAPI->supportsMethod('topicsMoved'))
412
-		$searchAPI->topicsMoved($topics, $toBoard);
430
+	if ($searchAPI->supportsMethod('topicsMoved')) {
431
+			$searchAPI->topicsMoved($topics, $toBoard);
432
+	}
413 433
 
414 434
 	// Determine the source boards...
415 435
 	$request = $smcFunc['db_query']('', '
@@ -423,8 +443,9 @@  discard block
 block discarded – undo
423 443
 		)
424 444
 	);
425 445
 	// Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards.
426
-	if ($smcFunc['db_num_rows']($request) == 0)
427
-		return;
446
+	if ($smcFunc['db_num_rows']($request) == 0) {
447
+			return;
448
+	}
428 449
 	while ($row = $smcFunc['db_fetch_assoc']($request))
429 450
 	{
430 451
 		if (!isset($fromBoards[$row['id_board']]['num_posts']))
@@ -442,10 +463,11 @@  discard block
 block discarded – undo
442 463
 		$fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts'];
443 464
 
444 465
 		// Add the topics to the right type.
445
-		if ($row['approved'])
446
-			$fromBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
447
-		else
448
-			$fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
466
+		if ($row['approved']) {
467
+					$fromBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
468
+		} else {
469
+					$fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
470
+		}
449 471
 	}
450 472
 	$smcFunc['db_free_result']($request);
451 473
 
@@ -571,13 +593,14 @@  discard block
 block discarded – undo
571 593
 			)
572 594
 		);
573 595
 		$approval_msgs = array();
574
-		while ($row = $smcFunc['db_fetch_assoc']($request))
575
-			$approval_msgs[] = $row['id_msg'];
596
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
597
+					$approval_msgs[] = $row['id_msg'];
598
+		}
576 599
 		$smcFunc['db_free_result']($request);
577 600
 
578 601
 		// Empty the approval queue for these, as we're going to approve them next.
579
-		if (!empty($approval_msgs))
580
-			$smcFunc['db_query']('', '
602
+		if (!empty($approval_msgs)) {
603
+					$smcFunc['db_query']('', '
581 604
 				DELETE FROM {db_prefix}approval_queue
582 605
 				WHERE id_msg IN ({array_int:message_list})
583 606
 					AND id_attach = {int:id_attach}',
@@ -586,6 +609,7 @@  discard block
 block discarded – undo
586 609
 					'id_attach' => 0,
587 610
 				)
588 611
 			);
612
+		}
589 613
 
590 614
 		// Get all the current max and mins.
591 615
 		$request = $smcFunc['db_query']('', '
@@ -619,8 +643,8 @@  discard block
 block discarded – undo
619 643
 		while ($row = $smcFunc['db_fetch_assoc']($request))
620 644
 		{
621 645
 			// If not, update.
622
-			if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max'])
623
-				$smcFunc['db_query']('', '
646
+			if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) {
647
+							$smcFunc['db_query']('', '
624 648
 					UPDATE {db_prefix}topics
625 649
 					SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg}
626 650
 					WHERE id_topic = {int:selected_topic}',
@@ -630,6 +654,7 @@  discard block
 block discarded – undo
630 654
 						'selected_topic' => $row['id_topic'],
631 655
 					)
632 656
 				);
657
+			}
633 658
 		}
634 659
 		$smcFunc['db_free_result']($request);
635 660
 	}
@@ -688,9 +713,10 @@  discard block
 block discarded – undo
688 713
 	}
689 714
 
690 715
 	// Update the cache?
691
-	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
692
-		foreach ($topics as $topic_id)
716
+	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) {
717
+			foreach ($topics as $topic_id)
693 718
 			cache_put_data('topic_board-' . $topic_id, null, 120);
719
+	}
694 720
 
695 721
 	require_once($sourcedir . '/Subs-Post.php');
696 722
 
@@ -714,15 +740,17 @@  discard block
 block discarded – undo
714 740
 {
715 741
 	global $board, $topic, $smcFunc, $scripturl;
716 742
 
717
-	if (isset($_GET['current_board']))
718
-		$move_from = (int) $_GET['current_board'];
743
+	if (isset($_GET['current_board'])) {
744
+			$move_from = (int) $_GET['current_board'];
745
+	}
719 746
 
720
-	if (empty($move_from) || empty($board) || empty($topic))
721
-		return true;
747
+	if (empty($move_from) || empty($board) || empty($topic)) {
748
+			return true;
749
+	}
722 750
 
723
-	if ($move_from == $board)
724
-		return true;
725
-	else
751
+	if ($move_from == $board) {
752
+			return true;
753
+	} else
726 754
 	{
727 755
 		$request = $smcFunc['db_query']('', '
728 756
 			SELECT m.subject, b.name
Please login to merge, or discard this patch.
Sources/Subs-MessageIndex.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Generates the query to determine the list of available boards for a user
@@ -25,8 +26,9 @@  discard block
 block discarded – undo
25 26
 {
26 27
 	global $smcFunc, $sourcedir;
27 28
 
28
-	if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards']))
29
-		trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR);
29
+	if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) {
30
+			trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR);
31
+	}
30 32
 
31 33
 	$where = array();
32 34
 	$where_parameters = array();
@@ -42,11 +44,11 @@  discard block
 block discarded – undo
42 44
 		$where_parameters['included_boards'] = $boardListOptions['included_boards'];
43 45
 	}
44 46
 
45
-	if (!empty($boardListOptions['ignore_boards']))
46
-		$where[] = '{query_wanna_see_board}';
47
-
48
-	elseif (!empty($boardListOptions['use_permissions']))
49
-		$where[] = '{query_see_board}';
47
+	if (!empty($boardListOptions['ignore_boards'])) {
48
+			$where[] = '{query_wanna_see_board}';
49
+	} elseif (!empty($boardListOptions['use_permissions'])) {
50
+			$where[] = '{query_see_board}';
51
+	}
50 52
 
51 53
 	if (!empty($boardListOptions['not_redirection']))
52 54
 	{
@@ -68,12 +70,13 @@  discard block
 block discarded – undo
68 70
 	{
69 71
 		while ($row = $smcFunc['db_fetch_assoc']($request))
70 72
 		{
71
-			if (!isset($return_value[$row['id_cat']]))
72
-				$return_value[$row['id_cat']] = array(
73
+			if (!isset($return_value[$row['id_cat']])) {
74
+							$return_value[$row['id_cat']] = array(
73 75
 					'id' => $row['id_cat'],
74 76
 					'name' => $row['cat_name'],
75 77
 					'boards' => array(),
76 78
 				);
79
+			}
77 80
 
78 81
 			$return_value[$row['id_cat']]['boards'][$row['id_board']] = array(
79 82
 				'id' => $row['id_board'],
Please login to merge, or discard this patch.
Sources/DbSearch-postgresql.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	$version = $smcFunc['db_get_version']();
38 38
 	// if we got a Beta Version
39 39
 	if (stripos($version, 'beta') !== false)
40
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
40
+		$version = substr($version, 0, stripos($version, 'beta')) . '.0';
41 41
 	// or RC
42 42
 	if (stripos($version, 'rc') !== false)
43
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
43
+		$version = substr($version, 0, stripos($version, 'rc')) . '.0';
44 44
 
45
-	if (version_compare($version,'9.5.0','>='))
45
+	if (version_compare($version, '9.5.0', '>='))
46 46
 		$smcFunc['db_support_ignore'] = true;
47 47
 }
48 48
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function smf_db_search_support($search_type)
56 56
 {
57
-	$supported_types = array('custom','fulltext');
57
+	$supported_types = array('custom', 'fulltext');
58 58
 
59 59
 	return in_array($search_type, $supported_types);
60 60
 }
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
109 109
 	{
110 110
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
111
-		if ($smcFunc['db_support_ignore']){
111
+		if ($smcFunc['db_support_ignore']) {
112 112
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
113
-			$db_string = $db_string.' ON CONFLICT DO NOTHING';
113
+			$db_string = $db_string . ' ON CONFLICT DO NOTHING';
114 114
 		}
115 115
 		else
116 116
 		{
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Add the file functions to the $smcFunc array.
@@ -23,28 +24,32 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_search_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => false,
32 33
 		);
34
+	}
33 35
 
34 36
 	db_extend();
35 37
 
36 38
 	//pg 9.5 got ignore support
37 39
 	$version = $smcFunc['db_get_version']();
38 40
 	// if we got a Beta Version
39
-	if (stripos($version, 'beta') !== false)
40
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
41
+	if (stripos($version, 'beta') !== false) {
42
+			$version = substr($version, 0, stripos($version, 'beta')).'.0';
43
+	}
41 44
 	// or RC
42
-	if (stripos($version, 'rc') !== false)
43
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
45
+	if (stripos($version, 'rc') !== false) {
46
+			$version = substr($version, 0, stripos($version, 'rc')).'.0';
47
+	}
44 48
 
45
-	if (version_compare($version,'9.5.0','>='))
46
-		$smcFunc['db_support_ignore'] = true;
47
-}
49
+	if (version_compare($version,'9.5.0','>=')) {
50
+			$smcFunc['db_support_ignore'] = true;
51
+	}
52
+	}
48 53
 
49 54
 /**
50 55
  * This function will tell you whether this database type supports this search type.
@@ -103,16 +108,16 @@  discard block
 block discarded – undo
103 108
 		),
104 109
 	);
105 110
 
106
-	if (isset($replacements[$identifier]))
107
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
111
+	if (isset($replacements[$identifier])) {
112
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
113
+	}
108 114
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
109 115
 	{
110 116
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
111 117
 		if ($smcFunc['db_support_ignore']){
112 118
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
113 119
 			$db_string = $db_string.' ON CONFLICT DO NOTHING';
114
-		}
115
-		else
120
+		} else
116 121
 		{
117 122
 			// Don't error on multi-insert.
118 123
 			$db_values['db_error_skip'] = true;
Please login to merge, or discard this patch.
Sources/ManageSettings.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 					'class' => 'centercol',
1324 1324
 				),
1325 1325
 				'data' => array(
1326
-					'function' => function ($rowData)
1326
+					'function' => function($rowData)
1327 1327
 					{
1328 1328
 						$isChecked = $rowData['disabled'] ? '' : ' checked';
1329 1329
 						$onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : '';
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 					'class' => 'centercol',
1340 1340
 				),
1341 1341
 				'data' => array(
1342
-					'function' => function ($rowData)
1342
+					'function' => function($rowData)
1343 1343
 					{
1344 1344
 						$isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : '';
1345 1345
 						$isDisabled = $rowData['can_show_register'] ? '' : ' disabled';
@@ -1386,15 +1386,15 @@  discard block
 block discarded – undo
1386 1386
 					'value' => $txt['custom_profile_fieldorder'],
1387 1387
 				),
1388 1388
 				'data' => array(
1389
-					'function' => function ($rowData) use ($context, $txt, $scripturl)
1389
+					'function' => function($rowData) use ($context, $txt, $scripturl)
1390 1390
 					{
1391
-						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />';
1391
+						$return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br />';
1392 1392
 
1393 1393
 						if ($rowData['field_order'] > 1)
1394
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1394
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>';
1395 1395
 
1396 1396
 						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1397
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1397
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>';
1398 1398
 
1399 1399
 						$return .= '</p>';
1400 1400
 
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 					'value' => $txt['custom_profile_fieldname'],
1413 1413
 				),
1414 1414
 				'data' => array(
1415
-					'function' => function ($rowData) use ($scripturl)
1415
+					'function' => function($rowData) use ($scripturl)
1416 1416
 					{
1417 1417
 						return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']);
1418 1418
 					},
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 					'value' => $txt['custom_profile_fieldtype'],
1429 1429
 				),
1430 1430
 				'data' => array(
1431
-					'function' => function ($rowData) use ($txt)
1431
+					'function' => function($rowData) use ($txt)
1432 1432
 					{
1433 1433
 						$textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']);
1434 1434
 						return isset($txt[$textKey]) ? $txt[$textKey] : $textKey;
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
 					'value' => $txt['custom_profile_active'],
1447 1447
 				),
1448 1448
 				'data' => array(
1449
-					'function' => function ($rowData) use ($txt)
1449
+					'function' => function($rowData) use ($txt)
1450 1450
 					{
1451 1451
 						return $rowData['active'] ? $txt['yes'] : $txt['no'];
1452 1452
 					},
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
 					'value' => $txt['custom_profile_placement'],
1464 1464
 				),
1465 1465
 				'data' => array(
1466
-					'function' => function ($rowData)
1466
+					'function' => function($rowData)
1467 1467
 					{
1468 1468
 						global $txt, $context;
1469 1469
 
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1699 1699
 
1700 1700
 		// All good, proceed.
1701
-		$smcFunc['db_query']('','
1701
+		$smcFunc['db_query']('', '
1702 1702
 			UPDATE {db_prefix}custom_fields
1703 1703
 			SET field_order = {int:old_order}
1704 1704
 			WHERE field_order = {int:new_order}',
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 				'old_order' => $context['field']['order'],
1708 1708
 			)
1709 1709
 		);
1710
-		$smcFunc['db_query']('','
1710
+		$smcFunc['db_query']('', '
1711 1711
 			UPDATE {db_prefix}custom_fields
1712 1712
 			SET field_order = {int:new_order}
1713 1713
 			WHERE id_field = {int:id_field}',
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
 			$smcFunc['db_free_result']($request);
1810 1810
 
1811 1811
 			$unique = false;
1812
-			for ($i = 0; !$unique && $i < 9; $i ++)
1812
+			for ($i = 0; !$unique && $i < 9; $i++)
1813 1813
 			{
1814 1814
 				if (!in_array($col_name, $current_fields))
1815 1815
 					$unique = true;
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 		);
1983 1983
 
1984 1984
 		// Re-arrange the order.
1985
-		$smcFunc['db_query']('','
1985
+		$smcFunc['db_query']('', '
1986 1986
 			UPDATE {db_prefix}custom_fields
1987 1987
 			SET field_order = field_order - 1
1988 1988
 			WHERE field_order > {int:current_order}',
@@ -2246,7 +2246,7 @@  discard block
 block discarded – undo
2246 2246
 	$context['token_check'] = 'noti-admin';
2247 2247
 
2248 2248
 	// Specify our action since we'll want to post back here instead of the profile
2249
-	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id'];
2249
+	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id'];
2250 2250
 
2251 2251
 	loadTemplate('Profile');
2252 2252
 	loadLanguage('Profile');
Please login to merge, or discard this patch.
Braces   +273 added lines, -199 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or.
@@ -202,16 +203,18 @@  discard block
 block discarded – undo
202 203
 	{
203 204
 		$all_zones = timezone_identifiers_list();
204 205
 		// Make sure we set the value to the same as the printed value.
205
-		foreach ($all_zones as $zone)
206
-			$config_vars['default_timezone'][2][$zone] = $zone;
206
+		foreach ($all_zones as $zone) {
207
+					$config_vars['default_timezone'][2][$zone] = $zone;
208
+		}
209
+	} else {
210
+			unset($config_vars['default_timezone']);
207 211
 	}
208
-	else
209
-		unset($config_vars['default_timezone']);
210 212
 
211 213
 	call_integration_hook('integrate_modify_basic_settings', array(&$config_vars));
212 214
 
213
-	if ($return_config)
214
-		return $config_vars;
215
+	if ($return_config) {
216
+			return $config_vars;
217
+	}
215 218
 
216 219
 	// Saving?
217 220
 	if (isset($_GET['save']))
@@ -219,8 +222,9 @@  discard block
 block discarded – undo
219 222
 		checkSession();
220 223
 
221 224
 		// Prevent absurd boundaries here - make it a day tops.
222
-		if (isset($_POST['lastActive']))
223
-			$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
225
+		if (isset($_POST['lastActive'])) {
226
+					$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
227
+		}
224 228
 
225 229
 		call_integration_hook('integrate_save_basic_settings');
226 230
 
@@ -265,8 +269,9 @@  discard block
 block discarded – undo
265 269
 
266 270
 	call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars));
267 271
 
268
-	if ($return_config)
269
-		return $config_vars;
272
+	if ($return_config) {
273
+			return $config_vars;
274
+	}
270 275
 
271 276
 	// Setup the template.
272 277
 	require_once($sourcedir . '/ManageServer.php');
@@ -283,13 +288,15 @@  discard block
 block discarded – undo
283 288
 
284 289
 		// Clean up the tags.
285 290
 		$bbcTags = array();
286
-		foreach (parse_bbc(false) as $tag)
287
-			$bbcTags[] = $tag['tag'];
291
+		foreach (parse_bbc(false) as $tag) {
292
+					$bbcTags[] = $tag['tag'];
293
+		}
288 294
 
289
-		if (!isset($_POST['disabledBBC_enabledTags']))
290
-			$_POST['disabledBBC_enabledTags'] = array();
291
-		elseif (!is_array($_POST['disabledBBC_enabledTags']))
292
-			$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
295
+		if (!isset($_POST['disabledBBC_enabledTags'])) {
296
+					$_POST['disabledBBC_enabledTags'] = array();
297
+		} elseif (!is_array($_POST['disabledBBC_enabledTags'])) {
298
+					$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
299
+		}
293 300
 		// Work out what is actually disabled!
294 301
 		$_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
295 302
 
@@ -333,8 +340,9 @@  discard block
 block discarded – undo
333 340
 
334 341
 	call_integration_hook('integrate_layout_settings', array(&$config_vars));
335 342
 
336
-	if ($return_config)
337
-		return $config_vars;
343
+	if ($return_config) {
344
+			return $config_vars;
345
+	}
338 346
 
339 347
 	// Saving?
340 348
 	if (isset($_GET['save']))
@@ -375,8 +383,9 @@  discard block
 block discarded – undo
375 383
 
376 384
 	call_integration_hook('integrate_likes_settings', array(&$config_vars));
377 385
 
378
-	if ($return_config)
379
-		return $config_vars;
386
+	if ($return_config) {
387
+			return $config_vars;
388
+	}
380 389
 
381 390
 	// Saving?
382 391
 	if (isset($_GET['save']))
@@ -414,8 +423,9 @@  discard block
 block discarded – undo
414 423
 
415 424
 	call_integration_hook('integrate_mentions_settings', array(&$config_vars));
416 425
 
417
-	if ($return_config)
418
-		return $config_vars;
426
+	if ($return_config) {
427
+			return $config_vars;
428
+	}
419 429
 
420 430
 	// Saving?
421 431
 	if (isset($_GET['save']))
@@ -459,8 +469,8 @@  discard block
 block discarded – undo
459 469
 			'enable' => array('check', 'warning_enable'),
460 470
 	);
461 471
 
462
-	if (!empty($modSettings['warning_settings']) && $currently_enabled)
463
-		$config_vars += array(
472
+	if (!empty($modSettings['warning_settings']) && $currently_enabled) {
473
+			$config_vars += array(
464 474
 			'',
465 475
 				array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']),
466 476
 				'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']),
@@ -469,15 +479,18 @@  discard block
 block discarded – undo
469 479
 				'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']),
470 480
 				array('permissions', 'view_warning'),
471 481
 		);
482
+	}
472 483
 
473 484
 	call_integration_hook('integrate_warning_settings', array(&$config_vars));
474 485
 
475
-	if ($return_config)
476
-		return $config_vars;
486
+	if ($return_config) {
487
+			return $config_vars;
488
+	}
477 489
 
478 490
 	// Cannot use moderation if post moderation is not enabled.
479
-	if (!$modSettings['postmod_active'])
480
-		unset($config_vars['moderate']);
491
+	if (!$modSettings['postmod_active']) {
492
+			unset($config_vars['moderate']);
493
+	}
481 494
 
482 495
 	// Will need the utility functions from here.
483 496
 	require_once($sourcedir . '/ManageServer.php');
@@ -502,16 +515,16 @@  discard block
 block discarded – undo
502 515
 				'warning_watch' => 10,
503 516
 				'warning_mute' => 60,
504 517
 			);
505
-			if ($modSettings['postmod_active'])
506
-				$vars['warning_moderate'] = 35;
518
+			if ($modSettings['postmod_active']) {
519
+							$vars['warning_moderate'] = 35;
520
+			}
507 521
 
508 522
 			foreach ($vars as $var => $value)
509 523
 			{
510 524
 				$config_vars[] = array('int', $var);
511 525
 				$_POST[$var] = $value;
512 526
 			}
513
-		}
514
-		else
527
+		} else
515 528
 		{
516 529
 			$_POST['warning_watch'] = min($_POST['warning_watch'], 100);
517 530
 			$_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0;
@@ -592,8 +605,9 @@  discard block
 block discarded – undo
592 605
 
593 606
 	call_integration_hook('integrate_spam_settings', array(&$config_vars));
594 607
 
595
-	if ($return_config)
596
-		return $config_vars;
608
+	if ($return_config) {
609
+			return $config_vars;
610
+	}
597 611
 
598 612
 	// You need to be an admin to edit settings!
599 613
 	isAllowedTo('admin_forum');
@@ -627,8 +641,9 @@  discard block
 block discarded – undo
627 641
 
628 642
 	if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers']))
629 643
 	{
630
-		if (empty($context['settings_insert_above']))
631
-			$context['settings_insert_above'] = '';
644
+		if (empty($context['settings_insert_above'])) {
645
+					$context['settings_insert_above'] = '';
646
+		}
632 647
 
633 648
 		$context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>';
634 649
 	}
@@ -671,8 +686,9 @@  discard block
 block discarded – undo
671 686
 		$_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
672 687
 
673 688
 		// Hack in guest requiring verification!
674
-		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha']))
675
-			$_POST['posts_require_captcha'] = -1;
689
+		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) {
690
+					$_POST['posts_require_captcha'] = -1;
691
+		}
676 692
 
677 693
 		$save_vars = $config_vars;
678 694
 		unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']);
@@ -689,14 +705,16 @@  discard block
 block discarded – undo
689 705
 		foreach ($context['qa_languages'] as $lang_id => $dummy)
690 706
 		{
691 707
 			// If we had some questions for this language before, but don't now, delete everything from that language.
692
-			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id]))
693
-				$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
708
+			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) {
709
+							$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
710
+			}
694 711
 
695 712
 			// Now step through and see if any existing questions no longer exist.
696
-			if (!empty($context['qa_by_lang'][$lang_id]))
697
-				foreach ($context['qa_by_lang'][$lang_id] as $q_id)
713
+			if (!empty($context['qa_by_lang'][$lang_id])) {
714
+							foreach ($context['qa_by_lang'][$lang_id] as $q_id)
698 715
 					if (empty($_POST['question'][$lang_id][$q_id]))
699 716
 						$changes['delete'][] = $q_id;
717
+			}
700 718
 
701 719
 			// Now let's see if there are new questions or ones that need updating.
702 720
 			if (isset($_POST['question'][$lang_id]))
@@ -705,14 +723,16 @@  discard block
 block discarded – undo
705 723
 				{
706 724
 					// Ignore junky ids.
707 725
 					$q_id = (int) $q_id;
708
-					if ($q_id <= 0)
709
-						continue;
726
+					if ($q_id <= 0) {
727
+											continue;
728
+					}
710 729
 
711 730
 					// Check the question isn't empty (because they want to delete it?)
712 731
 					if (empty($question) || trim($question) == '')
713 732
 					{
714
-						if (isset($context['question_answers'][$q_id]))
715
-							$changes['delete'][] = $q_id;
733
+						if (isset($context['question_answers'][$q_id])) {
734
+													$changes['delete'][] = $q_id;
735
+						}
716 736
 						continue;
717 737
 					}
718 738
 					$question = $smcFunc['htmlspecialchars'](trim($question));
@@ -720,19 +740,22 @@  discard block
 block discarded – undo
720 740
 					// Get the answers. Firstly check there actually might be some.
721 741
 					if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id]))
722 742
 					{
723
-						if (isset($context['question_answers'][$q_id]))
724
-							$changes['delete'][] = $q_id;
743
+						if (isset($context['question_answers'][$q_id])) {
744
+													$changes['delete'][] = $q_id;
745
+						}
725 746
 						continue;
726 747
 					}
727 748
 					// Now get them and check that they might be viable.
728 749
 					$answers = array();
729
-					foreach ($_POST['answer'][$lang_id][$q_id] as $answer)
730
-						if (!empty($answer) && trim($answer) !== '')
750
+					foreach ($_POST['answer'][$lang_id][$q_id] as $answer) {
751
+											if (!empty($answer) && trim($answer) !== '')
731 752
 							$answers[] = $smcFunc['htmlspecialchars'](trim($answer));
753
+					}
732 754
 					if (empty($answers))
733 755
 					{
734
-						if (isset($context['question_answers'][$q_id]))
735
-							$changes['delete'][] = $q_id;
756
+						if (isset($context['question_answers'][$q_id])) {
757
+													$changes['delete'][] = $q_id;
758
+						}
736 759
 						continue;
737 760
 					}
738 761
 					$answers = json_encode($answers);
@@ -742,16 +765,17 @@  discard block
 block discarded – undo
742 765
 					{
743 766
 						// New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids.
744 767
 						$changes['insert'][] = array($lang_id, $question, $answers);
745
-					}
746
-					else
768
+					} else
747 769
 					{
748 770
 						// It's an existing question. Let's see what's changed, if anything.
749
-						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers'])
750
-							$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
771
+						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) {
772
+													$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
773
+						}
751 774
 					}
752 775
 
753
-					if (!isset($qs_per_lang[$lang_id]))
754
-						$qs_per_lang[$lang_id] = 0;
776
+					if (!isset($qs_per_lang[$lang_id])) {
777
+											$qs_per_lang[$lang_id] = 0;
778
+					}
755 779
 					$qs_per_lang[$lang_id]++;
756 780
 				}
757 781
 			}
@@ -801,8 +825,9 @@  discard block
 block discarded – undo
801 825
 
802 826
 		// Lastly, the count of messages needs to be no more than the lowest number of questions for any one language.
803 827
 		$count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang);
804
-		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions)
805
-			$_POST['qa_verification_number'] = $count_questions;
828
+		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) {
829
+					$_POST['qa_verification_number'] = $count_questions;
830
+		}
806 831
 
807 832
 		call_integration_hook('integrate_save_spam_settings', array(&$save_vars));
808 833
 
@@ -817,24 +842,27 @@  discard block
 block discarded – undo
817 842
 
818 843
 	$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
819 844
 	$_SESSION['visual_verification_code'] = '';
820
-	for ($i = 0; $i < 6; $i++)
821
-		$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
845
+	for ($i = 0; $i < 6; $i++) {
846
+			$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
847
+	}
822 848
 
823 849
 	// Some javascript for CAPTCHA.
824 850
 	$context['settings_post_javascript'] = '';
825
-	if ($context['use_graphic_library'])
826
-		$context['settings_post_javascript'] .= '
851
+	if ($context['use_graphic_library']) {
852
+			$context['settings_post_javascript'] .= '
827 853
 		function refreshImages()
828 854
 		{
829 855
 			var imageType = document.getElementById(\'visual_verification_type\').value;
830 856
 			document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType;
831 857
 		}';
858
+	}
832 859
 
833 860
 	// Show the image itself, or text saying we can't.
834
-	if ($context['use_graphic_library'])
835
-		$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
836
-	else
837
-		$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
861
+	if ($context['use_graphic_library']) {
862
+			$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
863
+	} else {
864
+			$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
865
+	}
838 866
 
839 867
 	// Hack for PM spam settings.
840 868
 	list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
@@ -844,9 +872,10 @@  discard block
 block discarded – undo
844 872
 	$modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha'];
845 873
 
846 874
 	// Some minor javascript for the guest post setting.
847
-	if ($modSettings['posts_require_captcha'])
848
-		$context['settings_post_javascript'] .= '
875
+	if ($modSettings['posts_require_captcha']) {
876
+			$context['settings_post_javascript'] .= '
849 877
 		document.getElementById(\'guests_require_captcha\').disabled = true;';
878
+	}
850 879
 
851 880
 	// And everything else.
852 881
 	$context['post_url'] = $scripturl . '?action=admin;area=antispam;save';
@@ -893,8 +922,9 @@  discard block
 block discarded – undo
893 922
 
894 923
 	call_integration_hook('integrate_signature_settings', array(&$config_vars));
895 924
 
896
-	if ($return_config)
897
-		return $config_vars;
925
+	if ($return_config) {
926
+			return $config_vars;
927
+	}
898 928
 
899 929
 	// Setup the template.
900 930
 	$context['page_title'] = $txt['signature_settings'];
@@ -949,8 +979,9 @@  discard block
 block discarded – undo
949 979
 				$sig = strtr($row['signature'], array('<br>' => "\n"));
950 980
 
951 981
 				// Max characters...
952
-				if (!empty($sig_limits[1]))
953
-					$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
982
+				if (!empty($sig_limits[1])) {
983
+									$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
984
+				}
954 985
 				// Max lines...
955 986
 				if (!empty($sig_limits[2]))
956 987
 				{
@@ -960,8 +991,9 @@  discard block
 block discarded – undo
960 991
 						if ($sig[$i] == "\n")
961 992
 						{
962 993
 							$count++;
963
-							if ($count >= $sig_limits[2])
964
-								$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
994
+							if ($count >= $sig_limits[2]) {
995
+															$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
996
+							}
965 997
 						}
966 998
 					}
967 999
 				}
@@ -972,17 +1004,19 @@  discard block
 block discarded – undo
972 1004
 					{
973 1005
 						$limit_broke = 0;
974 1006
 						// Attempt to allow all sizes of abuse, so to speak.
975
-						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
976
-							$limit_broke = $sig_limits[7] . 'px';
977
-						elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
978
-							$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
979
-						elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
980
-							$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
981
-						elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
982
-							$limit_broke = 'large';
983
-
984
-						if ($limit_broke)
985
-							$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1007
+						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
1008
+													$limit_broke = $sig_limits[7] . 'px';
1009
+						} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
1010
+													$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
1011
+						} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
1012
+													$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
1013
+						} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
1014
+													$limit_broke = 'large';
1015
+						}
1016
+
1017
+						if ($limit_broke) {
1018
+													$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1019
+						}
986 1020
 					}
987 1021
 				}
988 1022
 
@@ -1038,32 +1072,34 @@  discard block
 block discarded – undo
1038 1072
 											$img_offset = false;
1039 1073
 										}
1040 1074
 									}
1075
+								} else {
1076
+																	$replaces[$image] = '';
1041 1077
 								}
1042
-								else
1043
-									$replaces[$image] = '';
1044 1078
 
1045 1079
 								continue;
1046 1080
 							}
1047 1081
 
1048 1082
 							// Does it have predefined restraints? Width first.
1049
-							if ($matches[6][$key])
1050
-								$matches[2][$key] = $matches[6][$key];
1083
+							if ($matches[6][$key]) {
1084
+															$matches[2][$key] = $matches[6][$key];
1085
+							}
1051 1086
 							if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
1052 1087
 							{
1053 1088
 								$width = $sig_limits[5];
1054 1089
 								$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
1090
+							} elseif ($matches[2][$key]) {
1091
+															$width = $matches[2][$key];
1055 1092
 							}
1056
-							elseif ($matches[2][$key])
1057
-								$width = $matches[2][$key];
1058 1093
 							// ... and height.
1059 1094
 							if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
1060 1095
 							{
1061 1096
 								$height = $sig_limits[6];
1062
-								if ($width != -1)
1063
-									$width = $width * ($height / $matches[4][$key]);
1097
+								if ($width != -1) {
1098
+																	$width = $width * ($height / $matches[4][$key]);
1099
+								}
1100
+							} elseif ($matches[4][$key]) {
1101
+															$height = $matches[4][$key];
1064 1102
 							}
1065
-							elseif ($matches[4][$key])
1066
-								$height = $matches[4][$key];
1067 1103
 
1068 1104
 							// If the dimensions are still not fixed - we need to check the actual image.
1069 1105
 							if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -1081,12 +1117,13 @@  discard block
 block discarded – undo
1081 1117
 									if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
1082 1118
 									{
1083 1119
 										$height = $sig_limits[6];
1084
-										if ($width == -1)
1085
-											$width = $sizes[0];
1120
+										if ($width == -1) {
1121
+																					$width = $sizes[0];
1122
+										}
1086 1123
 										$width = $width * ($height / $sizes[1]);
1124
+									} elseif ($width != -1) {
1125
+																			$height = $sizes[1];
1087 1126
 									}
1088
-									elseif ($width != -1)
1089
-										$height = $sizes[1];
1090 1127
 								}
1091 1128
 							}
1092 1129
 
@@ -1099,8 +1136,9 @@  discard block
 block discarded – undo
1099 1136
 							// Record that we got one.
1100 1137
 							$image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
1101 1138
 						}
1102
-						if (!empty($replaces))
1103
-							$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1139
+						if (!empty($replaces)) {
1140
+													$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1141
+						}
1104 1142
 					}
1105 1143
 				}
1106 1144
 				// Try to fix disabled tags.
@@ -1112,18 +1150,20 @@  discard block
 block discarded – undo
1112 1150
 
1113 1151
 				$sig = strtr($sig, array("\n" => '<br>'));
1114 1152
 				call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags));
1115
-				if ($sig != $row['signature'])
1116
-					$changes[$row['id_member']] = $sig;
1153
+				if ($sig != $row['signature']) {
1154
+									$changes[$row['id_member']] = $sig;
1155
+				}
1156
+			}
1157
+			if ($smcFunc['db_num_rows']($request) == 0) {
1158
+							$done = true;
1117 1159
 			}
1118
-			if ($smcFunc['db_num_rows']($request) == 0)
1119
-				$done = true;
1120 1160
 			$smcFunc['db_free_result']($request);
1121 1161
 
1122 1162
 			// Do we need to delete what we have?
1123 1163
 			if (!empty($changes))
1124 1164
 			{
1125
-				foreach ($changes as $id => $sig)
1126
-					$smcFunc['db_query']('', '
1165
+				foreach ($changes as $id => $sig) {
1166
+									$smcFunc['db_query']('', '
1127 1167
 						UPDATE {db_prefix}members
1128 1168
 						SET signature = {string:signature}
1129 1169
 						WHERE id_member = {int:id_member}',
@@ -1132,11 +1172,13 @@  discard block
 block discarded – undo
1132 1172
 							'signature' => $sig,
1133 1173
 						)
1134 1174
 					);
1175
+				}
1135 1176
 			}
1136 1177
 
1137 1178
 			$_GET['step'] += 50;
1138
-			if (!$done)
1139
-				pauseSignatureApplySettings();
1179
+			if (!$done) {
1180
+							pauseSignatureApplySettings();
1181
+			}
1140 1182
 		}
1141 1183
 		$settings_applied = true;
1142 1184
 	}
@@ -1154,8 +1196,9 @@  discard block
 block discarded – undo
1154 1196
 	);
1155 1197
 
1156 1198
 	// Temporarily make each setting a modSetting!
1157
-	foreach ($context['signature_settings'] as $key => $value)
1158
-		$modSettings['signature_' . $key] = $value;
1199
+	foreach ($context['signature_settings'] as $key => $value) {
1200
+			$modSettings['signature_' . $key] = $value;
1201
+	}
1159 1202
 
1160 1203
 	// Make sure we check the right tags!
1161 1204
 	$modSettings['bbc_disabled_signature_bbc'] = $disabledTags;
@@ -1167,23 +1210,26 @@  discard block
 block discarded – undo
1167 1210
 
1168 1211
 		// Clean up the tag stuff!
1169 1212
 		$bbcTags = array();
1170
-		foreach (parse_bbc(false) as $tag)
1171
-			$bbcTags[] = $tag['tag'];
1213
+		foreach (parse_bbc(false) as $tag) {
1214
+					$bbcTags[] = $tag['tag'];
1215
+		}
1172 1216
 
1173
-		if (!isset($_POST['signature_bbc_enabledTags']))
1174
-			$_POST['signature_bbc_enabledTags'] = array();
1175
-		elseif (!is_array($_POST['signature_bbc_enabledTags']))
1176
-			$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1217
+		if (!isset($_POST['signature_bbc_enabledTags'])) {
1218
+					$_POST['signature_bbc_enabledTags'] = array();
1219
+		} elseif (!is_array($_POST['signature_bbc_enabledTags'])) {
1220
+					$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1221
+		}
1177 1222
 
1178 1223
 		$sig_limits = array();
1179 1224
 		foreach ($context['signature_settings'] as $key => $value)
1180 1225
 		{
1181
-			if ($key == 'allow_smileys')
1182
-				continue;
1183
-			elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys']))
1184
-				$sig_limits[] = -1;
1185
-			else
1186
-				$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1226
+			if ($key == 'allow_smileys') {
1227
+							continue;
1228
+			} elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) {
1229
+							$sig_limits[] = -1;
1230
+			} else {
1231
+							$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1232
+			}
1187 1233
 		}
1188 1234
 
1189 1235
 		call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags));
@@ -1216,12 +1262,14 @@  discard block
 block discarded – undo
1216 1262
 
1217 1263
 	// Try get more time...
1218 1264
 	@set_time_limit(600);
1219
-	if (function_exists('apache_reset_timeout'))
1220
-		@apache_reset_timeout();
1265
+	if (function_exists('apache_reset_timeout')) {
1266
+			@apache_reset_timeout();
1267
+	}
1221 1268
 
1222 1269
 	// Have we exhausted all the time we allowed?
1223
-	if (time() - array_sum(explode(' ', $sig_start)) < 3)
1224
-		return;
1270
+	if (time() - array_sum(explode(' ', $sig_start)) < 3) {
1271
+			return;
1272
+	}
1225 1273
 
1226 1274
 	$context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1227 1275
 	$context['page_title'] = $txt['not_done_title'];
@@ -1267,9 +1315,10 @@  discard block
 block discarded – undo
1267 1315
 		$disable_fields = array_flip($standard_fields);
1268 1316
 		if (!empty($_POST['active']))
1269 1317
 		{
1270
-			foreach ($_POST['active'] as $value)
1271
-				if (isset($disable_fields[$value]))
1318
+			foreach ($_POST['active'] as $value) {
1319
+							if (isset($disable_fields[$value]))
1272 1320
 					unset($disable_fields[$value]);
1321
+			}
1273 1322
 		}
1274 1323
 		// What we have left!
1275 1324
 		$changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields));
@@ -1278,16 +1327,18 @@  discard block
 block discarded – undo
1278 1327
 		$reg_fields = array();
1279 1328
 		if (!empty($_POST['reg']))
1280 1329
 		{
1281
-			foreach ($_POST['reg'] as $value)
1282
-				if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1330
+			foreach ($_POST['reg'] as $value) {
1331
+							if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1283 1332
 					$reg_fields[] = $value;
1333
+			}
1284 1334
 		}
1285 1335
 		// What we have left!
1286 1336
 		$changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields);
1287 1337
 
1288 1338
 		$_SESSION['adm-save'] = true;
1289
-		if (!empty($changes))
1290
-			updateSettings($changes);
1339
+		if (!empty($changes)) {
1340
+					updateSettings($changes);
1341
+		}
1291 1342
 	}
1292 1343
 
1293 1344
 	createToken('admin-scp');
@@ -1390,11 +1441,13 @@  discard block
 block discarded – undo
1390 1441
 					{
1391 1442
 						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />';
1392 1443
 
1393
-						if ($rowData['field_order'] > 1)
1394
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1444
+						if ($rowData['field_order'] > 1) {
1445
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1446
+						}
1395 1447
 
1396
-						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1397
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1448
+						if ($rowData['field_order'] < $context['custFieldsMaxOrder']) {
1449
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1450
+						}
1398 1451
 
1399 1452
 						$return .= '</p>';
1400 1453
 
@@ -1532,16 +1585,16 @@  discard block
 block discarded – undo
1532 1585
 		$disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
1533 1586
 		$registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
1534 1587
 
1535
-		foreach ($standard_fields as $field)
1536
-			$list[] = array(
1588
+		foreach ($standard_fields as $field) {
1589
+					$list[] = array(
1537 1590
 				'id' => $field,
1538 1591
 				'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field),
1539 1592
 				'disabled' => in_array($field, $disabled_fields),
1540 1593
 				'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration),
1541 1594
 				'can_show_register' => !in_array($field, $fields_no_registration),
1542 1595
 			);
1543
-	}
1544
-	else
1596
+		}
1597
+	} else
1545 1598
 	{
1546 1599
 		// Load all the fields.
1547 1600
 		$request = $smcFunc['db_query']('', '
@@ -1555,8 +1608,9 @@  discard block
 block discarded – undo
1555 1608
 				'items_per_page' => $items_per_page,
1556 1609
 			)
1557 1610
 		);
1558
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1559
-			$list[] = $row;
1611
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1612
+					$list[] = $row;
1613
+		}
1560 1614
 		$smcFunc['db_free_result']($request);
1561 1615
 	}
1562 1616
 
@@ -1622,9 +1676,9 @@  discard block
 block discarded – undo
1622 1676
 		$context['field'] = array();
1623 1677
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1624 1678
 		{
1625
-			if ($row['field_type'] == 'textarea')
1626
-				@list ($rows, $cols) = @explode(',', $row['default_value']);
1627
-			else
1679
+			if ($row['field_type'] == 'textarea') {
1680
+							@list ($rows, $cols) = @explode(',', $row['default_value']);
1681
+			} else
1628 1682
 			{
1629 1683
 				$rows = 3;
1630 1684
 				$cols = 30;
@@ -1660,8 +1714,8 @@  discard block
 block discarded – undo
1660 1714
 	}
1661 1715
 
1662 1716
 	// Setup the default values as needed.
1663
-	if (empty($context['field']))
1664
-		$context['field'] = array(
1717
+	if (empty($context['field'])) {
1718
+			$context['field'] = array(
1665 1719
 			'name' => '',
1666 1720
 			'col_name' => '???',
1667 1721
 			'desc' => '',
@@ -1686,6 +1740,7 @@  discard block
 block discarded – undo
1686 1740
 			'enclose' => '',
1687 1741
 			'placement' => 0,
1688 1742
 		);
1743
+	}
1689 1744
 
1690 1745
 	// Are we moving it?
1691 1746
 	if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to))
@@ -1694,8 +1749,10 @@  discard block
 block discarded – undo
1694 1749
 		$new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1));
1695 1750
 
1696 1751
 		// Is this a valid position?
1697
-		if ($new_order <= 0 || $new_order > $order_count)
1698
-			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1752
+		if ($new_order <= 0 || $new_order > $order_count) {
1753
+					redirectexit('action=admin;area=featuresettings;sa=profile');
1754
+		}
1755
+		// @todo implement an error handler
1699 1756
 
1700 1757
 		// All good, proceed.
1701 1758
 		$smcFunc['db_query']('','
@@ -1726,12 +1783,14 @@  discard block
 block discarded – undo
1726 1783
 		validateToken('admin-ecp');
1727 1784
 
1728 1785
 		// Everyone needs a name - even the (bracket) unknown...
1729
-		if (trim($_POST['field_name']) == '')
1730
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1786
+		if (trim($_POST['field_name']) == '') {
1787
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1788
+		}
1731 1789
 
1732 1790
 		// Regex you say?  Do a very basic test to see if the pattern is valid
1733
-		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false)
1734
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1791
+		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) {
1792
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1793
+		}
1735 1794
 
1736 1795
 		$_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);
1737 1796
 		$_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']);
@@ -1748,8 +1807,9 @@  discard block
 block discarded – undo
1748 1807
 
1749 1808
 		// Some masking stuff...
1750 1809
 		$mask = isset($_POST['mask']) ? $_POST['mask'] : '';
1751
-		if ($mask == 'regex' && isset($_POST['regex']))
1752
-			$mask .= $_POST['regex'];
1810
+		if ($mask == 'regex' && isset($_POST['regex'])) {
1811
+					$mask .= $_POST['regex'];
1812
+		}
1753 1813
 
1754 1814
 		$field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255;
1755 1815
 		$enclose = isset($_POST['enclose']) ? $_POST['enclose'] : '';
@@ -1768,8 +1828,9 @@  discard block
 block discarded – undo
1768 1828
 				$v = strtr($v, array(',' => ''));
1769 1829
 
1770 1830
 				// Nada, zip, etc...
1771
-				if (trim($v) == '')
1772
-					continue;
1831
+				if (trim($v) == '') {
1832
+									continue;
1833
+				}
1773 1834
 
1774 1835
 				// Otherwise, save it boy.
1775 1836
 				$field_options .= $v . ',';
@@ -1777,15 +1838,17 @@  discard block
 block discarded – undo
1777 1838
 				$newOptions[$k] = $v;
1778 1839
 
1779 1840
 				// Is it default?
1780
-				if (isset($_POST['default_select']) && $_POST['default_select'] == $k)
1781
-					$default = $v;
1841
+				if (isset($_POST['default_select']) && $_POST['default_select'] == $k) {
1842
+									$default = $v;
1843
+				}
1782 1844
 			}
1783 1845
 			$field_options = substr($field_options, 0, -1);
1784 1846
 		}
1785 1847
 
1786 1848
 		// Text area has default has dimensions
1787
-		if ($_POST['field_type'] == 'textarea')
1788
-			$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1849
+		if ($_POST['field_type'] == 'textarea') {
1850
+					$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1851
+		}
1789 1852
 
1790 1853
 		// Come up with the unique name?
1791 1854
 		if (empty($context['fid']))
@@ -1794,32 +1857,36 @@  discard block
 block discarded – undo
1794 1857
 			preg_match('~([\w\d_-]+)~', $col_name, $matches);
1795 1858
 
1796 1859
 			// If there is nothing to the name, then let's start out own - for foreign languages etc.
1797
-			if (isset($matches[1]))
1798
-				$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1799
-			else
1800
-				$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1860
+			if (isset($matches[1])) {
1861
+							$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1862
+			} else {
1863
+							$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1864
+			}
1801 1865
 
1802 1866
 			// Make sure this is unique.
1803 1867
 			$current_fields = array();
1804 1868
 			$request = $smcFunc['db_query']('', '
1805 1869
 				SELECT id_field, col_name
1806 1870
 				FROM {db_prefix}custom_fields');
1807
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1808
-				$current_fields[$row['id_field']] = $row['col_name'];
1871
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1872
+							$current_fields[$row['id_field']] = $row['col_name'];
1873
+			}
1809 1874
 			$smcFunc['db_free_result']($request);
1810 1875
 
1811 1876
 			$unique = false;
1812 1877
 			for ($i = 0; !$unique && $i < 9; $i ++)
1813 1878
 			{
1814
-				if (!in_array($col_name, $current_fields))
1815
-					$unique = true;
1816
-				else
1817
-					$col_name = $initial_col_name . $i;
1879
+				if (!in_array($col_name, $current_fields)) {
1880
+									$unique = true;
1881
+				} else {
1882
+									$col_name = $initial_col_name . $i;
1883
+				}
1818 1884
 			}
1819 1885
 
1820 1886
 			// Still not a unique column name? Leave it up to the user, then.
1821
-			if (!$unique)
1822
-				fatal_lang_error('custom_option_not_unique');
1887
+			if (!$unique) {
1888
+							fatal_lang_error('custom_option_not_unique');
1889
+			}
1823 1890
 		}
1824 1891
 		// Work out what to do with the user data otherwise...
1825 1892
 		else
@@ -1847,8 +1914,9 @@  discard block
 block discarded – undo
1847 1914
 				// Work out what's changed!
1848 1915
 				foreach ($context['field']['options'] as $k => $option)
1849 1916
 				{
1850
-					if (trim($option) == '')
1851
-						continue;
1917
+					if (trim($option) == '') {
1918
+											continue;
1919
+					}
1852 1920
 
1853 1921
 					// Still exists?
1854 1922
 					if (in_array($option, $newOptions))
@@ -1862,8 +1930,8 @@  discard block
 block discarded – undo
1862 1930
 				foreach ($optionChanges as $k => $option)
1863 1931
 				{
1864 1932
 					// Just been renamed?
1865
-					if (!in_array($k, $takenKeys) && !empty($newOptions[$k]))
1866
-						$smcFunc['db_query']('', '
1933
+					if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) {
1934
+											$smcFunc['db_query']('', '
1867 1935
 							UPDATE {db_prefix}themes
1868 1936
 							SET value = {string:new_value}
1869 1937
 							WHERE variable = {string:current_column}
@@ -1876,6 +1944,7 @@  discard block
 block discarded – undo
1876 1944
 								'old_value' => $option,
1877 1945
 							)
1878 1946
 						);
1947
+					}
1879 1948
 				}
1880 1949
 			}
1881 1950
 			// @todo Maybe we should adjust based on new text length limits?
@@ -1918,8 +1987,8 @@  discard block
 block discarded – undo
1918 1987
 			);
1919 1988
 
1920 1989
 			// Just clean up any old selects - these are a pain!
1921
-			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions))
1922
-				$smcFunc['db_query']('', '
1990
+			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) {
1991
+							$smcFunc['db_query']('', '
1923 1992
 					DELETE FROM {db_prefix}themes
1924 1993
 					WHERE variable = {string:current_column}
1925 1994
 						AND value NOT IN ({array_string:new_option_values})
@@ -1930,8 +1999,8 @@  discard block
 block discarded – undo
1930 1999
 						'current_column' => $context['field']['col_name'],
1931 2000
 					)
1932 2001
 				);
1933
-		}
1934
-		else
2002
+			}
2003
+		} else
1935 2004
 		{
1936 2005
 			// Gotta figure it out the order.
1937 2006
 			$new_order = $order_count > 1 ? ($order_count + 1) : 1;
@@ -2105,11 +2174,13 @@  discard block
 block discarded – undo
2105 2174
 	call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false));
2106 2175
 
2107 2176
 	$prune_toggle_dt = array();
2108
-	foreach ($prune_toggle as $item)
2109
-		$prune_toggle_dt[] = 'setting_' . $item;
2177
+	foreach ($prune_toggle as $item) {
2178
+			$prune_toggle_dt[] = 'setting_' . $item;
2179
+	}
2110 2180
 
2111
-	if ($return_config)
2112
-		return $config_vars;
2181
+	if ($return_config) {
2182
+			return $config_vars;
2183
+	}
2113 2184
 
2114 2185
 	addInlineJavaScript('
2115 2186
 	function togglePruned()
@@ -2147,15 +2218,16 @@  discard block
 block discarded – undo
2147 2218
 			$vals = array();
2148 2219
 			foreach ($config_vars as $index => $dummy)
2149 2220
 			{
2150
-				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle))
2151
-					continue;
2221
+				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) {
2222
+									continue;
2223
+				}
2152 2224
 
2153 2225
 				$vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
2154 2226
 			}
2155 2227
 			$_POST['pruningOptions'] = implode(',', $vals);
2228
+		} else {
2229
+					$_POST['pruningOptions'] = '';
2156 2230
 		}
2157
-		else
2158
-			$_POST['pruningOptions'] = '';
2159 2231
 
2160 2232
 		saveDBSettings($savevar);
2161 2233
 		$_SESSION['adm-save'] = true;
@@ -2167,10 +2239,11 @@  discard block
 block discarded – undo
2167 2239
 	$context['sub_template'] = 'show_settings';
2168 2240
 
2169 2241
 	// Get the actual values
2170
-	if (!empty($modSettings['pruningOptions']))
2171
-		@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2172
-	else
2173
-		$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2242
+	if (!empty($modSettings['pruningOptions'])) {
2243
+			@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2244
+	} else {
2245
+			$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2246
+	}
2174 2247
 
2175 2248
 	prepareDBSettingContext($config_vars);
2176 2249
 }
@@ -2192,8 +2265,9 @@  discard block
 block discarded – undo
2192 2265
 	// Make it even easier to add new settings.
2193 2266
 	call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
2194 2267
 
2195
-	if ($return_config)
2196
-		return $config_vars;
2268
+	if ($return_config) {
2269
+			return $config_vars;
2270
+	}
2197 2271
 
2198 2272
 	$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general';
2199 2273
 	$context['settings_title'] = $txt['mods_cat_modifications_misc'];
Please login to merge, or discard this patch.
Sources/ManageErrors.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -42,42 +42,42 @@  discard block
 block discarded – undo
42 42
 
43 43
 	// You can filter by any of the following columns:
44 44
 	$filters = array(
45
-		'id_member' => array (
45
+		'id_member' => array(
46 46
 			'txt' => $txt['username'],
47 47
 			'operator' => '=',
48 48
 			'datatype' => 'int',
49 49
 		),
50
-		'ip' => array (
50
+		'ip' => array(
51 51
 			'txt' => $txt['ip_address'],
52 52
 			'operator' => '=',
53 53
 			'datatype' => 'inet',
54 54
 		),
55
-		'session' => array (
55
+		'session' => array(
56 56
 			'txt' => $txt['session'],
57 57
 			'operator' => 'LIKE',
58 58
 			'datatype' => 'string',
59 59
 		),
60
-		'url' => array (
60
+		'url' => array(
61 61
 			'txt' => $txt['error_url'],
62 62
 			'operator' => 'LIKE',
63 63
 			'datatype' => 'string',
64 64
 		),
65
-		'message' => array (
65
+		'message' => array(
66 66
 			'txt' => $txt['error_message'],
67 67
 			'operator' => 'LIKE',
68 68
 			'datatype' => 'string',
69 69
 		),
70
-		'error_type' => array (
70
+		'error_type' => array(
71 71
 			'txt' => $txt['error_type'],
72 72
 			'operator' => 'LIKE',
73 73
 			'datatype' => 'string',
74 74
 		),
75
-		'file' => array (
75
+		'file' => array(
76 76
 			'txt' => $txt['file'],
77 77
 			'operator' => 'LIKE',
78 78
 			'datatype' => 'string',
79 79
 		),
80
-		'line' => array (
80
+		'line' => array(
81 81
 			'txt' => $txt['line'],
82 82
 			'operator' => '=',
83 83
 			'datatype' => 'int',
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	$result = $smcFunc['db_query']('', '
104 104
 		SELECT COUNT(*)
105 105
 		FROM {db_prefix}log_errors' . (isset($filter) ? '
106
-		WHERE ' . $filter['variable'] . ' '.$filters[$_GET['filter']]['operator'].' {'.$filters[$_GET['filter']]['datatype'].':filter}' : ''),
106
+		WHERE ' . $filter['variable'] . ' ' . $filters[$_GET['filter']]['operator'] . ' {' . $filters[$_GET['filter']]['datatype'] . ':filter}' : ''),
107 107
 		array(
108 108
 			'filter' => isset($filter) ? $filter['value']['sql'] : '',
109 109
 		)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	$request = $smcFunc['db_query']('', '
147 147
 		SELECT id_error, id_member, ip, url, log_time, message, session, error_type, file, line
148 148
 		FROM {db_prefix}log_errors' . (isset($filter) ? '
149
-		WHERE ' . $filter['variable'] . ' '.$filters[$_GET['filter']]['operator'].' {'.$filters[$_GET['filter']]['datatype'].':filter}' : '') . '
149
+		WHERE ' . $filter['variable'] . ' ' . $filters[$_GET['filter']]['operator'] . ' {' . $filters[$_GET['filter']]['datatype'] . ':filter}' : '') . '
150 150
 		ORDER BY id_error ' . ($context['sort_direction'] == 'down' ? 'DESC' : '') . '
151 151
 		LIMIT {int:start}, {int:max}',
152 152
 		array(
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	$context['errors'] = array();
159 159
 	$members = array();
160 160
 
161
-	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++)
161
+	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++)
162 162
 	{
163 163
 		$search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', $smcFunc['db_escape_wildcard_string']($row['message']));
164 164
 		if ($search_message == $filter['value']['sql'])
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 			'id' => $row['id_error'],
185 185
 			'error_type' => array(
186 186
 				'type' => $row['error_type'],
187
-				'name' => isset($txt['errortype_'.$row['error_type']]) ? $txt['errortype_'.$row['error_type']] : $row['error_type'],
187
+				'name' => isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type'],
188 188
 			),
189 189
 			'file' => array(),
190 190
 		);
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	// We don't want to slice off too many so lets make sure we stop at the last one
413 413
 	$max = min($max, max(array_keys($file_data)));
414 414
 
415
-	$file_data = array_slice($file_data, $min-1, $max - $min);
415
+	$file_data = array_slice($file_data, $min - 1, $max - $min);
416 416
 
417 417
 	$context['file_data'] = array(
418 418
 		'contents' => $file_data,
Please login to merge, or discard this patch.
Braces   +49 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * View the forum's error log.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc;
31 32
 
32 33
 	// Viewing contents of a file?
33
-	if (isset($_GET['file']))
34
-		return ViewFile();
34
+	if (isset($_GET['file'])) {
35
+			return ViewFile();
36
+	}
35 37
 
36 38
 	// Check for the administrative permission to do this.
37 39
 	isAllowedTo('admin_forum');
@@ -85,8 +87,8 @@  discard block
 block discarded – undo
85 87
 	);
86 88
 
87 89
 	// Set up the filtering...
88
-	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']]))
89
-		$filter = array(
90
+	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) {
91
+			$filter = array(
90 92
 			'variable' => $_GET['filter'],
91 93
 			'value' => array(
92 94
 				'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']),
@@ -94,10 +96,12 @@  discard block
 block discarded – undo
94 96
 			'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'],
95 97
 			'entity' => $filters[$_GET['filter']]['txt']
96 98
 		);
99
+	}
97 100
 
98 101
 	// Deleting, are we?
99
-	if (isset($_POST['delall']) || isset($_POST['delete']))
100
-		deleteErrors();
102
+	if (isset($_POST['delall']) || isset($_POST['delete'])) {
103
+			deleteErrors();
104
+	}
101 105
 
102 106
 	// Just how many errors are there?
103 107
 	$result = $smcFunc['db_query']('', '
@@ -112,12 +116,14 @@  discard block
 block discarded – undo
112 116
 	$smcFunc['db_free_result']($result);
113 117
 
114 118
 	// If this filter is empty...
115
-	if ($num_errors == 0 && isset($filter))
116
-		redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
119
+	if ($num_errors == 0 && isset($filter)) {
120
+			redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
121
+	}
117 122
 
118 123
 	// Clean up start.
119
-	if (!isset($_GET['start']) || $_GET['start'] < 0)
120
-		$_GET['start'] = 0;
124
+	if (!isset($_GET['start']) || $_GET['start'] < 0) {
125
+			$_GET['start'] = 0;
126
+	}
121 127
 
122 128
 	// Do we want to reverse error listing?
123 129
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
@@ -127,9 +133,9 @@  discard block
 block discarded – undo
127 133
 	$context['start'] = $_GET['start'];
128 134
 
129 135
 	// Update the error count
130
-	if (!isset($filter))
131
-		$context['num_errors'] = $num_errors;
132
-	else
136
+	if (!isset($filter)) {
137
+			$context['num_errors'] = $num_errors;
138
+	} else
133 139
 	{
134 140
 		// We want all errors, not just the number of filtered messages...
135 141
 		$query = $smcFunc['db_query']('', '
@@ -161,8 +167,9 @@  discard block
 block discarded – undo
161 167
 	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++)
162 168
 	{
163 169
 		$search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', $smcFunc['db_escape_wildcard_string']($row['message']));
164
-		if ($search_message == $filter['value']['sql'])
165
-			$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
170
+		if ($search_message == $filter['value']['sql']) {
171
+					$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
172
+		}
166 173
 		$show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br>'));
167 174
 
168 175
 		$context['errors'][$row['id_error']] = array(
@@ -221,8 +228,9 @@  discard block
 block discarded – undo
221 228
 				'members' => count($members),
222 229
 			)
223 230
 		);
224
-		while ($row = $smcFunc['db_fetch_assoc']($request))
225
-			$members[$row['id_member']] = $row;
231
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
232
+					$members[$row['id_member']] = $row;
233
+		}
226 234
 		$smcFunc['db_free_result']($request);
227 235
 
228 236
 		// This is a guest...
@@ -254,20 +262,18 @@  discard block
 block discarded – undo
254 262
 			$id = $filter['value']['sql'];
255 263
 			loadMemberData($id, false, 'minimal');
256 264
 			$context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>';
257
-		}
258
-		elseif ($filter['variable'] == 'url')
259
-			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
260
-		elseif ($filter['variable'] == 'message')
265
+		} elseif ($filter['variable'] == 'url') {
266
+					$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
267
+		} elseif ($filter['variable'] == 'message')
261 268
 		{
262 269
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
263 270
 			$context['filter']['value']['html'] = preg_replace('~&amp;lt;span class=&amp;quot;remove&amp;quot;&amp;gt;(.+?)&amp;lt;/span&amp;gt;~', '$1', $context['filter']['value']['html']);
264
-		}
265
-		elseif ($filter['variable'] == 'error_type')
271
+		} elseif ($filter['variable'] == 'error_type')
266 272
 		{
267 273
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
274
+		} else {
275
+					$context['filter']['value']['html'] = &$filter['value']['sql'];
268 276
 		}
269
-		else
270
-			$context['filter']['value']['html'] = &$filter['value']['sql'];
271 277
 	}
272 278
 
273 279
 	$context['error_types'] = array();
@@ -308,10 +314,11 @@  discard block
 block discarded – undo
308 314
 	$context['error_types']['all']['label'] .= ' (' . $sum . ')';
309 315
 
310 316
 	// Finally, work out what is the last tab!
311
-	if (isset($context['error_types'][$sum]))
312
-		$context['error_types'][$sum]['is_last'] = true;
313
-	else
314
-		$context['error_types']['all']['is_last'] = true;
317
+	if (isset($context['error_types'][$sum])) {
318
+			$context['error_types'][$sum]['is_last'] = true;
319
+	} else {
320
+			$context['error_types']['all']['is_last'] = true;
321
+	}
315 322
 
316 323
 	// And this is pretty basic ;).
317 324
 	$context['page_title'] = $txt['errlog'];
@@ -337,21 +344,23 @@  discard block
 block discarded – undo
337 344
 	validateToken('admin-el');
338 345
 
339 346
 	// Delete all or just some?
340
-	if (isset($_POST['delall']) && !isset($filter))
341
-		$smcFunc['db_query']('truncate_table', '
347
+	if (isset($_POST['delall']) && !isset($filter)) {
348
+			$smcFunc['db_query']('truncate_table', '
342 349
 			TRUNCATE {db_prefix}log_errors',
343 350
 			array(
344 351
 			)
345 352
 		);
353
+	}
346 354
 	// Deleting all with a filter?
347
-	elseif (isset($_POST['delall']) && isset($filter))
348
-		$smcFunc['db_query']('', '
355
+	elseif (isset($_POST['delall']) && isset($filter)) {
356
+			$smcFunc['db_query']('', '
349 357
 			DELETE FROM {db_prefix}log_errors
350 358
 			WHERE ' . $filter['variable'] . ' LIKE {string:filter}',
351 359
 			array(
352 360
 				'filter' => $filter['value']['sql'],
353 361
 			)
354 362
 		);
363
+	}
355 364
 	// Just specific errors?
356 365
 	elseif (!empty($_POST['delete']))
357 366
 	{
@@ -397,15 +406,17 @@  discard block
 block discarded – undo
397 406
 	$line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0;
398 407
 
399 408
 	// Make sure the file we are looking for is one they are allowed to look at
400
-	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file))
401
-		fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
409
+	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) {
410
+			fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
411
+	}
402 412
 
403 413
 	// get the min and max lines
404 414
 	$min = $line - 20 <= 0 ? 1 : $line - 20;
405 415
 	$max = $line + 21; // One additional line to make everything work out correctly
406 416
 
407
-	if ($max <= 0 || $min >= $max)
408
-		fatal_lang_error('error_bad_line');
417
+	if ($max <= 0 || $min >= $max) {
418
+			fatal_lang_error('error_bad_line');
419
+	}
409 420
 
410 421
 	$file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file)))));
411 422
 
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   +416 added lines, -309 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 // 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
 		{
@@ -710,39 +756,45 @@  discard block
 block discarded – undo
710 756
 		{
711 757
 			$context['search_ignored'][] = $value;
712 758
 			unset($searchArray[$index]);
759
+		} else {
760
+					$searchArray[$index] = $searchArray[$index];
713 761
 		}
714
-		else
715
-			$searchArray[$index] = $searchArray[$index];
716 762
 	}
717 763
 	$searchArray = array_slice(array_unique($searchArray), 0, 10);
718 764
 
719 765
 	// Create an array of replacements for highlighting.
720 766
 	$context['mark'] = array();
721
-	foreach ($searchArray as $word)
722
-		$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
767
+	foreach ($searchArray as $word) {
768
+			$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
769
+	}
723 770
 
724 771
 	// Initialize two arrays storing the words that have to be searched for.
725 772
 	$orParts = array();
726 773
 	$searchWords = array();
727 774
 
728 775
 	// Make sure at least one word is being searched for.
729
-	if (empty($searchArray))
730
-		$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
776
+	if (empty($searchArray)) {
777
+			$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
778
+	}
731 779
 	// All words/sentences must match.
732
-	elseif (empty($search_params['searchtype']))
733
-		$orParts[0] = $searchArray;
780
+	elseif (empty($search_params['searchtype'])) {
781
+			$orParts[0] = $searchArray;
782
+	}
734 783
 	// Any word/sentence must match.
735
-	else
736
-		foreach ($searchArray as $index => $value)
784
+	else {
785
+			foreach ($searchArray as $index => $value)
737 786
 			$orParts[$index] = array($value);
787
+	}
738 788
 
739 789
 	// Don't allow duplicate error messages if one string is too short.
740
-	if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string']))
741
-		unset($context['search_errors']['invalid_search_string']);
790
+	if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) {
791
+			unset($context['search_errors']['invalid_search_string']);
792
+	}
742 793
 	// Make sure the excluded words are in all or-branches.
743
-	foreach ($orParts as $orIndex => $andParts)
744
-		foreach ($excludedWords as $word)
794
+	foreach ($orParts as $orIndex => $andParts) {
795
+			foreach ($excludedWords as $word)
745 796
 			$orParts[$orIndex][] = $word;
797
+	}
746 798
 
747 799
 	// Determine the or-branches and the fulltext search words.
748 800
 	foreach ($orParts as $orIndex => $andParts)
@@ -756,8 +808,9 @@  discard block
 block discarded – undo
756 808
 		);
757 809
 
758 810
 		// Sort the indexed words (large words -> small words -> excluded words).
759
-		if ($searchAPI->supportsMethod('searchSort'))
760
-			usort($orParts[$orIndex], 'searchSort');
811
+		if ($searchAPI->supportsMethod('searchSort')) {
812
+					usort($orParts[$orIndex], 'searchSort');
813
+		}
761 814
 
762 815
 		foreach ($orParts[$orIndex] as $word)
763 816
 		{
@@ -769,15 +822,17 @@  discard block
 block discarded – undo
769 822
 			if (!$is_excluded || count($subjectWords) === 1)
770 823
 			{
771 824
 				$searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords);
772
-				if ($is_excluded)
773
-					$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
825
+				if ($is_excluded) {
826
+									$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
827
+				}
828
+			} else {
829
+							$excludedPhrases[] = $word;
774 830
 			}
775
-			else
776
-				$excludedPhrases[] = $word;
777 831
 
778 832
 			// Have we got indexes to prepare?
779
-			if ($searchAPI->supportsMethod('prepareIndexes'))
780
-				$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
833
+			if ($searchAPI->supportsMethod('prepareIndexes')) {
834
+							$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
835
+			}
781 836
 		}
782 837
 
783 838
 		// Search_force_index requires all AND parts to have at least one fulltext word.
@@ -785,8 +840,7 @@  discard block
 block discarded – undo
785 840
 		{
786 841
 			$context['search_errors']['query_not_specific_enough'] = true;
787 842
 			break;
788
-		}
789
-		elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
843
+		} elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
790 844
 		{
791 845
 			$context['search_errors']['query_not_specific_enough'] = true;
792 846
 			break;
@@ -814,8 +868,9 @@  discard block
 block discarded – undo
814 868
 		$found_misspelling = false;
815 869
 		foreach ($searchArray as $word)
816 870
 		{
817
-			if (empty($link))
818
-				continue;
871
+			if (empty($link)) {
872
+							continue;
873
+			}
819 874
 
820 875
 			// Don't check phrases.
821 876
 			if (preg_match('~^\w+$~', $word) === 0)
@@ -830,8 +885,7 @@  discard block
 block discarded – undo
830 885
 				$did_you_mean['search'][] = $word;
831 886
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
832 887
 				continue;
833
-			}
834
-			elseif (spell_check($link, $word))
888
+			} elseif (spell_check($link, $word))
835 889
 			{
836 890
 				$did_you_mean['search'][] = $word;
837 891
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
@@ -842,11 +896,13 @@  discard block
 block discarded – undo
842 896
 			foreach ($suggestions as $i => $s)
843 897
 			{
844 898
 				// Search is case insensitive.
845
-				if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word))
846
-					unset($suggestions[$i]);
899
+				if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) {
900
+									unset($suggestions[$i]);
901
+				}
847 902
 				// Plus, don't suggest something the user thinks is rude!
848
-				elseif ($suggestions[$i] != censorText($s))
849
-					unset($suggestions[$i]);
903
+				elseif ($suggestions[$i] != censorText($s)) {
904
+									unset($suggestions[$i]);
905
+				}
850 906
 			}
851 907
 
852 908
 			// Anything found?  If so, correct it!
@@ -856,8 +912,7 @@  discard block
 block discarded – undo
856 912
 				$did_you_mean['search'][] = $suggestions[0];
857 913
 				$did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>';
858 914
 				$found_misspelling = true;
859
-			}
860
-			else
915
+			} else
861 916
 			{
862 917
 				$did_you_mean['search'][] = $word;
863 918
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
@@ -874,8 +929,7 @@  discard block
 block discarded – undo
874 929
 				{
875 930
 					$temp_excluded['search'][] = '-"' . $word . '"';
876 931
 					$temp_excluded['display'][] = '-&quot;' . $smcFunc['htmlspecialchars']($word) . '&quot;';
877
-				}
878
-				else
932
+				} else
879 933
 				{
880 934
 					$temp_excluded['search'][] = '-' . $word;
881 935
 					$temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word);
@@ -887,11 +941,13 @@  discard block
 block discarded – undo
887 941
 
888 942
 			$temp_params = $search_params;
889 943
 			$temp_params['search'] = implode(' ', $did_you_mean['search']);
890
-			if (isset($temp_params['brd']))
891
-				$temp_params['brd'] = implode(',', $temp_params['brd']);
944
+			if (isset($temp_params['brd'])) {
945
+							$temp_params['brd'] = implode(',', $temp_params['brd']);
946
+			}
892 947
 			$context['params'] = array();
893
-			foreach ($temp_params as $k => $v)
894
-				$context['did_you_mean_params'][] = $k . '|\'|' . $v;
948
+			foreach ($temp_params as $k => $v) {
949
+							$context['did_you_mean_params'][] = $k . '|\'|' . $v;
950
+			}
895 951
 			$context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params']));
896 952
 			$context['did_you_mean'] = implode(' ', $did_you_mean['display']);
897 953
 		}
@@ -899,18 +955,20 @@  discard block
 block discarded – undo
899 955
 
900 956
 	// Let the user adjust the search query, should they wish?
901 957
 	$context['search_params'] = $search_params;
902
-	if (isset($context['search_params']['search']))
903
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
904
-	if (isset($context['search_params']['userspec']))
905
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
958
+	if (isset($context['search_params']['search'])) {
959
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
960
+	}
961
+	if (isset($context['search_params']['userspec'])) {
962
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
963
+	}
906 964
 
907 965
 	// Do we have captcha enabled?
908 966
 	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']))
909 967
 	{
910 968
 		// If we come from another search box tone down the error...
911
-		if (!isset($_REQUEST['search_vv']))
912
-			$context['search_errors']['need_verification_code'] = true;
913
-		else
969
+		if (!isset($_REQUEST['search_vv'])) {
970
+					$context['search_errors']['need_verification_code'] = true;
971
+		} else
914 972
 		{
915 973
 			require_once($sourcedir . '/Subs-Editor.php');
916 974
 			$verificationOptions = array(
@@ -920,12 +978,14 @@  discard block
 block discarded – undo
920 978
 
921 979
 			if (is_array($context['require_verification']))
922 980
 			{
923
-				foreach ($context['require_verification'] as $error)
924
-					$context['search_errors'][$error] = true;
981
+				foreach ($context['require_verification'] as $error) {
982
+									$context['search_errors'][$error] = true;
983
+				}
925 984
 			}
926 985
 			// Don't keep asking for it - they've proven themselves worthy.
927
-			else
928
-				$_SESSION['ss_vv_passed'] = true;
986
+			else {
987
+							$_SESSION['ss_vv_passed'] = true;
988
+			}
929 989
 		}
930 990
 	}
931 991
 
@@ -933,19 +993,22 @@  discard block
 block discarded – undo
933 993
 
934 994
 	// All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below.
935 995
 	$temp_params = $search_params;
936
-	if (isset($temp_params['brd']))
937
-		$temp_params['brd'] = implode(',', $temp_params['brd']);
996
+	if (isset($temp_params['brd'])) {
997
+			$temp_params['brd'] = implode(',', $temp_params['brd']);
998
+	}
938 999
 	$context['params'] = array();
939
-	foreach ($temp_params as $k => $v)
940
-		$context['params'][] = $k . '|\'|' . $v;
1000
+	foreach ($temp_params as $k => $v) {
1001
+			$context['params'][] = $k . '|\'|' . $v;
1002
+	}
941 1003
 
942 1004
 	if (!empty($context['params']))
943 1005
 	{
944 1006
 		// Due to old IE's 2083 character limit, we have to compress long search strings
945 1007
 		$params = @gzcompress(implode('|"|', $context['params']));
946 1008
 		// Gzcompress failed, use try non-gz
947
-		if (empty($params))
948
-			$params = implode('|"|', $context['params']);
1009
+		if (empty($params)) {
1010
+					$params = implode('|"|', $context['params']);
1011
+		}
949 1012
 		// Base64 encode, then replace +/= with uri safe ones that can be reverted
950 1013
 		$context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params));
951 1014
 	}
@@ -971,8 +1034,9 @@  discard block
 block discarded – undo
971 1034
 	}
972 1035
 
973 1036
 	// Spam me not, Spam-a-lot?
974
-	if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])
975
-		spamProtection('search');
1037
+	if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) {
1038
+			spamProtection('search');
1039
+	}
976 1040
 	// Store the last search string to allow pages of results to be browsed.
977 1041
 	$_SESSION['last_ss'] = $search_params['search'];
978 1042
 
@@ -1032,8 +1096,9 @@  discard block
 block discarded – undo
1032 1096
 						'where' => array(),
1033 1097
 					);
1034 1098
 
1035
-					if ($modSettings['postmod_active'])
1036
-						$subject_query['where'][] = 't.approved = {int:is_approved}';
1099
+					if ($modSettings['postmod_active']) {
1100
+											$subject_query['where'][] = 't.approved = {int:is_approved}';
1101
+					}
1037 1102
 
1038 1103
 					$numTables = 0;
1039 1104
 					$prev_join = 0;
@@ -1045,8 +1110,7 @@  discard block
 block discarded – undo
1045 1110
 						{
1046 1111
 							$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)';
1047 1112
 							$subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
1048
-						}
1049
-						else
1113
+						} else
1050 1114
 						{
1051 1115
 							$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)';
1052 1116
 							$subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}');
@@ -1064,14 +1128,18 @@  discard block
 block discarded – undo
1064 1128
 						}
1065 1129
 						$subject_query['where'][] = $userQuery;
1066 1130
 					}
1067
-					if (!empty($search_params['topic']))
1068
-						$subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
1069
-					if (!empty($minMsgID))
1070
-						$subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
1071
-					if (!empty($maxMsgID))
1072
-						$subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
1073
-					if (!empty($boardQuery))
1074
-						$subject_query['where'][] = 't.id_board ' . $boardQuery;
1131
+					if (!empty($search_params['topic'])) {
1132
+											$subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
1133
+					}
1134
+					if (!empty($minMsgID)) {
1135
+											$subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
1136
+					}
1137
+					if (!empty($maxMsgID)) {
1138
+											$subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
1139
+					}
1140
+					if (!empty($boardQuery)) {
1141
+											$subject_query['where'][] = 't.id_board ' . $boardQuery;
1142
+					}
1075 1143
 					if (!empty($excludedPhrases))
1076 1144
 					{
1077 1145
 						if ($subject_query['from'] != '{db_prefix}messages AS m')
@@ -1091,8 +1159,9 @@  discard block
 block discarded – undo
1091 1159
 					foreach ($weight_factors as $type => $value)
1092 1160
 					{
1093 1161
 						$relevance .= $weight[$type];
1094
-						if (!empty($value['results']))
1095
-							$relevance .= ' * ' . $value['results'];
1162
+						if (!empty($value['results'])) {
1163
+													$relevance .= ' * ' . $value['results'];
1164
+						}
1096 1165
 						$relevance .= ' + ';
1097 1166
 					}
1098 1167
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
@@ -1130,20 +1199,23 @@  discard block
 block discarded – undo
1130 1199
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1131 1200
 						{
1132 1201
 							// No duplicates!
1133
-							if (isset($inserts[$row[1]]))
1134
-								continue;
1202
+							if (isset($inserts[$row[1]])) {
1203
+															continue;
1204
+							}
1135 1205
 
1136
-							foreach ($row as $key => $value)
1137
-								$inserts[$row[1]][] = (int) $row[$key];
1206
+							foreach ($row as $key => $value) {
1207
+															$inserts[$row[1]][] = (int) $row[$key];
1208
+							}
1138 1209
 						}
1139 1210
 						$smcFunc['db_free_result']($ignoreRequest);
1140 1211
 						$numSubjectResults = count($inserts);
1212
+					} else {
1213
+											$numSubjectResults += $smcFunc['db_affected_rows']();
1141 1214
 					}
1142
-					else
1143
-						$numSubjectResults += $smcFunc['db_affected_rows']();
1144 1215
 
1145
-					if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
1146
-						break;
1216
+					if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) {
1217
+											break;
1218
+					}
1147 1219
 				}
1148 1220
 
1149 1221
 				// If there's data to be inserted for non-IGNORE databases do it here!
@@ -1158,8 +1230,7 @@  discard block
 block discarded – undo
1158 1230
 				}
1159 1231
 
1160 1232
 				$_SESSION['search_cache']['num_results'] = $numSubjectResults;
1161
-			}
1162
-			else
1233
+			} else
1163 1234
 			{
1164 1235
 				$main_query = array(
1165 1236
 					'select' => array(
@@ -1191,8 +1262,7 @@  discard block
 block discarded – undo
1191 1262
 					$main_query['weights'] = $weight_factors;
1192 1263
 
1193 1264
 					$main_query['group_by'][] = 't.id_topic';
1194
-				}
1195
-				else
1265
+				} else
1196 1266
 				{
1197 1267
 					// This is outrageous!
1198 1268
 					$main_query['select']['id_topic'] = 'm.id_msg AS id_topic';
@@ -1213,8 +1283,9 @@  discard block
 block discarded – undo
1213 1283
 						$main_query['where'][] = 't.id_topic = {int:topic}';
1214 1284
 						$main_query['parameters']['topic'] = $search_params['topic'];
1215 1285
 					}
1216
-					if (!empty($search_params['show_complete']))
1217
-						$main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
1286
+					if (!empty($search_params['show_complete'])) {
1287
+											$main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
1288
+					}
1218 1289
 				}
1219 1290
 
1220 1291
 				// *** Get the subject results.
@@ -1241,14 +1312,15 @@  discard block
 block discarded – undo
1241 1312
 					) !== false;
1242 1313
 
1243 1314
 					// Clean up some previous cache.
1244
-					if (!$createTemporary)
1245
-						$smcFunc['db_search_query']('delete_log_search_topics', '
1315
+					if (!$createTemporary) {
1316
+											$smcFunc['db_search_query']('delete_log_search_topics', '
1246 1317
 							DELETE FROM {db_prefix}log_search_topics
1247 1318
 							WHERE id_search = {int:search_id}',
1248 1319
 							array(
1249 1320
 								'search_id' => $_SESSION['search_cache']['id_search'],
1250 1321
 							)
1251 1322
 						);
1323
+					}
1252 1324
 
1253 1325
 					foreach ($searchWords as $orIndex => $words)
1254 1326
 					{
@@ -1280,8 +1352,7 @@  discard block
 block discarded – undo
1280 1352
 								$subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
1281 1353
 								$subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}';
1282 1354
 								$subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]';
1283
-							}
1284
-							else
1355
+							} else
1285 1356
 							{
1286 1357
 								$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)';
1287 1358
 								$subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}';
@@ -1336,8 +1407,9 @@  discard block
 block discarded – undo
1336 1407
 						call_integration_hook('integrate_subject_search_query', array(&$subject_query));
1337 1408
 
1338 1409
 						// Nothing to search for?
1339
-						if (empty($subject_query['where']))
1340
-							continue;
1410
+						if (empty($subject_query['where'])) {
1411
+													continue;
1412
+						}
1341 1413
 
1342 1414
 						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( '
1343 1415
 							INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics
@@ -1360,19 +1432,21 @@  discard block
 block discarded – undo
1360 1432
 							{
1361 1433
 								$ind = $createTemporary ? 0 : 1;
1362 1434
 								// No duplicates!
1363
-								if (isset($inserts[$row[$ind]]))
1364
-									continue;
1435
+								if (isset($inserts[$row[$ind]])) {
1436
+																	continue;
1437
+								}
1365 1438
 
1366 1439
 								$inserts[$row[$ind]] = $row;
1367 1440
 							}
1368 1441
 							$smcFunc['db_free_result']($ignoreRequest);
1369 1442
 							$numSubjectResults = count($inserts);
1443
+						} else {
1444
+													$numSubjectResults += $smcFunc['db_affected_rows']();
1370 1445
 						}
1371
-						else
1372
-							$numSubjectResults += $smcFunc['db_affected_rows']();
1373 1446
 
1374
-						if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
1375
-							break;
1447
+						if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) {
1448
+													break;
1449
+						}
1376 1450
 					}
1377 1451
 
1378 1452
 					// Got some non-MySQL data to plonk in?
@@ -1390,8 +1464,9 @@  discard block
 block discarded – undo
1390 1464
 					{
1391 1465
 						$main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END';
1392 1466
 						$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)';
1393
-						if (!$createTemporary)
1394
-							$main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
1467
+						if (!$createTemporary) {
1468
+													$main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
1469
+						}
1395 1470
 					}
1396 1471
 				}
1397 1472
 
@@ -1419,14 +1494,15 @@  discard block
 block discarded – undo
1419 1494
 					) !== false;
1420 1495
 
1421 1496
 					// Clear, all clear!
1422
-					if (!$createTemporary)
1423
-						$smcFunc['db_search_query']('delete_log_search_messages', '
1497
+					if (!$createTemporary) {
1498
+											$smcFunc['db_search_query']('delete_log_search_messages', '
1424 1499
 							DELETE FROM {db_prefix}log_search_messages
1425 1500
 							WHERE id_search = {int:id_search}',
1426 1501
 							array(
1427 1502
 								'id_search' => $_SESSION['search_cache']['id_search'],
1428 1503
 							)
1429 1504
 						);
1505
+					}
1430 1506
 
1431 1507
 					foreach ($searchWords as $orIndex => $words)
1432 1508
 					{
@@ -1460,19 +1536,21 @@  discard block
 block discarded – undo
1460 1536
 								while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1461 1537
 								{
1462 1538
 									// No duplicates!
1463
-									if (isset($inserts[$row[0]]))
1464
-										continue;
1539
+									if (isset($inserts[$row[0]])) {
1540
+																			continue;
1541
+									}
1465 1542
 
1466 1543
 									$inserts[$row[0]] = $row;
1467 1544
 								}
1468 1545
 								$smcFunc['db_free_result']($ignoreRequest);
1469 1546
 								$indexedResults = count($inserts);
1547
+							} else {
1548
+															$indexedResults += $smcFunc['db_affected_rows']();
1470 1549
 							}
1471
-							else
1472
-								$indexedResults += $smcFunc['db_affected_rows']();
1473 1550
 
1474
-							if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults)
1475
-								break;
1551
+							if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) {
1552
+															break;
1553
+							}
1476 1554
 						}
1477 1555
 					}
1478 1556
 
@@ -1492,8 +1570,7 @@  discard block
 block discarded – undo
1492 1570
 						$context['search_errors']['query_not_specific_enough'] = true;
1493 1571
 						$_REQUEST['params'] = $context['params'];
1494 1572
 						return PlushSearch1();
1495
-					}
1496
-					elseif (!empty($indexedResults))
1573
+					} elseif (!empty($indexedResults))
1497 1574
 					{
1498 1575
 						$main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)';
1499 1576
 						if (!$createTemporary)
@@ -1515,15 +1592,18 @@  discard block
 block discarded – undo
1515 1592
 						foreach ($words['all_words'] as $regularWord)
1516 1593
 						{
1517 1594
 							$where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1518
-							if (in_array($regularWord, $excludedWords))
1519
-								$where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1595
+							if (in_array($regularWord, $excludedWords)) {
1596
+															$where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1597
+							}
1520 1598
 							$main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
1521 1599
 						}
1522
-						if (!empty($where))
1523
-							$orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
1600
+						if (!empty($where)) {
1601
+													$orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
1602
+						}
1603
+					}
1604
+					if (!empty($orWhere)) {
1605
+											$main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];
1524 1606
 					}
1525
-					if (!empty($orWhere))
1526
-						$main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];
1527 1607
 
1528 1608
 					if (!empty($userQuery))
1529 1609
 					{
@@ -1561,8 +1641,9 @@  discard block
 block discarded – undo
1561 1641
 					foreach ($main_query['weights'] as $type => $value)
1562 1642
 					{
1563 1643
 						$relevance .= $weight[$type];
1564
-						if (!empty($value['search']))
1565
-							$relevance .= ' * ' . $value['search'];
1644
+						if (!empty($value['search'])) {
1645
+													$relevance .= ' * ' . $value['search'];
1646
+						}
1566 1647
 						$relevance .= ' + ';
1567 1648
 						$new_weight_total += $weight[$type];
1568 1649
 					}
@@ -1593,11 +1674,13 @@  discard block
 block discarded – undo
1593 1674
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1594 1675
 						{
1595 1676
 							// No duplicates!
1596
-							if (isset($inserts[$row[2]]))
1597
-								continue;
1677
+							if (isset($inserts[$row[2]])) {
1678
+															continue;
1679
+							}
1598 1680
 
1599
-							foreach ($row as $key => $value)
1600
-								$inserts[$row[2]][] = (int) $row[$key];
1681
+							foreach ($row as $key => $value) {
1682
+															$inserts[$row[2]][] = (int) $row[$key];
1683
+							}
1601 1684
 						}
1602 1685
 						$smcFunc['db_free_result']($ignoreRequest);
1603 1686
 
@@ -1605,8 +1688,9 @@  discard block
 block discarded – undo
1605 1688
 						if (!empty($inserts))
1606 1689
 						{
1607 1690
 							$query_columns = array();
1608
-							foreach ($main_query['select'] as $k => $v)
1609
-								$query_columns[$k] = 'int';
1691
+							foreach ($main_query['select'] as $k => $v) {
1692
+															$query_columns[$k] = 'int';
1693
+							}
1610 1694
 
1611 1695
 							$smcFunc['db_insert']('',
1612 1696
 								'{db_prefix}log_search_results',
@@ -1616,21 +1700,23 @@  discard block
 block discarded – undo
1616 1700
 							);
1617 1701
 						}
1618 1702
 						$_SESSION['search_cache']['num_results'] += count($inserts);
1703
+					} else {
1704
+											$_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
1619 1705
 					}
1620
-					else
1621
-						$_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
1622 1706
 				}
1623 1707
 
1624 1708
 				// Insert subject-only matches.
1625 1709
 				if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0)
1626 1710
 				{
1627 1711
 					$relevance = '1000 * (';
1628
-					foreach ($weight_factors as $type => $value)
1629
-						if (isset($value['results']))
1712
+					foreach ($weight_factors as $type => $value) {
1713
+											if (isset($value['results']))
1630 1714
 						{
1631 1715
 							$relevance .= $weight[$type];
1632
-							if (!empty($value['results']))
1633
-								$relevance .= ' * ' . $value['results'];
1716
+					}
1717
+							if (!empty($value['results'])) {
1718
+															$relevance .= ' * ' . $value['results'];
1719
+							}
1634 1720
 							$relevance .= ' + ';
1635 1721
 						}
1636 1722
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
@@ -1664,8 +1750,9 @@  discard block
 block discarded – undo
1664 1750
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1665 1751
 						{
1666 1752
 							// No duplicates!
1667
-							if (isset($usedIDs[$row[1]]))
1668
-								continue;
1753
+							if (isset($usedIDs[$row[1]])) {
1754
+															continue;
1755
+							}
1669 1756
 
1670 1757
 							$usedIDs[$row[1]] = true;
1671 1758
 							$inserts[] = $row;
@@ -1683,12 +1770,12 @@  discard block
 block discarded – undo
1683 1770
 							);
1684 1771
 						}
1685 1772
 						$_SESSION['search_cache']['num_results'] += count($inserts);
1773
+					} else {
1774
+											$_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
1686 1775
 					}
1687
-					else
1688
-						$_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
1776
+				} elseif ($_SESSION['search_cache']['num_results'] == -1) {
1777
+									$_SESSION['search_cache']['num_results'] = 0;
1689 1778
 				}
1690
-				elseif ($_SESSION['search_cache']['num_results'] == -1)
1691
-					$_SESSION['search_cache']['num_results'] = 0;
1692 1779
 			}
1693 1780
 		}
1694 1781
 
@@ -1758,14 +1845,16 @@  discard block
 block discarded – undo
1758 1845
 			)
1759 1846
 		);
1760 1847
 		$posters = array();
1761
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1762
-			$posters[] = $row['id_member'];
1848
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1849
+					$posters[] = $row['id_member'];
1850
+		}
1763 1851
 		$smcFunc['db_free_result']($request);
1764 1852
 
1765 1853
 		call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters));
1766 1854
 
1767
-		if (!empty($posters))
1768
-			loadMemberData(array_unique($posters));
1855
+		if (!empty($posters)) {
1856
+					loadMemberData(array_unique($posters));
1857
+		}
1769 1858
 
1770 1859
 		// Get the messages out for the callback - select enough that it can be made to look just like Display.
1771 1860
 		$messages_request = $smcFunc['db_query']('', '
@@ -1799,8 +1888,9 @@  discard block
 block discarded – undo
1799 1888
 		);
1800 1889
 
1801 1890
 		// If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore.
1802
-		if ($smcFunc['db_num_rows']($messages_request) == 0)
1803
-			$context['topics'] = array();
1891
+		if ($smcFunc['db_num_rows']($messages_request) == 0) {
1892
+					$context['topics'] = array();
1893
+		}
1804 1894
 
1805 1895
 		// If we want to know who participated in what then load this now.
1806 1896
 		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'])
@@ -1818,8 +1908,9 @@  discard block
 block discarded – undo
1818 1908
 					'limit' => count($participants),
1819 1909
 				)
1820 1910
 			);
1821
-			while ($row = $smcFunc['db_fetch_assoc']($result))
1822
-				$participants[$row['id_topic']] = true;
1911
+			while ($row = $smcFunc['db_fetch_assoc']($result)) {
1912
+							$participants[$row['id_topic']] = true;
1913
+			}
1823 1914
 			$smcFunc['db_free_result']($result);
1824 1915
 		}
1825 1916
 	}
@@ -1828,15 +1919,17 @@  discard block
 block discarded – undo
1828 1919
 	$context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false);
1829 1920
 
1830 1921
 	// Consider the search complete!
1831
-	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1832
-		cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);
1922
+	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1923
+			cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);
1924
+	}
1833 1925
 
1834 1926
 	$context['key_words'] = &$searchArray;
1835 1927
 
1836 1928
 	// Setup the default topic icons... for checking they exist and the like!
1837 1929
 	$context['icon_sources'] = array();
1838
-	foreach ($context['stable_icons'] as $icon)
1839
-		$context['icon_sources'][$icon] = 'images_url';
1930
+	foreach ($context['stable_icons'] as $icon) {
1931
+			$context['icon_sources'][$icon] = 'images_url';
1932
+	}
1840 1933
 
1841 1934
 	$context['sub_template'] = 'results';
1842 1935
 	$context['page_title'] = $txt['search_results'];
@@ -1867,26 +1960,31 @@  discard block
 block discarded – undo
1867 1960
 	global $boards_can, $participants, $smcFunc;
1868 1961
 	static $recycle_board = null;
1869 1962
 
1870
-	if ($recycle_board === null)
1871
-		$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
1963
+	if ($recycle_board === null) {
1964
+			$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
1965
+	}
1872 1966
 
1873 1967
 	// Remember which message this is.  (ie. reply #83)
1874 1968
 	static $counter = null;
1875
-	if ($counter == null || $reset)
1876
-		$counter = $_REQUEST['start'] + 1;
1969
+	if ($counter == null || $reset) {
1970
+			$counter = $_REQUEST['start'] + 1;
1971
+	}
1877 1972
 
1878 1973
 	// If the query returned false, bail.
1879
-	if ($messages_request == false)
1880
-		return false;
1974
+	if ($messages_request == false) {
1975
+			return false;
1976
+	}
1881 1977
 
1882 1978
 	// Start from the beginning...
1883
-	if ($reset)
1884
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1979
+	if ($reset) {
1980
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1981
+	}
1885 1982
 
1886 1983
 	// Attempt to get the next message.
1887 1984
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
1888
-	if (!$message)
1889
-		return false;
1985
+	if (!$message) {
1986
+			return false;
1987
+	}
1890 1988
 
1891 1989
 	// Can't have an empty subject can we?
1892 1990
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1925,9 +2023,9 @@  discard block
 block discarded – undo
1925 2023
 
1926 2024
 		if ($smcFunc['strlen']($message['body']) > $charLimit)
1927 2025
 		{
1928
-			if (empty($context['key_words']))
1929
-				$message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
1930
-			else
2026
+			if (empty($context['key_words'])) {
2027
+							$message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
2028
+			} else
1931 2029
 			{
1932 2030
 				$matchString = '';
1933 2031
 				$force_partial_word = false;
@@ -1936,18 +2034,20 @@  discard block
 block discarded – undo
1936 2034
 					$keyword = un_htmlspecialchars($keyword);
1937 2035
 					$keyword = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&amp;')));
1938 2036
 
1939
-					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0)
1940
-						$force_partial_word = true;
2037
+					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) {
2038
+											$force_partial_word = true;
2039
+					}
1941 2040
 					$matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|';
1942 2041
 				}
1943 2042
 				$matchString = un_htmlspecialchars(substr($matchString, 0, -1));
1944 2043
 
1945 2044
 				$message['body'] = un_htmlspecialchars(strtr($message['body'], array('&nbsp;' => ' ', '<br>' => "\n", '&#91;' => '[', '&#93;' => ']', '&#58;' => ':', '&#64;' => '@')));
1946 2045
 
1947
-				if (empty($modSettings['search_method']) || $force_partial_word)
1948
-					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);
1949
-				else
1950
-					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);
2046
+				if (empty($modSettings['search_method']) || $force_partial_word) {
2047
+									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);
2048
+				} else {
2049
+									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);
2050
+				}
1951 2051
 
1952 2052
 				$message['body'] = '';
1953 2053
 				foreach ($matches[0] as $index => $match)
@@ -1960,8 +2060,7 @@  discard block
 block discarded – undo
1960 2060
 			// Re-fix the international characters.
1961 2061
 			$message['body'] = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']);
1962 2062
 		}
1963
-	}
1964
-	else
2063
+	} else
1965 2064
 	{
1966 2065
 		// Run BBC interpreter on the message.
1967 2066
 		$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
@@ -1980,21 +2079,26 @@  discard block
 block discarded – undo
1980 2079
 	// Sadly, we need to check the icon ain't broke.
1981 2080
 	if (!empty($modSettings['messageIconChecks_enable']))
1982 2081
 	{
1983
-		if (!isset($context['icon_sources'][$message['first_icon']]))
1984
-			$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1985
-		if (!isset($context['icon_sources'][$message['last_icon']]))
1986
-			$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1987
-		if (!isset($context['icon_sources'][$message['icon']]))
1988
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1989
-	}
1990
-	else
2082
+		if (!isset($context['icon_sources'][$message['first_icon']])) {
2083
+					$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
2084
+		}
2085
+		if (!isset($context['icon_sources'][$message['last_icon']])) {
2086
+					$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
2087
+		}
2088
+		if (!isset($context['icon_sources'][$message['icon']])) {
2089
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
2090
+		}
2091
+	} else
1991 2092
 	{
1992
-		if (!isset($context['icon_sources'][$message['first_icon']]))
1993
-			$context['icon_sources'][$message['first_icon']] = 'images_url';
1994
-		if (!isset($context['icon_sources'][$message['last_icon']]))
1995
-			$context['icon_sources'][$message['last_icon']] = 'images_url';
1996
-		if (!isset($context['icon_sources'][$message['icon']]))
1997
-			$context['icon_sources'][$message['icon']] = 'images_url';
2093
+		if (!isset($context['icon_sources'][$message['first_icon']])) {
2094
+					$context['icon_sources'][$message['first_icon']] = 'images_url';
2095
+		}
2096
+		if (!isset($context['icon_sources'][$message['last_icon']])) {
2097
+					$context['icon_sources'][$message['last_icon']] = 'images_url';
2098
+		}
2099
+		if (!isset($context['icon_sources'][$message['icon']])) {
2100
+					$context['icon_sources'][$message['icon']] = 'images_url';
2101
+		}
1998 2102
 	}
1999 2103
 
2000 2104
 	// Do we have quote tag enabled?
@@ -2004,12 +2108,14 @@  discard block
 block discarded – undo
2004 2108
 	$colorClass = 'windowbg';
2005 2109
 
2006 2110
 	// Sticky topics should get a different color, too.
2007
-	if ($message['is_sticky'])
2008
-		$colorClass .= ' sticky';
2111
+	if ($message['is_sticky']) {
2112
+			$colorClass .= ' sticky';
2113
+	}
2009 2114
 
2010 2115
 	// Locked topics get special treatment as well.
2011
-	if ($message['locked'])
2012
-		$colorClass .= ' locked';
2116
+	if ($message['locked']) {
2117
+			$colorClass .= ' locked';
2118
+	}
2013 2119
 
2014 2120
 	$output = array_merge($context['topics'][$message['id_msg']], array(
2015 2121
 		'id' => $message['id_topic'],
@@ -2153,8 +2259,9 @@  discard block
 block discarded – undo
2153 2259
 
2154 2260
 	// Load up the search API we are going to use.
2155 2261
 	$modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
2156
-	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'))
2157
-		fatal_lang_error('search_api_missing');
2262
+	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) {
2263
+			fatal_lang_error('search_api_missing');
2264
+	}
2158 2265
 	require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
2159 2266
 
2160 2267
 	// 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/Likes.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	public function get($property = '')
168 168
 	{
169 169
 		// All properties inside Likes are protected, thus, an underscore is used.
170
-		$property = '_'. $property;
170
+		$property = '_' . $property;
171 171
 		return property_exists($this, $property) ? $this->$property : false;
172 172
 	}
173 173
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 
572 572
 			// Nope?  then just do a redirect to whatever URL was provided.
573 573
 			else
574
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
574
+				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : '');
575 575
 
576 576
 			return;
577 577
 		}
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 			if (in_array($this->_sa, $generic))
589 589
 			{
590 590
 				$context['sub_template'] = 'generic';
591
-				$context['data'] = isset($txt['like_'. $this->_data]) ? $txt['like_'. $this->_data] : $this->_data;
591
+				$context['data'] = isset($txt['like_' . $this->_data]) ? $txt['like_' . $this->_data] : $this->_data;
592 592
 			}
593 593
 
594 594
 			// Directly pass the current called sub-action and the data generated by its associated Method.
Please login to merge, or discard this patch.
Braces   +106 added lines, -77 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Class Likes
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 		$this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false;
109 110
 
110 111
 		// We do not want to output debug information here.
111
-		if ($this->_js)
112
-			$db_show_debug = false;
112
+		if ($this->_js) {
113
+					$db_show_debug = false;
114
+		}
113 115
 	}
114 116
 
115 117
 	/**
@@ -143,8 +145,9 @@  discard block
 block discarded – undo
143 145
 			$call = $this->_sa;
144 146
 
145 147
 			// Guest can only view likes.
146
-			if ($call != 'view')
147
-				is_not_guest();
148
+			if ($call != 'view') {
149
+							is_not_guest();
150
+			}
148 151
 
149 152
 			checkSession('get');
150 153
 
@@ -182,15 +185,17 @@  discard block
 block discarded – undo
182 185
 		global $smcFunc, $modSettings;
183 186
 
184 187
 		// This feature is currently disable.
185
-		if (empty($modSettings['enable_likes']))
186
-			return $this->_error = 'like_disable';
188
+		if (empty($modSettings['enable_likes'])) {
189
+					return $this->_error = 'like_disable';
190
+		}
187 191
 
188 192
 		// Zerothly, they did indicate some kind of content to like, right?
189 193
 		preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches);
190 194
 		$this->_type = isset($matches[1]) ? $matches[1] : '';
191 195
 
192
-		if ($this->_type == '' || $this->_content <= 0)
193
-			return $this->_error = 'cannot_';
196
+		if ($this->_type == '' || $this->_content <= 0) {
197
+					return $this->_error = 'cannot_';
198
+		}
194 199
 
195 200
 		// First we need to verify if the user can see the type of content or not. This is set up to be extensible,
196 201
 		// so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks.
@@ -209,12 +214,14 @@  discard block
 block discarded – undo
209 214
 					'msg' => $this->_content,
210 215
 				)
211 216
 			);
212
-			if ($smcFunc['db_num_rows']($request) == 1)
213
-				list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
217
+			if ($smcFunc['db_num_rows']($request) == 1) {
218
+							list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
219
+			}
214 220
 
215 221
 			$smcFunc['db_free_result']($request);
216
-			if (empty($this->_idTopic))
217
-				return $this->_error = 'cannot_';
222
+			if (empty($this->_idTopic)) {
223
+							return $this->_error = 'cannot_';
224
+			}
218 225
 
219 226
 			// So we know what topic it's in and more importantly we know the user can see it.
220 227
 			// If we're not viewing, we need some info set up.
@@ -224,9 +231,7 @@  discard block
 block discarded – undo
224 231
 			$this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes';
225 232
 
226 233
 			$this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content'));
227
-		}
228
-
229
-		else
234
+		} else
230 235
 		{
231 236
 			// Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1
232 237
 			// When you hook this, check $this->_type first. If it is not something your mod worries about, return false.
@@ -244,8 +249,9 @@  discard block
 block discarded – undo
244 249
 					if ($result !== false)
245 250
 					{
246 251
 						// Match the type with what we already have.
247
-						if (!isset($result['type']) || $result['type'] != $this->_type)
248
-							return $this->_error = 'not_valid_like_type';
252
+						if (!isset($result['type']) || $result['type'] != $this->_type) {
253
+													return $this->_error = 'not_valid_like_type';
254
+						}
249 255
 
250 256
 						// Fill out the rest.
251 257
 						$this->_type = $result['type'];
@@ -256,17 +262,20 @@  discard block
 block discarded – undo
256 262
 				}
257 263
 			}
258 264
 
259
-			if (!$found)
260
-				return $this->_error = 'cannot_';
265
+			if (!$found) {
266
+							return $this->_error = 'cannot_';
267
+			}
261 268
 		}
262 269
 
263 270
 		// Does the user can see this?
264
-		if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see']))
265
-			return $this->_error = $this->_validLikes['can_see'];
271
+		if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) {
272
+					return $this->_error = $this->_validLikes['can_see'];
273
+		}
266 274
 
267 275
 		// Does the user can like this? Viewing a list of likes doesn't require this permission.
268
-			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like']))
269
-				return $this->_error = $this->_validLikes['can_like'];
276
+			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) {
277
+							return $this->_error = $this->_validLikes['can_like'];
278
+			}
270 279
 	}
271 280
 
272 281
 	/**
@@ -291,8 +300,9 @@  discard block
 block discarded – undo
291 300
 		);
292 301
 
293 302
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
294
-		if ($this->_sa == __FUNCTION__)
295
-			$this->_data = __FUNCTION__;
303
+		if ($this->_sa == __FUNCTION__) {
304
+					$this->_data = __FUNCTION__;
305
+		}
296 306
 	}
297 307
 
298 308
 	/**
@@ -322,8 +332,8 @@  discard block
 block discarded – undo
322 332
 
323 333
 		// Add a background task to process sending alerts.
324 334
 		// Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this.
325
-		if ($this->_type == 'msg')
326
-			$smcFunc['db_insert']('insert',
335
+		if ($this->_type == 'msg') {
336
+					$smcFunc['db_insert']('insert',
327 337
 				'{db_prefix}background_tasks',
328 338
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
329 339
 				array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array(
@@ -335,10 +345,12 @@  discard block
 block discarded – undo
335 345
 				)), 0),
336 346
 				array('id_task')
337 347
 			);
348
+		}
338 349
 
339 350
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
340
-		if ($this->_sa == __FUNCTION__)
341
-			$this->_data = __FUNCTION__;
351
+		if ($this->_sa == __FUNCTION__) {
352
+					$this->_data = __FUNCTION__;
353
+		}
342 354
 	}
343 355
 
344 356
 	/**
@@ -364,8 +376,9 @@  discard block
 block discarded – undo
364 376
 		$smcFunc['db_free_result']($request);
365 377
 
366 378
 		// If you want to call this directly, fill out _data property too.
367
-		if ($this->_sa == __FUNCTION__)
368
-			$this->_data = $this->_numLikes;
379
+		if ($this->_sa == __FUNCTION__) {
380
+					$this->_data = $this->_numLikes;
381
+		}
369 382
 	}
370 383
 
371 384
 	/**
@@ -378,8 +391,9 @@  discard block
 block discarded – undo
378 391
 		global $smcFunc;
379 392
 
380 393
 		// Safety first!
381
-		if (empty($this->_type) || empty($this->_content))
382
-			return $this->_error = 'cannot_';
394
+		if (empty($this->_type) || empty($this->_content)) {
395
+					return $this->_error = 'cannot_';
396
+		}
383 397
 
384 398
 		// Do we already like this?
385 399
 		$request = $smcFunc['db_query']('', '
@@ -397,26 +411,28 @@  discard block
 block discarded – undo
397 411
 		$this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0;
398 412
 		$smcFunc['db_free_result']($request);
399 413
 
400
-		if ($this->_alreadyLiked)
401
-			$this->delete();
402
-
403
-		else
404
-			$this->insert();
414
+		if ($this->_alreadyLiked) {
415
+					$this->delete();
416
+		} else {
417
+					$this->insert();
418
+		}
405 419
 
406 420
 		// Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable.
407 421
 		$this->_count();
408 422
 
409 423
 		// Update the likes count for messages.
410
-		if ($this->_type == 'msg')
411
-			$this->msgIssueLike();
424
+		if ($this->_type == 'msg') {
425
+					$this->msgIssueLike();
426
+		}
412 427
 
413 428
 		// Any callbacks?
414 429
 		elseif (!empty($this->_validLikes['callback']))
415 430
 		{
416 431
 			$call = call_helper($this->_validLikes['callback'], true);
417 432
 
418
-			if (!empty($call))
419
-				call_user_func_array($call, array($this));
433
+			if (!empty($call)) {
434
+							call_user_func_array($call, array($this));
435
+			}
420 436
 		}
421 437
 
422 438
 		// Sometimes there might be other things that need updating after we do this like.
@@ -425,8 +441,9 @@  discard block
 block discarded – undo
425 441
 		// Now some clean up. This is provided here for any like handlers that want to do any cache flushing.
426 442
 		// This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so
427 443
 		// in integrate_valid_likes where it absolutely has to exist.
428
-		if (!empty($this->_validLikes['flush_cache']))
429
-			cache_put_data($this->_validLikes['flush_cache'], null);
444
+		if (!empty($this->_validLikes['flush_cache'])) {
445
+					cache_put_data($this->_validLikes['flush_cache'], null);
446
+		}
430 447
 
431 448
 		// All done, start building the data to pass as response.
432 449
 		$this->_data = array(
@@ -450,8 +467,9 @@  discard block
 block discarded – undo
450 467
 	{
451 468
 		global $smcFunc;
452 469
 
453
-		if ($this->_type !== 'msg')
454
-			return;
470
+		if ($this->_type !== 'msg') {
471
+					return;
472
+		}
455 473
 
456 474
 		$smcFunc['db_query']('', '
457 475
 			UPDATE {db_prefix}messages
@@ -492,8 +510,9 @@  discard block
 block discarded – undo
492 510
 				'like_type' => $this->_type,
493 511
 			)
494 512
 		);
495
-		while ($row = $smcFunc['db_fetch_assoc']($request))
496
-			$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
513
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
514
+					$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
515
+		}
497 516
 
498 517
 		// Now to get member data, including avatars and so on.
499 518
 		$members = array_keys($context['likers']);
@@ -501,8 +520,9 @@  discard block
 block discarded – undo
501 520
 		if (count($loaded) != count($members))
502 521
 		{
503 522
 			$members = array_diff($members, $loaded);
504
-			foreach ($members as $not_loaded)
505
-				unset ($context['likers'][$not_loaded]);
523
+			foreach ($members as $not_loaded) {
524
+							unset ($context['likers'][$not_loaded]);
525
+			}
506 526
 		}
507 527
 
508 528
 		foreach ($context['likers'] as $liker => $dummy)
@@ -544,12 +564,14 @@  discard block
 block discarded – undo
544 564
 		global $context, $txt;
545 565
 
546 566
 		// Don't do anything if someone else has already take care of the response.
547
-		if (!$this->_setResponse)
548
-			return;
567
+		if (!$this->_setResponse) {
568
+					return;
569
+		}
549 570
 
550 571
 		// Want a json response huh?
551
-		if ($this->_validLikes['json'])
552
-			return $this->jsonResponse();
572
+		if ($this->_validLikes['json']) {
573
+					return $this->jsonResponse();
574
+		}
553 575
 
554 576
 		// Set everything up for display.
555 577
 		loadTemplate('Likes');
@@ -559,8 +581,9 @@  discard block
 block discarded – undo
559 581
 		if ($this->_error)
560 582
 		{
561 583
 			// If this is a generic error, set it up good.
562
-			if ($this->_error == 'cannot_')
563
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
584
+			if ($this->_error == 'cannot_') {
585
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
586
+			}
564 587
 
565 588
 			// Is this request coming from an ajax call?
566 589
 			if ($this->_js)
@@ -570,8 +593,9 @@  discard block
 block discarded – undo
570 593
 			}
571 594
 
572 595
 			// Nope?  then just do a redirect to whatever URL was provided.
573
-			else
574
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
596
+			else {
597
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
598
+			}
575 599
 
576 600
 			return;
577 601
 		}
@@ -580,8 +604,9 @@  discard block
 block discarded – undo
580 604
 		else
581 605
 		{
582 606
 			// Not an ajax request so send the user back to the previous location or the main page.
583
-			if (!$this->_js)
584
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
607
+			if (!$this->_js) {
608
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
609
+			}
585 610
 
586 611
 			// These fine gentlemen all share the same template.
587 612
 			$generic = array('delete', 'insert', '_count');
@@ -612,8 +637,9 @@  discard block
 block discarded – undo
612 637
 		// If there is an error, send it.
613 638
 		if ($this->_error)
614 639
 		{
615
-			if ($this->_error == 'cannot_')
616
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
640
+			if ($this->_error == 'cannot_') {
641
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
642
+			}
617 643
 
618 644
 			$print['error'] = $this->_error;
619 645
 		}
@@ -649,33 +675,36 @@  discard block
 block discarded – undo
649 675
 	<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
650 676
 		<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
651 677
 
652
-	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2'))
653
-		$_GET['verse'] = '4:16';
678
+	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) {
679
+			$_GET['verse'] = '4:16';
680
+	}
654 681
 
655
-	if ($_GET['verse'] == '2:18')
656
-		echo '
682
+	if ($_GET['verse'] == '2:18') {
683
+			echo '
657 684
 			Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
658
-	elseif ($_GET['verse'] == '4:16')
659
-		echo '
685
+	} elseif ($_GET['verse'] == '4:16') {
686
+			echo '
660 687
 			And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together.&nbsp; Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
661
-	elseif ($_GET['verse'] == '22:1-2')
662
-		echo '
688
+	} elseif ($_GET['verse'] == '22:1-2') {
689
+			echo '
663 690
 			<p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer.&nbsp; Alas, it needed more than <em>only one</em>, but yet even thought otherwise.&nbsp; It became that the opposition <em>rumored</em> and lied, but still to no avail.&nbsp; Their match, though not <em>perfect</em>, had them outdone.</p>
664 691
 			<p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue.&nbsp; <em>The end</em>.</p>';
692
+	}
665 693
 
666 694
 	echo '
667 695
 		</div>
668 696
 		<div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
669 697
 
670
-	if ($_GET['verse'] == '2:18')
671
-		echo '
698
+	if ($_GET['verse'] == '2:18') {
699
+			echo '
672 700
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
673
-	elseif ($_GET['verse'] == '4:16')
674
-		echo '
701
+	} elseif ($_GET['verse'] == '4:16') {
702
+			echo '
675 703
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
676
-	elseif ($_GET['verse'] == '22:1-2')
677
-		echo '
704
+	} elseif ($_GET['verse'] == '22:1-2') {
705
+			echo '
678 706
 			from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>';
707
+	}
679 708
 
680 709
 	echo '
681 710
 		</div>
Please login to merge, or discard this patch.