Completed
Push — release-2.1 ( 72357d...5fd6f8 )
by Michael
22s
created
Sources/Logging.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 /**
20 20
  * Truncate the GET array to a specified length
21 21
  * @param array $arr The array to truncate
22
- * @param max_length $max_length The upperbound on the length
22
+ * @param integer $max_length The upperbound on the length
23 23
  *
24 24
  * @return array The truncated array
25 25
  */
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array The truncated array
25 25
  */
26
-function truncateArray($arr, $max_length=1900)
26
+function truncateArray($arr, $max_length = 1900)
27 27
 {
28 28
 	$curr_length = array_sum(array_map("strlen", $arr));
29 29
 	if ($curr_length <= $max_length)
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	else
32 32
 	{
33 33
 		// Truncate each element's value to a reasonable length
34
-		$param_max = floor($max_length/count($arr));
34
+		$param_max = floor($max_length / count($arr));
35 35
 		foreach ($arr as $key => &$value)
36 36
 			$value = substr($value, 0, $param_max - strlen($key) - 5);
37 37
 		return $arr;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change)
198 198
 	{
199 199
 		// Write the change
200
-		$write_db_change =  '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
200
+		$write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
201 201
 		$written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX);
202 202
 
203 203
 		// survey says ...
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br>
271 271
 	', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br>
272 272
 	', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br>
273
-	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
273
+	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), '
274 274
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
275 275
 
276 276
 	if (function_exists('memory_get_peak_usage'))
Please login to merge, or discard this patch.
Braces   +140 added lines, -101 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Truncate the GET array to a specified length
@@ -26,14 +27,15 @@  discard block
 block discarded – undo
26 27
 function truncateArray($arr, $max_length=1900)
27 28
 {
28 29
 	$curr_length = array_sum(array_map("strlen", $arr));
29
-	if ($curr_length <= $max_length)
30
-		return $arr;
31
-	else
30
+	if ($curr_length <= $max_length) {
31
+			return $arr;
32
+	} else
32 33
 	{
33 34
 		// Truncate each element's value to a reasonable length
34 35
 		$param_max = floor($max_length/count($arr));
35
-		foreach ($arr as $key => &$value)
36
-			$value = substr($value, 0, $param_max - strlen($key) - 5);
36
+		foreach ($arr as $key => &$value) {
37
+					$value = substr($value, 0, $param_max - strlen($key) - 5);
38
+		}
37 39
 		return $arr;
38 40
 	}
39 41
 }
@@ -55,8 +57,9 @@  discard block
 block discarded – undo
55 57
 		// Don't update for every page - this isn't wholly accurate but who cares.
56 58
 		if ($topic)
57 59
 		{
58
-			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
59
-				$force = false;
60
+			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
61
+							$force = false;
62
+			}
60 63
 			$_SESSION['last_topic_id'] = $topic;
61 64
 		}
62 65
 	}
@@ -69,22 +72,24 @@  discard block
 block discarded – undo
69 72
 	}
70 73
 
71 74
 	// Don't mark them as online more than every so often.
72
-	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
73
-		return;
75
+	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {
76
+			return;
77
+	}
74 78
 
75 79
 	if (!empty($modSettings['who_enabled']))
76 80
 	{
77 81
 		$encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
78 82
 
79 83
 		// In the case of a dlattach action, session_var may not be set.
80
-		if (!isset($context['session_var']))
81
-			$context['session_var'] = $_SESSION['session_var'];
84
+		if (!isset($context['session_var'])) {
85
+					$context['session_var'] = $_SESSION['session_var'];
86
+		}
82 87
 
83 88
 		unset($encoded_get['sesc'], $encoded_get[$context['session_var']]);
84 89
 		$encoded_get = $smcFunc['json_encode']($encoded_get);
90
+	} else {
91
+			$encoded_get = '';
85 92
 	}
86
-	else
87
-		$encoded_get = '';
88 93
 
89 94
 	// Guests use 0, members use their session ID.
90 95
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
@@ -124,17 +129,18 @@  discard block
 block discarded – undo
124 129
 		);
125 130
 
126 131
 		// Guess it got deleted.
127
-		if ($smcFunc['db_affected_rows']() == 0)
132
+		if ($smcFunc['db_affected_rows']() == 0) {
133
+					$_SESSION['log_time'] = 0;
134
+		}
135
+	} else {
128 136
 			$_SESSION['log_time'] = 0;
129 137
 	}
130
-	else
131
-		$_SESSION['log_time'] = 0;
132 138
 
133 139
 	// Otherwise, we have to delete and insert.
134 140
 	if (empty($_SESSION['log_time']))
135 141
 	{
136
-		if ($do_delete || !empty($user_info['id']))
137
-			$smcFunc['db_query']('', '
142
+		if ($do_delete || !empty($user_info['id'])) {
143
+					$smcFunc['db_query']('', '
138 144
 				DELETE FROM {db_prefix}log_online
139 145
 				WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'),
140 146
 				array(
@@ -142,6 +148,7 @@  discard block
 block discarded – undo
142 148
 					'log_time' => time() - $modSettings['lastActive'] * 60,
143 149
 				)
144 150
 			);
151
+		}
145 152
 
146 153
 		$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
147 154
 			'{db_prefix}log_online',
@@ -155,21 +162,24 @@  discard block
 block discarded – undo
155 162
 	$_SESSION['log_time'] = time();
156 163
 
157 164
 	// Well, they are online now.
158
-	if (empty($_SESSION['timeOnlineUpdated']))
159
-		$_SESSION['timeOnlineUpdated'] = time();
165
+	if (empty($_SESSION['timeOnlineUpdated'])) {
166
+			$_SESSION['timeOnlineUpdated'] = time();
167
+	}
160 168
 
161 169
 	// Set their login time, if not already done within the last minute.
162 170
 	if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa'))))
163 171
 	{
164 172
 		// Don't count longer than 15 minutes.
165
-		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
166
-			$_SESSION['timeOnlineUpdated'] = time();
173
+		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
174
+					$_SESSION['timeOnlineUpdated'] = time();
175
+		}
167 176
 
168 177
 		$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
169 178
 		updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in']));
170 179
 
171
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
172
-			cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
180
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
181
+					cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
182
+		}
173 183
 
174 184
 		$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
175 185
 		$_SESSION['timeOnlineUpdated'] = time();
@@ -206,8 +216,7 @@  discard block
 block discarded – undo
206 216
 			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
207 217
 			// Copy the file back and run for your life!
208 218
 			@copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php');
209
-		}
210
-		else
219
+		} else
211 220
 		{
212 221
 			@touch($boarddir . '/' . 'Settings.php');
213 222
 			return true;
@@ -227,22 +236,27 @@  discard block
 block discarded – undo
227 236
 	global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt;
228 237
 
229 238
 	// Add to Settings.php if you want to show the debugging information.
230
-	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery'))
231
-		return;
239
+	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) {
240
+			return;
241
+	}
232 242
 
233
-	if (empty($_SESSION['view_queries']))
234
-		$_SESSION['view_queries'] = 0;
235
-	if (empty($context['debug']['language_files']))
236
-		$context['debug']['language_files'] = array();
237
-	if (empty($context['debug']['sheets']))
238
-		$context['debug']['sheets'] = array();
243
+	if (empty($_SESSION['view_queries'])) {
244
+			$_SESSION['view_queries'] = 0;
245
+	}
246
+	if (empty($context['debug']['language_files'])) {
247
+			$context['debug']['language_files'] = array();
248
+	}
249
+	if (empty($context['debug']['sheets'])) {
250
+			$context['debug']['sheets'] = array();
251
+	}
239 252
 
240 253
 	$files = get_included_files();
241 254
 	$total_size = 0;
242 255
 	for ($i = 0, $n = count($files); $i < $n; $i++)
243 256
 	{
244
-		if (file_exists($files[$i]))
245
-			$total_size += filesize($files[$i]);
257
+		if (file_exists($files[$i])) {
258
+					$total_size += filesize($files[$i]);
259
+		}
246 260
 		$files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)'));
247 261
 	}
248 262
 
@@ -251,8 +265,9 @@  discard block
 block discarded – undo
251 265
 	{
252 266
 		foreach ($db_cache as $q => $qq)
253 267
 		{
254
-			if (!empty($qq['w']))
255
-				$warnings += count($qq['w']);
268
+			if (!empty($qq['w'])) {
269
+							$warnings += count($qq['w']);
270
+			}
256 271
 		}
257 272
 
258 273
 		$_SESSION['debug'] = &$db_cache;
@@ -273,12 +288,14 @@  discard block
 block discarded – undo
273 288
 	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
274 289
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
275 290
 
276
-	if (function_exists('memory_get_peak_usage'))
277
-		echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
291
+	if (function_exists('memory_get_peak_usage')) {
292
+			echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
293
+	}
278 294
 
279 295
 	// What tokens are active?
280
-	if (isset($_SESSION['token']))
281
-		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
296
+	if (isset($_SESSION['token'])) {
297
+			echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
298
+	}
282 299
 
283 300
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
284 301
 	{
@@ -292,10 +309,12 @@  discard block
 block discarded – undo
292 309
 			$total_t += $cache_hit['t'];
293 310
 			$total_s += $cache_hit['s'];
294 311
 		}
295
-		if (!isset($cache_misses))
296
-			$cache_misses = array();
297
-		foreach ($cache_misses as $missed)
298
-			$missed_entries[] = $missed['d'] . ' ' . $missed['k'];
312
+		if (!isset($cache_misses)) {
313
+					$cache_misses = array();
314
+		}
315
+		foreach ($cache_misses as $missed) {
316
+					$missed_entries[] = $missed['d'] . ' ' . $missed['k'];
317
+		}
299 318
 
300 319
 		echo '
301 320
 	', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br>
@@ -306,38 +325,44 @@  discard block
 block discarded – undo
306 325
 	<a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br>
307 326
 	<br>';
308 327
 
309
-	if ($_SESSION['view_queries'] == 1 && !empty($db_cache))
310
-		foreach ($db_cache as $q => $qq)
328
+	if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
329
+			foreach ($db_cache as $q => $qq)
311 330
 		{
312 331
 			$is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0;
332
+	}
313 333
 			// Temporary tables created in earlier queries are not explainable.
314 334
 			if ($is_select)
315 335
 			{
316
-				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
317
-					if (strpos(trim($qq['q']), $tmp) !== false)
336
+				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
337
+									if (strpos(trim($qq['q']), $tmp) !== false)
318 338
 					{
319 339
 						$is_select = false;
340
+				}
320 341
 						break;
321 342
 					}
322 343
 			}
323 344
 			// But actual creation of the temporary tables are.
324
-			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0)
325
-				$is_select = true;
345
+			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) {
346
+							$is_select = true;
347
+			}
326 348
 
327 349
 			// Make the filenames look a bit better.
328
-			if (isset($qq['f']))
329
-				$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
350
+			if (isset($qq['f'])) {
351
+							$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
352
+			}
330 353
 
331 354
 			echo '
332 355
 	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br>
333 356
 	&nbsp;&nbsp;&nbsp;';
334
-			if (!empty($qq['f']) && !empty($qq['l']))
335
-				echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
357
+			if (!empty($qq['f']) && !empty($qq['l'])) {
358
+							echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
359
+			}
336 360
 
337
-			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
338
-				echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
339
-			elseif (isset($qq['t']))
340
-				echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
361
+			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) {
362
+							echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
363
+			} elseif (isset($qq['t'])) {
364
+							echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
365
+			}
341 366
 			echo '
342 367
 	<br>';
343 368
 		}
@@ -362,12 +387,14 @@  discard block
 block discarded – undo
362 387
 	global $modSettings, $smcFunc;
363 388
 	static $cache_stats = array();
364 389
 
365
-	if (empty($modSettings['trackStats']))
366
-		return false;
367
-	if (!empty($stats))
368
-		return $cache_stats = array_merge($cache_stats, $stats);
369
-	elseif (empty($cache_stats))
370
-		return false;
390
+	if (empty($modSettings['trackStats'])) {
391
+			return false;
392
+	}
393
+	if (!empty($stats)) {
394
+			return $cache_stats = array_merge($cache_stats, $stats);
395
+	} elseif (empty($cache_stats)) {
396
+			return false;
397
+	}
371 398
 
372 399
 	$setStringUpdate = '';
373 400
 	$insert_keys = array();
@@ -380,10 +407,11 @@  discard block
 block discarded – undo
380 407
 		$setStringUpdate .= '
381 408
 			' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ',';
382 409
 
383
-		if ($change === '+')
384
-			$cache_stats[$field] = 1;
385
-		else
386
-			$update_parameters[$field] = $change;
410
+		if ($change === '+') {
411
+					$cache_stats[$field] = 1;
412
+		} else {
413
+					$update_parameters[$field] = $change;
414
+		}
387 415
 		$insert_keys[$field] = 'int';
388 416
 	}
389 417
 
@@ -447,43 +475,50 @@  discard block
 block discarded – undo
447 475
 	);
448 476
 
449 477
 	// Make sure this particular log is enabled first...
450
-	if (empty($modSettings['modlog_enabled']))
451
-		unset ($log_types['moderate']);
452
-	if (empty($modSettings['userlog_enabled']))
453
-		unset ($log_types['user']);
454
-	if (empty($modSettings['adminlog_enabled']))
455
-		unset ($log_types['admin']);
478
+	if (empty($modSettings['modlog_enabled'])) {
479
+			unset ($log_types['moderate']);
480
+	}
481
+	if (empty($modSettings['userlog_enabled'])) {
482
+			unset ($log_types['user']);
483
+	}
484
+	if (empty($modSettings['adminlog_enabled'])) {
485
+			unset ($log_types['admin']);
486
+	}
456 487
 
457 488
 	call_integration_hook('integrate_log_types', array(&$log_types));
458 489
 
459 490
 	foreach ($logs as $log)
460 491
 	{
461
-		if (!isset($log_types[$log['log_type']]))
462
-			return false;
492
+		if (!isset($log_types[$log['log_type']])) {
493
+					return false;
494
+		}
463 495
 
464
-		if (!is_array($log['extra']))
465
-			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
496
+		if (!is_array($log['extra'])) {
497
+					trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
498
+		}
466 499
 
467 500
 		// Pull out the parts we want to store separately, but also make sure that the data is proper
468 501
 		if (isset($log['extra']['topic']))
469 502
 		{
470
-			if (!is_numeric($log['extra']['topic']))
471
-				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
503
+			if (!is_numeric($log['extra']['topic'])) {
504
+							trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
505
+			}
472 506
 			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
473 507
 			unset($log['extra']['topic']);
508
+		} else {
509
+					$topic_id = 0;
474 510
 		}
475
-		else
476
-			$topic_id = 0;
477 511
 
478 512
 		if (isset($log['extra']['message']))
479 513
 		{
480
-			if (!is_numeric($log['extra']['message']))
481
-				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
514
+			if (!is_numeric($log['extra']['message'])) {
515
+							trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
516
+			}
482 517
 			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
483 518
 			unset($log['extra']['message']);
519
+		} else {
520
+					$msg_id = 0;
484 521
 		}
485
-		else
486
-			$msg_id = 0;
487 522
 
488 523
 		// @todo cache this?
489 524
 		// Is there an associated report on this?
@@ -510,23 +545,26 @@  discard block
 block discarded – undo
510 545
 			$smcFunc['db_free_result']($request);
511 546
 		}
512 547
 
513
-		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
514
-			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
548
+		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) {
549
+					trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
550
+		}
515 551
 
516 552
 		if (isset($log['extra']['board']))
517 553
 		{
518
-			if (!is_numeric($log['extra']['board']))
519
-				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
554
+			if (!is_numeric($log['extra']['board'])) {
555
+							trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
556
+			}
520 557
 			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
521 558
 			unset($log['extra']['board']);
559
+		} else {
560
+					$board_id = 0;
522 561
 		}
