@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | |
255 | 255 | case 'datetime': |
256 | 256 | 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) |
257 | - return 'str_to_date('. |
|
258 | - 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]). |
|
257 | + return 'str_to_date(' . |
|
258 | + sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
259 | 259 | ',\'%Y-%m-%d %h:%i:%s\')'; |
260 | 260 | else |
261 | 261 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | { |
840 | 840 | $count = count($insertRows); |
841 | 841 | $ai = 0; |
842 | - for($i = 0; $i < $count; $i++) |
|
842 | + for ($i = 0; $i < $count; $i++) |
|
843 | 843 | { |
844 | 844 | $old_id = $smcFunc['db_insert_id'](); |
845 | 845 | |
@@ -865,13 +865,13 @@ discard block |
||
865 | 865 | $count2 = count($indexed_columns); |
866 | 866 | for ($x = 0; $x < $count2; $x++) |
867 | 867 | { |
868 | - $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
|
868 | + $where_string += key($indexed_columns[$x]) . ' = ' . $insertRows[$i][$x]; |
|
869 | 869 | if (($x + 1) < $count2) |
870 | 870 | $where_string += ' AND '; |
871 | 871 | } |
872 | 872 | |
873 | - $request = $smcFunc['db_query']('',' |
|
874 | - SELECT `'. $keys[0] . '` FROM ' . $table .' |
|
873 | + $request = $smcFunc['db_query']('', ' |
|
874 | + SELECT `'. $keys[0] . '` FROM ' . $table . ' |
|
875 | 875 | WHERE ' . $where_string . ' LIMIT 1', |
876 | 876 | array() |
877 | 877 | ); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | $return_var = array(); |
901 | 901 | $count = count($insertRows); |
902 | 902 | $start = smf_db_insert_id($table, $keys[0]); |
903 | - for ($i = 0; $i < $count; $i++ ) |
|
903 | + for ($i = 0; $i < $count; $i++) |
|
904 | 904 | $return_var[] = $start + $i; |
905 | 905 | } |
906 | 906 | return $return_var; |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', |
1031 | 1031 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
1032 | 1032 | $error_array[7], $error_array[8]); |
1033 | - mysqli_stmt_execute ($mysql_error_data_prep); |
|
1033 | + mysqli_stmt_execute($mysql_error_data_prep); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | ?> |
1037 | 1037 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
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 |
||
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', |
@@ -62,9 +63,11 @@ discard block |
||
62 | 63 | 'db_fetch_all' => 'smf_db_fetch_all', |
63 | 64 | 'db_error_insert' => 'smf_db_error_insert', |
64 | 65 | ); |
66 | + } |
|
65 | 67 | |
66 | - if (!empty($db_options['persist'])) |
|
67 | - $db_server = 'p:' . $db_server; |
|
68 | + if (!empty($db_options['persist'])) { |
|
69 | + $db_server = 'p:' . $db_server; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | $connection = mysqli_init(); |
70 | 73 | |
@@ -73,24 +76,27 @@ discard block |
||
73 | 76 | $success = false; |
74 | 77 | |
75 | 78 | if ($connection) { |
76 | - if (!empty($db_options['port'])) |
|
77 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
78 | - else |
|
79 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
79 | + if (!empty($db_options['port'])) { |
|
80 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
81 | + } else { |
|
82 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
83 | + } |
|
80 | 84 | } |
81 | 85 | |
82 | 86 | // Something's wrong, show an error if its fatal (which we assume it is) |
83 | 87 | if ($success === false) |
84 | 88 | { |
85 | - if (!empty($db_options['non_fatal'])) |
|
86 | - return null; |
|
87 | - else |
|
88 | - display_db_error(); |
|
89 | + if (!empty($db_options['non_fatal'])) { |
|
90 | + return null; |
|
91 | + } else { |
|
92 | + display_db_error(); |
|
93 | + } |
|
89 | 94 | } |
90 | 95 | |
91 | 96 | // Select the database, unless told not to |
92 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
93 | - display_db_error(); |
|
97 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
98 | + display_db_error(); |
|
99 | + } |
|
94 | 100 | |
95 | 101 | $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\'', |
96 | 102 | array(), |
@@ -166,34 +172,42 @@ discard block |
||
166 | 172 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
167 | 173 | |
168 | 174 | list ($values, $connection) = $db_callback; |
169 | - if (!is_object($connection)) |
|
170 | - display_db_error(); |
|
175 | + if (!is_object($connection)) { |
|
176 | + display_db_error(); |
|
177 | + } |
|
171 | 178 | |
172 | - if ($matches[1] === 'db_prefix') |
|
173 | - return $db_prefix; |
|
179 | + if ($matches[1] === 'db_prefix') { |
|
180 | + return $db_prefix; |
|
181 | + } |
|
174 | 182 | |
175 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
176 | - return $user_info[$matches[1]]; |
|
183 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
184 | + return $user_info[$matches[1]]; |
|
185 | + } |
|
177 | 186 | |
178 | - if ($matches[1] === 'empty') |
|
179 | - return '\'\''; |
|
187 | + if ($matches[1] === 'empty') { |
|
188 | + return '\'\''; |
|
189 | + } |
|
180 | 190 | |
181 | - if (!isset($matches[2])) |
|
182 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
191 | + if (!isset($matches[2])) { |
|
192 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
193 | + } |
|
183 | 194 | |
184 | - if ($matches[1] === 'literal') |
|
185 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
195 | + if ($matches[1] === 'literal') { |
|
196 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
197 | + } |
|
186 | 198 | |
187 | - if (!isset($values[$matches[2]])) |
|
188 | - 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__); |
|
199 | + if (!isset($values[$matches[2]])) { |
|
200 | + 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 | + } |
|
189 | 202 | |
190 | 203 | $replacement = $values[$matches[2]]; |
191 | 204 | |
192 | 205 | switch ($matches[1]) |
193 | 206 | { |
194 | 207 | case 'int': |
195 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
196 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
208 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
209 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
210 | + } |
|
197 | 211 | return (string) (int) $replacement; |
198 | 212 | break; |
199 | 213 | |
@@ -205,65 +219,73 @@ discard block |
||
205 | 219 | case 'array_int': |
206 | 220 | if (is_array($replacement)) |
207 | 221 | { |
208 | - if (empty($replacement)) |
|
209 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
222 | + if (empty($replacement)) { |
|
223 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
224 | + } |
|
210 | 225 | |
211 | 226 | foreach ($replacement as $key => $value) |
212 | 227 | { |
213 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
214 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
228 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
229 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
230 | + } |
|
215 | 231 | |
216 | 232 | $replacement[$key] = (string) (int) $value; |
217 | 233 | } |
218 | 234 | |
219 | 235 | return implode(', ', $replacement); |
236 | + } else { |
|
237 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
220 | 238 | } |
221 | - else |
|
222 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
223 | 239 | |
224 | 240 | break; |
225 | 241 | |
226 | 242 | case 'array_string': |
227 | 243 | if (is_array($replacement)) |
228 | 244 | { |
229 | - if (empty($replacement)) |
|
230 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
245 | + if (empty($replacement)) { |
|
246 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
247 | + } |
|
231 | 248 | |
232 | - foreach ($replacement as $key => $value) |
|
233 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
249 | + foreach ($replacement as $key => $value) { |
|
250 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
251 | + } |
|
234 | 252 | |
235 | 253 | return implode(', ', $replacement); |
254 | + } else { |
|
255 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
236 | 256 | } |
237 | - else |
|
238 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
239 | 257 | break; |
240 | 258 | |
241 | 259 | case 'date': |
242 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
243 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
244 | - else |
|
245 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
260 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
261 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
262 | + } else { |
|
263 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
264 | + } |
|
246 | 265 | break; |
247 | 266 | |
248 | 267 | case 'time': |
249 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
250 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
251 | - else |
|
252 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
268 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
269 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
270 | + } else { |
|
271 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
272 | + } |
|
253 | 273 | break; |
254 | 274 | |
255 | 275 | case 'datetime': |
256 | - 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) |
|
257 | - return 'str_to_date('. |
|
276 | + 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) { |
|
277 | + return 'str_to_date('. |
|
258 | 278 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
259 | 279 | ',\'%Y-%m-%d %h:%i:%s\')'; |
260 | - else |
|
261 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
280 | + } else { |
|
281 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
282 | + } |
|
262 | 283 | break; |
263 | 284 | |
264 | 285 | case 'float': |
265 | - if (!is_numeric($replacement)) |
|
266 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
286 | + if (!is_numeric($replacement)) { |
|
287 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
288 | + } |
|
267 | 289 | return (string) (float) $replacement; |
268 | 290 | break; |
269 | 291 | |
@@ -277,32 +299,37 @@ discard block |
||
277 | 299 | break; |
278 | 300 | |
279 | 301 | case 'inet': |
280 | - if ($replacement == 'null' || $replacement == '') |
|
281 | - return 'null'; |
|
282 | - if (!isValidIP($replacement)) |
|
283 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
302 | + if ($replacement == 'null' || $replacement == '') { |
|
303 | + return 'null'; |
|
304 | + } |
|
305 | + if (!isValidIP($replacement)) { |
|
306 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
307 | + } |
|
284 | 308 | //we don't use the native support of mysql > 5.6.2 |
285 | 309 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
286 | 310 | |
287 | 311 | case 'array_inet': |
288 | 312 | if (is_array($replacement)) |
289 | 313 | { |
290 | - if (empty($replacement)) |
|
291 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
314 | + if (empty($replacement)) { |
|
315 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
316 | + } |
|
292 | 317 | |
293 | 318 | foreach ($replacement as $key => $value) |
294 | 319 | { |
295 | - if ($replacement == 'null' || $replacement == '') |
|
296 | - $replacement[$key] = 'null'; |
|
297 | - if (!isValidIP($value)) |
|
298 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
320 | + if ($replacement == 'null' || $replacement == '') { |
|
321 | + $replacement[$key] = 'null'; |
|
322 | + } |
|
323 | + if (!isValidIP($value)) { |
|
324 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
325 | + } |
|
299 | 326 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
300 | 327 | } |
301 | 328 | |
302 | 329 | return implode(', ', $replacement); |
330 | + } else { |
|
331 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
303 | 332 | } |
304 | - else |
|
305 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
306 | 333 | break; |
307 | 334 | |
308 | 335 | default: |
@@ -378,22 +405,25 @@ discard block |
||
378 | 405 | // Are we in SSI mode? If so try that username and password first |
379 | 406 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
380 | 407 | { |
381 | - if (empty($db_persist)) |
|
382 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
383 | - else |
|
384 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
408 | + if (empty($db_persist)) { |
|
409 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
410 | + } else { |
|
411 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
412 | + } |
|
385 | 413 | } |
386 | 414 | // Fall back to the regular username and password if need be |
387 | 415 | if (!$db_connection) |
388 | 416 | { |
389 | - if (empty($db_persist)) |
|
390 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
391 | - else |
|
392 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
417 | + if (empty($db_persist)) { |
|
418 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
419 | + } else { |
|
420 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
421 | + } |
|
393 | 422 | } |
394 | 423 | |
395 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
396 | - $db_connection = false; |
|
424 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
425 | + $db_connection = false; |
|
426 | + } |
|
397 | 427 | |
398 | 428 | $connection = $db_connection; |
399 | 429 | } |
@@ -401,18 +431,20 @@ discard block |
||
401 | 431 | // One more query.... |
402 | 432 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
403 | 433 | |
404 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
405 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
434 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
435 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
436 | + } |
|
406 | 437 | |
407 | 438 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
408 | 439 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
409 | 440 | { |
410 | 441 | // Add before LIMIT |
411 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
412 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
413 | - else |
|
414 | - // Append it. |
|
442 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
443 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
444 | + } else { |
|
445 | + // Append it. |
|
415 | 446 | $db_string .= "\n\t\t\tORDER BY null"; |
447 | + } |
|
416 | 448 | } |
417 | 449 | |
418 | 450 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -434,8 +466,9 @@ discard block |
||
434 | 466 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
435 | 467 | |
436 | 468 | // Initialize $db_cache if not already initialized. |
437 | - if (!isset($db_cache)) |
|
438 | - $db_cache = array(); |
|
469 | + if (!isset($db_cache)) { |
|
470 | + $db_cache = array(); |
|
471 | + } |
|
439 | 472 | |
440 | 473 | if (!empty($_SESSION['debug_redirect'])) |
441 | 474 | { |
@@ -461,17 +494,18 @@ discard block |
||
461 | 494 | while (true) |
462 | 495 | { |
463 | 496 | $pos = strpos($db_string, '\'', $pos + 1); |
464 | - if ($pos === false) |
|
465 | - break; |
|
497 | + if ($pos === false) { |
|
498 | + break; |
|
499 | + } |
|
466 | 500 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
467 | 501 | |
468 | 502 | while (true) |
469 | 503 | { |
470 | 504 | $pos1 = strpos($db_string, '\'', $pos + 1); |
471 | 505 | $pos2 = strpos($db_string, '\\', $pos + 1); |
472 | - if ($pos1 === false) |
|
473 | - break; |
|
474 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
506 | + if ($pos1 === false) { |
|
507 | + break; |
|
508 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
475 | 509 | { |
476 | 510 | $pos = $pos1; |
477 | 511 | break; |
@@ -487,29 +521,35 @@ discard block |
||
487 | 521 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
488 | 522 | |
489 | 523 | // Comments? We don't use comments in our queries, we leave 'em outside! |
490 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
491 | - $fail = true; |
|
524 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
525 | + $fail = true; |
|
526 | + } |
|
492 | 527 | // Trying to change passwords, slow us down, or something? |
493 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
494 | - $fail = true; |
|
495 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
496 | - $fail = true; |
|
528 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
529 | + $fail = true; |
|
530 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
531 | + $fail = true; |
|
532 | + } |
|
497 | 533 | |
498 | - if (!empty($fail) && function_exists('log_error')) |
|
499 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
534 | + if (!empty($fail) && function_exists('log_error')) { |
|
535 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
536 | + } |
|
500 | 537 | } |
501 | 538 | |
502 | - if (empty($db_unbuffered)) |
|
503 | - $ret = @mysqli_query($connection, $db_string); |
|
504 | - else |
|
505 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
539 | + if (empty($db_unbuffered)) { |
|
540 | + $ret = @mysqli_query($connection, $db_string); |
|
541 | + } else { |
|
542 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
543 | + } |
|
506 | 544 | |
507 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
508 | - $ret = smf_db_error($db_string, $connection); |
|
545 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
546 | + $ret = smf_db_error($db_string, $connection); |
|
547 | + } |
|
509 | 548 | |
510 | 549 | // Debugging. |
511 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
512 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
550 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
551 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
552 | + } |
|
513 | 553 | |
514 | 554 | return $ret; |
515 | 555 | } |
@@ -556,12 +596,13 @@ discard block |
||
556 | 596 | // Decide which connection to use |
557 | 597 | $connection = $connection === null ? $db_connection : $connection; |
558 | 598 | |
559 | - if ($type == 'begin') |
|
560 | - return @mysqli_query($connection, 'BEGIN'); |
|
561 | - elseif ($type == 'rollback') |
|
562 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
563 | - elseif ($type == 'commit') |
|
564 | - return @mysqli_query($connection, 'COMMIT'); |
|
599 | + if ($type == 'begin') { |
|
600 | + return @mysqli_query($connection, 'BEGIN'); |
|
601 | + } elseif ($type == 'rollback') { |
|
602 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
603 | + } elseif ($type == 'commit') { |
|
604 | + return @mysqli_query($connection, 'COMMIT'); |
|
605 | + } |
|
565 | 606 | |
566 | 607 | return false; |
567 | 608 | } |
@@ -601,8 +642,9 @@ discard block |
||
601 | 642 | // 2013: Lost connection to server during query. |
602 | 643 | |
603 | 644 | // Log the error. |
604 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
605 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
645 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
646 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
647 | + } |
|
606 | 648 | |
607 | 649 | // Database error auto fixing ;). |
608 | 650 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -611,8 +653,9 @@ discard block |
||
611 | 653 | $old_cache = @$modSettings['cache_enable']; |
612 | 654 | $modSettings['cache_enable'] = '1'; |
613 | 655 | |
614 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
615 | - $db_last_error = max(@$db_last_error, $temp); |
|
656 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
657 | + $db_last_error = max(@$db_last_error, $temp); |
|
658 | + } |
|
616 | 659 | |
617 | 660 | if (@$db_last_error < time() - 3600 * 24 * 3) |
618 | 661 | { |
@@ -628,8 +671,9 @@ discard block |
||
628 | 671 | foreach ($tables as $table) |
629 | 672 | { |
630 | 673 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
631 | - if (trim($table) != '') |
|
632 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
674 | + if (trim($table) != '') { |
|
675 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
676 | + } |
|
633 | 677 | } |
634 | 678 | } |
635 | 679 | |
@@ -638,8 +682,9 @@ discard block |
||
638 | 682 | // Table crashed. Let's try to fix it. |
639 | 683 | elseif ($query_errno == 1016) |
640 | 684 | { |
641 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
642 | - $fix_tables = array('`' . $match[1] . '`'); |
|
685 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
686 | + $fix_tables = array('`' . $match[1] . '`'); |
|
687 | + } |
|
643 | 688 | } |
644 | 689 | // Indexes crashed. Should be easy to fix! |
645 | 690 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -658,13 +703,15 @@ discard block |
||
658 | 703 | |
659 | 704 | // Make a note of the REPAIR... |
660 | 705 | cache_put_data('db_last_error', time(), 600); |
661 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
662 | - updateSettingsFile(array('db_last_error' => time())); |
|
706 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
707 | + updateSettingsFile(array('db_last_error' => time())); |
|
708 | + } |
|
663 | 709 | |
664 | 710 | // Attempt to find and repair the broken table. |
665 | - foreach ($fix_tables as $table) |
|
666 | - $smcFunc['db_query']('', " |
|
711 | + foreach ($fix_tables as $table) { |
|
712 | + $smcFunc['db_query']('', " |
|
667 | 713 | REPAIR TABLE $table", false, false); |
714 | + } |
|
668 | 715 | |
669 | 716 | // And send off an email! |
670 | 717 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -673,11 +720,12 @@ discard block |
||
673 | 720 | |
674 | 721 | // Try the query again...? |
675 | 722 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
676 | - if ($ret !== false) |
|
677 | - return $ret; |
|
723 | + if ($ret !== false) { |
|
724 | + return $ret; |
|
725 | + } |
|
726 | + } else { |
|
727 | + $modSettings['cache_enable'] = $old_cache; |
|
678 | 728 | } |
679 | - else |
|
680 | - $modSettings['cache_enable'] = $old_cache; |
|
681 | 729 | |
682 | 730 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
683 | 731 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -687,22 +735,25 @@ discard block |
||
687 | 735 | // Are we in SSI mode? If so try that username and password first |
688 | 736 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
689 | 737 | { |
690 | - if (empty($db_persist)) |
|
691 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
692 | - else |
|
693 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
738 | + if (empty($db_persist)) { |
|
739 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
740 | + } else { |
|
741 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
742 | + } |
|
694 | 743 | } |
695 | 744 | // Fall back to the regular username and password if need be |
696 | 745 | if (!$db_connection) |
697 | 746 | { |
698 | - if (empty($db_persist)) |
|
699 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
700 | - else |
|
701 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
747 | + if (empty($db_persist)) { |
|
748 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
749 | + } else { |
|
750 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
751 | + } |
|
702 | 752 | } |
703 | 753 | |
704 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
705 | - $db_connection = false; |
|
754 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
755 | + $db_connection = false; |
|
756 | + } |
|
706 | 757 | } |
707 | 758 | |
708 | 759 | if ($db_connection) |
@@ -713,24 +764,27 @@ discard block |
||
713 | 764 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
714 | 765 | |
715 | 766 | $new_errno = mysqli_errno($db_connection); |
716 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
717 | - break; |
|
767 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
768 | + break; |
|
769 | + } |
|
718 | 770 | } |
719 | 771 | |
720 | 772 | // If it failed again, shucks to be you... we're not trying it over and over. |
721 | - if ($ret !== false) |
|
722 | - return $ret; |
|
773 | + if ($ret !== false) { |
|
774 | + return $ret; |
|
775 | + } |
|
723 | 776 | } |
724 | 777 | } |
725 | 778 | // Are they out of space, perhaps? |
726 | 779 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
727 | 780 | { |
728 | - if (!isset($txt)) |
|
729 | - $query_error .= ' - check database storage space.'; |
|
730 | - else |
|
781 | + if (!isset($txt)) { |
|
782 | + $query_error .= ' - check database storage space.'; |
|
783 | + } else |
|
731 | 784 | { |
732 | - if (!isset($txt['mysql_error_space'])) |
|
733 | - loadLanguage('Errors'); |
|
785 | + if (!isset($txt['mysql_error_space'])) { |
|
786 | + loadLanguage('Errors'); |
|
787 | + } |
|
734 | 788 | |
735 | 789 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
736 | 790 | } |
@@ -738,15 +792,17 @@ discard block |
||
738 | 792 | } |
739 | 793 | |
740 | 794 | // Nothing's defined yet... just die with it. |
741 | - if (empty($context) || empty($txt)) |
|
742 | - die($query_error); |
|
795 | + if (empty($context) || empty($txt)) { |
|
796 | + die($query_error); |
|
797 | + } |
|
743 | 798 | |
744 | 799 | // Show an error message, if possible. |
745 | 800 | $context['error_title'] = $txt['database_error']; |
746 | - if (allowedTo('admin_forum')) |
|
747 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
748 | - else |
|
749 | - $context['error_message'] = $txt['try_again']; |
|
801 | + if (allowedTo('admin_forum')) { |
|
802 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
803 | + } else { |
|
804 | + $context['error_message'] = $txt['try_again']; |
|
805 | + } |
|
750 | 806 | |
751 | 807 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
752 | 808 | { |
@@ -778,8 +834,9 @@ discard block |
||
778 | 834 | $return_var = null; |
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); |
@@ -789,23 +846,26 @@ discard block |
||
789 | 846 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
790 | 847 | { |
791 | 848 | $with_returning = true; |
792 | - if ($returnmode == 2) |
|
793 | - $return_var = array(); |
|
849 | + if ($returnmode == 2) { |
|
850 | + $return_var = array(); |
|
851 | + } |
|
794 | 852 | } |
795 | 853 | |
796 | 854 | // Inserting data as a single row can be done as a single array. |
797 | - if (!is_array($data[array_rand($data)])) |
|
798 | - $data = array($data); |
|
855 | + if (!is_array($data[array_rand($data)])) { |
|
856 | + $data = array($data); |
|
857 | + } |
|
799 | 858 | |
800 | 859 | // Create the mold for a single row insert. |
801 | 860 | $insertData = '('; |
802 | 861 | foreach ($columns as $columnName => $type) |
803 | 862 | { |
804 | 863 | // Are we restricting the length? |
805 | - if (strpos($type, 'string-') !== false) |
|
806 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
807 | - else |
|
808 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
864 | + if (strpos($type, 'string-') !== false) { |
|
865 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
866 | + } else { |
|
867 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
868 | + } |
|
809 | 869 | } |
810 | 870 | $insertData = substr($insertData, 0, -2) . ')'; |
811 | 871 | |
@@ -814,8 +874,9 @@ discard block |
||
814 | 874 | |
815 | 875 | // Here's where the variables are injected to the query. |
816 | 876 | $insertRows = array(); |
817 | - foreach ($data as $dataRow) |
|
818 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
877 | + foreach ($data as $dataRow) { |
|
878 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
879 | + } |
|
819 | 880 | |
820 | 881 | // Determine the method of insertion. |
821 | 882 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -834,8 +895,7 @@ discard block |
||
834 | 895 | ), |
835 | 896 | $connection |
836 | 897 | ); |
837 | - } |
|
838 | - else //special way for ignore method with returning |
|
898 | + } else //special way for ignore method with returning |
|
839 | 899 | { |
840 | 900 | $count = count($insertRows); |
841 | 901 | $ai = 0; |
@@ -855,19 +915,21 @@ discard block |
||
855 | 915 | ); |
856 | 916 | $new_id = $smcFunc['db_insert_id'](); |
857 | 917 | |
858 | - if ($last_id != $new_id) //the inserted value was new |
|
918 | + if ($last_id != $new_id) { |
|
919 | + //the inserted value was new |
|
859 | 920 | { |
860 | 921 | $ai = $new_id; |
861 | 922 | } |
862 | - else // the inserted value already exists we need to find the pk |
|
923 | + } else // the inserted value already exists we need to find the pk |
|
863 | 924 | { |
864 | 925 | $where_string = ''; |
865 | 926 | $count2 = count($indexed_columns); |
866 | 927 | for ($x = 0; $x < $count2; $x++) |
867 | 928 | { |
868 | 929 | $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
869 | - if (($x + 1) < $count2) |
|
870 | - $where_string += ' AND '; |
|
930 | + if (($x + 1) < $count2) { |
|
931 | + $where_string += ' AND '; |
|
932 | + } |
|
871 | 933 | } |
872 | 934 | |
873 | 935 | $request = $smcFunc['db_query']('',' |
@@ -883,25 +945,27 @@ discard block |
||
883 | 945 | } |
884 | 946 | } |
885 | 947 | |
886 | - if ($returnmode == 1) |
|
887 | - $return_var = $ai; |
|
888 | - else if ($returnmode == 2) |
|
889 | - $return_var[] = $ai; |
|
948 | + if ($returnmode == 1) { |
|
949 | + $return_var = $ai; |
|
950 | + } else if ($returnmode == 2) { |
|
951 | + $return_var[] = $ai; |
|
952 | + } |
|
890 | 953 | } |
891 | 954 | } |
892 | 955 | |
893 | 956 | |
894 | 957 | if ($with_returning) |
895 | 958 | { |
896 | - if ($returnmode == 1 && empty($return_var)) |
|
897 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
898 | - else if ($returnmode == 2 && empty($return_var)) |
|
959 | + if ($returnmode == 1 && empty($return_var)) { |
|
960 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
961 | + } else if ($returnmode == 2 && empty($return_var)) |
|
899 | 962 | { |
900 | 963 | $return_var = array(); |
901 | 964 | $count = count($insertRows); |
902 | 965 | $start = smf_db_insert_id($table, $keys[0]); |
903 | - for ($i = 0; $i < $count; $i++ ) |
|
904 | - $return_var[] = $start + $i; |
|
966 | + for ($i = 0; $i < $count; $i++ ) { |
|
967 | + $return_var[] = $start + $i; |
|
968 | + } |
|
905 | 969 | } |
906 | 970 | return $return_var; |
907 | 971 | } |
@@ -919,8 +983,9 @@ discard block |
||
919 | 983 | */ |
920 | 984 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
921 | 985 | { |
922 | - if (empty($log_message)) |
|
923 | - $log_message = $error_message; |
|
986 | + if (empty($log_message)) { |
|
987 | + $log_message = $error_message; |
|
988 | + } |
|
924 | 989 | |
925 | 990 | foreach (debug_backtrace() as $step) |
926 | 991 | { |
@@ -939,12 +1004,14 @@ discard block |
||
939 | 1004 | } |
940 | 1005 | |
941 | 1006 | // A special case - we want the file and line numbers for debugging. |
942 | - if ($error_type == 'return') |
|
943 | - return array($file, $line); |
|
1007 | + if ($error_type == 'return') { |
|
1008 | + return array($file, $line); |
|
1009 | + } |
|
944 | 1010 | |
945 | 1011 | // Is always a critical error. |
946 | - if (function_exists('log_error')) |
|
947 | - log_error($log_message, 'critical', $file, $line); |
|
1012 | + if (function_exists('log_error')) { |
|
1013 | + log_error($log_message, 'critical', $file, $line); |
|
1014 | + } |
|
948 | 1015 | |
949 | 1016 | if (function_exists('fatal_error')) |
950 | 1017 | { |
@@ -952,12 +1019,12 @@ discard block |
||
952 | 1019 | |
953 | 1020 | // Cannot continue... |
954 | 1021 | exit; |
1022 | + } elseif ($error_type) { |
|
1023 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
1024 | + } else { |
|
1025 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
1026 | + } |
|
955 | 1027 | } |
956 | - elseif ($error_type) |
|
957 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
958 | - else |
|
959 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
960 | -} |
|
961 | 1028 | |
962 | 1029 | /** |
963 | 1030 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -974,10 +1041,11 @@ discard block |
||
974 | 1041 | '\\' => '\\\\', |
975 | 1042 | ); |
976 | 1043 | |
977 | - if ($translate_human_wildcards) |
|
978 | - $replacements += array( |
|
1044 | + if ($translate_human_wildcards) { |
|
1045 | + $replacements += array( |
|
979 | 1046 | '*' => '%', |
980 | 1047 | ); |
1048 | + } |
|
981 | 1049 | |
982 | 1050 | return strtr($string, $replacements); |
983 | 1051 | } |
@@ -991,8 +1059,9 @@ discard block |
||
991 | 1059 | */ |
992 | 1060 | function smf_is_resource($result) |
993 | 1061 | { |
994 | - if ($result instanceof mysqli_result) |
|
995 | - return true; |
|
1062 | + if ($result instanceof mysqli_result) { |
|
1063 | + return true; |
|
1064 | + } |
|
996 | 1065 | |
997 | 1066 | return false; |
998 | 1067 | } |
@@ -1020,16 +1089,18 @@ discard block |
||
1020 | 1089 | global $db_prefix, $db_connection; |
1021 | 1090 | static $mysql_error_data_prep; |
1022 | 1091 | |
1023 | - if (empty($mysql_error_data_prep)) |
|
1024 | - $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
1092 | + if (empty($mysql_error_data_prep)) { |
|
1093 | + $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
1025 | 1094 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line) |
1026 | 1095 | VALUES( ?, ?, unhex(?), ?, ?, ?, ?, ?, ?)' |
1027 | 1096 | ); |
1097 | + } |
|
1028 | 1098 | |
1029 | - if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) |
|
1030 | - $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
1031 | - else |
|
1032 | - $error_array[2] = null; |
|
1099 | + if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) { |
|
1100 | + $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
1101 | + } else { |
|
1102 | + $error_array[2] = null; |
|
1103 | + } |
|
1033 | 1104 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', |
1034 | 1105 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
1035 | 1106 | $error_array[7], $error_array[8]); |
@@ -144,11 +144,12 @@ discard block |
||
144 | 144 | <div class="question">', $txt['poll_question'], ': <strong>', $context['poll']['question'], '</strong>'; |
145 | 145 | |
146 | 146 | $options = 1; |
147 | - foreach ($context['poll']['options'] as $option) |
|
148 | - echo ' |
|
147 | + foreach ($context['poll']['options'] as $option) { |
|
148 | + echo ' |
|
149 | 149 | <div class="', $option['voted_this'] ? 'voted' : '', '">', $txt['option'], ' ', $options++, ': <strong>', $option['option'], '</strong> |
150 | 150 | ', $context['allow_poll_view'] ? $txt['votes'] . ': ' . $option['votes'] . '' : '', ' |
151 | 151 | </div>'; |
152 | + } |
|
152 | 153 | |
153 | 154 | echo ' |
154 | 155 | </div>'; |
@@ -170,9 +171,10 @@ discard block |
||
170 | 171 | echo ' |
171 | 172 | <hr>'; |
172 | 173 | |
173 | - foreach ($context['printattach'][$post['id_msg']] as $attach) |
|
174 | - echo ' |
|
174 | + foreach ($context['printattach'][$post['id_msg']] as $attach) { |
|
175 | + echo ' |
|
175 | 176 | <img width="' . $attach['width'] . '" height="' . $attach['height'] . '" src="', $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attach['id_attach'] . '" alt="">'; |
177 | + } |
|
176 | 178 | } |
177 | 179 | |
178 | 180 | echo ' |
@@ -207,12 +209,13 @@ discard block |
||
207 | 209 | <div class="print_options">'; |
208 | 210 | |
209 | 211 | // Which option is set, text or text&images |
210 | - if (isset($_REQUEST['images'])) |
|
211 | - echo ' |
|
212 | + if (isset($_REQUEST['images'])) { |
|
213 | + echo ' |
|
212 | 214 | <a href="', $url_text, '">', $txt['print_page_text'], '</a> | <strong><a href="', $url_images, '">', $txt['print_page_images'], '</a></strong>'; |
213 | - else |
|
214 | - echo ' |
|
215 | + } else { |
|
216 | + echo ' |
|
215 | 217 | <strong><a href="', $url_text, '">', $txt['print_page_text'], '</a></strong> | <a href="', $url_images, '">', $txt['print_page_images'], '</a>'; |
218 | + } |
|
216 | 219 | |
217 | 220 | echo ' |
218 | 221 | </div><!-- .print_options -->'; |
@@ -3078,8 +3078,7 @@ |
||
3078 | 3078 | <div class="roundframe"> |
3079 | 3079 | <div> |
3080 | 3080 | ', !empty($context['tfa_backup']) ? ' |
3081 | - <div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : |
|
3082 | - ($modSettings['tfa_mode'] == 2 ? ' |
|
3081 | + <div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : ($modSettings['tfa_mode'] == 2 ? ' |
|
3083 | 3082 | <div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), ' |
3084 | 3083 | <div class="smalltext">', $txt['tfa_desc'], '</div> |
3085 | 3084 | <div class="floatleft"> |
@@ -18,23 +18,25 @@ discard block |
||
18 | 18 | global $context; |
19 | 19 | |
20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
22 | - echo ' |
|
21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
22 | + echo ' |
|
23 | 23 | <script> |
24 | 24 | disableAutoComplete(); |
25 | 25 | </script>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
28 | 29 | echo ' |
29 | 30 | ', template_error_message(); |
30 | 31 | |
31 | 32 | // If the profile was update successfully, let the user know this. |
32 | - if (!empty($context['profile_updated'])) |
|
33 | - echo ' |
|
33 | + if (!empty($context['profile_updated'])) { |
|
34 | + echo ' |
|
34 | 35 | <div class="infobox"> |
35 | 36 | ', $context['profile_updated'], ' |
36 | 37 | </div>'; |
37 | -} |
|
38 | + } |
|
39 | + } |
|
38 | 40 | |
39 | 41 | /** |
40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -99,19 +101,19 @@ discard block |
||
99 | 101 | </div> |
100 | 102 | <div class="alerts_unread">'; |
101 | 103 | |
102 | - if (empty($context['unread_alerts'])) |
|
103 | - template_alerts_all_read(); |
|
104 | - |
|
105 | - else |
|
104 | + if (empty($context['unread_alerts'])) { |
|
105 | + template_alerts_all_read(); |
|
106 | + } else |
|
106 | 107 | { |
107 | - foreach ($context['unread_alerts'] as $id_alert => $details) |
|
108 | - echo ' |
|
108 | + foreach ($context['unread_alerts'] as $id_alert => $details) { |
|
109 | + echo ' |
|
109 | 110 | <div class="unread"> |
110 | 111 | ', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', ' |
111 | 112 | <div class="details"> |
112 | 113 | ', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], ' |
113 | 114 | </div> |
114 | 115 | </div>'; |
116 | + } |
|
115 | 117 | } |
116 | 118 | |
117 | 119 | echo ' |
@@ -161,10 +163,11 @@ discard block |
||
161 | 163 | <div class="custom_fields_above_name"> |
162 | 164 | <ul>'; |
163 | 165 | |
164 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
165 | - if (!empty($field['output_html'])) |
|
166 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
167 | + if (!empty($field['output_html'])) |
|
166 | 168 | echo ' |
167 | 169 | <li>', $field['output_html'], '</li>'; |
170 | + } |
|
168 | 171 | |
169 | 172 | echo ' |
170 | 173 | </ul> |
@@ -176,20 +179,22 @@ discard block |
||
176 | 179 | <div class="username clear"> |
177 | 180 | <h4>'; |
178 | 181 | |
179 | - if (!empty($context['print_custom_fields']['before_member'])) |
|
180 | - foreach ($context['print_custom_fields']['before_member'] as $field) |
|
182 | + if (!empty($context['print_custom_fields']['before_member'])) { |
|
183 | + foreach ($context['print_custom_fields']['before_member'] as $field) |
|
181 | 184 | if (!empty($field['output_html'])) |
182 | 185 | echo ' |
183 | 186 | <span>', $field['output_html'], '</span>'; |
187 | + } |
|
184 | 188 | |
185 | 189 | echo ' |
186 | 190 | ', $context['member']['name']; |
187 | 191 | |
188 | - if (!empty($context['print_custom_fields']['after_member'])) |
|
189 | - foreach ($context['print_custom_fields']['after_member'] as $field) |
|
192 | + if (!empty($context['print_custom_fields']['after_member'])) { |
|
193 | + foreach ($context['print_custom_fields']['after_member'] as $field) |
|
190 | 194 | if (!empty($field['output_html'])) |
191 | 195 | echo ' |
192 | 196 | <span>', $field['output_html'], '</span>'; |
197 | + } |
|
193 | 198 | |
194 | 199 | |
195 | 200 | echo ' |
@@ -205,10 +210,11 @@ discard block |
||
205 | 210 | <div class="custom_fields_below_avatar"> |
206 | 211 | <ul>'; |
207 | 212 | |
208 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
209 | - if (!empty($field['output_html'])) |
|
213 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
214 | + if (!empty($field['output_html'])) |
|
210 | 215 | echo ' |
211 | 216 | <li>', $field['output_html'], '</li>'; |
217 | + } |
|
212 | 218 | |
213 | 219 | echo ' |
214 | 220 | </ul> |
@@ -220,22 +226,25 @@ discard block |
||
220 | 226 | <ul class="clear">'; |
221 | 227 | |
222 | 228 | // Email is only visible if it's your profile or you have the moderate_forum permission |
223 | - if ($context['member']['show_email']) |
|
224 | - echo ' |
|
229 | + if ($context['member']['show_email']) { |
|
230 | + echo ' |
|
225 | 231 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
232 | + } |
|
226 | 233 | |
227 | 234 | // Don't show an icon if they haven't specified a website. |
228 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
229 | - echo ' |
|
235 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
236 | + echo ' |
|
230 | 237 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
238 | + } |
|
231 | 239 | |
232 | 240 | // Are there any custom profile fields as icons? |
233 | 241 | if (!empty($context['print_custom_fields']['icons'])) |
234 | 242 | { |
235 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
236 | - if (!empty($field['output_html'])) |
|
243 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
244 | + if (!empty($field['output_html'])) |
|
237 | 245 | echo ' |
238 | 246 | <li class="custom_field">', $field['output_html'], '</li>'; |
247 | + } |
|
239 | 248 | } |
240 | 249 | |
241 | 250 | echo ' |
@@ -244,24 +253,27 @@ discard block |
||
244 | 253 | ', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
245 | 254 | |
246 | 255 | // Can they add this member as a buddy? |
247 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
248 | - echo ' |
|
256 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
257 | + echo ' |
|
249 | 258 | <br> |
250 | 259 | <a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
260 | + } |
|
251 | 261 | |
252 | 262 | echo ' |
253 | 263 | </span>'; |
254 | 264 | |
255 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
256 | - echo ' |
|
265 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
266 | + echo ' |
|
257 | 267 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
268 | + } |
|
258 | 269 | |
259 | 270 | echo ' |
260 | 271 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
261 | 272 | |
262 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
263 | - echo ' |
|
273 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
274 | + echo ' |
|
264 | 275 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
276 | + } |
|
265 | 277 | |
266 | 278 | echo ' |
267 | 279 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -273,10 +285,11 @@ discard block |
||
273 | 285 | <div class="custom_fields_bottom"> |
274 | 286 | <ul class="nolist">'; |
275 | 287 | |
276 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
277 | - if (!empty($field['output_html'])) |
|
288 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
289 | + if (!empty($field['output_html'])) |
|
278 | 290 | echo ' |
279 | 291 | <li>', $field['output_html'], '</li>'; |
292 | + } |
|
280 | 293 | |
281 | 294 | echo ' |
282 | 295 | </ul> |
@@ -289,30 +302,35 @@ discard block |
||
289 | 302 | <div id="detailedinfo"> |
290 | 303 | <dl class="settings">'; |
291 | 304 | |
292 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
293 | - echo ' |
|
305 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
306 | + echo ' |
|
294 | 307 | <dt>', $txt['username'], ': </dt> |
295 | 308 | <dd>', $context['member']['username'], '</dd>'; |
309 | + } |
|
296 | 310 | |
297 | - if (!isset($context['disabled_fields']['posts'])) |
|
298 | - echo ' |
|
311 | + if (!isset($context['disabled_fields']['posts'])) { |
|
312 | + echo ' |
|
299 | 313 | <dt>', $txt['profile_posts'], ': </dt> |
300 | 314 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
315 | + } |
|
301 | 316 | |
302 | - if ($context['member']['show_email']) |
|
303 | - echo ' |
|
317 | + if ($context['member']['show_email']) { |
|
318 | + echo ' |
|
304 | 319 | <dt>', $txt['email'], ': </dt> |
305 | 320 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
321 | + } |
|
306 | 322 | |
307 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
308 | - echo ' |
|
323 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
324 | + echo ' |
|
309 | 325 | <dt>', $txt['custom_title'], ': </dt> |
310 | 326 | <dd>', $context['member']['title'], '</dd>'; |
327 | + } |
|
311 | 328 | |
312 | - if (!empty($context['member']['blurb'])) |
|
313 | - echo ' |
|
329 | + if (!empty($context['member']['blurb'])) { |
|
330 | + echo ' |
|
314 | 331 | <dt>', $txt['personal_text'], ': </dt> |
315 | 332 | <dd>', $context['member']['blurb'], '</dd>'; |
333 | + } |
|
316 | 334 | |
317 | 335 | echo ' |
318 | 336 | <dt>', $txt['age'], ':</dt> |
@@ -326,19 +344,21 @@ discard block |
||
326 | 344 | { |
327 | 345 | $fields = array(); |
328 | 346 | |
329 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
330 | - if (!empty($field['output_html'])) |
|
347 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
348 | + if (!empty($field['output_html'])) |
|
331 | 349 | $fields[] = $field; |
350 | + } |
|
332 | 351 | |
333 | 352 | if (count($fields) > 0) |
334 | 353 | { |
335 | 354 | echo ' |
336 | 355 | <dl class="settings">'; |
337 | 356 | |
338 | - foreach ($fields as $field) |
|
339 | - echo ' |
|
357 | + foreach ($fields as $field) { |
|
358 | + echo ' |
|
340 | 359 | <dt>', $field['name'], ':</dt> |
341 | 360 | <dd>', $field['output_html'], '</dd>'; |
361 | + } |
|
342 | 362 | |
343 | 363 | echo ' |
344 | 364 | </dl>'; |
@@ -358,9 +378,10 @@ discard block |
||
358 | 378 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
359 | 379 | |
360 | 380 | // Can we provide information on what this means? |
361 | - if (!empty($context['warning_status'])) |
|
362 | - echo ' |
|
381 | + if (!empty($context['warning_status'])) { |
|
382 | + echo ' |
|
363 | 383 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
384 | + } |
|
364 | 385 | |
365 | 386 | echo ' |
366 | 387 | </dd>'; |
@@ -371,11 +392,12 @@ discard block |
||
371 | 392 | { |
372 | 393 | |
373 | 394 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
374 | - if (!empty($context['activate_message'])) |
|
375 | - echo ' |
|
395 | + if (!empty($context['activate_message'])) { |
|
396 | + echo ' |
|
376 | 397 | <dt class="clear"> |
377 | 398 | <span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>) |
378 | 399 | </dt>'; |
400 | + } |
|
379 | 401 | |
380 | 402 | // If the current member is banned, show a message and possibly a link to the ban. |
381 | 403 | if (!empty($context['member']['bans'])) |
@@ -387,10 +409,11 @@ discard block |
||
387 | 409 | <dt class="clear" id="ban_info" style="display: none;"> |
388 | 410 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
389 | 411 | |
390 | - foreach ($context['member']['bans'] as $ban) |
|
391 | - echo ' |
|
412 | + foreach ($context['member']['bans'] as $ban) { |
|
413 | + echo ' |
|
392 | 414 | <br> |
393 | 415 | <span class="smalltext">', $ban['explanation'], '</span>'; |
416 | + } |
|
394 | 417 | |
395 | 418 | echo ' |
396 | 419 | </dt>'; |
@@ -404,30 +427,34 @@ discard block |
||
404 | 427 | // If the person looking is allowed, they can check the members IP address and hostname. |
405 | 428 | if ($context['can_see_ip']) |
406 | 429 | { |
407 | - if (!empty($context['member']['ip'])) |
|
408 | - echo ' |
|
430 | + if (!empty($context['member']['ip'])) { |
|
431 | + echo ' |
|
409 | 432 | <dt>', $txt['ip'], ': </dt> |
410 | 433 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
434 | + } |
|
411 | 435 | |
412 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
413 | - echo ' |
|
436 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
437 | + echo ' |
|
414 | 438 | <dt>', $txt['hostname'], ': </dt> |
415 | 439 | <dd>', $context['member']['hostname'], '</dd>'; |
440 | + } |
|
416 | 441 | } |
417 | 442 | |
418 | 443 | echo ' |
419 | 444 | <dt>', $txt['local_time'], ':</dt> |
420 | 445 | <dd>', $context['member']['local_time'], '</dd>'; |
421 | 446 | |
422 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
423 | - echo ' |
|
447 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
448 | + echo ' |
|
424 | 449 | <dt>', $txt['language'], ':</dt> |
425 | 450 | <dd>', $context['member']['language'], '</dd>'; |
451 | + } |
|
426 | 452 | |
427 | - if ($context['member']['show_last_login']) |
|
428 | - echo ' |
|
453 | + if ($context['member']['show_last_login']) { |
|
454 | + echo ' |
|
429 | 455 | <dt>', $txt['lastLoggedIn'], ': </dt> |
430 | 456 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
457 | + } |
|
431 | 458 | |
432 | 459 | echo ' |
433 | 460 | </dl>'; |
@@ -439,10 +466,11 @@ discard block |
||
439 | 466 | <div class="custom_fields_above_signature"> |
440 | 467 | <ul class="nolist">'; |
441 | 468 | |
442 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
443 | - if (!empty($field['output_html'])) |
|
469 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
470 | + if (!empty($field['output_html'])) |
|
444 | 471 | echo ' |
445 | 472 | <li>', $field['output_html'], '</li>'; |
473 | + } |
|
446 | 474 | |
447 | 475 | echo ' |
448 | 476 | </ul> |
@@ -450,12 +478,13 @@ discard block |
||
450 | 478 | } |
451 | 479 | |
452 | 480 | // Show the users signature. |
453 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
454 | - echo ' |
|
481 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
482 | + echo ' |
|
455 | 483 | <div class="signature"> |
456 | 484 | <h5>', $txt['signature'], ':</h5> |
457 | 485 | ', $context['member']['signature'], ' |
458 | 486 | </div>'; |
487 | + } |
|
459 | 488 | |
460 | 489 | // Are there any custom profile fields for below the signature? |
461 | 490 | if (!empty($context['print_custom_fields']['below_signature'])) |
@@ -464,10 +493,11 @@ discard block |
||
464 | 493 | <div class="custom_fields_below_signature"> |
465 | 494 | <ul class="nolist">'; |
466 | 495 | |
467 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
468 | - if (!empty($field['output_html'])) |
|
496 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
497 | + if (!empty($field['output_html'])) |
|
469 | 498 | echo ' |
470 | 499 | <li>', $field['output_html'], '</li>'; |
500 | + } |
|
471 | 501 | |
472 | 502 | echo ' |
473 | 503 | </ul> |
@@ -513,62 +543,70 @@ discard block |
||
513 | 543 | </div> |
514 | 544 | <div class="list_posts">'; |
515 | 545 | |
516 | - if (!$post['approved']) |
|
517 | - echo ' |
|
546 | + if (!$post['approved']) { |
|
547 | + echo ' |
|
518 | 548 | <div class="approve_post"> |
519 | 549 | <em>', $txt['post_awaiting_approval'], '</em> |
520 | 550 | </div>'; |
551 | + } |
|
521 | 552 | |
522 | 553 | echo ' |
523 | 554 | ', $post['body'], ' |
524 | 555 | </div>'; |
525 | 556 | |
526 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
527 | - echo ' |
|
557 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
558 | + echo ' |
|
528 | 559 | <div class="floatright"> |
529 | 560 | <ul class="quickbuttons">'; |
561 | + } |
|
530 | 562 | |
531 | 563 | // If they *can* reply? |
532 | - if ($post['can_reply']) |
|
533 | - echo ' |
|
564 | + if ($post['can_reply']) { |
|
565 | + echo ' |
|
534 | 566 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
567 | + } |
|
535 | 568 | |
536 | 569 | // If they *can* quote? |
537 | - if ($post['can_quote']) |
|
538 | - echo ' |
|
570 | + if ($post['can_quote']) { |
|
571 | + echo ' |
|
539 | 572 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
573 | + } |
|
540 | 574 | |
541 | 575 | // How about... even... remove it entirely?! |
542 | - if ($post['can_delete']) |
|
543 | - echo ' |
|
576 | + if ($post['can_delete']) { |
|
577 | + echo ' |
|
544 | 578 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
579 | + } |
|
545 | 580 | |
546 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
547 | - echo ' |
|
581 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
582 | + echo ' |
|
548 | 583 | </ul> |
549 | 584 | </div><!-- .floatright -->'; |
585 | + } |
|
550 | 586 | |
551 | 587 | echo ' |
552 | 588 | </div><!-- $post[css_class] -->'; |
553 | 589 | } |
590 | + } else { |
|
591 | + template_show_list('attachments'); |
|
554 | 592 | } |
555 | - else |
|
556 | - template_show_list('attachments'); |
|
557 | 593 | |
558 | 594 | // No posts? Just end with a informative message. |
559 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
560 | - echo ' |
|
595 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
596 | + echo ' |
|
561 | 597 | <div class="windowbg2"> |
562 | 598 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
563 | 599 | </div>'; |
600 | + } |
|
564 | 601 | |
565 | 602 | // Show more page numbers. |
566 | - if (!empty($context['page_index'])) |
|
567 | - echo ' |
|
603 | + if (!empty($context['page_index'])) { |
|
604 | + echo ' |
|
568 | 605 | <div class="pagesection"> |
569 | 606 | <div class="pagelinks">', $context['page_index'], '</div> |
570 | 607 | </div>'; |
571 | -} |
|
608 | + } |
|
609 | + } |
|
572 | 610 | |
573 | 611 | /** |
574 | 612 | * Template for showing alerts within the alerts popup |
@@ -578,11 +616,12 @@ discard block |
||
578 | 616 | global $context, $txt, $scripturl; |
579 | 617 | |
580 | 618 | // Do we have an update message? |
581 | - if (!empty($context['update_message'])) |
|
582 | - echo ' |
|
619 | + if (!empty($context['update_message'])) { |
|
620 | + echo ' |
|
583 | 621 | <div class="infobox"> |
584 | 622 | ', $context['update_message'], '. |
585 | 623 | </div>'; |
624 | + } |
|
586 | 625 | |
587 | 626 | echo ' |
588 | 627 | <div class="cat_bar"> |
@@ -591,13 +630,12 @@ discard block |
||
591 | 630 | </h3> |
592 | 631 | </div>'; |
593 | 632 | |
594 | - if (empty($context['alerts'])) |
|
595 | - echo ' |
|
633 | + if (empty($context['alerts'])) { |
|
634 | + echo ' |
|
596 | 635 | <div class="information"> |
597 | 636 | ', $txt['alerts_none'], ' |
598 | 637 | </div>'; |
599 | - |
|
600 | - else |
|
638 | + } else |
|
601 | 639 | { |
602 | 640 | // Start the form. |
603 | 641 | echo ' |
@@ -659,12 +697,12 @@ discard block |
||
659 | 697 | </div>' : ''; |
660 | 698 | |
661 | 699 | // No drafts? Just show an informative message. |
662 | - if (empty($context['drafts'])) |
|
663 | - echo ' |
|
700 | + if (empty($context['drafts'])) { |
|
701 | + echo ' |
|
664 | 702 | <div class="windowbg2 centertext"> |
665 | 703 | ', $txt['draft_none'], ' |
666 | 704 | </div>'; |
667 | - else |
|
705 | + } else |
|
668 | 706 | { |
669 | 707 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
670 | 708 | foreach ($context['drafts'] as $draft) |
@@ -676,13 +714,15 @@ discard block |
||
676 | 714 | <h5> |
677 | 715 | <strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
678 | 716 | |
679 | - if (!empty($draft['sticky'])) |
|
680 | - echo ' |
|
717 | + if (!empty($draft['sticky'])) { |
|
718 | + echo ' |
|
681 | 719 | <span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
720 | + } |
|
682 | 721 | |
683 | - if (!empty($draft['locked'])) |
|
684 | - echo ' |
|
722 | + if (!empty($draft['locked'])) { |
|
723 | + echo ' |
|
685 | 724 | <span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
725 | + } |
|
686 | 726 | |
687 | 727 | echo ' |
688 | 728 | </h5> |
@@ -715,13 +755,13 @@ discard block |
||
715 | 755 | { |
716 | 756 | global $context, $scripturl, $txt; |
717 | 757 | |
718 | - if (!empty($context['saved_successful'])) |
|
719 | - echo ' |
|
758 | + if (!empty($context['saved_successful'])) { |
|
759 | + echo ' |
|
720 | 760 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
721 | - |
|
722 | - elseif (!empty($context['saved_failed'])) |
|
723 | - echo ' |
|
761 | + } elseif (!empty($context['saved_failed'])) { |
|
762 | + echo ' |
|
724 | 763 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
764 | + } |
|
725 | 765 | |
726 | 766 | echo ' |
727 | 767 | <div id="edit_buddies"> |
@@ -736,14 +776,16 @@ discard block |
||
736 | 776 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
737 | 777 | <th scope="col">', $txt['status'], '</th>'; |
738 | 778 | |
739 | - if (allowedTo('moderate_forum')) |
|
740 | - echo ' |
|
779 | + if (allowedTo('moderate_forum')) { |
|
780 | + echo ' |
|
741 | 781 | <th scope="col">', $txt['email'], '</th>'; |
782 | + } |
|
742 | 783 | |
743 | - if (!empty($context['custom_pf'])) |
|
744 | - foreach ($context['custom_pf'] as $column) |
|
784 | + if (!empty($context['custom_pf'])) { |
|
785 | + foreach ($context['custom_pf'] as $column) |
|
745 | 786 | echo ' |
746 | 787 | <th scope="col">', $column['label'], '</th>'; |
788 | + } |
|
747 | 789 | |
748 | 790 | echo ' |
749 | 791 | <th scope="col">', $txt['remove'], '</th> |
@@ -752,13 +794,14 @@ discard block |
||
752 | 794 | <tbody>'; |
753 | 795 | |
754 | 796 | // If they don't have any buddies don't list them! |
755 | - if (empty($context['buddies'])) |
|
756 | - echo ' |
|
797 | + if (empty($context['buddies'])) { |
|
798 | + echo ' |
|
757 | 799 | <tr class="windowbg"> |
758 | 800 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"> |
759 | 801 | <strong>', $txt['no_buddies'], '</strong> |
760 | 802 | </td> |
761 | 803 | </tr>'; |
804 | + } |
|
762 | 805 | |
763 | 806 | // Now loop through each buddy showing info on each. |
764 | 807 | else |
@@ -772,17 +815,19 @@ discard block |
||
772 | 815 | <a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a> |
773 | 816 | </td>'; |
774 | 817 | |
775 | - if ($buddy['show_email']) |
|
776 | - echo ' |
|
818 | + if ($buddy['show_email']) { |
|
819 | + echo ' |
|
777 | 820 | <td> |
778 | 821 | <a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a> |
779 | 822 | </td>'; |
823 | + } |
|
780 | 824 | |
781 | 825 | // Show the custom profile fields for this user. |
782 | - if (!empty($context['custom_pf'])) |
|
783 | - foreach ($context['custom_pf'] as $key => $column) |
|
826 | + if (!empty($context['custom_pf'])) { |
|
827 | + foreach ($context['custom_pf'] as $key => $column) |
|
784 | 828 | echo ' |
785 | 829 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
830 | + } |
|
786 | 831 | |
787 | 832 | echo ' |
788 | 833 | <td> |
@@ -815,9 +860,10 @@ discard block |
||
815 | 860 | </dl> |
816 | 861 | </div>'; |
817 | 862 | |
818 | - if (!empty($context['token_check'])) |
|
819 | - echo ' |
|
863 | + if (!empty($context['token_check'])) { |
|
864 | + echo ' |
|
820 | 865 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
866 | + } |
|
821 | 867 | |
822 | 868 | echo ' |
823 | 869 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -843,13 +889,13 @@ discard block |
||
843 | 889 | { |
844 | 890 | global $context, $scripturl, $txt; |
845 | 891 | |
846 | - if (!empty($context['saved_successful'])) |
|
847 | - echo ' |
|
892 | + if (!empty($context['saved_successful'])) { |
|
893 | + echo ' |
|
848 | 894 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
849 | - |
|
850 | - elseif (!empty($context['saved_failed'])) |
|
851 | - echo ' |
|
895 | + } elseif (!empty($context['saved_failed'])) { |
|
896 | + echo ' |
|
852 | 897 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
898 | + } |
|
853 | 899 | |
854 | 900 | echo ' |
855 | 901 | <div id="edit_buddies"> |
@@ -864,9 +910,10 @@ discard block |
||
864 | 910 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
865 | 911 | <th scope="col">', $txt['status'], '</th>'; |
866 | 912 | |
867 | - if (allowedTo('moderate_forum')) |
|
868 | - echo ' |
|
913 | + if (allowedTo('moderate_forum')) { |
|
914 | + echo ' |
|
869 | 915 | <th scope="col">', $txt['email'], '</th>'; |
916 | + } |
|
870 | 917 | |
871 | 918 | echo ' |
872 | 919 | <th scope="col">', $txt['ignore_remove'], '</th> |
@@ -875,13 +922,14 @@ discard block |
||
875 | 922 | <tbody>'; |
876 | 923 | |
877 | 924 | // If they don't have anyone on their ignore list, don't list it! |
878 | - if (empty($context['ignore_list'])) |
|
879 | - echo ' |
|
925 | + if (empty($context['ignore_list'])) { |
|
926 | + echo ' |
|
880 | 927 | <tr class="windowbg"> |
881 | 928 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"> |
882 | 929 | <strong>', $txt['no_ignore'], '</strong> |
883 | 930 | </td> |
884 | 931 | </tr>'; |
932 | + } |
|
885 | 933 | |
886 | 934 | // Now loop through each buddy showing info on each. |
887 | 935 | foreach ($context['ignore_list'] as $member) |
@@ -893,11 +941,12 @@ discard block |
||
893 | 941 | <a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a> |
894 | 942 | </td>'; |
895 | 943 | |
896 | - if ($member['show_email']) |
|
897 | - echo ' |
|
944 | + if ($member['show_email']) { |
|
945 | + echo ' |
|
898 | 946 | <td> |
899 | 947 | <a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a> |
900 | 948 | </td>'; |
949 | + } |
|
901 | 950 | echo ' |
902 | 951 | <td> |
903 | 952 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a> |
@@ -927,9 +976,10 @@ discard block |
||
927 | 976 | </dl> |
928 | 977 | </div>'; |
929 | 978 | |
930 | - if (!empty($context['token_check'])) |
|
931 | - echo ' |
|
979 | + if (!empty($context['token_check'])) { |
|
980 | + echo ' |
|
932 | 981 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
982 | + } |
|
933 | 983 | |
934 | 984 | echo ' |
935 | 985 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -975,9 +1025,10 @@ discard block |
||
975 | 1025 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
976 | 1026 | |
977 | 1027 | // Second address detected? |
978 | - if (!empty($context['last_ip2'])) |
|
979 | - echo ' |
|
1028 | + if (!empty($context['last_ip2'])) { |
|
1029 | + echo ' |
|
980 | 1030 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
1031 | + } |
|
981 | 1032 | |
982 | 1033 | echo ' |
983 | 1034 | </dd>'; |
@@ -1043,9 +1094,10 @@ discard block |
||
1043 | 1094 | </div> |
1044 | 1095 | <div class="windowbg2 noup">'; |
1045 | 1096 | |
1046 | - foreach ($context['whois_servers'] as $server) |
|
1047 | - echo ' |
|
1097 | + foreach ($context['whois_servers'] as $server) { |
|
1098 | + echo ' |
|
1048 | 1099 | <a href="', $server['url'], '" target="_blank"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>'; |
1100 | + } |
|
1049 | 1101 | echo ' |
1050 | 1102 | </div> |
1051 | 1103 | <br>'; |
@@ -1057,13 +1109,12 @@ discard block |
||
1057 | 1109 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
1058 | 1110 | </div>'; |
1059 | 1111 | |
1060 | - if (empty($context['ips'])) |
|
1061 | - echo ' |
|
1112 | + if (empty($context['ips'])) { |
|
1113 | + echo ' |
|
1062 | 1114 | <p class="windowbg2 description"> |
1063 | 1115 | <em>', $txt['no_members_from_ip'], '</em> |
1064 | 1116 | </p>'; |
1065 | - |
|
1066 | - else |
|
1117 | + } else |
|
1067 | 1118 | { |
1068 | 1119 | echo ' |
1069 | 1120 | <table class="table_grid"> |
@@ -1076,12 +1127,13 @@ discard block |
||
1076 | 1127 | <tbody>'; |
1077 | 1128 | |
1078 | 1129 | // Loop through each of the members and display them. |
1079 | - foreach ($context['ips'] as $ip => $memberlist) |
|
1080 | - echo ' |
|
1130 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
1131 | + echo ' |
|
1081 | 1132 | <tr class="windowbg"> |
1082 | 1133 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
1083 | 1134 | <td>', implode(', ', $memberlist), '</td> |
1084 | 1135 | </tr>'; |
1136 | + } |
|
1085 | 1137 | |
1086 | 1138 | echo ' |
1087 | 1139 | </tbody> |
@@ -1123,11 +1175,10 @@ discard block |
||
1123 | 1175 | </h3> |
1124 | 1176 | </div>'; |
1125 | 1177 | |
1126 | - if ($context['member']['has_all_permissions']) |
|
1127 | - echo ' |
|
1178 | + if ($context['member']['has_all_permissions']) { |
|
1179 | + echo ' |
|
1128 | 1180 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
1129 | - |
|
1130 | - else |
|
1181 | + } else |
|
1131 | 1182 | { |
1132 | 1183 | echo ' |
1133 | 1184 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1142,9 +1193,10 @@ discard block |
||
1142 | 1193 | <div class="windowbg smalltext"> |
1143 | 1194 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
1144 | 1195 | |
1145 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
1146 | - echo ' |
|
1196 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
1197 | + echo ' |
|
1147 | 1198 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
1199 | + } |
|
1148 | 1200 | echo ' |
1149 | 1201 | </div>'; |
1150 | 1202 | } |
@@ -1176,12 +1228,13 @@ discard block |
||
1176 | 1228 | </td> |
1177 | 1229 | <td class="smalltext">'; |
1178 | 1230 | |
1179 | - if ($permission['is_denied']) |
|
1180 | - echo ' |
|
1231 | + if ($permission['is_denied']) { |
|
1232 | + echo ' |
|
1181 | 1233 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1182 | - else |
|
1183 | - echo ' |
|
1234 | + } else { |
|
1235 | + echo ' |
|
1184 | 1236 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1237 | + } |
|
1185 | 1238 | |
1186 | 1239 | echo ' |
1187 | 1240 | </td> |
@@ -1192,10 +1245,10 @@ discard block |
||
1192 | 1245 | </table> |
1193 | 1246 | </div><!-- .tborder --> |
1194 | 1247 | <br>'; |
1195 | - } |
|
1196 | - else |
|
1197 | - echo ' |
|
1248 | + } else { |
|
1249 | + echo ' |
|
1198 | 1250 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
1251 | + } |
|
1199 | 1252 | |
1200 | 1253 | // Board permission section. |
1201 | 1254 | echo ' |
@@ -1206,14 +1259,16 @@ discard block |
||
1206 | 1259 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
1207 | 1260 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>'; |
1208 | 1261 | |
1209 | - if (!empty($context['boards'])) |
|
1210 | - echo ' |
|
1262 | + if (!empty($context['boards'])) { |
|
1263 | + echo ' |
|
1211 | 1264 | <option value="" disabled>---------------------------</option>'; |
1265 | + } |
|
1212 | 1266 | |
1213 | 1267 | // Fill the box with any local permission boards. |
1214 | - foreach ($context['boards'] as $board) |
|
1215 | - echo ' |
|
1268 | + foreach ($context['boards'] as $board) { |
|
1269 | + echo ' |
|
1216 | 1270 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
1271 | + } |
|
1217 | 1272 | |
1218 | 1273 | echo ' |
1219 | 1274 | </select> |
@@ -1242,13 +1297,13 @@ discard block |
||
1242 | 1297 | </td> |
1243 | 1298 | <td class="smalltext">'; |
1244 | 1299 | |
1245 | - if ($permission['is_denied']) |
|
1246 | - echo ' |
|
1300 | + if ($permission['is_denied']) { |
|
1301 | + echo ' |
|
1247 | 1302 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1248 | - |
|
1249 | - else |
|
1250 | - echo ' |
|
1303 | + } else { |
|
1304 | + echo ' |
|
1251 | 1305 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1306 | + } |
|
1252 | 1307 | |
1253 | 1308 | echo ' |
1254 | 1309 | </td> |
@@ -1257,10 +1312,10 @@ discard block |
||
1257 | 1312 | echo ' |
1258 | 1313 | </tbody> |
1259 | 1314 | </table>'; |
1260 | - } |
|
1261 | - else |
|
1262 | - echo ' |
|
1315 | + } else { |
|
1316 | + echo ' |
|
1263 | 1317 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
1318 | + } |
|
1264 | 1319 | echo ' |
1265 | 1320 | </div><!-- #permissions -->'; |
1266 | 1321 | } |
@@ -1301,9 +1356,10 @@ discard block |
||
1301 | 1356 | </div>'; |
1302 | 1357 | |
1303 | 1358 | // If they haven't post at all, don't draw the graph. |
1304 | - if (empty($context['posts_by_time'])) |
|
1305 | - echo ' |
|
1359 | + if (empty($context['posts_by_time'])) { |
|
1360 | + echo ' |
|
1306 | 1361 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1362 | + } |
|
1307 | 1363 | |
1308 | 1364 | // Otherwise do! |
1309 | 1365 | else |
@@ -1312,8 +1368,8 @@ discard block |
||
1312 | 1368 | <ul class="activity_stats flow_hidden">'; |
1313 | 1369 | |
1314 | 1370 | // The labels. |
1315 | - foreach ($context['posts_by_time'] as $time_of_day) |
|
1316 | - echo ' |
|
1371 | + foreach ($context['posts_by_time'] as $time_of_day) { |
|
1372 | + echo ' |
|
1317 | 1373 | <li', $time_of_day['is_last'] ? ' class="last"' : '', '> |
1318 | 1374 | <div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '"> |
1319 | 1375 | <div style="height: ', (int) $time_of_day['relative_percent'], 'px;"> |
@@ -1322,6 +1378,7 @@ discard block |
||
1322 | 1378 | </div> |
1323 | 1379 | <span class="stats_hour">', $time_of_day['hour_format'], '</span> |
1324 | 1380 | </li>'; |
1381 | + } |
|
1325 | 1382 | |
1326 | 1383 | echo ' |
1327 | 1384 | </ul>'; |
@@ -1340,11 +1397,10 @@ discard block |
||
1340 | 1397 | </h3> |
1341 | 1398 | </div>'; |
1342 | 1399 | |
1343 | - if (empty($context['popular_boards'])) |
|
1344 | - echo ' |
|
1400 | + if (empty($context['popular_boards'])) { |
|
1401 | + echo ' |
|
1345 | 1402 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1346 | - |
|
1347 | - else |
|
1403 | + } else |
|
1348 | 1404 | { |
1349 | 1405 | echo ' |
1350 | 1406 | <dl class="stats">'; |
@@ -1374,10 +1430,10 @@ discard block |
||
1374 | 1430 | </h3> |
1375 | 1431 | </div>'; |
1376 | 1432 | |
1377 | - if (empty($context['board_activity'])) |
|
1378 | - echo ' |
|
1433 | + if (empty($context['board_activity'])) { |
|
1434 | + echo ' |
|
1379 | 1435 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1380 | - else |
|
1436 | + } else |
|
1381 | 1437 | { |
1382 | 1438 | echo ' |
1383 | 1439 | <dl class="stats">'; |
@@ -1428,90 +1484,97 @@ discard block |
||
1428 | 1484 | <h3 class="catbg profile_hd">'; |
1429 | 1485 | |
1430 | 1486 | // Don't say "Profile" if this isn't the profile... |
1431 | - if (!empty($context['profile_header_text'])) |
|
1432 | - echo ' |
|
1487 | + if (!empty($context['profile_header_text'])) { |
|
1488 | + echo ' |
|
1433 | 1489 | ', $context['profile_header_text']; |
1434 | - else |
|
1435 | - echo ' |
|
1490 | + } else { |
|
1491 | + echo ' |
|
1436 | 1492 | ', $txt['profile']; |
1493 | + } |
|
1437 | 1494 | |
1438 | 1495 | echo ' |
1439 | 1496 | </h3> |
1440 | 1497 | </div>'; |
1441 | 1498 | |
1442 | 1499 | // Have we some description? |
1443 | - if ($context['page_desc']) |
|
1444 | - echo ' |
|
1500 | + if ($context['page_desc']) { |
|
1501 | + echo ' |
|
1445 | 1502 | <p class="information">', $context['page_desc'], '</p>'; |
1503 | + } |
|
1446 | 1504 | |
1447 | 1505 | echo ' |
1448 | 1506 | <div class="roundframe">'; |
1449 | 1507 | |
1450 | 1508 | // Any bits at the start? |
1451 | - if (!empty($context['profile_prehtml'])) |
|
1452 | - echo ' |
|
1509 | + if (!empty($context['profile_prehtml'])) { |
|
1510 | + echo ' |
|
1453 | 1511 | <div>', $context['profile_prehtml'], '</div>'; |
1512 | + } |
|
1454 | 1513 | |
1455 | - if (!empty($context['profile_fields'])) |
|
1456 | - echo ' |
|
1514 | + if (!empty($context['profile_fields'])) { |
|
1515 | + echo ' |
|
1457 | 1516 | <dl class="settings">'; |
1517 | + } |
|
1458 | 1518 | |
1459 | 1519 | // Start the big old loop 'of love. |
1460 | 1520 | $lastItem = 'hr'; |
1461 | 1521 | foreach ($context['profile_fields'] as $key => $field) |
1462 | 1522 | { |
1463 | 1523 | // We add a little hack to be sure we never get more than one hr in a row! |
1464 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
1465 | - continue; |
|
1524 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
1525 | + continue; |
|
1526 | + } |
|
1466 | 1527 | |
1467 | 1528 | $lastItem = $field['type']; |
1468 | - if ($field['type'] == 'hr') |
|
1469 | - echo ' |
|
1529 | + if ($field['type'] == 'hr') { |
|
1530 | + echo ' |
|
1470 | 1531 | </dl> |
1471 | 1532 | <hr> |
1472 | 1533 | <dl class="settings">'; |
1473 | - |
|
1474 | - elseif ($field['type'] == 'callback') |
|
1534 | + } elseif ($field['type'] == 'callback') |
|
1475 | 1535 | { |
1476 | 1536 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
1477 | 1537 | { |
1478 | 1538 | $callback_func = 'template_profile_' . $field['callback_func']; |
1479 | 1539 | $callback_func(); |
1480 | 1540 | } |
1481 | - } |
|
1482 | - else |
|
1541 | + } else |
|
1483 | 1542 | { |
1484 | 1543 | echo ' |
1485 | 1544 | <dt> |
1486 | 1545 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
1487 | 1546 | |
1488 | 1547 | // Does it have any subtext to show? |
1489 | - if (!empty($field['subtext'])) |
|
1490 | - echo ' |
|
1548 | + if (!empty($field['subtext'])) { |
|
1549 | + echo ' |
|
1491 | 1550 | <br> |
1492 | 1551 | <span class="smalltext">', $field['subtext'], '</span>'; |
1552 | + } |
|
1493 | 1553 | |
1494 | 1554 | echo ' |
1495 | 1555 | </dt> |
1496 | 1556 | <dd>'; |
1497 | 1557 | |
1498 | 1558 | // Want to put something infront of the box? |
1499 | - if (!empty($field['preinput'])) |
|
1500 | - echo ' |
|
1559 | + if (!empty($field['preinput'])) { |
|
1560 | + echo ' |
|
1501 | 1561 | ', $field['preinput']; |
1562 | + } |
|
1502 | 1563 | |
1503 | 1564 | // What type of data are we showing? |
1504 | - if ($field['type'] == 'label') |
|
1505 | - echo ' |
|
1565 | + if ($field['type'] == 'label') { |
|
1566 | + echo ' |
|
1506 | 1567 | ', $field['value']; |
1568 | + } |
|
1507 | 1569 | |
1508 | 1570 | // Maybe it's a text box - very likely! |
1509 | 1571 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
1510 | 1572 | { |
1511 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
1512 | - $type = 'number'; |
|
1513 | - else |
|
1514 | - $type = $field['type']; |
|
1573 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
1574 | + $type = 'number'; |
|
1575 | + } else { |
|
1576 | + $type = $field['type']; |
|
1577 | + } |
|
1515 | 1578 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
1516 | 1579 | |
1517 | 1580 | |
@@ -1519,10 +1582,11 @@ discard block |
||
1519 | 1582 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
1520 | 1583 | } |
1521 | 1584 | // You "checking" me out? ;) |
1522 | - elseif ($field['type'] == 'check') |
|
1523 | - echo ' |
|
1585 | + elseif ($field['type'] == 'check') { |
|
1586 | + echo ' |
|
1524 | 1587 | <input type="hidden" name="', $key, '" value="0"> |
1525 | 1588 | <input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
1589 | + } |
|
1526 | 1590 | |
1527 | 1591 | // Always fun - select boxes! |
1528 | 1592 | elseif ($field['type'] == 'select') |
@@ -1533,14 +1597,16 @@ discard block |
||
1533 | 1597 | if (isset($field['options'])) |
1534 | 1598 | { |
1535 | 1599 | // Is this some code to generate the options? |
1536 | - if (!is_array($field['options'])) |
|
1537 | - $field['options'] = $field['options'](); |
|
1600 | + if (!is_array($field['options'])) { |
|
1601 | + $field['options'] = $field['options'](); |
|
1602 | + } |
|
1538 | 1603 | |
1539 | 1604 | // Assuming we now have some! |
1540 | - if (is_array($field['options'])) |
|
1541 | - foreach ($field['options'] as $value => $name) |
|
1605 | + if (is_array($field['options'])) { |
|
1606 | + foreach ($field['options'] as $value => $name) |
|
1542 | 1607 | echo ' |
1543 | 1608 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
1609 | + } |
|
1544 | 1610 | } |
1545 | 1611 | |
1546 | 1612 | echo ' |
@@ -1548,31 +1614,34 @@ discard block |
||
1548 | 1614 | } |
1549 | 1615 | |
1550 | 1616 | // Something to end with? |
1551 | - if (!empty($field['postinput'])) |
|
1552 | - echo ' |
|
1617 | + if (!empty($field['postinput'])) { |
|
1618 | + echo ' |
|
1553 | 1619 | ', $field['postinput']; |
1620 | + } |
|
1554 | 1621 | |
1555 | 1622 | echo ' |
1556 | 1623 | </dd>'; |
1557 | 1624 | } |
1558 | 1625 | } |
1559 | 1626 | |
1560 | - if (!empty($context['profile_fields'])) |
|
1561 | - echo ' |
|
1627 | + if (!empty($context['profile_fields'])) { |
|
1628 | + echo ' |
|
1562 | 1629 | </dl>'; |
1630 | + } |
|
1563 | 1631 | |
1564 | 1632 | // Are there any custom profile fields - if so print them! |
1565 | 1633 | if (!empty($context['custom_fields'])) |
1566 | 1634 | { |
1567 | - if ($lastItem != 'hr') |
|
1568 | - echo ' |
|
1635 | + if ($lastItem != 'hr') { |
|
1636 | + echo ' |
|
1569 | 1637 | <hr>'; |
1638 | + } |
|
1570 | 1639 | |
1571 | 1640 | echo ' |
1572 | 1641 | <dl class="settings">'; |
1573 | 1642 | |
1574 | - foreach ($context['custom_fields'] as $field) |
|
1575 | - echo ' |
|
1643 | + foreach ($context['custom_fields'] as $field) { |
|
1644 | + echo ' |
|
1576 | 1645 | <dt> |
1577 | 1646 | <strong>', $field['name'], ': </strong><br> |
1578 | 1647 | <span class="smalltext">', $field['desc'], '</span> |
@@ -1580,6 +1649,7 @@ discard block |
||
1580 | 1649 | <dd> |
1581 | 1650 | ', $field['input_html'], ' |
1582 | 1651 | </dd>'; |
1652 | + } |
|
1583 | 1653 | |
1584 | 1654 | echo ' |
1585 | 1655 | </dl>'; |
@@ -1587,13 +1657,14 @@ discard block |
||
1587 | 1657 | } |
1588 | 1658 | |
1589 | 1659 | // Any closing HTML? |
1590 | - if (!empty($context['profile_posthtml'])) |
|
1591 | - echo ' |
|
1660 | + if (!empty($context['profile_posthtml'])) { |
|
1661 | + echo ' |
|
1592 | 1662 | <div>', $context['profile_posthtml'], '</div>'; |
1663 | + } |
|
1593 | 1664 | |
1594 | 1665 | // Only show the password box if it's actually needed. |
1595 | - if ($context['require_password']) |
|
1596 | - echo ' |
|
1666 | + if ($context['require_password']) { |
|
1667 | + echo ' |
|
1597 | 1668 | <dl class="settings"> |
1598 | 1669 | <dt> |
1599 | 1670 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1603,18 +1674,21 @@ discard block |
||
1603 | 1674 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20"> |
1604 | 1675 | </dd> |
1605 | 1676 | </dl>'; |
1677 | + } |
|
1606 | 1678 | |
1607 | 1679 | // The button shouldn't say "Change profile" unless we're changing the profile... |
1608 | - if (!empty($context['submit_button_text'])) |
|
1609 | - echo ' |
|
1680 | + if (!empty($context['submit_button_text'])) { |
|
1681 | + echo ' |
|
1610 | 1682 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">'; |
1611 | - else |
|
1612 | - echo ' |
|
1683 | + } else { |
|
1684 | + echo ' |
|
1613 | 1685 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button">'; |
1686 | + } |
|
1614 | 1687 | |
1615 | - if (!empty($context['token_check'])) |
|
1616 | - echo ' |
|
1688 | + if (!empty($context['token_check'])) { |
|
1689 | + echo ' |
|
1617 | 1690 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
1691 | + } |
|
1618 | 1692 | |
1619 | 1693 | echo ' |
1620 | 1694 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1624,10 +1698,11 @@ discard block |
||
1624 | 1698 | </form>'; |
1625 | 1699 | |
1626 | 1700 | // Any final spellchecking stuff? |
1627 | - if (!empty($context['show_spellchecking'])) |
|
1628 | - echo ' |
|
1701 | + if (!empty($context['show_spellchecking'])) { |
|
1702 | + echo ' |
|
1629 | 1703 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
1630 | -} |
|
1704 | + } |
|
1705 | + } |
|
1631 | 1706 | |
1632 | 1707 | /** |
1633 | 1708 | * Personal Message settings. |
@@ -1664,10 +1739,11 @@ discard block |
||
1664 | 1739 | <select name="pm_receive_from" id="pm_receive_from"> |
1665 | 1740 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
1666 | 1741 | |
1667 | - if (!empty($modSettings['enable_buddylist'])) |
|
1668 | - echo ' |
|
1742 | + if (!empty($modSettings['enable_buddylist'])) { |
|
1743 | + echo ' |
|
1669 | 1744 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
1670 | 1745 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
1746 | + } |
|
1671 | 1747 | |
1672 | 1748 | echo ' |
1673 | 1749 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1710,11 +1786,12 @@ discard block |
||
1710 | 1786 | if (empty($setting) || !is_array($setting)) |
1711 | 1787 | { |
1712 | 1788 | // Insert a separator (unless this is the first item in the list) |
1713 | - if ($i !== $first_option_key) |
|
1714 | - echo ' |
|
1789 | + if ($i !== $first_option_key) { |
|
1790 | + echo ' |
|
1715 | 1791 | </dl> |
1716 | 1792 | <hr> |
1717 | 1793 | <dl class="settings">'; |
1794 | + } |
|
1718 | 1795 | |
1719 | 1796 | // Should we give a name to this section? |
1720 | 1797 | if (is_string($setting) && !empty($setting)) |
@@ -1723,69 +1800,67 @@ discard block |
||
1723 | 1800 | echo ' |
1724 | 1801 | <dt><strong>' . $setting . '</strong></dt> |
1725 | 1802 | <dd></dd>'; |
1803 | + } else { |
|
1804 | + $titled_section = false; |
|
1726 | 1805 | } |
1727 | - else |
|
1728 | - $titled_section = false; |
|
1729 | 1806 | |
1730 | 1807 | continue; |
1731 | 1808 | } |
1732 | 1809 | |
1733 | 1810 | // Is this disabled? |
1734 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
1735 | - continue; |
|
1736 | - |
|
1737 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
1738 | - continue; |
|
1739 | - |
|
1740 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
1741 | - continue; |
|
1742 | - |
|
1743 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
1744 | - continue; |
|
1745 | - |
|
1746 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
1747 | - continue; |
|
1748 | - |
|
1749 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
1750 | - continue; |
|
1751 | - |
|
1752 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
1753 | - continue; |
|
1811 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
1812 | + continue; |
|
1813 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
1814 | + continue; |
|
1815 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
1816 | + continue; |
|
1817 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
1818 | + continue; |
|
1819 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
1820 | + continue; |
|
1821 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
1822 | + continue; |
|
1823 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
1824 | + continue; |
|
1825 | + } |
|
1754 | 1826 | |
1755 | 1827 | // Some of these may not be set... Set to defaults here |
1756 | 1828 | $opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod'); |
1757 | - if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) |
|
1758 | - $context['member']['options'][$setting['id']] = 0; |
|
1759 | - |
|
1760 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
1761 | - $setting['type'] = 'checkbox'; |
|
1762 | - |
|
1763 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
1764 | - $setting['type'] = 'number'; |
|
1829 | + if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) { |
|
1830 | + $context['member']['options'][$setting['id']] = 0; |
|
1831 | + } |
|
1765 | 1832 | |
1766 | - elseif ($setting['type'] == 'string') |
|
1767 | - $setting['type'] = 'text'; |
|
1833 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
1834 | + $setting['type'] = 'checkbox'; |
|
1835 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
1836 | + $setting['type'] = 'number'; |
|
1837 | + } elseif ($setting['type'] == 'string') { |
|
1838 | + $setting['type'] = 'text'; |
|
1839 | + } |
|
1768 | 1840 | |
1769 | - if (isset($setting['options'])) |
|
1770 | - $setting['type'] = 'list'; |
|
1841 | + if (isset($setting['options'])) { |
|
1842 | + $setting['type'] = 'list'; |
|
1843 | + } |
|
1771 | 1844 | |
1772 | 1845 | echo ' |
1773 | 1846 | <dt> |
1774 | 1847 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
1775 | 1848 | |
1776 | - if (isset($setting['description'])) |
|
1777 | - echo ' |
|
1849 | + if (isset($setting['description'])) { |
|
1850 | + echo ' |
|
1778 | 1851 | <br> |
1779 | 1852 | <span class="smalltext">', $setting['description'], '</span>'; |
1853 | + } |
|
1780 | 1854 | echo ' |
1781 | 1855 | </dt> |
1782 | 1856 | <dd>'; |
1783 | 1857 | |
1784 | 1858 | // Display checkbox options |
1785 | - if ($setting['type'] == 'checkbox') |
|
1786 | - echo ' |
|
1859 | + if ($setting['type'] == 'checkbox') { |
|
1860 | + echo ' |
|
1787 | 1861 | <input type="hidden" name="default_options[' . $setting['id'] . ']" value="0"> |
1788 | 1862 | <input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">'; |
1863 | + } |
|
1789 | 1864 | |
1790 | 1865 | // How about selection lists, we all love them |
1791 | 1866 | elseif ($setting['type'] == 'list') |
@@ -1793,9 +1868,10 @@ discard block |
||
1793 | 1868 | echo ' |
1794 | 1869 | <select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>'; |
1795 | 1870 | |
1796 | - foreach ($setting['options'] as $value => $label) |
|
1797 | - echo ' |
|
1871 | + foreach ($setting['options'] as $value => $label) { |
|
1872 | + echo ' |
|
1798 | 1873 | <option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>'; |
1874 | + } |
|
1799 | 1875 | |
1800 | 1876 | echo ' |
1801 | 1877 | </select>'; |
@@ -1811,14 +1887,13 @@ discard block |
||
1811 | 1887 | |
1812 | 1888 | echo ' |
1813 | 1889 | <input type="number"', $min . $max . $step; |
1814 | - } |
|
1815 | - elseif (isset($setting['type']) && $setting['type'] == 'url') |
|
1816 | - echo' |
|
1890 | + } elseif (isset($setting['type']) && $setting['type'] == 'url') { |
|
1891 | + echo' |
|
1817 | 1892 | <input type="url"'; |
1818 | - |
|
1819 | - else |
|
1820 | - echo ' |
|
1893 | + } else { |
|
1894 | + echo ' |
|
1821 | 1895 | <input type="text"'; |
1896 | + } |
|
1822 | 1897 | |
1823 | 1898 | echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>'; |
1824 | 1899 | } |
@@ -1855,8 +1930,8 @@ discard block |
||
1855 | 1930 | <dl class="settings">'; |
1856 | 1931 | |
1857 | 1932 | // Allow notification on announcements to be disabled? |
1858 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
1859 | - echo ' |
|
1933 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
1934 | + echo ' |
|
1860 | 1935 | <dt> |
1861 | 1936 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
1862 | 1937 | </dt> |
@@ -1864,15 +1939,17 @@ discard block |
||
1864 | 1939 | <input type="hidden" name="notify_announcements" value="0"> |
1865 | 1940 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
1866 | 1941 | </dd>'; |
1942 | + } |
|
1867 | 1943 | |
1868 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
1869 | - echo ' |
|
1944 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
1945 | + echo ' |
|
1870 | 1946 | <dt> |
1871 | 1947 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
1872 | 1948 | </dt> |
1873 | 1949 | <dd> |
1874 | 1950 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
1875 | 1951 | </dd>'; |
1952 | + } |
|
1876 | 1953 | |
1877 | 1954 | echo ' |
1878 | 1955 | </dl> |
@@ -1904,9 +1981,10 @@ discard block |
||
1904 | 1981 | |
1905 | 1982 | $label = $txt['alert_opt_' . $opts[1]]; |
1906 | 1983 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
1907 | - if ($label_pos == 'before') |
|
1908 | - echo ' |
|
1984 | + if ($label_pos == 'before') { |
|
1985 | + echo ' |
|
1909 | 1986 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
1987 | + } |
|
1910 | 1988 | |
1911 | 1989 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
1912 | 1990 | switch ($opts[0]) |
@@ -1920,17 +1998,19 @@ discard block |
||
1920 | 1998 | echo ' |
1921 | 1999 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
1922 | 2000 | |
1923 | - foreach ($opts['opts'] as $k => $v) |
|
1924 | - echo ' |
|
2001 | + foreach ($opts['opts'] as $k => $v) { |
|
2002 | + echo ' |
|
1925 | 2003 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
2004 | + } |
|
1926 | 2005 | echo ' |
1927 | 2006 | </select>'; |
1928 | 2007 | break; |
1929 | 2008 | } |
1930 | 2009 | |
1931 | - if ($label_pos == 'after') |
|
1932 | - echo ' |
|
2010 | + if ($label_pos == 'after') { |
|
2011 | + echo ' |
|
1933 | 2012 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
2013 | + } |
|
1934 | 2014 | |
1935 | 2015 | echo ' |
1936 | 2016 | </td> |
@@ -2047,11 +2127,12 @@ discard block |
||
2047 | 2127 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
2048 | 2128 | |
2049 | 2129 | // Do we have an update message? |
2050 | - if (!empty($context['update_message'])) |
|
2051 | - echo ' |
|
2130 | + if (!empty($context['update_message'])) { |
|
2131 | + echo ' |
|
2052 | 2132 | <div class="infobox"> |
2053 | 2133 | ', $context['update_message'], '. |
2054 | 2134 | </div>'; |
2135 | + } |
|
2055 | 2136 | |
2056 | 2137 | echo ' |
2057 | 2138 | <div id="groups">'; |
@@ -2073,8 +2154,7 @@ discard block |
||
2073 | 2154 | </div> |
2074 | 2155 | </div> |
2075 | 2156 | </div><!-- .groupmembership -->'; |
2076 | - } |
|
2077 | - else |
|
2157 | + } else |
|
2078 | 2158 | { |
2079 | 2159 | echo ' |
2080 | 2160 | <div class="title_bar"> |
@@ -2086,27 +2166,30 @@ discard block |
||
2086 | 2166 | echo ' |
2087 | 2167 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
2088 | 2168 | |
2089 | - if ($context['can_edit_primary']) |
|
2090 | - echo ' |
|
2169 | + if ($context['can_edit_primary']) { |
|
2170 | + echo ' |
|
2091 | 2171 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>'; |
2172 | + } |
|
2092 | 2173 | |
2093 | 2174 | echo ' |
2094 | 2175 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
2095 | 2176 | |
2096 | 2177 | // Can they leave their group? |
2097 | - if ($group['can_leave']) |
|
2098 | - echo ' |
|
2178 | + if ($group['can_leave']) { |
|
2179 | + echo ' |
|
2099 | 2180 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
2181 | + } |
|
2100 | 2182 | |
2101 | 2183 | echo ' |
2102 | 2184 | </div><!-- .windowbg -->'; |
2103 | 2185 | } |
2104 | 2186 | |
2105 | - if ($context['can_edit_primary']) |
|
2106 | - echo ' |
|
2187 | + if ($context['can_edit_primary']) { |
|
2188 | + echo ' |
|
2107 | 2189 | <div class="padding righttext"> |
2108 | 2190 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
2109 | 2191 | </div>'; |
2192 | + } |
|
2110 | 2193 | |
2111 | 2194 | // Any groups they can join? |
2112 | 2195 | if (!empty($context['groups']['available'])) |
@@ -2122,17 +2205,16 @@ discard block |
||
2122 | 2205 | <div class="windowbg"> |
2123 | 2206 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
2124 | 2207 | |
2125 | - if ($group['type'] == 3) |
|
2126 | - echo ' |
|
2208 | + if ($group['type'] == 3) { |
|
2209 | + echo ' |
|
2127 | 2210 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
2128 | - |
|
2129 | - elseif ($group['type'] == 2 && $group['pending']) |
|
2130 | - echo ' |
|
2211 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
2212 | + echo ' |
|
2131 | 2213 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
2132 | - |
|
2133 | - elseif ($group['type'] == 2) |
|
2134 | - echo ' |
|
2214 | + } elseif ($group['type'] == 2) { |
|
2215 | + echo ' |
|
2135 | 2216 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
2217 | + } |
|
2136 | 2218 | |
2137 | 2219 | echo ' |
2138 | 2220 | </div><!-- .windowbg -->'; |
@@ -2155,9 +2237,10 @@ discard block |
||
2155 | 2237 | |
2156 | 2238 | prevDiv.className = "windowbg"; |
2157 | 2239 | }'; |
2158 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
2159 | - echo ' |
|
2240 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
2241 | + echo ' |
|
2160 | 2242 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
2243 | + } |
|
2161 | 2244 | |
2162 | 2245 | echo ' |
2163 | 2246 | </script>'; |
@@ -2166,9 +2249,10 @@ discard block |
||
2166 | 2249 | echo ' |
2167 | 2250 | </div><!-- #groups -->'; |
2168 | 2251 | |
2169 | - if (!empty($context['token_check'])) |
|
2170 | - echo ' |
|
2252 | + if (!empty($context['token_check'])) { |
|
2253 | + echo ' |
|
2171 | 2254 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2255 | + } |
|
2172 | 2256 | |
2173 | 2257 | echo ' |
2174 | 2258 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2216,14 +2300,15 @@ discard block |
||
2216 | 2300 | |
2217 | 2301 | foreach ($category['boards'] as $board) |
2218 | 2302 | { |
2219 | - if ($i == $limit) |
|
2220 | - echo ' |
|
2303 | + if ($i == $limit) { |
|
2304 | + echo ' |
|
2221 | 2305 | </ul> |
2222 | 2306 | </li> |
2223 | 2307 | </ul> |
2224 | 2308 | <ul class="ignoreboards floatright"> |
2225 | 2309 | <li class="category"> |
2226 | 2310 | <ul>'; |
2311 | + } |
|
2227 | 2312 | |
2228 | 2313 | echo ' |
2229 | 2314 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2269,10 +2354,11 @@ discard block |
||
2269 | 2354 | |
2270 | 2355 | // Work out the starting color. |
2271 | 2356 | $context['current_color'] = $context['colors'][0]; |
2272 | - foreach ($context['colors'] as $limit => $color) |
|
2273 | - if ($context['member']['warning'] >= $limit) |
|
2357 | + foreach ($context['colors'] as $limit => $color) { |
|
2358 | + if ($context['member']['warning'] >= $limit) |
|
2274 | 2359 | $context['current_color'] = $color; |
2275 | -} |
|
2360 | + } |
|
2361 | + } |
|
2276 | 2362 | |
2277 | 2363 | // Show all warnings of a user? |
2278 | 2364 | function template_viewWarning() |
@@ -2311,14 +2397,15 @@ discard block |
||
2311 | 2397 | </dd>'; |
2312 | 2398 | |
2313 | 2399 | // There's some impact of this? |
2314 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
2315 | - echo ' |
|
2400 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
2401 | + echo ' |
|
2316 | 2402 | <dt> |
2317 | 2403 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
2318 | 2404 | </dt> |
2319 | 2405 | <dd> |
2320 | 2406 | ', $context['level_effects'][$context['current_level']], ' |
2321 | 2407 | </dd>'; |
2408 | + } |
|
2322 | 2409 | |
2323 | 2410 | echo ' |
2324 | 2411 | </dl> |
@@ -2356,10 +2443,11 @@ discard block |
||
2356 | 2443 | |
2357 | 2444 | // Otherwise see what we can do...'; |
2358 | 2445 | |
2359 | - foreach ($context['notification_templates'] as $k => $type) |
|
2360 | - echo ' |
|
2446 | + foreach ($context['notification_templates'] as $k => $type) { |
|
2447 | + echo ' |
|
2361 | 2448 | if (index == ', $k, ') |
2362 | 2449 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
2450 | + } |
|
2363 | 2451 | |
2364 | 2452 | echo ' |
2365 | 2453 | } |
@@ -2369,10 +2457,11 @@ discard block |
||
2369 | 2457 | // Also set the right effect. |
2370 | 2458 | effectText = "";'; |
2371 | 2459 | |
2372 | - foreach ($context['level_effects'] as $limit => $text) |
|
2373 | - echo ' |
|
2460 | + foreach ($context['level_effects'] as $limit => $text) { |
|
2461 | + echo ' |
|
2374 | 2462 | if (slideAmount >= ', $limit, ') |
2375 | 2463 | effectText = "', $text, '";'; |
2464 | + } |
|
2376 | 2465 | |
2377 | 2466 | echo ' |
2378 | 2467 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2387,32 +2476,35 @@ discard block |
||
2387 | 2476 | </h3> |
2388 | 2477 | </div>'; |
2389 | 2478 | |
2390 | - if (!$context['user']['is_owner']) |
|
2391 | - echo ' |
|
2479 | + if (!$context['user']['is_owner']) { |
|
2480 | + echo ' |
|
2392 | 2481 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
2482 | + } |
|
2393 | 2483 | |
2394 | 2484 | echo ' |
2395 | 2485 | <div class="windowbg"> |
2396 | 2486 | <dl class="settings">'; |
2397 | 2487 | |
2398 | - if (!$context['user']['is_owner']) |
|
2399 | - echo ' |
|
2488 | + if (!$context['user']['is_owner']) { |
|
2489 | + echo ' |
|
2400 | 2490 | <dt> |
2401 | 2491 | <strong>', $txt['profile_warning_name'], ':</strong> |
2402 | 2492 | </dt> |
2403 | 2493 | <dd> |
2404 | 2494 | <strong>', $context['member']['name'], '</strong> |
2405 | 2495 | </dd>'; |
2496 | + } |
|
2406 | 2497 | |
2407 | 2498 | echo ' |
2408 | 2499 | <dt> |
2409 | 2500 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
2410 | 2501 | |
2411 | 2502 | // Is there only so much they can apply? |
2412 | - if ($context['warning_limit']) |
|
2413 | - echo ' |
|
2503 | + if ($context['warning_limit']) { |
|
2504 | + echo ' |
|
2414 | 2505 | <br> |
2415 | 2506 | <span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
2507 | + } |
|
2416 | 2508 | |
2417 | 2509 | echo ' |
2418 | 2510 | </dt> |
@@ -2467,9 +2559,10 @@ discard block |
||
2467 | 2559 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
2468 | 2560 | <option value="-1" disabled>------------------------------</option>'; |
2469 | 2561 | |
2470 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
2471 | - echo ' |
|
2562 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
2563 | + echo ' |
|
2472 | 2564 | <option value="', $id_template, '">', $template['title'], '</option>'; |
2565 | + } |
|
2473 | 2566 | |
2474 | 2567 | echo ' |
2475 | 2568 | </select> |
@@ -2482,9 +2575,10 @@ discard block |
||
2482 | 2575 | </dl> |
2483 | 2576 | <div class="righttext">'; |
2484 | 2577 | |
2485 | - if (!empty($context['token_check'])) |
|
2486 | - echo ' |
|
2578 | + if (!empty($context['token_check'])) { |
|
2579 | + echo ' |
|
2487 | 2580 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2581 | + } |
|
2488 | 2582 | |
2489 | 2583 | echo ' |
2490 | 2584 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2500,8 +2594,8 @@ discard block |
||
2500 | 2594 | echo ' |
2501 | 2595 | <script>'; |
2502 | 2596 | |
2503 | - if (!$context['user']['is_owner']) |
|
2504 | - echo ' |
|
2597 | + if (!$context['user']['is_owner']) { |
|
2598 | + echo ' |
|
2505 | 2599 | modifyWarnNotify(); |
2506 | 2600 | $(document).ready(function() { |
2507 | 2601 | $("#preview_button").click(function() { |
@@ -2540,6 +2634,7 @@ discard block |
||
2540 | 2634 | }); |
2541 | 2635 | return false; |
2542 | 2636 | }'; |
2637 | + } |
|
2543 | 2638 | |
2544 | 2639 | echo ' |
2545 | 2640 | </script>'; |
@@ -2562,17 +2657,19 @@ discard block |
||
2562 | 2657 | </div>'; |
2563 | 2658 | |
2564 | 2659 | // If deleting another account give them a lovely info box. |
2565 | - if (!$context['user']['is_owner']) |
|
2566 | - echo ' |
|
2660 | + if (!$context['user']['is_owner']) { |
|
2661 | + echo ' |
|
2567 | 2662 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
2663 | + } |
|
2568 | 2664 | |
2569 | 2665 | echo ' |
2570 | 2666 | <div class="windowbg2">'; |
2571 | 2667 | |
2572 | 2668 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
2573 | - if ($context['needs_approval']) |
|
2574 | - echo ' |
|
2669 | + if ($context['needs_approval']) { |
|
2670 | + echo ' |
|
2575 | 2671 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
2672 | + } |
|
2576 | 2673 | |
2577 | 2674 | // If the user is deleting their own account warn them first - and require a password! |
2578 | 2675 | if ($context['user']['is_owner']) |
@@ -2584,9 +2681,10 @@ discard block |
||
2584 | 2681 | <input type="password" name="oldpasswrd" size="20"> |
2585 | 2682 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
2586 | 2683 | |
2587 | - if (!empty($context['token_check'])) |
|
2588 | - echo ' |
|
2684 | + if (!empty($context['token_check'])) { |
|
2685 | + echo ' |
|
2589 | 2686 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2687 | + } |
|
2590 | 2688 | |
2591 | 2689 | echo ' |
2592 | 2690 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2616,10 +2714,11 @@ discard block |
||
2616 | 2714 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
2617 | 2715 | </select>'; |
2618 | 2716 | |
2619 | - if ($context['show_perma_delete']) |
|
2620 | - echo ' |
|
2717 | + if ($context['show_perma_delete']) { |
|
2718 | + echo ' |
|
2621 | 2719 | <br> |
2622 | 2720 | <label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
2721 | + } |
|
2623 | 2722 | |
2624 | 2723 | echo ' |
2625 | 2724 | </div>'; |
@@ -2632,9 +2731,10 @@ discard block |
||
2632 | 2731 | <div> |
2633 | 2732 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
2634 | 2733 | |
2635 | - if (!empty($context['token_check'])) |
|
2636 | - echo ' |
|
2734 | + if (!empty($context['token_check'])) { |
|
2735 | + echo ' |
|
2637 | 2736 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2737 | + } |
|
2638 | 2738 | |
2639 | 2739 | echo ' |
2640 | 2740 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2660,8 +2760,8 @@ discard block |
||
2660 | 2760 | <hr>'; |
2661 | 2761 | |
2662 | 2762 | // Only show the password box if it's actually needed. |
2663 | - if ($context['require_password']) |
|
2664 | - echo ' |
|
2763 | + if ($context['require_password']) { |
|
2764 | + echo ' |
|
2665 | 2765 | <dl class="settings"> |
2666 | 2766 | <dt> |
2667 | 2767 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2671,13 +2771,15 @@ discard block |
||
2671 | 2771 | <input type="password" name="oldpasswrd" size="20"> |
2672 | 2772 | </dd> |
2673 | 2773 | </dl>'; |
2774 | + } |
|
2674 | 2775 | |
2675 | 2776 | echo ' |
2676 | 2777 | <div class="righttext">'; |
2677 | 2778 | |
2678 | - if (!empty($context['token_check'])) |
|
2679 | - echo ' |
|
2779 | + if (!empty($context['token_check'])) { |
|
2780 | + echo ' |
|
2680 | 2781 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2782 | + } |
|
2681 | 2783 | |
2682 | 2784 | echo ' |
2683 | 2785 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2704,9 +2806,10 @@ discard block |
||
2704 | 2806 | <ul id="list_errors">'; |
2705 | 2807 | |
2706 | 2808 | // Cycle through each error and display an error message. |
2707 | - foreach ($context['post_errors'] as $error) |
|
2708 | - echo ' |
|
2809 | + foreach ($context['post_errors'] as $error) { |
|
2810 | + echo ' |
|
2709 | 2811 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
2812 | + } |
|
2710 | 2813 | |
2711 | 2814 | echo ' |
2712 | 2815 | </ul>'; |
@@ -2732,12 +2835,13 @@ discard block |
||
2732 | 2835 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
2733 | 2836 | |
2734 | 2837 | // Fill the select box with all primary member groups that can be assigned to a member. |
2735 | - foreach ($context['member_groups'] as $member_group) |
|
2736 | - if (!empty($member_group['can_be_primary'])) |
|
2838 | + foreach ($context['member_groups'] as $member_group) { |
|
2839 | + if (!empty($member_group['can_be_primary'])) |
|
2737 | 2840 | echo ' |
2738 | 2841 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
2739 | 2842 | ', $member_group['name'], ' |
2740 | 2843 | </option>'; |
2844 | + } |
|
2741 | 2845 | |
2742 | 2846 | echo ' |
2743 | 2847 | </select> |
@@ -2750,10 +2854,11 @@ discard block |
||
2750 | 2854 | <input type="hidden" name="additional_groups[]" value="0">'; |
2751 | 2855 | |
2752 | 2856 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
2753 | - foreach ($context['member_groups'] as $member_group) |
|
2754 | - if ($member_group['can_be_additional']) |
|
2857 | + foreach ($context['member_groups'] as $member_group) { |
|
2858 | + if ($member_group['can_be_additional']) |
|
2755 | 2859 | echo ' |
2756 | 2860 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>'; |
2861 | + } |
|
2757 | 2862 | |
2758 | 2863 | echo ' |
2759 | 2864 | </span> |
@@ -2813,9 +2918,10 @@ discard block |
||
2813 | 2918 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
2814 | 2919 | <br>'; |
2815 | 2920 | |
2816 | - if ($context['show_spellchecking']) |
|
2817 | - echo ' |
|
2921 | + if ($context['show_spellchecking']) { |
|
2922 | + echo ' |
|
2818 | 2923 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
2924 | + } |
|
2819 | 2925 | |
2820 | 2926 | echo ' |
2821 | 2927 | </dt> |
@@ -2823,17 +2929,20 @@ discard block |
||
2823 | 2929 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>'; |
2824 | 2930 | |
2825 | 2931 | // If there is a limit at all! |
2826 | - if (!empty($context['signature_limits']['max_length'])) |
|
2827 | - echo ' |
|
2932 | + if (!empty($context['signature_limits']['max_length'])) { |
|
2933 | + echo ' |
|
2828 | 2934 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
2935 | + } |
|
2829 | 2936 | |
2830 | - if (!empty($context['show_preview_button'])) |
|
2831 | - echo ' |
|
2937 | + if (!empty($context['show_preview_button'])) { |
|
2938 | + echo ' |
|
2832 | 2939 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">'; |
2940 | + } |
|
2833 | 2941 | |
2834 | - if ($context['signature_warning']) |
|
2835 | - echo ' |
|
2942 | + if ($context['signature_warning']) { |
|
2943 | + echo ' |
|
2836 | 2944 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
2945 | + } |
|
2837 | 2946 | |
2838 | 2947 | // Some javascript used to count how many characters have been used so far in the signature. |
2839 | 2948 | echo ' |
@@ -2878,9 +2987,10 @@ discard block |
||
2878 | 2987 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
2879 | 2988 | |
2880 | 2989 | // This lists all the file categories. |
2881 | - foreach ($context['avatars'] as $avatar) |
|
2882 | - echo ' |
|
2990 | + foreach ($context['avatars'] as $avatar) { |
|
2991 | + echo ' |
|
2883 | 2992 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
2993 | + } |
|
2884 | 2994 | |
2885 | 2995 | echo ' |
2886 | 2996 | </select> |
@@ -2912,20 +3022,22 @@ discard block |
||
2912 | 3022 | } |
2913 | 3023 | |
2914 | 3024 | // If the user can link to an off server avatar, show them a box to input the address. |
2915 | - if (!empty($context['member']['avatar']['allow_external'])) |
|
2916 | - echo ' |
|
3025 | + if (!empty($context['member']['avatar']['allow_external'])) { |
|
3026 | + echo ' |
|
2917 | 3027 | <div id="avatar_external"> |
2918 | 3028 | <div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', ' |
2919 | 3029 | <input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);"> |
2920 | 3030 | </div>'; |
3031 | + } |
|
2921 | 3032 | |
2922 | 3033 | // If the user is able to upload avatars to the server show them an upload box. |
2923 | - if (!empty($context['member']['avatar']['allow_upload'])) |
|
2924 | - echo ' |
|
3034 | + if (!empty($context['member']['avatar']['allow_upload'])) { |
|
3035 | + echo ' |
|
2925 | 3036 | <div id="avatar_upload"> |
2926 | 3037 | <input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), ' |
2927 | 3038 | ', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), ' |
2928 | 3039 | </div>'; |
3040 | + } |
|
2929 | 3041 | |
2930 | 3042 | // if the user is able to use Gravatar avatars show then the image preview |
2931 | 3043 | if (!empty($context['member']['avatar']['allow_gravatar'])) |
@@ -2934,16 +3046,17 @@ discard block |
||
2934 | 3046 | <div id="avatar_gravatar"> |
2935 | 3047 | <img src="' . $context['member']['avatar']['href'] . '" alt="">'; |
2936 | 3048 | |
2937 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
2938 | - echo ' |
|
3049 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3050 | + echo ' |
|
2939 | 3051 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
2940 | - else |
|
3052 | + } else |
|
2941 | 3053 | { |
2942 | 3054 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
2943 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
2944 | - $textbox_value = ''; |
|
2945 | - else |
|
2946 | - $textbox_value = $context['member']['avatar']['external']; |
|
3055 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
3056 | + $textbox_value = ''; |
|
3057 | + } else { |
|
3058 | + $textbox_value = $context['member']['avatar']['external']; |
|
3059 | + } |
|
2947 | 3060 | |
2948 | 3061 | echo ' |
2949 | 3062 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -3015,8 +3128,9 @@ discard block |
||
3015 | 3128 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
3016 | 3129 | |
3017 | 3130 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
3018 | - if (empty($suffix)) |
|
3019 | - return; |
|
3131 | + if (empty($suffix)) { |
|
3132 | + return; |
|
3133 | + } |
|
3020 | 3134 | |
3021 | 3135 | echo ' |
3022 | 3136 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -3041,9 +3155,10 @@ discard block |
||
3041 | 3155 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">'; |
3042 | 3156 | |
3043 | 3157 | // Help the user by showing a list of common time formats. |
3044 | - foreach ($context['easy_timeformats'] as $time_format) |
|
3045 | - echo ' |
|
3158 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
3159 | + echo ' |
|
3046 | 3160 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
3161 | + } |
|
3047 | 3162 | |
3048 | 3163 | echo ' |
3049 | 3164 | </select><br> |
@@ -3081,9 +3196,10 @@ discard block |
||
3081 | 3196 | <dd> |
3082 | 3197 | <select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">'; |
3083 | 3198 | |
3084 | - foreach ($context['smiley_sets'] as $set) |
|
3085 | - echo ' |
|
3199 | + foreach ($context['smiley_sets'] as $set) { |
|
3200 | + echo ' |
|
3086 | 3201 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
3202 | + } |
|
3087 | 3203 | |
3088 | 3204 | echo ' |
3089 | 3205 | </select> |
@@ -3135,10 +3251,11 @@ discard block |
||
3135 | 3251 | <img src="', $context['tfa_qr_url'], '" alt=""> |
3136 | 3252 | </div>'; |
3137 | 3253 | |
3138 | - if (!empty($context['from_ajax'])) |
|
3139 | - echo ' |
|
3254 | + if (!empty($context['from_ajax'])) { |
|
3255 | + echo ' |
|
3140 | 3256 | <br> |
3141 | 3257 | <a href="javascript:self.close();"></a>'; |
3258 | + } |
|
3142 | 3259 | |
3143 | 3260 | echo ' |
3144 | 3261 | </div> |
@@ -3178,17 +3295,16 @@ discard block |
||
3178 | 3295 | </dt> |
3179 | 3296 | <dd>'; |
3180 | 3297 | |
3181 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
3182 | - echo ' |
|
3298 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
3299 | + echo ' |
|
3183 | 3300 | <a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
3184 | - |
|
3185 | - elseif (!$context['tfa_enabled']) |
|
3186 | - echo ' |
|
3301 | + } elseif (!$context['tfa_enabled']) { |
|
3302 | + echo ' |
|
3187 | 3303 | ', $txt['tfa_profile_disabled']; |
3188 | - |
|
3189 | - else |
|
3190 | - echo ' |
|
3304 | + } else { |
|
3305 | + echo ' |
|
3191 | 3306 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
3307 | + } |
|
3192 | 3308 | |
3193 | 3309 | echo ' |
3194 | 3310 | </dd>'; |
@@ -13,8 +13,9 @@ discard block |
||
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 | * Downloads an avatar or attachment based on $_GET['attach'], and increments the download count. |
@@ -40,11 +41,11 @@ discard block |
||
40 | 41 | |
41 | 42 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
42 | 43 | { |
43 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
44 | - $modSettings['enableCompressedOutput'] = 0; |
|
45 | - |
|
46 | - else |
|
47 | - ob_start('ob_gzhandler'); |
|
44 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
45 | + $modSettings['enableCompressedOutput'] = 0; |
|
46 | + } else { |
|
47 | + ob_start('ob_gzhandler'); |
|
48 | + } |
|
48 | 49 | } |
49 | 50 | |
50 | 51 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -76,8 +77,9 @@ discard block |
||
76 | 77 | } |
77 | 78 | |
78 | 79 | // Use cache when possible. |
79 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
80 | - list($file, $thumbFile) = $cache; |
|
80 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
81 | + list($file, $thumbFile) = $cache; |
|
82 | + } |
|
81 | 83 | |
82 | 84 | // Get the info from the DB. |
83 | 85 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -85,10 +87,9 @@ discard block |
||
85 | 87 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
86 | 88 | $attachRequest = null; |
87 | 89 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
88 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
89 | - $request = $attachRequest; |
|
90 | - |
|
91 | - else |
|
90 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
91 | + $request = $attachRequest; |
|
92 | + } else |
|
92 | 93 | { |
93 | 94 | // Make sure this attachment is on this board and load its info while we are at it. |
94 | 95 | $request = $smcFunc['db_query']('', ' |
@@ -181,13 +182,15 @@ discard block |
||
181 | 182 | } |
182 | 183 | |
183 | 184 | // Cache it. |
184 | - if (!empty($file) || !empty($thumbFile)) |
|
185 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
185 | + if (!empty($file) || !empty($thumbFile)) { |
|
186 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
187 | + } |
|
186 | 188 | } |
187 | 189 | |
188 | 190 | // Replace the normal file with its thumbnail if it has one! |
189 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
190 | - $file = $thumbFile; |
|
191 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
192 | + $file = $thumbFile; |
|
193 | + } |
|
191 | 194 | |
192 | 195 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
193 | 196 | if (!file_exists($file['filePath'])) |
@@ -237,8 +240,8 @@ discard block |
||
237 | 240 | } |
238 | 241 | |
239 | 242 | // Update the download counter (unless it's a thumbnail or resuming an incomplete download). |
240 | - if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) |
|
241 | - $smcFunc['db_query']('', ' |
|
243 | + if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) { |
|
244 | + $smcFunc['db_query']('', ' |
|
242 | 245 | UPDATE {db_prefix}attachments |
243 | 246 | SET downloads = downloads + 1 |
244 | 247 | WHERE id_attach = {int:id_attach}', |
@@ -246,12 +249,14 @@ discard block |
||
246 | 249 | 'id_attach' => $attachId, |
247 | 250 | ) |
248 | 251 | ); |
252 | + } |
|
249 | 253 | |
250 | 254 | // Send the attachment headers. |
251 | 255 | header('Pragma: '); |
252 | 256 | |
253 | - if (!isBrowser('gecko')) |
|
254 | - header('Content-Transfer-Encoding: binary'); |
|
257 | + if (!isBrowser('gecko')) { |
|
258 | + header('Content-Transfer-Encoding: binary'); |
|
259 | + } |
|
255 | 260 | |
256 | 261 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
257 | 262 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -260,18 +265,19 @@ discard block |
||
260 | 265 | header('ETag: ' . $eTag); |
261 | 266 | |
262 | 267 | // Make sure the mime type warrants an inline display. |
263 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
264 | - unset($_REQUEST['image']); |
|
268 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
269 | + unset($_REQUEST['image']); |
|
270 | + } |
|
265 | 271 | |
266 | 272 | // Does this have a mime type? |
267 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
268 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
269 | - |
|
270 | - else |
|
273 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
274 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
275 | + } else |
|
271 | 276 | { |
272 | 277 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
273 | - if (isset($_REQUEST['image'])) |
|
274 | - unset($_REQUEST['image']); |
|
278 | + if (isset($_REQUEST['image'])) { |
|
279 | + unset($_REQUEST['image']); |
|
280 | + } |
|
275 | 281 | } |
276 | 282 | |
277 | 283 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -279,24 +285,22 @@ discard block |
||
279 | 285 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
280 | 286 | |
281 | 287 | // Different browsers like different standards... |
282 | - if (isBrowser('firefox')) |
|
283 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
284 | - |
|
285 | - elseif (isBrowser('opera')) |
|
286 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
287 | - |
|
288 | - elseif (isBrowser('ie')) |
|
289 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
290 | - |
|
291 | - else |
|
292 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
288 | + if (isBrowser('firefox')) { |
|
289 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
290 | + } elseif (isBrowser('opera')) { |
|
291 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
292 | + } elseif (isBrowser('ie')) { |
|
293 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
294 | + } else { |
|
295 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
296 | + } |
|
293 | 297 | |
294 | 298 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
295 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
296 | - header('Cache-Control: no-cache'); |
|
297 | - |
|
298 | - else |
|
299 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
299 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
300 | + header('Cache-Control: no-cache'); |
|
301 | + } else { |
|
302 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
303 | + } |
|
300 | 304 | |
301 | 305 | // Multipart and resuming support |
302 | 306 | if (isset($_SERVER['HTTP_RANGE'])) |
@@ -304,9 +308,9 @@ discard block |
||
304 | 308 | header("HTTP/1.1 206 Partial Content"); |
305 | 309 | header("Content-Length: $new_length"); |
306 | 310 | header("Content-Range: bytes $range-$range_end/$size"); |
311 | + } else { |
|
312 | + header("Content-Length: " . $size); |
|
307 | 313 | } |
308 | - else |
|
309 | - header("Content-Length: " . $size); |
|
310 | 314 | |
311 | 315 | |
312 | 316 | // Try to buy some time... |
@@ -315,8 +319,9 @@ discard block |
||
315 | 319 | // For multipart/resumable downloads, send the requested chunk(s) of the file |
316 | 320 | if (isset($_SERVER['HTTP_RANGE'])) |
317 | 321 | { |
318 | - while (@ob_get_level() > 0) |
|
319 | - @ob_end_clean(); |
|
322 | + while (@ob_get_level() > 0) { |
|
323 | + @ob_end_clean(); |
|
324 | + } |
|
320 | 325 | |
321 | 326 | // 40 kilobytes is a good-ish amount |
322 | 327 | $chunksize = 40 * 1024; |
@@ -340,8 +345,9 @@ discard block |
||
340 | 345 | elseif ($size > 4194304) |
341 | 346 | { |
342 | 347 | // Forcibly end any output buffering going on. |
343 | - while (@ob_get_level() > 0) |
|
344 | - @ob_end_clean(); |
|
348 | + while (@ob_get_level() > 0) { |
|
349 | + @ob_end_clean(); |
|
350 | + } |
|
345 | 351 | |
346 | 352 | $fp = fopen($file['filePath'], 'rb'); |
347 | 353 | while (!feof($fp)) |
@@ -353,8 +359,9 @@ discard block |
||
353 | 359 | } |
354 | 360 | |
355 | 361 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
356 | - elseif (@readfile($file['filePath']) === null) |
|
357 | - echo file_get_contents($file['filePath']); |
|
362 | + elseif (@readfile($file['filePath']) === null) { |
|
363 | + echo file_get_contents($file['filePath']); |
|
364 | + } |
|
358 | 365 | |
359 | 366 | die(); |
360 | 367 | } |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | <subject is_first="', $context['message']['first_in_topic'] ? '1' : '0', '"><![CDATA[', cleanXml($context['message']['subject']), ']]></subject> |
74 | 74 | <body><![CDATA[', $context['message']['body'], ']]></body> |
75 | 75 | <success><![CDATA[', $txt['quick_modify_message'], ']]></success>'; |
76 | - } |
|
77 | - else |
|
78 | - echo ' |
|
76 | + } else { |
|
77 | + echo ' |
|
79 | 78 | <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '" in_body="', cleanXml($context['message']['error_in_body']) ? '1' : '0', '"><![CDATA[', implode('<br />', $context['message']['errors']), ']]></error>'; |
79 | + } |
|
80 | 80 | echo ' |
81 | 81 | </message> |
82 | 82 | </smf>'; |
@@ -101,13 +101,14 @@ discard block |
||
101 | 101 | echo ' |
102 | 102 | <modified><![CDATA[', empty($modified) ? '' : cleanXml('« <em>' . $modified . '</em>»'), ']]></modified>'; |
103 | 103 | |
104 | - if (!empty($context['message']['subject'])) |
|
105 | - echo ' |
|
104 | + if (!empty($context['message']['subject'])) { |
|
105 | + echo ' |
|
106 | 106 | <subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject>'; |
107 | - } |
|
108 | - else |
|
109 | - echo ' |
|
107 | + } |
|
108 | + } else { |
|
109 | + echo ' |
|
110 | 110 | <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '"><![CDATA[', cleanXml(implode('<br />', $context['message']['errors'])), ']]></error>'; |
111 | + } |
|
111 | 112 | echo ' |
112 | 113 | </message> |
113 | 114 | </smf>'; |
@@ -128,10 +129,11 @@ discard block |
||
128 | 129 | </preview> |
129 | 130 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '" topic_locked="', $context['locked'] ? '1' : '0', '">'; |
130 | 131 | |
131 | - if (!empty($context['post_error'])) |
|
132 | - foreach ($context['post_error'] as $message) |
|
132 | + if (!empty($context['post_error'])) { |
|
133 | + foreach ($context['post_error'] as $message) |
|
133 | 134 | echo ' |
134 | 135 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
136 | + } |
|
135 | 137 | |
136 | 138 | echo ' |
137 | 139 | <caption name="guestname" class="', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? 'error' : '', '" /> |
@@ -148,14 +150,15 @@ discard block |
||
148 | 150 | echo ' |
149 | 151 | <new_posts>'; |
150 | 152 | |
151 | - foreach ($context['previous_posts'] as $post) |
|
152 | - echo ' |
|
153 | + foreach ($context['previous_posts'] as $post) { |
|
154 | + echo ' |
|
153 | 155 | <post id="', $post['id'], '"> |
154 | 156 | <time><![CDATA[', $post['time'], ']]></time> |
155 | 157 | <poster><![CDATA[', cleanXml($post['poster']), ']]></poster> |
156 | 158 | <message><![CDATA[', cleanXml($post['message']), ']]></message> |
157 | 159 | <is_ignored>', $post['is_ignored'] ? '1' : '0', '</is_ignored> |
158 | 160 | </post>'; |
161 | + } |
|
159 | 162 | |
160 | 163 | echo ' |
161 | 164 | </new_posts>'; |
@@ -181,10 +184,11 @@ discard block |
||
181 | 184 | </preview> |
182 | 185 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">'; |
183 | 186 | |
184 | - if (!empty($context['post_error']['messages'])) |
|
185 | - foreach ($context['post_error']['messages'] as $message) |
|
187 | + if (!empty($context['post_error']['messages'])) { |
|
188 | + foreach ($context['post_error']['messages'] as $message) |
|
186 | 189 | echo ' |
187 | 190 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
191 | + } |
|
188 | 192 | |
189 | 193 | echo ' |
190 | 194 | <caption name="to" class="', isset($context['post_error']['no_to']) ? 'error' : '', '" /> |
@@ -214,10 +218,11 @@ discard block |
||
214 | 218 | </preview> |
215 | 219 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">'; |
216 | 220 | |
217 | - if (!empty($context['post_error']['messages'])) |
|
218 | - foreach ($context['post_error']['messages'] as $message) |
|
221 | + if (!empty($context['post_error']['messages'])) { |
|
222 | + foreach ($context['post_error']['messages'] as $message) |
|
219 | 223 | echo ' |
220 | 224 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
225 | + } |
|
221 | 226 | |
222 | 227 | echo ' |
223 | 228 | </errors>'; |
@@ -233,20 +238,23 @@ discard block |
||
233 | 238 | { |
234 | 239 | global $context, $modSettings; |
235 | 240 | |
236 | - if (empty($context['yearly'])) |
|
237 | - return; |
|
241 | + if (empty($context['yearly'])) { |
|
242 | + return; |
|
243 | + } |
|
238 | 244 | |
239 | 245 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
240 | 246 | <smf>'; |
241 | - foreach ($context['yearly'] as $year) |
|
242 | - foreach ($year['months'] as $month) |
|
247 | + foreach ($context['yearly'] as $year) { |
|
248 | + foreach ($year['months'] as $month) |
|
243 | 249 | { |
244 | 250 | echo ' |
245 | 251 | <month id="', $month['date']['year'], $month['date']['month'], '">'; |
252 | + } |
|
246 | 253 | |
247 | - foreach ($month['days'] as $day) |
|
248 | - echo ' |
|
254 | + foreach ($month['days'] as $day) { |
|
255 | + echo ' |
|
249 | 256 | <day date="', $day['year'], '-', $day['month'], '-', $day['day'], '" new_topics="', $day['new_topics'], '" new_posts="', $day['new_posts'], '" new_members="', $day['new_members'], '" most_members_online="', $day['most_members_online'], '"', empty($modSettings['hitStats']) ? '' : ' hits="' . $day['hits'] . '"', ' />'; |
257 | + } |
|
250 | 258 | |
251 | 259 | echo ' |
252 | 260 | </month>'; |
@@ -269,17 +277,18 @@ discard block |
||
269 | 277 | <pageIndex section="selected" startFrom="', $context['selected']['start'], '"><![CDATA[', $context['selected']['page_index'], ']]></pageIndex>'; |
270 | 278 | foreach ($context['changes'] as $change) |
271 | 279 | { |
272 | - if ($change['type'] == 'remove') |
|
273 | - echo ' |
|
280 | + if ($change['type'] == 'remove') { |
|
281 | + echo ' |
|
274 | 282 | <change id="', $change['id'], '" curAction="remove" section="', $change['section'], '" />'; |
275 | - else |
|
276 | - echo ' |
|
283 | + } else { |
|
284 | + echo ' |
|
277 | 285 | <change id="', $change['id'], '" curAction="insert" section="', $change['section'], '"> |
278 | 286 | <subject><![CDATA[', cleanXml($change['insert_value']['subject']), ']]></subject> |
279 | 287 | <time><![CDATA[', cleanXml($change['insert_value']['time']), ']]></time> |
280 | 288 | <body><![CDATA[', cleanXml($change['insert_value']['body']), ']]></body> |
281 | 289 | <poster><![CDATA[', cleanXml($change['insert_value']['poster']), ']]></poster> |
282 | 290 | </change>'; |
291 | + } |
|
283 | 292 | } |
284 | 293 | echo ' |
285 | 294 | </smf>'; |
@@ -310,10 +319,10 @@ discard block |
||
310 | 319 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
311 | 320 | <smf>'; |
312 | 321 | |
313 | - if (empty($context['topics'])) |
|
314 | - echo ' |
|
322 | + if (empty($context['topics'])) { |
|
323 | + echo ' |
|
315 | 324 | <noresults>', $txt['search_no_results'], '</noresults>'; |
316 | - else |
|
325 | + } else |
|
317 | 326 | { |
318 | 327 | echo ' |
319 | 328 | <results>'; |
@@ -382,9 +391,10 @@ discard block |
||
382 | 391 | echo ' |
383 | 392 | <item type="category" id="', $category['id'], '"><![CDATA[', cleanXml($category['name']), ']]></item>'; |
384 | 393 | |
385 | - foreach ($category['boards'] as $board) |
|
386 | - echo ' |
|
394 | + foreach ($category['boards'] as $board) { |
|
395 | + echo ' |
|
387 | 396 | <item type="board" id="', $board['id'], '" childlevel="', $board['child_level'], '"><![CDATA[', cleanXml($board['name']), ']]></item>'; |
397 | + } |
|
388 | 398 | } |
389 | 399 | echo ' |
390 | 400 | </smf>'; |
@@ -400,9 +410,10 @@ discard block |
||
400 | 410 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
401 | 411 | <smf>'; |
402 | 412 | |
403 | - foreach ($context['icons'] as $icon) |
|
404 | - echo ' |
|
413 | + foreach ($context['icons'] as $icon) { |
|
414 | + echo ' |
|
405 | 415 | <icon value="', $icon['value'], '" url="', $icon['url'], '"><![CDATA[', cleanXml($icon['name']), ']]></icon>'; |
416 | + } |
|
406 | 417 | |
407 | 418 | echo ' |
408 | 419 | </smf>'; |
@@ -452,16 +463,18 @@ discard block |
||
452 | 463 | foreach ($xml_data as $key => $data) |
453 | 464 | { |
454 | 465 | // A group? |
455 | - if (is_array($data) && isset($data['identifier'])) |
|
456 | - template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level); |
|
466 | + if (is_array($data) && isset($data['identifier'])) { |
|
467 | + template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level); |
|
468 | + } |
|
457 | 469 | // An item... |
458 | 470 | elseif (is_array($data) && isset($data['value'])) |
459 | 471 | { |
460 | 472 | echo "\n", str_repeat("\t", $level), '<', $child_ident; |
461 | 473 | |
462 | - if (!empty($data['attributes'])) |
|
463 | - foreach ($data['attributes'] as $k => $v) |
|
474 | + if (!empty($data['attributes'])) { |
|
475 | + foreach ($data['attributes'] as $k => $v) |
|
464 | 476 | echo ' ' . $k . '="' . $v . '"'; |
477 | + } |
|
465 | 478 | echo '><![CDATA[', cleanXml($data['value']), ']]></', $child_ident, '>'; |
466 | 479 | } |
467 | 480 |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | <div class="windowbg"> |
32 | 32 | <ul id="likes">'; |
33 | 33 | |
34 | - foreach ($context['likers'] as $liker => $like_details) |
|
35 | - echo ' |
|
34 | + foreach ($context['likers'] as $liker => $like_details) { |
|
35 | + echo ' |
|
36 | 36 | <li> |
37 | 37 | ', $like_details['profile']['avatar']['image'], ' |
38 | 38 | <span> |
@@ -41,6 +41,7 @@ discard block |
||
41 | 41 | </span> |
42 | 42 | <span class="floatright">', $like_details['time'], '</span> |
43 | 43 | </li>'; |
44 | + } |
|
44 | 45 | |
45 | 46 | echo ' |
46 | 47 | </ul> |
@@ -61,11 +62,12 @@ discard block |
||
61 | 62 | echo ' |
62 | 63 | <ul class="floatleft">'; |
63 | 64 | |
64 | - if (!empty($context['data']['can_like'])) |
|
65 | - echo ' |
|
65 | + if (!empty($context['data']['can_like'])) { |
|
66 | + echo ' |
|
66 | 67 | <li class="like_button" id="', $context['data']['type'], '_', $context['data']['id_content'], '_likes"', '> |
67 | 68 | <a href="', $scripturl, '?action=likes;ltype=', $context['data']['type'], ';sa=like;like=', $context['data']['id_content'], ';', $context['session_var'], '=', $context['session_id'], '" class="', $context['data']['type'], '_like"><span class="generic_icons ', $context['data']['already_liked'] ? 'unlike' : 'like', '"></span> ', $context['data']['already_liked'] ? $txt['unlike'] : $txt['like'], '</a> |
68 | 69 | </li>'; |
70 | + } |
|
69 | 71 | |
70 | 72 | if (!empty($context['data']['count'])) |
71 | 73 | { |
@@ -55,18 +55,20 @@ discard block |
||
55 | 55 | <div class="modbox"> |
56 | 56 | <ul>'; |
57 | 57 | |
58 | - foreach ($context['group_requests'] as $request) |
|
59 | - echo ' |
|
58 | + foreach ($context['group_requests'] as $request) { |
|
59 | + echo ' |
|
60 | 60 | <li class="smalltext"> |
61 | 61 | <a href="', $request['request_href'], '">', $request['group']['name'], '</a> ', $txt['mc_groupr_by'], ' ', $request['member']['link'], ' |
62 | 62 | </li>'; |
63 | + } |
|
63 | 64 | |
64 | 65 | // Don't have any watched users right now? |
65 | - if (empty($context['group_requests'])) |
|
66 | - echo ' |
|
66 | + if (empty($context['group_requests'])) { |
|
67 | + echo ' |
|
67 | 68 | <li> |
68 | 69 | <strong class="smalltext">', $txt['mc_group_requests_none'], '</strong> |
69 | 70 | </li>'; |
71 | + } |
|
70 | 72 | |
71 | 73 | echo ' |
72 | 74 | </ul> |
@@ -124,18 +126,20 @@ discard block |
||
124 | 126 | <div class="modbox"> |
125 | 127 | <ul>'; |
126 | 128 | |
127 | - foreach ($context['watched_users'] as $user) |
|
128 | - echo ' |
|
129 | + foreach ($context['watched_users'] as $user) { |
|
130 | + echo ' |
|
129 | 131 | <li> |
130 | 132 | <span class="smalltext">', sprintf(!empty($user['last_login']) ? $txt['mc_seen'] : $txt['mc_seen_never'], $user['link'], $user['last_login']), '</span> |
131 | 133 | </li>'; |
134 | + } |
|
132 | 135 | |
133 | 136 | // Don't have any watched users right now? |
134 | - if (empty($context['watched_users'])) |
|
135 | - echo ' |
|
137 | + if (empty($context['watched_users'])) { |
|
138 | + echo ' |
|
136 | 139 | <li> |
137 | 140 | <strong class="smalltext">', $txt['mc_watched_users_none'], '</strong> |
138 | 141 | </li>'; |
142 | + } |
|
139 | 143 | |
140 | 144 | echo ' |
141 | 145 | </ul> |
@@ -193,18 +197,20 @@ discard block |
||
193 | 197 | <div class="modbox"> |
194 | 198 | <ul>'; |
195 | 199 | |
196 | - foreach ($context['reported_posts'] as $post) |
|
197 | - echo ' |
|
200 | + foreach ($context['reported_posts'] as $post) { |
|
201 | + echo ' |
|
198 | 202 | <li> |
199 | 203 | <span class="smalltext">', sprintf($txt['mc_post_report'], $post['report_link'], $post['author']['link']), '</span> |
200 | 204 | </li>'; |
205 | + } |
|
201 | 206 | |
202 | 207 | // Don't have any watched users right now? |
203 | - if (empty($context['reported_posts'])) |
|
204 | - echo ' |
|
208 | + if (empty($context['reported_posts'])) { |
|
209 | + echo ' |
|
205 | 210 | <li> |
206 | 211 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
207 | 212 | </li>'; |
213 | + } |
|
208 | 214 | |
209 | 215 | echo ' |
210 | 216 | </ul> |
@@ -262,18 +268,20 @@ discard block |
||
262 | 268 | <div class="modbox"> |
263 | 269 | <ul>'; |
264 | 270 | |
265 | - foreach ($context['reported_users'] as $user) |
|
266 | - echo ' |
|
271 | + foreach ($context['reported_users'] as $user) { |
|
272 | + echo ' |
|
267 | 273 | <li> |
268 | 274 | <span class="smalltext">', $user['user']['link'], '</span> |
269 | 275 | </li>'; |
276 | + } |
|
270 | 277 | |
271 | 278 | // Don't have any watched users right now? |
272 | - if (empty($context['reported_users'])) |
|
273 | - echo ' |
|
279 | + if (empty($context['reported_users'])) { |
|
280 | + echo ' |
|
274 | 281 | <li> |
275 | 282 | <strong class="smalltext">', $txt['mc_reported_users_none'], '</strong> |
276 | 283 | </li>'; |
284 | + } |
|
277 | 285 | |
278 | 286 | echo ' |
279 | 287 | </ul> |
@@ -321,11 +329,12 @@ discard block |
||
321 | 329 | global $context, $txt, $scripturl; |
322 | 330 | |
323 | 331 | // Let them know the action was a success. |
324 | - if (!empty($context['report_post_action'])) |
|
325 | - echo ' |
|
332 | + if (!empty($context['report_post_action'])) { |
|
333 | + echo ' |
|
326 | 334 | <div class="infobox"> |
327 | 335 | ', $txt['report_action_' . $context['report_post_action']], ' |
328 | 336 | </div>'; |
337 | + } |
|
329 | 338 | |
330 | 339 | echo ' |
331 | 340 | <div class="modnotes"> |
@@ -342,11 +351,12 @@ discard block |
||
342 | 351 | <ul class="moderation_notes">'; |
343 | 352 | |
344 | 353 | // Cycle through the notes. |
345 | - foreach ($context['notes'] as $note) |
|
346 | - echo ' |
|
354 | + foreach ($context['notes'] as $note) { |
|
355 | + echo ' |
|
347 | 356 | <li class="smalltext"> |
348 | 357 | ', ($note['can_delete'] ? '<a href="' . $note['delete_href'] . ';' . $context['mod-modnote-del_token_var'] . '=' . $context['mod-modnote-del_token'] . '" data-confirm="' . $txt['mc_reportedp_delete_confirm'] . '" class="you_sure"><span class="generic_icons delete"></span></a>' : ''), $note['time'], ' <strong>', $note['author']['link'], ':</strong> ', $note['text'], ' |
349 | 358 | </li>'; |
359 | + } |
|
350 | 360 | |
351 | 361 | echo ' |
352 | 362 | </ul> |
@@ -388,18 +398,19 @@ discard block |
||
388 | 398 | $remove_button = create_button('delete', 'remove_message', 'remove'); |
389 | 399 | |
390 | 400 | // No posts? |
391 | - if (empty($context['unapproved_items'])) |
|
392 | - echo ' |
|
401 | + if (empty($context['unapproved_items'])) { |
|
402 | + echo ' |
|
393 | 403 | <div class="windowbg2"> |
394 | 404 | <p class="centertext"> |
395 | 405 | ', $txt['mc_unapproved_' . $context['current_view'] . '_none_found'], ' |
396 | 406 | </p> |
397 | 407 | </div>'; |
398 | - else |
|
399 | - echo ' |
|
408 | + } else { |
|
409 | + echo ' |
|
400 | 410 | <div class="pagesection floatleft"> |
401 | 411 | ', $context['page_index'], ' |
402 | 412 | </div>'; |
413 | + } |
|
403 | 414 | |
404 | 415 | foreach ($context['unapproved_items'] as $item) |
405 | 416 | { |
@@ -418,14 +429,16 @@ discard block |
||
418 | 429 | <span class="floatright"> |
419 | 430 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>'; |
420 | 431 | |
421 | - if ($item['can_delete']) |
|
422 | - echo ' |
|
432 | + if ($item['can_delete']) { |
|
433 | + echo ' |
|
423 | 434 | ', $context['menu_separator'], ' |
424 | 435 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>'; |
436 | + } |
|
425 | 437 | |
426 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
427 | - echo ' |
|
438 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
439 | + echo ' |
|
428 | 440 | <input type="checkbox" name="item[]" value="', $item['id'], '" checked> '; |
441 | + } |
|
429 | 442 | |
430 | 443 | echo ' |
431 | 444 | </span> |
@@ -435,8 +448,8 @@ discard block |
||
435 | 448 | echo ' |
436 | 449 | <div class="pagesection">'; |
437 | 450 | |
438 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
439 | - echo ' |
|
451 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
452 | + echo ' |
|
440 | 453 | <div class="floatright"> |
441 | 454 | <select name="do" onchange="if (this.value != 0 && confirm(\'', $txt['mc_unapproved_sure'], '\')) submit();"> |
442 | 455 | <option value="0">', $txt['with_selected'], ':</option> |
@@ -448,12 +461,14 @@ discard block |
||
448 | 461 | <input type="submit" name="mc_go" value="', $txt['go'], '" class="button"> |
449 | 462 | </noscript> |
450 | 463 | </div>'; |
464 | + } |
|
451 | 465 | |
452 | - if (!empty($context['unapproved_items'])) |
|
453 | - echo ' |
|
466 | + if (!empty($context['unapproved_items'])) { |
|
467 | + echo ' |
|
454 | 468 | <div class="floatleft"> |
455 | 469 | <div class="pagelinks">', $context['page_index'], '</div> |
456 | 470 | </div>'; |
471 | + } |
|
457 | 472 | |
458 | 473 | echo ' |
459 | 474 | </div><!-- .pagesection --> |
@@ -473,8 +488,9 @@ discard block |
||
473 | 488 | global $scripturl, $context, $txt, $delete_button; |
474 | 489 | |
475 | 490 | // We'll have a delete please bob. |
476 | - if (empty($delete_button)) |
|
477 | - $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
491 | + if (empty($delete_button)) { |
|
492 | + $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
493 | + } |
|
478 | 494 | |
479 | 495 | $output_html = ' |
480 | 496 | <div> |
@@ -483,10 +499,11 @@ discard block |
||
483 | 499 | </div> |
484 | 500 | <div class="floatright">'; |
485 | 501 | |
486 | - if ($post['can_delete']) |
|
487 | - $output_html .= ' |
|
502 | + if ($post['can_delete']) { |
|
503 | + $output_html .= ' |
|
488 | 504 | <a href="' . $scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['mc_watched_users_delete_post'] . '" class="you_sure">' . $delete_button . '</a> |
489 | 505 | <input type="checkbox" name="delete[]" value="' . $post['id'] . '">'; |
506 | + } |
|
490 | 507 | |
491 | 508 | $output_html .= ' |
492 | 509 | </div> |
@@ -529,12 +546,12 @@ discard block |
||
529 | 546 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
530 | 547 | </div> |
531 | 548 | </form>'; |
532 | - } |
|
533 | - else |
|
534 | - echo ' |
|
549 | + } else { |
|
550 | + echo ' |
|
535 | 551 | <div class="windowbg"> |
536 | 552 | <div class="centertext">', $txt['mc_no_settings'], '</div> |
537 | 553 | </div>'; |
554 | + } |
|
538 | 555 | |
539 | 556 | echo ' |
540 | 557 | </div><!-- #modcenter -->'; |
@@ -630,13 +647,14 @@ discard block |
||
630 | 647 | </dd> |
631 | 648 | </dl>'; |
632 | 649 | |
633 | - if ($context['template_data']['can_edit_personal']) |
|
634 | - echo ' |
|
650 | + if ($context['template_data']['can_edit_personal']) { |
|
651 | + echo ' |
|
635 | 652 | <input type="checkbox" name="make_personal" id="make_personal"', $context['template_data']['personal'] ? ' checked' : '', '> |
636 | 653 | <label for="make_personal"> |
637 | 654 | <strong>', $txt['mc_warning_template_personal'], '</strong> |
638 | 655 | </label><br> |
639 | 656 | <span class="smalltext">', $txt['mc_warning_template_personal_desc'], '</span><br>'; |
657 | + } |
|
640 | 658 | |
641 | 659 | echo ' |
642 | 660 | <hr> |
@@ -26,9 +26,10 @@ discard block |
||
26 | 26 | </h3> |
27 | 27 | </div>'; |
28 | 28 | |
29 | - if ($context['ban']['is_new']) |
|
30 | - echo ' |
|
29 | + if ($context['ban']['is_new']) { |
|
30 | + echo ' |
|
31 | 31 | <div class="information noup">', $txt['ban_add_notes'], '</div>'; |
32 | + } |
|
32 | 33 | |
33 | 34 | // If there were errors creating the ban, show them. |
34 | 35 | if (!empty($context['error_messages'])) |
@@ -38,9 +39,10 @@ discard block |
||
38 | 39 | <strong>', $txt['ban_errors_detected'], '</strong> |
39 | 40 | <ul>'; |
40 | 41 | |
41 | - foreach ($context['error_messages'] as $error) |
|
42 | - echo ' |
|
42 | + foreach ($context['error_messages'] as $error) { |
|
43 | + echo ' |
|
43 | 44 | <li class="error">', $error, '</li>'; |
45 | + } |
|
44 | 46 | |
45 | 47 | echo ' |
46 | 48 | </ul> |
@@ -57,8 +59,8 @@ discard block |
||
57 | 59 | <input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60"> |
58 | 60 | </dd>'; |
59 | 61 | |
60 | - if (isset($context['ban']['reason'])) |
|
61 | - echo ' |
|
62 | + if (isset($context['ban']['reason'])) { |
|
63 | + echo ' |
|
62 | 64 | <dt> |
63 | 65 | <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br> |
64 | 66 | <span class="smalltext">', $txt['ban_reason_desc'], '</span> |
@@ -66,9 +68,10 @@ discard block |
||
66 | 68 | <dd> |
67 | 69 | <textarea name="reason" id="reason" cols="40" rows="3">', $context['ban']['reason'], '</textarea> |
68 | 70 | </dd>'; |
71 | + } |
|
69 | 72 | |
70 | - if (isset($context['ban']['notes'])) |
|
71 | - echo ' |
|
73 | + if (isset($context['ban']['notes'])) { |
|
74 | + echo ' |
|
72 | 75 | <dt> |
73 | 76 | <strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br> |
74 | 77 | <span class="smalltext">', $txt['ban_notes_desc'], '</span> |
@@ -76,6 +79,7 @@ discard block |
||
76 | 79 | <dd> |
77 | 80 | <textarea name="notes" id="ban_notes" cols="40" rows="3">', $context['ban']['notes'], '</textarea> |
78 | 81 | </dd>'; |
82 | + } |
|
79 | 83 | |
80 | 84 | echo ' |
81 | 85 | </dl> |
@@ -115,8 +119,8 @@ discard block |
||
115 | 119 | <input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
116 | 120 | </dd>'; |
117 | 121 | |
118 | - if (empty($modSettings['disableHostnameLookup'])) |
|
119 | - echo ' |
|
122 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
123 | + echo ' |
|
120 | 124 | <dt> |
121 | 125 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', !empty($context['ban_suggestions']['hostname']) ? ' checked' : '', '> |
122 | 126 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -124,6 +128,7 @@ discard block |
||
124 | 128 | <dd> |
125 | 129 | <input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
126 | 130 | </dd>'; |
131 | + } |
|
127 | 132 | |
128 | 133 | echo ' |
129 | 134 | <dt> |
@@ -153,14 +158,15 @@ discard block |
||
153 | 158 | <dl class="settings">'; |
154 | 159 | |
155 | 160 | $count = 0; |
156 | - foreach ($ban_ips as $ip) |
|
157 | - echo ' |
|
161 | + foreach ($ban_ips as $ip) { |
|
162 | + echo ' |
|
158 | 163 | <dt> |
159 | 164 | <input type="checkbox" id="suggestions_', $key, '_', $count, '" name="ban_suggestions[', $key, '][]"', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? ' checked' : '', ' value="', $ip, '"> |
160 | 165 | </dt> |
161 | 166 | <dd> |
162 | 167 | <label for="suggestions_', $key, '_', $count++, '">', $ip, '</label> |
163 | 168 | </dd>'; |
169 | + } |
|
164 | 170 | |
165 | 171 | echo ' |
166 | 172 | </dl>'; |
@@ -202,8 +208,8 @@ discard block |
||
202 | 208 | addLoadEvent(fUpdateStatus);'; |
203 | 209 | |
204 | 210 | // Auto suggest only needed for adding new bans, not editing |
205 | - if ($context['ban']['is_new'] && empty($_REQUEST['u'])) |
|
206 | - echo ' |
|
211 | + if ($context['ban']['is_new'] && empty($_REQUEST['u'])) { |
|
212 | + echo ' |
|
207 | 213 | var oAddMemberSuggest = new smc_AutoSuggest({ |
208 | 214 | sSelf: \'oAddMemberSuggest\', |
209 | 215 | sSessionId: smf_session_id, |
@@ -221,6 +227,7 @@ discard block |
||
221 | 227 | return true; |
222 | 228 | } |
223 | 229 | oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');'; |
230 | + } |
|
224 | 231 | |
225 | 232 | echo ' |
226 | 233 | function confirmBan(aForm) |
@@ -269,8 +276,8 @@ discard block |
||
269 | 276 | <input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
270 | 277 | </dd>'; |
271 | 278 | |
272 | - if (empty($modSettings['disableHostnameLookup'])) |
|
273 | - echo ' |
|
279 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
280 | + echo ' |
|
274 | 281 | <dt> |
275 | 282 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', $context['ban_trigger']['hostname']['selected'] ? ' checked' : '', '> |
276 | 283 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -278,6 +285,7 @@ discard block |
||
278 | 285 | <dd> |
279 | 286 | <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
280 | 287 | </dd>'; |
288 | + } |
|
281 | 289 | |
282 | 290 | echo ' |
283 | 291 | <dt> |
@@ -20,13 +20,12 @@ discard block |
||
20 | 20 | // We completed some tasks? |
21 | 21 | if (!empty($context['tasks_were_run'])) |
22 | 22 | { |
23 | - if (empty($context['scheduled_errors'])) |
|
24 | - echo ' |
|
23 | + if (empty($context['scheduled_errors'])) { |
|
24 | + echo ' |
|
25 | 25 | <div class="infobox"> |
26 | 26 | ', $txt['scheduled_tasks_were_run'], ' |
27 | 27 | </div>'; |
28 | - |
|
29 | - else |
|
28 | + } else |
|
30 | 29 | { |
31 | 30 | echo ' |
32 | 31 | <div class="errorbox" id="errors"> |
@@ -35,14 +34,15 @@ discard block |
||
35 | 34 | <strong id="error_serious">', $txt['scheduled_tasks_were_run_errors'], '</strong> |
36 | 35 | </dt>'; |
37 | 36 | |
38 | - foreach ($context['scheduled_errors'] as $task => $errors) |
|
39 | - echo ' |
|
37 | + foreach ($context['scheduled_errors'] as $task => $errors) { |
|
38 | + echo ' |
|
40 | 39 | <dd class="error"> |
41 | 40 | <strong>', isset($txt['scheduled_task_' . $task]) ? $txt['scheduled_task_' . $task] : $task, '</strong> |
42 | 41 | <ul> |
43 | 42 | <li>', implode('</li><li>', $errors), '</li> |
44 | 43 | </ul> |
45 | 44 | </dd>'; |
45 | + } |
|
46 | 46 | |
47 | 47 | echo ' |
48 | 48 | </dl> |