Completed
Pull Request — release-2.1 (#4156)
by 01
13:04 queued 03:20
created
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/Subs-Db-mysql.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 		
258 258
 		case 'datetime':
259 259
 			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)
260
-				return 'str_to_date('.
261
-					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]).
260
+				return 'str_to_date(' .
261
+					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]) .
262 262
 					',\'%Y-%m-%d %h:%i:%s\')';
263 263
 			else
264 264
 				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 		$connection
826 826
 	);
827 827
 	
828
-	if(!empty($keys) && (count($keys) > 0) && ($method === '' || $method === 'insert') && $returnmode > 0)
828
+	if (!empty($keys) && (count($keys) > 0) && ($method === '' || $method === 'insert') && $returnmode > 0)
829 829
 	{
830 830
 		if ($returnmode == 1)
831 831
 			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 			$return_var = array();
835 835
 			$count = count($insertRows);
836 836
 			$start = smf_db_insert_id($table, $keys[0]);
837
-			for ($i = 0; $i < $count; $i++ )
837
+			for ($i = 0; $i < $count; $i++)
838 838
 				$return_var[] = $start + $i;
839 839
 		}
840 840
 		return $return_var;
Please login to merge, or discard this patch.
Braces   +251 added lines, -185 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',
@@ -60,9 +61,11 @@  discard block
 block discarded – undo
60 61
 			'db_mb4'                    => false,
61 62
 			'db_ping'                   => 'mysqli_ping',
62 63
 		);
64
+	}
63 65
 
64
-	if (!empty($db_options['persist']))
65
-		$db_server = 'p:' . $db_server;
66
+	if (!empty($db_options['persist'])) {
67
+			$db_server = 'p:' . $db_server;
68
+	}
66 69
 
67 70
 	$connection = mysqli_init();
68 71
 
@@ -71,24 +74,27 @@  discard block
 block discarded – undo
71 74
 	$success = false;
72 75
 
73 76
 	if ($connection) {
74
-		if (!empty($db_options['port']))
75
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
76
-		else
77
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
77
+		if (!empty($db_options['port'])) {
78
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
79
+		} else {
80
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
81
+		}
78 82
 	}
79 83
 
80 84
 	// Something's wrong, show an error if its fatal (which we assume it is)
81 85
 	if ($success === false)
82 86
 	{
83
-		if (!empty($db_options['non_fatal']))
84
-			return null;
85
-		else
86
-			display_db_error();
87
+		if (!empty($db_options['non_fatal'])) {
88
+					return null;
89
+		} else {
90
+					display_db_error();
91
+		}
87 92
 	}
88 93
 
89 94
 	// Select the database, unless told not to
90
-	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal']))
91
-		display_db_error();
95
+	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) {
96
+			display_db_error();
97
+	}
92 98
 
93 99
 	$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\'',
94 100
 		array(),
@@ -164,38 +170,46 @@  discard block
 block discarded – undo
164 170
 	global $db_callback, $user_info, $db_prefix, $smcFunc;
165 171
 
166 172
 	list ($values, $connection) = $db_callback;
167
-	if (!is_object($connection))
168
-		display_db_error();
173
+	if (!is_object($connection)) {
174
+			display_db_error();
175
+	}
169 176
 
170
-	if ($matches[1] === 'db_prefix')
171
-		return $db_prefix;
177
+	if ($matches[1] === 'db_prefix') {
178
+			return $db_prefix;
179
+	}
172 180
 
173 181
 	if (!empty($user_info))
174 182
 	{
175
-		foreach (array_keys($user_info) as $key)
176
-			if (strpos($key, 'query_') !== false && $key === $matches[1])
183
+		foreach (array_keys($user_info) as $key) {
184
+					if (strpos($key, 'query_') !== false && $key === $matches[1])
177 185
 				return $user_info[$matches[1]];
186
+		}
178 187
 	}
179 188
 
180
-	if ($matches[1] === 'empty')
181
-		return '\'\'';
189
+	if ($matches[1] === 'empty') {
190
+			return '\'\'';
191
+	}
182 192
 
183
-	if (!isset($matches[2]))
184
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
193
+	if (!isset($matches[2])) {
194
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
195
+	}
185 196
 
186
-	if ($matches[1] === 'literal')
187
-		return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
197
+	if ($matches[1] === 'literal') {
198
+			return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
199
+	}
188 200
 
189
-	if (!isset($values[$matches[2]]))
190
-		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__);
201
+	if (!isset($values[$matches[2]])) {
202
+			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__);
203
+	}
191 204
 
192 205
 	$replacement = $values[$matches[2]];
193 206
 
194 207
 	switch ($matches[1])
195 208
 	{
196 209
 		case 'int':
197
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
198
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
210
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
211
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
212
+			}
199 213
 			return (string) (int) $replacement;
200 214
 		break;
201 215
 
@@ -207,65 +221,73 @@  discard block
 block discarded – undo
207 221
 		case 'array_int':
208 222
 			if (is_array($replacement))
209 223
 			{
210
-				if (empty($replacement))
211
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
224
+				if (empty($replacement)) {
225
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
226
+				}
212 227
 
213 228
 				foreach ($replacement as $key => $value)
214 229
 				{
215
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
216
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
230
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
231
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
232
+					}
217 233
 
218 234
 					$replacement[$key] = (string) (int) $value;
219 235
 				}