523
-		else
524
-			$board_id = 0;
525 562
 
526 563
 		if (isset($log['extra']['board_to']))
527 564
 		{
528
-			if (!is_numeric($log['extra']['board_to']))
529
-				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
565
+			if (!is_numeric($log['extra']['board_to'])) {
566
+							trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
567
+			}
530 568
 			if (empty($board_id))
531 569
 			{
532 570
 				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
@@ -534,10 +572,11 @@  discard block
 block discarded – undo
534 572
 			}
535 573
 		}
536 574
 
537
-		if (isset($log['extra']['member_affected']))
538
-			$memID = $log['extra']['member_affected'];
539
-		else
540
-			$memID = $user_info['id'];
575
+		if (isset($log['extra']['member_affected'])) {
576
+					$memID = $log['extra']['member_affected'];
577
+		} else {
578
+					$memID = $user_info['id'];
579
+		}
541 580
 
542 581
 		$inserts[] = array(
543 582
 			time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'],
Please login to merge, or discard this patch.
Sources/ManageServer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 		while ($row = $smcFunc['db_fetch_assoc']($request))
240 240
 			$fts_language[$row['cfgname']] = $row['cfgname'];
241 241
 		
242
-		$config_vars = array_merge ($config_vars, array(
242
+		$config_vars = array_merge($config_vars, array(
243 243
 				'',
244 244
 				array('search_language', $txt['search_language'], 'db', 'select', $fts_language, 'pgFulltextSearch')
245 245
 			)
Please login to merge, or discard this patch.
Braces   +265 added lines, -204 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
  * @version 2.1 Beta 4
60 60
  */
61 61
 
62
-if (!defined('SMF'))
62
+if (!defined('SMF')) {
63 63
 	die('No direct access...');
64
+}
64 65
 
65 66
 /**
66 67
  * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
@@ -111,10 +112,11 @@  discard block
 block discarded – undo
111 112
 	$settings_not_writable = !is_writable($boarddir . '/Settings.php');
112 113
 	$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
113 114
 
114
-	if ($settings_not_writable)
115
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
116
-	elseif ($settings_backup_fail)
117
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
115
+	if ($settings_not_writable) {
116
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
117
+	} elseif ($settings_backup_fail) {
118
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
119
+	}
118 120
 
119 121
 	$context['settings_not_writable'] = $settings_not_writable;
120 122
 
@@ -168,8 +170,9 @@  discard block
 block discarded – undo
168 170
 
169 171
 	call_integration_hook('integrate_general_settings', array(&$config_vars));
170 172
 
171
-	if ($return_config)
172
-		return $config_vars;
173
+	if ($return_config) {
174
+			return $config_vars;
175
+	}
173 176
 
174 177
 	// Setup the template stuff.
175 178
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
@@ -186,8 +189,9 @@  discard block
 block discarded – undo
186 189
 			$registerSMStats = registerSMStats();
187 190
 
188 191
 			// Failed to register, disable it again.
189
-			if (empty($registerSMStats))
190
-				$_POST['enable_sm_stats'] = 0;
192
+			if (empty($registerSMStats)) {
193
+							$_POST['enable_sm_stats'] = 0;
194
+			}
191 195
 		}
192 196
 
193 197
 		saveSettings($config_vars);
@@ -248,8 +252,9 @@  discard block
 block discarded – undo
248 252
 		$request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array());
249 253
 		$fts_language = array();
250 254
 
251
-		while ($row = $smcFunc['db_fetch_assoc']($request))
252
-			$fts_language[$row['cfgname']] = $row['cfgname'];
255
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
256
+					$fts_language[$row['cfgname']] = $row['cfgname'];
257
+		}
253 258
 
254 259
 		$config_vars = array_merge ($config_vars, array(
255 260
 				'',
@@ -261,8 +266,9 @@  discard block
 block discarded – undo
261 266
 
262 267
 	call_integration_hook('integrate_database_settings', array(&$config_vars));
263 268
 
264
-	if ($return_config)
265
-		return $config_vars;
269
+	if ($return_config) {
270
+			return $config_vars;
271
+	}
266 272
 
267 273
 	// Setup the template stuff.
268 274
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save';
@@ -337,13 +343,15 @@  discard block
 block discarded – undo
337 343
 		hideGlobalCookies();
338 344
 	});', true);
339 345
 
340
-	if (empty($user_settings['tfa_secret']))
341
-		addInlineJavaScript('');
346
+	if (empty($user_settings['tfa_secret'])) {
347
+			addInlineJavaScript('');
348
+	}
342 349
 
343 350
 	call_integration_hook('integrate_cookie_settings', array(&$config_vars));
344 351
 
345
-	if ($return_config)
346
-		return $config_vars;
352
+	if ($return_config) {
353
+			return $config_vars;
354
+	}
347 355
 
348 356
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
349 357
 	$context['settings_title'] = $txt['cookies_sessions_settings'];
@@ -354,11 +362,13 @@  discard block
 block discarded – undo
354 362
 		call_integration_hook('integrate_save_cookie_settings');
355 363
 
356 364
 		// Local and global do not play nicely together.
357
-		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies']))
358
-			unset ($_POST['globalCookies']);
365
+		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) {
366
+					unset ($_POST['globalCookies']);
367
+		}
359 368
 
360
-		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false)
361
-			fatal_lang_error('invalid_cookie_domain', false);
369
+		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) {
370
+					fatal_lang_error('invalid_cookie_domain', false);
371
+		}
362 372
 
363 373
 		saveSettings($config_vars);
364 374
 
@@ -441,8 +451,9 @@  discard block
 block discarded – undo
441 451
 
442 452
 	call_integration_hook('integrate_general_security_settings', array(&$config_vars));
443 453
 
444
-	if ($return_config)
445
-		return $config_vars;
454
+	if ($return_config) {
455
+			return $config_vars;
456
+	}
446 457
 
447 458
 	// Saving?
448 459
 	if (isset($_GET['save']))
@@ -481,8 +492,7 @@  discard block
 block discarded – undo
481 492
 		$txt['cache_settings_message'] = $txt['detected_no_caching'];
482 493
 		$cache_level = array($txt['cache_off']);
483 494
 		$detected['none'] = $txt['cache_off'];
484
-	}
485
-	else
495
+	} else
486 496
 	{
487 497
 		$txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
488 498
 		$cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
@@ -519,8 +529,9 @@  discard block
 block discarded – undo
519 529
 			}
520 530
 		}
521 531
 	}
522
-	if ($return_config)
523
-		return $config_vars;
532
+	if ($return_config) {
533
+			return $config_vars;
534
+	}
524 535
 
525 536
 	// Saving again?
526 537
 	if (isset($_GET['save']))
@@ -548,8 +559,9 @@  discard block
 block discarded – undo
548 559
 	$context['save_disabled'] = $context['settings_not_writable'];
549 560
 
550 561
 	// Decide what message to show.
551
-	if (!$context['save_disabled'])
552
-		$context['settings_message'] = $txt['caching_information'];
562
+	if (!$context['save_disabled']) {
563
+			$context['settings_message'] = $txt['caching_information'];
564
+	}
553 565
 
554 566
 	// Prepare the template.
555 567
 	prepareServerSettingsContext($config_vars);
@@ -572,24 +584,25 @@  discard block
 block discarded – undo
572 584
 	if (stripos(PHP_OS, 'win') === 0)
573 585
 	{
574 586
 		$context['settings_message'] = $txt['loadavg_disabled_windows'];
575
-		if (isset($_GET['save']))
576
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
577
-	}
578
-	elseif (stripos(PHP_OS, 'darwin') === 0)
587
+		if (isset($_GET['save'])) {
588
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
589
+		}
590
+	} elseif (stripos(PHP_OS, 'darwin') === 0)
579 591
 	{
580 592
 		$context['settings_message'] = $txt['loadavg_disabled_osx'];
581
-		if (isset($_GET['save']))
582
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
583
-	}
584
-	else
593
+		if (isset($_GET['save'])) {
594
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
595
+		}
596
+	} else
585 597
 	{
586 598
 		$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
587
-		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0)
588
-			$modSettings['load_average'] = (float) $matches[1];
589
-		elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0)
590
-			$modSettings['load_average'] = (float) $matches[1];
591
-		else
592
-			unset($modSettings['load_average']);
599
+		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) {
600
+					$modSettings['load_average'] = (float) $matches[1];
601
+		} elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) {
602
+					$modSettings['load_average'] = (float) $matches[1];
603
+		} else {
604
+					unset($modSettings['load_average']);
605
+		}
593 606
 
594 607
 		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
595 608
 		{
@@ -625,8 +638,9 @@  discard block
 block discarded – undo
625 638
 
626 639
 	call_integration_hook('integrate_loadavg_settings', array(&$config_vars));
627 640
 
628
-	if ($return_config)
629
-		return $config_vars;
641
+	if ($return_config) {
642
+			return $config_vars;
643
+	}
630 644
 
631 645
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
632 646
 	$context['settings_title'] = $txt['load_balancing_settings'];
@@ -637,24 +651,27 @@  discard block
 block discarded – undo
637 651
 		// Stupidity is not allowed.
638 652
 		foreach ($_POST as $key => $value)
639 653
 		{
640
-			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values)))
641
-				continue;
642
-			else
643
-				$_POST[$key] = (float) $value;
644
-
645
-			if ($key == 'loadavg_auto_opt' && $value <= 1)
646
-				$_POST['loadavg_auto_opt'] = 1.0;
647
-			elseif ($key == 'loadavg_forum' && $value < 10)
648
-				$_POST['loadavg_forum'] = 10.0;
649
-			elseif ($value < 2)
650
-				$_POST[$key] = 2.0;
654
+			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) {
655
+							continue;
656
+			} else {
657
+							$_POST[$key] = (float) $value;
658
+			}
659
+
660
+			if ($key == 'loadavg_auto_opt' && $value <= 1) {
661
+							$_POST['loadavg_auto_opt'] = 1.0;
662
+			} elseif ($key == 'loadavg_forum' && $value < 10) {
663
+							$_POST['loadavg_forum'] = 10.0;
664
+			} elseif ($value < 2) {
665
+							$_POST[$key] = 2.0;
666
+			}
651 667
 		}
652 668
 
653 669
 		call_integration_hook('integrate_save_loadavg_settings');
654 670
 
655 671
 		saveDBSettings($config_vars);
656
-		if (!isset($_SESSION['adm-save']))
657
-			$_SESSION['adm-save'] = true;
672
+		if (!isset($_SESSION['adm-save'])) {
673
+					$_SESSION['adm-save'] = true;
674
+		}
658 675
 		redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
659 676
 	}
660 677
 
@@ -690,10 +707,11 @@  discard block
 block discarded – undo
690 707
 
691 708
 	if (isset($_SESSION['adm-save']))
692 709
 	{
693
-		if ($_SESSION['adm-save'] === true)
694
-			$context['saved_successful'] = true;
695
-		else
696
-			$context['saved_failed'] = $_SESSION['adm-save'];
710
+		if ($_SESSION['adm-save'] === true) {
711
+					$context['saved_successful'] = true;
712
+		} else {
713
+					$context['saved_failed'] = $_SESSION['adm-save'];
714
+		}
697 715
 
698 716
 		unset($_SESSION['adm-save']);
699 717
 	}
@@ -701,9 +719,9 @@  discard block
 block discarded – undo
701 719
 	$context['config_vars'] = array();
702 720
 	foreach ($config_vars as $identifier => $config_var)
703 721
 	{
704
-		if (!is_array($config_var) || !isset($config_var[1]))
705
-			$context['config_vars'][] = $config_var;
706
-		else
722
+		if (!is_array($config_var) || !isset($config_var[1])) {
723
+					$context['config_vars'][] = $config_var;
724
+		} else
707 725
 		{
708 726
 			$varname = $config_var[0];
709 727
 			global $$varname;
@@ -738,16 +756,19 @@  discard block
 block discarded – undo
738 756
 			if ($config_var[3] == 'int' || $config_var[3] == 'float')
739 757
 			{
740 758
 				// Default to a min of 0 if one isn't set
741
-				if (isset($config_var['min']))
742
-					$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
743
-				else
744
-					$context['config_vars'][$config_var[0]]['min'] = 0;
759
+				if (isset($config_var['min'])) {
760
+									$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
761
+				} else {
762
+									$context['config_vars'][$config_var[0]]['min'] = 0;
763
+				}
745 764
 
746
-				if (isset($config_var['max']))
747
-					$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
765
+				if (isset($config_var['max'])) {
766
+									$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
767
+				}
748 768
 
749
-				if (isset($config_var['step']))
750
-					$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
769
+				if (isset($config_var['step'])) {
770
+									$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
771
+				}
751 772
 			}
752 773
 
753 774
 			// If this is a select box handle any data.
@@ -755,12 +776,13 @@  discard block
 block discarded – undo
755 776
 			{
756 777
 				// If it's associative
757 778
 				$config_values = array_values($config_var[4]);
758
-				if (isset($config_values[0]) && is_array($config_values[0]))
759
-					$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
760
-				else
779
+				if (isset($config_values[0]) && is_array($config_values[0])) {
780
+									$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
781
+				} else
761 782
 				{
762
-					foreach ($config_var[4] as $key => $item)
763
-						$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
783
+					foreach ($config_var[4] as $key => $item) {
784
+											$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
785
+					}
764 786
 				}
765 787
 			}
766 788
 		}
@@ -785,10 +807,11 @@  discard block
 block discarded – undo
785 807
 
786 808
 	if (isset($_SESSION['adm-save']))
787 809
 	{
788
-		if ($_SESSION['adm-save'] === true)
789
-			$context['saved_successful'] = true;
790
-		else
791
-			$context['saved_failed'] = $_SESSION['adm-save'];
810
+		if ($_SESSION['adm-save'] === true) {
811
+					$context['saved_successful'] = true;
812
+		} else {
813
+					$context['saved_failed'] = $_SESSION['adm-save'];
814
+		}
792 815
 
793 816
 		unset($_SESSION['adm-save']);
794 817
 	}
@@ -800,26 +823,30 @@  discard block
 block discarded – undo
800 823
 	foreach ($config_vars as $config_var)
801 824
 	{
802 825
 		// HR?
803
-		if (!is_array($config_var))
804
-			$context['config_vars'][] = $config_var;
805
-		else
826
+		if (!is_array($config_var)) {
827
+					$context['config_vars'][] = $config_var;
828
+		} else
806 829
 		{
807 830
 			// If it has no name it doesn't have any purpose!
808
-			if (empty($config_var[1]))
809
-				continue;
831
+			if (empty($config_var[1])) {
832
+							continue;
833
+			}
810 834
 
811 835
 			// Special case for inline permissions
812
-			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
813
-				$inlinePermissions[] = $config_var[1];
814
-			elseif ($config_var[0] == 'permissions')
815
-				continue;
836
+			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) {
837
+							$inlinePermissions[] = $config_var[1];
838
+			} elseif ($config_var[0] == 'permissions') {
839
+							continue;
840
+			}
816 841
 
817
-			if ($config_var[0] == 'boards')
818
-				$board_list = true;
842
+			if ($config_var[0] == 'boards') {
843
+							$board_list = true;
844
+			}
819 845
 
820 846
 			// Are we showing the BBC selection box?
821
-			if ($config_var[0] == 'bbc')
822
-				$bbcChoice[] = $config_var[1];
847
+			if ($config_var[0] == 'bbc') {
848
+							$bbcChoice[] = $config_var[1];
849
+			}
823 850
 
824 851
 			// We need to do some parsing of the value before we pass it in.
825 852
 			if (isset($modSettings[$config_var[1]]))
@@ -838,8 +865,7 @@  discard block
 block discarded – undo
838 865
 					default:
839 866
 						$value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
840 867
 				}
841
-			}
842
-			else
868
+			} else
843 869
 			{
844 870
 				// Darn, it's empty. What type is expected?
845 871
 				switch ($config_var[0])
@@ -879,16 +905,19 @@  discard block
 block discarded – undo
879 905
 			if ($config_var[0] == 'int' || $config_var[0] == 'float')
880 906
 			{
881 907
 				// Default to a min of 0 if one isn't set
882
-				if (isset($config_var['min']))
883
-					$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
884
-				else
885
-					$context['config_vars'][$config_var[1]]['min'] = 0;
908
+				if (isset($config_var['min'])) {
909
+									$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
910
+				} else {
911
+									$context['config_vars'][$config_var[1]]['min'] = 0;
912
+				}
886 913
 
887
-				if (isset($config_var['max']))
888
-					$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
914
+				if (isset($config_var['max'])) {
915
+									$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
916
+				}
889 917
 
890
-				if (isset($config_var['step']))
891
-					$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
918
+				if (isset($config_var['step'])) {
919
+									$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
920
+				}
892 921
 			}
893 922
 
894 923
 			// If this is a select box handle any data.
@@ -902,12 +931,13 @@  discard block
 block discarded – undo
902 931
 				}
903 932
 
904 933
 				// If it's associative
905
-				if (isset($config_var[2][0]) && is_array($config_var[2][0]))
906
-					$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
907
-				else
934
+				if (isset($config_var[2][0]) && is_array($config_var[2][0])) {
935
+									$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
936
+				} else
908 937
 				{
909
-					foreach ($config_var[2] as $key => $item)
910
-						$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
938
+					foreach ($config_var[2] as $key => $item) {
939
+											$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
940
+					}
911 941
 				}
912 942
 			}
913 943
 
@@ -916,17 +946,19 @@  discard block
 block discarded – undo
916 946
 			{
917 947
 				if (!is_numeric($k))
918 948
 				{
919
-					if (substr($k, 0, 2) == 'on')
920
-						$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
921
-					else
922
-						$context['config_vars'][$config_var[1]][$k] = $v;
949
+					if (substr($k, 0, 2) == 'on') {
950
+											$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
951
+					} else {
952
+											$context['config_vars'][$config_var[1]][$k] = $v;
953
+					}
923 954
 				}
924 955
 
925 956
 				// See if there are any other labels that might fit?
926
-				if (isset($txt['setting_' . $config_var[1]]))
927
-					$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
928
-				elseif (isset($txt['groups_' . $config_var[1]]))
929
-					$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
957
+				if (isset($txt['setting_' . $config_var[1]])) {
958
+									$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
959
+				} elseif (isset($txt['groups_' . $config_var[1]])) {
960
+									$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
961
+				}
930 962
 			}
931 963
 
932 964
 			// Set the subtext in case it's part of the label.
@@ -959,8 +991,9 @@  discard block
 block discarded – undo
959 991
 		// What are the options, eh?
960 992
 		$temp = parse_bbc(false);
961 993
 		$bbcTags = array();
962
-		foreach ($temp as $tag)
963
-			$bbcTags[] = $tag['tag'];
994
+		foreach ($temp as $tag) {
995
+					$bbcTags[] = $tag['tag'];
996
+		}
964 997
 
965 998
 		$bbcTags = array_unique($bbcTags);
966 999
 		$totalTags = count($bbcTags);
@@ -975,8 +1008,9 @@  discard block
 block discarded – undo
975 1008
 		$col = 0; $i = 0;
976 1009
 		foreach ($bbcTags as $tag)
977 1010
 		{
978
-			if ($i % $tagsPerColumn == 0 && $i != 0)
979
-				$col++;
1011
+			if ($i % $tagsPerColumn == 0 && $i != 0) {
1012
+							$col++;
1013
+			}
980 1014
 
981 1015
 			$context['bbc_columns'][$col][] = array(
982 1016
 				'tag' => $tag,
@@ -1019,18 +1053,21 @@  discard block
 block discarded – undo
1019 1053
 	validateToken('admin-ssc');
1020 1054
 
1021 1055
 	// Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
1022
-	if (isset($_POST['cookiename']))
1023
-		$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1056
+	if (isset($_POST['cookiename'])) {
1057
+			$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1058
+	}
1024 1059
 
1025 1060
 	// Fix the forum's URL if necessary.
1026 1061
 	if (isset($_POST['boardurl']))
1027 1062
 	{
1028
-		if (substr($_POST['boardurl'], -10) == '/index.php')
1029
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1030
-		elseif (substr($_POST['boardurl'], -1) == '/')
1031
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1032
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
1033
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1063
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1064
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1065
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1066
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1067
+		}
1068
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1069
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1070
+		}
1034 1071
 	}
1035 1072
 
1036 1073
 	// Any passwords?
@@ -1065,21 +1102,21 @@  discard block
 block discarded – undo
1065 1102
 	// Figure out which config vars we're saving here...
1066 1103
 	foreach ($config_vars as $var)
1067 1104
 	{
1068
-		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]])))
1069
-			continue;
1105
+		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) {
1106
+					continue;
1107
+		}
1070 1108
 
1071 1109
 		$config_var = $var[0];
1072 1110
 
1073 1111
 		if (in_array($config_var, $config_passwords))
1074 1112
 		{
1075
-			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
1076
-				$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1077
-		}
1078
-		elseif (in_array($config_var, $config_strs))
1113
+			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
1114
+							$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1115
+			}
1116
+		} elseif (in_array($config_var, $config_strs))
1079 1117
 		{
1080 1118
 			$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
1081
-		}
1082
-		elseif (in_array($config_var, $config_ints))
1119
+		} elseif (in_array($config_var, $config_ints))
1083 1120
 		{
1084 1121
 			$new_settings[$config_var] = (int) $_POST[$config_var];
1085 1122
 
@@ -1088,17 +1125,17 @@  discard block
 block discarded – undo
1088 1125
 			$new_settings[$config_var] = max($min, $new_settings[$config_var]);
1089 1126
 
1090 1127
 			// Is there a max value for this as well?
1091
-			if (isset($var['max']))
1092
-				$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1093
-		}
1094
-		elseif (in_array($config_var, $config_bools))
1128
+			if (isset($var['max'])) {
1129
+							$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1130
+			}
1131
+		} elseif (in_array($config_var, $config_bools))
1095 1132
 		{
1096
-			if (!empty($_POST[$config_var]))
1097
-				$new_settings[$config_var] = '1';
1098
-			else
1099
-				$new_settings[$config_var] = '0';
1100
-		}
1101
-		else
1133
+			if (!empty($_POST[$config_var])) {
1134
+							$new_settings[$config_var] = '1';
1135
+			} else {
1136
+							$new_settings[$config_var] = '0';
1137
+			}
1138
+		} else
1102 1139
 		{
1103 1140
 			// This shouldn't happen, but it might...
1104 1141
 			fatal_error('Unknown config_var \'' . $config_var . '\'');
@@ -1114,30 +1151,35 @@  discard block
 block discarded – undo
1114 1151
 	foreach ($config_vars as $config_var)
1115 1152
 	{
1116 1153
 		// We just saved the file-based settings, so skip their definitions.
1117
-		if (!is_array($config_var) || $config_var[2] == 'file')
1118
-			continue;
1154
+		if (!is_array($config_var) || $config_var[2] == 'file') {
1155
+					continue;
1156
+		}
1119 1157
 
1120 1158
 		$new_setting = array($config_var[3], $config_var[0]);
1121 1159
 
1122 1160
 		// Select options need carried over, too.
1123
-		if (isset($config_var[4]))
1124
-			$new_setting[] = $config_var[4];
1161
+		if (isset($config_var[4])) {
1162
+					$new_setting[] = $config_var[4];
1163
+		}
1125 1164
 
1126 1165
 		// Include min and max if necessary
1127
-		if (isset($config_var['min']))
1128
-			$new_setting['min'] = $config_var['min'];
1166
+		if (isset($config_var['min'])) {
1167
+					$new_setting['min'] = $config_var['min'];
1168
+		}
1129 1169
 
1130
-		if (isset($config_var['max']))
1131
-			$new_setting['max'] = $config_var['max'];
1170
+		if (isset($config_var['max'])) {
1171
+					$new_setting['max'] = $config_var['max'];
1172
+		}
1132 1173
 
1133 1174
 		// Rewrite the definition a bit.
1134 1175
 		$new_settings[] = $new_setting;
1135 1176
 	}
1136 1177
 
1137 1178
 	// Save the new database-based settings, if any.
1138
-	if (!empty($new_settings))
1139
-		saveDBSettings($new_settings);
1140
-}
1179
+	if (!empty($new_settings)) {
1180
+			saveDBSettings($new_settings);
1181
+	}
1182
+	}
1141 1183
 
1142 1184
 /**
1143 1185
  * Helper function for saving database settings.
@@ -1155,22 +1197,25 @@  discard block
 block discarded – undo
1155 1197
 	$inlinePermissions = array();
1156 1198
 	foreach ($config_vars as $var)
1157 1199
 	{
1158
-		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
1159
-			continue;
1200
+		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) {
1201
+					continue;
1202
+		}
1160 1203
 
1161 1204
 		// Checkboxes!
1162
-		elseif ($var[0] == 'check')
1163
-			$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1205
+		elseif ($var[0] == 'check') {
1206
+					$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1207
+		}
1164 1208
 		// Select boxes!
1165
-		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
1166
-			$setArray[$var[1]] = $_POST[$var[1]];
1167
-		elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1209
+		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) {
1210
+					$setArray[$var[1]] = $_POST[$var[1]];
1211
+		} elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1168 1212
 		{
1169 1213
 			// For security purposes we validate this line by line.
1170 1214
 			$lOptions = array();
1171
-			foreach ($_POST[$var[1]] as $invar)
1172
-				if (in_array($invar, array_keys($var[2])))
1215
+			foreach ($_POST[$var[1]] as $invar) {
1216
+							if (in_array($invar, array_keys($var[2])))
1173 1217
 					$lOptions[] = $invar;
1218
+			}
1174 1219
 
1175 1220
 			$setArray[$var[1]] = $smcFunc['json_encode']($lOptions);
1176 1221
 		}
@@ -1184,18 +1229,20 @@  discard block
 block discarded – undo
1184 1229
 				$request = $smcFunc['db_query']('', '
1185 1230
 					SELECT id_board
1186 1231
 					FROM {db_prefix}boards');
1187
-				while ($row = $smcFunc['db_fetch_row']($request))
1188
-					$board_list[$row[0]] = true;
1232
+				while ($row = $smcFunc['db_fetch_row']($request)) {
1233
+									$board_list[$row[0]] = true;
1234
+				}
1189 1235
 
1190 1236
 				$smcFunc['db_free_result']($request);
1191 1237
 			}
1192 1238
 
1193 1239
 			$lOptions = array();
1194 1240
 
1195
-			if (!empty($_POST[$var[1]]))
1196
-				foreach ($_POST[$var[1]] as $invar => $dummy)
1241
+			if (!empty($_POST[$var[1]])) {
1242
+							foreach ($_POST[$var[1]] as $invar => $dummy)
1197 1243
 					if (isset($board_list[$invar]))
1198 1244
 						$lOptions[] = $invar;
1245
+			}
1199 1246
 
1200 1247
 			$setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : '';
1201 1248
 		}
@@ -1209,8 +1256,9 @@  discard block
 block discarded – undo
1209 1256
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1210 1257
 
1211 1258
 			// Do we have a max value for this as well?
1212
-			if (isset($var['max']))
1213
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1259
+			if (isset($var['max'])) {
1260
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1261
+			}
1214 1262
 		}
1215 1263
 		// Floating point!
1216 1264
 		elseif ($var[0] == 'float')
@@ -1222,40 +1270,47 @@  discard block
 block discarded – undo
1222 1270
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1223 1271
 
1224 1272
 			// Do we have a max value for this as well?
1225
-			if (isset($var['max']))
1226
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1273
+			if (isset($var['max'])) {
1274
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1275
+			}
1227 1276
 		}
1228 1277
 		// Text!
1229
-		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time')))
1230
-			$setArray[$var[1]] = $_POST[$var[1]];
1278
+		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) {
1279
+					$setArray[$var[1]] = $_POST[$var[1]];
1280
+		}
1231 1281
 		// Passwords!
1232 1282
 		elseif ($var[0] == 'password')
1233 1283
 		{
1234
-			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
1235
-				$setArray[$var[1]] = $_POST[$var[1]][0];
1284
+			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) {
1285
+							$setArray[$var[1]] = $_POST[$var[1]][0];
1286
+			}
1236 1287
 		}
1237 1288
 		// BBC.
1238 1289
 		elseif ($var[0] == 'bbc')
1239 1290
 		{
1240 1291
 
1241 1292
 			$bbcTags = array();
1242
-			foreach (parse_bbc(false) as $tag)
1243
-				$bbcTags[] = $tag['tag'];
1293
+			foreach (parse_bbc(false) as $tag) {
1294
+							$bbcTags[] = $tag['tag'];
1295
+			}
1244 1296
 
1245
-			if (!isset($_POST[$var[1] . '_enabledTags']))
1246
-				$_POST[$var[1] . '_enabledTags'] = array();
1247
-			elseif (!is_array($_POST[$var[1] . '_enabledTags']))
1248
-				$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1297
+			if (!isset($_POST[$var[1] . '_enabledTags'])) {
1298
+							$_POST[$var[1] . '_enabledTags'] = array();
1299
+			} elseif (!is_array($_POST[$var[1] . '_enabledTags'])) {
1300
+							$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1301
+			}
1249 1302
 
1250 1303
 			$setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
1251 1304
 		}
1252 1305
 		// Permissions?
1253
-		elseif ($var[0] == 'permissions')
1254
-			$inlinePermissions[] = $var[1];
1306
+		elseif ($var[0] == 'permissions') {
1307
+					$inlinePermissions[] = $var[1];
1308
+		}
1255 1309
 	}
1256 1310
 
1257
-	if (!empty($setArray))
1258
-		updateSettings($setArray);
1311
+	if (!empty($setArray)) {
1312
+			updateSettings($setArray);
1313
+	}
1259 1314
 
1260 1315
 	// If we have inline permissions we need to save them.
1261 1316
 	if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
@@ -1292,18 +1347,21 @@  discard block
 block discarded – undo
1292 1347
 	// put all of it into an array
1293 1348
 	foreach ($info_lines as $line)
1294 1349
 	{
1295
-		if (preg_match('~(' . $remove . ')~', $line))
1296
-			continue;
1350
+		if (preg_match('~(' . $remove . ')~', $line)) {
1351
+					continue;
1352
+		}
1297 1353
 
1298 1354
 		// new category?
1299
-		if (strpos($line, '<h2>') !== false)
1300
-			$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1355
+		if (strpos($line, '<h2>') !== false) {
1356
+					$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1357
+		}
1301 1358
 
1302 1359
 		// load it as setting => value or the old setting local master
1303
-		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1304
-			$pinfo[$category][$val[1]] = $val[2];
1305
-		elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1306
-			$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1360
+		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1361
+					$pinfo[$category][$val[1]] = $val[2];
1362
+		} elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1363
+					$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1364
+		}
1307 1365
 	}
1308 1366
 
1309 1367
 	// load it in to context and display it
@@ -1338,8 +1396,9 @@  discard block
 block discarded – undo
1338 1396
 				$testAPI = new $cache_class_name();
1339 1397
 
1340 1398
 				// No Support?  NEXT!
1341
-				if (!$testAPI->isSupported(true))
1342
-					continue;
1399
+				if (!$testAPI->isSupported(true)) {
1400
+									continue;
1401
+				}
1343 1402
 
1344 1403
 				$apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache;
1345 1404
 			}
@@ -1364,8 +1423,9 @@  discard block
 block discarded – undo
1364 1423
 	global $modSettings, $boardurl, $smcFunc;
1365 1424
 
1366 1425
 	// Already have a key?  Can't register again.
1367
-	if (!empty($modSettings['sm_stats_key']))
1368
-		return true;
1426
+	if (!empty($modSettings['sm_stats_key'])) {
1427
+			return true;
1428
+	}
1369 1429
 
1370 1430
 	$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
1371 1431
 	if ($fp)
@@ -1376,8 +1436,9 @@  discard block
 block discarded – undo
1376 1436
 		fwrite($fp, $out);
1377 1437
 
1378 1438
 		$return_data = '';
1379
-		while (!feof($fp))
1380
-			$return_data .= fgets($fp, 128);
1439
+		while (!feof($fp)) {
1440
+					$return_data .= fgets($fp, 128);
1441
+		}
1381 1442
 
1382 1443
 		fclose($fp);
1383 1444
 
Please login to merge, or discard this patch.
Sources/DbSearch-postgresql.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	$version = $smcFunc['db_get_version']();
39 39
 	// if we got a Beta Version
40 40
 	if (stripos($version, 'beta') !== false)
41
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
41
+		$version = substr($version, 0, stripos($version, 'beta')) . '.0';
42 42
 	// or RC
43 43
 	if (stripos($version, 'rc') !== false)
44
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
44
+		$version = substr($version, 0, stripos($version, 'rc')) . '.0';
45 45
 
46
-	if (version_compare($version,'9.5.0','>='))
46
+	if (version_compare($version, '9.5.0', '>='))
47 47
 		$smcFunc['db_support_ignore'] = true;
48 48
 }
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function smf_db_search_support($search_type)
57 57
 {
58
-	$supported_types = array('custom','fulltext');
58
+	$supported_types = array('custom', 'fulltext');
59 59
 
60 60
 	return in_array($search_type, $supported_types);
61 61
 }
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
110 110
 	{
111 111
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
112
-		if ($smcFunc['db_support_ignore']){
112
+		if ($smcFunc['db_support_ignore']) {
113 113
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
114
-			$db_string = $db_string.' ON CONFLICT DO NOTHING';
114
+			$db_string = $db_string . ' ON CONFLICT DO NOTHING';
115 115
 		}
116 116
 		else
117 117
 		{
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$language_ftx = $modSettings['search_language'];
169 169
 	else
170 170
 	{
171
-		$request = $smcFunc['db_query']('','
171
+		$request = $smcFunc['db_query']('', '
172 172
 			SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig',
173 173
 			array(
174 174
 			'default_language' => 'default_text_search_config'
Please login to merge, or discard this patch.
Braces   +25 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Add the file functions to the $smcFunc array.
@@ -23,29 +24,33 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_search_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => false,
32 33
 			'db_search_language' => 'smf_db_search_language',
33 34
 		);
35
+	}
34 36
 
35 37
 	db_extend();
36 38
 
37 39
 	//pg 9.5 got ignore support
38 40
 	$version = $smcFunc['db_get_version']();
39 41
 	// if we got a Beta Version
40
-	if (stripos($version, 'beta') !== false)
41
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
42
+	if (stripos($version, 'beta') !== false) {
43
+			$version = substr($version, 0, stripos($version, 'beta')).'.0';
44
+	}
42 45
 	// or RC
43
-	if (stripos($version, 'rc') !== false)
44
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
46
+	if (stripos($version, 'rc') !== false) {
47
+			$version = substr($version, 0, stripos($version, 'rc')).'.0';
48
+	}
45 49
 
46
-	if (version_compare($version,'9.5.0','>='))
47
-		$smcFunc['db_support_ignore'] = true;
48
-}
50
+	if (version_compare($version,'9.5.0','>=')) {
51
+			$smcFunc['db_support_ignore'] = true;
52
+	}
53
+	}
49 54
 
50 55
 /**
51 56
  * This function will tell you whether this database type supports this search type.
@@ -104,16 +109,16 @@  discard block
 block discarded – undo
104 109
 		),
105 110
 	);
106 111
 
107
-	if (isset($replacements[$identifier]))
108
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
112
+	if (isset($replacements[$identifier])) {
113
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
114
+	}
109 115
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
110 116
 	{
111 117
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
112 118
 		if ($smcFunc['db_support_ignore']){
113 119
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
114 120
 			$db_string = $db_string.' ON CONFLICT DO NOTHING';
115
-		}
116
-		else
121
+		} else
117 122
 		{
118 123
 			// Don't error on multi-insert.
119 124
 			$db_values['db_error_skip'] = true;
@@ -121,8 +126,9 @@  discard block
 block discarded – undo
121 126
 	}
122 127
 
123 128
 	//fix double quotes
124
-	if ($identifier == 'insert_into_log_messages_fulltext')
125
-		$db_values = str_replace('"', "'", $db_values);
129
+	if ($identifier == 'insert_into_log_messages_fulltext') {
130
+			$db_values = str_replace('"', "'", $db_values);
131
+	}
126 132
 
127 133
 	$return = $smcFunc['db_query']('', $db_string,
128 134
 		$db_values, $connection
@@ -164,9 +170,9 @@  discard block
 block discarded – undo
164 170
 
165 171
 	$language_ftx = 'english';
166 172
 
167
-	if (!empty($modSettings['search_language']))
168
-		$language_ftx = $modSettings['search_language'];
169
-	else
173
+	if (!empty($modSettings['search_language'])) {
174
+			$language_ftx = $modSettings['search_language'];
175
+	} else
170 176
 	{
171 177
 		$request = $smcFunc['db_query']('','
172 178
 			SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig',
Please login to merge, or discard this patch.
Sources/Drafts.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
  *
174 174
  * @param string $post_errors A string of info about errors encountered trying to save this draft
175 175
  * @param array $recipientList An array of data about who this PM is being sent to
176
- * @return boolean false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise
176
+ * @return boolean|null false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise
177 177
  */
178 178
 function SavePMDraft(&$post_errors, $recipientList)
179 179
 {
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
  *
389 389
  * @param int $id_draft The ID of the draft to delete
390 390
  * @param boolean $check Whether or not to check that the draft belongs to the current user
391
- * @return boolean False if it couldn't be deleted (doesn't return anything otherwise)
391
+ * @return false|null False if it couldn't be deleted (doesn't return anything otherwise)
392 392
  */
393 393
 function DeleteDraft($id_draft, $check = true)
394 394
 {
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
  * @param int $member_id ID of the member to show drafts for
423 423
  * @param boolean|integer If $type is 1, this can be set to only load drafts for posts in the specific topic
424 424
  * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts
425
- * @return boolean False if the drafts couldn't be loaded, nothing otherwise
425
+ * @return false|null False if the drafts couldn't be loaded, nothing otherwise
426 426
  */
427 427
 function ShowDrafts($member_id, $topic = false, $draft_type = 0)
428 428
 {
Please login to merge, or discard this patch.
Braces   +75 added lines, -53 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 loadLanguage('Drafts');
21 22
 
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 	global $context, $user_info, $smcFunc, $modSettings, $board;
34 35
 
35 36
 	// can you be, should you be ... here?
36
-	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft']))
37
-		return false;
37
+	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) {
38
+			return false;
39
+	}
38 40
 
39 41
 	// read in what they sent us, if anything
40 42
 	$id_draft = (int) $_POST['id_draft'];
@@ -46,14 +48,16 @@  discard block
 block discarded – undo
46 48
 		$context['draft_saved_on'] = $draft_info['poster_time'];
47 49
 
48 50
 		// since we were called from the autosave function, send something back
49
-		if (!empty($id_draft))
50
-			XmlDraft($id_draft);
51
+		if (!empty($id_draft)) {
52
+					XmlDraft($id_draft);
53
+		}
51 54
 
52 55
 		return true;
53 56
 	}
54 57
 
55
-	if (!isset($_POST['message']))
56
-		$_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : '';
58
+	if (!isset($_POST['message'])) {
59
+			$_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : '';
60
+	}
57 61
 
58 62
 	// prepare any data from the form
59 63
 	$topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic'];
@@ -66,8 +70,9 @@  discard block
 block discarded – undo
66 70
 
67 71
 	// message and subject still need a bit more work
68 72
 	preparsecode($draft['body']);
69
-	if ($smcFunc['strlen']($draft['subject']) > 100)
70
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
73
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
74
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
75
+	}
71 76
 
72 77
 	// Modifying an existing draft, like hitting the save draft button or autosave enabled?
73 78
 	if (!empty($id_draft) && !empty($draft_info))
@@ -148,9 +153,9 @@  discard block
 block discarded – undo
148 153
 		{
149 154
 			$context['draft_saved'] = true;
150 155
 			$context['id_draft'] = $id_draft;
156
+		} else {
157
+					$post_errors[] = 'draft_not_saved';
151 158
 		}
152
-		else
153
-			$post_errors[] = 'draft_not_saved';
154 159
 
155 160
 		// cleanup
156 161
 		unset($_POST['save_draft']);
@@ -180,8 +185,9 @@  discard block
 block discarded – undo
180 185
 	global $context, $user_info, $smcFunc, $modSettings;
181 186
 
182 187
 	// PM survey says ... can you stay or must you go
183
-	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft']))
184
-		return false;
188
+	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) {
189
+			return false;
190
+	}
185 191
 
186 192
 	// read in what you sent us
187 193
 	$id_pm_draft = (int) $_POST['id_pm_draft'];
@@ -193,8 +199,9 @@  discard block
 block discarded – undo
193 199
 		$context['draft_saved_on'] = $draft_info['poster_time'];
194 200
 
195 201
 		// Send something back to the javascript caller
196
-		if (!empty($id_draft))
197
-			XmlDraft($id_draft);
202
+		if (!empty($id_draft)) {
203
+					XmlDraft($id_draft);
204
+		}
198 205
 
199 206
 		return true;
200 207
 	}
