@@ -2259,9 +2259,9 @@ discard block |
||
| 2259 | 2259 | * |
| 2260 | 2260 | * @uses the template_include() function to include the file. |
| 2261 | 2261 | * @param string $template_name The name of the template to load |
| 2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
| 2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
| 2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
| 2264 | - * @return boolean Whether or not the template was loaded |
|
| 2264 | + * @return boolean|null Whether or not the template was loaded |
|
| 2265 | 2265 | */ |
| 2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
| 2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
| 2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
| 2445 | 2445 | * |
| 2446 | 2446 | * @param string $css Some css code |
| 2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
| 2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
| 2448 | 2448 | */ |
| 2449 | 2449 | function addInlineCss($css) |
| 2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
| 2558 | 2558 | * |
| 2559 | 2559 | * @param string $javascript Some JS code |
| 2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
| 2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
| 2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
| 2562 | 2562 | */ |
| 2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
| 2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
| 2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
| 2792 | 2792 | * |
| 2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
| 2794 | - * @return array An array of information about available languages |
|
| 2794 | + * @return string An array of information about available languages |
|
| 2795 | 2795 | */ |
| 2796 | 2796 | function getLanguages($use_cache = true) |
| 2797 | 2797 | { |
@@ -1719,7 +1719,7 @@ |
||
| 1719 | 1719 | $id_theme = $modSettings['theme_guests']; |
| 1720 | 1720 | |
| 1721 | 1721 | // We already load the basic stuff? |
| 1722 | - if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
|
| 1722 | + if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme) |
|
| 1723 | 1723 | { |
| 1724 | 1724 | // Verify the id_theme... no foul play. |
| 1725 | 1725 | // Always allow the board specific theme, if they are overriding. |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
| 25 | 26 | global $cache_enable, $sourcedir, $context; |
| 26 | 27 | |
| 27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
| 28 | - if (!empty($db_character_set)) |
|
| 29 | - $smcFunc['db_query']('', ' |
|
| 29 | + if (!empty($db_character_set)) { |
|
| 30 | + $smcFunc['db_query']('', ' |
|
| 30 | 31 | SET NAMES {string:db_character_set}', |
| 31 | 32 | array( |
| 32 | 33 | 'db_character_set' => $db_character_set, |
| 33 | 34 | ) |
| 34 | 35 | ); |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // We need some caching support, maybe. |
| 37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
| 46 | 48 | ) |
| 47 | 49 | ); |
| 48 | 50 | $modSettings = array(); |
| 49 | - if (!$request) |
|
| 50 | - display_db_error(); |
|
| 51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 52 | - $modSettings[$row[0]] = $row[1]; |
|
| 51 | + if (!$request) { |
|
| 52 | + display_db_error(); |
|
| 53 | + } |
|
| 54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 55 | + $modSettings[$row[0]] = $row[1]; |
|
| 56 | + } |
|
| 53 | 57 | $smcFunc['db_free_result']($request); |
| 54 | 58 | |
| 55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
| 56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
| 57 | - $modSettings['defaultMaxTopics'] = 20; |
|
| 58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
| 59 | - $modSettings['defaultMaxMessages'] = 15; |
|
| 60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
| 61 | - $modSettings['defaultMaxMembers'] = 30; |
|
| 62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
| 63 | - $modSettings['defaultMaxListItems'] = 15; |
|
| 60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
| 61 | + $modSettings['defaultMaxTopics'] = 20; |
|
| 62 | + } |
|
| 63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
| 64 | + $modSettings['defaultMaxMessages'] = 15; |
|
| 65 | + } |
|
| 66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
| 67 | + $modSettings['defaultMaxMembers'] = 30; |
|
| 68 | + } |
|
| 69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
| 70 | + $modSettings['defaultMaxListItems'] = 15; |
|
| 71 | + } |
|
| 64 | 72 | |
| 65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
| 66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 76 | + } |
|
| 68 | 77 | |
| 69 | - if (!empty($cache_enable)) |
|
| 70 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 78 | + if (!empty($cache_enable)) { |
|
| 79 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 80 | + } |
|
| 71 | 81 | } |
| 72 | 82 | |
| 73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
| 87 | 97 | }; |
| 88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
| 89 | 99 | { |
| 90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
| 91 | - return $string; |
|
| 100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
| 101 | + return $string; |
|
| 102 | + } |
|
| 92 | 103 | |
| 93 | 104 | $i = 0; |
| 94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
| 100 | 111 | { |
| 101 | 112 | $new_string .= $string[$i]; |
| 102 | 113 | $i++; |
| 103 | - } |
|
| 104 | - elseif ($ord < 224) |
|
| 114 | + } elseif ($ord < 224) |
|
| 105 | 115 | { |
| 106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
| 107 | 117 | $i += 2; |
| 108 | - } |
|
| 109 | - elseif ($ord < 240) |
|
| 118 | + } elseif ($ord < 240) |
|
| 110 | 119 | { |
| 111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 112 | 121 | $i += 3; |
| 113 | - } |
|
| 114 | - elseif ($ord < 248) |
|
| 122 | + } elseif ($ord < 248) |
|
| 115 | 123 | { |
| 116 | 124 | // Magic happens. |
| 117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
| 155 | 163 | { |
| 156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 157 | 165 | return is_int($result) ? $result + $offset : false; |
| 158 | - } |
|
| 159 | - else |
|
| 166 | + } else |
|
| 160 | 167 | { |
| 161 | 168 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
| 165 | 172 | while ((int) $result === $result) |
| 166 | 173 | { |
| 167 | 174 | $offset += $result; |
| 168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 169 | - return $offset; |
|
| 175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 176 | + return $offset; |
|
| 177 | + } |
|
| 170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 171 | 179 | } |
| 172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
| 204 | 212 | $string = $ent_check($string); |
| 205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 206 | 214 | $string = $matches[0]; |
| 207 | - while (strlen($string) > $length) |
|
| 208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 215 | + while (strlen($string) > $length) { |
|
| 216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 217 | + } |
|
| 209 | 218 | return $string; |
| 210 | 219 | }, |
| 211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
| 215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 216 | 225 | { |
| 217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 229 | + } |
|
| 220 | 230 | return implode('', $words); |
| 221 | 231 | } : 'ucwords', |
| 222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
| 224 | 234 | ); |
| 225 | 235 | |
| 226 | 236 | // Setting the timezone is a requirement for some functions. |
| 227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 229 | - else |
|
| 237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 239 | + } else |
|
| 230 | 240 | { |
| 231 | 241 | // Get PHP's default timezone, if set |
| 232 | 242 | $ini_tz = ini_get('date.timezone'); |
| 233 | - if (!empty($ini_tz)) |
|
| 234 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 235 | - else |
|
| 236 | - $modSettings['default_timezone'] = ''; |
|
| 243 | + if (!empty($ini_tz)) { |
|
| 244 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 245 | + } else { |
|
| 246 | + $modSettings['default_timezone'] = ''; |
|
| 247 | + } |
|
| 237 | 248 | |
| 238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
| 251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 252 | 263 | { |
| 253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 258 | - else |
|
| 259 | - unset($modSettings['load_average']); |
|
| 265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 269 | + } else { |
|
| 270 | + unset($modSettings['load_average']); |
|
| 271 | + } |
|
| 260 | 272 | |
| 261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 275 | + } |
|
| 263 | 276 | } |
| 264 | 277 | |
| 265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 280 | + } |
|
| 267 | 281 | |
| 268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 269 | - display_loadavg_error(); |
|
| 282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 283 | + display_loadavg_error(); |
|
| 284 | + } |
|
| 270 | 285 | } |
| 271 | 286 | |
| 272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
| 287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 288 | 303 | { |
| 289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
| 290 | - foreach ($integration_settings as $hook => $function) |
|
| 291 | - add_integration_function($hook, $function, '', false); |
|
| 305 | + foreach ($integration_settings as $hook => $function) { |
|
| 306 | + add_integration_function($hook, $function, '', false); |
|
| 307 | + } |
|
| 292 | 308 | } |
| 293 | 309 | |
| 294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
| 298 | 314 | foreach ($pre_includes as $include) |
| 299 | 315 | { |
| 300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 301 | - if (file_exists($include)) |
|
| 302 | - require_once($include); |
|
| 317 | + if (file_exists($include)) { |
|
| 318 | + require_once($include); |
|
| 319 | + } |
|
| 303 | 320 | } |
| 304 | 321 | } |
| 305 | 322 | |
@@ -403,27 +420,28 @@ discard block |
||
| 403 | 420 | break; |
| 404 | 421 | } |
| 405 | 422 | } |
| 423 | + } else { |
|
| 424 | + $id_member = 0; |
|
| 406 | 425 | } |
| 407 | - else |
|
| 408 | - $id_member = 0; |
|
| 409 | 426 | |
| 410 | 427 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 411 | 428 | { |
| 412 | 429 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
| 413 | 430 | |
| 414 | - if (empty($cookie_data)) |
|
| 415 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 431 | + if (empty($cookie_data)) { |
|
| 432 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 433 | + } |
|
| 416 | 434 | |
| 417 | 435 | list ($id_member, $password) = $cookie_data; |
| 418 | 436 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
| 419 | - } |
|
| 420 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 437 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 421 | 438 | { |
| 422 | 439 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 423 | 440 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
| 424 | 441 | |
| 425 | - if (empty($cookie_data)) |
|
| 426 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 442 | + if (empty($cookie_data)) { |
|
| 443 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 444 | + } |
|
| 427 | 445 | |
| 428 | 446 | list ($id_member, $password, $login_span) = $cookie_data; |
| 429 | 447 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -448,24 +466,28 @@ discard block |
||
| 448 | 466 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 449 | 467 | $smcFunc['db_free_result']($request); |
| 450 | 468 | |
| 451 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
| 452 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 469 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
| 470 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 471 | + } |
|
| 453 | 472 | |
| 454 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 455 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 473 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 474 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 475 | + } |
|
| 456 | 476 | } |
| 457 | 477 | |
| 458 | 478 | // Did we find 'im? If not, junk it. |
| 459 | 479 | if (!empty($user_settings)) |
| 460 | 480 | { |
| 461 | 481 | // As much as the password should be right, we can assume the integration set things up. |
| 462 | - if (!empty($already_verified) && $already_verified === true) |
|
| 463 | - $check = true; |
|
| 482 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 483 | + $check = true; |
|
| 484 | + } |
|
| 464 | 485 | // SHA-512 hash should be 128 characters long. |
| 465 | - elseif (strlen($password) == 128) |
|
| 466 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 467 | - else |
|
| 468 | - $check = false; |
|
| 486 | + elseif (strlen($password) == 128) { |
|
| 487 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 488 | + } else { |
|
| 489 | + $check = false; |
|
| 490 | + } |
|
| 469 | 491 | |
| 470 | 492 | // Wrong password or not activated - either way, you're going nowhere. |
| 471 | 493 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
@@ -474,9 +496,9 @@ discard block |
||
| 474 | 496 | setLoginCookie(-3600, 0); |
| 475 | 497 | $user_settings = array(); |
| 476 | 498 | } |
| 499 | + } else { |
|
| 500 | + $id_member = 0; |
|
| 477 | 501 | } |
| 478 | - else |
|
| 479 | - $id_member = 0; |
|
| 480 | 502 | |
| 481 | 503 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 482 | 504 | if (!empty($id_member)) |
@@ -505,8 +527,9 @@ discard block |
||
| 505 | 527 | |
| 506 | 528 | list ($tfamember, $tfasecret) = $tfa_data; |
| 507 | 529 | |
| 508 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
| 509 | - $tfasecret = null; |
|
| 530 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
| 531 | + $tfasecret = null; |
|
| 532 | + } |
|
| 510 | 533 | } |
| 511 | 534 | |
| 512 | 535 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -526,10 +549,12 @@ discard block |
||
| 526 | 549 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 527 | 550 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 528 | 551 | { |
| 529 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 552 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 553 | + //only do this if we are just forcing SOME membergroups |
|
| 530 | 554 | { |
| 531 | 555 | //Build an array of ALL user membergroups. |
| 532 | 556 | $full_groups = array($user_settings['id_group']); |
| 557 | + } |
|
| 533 | 558 | if (!empty($user_settings['additional_groups'])) |
| 534 | 559 | { |
| 535 | 560 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -549,17 +574,18 @@ discard block |
||
| 549 | 574 | ); |
| 550 | 575 | $row = $smcFunc['db_fetch_assoc']($request); |
| 551 | 576 | $smcFunc['db_free_result']($request); |
| 577 | + } else { |
|
| 578 | + $row['total'] = 1; |
|
| 552 | 579 | } |
| 553 | - else |
|
| 554 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 580 | + //simplifies logics in the next "if" |
|
| 555 | 581 | |
| 556 | 582 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 557 | 583 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 558 | 584 | |
| 559 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 560 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 561 | - } |
|
| 562 | - else if (!empty($user_settings) && empty($id_member)) |
|
| 585 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 586 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 587 | + } |
|
| 588 | + } else if (!empty($user_settings) && empty($id_member)) |
|
| 563 | 589 | { |
| 564 | 590 | $user_settings = array(); |
| 565 | 591 | } |
@@ -598,33 +624,37 @@ discard block |
||
| 598 | 624 | 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'])); |
| 599 | 625 | $user_settings['last_login'] = time(); |
| 600 | 626 | |
| 601 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 602 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 627 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 628 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 629 | + } |
|
| 603 | 630 | |
| 604 | - if (!empty($modSettings['cache_enable'])) |
|
| 605 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 631 | + if (!empty($modSettings['cache_enable'])) { |
|
| 632 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 633 | + } |
|
| 606 | 634 | } |
| 635 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 636 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 607 | 637 | } |
| 608 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 609 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 610 | 638 | |
| 611 | 639 | $username = $user_settings['member_name']; |
| 612 | 640 | |
| 613 | - if (empty($user_settings['additional_groups'])) |
|
| 614 | - $user_info = array( |
|
| 641 | + if (empty($user_settings['additional_groups'])) { |
|
| 642 | + $user_info = array( |
|
| 615 | 643 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 616 | 644 | ); |
| 617 | - else |
|
| 618 | - $user_info = array( |
|
| 645 | + } else { |
|
| 646 | + $user_info = array( |
|
| 619 | 647 | 'groups' => array_merge( |
| 620 | 648 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 621 | 649 | explode(',', $user_settings['additional_groups']) |
| 622 | 650 | ) |
| 623 | 651 | ); |
| 652 | + } |
|
| 624 | 653 | |
| 625 | 654 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 626 | - foreach ($user_info['groups'] as $k => $v) |
|
| 627 | - $user_info['groups'][$k] = (int) $v; |
|
| 655 | + foreach ($user_info['groups'] as $k => $v) { |
|
| 656 | + $user_info['groups'][$k] = (int) $v; |
|
| 657 | + } |
|
| 628 | 658 | |
| 629 | 659 | // This is a logged in user, so definitely not a spider. |
| 630 | 660 | $user_info['possibly_robot'] = false; |
@@ -638,8 +668,7 @@ discard block |
||
| 638 | 668 | $time_system = new DateTime('now', $tz_system); |
| 639 | 669 | $time_user = new DateTime('now', $tz_user); |
| 640 | 670 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 641 | - } |
|
| 642 | - else |
|
| 671 | + } else |
|
| 643 | 672 | { |
| 644 | 673 | // !!! Compatibility. |
| 645 | 674 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -653,8 +682,9 @@ discard block |
||
| 653 | 682 | $user_info = array('groups' => array(-1)); |
| 654 | 683 | $user_settings = array(); |
| 655 | 684 | |
| 656 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 657 | - $_COOKIE[$cookiename] = ''; |
|
| 685 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 686 | + $_COOKIE[$cookiename] = ''; |
|
| 687 | + } |
|
| 658 | 688 | |
| 659 | 689 | // Expire the 2FA cookie |
| 660 | 690 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -671,19 +701,20 @@ discard block |
||
| 671 | 701 | } |
| 672 | 702 | |
| 673 | 703 | // Create a login token if it doesn't exist yet. |
| 674 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 675 | - createToken('login'); |
|
| 676 | - else |
|
| 677 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 704 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 705 | + createToken('login'); |
|
| 706 | + } else { |
|
| 707 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 708 | + } |
|
| 678 | 709 | |
| 679 | 710 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 680 | 711 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 681 | 712 | { |
| 682 | 713 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 683 | 714 | $user_info['possibly_robot'] = SpiderCheck(); |
| 715 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 716 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 684 | 717 | } |
| 685 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 686 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 687 | 718 | // If we haven't turned on proper spider hunts then have a guess! |
| 688 | 719 | else |
| 689 | 720 | { |
@@ -731,8 +762,9 @@ discard block |
||
| 731 | 762 | $user_info['groups'] = array_unique($user_info['groups']); |
| 732 | 763 | |
| 733 | 764 | // 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. |
| 734 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 735 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 765 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 766 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 767 | + } |
|
| 736 | 768 | |
| 737 | 769 | // Allow the user to change their language. |
| 738 | 770 | if (!empty($modSettings['userLanguage'])) |
@@ -745,13 +777,14 @@ discard block |
||
| 745 | 777 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 746 | 778 | |
| 747 | 779 | // Make it permanent for members. |
| 748 | - if (!empty($user_info['id'])) |
|
| 749 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 750 | - else |
|
| 751 | - $_SESSION['language'] = $user_info['language']; |
|
| 780 | + if (!empty($user_info['id'])) { |
|
| 781 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 782 | + } else { |
|
| 783 | + $_SESSION['language'] = $user_info['language']; |
|
| 784 | + } |
|
| 785 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 786 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 752 | 787 | } |
| 753 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 754 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 755 | 788 | } |
| 756 | 789 | |
| 757 | 790 | $temp = build_query_board($user_info['id']); |
@@ -814,9 +847,9 @@ discard block |
||
| 814 | 847 | } |
| 815 | 848 | |
| 816 | 849 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 817 | - if (!empty($topic)) |
|
| 818 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 819 | - else |
|
| 850 | + if (!empty($topic)) { |
|
| 851 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 852 | + } else |
|
| 820 | 853 | { |
| 821 | 854 | loadPermissions(); |
| 822 | 855 | loadTheme(); |
@@ -834,10 +867,11 @@ discard block |
||
| 834 | 867 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 835 | 868 | { |
| 836 | 869 | // @todo SLOW? |
| 837 | - if (!empty($topic)) |
|
| 838 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 839 | - else |
|
| 840 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 870 | + if (!empty($topic)) { |
|
| 871 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 872 | + } else { |
|
| 873 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 874 | + } |
|
| 841 | 875 | |
| 842 | 876 | if (!empty($temp)) |
| 843 | 877 | { |
@@ -875,8 +909,9 @@ discard block |
||
| 875 | 909 | $row = $smcFunc['db_fetch_assoc']($request); |
| 876 | 910 | |
| 877 | 911 | // Set the current board. |
| 878 | - if (!empty($row['id_board'])) |
|
| 879 | - $board = $row['id_board']; |
|
| 912 | + if (!empty($row['id_board'])) { |
|
| 913 | + $board = $row['id_board']; |
|
| 914 | + } |
|
| 880 | 915 | |
| 881 | 916 | // Basic operating information. (globals... :/) |
| 882 | 917 | $board_info = array( |
@@ -912,21 +947,23 @@ discard block |
||
| 912 | 947 | |
| 913 | 948 | do |
| 914 | 949 | { |
| 915 | - if (!empty($row['id_moderator'])) |
|
| 916 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 950 | + if (!empty($row['id_moderator'])) { |
|
| 951 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 917 | 952 | 'id' => $row['id_moderator'], |
| 918 | 953 | 'name' => $row['real_name'], |
| 919 | 954 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 920 | 955 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 921 | 956 | ); |
| 957 | + } |
|
| 922 | 958 | |
| 923 | - if (!empty($row['id_moderator_group'])) |
|
| 924 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 959 | + if (!empty($row['id_moderator_group'])) { |
|
| 960 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 925 | 961 | 'id' => $row['id_moderator_group'], |
| 926 | 962 | 'name' => $row['group_name'], |
| 927 | 963 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 928 | 964 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 929 | 965 | ); |
| 966 | + } |
|
| 930 | 967 | } |
| 931 | 968 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 932 | 969 | |
@@ -958,12 +995,12 @@ discard block |
||
| 958 | 995 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 959 | 996 | { |
| 960 | 997 | // @todo SLOW? |
| 961 | - if (!empty($topic)) |
|
| 962 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 998 | + if (!empty($topic)) { |
|
| 999 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1000 | + } |
|
| 963 | 1001 | cache_put_data('board-' . $board, $board_info, 120); |
| 964 | 1002 | } |
| 965 | - } |
|
| 966 | - else |
|
| 1003 | + } else |
|
| 967 | 1004 | { |
| 968 | 1005 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 969 | 1006 | $board_info = array( |
@@ -977,8 +1014,9 @@ discard block |
||
| 977 | 1014 | $smcFunc['db_free_result']($request); |
| 978 | 1015 | } |
| 979 | 1016 | |
| 980 | - if (!empty($topic)) |
|
| 981 | - $_GET['board'] = (int) $board; |
|
| 1017 | + if (!empty($topic)) { |
|
| 1018 | + $_GET['board'] = (int) $board; |
|
| 1019 | + } |
|
| 982 | 1020 | |
| 983 | 1021 | if (!empty($board)) |
| 984 | 1022 | { |
@@ -988,10 +1026,12 @@ discard block |
||
| 988 | 1026 | // Now check if the user is a moderator. |
| 989 | 1027 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 990 | 1028 | |
| 991 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 992 | - $board_info['error'] = 'access'; |
|
| 993 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 994 | - $board_info['error'] = 'access'; |
|
| 1029 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1030 | + $board_info['error'] = 'access'; |
|
| 1031 | + } |
|
| 1032 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1033 | + $board_info['error'] = 'access'; |
|
| 1034 | + } |
|
| 995 | 1035 | |
| 996 | 1036 | // Build up the linktree. |
| 997 | 1037 | $context['linktree'] = array_merge( |
@@ -1014,8 +1054,9 @@ discard block |
||
| 1014 | 1054 | $context['current_board'] = $board; |
| 1015 | 1055 | |
| 1016 | 1056 | // No posting in redirection boards! |
| 1017 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1018 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1057 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1058 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1059 | + } |
|
| 1019 | 1060 | |
| 1020 | 1061 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1021 | 1062 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1041,24 +1082,23 @@ discard block |
||
| 1041 | 1082 | ob_end_clean(); |
| 1042 | 1083 | header('HTTP/1.1 403 Forbidden'); |
| 1043 | 1084 | die; |
| 1044 | - } |
|
| 1045 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1085 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1046 | 1086 | { |
| 1047 | 1087 | // Slightly different error message here... |
| 1048 | 1088 | fatal_lang_error('cannot_post_redirect', false); |
| 1049 | - } |
|
| 1050 | - elseif ($user_info['is_guest']) |
|
| 1089 | + } elseif ($user_info['is_guest']) |
|
| 1051 | 1090 | { |
| 1052 | 1091 | loadLanguage('Errors'); |
| 1053 | 1092 | is_not_guest($txt['topic_gone']); |
| 1093 | + } else { |
|
| 1094 | + fatal_lang_error('topic_gone', false); |
|
| 1054 | 1095 | } |
| 1055 | - else |
|
| 1056 | - fatal_lang_error('topic_gone', false); |
|
| 1057 | 1096 | } |
| 1058 | 1097 | |
| 1059 | - if ($user_info['is_mod']) |
|
| 1060 | - $user_info['groups'][] = 3; |
|
| 1061 | -} |
|
| 1098 | + if ($user_info['is_mod']) { |
|
| 1099 | + $user_info['groups'][] = 3; |
|
| 1100 | + } |
|
| 1101 | + } |
|
| 1062 | 1102 | |
| 1063 | 1103 | /** |
| 1064 | 1104 | * Load this user's permissions. |
@@ -1079,8 +1119,9 @@ discard block |
||
| 1079 | 1119 | asort($cache_groups); |
| 1080 | 1120 | $cache_groups = implode(',', $cache_groups); |
| 1081 | 1121 | // If it's a spider then cache it different. |
| 1082 | - if ($user_info['possibly_robot']) |
|
| 1083 | - $cache_groups .= '-spider'; |
|
| 1122 | + if ($user_info['possibly_robot']) { |
|
| 1123 | + $cache_groups .= '-spider'; |
|
| 1124 | + } |
|
| 1084 | 1125 | |
| 1085 | 1126 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1086 | 1127 | { |
@@ -1088,9 +1129,9 @@ discard block |
||
| 1088 | 1129 | banPermissions(); |
| 1089 | 1130 | |
| 1090 | 1131 | return; |
| 1132 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1133 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1091 | 1134 | } |
| 1092 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1093 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1094 | 1135 | } |
| 1095 | 1136 | |
| 1096 | 1137 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1112,23 +1153,26 @@ discard block |
||
| 1112 | 1153 | $removals = array(); |
| 1113 | 1154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1114 | 1155 | { |
| 1115 | - if (empty($row['add_deny'])) |
|
| 1116 | - $removals[] = $row['permission']; |
|
| 1117 | - else |
|
| 1118 | - $user_info['permissions'][] = $row['permission']; |
|
| 1156 | + if (empty($row['add_deny'])) { |
|
| 1157 | + $removals[] = $row['permission']; |
|
| 1158 | + } else { |
|
| 1159 | + $user_info['permissions'][] = $row['permission']; |
|
| 1160 | + } |
|
| 1119 | 1161 | } |
| 1120 | 1162 | $smcFunc['db_free_result']($request); |
| 1121 | 1163 | |
| 1122 | - if (isset($cache_groups)) |
|
| 1123 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1164 | + if (isset($cache_groups)) { |
|
| 1165 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1166 | + } |
|
| 1124 | 1167 | } |
| 1125 | 1168 | |
| 1126 | 1169 | // Get the board permissions. |
| 1127 | 1170 | if (!empty($board)) |
| 1128 | 1171 | { |
| 1129 | 1172 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1130 | - if (!isset($board_info['profile'])) |
|
| 1131 | - fatal_lang_error('no_board'); |
|
| 1173 | + if (!isset($board_info['profile'])) { |
|
| 1174 | + fatal_lang_error('no_board'); |
|
| 1175 | + } |
|
| 1132 | 1176 | |
| 1133 | 1177 | $request = $smcFunc['db_query']('', ' |
| 1134 | 1178 | SELECT permission, add_deny |
@@ -1144,20 +1188,23 @@ discard block |
||
| 1144 | 1188 | ); |
| 1145 | 1189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1146 | 1190 | { |
| 1147 | - if (empty($row['add_deny'])) |
|
| 1148 | - $removals[] = $row['permission']; |
|
| 1149 | - else |
|
| 1150 | - $user_info['permissions'][] = $row['permission']; |
|
| 1191 | + if (empty($row['add_deny'])) { |
|
| 1192 | + $removals[] = $row['permission']; |
|
| 1193 | + } else { |
|
| 1194 | + $user_info['permissions'][] = $row['permission']; |
|
| 1195 | + } |
|
| 1151 | 1196 | } |
| 1152 | 1197 | $smcFunc['db_free_result']($request); |
| 1153 | 1198 | } |
| 1154 | 1199 | |
| 1155 | 1200 | // Remove all the permissions they shouldn't have ;). |
| 1156 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1157 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1201 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1202 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1203 | + } |
|
| 1158 | 1204 | |
| 1159 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1160 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1205 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1206 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1207 | + } |
|
| 1161 | 1208 | |
| 1162 | 1209 | // Banned? Watch, don't touch.. |
| 1163 | 1210 | banPermissions(); |
@@ -1169,17 +1216,18 @@ discard block |
||
| 1169 | 1216 | { |
| 1170 | 1217 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1171 | 1218 | rebuildModCache(); |
| 1219 | + } else { |
|
| 1220 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1172 | 1221 | } |
| 1173 | - else |
|
| 1174 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1175 | 1222 | |
| 1176 | 1223 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1177 | 1224 | // For example this drastically simplifies certain changes to the profile area. |
| 1178 | 1225 | $user_info['permissions'][] = 'is_not_guest'; |
| 1179 | 1226 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1180 | 1227 | $user_info['permissions'][] = 'profile_view_own'; |
| 1181 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1182 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1228 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1229 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1230 | + } |
|
| 1183 | 1231 | } |
| 1184 | 1232 | } |
| 1185 | 1233 | |
@@ -1197,8 +1245,9 @@ discard block |
||
| 1197 | 1245 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1198 | 1246 | |
| 1199 | 1247 | // Can't just look for no users :P. |
| 1200 | - if (empty($users)) |
|
| 1201 | - return array(); |
|
| 1248 | + if (empty($users)) { |
|
| 1249 | + return array(); |
|
| 1250 | + } |
|
| 1202 | 1251 | |
| 1203 | 1252 | // Pass the set value |
| 1204 | 1253 | $context['loadMemberContext_set'] = $set; |
@@ -1213,8 +1262,9 @@ discard block |
||
| 1213 | 1262 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1214 | 1263 | { |
| 1215 | 1264 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1216 | - if ($data == null) |
|
| 1217 | - continue; |
|
| 1265 | + if ($data == null) { |
|
| 1266 | + continue; |
|
| 1267 | + } |
|
| 1218 | 1268 | |
| 1219 | 1269 | $loaded_ids[] = $data['id_member']; |
| 1220 | 1270 | $user_profile[$data['id_member']] = $data; |
@@ -1281,16 +1331,19 @@ discard block |
||
| 1281 | 1331 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
| 1282 | 1332 | |
| 1283 | 1333 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1284 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
| 1285 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1334 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
| 1335 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1336 | + } |
|
| 1286 | 1337 | |
| 1287 | 1338 | // Keep track of the member's normal member group |
| 1288 | 1339 | $row['primary_group'] = $row['member_group']; |
| 1289 | 1340 | |
| 1290 | - if (isset($row['member_ip'])) |
|
| 1291 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1292 | - if (isset($row['member_ip2'])) |
|
| 1293 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1341 | + if (isset($row['member_ip'])) { |
|
| 1342 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1343 | + } |
|
| 1344 | + if (isset($row['member_ip2'])) { |
|
| 1345 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1346 | + } |
|
| 1294 | 1347 | $new_loaded_ids[] = $row['id_member']; |
| 1295 | 1348 | $loaded_ids[] = $row['id_member']; |
| 1296 | 1349 | $row['options'] = array(); |
@@ -1309,8 +1362,9 @@ discard block |
||
| 1309 | 1362 | 'loaded_ids' => $new_loaded_ids, |
| 1310 | 1363 | ) |
| 1311 | 1364 | ); |
| 1312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1313 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1365 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1366 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1367 | + } |
|
| 1314 | 1368 | $smcFunc['db_free_result']($request); |
| 1315 | 1369 | } |
| 1316 | 1370 | |
@@ -1321,10 +1375,11 @@ discard block |
||
| 1321 | 1375 | { |
| 1322 | 1376 | foreach ($loaded_ids as $a_member) |
| 1323 | 1377 | { |
| 1324 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1325 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1326 | - else |
|
| 1327 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1378 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1379 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1380 | + } else { |
|
| 1381 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1382 | + } |
|
| 1328 | 1383 | |
| 1329 | 1384 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1330 | 1385 | |
@@ -1337,8 +1392,9 @@ discard block |
||
| 1337 | 1392 | |
| 1338 | 1393 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1339 | 1394 | { |
| 1340 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1341 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1395 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1396 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1397 | + } |
|
| 1342 | 1398 | } |
| 1343 | 1399 | |
| 1344 | 1400 | // Are we loading any moderators? If so, fix their group data... |
@@ -1364,14 +1420,17 @@ discard block |
||
| 1364 | 1420 | foreach ($temp_mods as $id) |
| 1365 | 1421 | { |
| 1366 | 1422 | // By popular demand, don't show admins or global moderators as moderators. |
| 1367 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1368 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1423 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1424 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1425 | + } |
|
| 1369 | 1426 | |
| 1370 | 1427 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1371 | - if (!empty($row['icons'])) |
|
| 1372 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1373 | - if (!empty($row['member_group_color'])) |
|
| 1374 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1428 | + if (!empty($row['icons'])) { |
|
| 1429 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1430 | + } |
|
| 1431 | + if (!empty($row['member_group_color'])) { |
|
| 1432 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1433 | + } |
|
| 1375 | 1434 | } |
| 1376 | 1435 | } |
| 1377 | 1436 | |
@@ -1393,12 +1452,14 @@ discard block |
||
| 1393 | 1452 | static $loadedLanguages = array(); |
| 1394 | 1453 | |
| 1395 | 1454 | // If this person's data is already loaded, skip it. |
| 1396 | - if (isset($dataLoaded[$user])) |
|
| 1397 | - return true; |
|
| 1455 | + if (isset($dataLoaded[$user])) { |
|
| 1456 | + return true; |
|
| 1457 | + } |
|
| 1398 | 1458 | |
| 1399 | 1459 | // We can't load guests or members not loaded by loadMemberData()! |
| 1400 | - if ($user == 0) |
|
| 1401 | - return false; |
|
| 1460 | + if ($user == 0) { |
|
| 1461 | + return false; |
|
| 1462 | + } |
|
| 1402 | 1463 | if (!isset($user_profile[$user])) |
| 1403 | 1464 | { |
| 1404 | 1465 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1424,12 +1485,16 @@ discard block |
||
| 1424 | 1485 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1425 | 1486 | |
| 1426 | 1487 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1427 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1488 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1489 | + //icon is set and exists |
|
| 1428 | 1490 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1429 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1491 | + } elseif (isset($profile['icons'][1])) { |
|
| 1492 | + //icon is set and doesn't exist, fallback to default |
|
| 1430 | 1493 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1431 | - else //not set, bye bye |
|
| 1494 | + } else { |
|
| 1495 | + //not set, bye bye |
|
| 1432 | 1496 | $group_icon_url = ''; |
| 1497 | + } |
|
| 1433 | 1498 | |
| 1434 | 1499 | // These minimal values are always loaded |
| 1435 | 1500 | $memberContext[$user] = array( |
@@ -1448,8 +1513,9 @@ discard block |
||
| 1448 | 1513 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1449 | 1514 | { |
| 1450 | 1515 | // Go the extra mile and load the user's native language name. |
| 1451 | - if (empty($loadedLanguages)) |
|
| 1452 | - $loadedLanguages = getLanguages(); |
|
| 1516 | + if (empty($loadedLanguages)) { |
|
| 1517 | + $loadedLanguages = getLanguages(); |
|
| 1518 | + } |
|
| 1453 | 1519 | |
| 1454 | 1520 | $memberContext[$user] += array( |
| 1455 | 1521 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1504,31 +1570,33 @@ discard block |
||
| 1504 | 1570 | { |
| 1505 | 1571 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1506 | 1572 | { |
| 1507 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1508 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1509 | - else |
|
| 1510 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1511 | - } |
|
| 1512 | - else |
|
| 1573 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1574 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1575 | + } else { |
|
| 1576 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1577 | + } |
|
| 1578 | + } else |
|
| 1513 | 1579 | { |
| 1514 | 1580 | // So it's stored in the member table? |
| 1515 | 1581 | if (!empty($profile['avatar'])) |
| 1516 | 1582 | { |
| 1517 | 1583 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1584 | + } elseif (!empty($profile['filename'])) { |
|
| 1585 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1518 | 1586 | } |
| 1519 | - elseif (!empty($profile['filename'])) |
|
| 1520 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1521 | 1587 | // Right... no avatar...use the default one |
| 1522 | - else |
|
| 1523 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1588 | + else { |
|
| 1589 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1590 | + } |
|
| 1524 | 1591 | } |
| 1525 | - if (!empty($image)) |
|
| 1526 | - $memberContext[$user]['avatar'] = array( |
|
| 1592 | + if (!empty($image)) { |
|
| 1593 | + $memberContext[$user]['avatar'] = array( |
|
| 1527 | 1594 | 'name' => $profile['avatar'], |
| 1528 | 1595 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1529 | 1596 | 'href' => $image, |
| 1530 | 1597 | 'url' => $image, |
| 1531 | 1598 | ); |
| 1599 | + } |
|
| 1532 | 1600 | } |
| 1533 | 1601 | |
| 1534 | 1602 | // Are we also loading the members custom fields into context? |
@@ -1536,35 +1604,41 @@ discard block |
||
| 1536 | 1604 | { |
| 1537 | 1605 | $memberContext[$user]['custom_fields'] = array(); |
| 1538 | 1606 | |
| 1539 | - if (!isset($context['display_fields'])) |
|
| 1540 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1607 | + if (!isset($context['display_fields'])) { |
|
| 1608 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1609 | + } |
|
| 1541 | 1610 | |
| 1542 | 1611 | foreach ($context['display_fields'] as $custom) |
| 1543 | 1612 | { |
| 1544 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1545 | - continue; |
|
| 1613 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1614 | + continue; |
|
| 1615 | + } |
|
| 1546 | 1616 | |
| 1547 | 1617 | $value = $profile['options'][$custom['col_name']]; |
| 1548 | 1618 | |
| 1549 | 1619 | // Don't show the "disabled" option for the "gender" field. |
| 1550 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 1551 | - continue; |
|
| 1620 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 1621 | + continue; |
|
| 1622 | + } |
|
| 1552 | 1623 | |
| 1553 | 1624 | // BBC? |
| 1554 | - if ($custom['bbc']) |
|
| 1555 | - $value = parse_bbc($value); |
|
| 1625 | + if ($custom['bbc']) { |
|
| 1626 | + $value = parse_bbc($value); |
|
| 1627 | + } |
|
| 1556 | 1628 | // ... or checkbox? |
| 1557 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1558 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1629 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1630 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1631 | + } |
|
| 1559 | 1632 | |
| 1560 | 1633 | // Enclosing the user input within some other text? |
| 1561 | - if (!empty($custom['enclose'])) |
|
| 1562 | - $value = strtr($custom['enclose'], array( |
|
| 1634 | + if (!empty($custom['enclose'])) { |
|
| 1635 | + $value = strtr($custom['enclose'], array( |
|
| 1563 | 1636 | '{SCRIPTURL}' => $scripturl, |
| 1564 | 1637 | '{IMAGES_URL}' => $settings['images_url'], |
| 1565 | 1638 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1566 | 1639 | '{INPUT}' => $value, |
| 1567 | 1640 | )); |
| 1641 | + } |
|
| 1568 | 1642 | |
| 1569 | 1643 | $memberContext[$user]['custom_fields'][] = array( |
| 1570 | 1644 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1591,8 +1665,9 @@ discard block |
||
| 1591 | 1665 | global $smcFunc, $txt, $scripturl, $settings; |
| 1592 | 1666 | |
| 1593 | 1667 | // Do not waste my time... |
| 1594 | - if (empty($users) || empty($params)) |
|
| 1595 | - return false; |
|
| 1668 | + if (empty($users) || empty($params)) { |
|
| 1669 | + return false; |
|
| 1670 | + } |
|
| 1596 | 1671 | |
| 1597 | 1672 | // Make sure it's an array. |
| 1598 | 1673 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1616,31 +1691,36 @@ discard block |
||
| 1616 | 1691 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1617 | 1692 | { |
| 1618 | 1693 | // BBC? |
| 1619 | - if (!empty($row['bbc'])) |
|
| 1620 | - $row['value'] = parse_bbc($row['value']); |
|
| 1694 | + if (!empty($row['bbc'])) { |
|
| 1695 | + $row['value'] = parse_bbc($row['value']); |
|
| 1696 | + } |
|
| 1621 | 1697 | |
| 1622 | 1698 | // ... or checkbox? |
| 1623 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1624 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1699 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1700 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1701 | + } |
|
| 1625 | 1702 | |
| 1626 | 1703 | // Enclosing the user input within some other text? |
| 1627 | - if (!empty($row['enclose'])) |
|
| 1628 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1704 | + if (!empty($row['enclose'])) { |
|
| 1705 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1629 | 1706 | '{SCRIPTURL}' => $scripturl, |
| 1630 | 1707 | '{IMAGES_URL}' => $settings['images_url'], |
| 1631 | 1708 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1632 | 1709 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1633 | 1710 | )); |
| 1711 | + } |
|
| 1634 | 1712 | |
| 1635 | 1713 | // Send a simple array if there is just 1 param |
| 1636 | - if (count($params) == 1) |
|
| 1637 | - $return[$row['id_member']] = $row; |
|
| 1714 | + if (count($params) == 1) { |
|
| 1715 | + $return[$row['id_member']] = $row; |
|
| 1716 | + } |
|
| 1638 | 1717 | |
| 1639 | 1718 | // More than 1? knock yourself out... |
| 1640 | 1719 | else |
| 1641 | 1720 | { |
| 1642 | - if (!isset($return[$row['id_member']])) |
|
| 1643 | - $return[$row['id_member']] = array(); |
|
| 1721 | + if (!isset($return[$row['id_member']])) { |
|
| 1722 | + $return[$row['id_member']] = array(); |
|
| 1723 | + } |
|
| 1644 | 1724 | |
| 1645 | 1725 | $return[$row['id_member']][$row['variable']] = $row; |
| 1646 | 1726 | } |
@@ -1674,8 +1754,9 @@ discard block |
||
| 1674 | 1754 | global $context; |
| 1675 | 1755 | |
| 1676 | 1756 | // Don't know any browser! |
| 1677 | - if (empty($context['browser'])) |
|
| 1678 | - detectBrowser(); |
|
| 1757 | + if (empty($context['browser'])) { |
|
| 1758 | + detectBrowser(); |
|
| 1759 | + } |
|
| 1679 | 1760 | |
| 1680 | 1761 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1681 | 1762 | } |
@@ -1693,8 +1774,9 @@ discard block |
||
| 1693 | 1774 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1694 | 1775 | |
| 1695 | 1776 | // The theme was specified by parameter. |
| 1696 | - if (!empty($id_theme)) |
|
| 1697 | - $id_theme = (int) $id_theme; |
|
| 1777 | + if (!empty($id_theme)) { |
|
| 1778 | + $id_theme = (int) $id_theme; |
|
| 1779 | + } |
|
| 1698 | 1780 | // The theme was specified by REQUEST. |
| 1699 | 1781 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1700 | 1782 | { |
@@ -1702,54 +1784,61 @@ discard block |
||
| 1702 | 1784 | $_SESSION['id_theme'] = $id_theme; |
| 1703 | 1785 | } |
| 1704 | 1786 | // The theme was specified by REQUEST... previously. |
| 1705 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1706 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1787 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1788 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1789 | + } |
|
| 1707 | 1790 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1708 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1709 | - $id_theme = $user_info['theme']; |
|
| 1791 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1792 | + $id_theme = $user_info['theme']; |
|
| 1793 | + } |
|
| 1710 | 1794 | // The theme was specified by the board. |
| 1711 | - elseif (!empty($board_info['theme'])) |
|
| 1712 | - $id_theme = $board_info['theme']; |
|
| 1795 | + elseif (!empty($board_info['theme'])) { |
|
| 1796 | + $id_theme = $board_info['theme']; |
|
| 1797 | + } |
|
| 1713 | 1798 | // The theme is the forum's default. |
| 1714 | - else |
|
| 1715 | - $id_theme = $modSettings['theme_guests']; |
|
| 1799 | + else { |
|
| 1800 | + $id_theme = $modSettings['theme_guests']; |
|
| 1801 | + } |
|
| 1716 | 1802 | |
| 1717 | 1803 | // We already load the basic stuff? |
| 1718 | 1804 | if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
| 1719 | 1805 | { |
| 1720 | 1806 | // Verify the id_theme... no foul play. |
| 1721 | 1807 | // Always allow the board specific theme, if they are overriding. |
| 1722 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1723 | - $id_theme = $board_info['theme']; |
|
| 1808 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1809 | + $id_theme = $board_info['theme']; |
|
| 1810 | + } |
|
| 1724 | 1811 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1725 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1726 | - $id_theme = (int) $id_theme; |
|
| 1727 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1812 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1813 | + $id_theme = (int) $id_theme; |
|
| 1814 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1728 | 1815 | { |
| 1729 | 1816 | $themes = explode(',', $modSettings['enableThemes']); |
| 1730 | - if (!in_array($id_theme, $themes)) |
|
| 1731 | - $id_theme = $modSettings['theme_guests']; |
|
| 1732 | - else |
|
| 1733 | - $id_theme = (int) $id_theme; |
|
| 1817 | + if (!in_array($id_theme, $themes)) { |
|
| 1818 | + $id_theme = $modSettings['theme_guests']; |
|
| 1819 | + } else { |
|
| 1820 | + $id_theme = (int) $id_theme; |
|
| 1821 | + } |
|
| 1822 | + } else { |
|
| 1823 | + $id_theme = (int) $id_theme; |
|
| 1734 | 1824 | } |
| 1735 | - else |
|
| 1736 | - $id_theme = (int) $id_theme; |
|
| 1737 | 1825 | |
| 1738 | 1826 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1739 | 1827 | |
| 1740 | 1828 | // Disable image proxy if we don't have SSL enabled |
| 1741 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
| 1742 | - $image_proxy_enabled = false; |
|
| 1829 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
| 1830 | + $image_proxy_enabled = false; |
|
| 1831 | + } |
|
| 1743 | 1832 | |
| 1744 | 1833 | 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']) |
| 1745 | 1834 | { |
| 1746 | 1835 | $themeData = $temp; |
| 1747 | 1836 | $flag = true; |
| 1837 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1838 | + $themeData = $temp + array($member => array()); |
|
| 1839 | + } else { |
|
| 1840 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1748 | 1841 | } |
| 1749 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1750 | - $themeData = $temp + array($member => array()); |
|
| 1751 | - else |
|
| 1752 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1753 | 1842 | |
| 1754 | 1843 | if (empty($flag)) |
| 1755 | 1844 | { |
@@ -1768,31 +1857,37 @@ discard block |
||
| 1768 | 1857 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1769 | 1858 | { |
| 1770 | 1859 | // There are just things we shouldn't be able to change as members. |
| 1771 | - 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'))) |
|
| 1772 | - continue; |
|
| 1860 | + 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'))) { |
|
| 1861 | + continue; |
|
| 1862 | + } |
|
| 1773 | 1863 | |
| 1774 | 1864 | // If this is the theme_dir of the default theme, store it. |
| 1775 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1776 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1865 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1866 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1867 | + } |
|
| 1777 | 1868 | |
| 1778 | 1869 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1779 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1780 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1870 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1871 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1872 | + } |
|
| 1781 | 1873 | } |
| 1782 | 1874 | $smcFunc['db_free_result']($result); |
| 1783 | 1875 | |
| 1784 | - if (!empty($themeData[-1])) |
|
| 1785 | - foreach ($themeData[-1] as $k => $v) |
|
| 1876 | + if (!empty($themeData[-1])) { |
|
| 1877 | + foreach ($themeData[-1] as $k => $v) |
|
| 1786 | 1878 | { |
| 1787 | 1879 | if (!isset($themeData[$member][$k])) |
| 1788 | 1880 | $themeData[$member][$k] = $v; |
| 1881 | + } |
|
| 1789 | 1882 | } |
| 1790 | 1883 | |
| 1791 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1792 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1884 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1885 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1886 | + } |
|
| 1793 | 1887 | // Only if we didn't already load that part of the cache... |
| 1794 | - elseif (!isset($temp)) |
|
| 1795 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1888 | + elseif (!isset($temp)) { |
|
| 1889 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1890 | + } |
|
| 1796 | 1891 | } |
| 1797 | 1892 | |
| 1798 | 1893 | $settings = $themeData[0]; |
@@ -1809,22 +1904,26 @@ discard block |
||
| 1809 | 1904 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1810 | 1905 | |
| 1811 | 1906 | // Based on theme (if there is one). |
| 1812 | - if (!empty($settings['base_theme_dir'])) |
|
| 1813 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1907 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1908 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1909 | + } |
|
| 1814 | 1910 | |
| 1815 | 1911 | // Lastly the default theme. |
| 1816 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1817 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1912 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1913 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1914 | + } |
|
| 1818 | 1915 | } |
| 1819 | 1916 | |
| 1820 | 1917 | |
| 1821 | - if (!$initialize) |
|
| 1822 | - return; |
|
| 1918 | + if (!$initialize) { |
|
| 1919 | + return; |
|
| 1920 | + } |
|
| 1823 | 1921 | |
| 1824 | 1922 | // Check to see if we're forcing SSL |
| 1825 | 1923 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
| 1826 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
| 1827 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1924 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
| 1925 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1926 | + } |
|
| 1828 | 1927 | |
| 1829 | 1928 | // Check to see if they're accessing it from the wrong place. |
| 1830 | 1929 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1832,8 +1931,9 @@ discard block |
||
| 1832 | 1931 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
| 1833 | 1932 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1834 | 1933 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1835 | - if ($temp != '/') |
|
| 1836 | - $detected_url .= $temp; |
|
| 1934 | + if ($temp != '/') { |
|
| 1935 | + $detected_url .= $temp; |
|
| 1936 | + } |
|
| 1837 | 1937 | } |
| 1838 | 1938 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1839 | 1939 | { |
@@ -1845,8 +1945,9 @@ discard block |
||
| 1845 | 1945 | foreach ($aliases as $alias) |
| 1846 | 1946 | { |
| 1847 | 1947 | // Rip off all the boring parts, spaces, etc. |
| 1848 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1849 | - $do_fix = true; |
|
| 1948 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1949 | + $do_fix = true; |
|
| 1950 | + } |
|
| 1850 | 1951 | } |
| 1851 | 1952 | } |
| 1852 | 1953 | |
@@ -1854,20 +1955,22 @@ discard block |
||
| 1854 | 1955 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1855 | 1956 | { |
| 1856 | 1957 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1857 | - if (empty($_GET)) |
|
| 1858 | - redirectexit('wwwRedirect'); |
|
| 1859 | - else |
|
| 1958 | + if (empty($_GET)) { |
|
| 1959 | + redirectexit('wwwRedirect'); |
|
| 1960 | + } else |
|
| 1860 | 1961 | { |
| 1861 | 1962 | list ($k, $v) = each($_GET); |
| 1862 | 1963 | |
| 1863 | - if ($k != 'wwwRedirect') |
|
| 1864 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1964 | + if ($k != 'wwwRedirect') { |
|
| 1965 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1966 | + } |
|
| 1865 | 1967 | } |
| 1866 | 1968 | } |
| 1867 | 1969 | |
| 1868 | 1970 | // #3 is just a check for SSL... |
| 1869 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1870 | - $do_fix = true; |
|
| 1971 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1972 | + $do_fix = true; |
|
| 1973 | + } |
|
| 1871 | 1974 | |
| 1872 | 1975 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1873 | 1976 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1901,8 +2004,9 @@ discard block |
||
| 1901 | 2004 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1902 | 2005 | } |
| 1903 | 2006 | } |
| 1904 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1905 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2007 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2008 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2009 | + } |
|
| 1906 | 2010 | } |
| 1907 | 2011 | } |
| 1908 | 2012 | // Set up the contextual user array. |
@@ -1921,16 +2025,16 @@ discard block |
||
| 1921 | 2025 | 'email' => $user_info['email'], |
| 1922 | 2026 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1923 | 2027 | ); |
| 1924 | - if (!$context['user']['is_guest']) |
|
| 1925 | - $context['user']['name'] = $user_info['name']; |
|
| 1926 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1927 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2028 | + if (!$context['user']['is_guest']) { |
|
| 2029 | + $context['user']['name'] = $user_info['name']; |
|
| 2030 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2031 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2032 | + } |
|
| 1928 | 2033 | |
| 1929 | 2034 | // Determine the current smiley set. |
| 1930 | 2035 | $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']; |
| 1931 | 2036 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1932 | - } |
|
| 1933 | - else |
|
| 2037 | + } else |
|
| 1934 | 2038 | { |
| 1935 | 2039 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
| 1936 | 2040 | $context['user'] = array( |
@@ -1964,18 +2068,24 @@ discard block |
||
| 1964 | 2068 | } |
| 1965 | 2069 | |
| 1966 | 2070 | // Some basic information... |
| 1967 | - if (!isset($context['html_headers'])) |
|
| 1968 | - $context['html_headers'] = ''; |
|
| 1969 | - if (!isset($context['javascript_files'])) |
|
| 1970 | - $context['javascript_files'] = array(); |
|
| 1971 | - if (!isset($context['css_files'])) |
|
| 1972 | - $context['css_files'] = array(); |
|
| 1973 | - if (!isset($context['css_header'])) |
|
| 1974 | - $context['css_header'] = array(); |
|
| 1975 | - if (!isset($context['javascript_inline'])) |
|
| 1976 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1977 | - if (!isset($context['javascript_vars'])) |
|
| 1978 | - $context['javascript_vars'] = array(); |
|
| 2071 | + if (!isset($context['html_headers'])) { |
|
| 2072 | + $context['html_headers'] = ''; |
|
| 2073 | + } |
|
| 2074 | + if (!isset($context['javascript_files'])) { |
|
| 2075 | + $context['javascript_files'] = array(); |
|
| 2076 | + } |
|
| 2077 | + if (!isset($context['css_files'])) { |
|
| 2078 | + $context['css_files'] = array(); |
|
| 2079 | + } |
|
| 2080 | + if (!isset($context['css_header'])) { |
|
| 2081 | + $context['css_header'] = array(); |
|
| 2082 | + } |
|
| 2083 | + if (!isset($context['javascript_inline'])) { |
|
| 2084 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2085 | + } |
|
| 2086 | + if (!isset($context['javascript_vars'])) { |
|
| 2087 | + $context['javascript_vars'] = array(); |
|
| 2088 | + } |
|
| 1979 | 2089 | |
| 1980 | 2090 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
| 1981 | 2091 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1987,16 +2097,18 @@ discard block |
||
| 1987 | 2097 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 1988 | 2098 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 1989 | 2099 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 1990 | - if (isset($modSettings['load_average'])) |
|
| 1991 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2100 | + if (isset($modSettings['load_average'])) { |
|
| 2101 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2102 | + } |
|
| 1992 | 2103 | |
| 1993 | 2104 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 1994 | 2105 | detectBrowser(); |
| 1995 | 2106 | |
| 1996 | 2107 | // Set the top level linktree up. |
| 1997 | 2108 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
| 1998 | - if (empty($context['linktree'])) |
|
| 1999 | - $context['linktree'] = array(); |
|
| 2109 | + if (empty($context['linktree'])) { |
|
| 2110 | + $context['linktree'] = array(); |
|
| 2111 | + } |
|
| 2000 | 2112 | array_unshift($context['linktree'], array( |
| 2001 | 2113 | 'url' => $scripturl, |
| 2002 | 2114 | 'name' => $context['forum_name_html_safe'] |
@@ -2005,8 +2117,9 @@ discard block |
||
| 2005 | 2117 | // This allows sticking some HTML on the page output - useful for controls. |
| 2006 | 2118 | $context['insert_after_template'] = ''; |
| 2007 | 2119 | |
| 2008 | - if (!isset($txt)) |
|
| 2009 | - $txt = array(); |
|
| 2120 | + if (!isset($txt)) { |
|
| 2121 | + $txt = array(); |
|
| 2122 | + } |
|
| 2010 | 2123 | |
| 2011 | 2124 | $simpleActions = array( |
| 2012 | 2125 | 'findmember', |
@@ -2052,9 +2165,10 @@ discard block |
||
| 2052 | 2165 | |
| 2053 | 2166 | // See if theres any extra param to check. |
| 2054 | 2167 | $requiresXML = false; |
| 2055 | - foreach ($extraParams as $key => $extra) |
|
| 2056 | - if (isset($_REQUEST[$extra])) |
|
| 2168 | + foreach ($extraParams as $key => $extra) { |
|
| 2169 | + if (isset($_REQUEST[$extra])) |
|
| 2057 | 2170 | $requiresXML = true; |
| 2171 | + } |
|
| 2058 | 2172 | |
| 2059 | 2173 | // Output is fully XML, so no need for the index template. |
| 2060 | 2174 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2069,37 +2183,39 @@ discard block |
||
| 2069 | 2183 | { |
| 2070 | 2184 | loadLanguage('index+Modifications'); |
| 2071 | 2185 | $context['template_layers'] = array(); |
| 2072 | - } |
|
| 2073 | - |
|
| 2074 | - else |
|
| 2186 | + } else |
|
| 2075 | 2187 | { |
| 2076 | 2188 | // Custom templates to load, or just default? |
| 2077 | - if (isset($settings['theme_templates'])) |
|
| 2078 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2079 | - else |
|
| 2080 | - $templates = array('index'); |
|
| 2189 | + if (isset($settings['theme_templates'])) { |
|
| 2190 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2191 | + } else { |
|
| 2192 | + $templates = array('index'); |
|
| 2193 | + } |
|
| 2081 | 2194 | |
| 2082 | 2195 | // Load each template... |
| 2083 | - foreach ($templates as $template) |
|
| 2084 | - loadTemplate($template); |
|
| 2196 | + foreach ($templates as $template) { |
|
| 2197 | + loadTemplate($template); |
|
| 2198 | + } |
|
| 2085 | 2199 | |
| 2086 | 2200 | // ...and attempt to load their associated language files. |
| 2087 | 2201 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2088 | 2202 | loadLanguage($required_files, '', false); |
| 2089 | 2203 | |
| 2090 | 2204 | // Custom template layers? |
| 2091 | - if (isset($settings['theme_layers'])) |
|
| 2092 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2093 | - else |
|
| 2094 | - $context['template_layers'] = array('html', 'body'); |
|
| 2205 | + if (isset($settings['theme_layers'])) { |
|
| 2206 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2207 | + } else { |
|
| 2208 | + $context['template_layers'] = array('html', 'body'); |
|
| 2209 | + } |
|
| 2095 | 2210 | } |
| 2096 | 2211 | |
| 2097 | 2212 | // Initialize the theme. |
| 2098 | 2213 | loadSubTemplate('init', 'ignore'); |
| 2099 | 2214 | |
| 2100 | 2215 | // Allow overriding the board wide time/number formats. |
| 2101 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2102 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2216 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2217 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2218 | + } |
|
| 2103 | 2219 | |
| 2104 | 2220 | // Set the character set from the template. |
| 2105 | 2221 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2107,12 +2223,14 @@ discard block |
||
| 2107 | 2223 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2108 | 2224 | |
| 2109 | 2225 | // Guests may still need a name. |
| 2110 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2111 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2226 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2227 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2228 | + } |
|
| 2112 | 2229 | |
| 2113 | 2230 | // Any theme-related strings that need to be loaded? |
| 2114 | - if (!empty($settings['require_theme_strings'])) |
|
| 2115 | - loadLanguage('ThemeStrings', '', false); |
|
| 2231 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2232 | + loadLanguage('ThemeStrings', '', false); |
|
| 2233 | + } |
|
| 2116 | 2234 | |
| 2117 | 2235 | // Make a special URL for the language. |
| 2118 | 2236 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2123,8 +2241,9 @@ discard block |
||
| 2123 | 2241 | // Here is my luvly Responsive CSS |
| 2124 | 2242 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
| 2125 | 2243 | |
| 2126 | - if ($context['right_to_left']) |
|
| 2127 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2244 | + if ($context['right_to_left']) { |
|
| 2245 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2246 | + } |
|
| 2128 | 2247 | |
| 2129 | 2248 | // We allow theme variants, because we're cool. |
| 2130 | 2249 | $context['theme_variant'] = ''; |
@@ -2132,14 +2251,17 @@ discard block |
||
| 2132 | 2251 | if (!empty($settings['theme_variants'])) |
| 2133 | 2252 | { |
| 2134 | 2253 | // Overriding - for previews and that ilk. |
| 2135 | - if (!empty($_REQUEST['variant'])) |
|
| 2136 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2254 | + if (!empty($_REQUEST['variant'])) { |
|
| 2255 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2256 | + } |
|
| 2137 | 2257 | // User selection? |
| 2138 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2139 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2258 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2259 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2260 | + } |
|
| 2140 | 2261 | // If not a user variant, select the default. |
| 2141 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2142 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2262 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2263 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2264 | + } |
|
| 2143 | 2265 | |
| 2144 | 2266 | // Do this to keep things easier in the templates. |
| 2145 | 2267 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2148,20 +2270,23 @@ discard block |
||
| 2148 | 2270 | if (!empty($context['theme_variant'])) |
| 2149 | 2271 | { |
| 2150 | 2272 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
| 2151 | - if ($context['right_to_left']) |
|
| 2152 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2273 | + if ($context['right_to_left']) { |
|
| 2274 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2275 | + } |
|
| 2153 | 2276 | } |
| 2154 | 2277 | } |
| 2155 | 2278 | |
| 2156 | 2279 | // Let's be compatible with old themes! |
| 2157 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2158 | - $context['template_layers'] = array('main'); |
|
| 2280 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2281 | + $context['template_layers'] = array('main'); |
|
| 2282 | + } |
|
| 2159 | 2283 | |
| 2160 | 2284 | $context['tabindex'] = 1; |
| 2161 | 2285 | |
| 2162 | 2286 | // Compatibility. |
| 2163 | - if (!isset($settings['theme_version'])) |
|
| 2164 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2287 | + if (!isset($settings['theme_version'])) { |
|
| 2288 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2289 | + } |
|
| 2165 | 2290 | |
| 2166 | 2291 | // Default JS variables for use in every theme |
| 2167 | 2292 | $context['javascript_vars'] = array( |
@@ -2180,18 +2305,18 @@ discard block |
||
| 2180 | 2305 | ); |
| 2181 | 2306 | |
| 2182 | 2307 | // Add the JQuery library to the list of files to load. |
| 2183 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2184 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2185 | - |
|
| 2186 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2187 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2188 | - |
|
| 2189 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2190 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2308 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2309 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2310 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2311 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2312 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2313 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2314 | + } |
|
| 2191 | 2315 | |
| 2192 | 2316 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2193 | - else |
|
| 2194 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2317 | + else { |
|
| 2318 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2319 | + } |
|
| 2195 | 2320 | |
| 2196 | 2321 | // Queue our JQuery plugins! |
| 2197 | 2322 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2214,12 +2339,12 @@ discard block |
||
| 2214 | 2339 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2215 | 2340 | |
| 2216 | 2341 | // What to do, what to do?! |
| 2217 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2218 | - AutoTask(); |
|
| 2219 | - else |
|
| 2220 | - ReduceMailQueue(); |
|
| 2221 | - } |
|
| 2222 | - else |
|
| 2342 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2343 | + AutoTask(); |
|
| 2344 | + } else { |
|
| 2345 | + ReduceMailQueue(); |
|
| 2346 | + } |
|
| 2347 | + } else |
|
| 2223 | 2348 | { |
| 2224 | 2349 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2225 | 2350 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2270,8 +2395,9 @@ discard block |
||
| 2270 | 2395 | foreach ($theme_includes as $include) |
| 2271 | 2396 | { |
| 2272 | 2397 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2273 | - if (file_exists($include)) |
|
| 2274 | - require_once($include); |
|
| 2398 | + if (file_exists($include)) { |
|
| 2399 | + require_once($include); |
|
| 2400 | + } |
|
| 2275 | 2401 | } |
| 2276 | 2402 | } |
| 2277 | 2403 | |
@@ -2301,16 +2427,19 @@ discard block |
||
| 2301 | 2427 | // Do any style sheets first, cause we're easy with those. |
| 2302 | 2428 | if (!empty($style_sheets)) |
| 2303 | 2429 | { |
| 2304 | - if (!is_array($style_sheets)) |
|
| 2305 | - $style_sheets = array($style_sheets); |
|
| 2430 | + if (!is_array($style_sheets)) { |
|
| 2431 | + $style_sheets = array($style_sheets); |
|
| 2432 | + } |
|
| 2306 | 2433 | |
| 2307 | - foreach ($style_sheets as $sheet) |
|
| 2308 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2434 | + foreach ($style_sheets as $sheet) { |
|
| 2435 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2436 | + } |
|
| 2309 | 2437 | } |
| 2310 | 2438 | |
| 2311 | 2439 | // No template to load? |
| 2312 | - if ($template_name === false) |
|
| 2313 | - return true; |
|
| 2440 | + if ($template_name === false) { |
|
| 2441 | + return true; |
|
| 2442 | + } |
|
| 2314 | 2443 | |
| 2315 | 2444 | $loaded = false; |
| 2316 | 2445 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2325,12 +2454,14 @@ discard block |
||
| 2325 | 2454 | |
| 2326 | 2455 | if ($loaded) |
| 2327 | 2456 | { |
| 2328 | - if ($db_show_debug === true) |
|
| 2329 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2457 | + if ($db_show_debug === true) { |
|
| 2458 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2459 | + } |
|
| 2330 | 2460 | |
| 2331 | 2461 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2332 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2333 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2462 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2463 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2464 | + } |
|
| 2334 | 2465 | } |
| 2335 | 2466 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2336 | 2467 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2350,13 +2481,14 @@ discard block |
||
| 2350 | 2481 | loadTemplate($template_name); |
| 2351 | 2482 | } |
| 2352 | 2483 | // Cause an error otherwise. |
| 2353 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2354 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2355 | - elseif ($fatal) |
|
| 2356 | - 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')); |
|
| 2357 | - else |
|
| 2358 | - return false; |
|
| 2359 | -} |
|
| 2484 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2485 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2486 | + } elseif ($fatal) { |
|
| 2487 | + 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')); |
|
| 2488 | + } else { |
|
| 2489 | + return false; |
|
| 2490 | + } |
|
| 2491 | + } |
|
| 2360 | 2492 | |
| 2361 | 2493 | /** |
| 2362 | 2494 | * Load a sub-template. |
@@ -2374,17 +2506,19 @@ discard block |
||
| 2374 | 2506 | { |
| 2375 | 2507 | global $context, $txt, $db_show_debug; |
| 2376 | 2508 | |
| 2377 | - if ($db_show_debug === true) |
|
| 2378 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2509 | + if ($db_show_debug === true) { |
|
| 2510 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2511 | + } |
|
| 2379 | 2512 | |
| 2380 | 2513 | // Figure out what the template function is named. |
| 2381 | 2514 | $theme_function = 'template_' . $sub_template_name; |
| 2382 | - if (function_exists($theme_function)) |
|
| 2383 | - $theme_function(); |
|
| 2384 | - elseif ($fatal === false) |
|
| 2385 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2386 | - elseif ($fatal !== 'ignore') |
|
| 2387 | - 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')); |
|
| 2515 | + if (function_exists($theme_function)) { |
|
| 2516 | + $theme_function(); |
|
| 2517 | + } elseif ($fatal === false) { |
|
| 2518 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2519 | + } elseif ($fatal !== 'ignore') { |
|
| 2520 | + 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')); |
|
| 2521 | + } |
|
| 2388 | 2522 | |
| 2389 | 2523 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2390 | 2524 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2421,8 +2555,9 @@ discard block |
||
| 2421 | 2555 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2422 | 2556 | |
| 2423 | 2557 | // If this is an external file, automatically set this to false. |
| 2424 | - if (!empty($params['external'])) |
|
| 2425 | - $params['minimize'] = false; |
|
| 2558 | + if (!empty($params['external'])) { |
|
| 2559 | + $params['minimize'] = false; |
|
| 2560 | + } |
|
| 2426 | 2561 | |
| 2427 | 2562 | // Account for shorthand like admin.css?alp21 filenames |
| 2428 | 2563 | $has_seed = strpos($fileName, '.css?'); |
@@ -2439,13 +2574,10 @@ discard block |
||
| 2439 | 2574 | { |
| 2440 | 2575 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2441 | 2576 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2577 | + } else { |
|
| 2578 | + $fileUrl = false; |
|
| 2442 | 2579 | } |
| 2443 | - |
|
| 2444 | - else |
|
| 2445 | - $fileUrl = false; |
|
| 2446 | - } |
|
| 2447 | - |
|
| 2448 | - else |
|
| 2580 | + } else |
|
| 2449 | 2581 | { |
| 2450 | 2582 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2451 | 2583 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2460,12 +2592,14 @@ discard block |
||
| 2460 | 2592 | } |
| 2461 | 2593 | |
| 2462 | 2594 | // Add it to the array for use in the template |
| 2463 | - if (!empty($fileName)) |
|
| 2464 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2595 | + if (!empty($fileName)) { |
|
| 2596 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2597 | + } |
|
| 2465 | 2598 | |
| 2466 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2467 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2468 | -} |
|
| 2599 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2600 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2601 | + } |
|
| 2602 | + } |
|
| 2469 | 2603 | |
| 2470 | 2604 | /** |
| 2471 | 2605 | * Add a block of inline css code to be executed later |
@@ -2482,8 +2616,9 @@ discard block |
||
| 2482 | 2616 | global $context; |
| 2483 | 2617 | |
| 2484 | 2618 | // Gotta add something... |
| 2485 | - if (empty($css)) |
|
| 2486 | - return false; |
|
| 2619 | + if (empty($css)) { |
|
| 2620 | + return false; |
|
| 2621 | + } |
|
| 2487 | 2622 | |
| 2488 | 2623 | $context['css_header'][] = $css; |
| 2489 | 2624 | } |
@@ -2518,8 +2653,9 @@ discard block |
||
| 2518 | 2653 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2519 | 2654 | |
| 2520 | 2655 | // If this is an external file, automatically set this to false. |
| 2521 | - if (!empty($params['external'])) |
|
| 2522 | - $params['minimize'] = false; |
|
| 2656 | + if (!empty($params['external'])) { |
|
| 2657 | + $params['minimize'] = false; |
|
| 2658 | + } |
|
| 2523 | 2659 | |
| 2524 | 2660 | // Account for shorthand like admin.js?alp21 filenames |
| 2525 | 2661 | $has_seed = strpos($fileName, '.js?'); |
@@ -2536,16 +2672,12 @@ discard block |
||
| 2536 | 2672 | { |
| 2537 | 2673 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2538 | 2674 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2539 | - } |
|
| 2540 | - |
|
| 2541 | - else |
|
| 2675 | + } else |
|
| 2542 | 2676 | { |
| 2543 | 2677 | $fileUrl = false; |
| 2544 | 2678 | $filePath = false; |
| 2545 | 2679 | } |
| 2546 | - } |
|
| 2547 | - |
|
| 2548 | - else |
|
| 2680 | + } else |
|
| 2549 | 2681 | { |
| 2550 | 2682 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2551 | 2683 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2560,9 +2692,10 @@ discard block |
||
| 2560 | 2692 | } |
| 2561 | 2693 | |
| 2562 | 2694 | // Add it to the array for use in the template |
| 2563 | - if (!empty($fileName)) |
|
| 2564 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2565 | -} |
|
| 2695 | + if (!empty($fileName)) { |
|
| 2696 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2697 | + } |
|
| 2698 | + } |
|
| 2566 | 2699 | |
| 2567 | 2700 | /** |
| 2568 | 2701 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2576,9 +2709,10 @@ discard block |
||
| 2576 | 2709 | { |
| 2577 | 2710 | global $context; |
| 2578 | 2711 | |
| 2579 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2580 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2581 | -} |
|
| 2712 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2713 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2714 | + } |
|
| 2715 | + } |
|
| 2582 | 2716 | |
| 2583 | 2717 | /** |
| 2584 | 2718 | * Add a block of inline Javascript code to be executed later |
@@ -2595,8 +2729,9 @@ discard block |
||
| 2595 | 2729 | { |
| 2596 | 2730 | global $context; |
| 2597 | 2731 | |
| 2598 | - if (empty($javascript)) |
|
| 2599 | - return false; |
|
| 2732 | + if (empty($javascript)) { |
|
| 2733 | + return false; |
|
| 2734 | + } |
|
| 2600 | 2735 | |
| 2601 | 2736 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2602 | 2737 | } |
@@ -2617,15 +2752,18 @@ discard block |
||
| 2617 | 2752 | static $already_loaded = array(); |
| 2618 | 2753 | |
| 2619 | 2754 | // Default to the user's language. |
| 2620 | - if ($lang == '') |
|
| 2621 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2755 | + if ($lang == '') { |
|
| 2756 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2757 | + } |
|
| 2622 | 2758 | |
| 2623 | 2759 | // Do we want the English version of language file as fallback? |
| 2624 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2625 | - loadLanguage($template_name, 'english', false); |
|
| 2760 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2761 | + loadLanguage($template_name, 'english', false); |
|
| 2762 | + } |
|
| 2626 | 2763 | |
| 2627 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2628 | - return $lang; |
|
| 2764 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2765 | + return $lang; |
|
| 2766 | + } |
|
| 2629 | 2767 | |
| 2630 | 2768 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2631 | 2769 | if (empty($settings['default_theme_dir'])) |
@@ -2636,8 +2774,9 @@ discard block |
||
| 2636 | 2774 | |
| 2637 | 2775 | // What theme are we in? |
| 2638 | 2776 | $theme_name = basename($settings['theme_url']); |
| 2639 | - if (empty($theme_name)) |
|
| 2640 | - $theme_name = 'unknown'; |
|
| 2777 | + if (empty($theme_name)) { |
|
| 2778 | + $theme_name = 'unknown'; |
|
| 2779 | + } |
|
| 2641 | 2780 | |
| 2642 | 2781 | // For each file open it up and write it out! |
| 2643 | 2782 | foreach (explode('+', $template_name) as $template) |
@@ -2679,8 +2818,9 @@ discard block |
||
| 2679 | 2818 | $found = true; |
| 2680 | 2819 | |
| 2681 | 2820 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 2682 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
| 2683 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2821 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
| 2822 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2823 | + } |
|
| 2684 | 2824 | |
| 2685 | 2825 | break; |
| 2686 | 2826 | } |
@@ -2720,8 +2860,9 @@ discard block |
||
| 2720 | 2860 | } |
| 2721 | 2861 | |
| 2722 | 2862 | // Keep track of what we're up to soldier. |
| 2723 | - if ($db_show_debug === true) |
|
| 2724 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2863 | + if ($db_show_debug === true) { |
|
| 2864 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2865 | + } |
|
| 2725 | 2866 | |
| 2726 | 2867 | // Remember what we have loaded, and in which language. |
| 2727 | 2868 | $already_loaded[$template_name] = $lang; |
@@ -2767,8 +2908,9 @@ discard block |
||
| 2767 | 2908 | ) |
| 2768 | 2909 | ); |
| 2769 | 2910 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2770 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2771 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2911 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2912 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2913 | + } |
|
| 2772 | 2914 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2773 | 2915 | { |
| 2774 | 2916 | if (!isset($boards[$row['id_board']])) |
@@ -2785,8 +2927,8 @@ discard block |
||
| 2785 | 2927 | ); |
| 2786 | 2928 | } |
| 2787 | 2929 | // If a moderator exists for this board, add that moderator for all children too. |
| 2788 | - if (!empty($row['id_moderator'])) |
|
| 2789 | - foreach ($boards as $id => $dummy) |
|
| 2930 | + if (!empty($row['id_moderator'])) { |
|
| 2931 | + foreach ($boards as $id => $dummy) |
|
| 2790 | 2932 | { |
| 2791 | 2933 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2792 | 2934 | 'id' => $row['id_moderator'], |
@@ -2794,11 +2936,12 @@ discard block |
||
| 2794 | 2936 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2795 | 2937 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2796 | 2938 | ); |
| 2939 | + } |
|
| 2797 | 2940 | } |
| 2798 | 2941 | |
| 2799 | 2942 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2800 | - if (!empty($row['id_moderator_group'])) |
|
| 2801 | - foreach ($boards as $id => $dummy) |
|
| 2943 | + if (!empty($row['id_moderator_group'])) { |
|
| 2944 | + foreach ($boards as $id => $dummy) |
|
| 2802 | 2945 | { |
| 2803 | 2946 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2804 | 2947 | 'id' => $row['id_moderator_group'], |
@@ -2806,6 +2949,7 @@ discard block |
||
| 2806 | 2949 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2807 | 2950 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2808 | 2951 | ); |
| 2952 | + } |
|
| 2809 | 2953 | } |
| 2810 | 2954 | } |
| 2811 | 2955 | $smcFunc['db_free_result']($result); |
@@ -2832,23 +2976,27 @@ discard block |
||
| 2832 | 2976 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2833 | 2977 | { |
| 2834 | 2978 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2835 | - if (empty($smcFunc['ucwords'])) |
|
| 2836 | - reloadSettings(); |
|
| 2979 | + if (empty($smcFunc['ucwords'])) { |
|
| 2980 | + reloadSettings(); |
|
| 2981 | + } |
|
| 2837 | 2982 | |
| 2838 | 2983 | // If we don't have our theme information yet, let's get it. |
| 2839 | - if (empty($settings['default_theme_dir'])) |
|
| 2840 | - loadTheme(0, false); |
|
| 2984 | + if (empty($settings['default_theme_dir'])) { |
|
| 2985 | + loadTheme(0, false); |
|
| 2986 | + } |
|
| 2841 | 2987 | |
| 2842 | 2988 | // Default language directories to try. |
| 2843 | 2989 | $language_directories = array( |
| 2844 | 2990 | $settings['default_theme_dir'] . '/languages', |
| 2845 | 2991 | ); |
| 2846 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2847 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2992 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 2993 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2994 | + } |
|
| 2848 | 2995 | |
| 2849 | 2996 | // We possibly have a base theme directory. |
| 2850 | - if (!empty($settings['base_theme_dir'])) |
|
| 2851 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2997 | + if (!empty($settings['base_theme_dir'])) { |
|
| 2998 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2999 | + } |
|
| 2852 | 3000 | |
| 2853 | 3001 | // Remove any duplicates. |
| 2854 | 3002 | $language_directories = array_unique($language_directories); |
@@ -2862,20 +3010,21 @@ discard block |
||
| 2862 | 3010 | foreach ($language_directories as $language_dir) |
| 2863 | 3011 | { |
| 2864 | 3012 | // Can't look in here... doesn't exist! |
| 2865 | - if (!file_exists($language_dir)) |
|
| 2866 | - continue; |
|
| 3013 | + if (!file_exists($language_dir)) { |
|
| 3014 | + continue; |
|
| 3015 | + } |
|
| 2867 | 3016 | |
| 2868 | 3017 | $dir = dir($language_dir); |
| 2869 | 3018 | while ($entry = $dir->read()) |
| 2870 | 3019 | { |
| 2871 | 3020 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 2872 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
| 2873 | - continue; |
|
| 2874 | - |
|
| 2875 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2876 | - $langName = $langList[$matches[1]]; |
|
| 3021 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
| 3022 | + continue; |
|
| 3023 | + } |
|
| 2877 | 3024 | |
| 2878 | - else |
|
| 3025 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 3026 | + $langName = $langList[$matches[1]]; |
|
| 3027 | + } else |
|
| 2879 | 3028 | { |
| 2880 | 3029 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2881 | 3030 | |
@@ -2916,12 +3065,14 @@ discard block |
||
| 2916 | 3065 | } |
| 2917 | 3066 | |
| 2918 | 3067 | // Do we need to store the lang list? |
| 2919 | - if (empty($langList)) |
|
| 2920 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3068 | + if (empty($langList)) { |
|
| 3069 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3070 | + } |
|
| 2921 | 3071 | |
| 2922 | 3072 | // Let's cash in on this deal. |
| 2923 | - if (!empty($modSettings['cache_enable'])) |
|
| 2924 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3073 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3074 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3075 | + } |
|
| 2925 | 3076 | } |
| 2926 | 3077 | |
| 2927 | 3078 | return $context['languages']; |
@@ -2944,8 +3095,9 @@ discard block |
||
| 2944 | 3095 | global $modSettings, $options, $txt; |
| 2945 | 3096 | static $censor_vulgar = null, $censor_proper; |
| 2946 | 3097 | |
| 2947 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2948 | - return $text; |
|
| 3098 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3099 | + return $text; |
|
| 3100 | + } |
|
| 2949 | 3101 | |
| 2950 | 3102 | // If they haven't yet been loaded, load them. |
| 2951 | 3103 | if ($censor_vulgar == null) |
@@ -2973,9 +3125,9 @@ discard block |
||
| 2973 | 3125 | { |
| 2974 | 3126 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 2975 | 3127 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3128 | + } else { |
|
| 3129 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2976 | 3130 | } |
| 2977 | - else |
|
| 2978 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2979 | 3131 | |
| 2980 | 3132 | return $text; |
| 2981 | 3133 | } |
@@ -3001,38 +3153,42 @@ discard block |
||
| 3001 | 3153 | @ini_set('track_errors', '1'); |
| 3002 | 3154 | |
| 3003 | 3155 | // Don't include the file more than once, if $once is true. |
| 3004 | - if ($once && in_array($filename, $templates)) |
|
| 3005 | - return; |
|
| 3156 | + if ($once && in_array($filename, $templates)) { |
|
| 3157 | + return; |
|
| 3158 | + } |
|
| 3006 | 3159 | // Add this file to the include list, whether $once is true or not. |
| 3007 | - else |
|
| 3008 | - $templates[] = $filename; |
|
| 3160 | + else { |
|
| 3161 | + $templates[] = $filename; |
|
| 3162 | + } |
|
| 3009 | 3163 | |
| 3010 | 3164 | // Are we going to use eval? |
| 3011 | 3165 | if (empty($modSettings['disableTemplateEval'])) |
| 3012 | 3166 | { |
| 3013 | 3167 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
| 3014 | 3168 | $settings['current_include_filename'] = $filename; |
| 3015 | - } |
|
| 3016 | - else |
|
| 3169 | + } else |
|
| 3017 | 3170 | { |
| 3018 | 3171 | $file_found = file_exists($filename); |
| 3019 | 3172 | |
| 3020 | - if ($once && $file_found) |
|
| 3021 | - require_once($filename); |
|
| 3022 | - elseif ($file_found) |
|
| 3023 | - require($filename); |
|
| 3173 | + if ($once && $file_found) { |
|
| 3174 | + require_once($filename); |
|
| 3175 | + } elseif ($file_found) { |
|
| 3176 | + require($filename); |
|
| 3177 | + } |
|
| 3024 | 3178 | } |
| 3025 | 3179 | |
| 3026 | 3180 | if ($file_found !== true) |
| 3027 | 3181 | { |
| 3028 | 3182 | ob_end_clean(); |
| 3029 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3030 | - @ob_start('ob_gzhandler'); |
|
| 3031 | - else |
|
| 3032 | - ob_start(); |
|
| 3183 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3184 | + @ob_start('ob_gzhandler'); |
|
| 3185 | + } else { |
|
| 3186 | + ob_start(); |
|
| 3187 | + } |
|
| 3033 | 3188 | |
| 3034 | - if (isset($_GET['debug'])) |
|
| 3035 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3189 | + if (isset($_GET['debug'])) { |
|
| 3190 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3191 | + } |
|
| 3036 | 3192 | |
| 3037 | 3193 | // Don't cache error pages!! |
| 3038 | 3194 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3051,12 +3207,13 @@ discard block |
||
| 3051 | 3207 | echo '<!DOCTYPE html> |
| 3052 | 3208 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3053 | 3209 | <head>'; |
| 3054 | - if (isset($context['character_set'])) |
|
| 3055 | - echo ' |
|
| 3210 | + if (isset($context['character_set'])) { |
|
| 3211 | + echo ' |
|
| 3056 | 3212 | <meta charset="', $context['character_set'], '">'; |
| 3213 | + } |
|
| 3057 | 3214 | |
| 3058 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3059 | - echo ' |
|
| 3215 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3216 | + echo ' |
|
| 3060 | 3217 | <title>', $mtitle, '</title> |
| 3061 | 3218 | </head> |
| 3062 | 3219 | <body> |
@@ -3064,8 +3221,8 @@ discard block |
||
| 3064 | 3221 | ', $mmessage, ' |
| 3065 | 3222 | </body> |
| 3066 | 3223 | </html>'; |
| 3067 | - elseif (!allowedTo('admin_forum')) |
|
| 3068 | - echo ' |
|
| 3224 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3225 | + echo ' |
|
| 3069 | 3226 | <title>', $txt['template_parse_error'], '</title> |
| 3070 | 3227 | </head> |
| 3071 | 3228 | <body> |
@@ -3073,16 +3230,18 @@ discard block |
||
| 3073 | 3230 | ', $txt['template_parse_error_message'], ' |
| 3074 | 3231 | </body> |
| 3075 | 3232 | </html>'; |
| 3076 | - else |
|
| 3233 | + } else |
|
| 3077 | 3234 | { |
| 3078 | 3235 | require_once($sourcedir . '/Subs-Package.php'); |
| 3079 | 3236 | |
| 3080 | 3237 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3081 | 3238 | $error_array = error_get_last(); |
| 3082 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
| 3083 | - $error = $error_array['message']; |
|
| 3084 | - if (empty($error)) |
|
| 3085 | - $error = $txt['template_parse_errmsg']; |
|
| 3239 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
| 3240 | + $error = $error_array['message']; |
|
| 3241 | + } |
|
| 3242 | + if (empty($error)) { |
|
| 3243 | + $error = $txt['template_parse_errmsg']; |
|
| 3244 | + } |
|
| 3086 | 3245 | |
| 3087 | 3246 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3088 | 3247 | |
@@ -3093,11 +3252,12 @@ discard block |
||
| 3093 | 3252 | <h3>', $txt['template_parse_error'], '</h3> |
| 3094 | 3253 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3095 | 3254 | |
| 3096 | - if (!empty($error)) |
|
| 3097 | - echo ' |
|
| 3255 | + if (!empty($error)) { |
|
| 3256 | + echo ' |
|
| 3098 | 3257 | <hr> |
| 3099 | 3258 | |
| 3100 | 3259 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3260 | + } |
|
| 3101 | 3261 | |
| 3102 | 3262 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3103 | 3263 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3107,10 +3267,11 @@ discard block |
||
| 3107 | 3267 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3108 | 3268 | |
| 3109 | 3269 | // Fix the PHP code stuff... |
| 3110 | - if (!isBrowser('gecko')) |
|
| 3111 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3112 | - else |
|
| 3113 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3270 | + if (!isBrowser('gecko')) { |
|
| 3271 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3272 | + } else { |
|
| 3273 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3274 | + } |
|
| 3114 | 3275 | |
| 3115 | 3276 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3116 | 3277 | $j = -1; |
@@ -3118,8 +3279,9 @@ discard block |
||
| 3118 | 3279 | { |
| 3119 | 3280 | $j++; |
| 3120 | 3281 | |
| 3121 | - if (substr_count($line, '<br>') == 0) |
|
| 3122 | - continue; |
|
| 3282 | + if (substr_count($line, '<br>') == 0) { |
|
| 3283 | + continue; |
|
| 3284 | + } |
|
| 3123 | 3285 | |
| 3124 | 3286 | $n = substr_count($line, '<br>'); |
| 3125 | 3287 | for ($i = 0; $i < $n; $i++) |
@@ -3138,38 +3300,42 @@ discard block |
||
| 3138 | 3300 | // Figure out what the color coding was before... |
| 3139 | 3301 | $line = max($match[1] - 9, 1); |
| 3140 | 3302 | $last_line = ''; |
| 3141 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3142 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3303 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3304 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3143 | 3305 | { |
| 3144 | 3306 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3145 | 3307 | $last_line = $color_match[1]; |
| 3308 | + } |
|
| 3146 | 3309 | break; |
| 3147 | 3310 | } |
| 3148 | 3311 | |
| 3149 | 3312 | // Show the relevant lines... |
| 3150 | 3313 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3151 | 3314 | { |
| 3152 | - if ($line == $match[1]) |
|
| 3153 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3315 | + if ($line == $match[1]) { |
|
| 3316 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3317 | + } |
|
| 3154 | 3318 | |
| 3155 | 3319 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3156 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3157 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3320 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3321 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3322 | + } |
|
| 3158 | 3323 | |
| 3159 | 3324 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3160 | 3325 | { |
| 3161 | 3326 | $last_line = $color_match[1]; |
| 3162 | 3327 | echo '</', substr($last_line, 1, 4), '>'; |
| 3328 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3329 | + $last_line = ''; |
|
| 3330 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3331 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3163 | 3332 | } |
| 3164 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3165 | - $last_line = ''; |
|
| 3166 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3167 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3168 | 3333 | |
| 3169 | - if ($line == $match[1]) |
|
| 3170 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3171 | - else |
|
| 3172 | - echo "\n"; |
|
| 3334 | + if ($line == $match[1]) { |
|
| 3335 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3336 | + } else { |
|
| 3337 | + echo "\n"; |
|
| 3338 | + } |
|
| 3173 | 3339 | } |
| 3174 | 3340 | |
| 3175 | 3341 | echo '</pre></div>'; |
@@ -3193,8 +3359,9 @@ discard block |
||
| 3193 | 3359 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
| 3194 | 3360 | |
| 3195 | 3361 | // Figure out what type of database we are using. |
| 3196 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3197 | - $db_type = 'mysql'; |
|
| 3362 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3363 | + $db_type = 'mysql'; |
|
| 3364 | + } |
|
| 3198 | 3365 | |
| 3199 | 3366 | // Load the file for the database. |
| 3200 | 3367 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3202,8 +3369,9 @@ discard block |
||
| 3202 | 3369 | $db_options = array(); |
| 3203 | 3370 | |
| 3204 | 3371 | // Add in the port if needed |
| 3205 | - if (!empty($db_port)) |
|
| 3206 | - $db_options['port'] = $db_port; |
|
| 3372 | + if (!empty($db_port)) { |
|
| 3373 | + $db_options['port'] = $db_port; |
|
| 3374 | + } |
|
| 3207 | 3375 | |
| 3208 | 3376 | // 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. |
| 3209 | 3377 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3222,13 +3390,15 @@ discard block |
||
| 3222 | 3390 | } |
| 3223 | 3391 | |
| 3224 | 3392 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3225 | - if (!$db_connection) |
|
| 3226 | - display_db_error(); |
|
| 3393 | + if (!$db_connection) { |
|
| 3394 | + display_db_error(); |
|
| 3395 | + } |
|
| 3227 | 3396 | |
| 3228 | 3397 | // If in SSI mode fix up the prefix. |
| 3229 | - if (SMF == 'SSI') |
|
| 3230 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3231 | -} |
|
| 3398 | + if (SMF == 'SSI') { |
|
| 3399 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3400 | + } |
|
| 3401 | + } |
|
| 3232 | 3402 | |
| 3233 | 3403 | /** |
| 3234 | 3404 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3242,10 +3412,11 @@ discard block |
||
| 3242 | 3412 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3243 | 3413 | |
| 3244 | 3414 | // Not overriding this and we have a cacheAPI, send it back. |
| 3245 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3246 | - return $cacheAPI; |
|
| 3247 | - elseif (is_null($cacheAPI)) |
|
| 3248 | - $cacheAPI = false; |
|
| 3415 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3416 | + return $cacheAPI; |
|
| 3417 | + } elseif (is_null($cacheAPI)) { |
|
| 3418 | + $cacheAPI = false; |
|
| 3419 | + } |
|
| 3249 | 3420 | |
| 3250 | 3421 | // Make sure our class is in session. |
| 3251 | 3422 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3266,8 +3437,9 @@ discard block |
||
| 3266 | 3437 | if (!$testAPI->isSupported()) |
| 3267 | 3438 | { |
| 3268 | 3439 | // Can we save ourselves? |
| 3269 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3270 | - return loadCacheAccelerator(null, false); |
|
| 3440 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3441 | + return loadCacheAccelerator(null, false); |
|
| 3442 | + } |
|
| 3271 | 3443 | return false; |
| 3272 | 3444 | } |
| 3273 | 3445 | |
@@ -3279,9 +3451,9 @@ discard block |
||
| 3279 | 3451 | { |
| 3280 | 3452 | $cacheAPI = $testAPI; |
| 3281 | 3453 | return $cacheAPI; |
| 3454 | + } else { |
|
| 3455 | + return $testAPI; |
|
| 3282 | 3456 | } |
| 3283 | - else |
|
| 3284 | - return $testAPI; |
|
| 3285 | 3457 | } |
| 3286 | 3458 | } |
| 3287 | 3459 | |
@@ -3301,8 +3473,9 @@ discard block |
||
| 3301 | 3473 | |
| 3302 | 3474 | // @todo Why are we doing this if caching is disabled? |
| 3303 | 3475 | |
| 3304 | - if (function_exists('call_integration_hook')) |
|
| 3305 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3476 | + if (function_exists('call_integration_hook')) { |
|
| 3477 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3478 | + } |
|
| 3306 | 3479 | |
| 3307 | 3480 | /* Refresh the cache if either: |
| 3308 | 3481 | 1. Caching is disabled. |
@@ -3316,16 +3489,19 @@ discard block |
||
| 3316 | 3489 | require_once($sourcedir . '/' . $file); |
| 3317 | 3490 | $cache_block = call_user_func_array($function, $params); |
| 3318 | 3491 | |
| 3319 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3320 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3492 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3493 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3494 | + } |
|
| 3321 | 3495 | } |
| 3322 | 3496 | |
| 3323 | 3497 | // Some cached data may need a freshening up after retrieval. |
| 3324 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3325 | - eval($cache_block['post_retri_eval']); |
|
| 3498 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3499 | + eval($cache_block['post_retri_eval']); |
|
| 3500 | + } |
|
| 3326 | 3501 | |
| 3327 | - if (function_exists('call_integration_hook')) |
|
| 3328 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3502 | + if (function_exists('call_integration_hook')) { |
|
| 3503 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3504 | + } |
|
| 3329 | 3505 | |
| 3330 | 3506 | return $cache_block['data']; |
| 3331 | 3507 | } |
@@ -3352,8 +3528,9 @@ discard block |
||
| 3352 | 3528 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3353 | 3529 | global $cache_hits, $cache_count, $db_show_debug; |
| 3354 | 3530 | |
| 3355 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3356 | - return; |
|
| 3531 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3532 | + return; |
|
| 3533 | + } |
|
| 3357 | 3534 | |
| 3358 | 3535 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3359 | 3536 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3366,12 +3543,14 @@ discard block |
||
| 3366 | 3543 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
| 3367 | 3544 | $cacheAPI->putData($key, $value, $ttl); |
| 3368 | 3545 | |
| 3369 | - if (function_exists('call_integration_hook')) |
|
| 3370 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3546 | + if (function_exists('call_integration_hook')) { |
|
| 3547 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3548 | + } |
|
| 3371 | 3549 | |
| 3372 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3373 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3374 | -} |
|
| 3550 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3551 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3552 | + } |
|
| 3553 | + } |
|
| 3375 | 3554 | |
| 3376 | 3555 | /** |
| 3377 | 3556 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3387,8 +3566,9 @@ discard block |
||
| 3387 | 3566 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3388 | 3567 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3389 | 3568 | |
| 3390 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3391 | - return; |
|
| 3569 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3570 | + return; |
|
| 3571 | + } |
|
| 3392 | 3572 | |
| 3393 | 3573 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3394 | 3574 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3408,16 +3588,18 @@ discard block |
||
| 3408 | 3588 | |
| 3409 | 3589 | if (empty($value)) |
| 3410 | 3590 | { |
| 3411 | - if (!is_array($cache_misses)) |
|
| 3412 | - $cache_misses = array(); |
|
| 3591 | + if (!is_array($cache_misses)) { |
|
| 3592 | + $cache_misses = array(); |
|
| 3593 | + } |
|
| 3413 | 3594 | |
| 3414 | 3595 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3415 | 3596 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3416 | 3597 | } |
| 3417 | 3598 | } |
| 3418 | 3599 | |
| 3419 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3420 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3600 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3601 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3602 | + } |
|
| 3421 | 3603 | |
| 3422 | 3604 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
| 3423 | 3605 | } |
@@ -3439,8 +3621,9 @@ discard block |
||
| 3439 | 3621 | global $cacheAPI; |
| 3440 | 3622 | |
| 3441 | 3623 | // If we can't get to the API, can't do this. |
| 3442 | - if (empty($cacheAPI)) |
|
| 3443 | - return; |
|
| 3624 | + if (empty($cacheAPI)) { |
|
| 3625 | + return; |
|
| 3626 | + } |
|
| 3444 | 3627 | |
| 3445 | 3628 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3446 | 3629 | $cacheAPI->cleanCache($type); |
@@ -3465,8 +3648,9 @@ discard block |
||
| 3465 | 3648 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
| 3466 | 3649 | |
| 3467 | 3650 | // Come on! |
| 3468 | - if (empty($data)) |
|
| 3469 | - return array(); |
|
| 3651 | + if (empty($data)) { |
|
| 3652 | + return array(); |
|
| 3653 | + } |
|
| 3470 | 3654 | |
| 3471 | 3655 | // Set a nice default var. |
| 3472 | 3656 | $image = ''; |
@@ -3474,11 +3658,11 @@ discard block |
||
| 3474 | 3658 | // Gravatar has been set as mandatory! |
| 3475 | 3659 | if (!empty($modSettings['gravatarOverride'])) |
| 3476 | 3660 | { |
| 3477 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3478 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3479 | - |
|
| 3480 | - else if (!empty($data['email'])) |
|
| 3481 | - $image = get_gravatar_url($data['email']); |
|
| 3661 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3662 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3663 | + } else if (!empty($data['email'])) { |
|
| 3664 | + $image = get_gravatar_url($data['email']); |
|
| 3665 | + } |
|
| 3482 | 3666 | } |
| 3483 | 3667 | |
| 3484 | 3668 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3490,54 +3674,60 @@ discard block |
||
| 3490 | 3674 | // Gravatar. |
| 3491 | 3675 | if (stristr($data['avatar'], 'gravatar://')) |
| 3492 | 3676 | { |
| 3493 | - if ($data['avatar'] == 'gravatar://') |
|
| 3494 | - $image = get_gravatar_url($data['email']); |
|
| 3495 | - |
|
| 3496 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3497 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3677 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3678 | + $image = get_gravatar_url($data['email']); |
|
| 3679 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3680 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3681 | + } |
|
| 3498 | 3682 | } |
| 3499 | 3683 | |
| 3500 | 3684 | // External url. |
| 3501 | 3685 | else |
| 3502 | 3686 | { |
| 3503 | 3687 | // Using ssl? |
| 3504 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
| 3505 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3688 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
| 3689 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3690 | + } |
|
| 3506 | 3691 | |
| 3507 | 3692 | // Just a plain external url. |
| 3508 | - else |
|
| 3509 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3693 | + else { |
|
| 3694 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3695 | + } |
|
| 3510 | 3696 | } |
| 3511 | 3697 | } |
| 3512 | 3698 | |
| 3513 | 3699 | // Perhaps this user has an attachment as avatar... |
| 3514 | - else if (!empty($data['filename'])) |
|
| 3515 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3700 | + else if (!empty($data['filename'])) { |
|
| 3701 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3702 | + } |
|
| 3516 | 3703 | |
| 3517 | 3704 | // Right... no avatar... use our default image. |
| 3518 | - else |
|
| 3519 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3705 | + else { |
|
| 3706 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3707 | + } |
|
| 3520 | 3708 | } |
| 3521 | 3709 | |
| 3522 | 3710 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3523 | 3711 | |
| 3524 | 3712 | // 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. |
| 3525 | - if (!empty($image)) |
|
| 3526 | - return array( |
|
| 3713 | + if (!empty($image)) { |
|
| 3714 | + return array( |
|
| 3527 | 3715 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3528 | 3716 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3529 | 3717 | 'href' => $image, |
| 3530 | 3718 | 'url' => $image, |
| 3531 | 3719 | ); |
| 3720 | + } |
|
| 3532 | 3721 | |
| 3533 | 3722 | // Fallback to make life easier for everyone... |
| 3534 | - else |
|
| 3535 | - return array( |
|
| 3723 | + else { |
|
| 3724 | + return array( |
|
| 3536 | 3725 | 'name' => '', |
| 3537 | 3726 | 'image' => '', |
| 3538 | 3727 | 'href' => '', |
| 3539 | 3728 | 'url' => '', |
| 3540 | 3729 | ); |
| 3541 | -} |
|
| 3730 | + } |
|
| 3731 | + } |
|
| 3542 | 3732 | |
| 3543 | 3733 | ?> |
| 3544 | 3734 | \ No newline at end of file |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | 'class' => 'centercol', |
| 1335 | 1335 | ), |
| 1336 | 1336 | 'data' => array( |
| 1337 | - 'function' => function ($rowData) |
|
| 1337 | + 'function' => function($rowData) |
|
| 1338 | 1338 | { |
| 1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
| 1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | 'class' => 'centercol', |
| 1351 | 1351 | ), |
| 1352 | 1352 | 'data' => array( |
| 1353 | - 'function' => function ($rowData) |
|
| 1353 | + 'function' => function($rowData) |
|
| 1354 | 1354 | { |
| 1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
| 1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
| 1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
| 1398 | 1398 | ), |
| 1399 | 1399 | 'data' => array( |
| 1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
| 1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
| 1401 | 1401 | { |
| 1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
| 1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
| 1403 | 1403 | |
| 1404 | 1404 | if ($rowData['field_order'] > 1) |
| 1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
| 1406 | 1406 | |
| 1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
| 1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
| 1409 | 1409 | |
| 1410 | 1410 | $return .= '</p>'; |
| 1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
| 1424 | 1424 | ), |
| 1425 | 1425 | 'data' => array( |
| 1426 | - 'function' => function ($rowData) use ($scripturl) |
|
| 1426 | + 'function' => function($rowData) use ($scripturl) |
|
| 1427 | 1427 | { |
| 1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
| 1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
| 1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
| 1440 | 1440 | ), |
| 1441 | 1441 | 'data' => array( |
| 1442 | - 'function' => function ($rowData) use ($txt) |
|
| 1442 | + 'function' => function($rowData) use ($txt) |
|
| 1443 | 1443 | { |
| 1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
| 1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
| 1457 | 1457 | 'value' => $txt['custom_profile_active'], |
| 1458 | 1458 | ), |
| 1459 | 1459 | 'data' => array( |
| 1460 | - 'function' => function ($rowData) use ($txt) |
|
| 1460 | + 'function' => function($rowData) use ($txt) |
|
| 1461 | 1461 | { |
| 1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
| 1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
| 1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
| 1475 | 1475 | ), |
| 1476 | 1476 | 'data' => array( |
| 1477 | - 'function' => function ($rowData) |
|
| 1477 | + 'function' => function($rowData) |
|
| 1478 | 1478 | { |
| 1479 | 1479 | global $txt, $context; |
| 1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
| 1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
| 1710 | 1710 | |
| 1711 | 1711 | // All good, proceed. |
| 1712 | - $smcFunc['db_query']('',' |
|
| 1712 | + $smcFunc['db_query']('', ' |
|
| 1713 | 1713 | UPDATE {db_prefix}custom_fields |
| 1714 | 1714 | SET field_order = {int:old_order} |
| 1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
| 1718 | 1718 | 'old_order' => $context['field']['order'], |
| 1719 | 1719 | ) |
| 1720 | 1720 | ); |
| 1721 | - $smcFunc['db_query']('',' |
|
| 1721 | + $smcFunc['db_query']('', ' |
|
| 1722 | 1722 | UPDATE {db_prefix}custom_fields |
| 1723 | 1723 | SET field_order = {int:new_order} |
| 1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
| 1820 | 1820 | $smcFunc['db_free_result']($request); |
| 1821 | 1821 | |
| 1822 | 1822 | $unique = false; |
| 1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
| 1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
| 1824 | 1824 | { |
| 1825 | 1825 | if (!in_array($col_name, $current_fields)) |
| 1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
| 1993 | 1993 | ); |
| 1994 | 1994 | |
| 1995 | 1995 | // Re-arrange the order. |
| 1996 | - $smcFunc['db_query']('',' |
|
| 1996 | + $smcFunc['db_query']('', ' |
|
| 1997 | 1997 | UPDATE {db_prefix}custom_fields |
| 1998 | 1998 | SET field_order = field_order - 1 |
| 1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
| 2257 | 2257 | $context['token_check'] = 'noti-admin'; |
| 2258 | 2258 | |
| 2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
| 2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
| 2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
| 2261 | 2261 | |
| 2262 | 2262 | loadTemplate('Profile'); |
| 2263 | 2263 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
| 206 | 207 | { |
| 207 | 208 | $all_zones = timezone_identifiers_list(); |
| 208 | 209 | // Make sure we set the value to the same as the printed value. |
| 209 | - foreach ($all_zones as $zone) |
|
| 210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 210 | + foreach ($all_zones as $zone) { |
|
| 211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 212 | + } |
|
| 213 | + } else { |
|
| 214 | + unset($config_vars['default_timezone']); |
|
| 211 | 215 | } |
| 212 | - else |
|
| 213 | - unset($config_vars['default_timezone']); |
|
| 214 | 216 | |
| 215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
| 216 | 218 | |
| 217 | - if ($return_config) |
|
| 218 | - return $config_vars; |
|
| 219 | + if ($return_config) { |
|
| 220 | + return $config_vars; |
|
| 221 | + } |
|
| 219 | 222 | |
| 220 | 223 | // Saving? |
| 221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
| 223 | 226 | checkSession(); |
| 224 | 227 | |
| 225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
| 226 | - if (isset($_POST['lastActive'])) |
|
| 227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 229 | + if (isset($_POST['lastActive'])) { |
|
| 230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 231 | + } |
|
| 228 | 232 | |
| 229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
| 230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
| 269 | 273 | |
| 270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
| 271 | 275 | |
| 272 | - if ($return_config) |
|
| 273 | - return $config_vars; |
|
| 276 | + if ($return_config) { |
|
| 277 | + return $config_vars; |
|
| 278 | + } |
|
| 274 | 279 | |
| 275 | 280 | // Setup the template. |
| 276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
| 287 | 292 | |
| 288 | 293 | // Clean up the tags. |
| 289 | 294 | $bbcTags = array(); |
| 290 | - foreach (parse_bbc(false) as $tag) |
|
| 291 | - $bbcTags[] = $tag['tag']; |
|
| 295 | + foreach (parse_bbc(false) as $tag) { |
|
| 296 | + $bbcTags[] = $tag['tag']; |
|
| 297 | + } |
|
| 292 | 298 | |
| 293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
| 294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
| 295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
| 296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
| 300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
| 301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
| 302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 303 | + } |
|
| 297 | 304 | // Work out what is actually disabled! |
| 298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
| 299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
| 337 | 344 | |
| 338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
| 339 | 346 | |
| 340 | - if ($return_config) |
|
| 341 | - return $config_vars; |
|
| 347 | + if ($return_config) { |
|
| 348 | + return $config_vars; |
|
| 349 | + } |
|
| 342 | 350 | |
| 343 | 351 | // Saving? |
| 344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
| 379 | 387 | |
| 380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
| 381 | 389 | |
| 382 | - if ($return_config) |
|
| 383 | - return $config_vars; |
|
| 390 | + if ($return_config) { |
|
| 391 | + return $config_vars; |
|
| 392 | + } |
|
| 384 | 393 | |
| 385 | 394 | // Saving? |
| 386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
| 418 | 427 | |
| 419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
| 420 | 429 | |
| 421 | - if ($return_config) |
|
| 422 | - return $config_vars; |
|
| 430 | + if ($return_config) { |
|
| 431 | + return $config_vars; |
|
| 432 | + } |
|
| 423 | 433 | |
| 424 | 434 | // Saving? |
| 425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
| 463 | 473 | 'enable' => array('check', 'warning_enable'), |
| 464 | 474 | ); |
| 465 | 475 | |
| 466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
| 467 | - $config_vars += array( |
|
| 476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
| 477 | + $config_vars += array( |
|
| 468 | 478 | '', |
| 469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
| 470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
| 473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
| 474 | 484 | array('permissions', 'view_warning'), |
| 475 | 485 | ); |
| 486 | + } |
|
| 476 | 487 | |
| 477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
| 478 | 489 | |
| 479 | - if ($return_config) |
|
| 480 | - return $config_vars; |
|
| 490 | + if ($return_config) { |
|
| 491 | + return $config_vars; |
|
| 492 | + } |
|
| 481 | 493 | |
| 482 | 494 | // Cannot use moderation if post moderation is not enabled. |
| 483 | - if (!$modSettings['postmod_active']) |
|
| 484 | - unset($config_vars['moderate']); |
|
| 495 | + if (!$modSettings['postmod_active']) { |
|
| 496 | + unset($config_vars['moderate']); |
|
| 497 | + } |
|
| 485 | 498 | |
| 486 | 499 | // Will need the utility functions from here. |
| 487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
| 506 | 519 | 'warning_watch' => 10, |
| 507 | 520 | 'warning_mute' => 60, |
| 508 | 521 | ); |
| 509 | - if ($modSettings['postmod_active']) |
|
| 510 | - $vars['warning_moderate'] = 35; |
|
| 522 | + if ($modSettings['postmod_active']) { |
|
| 523 | + $vars['warning_moderate'] = 35; |
|
| 524 | + } |
|
| 511 | 525 | |
| 512 | 526 | foreach ($vars as $var => $value) |
| 513 | 527 | { |
| 514 | 528 | $config_vars[] = array('int', $var); |
| 515 | 529 | $_POST[$var] = $value; |
| 516 | 530 | } |
| 517 | - } |
|
| 518 | - else |
|
| 531 | + } else |
|
| 519 | 532 | { |
| 520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
| 521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
| 603 | 616 | |
| 604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
| 605 | 618 | |
| 606 | - if ($return_config) |
|
| 607 | - return $config_vars; |
|
| 619 | + if ($return_config) { |
|
| 620 | + return $config_vars; |
|
| 621 | + } |
|
| 608 | 622 | |
| 609 | 623 | // You need to be an admin to edit settings! |
| 610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
| 638 | 652 | |
| 639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
| 640 | 654 | { |
| 641 | - if (empty($context['settings_insert_above'])) |
|
| 642 | - $context['settings_insert_above'] = ''; |
|
| 655 | + if (empty($context['settings_insert_above'])) { |
|
| 656 | + $context['settings_insert_above'] = ''; |
|
| 657 | + } |
|
| 643 | 658 | |
| 644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
| 645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
| 682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
| 683 | 698 | |
| 684 | 699 | // Hack in guest requiring verification! |
| 685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
| 686 | - $_POST['posts_require_captcha'] = -1; |
|
| 700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
| 701 | + $_POST['posts_require_captcha'] = -1; |
|
| 702 | + } |
|
| 687 | 703 | |
| 688 | 704 | $save_vars = $config_vars; |
| 689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
| 700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
| 701 | 717 | { |
| 702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
| 703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
| 704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
| 720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 721 | + } |
|
| 705 | 722 | |
| 706 | 723 | // Now step through and see if any existing questions no longer exist. |
| 707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
| 710 | 727 | $changes['delete'][] = $q_id; |
| 728 | + } |
|
| 711 | 729 | |
| 712 | 730 | // Now let's see if there are new questions or ones that need updating. |
| 713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
| 716 | 734 | { |
| 717 | 735 | // Ignore junky ids. |
| 718 | 736 | $q_id = (int) $q_id; |
| 719 | - if ($q_id <= 0) |
|
| 720 | - continue; |
|
| 737 | + if ($q_id <= 0) { |
|
| 738 | + continue; |
|
| 739 | + } |
|
| 721 | 740 | |
| 722 | 741 | // Check the question isn't empty (because they want to delete it?) |
| 723 | 742 | if (empty($question) || trim($question) == '') |
| 724 | 743 | { |
| 725 | - if (isset($context['question_answers'][$q_id])) |
|
| 726 | - $changes['delete'][] = $q_id; |
|
| 744 | + if (isset($context['question_answers'][$q_id])) { |
|
| 745 | + $changes['delete'][] = $q_id; |
|
| 746 | + } |
|
| 727 | 747 | continue; |
| 728 | 748 | } |
| 729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
| 731 | 751 | // Get the answers. Firstly check there actually might be some. |
| 732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
| 733 | 753 | { |
| 734 | - if (isset($context['question_answers'][$q_id])) |
|
| 735 | - $changes['delete'][] = $q_id; |
|
| 754 | + if (isset($context['question_answers'][$q_id])) { |
|
| 755 | + $changes['delete'][] = $q_id; |
|
| 756 | + } |
|
| 736 | 757 | continue; |
| 737 | 758 | } |
| 738 | 759 | // Now get them and check that they might be viable. |
| 739 | 760 | $answers = array(); |
| 740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
| 741 | - if (!empty($answer) && trim($answer) !== '') |
|
| 761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
| 762 | + if (!empty($answer) && trim($answer) !== '') |
|
| 742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
| 764 | + } |
|
| 743 | 765 | if (empty($answers)) |
| 744 | 766 | { |
| 745 | - if (isset($context['question_answers'][$q_id])) |
|
| 746 | - $changes['delete'][] = $q_id; |
|
| 767 | + if (isset($context['question_answers'][$q_id])) { |
|
| 768 | + $changes['delete'][] = $q_id; |
|
| 769 | + } |
|
| 747 | 770 | continue; |
| 748 | 771 | } |
| 749 | 772 | $answers = $smcFunc['json_encode']($answers); |
@@ -753,16 +776,17 @@ discard block |
||
| 753 | 776 | { |
| 754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
| 755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
| 756 | - } |
|
| 757 | - else |
|
| 779 | + } else |
|
| 758 | 780 | { |
| 759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
| 760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
| 761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
| 783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 784 | + } |
|
| 762 | 785 | } |
| 763 | 786 | |
| 764 | - if (!isset($qs_per_lang[$lang_id])) |
|
| 765 | - $qs_per_lang[$lang_id] = 0; |
|
| 787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
| 788 | + $qs_per_lang[$lang_id] = 0; |
|
| 789 | + } |
|
| 766 | 790 | $qs_per_lang[$lang_id]++; |
| 767 | 791 | } |
| 768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
| 812 | 836 | |
| 813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
| 814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
| 815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
| 816 | - $_POST['qa_verification_number'] = $count_questions; |
|
| 839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
| 840 | + $_POST['qa_verification_number'] = $count_questions; |
|
| 841 | + } |
|
| 817 | 842 | |
| 818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
| 819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
| 828 | 853 | |
| 829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
| 830 | 855 | $_SESSION['visual_verification_code'] = ''; |
| 831 | - for ($i = 0; $i < 6; $i++) |
|
| 832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 856 | + for ($i = 0; $i < 6; $i++) { |
|
| 857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 858 | + } |
|
| 833 | 859 | |
| 834 | 860 | // Some javascript for CAPTCHA. |
| 835 | 861 | $context['settings_post_javascript'] = ''; |
| 836 | - if ($context['use_graphic_library']) |
|
| 837 | - $context['settings_post_javascript'] .= ' |
|
| 862 | + if ($context['use_graphic_library']) { |
|
| 863 | + $context['settings_post_javascript'] .= ' |
|
| 838 | 864 | function refreshImages() |
| 839 | 865 | { |
| 840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
| 841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
| 842 | 868 | }'; |
| 869 | + } |
|
| 843 | 870 | |
| 844 | 871 | // Show the image itself, or text saying we can't. |
| 845 | - if ($context['use_graphic_library']) |
|
| 846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 847 | - else |
|
| 848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 872 | + if ($context['use_graphic_library']) { |
|
| 873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 874 | + } else { |
|
| 875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 876 | + } |
|
| 849 | 877 | |
| 850 | 878 | // Hack for PM spam settings. |
| 851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
| 855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
| 856 | 884 | |
| 857 | 885 | // Some minor javascript for the guest post setting. |
| 858 | - if ($modSettings['posts_require_captcha']) |
|
| 859 | - $context['settings_post_javascript'] .= ' |
|
| 886 | + if ($modSettings['posts_require_captcha']) { |
|
| 887 | + $context['settings_post_javascript'] .= ' |
|
| 860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
| 889 | + } |
|
| 861 | 890 | |
| 862 | 891 | // And everything else. |
| 863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
| 904 | 933 | |
| 905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
| 906 | 935 | |
| 907 | - if ($return_config) |
|
| 908 | - return $config_vars; |
|
| 936 | + if ($return_config) { |
|
| 937 | + return $config_vars; |
|
| 938 | + } |
|
| 909 | 939 | |
| 910 | 940 | // Setup the template. |
| 911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
| 960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
| 961 | 991 | |
| 962 | 992 | // Max characters... |
| 963 | - if (!empty($sig_limits[1])) |
|
| 964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 993 | + if (!empty($sig_limits[1])) { |
|
| 994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 995 | + } |
|
| 965 | 996 | // Max lines... |
| 966 | 997 | if (!empty($sig_limits[2])) |
| 967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
| 971 | 1002 | if ($sig[$i] == "\n") |
| 972 | 1003 | { |
| 973 | 1004 | $count++; |
| 974 | - if ($count >= $sig_limits[2]) |
|
| 975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 1005 | + if ($count >= $sig_limits[2]) { |
|
| 1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 1007 | + } |
|
| 976 | 1008 | } |
| 977 | 1009 | } |
| 978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
| 983 | 1015 | { |
| 984 | 1016 | $limit_broke = 0; |
| 985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
| 986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 993 | - $limit_broke = 'large'; |
|
| 994 | - |
|
| 995 | - if ($limit_broke) |
|
| 996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 1025 | + $limit_broke = 'large'; |
|
| 1026 | + } |
|
| 1027 | + |
|
| 1028 | + if ($limit_broke) { |
|
| 1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1030 | + } |
|
| 997 | 1031 | } |
| 998 | 1032 | } |
| 999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
| 1049 | 1083 | $img_offset = false; |
| 1050 | 1084 | } |
| 1051 | 1085 | } |
| 1086 | + } else { |
|
| 1087 | + $replaces[$image] = ''; |
|
| 1052 | 1088 | } |
| 1053 | - else |
|
| 1054 | - $replaces[$image] = ''; |
|
| 1055 | 1089 | |
| 1056 | 1090 | continue; |
| 1057 | 1091 | } |
| 1058 | 1092 | |
| 1059 | 1093 | // Does it have predefined restraints? Width first. |
| 1060 | - if ($matches[6][$key]) |
|
| 1061 | - $matches[2][$key] = $matches[6][$key]; |
|
| 1094 | + if ($matches[6][$key]) { |
|
| 1095 | + $matches[2][$key] = $matches[6][$key]; |
|
| 1096 | + } |
|
| 1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 1063 | 1098 | { |
| 1064 | 1099 | $width = $sig_limits[5]; |
| 1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 1101 | + } elseif ($matches[2][$key]) { |
|
| 1102 | + $width = $matches[2][$key]; |
|
| 1066 | 1103 | } |
| 1067 | - elseif ($matches[2][$key]) |
|
| 1068 | - $width = $matches[2][$key]; |
|
| 1069 | 1104 | // ... and height. |
| 1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 1071 | 1106 | { |
| 1072 | 1107 | $height = $sig_limits[6]; |
| 1073 | - if ($width != -1) |
|
| 1074 | - $width = $width * ($height / $matches[4][$key]); |
|
| 1108 | + if ($width != -1) { |
|
| 1109 | + $width = $width * ($height / $matches[4][$key]); |
|
| 1110 | + } |
|
| 1111 | + } elseif ($matches[4][$key]) { |
|
| 1112 | + $height = $matches[4][$key]; |
|
| 1075 | 1113 | } |
| 1076 | - elseif ($matches[4][$key]) |
|
| 1077 | - $height = $matches[4][$key]; |
|
| 1078 | 1114 | |
| 1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
| 1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
| 1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 1093 | 1129 | { |
| 1094 | 1130 | $height = $sig_limits[6]; |
| 1095 | - if ($width == -1) |
|
| 1096 | - $width = $sizes[0]; |
|
| 1131 | + if ($width == -1) { |
|
| 1132 | + $width = $sizes[0]; |
|
| 1133 | + } |
|
| 1097 | 1134 | $width = $width * ($height / $sizes[1]); |
| 1135 | + } elseif ($width != -1) { |
|
| 1136 | + $height = $sizes[1]; |
|
| 1098 | 1137 | } |
| 1099 | - elseif ($width != -1) |
|
| 1100 | - $height = $sizes[1]; |
|
| 1101 | 1138 | } |
| 1102 | 1139 | } |
| 1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
| 1110 | 1147 | // Record that we got one. |
| 1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
| 1112 | 1149 | } |
| 1113 | - if (!empty($replaces)) |
|
| 1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1150 | + if (!empty($replaces)) { |
|
| 1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1152 | + } |
|
| 1115 | 1153 | } |
| 1116 | 1154 | } |
| 1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
| 1123 | 1161 | |
| 1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
| 1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
| 1126 | - if ($sig != $row['signature']) |
|
| 1127 | - $changes[$row['id_member']] = $sig; |
|
| 1164 | + if ($sig != $row['signature']) { |
|
| 1165 | + $changes[$row['id_member']] = $sig; |
|
| 1166 | + } |
|
| 1167 | + } |
|
| 1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1169 | + $done = true; |
|
| 1128 | 1170 | } |
| 1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1130 | - $done = true; |
|
| 1131 | 1171 | $smcFunc['db_free_result']($request); |
| 1132 | 1172 | |
| 1133 | 1173 | // Do we need to delete what we have? |
| 1134 | 1174 | if (!empty($changes)) |
| 1135 | 1175 | { |
| 1136 | - foreach ($changes as $id => $sig) |
|
| 1137 | - $smcFunc['db_query']('', ' |
|
| 1176 | + foreach ($changes as $id => $sig) { |
|
| 1177 | + $smcFunc['db_query']('', ' |
|
| 1138 | 1178 | UPDATE {db_prefix}members |
| 1139 | 1179 | SET signature = {string:signature} |
| 1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
| 1143 | 1183 | 'signature' => $sig, |
| 1144 | 1184 | ) |
| 1145 | 1185 | ); |
| 1186 | + } |
|
| 1146 | 1187 | } |
| 1147 | 1188 | |
| 1148 | 1189 | $_GET['step'] += 50; |
| 1149 | - if (!$done) |
|
| 1150 | - pauseSignatureApplySettings(); |
|
| 1190 | + if (!$done) { |
|
| 1191 | + pauseSignatureApplySettings(); |
|
| 1192 | + } |
|
| 1151 | 1193 | } |
| 1152 | 1194 | $settings_applied = true; |
| 1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
| 1165 | 1207 | ); |
| 1166 | 1208 | |
| 1167 | 1209 | // Temporarily make each setting a modSetting! |
| 1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
| 1169 | - $modSettings['signature_' . $key] = $value; |
|
| 1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
| 1211 | + $modSettings['signature_' . $key] = $value; |
|
| 1212 | + } |
|
| 1170 | 1213 | |
| 1171 | 1214 | // Make sure we check the right tags! |
| 1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
| 1178 | 1221 | |
| 1179 | 1222 | // Clean up the tag stuff! |
| 1180 | 1223 | $bbcTags = array(); |
| 1181 | - foreach (parse_bbc(false) as $tag) |
|
| 1182 | - $bbcTags[] = $tag['tag']; |
|
| 1224 | + foreach (parse_bbc(false) as $tag) { |
|
| 1225 | + $bbcTags[] = $tag['tag']; |
|
| 1226 | + } |
|
| 1183 | 1227 | |
| 1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
| 1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
| 1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
| 1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
| 1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1232 | + } |
|
| 1188 | 1233 | |
| 1189 | 1234 | $sig_limits = array(); |
| 1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
| 1191 | 1236 | { |
| 1192 | - if ($key == 'allow_smileys') |
|
| 1193 | - continue; |
|
| 1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
| 1195 | - $sig_limits[] = -1; |
|
| 1196 | - else |
|
| 1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1237 | + if ($key == 'allow_smileys') { |
|
| 1238 | + continue; |
|
| 1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
| 1240 | + $sig_limits[] = -1; |
|
| 1241 | + } else { |
|
| 1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1243 | + } |
|
| 1198 | 1244 | } |
| 1199 | 1245 | |
| 1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
| 1227 | 1273 | |
| 1228 | 1274 | // Try get more time... |
| 1229 | 1275 | @set_time_limit(600); |
| 1230 | - if (function_exists('apache_reset_timeout')) |
|
| 1231 | - @apache_reset_timeout(); |
|
| 1276 | + if (function_exists('apache_reset_timeout')) { |
|
| 1277 | + @apache_reset_timeout(); |
|
| 1278 | + } |
|
| 1232 | 1279 | |
| 1233 | 1280 | // Have we exhausted all the time we allowed? |
| 1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
| 1235 | - return; |
|
| 1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
| 1282 | + return; |
|
| 1283 | + } |
|
| 1236 | 1284 | |
| 1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
| 1278 | 1326 | $disable_fields = array_flip($standard_fields); |
| 1279 | 1327 | if (!empty($_POST['active'])) |
| 1280 | 1328 | { |
| 1281 | - foreach ($_POST['active'] as $value) |
|
| 1282 | - if (isset($disable_fields[$value])) |
|
| 1329 | + foreach ($_POST['active'] as $value) { |
|
| 1330 | + if (isset($disable_fields[$value])) |
|
| 1283 | 1331 | unset($disable_fields[$value]); |
| 1332 | + } |
|
| 1284 | 1333 | } |
| 1285 | 1334 | // What we have left! |
| 1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
| 1289 | 1338 | $reg_fields = array(); |
| 1290 | 1339 | if (!empty($_POST['reg'])) |
| 1291 | 1340 | { |
| 1292 | - foreach ($_POST['reg'] as $value) |
|
| 1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1341 | + foreach ($_POST['reg'] as $value) { |
|
| 1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1294 | 1343 | $reg_fields[] = $value; |
| 1344 | + } |
|
| 1295 | 1345 | } |
| 1296 | 1346 | // What we have left! |
| 1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
| 1298 | 1348 | |
| 1299 | 1349 | $_SESSION['adm-save'] = true; |
| 1300 | - if (!empty($changes)) |
|
| 1301 | - updateSettings($changes); |
|
| 1350 | + if (!empty($changes)) { |
|
| 1351 | + updateSettings($changes); |
|
| 1352 | + } |
|
| 1302 | 1353 | } |
| 1303 | 1354 | |
| 1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
| 1401 | 1452 | { |
| 1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
| 1403 | 1454 | |
| 1404 | - if ($rowData['field_order'] > 1) |
|
| 1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1455 | + if ($rowData['field_order'] > 1) { |
|
| 1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1457 | + } |
|
| 1406 | 1458 | |
| 1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
| 1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
| 1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1461 | + } |
|
| 1409 | 1462 | |
| 1410 | 1463 | $return .= '</p>'; |
| 1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
| 1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
| 1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
| 1545 | 1598 | |
| 1546 | - foreach ($standard_fields as $field) |
|
| 1547 | - $list[] = array( |
|
| 1599 | + foreach ($standard_fields as $field) { |
|
| 1600 | + $list[] = array( |
|
| 1548 | 1601 | 'id' => $field, |
| 1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
| 1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
| 1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
| 1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
| 1553 | 1606 | ); |
| 1554 | - } |
|
| 1555 | - else |
|
| 1607 | + } |
|
| 1608 | + } else |
|
| 1556 | 1609 | { |
| 1557 | 1610 | // Load all the fields. |
| 1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
| 1566 | 1619 | 'items_per_page' => $items_per_page, |
| 1567 | 1620 | ) |
| 1568 | 1621 | ); |
| 1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1570 | - $list[] = $row; |
|
| 1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1623 | + $list[] = $row; |
|
| 1624 | + } |
|
| 1571 | 1625 | $smcFunc['db_free_result']($request); |
| 1572 | 1626 | } |
| 1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
| 1633 | 1687 | $context['field'] = array(); |
| 1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1635 | 1689 | { |
| 1636 | - if ($row['field_type'] == 'textarea') |
|
| 1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1638 | - else |
|
| 1690 | + if ($row['field_type'] == 'textarea') { |
|
| 1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1692 | + } else |
|
| 1639 | 1693 | { |
| 1640 | 1694 | $rows = 3; |
| 1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
| 1671 | 1725 | } |
| 1672 | 1726 | |
| 1673 | 1727 | // Setup the default values as needed. |
| 1674 | - if (empty($context['field'])) |
|
| 1675 | - $context['field'] = array( |
|
| 1728 | + if (empty($context['field'])) { |
|
| 1729 | + $context['field'] = array( |
|
| 1676 | 1730 | 'name' => '', |
| 1677 | 1731 | 'col_name' => '???', |
| 1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
| 1697 | 1751 | 'enclose' => '', |
| 1698 | 1752 | 'placement' => 0, |
| 1699 | 1753 | ); |
| 1754 | + } |
|
| 1700 | 1755 | |
| 1701 | 1756 | // Are we moving it? |
| 1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
| 1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
| 1706 | 1761 | |
| 1707 | 1762 | // Is this a valid position? |
| 1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
| 1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
| 1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
| 1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
| 1765 | + } |
|
| 1766 | + // @todo implement an error handler |
|
| 1710 | 1767 | |
| 1711 | 1768 | // All good, proceed. |
| 1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
| 1737 | 1794 | validateToken('admin-ecp'); |
| 1738 | 1795 | |
| 1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
| 1740 | - if (trim($_POST['field_name']) == '') |
|
| 1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1797 | + if (trim($_POST['field_name']) == '') { |
|
| 1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1799 | + } |
|
| 1742 | 1800 | |
| 1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
| 1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
| 1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
| 1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1804 | + } |
|
| 1746 | 1805 | |
| 1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
| 1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
| 1759 | 1818 | |
| 1760 | 1819 | // Some masking stuff... |
| 1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
| 1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
| 1763 | - $mask .= $_POST['regex']; |
|
| 1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
| 1822 | + $mask .= $_POST['regex']; |
|
| 1823 | + } |
|
| 1764 | 1824 | |
| 1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
| 1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
| 1779 | 1839 | $v = strtr($v, array(',' => '')); |
| 1780 | 1840 | |
| 1781 | 1841 | // Nada, zip, etc... |
| 1782 | - if (trim($v) == '') |
|
| 1783 | - continue; |
|
| 1842 | + if (trim($v) == '') { |
|
| 1843 | + continue; |
|
| 1844 | + } |
|
| 1784 | 1845 | |
| 1785 | 1846 | // Otherwise, save it boy. |
| 1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
| 1788 | 1849 | $newOptions[$k] = $v; |
| 1789 | 1850 | |
| 1790 | 1851 | // Is it default? |
| 1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
| 1792 | - $default = $v; |
|
| 1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
| 1853 | + $default = $v; |
|
| 1854 | + } |
|
| 1793 | 1855 | } |
| 1794 | 1856 | $field_options = substr($field_options, 0, -1); |
| 1795 | 1857 | } |
| 1796 | 1858 | |
| 1797 | 1859 | // Text area has default has dimensions |
| 1798 | - if ($_POST['field_type'] == 'textarea') |
|
| 1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1860 | + if ($_POST['field_type'] == 'textarea') { |
|
| 1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1862 | + } |
|
| 1800 | 1863 | |
| 1801 | 1864 | // Come up with the unique name? |
| 1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
| 1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
| 1806 | 1869 | |
| 1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
| 1808 | - if (isset($matches[1])) |
|
| 1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1810 | - else |
|
| 1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1871 | + if (isset($matches[1])) { |
|
| 1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1873 | + } else { |
|
| 1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1875 | + } |
|
| 1812 | 1876 | |
| 1813 | 1877 | // Make sure this is unique. |
| 1814 | 1878 | $current_fields = array(); |
| 1815 | 1879 | $request = $smcFunc['db_query']('', ' |
| 1816 | 1880 | SELECT id_field, col_name |
| 1817 | 1881 | FROM {db_prefix}custom_fields'); |
| 1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1884 | + } |
|
| 1820 | 1885 | $smcFunc['db_free_result']($request); |
| 1821 | 1886 | |
| 1822 | 1887 | $unique = false; |
| 1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
| 1824 | 1889 | { |
| 1825 | - if (!in_array($col_name, $current_fields)) |
|
| 1826 | - $unique = true; |
|
| 1827 | - else |
|
| 1828 | - $col_name = $initial_col_name . $i; |
|
| 1890 | + if (!in_array($col_name, $current_fields)) { |
|
| 1891 | + $unique = true; |
|
| 1892 | + } else { |
|
| 1893 | + $col_name = $initial_col_name . $i; |
|
| 1894 | + } |
|
| 1829 | 1895 | } |
| 1830 | 1896 | |
| 1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
| 1832 | - if (!$unique) |
|
| 1833 | - fatal_lang_error('custom_option_not_unique'); |
|
| 1898 | + if (!$unique) { |
|
| 1899 | + fatal_lang_error('custom_option_not_unique'); |
|
| 1900 | + } |
|
| 1834 | 1901 | } |
| 1835 | 1902 | // Work out what to do with the user data otherwise... |
| 1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
| 1858 | 1925 | // Work out what's changed! |
| 1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
| 1860 | 1927 | { |
| 1861 | - if (trim($option) == '') |
|
| 1862 | - continue; |
|
| 1928 | + if (trim($option) == '') { |
|
| 1929 | + continue; |
|
| 1930 | + } |
|
| 1863 | 1931 | |
| 1864 | 1932 | // Still exists? |
| 1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
| 1873 | 1941 | foreach ($optionChanges as $k => $option) |
| 1874 | 1942 | { |
| 1875 | 1943 | // Just been renamed? |
| 1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
| 1877 | - $smcFunc['db_query']('', ' |
|
| 1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
| 1945 | + $smcFunc['db_query']('', ' |
|
| 1878 | 1946 | UPDATE {db_prefix}themes |
| 1879 | 1947 | SET value = {string:new_value} |
| 1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
| 1887 | 1955 | 'old_value' => $option, |
| 1888 | 1956 | ) |
| 1889 | 1957 | ); |
| 1958 | + } |
|
| 1890 | 1959 | } |
| 1891 | 1960 | } |
| 1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
| 1929 | 1998 | ); |
| 1930 | 1999 | |
| 1931 | 2000 | // Just clean up any old selects - these are a pain! |
| 1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
| 1933 | - $smcFunc['db_query']('', ' |
|
| 2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
| 2002 | + $smcFunc['db_query']('', ' |
|
| 1934 | 2003 | DELETE FROM {db_prefix}themes |
| 1935 | 2004 | WHERE variable = {string:current_column} |
| 1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
| 1941 | 2010 | 'current_column' => $context['field']['col_name'], |
| 1942 | 2011 | ) |
| 1943 | 2012 | ); |
| 1944 | - } |
|
| 1945 | - else |
|
| 2013 | + } |
|
| 2014 | + } else |
|
| 1946 | 2015 | { |
| 1947 | 2016 | // Gotta figure it out the order. |
| 1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
| 2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
| 2117 | 2186 | |
| 2118 | 2187 | $prune_toggle_dt = array(); |
| 2119 | - foreach ($prune_toggle as $item) |
|
| 2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2188 | + foreach ($prune_toggle as $item) { |
|
| 2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2190 | + } |
|
| 2121 | 2191 | |
| 2122 | - if ($return_config) |
|
| 2123 | - return $config_vars; |
|
| 2192 | + if ($return_config) { |
|
| 2193 | + return $config_vars; |
|
| 2194 | + } |
|
| 2124 | 2195 | |
| 2125 | 2196 | addInlineJavaScript(' |
| 2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
| 2158 | 2229 | $vals = array(); |
| 2159 | 2230 | foreach ($config_vars as $index => $dummy) |
| 2160 | 2231 | { |
| 2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
| 2162 | - continue; |
|
| 2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
| 2233 | + continue; |
|
| 2234 | + } |
|
| 2163 | 2235 | |
| 2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
| 2165 | 2237 | } |
| 2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
| 2239 | + } else { |
|
| 2240 | + $_POST['pruningOptions'] = ''; |
|
| 2167 | 2241 | } |
| 2168 | - else |
|
| 2169 | - $_POST['pruningOptions'] = ''; |
|
| 2170 | 2242 | |
| 2171 | 2243 | saveDBSettings($savevar); |
| 2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
| 2178 | 2250 | $context['sub_template'] = 'show_settings'; |
| 2179 | 2251 | |
| 2180 | 2252 | // Get the actual values |
| 2181 | - if (!empty($modSettings['pruningOptions'])) |
|
| 2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2183 | - else |
|
| 2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
| 2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2255 | + } else { |
|
| 2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2257 | + } |
|
| 2185 | 2258 | |
| 2186 | 2259 | prepareDBSettingContext($config_vars); |
| 2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
| 2203 | 2276 | // Make it even easier to add new settings. |
| 2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
| 2205 | 2278 | |
| 2206 | - if ($return_config) |
|
| 2207 | - return $config_vars; |
|
| 2279 | + if ($return_config) { |
|
| 2280 | + return $config_vars; |
|
| 2281 | + } |
|
| 2208 | 2282 | |
| 2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
| 2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -891,13 +891,13 @@ |
||
| 891 | 891 | if ($start_char === 'C') |
| 892 | 892 | $limit_seek = $limit; |
| 893 | 893 | else |
| 894 | - $limit_seek = $limit + 1; |
|
| 894 | + $limit_seek = $limit + 1; |
|
| 895 | 895 | |
| 896 | 896 | $request = $smcFunc['db_query']('', ' |
| 897 | 897 | SELECT id_msg, id_member, approved |
| 898 | 898 | FROM {db_prefix}messages |
| 899 | 899 | WHERE id_topic = {int:current_topic} |
| 900 | - AND id_msg '. $page_operator . ' {int:page_id}'. (!$modSettings['postmod_active'] || $approve_posts ? '' : ' |
|
| 900 | + AND id_msg '. $page_operator . ' {int:page_id}' . (!$modSettings['postmod_active'] || $approve_posts ? '' : ' |
|
| 901 | 901 | AND (approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR id_member = {int:current_member}') . ')') . ' |
| 902 | 902 | ORDER BY id_msg ' . ($ascending ? '' : 'DESC') . ($context['messages_per_page'] == -1 ? '' : ' |
| 903 | 903 | LIMIT {int:limit}'), |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | global $messages_request, $language, $smcFunc; |
| 35 | 36 | |
| 36 | 37 | // What are you gonna display if these are empty?! |
| 37 | - if (empty($topic)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($topic)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // Load the proper template. |
| 41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
| 52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 53 | 55 | |
| 54 | 56 | // Let's do some work on what to search index. |
| 55 | - if (count($_GET) > 2) |
|
| 56 | - foreach ($_GET as $k => $v) |
|
| 57 | + if (count($_GET) > 2) { |
|
| 58 | + foreach ($_GET as $k => $v) |
|
| 57 | 59 | { |
| 58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
| 59 | 61 | $context['robot_no_index'] = true; |
| 62 | + } |
|
| 60 | 63 | } |
| 61 | 64 | |
| 62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 63 | - $context['robot_no_index'] = true; |
|
| 65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 66 | + $context['robot_no_index'] = true; |
|
| 67 | + } |
|
| 64 | 68 | |
| 65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
| 66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
| 172 | 176 | $topic_parameters |
| 173 | 177 | ); |
| 174 | 178 | |
| 175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 176 | - fatal_lang_error('not_a_topic', false, 404); |
|
| 179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 180 | + fatal_lang_error('not_a_topic', false, 404); |
|
| 181 | + } |
|
| 177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
| 178 | 183 | $smcFunc['db_free_result']($request); |
| 179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
| 210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
| 211 | 216 | |
| 212 | 217 | // Add up unapproved replies to get real number of replies... |
| 213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
| 214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
| 219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 220 | + } |
|
| 215 | 221 | |
| 216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
| 217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
| 231 | 237 | $smcFunc['db_free_result']($request); |
| 232 | 238 | |
| 233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
| 240 | + } elseif ($user_info['is_guest']) { |
|
| 241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 242 | + } else { |
|
| 243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 234 | 244 | } |
| 235 | - elseif ($user_info['is_guest']) |
|
| 236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 237 | - else |
|
| 238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 239 | 245 | |
| 240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
| 241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
| 248 | 254 | { |
| 249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
| 250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
| 251 | - } |
|
| 252 | - else |
|
| 257 | + } else |
|
| 253 | 258 | { |
| 254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
| 255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
| 277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
| 278 | 283 | { |
| 279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
| 280 | - if ($timestamp === 0) |
|
| 281 | - $_REQUEST['start'] = 0; |
|
| 282 | - else |
|
| 285 | + if ($timestamp === 0) { |
|
| 286 | + $_REQUEST['start'] = 0; |
|
| 287 | + } else |
|
| 283 | 288 | { |
| 284 | 289 | // Find the number of messages posted before said time... |
| 285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
| 307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
| 308 | 313 | { |
| 309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
| 310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
| 311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
| 313 | - $context['start_from'] = 0; |
|
| 314 | - else |
|
| 315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
| 318 | + $context['start_from'] = 0; |
|
| 319 | + } else |
|
| 315 | 320 | { |
| 316 | 321 | // Find the start value for that message...... |
| 317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
| 394 | 399 | ); |
| 395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 396 | 401 | { |
| 397 | - if (empty($row['id_member'])) |
|
| 398 | - continue; |
|
| 402 | + if (empty($row['id_member'])) { |
|
| 403 | + continue; |
|
| 404 | + } |
|
| 399 | 405 | |
| 400 | - if (!empty($row['online_color'])) |
|
| 401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 402 | - else |
|
| 403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 406 | + if (!empty($row['online_color'])) { |
|
| 407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 408 | + } else { |
|
| 409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 410 | + } |
|
| 404 | 411 | |
| 405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 406 | - if ($is_buddy) |
|
| 407 | - $link = '<strong>' . $link . '</strong>'; |
|
| 413 | + if ($is_buddy) { |
|
| 414 | + $link = '<strong>' . $link . '</strong>'; |
|
| 415 | + } |
|
| 408 | 416 | |
| 409 | 417 | // Add them both to the list and to the more detailed list. |
| 410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 420 | + } |
|
| 412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 413 | 422 | 'id' => $row['id_member'], |
| 414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
| 420 | 429 | 'hidden' => empty($row['show_online']), |
| 421 | 430 | ); |
| 422 | 431 | |
| 423 | - if (empty($row['show_online'])) |
|
| 424 | - $context['view_num_hidden']++; |
|
| 432 | + if (empty($row['show_online'])) { |
|
| 433 | + $context['view_num_hidden']++; |
|
| 434 | + } |
|
| 425 | 435 | } |
| 426 | 436 | |
| 427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
| 435 | 445 | |
| 436 | 446 | // If all is set, but not allowed... just unset it. |
| 437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
| 438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
| 439 | - unset($_REQUEST['all']); |
|
| 448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
| 449 | + unset($_REQUEST['all']); |
|
| 450 | + } |
|
| 440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
| 441 | - elseif (isset($_REQUEST['all'])) |
|
| 442 | - $_REQUEST['start'] = -1; |
|
| 452 | + elseif (isset($_REQUEST['all'])) { |
|
| 453 | + $_REQUEST['start'] = -1; |
|
| 454 | + } |
|
| 443 | 455 | |
| 444 | 456 | // Construct the page index, allowing for the .START method... |
| 445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
| 476 | 488 | $_REQUEST['start'] = 0; |
| 477 | 489 | } |
| 478 | 490 | // They aren't using it, but the *option* is there, at least. |
| 479 | - else |
|
| 480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 491 | + else { |
|
| 492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 493 | + } |
|
| 481 | 494 | } |
| 482 | 495 | |
| 483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
| 493 | 506 | if (!empty($board_info['moderators'])) |
| 494 | 507 | { |
| 495 | 508 | // Add a link for each moderator... |
| 496 | - foreach ($board_info['moderators'] as $mod) |
|
| 497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 509 | + foreach ($board_info['moderators'] as $mod) { |
|
| 510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 511 | + } |
|
| 498 | 512 | } |
| 499 | 513 | if (!empty($board_info['moderator_groups'])) |
| 500 | 514 | { |
| 501 | 515 | // Add a link for each moderator group as well... |
| 502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 518 | + } |
|
| 504 | 519 | } |
| 505 | 520 | |
| 506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
| 531 | 546 | // For quick reply we need a response prefix in the default forum language. |
| 532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
| 533 | 548 | { |
| 534 | - if ($language === $user_info['language']) |
|
| 535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 536 | - else |
|
| 549 | + if ($language === $user_info['language']) { |
|
| 550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 551 | + } else |
|
| 537 | 552 | { |
| 538 | 553 | loadLanguage('index', $language, false); |
| 539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -565,8 +580,9 @@ discard block |
||
| 565 | 580 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 566 | 581 | |
| 567 | 582 | // Sanity check |
| 568 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 569 | - continue; |
|
| 583 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 584 | + continue; |
|
| 585 | + } |
|
| 570 | 586 | |
| 571 | 587 | $linked_calendar_event = array( |
| 572 | 588 | 'id' => $row['id_event'], |
@@ -615,8 +631,9 @@ discard block |
||
| 615 | 631 | } |
| 616 | 632 | $smcFunc['db_free_result']($request); |
| 617 | 633 | |
| 618 | - if (!empty($context['linked_calendar_events'])) |
|
| 619 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 634 | + if (!empty($context['linked_calendar_events'])) { |
|
| 635 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 636 | + } |
|
| 620 | 637 | } |
| 621 | 638 | |
| 622 | 639 | // Create the poll info if it exists. |
@@ -679,8 +696,9 @@ discard block |
||
| 679 | 696 | $smcFunc['db_free_result']($request); |
| 680 | 697 | |
| 681 | 698 | // Got we multi choice? |
| 682 | - if ($pollinfo['max_votes'] > 1) |
|
| 683 | - $realtotal = $pollinfo['total']; |
|
| 699 | + if ($pollinfo['max_votes'] > 1) { |
|
| 700 | + $realtotal = $pollinfo['total']; |
|
| 701 | + } |
|
| 684 | 702 | |
| 685 | 703 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
| 686 | 704 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -693,20 +711,21 @@ discard block |
||
| 693 | 711 | foreach ($guestinfo as $i => $guestvoted) |
| 694 | 712 | { |
| 695 | 713 | $guestvoted = explode(',', $guestvoted); |
| 696 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
| 697 | - break; |
|
| 714 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
| 715 | + break; |
|
| 716 | + } |
|
| 698 | 717 | } |
| 699 | 718 | // Has the poll been reset since guest voted? |
| 700 | 719 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 701 | 720 | { |
| 702 | 721 | // Remove the poll info from the cookie to allow guest to vote again |
| 703 | 722 | unset($guestinfo[$i]); |
| 704 | - if (!empty($guestinfo)) |
|
| 705 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 706 | - else |
|
| 707 | - unset($_COOKIE['guest_poll_vote']); |
|
| 708 | - } |
|
| 709 | - else |
|
| 723 | + if (!empty($guestinfo)) { |
|
| 724 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 725 | + } else { |
|
| 726 | + unset($_COOKIE['guest_poll_vote']); |
|
| 727 | + } |
|
| 728 | + } else |
|
| 710 | 729 | { |
| 711 | 730 | // What did they vote for? |
| 712 | 731 | unset($guestvoted[0], $guestvoted[1]); |
@@ -820,23 +839,29 @@ discard block |
||
| 820 | 839 | // Build the poll moderation button array. |
| 821 | 840 | $context['poll_buttons'] = array(); |
| 822 | 841 | |
| 823 | - if ($context['allow_return_vote']) |
|
| 824 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 842 | + if ($context['allow_return_vote']) { |
|
| 843 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 844 | + } |
|
| 825 | 845 | |
| 826 | - if ($context['show_view_results_button']) |
|
| 827 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 846 | + if ($context['show_view_results_button']) { |
|
| 847 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 848 | + } |
|
| 828 | 849 | |
| 829 | - if ($context['allow_change_vote']) |
|
| 830 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 850 | + if ($context['allow_change_vote']) { |
|
| 851 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 852 | + } |
|
| 831 | 853 | |
| 832 | - if ($context['allow_lock_poll']) |
|
| 833 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 854 | + if ($context['allow_lock_poll']) { |
|
| 855 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 856 | + } |
|
| 834 | 857 | |
| 835 | - if ($context['allow_edit_poll']) |
|
| 836 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 858 | + if ($context['allow_edit_poll']) { |
|
| 859 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 860 | + } |
|
| 837 | 861 | |
| 838 | - if ($context['can_remove_poll']) |
|
| 839 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 862 | + if ($context['can_remove_poll']) { |
|
| 863 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 864 | + } |
|
| 840 | 865 | |
| 841 | 866 | // Allow mods to add additional buttons here |
| 842 | 867 | call_integration_hook('integrate_poll_buttons'); |
@@ -871,9 +896,9 @@ discard block |
||
| 871 | 896 | { |
| 872 | 897 | $start_char = 'C'; |
| 873 | 898 | $page_id = $context['topicinfo']['id_first_msg']; |
| 899 | + } else { |
|
| 900 | + $start_char = null; |
|
| 874 | 901 | } |
| 875 | - else |
|
| 876 | - $start_char = null; |
|
| 877 | 902 | |
| 878 | 903 | $limit = $context['messages_per_page']; |
| 879 | 904 | |
@@ -888,17 +913,17 @@ discard block |
||
| 888 | 913 | { |
| 889 | 914 | $ascending = true; |
| 890 | 915 | $page_operator = '>='; |
| 891 | - } |
|
| 892 | - else |
|
| 916 | + } else |
|
| 893 | 917 | { |
| 894 | 918 | $ascending = false; |
| 895 | 919 | $page_operator = '<='; |
| 896 | 920 | } |
| 897 | 921 | |
| 898 | - if ($start_char === 'C') |
|
| 899 | - $limit_seek = $limit; |
|
| 900 | - else |
|
| 901 | - $limit_seek = $limit + 1; |
|
| 922 | + if ($start_char === 'C') { |
|
| 923 | + $limit_seek = $limit; |
|
| 924 | + } else { |
|
| 925 | + $limit_seek = $limit + 1; |
|
| 926 | + } |
|
| 902 | 927 | |
| 903 | 928 | $request = $smcFunc['db_query']('', ' |
| 904 | 929 | SELECT id_msg, id_member, approved |
@@ -921,21 +946,23 @@ discard block |
||
| 921 | 946 | $found_msg = false; |
| 922 | 947 | |
| 923 | 948 | // Fallback |
| 924 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
| 925 | - unset($start_char); |
|
| 926 | - else |
|
| 949 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
| 950 | + unset($start_char); |
|
| 951 | + } else |
|
| 927 | 952 | { |
| 928 | 953 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 929 | 954 | { |
| 930 | 955 | // Check if the start msg is in our result |
| 931 | - if ($row['id_msg'] == $page_id) |
|
| 932 | - $found_msg = true; |
|
| 956 | + if ($row['id_msg'] == $page_id) { |
|
| 957 | + $found_msg = true; |
|
| 958 | + } |
|
| 933 | 959 | |
| 934 | 960 | // Skip the the start msg if we not in mode C |
| 935 | 961 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
| 936 | 962 | { |
| 937 | - if (!empty($row['id_member'])) |
|
| 938 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 963 | + if (!empty($row['id_member'])) { |
|
| 964 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 965 | + } |
|
| 939 | 966 | |
| 940 | 967 | $messages[] = $row['id_msg']; |
| 941 | 968 | } |
@@ -951,8 +978,9 @@ discard block |
||
| 951 | 978 | } |
| 952 | 979 | |
| 953 | 980 | // Before Page bring in the right order |
| 954 | - if (!empty($start_char) && $start_char === 'L') |
|
| 955 | - krsort($messages); |
|
| 981 | + if (!empty($start_char) && $start_char === 'L') { |
|
| 982 | + krsort($messages); |
|
| 983 | + } |
|
| 956 | 984 | } |
| 957 | 985 | |
| 958 | 986 | // Jump to page |
@@ -989,14 +1017,16 @@ discard block |
||
| 989 | 1017 | |
| 990 | 1018 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 991 | 1019 | { |
| 992 | - if (!empty($row['id_member'])) |
|
| 993 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 1020 | + if (!empty($row['id_member'])) { |
|
| 1021 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 1022 | + } |
|
| 994 | 1023 | $messages[] = $row['id_msg']; |
| 995 | 1024 | } |
| 996 | 1025 | |
| 997 | 1026 | // Sort the messages into the correct display order |
| 998 | - if (!$ascending) |
|
| 999 | - sort($messages); |
|
| 1027 | + if (!$ascending) { |
|
| 1028 | + sort($messages); |
|
| 1029 | + } |
|
| 1000 | 1030 | } |
| 1001 | 1031 | |
| 1002 | 1032 | // Remember the paging data for next time |
@@ -1016,8 +1046,9 @@ discard block |
||
| 1016 | 1046 | if (!$user_info['is_guest'] && !empty($messages)) |
| 1017 | 1047 | { |
| 1018 | 1048 | $mark_at_msg = max($messages); |
| 1019 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
| 1020 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
| 1049 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 1050 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
| 1051 | + } |
|
| 1021 | 1052 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
| 1022 | 1053 | { |
| 1023 | 1054 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1049,8 +1080,9 @@ discard block |
||
| 1049 | 1080 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1050 | 1081 | { |
| 1051 | 1082 | // Find if this topic is marked for notification... |
| 1052 | - if (!empty($row['id_topic'])) |
|
| 1053 | - $context['is_marked_notify'] = true; |
|
| 1083 | + if (!empty($row['id_topic'])) { |
|
| 1084 | + $context['is_marked_notify'] = true; |
|
| 1085 | + } |
|
| 1054 | 1086 | |
| 1055 | 1087 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
| 1056 | 1088 | if (!empty($row['sent']) && $do_once) |
@@ -1072,8 +1104,9 @@ discard block |
||
| 1072 | 1104 | } |
| 1073 | 1105 | |
| 1074 | 1106 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
| 1075 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
| 1076 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1107 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
| 1108 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1109 | + } |
|
| 1077 | 1110 | // Mark board as seen if this is the only new topic. |
| 1078 | 1111 | elseif (isset($_REQUEST['topicseen'])) |
| 1079 | 1112 | { |
@@ -1097,14 +1130,16 @@ discard block |
||
| 1097 | 1130 | $smcFunc['db_free_result']($request); |
| 1098 | 1131 | |
| 1099 | 1132 | // If there're no real new topics in this board, mark the board as seen. |
| 1100 | - if (empty($numNewTopics)) |
|
| 1101 | - $_REQUEST['boardseen'] = true; |
|
| 1102 | - else |
|
| 1103 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1133 | + if (empty($numNewTopics)) { |
|
| 1134 | + $_REQUEST['boardseen'] = true; |
|
| 1135 | + } else { |
|
| 1136 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1137 | + } |
|
| 1104 | 1138 | } |
| 1105 | 1139 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
| 1106 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
| 1107 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1140 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 1141 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1142 | + } |
|
| 1108 | 1143 | |
| 1109 | 1144 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
| 1110 | 1145 | if (isset($_REQUEST['boardseen'])) |
@@ -1161,23 +1196,26 @@ discard block |
||
| 1161 | 1196 | $temp = array(); |
| 1162 | 1197 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1163 | 1198 | { |
| 1164 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
| 1165 | - continue; |
|
| 1199 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
| 1200 | + continue; |
|
| 1201 | + } |
|
| 1166 | 1202 | |
| 1167 | 1203 | $temp[$row['id_attach']] = $row; |
| 1168 | 1204 | $temp[$row['id_attach']]['topic'] = $topic; |
| 1169 | 1205 | $temp[$row['id_attach']]['board'] = $board; |
| 1170 | 1206 | |
| 1171 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
| 1172 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1207 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
| 1208 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1209 | + } |
|
| 1173 | 1210 | } |
| 1174 | 1211 | $smcFunc['db_free_result']($request); |
| 1175 | 1212 | |
| 1176 | 1213 | // This is better than sorting it with the query... |
| 1177 | 1214 | ksort($temp); |
| 1178 | 1215 | |
| 1179 | - foreach ($temp as $row) |
|
| 1180 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1216 | + foreach ($temp as $row) { |
|
| 1217 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1218 | + } |
|
| 1181 | 1219 | } |
| 1182 | 1220 | |
| 1183 | 1221 | $msg_parameters = array( |
@@ -1204,21 +1242,23 @@ discard block |
||
| 1204 | 1242 | ); |
| 1205 | 1243 | |
| 1206 | 1244 | // And the likes |
| 1207 | - if (!empty($modSettings['enable_likes'])) |
|
| 1208 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1245 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1246 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1247 | + } |
|
| 1209 | 1248 | |
| 1210 | 1249 | // Go to the last message if the given time is beyond the time of the last message. |
| 1211 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
| 1212 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1250 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
| 1251 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1252 | + } |
|
| 1213 | 1253 | |
| 1214 | 1254 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
| 1215 | 1255 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
| 1216 | - if (empty($options['view_newest_first'])) |
|
| 1217 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1218 | - else |
|
| 1219 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1220 | - } |
|
| 1221 | - else |
|
| 1256 | + if (empty($options['view_newest_first'])) { |
|
| 1257 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1258 | + } else { |
|
| 1259 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1260 | + } |
|
| 1261 | + } else |
|
| 1222 | 1262 | { |
| 1223 | 1263 | $messages_request = false; |
| 1224 | 1264 | $context['first_message'] = 0; |
@@ -1253,8 +1293,9 @@ discard block |
||
| 1253 | 1293 | 'can_restore_msg' => 'move_any', |
| 1254 | 1294 | 'can_like' => 'likes_like', |
| 1255 | 1295 | ); |
| 1256 | - foreach ($common_permissions as $contextual => $perm) |
|
| 1257 | - $context[$contextual] = allowedTo($perm); |
|
| 1296 | + foreach ($common_permissions as $contextual => $perm) { |
|
| 1297 | + $context[$contextual] = allowedTo($perm); |
|
| 1298 | + } |
|
| 1258 | 1299 | |
| 1259 | 1300 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
| 1260 | 1301 | $anyown_permissions = array( |
@@ -1267,8 +1308,9 @@ discard block |
||
| 1267 | 1308 | 'can_reply_unapproved' => 'post_unapproved_replies', |
| 1268 | 1309 | 'can_view_warning' => 'profile_warning', |
| 1269 | 1310 | ); |
| 1270 | - foreach ($anyown_permissions as $contextual => $perm) |
|
| 1271 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1311 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
| 1312 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1313 | + } |
|
| 1272 | 1314 | |
| 1273 | 1315 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
| 1274 | 1316 | { |
@@ -1314,8 +1356,9 @@ discard block |
||
| 1314 | 1356 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
| 1315 | 1357 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
| 1316 | 1358 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
| 1317 | - if (!empty($context['drafts_save'])) |
|
| 1318 | - loadLanguage('Drafts'); |
|
| 1359 | + if (!empty($context['drafts_save'])) { |
|
| 1360 | + loadLanguage('Drafts'); |
|
| 1361 | + } |
|
| 1319 | 1362 | |
| 1320 | 1363 | // When was the last time this topic was replied to? Should we warn them about it? |
| 1321 | 1364 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1376,26 +1419,31 @@ discard block |
||
| 1376 | 1419 | // Message icons - customized icons are off? |
| 1377 | 1420 | $context['icons'] = getMessageIcons($board); |
| 1378 | 1421 | |
| 1379 | - if (!empty($context['icons'])) |
|
| 1380 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1422 | + if (!empty($context['icons'])) { |
|
| 1423 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1424 | + } |
|
| 1381 | 1425 | |
| 1382 | 1426 | // Build the normal button array. |
| 1383 | 1427 | $context['normal_buttons'] = array(); |
| 1384 | 1428 | |
| 1385 | - if ($context['can_reply']) |
|
| 1386 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1429 | + if ($context['can_reply']) { |
|
| 1430 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1431 | + } |
|
| 1387 | 1432 | |
| 1388 | - if ($context['can_add_poll']) |
|
| 1389 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1433 | + if ($context['can_add_poll']) { |
|
| 1434 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1435 | + } |
|
| 1390 | 1436 | |
| 1391 | - if ($context['can_mark_unread']) |
|
| 1392 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1437 | + if ($context['can_mark_unread']) { |
|
| 1438 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1439 | + } |
|
| 1393 | 1440 | |
| 1394 | - if ($context['can_print']) |
|
| 1395 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1441 | + if ($context['can_print']) { |
|
| 1442 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1443 | + } |
|
| 1396 | 1444 | |
| 1397 | - if ($context['can_set_notify']) |
|
| 1398 | - $context['normal_buttons']['notify'] = array( |
|
| 1445 | + if ($context['can_set_notify']) { |
|
| 1446 | + $context['normal_buttons']['notify'] = array( |
|
| 1399 | 1447 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
| 1400 | 1448 | 'sub_buttons' => array( |
| 1401 | 1449 | array( |
@@ -1417,38 +1465,47 @@ discard block |
||
| 1417 | 1465 | ), |
| 1418 | 1466 | ), |
| 1419 | 1467 | ); |
| 1468 | + } |
|
| 1420 | 1469 | |
| 1421 | 1470 | // Build the mod button array |
| 1422 | 1471 | $context['mod_buttons'] = array(); |
| 1423 | 1472 | |
| 1424 | - if ($context['can_move']) |
|
| 1425 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1473 | + if ($context['can_move']) { |
|
| 1474 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1475 | + } |
|
| 1426 | 1476 | |
| 1427 | - if ($context['can_delete']) |
|
| 1428 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1477 | + if ($context['can_delete']) { |
|
| 1478 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1479 | + } |
|
| 1429 | 1480 | |
| 1430 | - if ($context['can_lock']) |
|
| 1431 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1481 | + if ($context['can_lock']) { |
|
| 1482 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1483 | + } |
|
| 1432 | 1484 | |
| 1433 | - if ($context['can_sticky']) |
|
| 1434 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1485 | + if ($context['can_sticky']) { |
|
| 1486 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1487 | + } |
|
| 1435 | 1488 | |
| 1436 | - if ($context['can_merge']) |
|
| 1437 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1489 | + if ($context['can_merge']) { |
|
| 1490 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1491 | + } |
|
| 1438 | 1492 | |
| 1439 | - if ($context['calendar_post']) |
|
| 1440 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1493 | + if ($context['calendar_post']) { |
|
| 1494 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1495 | + } |
|
| 1441 | 1496 | |
| 1442 | 1497 | // Restore topic. eh? No monkey business. |
| 1443 | - if ($context['can_restore_topic']) |
|
| 1444 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1498 | + if ($context['can_restore_topic']) { |
|
| 1499 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1500 | + } |
|
| 1445 | 1501 | |
| 1446 | 1502 | // Show a message in case a recently posted message became unapproved. |
| 1447 | 1503 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 1448 | 1504 | |
| 1449 | 1505 | // Don't want to show this forever... |
| 1450 | - if ($context['becomesUnapproved']) |
|
| 1451 | - unset($_SESSION['becomesUnapproved']); |
|
| 1506 | + if ($context['becomesUnapproved']) { |
|
| 1507 | + unset($_SESSION['becomesUnapproved']); |
|
| 1508 | + } |
|
| 1452 | 1509 | |
| 1453 | 1510 | // Allow adding new mod buttons easily. |
| 1454 | 1511 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1457,12 +1514,14 @@ discard block |
||
| 1457 | 1514 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
| 1458 | 1515 | |
| 1459 | 1516 | // Load the drafts js file |
| 1460 | - if ($context['drafts_autosave']) |
|
| 1461 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
| 1517 | + if ($context['drafts_autosave']) { |
|
| 1518 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
| 1519 | + } |
|
| 1462 | 1520 | |
| 1463 | 1521 | // Spellcheck |
| 1464 | - if ($context['show_spellchecking']) |
|
| 1465 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 1522 | + if ($context['show_spellchecking']) { |
|
| 1523 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 1524 | + } |
|
| 1466 | 1525 | |
| 1467 | 1526 | // topic.js |
| 1468 | 1527 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1496,16 +1555,19 @@ discard block |
||
| 1496 | 1555 | static $counter = null; |
| 1497 | 1556 | |
| 1498 | 1557 | // If the query returned false, bail. |
| 1499 | - if ($messages_request == false) |
|
| 1500 | - return false; |
|
| 1558 | + if ($messages_request == false) { |
|
| 1559 | + return false; |
|
| 1560 | + } |
|
| 1501 | 1561 | |
| 1502 | 1562 | // Remember which message this is. (ie. reply #83) |
| 1503 | - if ($counter === null || $reset) |
|
| 1504 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1563 | + if ($counter === null || $reset) { |
|
| 1564 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1565 | + } |
|
| 1505 | 1566 | |
| 1506 | 1567 | // Start from the beginning... |
| 1507 | - if ($reset) |
|
| 1508 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1568 | + if ($reset) { |
|
| 1569 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1570 | + } |
|
| 1509 | 1571 | |
| 1510 | 1572 | // Attempt to get the next message. |
| 1511 | 1573 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1519,19 +1581,21 @@ discard block |
||
| 1519 | 1581 | if (empty($context['icon_sources'])) |
| 1520 | 1582 | { |
| 1521 | 1583 | $context['icon_sources'] = array(); |
| 1522 | - foreach ($context['stable_icons'] as $icon) |
|
| 1523 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 1584 | + foreach ($context['stable_icons'] as $icon) { |
|
| 1585 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 1586 | + } |
|
| 1524 | 1587 | } |
| 1525 | 1588 | |
| 1526 | 1589 | // Message Icon Management... check the images exist. |
| 1527 | 1590 | if (empty($modSettings['messageIconChecks_disable'])) |
| 1528 | 1591 | { |
| 1529 | 1592 | // If the current icon isn't known, then we need to do something... |
| 1530 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1531 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1593 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1594 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1595 | + } |
|
| 1596 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1597 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1532 | 1598 | } |
| 1533 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
| 1534 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1535 | 1599 | |
| 1536 | 1600 | // If you're a lazy bum, you probably didn't give a subject... |
| 1537 | 1601 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1556,8 +1620,7 @@ discard block |
||
| 1556 | 1620 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
| 1557 | 1621 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
| 1558 | 1622 | $memberContext[$message['id_member']]['is_guest'] = true; |
| 1559 | - } |
|
| 1560 | - else |
|
| 1623 | + } else |
|
| 1561 | 1624 | { |
| 1562 | 1625 | // Define this here to make things a bit more readable |
| 1563 | 1626 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1580,8 +1643,9 @@ discard block |
||
| 1580 | 1643 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
| 1581 | 1644 | |
| 1582 | 1645 | // If it's in the recycle bin we need to override whatever icon we did have. |
| 1583 | - if (!empty($board_info['recycle'])) |
|
| 1584 | - $message['icon'] = 'recycled'; |
|
| 1646 | + if (!empty($board_info['recycle'])) { |
|
| 1647 | + $message['icon'] = 'recycled'; |
|
| 1648 | + } |
|
| 1585 | 1649 | |
| 1586 | 1650 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1587 | 1651 | |
@@ -1625,32 +1689,36 @@ discard block |
||
| 1625 | 1689 | } |
| 1626 | 1690 | |
| 1627 | 1691 | // Are likes enable? |
| 1628 | - if (!empty($modSettings['enable_likes'])) |
|
| 1629 | - $output['likes'] = array( |
|
| 1692 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1693 | + $output['likes'] = array( |
|
| 1630 | 1694 | 'count' => $message['likes'], |
| 1631 | 1695 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
| 1632 | 1696 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 1633 | 1697 | ); |
| 1698 | + } |
|
| 1634 | 1699 | |
| 1635 | 1700 | // Is this user the message author? |
| 1636 | 1701 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
| 1637 | - if (!empty($output['modified']['name'])) |
|
| 1638 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1702 | + if (!empty($output['modified']['name'])) { |
|
| 1703 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1704 | + } |
|
| 1639 | 1705 | |
| 1640 | 1706 | // Did they give a reason for editing? |
| 1641 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
| 1642 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1707 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
| 1708 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1709 | + } |
|
| 1643 | 1710 | |
| 1644 | 1711 | // Any custom profile fields? |
| 1645 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
| 1646 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1712 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
| 1713 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1647 | 1714 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1715 | + } |
|
| 1648 | 1716 | |
| 1649 | - if (empty($options['view_newest_first'])) |
|
| 1650 | - $counter++; |
|
| 1651 | - |
|
| 1652 | - else |
|
| 1653 | - $counter--; |
|
| 1717 | + if (empty($options['view_newest_first'])) { |
|
| 1718 | + $counter++; |
|
| 1719 | + } else { |
|
| 1720 | + $counter--; |
|
| 1721 | + } |
|
| 1654 | 1722 | |
| 1655 | 1723 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
| 1656 | 1724 | |
@@ -1676,21 +1744,23 @@ discard block |
||
| 1676 | 1744 | $context['no_last_modified'] = true; |
| 1677 | 1745 | |
| 1678 | 1746 | // Prevent a preview image from being displayed twice. |
| 1679 | - if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) |
|
| 1680 | - return; |
|
| 1747 | + if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) { |
|
| 1748 | + return; |
|
| 1749 | + } |
|
| 1681 | 1750 | |
| 1682 | 1751 | // Make sure some attachment was requested! |
| 1683 | - if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) |
|
| 1684 | - fatal_lang_error('no_access', false); |
|
| 1752 | + if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) { |
|
| 1753 | + fatal_lang_error('no_access', false); |
|
| 1754 | + } |
|
| 1685 | 1755 | |
| 1686 | 1756 | $_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id']; |
| 1687 | 1757 | |
| 1688 | 1758 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 1689 | 1759 | $attachRequest = null; |
| 1690 | 1760 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 1691 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 1692 | - $request = $attachRequest; |
|
| 1693 | - else |
|
| 1761 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 1762 | + $request = $attachRequest; |
|
| 1763 | + } else |
|
| 1694 | 1764 | { |
| 1695 | 1765 | // This checks only the current board for $board/$topic's permissions. |
| 1696 | 1766 | isAllowedTo('view_attachments'); |
@@ -1711,19 +1781,21 @@ discard block |
||
| 1711 | 1781 | ); |
| 1712 | 1782 | } |
| 1713 | 1783 | |
| 1714 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1715 | - fatal_lang_error('no_access', false); |
|
| 1784 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1785 | + fatal_lang_error('no_access', false); |
|
| 1786 | + } |
|
| 1716 | 1787 | |
| 1717 | 1788 | list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request); |
| 1718 | 1789 | $smcFunc['db_free_result']($request); |
| 1719 | 1790 | |
| 1720 | 1791 | // If it isn't yet approved, do they have permission to view it? |
| 1721 | - if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
|
| 1722 | - isAllowedTo('approve_posts'); |
|
| 1792 | + if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) { |
|
| 1793 | + isAllowedTo('approve_posts'); |
|
| 1794 | + } |
|
| 1723 | 1795 | |
| 1724 | 1796 | // Update the download counter (unless it's a thumbnail). |
| 1725 | - if ($attachment_type != 3) |
|
| 1726 | - $smcFunc['db_query']('', ' |
|
| 1797 | + if ($attachment_type != 3) { |
|
| 1798 | + $smcFunc['db_query']('', ' |
|
| 1727 | 1799 | UPDATE {db_prefix}attachments |
| 1728 | 1800 | SET downloads = downloads + 1 |
| 1729 | 1801 | WHERE id_attach = {int:id_attach}', |
@@ -1731,15 +1803,15 @@ discard block |
||
| 1731 | 1803 | 'id_attach' => $id_attach, |
| 1732 | 1804 | ) |
| 1733 | 1805 | ); |
| 1806 | + } |
|
| 1734 | 1807 | |
| 1735 | 1808 | $filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash); |
| 1736 | 1809 | |
| 1737 | 1810 | // This is done to clear any output that was made before now. |
| 1738 | 1811 | ob_end_clean(); |
| 1739 | - if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) |
|
| 1740 | - @ob_start('ob_gzhandler'); |
|
| 1741 | - |
|
| 1742 | - else |
|
| 1812 | + if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) { |
|
| 1813 | + @ob_start('ob_gzhandler'); |
|
| 1814 | + } else |
|
| 1743 | 1815 | { |
| 1744 | 1816 | ob_start(); |
| 1745 | 1817 | header('Content-Encoding: none'); |
@@ -1782,8 +1854,9 @@ discard block |
||
| 1782 | 1854 | // Send the attachment headers. |
| 1783 | 1855 | header('Pragma: '); |
| 1784 | 1856 | |
| 1785 | - if (!isBrowser('gecko')) |
|
| 1786 | - header('Content-Transfer-Encoding: binary'); |
|
| 1857 | + if (!isBrowser('gecko')) { |
|
| 1858 | + header('Content-Transfer-Encoding: binary'); |
|
| 1859 | + } |
|
| 1787 | 1860 | |
| 1788 | 1861 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 1789 | 1862 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); |
@@ -1792,18 +1865,19 @@ discard block |
||
| 1792 | 1865 | header('ETag: ' . $eTag); |
| 1793 | 1866 | |
| 1794 | 1867 | // Make sure the mime type warrants an inline display. |
| 1795 | - if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) |
|
| 1796 | - unset($_REQUEST['image']); |
|
| 1868 | + if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) { |
|
| 1869 | + unset($_REQUEST['image']); |
|
| 1870 | + } |
|
| 1797 | 1871 | |
| 1798 | 1872 | // Does this have a mime type? |
| 1799 | - elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 1800 | - header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 1801 | - |
|
| 1802 | - else |
|
| 1873 | + elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 1874 | + header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 1875 | + } else |
|
| 1803 | 1876 | { |
| 1804 | 1877 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 1805 | - if (isset($_REQUEST['image'])) |
|
| 1806 | - unset($_REQUEST['image']); |
|
| 1878 | + if (isset($_REQUEST['image'])) { |
|
| 1879 | + unset($_REQUEST['image']); |
|
| 1880 | + } |
|
| 1807 | 1881 | } |
| 1808 | 1882 | |
| 1809 | 1883 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -1811,23 +1885,22 @@ discard block |
||
| 1811 | 1885 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 1812 | 1886 | |
| 1813 | 1887 | // Different browsers like different standards... |
| 1814 | - if (isBrowser('firefox')) |
|
| 1815 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 1816 | - |
|
| 1817 | - elseif (isBrowser('opera')) |
|
| 1818 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 1819 | - |
|
| 1820 | - elseif (isBrowser('ie')) |
|
| 1821 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 1822 | - |
|
| 1823 | - else |
|
| 1824 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 1888 | + if (isBrowser('firefox')) { |
|
| 1889 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 1890 | + } elseif (isBrowser('opera')) { |
|
| 1891 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 1892 | + } elseif (isBrowser('ie')) { |
|
| 1893 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 1894 | + } else { |
|
| 1895 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 1896 | + } |
|
| 1825 | 1897 | |
| 1826 | 1898 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 1827 | - if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 1828 | - header('Cache-Control: no-cache'); |
|
| 1829 | - else |
|
| 1830 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 1899 | + if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 1900 | + header('Cache-Control: no-cache'); |
|
| 1901 | + } else { |
|
| 1902 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 1903 | + } |
|
| 1831 | 1904 | |
| 1832 | 1905 | header('Content-Length: ' . filesize($filename)); |
| 1833 | 1906 | |
@@ -1837,20 +1910,23 @@ discard block |
||
| 1837 | 1910 | // Recode line endings for text files, if enabled. |
| 1838 | 1911 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
| 1839 | 1912 | { |
| 1840 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
| 1841 | - $callback = function($buffer) |
|
| 1913 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
| 1914 | + $callback = function($buffer) |
|
| 1842 | 1915 | { |
| 1843 | 1916 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
| 1917 | + } |
|
| 1844 | 1918 | }; |
| 1845 | - elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
| 1846 | - $callback = function($buffer) |
|
| 1919 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
| 1920 | + $callback = function($buffer) |
|
| 1847 | 1921 | { |
| 1848 | 1922 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
| 1923 | + } |
|
| 1849 | 1924 | }; |
| 1850 | - else |
|
| 1851 | - $callback = function($buffer) |
|
| 1925 | + else { |
|
| 1926 | + $callback = function($buffer) |
|
| 1852 | 1927 | { |
| 1853 | 1928 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
| 1929 | + } |
|
| 1854 | 1930 | }; |
| 1855 | 1931 | } |
| 1856 | 1932 | |
@@ -1858,23 +1934,26 @@ discard block |
||
| 1858 | 1934 | if (filesize($filename) > 4194304) |
| 1859 | 1935 | { |
| 1860 | 1936 | // Forcibly end any output buffering going on. |
| 1861 | - while (@ob_get_level() > 0) |
|
| 1862 | - @ob_end_clean(); |
|
| 1937 | + while (@ob_get_level() > 0) { |
|
| 1938 | + @ob_end_clean(); |
|
| 1939 | + } |
|
| 1863 | 1940 | |
| 1864 | 1941 | $fp = fopen($filename, 'rb'); |
| 1865 | 1942 | while (!feof($fp)) |
| 1866 | 1943 | { |
| 1867 | - if (isset($callback)) |
|
| 1868 | - echo $callback(fread($fp, 8192)); |
|
| 1869 | - else |
|
| 1870 | - echo fread($fp, 8192); |
|
| 1944 | + if (isset($callback)) { |
|
| 1945 | + echo $callback(fread($fp, 8192)); |
|
| 1946 | + } else { |
|
| 1947 | + echo fread($fp, 8192); |
|
| 1948 | + } |
|
| 1871 | 1949 | flush(); |
| 1872 | 1950 | } |
| 1873 | 1951 | fclose($fp); |
| 1874 | 1952 | } |
| 1875 | 1953 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
| 1876 | - elseif (isset($callback) || @readfile($filename) === null) |
|
| 1877 | - echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
| 1954 | + elseif (isset($callback) || @readfile($filename) === null) { |
|
| 1955 | + echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
| 1956 | + } |
|
| 1878 | 1957 | |
| 1879 | 1958 | obExit(false); |
| 1880 | 1959 | } |
@@ -1887,8 +1966,9 @@ discard block |
||
| 1887 | 1966 | */ |
| 1888 | 1967 | function approved_attach_sort($a, $b) |
| 1889 | 1968 | { |
| 1890 | - if ($a['is_approved'] == $b['is_approved']) |
|
| 1891 | - return 0; |
|
| 1969 | + if ($a['is_approved'] == $b['is_approved']) { |
|
| 1970 | + return 0; |
|
| 1971 | + } |
|
| 1892 | 1972 | |
| 1893 | 1973 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
| 1894 | 1974 | } |
@@ -1905,16 +1985,19 @@ discard block |
||
| 1905 | 1985 | |
| 1906 | 1986 | require_once($sourcedir . '/RemoveTopic.php'); |
| 1907 | 1987 | |
| 1908 | - if (empty($_REQUEST['msgs'])) |
|
| 1909 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1988 | + if (empty($_REQUEST['msgs'])) { |
|
| 1989 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1990 | + } |
|
| 1910 | 1991 | |
| 1911 | 1992 | $messages = array(); |
| 1912 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
| 1913 | - $messages[] = (int) $dummy; |
|
| 1993 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
| 1994 | + $messages[] = (int) $dummy; |
|
| 1995 | + } |
|
| 1914 | 1996 | |
| 1915 | 1997 | // We are restoring messages. We handle this in another place. |
| 1916 | - if (isset($_REQUEST['restore_selected'])) |
|
| 1917 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1998 | + if (isset($_REQUEST['restore_selected'])) { |
|
| 1999 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 2000 | + } |
|
| 1918 | 2001 | if (isset($_REQUEST['split_selection'])) |
| 1919 | 2002 | { |
| 1920 | 2003 | $request = $smcFunc['db_query']('', ' |
@@ -1933,8 +2016,9 @@ discard block |
||
| 1933 | 2016 | } |
| 1934 | 2017 | |
| 1935 | 2018 | // Allowed to delete any message? |
| 1936 | - if (allowedTo('delete_any')) |
|
| 1937 | - $allowed_all = true; |
|
| 2019 | + if (allowedTo('delete_any')) { |
|
| 2020 | + $allowed_all = true; |
|
| 2021 | + } |
|
| 1938 | 2022 | // Allowed to delete replies to their messages? |
| 1939 | 2023 | elseif (allowedTo('delete_replies')) |
| 1940 | 2024 | { |
@@ -1951,13 +2035,14 @@ discard block |
||
| 1951 | 2035 | $smcFunc['db_free_result']($request); |
| 1952 | 2036 | |
| 1953 | 2037 | $allowed_all = $starter == $user_info['id']; |
| 2038 | + } else { |
|
| 2039 | + $allowed_all = false; |
|
| 1954 | 2040 | } |
| 1955 | - else |
|
| 1956 | - $allowed_all = false; |
|
| 1957 | 2041 | |
| 1958 | 2042 | // Make sure they're allowed to delete their own messages, if not any. |
| 1959 | - if (!$allowed_all) |
|
| 1960 | - isAllowedTo('delete_own'); |
|
| 2043 | + if (!$allowed_all) { |
|
| 2044 | + isAllowedTo('delete_own'); |
|
| 2045 | + } |
|
| 1961 | 2046 | |
| 1962 | 2047 | // Allowed to remove which messages? |
| 1963 | 2048 | $request = $smcFunc['db_query']('', ' |
@@ -1977,8 +2062,9 @@ discard block |
||
| 1977 | 2062 | $messages = array(); |
| 1978 | 2063 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1979 | 2064 | { |
| 1980 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 1981 | - continue; |
|
| 2065 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 2066 | + continue; |
|
| 2067 | + } |
|
| 1982 | 2068 | |
| 1983 | 2069 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
| 1984 | 2070 | } |
@@ -2001,17 +2087,20 @@ discard block |
||
| 2001 | 2087 | foreach ($messages as $message => $info) |
| 2002 | 2088 | { |
| 2003 | 2089 | // Just skip the first message - if it's not the last. |
| 2004 | - if ($message == $first_message && $message != $last_message) |
|
| 2005 | - continue; |
|
| 2090 | + if ($message == $first_message && $message != $last_message) { |
|
| 2091 | + continue; |
|
| 2092 | + } |
|
| 2006 | 2093 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
| 2007 | - elseif ($message == $first_message) |
|
| 2008 | - $topicGone = true; |
|
| 2094 | + elseif ($message == $first_message) { |
|
| 2095 | + $topicGone = true; |
|
| 2096 | + } |
|
| 2009 | 2097 | |
| 2010 | 2098 | removeMessage($message); |
| 2011 | 2099 | |
| 2012 | 2100 | // Log this moderation action ;). |
| 2013 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 2014 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 2101 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 2102 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 2103 | + } |
|
| 2015 | 2104 | } |
| 2016 | 2105 | |
| 2017 | 2106 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $query_where = array(); |
| 167 | 167 | $query_params = $search_data['params']; |
| 168 | 168 | |
| 169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
| 169 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
| 170 | 170 | $modSettings['search_simple_fulltext'] = true; |
| 171 | 171 | |
| 172 | 172 | if ($query_params['id_search']) |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | if (!empty($modSettings['search_simple_fulltext'])) |
| 211 | 211 | { |
| 212 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
| 212 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
| 213 | 213 | { |
| 214 | 214 | $language_ftx = $smcFunc['db_search_language'](); |
| 215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | // remove any indexed words that are used in the complex body search terms |
| 228 | 228 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
| 229 | 229 | |
| 230 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
| 230 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
| 231 | 231 | $row = 0; |
| 232 | 232 | foreach ($words['indexed_words'] as $fulltextWord) { |
| 233 | 233 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | // if we have bool terms to search, add them in |
| 245 | 245 | if ($query_params['boolean_match']) { |
| 246 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
| 246 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
| 247 | 247 | { |
| 248 | 248 | $language_ftx = $smcFunc['db_search_language'](); |
| 249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
| 259 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
| 260 | 260 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
| 261 | 261 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
| 262 | 262 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
| 98 | 99 | $smcFunc['db_free_result']($request); |
| 99 | 100 | } |
| 100 | 101 | // 4 is the MySQL default... |
| 101 | - else |
|
| 102 | - $min_word_length = 4; |
|
| 102 | + else { |
|
| 103 | + $min_word_length = 4; |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | return $min_word_length; |
| 105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
| 138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
| 139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
| 140 | 142 | } |
| 141 | - } |
|
| 142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
| 143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
| 143 | 144 | { |
| 144 | 145 | // short words have feelings too |
| 145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
| 149 | 150 | |
| 150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
| 151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
| 152 | - if ($isExcluded) |
|
| 153 | - $wordsExclude[] = $fulltextWord; |
|
| 153 | + if ($isExcluded) { |
|
| 154 | + $wordsExclude[] = $fulltextWord; |
|
| 155 | + } |
|
| 154 | 156 | } |
| 155 | 157 | |
| 156 | 158 | /** |
@@ -166,44 +168,54 @@ discard block |
||
| 166 | 168 | $query_where = array(); |
| 167 | 169 | $query_params = $search_data['params']; |
| 168 | 170 | |
| 169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
| 170 | - $modSettings['search_simple_fulltext'] = true; |
|
| 171 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
| 172 | + $modSettings['search_simple_fulltext'] = true; |
|
| 173 | + } |
|
| 171 | 174 | |
| 172 | - if ($query_params['id_search']) |
|
| 173 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 175 | + if ($query_params['id_search']) { |
|
| 176 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 177 | + } |
|
| 174 | 178 | |
| 175 | 179 | $count = 0; |
| 176 | - if (empty($modSettings['search_simple_fulltext'])) |
|
| 177 | - foreach ($words['words'] as $regularWord) |
|
| 180 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
| 181 | + foreach ($words['words'] as $regularWord) |
|
| 178 | 182 | { |
| 179 | 183 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
| 184 | + } |
|
| 180 | 185 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 181 | 186 | } |
| 182 | 187 | |
| 183 | - if ($query_params['user_query']) |
|
| 184 | - $query_where[] = '{raw:user_query}'; |
|
| 185 | - if ($query_params['board_query']) |
|
| 186 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 188 | + if ($query_params['user_query']) { |
|
| 189 | + $query_where[] = '{raw:user_query}'; |
|
| 190 | + } |
|
| 191 | + if ($query_params['board_query']) { |
|
| 192 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 193 | + } |
|
| 187 | 194 | |
| 188 | - if ($query_params['topic']) |
|
| 189 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 190 | - if ($query_params['min_msg_id']) |
|
| 191 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 192 | - if ($query_params['max_msg_id']) |
|
| 193 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 195 | + if ($query_params['topic']) { |
|
| 196 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 197 | + } |
|
| 198 | + if ($query_params['min_msg_id']) { |
|
| 199 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 200 | + } |
|
| 201 | + if ($query_params['max_msg_id']) { |
|
| 202 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | $count = 0; |
| 196 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 197 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 206 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 207 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 198 | 208 | { |
| 199 | 209 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 210 | + } |
|
| 200 | 211 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 201 | 212 | } |
| 202 | 213 | $count = 0; |
| 203 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 204 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 214 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 215 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 205 | 216 | { |
| 206 | 217 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
| 218 | + } |
|
| 207 | 219 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 208 | 220 | } |
| 209 | 221 | |
@@ -215,12 +227,11 @@ discard block |
||
| 215 | 227 | |
| 216 | 228 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:body_match})'; |
| 217 | 229 | $query_params['language_ftx'] = $language_ftx; |
| 230 | + } else { |
|
| 231 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
| 218 | 232 | } |
| 219 | - else |
|
| 220 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
| 221 | 233 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
| 222 | - } |
|
| 223 | - else |
|
| 234 | + } else |
|
| 224 | 235 | { |
| 225 | 236 | $query_params['boolean_match'] = ''; |
| 226 | 237 | |
@@ -234,10 +245,10 @@ discard block |
||
| 234 | 245 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
| 235 | 246 | $row++; |
| 236 | 247 | } |
| 237 | - } |
|
| 238 | - else |
|
| 239 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
| 248 | + } else { |
|
| 249 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
| 240 | 250 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
| 251 | + } |
|
| 241 | 252 | |
| 242 | 253 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
| 243 | 254 | |
@@ -249,9 +260,9 @@ discard block |
||
| 249 | 260 | |
| 250 | 261 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:boolean_match})'; |
| 251 | 262 | $query_params['language_ftx'] = $language_ftx; |
| 263 | + } else { |
|
| 264 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
| 252 | 265 | } |
| 253 | - else |
|
| 254 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
| 255 | 266 | } |
| 256 | 267 | |
| 257 | 268 | } |
@@ -116,9 +116,10 @@ discard block |
||
| 116 | 116 | <h3 class="catbg">', $txt['attachment_transfer'], '</h3> |
| 117 | 117 | </div>'; |
| 118 | 118 | |
| 119 | - if (!empty($context['results'])) |
|
| 120 | - echo ' |
|
| 119 | + if (!empty($context['results'])) { |
|
| 120 | + echo ' |
|
| 121 | 121 | <div class="noticebox">', $context['results'], '</div>'; |
| 122 | + } |
|
| 122 | 123 | |
| 123 | 124 | echo ' |
| 124 | 125 | <div class="windowbg2 noup"> |
@@ -129,9 +130,10 @@ discard block |
||
| 129 | 130 | <dd><select name="from"> |
| 130 | 131 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
| 131 | 132 | |
| 132 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
| 133 | - echo ' |
|
| 133 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
| 134 | + echo ' |
|
| 134 | 135 | <option value="', $id, '">', $dir, '</option>'; |
| 136 | + } |
|
| 135 | 137 | echo ' |
| 136 | 138 | </select></dd> |
| 137 | 139 | <dt>', $txt['attachment_transfer_auto'], '</dt> |
@@ -139,13 +141,14 @@ discard block |
||
| 139 | 141 | <option value="0">', $txt['attachment_transfer_auto_select'], '</option> |
| 140 | 142 | <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>'; |
| 141 | 143 | |
| 142 | - if (!empty($context['base_dirs'])) |
|
| 143 | - foreach ($context['base_dirs'] as $id => $dir) |
|
| 144 | + if (!empty($context['base_dirs'])) { |
|
| 145 | + foreach ($context['base_dirs'] as $id => $dir) |
|
| 144 | 146 | echo ' |
| 145 | 147 | <option value="', $id, '">', $dir, '</option>'; |
| 146 | - else |
|
| 147 | - echo ' |
|
| 148 | + } else { |
|
| 149 | + echo ' |
|
| 148 | 150 | <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>'; |
| 151 | + } |
|
| 149 | 152 | |
| 150 | 153 | echo ' |
| 151 | 154 | </select></dd> |
@@ -153,16 +156,18 @@ discard block |
||
| 153 | 156 | <dd><select name="to"> |
| 154 | 157 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
| 155 | 158 | |
| 156 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
| 157 | - echo ' |
|
| 159 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
| 160 | + echo ' |
|
| 158 | 161 | <option value="', $id, '">', $dir, '</option>'; |
| 162 | + } |
|
| 159 | 163 | echo ' |
| 160 | 164 | </select></dd>'; |
| 161 | 165 | |
| 162 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
| 163 | - echo ' |
|
| 166 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
| 167 | + echo ' |
|
| 164 | 168 | <dt>', $txt['attachment_transfer_empty'], '</dt> |
| 165 | 169 | <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>'; |
| 170 | + } |
|
| 166 | 171 | echo ' |
| 167 | 172 | </dl> |
| 168 | 173 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -238,10 +243,11 @@ discard block |
||
| 238 | 243 | // Loop through each error reporting the status |
| 239 | 244 | foreach ($context['repair_errors'] as $error => $number) |
| 240 | 245 | { |
| 241 | - if (!empty($number)) |
|
| 242 | - echo ' |
|
| 246 | + if (!empty($number)) { |
|
| 247 | + echo ' |
|
| 243 | 248 | <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '"> |
| 244 | 249 | <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>'; |
| 250 | + } |
|
| 245 | 251 | } |
| 246 | 252 | |
| 247 | 253 | echo ' <br> |
@@ -18,11 +18,12 @@ discard block |
||
| 18 | 18 | global $context, $txt, $scripturl, $modSettings; |
| 19 | 19 | |
| 20 | 20 | // If maintenance has finished tell the user. |
| 21 | - if (!empty($context['maintenance_finished'])) |
|
| 22 | - echo ' |
|
| 21 | + if (!empty($context['maintenance_finished'])) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="infobox"> |
| 24 | 24 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 25 | 25 | </div>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | echo ' |
| 28 | 29 | <div id="manage_maintenance"> |
@@ -107,11 +108,12 @@ discard block |
||
| 107 | 108 | <div id="manage_maintenance">'; |
| 108 | 109 | |
| 109 | 110 | // If maintenance has finished tell the user. |
| 110 | - if (!empty($context['maintenance_finished'])) |
|
| 111 | - echo ' |
|
| 111 | + if (!empty($context['maintenance_finished'])) { |
|
| 112 | + echo ' |
|
| 112 | 113 | <div class="infobox"> |
| 113 | 114 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 114 | 115 | </div>'; |
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | echo ' |
| 117 | 119 | <div class="cat_bar"> |
@@ -238,11 +240,12 @@ discard block |
||
| 238 | 240 | <div id="manage_maintenance">'; |
| 239 | 241 | |
| 240 | 242 | // If maintenance has finished tell the user. |
| 241 | - if (!empty($context['maintenance_finished'])) |
|
| 242 | - echo ' |
|
| 243 | + if (!empty($context['maintenance_finished'])) { |
|
| 244 | + echo ' |
|
| 243 | 245 | <div class="infobox"> |
| 244 | 246 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 245 | 247 | </div>'; |
| 248 | + } |
|
| 246 | 249 | |
| 247 | 250 | echo ' |
| 248 | 251 | <div class="cat_bar"> |
@@ -300,9 +303,10 @@ discard block |
||
| 300 | 303 | <p><a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a></p> |
| 301 | 304 | <div style="display: none; padding: 3px" id="membersPanel">'; |
| 302 | 305 | |
| 303 | - foreach ($context['membergroups'] as $group) |
|
| 304 | - echo ' |
|
| 306 | + foreach ($context['membergroups'] as $group) { |
|
| 307 | + echo ' |
|
| 305 | 308 | <label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>'; |
| 309 | + } |
|
| 306 | 310 | |
| 307 | 311 | echo ' |
| 308 | 312 | </div> |
@@ -346,11 +350,12 @@ discard block |
||
| 346 | 350 | global $scripturl, $txt, $context, $settings, $modSettings; |
| 347 | 351 | |
| 348 | 352 | // If maintenance has finished tell the user. |
| 349 | - if (!empty($context['maintenance_finished'])) |
|
| 350 | - echo ' |
|
| 353 | + if (!empty($context['maintenance_finished'])) { |
|
| 354 | + echo ' |
|
| 351 | 355 | <div class="infobox"> |
| 352 | 356 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 353 | 357 | </div>'; |
| 358 | + } |
|
| 354 | 359 | |
| 355 | 360 | // Bit of javascript for showing which boards to prune in an otherwise hidden list. |
| 356 | 361 | echo ' |
@@ -418,19 +423,21 @@ discard block |
||
| 418 | 423 | <ul>'; |
| 419 | 424 | |
| 420 | 425 | // Display a checkbox with every board. |
| 421 | - foreach ($category['boards'] as $board) |
|
| 422 | - echo ' |
|
| 426 | + foreach ($category['boards'] as $board) { |
|
| 427 | + echo ' |
|
| 423 | 428 | <li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"><label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label></li>'; |
| 429 | + } |
|
| 424 | 430 | |
| 425 | 431 | echo ' |
| 426 | 432 | </ul> |
| 427 | 433 | </fieldset>'; |
| 428 | 434 | |
| 429 | 435 | // Increase $i, and check if we're at the middle yet. |
| 430 | - if (++$i == $middle) |
|
| 431 | - echo ' |
|
| 436 | + if (++$i == $middle) { |
|
| 437 | + echo ' |
|
| 432 | 438 | </div> |
| 433 | 439 | <div class="floatright" style="width: 49%;">'; |
| 440 | + } |
|
| 434 | 441 | } |
| 435 | 442 | |
| 436 | 443 | echo ' |
@@ -469,9 +476,10 @@ discard block |
||
| 469 | 476 | echo ' |
| 470 | 477 | <optgroup label="', $category['name'], '">'; |
| 471 | 478 | |
| 472 | - foreach ($category['boards'] as $board) |
|
| 473 | - echo ' |
|
| 479 | + foreach ($category['boards'] as $board) { |
|
| 480 | + echo ' |
|
| 474 | 481 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
| 482 | + } |
|
| 475 | 483 | |
| 476 | 484 | echo ' |
| 477 | 485 | </optgroup>'; |
@@ -489,9 +497,10 @@ discard block |
||
| 489 | 497 | echo ' |
| 490 | 498 | <optgroup label="', $category['name'], '">'; |
| 491 | 499 | |
| 492 | - foreach ($category['boards'] as $board) |
|
| 493 | - echo ' |
|
| 500 | + foreach ($category['boards'] as $board) { |
|
| 501 | + echo ' |
|
| 494 | 502 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
| 503 | + } |
|
| 495 | 504 | |
| 496 | 505 | echo ' |
| 497 | 506 | </optgroup>'; |
@@ -531,9 +540,10 @@ discard block |
||
| 531 | 540 | ', $txt['database_optimize_attempt'], '<br>'; |
| 532 | 541 | |
| 533 | 542 | // List each table being optimized... |
| 534 | - foreach ($context['optimized_tables'] as $table) |
|
| 535 | - echo ' |
|
| 543 | + foreach ($context['optimized_tables'] as $table) { |
|
| 544 | + echo ' |
|
| 536 | 545 | ', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>'; |
| 546 | + } |
|
| 537 | 547 | |
| 538 | 548 | // How did we go? |
| 539 | 549 | echo ' |
@@ -590,13 +600,14 @@ discard block |
||
| 590 | 600 | ', implode('</li><li>', $context['exceeding_messages']), ' |
| 591 | 601 | </li> |
| 592 | 602 | </ul>'; |
| 593 | - if (!empty($context['exceeding_messages_morethan'])) |
|
| 594 | - echo ' |
|
| 603 | + if (!empty($context['exceeding_messages_morethan'])) { |
|
| 604 | + echo ' |
|
| 595 | 605 | <p>', $context['exceeding_messages_morethan'], '</p>'; |
| 596 | - } |
|
| 597 | - else |
|
| 598 | - echo ' |
|
| 606 | + } |
|
| 607 | + } else { |
|
| 608 | + echo ' |
|
| 599 | 609 | <p class="infobox">', $txt['convert_to_text'], '</p>'; |
| 610 | + } |
|
| 600 | 611 | |
| 601 | 612 | echo ' |
| 602 | 613 | <form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '"> |
@@ -29,9 +29,10 @@ discard block |
||
| 29 | 29 | // Go through each type of report they can run. |
| 30 | 30 | foreach ($context['report_types'] as $type) |
| 31 | 31 | { |
| 32 | - if (isset($type['description'])) |
|
| 33 | - echo ' |
|
| 32 | + if (isset($type['description'])) { |
|
| 33 | + echo ' |
|
| 34 | 34 | <dt>', $type['description'], '</dt>'; |
| 35 | + } |
|
| 35 | 36 | echo ' |
| 36 | 37 | <dd> |
| 37 | 38 | <input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', '> |
@@ -61,8 +62,9 @@ discard block |
||
| 61 | 62 | </div> |
| 62 | 63 | <div id="report_buttons">'; |
| 63 | 64 | |
| 64 | - if (!empty($context['report_buttons'])) |
|
| 65 | - template_button_strip($context['report_buttons'], 'right'); |
|
| 65 | + if (!empty($context['report_buttons'])) { |
|
| 66 | + template_button_strip($context['report_buttons'], 'right'); |
|
| 67 | + } |
|
| 66 | 68 | |
| 67 | 69 | echo ' |
| 68 | 70 | </div>'; |
@@ -73,25 +75,27 @@ discard block |
||
| 73 | 75 | echo ' |
| 74 | 76 | <table class="table_grid report_results">'; |
| 75 | 77 | |
| 76 | - if (!empty($table['title'])) |
|
| 77 | - echo ' |
|
| 78 | + if (!empty($table['title'])) { |
|
| 79 | + echo ' |
|
| 78 | 80 | <thead> |
| 79 | 81 | <tr class="title_bar"> |
| 80 | 82 | <th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th> |
| 81 | 83 | </tr> |
| 82 | 84 | </thead> |
| 83 | 85 | <tbody>'; |
| 86 | + } |
|
| 84 | 87 | |
| 85 | 88 | // Now do each row! |
| 86 | 89 | $row_number = 0; |
| 87 | 90 | foreach ($table['data'] as $row) |
| 88 | 91 | { |
| 89 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 90 | - echo ' |
|
| 92 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 93 | + echo ' |
|
| 91 | 94 | <tr class="windowbg table_caption">'; |
| 92 | - else |
|
| 93 | - echo ' |
|
| 95 | + } else { |
|
| 96 | + echo ' |
|
| 94 | 97 | <tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">'; |
| 98 | + } |
|
| 95 | 99 | |
| 96 | 100 | // Now do each column. |
| 97 | 101 | $column_number = 0; |
@@ -109,16 +113,17 @@ discard block |
||
| 109 | 113 | } |
| 110 | 114 | |
| 111 | 115 | // Shaded? |
| 112 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 113 | - echo ' |
|
| 116 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 117 | + echo ' |
|
| 114 | 118 | <td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 115 | 119 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 116 | 120 | </td>'; |
| 117 | - else |
|
| 118 | - echo ' |
|
| 121 | + } else { |
|
| 122 | + echo ' |
|
| 119 | 123 | <td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 120 | 124 | ', $data['v'], ' |
| 121 | 125 | </td>'; |
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | $column_number++; |
| 124 | 129 | } |
@@ -167,24 +172,26 @@ discard block |
||
| 167 | 172 | <div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '"> |
| 168 | 173 | <table class="bordercolor">'; |
| 169 | 174 | |
| 170 | - if (!empty($table['title'])) |
|
| 171 | - echo ' |
|
| 175 | + if (!empty($table['title'])) { |
|
| 176 | + echo ' |
|
| 172 | 177 | <tr class="title_bar"> |
| 173 | 178 | <td colspan="', $table['column_count'], '"> |
| 174 | 179 | ', $table['title'], ' |
| 175 | 180 | </td> |
| 176 | 181 | </tr>'; |
| 182 | + } |
|
| 177 | 183 | |
| 178 | 184 | // Now do each row! |
| 179 | 185 | $row_number = 0; |
| 180 | 186 | foreach ($table['data'] as $row) |
| 181 | 187 | { |
| 182 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 183 | - echo ' |
|
| 188 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 189 | + echo ' |
|
| 184 | 190 | <tr class="titlebg">'; |
| 185 | - else |
|
| 186 | - echo ' |
|
| 191 | + } else { |
|
| 192 | + echo ' |
|
| 187 | 193 | <tr class="windowbg">'; |
| 194 | + } |
|
| 188 | 195 | |
| 189 | 196 | // Now do each column!! |
| 190 | 197 | $column_number = 0; |
@@ -201,16 +208,17 @@ discard block |
||
| 201 | 208 | } |
| 202 | 209 | |
| 203 | 210 | // Shaded? |
| 204 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 205 | - echo ' |
|
| 211 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 212 | + echo ' |
|
| 206 | 213 | <td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 207 | 214 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 208 | 215 | </td>'; |
| 209 | - else |
|
| 210 | - echo ' |
|
| 216 | + } else { |
|
| 217 | + echo ' |
|
| 211 | 218 | <td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 212 | 219 | ', $data['v'], ' |
| 213 | 220 | </td>'; |
| 221 | + } |
|
| 214 | 222 | |
| 215 | 223 | $column_number++; |
| 216 | 224 | } |
@@ -26,9 +26,10 @@ discard block |
||
| 26 | 26 | </h3> |
| 27 | 27 | </div>'; |
| 28 | 28 | |
| 29 | - if ($context['ban']['is_new']) |
|
| 30 | - echo ' |
|
| 29 | + if ($context['ban']['is_new']) { |
|
| 30 | + echo ' |
|
| 31 | 31 | <div class="information noup">', $txt['ban_add_notes'], '</div>'; |
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | // If there were errors creating the ban, show them. |
| 34 | 35 | if (!empty($context['error_messages'])) |
@@ -38,9 +39,10 @@ discard block |
||
| 38 | 39 | <strong>', $txt['ban_errors_detected'], '</strong> |
| 39 | 40 | <ul>'; |
| 40 | 41 | |
| 41 | - foreach ($context['error_messages'] as $error) |
|
| 42 | - echo ' |
|
| 42 | + foreach ($context['error_messages'] as $error) { |
|
| 43 | + echo ' |
|
| 43 | 44 | <li class="error">', $error, '</li>'; |
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | echo ' |
| 46 | 48 | </ul> |
@@ -57,8 +59,8 @@ discard block |
||
| 57 | 59 | <input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60"> |
| 58 | 60 | </dd>'; |
| 59 | 61 | |
| 60 | - if (isset($context['ban']['reason'])) |
|
| 61 | - echo ' |
|
| 62 | + if (isset($context['ban']['reason'])) { |
|
| 63 | + echo ' |
|
| 62 | 64 | <dt> |
| 63 | 65 | <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br> |
| 64 | 66 | <span class="smalltext">', $txt['ban_reason_desc'], '</span> |
@@ -66,9 +68,10 @@ discard block |
||
| 66 | 68 | <dd> |
| 67 | 69 | <textarea name="reason" id="reason" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['reason'], '</textarea> |
| 68 | 70 | </dd>'; |
| 71 | + } |
|
| 69 | 72 | |
| 70 | - if (isset($context['ban']['notes'])) |
|
| 71 | - echo ' |
|
| 73 | + if (isset($context['ban']['notes'])) { |
|
| 74 | + echo ' |
|
| 72 | 75 | <dt> |
| 73 | 76 | <strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br> |
| 74 | 77 | <span class="smalltext">', $txt['ban_notes_desc'], '</span> |
@@ -76,6 +79,7 @@ discard block |
||
| 76 | 79 | <dd> |
| 77 | 80 | <textarea name="notes" id="ban_notes" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['notes'], '</textarea> |
| 78 | 81 | </dd>'; |
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | echo ' |
| 81 | 85 | </dl> |
@@ -115,8 +119,8 @@ discard block |
||
| 115 | 119 | <input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
| 116 | 120 | </dd>'; |
| 117 | 121 | |
| 118 | - if (empty($modSettings['disableHostnameLookup'])) |
|
| 119 | - echo ' |
|
| 122 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
| 123 | + echo ' |
|
| 120 | 124 | <dt> |
| 121 | 125 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', !empty($context['ban_suggestions']['hostname']) ? ' checked' : '', '> |
| 122 | 126 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -124,6 +128,7 @@ discard block |
||
| 124 | 128 | <dd> |
| 125 | 129 | <input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
| 126 | 130 | </dd>'; |
| 131 | + } |
|
| 127 | 132 | |
| 128 | 133 | echo ' |
| 129 | 134 | <dt> |
@@ -153,14 +158,15 @@ discard block |
||
| 153 | 158 | <dl class="settings">'; |
| 154 | 159 | |
| 155 | 160 | $count = 0; |
| 156 | - foreach ($ban_ips as $ip) |
|
| 157 | - echo ' |
|
| 161 | + foreach ($ban_ips as $ip) { |
|
| 162 | + echo ' |
|
| 158 | 163 | <dt> |
| 159 | 164 | <input type="checkbox" id="suggestions_', $key, '_', $count, '" name="ban_suggestions[', $key, '][]"', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? ' checked' : '', ' value="', $ip, '"> |
| 160 | 165 | </dt> |
| 161 | 166 | <dd> |
| 162 | 167 | <label for="suggestions_', $key, '_', $count++, '">', $ip, '</label> |
| 163 | 168 | </dd>'; |
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | echo ' |
| 166 | 172 | </dl>'; |
@@ -202,8 +208,8 @@ discard block |
||
| 202 | 208 | addLoadEvent(fUpdateStatus);'; |
| 203 | 209 | |
| 204 | 210 | // Auto suggest only needed for adding new bans, not editing |
| 205 | - if ($context['ban']['is_new'] && empty($_REQUEST['u'])) |
|
| 206 | - echo ' |
|
| 211 | + if ($context['ban']['is_new'] && empty($_REQUEST['u'])) { |
|
| 212 | + echo ' |
|
| 207 | 213 | var oAddMemberSuggest = new smc_AutoSuggest({ |
| 208 | 214 | sSelf: \'oAddMemberSuggest\', |
| 209 | 215 | sSessionId: smf_session_id, |
@@ -221,6 +227,7 @@ discard block |
||
| 221 | 227 | return true; |
| 222 | 228 | } |
| 223 | 229 | oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');'; |
| 230 | + } |
|
| 224 | 231 | |
| 225 | 232 | echo ' |
| 226 | 233 | function confirmBan(aForm) |
@@ -268,8 +275,8 @@ discard block |
||
| 268 | 275 | <input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
| 269 | 276 | </dd>'; |
| 270 | 277 | |
| 271 | - if (empty($modSettings['disableHostnameLookup'])) |
|
| 272 | - echo ' |
|
| 278 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
| 279 | + echo ' |
|
| 273 | 280 | <dt> |
| 274 | 281 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', $context['ban_trigger']['hostname']['selected'] ? ' checked' : '', '> |
| 275 | 282 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -277,6 +284,7 @@ discard block |
||
| 277 | 284 | <dd> |
| 278 | 285 | <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
| 279 | 286 | </dd>'; |
| 287 | + } |
|
| 280 | 288 | |
| 281 | 289 | echo ' |
| 282 | 290 | <dt> |
@@ -18,9 +18,10 @@ discard block |
||
| 18 | 18 | global $context, $txt, $scripturl; |
| 19 | 19 | |
| 20 | 20 | // Are we done sending the newsletter? |
| 21 | - if (!empty($context['newsletter_sent'])) |
|
| 22 | - echo ' |
|
| 21 | + if (!empty($context['newsletter_sent'])) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="infobox">', $txt['admin_news_newsletter_' . $context['newsletter_sent']], '</div>'; |
| 24 | + } |
|
| 24 | 25 | |
| 25 | 26 | echo ' |
| 26 | 27 | <div id="admincenter"> |
@@ -39,9 +40,10 @@ discard block |
||
| 39 | 40 | </dt> |
| 40 | 41 | <dd>'; |
| 41 | 42 | |
| 42 | - foreach ($context['groups'] as $group) |
|
| 43 | - echo ' |
|
| 43 | + foreach ($context['groups'] as $group) { |
|
| 44 | + echo ' |
|
| 44 | 45 | <label for="groups_', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>'; |
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | echo ' |
| 47 | 49 | <br> |
@@ -82,9 +84,10 @@ discard block |
||
| 82 | 84 | </dt> |
| 83 | 85 | <dd>'; |
| 84 | 86 | |
| 85 | - foreach ($context['groups'] as $group) |
|
| 86 | - echo ' |
|
| 87 | + foreach ($context['groups'] as $group) { |
|
| 88 | + echo ' |
|
| 87 | 89 | <label for="exclude_groups_', $group['id'], '"><input type="checkbox" name="exclude_groups[', $group['id'], ']" id="exclude_groups_', $group['id'], '" value="', $group['id'], '"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>'; |
| 90 | + } |
|
| 88 | 91 | |
| 89 | 92 | echo ' |
| 90 | 93 | <br> |
@@ -228,9 +231,10 @@ discard block |
||
| 228 | 231 | <div id="bbcBox_message"></div>'; |
| 229 | 232 | |
| 230 | 233 | // What about smileys? |
| 231 | - if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
|
| 232 | - echo ' |
|
| 234 | + if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) { |
|
| 235 | + echo ' |
|
| 233 | 236 | <div id="smileyBox_message"></div>'; |
| 237 | + } |
|
| 234 | 238 | |
| 235 | 239 | // Show BBC buttons, smileys and textbox. |
| 236 | 240 | echo ' |
@@ -251,9 +255,10 @@ discard block |
||
| 251 | 255 | <input type="hidden" name="email_force" value="', $context['email_force'], '"> |
| 252 | 256 | <input type="hidden" name="total_emails" value="', $context['total_emails'], '">'; |
| 253 | 257 | |
| 254 | - foreach ($context['recipients'] as $key => $values) |
|
| 255 | - echo ' |
|
| 258 | + foreach ($context['recipients'] as $key => $values) { |
|
| 259 | + echo ' |
|
| 256 | 260 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
| 261 | + } |
|
| 257 | 262 | |
| 258 | 263 | echo ' |
| 259 | 264 | <script>'; |
@@ -408,9 +413,10 @@ discard block |
||
| 408 | 413 | <input type="hidden" name="parse_html" value="', $context['parse_html'], '">'; |
| 409 | 414 | |
| 410 | 415 | // All the things we must remember! |
| 411 | - foreach ($context['recipients'] as $key => $values) |
|
| 412 | - echo ' |
|
| 416 | + foreach ($context['recipients'] as $key => $values) { |
|
| 417 | + echo ' |
|
| 413 | 418 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
| 419 | + } |
|
| 414 | 420 | |
| 415 | 421 | echo ' |
| 416 | 422 | </div> |
@@ -443,9 +449,10 @@ discard block |
||
| 443 | 449 | { |
| 444 | 450 | global $context, $txt; |
| 445 | 451 | |
| 446 | - if (!empty($context['saved_successful'])) |
|
| 447 | - echo ' |
|
| 452 | + if (!empty($context['saved_successful'])) { |
|
| 453 | + echo ' |
|
| 448 | 454 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 455 | + } |
|
| 449 | 456 | |
| 450 | 457 | template_show_list('news_lists'); |
| 451 | 458 | } |