220 236
 
221 237
 				return implode(', ', $replacement);
238
+			} else {
239
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
222 240
 			}
223
-			else
224
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
225 241
 
226 242
 		break;
227 243
 
228 244
 		case 'array_string':
229 245
 			if (is_array($replacement))
230 246
 			{
231
-				if (empty($replacement))
232
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
247
+				if (empty($replacement)) {
248
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
249
+				}
233 250
 
234
-				foreach ($replacement as $key => $value)
235
-					$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
251
+				foreach ($replacement as $key => $value) {
252
+									$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
253
+				}
236 254
 
237 255
 				return implode(', ', $replacement);
256
+			} else {
257
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
238 258
 			}
239
-			else
240
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
241 259
 		break;
242 260
 
243 261
 		case 'date':
244
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
245
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
246
-			else
247
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
262
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
263
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
264
+			} else {
265
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
266
+			}
248 267
 		break;
249 268
 
250 269
 		case 'time':
251
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
252
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
253
-			else
254
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
270
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
271
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
272
+			} else {
273
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
274
+			}
255 275
 		break;
256 276
 
257 277
 		case 'datetime':
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('.
278
+			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) {
279
+							return 'str_to_date('.
260 280
 					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 281
 					',\'%Y-%m-%d %h:%i:%s\')';
262
-			else
263
-				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
282
+			} else {
283
+							smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
284
+			}
264 285
 		break;
265 286
 
266 287
 		case 'float':
267
-			if (!is_numeric($replacement))
268
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
288
+			if (!is_numeric($replacement)) {
289
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
290
+			}
269 291
 			return (string) (float) $replacement;
270 292
 		break;
271 293
 
@@ -279,32 +301,37 @@  discard block
 block discarded – undo
279 301
 		break;
280 302
 
281 303
 		case 'inet':
282
-			if ($replacement == 'null' || $replacement == '')
283
-				return 'null';
284
-			if (!isValidIP($replacement))
285
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
304
+			if ($replacement == 'null' || $replacement == '') {
305
+							return 'null';
306
+			}
307
+			if (!isValidIP($replacement)) {
308
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
309
+			}
286 310
 			//we don't use the native support of mysql > 5.6.2
287 311
 			return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement)));
288 312
 
289 313
 		case 'array_inet':
290 314
 			if (is_array($replacement))
291 315
 			{
292
-				if (empty($replacement))
293
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
316
+				if (empty($replacement)) {
317
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
318
+				}
294 319
 
295 320
 				foreach ($replacement as $key => $value)
296 321
 				{
297
-					if ($replacement == 'null' || $replacement == '')
298
-						$replacement[$key] = 'null';
299
-					if (!isValidIP($value))
300
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
322
+					if ($replacement == 'null' || $replacement == '') {
323
+											$replacement[$key] = 'null';
324
+					}
325
+					if (!isValidIP($value)) {
326
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
327
+					}
301 328
 					$replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value)));
302 329
 				}
303 330
 
304 331
 				return implode(', ', $replacement);
332
+			} else {
333
+							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 334
 			}
306
-			else
307
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
308 335
 		break;
309 336
 
310 337
 		default:
@@ -380,22 +407,25 @@  discard block
 block discarded – undo
380 407
 		// Are we in SSI mode?  If so try that username and password first
381 408
 		if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
382 409
 		{
383
-			if (empty($db_persist))
384
-				$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
385
-			else
386
-				$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
410
+			if (empty($db_persist)) {
411
+							$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
412
+			} else {
413
+							$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
414
+			}
387 415
 		}
388 416
 		// Fall back to the regular username and password if need be
389 417
 		if (!$db_connection)
390 418
 		{
391
-			if (empty($db_persist))
392
-				$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
393
-			else
394
-				$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
419
+			if (empty($db_persist)) {
420
+							$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
421
+			} else {
422
+							$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
423
+			}
395 424
 		}
396 425
 
397
-		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
398
-			$db_connection = false;
426
+		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
427
+					$db_connection = false;
428
+		}
399 429
 
400 430
 		$connection = $db_connection;
401 431
 	}
@@ -403,18 +433,20 @@  discard block
 block discarded – undo
403 433
 	// One more query....
404 434
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
405 435
 
406
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
407
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
436
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
437
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
438
+	}
408 439
 
409 440
 	// Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By
410 441
 	if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
411 442
 	{
412 443
 		// Add before LIMIT
413
-		if ($pos = strpos($db_string, 'LIMIT '))
414
-			$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
415
-		else
416
-			// Append it.
444
+		if ($pos = strpos($db_string, 'LIMIT ')) {
445
+					$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
446
+		} else {
447
+					// Append it.
417 448
 			$db_string .= "\n\t\t\tORDER BY null";
449
+		}
418 450
 	}
419 451
 
420 452
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
@@ -436,8 +468,9 @@  discard block
 block discarded – undo
436 468
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
437 469
 
438 470
 		// Initialize $db_cache if not already initialized.
