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