@@ -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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -392,9 +409,9 @@ discard block |
||
392 | 409 | break; |
393 | 410 | } |
394 | 411 | } |
412 | + } else { |
|
413 | + $id_member = 0; |
|
395 | 414 | } |
396 | - else |
|
397 | - $id_member = 0; |
|
398 | 415 | |
399 | 416 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
400 | 417 | { |
@@ -402,8 +419,9 @@ discard block |
||
402 | 419 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
403 | 420 | |
404 | 421 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
405 | - if (empty($cookie_data)) |
|
406 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
422 | + if (empty($cookie_data)) { |
|
423 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
424 | + } |
|
407 | 425 | |
408 | 426 | list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, ''); |
409 | 427 | |
@@ -411,16 +429,17 @@ discard block |
||
411 | 429 | |
412 | 430 | // Make sure the cookie is set to the correct domain and path |
413 | 431 | require_once($sourcedir . '/Subs-Auth.php'); |
414 | - if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) |
|
415 | - setLoginCookie((int) $login_span - time(), $id_member); |
|
416 | - } |
|
417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
432 | + if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) { |
|
433 | + setLoginCookie((int) $login_span - time(), $id_member); |
|
434 | + } |
|
435 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
418 | 436 | { |
419 | 437 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
420 | 438 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true); |
421 | 439 | |
422 | - if (empty($cookie_data)) |
|
423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
440 | + if (empty($cookie_data)) { |
|
441 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
442 | + } |
|
424 | 443 | |
425 | 444 | list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, ''); |
426 | 445 | $id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +464,34 @@ discard block |
||
445 | 464 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
446 | 465 | $smcFunc['db_free_result']($request); |
447 | 466 | |
448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
449 | - $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
467 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
468 | + $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
469 | + } |
|
450 | 470 | |
451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
471 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
472 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
473 | + } |
|
453 | 474 | } |
454 | 475 | |
455 | 476 | // Did we find 'im? If not, junk it. |
456 | 477 | if (!empty($user_settings)) |
457 | 478 | { |
458 | 479 | // As much as the password should be right, we can assume the integration set things up. |
459 | - if (!empty($already_verified) && $already_verified === true) |
|
460 | - $check = true; |
|
480 | + if (!empty($already_verified) && $already_verified === true) { |
|
481 | + $check = true; |
|
482 | + } |
|
461 | 483 | // SHA-512 hash should be 128 characters long. |
462 | - elseif (strlen($password) == 128) |
|
463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
464 | - else |
|
465 | - $check = false; |
|
484 | + elseif (strlen($password) == 128) { |
|
485 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
486 | + } else { |
|
487 | + $check = false; |
|
488 | + } |
|
466 | 489 | |
467 | 490 | // Wrong password or not activated - either way, you're going nowhere. |
468 | 491 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
492 | + } else { |
|
493 | + $id_member = 0; |
|
469 | 494 | } |
470 | - else |
|
471 | - $id_member = 0; |
|
472 | 495 | |
473 | 496 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
474 | 497 | if (!$id_member) |
@@ -497,8 +520,9 @@ discard block |
||
497 | 520 | |
498 | 521 | list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, ''); |
499 | 522 | |
500 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
501 | - $tfasecret = null; |
|
523 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
524 | + $tfasecret = null; |
|
525 | + } |
|
502 | 526 | } |
503 | 527 | |
504 | 528 | // They didn't finish logging in before coming here? Then they're no one to us. |
@@ -520,10 +544,12 @@ discard block |
||
520 | 544 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
521 | 545 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
522 | 546 | { |
523 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
547 | + if ($modSettings['tfa_mode'] == 2) { |
|
548 | + //only do this if we are just forcing SOME membergroups |
|
524 | 549 | { |
525 | 550 | //Build an array of ALL user membergroups. |
526 | 551 | $full_groups = array($user_settings['id_group']); |
552 | + } |
|
527 | 553 | if (!empty($user_settings['additional_groups'])) |
528 | 554 | { |
529 | 555 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -543,15 +569,17 @@ discard block |
||
543 | 569 | ); |
544 | 570 | $row = $smcFunc['db_fetch_assoc']($request); |
545 | 571 | $smcFunc['db_free_result']($request); |
572 | + } else { |
|
573 | + $row['total'] = 1; |
|
546 | 574 | } |
547 | - else |
|
548 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
575 | + //simplifies logics in the next "if" |
|
549 | 576 | |
550 | 577 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
551 | 578 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
552 | 579 | |
553 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
554 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
580 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
581 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
582 | + } |
|
555 | 583 | } |
556 | 584 | } |
557 | 585 | |
@@ -588,33 +616,37 @@ discard block |
||
588 | 616 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
589 | 617 | $user_settings['last_login'] = time(); |
590 | 618 | |
591 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
592 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
619 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
620 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
621 | + } |
|
593 | 622 | |
594 | - if (!empty($modSettings['cache_enable'])) |
|
595 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
623 | + if (!empty($modSettings['cache_enable'])) { |
|
624 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
625 | + } |
|
596 | 626 | } |
627 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
628 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
597 | 629 | } |
598 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
599 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
600 | 630 | |
601 | 631 | $username = $user_settings['member_name']; |
602 | 632 | |
603 | - if (empty($user_settings['additional_groups'])) |
|
604 | - $user_info = array( |
|
633 | + if (empty($user_settings['additional_groups'])) { |
|
634 | + $user_info = array( |
|
605 | 635 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
606 | 636 | ); |
607 | - else |
|
608 | - $user_info = array( |
|
637 | + } else { |
|
638 | + $user_info = array( |
|
609 | 639 | 'groups' => array_merge( |
610 | 640 | array($user_settings['id_group'], $user_settings['id_post_group']), |
611 | 641 | explode(',', $user_settings['additional_groups']) |
612 | 642 | ) |
613 | 643 | ); |
644 | + } |
|
614 | 645 | |
615 | 646 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
616 | - foreach ($user_info['groups'] as $k => $v) |
|
617 | - $user_info['groups'][$k] = (int) $v; |
|
647 | + foreach ($user_info['groups'] as $k => $v) { |
|
648 | + $user_info['groups'][$k] = (int) $v; |
|
649 | + } |
|
618 | 650 | |
619 | 651 | // This is a logged in user, so definitely not a spider. |
620 | 652 | $user_info['possibly_robot'] = false; |
@@ -628,8 +660,7 @@ discard block |
||
628 | 660 | $time_system = new DateTime('now', $tz_system); |
629 | 661 | $time_user = new DateTime('now', $tz_user); |
630 | 662 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
631 | - } |
|
632 | - else |
|
663 | + } else |
|
633 | 664 | { |
634 | 665 | // !!! Compatibility. |
635 | 666 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -643,8 +674,9 @@ discard block |
||
643 | 674 | $user_info = array('groups' => array(-1)); |
644 | 675 | $user_settings = array(); |
645 | 676 | |
646 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
647 | - $_COOKIE[$cookiename] = ''; |
|
677 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
678 | + $_COOKIE[$cookiename] = ''; |
|
679 | + } |
|
648 | 680 | |
649 | 681 | // Expire the 2FA cookie |
650 | 682 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -661,19 +693,20 @@ discard block |
||
661 | 693 | } |
662 | 694 | |
663 | 695 | // Create a login token if it doesn't exist yet. |
664 | - if (!isset($_SESSION['token']['post-login'])) |
|
665 | - createToken('login'); |
|
666 | - else |
|
667 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
697 | + createToken('login'); |
|
698 | + } else { |
|
699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
700 | + } |
|
668 | 701 | |
669 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
670 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
671 | 704 | { |
672 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
673 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
674 | 709 | } |
675 | - elseif (!empty($modSettings['spider_mode'])) |
|
676 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
677 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
678 | 711 | else |
679 | 712 | { |
@@ -721,8 +754,9 @@ discard block |
||
721 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
722 | 755 | |
723 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
724 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
725 | - unset($user_info['ignoreboards'][$tmp]); |
|
757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
758 | + unset($user_info['ignoreboards'][$tmp]); |
|
759 | + } |
|
726 | 760 | |
727 | 761 | // Allow the user to change their language. |
728 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -735,13 +769,14 @@ discard block |
||
735 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
736 | 770 | |
737 | 771 | // Make it permanent for members. |
738 | - if (!empty($user_info['id'])) |
|
739 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
740 | - else |
|
741 | - $_SESSION['language'] = $user_info['language']; |
|
772 | + if (!empty($user_info['id'])) { |
|
773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
774 | + } else { |
|
775 | + $_SESSION['language'] = $user_info['language']; |
|
776 | + } |
|
777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
742 | 779 | } |
743 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
744 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
745 | 780 | } |
746 | 781 | |
747 | 782 | $temp = build_query_board($user_info['id']); |
@@ -804,9 +839,9 @@ discard block |
||
804 | 839 | } |
805 | 840 | |
806 | 841 | // Remember redirection is the key to avoiding fallout from your bosses. |
807 | - if (!empty($topic)) |
|
808 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
809 | - else |
|
842 | + if (!empty($topic)) { |
|
843 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
844 | + } else |
|
810 | 845 | { |
811 | 846 | loadPermissions(); |
812 | 847 | loadTheme(); |
@@ -824,10 +859,11 @@ discard block |
||
824 | 859 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
825 | 860 | { |
826 | 861 | // @todo SLOW? |
827 | - if (!empty($topic)) |
|
828 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
829 | - else |
|
830 | - $temp = cache_get_data('board-' . $board, 120); |
|
862 | + if (!empty($topic)) { |
|
863 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
864 | + } else { |
|
865 | + $temp = cache_get_data('board-' . $board, 120); |
|
866 | + } |
|
831 | 867 | |
832 | 868 | if (!empty($temp)) |
833 | 869 | { |
@@ -865,8 +901,9 @@ discard block |
||
865 | 901 | $row = $smcFunc['db_fetch_assoc']($request); |
866 | 902 | |
867 | 903 | // Set the current board. |
868 | - if (!empty($row['id_board'])) |
|
869 | - $board = $row['id_board']; |
|
904 | + if (!empty($row['id_board'])) { |
|
905 | + $board = $row['id_board']; |
|
906 | + } |
|
870 | 907 | |
871 | 908 | // Basic operating information. (globals... :/) |
872 | 909 | $board_info = array( |
@@ -902,21 +939,23 @@ discard block |
||
902 | 939 | |
903 | 940 | do |
904 | 941 | { |
905 | - if (!empty($row['id_moderator'])) |
|
906 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
942 | + if (!empty($row['id_moderator'])) { |
|
943 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
907 | 944 | 'id' => $row['id_moderator'], |
908 | 945 | 'name' => $row['real_name'], |
909 | 946 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
910 | 947 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
911 | 948 | ); |
949 | + } |
|
912 | 950 | |
913 | - if (!empty($row['id_moderator_group'])) |
|
914 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
951 | + if (!empty($row['id_moderator_group'])) { |
|
952 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
915 | 953 | 'id' => $row['id_moderator_group'], |
916 | 954 | 'name' => $row['group_name'], |
917 | 955 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
918 | 956 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
919 | 957 | ); |
958 | + } |
|
920 | 959 | } |
921 | 960 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
922 | 961 | |
@@ -948,12 +987,12 @@ discard block |
||
948 | 987 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
949 | 988 | { |
950 | 989 | // @todo SLOW? |
951 | - if (!empty($topic)) |
|
952 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
990 | + if (!empty($topic)) { |
|
991 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
992 | + } |
|
953 | 993 | cache_put_data('board-' . $board, $board_info, 120); |
954 | 994 | } |
955 | - } |
|
956 | - else |
|
995 | + } else |
|
957 | 996 | { |
958 | 997 | // Otherwise the topic is invalid, there are no moderators, etc. |
959 | 998 | $board_info = array( |
@@ -967,8 +1006,9 @@ discard block |
||
967 | 1006 | $smcFunc['db_free_result']($request); |
968 | 1007 | } |
969 | 1008 | |
970 | - if (!empty($topic)) |
|
971 | - $_GET['board'] = (int) $board; |
|
1009 | + if (!empty($topic)) { |
|
1010 | + $_GET['board'] = (int) $board; |
|
1011 | + } |
|
972 | 1012 | |
973 | 1013 | if (!empty($board)) |
974 | 1014 | { |
@@ -978,10 +1018,12 @@ discard block |
||
978 | 1018 | // Now check if the user is a moderator. |
979 | 1019 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
980 | 1020 | |
981 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
982 | - $board_info['error'] = 'access'; |
|
983 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
984 | - $board_info['error'] = 'access'; |
|
1021 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1022 | + $board_info['error'] = 'access'; |
|
1023 | + } |
|
1024 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1025 | + $board_info['error'] = 'access'; |
|
1026 | + } |
|
985 | 1027 | |
986 | 1028 | // Build up the linktree. |
987 | 1029 | $context['linktree'] = array_merge( |
@@ -1004,8 +1046,9 @@ discard block |
||
1004 | 1046 | $context['current_board'] = $board; |
1005 | 1047 | |
1006 | 1048 | // No posting in redirection boards! |
1007 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1008 | - $board_info['error'] == 'post_in_redirect'; |
|
1049 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1050 | + $board_info['error'] == 'post_in_redirect'; |
|
1051 | + } |
|
1009 | 1052 | |
1010 | 1053 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1011 | 1054 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1031,24 +1074,23 @@ discard block |
||
1031 | 1074 | ob_end_clean(); |
1032 | 1075 | header('HTTP/1.1 403 Forbidden'); |
1033 | 1076 | die; |
1034 | - } |
|
1035 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1077 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1036 | 1078 | { |
1037 | 1079 | // Slightly different error message here... |
1038 | 1080 | fatal_lang_error('cannot_post_redirect', false); |
1039 | - } |
|
1040 | - elseif ($user_info['is_guest']) |
|
1081 | + } elseif ($user_info['is_guest']) |
|
1041 | 1082 | { |
1042 | 1083 | loadLanguage('Errors'); |
1043 | 1084 | is_not_guest($txt['topic_gone']); |
1085 | + } else { |
|
1086 | + fatal_lang_error('topic_gone', false); |
|
1044 | 1087 | } |
1045 | - else |
|
1046 | - fatal_lang_error('topic_gone', false); |
|
1047 | 1088 | } |
1048 | 1089 | |
1049 | - if ($user_info['is_mod']) |
|
1050 | - $user_info['groups'][] = 3; |
|
1051 | -} |
|
1090 | + if ($user_info['is_mod']) { |
|
1091 | + $user_info['groups'][] = 3; |
|
1092 | + } |
|
1093 | + } |
|
1052 | 1094 | |
1053 | 1095 | /** |
1054 | 1096 | * Load this user's permissions. |
@@ -1069,8 +1111,9 @@ discard block |
||
1069 | 1111 | asort($cache_groups); |
1070 | 1112 | $cache_groups = implode(',', $cache_groups); |
1071 | 1113 | // If it's a spider then cache it different. |
1072 | - if ($user_info['possibly_robot']) |
|
1073 | - $cache_groups .= '-spider'; |
|
1114 | + if ($user_info['possibly_robot']) { |
|
1115 | + $cache_groups .= '-spider'; |
|
1116 | + } |
|
1074 | 1117 | |
1075 | 1118 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1076 | 1119 | { |
@@ -1078,9 +1121,9 @@ discard block |
||
1078 | 1121 | banPermissions(); |
1079 | 1122 | |
1080 | 1123 | return; |
1124 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1125 | + list ($user_info['permissions'], $removals) = $temp; |
|
1081 | 1126 | } |
1082 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1083 | - list ($user_info['permissions'], $removals) = $temp; |
|
1084 | 1127 | } |
1085 | 1128 | |
1086 | 1129 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1102,23 +1145,26 @@ discard block |
||
1102 | 1145 | $removals = array(); |
1103 | 1146 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1104 | 1147 | { |
1105 | - if (empty($row['add_deny'])) |
|
1106 | - $removals[] = $row['permission']; |
|
1107 | - else |
|
1108 | - $user_info['permissions'][] = $row['permission']; |
|
1148 | + if (empty($row['add_deny'])) { |
|
1149 | + $removals[] = $row['permission']; |
|
1150 | + } else { |
|
1151 | + $user_info['permissions'][] = $row['permission']; |
|
1152 | + } |
|
1109 | 1153 | } |
1110 | 1154 | $smcFunc['db_free_result']($request); |
1111 | 1155 | |
1112 | - if (isset($cache_groups)) |
|
1113 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1156 | + if (isset($cache_groups)) { |
|
1157 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1158 | + } |
|
1114 | 1159 | } |
1115 | 1160 | |
1116 | 1161 | // Get the board permissions. |
1117 | 1162 | if (!empty($board)) |
1118 | 1163 | { |
1119 | 1164 | // Make sure the board (if any) has been loaded by loadBoard(). |
1120 | - if (!isset($board_info['profile'])) |
|
1121 | - fatal_lang_error('no_board'); |
|
1165 | + if (!isset($board_info['profile'])) { |
|
1166 | + fatal_lang_error('no_board'); |
|
1167 | + } |
|
1122 | 1168 | |
1123 | 1169 | $request = $smcFunc['db_query']('', ' |
1124 | 1170 | SELECT permission, add_deny |
@@ -1134,20 +1180,23 @@ discard block |
||
1134 | 1180 | ); |
1135 | 1181 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1136 | 1182 | { |
1137 | - if (empty($row['add_deny'])) |
|
1138 | - $removals[] = $row['permission']; |
|
1139 | - else |
|
1140 | - $user_info['permissions'][] = $row['permission']; |
|
1183 | + if (empty($row['add_deny'])) { |
|
1184 | + $removals[] = $row['permission']; |
|
1185 | + } else { |
|
1186 | + $user_info['permissions'][] = $row['permission']; |
|
1187 | + } |
|
1141 | 1188 | } |
1142 | 1189 | $smcFunc['db_free_result']($request); |
1143 | 1190 | } |
1144 | 1191 | |
1145 | 1192 | // Remove all the permissions they shouldn't have ;). |
1146 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1147 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1193 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1194 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1195 | + } |
|
1148 | 1196 | |
1149 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1150 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1197 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1198 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1199 | + } |
|
1151 | 1200 | |
1152 | 1201 | // Banned? Watch, don't touch.. |
1153 | 1202 | banPermissions(); |
@@ -1159,17 +1208,18 @@ discard block |
||
1159 | 1208 | { |
1160 | 1209 | require_once($sourcedir . '/Subs-Auth.php'); |
1161 | 1210 | rebuildModCache(); |
1211 | + } else { |
|
1212 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1162 | 1213 | } |
1163 | - else |
|
1164 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1165 | 1214 | |
1166 | 1215 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1167 | 1216 | // For example this drastically simplifies certain changes to the profile area. |
1168 | 1217 | $user_info['permissions'][] = 'is_not_guest'; |
1169 | 1218 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1170 | 1219 | $user_info['permissions'][] = 'profile_view_own'; |
1171 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1172 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1220 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1221 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1222 | + } |
|
1173 | 1223 | } |
1174 | 1224 | } |
1175 | 1225 | |
@@ -1187,8 +1237,9 @@ discard block |
||
1187 | 1237 | global $image_proxy_enabled, $boardurl, $user_info; |
1188 | 1238 | |
1189 | 1239 | // Can't just look for no users :P. |
1190 | - if (empty($users)) |
|
1191 | - return array(); |
|
1240 | + if (empty($users)) { |
|
1241 | + return array(); |
|
1242 | + } |
|
1192 | 1243 | |
1193 | 1244 | // Pass the set value |
1194 | 1245 | $context['loadMemberContext_set'] = $set; |
@@ -1203,8 +1254,9 @@ discard block |
||
1203 | 1254 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1204 | 1255 | { |
1205 | 1256 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1206 | - if ($data == null) |
|
1207 | - continue; |
|
1257 | + if ($data == null) { |
|
1258 | + continue; |
|
1259 | + } |
|
1208 | 1260 | |
1209 | 1261 | $loaded_ids[] = $data['id_member']; |
1210 | 1262 | $user_profile[$data['id_member']] = $data; |
@@ -1271,16 +1323,19 @@ discard block |
||
1271 | 1323 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1272 | 1324 | |
1273 | 1325 | // Take care of proxying avatar if required, do this here for maximum reach |
1274 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
1275 | - $row['avatar'] = get_proxied_url($row['avatar']); |
|
1326 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
1327 | + $row['avatar'] = get_proxied_url($row['avatar']); |
|
1328 | + } |
|
1276 | 1329 | |
1277 | 1330 | // Keep track of the member's normal member group |
1278 | 1331 | $row['primary_group'] = $row['member_group']; |
1279 | 1332 | |
1280 | - if (isset($row['member_ip'])) |
|
1281 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1282 | - if (isset($row['member_ip2'])) |
|
1283 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1333 | + if (isset($row['member_ip'])) { |
|
1334 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1335 | + } |
|
1336 | + if (isset($row['member_ip2'])) { |
|
1337 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1338 | + } |
|
1284 | 1339 | $new_loaded_ids[] = $row['id_member']; |
1285 | 1340 | $loaded_ids[] = $row['id_member']; |
1286 | 1341 | $row['options'] = array(); |
@@ -1299,8 +1354,9 @@ discard block |
||
1299 | 1354 | 'loaded_ids' => $new_loaded_ids, |
1300 | 1355 | ) |
1301 | 1356 | ); |
1302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1303 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1357 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1358 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1359 | + } |
|
1304 | 1360 | $smcFunc['db_free_result']($request); |
1305 | 1361 | } |
1306 | 1362 | |
@@ -1311,10 +1367,11 @@ discard block |
||
1311 | 1367 | { |
1312 | 1368 | foreach ($loaded_ids as $a_member) |
1313 | 1369 | { |
1314 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1315 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1316 | - else |
|
1317 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1370 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1371 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1372 | + } else { |
|
1373 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1374 | + } |
|
1318 | 1375 | |
1319 | 1376 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1320 | 1377 | |
@@ -1327,8 +1384,9 @@ discard block |
||
1327 | 1384 | |
1328 | 1385 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1329 | 1386 | { |
1330 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1331 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1387 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1388 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1389 | + } |
|
1332 | 1390 | } |
1333 | 1391 | |
1334 | 1392 | // Are we loading any moderators? If so, fix their group data... |
@@ -1354,14 +1412,17 @@ discard block |
||
1354 | 1412 | foreach ($temp_mods as $id) |
1355 | 1413 | { |
1356 | 1414 | // By popular demand, don't show admins or global moderators as moderators. |
1357 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1358 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1415 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1416 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1417 | + } |
|
1359 | 1418 | |
1360 | 1419 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1361 | - if (!empty($row['icons'])) |
|
1362 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1363 | - if (!empty($row['member_group_color'])) |
|
1364 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1420 | + if (!empty($row['icons'])) { |
|
1421 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1422 | + } |
|
1423 | + if (!empty($row['member_group_color'])) { |
|
1424 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1425 | + } |
|
1365 | 1426 | } |
1366 | 1427 | } |
1367 | 1428 | |
@@ -1383,12 +1444,14 @@ discard block |
||
1383 | 1444 | static $loadedLanguages = array(); |
1384 | 1445 | |
1385 | 1446 | // If this person's data is already loaded, skip it. |
1386 | - if (isset($dataLoaded[$user])) |
|
1387 | - return true; |
|
1447 | + if (isset($dataLoaded[$user])) { |
|
1448 | + return true; |
|
1449 | + } |
|
1388 | 1450 | |
1389 | 1451 | // We can't load guests or members not loaded by loadMemberData()! |
1390 | - if ($user == 0) |
|
1391 | - return false; |
|
1452 | + if ($user == 0) { |
|
1453 | + return false; |
|
1454 | + } |
|
1392 | 1455 | if (!isset($user_profile[$user])) |
1393 | 1456 | { |
1394 | 1457 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1414,12 +1477,16 @@ discard block |
||
1414 | 1477 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1415 | 1478 | |
1416 | 1479 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1417 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1480 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1481 | + //icon is set and exists |
|
1418 | 1482 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1419 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1483 | + } elseif (isset($profile['icons'][1])) { |
|
1484 | + //icon is set and doesn't exist, fallback to default |
|
1420 | 1485 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1421 | - else //not set, bye bye |
|
1486 | + } else { |
|
1487 | + //not set, bye bye |
|
1422 | 1488 | $group_icon_url = ''; |
1489 | + } |
|
1423 | 1490 | |
1424 | 1491 | // These minimal values are always loaded |
1425 | 1492 | $memberContext[$user] = array( |
@@ -1438,8 +1505,9 @@ discard block |
||
1438 | 1505 | if ($context['loadMemberContext_set'] != 'minimal') |
1439 | 1506 | { |
1440 | 1507 | // Go the extra mile and load the user's native language name. |
1441 | - if (empty($loadedLanguages)) |
|
1442 | - $loadedLanguages = getLanguages(); |
|
1508 | + if (empty($loadedLanguages)) { |
|
1509 | + $loadedLanguages = getLanguages(); |
|
1510 | + } |
|
1443 | 1511 | |
1444 | 1512 | $memberContext[$user] += array( |
1445 | 1513 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1494,31 +1562,33 @@ discard block |
||
1494 | 1562 | { |
1495 | 1563 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1496 | 1564 | { |
1497 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1498 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1499 | - else |
|
1500 | - $image = get_gravatar_url($profile['email_address']); |
|
1501 | - } |
|
1502 | - else |
|
1565 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1566 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1567 | + } else { |
|
1568 | + $image = get_gravatar_url($profile['email_address']); |
|
1569 | + } |
|
1570 | + } else |
|
1503 | 1571 | { |
1504 | 1572 | // So it's stored in the member table? |
1505 | 1573 | if (!empty($profile['avatar'])) |
1506 | 1574 | { |
1507 | 1575 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1576 | + } elseif (!empty($profile['filename'])) { |
|
1577 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1508 | 1578 | } |
1509 | - elseif (!empty($profile['filename'])) |
|
1510 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1511 | 1579 | // Right... no avatar...use the default one |
1512 | - else |
|
1513 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1580 | + else { |
|
1581 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1582 | + } |
|
1514 | 1583 | } |
1515 | - if (!empty($image)) |
|
1516 | - $memberContext[$user]['avatar'] = array( |
|
1584 | + if (!empty($image)) { |
|
1585 | + $memberContext[$user]['avatar'] = array( |
|
1517 | 1586 | 'name' => $profile['avatar'], |
1518 | 1587 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1519 | 1588 | 'href' => $image, |
1520 | 1589 | 'url' => $image, |
1521 | 1590 | ); |
1591 | + } |
|
1522 | 1592 | } |
1523 | 1593 | |
1524 | 1594 | // Are we also loading the members custom fields into context? |
@@ -1526,13 +1596,15 @@ discard block |
||
1526 | 1596 | { |
1527 | 1597 | $memberContext[$user]['custom_fields'] = array(); |
1528 | 1598 | |
1529 | - if (!isset($context['display_fields'])) |
|
1530 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1599 | + if (!isset($context['display_fields'])) { |
|
1600 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1601 | + } |
|
1531 | 1602 | |
1532 | 1603 | foreach ($context['display_fields'] as $custom) |
1533 | 1604 | { |
1534 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1535 | - continue; |
|
1605 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1606 | + continue; |
|
1607 | + } |
|
1536 | 1608 | |
1537 | 1609 | $value = $profile['options'][$custom['col_name']]; |
1538 | 1610 | |
@@ -1540,31 +1612,36 @@ discard block |
||
1540 | 1612 | $currentKey = 0; |
1541 | 1613 | |
1542 | 1614 | // Create a key => value array for multiple options fields |
1543 | - if (!empty($custom['options'])) |
|
1544 | - foreach ($custom['options'] as $k => $v) |
|
1615 | + if (!empty($custom['options'])) { |
|
1616 | + foreach ($custom['options'] as $k => $v) |
|
1545 | 1617 | { |
1546 | 1618 | $fieldOptions[] = $v; |
1547 | - if (empty($currentKey)) |
|
1548 | - $currentKey = $v == $value ? $k : 0; |
|
1619 | + } |
|
1620 | + if (empty($currentKey)) { |
|
1621 | + $currentKey = $v == $value ? $k : 0; |
|
1622 | + } |
|
1549 | 1623 | } |
1550 | 1624 | |
1551 | 1625 | // BBC? |
1552 | - if ($custom['bbc']) |
|
1553 | - $value = parse_bbc($value); |
|
1626 | + if ($custom['bbc']) { |
|
1627 | + $value = parse_bbc($value); |
|
1628 | + } |
|
1554 | 1629 | |
1555 | 1630 | // ... or checkbox? |
1556 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1557 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1631 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1632 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1633 | + } |
|
1558 | 1634 | |
1559 | 1635 | // Enclosing the user input within some other text? |
1560 | - if (!empty($custom['enclose'])) |
|
1561 | - $value = strtr($custom['enclose'], array( |
|
1636 | + if (!empty($custom['enclose'])) { |
|
1637 | + $value = strtr($custom['enclose'], array( |
|
1562 | 1638 | '{SCRIPTURL}' => $scripturl, |
1563 | 1639 | '{IMAGES_URL}' => $settings['images_url'], |
1564 | 1640 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1565 | 1641 | '{INPUT}' => $value, |
1566 | 1642 | '{KEY}' => $currentKey, |
1567 | 1643 | )); |
1644 | + } |
|
1568 | 1645 | |
1569 | 1646 | $memberContext[$user]['custom_fields'][] = array( |
1570 | 1647 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1591,8 +1668,9 @@ discard block |
||
1591 | 1668 | global $smcFunc, $txt, $scripturl, $settings; |
1592 | 1669 | |
1593 | 1670 | // Do not waste my time... |
1594 | - if (empty($users) || empty($params)) |
|
1595 | - return false; |
|
1671 | + if (empty($users) || empty($params)) { |
|
1672 | + return false; |
|
1673 | + } |
|
1596 | 1674 | |
1597 | 1675 | // Make sure it's an array. |
1598 | 1676 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1619,41 +1697,48 @@ discard block |
||
1619 | 1697 | $currentKey = 0; |
1620 | 1698 | |
1621 | 1699 | // Create a key => value array for multiple options fields |
1622 | - if (!empty($row['field_options'])) |
|
1623 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1700 | + if (!empty($row['field_options'])) { |
|
1701 | + foreach (explode(',', $row['field_options']) as $k => $v) |
|
1624 | 1702 | { |
1625 | 1703 | $fieldOptions[] = $v; |
1626 | - if (empty($currentKey)) |
|
1627 | - $currentKey = $v == $row['value'] ? $k : 0; |
|
1704 | + } |
|
1705 | + if (empty($currentKey)) { |
|
1706 | + $currentKey = $v == $row['value'] ? $k : 0; |
|
1707 | + } |
|
1628 | 1708 | } |
1629 | 1709 | |
1630 | 1710 | // BBC? |
1631 | - if (!empty($row['bbc'])) |
|
1632 | - $row['value'] = parse_bbc($row['value']); |
|
1711 | + if (!empty($row['bbc'])) { |
|
1712 | + $row['value'] = parse_bbc($row['value']); |
|
1713 | + } |
|
1633 | 1714 | |
1634 | 1715 | // ... or checkbox? |
1635 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1636 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1716 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1717 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1718 | + } |
|
1637 | 1719 | |
1638 | 1720 | // Enclosing the user input within some other text? |
1639 | - if (!empty($row['enclose'])) |
|
1640 | - $row['value'] = strtr($row['enclose'], array( |
|
1721 | + if (!empty($row['enclose'])) { |
|
1722 | + $row['value'] = strtr($row['enclose'], array( |
|
1641 | 1723 | '{SCRIPTURL}' => $scripturl, |
1642 | 1724 | '{IMAGES_URL}' => $settings['images_url'], |
1643 | 1725 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1644 | 1726 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1645 | 1727 | '{KEY}' => $currentKey, |
1646 | 1728 | )); |
1729 | + } |
|
1647 | 1730 | |
1648 | 1731 | // Send a simple array if there is just 1 param |
1649 | - if (count($params) == 1) |
|
1650 | - $return[$row['id_member']] = $row; |
|
1732 | + if (count($params) == 1) { |
|
1733 | + $return[$row['id_member']] = $row; |
|
1734 | + } |
|
1651 | 1735 | |
1652 | 1736 | // More than 1? knock yourself out... |
1653 | 1737 | else |
1654 | 1738 | { |
1655 | - if (!isset($return[$row['id_member']])) |
|
1656 | - $return[$row['id_member']] = array(); |
|
1739 | + if (!isset($return[$row['id_member']])) { |
|
1740 | + $return[$row['id_member']] = array(); |
|
1741 | + } |
|
1657 | 1742 | |
1658 | 1743 | $return[$row['id_member']][$row['variable']] = $row; |
1659 | 1744 | } |
@@ -1687,8 +1772,9 @@ discard block |
||
1687 | 1772 | global $context; |
1688 | 1773 | |
1689 | 1774 | // Don't know any browser! |
1690 | - if (empty($context['browser'])) |
|
1691 | - detectBrowser(); |
|
1775 | + if (empty($context['browser'])) { |
|
1776 | + detectBrowser(); |
|
1777 | + } |
|
1692 | 1778 | |
1693 | 1779 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1694 | 1780 | } |
@@ -1706,8 +1792,9 @@ discard block |
||
1706 | 1792 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1707 | 1793 | |
1708 | 1794 | // The theme was specified by parameter. |
1709 | - if (!empty($id_theme)) |
|
1710 | - $id_theme = (int) $id_theme; |
|
1795 | + if (!empty($id_theme)) { |
|
1796 | + $id_theme = (int) $id_theme; |
|
1797 | + } |
|
1711 | 1798 | // The theme was specified by REQUEST. |
1712 | 1799 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1713 | 1800 | { |
@@ -1715,32 +1802,38 @@ discard block |
||
1715 | 1802 | $_SESSION['id_theme'] = $id_theme; |
1716 | 1803 | } |
1717 | 1804 | // The theme was specified by REQUEST... previously. |
1718 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1719 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1805 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1806 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1807 | + } |
|
1720 | 1808 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1721 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1722 | - $id_theme = $user_info['theme']; |
|
1809 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1810 | + $id_theme = $user_info['theme']; |
|
1811 | + } |
|
1723 | 1812 | // The theme was specified by the board. |
1724 | - elseif (!empty($board_info['theme'])) |
|
1725 | - $id_theme = $board_info['theme']; |
|
1813 | + elseif (!empty($board_info['theme'])) { |
|
1814 | + $id_theme = $board_info['theme']; |
|
1815 | + } |
|
1726 | 1816 | // The theme is the forum's default. |
1727 | - else |
|
1728 | - $id_theme = $modSettings['theme_guests']; |
|
1817 | + else { |
|
1818 | + $id_theme = $modSettings['theme_guests']; |
|
1819 | + } |
|
1729 | 1820 | |
1730 | 1821 | // Verify the id_theme... no foul play. |
1731 | 1822 | // Always allow the board specific theme, if they are overriding. |
1732 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1733 | - $id_theme = $board_info['theme']; |
|
1823 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1824 | + $id_theme = $board_info['theme']; |
|
1825 | + } |
|
1734 | 1826 | // If they have specified a particular theme to use with SSI allow it to be used. |
1735 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1736 | - $id_theme = (int) $id_theme; |
|
1737 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1827 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1828 | + $id_theme = (int) $id_theme; |
|
1829 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1738 | 1830 | { |
1739 | 1831 | $themes = explode(',', $modSettings['enableThemes']); |
1740 | - if (!in_array($id_theme, $themes)) |
|
1741 | - $id_theme = $modSettings['theme_guests']; |
|
1742 | - else |
|
1743 | - $id_theme = (int) $id_theme; |
|
1832 | + if (!in_array($id_theme, $themes)) { |
|
1833 | + $id_theme = $modSettings['theme_guests']; |
|
1834 | + } else { |
|
1835 | + $id_theme = (int) $id_theme; |
|
1836 | + } |
|
1744 | 1837 | } |
1745 | 1838 | |
1746 | 1839 | // We already load the basic stuff? |
@@ -1749,18 +1842,19 @@ discard block |
||
1749 | 1842 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1750 | 1843 | |
1751 | 1844 | // Disable image proxy if we don't have SSL enabled |
1752 | - if (empty($modSettings['force_ssl'])) |
|
1753 | - $image_proxy_enabled = false; |
|
1845 | + if (empty($modSettings['force_ssl'])) { |
|
1846 | + $image_proxy_enabled = false; |
|
1847 | + } |
|
1754 | 1848 | |
1755 | 1849 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1756 | 1850 | { |
1757 | 1851 | $themeData = $temp; |
1758 | 1852 | $flag = true; |
1853 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1854 | + $themeData = $temp + array($member => array()); |
|
1855 | + } else { |
|
1856 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1759 | 1857 | } |
1760 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1761 | - $themeData = $temp + array($member => array()); |
|
1762 | - else |
|
1763 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1764 | 1858 | |
1765 | 1859 | if (empty($flag)) |
1766 | 1860 | { |
@@ -1780,31 +1874,37 @@ discard block |
||
1780 | 1874 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1781 | 1875 | { |
1782 | 1876 | // There are just things we shouldn't be able to change as members. |
1783 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1784 | - continue; |
|
1877 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1878 | + continue; |
|
1879 | + } |
|
1785 | 1880 | |
1786 | 1881 | // If this is the theme_dir of the default theme, store it. |
1787 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1788 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1882 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1883 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1884 | + } |
|
1789 | 1885 | |
1790 | 1886 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1791 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1792 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1887 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1888 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1889 | + } |
|
1793 | 1890 | } |
1794 | 1891 | $smcFunc['db_free_result']($result); |
1795 | 1892 | |
1796 | - if (!empty($themeData[-1])) |
|
1797 | - foreach ($themeData[-1] as $k => $v) |
|
1893 | + if (!empty($themeData[-1])) { |
|
1894 | + foreach ($themeData[-1] as $k => $v) |
|
1798 | 1895 | { |
1799 | 1896 | if (!isset($themeData[$member][$k])) |
1800 | 1897 | $themeData[$member][$k] = $v; |
1898 | + } |
|
1801 | 1899 | } |
1802 | 1900 | |
1803 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1804 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1901 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1902 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1903 | + } |
|
1805 | 1904 | // Only if we didn't already load that part of the cache... |
1806 | - elseif (!isset($temp)) |
|
1807 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1905 | + elseif (!isset($temp)) { |
|
1906 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1907 | + } |
|
1808 | 1908 | } |
1809 | 1909 | |
1810 | 1910 | $settings = $themeData[0]; |
@@ -1821,17 +1921,20 @@ discard block |
||
1821 | 1921 | $settings['template_dirs'][] = $settings['theme_dir']; |
1822 | 1922 | |
1823 | 1923 | // Based on theme (if there is one). |
1824 | - if (!empty($settings['base_theme_dir'])) |
|
1825 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1924 | + if (!empty($settings['base_theme_dir'])) { |
|
1925 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1926 | + } |
|
1826 | 1927 | |
1827 | 1928 | // Lastly the default theme. |
1828 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1829 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1929 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1930 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1931 | + } |
|
1830 | 1932 | } |
1831 | 1933 | |
1832 | 1934 | |
1833 | - if (!$initialize) |
|
1834 | - return; |
|
1935 | + if (!$initialize) { |
|
1936 | + return; |
|
1937 | + } |
|
1835 | 1938 | |
1836 | 1939 | // Check to see if we're forcing SSL |
1837 | 1940 | if (!empty($modSettings['force_ssl']) && empty($maintenance) && |
@@ -1852,8 +1955,9 @@ discard block |
||
1852 | 1955 | $detected_url = httpsOn() ? 'https://' : 'http://'; |
1853 | 1956 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1854 | 1957 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1855 | - if ($temp != '/') |
|
1856 | - $detected_url .= $temp; |
|
1958 | + if ($temp != '/') { |
|
1959 | + $detected_url .= $temp; |
|
1960 | + } |
|
1857 | 1961 | } |
1858 | 1962 | if (isset($detected_url) && $detected_url != $boardurl) |
1859 | 1963 | { |
@@ -1865,8 +1969,9 @@ discard block |
||
1865 | 1969 | foreach ($aliases as $alias) |
1866 | 1970 | { |
1867 | 1971 | // Rip off all the boring parts, spaces, etc. |
1868 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1869 | - $do_fix = true; |
|
1972 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1973 | + $do_fix = true; |
|
1974 | + } |
|
1870 | 1975 | } |
1871 | 1976 | } |
1872 | 1977 | |
@@ -1874,21 +1979,23 @@ discard block |
||
1874 | 1979 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1875 | 1980 | { |
1876 | 1981 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1877 | - if (empty($_GET)) |
|
1878 | - redirectexit('wwwRedirect'); |
|
1879 | - else |
|
1982 | + if (empty($_GET)) { |
|
1983 | + redirectexit('wwwRedirect'); |
|
1984 | + } else |
|
1880 | 1985 | { |
1881 | 1986 | $k = key($_GET); |
1882 | 1987 | $v = current($_GET); |
1883 | 1988 | |
1884 | - if ($k != 'wwwRedirect') |
|
1885 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1989 | + if ($k != 'wwwRedirect') { |
|
1990 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1991 | + } |
|
1886 | 1992 | } |
1887 | 1993 | } |
1888 | 1994 | |
1889 | 1995 | // #3 is just a check for SSL... |
1890 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1891 | - $do_fix = true; |
|
1996 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1997 | + $do_fix = true; |
|
1998 | + } |
|
1892 | 1999 | |
1893 | 2000 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1894 | 2001 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1923,8 +2030,9 @@ discard block |
||
1923 | 2030 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1924 | 2031 | } |
1925 | 2032 | } |
1926 | - foreach ($context['linktree'] as $k => $dummy) |
|
1927 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2033 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2034 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2035 | + } |
|
1928 | 2036 | } |
1929 | 2037 | } |
1930 | 2038 | // Set up the contextual user array. |
@@ -1943,16 +2051,16 @@ discard block |
||
1943 | 2051 | 'email' => $user_info['email'], |
1944 | 2052 | 'ignoreusers' => $user_info['ignoreusers'], |
1945 | 2053 | ); |
1946 | - if (!$context['user']['is_guest']) |
|
1947 | - $context['user']['name'] = $user_info['name']; |
|
1948 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1949 | - $context['user']['name'] = $txt['guest_title']; |
|
2054 | + if (!$context['user']['is_guest']) { |
|
2055 | + $context['user']['name'] = $user_info['name']; |
|
2056 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2057 | + $context['user']['name'] = $txt['guest_title']; |
|
2058 | + } |
|
1950 | 2059 | |
1951 | 2060 | // Determine the current smiley set. |
1952 | 2061 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1953 | 2062 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1954 | - } |
|
1955 | - else |
|
2063 | + } else |
|
1956 | 2064 | { |
1957 | 2065 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1958 | 2066 | $context['user'] = array( |
@@ -1986,18 +2094,24 @@ discard block |
||
1986 | 2094 | } |
1987 | 2095 | |
1988 | 2096 | // Some basic information... |
1989 | - if (!isset($context['html_headers'])) |
|
1990 | - $context['html_headers'] = ''; |
|
1991 | - if (!isset($context['javascript_files'])) |
|
1992 | - $context['javascript_files'] = array(); |
|
1993 | - if (!isset($context['css_files'])) |
|
1994 | - $context['css_files'] = array(); |
|
1995 | - if (!isset($context['css_header'])) |
|
1996 | - $context['css_header'] = array(); |
|
1997 | - if (!isset($context['javascript_inline'])) |
|
1998 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1999 | - if (!isset($context['javascript_vars'])) |
|
2000 | - $context['javascript_vars'] = array(); |
|
2097 | + if (!isset($context['html_headers'])) { |
|
2098 | + $context['html_headers'] = ''; |
|
2099 | + } |
|
2100 | + if (!isset($context['javascript_files'])) { |
|
2101 | + $context['javascript_files'] = array(); |
|
2102 | + } |
|
2103 | + if (!isset($context['css_files'])) { |
|
2104 | + $context['css_files'] = array(); |
|
2105 | + } |
|
2106 | + if (!isset($context['css_header'])) { |
|
2107 | + $context['css_header'] = array(); |
|
2108 | + } |
|
2109 | + if (!isset($context['javascript_inline'])) { |
|
2110 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2111 | + } |
|
2112 | + if (!isset($context['javascript_vars'])) { |
|
2113 | + $context['javascript_vars'] = array(); |
|
2114 | + } |
|
2001 | 2115 | |
2002 | 2116 | $context['login_url'] = $scripturl . '?action=login2'; |
2003 | 2117 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2009,16 +2123,18 @@ discard block |
||
2009 | 2123 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
2010 | 2124 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
2011 | 2125 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
2012 | - if (isset($modSettings['load_average'])) |
|
2013 | - $context['load_average'] = $modSettings['load_average']; |
|
2126 | + if (isset($modSettings['load_average'])) { |
|
2127 | + $context['load_average'] = $modSettings['load_average']; |
|
2128 | + } |
|
2014 | 2129 | |
2015 | 2130 | // Detect the browser. This is separated out because it's also used in attachment downloads |
2016 | 2131 | detectBrowser(); |
2017 | 2132 | |
2018 | 2133 | // Set the top level linktree up. |
2019 | 2134 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
2020 | - if (empty($context['linktree'])) |
|
2021 | - $context['linktree'] = array(); |
|
2135 | + if (empty($context['linktree'])) { |
|
2136 | + $context['linktree'] = array(); |
|
2137 | + } |
|
2022 | 2138 | array_unshift($context['linktree'], array( |
2023 | 2139 | 'url' => $scripturl, |
2024 | 2140 | 'name' => $context['forum_name_html_safe'] |
@@ -2027,8 +2143,9 @@ discard block |
||
2027 | 2143 | // This allows sticking some HTML on the page output - useful for controls. |
2028 | 2144 | $context['insert_after_template'] = ''; |
2029 | 2145 | |
2030 | - if (!isset($txt)) |
|
2031 | - $txt = array(); |
|
2146 | + if (!isset($txt)) { |
|
2147 | + $txt = array(); |
|
2148 | + } |
|
2032 | 2149 | |
2033 | 2150 | $simpleActions = array( |
2034 | 2151 | 'findmember', |
@@ -2074,9 +2191,10 @@ discard block |
||
2074 | 2191 | |
2075 | 2192 | // See if theres any extra param to check. |
2076 | 2193 | $requiresXML = false; |
2077 | - foreach ($extraParams as $key => $extra) |
|
2078 | - if (isset($_REQUEST[$extra])) |
|
2194 | + foreach ($extraParams as $key => $extra) { |
|
2195 | + if (isset($_REQUEST[$extra])) |
|
2079 | 2196 | $requiresXML = true; |
2197 | + } |
|
2080 | 2198 | |
2081 | 2199 | // Output is fully XML, so no need for the index template. |
2082 | 2200 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2091,37 +2209,39 @@ discard block |
||
2091 | 2209 | { |
2092 | 2210 | loadLanguage('index+Modifications'); |
2093 | 2211 | $context['template_layers'] = array(); |
2094 | - } |
|
2095 | - |
|
2096 | - else |
|
2212 | + } else |
|
2097 | 2213 | { |
2098 | 2214 | // Custom templates to load, or just default? |
2099 | - if (isset($settings['theme_templates'])) |
|
2100 | - $templates = explode(',', $settings['theme_templates']); |
|
2101 | - else |
|
2102 | - $templates = array('index'); |
|
2215 | + if (isset($settings['theme_templates'])) { |
|
2216 | + $templates = explode(',', $settings['theme_templates']); |
|
2217 | + } else { |
|
2218 | + $templates = array('index'); |
|
2219 | + } |
|
2103 | 2220 | |
2104 | 2221 | // Load each template... |
2105 | - foreach ($templates as $template) |
|
2106 | - loadTemplate($template); |
|
2222 | + foreach ($templates as $template) { |
|
2223 | + loadTemplate($template); |
|
2224 | + } |
|
2107 | 2225 | |
2108 | 2226 | // ...and attempt to load their associated language files. |
2109 | 2227 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2110 | 2228 | loadLanguage($required_files, '', false); |
2111 | 2229 | |
2112 | 2230 | // Custom template layers? |
2113 | - if (isset($settings['theme_layers'])) |
|
2114 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2115 | - else |
|
2116 | - $context['template_layers'] = array('html', 'body'); |
|
2231 | + if (isset($settings['theme_layers'])) { |
|
2232 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2233 | + } else { |
|
2234 | + $context['template_layers'] = array('html', 'body'); |
|
2235 | + } |
|
2117 | 2236 | } |
2118 | 2237 | |
2119 | 2238 | // Initialize the theme. |
2120 | 2239 | loadSubTemplate('init', 'ignore'); |
2121 | 2240 | |
2122 | 2241 | // Allow overriding the board wide time/number formats. |
2123 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2124 | - $user_info['time_format'] = $txt['time_format']; |
|
2242 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2243 | + $user_info['time_format'] = $txt['time_format']; |
|
2244 | + } |
|
2125 | 2245 | |
2126 | 2246 | // Set the character set from the template. |
2127 | 2247 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2129,12 +2249,14 @@ discard block |
||
2129 | 2249 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2130 | 2250 | |
2131 | 2251 | // Guests may still need a name. |
2132 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2133 | - $context['user']['name'] = $txt['guest_title']; |
|
2252 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2253 | + $context['user']['name'] = $txt['guest_title']; |
|
2254 | + } |
|
2134 | 2255 | |
2135 | 2256 | // Any theme-related strings that need to be loaded? |
2136 | - if (!empty($settings['require_theme_strings'])) |
|
2137 | - loadLanguage('ThemeStrings', '', false); |
|
2257 | + if (!empty($settings['require_theme_strings'])) { |
|
2258 | + loadLanguage('ThemeStrings', '', false); |
|
2259 | + } |
|
2138 | 2260 | |
2139 | 2261 | // Make a special URL for the language. |
2140 | 2262 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2145,8 +2267,9 @@ discard block |
||
2145 | 2267 | // Here is my luvly Responsive CSS |
2146 | 2268 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive'); |
2147 | 2269 | |
2148 | - if ($context['right_to_left']) |
|
2149 | - loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
2270 | + if ($context['right_to_left']) { |
|
2271 | + loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
2272 | + } |
|
2150 | 2273 | |
2151 | 2274 | // We allow theme variants, because we're cool. |
2152 | 2275 | $context['theme_variant'] = ''; |
@@ -2154,14 +2277,17 @@ discard block |
||
2154 | 2277 | if (!empty($settings['theme_variants'])) |
2155 | 2278 | { |
2156 | 2279 | // Overriding - for previews and that ilk. |
2157 | - if (!empty($_REQUEST['variant'])) |
|
2158 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2280 | + if (!empty($_REQUEST['variant'])) { |
|
2281 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2282 | + } |
|
2159 | 2283 | // User selection? |
2160 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2161 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2284 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2285 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2286 | + } |
|
2162 | 2287 | // If not a user variant, select the default. |
2163 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2164 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2288 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2289 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2290 | + } |
|
2165 | 2291 | |
2166 | 2292 | // Do this to keep things easier in the templates. |
2167 | 2293 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2170,20 +2296,23 @@ discard block |
||
2170 | 2296 | if (!empty($context['theme_variant'])) |
2171 | 2297 | { |
2172 | 2298 | loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']); |
2173 | - if ($context['right_to_left']) |
|
2174 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
2299 | + if ($context['right_to_left']) { |
|
2300 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
2301 | + } |
|
2175 | 2302 | } |
2176 | 2303 | } |
2177 | 2304 | |
2178 | 2305 | // Let's be compatible with old themes! |
2179 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2180 | - $context['template_layers'] = array('main'); |
|
2306 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2307 | + $context['template_layers'] = array('main'); |
|
2308 | + } |
|
2181 | 2309 | |
2182 | 2310 | $context['tabindex'] = 1; |
2183 | 2311 | |
2184 | 2312 | // Compatibility. |
2185 | - if (!isset($settings['theme_version'])) |
|
2186 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2313 | + if (!isset($settings['theme_version'])) { |
|
2314 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2315 | + } |
|
2187 | 2316 | |
2188 | 2317 | // Default JS variables for use in every theme |
2189 | 2318 | $context['javascript_vars'] = array( |
@@ -2202,18 +2331,18 @@ discard block |
||
2202 | 2331 | ); |
2203 | 2332 | |
2204 | 2333 | // Add the JQuery library to the list of files to load. |
2205 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2206 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2207 | - |
|
2208 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2209 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2210 | - |
|
2211 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2212 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2334 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2335 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2336 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2337 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2338 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2339 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2340 | + } |
|
2213 | 2341 | |
2214 | 2342 | // Auto loading? template_javascript() will take care of the local half of this. |
2215 | - else |
|
2216 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2343 | + else { |
|
2344 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2345 | + } |
|
2217 | 2346 | |
2218 | 2347 | // Queue our JQuery plugins! |
2219 | 2348 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2236,12 +2365,12 @@ discard block |
||
2236 | 2365 | require_once($sourcedir . '/ScheduledTasks.php'); |
2237 | 2366 | |
2238 | 2367 | // What to do, what to do?! |
2239 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2240 | - AutoTask(); |
|
2241 | - else |
|
2242 | - ReduceMailQueue(); |
|
2243 | - } |
|
2244 | - else |
|
2368 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2369 | + AutoTask(); |
|
2370 | + } else { |
|
2371 | + ReduceMailQueue(); |
|
2372 | + } |
|
2373 | + } else |
|
2245 | 2374 | { |
2246 | 2375 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2247 | 2376 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2292,8 +2421,9 @@ discard block |
||
2292 | 2421 | foreach ($theme_includes as $include) |
2293 | 2422 | { |
2294 | 2423 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2295 | - if (file_exists($include)) |
|
2296 | - require_once($include); |
|
2424 | + if (file_exists($include)) { |
|
2425 | + require_once($include); |
|
2426 | + } |
|
2297 | 2427 | } |
2298 | 2428 | } |
2299 | 2429 | |
@@ -2323,16 +2453,19 @@ discard block |
||
2323 | 2453 | // Do any style sheets first, cause we're easy with those. |
2324 | 2454 | if (!empty($style_sheets)) |
2325 | 2455 | { |
2326 | - if (!is_array($style_sheets)) |
|
2327 | - $style_sheets = array($style_sheets); |
|
2456 | + if (!is_array($style_sheets)) { |
|
2457 | + $style_sheets = array($style_sheets); |
|
2458 | + } |
|
2328 | 2459 | |
2329 | - foreach ($style_sheets as $sheet) |
|
2330 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2460 | + foreach ($style_sheets as $sheet) { |
|
2461 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2462 | + } |
|
2331 | 2463 | } |
2332 | 2464 | |
2333 | 2465 | // No template to load? |
2334 | - if ($template_name === false) |
|
2335 | - return true; |
|
2466 | + if ($template_name === false) { |
|
2467 | + return true; |
|
2468 | + } |
|
2336 | 2469 | |
2337 | 2470 | $loaded = false; |
2338 | 2471 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2347,12 +2480,14 @@ discard block |
||
2347 | 2480 | |
2348 | 2481 | if ($loaded) |
2349 | 2482 | { |
2350 | - if ($db_show_debug === true) |
|
2351 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2483 | + if ($db_show_debug === true) { |
|
2484 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2485 | + } |
|
2352 | 2486 | |
2353 | 2487 | // If they have specified an initialization function for this template, go ahead and call it now. |
2354 | - if (function_exists('template_' . $template_name . '_init')) |
|
2355 | - call_user_func('template_' . $template_name . '_init'); |
|
2488 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2489 | + call_user_func('template_' . $template_name . '_init'); |
|
2490 | + } |
|
2356 | 2491 | } |
2357 | 2492 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2358 | 2493 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2372,13 +2507,14 @@ discard block |
||
2372 | 2507 | loadTemplate($template_name); |
2373 | 2508 | } |
2374 | 2509 | // Cause an error otherwise. |
2375 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2376 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2377 | - elseif ($fatal) |
|
2378 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2379 | - else |
|
2380 | - return false; |
|
2381 | -} |
|
2510 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2511 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2512 | + } elseif ($fatal) { |
|
2513 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2514 | + } else { |
|
2515 | + return false; |
|
2516 | + } |
|
2517 | + } |
|
2382 | 2518 | |
2383 | 2519 | /** |
2384 | 2520 | * Load a sub-template. |
@@ -2396,17 +2532,19 @@ discard block |
||
2396 | 2532 | { |
2397 | 2533 | global $context, $txt, $db_show_debug; |
2398 | 2534 | |
2399 | - if ($db_show_debug === true) |
|
2400 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2535 | + if ($db_show_debug === true) { |
|
2536 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2537 | + } |
|
2401 | 2538 | |
2402 | 2539 | // Figure out what the template function is named. |
2403 | 2540 | $theme_function = 'template_' . $sub_template_name; |
2404 | - if (function_exists($theme_function)) |
|
2405 | - $theme_function(); |
|
2406 | - elseif ($fatal === false) |
|
2407 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2408 | - elseif ($fatal !== 'ignore') |
|
2409 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2541 | + if (function_exists($theme_function)) { |
|
2542 | + $theme_function(); |
|
2543 | + } elseif ($fatal === false) { |
|
2544 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2545 | + } elseif ($fatal !== 'ignore') { |
|
2546 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2547 | + } |
|
2410 | 2548 | |
2411 | 2549 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2412 | 2550 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2436,8 +2574,9 @@ discard block |
||
2436 | 2574 | { |
2437 | 2575 | global $settings, $context, $modSettings; |
2438 | 2576 | |
2439 | - if (empty($context['css_files_order'])) |
|
2440 | - $context['css_files_order'] = array(); |
|
2577 | + if (empty($context['css_files_order'])) { |
|
2578 | + $context['css_files_order'] = array(); |
|
2579 | + } |
|
2441 | 2580 | |
2442 | 2581 | $params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : ''); |
2443 | 2582 | $params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false; |
@@ -2448,8 +2587,9 @@ discard block |
||
2448 | 2587 | $params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000; |
2449 | 2588 | |
2450 | 2589 | // If this is an external file, automatically set this to false. |
2451 | - if (!empty($params['external'])) |
|
2452 | - $params['minimize'] = false; |
|
2590 | + if (!empty($params['external'])) { |
|
2591 | + $params['minimize'] = false; |
|
2592 | + } |
|
2453 | 2593 | |
2454 | 2594 | // Account for shorthand like admin.css?alp21 filenames |
2455 | 2595 | $has_seed = strpos($fileName, '.css?'); |
@@ -2466,16 +2606,12 @@ discard block |
||
2466 | 2606 | { |
2467 | 2607 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2468 | 2608 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2469 | - } |
|
2470 | - |
|
2471 | - else |
|
2609 | + } else |
|
2472 | 2610 | { |
2473 | 2611 | $fileUrl = false; |
2474 | 2612 | $filePath = false; |
2475 | 2613 | } |
2476 | - } |
|
2477 | - |
|
2478 | - else |
|
2614 | + } else |
|
2479 | 2615 | { |
2480 | 2616 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2481 | 2617 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2493,16 +2629,18 @@ discard block |
||
2493 | 2629 | if (!empty($fileName)) |
2494 | 2630 | { |
2495 | 2631 | // find a free number/position |
2496 | - while (isset($context['css_files_order'][$params['order_pos']])) |
|
2497 | - $params['order_pos']++; |
|
2632 | + while (isset($context['css_files_order'][$params['order_pos']])) { |
|
2633 | + $params['order_pos']++; |
|
2634 | + } |
|
2498 | 2635 | $context['css_files_order'][$params['order_pos']] = $id; |
2499 | 2636 | |
2500 | 2637 | $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
2501 | 2638 | } |
2502 | 2639 | |
2503 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2504 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2505 | -} |
|
2640 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2641 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2642 | + } |
|
2643 | + } |
|
2506 | 2644 | |
2507 | 2645 | /** |
2508 | 2646 | * Add a block of inline css code to be executed later |
@@ -2519,8 +2657,9 @@ discard block |
||
2519 | 2657 | global $context; |
2520 | 2658 | |
2521 | 2659 | // Gotta add something... |
2522 | - if (empty($css)) |
|
2523 | - return false; |
|
2660 | + if (empty($css)) { |
|
2661 | + return false; |
|
2662 | + } |
|
2524 | 2663 | |
2525 | 2664 | $context['css_header'][] = $css; |
2526 | 2665 | } |
@@ -2556,8 +2695,9 @@ discard block |
||
2556 | 2695 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2557 | 2696 | |
2558 | 2697 | // If this is an external file, automatically set this to false. |
2559 | - if (!empty($params['external'])) |
|
2560 | - $params['minimize'] = false; |
|
2698 | + if (!empty($params['external'])) { |
|
2699 | + $params['minimize'] = false; |
|
2700 | + } |
|
2561 | 2701 | |
2562 | 2702 | // Account for shorthand like admin.js?alp21 filenames |
2563 | 2703 | $has_seed = strpos($fileName, '.js?'); |
@@ -2574,16 +2714,12 @@ discard block |
||
2574 | 2714 | { |
2575 | 2715 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2576 | 2716 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2577 | - } |
|
2578 | - |
|
2579 | - else |
|
2717 | + } else |
|
2580 | 2718 | { |
2581 | 2719 | $fileUrl = false; |
2582 | 2720 | $filePath = false; |
2583 | 2721 | } |
2584 | - } |
|
2585 | - |
|
2586 | - else |
|
2722 | + } else |
|
2587 | 2723 | { |
2588 | 2724 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2589 | 2725 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2598,9 +2734,10 @@ discard block |
||
2598 | 2734 | } |
2599 | 2735 | |
2600 | 2736 | // Add it to the array for use in the template |
2601 | - if (!empty($fileName)) |
|
2602 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2603 | -} |
|
2737 | + if (!empty($fileName)) { |
|
2738 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2739 | + } |
|
2740 | + } |
|
2604 | 2741 | |
2605 | 2742 | /** |
2606 | 2743 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2614,9 +2751,10 @@ discard block |
||
2614 | 2751 | { |
2615 | 2752 | global $context; |
2616 | 2753 | |
2617 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2618 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2619 | -} |
|
2754 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2755 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2756 | + } |
|
2757 | + } |
|
2620 | 2758 | |
2621 | 2759 | /** |
2622 | 2760 | * Add a block of inline Javascript code to be executed later |
@@ -2633,8 +2771,9 @@ discard block |
||
2633 | 2771 | { |
2634 | 2772 | global $context; |
2635 | 2773 | |
2636 | - if (empty($javascript)) |
|
2637 | - return false; |
|
2774 | + if (empty($javascript)) { |
|
2775 | + return false; |
|
2776 | + } |
|
2638 | 2777 | |
2639 | 2778 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2640 | 2779 | } |
@@ -2655,15 +2794,18 @@ discard block |
||
2655 | 2794 | static $already_loaded = array(); |
2656 | 2795 | |
2657 | 2796 | // Default to the user's language. |
2658 | - if ($lang == '') |
|
2659 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2797 | + if ($lang == '') { |
|
2798 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2799 | + } |
|
2660 | 2800 | |
2661 | 2801 | // Do we want the English version of language file as fallback? |
2662 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2663 | - loadLanguage($template_name, 'english', false); |
|
2802 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2803 | + loadLanguage($template_name, 'english', false); |
|
2804 | + } |
|
2664 | 2805 | |
2665 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2666 | - return $lang; |
|
2806 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2807 | + return $lang; |
|
2808 | + } |
|
2667 | 2809 | |
2668 | 2810 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2669 | 2811 | if (empty($settings['default_theme_dir'])) |
@@ -2674,8 +2816,9 @@ discard block |
||
2674 | 2816 | |
2675 | 2817 | // What theme are we in? |
2676 | 2818 | $theme_name = basename($settings['theme_url']); |
2677 | - if (empty($theme_name)) |
|
2678 | - $theme_name = 'unknown'; |
|
2819 | + if (empty($theme_name)) { |
|
2820 | + $theme_name = 'unknown'; |
|
2821 | + } |
|
2679 | 2822 | |
2680 | 2823 | // For each file open it up and write it out! |
2681 | 2824 | foreach (explode('+', $template_name) as $template) |
@@ -2717,8 +2860,9 @@ discard block |
||
2717 | 2860 | $found = true; |
2718 | 2861 | |
2719 | 2862 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2720 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2721 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2863 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2864 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2865 | + } |
|
2722 | 2866 | |
2723 | 2867 | break; |
2724 | 2868 | } |
@@ -2758,8 +2902,9 @@ discard block |
||
2758 | 2902 | } |
2759 | 2903 | |
2760 | 2904 | // Keep track of what we're up to soldier. |
2761 | - if ($db_show_debug === true) |
|
2762 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2905 | + if ($db_show_debug === true) { |
|
2906 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2907 | + } |
|
2763 | 2908 | |
2764 | 2909 | // Remember what we have loaded, and in which language. |
2765 | 2910 | $already_loaded[$template_name] = $lang; |
@@ -2805,8 +2950,9 @@ discard block |
||
2805 | 2950 | ) |
2806 | 2951 | ); |
2807 | 2952 | // In the EXTREMELY unlikely event this happens, give an error message. |
2808 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2809 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2953 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2954 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2955 | + } |
|
2810 | 2956 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2811 | 2957 | { |
2812 | 2958 | if (!isset($boards[$row['id_board']])) |
@@ -2823,8 +2969,8 @@ discard block |
||
2823 | 2969 | ); |
2824 | 2970 | } |
2825 | 2971 | // If a moderator exists for this board, add that moderator for all children too. |
2826 | - if (!empty($row['id_moderator'])) |
|
2827 | - foreach ($boards as $id => $dummy) |
|
2972 | + if (!empty($row['id_moderator'])) { |
|
2973 | + foreach ($boards as $id => $dummy) |
|
2828 | 2974 | { |
2829 | 2975 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2830 | 2976 | 'id' => $row['id_moderator'], |
@@ -2832,11 +2978,12 @@ discard block |
||
2832 | 2978 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2833 | 2979 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2834 | 2980 | ); |
2981 | + } |
|
2835 | 2982 | } |
2836 | 2983 | |
2837 | 2984 | // If a moderator group exists for this board, add that moderator group for all children too |
2838 | - if (!empty($row['id_moderator_group'])) |
|
2839 | - foreach ($boards as $id => $dummy) |
|
2985 | + if (!empty($row['id_moderator_group'])) { |
|
2986 | + foreach ($boards as $id => $dummy) |
|
2840 | 2987 | { |
2841 | 2988 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2842 | 2989 | 'id' => $row['id_moderator_group'], |
@@ -2844,6 +2991,7 @@ discard block |
||
2844 | 2991 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2845 | 2992 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2846 | 2993 | ); |
2994 | + } |
|
2847 | 2995 | } |
2848 | 2996 | } |
2849 | 2997 | $smcFunc['db_free_result']($result); |
@@ -2870,23 +3018,27 @@ discard block |
||
2870 | 3018 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2871 | 3019 | { |
2872 | 3020 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2873 | - if (empty($smcFunc['ucwords'])) |
|
2874 | - reloadSettings(); |
|
3021 | + if (empty($smcFunc['ucwords'])) { |
|
3022 | + reloadSettings(); |
|
3023 | + } |
|
2875 | 3024 | |
2876 | 3025 | // If we don't have our theme information yet, let's get it. |
2877 | - if (empty($settings['default_theme_dir'])) |
|
2878 | - loadTheme(0, false); |
|
3026 | + if (empty($settings['default_theme_dir'])) { |
|
3027 | + loadTheme(0, false); |
|
3028 | + } |
|
2879 | 3029 | |
2880 | 3030 | // Default language directories to try. |
2881 | 3031 | $language_directories = array( |
2882 | 3032 | $settings['default_theme_dir'] . '/languages', |
2883 | 3033 | ); |
2884 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2885 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3034 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
3035 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3036 | + } |
|
2886 | 3037 | |
2887 | 3038 | // We possibly have a base theme directory. |
2888 | - if (!empty($settings['base_theme_dir'])) |
|
2889 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3039 | + if (!empty($settings['base_theme_dir'])) { |
|
3040 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3041 | + } |
|
2890 | 3042 | |
2891 | 3043 | // Remove any duplicates. |
2892 | 3044 | $language_directories = array_unique($language_directories); |
@@ -2900,20 +3052,21 @@ discard block |
||
2900 | 3052 | foreach ($language_directories as $language_dir) |
2901 | 3053 | { |
2902 | 3054 | // Can't look in here... doesn't exist! |
2903 | - if (!file_exists($language_dir)) |
|
2904 | - continue; |
|
3055 | + if (!file_exists($language_dir)) { |
|
3056 | + continue; |
|
3057 | + } |
|
2905 | 3058 | |
2906 | 3059 | $dir = dir($language_dir); |
2907 | 3060 | while ($entry = $dir->read()) |
2908 | 3061 | { |
2909 | 3062 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2910 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2911 | - continue; |
|
2912 | - |
|
2913 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2914 | - $langName = $langList[$matches[1]]; |
|
3063 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3064 | + continue; |
|
3065 | + } |
|
2915 | 3066 | |
2916 | - else |
|
3067 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3068 | + $langName = $langList[$matches[1]]; |
|
3069 | + } else |
|
2917 | 3070 | { |
2918 | 3071 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2919 | 3072 | |
@@ -2954,12 +3107,14 @@ discard block |
||
2954 | 3107 | } |
2955 | 3108 | |
2956 | 3109 | // Do we need to store the lang list? |
2957 | - if (empty($langList)) |
|
2958 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3110 | + if (empty($langList)) { |
|
3111 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3112 | + } |
|
2959 | 3113 | |
2960 | 3114 | // Let's cash in on this deal. |
2961 | - if (!empty($modSettings['cache_enable'])) |
|
2962 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3115 | + if (!empty($modSettings['cache_enable'])) { |
|
3116 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3117 | + } |
|
2963 | 3118 | } |
2964 | 3119 | |
2965 | 3120 | return $context['languages']; |
@@ -2982,8 +3137,9 @@ discard block |
||
2982 | 3137 | global $modSettings, $options, $txt; |
2983 | 3138 | static $censor_vulgar = null, $censor_proper; |
2984 | 3139 | |
2985 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2986 | - return $text; |
|
3140 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3141 | + return $text; |
|
3142 | + } |
|
2987 | 3143 | |
2988 | 3144 | // If they haven't yet been loaded, load them. |
2989 | 3145 | if ($censor_vulgar == null) |
@@ -3014,9 +3170,9 @@ discard block |
||
3014 | 3170 | { |
3015 | 3171 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
3016 | 3172 | $text = $func($censor_vulgar, $censor_proper, $text); |
3173 | + } else { |
|
3174 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3017 | 3175 | } |
3018 | - else |
|
3019 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3020 | 3176 | |
3021 | 3177 | return $text; |
3022 | 3178 | } |
@@ -3042,30 +3198,35 @@ discard block |
||
3042 | 3198 | @ini_set('track_errors', '1'); |
3043 | 3199 | |
3044 | 3200 | // Don't include the file more than once, if $once is true. |
3045 | - if ($once && in_array($filename, $templates)) |
|
3046 | - return; |
|
3201 | + if ($once && in_array($filename, $templates)) { |
|
3202 | + return; |
|
3203 | + } |
|
3047 | 3204 | // Add this file to the include list, whether $once is true or not. |
3048 | - else |
|
3049 | - $templates[] = $filename; |
|
3205 | + else { |
|
3206 | + $templates[] = $filename; |
|
3207 | + } |
|
3050 | 3208 | |
3051 | 3209 | |
3052 | 3210 | $file_found = file_exists($filename); |
3053 | 3211 | |
3054 | - if ($once && $file_found) |
|
3055 | - require_once($filename); |
|
3056 | - elseif ($file_found) |
|
3057 | - require($filename); |
|
3212 | + if ($once && $file_found) { |
|
3213 | + require_once($filename); |
|
3214 | + } elseif ($file_found) { |
|
3215 | + require($filename); |
|
3216 | + } |
|
3058 | 3217 | |
3059 | 3218 | if ($file_found !== true) |
3060 | 3219 | { |
3061 | 3220 | ob_end_clean(); |
3062 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3063 | - @ob_start('ob_gzhandler'); |
|
3064 | - else |
|
3065 | - ob_start(); |
|
3221 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3222 | + @ob_start('ob_gzhandler'); |
|
3223 | + } else { |
|
3224 | + ob_start(); |
|
3225 | + } |
|
3066 | 3226 | |
3067 | - if (isset($_GET['debug'])) |
|
3068 | - header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3227 | + if (isset($_GET['debug'])) { |
|
3228 | + header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3229 | + } |
|
3069 | 3230 | |
3070 | 3231 | // Don't cache error pages!! |
3071 | 3232 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3084,12 +3245,13 @@ discard block |
||
3084 | 3245 | echo '<!DOCTYPE html> |
3085 | 3246 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3086 | 3247 | <head>'; |
3087 | - if (isset($context['character_set'])) |
|
3088 | - echo ' |
|
3248 | + if (isset($context['character_set'])) { |
|
3249 | + echo ' |
|
3089 | 3250 | <meta charset="', $context['character_set'], '">'; |
3251 | + } |
|
3090 | 3252 | |
3091 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3092 | - echo ' |
|
3253 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3254 | + echo ' |
|
3093 | 3255 | <title>', $mtitle, '</title> |
3094 | 3256 | </head> |
3095 | 3257 | <body> |
@@ -3097,8 +3259,8 @@ discard block |
||
3097 | 3259 | ', $mmessage, ' |
3098 | 3260 | </body> |
3099 | 3261 | </html>'; |
3100 | - elseif (!allowedTo('admin_forum')) |
|
3101 | - echo ' |
|
3262 | + } elseif (!allowedTo('admin_forum')) { |
|
3263 | + echo ' |
|
3102 | 3264 | <title>', $txt['template_parse_error'], '</title> |
3103 | 3265 | </head> |
3104 | 3266 | <body> |
@@ -3106,14 +3268,16 @@ discard block |
||
3106 | 3268 | ', $txt['template_parse_error_message'], ' |
3107 | 3269 | </body> |
3108 | 3270 | </html>'; |
3109 | - else |
|
3271 | + } else |
|
3110 | 3272 | { |
3111 | 3273 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3112 | 3274 | $error_array = error_get_last(); |
3113 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3114 | - $error = $error_array['message']; |
|
3115 | - if (empty($error)) |
|
3116 | - $error = $txt['template_parse_errmsg']; |
|
3275 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3276 | + $error = $error_array['message']; |
|
3277 | + } |
|
3278 | + if (empty($error)) { |
|
3279 | + $error = $txt['template_parse_errmsg']; |
|
3280 | + } |
|
3117 | 3281 | |
3118 | 3282 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3119 | 3283 | |
@@ -3124,11 +3288,12 @@ discard block |
||
3124 | 3288 | <h3>', $txt['template_parse_error'], '</h3> |
3125 | 3289 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3126 | 3290 | |
3127 | - if (!empty($error)) |
|
3128 | - echo ' |
|
3291 | + if (!empty($error)) { |
|
3292 | + echo ' |
|
3129 | 3293 | <hr> |
3130 | 3294 | |
3131 | 3295 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3296 | + } |
|
3132 | 3297 | |
3133 | 3298 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3134 | 3299 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3138,10 +3303,11 @@ discard block |
||
3138 | 3303 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3139 | 3304 | |
3140 | 3305 | // Fix the PHP code stuff... |
3141 | - if (!isBrowser('gecko')) |
|
3142 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3143 | - else |
|
3144 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3306 | + if (!isBrowser('gecko')) { |
|
3307 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3308 | + } else { |
|
3309 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3310 | + } |
|
3145 | 3311 | |
3146 | 3312 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3147 | 3313 | $j = -1; |
@@ -3149,8 +3315,9 @@ discard block |
||
3149 | 3315 | { |
3150 | 3316 | $j++; |
3151 | 3317 | |
3152 | - if (substr_count($line, '<br>') == 0) |
|
3153 | - continue; |
|
3318 | + if (substr_count($line, '<br>') == 0) { |
|
3319 | + continue; |
|
3320 | + } |
|
3154 | 3321 | |
3155 | 3322 | $n = substr_count($line, '<br>'); |
3156 | 3323 | for ($i = 0; $i < $n; $i++) |
@@ -3169,38 +3336,42 @@ discard block |
||
3169 | 3336 | // Figure out what the color coding was before... |
3170 | 3337 | $line = max($match[1] - 9, 1); |
3171 | 3338 | $last_line = ''; |
3172 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3173 | - if (strpos($data2[$line2], '<') !== false) |
|
3339 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3340 | + if (strpos($data2[$line2], '<') !== false) |
|
3174 | 3341 | { |
3175 | 3342 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3176 | 3343 | $last_line = $color_match[1]; |
3344 | + } |
|
3177 | 3345 | break; |
3178 | 3346 | } |
3179 | 3347 | |
3180 | 3348 | // Show the relevant lines... |
3181 | 3349 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3182 | 3350 | { |
3183 | - if ($line == $match[1]) |
|
3184 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3351 | + if ($line == $match[1]) { |
|
3352 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3353 | + } |
|
3185 | 3354 | |
3186 | 3355 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3187 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3188 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3356 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3357 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3358 | + } |
|
3189 | 3359 | |
3190 | 3360 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3191 | 3361 | { |
3192 | 3362 | $last_line = $color_match[1]; |
3193 | 3363 | echo '</', substr($last_line, 1, 4), '>'; |
3364 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3365 | + $last_line = ''; |
|
3366 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3367 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3194 | 3368 | } |
3195 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3196 | - $last_line = ''; |
|
3197 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3198 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3199 | 3369 | |
3200 | - if ($line == $match[1]) |
|
3201 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3202 | - else |
|
3203 | - echo "\n"; |
|
3370 | + if ($line == $match[1]) { |
|
3371 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3372 | + } else { |
|
3373 | + echo "\n"; |
|
3374 | + } |
|
3204 | 3375 | } |
3205 | 3376 | |
3206 | 3377 | echo '</pre></div>'; |
@@ -3224,8 +3395,9 @@ discard block |
||
3224 | 3395 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3225 | 3396 | |
3226 | 3397 | // Figure out what type of database we are using. |
3227 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3228 | - $db_type = 'mysql'; |
|
3398 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3399 | + $db_type = 'mysql'; |
|
3400 | + } |
|
3229 | 3401 | |
3230 | 3402 | // Load the file for the database. |
3231 | 3403 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3233,8 +3405,9 @@ discard block |
||
3233 | 3405 | $db_options = array(); |
3234 | 3406 | |
3235 | 3407 | // Add in the port if needed |
3236 | - if (!empty($db_port)) |
|
3237 | - $db_options['port'] = $db_port; |
|
3408 | + if (!empty($db_port)) { |
|
3409 | + $db_options['port'] = $db_port; |
|
3410 | + } |
|
3238 | 3411 | |
3239 | 3412 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3240 | 3413 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3253,13 +3426,15 @@ discard block |
||
3253 | 3426 | } |
3254 | 3427 | |
3255 | 3428 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3256 | - if (!$db_connection) |
|
3257 | - display_db_error(); |
|
3429 | + if (!$db_connection) { |
|
3430 | + display_db_error(); |
|
3431 | + } |
|
3258 | 3432 | |
3259 | 3433 | // If in SSI mode fix up the prefix. |
3260 | - if (SMF == 'SSI') |
|
3261 | - db_fix_prefix($db_prefix, $db_name); |
|
3262 | -} |
|
3434 | + if (SMF == 'SSI') { |
|
3435 | + db_fix_prefix($db_prefix, $db_name); |
|
3436 | + } |
|
3437 | + } |
|
3263 | 3438 | |
3264 | 3439 | /** |
3265 | 3440 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3273,10 +3448,11 @@ discard block |
||
3273 | 3448 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3274 | 3449 | |
3275 | 3450 | // Not overriding this and we have a cacheAPI, send it back. |
3276 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3277 | - return $cacheAPI; |
|
3278 | - elseif (is_null($cacheAPI)) |
|
3279 | - $cacheAPI = false; |
|
3451 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3452 | + return $cacheAPI; |
|
3453 | + } elseif (is_null($cacheAPI)) { |
|
3454 | + $cacheAPI = false; |
|
3455 | + } |
|
3280 | 3456 | |
3281 | 3457 | // Make sure our class is in session. |
3282 | 3458 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3297,8 +3473,9 @@ discard block |
||
3297 | 3473 | if (!$testAPI->isSupported()) |
3298 | 3474 | { |
3299 | 3475 | // Can we save ourselves? |
3300 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3301 | - return loadCacheAccelerator(null, false); |
|
3476 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3477 | + return loadCacheAccelerator(null, false); |
|
3478 | + } |
|
3302 | 3479 | return false; |
3303 | 3480 | } |
3304 | 3481 | |
@@ -3310,9 +3487,9 @@ discard block |
||
3310 | 3487 | { |
3311 | 3488 | $cacheAPI = $testAPI; |
3312 | 3489 | return $cacheAPI; |
3490 | + } else { |
|
3491 | + return $testAPI; |
|
3313 | 3492 | } |
3314 | - else |
|
3315 | - return $testAPI; |
|
3316 | 3493 | } |
3317 | 3494 | } |
3318 | 3495 | |
@@ -3332,8 +3509,9 @@ discard block |
||
3332 | 3509 | |
3333 | 3510 | // @todo Why are we doing this if caching is disabled? |
3334 | 3511 | |
3335 | - if (function_exists('call_integration_hook')) |
|
3336 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3512 | + if (function_exists('call_integration_hook')) { |
|
3513 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3514 | + } |
|
3337 | 3515 | |
3338 | 3516 | /* Refresh the cache if either: |
3339 | 3517 | 1. Caching is disabled. |
@@ -3347,16 +3525,19 @@ discard block |
||
3347 | 3525 | require_once($sourcedir . '/' . $file); |
3348 | 3526 | $cache_block = call_user_func_array($function, $params); |
3349 | 3527 | |
3350 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3351 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3528 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3529 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3530 | + } |
|
3352 | 3531 | } |
3353 | 3532 | |
3354 | 3533 | // Some cached data may need a freshening up after retrieval. |
3355 | - if (!empty($cache_block['post_retri_eval'])) |
|
3356 | - eval($cache_block['post_retri_eval']); |
|
3534 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3535 | + eval($cache_block['post_retri_eval']); |
|
3536 | + } |
|
3357 | 3537 | |
3358 | - if (function_exists('call_integration_hook')) |
|
3359 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3538 | + if (function_exists('call_integration_hook')) { |
|
3539 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3540 | + } |
|
3360 | 3541 | |
3361 | 3542 | return $cache_block['data']; |
3362 | 3543 | } |
@@ -3383,8 +3564,9 @@ discard block |
||
3383 | 3564 | global $smcFunc, $cache_enable, $cacheAPI; |
3384 | 3565 | global $cache_hits, $cache_count, $db_show_debug; |
3385 | 3566 | |
3386 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3387 | - return; |
|
3567 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3568 | + return; |
|
3569 | + } |
|
3388 | 3570 | |
3389 | 3571 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3390 | 3572 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3397,12 +3579,14 @@ discard block |
||
3397 | 3579 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3398 | 3580 | $cacheAPI->putData($key, $value, $ttl); |
3399 | 3581 | |
3400 | - if (function_exists('call_integration_hook')) |
|
3401 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3582 | + if (function_exists('call_integration_hook')) { |
|
3583 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3584 | + } |
|
3402 | 3585 | |
3403 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3404 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3405 | -} |
|
3586 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3587 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3588 | + } |
|
3589 | + } |
|
3406 | 3590 | |
3407 | 3591 | /** |
3408 | 3592 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3418,8 +3602,9 @@ discard block |
||
3418 | 3602 | global $smcFunc, $cache_enable, $cacheAPI; |
3419 | 3603 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3420 | 3604 | |
3421 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3422 | - return; |
|
3605 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3606 | + return; |
|
3607 | + } |
|
3423 | 3608 | |
3424 | 3609 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3425 | 3610 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3439,16 +3624,18 @@ discard block |
||
3439 | 3624 | |
3440 | 3625 | if (empty($value)) |
3441 | 3626 | { |
3442 | - if (!is_array($cache_misses)) |
|
3443 | - $cache_misses = array(); |
|
3627 | + if (!is_array($cache_misses)) { |
|
3628 | + $cache_misses = array(); |
|
3629 | + } |
|
3444 | 3630 | |
3445 | 3631 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3446 | 3632 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3447 | 3633 | } |
3448 | 3634 | } |
3449 | 3635 | |
3450 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3451 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3636 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3637 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3638 | + } |
|
3452 | 3639 | |
3453 | 3640 | return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3454 | 3641 | } |
@@ -3470,8 +3657,9 @@ discard block |
||
3470 | 3657 | global $cacheAPI; |
3471 | 3658 | |
3472 | 3659 | // If we can't get to the API, can't do this. |
3473 | - if (empty($cacheAPI)) |
|
3474 | - return; |
|
3660 | + if (empty($cacheAPI)) { |
|
3661 | + return; |
|
3662 | + } |
|
3475 | 3663 | |
3476 | 3664 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3477 | 3665 | $cacheAPI->cleanCache($type); |
@@ -3496,8 +3684,9 @@ discard block |
||
3496 | 3684 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $user_info; |
3497 | 3685 | |
3498 | 3686 | // Come on! |
3499 | - if (empty($data)) |
|
3500 | - return array(); |
|
3687 | + if (empty($data)) { |
|
3688 | + return array(); |
|
3689 | + } |
|
3501 | 3690 | |
3502 | 3691 | // Set a nice default var. |
3503 | 3692 | $image = ''; |
@@ -3505,11 +3694,11 @@ discard block |
||
3505 | 3694 | // Gravatar has been set as mandatory! |
3506 | 3695 | if (!empty($modSettings['gravatarOverride'])) |
3507 | 3696 | { |
3508 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3509 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3510 | - |
|
3511 | - else if (!empty($data['email'])) |
|
3512 | - $image = get_gravatar_url($data['email']); |
|
3697 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3698 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3699 | + } else if (!empty($data['email'])) { |
|
3700 | + $image = get_gravatar_url($data['email']); |
|
3701 | + } |
|
3513 | 3702 | } |
3514 | 3703 | |
3515 | 3704 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3521,54 +3710,60 @@ discard block |
||
3521 | 3710 | // Gravatar. |
3522 | 3711 | if (stristr($data['avatar'], 'gravatar://')) |
3523 | 3712 | { |
3524 | - if ($data['avatar'] == 'gravatar://') |
|
3525 | - $image = get_gravatar_url($data['email']); |
|
3526 | - |
|
3527 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3528 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3713 | + if ($data['avatar'] == 'gravatar://') { |
|
3714 | + $image = get_gravatar_url($data['email']); |
|
3715 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3716 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3717 | + } |
|
3529 | 3718 | } |
3530 | 3719 | |
3531 | 3720 | // External url. |
3532 | 3721 | else |
3533 | 3722 | { |
3534 | 3723 | // Using ssl? |
3535 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
3536 | - $image = get_proxied_url($data['avatar']); |
|
3724 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
3725 | + $image = get_proxied_url($data['avatar']); |
|
3726 | + } |
|
3537 | 3727 | |
3538 | 3728 | // Just a plain external url. |
3539 | - else |
|
3540 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3729 | + else { |
|
3730 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3731 | + } |
|
3541 | 3732 | } |
3542 | 3733 | } |
3543 | 3734 | |
3544 | 3735 | // Perhaps this user has an attachment as avatar... |
3545 | - else if (!empty($data['filename'])) |
|
3546 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3736 | + else if (!empty($data['filename'])) { |
|
3737 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3738 | + } |
|
3547 | 3739 | |
3548 | 3740 | // Right... no avatar... use our default image. |
3549 | - else |
|
3550 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3741 | + else { |
|
3742 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3743 | + } |
|
3551 | 3744 | } |
3552 | 3745 | |
3553 | 3746 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3554 | 3747 | |
3555 | 3748 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3556 | - if (!empty($image)) |
|
3557 | - return array( |
|
3749 | + if (!empty($image)) { |
|
3750 | + return array( |
|
3558 | 3751 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3559 | 3752 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3560 | 3753 | 'href' => $image, |
3561 | 3754 | 'url' => $image, |
3562 | 3755 | ); |
3756 | + } |
|
3563 | 3757 | |
3564 | 3758 | // Fallback to make life easier for everyone... |
3565 | - else |
|
3566 | - return array( |
|
3759 | + else { |
|
3760 | + return array( |
|
3567 | 3761 | 'name' => '', |
3568 | 3762 | 'image' => '', |
3569 | 3763 | 'href' => '', |
3570 | 3764 | 'url' => '', |
3571 | 3765 | ); |
3572 | -} |
|
3766 | + } |
|
3767 | + } |
|
3573 | 3768 | |
3574 | 3769 | ?> |
3575 | 3770 | \ No newline at end of file |