439
-		if (!isset($db_cache))
440
-			$db_cache = array();
471
+		if (!isset($db_cache)) {
472
+					$db_cache = array();
473
+		}
441 474
 
442 475
 		if (!empty($_SESSION['debug_redirect']))
443 476
 		{
@@ -463,17 +496,18 @@  discard block
 block discarded – undo
463 496
 		while (true)
464 497
 		{
465 498
 			$pos = strpos($db_string, '\'', $pos + 1);
466
-			if ($pos === false)
467
-				break;
499
+			if ($pos === false) {
500
+							break;
501
+			}
468 502
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
469 503
 
470 504
 			while (true)
471 505
 			{
472 506
 				$pos1 = strpos($db_string, '\'', $pos + 1);
473 507
 				$pos2 = strpos($db_string, '\\', $pos + 1);
474
-				if ($pos1 === false)
475
-					break;
476
-				elseif ($pos2 === false || $pos2 > $pos1)
508
+				if ($pos1 === false) {
509
+									break;
510
+				} elseif ($pos2 === false || $pos2 > $pos1)
477 511
 				{
478 512
 					$pos = $pos1;
479 513
 					break;
@@ -489,29 +523,35 @@  discard block
 block discarded – undo
489 523
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
490 524
 
491 525
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
492
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
493
-			$fail = true;
526
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
527
+					$fail = true;
528
+		}
494 529
 		// Trying to change passwords, slow us down, or something?
495
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
496
-			$fail = true;
497
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
498
-			$fail = true;
530
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
531
+					$fail = true;
532
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
533
+					$fail = true;
534
+		}
499 535
 
500
-		if (!empty($fail) && function_exists('log_error'))
501
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
536
+		if (!empty($fail) && function_exists('log_error')) {
537
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
538
+		}
502 539
 	}
503 540
 
504
-	if (empty($db_unbuffered))
505
-		$ret = @mysqli_query($connection, $db_string);
506
-	else
507
-		$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
541
+	if (empty($db_unbuffered)) {
542
+			$ret = @mysqli_query($connection, $db_string);
543
+	} else {
544
+			$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
545
+	}
508 546
 
509
-	if ($ret === false && empty($db_values['db_error_skip']))
510
-		$ret = smf_db_error($db_string, $connection);
547
+	if ($ret === false && empty($db_values['db_error_skip'])) {
548
+			$ret = smf_db_error($db_string, $connection);
549
+	}
511 550
 
512 551
 	// Debugging.
513
-	if (isset($db_show_debug) && $db_show_debug === true)
514
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
552
+	if (isset($db_show_debug) && $db_show_debug === true) {
553
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
554
+	}
515 555
 
516 556
 	return $ret;
517 557
 }
@@ -558,12 +598,13 @@  discard block
 block discarded – undo
558 598
 	// Decide which connection to use
559 599
 	$connection = $connection === null ? $db_connection : $connection;
560 600
 
561
-	if ($type == 'begin')
562
-		return @mysqli_query($connection, 'BEGIN');
563
-	elseif ($type == 'rollback')
564
-		return @mysqli_query($connection, 'ROLLBACK');
565
-	elseif ($type == 'commit')
566
-		return @mysqli_query($connection, 'COMMIT');
601
+	if ($type == 'begin') {
602
+			return @mysqli_query($connection, 'BEGIN');
603
+	} elseif ($type == 'rollback') {
604
+			return @mysqli_query($connection, 'ROLLBACK');
605
+	} elseif ($type == 'commit') {
606
+			return @mysqli_query($connection, 'COMMIT');
607
+	}
567 608
 
568 609
 	return false;
569 610
 }
@@ -603,8 +644,9 @@  discard block
 block discarded – undo
603 644
 	//    2013: Lost connection to server during query.
604 645
 
605 646
 	// Log the error.
606
-	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error'))
607
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
647
+	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
648
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
649
+	}
608 650
 
609 651
 	// Database error auto fixing ;).
610 652
 	if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1'))
@@ -613,8 +655,9 @@  discard block
 block discarded – undo
613 655
 		$old_cache = @$modSettings['cache_enable'];
614 656
 		$modSettings['cache_enable'] = '1';
615 657
 
616
-		if (($temp = cache_get_data('db_last_error', 600)) !== null)
617
-			$db_last_error = max(@$db_last_error, $temp);
658
+		if (($temp = cache_get_data('db_last_error', 600)) !== null) {
659
+					$db_last_error = max(@$db_last_error, $temp);
660
+		}
618 661
 
619 662
 		if (@$db_last_error < time() - 3600 * 24 * 3)
620 663
 		{
@@ -630,8 +673,9 @@  discard block
 block discarded – undo
630 673
 					foreach ($tables as $table)
631 674
 					{
632 675
 						// Now, it's still theoretically possible this could be an injection.  So backtick it!
633
-						if (trim($table) != '')
634
-							$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
676
+						if (trim($table) != '') {
677
+													$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
678
+						}
635 679
 					}
636 680
 				}
637 681
 
@@ -640,8 +684,9 @@  discard block
 block discarded – undo
640 684
 			// Table crashed.  Let's try to fix it.
641 685
 			elseif ($query_errno == 1016)