@@ -204,9 +211,9 @@  discard block
 block discarded – undo
204 211
 	{
205 212
 		$recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array();
206 213
 		$recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array();
214
+	} elseif (!empty($draft_info['to_list']) && empty($recipientList)) {
215
+			$recipientList = $smcFunc['json_decode']($draft_info['to_list'], true);
207 216
 	}
208
-	elseif (!empty($draft_info['to_list']) && empty($recipientList))
209
-		$recipientList = $smcFunc['json_decode']($draft_info['to_list'], true);
210 217
 
211 218
 	// prepare the data we got from the form
212 219
 	$reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to'];
@@ -215,8 +222,9 @@  discard block
 block discarded – undo
215 222
 
216 223
 	// message and subject always need a bit more work
217 224
 	preparsecode($draft['body']);
218
-	if ($smcFunc['strlen']($draft['subject']) > 100)
219
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
225
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
226
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
227
+	}
220 228
 
221 229
 	// Modifying an existing PM draft?
222 230
 	if (!empty($id_pm_draft) && !empty($draft_info))
@@ -280,9 +288,9 @@  discard block
 block discarded – undo
280 288
 		{
281 289
 			$context['draft_saved'] = true;
282 290
 			$context['id_pm_draft'] = $id_pm_draft;
291
+		} else {
292
+					$post_errors[] = 'draft_not_saved';
283 293
 		}
