@@ -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('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($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 | |
@@ -405,27 +422,28 @@ discard block |
||
405 | 422 | break; |
406 | 423 | } |
407 | 424 | } |
425 | + } else { |
|
426 | + $id_member = 0; |
|
408 | 427 | } |
409 | - else |
|
410 | - $id_member = 0; |
|
411 | 428 | |
412 | 429 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
413 | 430 | { |
414 | 431 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
415 | 432 | |
416 | - if (empty($cookie_data)) |
|
417 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
433 | + if (empty($cookie_data)) { |
|
434 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | list ($id_member, $password) = $cookie_data; |
420 | 438 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
421 | - } |
|
422 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
439 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
423 | 440 | { |
424 | 441 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
425 | 442 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
426 | 443 | |
427 | - if (empty($cookie_data)) |
|
428 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
444 | + if (empty($cookie_data)) { |
|
445 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
446 | + } |
|
429 | 447 | |
430 | 448 | list ($id_member, $password, $login_span) = $cookie_data; |
431 | 449 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -450,30 +468,34 @@ discard block |
||
450 | 468 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
451 | 469 | $smcFunc['db_free_result']($request); |
452 | 470 | |
453 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
454 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
471 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
472 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
473 | + } |
|
455 | 474 | |
456 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
457 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
475 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
476 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
477 | + } |
|
458 | 478 | } |
459 | 479 | |
460 | 480 | // Did we find 'im? If not, junk it. |
461 | 481 | if (!empty($user_settings)) |
462 | 482 | { |
463 | 483 | // As much as the password should be right, we can assume the integration set things up. |
464 | - if (!empty($already_verified) && $already_verified === true) |
|
465 | - $check = true; |
|
484 | + if (!empty($already_verified) && $already_verified === true) { |
|
485 | + $check = true; |
|
486 | + } |
|
466 | 487 | // SHA-512 hash should be 128 characters long. |
467 | - elseif (strlen($password) == 128) |
|
468 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
469 | - else |
|
470 | - $check = false; |
|
488 | + elseif (strlen($password) == 128) { |
|
489 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
490 | + } else { |
|
491 | + $check = false; |
|
492 | + } |
|
471 | 493 | |
472 | 494 | // Wrong password or not activated - either way, you're going nowhere. |
473 | 495 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
496 | + } else { |
|
497 | + $id_member = 0; |
|
474 | 498 | } |
475 | - else |
|
476 | - $id_member = 0; |
|
477 | 499 | |
478 | 500 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
479 | 501 | if (!$id_member) |
@@ -502,8 +524,9 @@ discard block |
||
502 | 524 | |
503 | 525 | list ($tfamember, $tfasecret) = $tfa_data; |
504 | 526 | |
505 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
506 | - $tfasecret = null; |
|
527 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
528 | + $tfasecret = null; |
|
529 | + } |
|
507 | 530 | } |
508 | 531 | |
509 | 532 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -523,10 +546,12 @@ discard block |
||
523 | 546 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
524 | 547 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
525 | 548 | { |
526 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
549 | + if ($modSettings['tfa_mode'] == 2) { |
|
550 | + //only do this if we are just forcing SOME membergroups |
|
527 | 551 | { |
528 | 552 | //Build an array of ALL user membergroups. |
529 | 553 | $full_groups = array($user_settings['id_group']); |
554 | + } |
|
530 | 555 | if (!empty($user_settings['additional_groups'])) |
531 | 556 | { |
532 | 557 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -546,15 +571,17 @@ discard block |
||
546 | 571 | ); |
547 | 572 | $row = $smcFunc['db_fetch_assoc']($request); |
548 | 573 | $smcFunc['db_free_result']($request); |
574 | + } else { |
|
575 | + $row['total'] = 1; |
|
549 | 576 | } |
550 | - else |
|
551 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
577 | + //simplifies logics in the next "if" |
|
552 | 578 | |
553 | 579 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
554 | 580 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
555 | 581 | |
556 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
557 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
582 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
583 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
584 | + } |
|
558 | 585 | } |
559 | 586 | } |
560 | 587 | |
@@ -591,33 +618,37 @@ discard block |
||
591 | 618 | 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'])); |
592 | 619 | $user_settings['last_login'] = time(); |
593 | 620 | |
594 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
595 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
621 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
622 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
623 | + } |
|
596 | 624 | |
597 | - if (!empty($modSettings['cache_enable'])) |
|
598 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
625 | + if (!empty($modSettings['cache_enable'])) { |
|
626 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
627 | + } |
|
599 | 628 | } |
629 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
630 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
600 | 631 | } |
601 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
602 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
603 | 632 | |
604 | 633 | $username = $user_settings['member_name']; |
605 | 634 | |
606 | - if (empty($user_settings['additional_groups'])) |
|
607 | - $user_info = array( |
|
635 | + if (empty($user_settings['additional_groups'])) { |
|
636 | + $user_info = array( |
|
608 | 637 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
609 | 638 | ); |
610 | - else |
|
611 | - $user_info = array( |
|
639 | + } else { |
|
640 | + $user_info = array( |
|
612 | 641 | 'groups' => array_merge( |
613 | 642 | array($user_settings['id_group'], $user_settings['id_post_group']), |
614 | 643 | explode(',', $user_settings['additional_groups']) |
615 | 644 | ) |
616 | 645 | ); |
646 | + } |
|
617 | 647 | |
618 | 648 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
619 | - foreach ($user_info['groups'] as $k => $v) |
|
620 | - $user_info['groups'][$k] = (int) $v; |
|
649 | + foreach ($user_info['groups'] as $k => $v) { |
|
650 | + $user_info['groups'][$k] = (int) $v; |
|
651 | + } |
|
621 | 652 | |
622 | 653 | // This is a logged in user, so definitely not a spider. |
623 | 654 | $user_info['possibly_robot'] = false; |
@@ -631,8 +662,7 @@ discard block |
||
631 | 662 | $time_system = new DateTime('now', $tz_system); |
632 | 663 | $time_user = new DateTime('now', $tz_user); |
633 | 664 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
634 | - } |
|
635 | - else |
|
665 | + } else |
|
636 | 666 | { |
637 | 667 | // !!! Compatibility. |
638 | 668 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -646,8 +676,9 @@ discard block |
||
646 | 676 | $user_info = array('groups' => array(-1)); |
647 | 677 | $user_settings = array(); |
648 | 678 | |
649 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
650 | - $_COOKIE[$cookiename] = ''; |
|
679 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
680 | + $_COOKIE[$cookiename] = ''; |
|
681 | + } |
|
651 | 682 | |
652 | 683 | // Expire the 2FA cookie |
653 | 684 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -664,19 +695,20 @@ discard block |
||
664 | 695 | } |
665 | 696 | |
666 | 697 | // Create a login token if it doesn't exist yet. |
667 | - if (!isset($_SESSION['token']['post-login'])) |
|
668 | - createToken('login'); |
|
669 | - else |
|
670 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
698 | + if (!isset($_SESSION['token']['post-login'])) { |
|
699 | + createToken('login'); |
|
700 | + } else { |
|
701 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
702 | + } |
|
671 | 703 | |
672 | 704 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
673 | 705 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
674 | 706 | { |
675 | 707 | require_once($sourcedir . '/ManageSearchEngines.php'); |
676 | 708 | $user_info['possibly_robot'] = SpiderCheck(); |
709 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
710 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
677 | 711 | } |
678 | - elseif (!empty($modSettings['spider_mode'])) |
|
679 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
680 | 712 | // If we haven't turned on proper spider hunts then have a guess! |
681 | 713 | else |
682 | 714 | { |
@@ -724,8 +756,9 @@ discard block |
||
724 | 756 | $user_info['groups'] = array_unique($user_info['groups']); |
725 | 757 | |
726 | 758 | // 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. |
727 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
728 | - unset($user_info['ignoreboards'][$tmp]); |
|
759 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
760 | + unset($user_info['ignoreboards'][$tmp]); |
|
761 | + } |
|
729 | 762 | |
730 | 763 | // Allow the user to change their language. |
731 | 764 | if (!empty($modSettings['userLanguage'])) |
@@ -738,13 +771,14 @@ discard block |
||
738 | 771 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
739 | 772 | |
740 | 773 | // Make it permanent for members. |
741 | - if (!empty($user_info['id'])) |
|
742 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
743 | - else |
|
744 | - $_SESSION['language'] = $user_info['language']; |
|
774 | + if (!empty($user_info['id'])) { |
|
775 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
776 | + } else { |
|
777 | + $_SESSION['language'] = $user_info['language']; |
|
778 | + } |
|
779 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
780 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
745 | 781 | } |
746 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
747 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
748 | 782 | } |
749 | 783 | |
750 | 784 | $temp = build_query_board($user_info['id']); |
@@ -807,9 +841,9 @@ discard block |
||
807 | 841 | } |
808 | 842 | |
809 | 843 | // Remember redirection is the key to avoiding fallout from your bosses. |
810 | - if (!empty($topic)) |
|
811 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
812 | - else |
|
844 | + if (!empty($topic)) { |
|
845 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
846 | + } else |
|
813 | 847 | { |
814 | 848 | loadPermissions(); |
815 | 849 | loadTheme(); |
@@ -827,10 +861,11 @@ discard block |
||
827 | 861 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
828 | 862 | { |
829 | 863 | // @todo SLOW? |
830 | - if (!empty($topic)) |
|
831 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
832 | - else |
|
833 | - $temp = cache_get_data('board-' . $board, 120); |
|
864 | + if (!empty($topic)) { |
|
865 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
866 | + } else { |
|
867 | + $temp = cache_get_data('board-' . $board, 120); |
|
868 | + } |
|
834 | 869 | |
835 | 870 | if (!empty($temp)) |
836 | 871 | { |
@@ -868,8 +903,9 @@ discard block |
||
868 | 903 | $row = $smcFunc['db_fetch_assoc']($request); |
869 | 904 | |
870 | 905 | // Set the current board. |
871 | - if (!empty($row['id_board'])) |
|
872 | - $board = $row['id_board']; |
|
906 | + if (!empty($row['id_board'])) { |
|
907 | + $board = $row['id_board']; |
|
908 | + } |
|
873 | 909 | |
874 | 910 | // Basic operating information. (globals... :/) |
875 | 911 | $board_info = array( |
@@ -905,21 +941,23 @@ discard block |
||
905 | 941 | |
906 | 942 | do |
907 | 943 | { |
908 | - if (!empty($row['id_moderator'])) |
|
909 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
944 | + if (!empty($row['id_moderator'])) { |
|
945 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
910 | 946 | 'id' => $row['id_moderator'], |
911 | 947 | 'name' => $row['real_name'], |
912 | 948 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
913 | 949 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
914 | 950 | ); |
951 | + } |
|
915 | 952 | |
916 | - if (!empty($row['id_moderator_group'])) |
|
917 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
953 | + if (!empty($row['id_moderator_group'])) { |
|
954 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
918 | 955 | 'id' => $row['id_moderator_group'], |
919 | 956 | 'name' => $row['group_name'], |
920 | 957 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
921 | 958 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
922 | 959 | ); |
960 | + } |
|
923 | 961 | } |
924 | 962 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
925 | 963 | |
@@ -951,12 +989,12 @@ discard block |
||
951 | 989 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
952 | 990 | { |
953 | 991 | // @todo SLOW? |
954 | - if (!empty($topic)) |
|
955 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
992 | + if (!empty($topic)) { |
|
993 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
994 | + } |
|
956 | 995 | cache_put_data('board-' . $board, $board_info, 120); |
957 | 996 | } |
958 | - } |
|
959 | - else |
|
997 | + } else |
|
960 | 998 | { |
961 | 999 | // Otherwise the topic is invalid, there are no moderators, etc. |
962 | 1000 | $board_info = array( |
@@ -970,8 +1008,9 @@ discard block |
||
970 | 1008 | $smcFunc['db_free_result']($request); |
971 | 1009 | } |
972 | 1010 | |
973 | - if (!empty($topic)) |
|
974 | - $_GET['board'] = (int) $board; |
|
1011 | + if (!empty($topic)) { |
|
1012 | + $_GET['board'] = (int) $board; |
|
1013 | + } |
|
975 | 1014 | |
976 | 1015 | if (!empty($board)) |
977 | 1016 | { |
@@ -981,10 +1020,12 @@ discard block |
||
981 | 1020 | // Now check if the user is a moderator. |
982 | 1021 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
983 | 1022 | |
984 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
985 | - $board_info['error'] = 'access'; |
|
986 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
987 | - $board_info['error'] = 'access'; |
|
1023 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1024 | + $board_info['error'] = 'access'; |
|
1025 | + } |
|
1026 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1027 | + $board_info['error'] = 'access'; |
|
1028 | + } |
|
988 | 1029 | |
989 | 1030 | // Build up the linktree. |
990 | 1031 | $context['linktree'] = array_merge( |
@@ -1007,8 +1048,9 @@ discard block |
||
1007 | 1048 | $context['current_board'] = $board; |
1008 | 1049 | |
1009 | 1050 | // No posting in redirection boards! |
1010 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1011 | - $board_info['error'] == 'post_in_redirect'; |
|
1051 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1052 | + $board_info['error'] == 'post_in_redirect'; |
|
1053 | + } |
|
1012 | 1054 | |
1013 | 1055 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1014 | 1056 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1034,24 +1076,23 @@ discard block |
||
1034 | 1076 | ob_end_clean(); |
1035 | 1077 | header('HTTP/1.1 403 Forbidden'); |
1036 | 1078 | die; |
1037 | - } |
|
1038 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1079 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1039 | 1080 | { |
1040 | 1081 | // Slightly different error message here... |
1041 | 1082 | fatal_lang_error('cannot_post_redirect', false); |
1042 | - } |
|
1043 | - elseif ($user_info['is_guest']) |
|
1083 | + } elseif ($user_info['is_guest']) |
|
1044 | 1084 | { |
1045 | 1085 | loadLanguage('Errors'); |
1046 | 1086 | is_not_guest($txt['topic_gone']); |
1087 | + } else { |
|
1088 | + fatal_lang_error('topic_gone', false); |
|
1047 | 1089 | } |
1048 | - else |
|
1049 | - fatal_lang_error('topic_gone', false); |
|
1050 | 1090 | } |
1051 | 1091 | |
1052 | - if ($user_info['is_mod']) |
|
1053 | - $user_info['groups'][] = 3; |
|
1054 | -} |
|
1092 | + if ($user_info['is_mod']) { |
|
1093 | + $user_info['groups'][] = 3; |
|
1094 | + } |
|
1095 | + } |
|
1055 | 1096 | |
1056 | 1097 | /** |
1057 | 1098 | * Load this user's permissions. |
@@ -1072,8 +1113,9 @@ discard block |
||
1072 | 1113 | asort($cache_groups); |
1073 | 1114 | $cache_groups = implode(',', $cache_groups); |
1074 | 1115 | // If it's a spider then cache it different. |
1075 | - if ($user_info['possibly_robot']) |
|
1076 | - $cache_groups .= '-spider'; |
|
1116 | + if ($user_info['possibly_robot']) { |
|
1117 | + $cache_groups .= '-spider'; |
|
1118 | + } |
|
1077 | 1119 | |
1078 | 1120 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1079 | 1121 | { |
@@ -1081,9 +1123,9 @@ discard block |
||
1081 | 1123 | banPermissions(); |
1082 | 1124 | |
1083 | 1125 | return; |
1126 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1127 | + list ($user_info['permissions'], $removals) = $temp; |
|
1084 | 1128 | } |
1085 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1086 | - list ($user_info['permissions'], $removals) = $temp; |
|
1087 | 1129 | } |
1088 | 1130 | |
1089 | 1131 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1105,23 +1147,26 @@ discard block |
||
1105 | 1147 | $removals = array(); |
1106 | 1148 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1107 | 1149 | { |
1108 | - if (empty($row['add_deny'])) |
|
1109 | - $removals[] = $row['permission']; |
|
1110 | - else |
|
1111 | - $user_info['permissions'][] = $row['permission']; |
|
1150 | + if (empty($row['add_deny'])) { |
|
1151 | + $removals[] = $row['permission']; |
|
1152 | + } else { |
|
1153 | + $user_info['permissions'][] = $row['permission']; |
|
1154 | + } |
|
1112 | 1155 | } |
1113 | 1156 | $smcFunc['db_free_result']($request); |
1114 | 1157 | |
1115 | - if (isset($cache_groups)) |
|
1116 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1158 | + if (isset($cache_groups)) { |
|
1159 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1160 | + } |
|
1117 | 1161 | } |
1118 | 1162 | |
1119 | 1163 | // Get the board permissions. |
1120 | 1164 | if (!empty($board)) |
1121 | 1165 | { |
1122 | 1166 | // Make sure the board (if any) has been loaded by loadBoard(). |
1123 | - if (!isset($board_info['profile'])) |
|
1124 | - fatal_lang_error('no_board'); |
|
1167 | + if (!isset($board_info['profile'])) { |
|
1168 | + fatal_lang_error('no_board'); |
|
1169 | + } |
|
1125 | 1170 | |
1126 | 1171 | $request = $smcFunc['db_query']('', ' |
1127 | 1172 | SELECT permission, add_deny |
@@ -1137,20 +1182,23 @@ discard block |
||
1137 | 1182 | ); |
1138 | 1183 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1139 | 1184 | { |
1140 | - if (empty($row['add_deny'])) |
|
1141 | - $removals[] = $row['permission']; |
|
1142 | - else |
|
1143 | - $user_info['permissions'][] = $row['permission']; |
|
1185 | + if (empty($row['add_deny'])) { |
|
1186 | + $removals[] = $row['permission']; |
|
1187 | + } else { |
|
1188 | + $user_info['permissions'][] = $row['permission']; |
|
1189 | + } |
|
1144 | 1190 | } |
1145 | 1191 | $smcFunc['db_free_result']($request); |
1146 | 1192 | } |
1147 | 1193 | |
1148 | 1194 | // Remove all the permissions they shouldn't have ;). |
1149 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1150 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1195 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1196 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1197 | + } |
|
1151 | 1198 | |
1152 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1153 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1199 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1200 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1201 | + } |
|
1154 | 1202 | |
1155 | 1203 | // Banned? Watch, don't touch.. |
1156 | 1204 | banPermissions(); |
@@ -1162,17 +1210,18 @@ discard block |
||
1162 | 1210 | { |
1163 | 1211 | require_once($sourcedir . '/Subs-Auth.php'); |
1164 | 1212 | rebuildModCache(); |
1213 | + } else { |
|
1214 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1165 | 1215 | } |
1166 | - else |
|
1167 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1168 | 1216 | |
1169 | 1217 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1170 | 1218 | // For example this drastically simplifies certain changes to the profile area. |
1171 | 1219 | $user_info['permissions'][] = 'is_not_guest'; |
1172 | 1220 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1173 | 1221 | $user_info['permissions'][] = 'profile_view_own'; |
1174 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1175 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1222 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1223 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1224 | + } |
|
1176 | 1225 | } |
1177 | 1226 | } |
1178 | 1227 | |
@@ -1190,8 +1239,9 @@ discard block |
||
1190 | 1239 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1191 | 1240 | |
1192 | 1241 | // Can't just look for no users :P. |
1193 | - if (empty($users)) |
|
1194 | - return array(); |
|
1242 | + if (empty($users)) { |
|
1243 | + return array(); |
|
1244 | + } |
|
1195 | 1245 | |
1196 | 1246 | // Pass the set value |
1197 | 1247 | $context['loadMemberContext_set'] = $set; |
@@ -1206,8 +1256,9 @@ discard block |
||
1206 | 1256 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1207 | 1257 | { |
1208 | 1258 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1209 | - if ($data == null) |
|
1210 | - continue; |
|
1259 | + if ($data == null) { |
|
1260 | + continue; |
|
1261 | + } |
|
1211 | 1262 | |
1212 | 1263 | $loaded_ids[] = $data['id_member']; |
1213 | 1264 | $user_profile[$data['id_member']] = $data; |
@@ -1274,16 +1325,19 @@ discard block |
||
1274 | 1325 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1275 | 1326 | |
1276 | 1327 | // Take care of proxying avatar if required, do this here for maximum reach |
1277 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1278 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1328 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1329 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1330 | + } |
|
1279 | 1331 | |
1280 | 1332 | // Keep track of the member's normal member group |
1281 | 1333 | $row['primary_group'] = $row['member_group']; |
1282 | 1334 | |
1283 | - if (isset($row['member_ip'])) |
|
1284 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1285 | - if (isset($row['member_ip2'])) |
|
1286 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1335 | + if (isset($row['member_ip'])) { |
|
1336 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1337 | + } |
|
1338 | + if (isset($row['member_ip2'])) { |
|
1339 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1340 | + } |
|
1287 | 1341 | $new_loaded_ids[] = $row['id_member']; |
1288 | 1342 | $loaded_ids[] = $row['id_member']; |
1289 | 1343 | $row['options'] = array(); |
@@ -1302,8 +1356,9 @@ discard block |
||
1302 | 1356 | 'loaded_ids' => $new_loaded_ids, |
1303 | 1357 | ) |
1304 | 1358 | ); |
1305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1306 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1359 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1360 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1361 | + } |
|
1307 | 1362 | $smcFunc['db_free_result']($request); |
1308 | 1363 | } |
1309 | 1364 | |
@@ -1314,10 +1369,11 @@ discard block |
||
1314 | 1369 | { |
1315 | 1370 | foreach ($loaded_ids as $a_member) |
1316 | 1371 | { |
1317 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1318 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1319 | - else |
|
1320 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1372 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1373 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1374 | + } else { |
|
1375 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1376 | + } |
|
1321 | 1377 | |
1322 | 1378 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1323 | 1379 | |
@@ -1330,8 +1386,9 @@ discard block |
||
1330 | 1386 | |
1331 | 1387 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1332 | 1388 | { |
1333 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1334 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1389 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1390 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1391 | + } |
|
1335 | 1392 | } |
1336 | 1393 | |
1337 | 1394 | // Are we loading any moderators? If so, fix their group data... |
@@ -1357,14 +1414,17 @@ discard block |
||
1357 | 1414 | foreach ($temp_mods as $id) |
1358 | 1415 | { |
1359 | 1416 | // By popular demand, don't show admins or global moderators as moderators. |
1360 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1361 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1417 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1418 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1419 | + } |
|
1362 | 1420 | |
1363 | 1421 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1364 | - if (!empty($row['icons'])) |
|
1365 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1366 | - if (!empty($row['member_group_color'])) |
|
1367 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1422 | + if (!empty($row['icons'])) { |
|
1423 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1424 | + } |
|
1425 | + if (!empty($row['member_group_color'])) { |
|
1426 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1427 | + } |
|
1368 | 1428 | } |
1369 | 1429 | } |
1370 | 1430 | |
@@ -1386,12 +1446,14 @@ discard block |
||
1386 | 1446 | static $loadedLanguages = array(); |
1387 | 1447 | |
1388 | 1448 | // If this person's data is already loaded, skip it. |
1389 | - if (isset($dataLoaded[$user])) |
|
1390 | - return true; |
|
1449 | + if (isset($dataLoaded[$user])) { |
|
1450 | + return true; |
|
1451 | + } |
|
1391 | 1452 | |
1392 | 1453 | // We can't load guests or members not loaded by loadMemberData()! |
1393 | - if ($user == 0) |
|
1394 | - return false; |
|
1454 | + if ($user == 0) { |
|
1455 | + return false; |
|
1456 | + } |
|
1395 | 1457 | if (!isset($user_profile[$user])) |
1396 | 1458 | { |
1397 | 1459 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1417,12 +1479,16 @@ discard block |
||
1417 | 1479 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1418 | 1480 | |
1419 | 1481 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1420 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1482 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1483 | + //icon is set and exists |
|
1421 | 1484 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1422 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1485 | + } elseif (isset($profile['icons'][1])) { |
|
1486 | + //icon is set and doesn't exist, fallback to default |
|
1423 | 1487 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1424 | - else //not set, bye bye |
|
1488 | + } else { |
|
1489 | + //not set, bye bye |
|
1425 | 1490 | $group_icon_url = ''; |
1491 | + } |
|
1426 | 1492 | |
1427 | 1493 | // These minimal values are always loaded |
1428 | 1494 | $memberContext[$user] = array( |
@@ -1441,8 +1507,9 @@ discard block |
||
1441 | 1507 | if ($context['loadMemberContext_set'] != 'minimal') |
1442 | 1508 | { |
1443 | 1509 | // Go the extra mile and load the user's native language name. |
1444 | - if (empty($loadedLanguages)) |
|
1445 | - $loadedLanguages = getLanguages(); |
|
1510 | + if (empty($loadedLanguages)) { |
|
1511 | + $loadedLanguages = getLanguages(); |
|
1512 | + } |
|
1446 | 1513 | |
1447 | 1514 | $memberContext[$user] += array( |
1448 | 1515 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1497,31 +1564,33 @@ discard block |
||
1497 | 1564 | { |
1498 | 1565 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1499 | 1566 | { |
1500 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1501 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1502 | - else |
|
1503 | - $image = get_gravatar_url($profile['email_address']); |
|
1504 | - } |
|
1505 | - else |
|
1567 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1568 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1569 | + } else { |
|
1570 | + $image = get_gravatar_url($profile['email_address']); |
|
1571 | + } |
|
1572 | + } else |
|
1506 | 1573 | { |
1507 | 1574 | // So it's stored in the member table? |
1508 | 1575 | if (!empty($profile['avatar'])) |
1509 | 1576 | { |
1510 | 1577 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1578 | + } elseif (!empty($profile['filename'])) { |
|
1579 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1511 | 1580 | } |
1512 | - elseif (!empty($profile['filename'])) |
|
1513 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1514 | 1581 | // Right... no avatar...use the default one |
1515 | - else |
|
1516 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1582 | + else { |
|
1583 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1584 | + } |
|
1517 | 1585 | } |
1518 | - if (!empty($image)) |
|
1519 | - $memberContext[$user]['avatar'] = array( |
|
1586 | + if (!empty($image)) { |
|
1587 | + $memberContext[$user]['avatar'] = array( |
|
1520 | 1588 | 'name' => $profile['avatar'], |
1521 | 1589 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1522 | 1590 | 'href' => $image, |
1523 | 1591 | 'url' => $image, |
1524 | 1592 | ); |
1593 | + } |
|
1525 | 1594 | } |
1526 | 1595 | |
1527 | 1596 | // Are we also loading the members custom fields into context? |
@@ -1529,35 +1598,41 @@ discard block |
||
1529 | 1598 | { |
1530 | 1599 | $memberContext[$user]['custom_fields'] = array(); |
1531 | 1600 | |
1532 | - if (!isset($context['display_fields'])) |
|
1533 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1601 | + if (!isset($context['display_fields'])) { |
|
1602 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1603 | + } |
|
1534 | 1604 | |
1535 | 1605 | foreach ($context['display_fields'] as $custom) |
1536 | 1606 | { |
1537 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1538 | - continue; |
|
1607 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1608 | + continue; |
|
1609 | + } |
|
1539 | 1610 | |
1540 | 1611 | $value = $profile['options'][$custom['col_name']]; |
1541 | 1612 | |
1542 | 1613 | // Don't show the "disabled" option for the "gender" field. |
1543 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
1544 | - continue; |
|
1614 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
1615 | + continue; |
|
1616 | + } |
|
1545 | 1617 | |
1546 | 1618 | // BBC? |
1547 | - if ($custom['bbc']) |
|
1548 | - $value = parse_bbc($value); |
|
1619 | + if ($custom['bbc']) { |
|
1620 | + $value = parse_bbc($value); |
|
1621 | + } |
|
1549 | 1622 | // ... or checkbox? |
1550 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1551 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1623 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1624 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1625 | + } |
|
1552 | 1626 | |
1553 | 1627 | // Enclosing the user input within some other text? |
1554 | - if (!empty($custom['enclose'])) |
|
1555 | - $value = strtr($custom['enclose'], array( |
|
1628 | + if (!empty($custom['enclose'])) { |
|
1629 | + $value = strtr($custom['enclose'], array( |
|
1556 | 1630 | '{SCRIPTURL}' => $scripturl, |
1557 | 1631 | '{IMAGES_URL}' => $settings['images_url'], |
1558 | 1632 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1559 | 1633 | '{INPUT}' => $value, |
1560 | 1634 | )); |
1635 | + } |
|
1561 | 1636 | |
1562 | 1637 | $memberContext[$user]['custom_fields'][] = array( |
1563 | 1638 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1584,8 +1659,9 @@ discard block |
||
1584 | 1659 | global $smcFunc, $txt, $scripturl, $settings; |
1585 | 1660 | |
1586 | 1661 | // Do not waste my time... |
1587 | - if (empty($users) || empty($params)) |
|
1588 | - return false; |
|
1662 | + if (empty($users) || empty($params)) { |
|
1663 | + return false; |
|
1664 | + } |
|
1589 | 1665 | |
1590 | 1666 | // Make sure it's an array. |
1591 | 1667 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1609,31 +1685,36 @@ discard block |
||
1609 | 1685 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1610 | 1686 | { |
1611 | 1687 | // BBC? |
1612 | - if (!empty($row['bbc'])) |
|
1613 | - $row['value'] = parse_bbc($row['value']); |
|
1688 | + if (!empty($row['bbc'])) { |
|
1689 | + $row['value'] = parse_bbc($row['value']); |
|
1690 | + } |
|
1614 | 1691 | |
1615 | 1692 | // ... or checkbox? |
1616 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1617 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1693 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1694 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1695 | + } |
|
1618 | 1696 | |
1619 | 1697 | // Enclosing the user input within some other text? |
1620 | - if (!empty($row['enclose'])) |
|
1621 | - $row['value'] = strtr($row['enclose'], array( |
|
1698 | + if (!empty($row['enclose'])) { |
|
1699 | + $row['value'] = strtr($row['enclose'], array( |
|
1622 | 1700 | '{SCRIPTURL}' => $scripturl, |
1623 | 1701 | '{IMAGES_URL}' => $settings['images_url'], |
1624 | 1702 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1625 | 1703 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1626 | 1704 | )); |
1705 | + } |
|
1627 | 1706 | |
1628 | 1707 | // Send a simple array if there is just 1 param |
1629 | - if (count($params) == 1) |
|
1630 | - $return[$row['id_member']] = $row; |
|
1708 | + if (count($params) == 1) { |
|
1709 | + $return[$row['id_member']] = $row; |
|
1710 | + } |
|
1631 | 1711 | |
1632 | 1712 | // More than 1? knock yourself out... |
1633 | 1713 | else |
1634 | 1714 | { |
1635 | - if (!isset($return[$row['id_member']])) |
|
1636 | - $return[$row['id_member']] = array(); |
|
1715 | + if (!isset($return[$row['id_member']])) { |
|
1716 | + $return[$row['id_member']] = array(); |
|
1717 | + } |
|
1637 | 1718 | |
1638 | 1719 | $return[$row['id_member']][$row['variable']] = $row; |
1639 | 1720 | } |
@@ -1667,8 +1748,9 @@ discard block |
||
1667 | 1748 | global $context; |
1668 | 1749 | |
1669 | 1750 | // Don't know any browser! |
1670 | - if (empty($context['browser'])) |
|
1671 | - detectBrowser(); |
|
1751 | + if (empty($context['browser'])) { |
|
1752 | + detectBrowser(); |
|
1753 | + } |
|
1672 | 1754 | |
1673 | 1755 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1674 | 1756 | } |
@@ -1686,8 +1768,9 @@ discard block |
||
1686 | 1768 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1687 | 1769 | |
1688 | 1770 | // The theme was specified by parameter. |
1689 | - if (!empty($id_theme)) |
|
1690 | - $id_theme = (int) $id_theme; |
|
1771 | + if (!empty($id_theme)) { |
|
1772 | + $id_theme = (int) $id_theme; |
|
1773 | + } |
|
1691 | 1774 | // The theme was specified by REQUEST. |
1692 | 1775 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1693 | 1776 | { |
@@ -1695,54 +1778,61 @@ discard block |
||
1695 | 1778 | $_SESSION['id_theme'] = $id_theme; |
1696 | 1779 | } |
1697 | 1780 | // The theme was specified by REQUEST... previously. |
1698 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1699 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1781 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1782 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1783 | + } |
|
1700 | 1784 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1701 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1702 | - $id_theme = $user_info['theme']; |
|
1785 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1786 | + $id_theme = $user_info['theme']; |
|
1787 | + } |
|
1703 | 1788 | // The theme was specified by the board. |
1704 | - elseif (!empty($board_info['theme'])) |
|
1705 | - $id_theme = $board_info['theme']; |
|
1789 | + elseif (!empty($board_info['theme'])) { |
|
1790 | + $id_theme = $board_info['theme']; |
|
1791 | + } |
|
1706 | 1792 | // The theme is the forum's default. |
1707 | - else |
|
1708 | - $id_theme = $modSettings['theme_guests']; |
|
1793 | + else { |
|
1794 | + $id_theme = $modSettings['theme_guests']; |
|
1795 | + } |
|
1709 | 1796 | |
1710 | 1797 | // We already load the basic stuff? |
1711 | 1798 | if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
1712 | 1799 | { |
1713 | 1800 | // Verify the id_theme... no foul play. |
1714 | 1801 | // Always allow the board specific theme, if they are overriding. |
1715 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1716 | - $id_theme = $board_info['theme']; |
|
1802 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1803 | + $id_theme = $board_info['theme']; |
|
1804 | + } |
|
1717 | 1805 | // If they have specified a particular theme to use with SSI allow it to be used. |
1718 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1719 | - $id_theme = (int) $id_theme; |
|
1720 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1806 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1807 | + $id_theme = (int) $id_theme; |
|
1808 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1721 | 1809 | { |
1722 | 1810 | $themes = explode(',', $modSettings['enableThemes']); |
1723 | - if (!in_array($id_theme, $themes)) |
|
1724 | - $id_theme = $modSettings['theme_guests']; |
|
1725 | - else |
|
1726 | - $id_theme = (int) $id_theme; |
|
1811 | + if (!in_array($id_theme, $themes)) { |
|
1812 | + $id_theme = $modSettings['theme_guests']; |
|
1813 | + } else { |
|
1814 | + $id_theme = (int) $id_theme; |
|
1815 | + } |
|
1816 | + } else { |
|
1817 | + $id_theme = (int) $id_theme; |
|
1727 | 1818 | } |
1728 | - else |
|
1729 | - $id_theme = (int) $id_theme; |
|
1730 | 1819 | |
1731 | 1820 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1732 | 1821 | |
1733 | 1822 | // Disable image proxy if we don't have SSL enabled |
1734 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1735 | - $image_proxy_enabled = false; |
|
1823 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1824 | + $image_proxy_enabled = false; |
|
1825 | + } |
|
1736 | 1826 | |
1737 | 1827 | 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']) |
1738 | 1828 | { |
1739 | 1829 | $themeData = $temp; |
1740 | 1830 | $flag = true; |
1831 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1832 | + $themeData = $temp + array($member => array()); |
|
1833 | + } else { |
|
1834 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1741 | 1835 | } |
1742 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1743 | - $themeData = $temp + array($member => array()); |
|
1744 | - else |
|
1745 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1746 | 1836 | |
1747 | 1837 | if (empty($flag)) |
1748 | 1838 | { |
@@ -1761,31 +1851,37 @@ discard block |
||
1761 | 1851 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1762 | 1852 | { |
1763 | 1853 | // There are just things we shouldn't be able to change as members. |
1764 | - 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'))) |
|
1765 | - continue; |
|
1854 | + 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'))) { |
|
1855 | + continue; |
|
1856 | + } |
|
1766 | 1857 | |
1767 | 1858 | // If this is the theme_dir of the default theme, store it. |
1768 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1769 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1859 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1860 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1861 | + } |
|
1770 | 1862 | |
1771 | 1863 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1772 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1773 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1864 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1865 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1866 | + } |
|
1774 | 1867 | } |
1775 | 1868 | $smcFunc['db_free_result']($result); |
1776 | 1869 | |
1777 | - if (!empty($themeData[-1])) |
|
1778 | - foreach ($themeData[-1] as $k => $v) |
|
1870 | + if (!empty($themeData[-1])) { |
|
1871 | + foreach ($themeData[-1] as $k => $v) |
|
1779 | 1872 | { |
1780 | 1873 | if (!isset($themeData[$member][$k])) |
1781 | 1874 | $themeData[$member][$k] = $v; |
1875 | + } |
|
1782 | 1876 | } |
1783 | 1877 | |
1784 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1785 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1878 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1879 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1880 | + } |
|
1786 | 1881 | // Only if we didn't already load that part of the cache... |
1787 | - elseif (!isset($temp)) |
|
1788 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1882 | + elseif (!isset($temp)) { |
|
1883 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1884 | + } |
|
1789 | 1885 | } |
1790 | 1886 | |
1791 | 1887 | $settings = $themeData[0]; |
@@ -1802,17 +1898,20 @@ discard block |
||
1802 | 1898 | $settings['template_dirs'][] = $settings['theme_dir']; |
1803 | 1899 | |
1804 | 1900 | // Based on theme (if there is one). |
1805 | - if (!empty($settings['base_theme_dir'])) |
|
1806 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1901 | + if (!empty($settings['base_theme_dir'])) { |
|
1902 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1903 | + } |
|
1807 | 1904 | |
1808 | 1905 | // Lastly the default theme. |
1809 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1810 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1906 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1907 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1908 | + } |
|
1811 | 1909 | } |
1812 | 1910 | |
1813 | 1911 | |
1814 | - if (!$initialize) |
|
1815 | - return; |
|
1912 | + if (!$initialize) { |
|
1913 | + return; |
|
1914 | + } |
|
1816 | 1915 | |
1817 | 1916 | // Check to see if we're forcing SSL |
1818 | 1917 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
@@ -1833,8 +1932,9 @@ discard block |
||
1833 | 1932 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1834 | 1933 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1835 | 1934 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1836 | - if ($temp != '/') |
|
1837 | - $detected_url .= $temp; |
|
1935 | + if ($temp != '/') { |
|
1936 | + $detected_url .= $temp; |
|
1937 | + } |
|
1838 | 1938 | } |
1839 | 1939 | if (isset($detected_url) && $detected_url != $boardurl) |
1840 | 1940 | { |
@@ -1846,8 +1946,9 @@ discard block |
||
1846 | 1946 | foreach ($aliases as $alias) |
1847 | 1947 | { |
1848 | 1948 | // Rip off all the boring parts, spaces, etc. |
1849 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1850 | - $do_fix = true; |
|
1949 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1950 | + $do_fix = true; |
|
1951 | + } |
|
1851 | 1952 | } |
1852 | 1953 | } |
1853 | 1954 | |
@@ -1855,21 +1956,23 @@ discard block |
||
1855 | 1956 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1856 | 1957 | { |
1857 | 1958 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1858 | - if (empty($_GET)) |
|
1859 | - redirectexit('wwwRedirect'); |
|
1860 | - else |
|
1959 | + if (empty($_GET)) { |
|
1960 | + redirectexit('wwwRedirect'); |
|
1961 | + } else |
|
1861 | 1962 | { |
1862 | 1963 | $k = key($_GET); |
1863 | 1964 | $v = current($_GET); |
1864 | 1965 | |
1865 | - if ($k != 'wwwRedirect') |
|
1866 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1966 | + if ($k != 'wwwRedirect') { |
|
1967 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1968 | + } |
|
1867 | 1969 | } |
1868 | 1970 | } |
1869 | 1971 | |
1870 | 1972 | // #3 is just a check for SSL... |
1871 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1872 | - $do_fix = true; |
|
1973 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1974 | + $do_fix = true; |
|
1975 | + } |
|
1873 | 1976 | |
1874 | 1977 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1875 | 1978 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1904,8 +2007,9 @@ discard block |
||
1904 | 2007 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1905 | 2008 | } |
1906 | 2009 | } |
1907 | - foreach ($context['linktree'] as $k => $dummy) |
|
1908 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2010 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2011 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2012 | + } |
|
1909 | 2013 | } |
1910 | 2014 | } |
1911 | 2015 | // Set up the contextual user array. |
@@ -1924,16 +2028,16 @@ discard block |
||
1924 | 2028 | 'email' => $user_info['email'], |
1925 | 2029 | 'ignoreusers' => $user_info['ignoreusers'], |
1926 | 2030 | ); |
1927 | - if (!$context['user']['is_guest']) |
|
1928 | - $context['user']['name'] = $user_info['name']; |
|
1929 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1930 | - $context['user']['name'] = $txt['guest_title']; |
|
2031 | + if (!$context['user']['is_guest']) { |
|
2032 | + $context['user']['name'] = $user_info['name']; |
|
2033 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2034 | + $context['user']['name'] = $txt['guest_title']; |
|
2035 | + } |
|
1931 | 2036 | |
1932 | 2037 | // Determine the current smiley set. |
1933 | 2038 | $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']; |
1934 | 2039 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1935 | - } |
|
1936 | - else |
|
2040 | + } else |
|
1937 | 2041 | { |
1938 | 2042 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1939 | 2043 | $context['user'] = array( |
@@ -1967,18 +2071,24 @@ discard block |
||
1967 | 2071 | } |
1968 | 2072 | |
1969 | 2073 | // Some basic information... |
1970 | - if (!isset($context['html_headers'])) |
|
1971 | - $context['html_headers'] = ''; |
|
1972 | - if (!isset($context['javascript_files'])) |
|
1973 | - $context['javascript_files'] = array(); |
|
1974 | - if (!isset($context['css_files'])) |
|
1975 | - $context['css_files'] = array(); |
|
1976 | - if (!isset($context['css_header'])) |
|
1977 | - $context['css_header'] = array(); |
|
1978 | - if (!isset($context['javascript_inline'])) |
|
1979 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1980 | - if (!isset($context['javascript_vars'])) |
|
1981 | - $context['javascript_vars'] = array(); |
|
2074 | + if (!isset($context['html_headers'])) { |
|
2075 | + $context['html_headers'] = ''; |
|
2076 | + } |
|
2077 | + if (!isset($context['javascript_files'])) { |
|
2078 | + $context['javascript_files'] = array(); |
|
2079 | + } |
|
2080 | + if (!isset($context['css_files'])) { |
|
2081 | + $context['css_files'] = array(); |
|
2082 | + } |
|
2083 | + if (!isset($context['css_header'])) { |
|
2084 | + $context['css_header'] = array(); |
|
2085 | + } |
|
2086 | + if (!isset($context['javascript_inline'])) { |
|
2087 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2088 | + } |
|
2089 | + if (!isset($context['javascript_vars'])) { |
|
2090 | + $context['javascript_vars'] = array(); |
|
2091 | + } |
|
1982 | 2092 | |
1983 | 2093 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
1984 | 2094 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1990,16 +2100,18 @@ discard block |
||
1990 | 2100 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
1991 | 2101 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
1992 | 2102 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
1993 | - if (isset($modSettings['load_average'])) |
|
1994 | - $context['load_average'] = $modSettings['load_average']; |
|
2103 | + if (isset($modSettings['load_average'])) { |
|
2104 | + $context['load_average'] = $modSettings['load_average']; |
|
2105 | + } |
|
1995 | 2106 | |
1996 | 2107 | // Detect the browser. This is separated out because it's also used in attachment downloads |
1997 | 2108 | detectBrowser(); |
1998 | 2109 | |
1999 | 2110 | // Set the top level linktree up. |
2000 | 2111 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
2001 | - if (empty($context['linktree'])) |
|
2002 | - $context['linktree'] = array(); |
|
2112 | + if (empty($context['linktree'])) { |
|
2113 | + $context['linktree'] = array(); |
|
2114 | + } |
|
2003 | 2115 | array_unshift($context['linktree'], array( |
2004 | 2116 | 'url' => $scripturl, |
2005 | 2117 | 'name' => $context['forum_name_html_safe'] |
@@ -2008,8 +2120,9 @@ discard block |
||
2008 | 2120 | // This allows sticking some HTML on the page output - useful for controls. |
2009 | 2121 | $context['insert_after_template'] = ''; |
2010 | 2122 | |
2011 | - if (!isset($txt)) |
|
2012 | - $txt = array(); |
|
2123 | + if (!isset($txt)) { |
|
2124 | + $txt = array(); |
|
2125 | + } |
|
2013 | 2126 | |
2014 | 2127 | $simpleActions = array( |
2015 | 2128 | 'findmember', |
@@ -2055,9 +2168,10 @@ discard block |
||
2055 | 2168 | |
2056 | 2169 | // See if theres any extra param to check. |
2057 | 2170 | $requiresXML = false; |
2058 | - foreach ($extraParams as $key => $extra) |
|
2059 | - if (isset($_REQUEST[$extra])) |
|
2171 | + foreach ($extraParams as $key => $extra) { |
|
2172 | + if (isset($_REQUEST[$extra])) |
|
2060 | 2173 | $requiresXML = true; |
2174 | + } |
|
2061 | 2175 | |
2062 | 2176 | // Output is fully XML, so no need for the index template. |
2063 | 2177 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2072,37 +2186,39 @@ discard block |
||
2072 | 2186 | { |
2073 | 2187 | loadLanguage('index+Modifications'); |
2074 | 2188 | $context['template_layers'] = array(); |
2075 | - } |
|
2076 | - |
|
2077 | - else |
|
2189 | + } else |
|
2078 | 2190 | { |
2079 | 2191 | // Custom templates to load, or just default? |
2080 | - if (isset($settings['theme_templates'])) |
|
2081 | - $templates = explode(',', $settings['theme_templates']); |
|
2082 | - else |
|
2083 | - $templates = array('index'); |
|
2192 | + if (isset($settings['theme_templates'])) { |
|
2193 | + $templates = explode(',', $settings['theme_templates']); |
|
2194 | + } else { |
|
2195 | + $templates = array('index'); |
|
2196 | + } |
|
2084 | 2197 | |
2085 | 2198 | // Load each template... |
2086 | - foreach ($templates as $template) |
|
2087 | - loadTemplate($template); |
|
2199 | + foreach ($templates as $template) { |
|
2200 | + loadTemplate($template); |
|
2201 | + } |
|
2088 | 2202 | |
2089 | 2203 | // ...and attempt to load their associated language files. |
2090 | 2204 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2091 | 2205 | loadLanguage($required_files, '', false); |
2092 | 2206 | |
2093 | 2207 | // Custom template layers? |
2094 | - if (isset($settings['theme_layers'])) |
|
2095 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2096 | - else |
|
2097 | - $context['template_layers'] = array('html', 'body'); |
|
2208 | + if (isset($settings['theme_layers'])) { |
|
2209 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2210 | + } else { |
|
2211 | + $context['template_layers'] = array('html', 'body'); |
|
2212 | + } |
|
2098 | 2213 | } |
2099 | 2214 | |
2100 | 2215 | // Initialize the theme. |
2101 | 2216 | loadSubTemplate('init', 'ignore'); |
2102 | 2217 | |
2103 | 2218 | // Allow overriding the board wide time/number formats. |
2104 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2105 | - $user_info['time_format'] = $txt['time_format']; |
|
2219 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2220 | + $user_info['time_format'] = $txt['time_format']; |
|
2221 | + } |
|
2106 | 2222 | |
2107 | 2223 | // Set the character set from the template. |
2108 | 2224 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2110,12 +2226,14 @@ discard block |
||
2110 | 2226 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2111 | 2227 | |
2112 | 2228 | // Guests may still need a name. |
2113 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2114 | - $context['user']['name'] = $txt['guest_title']; |
|
2229 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2230 | + $context['user']['name'] = $txt['guest_title']; |
|
2231 | + } |
|
2115 | 2232 | |
2116 | 2233 | // Any theme-related strings that need to be loaded? |
2117 | - if (!empty($settings['require_theme_strings'])) |
|
2118 | - loadLanguage('ThemeStrings', '', false); |
|
2234 | + if (!empty($settings['require_theme_strings'])) { |
|
2235 | + loadLanguage('ThemeStrings', '', false); |
|
2236 | + } |
|
2119 | 2237 | |
2120 | 2238 | // Make a special URL for the language. |
2121 | 2239 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2126,8 +2244,9 @@ discard block |
||
2126 | 2244 | // Here is my luvly Responsive CSS |
2127 | 2245 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2128 | 2246 | |
2129 | - if ($context['right_to_left']) |
|
2130 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2247 | + if ($context['right_to_left']) { |
|
2248 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2249 | + } |
|
2131 | 2250 | |
2132 | 2251 | // We allow theme variants, because we're cool. |
2133 | 2252 | $context['theme_variant'] = ''; |
@@ -2135,14 +2254,17 @@ discard block |
||
2135 | 2254 | if (!empty($settings['theme_variants'])) |
2136 | 2255 | { |
2137 | 2256 | // Overriding - for previews and that ilk. |
2138 | - if (!empty($_REQUEST['variant'])) |
|
2139 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2257 | + if (!empty($_REQUEST['variant'])) { |
|
2258 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2259 | + } |
|
2140 | 2260 | // User selection? |
2141 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2142 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2261 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2262 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2263 | + } |
|
2143 | 2264 | // If not a user variant, select the default. |
2144 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2145 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2265 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2266 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2267 | + } |
|
2146 | 2268 | |
2147 | 2269 | // Do this to keep things easier in the templates. |
2148 | 2270 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2151,20 +2273,23 @@ discard block |
||
2151 | 2273 | if (!empty($context['theme_variant'])) |
2152 | 2274 | { |
2153 | 2275 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2154 | - if ($context['right_to_left']) |
|
2155 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2276 | + if ($context['right_to_left']) { |
|
2277 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2278 | + } |
|
2156 | 2279 | } |
2157 | 2280 | } |
2158 | 2281 | |
2159 | 2282 | // Let's be compatible with old themes! |
2160 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2161 | - $context['template_layers'] = array('main'); |
|
2283 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2284 | + $context['template_layers'] = array('main'); |
|
2285 | + } |
|
2162 | 2286 | |
2163 | 2287 | $context['tabindex'] = 1; |
2164 | 2288 | |
2165 | 2289 | // Compatibility. |
2166 | - if (!isset($settings['theme_version'])) |
|
2167 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2290 | + if (!isset($settings['theme_version'])) { |
|
2291 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2292 | + } |
|
2168 | 2293 | |
2169 | 2294 | // Default JS variables for use in every theme |
2170 | 2295 | $context['javascript_vars'] = array( |
@@ -2183,18 +2308,18 @@ discard block |
||
2183 | 2308 | ); |
2184 | 2309 | |
2185 | 2310 | // Add the JQuery library to the list of files to load. |
2186 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2187 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2188 | - |
|
2189 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2190 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2191 | - |
|
2192 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2193 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2311 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2312 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2313 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2314 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2315 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2316 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2317 | + } |
|
2194 | 2318 | |
2195 | 2319 | // Auto loading? template_javascript() will take care of the local half of this. |
2196 | - else |
|
2197 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2320 | + else { |
|
2321 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2322 | + } |
|
2198 | 2323 | |
2199 | 2324 | // Queue our JQuery plugins! |
2200 | 2325 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2217,12 +2342,12 @@ discard block |
||
2217 | 2342 | require_once($sourcedir . '/ScheduledTasks.php'); |
2218 | 2343 | |
2219 | 2344 | // What to do, what to do?! |
2220 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2221 | - AutoTask(); |
|
2222 | - else |
|
2223 | - ReduceMailQueue(); |
|
2224 | - } |
|
2225 | - else |
|
2345 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2346 | + AutoTask(); |
|
2347 | + } else { |
|
2348 | + ReduceMailQueue(); |
|
2349 | + } |
|
2350 | + } else |
|
2226 | 2351 | { |
2227 | 2352 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2228 | 2353 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2273,8 +2398,9 @@ discard block |
||
2273 | 2398 | foreach ($theme_includes as $include) |
2274 | 2399 | { |
2275 | 2400 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2276 | - if (file_exists($include)) |
|
2277 | - require_once($include); |
|
2401 | + if (file_exists($include)) { |
|
2402 | + require_once($include); |
|
2403 | + } |
|
2278 | 2404 | } |
2279 | 2405 | } |
2280 | 2406 | |
@@ -2304,16 +2430,19 @@ discard block |
||
2304 | 2430 | // Do any style sheets first, cause we're easy with those. |
2305 | 2431 | if (!empty($style_sheets)) |
2306 | 2432 | { |
2307 | - if (!is_array($style_sheets)) |
|
2308 | - $style_sheets = array($style_sheets); |
|
2433 | + if (!is_array($style_sheets)) { |
|
2434 | + $style_sheets = array($style_sheets); |
|
2435 | + } |
|
2309 | 2436 | |
2310 | - foreach ($style_sheets as $sheet) |
|
2311 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2437 | + foreach ($style_sheets as $sheet) { |
|
2438 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2439 | + } |
|
2312 | 2440 | } |
2313 | 2441 | |
2314 | 2442 | // No template to load? |
2315 | - if ($template_name === false) |
|
2316 | - return true; |
|
2443 | + if ($template_name === false) { |
|
2444 | + return true; |
|
2445 | + } |
|
2317 | 2446 | |
2318 | 2447 | $loaded = false; |
2319 | 2448 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2328,12 +2457,14 @@ discard block |
||
2328 | 2457 | |
2329 | 2458 | if ($loaded) |
2330 | 2459 | { |
2331 | - if ($db_show_debug === true) |
|
2332 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2460 | + if ($db_show_debug === true) { |
|
2461 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2462 | + } |
|
2333 | 2463 | |
2334 | 2464 | // If they have specified an initialization function for this template, go ahead and call it now. |
2335 | - if (function_exists('template_' . $template_name . '_init')) |
|
2336 | - call_user_func('template_' . $template_name . '_init'); |
|
2465 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2466 | + call_user_func('template_' . $template_name . '_init'); |
|
2467 | + } |
|
2337 | 2468 | } |
2338 | 2469 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2339 | 2470 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2353,13 +2484,14 @@ discard block |
||
2353 | 2484 | loadTemplate($template_name); |
2354 | 2485 | } |
2355 | 2486 | // Cause an error otherwise. |
2356 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2357 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2358 | - elseif ($fatal) |
|
2359 | - 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')); |
|
2360 | - else |
|
2361 | - return false; |
|
2362 | -} |
|
2487 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2488 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2489 | + } elseif ($fatal) { |
|
2490 | + 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')); |
|
2491 | + } else { |
|
2492 | + return false; |
|
2493 | + } |
|
2494 | + } |
|
2363 | 2495 | |
2364 | 2496 | /** |
2365 | 2497 | * Load a sub-template. |
@@ -2377,17 +2509,19 @@ discard block |
||
2377 | 2509 | { |
2378 | 2510 | global $context, $txt, $db_show_debug; |
2379 | 2511 | |
2380 | - if ($db_show_debug === true) |
|
2381 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2512 | + if ($db_show_debug === true) { |
|
2513 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2514 | + } |
|
2382 | 2515 | |
2383 | 2516 | // Figure out what the template function is named. |
2384 | 2517 | $theme_function = 'template_' . $sub_template_name; |
2385 | - if (function_exists($theme_function)) |
|
2386 | - $theme_function(); |
|
2387 | - elseif ($fatal === false) |
|
2388 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2389 | - elseif ($fatal !== 'ignore') |
|
2390 | - 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')); |
|
2518 | + if (function_exists($theme_function)) { |
|
2519 | + $theme_function(); |
|
2520 | + } elseif ($fatal === false) { |
|
2521 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2522 | + } elseif ($fatal !== 'ignore') { |
|
2523 | + 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')); |
|
2524 | + } |
|
2391 | 2525 | |
2392 | 2526 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2393 | 2527 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2424,8 +2558,9 @@ discard block |
||
2424 | 2558 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2425 | 2559 | |
2426 | 2560 | // If this is an external file, automatically set this to false. |
2427 | - if (!empty($params['external'])) |
|
2428 | - $params['minimize'] = false; |
|
2561 | + if (!empty($params['external'])) { |
|
2562 | + $params['minimize'] = false; |
|
2563 | + } |
|
2429 | 2564 | |
2430 | 2565 | // Account for shorthand like admin.css?alp21 filenames |
2431 | 2566 | $has_seed = strpos($fileName, '.css?'); |
@@ -2442,13 +2577,10 @@ discard block |
||
2442 | 2577 | { |
2443 | 2578 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2444 | 2579 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2580 | + } else { |
|
2581 | + $fileUrl = false; |
|
2445 | 2582 | } |
2446 | - |
|
2447 | - else |
|
2448 | - $fileUrl = false; |
|
2449 | - } |
|
2450 | - |
|
2451 | - else |
|
2583 | + } else |
|
2452 | 2584 | { |
2453 | 2585 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2454 | 2586 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2463,12 +2595,14 @@ discard block |
||
2463 | 2595 | } |
2464 | 2596 | |
2465 | 2597 | // Add it to the array for use in the template |
2466 | - if (!empty($fileName)) |
|
2467 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2598 | + if (!empty($fileName)) { |
|
2599 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2600 | + } |
|
2468 | 2601 | |
2469 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2470 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2471 | -} |
|
2602 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2603 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2604 | + } |
|
2605 | + } |
|
2472 | 2606 | |
2473 | 2607 | /** |
2474 | 2608 | * Add a block of inline css code to be executed later |
@@ -2485,8 +2619,9 @@ discard block |
||
2485 | 2619 | global $context; |
2486 | 2620 | |
2487 | 2621 | // Gotta add something... |
2488 | - if (empty($css)) |
|
2489 | - return false; |
|
2622 | + if (empty($css)) { |
|
2623 | + return false; |
|
2624 | + } |
|
2490 | 2625 | |
2491 | 2626 | $context['css_header'][] = $css; |
2492 | 2627 | } |
@@ -2521,8 +2656,9 @@ discard block |
||
2521 | 2656 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2522 | 2657 | |
2523 | 2658 | // If this is an external file, automatically set this to false. |
2524 | - if (!empty($params['external'])) |
|
2525 | - $params['minimize'] = false; |
|
2659 | + if (!empty($params['external'])) { |
|
2660 | + $params['minimize'] = false; |
|
2661 | + } |
|
2526 | 2662 | |
2527 | 2663 | // Account for shorthand like admin.js?alp21 filenames |
2528 | 2664 | $has_seed = strpos($fileName, '.js?'); |
@@ -2539,16 +2675,12 @@ discard block |
||
2539 | 2675 | { |
2540 | 2676 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2541 | 2677 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2542 | - } |
|
2543 | - |
|
2544 | - else |
|
2678 | + } else |
|
2545 | 2679 | { |
2546 | 2680 | $fileUrl = false; |
2547 | 2681 | $filePath = false; |
2548 | 2682 | } |
2549 | - } |
|
2550 | - |
|
2551 | - else |
|
2683 | + } else |
|
2552 | 2684 | { |
2553 | 2685 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2554 | 2686 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2563,9 +2695,10 @@ discard block |
||
2563 | 2695 | } |
2564 | 2696 | |
2565 | 2697 | // Add it to the array for use in the template |
2566 | - if (!empty($fileName)) |
|
2567 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2568 | -} |
|
2698 | + if (!empty($fileName)) { |
|
2699 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2700 | + } |
|
2701 | + } |
|
2569 | 2702 | |
2570 | 2703 | /** |
2571 | 2704 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2579,9 +2712,10 @@ discard block |
||
2579 | 2712 | { |
2580 | 2713 | global $context; |
2581 | 2714 | |
2582 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2583 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2584 | -} |
|
2715 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2716 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2717 | + } |
|
2718 | + } |
|
2585 | 2719 | |
2586 | 2720 | /** |
2587 | 2721 | * Add a block of inline Javascript code to be executed later |
@@ -2598,8 +2732,9 @@ discard block |
||
2598 | 2732 | { |
2599 | 2733 | global $context; |
2600 | 2734 | |
2601 | - if (empty($javascript)) |
|
2602 | - return false; |
|
2735 | + if (empty($javascript)) { |
|
2736 | + return false; |
|
2737 | + } |
|
2603 | 2738 | |
2604 | 2739 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2605 | 2740 | } |
@@ -2620,15 +2755,18 @@ discard block |
||
2620 | 2755 | static $already_loaded = array(); |
2621 | 2756 | |
2622 | 2757 | // Default to the user's language. |
2623 | - if ($lang == '') |
|
2624 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2758 | + if ($lang == '') { |
|
2759 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2760 | + } |
|
2625 | 2761 | |
2626 | 2762 | // Do we want the English version of language file as fallback? |
2627 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2628 | - loadLanguage($template_name, 'english', false); |
|
2763 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2764 | + loadLanguage($template_name, 'english', false); |
|
2765 | + } |
|
2629 | 2766 | |
2630 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2631 | - return $lang; |
|
2767 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2768 | + return $lang; |
|
2769 | + } |
|
2632 | 2770 | |
2633 | 2771 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2634 | 2772 | if (empty($settings['default_theme_dir'])) |
@@ -2639,8 +2777,9 @@ discard block |
||
2639 | 2777 | |
2640 | 2778 | // What theme are we in? |
2641 | 2779 | $theme_name = basename($settings['theme_url']); |
2642 | - if (empty($theme_name)) |
|
2643 | - $theme_name = 'unknown'; |
|
2780 | + if (empty($theme_name)) { |
|
2781 | + $theme_name = 'unknown'; |
|
2782 | + } |
|
2644 | 2783 | |
2645 | 2784 | // For each file open it up and write it out! |
2646 | 2785 | foreach (explode('+', $template_name) as $template) |
@@ -2682,8 +2821,9 @@ discard block |
||
2682 | 2821 | $found = true; |
2683 | 2822 | |
2684 | 2823 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2685 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2686 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2824 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2825 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2826 | + } |
|
2687 | 2827 | |
2688 | 2828 | break; |
2689 | 2829 | } |
@@ -2723,8 +2863,9 @@ discard block |
||
2723 | 2863 | } |
2724 | 2864 | |
2725 | 2865 | // Keep track of what we're up to soldier. |
2726 | - if ($db_show_debug === true) |
|
2727 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2866 | + if ($db_show_debug === true) { |
|
2867 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2868 | + } |
|
2728 | 2869 | |
2729 | 2870 | // Remember what we have loaded, and in which language. |
2730 | 2871 | $already_loaded[$template_name] = $lang; |
@@ -2770,8 +2911,9 @@ discard block |
||
2770 | 2911 | ) |
2771 | 2912 | ); |
2772 | 2913 | // In the EXTREMELY unlikely event this happens, give an error message. |
2773 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2774 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2914 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2915 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2916 | + } |
|
2775 | 2917 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2776 | 2918 | { |
2777 | 2919 | if (!isset($boards[$row['id_board']])) |
@@ -2788,8 +2930,8 @@ discard block |
||
2788 | 2930 | ); |
2789 | 2931 | } |
2790 | 2932 | // If a moderator exists for this board, add that moderator for all children too. |
2791 | - if (!empty($row['id_moderator'])) |
|
2792 | - foreach ($boards as $id => $dummy) |
|
2933 | + if (!empty($row['id_moderator'])) { |
|
2934 | + foreach ($boards as $id => $dummy) |
|
2793 | 2935 | { |
2794 | 2936 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2795 | 2937 | 'id' => $row['id_moderator'], |
@@ -2797,11 +2939,12 @@ discard block |
||
2797 | 2939 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2798 | 2940 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2799 | 2941 | ); |
2942 | + } |
|
2800 | 2943 | } |
2801 | 2944 | |
2802 | 2945 | // If a moderator group exists for this board, add that moderator group for all children too |
2803 | - if (!empty($row['id_moderator_group'])) |
|
2804 | - foreach ($boards as $id => $dummy) |
|
2946 | + if (!empty($row['id_moderator_group'])) { |
|
2947 | + foreach ($boards as $id => $dummy) |
|
2805 | 2948 | { |
2806 | 2949 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2807 | 2950 | 'id' => $row['id_moderator_group'], |
@@ -2809,6 +2952,7 @@ discard block |
||
2809 | 2952 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2810 | 2953 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2811 | 2954 | ); |
2955 | + } |
|
2812 | 2956 | } |
2813 | 2957 | } |
2814 | 2958 | $smcFunc['db_free_result']($result); |
@@ -2835,23 +2979,27 @@ discard block |
||
2835 | 2979 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2836 | 2980 | { |
2837 | 2981 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2838 | - if (empty($smcFunc['ucwords'])) |
|
2839 | - reloadSettings(); |
|
2982 | + if (empty($smcFunc['ucwords'])) { |
|
2983 | + reloadSettings(); |
|
2984 | + } |
|
2840 | 2985 | |
2841 | 2986 | // If we don't have our theme information yet, let's get it. |
2842 | - if (empty($settings['default_theme_dir'])) |
|
2843 | - loadTheme(0, false); |
|
2987 | + if (empty($settings['default_theme_dir'])) { |
|
2988 | + loadTheme(0, false); |
|
2989 | + } |
|
2844 | 2990 | |
2845 | 2991 | // Default language directories to try. |
2846 | 2992 | $language_directories = array( |
2847 | 2993 | $settings['default_theme_dir'] . '/languages', |
2848 | 2994 | ); |
2849 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2850 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2995 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
2996 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2997 | + } |
|
2851 | 2998 | |
2852 | 2999 | // We possibly have a base theme directory. |
2853 | - if (!empty($settings['base_theme_dir'])) |
|
2854 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3000 | + if (!empty($settings['base_theme_dir'])) { |
|
3001 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3002 | + } |
|
2855 | 3003 | |
2856 | 3004 | // Remove any duplicates. |
2857 | 3005 | $language_directories = array_unique($language_directories); |
@@ -2865,20 +3013,21 @@ discard block |
||
2865 | 3013 | foreach ($language_directories as $language_dir) |
2866 | 3014 | { |
2867 | 3015 | // Can't look in here... doesn't exist! |
2868 | - if (!file_exists($language_dir)) |
|
2869 | - continue; |
|
3016 | + if (!file_exists($language_dir)) { |
|
3017 | + continue; |
|
3018 | + } |
|
2870 | 3019 | |
2871 | 3020 | $dir = dir($language_dir); |
2872 | 3021 | while ($entry = $dir->read()) |
2873 | 3022 | { |
2874 | 3023 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2875 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2876 | - continue; |
|
2877 | - |
|
2878 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2879 | - $langName = $langList[$matches[1]]; |
|
3024 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3025 | + continue; |
|
3026 | + } |
|
2880 | 3027 | |
2881 | - else |
|
3028 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3029 | + $langName = $langList[$matches[1]]; |
|
3030 | + } else |
|
2882 | 3031 | { |
2883 | 3032 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2884 | 3033 | |
@@ -2919,12 +3068,14 @@ discard block |
||
2919 | 3068 | } |
2920 | 3069 | |
2921 | 3070 | // Do we need to store the lang list? |
2922 | - if (empty($langList)) |
|
2923 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3071 | + if (empty($langList)) { |
|
3072 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3073 | + } |
|
2924 | 3074 | |
2925 | 3075 | // Let's cash in on this deal. |
2926 | - if (!empty($modSettings['cache_enable'])) |
|
2927 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3076 | + if (!empty($modSettings['cache_enable'])) { |
|
3077 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3078 | + } |
|
2928 | 3079 | } |
2929 | 3080 | |
2930 | 3081 | return $context['languages']; |
@@ -2947,8 +3098,9 @@ discard block |
||
2947 | 3098 | global $modSettings, $options, $txt; |
2948 | 3099 | static $censor_vulgar = null, $censor_proper; |
2949 | 3100 | |
2950 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2951 | - return $text; |
|
3101 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3102 | + return $text; |
|
3103 | + } |
|
2952 | 3104 | |
2953 | 3105 | // If they haven't yet been loaded, load them. |
2954 | 3106 | if ($censor_vulgar == null) |
@@ -2976,9 +3128,9 @@ discard block |
||
2976 | 3128 | { |
2977 | 3129 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
2978 | 3130 | $text = $func($censor_vulgar, $censor_proper, $text); |
3131 | + } else { |
|
3132 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2979 | 3133 | } |
2980 | - else |
|
2981 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2982 | 3134 | |
2983 | 3135 | return $text; |
2984 | 3136 | } |
@@ -3004,38 +3156,42 @@ discard block |
||
3004 | 3156 | @ini_set('track_errors', '1'); |
3005 | 3157 | |
3006 | 3158 | // Don't include the file more than once, if $once is true. |
3007 | - if ($once && in_array($filename, $templates)) |
|
3008 | - return; |
|
3159 | + if ($once && in_array($filename, $templates)) { |
|
3160 | + return; |
|
3161 | + } |
|
3009 | 3162 | // Add this file to the include list, whether $once is true or not. |
3010 | - else |
|
3011 | - $templates[] = $filename; |
|
3163 | + else { |
|
3164 | + $templates[] = $filename; |
|
3165 | + } |
|
3012 | 3166 | |
3013 | 3167 | // Are we going to use eval? |
3014 | 3168 | if (empty($modSettings['disableTemplateEval'])) |
3015 | 3169 | { |
3016 | 3170 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
3017 | 3171 | $settings['current_include_filename'] = $filename; |
3018 | - } |
|
3019 | - else |
|
3172 | + } else |
|
3020 | 3173 | { |
3021 | 3174 | $file_found = file_exists($filename); |
3022 | 3175 | |
3023 | - if ($once && $file_found) |
|
3024 | - require_once($filename); |
|
3025 | - elseif ($file_found) |
|
3026 | - require($filename); |
|
3176 | + if ($once && $file_found) { |
|
3177 | + require_once($filename); |
|
3178 | + } elseif ($file_found) { |
|
3179 | + require($filename); |
|
3180 | + } |
|
3027 | 3181 | } |
3028 | 3182 | |
3029 | 3183 | if ($file_found !== true) |
3030 | 3184 | { |
3031 | 3185 | ob_end_clean(); |
3032 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3033 | - @ob_start('ob_gzhandler'); |
|
3034 | - else |
|
3035 | - ob_start(); |
|
3186 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3187 | + @ob_start('ob_gzhandler'); |
|
3188 | + } else { |
|
3189 | + ob_start(); |
|
3190 | + } |
|
3036 | 3191 | |
3037 | - if (isset($_GET['debug'])) |
|
3038 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3192 | + if (isset($_GET['debug'])) { |
|
3193 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3194 | + } |
|
3039 | 3195 | |
3040 | 3196 | // Don't cache error pages!! |
3041 | 3197 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3054,12 +3210,13 @@ discard block |
||
3054 | 3210 | echo '<!DOCTYPE html> |
3055 | 3211 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3056 | 3212 | <head>'; |
3057 | - if (isset($context['character_set'])) |
|
3058 | - echo ' |
|
3213 | + if (isset($context['character_set'])) { |
|
3214 | + echo ' |
|
3059 | 3215 | <meta charset="', $context['character_set'], '">'; |
3216 | + } |
|
3060 | 3217 | |
3061 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3062 | - echo ' |
|
3218 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3219 | + echo ' |
|
3063 | 3220 | <title>', $mtitle, '</title> |
3064 | 3221 | </head> |
3065 | 3222 | <body> |
@@ -3067,8 +3224,8 @@ discard block |
||
3067 | 3224 | ', $mmessage, ' |
3068 | 3225 | </body> |
3069 | 3226 | </html>'; |
3070 | - elseif (!allowedTo('admin_forum')) |
|
3071 | - echo ' |
|
3227 | + } elseif (!allowedTo('admin_forum')) { |
|
3228 | + echo ' |
|
3072 | 3229 | <title>', $txt['template_parse_error'], '</title> |
3073 | 3230 | </head> |
3074 | 3231 | <body> |
@@ -3076,16 +3233,18 @@ discard block |
||
3076 | 3233 | ', $txt['template_parse_error_message'], ' |
3077 | 3234 | </body> |
3078 | 3235 | </html>'; |
3079 | - else |
|
3236 | + } else |
|
3080 | 3237 | { |
3081 | 3238 | require_once($sourcedir . '/Subs-Package.php'); |
3082 | 3239 | |
3083 | 3240 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3084 | 3241 | $error_array = error_get_last(); |
3085 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3086 | - $error = $error_array['message']; |
|
3087 | - if (empty($error)) |
|
3088 | - $error = $txt['template_parse_errmsg']; |
|
3242 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3243 | + $error = $error_array['message']; |
|
3244 | + } |
|
3245 | + if (empty($error)) { |
|
3246 | + $error = $txt['template_parse_errmsg']; |
|
3247 | + } |
|
3089 | 3248 | |
3090 | 3249 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3091 | 3250 | |
@@ -3096,11 +3255,12 @@ discard block |
||
3096 | 3255 | <h3>', $txt['template_parse_error'], '</h3> |
3097 | 3256 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3098 | 3257 | |
3099 | - if (!empty($error)) |
|
3100 | - echo ' |
|
3258 | + if (!empty($error)) { |
|
3259 | + echo ' |
|
3101 | 3260 | <hr> |
3102 | 3261 | |
3103 | 3262 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3263 | + } |
|
3104 | 3264 | |
3105 | 3265 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3106 | 3266 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3110,10 +3270,11 @@ discard block |
||
3110 | 3270 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3111 | 3271 | |
3112 | 3272 | // Fix the PHP code stuff... |
3113 | - if (!isBrowser('gecko')) |
|
3114 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3115 | - else |
|
3116 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3273 | + if (!isBrowser('gecko')) { |
|
3274 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3275 | + } else { |
|
3276 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3277 | + } |
|
3117 | 3278 | |
3118 | 3279 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3119 | 3280 | $j = -1; |
@@ -3121,8 +3282,9 @@ discard block |
||
3121 | 3282 | { |
3122 | 3283 | $j++; |
3123 | 3284 | |
3124 | - if (substr_count($line, '<br>') == 0) |
|
3125 | - continue; |
|
3285 | + if (substr_count($line, '<br>') == 0) { |
|
3286 | + continue; |
|
3287 | + } |
|
3126 | 3288 | |
3127 | 3289 | $n = substr_count($line, '<br>'); |
3128 | 3290 | for ($i = 0; $i < $n; $i++) |
@@ -3141,38 +3303,42 @@ discard block |
||
3141 | 3303 | // Figure out what the color coding was before... |
3142 | 3304 | $line = max($match[1] - 9, 1); |
3143 | 3305 | $last_line = ''; |
3144 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3145 | - if (strpos($data2[$line2], '<') !== false) |
|
3306 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3307 | + if (strpos($data2[$line2], '<') !== false) |
|
3146 | 3308 | { |
3147 | 3309 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3148 | 3310 | $last_line = $color_match[1]; |
3311 | + } |
|
3149 | 3312 | break; |
3150 | 3313 | } |
3151 | 3314 | |
3152 | 3315 | // Show the relevant lines... |
3153 | 3316 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3154 | 3317 | { |
3155 | - if ($line == $match[1]) |
|
3156 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3318 | + if ($line == $match[1]) { |
|
3319 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3320 | + } |
|
3157 | 3321 | |
3158 | 3322 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3159 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3160 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3323 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3324 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3325 | + } |
|
3161 | 3326 | |
3162 | 3327 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3163 | 3328 | { |
3164 | 3329 | $last_line = $color_match[1]; |
3165 | 3330 | echo '</', substr($last_line, 1, 4), '>'; |
3331 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3332 | + $last_line = ''; |
|
3333 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3334 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3166 | 3335 | } |
3167 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3168 | - $last_line = ''; |
|
3169 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3170 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3171 | 3336 | |
3172 | - if ($line == $match[1]) |
|
3173 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3174 | - else |
|
3175 | - echo "\n"; |
|
3337 | + if ($line == $match[1]) { |
|
3338 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3339 | + } else { |
|
3340 | + echo "\n"; |
|
3341 | + } |
|
3176 | 3342 | } |
3177 | 3343 | |
3178 | 3344 | echo '</pre></div>'; |
@@ -3196,8 +3362,9 @@ discard block |
||
3196 | 3362 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3197 | 3363 | |
3198 | 3364 | // Figure out what type of database we are using. |
3199 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3200 | - $db_type = 'mysql'; |
|
3365 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3366 | + $db_type = 'mysql'; |
|
3367 | + } |
|
3201 | 3368 | |
3202 | 3369 | // Load the file for the database. |
3203 | 3370 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3205,8 +3372,9 @@ discard block |
||
3205 | 3372 | $db_options = array(); |
3206 | 3373 | |
3207 | 3374 | // Add in the port if needed |
3208 | - if (!empty($db_port)) |
|
3209 | - $db_options['port'] = $db_port; |
|
3375 | + if (!empty($db_port)) { |
|
3376 | + $db_options['port'] = $db_port; |
|
3377 | + } |
|
3210 | 3378 | |
3211 | 3379 | // 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. |
3212 | 3380 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3225,13 +3393,15 @@ discard block |
||
3225 | 3393 | } |
3226 | 3394 | |
3227 | 3395 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3228 | - if (!$db_connection) |
|
3229 | - display_db_error(); |
|
3396 | + if (!$db_connection) { |
|
3397 | + display_db_error(); |
|
3398 | + } |
|
3230 | 3399 | |
3231 | 3400 | // If in SSI mode fix up the prefix. |
3232 | - if (SMF == 'SSI') |
|
3233 | - db_fix_prefix($db_prefix, $db_name); |
|
3234 | -} |
|
3401 | + if (SMF == 'SSI') { |
|
3402 | + db_fix_prefix($db_prefix, $db_name); |
|
3403 | + } |
|
3404 | + } |
|
3235 | 3405 | |
3236 | 3406 | /** |
3237 | 3407 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3245,10 +3415,11 @@ discard block |
||
3245 | 3415 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3246 | 3416 | |
3247 | 3417 | // Not overriding this and we have a cacheAPI, send it back. |
3248 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3249 | - return $cacheAPI; |
|
3250 | - elseif (is_null($cacheAPI)) |
|
3251 | - $cacheAPI = false; |
|
3418 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3419 | + return $cacheAPI; |
|
3420 | + } elseif (is_null($cacheAPI)) { |
|
3421 | + $cacheAPI = false; |
|
3422 | + } |
|
3252 | 3423 | |
3253 | 3424 | // Make sure our class is in session. |
3254 | 3425 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3269,8 +3440,9 @@ discard block |
||
3269 | 3440 | if (!$testAPI->isSupported()) |
3270 | 3441 | { |
3271 | 3442 | // Can we save ourselves? |
3272 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3273 | - return loadCacheAccelerator(null, false); |
|
3443 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3444 | + return loadCacheAccelerator(null, false); |
|
3445 | + } |
|
3274 | 3446 | return false; |
3275 | 3447 | } |
3276 | 3448 | |
@@ -3282,9 +3454,9 @@ discard block |
||
3282 | 3454 | { |
3283 | 3455 | $cacheAPI = $testAPI; |
3284 | 3456 | return $cacheAPI; |
3457 | + } else { |
|
3458 | + return $testAPI; |
|
3285 | 3459 | } |
3286 | - else |
|
3287 | - return $testAPI; |
|
3288 | 3460 | } |
3289 | 3461 | } |
3290 | 3462 | |
@@ -3304,8 +3476,9 @@ discard block |
||
3304 | 3476 | |
3305 | 3477 | // @todo Why are we doing this if caching is disabled? |
3306 | 3478 | |
3307 | - if (function_exists('call_integration_hook')) |
|
3308 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3479 | + if (function_exists('call_integration_hook')) { |
|
3480 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3481 | + } |
|
3309 | 3482 | |
3310 | 3483 | /* Refresh the cache if either: |
3311 | 3484 | 1. Caching is disabled. |
@@ -3319,16 +3492,19 @@ discard block |
||
3319 | 3492 | require_once($sourcedir . '/' . $file); |
3320 | 3493 | $cache_block = call_user_func_array($function, $params); |
3321 | 3494 | |
3322 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3323 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3495 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3496 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3497 | + } |
|
3324 | 3498 | } |
3325 | 3499 | |
3326 | 3500 | // Some cached data may need a freshening up after retrieval. |
3327 | - if (!empty($cache_block['post_retri_eval'])) |
|
3328 | - eval($cache_block['post_retri_eval']); |
|
3501 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3502 | + eval($cache_block['post_retri_eval']); |
|
3503 | + } |
|
3329 | 3504 | |
3330 | - if (function_exists('call_integration_hook')) |
|
3331 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3505 | + if (function_exists('call_integration_hook')) { |
|
3506 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3507 | + } |
|
3332 | 3508 | |
3333 | 3509 | return $cache_block['data']; |
3334 | 3510 | } |
@@ -3355,8 +3531,9 @@ discard block |
||
3355 | 3531 | global $smcFunc, $cache_enable, $cacheAPI; |
3356 | 3532 | global $cache_hits, $cache_count, $db_show_debug; |
3357 | 3533 | |
3358 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3359 | - return; |
|
3534 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3535 | + return; |
|
3536 | + } |
|
3360 | 3537 | |
3361 | 3538 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3362 | 3539 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3369,12 +3546,14 @@ discard block |
||
3369 | 3546 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3370 | 3547 | $cacheAPI->putData($key, $value, $ttl); |
3371 | 3548 | |
3372 | - if (function_exists('call_integration_hook')) |
|
3373 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3549 | + if (function_exists('call_integration_hook')) { |
|
3550 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3551 | + } |
|
3374 | 3552 | |
3375 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3376 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3377 | -} |
|
3553 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3554 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3555 | + } |
|
3556 | + } |
|
3378 | 3557 | |
3379 | 3558 | /** |
3380 | 3559 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3390,8 +3569,9 @@ discard block |
||
3390 | 3569 | global $smcFunc, $cache_enable, $cacheAPI; |
3391 | 3570 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3392 | 3571 | |
3393 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3394 | - return; |
|
3572 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3573 | + return; |
|
3574 | + } |
|
3395 | 3575 | |
3396 | 3576 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3397 | 3577 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3411,16 +3591,18 @@ discard block |
||
3411 | 3591 | |
3412 | 3592 | if (empty($value)) |
3413 | 3593 | { |
3414 | - if (!is_array($cache_misses)) |
|
3415 | - $cache_misses = array(); |
|
3594 | + if (!is_array($cache_misses)) { |
|
3595 | + $cache_misses = array(); |
|
3596 | + } |
|
3416 | 3597 | |
3417 | 3598 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3418 | 3599 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3419 | 3600 | } |
3420 | 3601 | } |
3421 | 3602 | |
3422 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3423 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3603 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3604 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3605 | + } |
|
3424 | 3606 | |
3425 | 3607 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3426 | 3608 | } |
@@ -3442,8 +3624,9 @@ discard block |
||
3442 | 3624 | global $cacheAPI; |
3443 | 3625 | |
3444 | 3626 | // If we can't get to the API, can't do this. |
3445 | - if (empty($cacheAPI)) |
|
3446 | - return; |
|
3627 | + if (empty($cacheAPI)) { |
|
3628 | + return; |
|
3629 | + } |
|
3447 | 3630 | |
3448 | 3631 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3449 | 3632 | $cacheAPI->cleanCache($type); |
@@ -3468,8 +3651,9 @@ discard block |
||
3468 | 3651 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3469 | 3652 | |
3470 | 3653 | // Come on! |
3471 | - if (empty($data)) |
|
3472 | - return array(); |
|
3654 | + if (empty($data)) { |
|
3655 | + return array(); |
|
3656 | + } |
|
3473 | 3657 | |
3474 | 3658 | // Set a nice default var. |
3475 | 3659 | $image = ''; |
@@ -3477,11 +3661,11 @@ discard block |
||
3477 | 3661 | // Gravatar has been set as mandatory! |
3478 | 3662 | if (!empty($modSettings['gravatarOverride'])) |
3479 | 3663 | { |
3480 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3481 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3482 | - |
|
3483 | - else if (!empty($data['email'])) |
|
3484 | - $image = get_gravatar_url($data['email']); |
|
3664 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3665 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3666 | + } else if (!empty($data['email'])) { |
|
3667 | + $image = get_gravatar_url($data['email']); |
|
3668 | + } |
|
3485 | 3669 | } |
3486 | 3670 | |
3487 | 3671 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3493,54 +3677,60 @@ discard block |
||
3493 | 3677 | // Gravatar. |
3494 | 3678 | if (stristr($data['avatar'], 'gravatar://')) |
3495 | 3679 | { |
3496 | - if ($data['avatar'] == 'gravatar://') |
|
3497 | - $image = get_gravatar_url($data['email']); |
|
3498 | - |
|
3499 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3500 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3680 | + if ($data['avatar'] == 'gravatar://') { |
|
3681 | + $image = get_gravatar_url($data['email']); |
|
3682 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3683 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3684 | + } |
|
3501 | 3685 | } |
3502 | 3686 | |
3503 | 3687 | // External url. |
3504 | 3688 | else |
3505 | 3689 | { |
3506 | 3690 | // Using ssl? |
3507 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3508 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3691 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3692 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3693 | + } |
|
3509 | 3694 | |
3510 | 3695 | // Just a plain external url. |
3511 | - else |
|
3512 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3696 | + else { |
|
3697 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3698 | + } |
|
3513 | 3699 | } |
3514 | 3700 | } |
3515 | 3701 | |
3516 | 3702 | // Perhaps this user has an attachment as avatar... |
3517 | - else if (!empty($data['filename'])) |
|
3518 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3703 | + else if (!empty($data['filename'])) { |
|
3704 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3705 | + } |
|
3519 | 3706 | |
3520 | 3707 | // Right... no avatar... use our default image. |
3521 | - else |
|
3522 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3708 | + else { |
|
3709 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3710 | + } |
|
3523 | 3711 | } |
3524 | 3712 | |
3525 | 3713 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3526 | 3714 | |
3527 | 3715 | // 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. |
3528 | - if (!empty($image)) |
|
3529 | - return array( |
|
3716 | + if (!empty($image)) { |
|
3717 | + return array( |
|
3530 | 3718 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3531 | 3719 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3532 | 3720 | 'href' => $image, |
3533 | 3721 | 'url' => $image, |
3534 | 3722 | ); |
3723 | + } |
|
3535 | 3724 | |
3536 | 3725 | // Fallback to make life easier for everyone... |
3537 | - else |
|
3538 | - return array( |
|
3726 | + else { |
|
3727 | + return array( |
|
3539 | 3728 | 'name' => '', |
3540 | 3729 | 'image' => '', |
3541 | 3730 | 'href' => '', |
3542 | 3731 | 'url' => '', |
3543 | 3732 | ); |
3544 | -} |
|
3733 | + } |
|
3734 | + } |
|
3545 | 3735 | |
3546 | 3736 | ?> |
3547 | 3737 | \ No newline at end of file |