642 686
 			{
643
-				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0)
644
-					$fix_tables = array('`' . $match[1] . '`');
687
+				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) {
688
+									$fix_tables = array('`' . $match[1] . '`');
689
+				}
645 690
 			}
646 691
 			// Indexes crashed.  Should be easy to fix!
647 692
 			elseif ($query_errno == 1034 || $query_errno == 1035)
@@ -660,13 +705,15 @@  discard block
 block discarded – undo
660 705
 
661 706
 			// Make a note of the REPAIR...
662 707
 			cache_put_data('db_last_error', time(), 600);
663
-			if (($temp = cache_get_data('db_last_error', 600)) === null)
664
-				updateSettingsFile(array('db_last_error' => time()));
708
+			if (($temp = cache_get_data('db_last_error', 600)) === null) {
709
+							updateSettingsFile(array('db_last_error' => time()));
710
+			}
665 711
 
666 712
 			// Attempt to find and repair the broken table.
667
-			foreach ($fix_tables as $table)
668
-				$smcFunc['db_query']('', "
713
+			foreach ($fix_tables as $table) {
714
+							$smcFunc['db_query']('', "
669 715
 					REPAIR TABLE $table", false, false);
716
+			}
670 717
 
671 718
 			// And send off an email!
672 719
 			sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror');
@@ -675,11 +722,12 @@  discard block
 block discarded – undo
675 722
 
676 723
 			// Try the query again...?
677 724
 			$ret = $smcFunc['db_query']('', $db_string, false, false);
678
-			if ($ret !== false)
679
-				return $ret;
725
+			if ($ret !== false) {
726
+							return $ret;
727
+			}
728
+		} else {
729
+					$modSettings['cache_enable'] = $old_cache;
680 730
 		}
681
-		else
682
-			$modSettings['cache_enable'] = $old_cache;
683 731
 
684 732
 		// Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
685 733
 		if (in_array($query_errno, array(1205, 1213, 2006, 2013)))
@@ -689,22 +737,25 @@  discard block
 block discarded – undo
689 737
 				// Are we in SSI mode?  If so try that username and password first
690 738
 				if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
691 739
 				{
692
-					if (empty($db_persist))
693
-						$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
694
-					else
695
-						$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
740
+					if (empty($db_persist)) {
741
+											$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
742
+					} else {
743
+											$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
744
+					}
696 745
 				}
697 746
 				// Fall back to the regular username and password if need be
698 747
 				if (!$db_connection)
699 748
 				{
700
-					if (empty($db_persist))
701
-						$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
702
-					else
703
-						$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
749
+					if (empty($db_persist)) {
750
+											$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
751
+					} else {
752
+											$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
753
+					}
704 754
 				}
705 755
 
706
-				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
707
-					$db_connection = false;
756
+				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
757
+									$db_connection = false;
758
+				}
708 759
 			}
709 760
 
710 761
 			if ($db_connection)
@@ -715,24 +766,27 @@  discard block
 block discarded – undo
715 766
 					$ret = $smcFunc['db_query']('', $db_string, false, false);
716 767
 
717 768
 					$new_errno = mysqli_errno($db_connection);
718
-					if ($ret !== false || in_array($new_errno, array(1205, 1213)))
719
-						break;
769
+					if ($ret !== false || in_array($new_errno, array(1205, 1213))) {
770
+											break;
771
+					}
720 772
 				}
721 773
 
722 774
 				// If it failed again, shucks to be you... we're not trying it over and over.
723
-				if ($ret !== false)
724
-					return $ret;
775
+				if ($ret !== false) {
776
+									return $ret;
777
+				}
725 778
 			}
726 779
 		}
727 780
 		// Are they out of space, perhaps?
728 781
 		elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false))
729 782
 		{
730
-			if (!isset($txt))
731
-				$query_error .= ' - check database storage space.';
732
-			else
783
+			if (!isset($txt)) {
784
+							$query_error .= ' - check database storage space.';
785
+			} else
733 786
 			{
734
-				if (!isset($txt['mysql_error_space']))
735
-					loadLanguage('Errors');
787
+				if (!isset($txt['mysql_error_space'])) {
788
+									loadLanguage('Errors');
789
+				}
736 790
 
737 791
 				$query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space'];
738 792
 			}
@@ -740,15 +794,17 @@  discard block
 block discarded – undo
740 794
 	}
741 795
 
742 796
 	// Nothing's defined yet... just die with it.
743
-	if (empty($context) || empty($txt))
744
-		die($query_error);
797
+	if (empty($context) || empty($txt)) {
798
+			die($query_error);
799
+	}
745 800
 
746 801
 	// Show an error message, if possible.
747 802
 	$context['error_title'] = $txt['database_error'];
748
-	if (allowedTo('admin_forum'))
749
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
750
-	else
751
-		$context['error_message'] = $txt['try_again'];
803
+	if (allowedTo('admin_forum')) {
804
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
805
+	} else {
806
+			$context['error_message'] = $txt['try_again'];
807
+	}
752 808
 