284
-		else
285
-			$post_errors[] = 'draft_not_saved';
286 294
 	}
287 295
 
288 296
 	// if we were called from the autosave function, send something back
@@ -315,8 +323,9 @@  discard block
 block discarded – undo
315 323
 	$type = (int) $type;
316 324
 
317 325
 	// nothing to read, nothing to do
318
-	if (empty($id_draft))
319
-		return false;
326
+	if (empty($id_draft)) {
327
+			return false;
328
+	}
320 329
 
321 330
 	// load in this draft from the DB
322 331
 	$request = $smcFunc['db_query']('', '
@@ -337,8 +346,9 @@  discard block
 block discarded – undo
337 346
 	);
338 347
 
339 348
 	// no results?
340
-	if (!$smcFunc['db_num_rows']($request))
341
-		return false;
349
+	if (!$smcFunc['db_num_rows']($request)) {
350
+			return false;
351
+	}
342 352
 
343 353
 	// load up the data
344 354
 	$draft_info = $smcFunc['db_fetch_assoc']($request);
@@ -358,8 +368,7 @@  discard block
 block discarded – undo
358 368
 			$context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
359 369
 			$context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : '';
360 370
 			$context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0;
361
-		}
362
-		elseif ($type === 1)
371
+		} elseif ($type === 1)
363 372
 		{
364 373
 			// one of those pm drafts? then set it up like we have an error
365 374
 			$_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
@@ -395,12 +404,14 @@  discard block
 block discarded – undo
395 404
 	global $user_info, $smcFunc;
396 405
 
397 406
 	// Only a single draft.
398
-	if (is_numeric($id_draft))
399
-		$id_draft = array($id_draft);
407
+	if (is_numeric($id_draft)) {
408
+			$id_draft = array($id_draft);
409
+	}
400 410
 
401 411
 	// can't delete nothing
402
-	if (empty($id_draft) || ($check && empty($user_info['id'])))
403
-		return false;
412
+	if (empty($id_draft) || ($check && empty($user_info['id']))) {
413
+			return false;
414
+	}
404 415
 
405 416
 	$smcFunc['db_query']('', '
406 417
 		DELETE FROM {db_prefix}user_drafts
@@ -429,14 +440,16 @@  discard block
 block discarded – undo
429 440
 	global $smcFunc, $scripturl, $context, $txt, $modSettings;
430 441
 
431 442
 	// Permissions
432
-	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id))
433
-		return false;
443
+	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) {
444
+			return false;
445
+	}
434 446
 
435 447
 	$context['drafts'] = array();
436 448
 
437 449
 	// has a specific draft has been selected?  Load it up if there is not a message already in the editor
438
-	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message']))
439
-		ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
450
+	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) {
451
+			ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
452
+	}
440 453
 
441 454
 	// load the drafts this user has available
442 455
 	$request = $smcFunc['db_query']('', '
@@ -459,8 +472,9 @@  discard block
 block discarded – undo
459 472
 	// add them to the draft array for display
460 473
 	while ($row = $smcFunc['db_fetch_assoc']($request))
461 474
 	{
462
-		if (empty($row['subject']))
463
-			$row['subject'] = $txt['no_subject'];
475
+		if (empty($row['subject'])) {
476
+					$row['subject'] = $txt['no_subject'];
477
+		}
464 478
 
465 479
 		// Post drafts
466 480
 		if ($draft_type === 0)
@@ -545,8 +559,9 @@  discard block
 block discarded – undo
545 559
 	}
546 560
 
547 561
 	// Default to 10.
548
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
549
-		$_REQUEST['viewscount'] = 10;
562
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
563
+			$_REQUEST['viewscount'] = 10;
564
+	}
550 565
 
551 566
 	// Get the count of applicable drafts on the boards they can (still) see ...
552 567
 	// @todo .. should we just let them see their drafts even if they have lost board access ?
@@ -611,12 +626,14 @@  discard block
 block discarded – undo
611 626
 	while ($row = $smcFunc['db_fetch_assoc']($request))
612 627
 	{
613 628
 		// Censor....
614
-		if (empty($row['body']))
615
-			$row['body'] = '';
629
+		if (empty($row['body'])) {
630
+					$row['body'] = '';
631
+		}
616 632
 
617 633
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
618
-		if (empty($row['subject']))
619
-			$row['subject'] = $txt['no_subject'];
634
+		if (empty($row['subject'])) {
635
+					$row['subject'] = $txt['no_subject'];
636
+		}
620 637
 
621 638
 		censorText($row['body']);
622 639
 		censorText($row['subject']);
@@ -648,8 +665,9 @@  discard block
 block discarded – undo
648 665
 	$smcFunc['db_free_result']($request);
649 666
 
650 667
 	// If the drafts were retrieved in reverse order, get them right again.
651
-	if ($reverse)
652
-		$context['drafts'] = array_reverse($context['drafts'], true);
668
+	if ($reverse) {
669
+			$context['drafts'] = array_reverse($context['drafts'], true);
670
+	}
653 671
 
654 672
 	// Menu tab
655 673
 	$context[$context['profile_menu_name']]['tab_data'] = array(
@@ -707,8 +725,9 @@  discard block
 block discarded – undo
707 725
 	}
708 726
 
709 727
 	// Default to 10.
710
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
711
-		$_REQUEST['viewscount'] = 10;
728
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
729
+			$_REQUEST['viewscount'] = 10;
730
+	}
712 731
 