753 809
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
754 810
 	{
@@ -778,25 +834,28 @@  discard block
 block discarded – undo
778 834
 	$connection = $connection === null ? $db_connection : $connection;
779 835
 
780 836
 	// With nothing to insert, simply return.
781
-	if (empty($data))
782
-		return;
837
+	if (empty($data)) {
838
+			return;
839
+	}
783 840
 
784 841
 	// Replace the prefix holder with the actual prefix.
785 842
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
786 843
 
787 844
 	// Inserting data as a single row can be done as a single array.
788
-	if (!is_array($data[array_rand($data)]))
789
-		$data = array($data);
845
+	if (!is_array($data[array_rand($data)])) {
846
+			$data = array($data);
847
+	}
790 848
 
791 849
 	// Create the mold for a single row insert.
792 850
 	$insertData = '(';
793 851
 	foreach ($columns as $columnName => $type)
794 852
 	{
795 853
 		// Are we restricting the length?
796
-		if (strpos($type, 'string-') !== false)
797
-			$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
798
-		else
799
-			$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
854
+		if (strpos($type, 'string-') !== false) {
855
+					$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
856
+		} else {
857
+					$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
858
+		}
800 859
 	}
801 860
 	$insertData = substr($insertData, 0, -2) . ')';
802 861
 
@@ -805,8 +864,9 @@  discard block
 block discarded – undo
805 864
 
806 865
 	// Here's where the variables are injected to the query.
807 866
 	$insertRows = array();
808
-	foreach ($data as $dataRow)
809
-		$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
867
+	foreach ($data as $dataRow) {
868
+			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
869
+	}
810 870
 
811 871
 	// Determine the method of insertion.
812 872
 	$queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT');
@@ -826,15 +886,16 @@  discard block
 block discarded – undo
826 886
 
827 887
 	if(!empty($keys) && (count($keys) > 0) && ($method === '' || $method === 'insert') && $returnmode > 0)
828 888
 	{
829
-		if ($returnmode == 1)
830
-			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
831
-		else if ($returnmode == 2)
889
+		if ($returnmode == 1) {
890
+					$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
891
+		} else if ($returnmode == 2)
832 892
 		{
833 893
 			$return_var = array();
834 894
 			$count = count($insertRows);
835 895
 			$start = smf_db_insert_id($table, $keys[0]);
836
-			for ($i = 0; $i < $count; $i++ )
837
-				$return_var[] = $start + $i;
896
+			for ($i = 0; $i < $count; $i++ ) {
897
+							$return_var[] = $start + $i;
898
+			}
838 899
 		}
839 900
 		return $return_var;
840 901
 	}
@@ -852,8 +913,9 @@  discard block
 block discarded – undo
852 913
  */
853 914
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
854 915
 {
855
-	if (empty($log_message))
856
-		$log_message = $error_message;
916
+	if (empty($log_message)) {
917
+			$log_message = $error_message;
918
+	}
857 919
 
858 920
 	foreach (debug_backtrace() as $step)
859 921
 	{
@@ -872,12 +934,14 @@  discard block
 block discarded – undo
872 934
 	}
873 935
 
874 936
 	// A special case - we want the file and line numbers for debugging.
875
-	if ($error_type == 'return')
876
-		return array($file, $line);
937
+	if ($error_type == 'return') {
938
+			return array($file, $line);
939
+	}
877 940
 
878 941
 	// Is always a critical error.
879
-	if (function_exists('log_error'))
880
-		log_error($log_message, 'critical', $file, $line);
942
+	if (function_exists('log_error')) {
943
+			log_error($log_message, 'critical', $file, $line);
944
+	}
881 945
 
882 946
 	if (function_exists('fatal_error'))
883 947
 	{
@@ -885,12 +949,12 @@  discard block
 block discarded – undo
885 949
 
886 950
 		// Cannot continue...
887 951
 		exit;
952
+	} elseif ($error_type) {
953
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
954
+	} else {
955
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
956
+	}
888 957
 	}
889
-	elseif ($error_type)
890
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
891
-	else
892
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
893
-}
894 958
 
895 959
 /**
896 960
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -907,10 +971,11 @@  discard block
 block discarded – undo
907 971
 		'\\' => '\\\\',
908 972
 	);
909 973
 
910
-	if ($translate_human_wildcards)
911
-		$replacements += array(
974
+	if ($translate_human_wildcards) {
975
+			$replacements += array(
912 976
 			'*' => '%',
913 977
 		);
978
+	}
914 979
 
915 980
 	return strtr($string, $replacements);
916 981
 }
@@ -924,8 +989,9 @@  discard block
 block discarded – undo
924 989
  */
925 990
 function smf_is_resource($result)
926 991
 {
927
-	if ($result instanceof mysqli_result)
928
-		return true;
992
+	if ($result instanceof mysqli_result) {
993
+			return true;
994
+	}
929 995
 
930 996
 	return false;
931 997
 }
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 = smf_json_decode($draft_info['to_list'], true);
207 216
 	}
208
-	elseif (!empty($draft_info['to_list']) && empty($recipientList))
209
-		$recipientList = smf_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/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.
Sources/PostModeration.php 1 patch
Braces   +100 added lines, -79 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
  * This is a handling function for all things post moderation.
@@ -39,8 +40,9 @@  discard block
 block discarded – undo
39 40
 	);
40 41
 
41 42
 	// Pick something valid...
42
-	if (!isset($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']]))
43
-		$_REQUEST['sa'] = 'replies';
43
+	if (!isset($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) {
44
+			$_REQUEST['sa'] = 'replies';
45
+	}
44 46
 
45 47
 	call_integration_hook('integrate_post_moderation', array(&$subActions));
46 48
 
@@ -68,13 +70,15 @@  discard block
 block discarded – undo
68 70
 		$approve_boards = $approve_boards == array(0) ? $filter_board : array_intersect($approve_boards, $filter_board);
69 71
 	}
70 72
 
71
-	if ($approve_boards == array(0))
72
-		$approve_query = '';
73
-	elseif (!empty($approve_boards))
74
-		$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
73
+	if ($approve_boards == array(0)) {
74
+			$approve_query = '';
75
+	} elseif (!empty($approve_boards)) {
76
+			$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
77
+	}
75 78
 	// Nada, zip, etc...
76
-	else
77
-		$approve_query = ' AND 1=0';
79
+	else {
80
+			$approve_query = ' AND 1=0';
81
+	}
78 82
 
79 83
 	// We also need to know where we can delete topics and/or replies to.
80 84
 	if ($context['current_view'] == 'topics')
@@ -82,8 +86,7 @@  discard block
 block discarded – undo
82 86
 		$delete_own_boards = boardsAllowedTo('remove_own');
83 87
 		$delete_any_boards = boardsAllowedTo('remove_any');
84 88
 		$delete_own_replies = array();
85
-	}
86
-	else
89
+	} else
87 90
 	{
88 91
 		$delete_own_boards = boardsAllowedTo('delete_own');
89 92
 		$delete_any_boards = boardsAllowedTo('delete_any');
@@ -92,21 +95,25 @@  discard block
 block discarded – undo
92 95
 
93 96
 	$toAction = array();
94 97
 	// Check if we have something to do?
95
-	if (isset($_GET['approve']))
96
-		$toAction[] = (int) $_GET['approve'];
98
+	if (isset($_GET['approve'])) {
99
+			$toAction[] = (int) $_GET['approve'];
100
+	}
97 101
 	// Just a deletion?
98
-	elseif (isset($_GET['delete']))
99
-		$toAction[] = (int) $_GET['delete'];
102
+	elseif (isset($_GET['delete'])) {
103
+			$toAction[] = (int) $_GET['delete'];
104
+	}
100 105
 	// Lots of approvals?
101
-	elseif (isset($_POST['item']))
102
-		foreach ($_POST['item'] as $item)
106
+	elseif (isset($_POST['item'])) {
107
+			foreach ($_POST['item'] as $item)
103 108
 			$toAction[] = (int) $item;
109
+	}
104 110
 
105 111
 	// What are we actually doing.
106
-	if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve'))
107
-		$curAction = 'approve';
108
-	elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete'))
109
-		$curAction = 'delete';
112
+	if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve')) {
113
+			$curAction = 'approve';
114
+	} elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete')) {
115
+			$curAction = 'delete';
116
+	}
110 117
 
111 118
 	// Right, so we have something to do?
112 119
 	if (!empty($toAction) && isset($curAction))
@@ -135,8 +142,9 @@  discard block
 block discarded – undo
135 142
 		while ($row = $smcFunc['db_fetch_assoc']($request))
136 143
 		{
137 144
 			// If it's not within what our view is ignore it...
138
-			if (($row['id_msg'] == $row['id_first_msg'] && $context['current_view'] != 'topics') || ($row['id_msg'] != $row['id_first_msg'] && $context['current_view'] != 'replies'))
139
-				continue;
145
+			if (($row['id_msg'] == $row['id_first_msg'] && $context['current_view'] != 'topics') || ($row['id_msg'] != $row['id_first_msg'] && $context['current_view'] != 'replies')) {
146
+							continue;
147
+			}
140 148
 
141 149
 			$can_add = false;
142 150
 			// If we're approving this is simple.
@@ -148,18 +156,22 @@  discard block
 block discarded – undo
148 156
 			elseif ($curAction == 'delete')
149 157
 			{
150 158
 				// Own post is easy!
151
-				if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards)))
152
-					$can_add = true;
159
+				if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) {
160
+									$can_add = true;
161
+				}
153 162
 				// Is it a reply to their own topic?
154
-				elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies)))
155
-					$can_add = true;
163
+				elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) {
164
+									$can_add = true;
165
+				}
156 166
 				// Someone elses?
157
-				elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards)))
158
-					$can_add = true;
167
+				elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) {
168
+									$can_add = true;
169
+				}
159 170
 			}
160 171
 
161
-			if ($can_add)
162
-				$anItem = $context['current_view'] == 'topics' ? $row['id_topic'] : $row['id_msg'];
172
+			if ($can_add) {
173
+							$anItem = $context['current_view'] == 'topics' ? $row['id_topic'] : $row['id_msg'];
174
+			}
163 175
 			$toAction[] = $anItem;
164 176
 
165 177
 			// All clear. What have we got now, what, what?
@@ -177,8 +189,7 @@  discard block
 block discarded – undo
177 189
 			if ($curAction == 'approve')