713 732
 	// Get the count of applicable drafts
714 733
 	$request = $smcFunc['db_query']('', '
@@ -767,12 +786,14 @@  discard block
 block discarded – undo
767 786
 	while ($row = $smcFunc['db_fetch_assoc']($request))
768 787
 	{
769 788
 		// Censor....
770
-		if (empty($row['body']))
771
-			$row['body'] = '';
789
+		if (empty($row['body'])) {
790
+					$row['body'] = '';
791
+		}
772 792
 
773 793
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
774
-		if (empty($row['subject']))
775
-			$row['subject'] = $txt['no_subject'];
794
+		if (empty($row['subject'])) {
795
+					$row['subject'] = $txt['no_subject'];
796
+		}
776 797
 
777 798
 		censorText($row['body']);
778 799
 		censorText($row['subject']);
@@ -827,8 +848,9 @@  discard block
 block discarded – undo
827 848
 	$smcFunc['db_free_result']($request);
828 849
 
829 850
 	// if the drafts were retrieved in reverse order, then put them in the right order again.
830
-	if ($reverse)
831
-		$context['drafts'] = array_reverse($context['drafts'], true);
851
+	if ($reverse) {
852
+			$context['drafts'] = array_reverse($context['drafts'], true);
853
+	}
832 854
 
833 855
 	// off to the template we go
834 856
 	$context['page_title'] = $txt['drafts'];
Please login to merge, or discard this patch.
Sources/ReCaptcha/ReCaptcha.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -31,67 +31,67 @@
 block discarded – undo
31 31
  */
32 32
 class ReCaptcha
33 33
 {
34
-    /**
35
-     * Version of this client library.
36
-     * @const string
37
-     */
38
-    const VERSION = 'php_1.1.2';
34
+	/**
35
+	 * Version of this client library.
36
+	 * @const string
37
+	 */
38
+	const VERSION = 'php_1.1.2';
39 39
 
40
-    /**
41
-     * Shared secret for the site.
42
-     * @var string
43
-     */
44
-    private $secret;
40
+	/**
41
+	 * Shared secret for the site.
42
+	 * @var string
43
+	 */
44
+	private $secret;
45 45
 
46
-    /**
47
-     * Method used to communicate  with service. Defaults to POST request.
48
-     * @var RequestMethod
49
-     */
50
-    private $requestMethod;
46
+	/**
47
+	 * Method used to communicate  with service. Defaults to POST request.
48
+	 * @var RequestMethod
49
+	 */
50
+	private $requestMethod;
51 51
 
52
-    /**
53
-     * Create a configured instance to use the reCAPTCHA service.
54
-     *
55
-     * @param string $secret shared secret between site and reCAPTCHA server.
56
-     * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
57
-     */
58
-    public function __construct($secret, RequestMethod $requestMethod = null)
59
-    {
60
-        if (empty($secret)) {
61
-            throw new \RuntimeException('No secret provided');
62
-        }
52
+	/**
53
+	 * Create a configured instance to use the reCAPTCHA service.
54
+	 *
55
+	 * @param string $secret shared secret between site and reCAPTCHA server.
56
+	 * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
57
+	 */
58
+	public function __construct($secret, RequestMethod $requestMethod = null)
59
+	{
60
+		if (empty($secret)) {
61
+			throw new \RuntimeException('No secret provided');
62
+		}
63 63
 
64
-        if (!is_string($secret)) {
65
-            throw new \RuntimeException('The provided secret must be a string');
66
-        }
64
+		if (!is_string($secret)) {
65
+			throw new \RuntimeException('The provided secret must be a string');
66
+		}
67 67
 
68
-        $this->secret = $secret;
68
+		$this->secret = $secret;
69 69
 
70
-        if (!is_null($requestMethod)) {
71
-            $this->requestMethod = $requestMethod;
72
-        } else {
73
-            $this->requestMethod = new RequestMethod\Post();
74
-        }
75
-    }
70
+		if (!is_null($requestMethod)) {
71
+			$this->requestMethod = $requestMethod;
72
+		} else {
73
+			$this->requestMethod = new RequestMethod\Post();
74
+		}
75
+	}
76 76
 
77
-    /**
78
-     * Calls the reCAPTCHA siteverify API to verify whether the user passes
79
-     * CAPTCHA test.
80
-     *
81
-     * @param string $response The value of 'g-recaptcha-response' in the submitted form.
82
-     * @param string $remoteIp The end user's IP address.
83
-     * @return Response Response from the service.
84
-     */
85
-    public function verify($response, $remoteIp = null)
86
-    {
87
-        // Discard empty solution submissions
88
-        if (empty($response)) {
89
-            $recaptchaResponse = new Response(false, array('missing-input-response'));
90
-            return $recaptchaResponse;
91
-        }
77
+	/**
78
+	 * Calls the reCAPTCHA siteverify API to verify whether the user passes
79
+	 * CAPTCHA test.
80
+	 *
81
+	 * @param string $response The value of 'g-recaptcha-response' in the submitted form.
82
+	 * @param string $remoteIp The end user's IP address.
83
+	 * @return Response Response from the service.
84
+	 */
85
+	public function verify($response, $remoteIp = null)
86
+	{
87
+		// Discard empty solution submissions
88
+		if (empty($response)) {
89
+			$recaptchaResponse = new Response(false, array('missing-input-response'));
90
+			return $recaptchaResponse;
91
+		}
92 92
 
93
-        $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
94
-        $rawResponse = $this->requestMethod->submit($params);
95
-        return Response::fromJson($rawResponse);
96
-    }
93
+		$params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
94
+		$rawResponse = $this->requestMethod->submit($params);
95
+		return Response::fromJson($rawResponse);
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Themes/default/Admin.template.php 1 patch
Braces   +173 added lines, -125 removed lines patch added patch discarded remove patch
@@ -64,9 +64,10 @@  discard block
 block discarded – undo
64 64
 										<strong>', $txt['administrators'], ':</strong>
65 65
 										', implode(', ', $context['administrators']);
66 66
 	// If we have lots of admins... don't show them all.
67
-	if (!empty($context['more_admins_link']))
68
-		echo '
67
+	if (!empty($context['more_admins_link'])) {
68
+			echo '
69 69
 							(', $context['more_admins_link'], ')';
70
+	}
70 71
 
71 72
 	echo '
72 73
 									</div>
@@ -83,16 +84,18 @@  discard block
 block discarded – undo
83 84
 		foreach ($area['areas'] as $item_id => $item)
84 85
 		{
85 86
 			// No point showing the 'home' page here, we're already on it!
86
-			if ($area_id == 'forum' && $item_id == 'index')
87
-				continue;
87
+			if ($area_id == 'forum' && $item_id == 'index') {
88
+							continue;
89
+			}
88 90
 
89 91
 			$url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : '');
90
-			if (!empty($item['icon_file']))
91
-				echo '
92
+			if (!empty($item['icon_file'])) {
93
+							echo '
92 94
 							<a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>';
93
-			else
94
-				echo '
95
+			} else {
96
+							echo '
95 97
 							<a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>';
98
+			}
96 99
 		}
97 100
 
98 101
 		echo '
@@ -103,10 +106,11 @@  discard block
 block discarded – undo
103 106
 					</div>';
104 107
 
105 108
 	// The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization.
106
-	if (empty($modSettings['disable_smf_js']))
107
-		echo '
109
+	if (empty($modSettings['disable_smf_js'])) {
110
+			echo '
108 111
 					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
109 112
 					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
113
+	}
110 114
 
111 115
 	// This sets the announcements and current versions themselves ;).
112 116
 	echo '
@@ -185,9 +189,10 @@  discard block
 block discarded – undo
185 189
 								<em>', $version['version'], '</em>';
186 190
 
187 191
 		// more details for this item, show them a link
188
-		if ($context['can_admin'] && isset($version['more']))
189
-			echo
192
+		if ($context['can_admin'] && isset($version['more'])) {
193
+					echo
190 194
 								' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>';
195
+		}
191 196
 		echo '
192 197
 								<br>';
193 198
 	}
@@ -218,20 +223,22 @@  discard block
 block discarded – undo
218 223
 
219 224
 	foreach ($context['credits'] as $section)
220 225
 	{
221
-		if (isset($section['pretext']))
222
-			echo '
226
+		if (isset($section['pretext'])) {
227
+					echo '
223 228
 								<p>', $section['pretext'], '</p><hr>';
229
+		}
224 230
 
225 231
 		echo '
226 232
 								<dl>';
227 233
 
228 234
 		foreach ($section['groups'] as $group)
229 235
 		{
230
-			if (isset($group['title']))
231
-				echo '
236
+			if (isset($group['title'])) {
237
+							echo '
232 238
 									<dt>
233 239
 										<strong>', $group['title'], ':</strong>
234 240
 									</dt>';
241
+			}
235 242
 
236 243
 			echo '
237 244
 									<dd>', implode(', ', $group['members']), '</dd>';
@@ -240,10 +247,11 @@  discard block
 block discarded – undo
240 247
 		echo '
241 248
 								</dl>';
242 249
 
243
-		if (isset($section['posttext']))
244
-			echo '
250
+		if (isset($section['posttext'])) {
251
+					echo '
245 252
 								<hr>
246 253
 								<p>', $section['posttext'], '</p>';
254
+		}
247 255
 	}
248 256
 
249 257
 	echo '
@@ -259,9 +267,10 @@  discard block
 block discarded – undo
259 267
 							smfSupportVersions.forum = "', $context['forum_version'], '";';
260 268
 
261 269
 	// Don't worry, none of this is logged, it's just used to give information that might be of use.
262
-	foreach ($context['current_versions'] as $variable => $version)
263
-		echo '
270
+	foreach ($context['current_versions'] as $variable => $version) {
271
+			echo '
264 272
 							smfSupportVersions.', $variable, ' = "', $version['version'], '";';
273
+	}
265 274
 
266 275
 	// Now we just have to include the script and wait ;).
267 276
 	echo '
@@ -358,8 +367,8 @@  discard block
 block discarded – undo
358 367
 							<tbody>';
359 368
 
360 369
 	// Loop through every source file displaying its version - using javascript.
361
-	foreach ($context['file_versions'] as $filename => $version)
362
-		echo '
370
+	foreach ($context['file_versions'] as $filename => $version) {
371
+			echo '
363 372
 								<tr class="windowbg">
364 373
 									<td class="half_table">
365 374
 										', $filename, '
@@ -371,6 +380,7 @@  discard block
 block discarded – undo
371 380
 										<em id="currentSources', $filename, '">??</em>
372 381
 									</td>
373 382
 								</tr>';
383
+	}
374 384
 
375 385
 	// Default template files.
376 386
 	echo '
@@ -396,8 +406,8 @@  discard block
 block discarded – undo
396 406
 							<table id="Default" class="table_grid">
397 407
 								<tbody>';
398 408
 
399
-	foreach ($context['default_template_versions'] as $filename => $version)
400
-		echo '
409
+	foreach ($context['default_template_versions'] as $filename => $version) {
410
+			echo '
401 411
 									<tr class="windowbg">
402 412
 										<td class="half_table">
403 413
 											', $filename, '
@@ -409,6 +419,7 @@  discard block
 block discarded – undo
409 419
 											<em id="currentDefault', $filename, '">??</em>
410 420
 										</td>
411 421
 									</tr>';
422
+	}
412 423
 
413 424
 	// Now the language files...
414 425
 	echo '
@@ -436,8 +447,8 @@  discard block
 block discarded – undo
436 447
 
437 448
 	foreach ($context['default_language_versions'] as $language => $files)
438 449
 	{
439
-		foreach ($files as $filename => $version)
440
-			echo '
450
+		foreach ($files as $filename => $version) {
451
+					echo '
441 452
 									<tr class="windowbg">
442 453
 										<td class="half_table">
443 454
 											', $filename, '.<em>', $language, '</em>.php
@@ -449,6 +460,7 @@  discard block
 block discarded – undo
449 460
 											<em id="current', $filename, '.', $language, '">??</em>
450 461
 										</td>
451 462
 									</tr>';
463
+		}
452 464
 	}
453 465
 
454 466
 	echo '
@@ -478,8 +490,8 @@  discard block
 block discarded – undo
478 490
 							<table id="Templates" class="table_grid">
479 491
 								<tbody>';
480 492
 
481
-		foreach ($context['template_versions'] as $filename => $version)
482
-			echo '
493
+		foreach ($context['template_versions'] as $filename => $version) {
494
+					echo '
483 495
 									<tr class="windowbg">
484 496
 										<td class="half_table">
485 497
 											', $filename, '
@@ -491,6 +503,7 @@  discard block
 block discarded – undo
491 503
 											<em id="currentTemplates', $filename, '">??</em>
492 504
 										</td>
493 505
 									</tr>';
506
+		}
494 507
 
495 508
 		echo '
496 509
 								</tbody>
@@ -520,8 +533,8 @@  discard block
 block discarded – undo
520 533
 							<table id="Tasks" class="table_grid">
521 534
 								<tbody>';
522 535
 
523
-		foreach ($context['tasks_versions'] as $filename => $version)
524
-			echo '
536
+		foreach ($context['tasks_versions'] as $filename => $version) {
537
+					echo '
525 538
 									<tr class="windowbg">
526 539
 										<td class="half_table">
527 540
 											', $filename, '
@@ -533,6 +546,7 @@  discard block
 block discarded – undo
533 546
 											<em id="currentTasks', $filename, '">??</em>
534 547
 										</td>
535 548
 									</tr>';
549
+		}
536 550
 
537 551
 		echo '
538 552
 								</tbody>
@@ -574,9 +588,10 @@  discard block
 block discarded – undo
574 588
 {
575 589
 	global $context, $scripturl, $txt, $modSettings;
576 590
 
577
-	if (!empty($context['saved_successful']))
578
-		echo '
591
+	if (!empty($context['saved_successful'])) {
592
+			echo '
579 593
 					<div class="infobox">', $txt['settings_saved'], '</div>';
594
+	}
580 595
 
581 596
 	// First section is for adding/removing words from the censored list.
582 597
 	echo '
@@ -591,11 +606,12 @@  discard block
 block discarded – undo
591 606
 								<p>', $txt['admin_censored_where'], '</p>';
592 607
 
593 608
 	// Show text boxes for censoring [bad   ] => [good  ].
594
-	foreach ($context['censored_words'] as $vulgar => $proper)
595
-		echo '
609
+	foreach ($context['censored_words'] as $vulgar => $proper) {
610
+			echo '
596 611
 								<div class="block">
597 612
 									<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> =&gt; <input type="text" name="censor_proper[]" value="', $proper, '" size="30">
598 613
 								</div>';
614
+	}
599 615
 
600 616
 	// Now provide a way to censor more words.
601 617
 	echo '
@@ -669,19 +685,21 @@  discard block
 block discarded – undo
669 685
 						<div class="windowbg2 noup">
670 686
 							', $txt['not_done_reason'];
671 687
 
672
-	if (!empty($context['continue_percent']))
673
-		echo '
688
+	if (!empty($context['continue_percent'])) {
689
+			echo '
674 690
 							<div class="progress_bar">
675 691
 								<div class="full_bar">', $context['continue_percent'], '%</div>
676 692
 								<div class="green_percent" style="width: ', $context['continue_percent'], '%;">&nbsp;</div>
677 693
 							</div>';
694
+	}
678 695
 
679
-	if (!empty($context['substep_enabled']))
680
-		echo '
696
+	if (!empty($context['substep_enabled'])) {
697
+			echo '
681 698
 							<div class="progress_bar">
682 699
 								<div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div>
683 700
 								<div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;">&nbsp;</div>
684 701
 							</div>';
702
+	}
685 703
 
686 704
 	echo '
687 705
 							<form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">
@@ -716,35 +734,40 @@  discard block
 block discarded – undo
716 734
 {
717 735
 	global $context, $txt, $scripturl;
718 736
 
719
-	if (!empty($context['saved_successful']))
720
-		echo '
737
+	if (!empty($context['saved_successful'])) {
738
+			echo '
721 739
 					<div class="infobox">', $txt['settings_saved'], '</div>';
722
-	elseif (!empty($context['saved_failed']))
723
-		echo '
740
+	} elseif (!empty($context['saved_failed'])) {
741
+			echo '
724 742
 					<div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>';
743
+	}
725 744
 
726
-	if (!empty($context['settings_pre_javascript']))
727
-		echo '
745
+	if (!empty($context['settings_pre_javascript'])) {
746
+			echo '
728 747
 					<script>', $context['settings_pre_javascript'], '</script>';
748
+	}
729 749
 
730
-	if (!empty($context['settings_insert_above']))
731
-		echo $context['settings_insert_above'];
750
+	if (!empty($context['settings_insert_above'])) {
751
+			echo $context['settings_insert_above'];
752
+	}
732 753
 
733 754
 	echo '
734 755
 					<div id="admincenter">
735 756
 						<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>';
736 757
 
737 758
 	// Is there a custom title?
738
-	if (isset($context['settings_title']))
739
-		echo '
759
+	if (isset($context['settings_title'])) {
760
+			echo '
740 761
 							<div class="cat_bar">
741 762
 								<h3 class="catbg">', $context['settings_title'], '</h3>
742 763
 							</div>';
764
+	}
743 765
 
744 766
 	// Have we got a message to display?
745
-	if (!empty($context['settings_message']))
746
-		echo '
767
+	if (!empty($context['settings_message'])) {
768
+			echo '
747 769
 							<div class="information">', $context['settings_message'], '</div>';
770
+	}
748 771
 
749 772
 	// Now actually loop through all the variables.
750 773
 	$is_open = false;
@@ -797,8 +820,9 @@  discard block
 block discarded – undo
797 820
 		// Hang about? Are you pulling my leg - a callback?!
798 821
 		if (is_array($config_var) && $config_var['type'] == 'callback')
799 822
 		{
800
-			if (function_exists('template_callback_' . $config_var['name']))
801
-				call_user_func('template_callback_' . $config_var['name']);
823
+			if (function_exists('template_callback_' . $config_var['name'])) {
824
+							call_user_func('template_callback_' . $config_var['name']);
825
+			}
802 826
 
803 827
 			continue;
804 828
 		}
@@ -828,9 +852,10 @@  discard block
 block discarded – undo
828 852
 				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
829 853
 
830 854
 				// Show the [?] button.
831
-				if ($config_var['help'])
832
-					echo '
855
+				if ($config_var['help']) {
856
+									echo '
833 857
 							<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ';
858
+				}
834 859
 
835 860
 				echo '
836 861
 										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
@@ -839,22 +864,25 @@  discard block
 block discarded – undo
839 864
 										$config_var['preinput'];
840 865
 
841 866
 				// Show a check box.
842
-				if ($config_var['type'] == 'check')
843
-					echo '
867
+				if ($config_var['type'] == 'check') {
868
+									echo '
844 869
 										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">';
870
+				}
845 871
 				// Escape (via htmlspecialchars.) the text box.
846
-				elseif ($config_var['type'] == 'password')
847
-					echo '
872
+				elseif ($config_var['type'] == 'password') {
873
+									echo '
848 874
 										<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;" class="input_password"><br>
849 875
 										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">';
876
+				}
850 877
 				// Show a selection box.
851 878
 				elseif ($config_var['type'] == 'select')
852 879
 				{
853 880
 					echo '
854 881
 										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>';
855
-					foreach ($config_var['data'] as $option)
856
-						echo '
882
+					foreach ($config_var['data'] as $option) {
883
+											echo '
857 884
 											<option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>';
885
+					}
858 886
 					echo '
859 887
 										</select>';
860 888
 				}
@@ -868,15 +896,17 @@  discard block
 block discarded – undo
868 896
 												<legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>';
869 897
 					foreach ($context['board_list'] as $id_cat => $cat)
870 898
 					{
871
-						if (!$first)
872
-							echo '
899
+						if (!$first) {
900
+													echo '
873 901
 											<hr>';
902
+						}
874 903
 						echo '
875 904
 											<strong>', $cat['name'], '</strong>
876 905
 											<ul>';
877
-						foreach ($cat['boards'] as $id_board => $brd)
878
-							echo '
906
+						foreach ($cat['boards'] as $id_board => $brd) {
907
+													echo '
879 908
 												<li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat('&nbsp; &nbsp;', $brd['child_level']) : '', $brd['name'], '</label></li>';
909
+						}
880 910
 
881 911
 						echo '
882 912
 											</ul>';
@@ -886,12 +916,14 @@  discard block
 block discarded – undo
886 916
 											</fieldset>';
887 917
 				}
888 918
 				// Text area?
889
-				elseif ($config_var['type'] == 'large_text')
890
-					echo '
919
+				elseif ($config_var['type'] == 'large_text') {
920
+									echo '
891 921
 											<textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>';
922
+				}
892 923
 				// Permission group?
893
-				elseif ($config_var['type'] == 'permissions')
894
-					theme_inline_permissions($config_var['name']);
924
+				elseif ($config_var['type'] == 'permissions') {
925
+									theme_inline_permissions($config_var['name']);
926
+				}
895 927
 				// BBC selection?
896 928
 				elseif ($config_var['type'] == 'bbc')
897 929
 				{
@@ -902,20 +934,22 @@  discard block
 block discarded – undo
902 934
 
903 935
 					foreach ($context['bbc_columns'] as $bbcColumn)
904 936
 					{
905
-						foreach ($bbcColumn as $bbcTag)
906
-							echo '
937
+						foreach ($bbcColumn as $bbcTag) {
938
+													echo '
907 939
 														<li class="list_bbc floatleft">
908 940
 															<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', ' class="input_check"> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', '
909 941
 														</li>';
942
+						}
910 943
 					}
911 944
 					echo '							</ul>
912 945
 												<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
913 946
 											</fieldset>';
914 947
 				}
915 948
 				// A simple message?
916
-				elseif ($config_var['type'] == 'var_message')
917
-					echo '
949
+				elseif ($config_var['type'] == 'var_message') {
950
+									echo '
918 951
 											<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>';
952
+				}
919 953
 				// Assume it must be a text box
920 954
 				else
921 955
 				{
@@ -940,63 +974,70 @@  discard block
 block discarded – undo
940 974
 											' . $config_var['postinput'] : '',
941 975
 										'</dd>';
942 976
 			}
943
-		}
944
-
945
-		else
977
+		} else
946 978
 		{
947 979
 			// Just show a separator.
948
-			if ($config_var == '')
949
-				echo '
980
+			if ($config_var == '') {
981
+							echo '
950 982
 								</dl>
951 983
 								<hr>
952 984
 								<dl class="settings">';
953
-			else
954
-				echo '
985
+			} else {
986
+							echo '
955 987
 									<dd>
956 988
 										<strong>' . $config_var . '</strong>
957 989
 									</dd>';
990
+			}
958 991
 		}
959 992
 	}
960 993
 
961
-	if ($is_open)
962
-		echo '
994
+	if ($is_open) {
995
+			echo '
963 996
 								</dl>';
997
+	}
964 998
 
965
-	if (empty($context['settings_save_dont_show']))
966
-		echo '
999
+	if (empty($context['settings_save_dont_show'])) {
1000
+			echo '
967 1001
 								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">';
1002
+	}
968 1003
 
969
-	if ($is_open)
970
-		echo '
1004
+	if ($is_open) {
1005
+			echo '
971 1006
 							</div>';
1007
+	}
972 1008
 
973 1009
 
974 1010
 	// At least one token has to be used!
975
-	if (isset($context['admin-ssc_token']))
976
-		echo '
1011
+	if (isset($context['admin-ssc_token'])) {
1012
+			echo '
977 1013
 							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
1014
+	}
978 1015
 
979
-	if (isset($context['admin-dbsc_token']))
980
-		echo '
1016
+	if (isset($context['admin-dbsc_token'])) {
1017
+			echo '
981 1018
 							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
1019
+	}
982 1020
 
983
-	if (isset($context['admin-mp_token']))
984
-		echo '
1021
+	if (isset($context['admin-mp_token'])) {
1022
+			echo '
985 1023
 							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
1024
+	}
986 1025
 
987 1026
 	echo '
988 1027
 							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
989 1028
 						</form>
990 1029
 					</div>';
991 1030
 
992
-	if (!empty($context['settings_post_javascript']))
993
-		echo '
1031
+	if (!empty($context['settings_post_javascript'])) {
1032
+			echo '
994 1033
 					<script>
995 1034
 					', $context['settings_post_javascript'], '
996 1035
 					</script>';
1036
+	}
997 1037
 
998
-	if (!empty($context['settings_insert_below']))
999
-		echo $context['settings_insert_below'];
1038
+	if (!empty($context['settings_insert_below'])) {
1039
+			echo $context['settings_insert_below'];
1040
+	}
1000 1041
 
1001 1042
 	// We may have added a board listing. If we did, we need to make it work.
1002 1043
 	addInlineJavascript('
@@ -1019,9 +1060,10 @@  discard block
 block discarded – undo
1019 1060
 {
1020 1061
 	global $context, $txt;
1021 1062
 
1022
-	if (!empty($context['saved_successful']))
1023
-		echo '
1063
+	if (!empty($context['saved_successful'])) {
1064
+			echo '
1024 1065
 					<div class="infobox">', $txt['settings_saved'], '</div>';
1066
+	}
1025 1067
 
1026 1068
 	// Standard fields.
1027 1069
 	template_show_list('standard_profile_fields');
@@ -1053,11 +1095,12 @@  discard block
 block discarded – undo
1053 1095
 	if (isset($_GET['msg']))
1054 1096
 	{
1055 1097
 		loadLanguage('Errors');
1056
-		if (isset($txt['custom_option_' . $_GET['msg']]))
1057
-			echo '
1098
+		if (isset($txt['custom_option_' . $_GET['msg']])) {
1099
+					echo '
1058 1100
 					<div class="errorbox">',
1059 1101
 						$txt['custom_option_' . $_GET['msg']], '
1060 1102
 					</div>';
1103
+		}
1061 1104
 	}
1062 1105
 
1063 1106
 	echo '
@@ -1123,9 +1166,10 @@  discard block
 block discarded – undo
1123 1166
 										<dd>
1124 1167
 											<select name="placement" id="placement">';
1125 1168
 
1126
-	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1127
-		echo '
1169
+	foreach ($context['cust_profile_fields_placement'] as $order => $name) {
1170
+			echo '
1128 1171
 												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1172
+	}
1129 1173
 
1130 1174
 	echo '
1131 1175
 											</select>
@@ -1148,9 +1192,10 @@  discard block
 block discarded – undo
1148 1192
 										</dt>
1149 1193
 										<dd>
1150 1194
 											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1151
-	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1152
-		echo '
1195
+	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) {
1196
+			echo '
1153 1197
 												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1198
+	}
1154 1199
 
1155 1200
 	echo '
1156 1201
 											</select>
@@ -1251,9 +1296,10 @@  discard block
 block discarded – undo
1251 1296
 								</fieldset>
1252 1297
 									<input type="submit" name="save" value="', $txt['save'], '" class="button_submit">';
1253 1298
 
1254
-	if ($context['fid'])
1255
-		echo '
1299
+	if ($context['fid']) {
1300
+			echo '
1256 1301
 									<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">';
1302
+	}
1257 1303
 
1258 1304
 	echo '
1259 1305
 							</div>
@@ -1296,8 +1342,7 @@  discard block
 block discarded – undo
1296 1342
 	{
1297 1343
 		echo '
1298 1344
 						<p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>';
1299
-	}
1300
-	else
1345
+	} else
1301 1346
 	{
1302 1347
 		echo '
1303 1348
 						<ol class="search_results">';
@@ -1323,9 +1368,10 @@  discard block
 block discarded – undo
1323 1368
 							<li>
1324 1369
 								<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1325 1370
 
1326
-				if ($result['help'])
1327
-					echo '
1371
+				if ($result['help']) {
1372
+									echo '
1328 1373
 								<p class="double_height">', $result['help'], '</p>';
1374
+				}
1329 1375
 
1330 1376
 				echo '
1331 1377
 							</li>';
@@ -1365,18 +1411,20 @@  discard block
 block discarded – undo
1365 1411
 									<strong>', $txt['setup_verification_answer'], '</strong>
1366 1412
 								</dd>';
1367 1413
 
1368
-		if (!empty($context['qa_by_lang'][$lang_id]))
1369
-			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1414
+		if (!empty($context['qa_by_lang'][$lang_id])) {
1415
+					foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1370 1416
 			{
1371 1417
 				$question = $context['question_answers'][$q_id];
1418
+		}
1372 1419
 				echo '
1373 1420
 								<dt>
1374 1421
 									<input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question">
1375 1422
 								</dt>
1376 1423
 								<dd>';
1377
-				foreach ($question['answers'] as $answer)
1378
-					echo '
1424
+				foreach ($question['answers'] as $answer) {
1425
+									echo '
1379 1426
 									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">';
1427
+				}
1380 1428
 
1381 1429
 				echo '
1382 1430
 									<div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
@@ -1415,11 +1463,12 @@  discard block
 block discarded – undo
1415 1463
 							', $txt['errors_found'], ':
1416 1464
 							<ul>';
1417 1465
 
1418
-			foreach ($context['repair_errors'] as $error)
1419
-				echo '
1466
+			foreach ($context['repair_errors'] as $error) {
1467
+							echo '
1420 1468
 								<li>
1421 1469
 									', $error, '
1422 1470
 								</li>';
1471
+			}
1423 1472
 
1424 1473
 			echo '
1425 1474
 							</ul>
@@ -1429,16 +1478,15 @@  discard block
 block discarded – undo
1429 1478
 							<p class="padding">
1430 1479
 								<strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong>
1431 1480
 							</p>';
1432
-		}
1433
-		else
1434
-			echo '
1481
+		} else {
1482
+					echo '
1435 1483
 							<p>', $txt['maintain_no_errors'], '</p>
1436 1484
 							<p class="padding">
1437 1485
 								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1438 1486
 							</p>';
1487
+		}
1439 1488
 
1440
-	}
1441
-	else
1489
+	} else
1442 1490
 	{
1443 1491
 		if (!empty($context['redirect_to_recount']))
1444 1492
 		{
@@ -1450,8 +1498,7 @@  discard block
 block discarded – undo
1450 1498
 								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1451 1499
 								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1452 1500
 							</form>';
1453
-		}
1454
-		else
1501
+		} else
1455 1502
 		{
1456 1503
 			echo '
1457 1504
 							<p>', $txt['errors_fixed'], '</p>
@@ -1603,8 +1650,8 @@  discard block
 block discarded – undo
1603 1650
 function template_admin_quick_search()
1604 1651
 {
1605 1652
 	global $context, $txt;
1606
-	if ($context['user']['is_admin'])
1607
-		echo '
1653
+	if ($context['user']['is_admin']) {
1654
+			echo '
1608 1655
 								<span class="floatright admin_search">
1609 1656
 									<span class="generic_icons filter centericon"></span>
1610 1657
 									<input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text">
@@ -1615,6 +1662,7 @@  discard block
 block discarded – undo
1615 1662
 									</select>
1616 1663
 									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit">
1617 1664
 								</span>';
1618
-}
1665
+	}
1666
+	}
1619 1667
 