178 190
 			{
179 191
 				approveMessages($toAction, $details, $context['current_view']);
180
-			}
181
-			else
192
+			} else
182 193
 			{
183 194
 				removeMessages($toAction, $details, $context['current_view']);
184 195
 			}
@@ -265,16 +276,19 @@  discard block
 block discarded – undo
265 276
 	for ($i = 1; $row = $smcFunc['db_fetch_assoc']($request); $i++)
266 277
 	{
267 278
 		// Can delete is complicated, let's solve it first... is it their own post?
268
-		if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards)))
269
-			$can_delete = true;
279
+		if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) {
280
+					$can_delete = true;
281
+		}
270 282
 		// Is it a reply to their own topic?
271
-		elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies)))
272
-			$can_delete = true;
283
+		elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) {
284
+					$can_delete = true;
285
+		}
273 286
 		// Someone elses?
274
-		elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards)))
275
-			$can_delete = true;
276
-		else
277
-			$can_delete = false;
287
+		elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) {
288
+					$can_delete = true;
289
+		} else {
290
+					$can_delete = false;
291
+		}
278 292
 
279 293
 		$context['unapproved_items'][] = array(
280 294
 			'id' => $row['id_msg'],
@@ -323,28 +337,31 @@  discard block
 block discarded – undo
323 337
 	// Once again, permissions are king!
324 338
 	$approve_boards = boardsAllowedTo('approve_posts');
325 339
 
326
-	if ($approve_boards == array(0))
327
-		$approve_query = '';
328
-	elseif (!empty($approve_boards))
329
-		$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
330
-	else
331
-		$approve_query = ' AND 1=0';
340
+	if ($approve_boards == array(0)) {
341
+			$approve_query = '';
342
+	} elseif (!empty($approve_boards)) {
343
+			$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
344
+	} else {
345
+			$approve_query = ' AND 1=0';
346
+	}
332 347
 
333 348
 	// Get together the array of things to act on, if any.
334 349
 	$attachments = array();
335
-	if (isset($_GET['approve']))
336
-		$attachments[] = (int) $_GET['approve'];
337
-	elseif (isset($_GET['delete']))
338
-		$attachments[] = (int) $_GET['delete'];
339
-	elseif (isset($_POST['item']))
340
-		foreach ($_POST['item'] as $item)
350
+	if (isset($_GET['approve'])) {
351
+			$attachments[] = (int) $_GET['approve'];
352
+	} elseif (isset($_GET['delete'])) {
353
+			$attachments[] = (int) $_GET['delete'];
354
+	} elseif (isset($_POST['item'])) {
355
+			foreach ($_POST['item'] as $item)
341 356
 			$attachments[] = (int) $item;
357
+	}
342 358
 
343 359
 	// Are we approving or deleting?
344
-	if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve'))
345
-		$curAction = 'approve';
346
-	elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete'))
347
-		$curAction = 'delete';
360
+	if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve')) {
361
+			$curAction = 'approve';
362
+	} elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete')) {
363
+			$curAction = 'delete';
364
+	}
348 365
 
349 366
 	// Something to do, let's do it!
350 367
 	if (!empty($attachments) && isset($curAction))
@@ -372,17 +389,19 @@  discard block
 block discarded – undo
372 389
 			)
373 390
 		);
374 391
 		$attachments = array();
375
-		while ($row = $smcFunc['db_fetch_assoc']($request))
376
-			$attachments[] = $row['id_attach'];
392
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
393
+					$attachments[] = $row['id_attach'];
394
+		}
377 395
 		$smcFunc['db_free_result']($request);
378 396
 
379 397
 		// Assuming it wasn't all like, proper illegal, we can do the approving.
380 398
 		if (!empty($attachments))
381 399
 		{
382
-			if ($curAction == 'approve')
383
-				ApproveAttachments($attachments);
384
-			else
385
-				removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
400
+			if ($curAction == 'approve') {
401
+							ApproveAttachments($attachments);
402
+			} else {
403
+							removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
404
+			}
386 405
 		}
387 406
 	}
388 407
 
@@ -682,15 +701,16 @@  discard block
 block discarded – undo
682 701
 	{
683 702
 		approveTopics($topic, !$approved);
684 703
 
685
-		if ($starter != $user_info['id'])
686
-			logAction(($approved ? 'un' : '') . 'approve_topic', array('topic' => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board));
687
-	}
688
-	else
704
+		if ($starter != $user_info['id']) {
705
+					logAction(($approved ? 'un' : '') . 'approve_topic', array('topic' => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board));
706
+		}
707
+	} else
689 708
 	{
690 709
 		approvePosts($_REQUEST['msg'], !$approved);
691 710
 
692
-		if ($poster != $user_info['id'])
693
-			logAction(($approved ? 'un' : '') . 'approve', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board));
711
+		if ($poster != $user_info['id']) {
712
+					logAction(($approved ? 'un' : '') . 'approve', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board));
713
+		}
694 714
 	}
695 715
 
696 716
 	redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
@@ -716,8 +736,7 @@  discard block
 block discarded – undo
716 736
 		{
717 737
 			logAction('approve_topic', array('topic' => $topic, 'subject' => $messageDetails[$topic]['subject'], 'member' => $messageDetails[$topic]['member'], 'board' => $messageDetails[$topic]['board']));
718 738
 		}
719
-	}
720
-	else
739
+	} else
721 740
 	{
722 741
 		approvePosts($messages);
723 742
 		// and tell the world about it again
@@ -745,8 +764,9 @@  discard block
 block discarded – undo
745 764
 		)
746 765
 	);
747 766
 	$msgs = array();
748
-	while ($row = $smcFunc['db_fetch_row']($request))
749
-		$msgs[] = $row[0];
767
+	while ($row = $smcFunc['db_fetch_row']($request)) {
768
+			$msgs[] = $row[0];
769
+	}
750 770
 	$smcFunc['db_free_result']($request);
751 771
 
752 772
 	if (!empty($msgs))
@@ -765,8 +785,9 @@  discard block
 block discarded – undo
765 785
 		)
766 786
 	);
767 787
 	$attaches = array();
768
-	while ($row = $smcFunc['db_fetch_row']($request))
769
-		$attaches[] = $row[0];
788
+	while ($row = $smcFunc['db_fetch_row']($request)) {
789
+			$attaches[] = $row[0];
790
+	}
770 791
 	$smcFunc['db_free_result']($request);
771 792
 
772 793
 	if (!empty($attaches))
@@ -794,12 +815,12 @@  discard block
 block discarded – undo
794 815
 	{
795 816
 		removeTopics($messages);
796 817
 		// and tell the world about it
797
-		foreach ($messages as $topic)
798
-			// Note, only log topic ID in native form if it's not gone forever.
818
+		foreach ($messages as $topic) {
819
+					// Note, only log topic ID in native form if it's not gone forever.
799 820
 			logAction('remove', array(
800 821
 				(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $messageDetails[$topic]['board'] ? 'topic' : 'old_topic_id') => $topic, 'subject' => $messageDetails[$topic]['subject'], 'member' => $messageDetails[$topic]['member'], 'board' => $messageDetails[$topic]['board']));
801
-	}
802
-	else
822
+		}
823
+	} else
803 824
 	{
804 825
 		foreach ($messages as $post)
805 826
 		{
Please login to merge, or discard this patch.
Sources/BoardIndex.php 1 patch
Braces   +20 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * This function shows the board index.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	$context['canonical_url'] = $scripturl;
35 36
 
36 37
 	// Do not let search engines index anything if there is a random thing in $_GET.
37
-	if (!empty($_GET))
38
-		$context['robot_no_index'] = true;
38
+	if (!empty($_GET)) {
39
+			$context['robot_no_index'] = true;
40
+	}
39 41
 
40 42
 	// Retrieve the categories and boards.
41 43
 	require_once($sourcedir . '/Subs-BoardIndex.php');
@@ -62,11 +64,12 @@  discard block
 block discarded – undo
62 64
 			$context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions));
63 65
 		}
64 66
 
65
-		if (!empty($context['latest_posts']) || !empty($context['latest_post']))
66
-			$context['info_center'][] = array(
67
+		if (!empty($context['latest_posts']) || !empty($context['latest_post'])) {
68
+					$context['info_center'][] = array(
67 69
 				'tpl' => 'recent',
68 70
 				'txt' => 'recent_posts',
69 71
 			);
72
+		}
70 73
 	}
71 74
 
72 75
 	// Load the calendar?
@@ -87,20 +90,22 @@  discard block
 block discarded – undo
87 90
 		// This is used to show the "how-do-I-edit" help.
88 91
 		$context['calendar_can_edit'] = allowedTo('calendar_edit_any');
89 92
 
90
-		if ($context['show_calendar'])
91
-			$context['info_center'][] = array(
93
+		if ($context['show_calendar']) {
94
+					$context['info_center'][] = array(
92 95
 				'tpl' => 'calendar',
93 96
 				'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming',
94 97
 			);
98
+		}
95 99
 	}
96 100
 
97 101
 	// And stats.
98 102
 	$context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']);
99
-	if ($settings['show_stats_index'])
100
-		$context['info_center'][] = array(
103
+	if ($settings['show_stats_index']) {
104
+			$context['info_center'][] = array(
101 105
 				'tpl' => 'stats',
102 106
 				'txt' => 'forum_stats',
103 107
 			);
108
+	}
104 109
 
105 110
 	// Now the online stuff
106 111
 	require_once($sourcedir . '/Subs-MembersOnline.php');
@@ -118,12 +123,14 @@  discard block
 block discarded – undo
118 123
 			);
119 124
 
120 125
 	// Track most online statistics? (Subs-MembersOnline.php)
121
-	if (!empty($modSettings['trackStats']))
122
-		trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
126
+	if (!empty($modSettings['trackStats'])) {
127
+			trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
128
+	}
123 129
 
124 130
 	// Are we showing all membergroups on the board index?
125
-	if (!empty($settings['show_group_key']))
126
-		$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
131
+	if (!empty($settings['show_group_key'])) {
132
+			$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
133
+	}
127 134
 
128 135
 	// And back to normality.
129 136
 	$context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']);
Please login to merge, or discard this patch.