1620 1668
 ?>
1621 1669
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Db-mysql.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 
257 257
 		case 'datetime':
258 258
 			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
259
-				return 'str_to_date('.
260
-					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
259
+				return 'str_to_date(' .
260
+					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) .
261 261
 					',\'%Y-%m-%d %h:%i:%s\')';
262 262
 			else
263 263
 				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	{
842 842
 		$count = count($insertRows);
843 843
 		$ai = 0;
844
-		for($i = 0; $i < $count; $i++)
844
+		for ($i = 0; $i < $count; $i++)
845 845
 		{
846 846
 			$old_id = $smcFunc['db_insert_id']();
847 847
 			
@@ -867,13 +867,13 @@  discard block
 block discarded – undo
867 867
 				$count2 = count($indexed_columns);
868 868
 				for ($x = 0; $x < $count2; $x++)
869 869
 				{
870
-					$where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x];
870
+					$where_string += key($indexed_columns[$x]) . ' = ' . $insertRows[$i][$x];
871 871
 					if (($x + 1) < $count2)
872 872
 						$where_string += ' AND ';
873 873
 				}
874 874
 
875
-				$request = $smcFunc['db_query']('','
876
-					SELECT `'. $keys[0] . '` FROM ' . $table .'
875
+				$request = $smcFunc['db_query']('', '
876
+					SELECT `'. $keys[0] . '` FROM ' . $table . '
877 877
 					WHERE ' . $where_string . ' LIMIT 1',
878 878
 					array()
879 879
 				);
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 			$return_var = array();
903 903
 			$count = count($insertRows);
904 904
 			$start = smf_db_insert_id($table, $keys[0]);
905
-			for ($i = 0; $i < $count; $i++ )
905
+			for ($i = 0; $i < $count; $i++)
906 906
 				$return_var[] = $start + $i;
907 907
 		}
908 908
 		return $return_var;
Please login to merge, or discard this patch.
Braces   +266 added lines, -197 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Maps the implementations in this file (smf_db_function_name)
@@ -33,8 +34,8 @@  discard block
 block discarded – undo
33 34
 	global $smcFunc;
34 35
 
35 36
 	// Map some database specific functions, only do this once.
36
-	if (!isset($smcFunc['db_fetch_assoc']))
37
-		$smcFunc += array(
37
+	if (!isset($smcFunc['db_fetch_assoc'])) {
38
+			$smcFunc += array(
38 39
 			'db_query'                  => 'smf_db_query',
39 40
 			'db_quote'                  => 'smf_db_quote',
40 41
 			'db_fetch_assoc'            => 'mysqli_fetch_assoc',
@@ -61,9 +62,11 @@  discard block
 block discarded – undo
61 62
 			'db_ping'                   => 'mysqli_ping',
62 63
 			'db_fetch_all'              => 'smf_db_fetch_all',
63 64
 		);
65
+	}
64 66
 
65
-	if (!empty($db_options['persist']))
66
-		$db_server = 'p:' . $db_server;
67
+	if (!empty($db_options['persist'])) {
68
+			$db_server = 'p:' . $db_server;
69
+	}
67 70
 
68 71
 	$connection = mysqli_init();
69 72
 
@@ -72,24 +75,27 @@  discard block
 block discarded – undo
72 75
 	$success = false;
73 76
 
74 77
 	if ($connection) {
75
-		if (!empty($db_options['port']))
76
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
77
-		else
78
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
78
+		if (!empty($db_options['port'])) {
79
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
80
+		} else {
81
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
82
+		}
79 83
 	}
80 84
 
81 85
 	// Something's wrong, show an error if its fatal (which we assume it is)
82 86
 	if ($success === false)
83 87
 	{
84
-		if (!empty($db_options['non_fatal']))
85
-			return null;
86
-		else
87
-			display_db_error();
88
+		if (!empty($db_options['non_fatal'])) {
89
+					return null;
90
+		} else {
91
+					display_db_error();
92
+		}
88 93
 	}
89 94
 
90 95
 	// Select the database, unless told not to
91
-	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal']))
92
-		display_db_error();
96
+	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) {
97
+			display_db_error();
98
+	}
93 99
 
94 100
 	$smcFunc['db_query']('', 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'',
95 101
 		array(),
@@ -165,34 +171,42 @@  discard block
 block discarded – undo
165 171
 	global $db_callback, $user_info, $db_prefix, $smcFunc;
166 172
 
167 173
 	list ($values, $connection) = $db_callback;
168
-	if (!is_object($connection))
169
-		display_db_error();
174
+	if (!is_object($connection)) {
175
+			display_db_error();
176
+	}
170 177
 
171
-	if ($matches[1] === 'db_prefix')
172
-		return $db_prefix;
178
+	if ($matches[1] === 'db_prefix') {
179
+			return $db_prefix;
180
+	}
173 181
 
174
-	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false)
175
-		return $user_info[$matches[1]];
182
+	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) {
183
+			return $user_info[$matches[1]];
184
+	}
176 185
 
177
-	if ($matches[1] === 'empty')
178
-		return '\'\'';
186
+	if ($matches[1] === 'empty') {
187
+			return '\'\'';
188
+	}
179 189
 
180
-	if (!isset($matches[2]))
181
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
190
+	if (!isset($matches[2])) {
191
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
192
+	}
182 193
 
183
-	if ($matches[1] === 'literal')
184
-		return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
194
+	if ($matches[1] === 'literal') {
195
+			return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
196
+	}
185 197
 
186
-	if (!isset($values[$matches[2]]))
187
-		smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
198
+	if (!isset($values[$matches[2]])) {
199
+			smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
200
+	}
188 201
 
189 202
 	$replacement = $values[$matches[2]];
190 203
 
191 204
 	switch ($matches[1])
192 205
 	{
193 206
 		case 'int':
194
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
195
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
207
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
208
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
209
+			}
196 210
 			return (string) (int) $replacement;
197 211
 		break;
198 212
 
@@ -204,65 +218,73 @@  discard block
 block discarded – undo
204 218
 		case 'array_int':
205 219
 			if (is_array($replacement))
206 220
 			{
207
-				if (empty($replacement))
208
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
221
+				if (empty($replacement)) {
222
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
223
+				}
209 224
 
210 225
 				foreach ($replacement as $key => $value)
211 226
 				{
212
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
213
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
227
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
228
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
229
+					}
214 230
 
215 231
 					$replacement[$key] = (string) (int) $value;
216 232
 				}
217 233
 
218 234
 				return implode(', ', $replacement);
235
+			} else {
236
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
219 237
 			}
220
-			else
221
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
222 238
 
223 239
 		break;
224 240
 
225 241
 		case 'array_string':
226 242
 			if (is_array($replacement))
227 243
 			{
228
-				if (empty($replacement))
229
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
244
+				if (empty($replacement)) {
245
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
246
+				}
230 247
 
231
-				foreach ($replacement as $key => $value)
232
-					$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
248
+				foreach ($replacement as $key => $value) {
249
+									$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
250
+				}
233 251
 
234 252
 				return implode(', ', $replacement);
253
+			} else {
254
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
235 255
 			}
236
-			else
237
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
238 256
 		break;
239 257
 
240 258
 		case 'date':
241
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
242
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
243
-			else
244
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
259
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
260
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
261
+			} else {
262
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
263
+			}
245 264
 		break;
246 265
 
247 266
 		case 'time':
248
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
249
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
250
-			else
251
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
267
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
268
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
269
+			} else {
270
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
271
+			}
252 272
 		break;
253 273
 
254 274
 		case 'datetime':
255
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
256
-				return 'str_to_date('.
275
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) {
276
+							return 'str_to_date('.
257 277
 					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
258 278
 					',\'%Y-%m-%d %h:%i:%s\')';
259
-			else
260
-				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
279
+			} else {
280
+							smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
281
+			}
261 282
 		break;
262 283
 
263 284
 		case 'float':
264
-			if (!is_numeric($replacement))
265
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
285
+			if (!is_numeric($replacement)) {
286
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
287
+			}
266 288
 			return (string) (float) $replacement;
267 289
 		break;
268 290
 
@@ -276,32 +298,37 @@  discard block
 block discarded – undo
276 298
 		break;
277 299
 
278 300
 		case 'inet':
279
-			if ($replacement == 'null' || $replacement == '')
280
-				return 'null';
281
-			if (!isValidIP($replacement))
282
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
301
+			if ($replacement == 'null' || $replacement == '') {
302
+							return 'null';
303
+			}
304
+			if (!isValidIP($replacement)) {
305
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
306
+			}
283 307
 			//we don't use the native support of mysql > 5.6.2
284 308
 			return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement)));
285 309
 
286 310
 		case 'array_inet':
287 311
 			if (is_array($replacement))
288 312
 			{
289
-				if (empty($replacement))
290
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
313
+				if (empty($replacement)) {
314
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
315
+				}
291 316
 
292 317
 				foreach ($replacement as $key => $value)
293 318
 				{
294
-					if ($replacement == 'null' || $replacement == '')
295
-						$replacement[$key] = 'null';
296
-					if (!isValidIP($value))
297
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
319
+					if ($replacement == 'null' || $replacement == '') {
320
+											$replacement[$key] = 'null';
321
+					}
322
+					if (!isValidIP($value)) {
323
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
324
+					}
298 325
 					$replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value)));
299 326
 				}
300 327
 
301 328
 				return implode(', ', $replacement);
329
+			} else {
330
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
302 331
 			}
303
-			else
304
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
305 332
 		break;
306 333
 
307 334
 		default:
@@ -377,22 +404,25 @@  discard block
 block discarded – undo
377 404
 		// Are we in SSI mode?  If so try that username and password first
378 405
 		if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
379 406
 		{
380
-			if (empty($db_persist))
381
-				$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
382
-			else
383
-				$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
407
+			if (empty($db_persist)) {
408
+							$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
409
+			} else {
410
+							$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
411
+			}
384 412
 		}
385 413
 		// Fall back to the regular username and password if need be
386 414
 		if (!$db_connection)
387 415
 		{
388
-			if (empty($db_persist))
389
-				$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
390
-			else
391
-				$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
416
+			if (empty($db_persist)) {
417
+							$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
418
+			} else {
419
+							$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
420
+			}
392 421
 		}
393 422
 
394
-		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
395
-			$db_connection = false;
423
+		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
424
+					$db_connection = false;
425
+		}
396 426
 
397 427
 		$connection = $db_connection;
398 428
 	}
@@ -400,18 +430,20 @@  discard block
 block discarded – undo
400 430
 	// One more query....
401 431
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
402 432
 
403
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
404
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
433
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
434
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
435
+	}
405 436
 
406 437
 	// Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By
407 438
 	if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
408 439
 	{
409 440
 		// Add before LIMIT
410
-		if ($pos = strpos($db_string, 'LIMIT '))
411
-			$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
412
-		else
413
-			// Append it.
441
+		if ($pos = strpos($db_string, 'LIMIT ')) {
442
+					$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
443
+		} else {
444
+					// Append it.
414 445
 			$db_string .= "\n\t\t\tORDER BY null";
446
+		}
415 447
 	}
416 448
 
417 449
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
@@ -433,8 +465,9 @@  discard block
 block discarded – undo
433 465
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
434 466
 
435 467
 		// Initialize $db_cache if not already initialized.
436
-		if (!isset($db_cache))
437
-			$db_cache = array();
468
+		if (!isset($db_cache)) {
469
+					$db_cache = array();
470
+		}
438 471
 
439 472
 		if (!empty($_SESSION['debug_redirect']))
440 473
 		{
@@ -460,17 +493,18 @@  discard block
 block discarded – undo
460 493
 		while (true)
461 494
 		{
462 495
 			$pos = strpos($db_string, '\'', $pos + 1);
463
-			if ($pos === false)
464
-				break;
496
+			if ($pos === false) {
497
+							break;
498
+			}
465 499
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
466 500
 
467 501
 			while (true)
468 502
 			{
469 503
 				$pos1 = strpos($db_string, '\'', $pos + 1);
470 504
 				$pos2 = strpos($db_string, '\\', $pos + 1);
471
-				if ($pos1 === false)
472
-					break;
473
-				elseif ($pos2 === false || $pos2 > $pos1)
505
+				if ($pos1 === false) {
506
+									break;
507
+				} elseif ($pos2 === false || $pos2 > $pos1)
474 508
 				{
475 509
 					$pos = $pos1;
476 510
 					break;
@@ -486,29 +520,35 @@  discard block
 block discarded – undo
486 520
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
487 521
 
488 522
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
489
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
490
-			$fail = true;
523
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
524
+					$fail = true;
525
+		}
491 526
 		// Trying to change passwords, slow us down, or something?
492
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
493
-			$fail = true;
494
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
495
-			$fail = true;
527
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
528
+					$fail = true;
529
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
530
+					$fail = true;
531
+		}
496 532
 
497
-		if (!empty($fail) && function_exists('log_error'))
498
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
533
+		if (!empty($fail) && function_exists('log_error')) {
534
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
535
+		}
499 536
 	}
500 537
 
501
-	if (empty($db_unbuffered))
502
-		$ret = @mysqli_query($connection, $db_string);
503
-	else
504
-		$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
538
+	if (empty($db_unbuffered)) {
539
+			$ret = @mysqli_query($connection, $db_string);
540
+	} else {
541
+			$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
542
+	}
505 543
 
506
-	if ($ret === false && empty($db_values['db_error_skip']))
507
-		$ret = smf_db_error($db_string, $connection);
544
+	if ($ret === false && empty($db_values['db_error_skip'])) {
545
+			$ret = smf_db_error($db_string, $connection);
546
+	}
508 547
 
509 548
 	// Debugging.
510
-	if (isset($db_show_debug) && $db_show_debug === true)
511
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
549
+	if (isset($db_show_debug) && $db_show_debug === true) {
550
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
551
+	}
512 552
 
513 553
 	return $ret;
514 554
 }
@@ -555,12 +595,13 @@  discard block
 block discarded – undo
555 595
 	// Decide which connection to use
556 596
 	$connection = $connection === null ? $db_connection : $connection;
557 597
 
558
-	if ($type == 'begin')
559
-		return @mysqli_query($connection, 'BEGIN');
560
-	elseif ($type == 'rollback')
561
-		return @mysqli_query($connection, 'ROLLBACK');
562
-	elseif ($type == 'commit')
563
-		return @mysqli_query($connection, 'COMMIT');
598
+	if ($type == 'begin') {
599
+			return @mysqli_query($connection, 'BEGIN');
600
+	} elseif ($type == 'rollback') {
601
+			return @mysqli_query($connection, 'ROLLBACK');
602
+	} elseif ($type == 'commit') {
603
+			return @mysqli_query($connection, 'COMMIT');
604
+	}
564 605
 
565 606
 	return false;
566 607
 }
@@ -600,8 +641,9 @@  discard block
 block discarded – undo
600 641
 	//    2013: Lost connection to server during query.
601 642
 
602 643
 	// Log the error.
603
-	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error'))
604
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
644
+	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
645
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
646
+	}
605 647
 
606 648
 	// Database error auto fixing ;).
607 649
 	if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1'))
@@ -610,8 +652,9 @@  discard block
 block discarded – undo
610 652
 		$old_cache = @$modSettings['cache_enable'];
611 653
 		$modSettings['cache_enable'] = '1';
612 654
 
613
-		if (($temp = cache_get_data('db_last_error', 600)) !== null)
614
-			$db_last_error = max(@$db_last_error, $temp);
655
+		if (($temp = cache_get_data('db_last_error', 600)) !== null) {
656
+					$db_last_error = max(@$db_last_error, $temp);
657
+		}
615 658
 
616 659
 		if (@$db_last_error < time() - 3600 * 24 * 3)
617 660
 		{
@@ -627,8 +670,9 @@  discard block
 block discarded – undo
627 670
 					foreach ($tables as $table)
628 671
 					{
629 672
 						// Now, it's still theoretically possible this could be an injection.  So backtick it!
630
-						if (trim($table) != '')
631
-							$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
673
+						if (trim($table) != '') {
674
+													$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
675
+						}
632 676
 					}
633 677
 				}
634 678
 
@@ -637,8 +681,9 @@  discard block
 block discarded – undo
637 681
 			// Table crashed.  Let's try to fix it.
638 682
 			elseif ($query_errno == 1016)
639 683
 			{
640
-				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0)
641
-					$fix_tables = array('`' . $match[1] . '`');
684
+				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) {
685
+									$fix_tables = array('`' . $match[1] . '`');
686
+				}
642 687
 			}
643 688
 			// Indexes crashed.  Should be easy to fix!
644 689
 			elseif ($query_errno == 1034 || $query_errno == 1035)
@@ -657,13 +702,15 @@  discard block
 block discarded – undo
657 702
 
658 703
 			// Make a note of the REPAIR...
659 704
 			cache_put_data('db_last_error', time(), 600);
660
-			if (($temp = cache_get_data('db_last_error', 600)) === null)
661
-				updateSettingsFile(array('db_last_error' => time()));
705
+			if (($temp = cache_get_data('db_last_error', 600)) === null) {
706
+							updateSettingsFile(array('db_last_error' => time()));
707
+			}
662 708
 
663 709
 			// Attempt to find and repair the broken table.
664
-			foreach ($fix_tables as $table)
665
-				$smcFunc['db_query']('', "
710
+			foreach ($fix_tables as $table) {
711
+							$smcFunc['db_query']('', "
666 712
 					REPAIR TABLE $table", false, false);
713
+			}
667 714
 
668 715
 			// And send off an email!
669 716
 			sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror');
@@ -672,11 +719,12 @@  discard block
 block discarded – undo
672 719
 
673 720
 			// Try the query again...?
674 721
 			$ret = $smcFunc['db_query']('', $db_string, false, false);
675
-			if ($ret !== false)
676
-				return $ret;
722
+			if ($ret !== false) {
723
+							return $ret;
724
+			}
725
+		} else {
726
+					$modSettings['cache_enable'] = $old_cache;
677 727
 		}
678
-		else
679
-			$modSettings['cache_enable'] = $old_cache;
680 728
 
681 729
 		// Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
682 730
 		if (in_array($query_errno, array(1205, 1213, 2006, 2013)))
@@ -686,22 +734,25 @@  discard block
 block discarded – undo
686 734
 				// Are we in SSI mode?  If so try that username and password first
687 735
 				if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
688 736
 				{
689
-					if (empty($db_persist))
690
-						$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
691
-					else
692
-						$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
737
+					if (empty($db_persist)) {
738
+											$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
739
+					} else {
740
+											$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
741
+					}
693 742
 				}
694 743
 				// Fall back to the regular username and password if need be
695 744
 				if (!$db_connection)
696 745
 				{
697
-					if (empty($db_persist))
698
-						$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
699
-					else
700
-						$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
746
+					if (empty($db_persist)) {
747
+											$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
748
+					} else {
749
+											$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
750
+					}
701 751
 				}
702 752
 
703
-				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
704
-					$db_connection = false;
753
+				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
754
+									$db_connection = false;
755
+				}
705 756
 			}
706 757
 
707 758
 			if ($db_connection)
@@ -712,24 +763,27 @@  discard block
 block discarded – undo
712 763
 					$ret = $smcFunc['db_query']('', $db_string, false, false);
713 764
 
714 765
 					$new_errno = mysqli_errno($db_connection);
715
-					if ($ret !== false || in_array($new_errno, array(1205, 1213)))
716
-						break;
766
+					if ($ret !== false || in_array($new_errno, array(1205, 1213))) {
767
+											break;
768
+					}
717 769
 				}
718 770
 
719 771
 				// If it failed again, shucks to be you... we're not trying it over and over.
720
-				if ($ret !== false)
721
-					return $ret;
772
+				if ($ret !== false) {
773
+									return $ret;
774
+				}
722 775
 			}
723 776
 		}
724 777
 		// Are they out of space, perhaps?
725 778
 		elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false))
726 779
 		{
727
-			if (!isset($txt))
728
-				$query_error .= ' - check database storage space.';
729
-			else
780
+			if (!isset($txt)) {
781
+							$query_error .= ' - check database storage space.';
782
+			} else
730 783
 			{
731
-				if (!isset($txt['mysql_error_space']))
732
-					loadLanguage('Errors');
784
+				if (!isset($txt['mysql_error_space'])) {
785
+									loadLanguage('Errors');
786
+				}
733 787
 
734 788
 				$query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space'];
735 789
 			}
@@ -737,15 +791,17 @@  discard block
 block discarded – undo
737 791
 	}
738 792
 
739 793
 	// Nothing's defined yet... just die with it.
740
-	if (empty($context) || empty($txt))
741
-		die($query_error);
794
+	if (empty($context) || empty($txt)) {
795
+			die($query_error);
796
+	}
742 797
 
743 798
 	// Show an error message, if possible.
744 799
 	$context['error_title'] = $txt['database_error'];
745
-	if (allowedTo('admin_forum'))
746
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
747
-	else
748
-		$context['error_message'] = $txt['try_again'];
800
+	if (allowedTo('admin_forum')) {
801
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
802
+	} else {
803
+			$context['error_message'] = $txt['try_again'];
804
+	}
749 805
 
750 806
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
751 807
 	{
@@ -777,8 +833,9 @@  discard block
 block discarded – undo
777 833
 	$return_var = null;
778 834
 
779 835
 	// With nothing to insert, simply return.
780
-	if (empty($data))
781
-		return;
836
+	if (empty($data)) {
837
+			return;
838
+	}
782 839
 
783 840
 	// Replace the prefix holder with the actual prefix.
784 841
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
@@ -788,23 +845,26 @@  discard block
 block discarded – undo
788 845
 	if (!empty($keys) && (count($keys) > 0) && $returnmode > 0)
789 846
 	{
790 847
 		$with_returning = true;
791
-		if ($returnmode == 2)
792
-			$return_var = array();
848
+		if ($returnmode == 2) {
849
+					$return_var = array();
850
+		}
793 851
 	}
794 852
 
795 853
 	// Inserting data as a single row can be done as a single array.
796
-	if (!is_array($data[array_rand($data)]))
797
-		$data = array($data);
854
+	if (!is_array($data[array_rand($data)])) {
855
+			$data = array($data);
856
+	}
798 857
 
799 858
 	// Create the mold for a single row insert.
800 859
 	$insertData = '(';
801 860
 	foreach ($columns as $columnName => $type)
802 861
 	{
803 862
 		// Are we restricting the length?
804
-		if (strpos($type, 'string-') !== false)
805
-			$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
806
-		else
807
-			$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
863
+		if (strpos($type, 'string-') !== false) {
864
+					$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
865
+		} else {
866
+					$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
867
+		}
808 868
 	}
809 869
 	$insertData = substr($insertData, 0, -2) . ')';
810 870
 
@@ -813,8 +873,9 @@  discard block
 block discarded – undo
813 873
 
814 874
 	// Here's where the variables are injected to the query.
815 875
 	$insertRows = array();
816
-	foreach ($data as $dataRow)
817
-		$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
876
+	foreach ($data as $dataRow) {
877
+			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
878
+	}
818 879
 
819 880
 	// Determine the method of insertion.
820 881
 	$queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT');
@@ -833,8 +894,7 @@  discard block
 block discarded – undo
833 894
 			),
834 895
 			$connection
835 896
 		);
836
-	}
837
-	else //special way for ignore method with returning
897
+	} else //special way for ignore method with returning
838 898
 	{
839 899
 		$count = count($insertRows);
840 900
 		$ai = 0;
@@ -854,19 +914,21 @@  discard block
 block discarded – undo
854 914
 			);
855 915
 			$new_id = $smcFunc['db_insert_id']();
856 916
 			
857
-			if ($last_id != $new_id) //the inserted value was new
917
+			if ($last_id != $new_id) {
918
+				//the inserted value was new
858 919
 			{
859 920
 				$ai = $new_id;
860 921
 			}
861
-			else	// the inserted value already exists we need to find the pk
922
+			} else	// the inserted value already exists we need to find the pk
862 923
 			{
863 924
 				$where_string = '';
864 925
 				$count2 = count($indexed_columns);
865 926
 				for ($x = 0; $x < $count2; $x++)
866 927
 				{
867 928
 					$where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x];
868
-					if (($x + 1) < $count2)
869
-						$where_string += ' AND ';
929
+					if (($x + 1) < $count2) {
930
+											$where_string += ' AND ';
931
+					}
870 932
 				}
871 933
 
872 934
 				$request = $smcFunc['db_query']('','
@@ -882,25 +944,27 @@  discard block
 block discarded – undo
882 944
 				}
883 945
 			}
884 946
 			
885
-			if ($returnmode == 1)
886
-				$return_var = $ai;
887
-			else if ($returnmode == 2)
888
-				$return_var[] = $ai;
947
+			if ($returnmode == 1) {
948
+							$return_var = $ai;
949
+			} else if ($returnmode == 2) {
950
+							$return_var[] = $ai;
951
+			}
889 952
 		}
890 953
 	}
891 954
 	
892 955
 
893 956
 	if ($with_returning)
894 957
 	{
895
-		if ($returnmode == 1 && empty($return_var))
896
-			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
897
-		else if ($returnmode == 2 && empty($return_var))
958
+		if ($returnmode == 1 && empty($return_var)) {
959
+					$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
960
+		} else if ($returnmode == 2 && empty($return_var))
898 961
 		{
899 962
 			$return_var = array();
900 963
 			$count = count($insertRows);
901 964
 			$start = smf_db_insert_id($table, $keys[0]);
902
-			for ($i = 0; $i < $count; $i++ )
903
-				$return_var[] = $start + $i;
965
+			for ($i = 0; $i < $count; $i++ ) {
966
+							$return_var[] = $start + $i;
967
+			}
904 968
 		}
905 969
 		return $return_var;
906 970
 	}
@@ -918,8 +982,9 @@  discard block
 block discarded – undo
918 982
  */
919 983
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
920 984
 {
921
-	if (empty($log_message))
922
-		$log_message = $error_message;
985
+	if (empty($log_message)) {
986
+			$log_message = $error_message;
987
+	}
923 988
 
924 989
 	foreach (debug_backtrace() as $step)
925 990
 	{
@@ -938,12 +1003,14 @@  discard block
 block discarded – undo
938 1003
 	}
939 1004
 
940 1005
 	// A special case - we want the file and line numbers for debugging.
941
-	if ($error_type == 'return')
942
-		return array($file, $line);
1006
+	if ($error_type == 'return') {
1007
+			return array($file, $line);
1008
+	}
943 1009
 
944 1010
 	// Is always a critical error.
945
-	if (function_exists('log_error'))
946
-		log_error($log_message, 'critical', $file, $line);
1011
+	if (function_exists('log_error')) {
1012
+			log_error($log_message, 'critical', $file, $line);
1013
+	}
947 1014
 
948 1015
 	if (function_exists('fatal_error'))
949 1016
 	{
@@ -951,12 +1018,12 @@  discard block
 block discarded – undo
951 1018
 
952 1019
 		// Cannot continue...
953 1020
 		exit;
1021
+	} elseif ($error_type) {
1022
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
1023
+	} else {
1024
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
1025
+	}
954 1026
 	}
955
-	elseif ($error_type)
956
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
957
-	else
958
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
959
-}
960 1027
 
961 1028
 /**
962 1029
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -973,10 +1040,11 @@  discard block
 block discarded – undo
973 1040
 		'\\' => '\\\\',
974 1041
 	);
975 1042
 
976
-	if ($translate_human_wildcards)
977
-		$replacements += array(
1043
+	if ($translate_human_wildcards) {
1044
+			$replacements += array(
978 1045
 			'*' => '%',
979 1046
 		);
1047
+	}
980 1048
 
981 1049
 	return strtr($string, $replacements);
982 1050
 }
@@ -990,8 +1058,9 @@  discard block
 block discarded – undo
990 1058
  */
991 1059
 function smf_is_resource($result)
992 1060
 {
993
-	if ($result instanceof mysqli_result)
994
-		return true;
1061
+	if ($result instanceof mysqli_result) {
1062
+			return true;
1063
+	}
995 1064
 
996 1065
 	return false;
997 1066
 }
Please login to merge, or discard this patch.
Sources/CacheAPI-zend.php 1 patch
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 	{
28 29
 		$supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get');
29 30
 
30
-		if ($test)
31
-			return $supported;
31
+		if ($test) {
32
+					return $supported;
33
+		}
32 34
 		return parent::isSupported() && $supported;
33 35
 	}
34 36
 
@@ -40,10 +42,11 @@  discard block
 block discarded – undo
40 42
 		$key = $this->prefix . strtr($key, ':/', '-_');
41 43
 
42 44
 		// Zend's pricey stuff.
43
-		if (function_exists('zend_shm_cache_fetch'))
44
-			return zend_shm_cache_fetch('SMF::' . $key);
45
-		elseif (function_exists('output_cache_get'))
46
-			return output_cache_get($key, $ttl);
45
+		if (function_exists('zend_shm_cache_fetch')) {
46
+					return zend_shm_cache_fetch('SMF::' . $key);
47
+		} elseif (function_exists('output_cache_get')) {
48
+					return output_cache_get($key, $ttl);
49
+		}
47 50
 	}
48 51
 
49 52
 	/**
@@ -53,10 +56,11 @@  discard block
 block discarded – undo
53 56
 	{
54 57
 		$key = $this->prefix . strtr($key, ':/', '-_');
55 58
 
56
-		if (function_exists('zend_shm_cache_store'))
57
-			return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
58
-		elseif (function_exists('output_cache_put'))
59
-			return output_cache_put($key, $value);
59
+		if (function_exists('zend_shm_cache_store')) {
60
+					return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
61
+		} elseif (function_exists('output_cache_put')) {
62
+					return output_cache_put($key, $value);
63
+		}
60 64
 	}
61 65
 
62 66
 	/**
Please login to merge, or discard this patch.
Sources/CacheAPI-apc.php 1 patch
Braces   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 	{
28 29
 		$supported = function_exists('apc_fetch') && function_exists('apc_store');
29 30
 
30
-		if ($test)
31
-			return $supported;
31
+		if ($test) {
32
+					return $supported;
33
+		}
32 34
 		return parent::isSupported() && $supported;
33 35
 	}
34 36
 
@@ -50,10 +52,11 @@  discard block
 block discarded – undo
50 52
 		$key = $this->prefix . strtr($key, ':/', '-_');
51 53
 
52 54
 		// An extended key is needed to counteract a bug in APC.
53
-		if ($value === null)
54
-			return apc_delete($key . 'smf');
55
-		else
56
-			return apc_store($key . 'smf', $value, $ttl);
55
+		if ($value === null) {
56
+					return apc_delete($key . 'smf');
57
+		} else {
58
+					return apc_store($key . 'smf', $value, $ttl);
59
+		}
57 60
 	}
58 61
 
59 62
 	/**
@@ -67,9 +70,9 @@  discard block
 block discarded – undo
67 70
 			// Always returns true.
68 71
 			apc_clear_cache('user');
69 72
 			apc_clear_cache('system');
73
+		} elseif ($type === 'user') {
74
+					apc_clear_cache('user');
70 75
 		}
71
-		elseif ($type === 'user')
72
-			apc_clear_cache('user');
73 76
 
74 77
 		$this->invalidateCache();
75 78
 		return true;
Please login to merge, or discard this patch.