@@ -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 | { |
@@ -2460,7 +2460,7 @@ discard block |
||
| 2460 | 2460 | /** |
| 2461 | 2461 | * Add a Javascript file for output later |
| 2462 | 2462 | * |
| 2463 | - * @param string $filename The name of the file to load |
|
| 2463 | + * @param string $fileName The name of the file to load |
|
| 2464 | 2464 | * @param array $params An array of parameter info |
| 2465 | 2465 | * Keys are the following: |
| 2466 | 2466 | * - ['external'] (true/false): define if the file is a externally located file. Needs to be set to true if you are loading an external file |
@@ -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 | { |
@@ -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,30 +466,34 @@ 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; |
| 494 | + } else { |
|
| 495 | + $id_member = 0; |
|
| 472 | 496 | } |
| 473 | - else |
|
| 474 | - $id_member = 0; |
|
| 475 | 497 | |
| 476 | 498 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 477 | 499 | if (!$id_member) |
@@ -495,8 +517,9 @@ discard block |
||
| 495 | 517 | |
| 496 | 518 | list ($tfamember, $tfasecret) = $tfa_data; |
| 497 | 519 | |
| 498 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
| 499 | - $tfasecret = null; |
|
| 520 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
| 521 | + $tfasecret = null; |
|
| 522 | + } |
|
| 500 | 523 | } |
| 501 | 524 | |
| 502 | 525 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -516,10 +539,12 @@ discard block |
||
| 516 | 539 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 517 | 540 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 518 | 541 | { |
| 519 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 542 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 543 | + //only do this if we are just forcing SOME membergroups |
|
| 520 | 544 | { |
| 521 | 545 | //Build an array of ALL user membergroups. |
| 522 | 546 | $full_groups = array($user_settings['id_group']); |
| 547 | + } |
|
| 523 | 548 | if (!empty($user_settings['additional_groups'])) |
| 524 | 549 | { |
| 525 | 550 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -539,15 +564,17 @@ discard block |
||
| 539 | 564 | ); |
| 540 | 565 | $row = $smcFunc['db_fetch_assoc']($request); |
| 541 | 566 | $smcFunc['db_free_result']($request); |
| 567 | + } else { |
|
| 568 | + $row['total'] = 1; |
|
| 542 | 569 | } |
| 543 | - else |
|
| 544 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 570 | + //simplifies logics in the next "if" |
|
| 545 | 571 | |
| 546 | 572 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 547 | 573 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 548 | 574 | |
| 549 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 550 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 575 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 576 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 577 | + } |
|
| 551 | 578 | } |
| 552 | 579 | } |
| 553 | 580 | |
@@ -584,33 +611,37 @@ discard block |
||
| 584 | 611 | 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'])); |
| 585 | 612 | $user_settings['last_login'] = time(); |
| 586 | 613 | |
| 587 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 588 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 614 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 615 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 616 | + } |
|
| 589 | 617 | |
| 590 | - if (!empty($modSettings['cache_enable'])) |
|
| 591 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 618 | + if (!empty($modSettings['cache_enable'])) { |
|
| 619 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 620 | + } |
|
| 592 | 621 | } |
| 622 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 623 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 593 | 624 | } |
| 594 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 595 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 596 | 625 | |
| 597 | 626 | $username = $user_settings['member_name']; |
| 598 | 627 | |
| 599 | - if (empty($user_settings['additional_groups'])) |
|
| 600 | - $user_info = array( |
|
| 628 | + if (empty($user_settings['additional_groups'])) { |
|
| 629 | + $user_info = array( |
|
| 601 | 630 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 602 | 631 | ); |
| 603 | - else |
|
| 604 | - $user_info = array( |
|
| 632 | + } else { |
|
| 633 | + $user_info = array( |
|
| 605 | 634 | 'groups' => array_merge( |
| 606 | 635 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 607 | 636 | explode(',', $user_settings['additional_groups']) |
| 608 | 637 | ) |
| 609 | 638 | ); |
| 639 | + } |
|
| 610 | 640 | |
| 611 | 641 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 612 | - foreach ($user_info['groups'] as $k => $v) |
|
| 613 | - $user_info['groups'][$k] = (int) $v; |
|
| 642 | + foreach ($user_info['groups'] as $k => $v) { |
|
| 643 | + $user_info['groups'][$k] = (int) $v; |
|
| 644 | + } |
|
| 614 | 645 | |
| 615 | 646 | // This is a logged in user, so definitely not a spider. |
| 616 | 647 | $user_info['possibly_robot'] = false; |
@@ -624,8 +655,7 @@ discard block |
||
| 624 | 655 | $time_system = new DateTime('now', $tz_system); |
| 625 | 656 | $time_user = new DateTime('now', $tz_user); |
| 626 | 657 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 627 | - } |
|
| 628 | - else |
|
| 658 | + } else |
|
| 629 | 659 | { |
| 630 | 660 | // !!! Compatibility. |
| 631 | 661 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -639,8 +669,9 @@ discard block |
||
| 639 | 669 | $user_info = array('groups' => array(-1)); |
| 640 | 670 | $user_settings = array(); |
| 641 | 671 | |
| 642 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 643 | - $_COOKIE[$cookiename] = ''; |
|
| 672 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 673 | + $_COOKIE[$cookiename] = ''; |
|
| 674 | + } |
|
| 644 | 675 | |
| 645 | 676 | // Expire the 2FA cookie |
| 646 | 677 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -657,19 +688,20 @@ discard block |
||
| 657 | 688 | } |
| 658 | 689 | |
| 659 | 690 | // Create a login token if it doesn't exist yet. |
| 660 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 661 | - createToken('login'); |
|
| 662 | - else |
|
| 663 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 691 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 692 | + createToken('login'); |
|
| 693 | + } else { |
|
| 694 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 695 | + } |
|
| 664 | 696 | |
| 665 | 697 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 666 | 698 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 667 | 699 | { |
| 668 | 700 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 669 | 701 | $user_info['possibly_robot'] = SpiderCheck(); |
| 702 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 703 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 670 | 704 | } |
| 671 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 672 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 673 | 705 | // If we haven't turned on proper spider hunts then have a guess! |
| 674 | 706 | else |
| 675 | 707 | { |
@@ -717,8 +749,9 @@ discard block |
||
| 717 | 749 | $user_info['groups'] = array_unique($user_info['groups']); |
| 718 | 750 | |
| 719 | 751 | // 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. |
| 720 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 721 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 752 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 753 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 754 | + } |
|
| 722 | 755 | |
| 723 | 756 | // Allow the user to change their language. |
| 724 | 757 | if (!empty($modSettings['userLanguage'])) |
@@ -731,31 +764,36 @@ discard block |
||
| 731 | 764 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 732 | 765 | |
| 733 | 766 | // Make it permanent for members. |
| 734 | - if (!empty($user_info['id'])) |
|
| 735 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 736 | - else |
|
| 737 | - $_SESSION['language'] = $user_info['language']; |
|
| 767 | + if (!empty($user_info['id'])) { |
|
| 768 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 769 | + } else { |
|
| 770 | + $_SESSION['language'] = $user_info['language']; |
|
| 771 | + } |
|
| 772 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 773 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 738 | 774 | } |
| 739 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 740 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 741 | 775 | } |
| 742 | 776 | |
| 743 | 777 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 744 | - if ($user_info['is_admin']) |
|
| 745 | - $user_info['query_see_board'] = '1=1'; |
|
| 778 | + if ($user_info['is_admin']) { |
|
| 779 | + $user_info['query_see_board'] = '1=1'; |
|
| 780 | + } |
|
| 746 | 781 | // Otherwise just the groups in $user_info['groups']. |
| 747 | - else |
|
| 748 | - $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 782 | + else { |
|
| 783 | + $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 784 | + } |
|
| 749 | 785 | |
| 750 | 786 | // Build the list of boards they WANT to see. |
| 751 | 787 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 752 | 788 | |
| 753 | 789 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 754 | - if (empty($user_info['ignoreboards'])) |
|
| 755 | - $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 790 | + if (empty($user_info['ignoreboards'])) { |
|
| 791 | + $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 792 | + } |
|
| 756 | 793 | // Ok I guess they don't want to see all the boards |
| 757 | - else |
|
| 758 | - $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 794 | + else { |
|
| 795 | + $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 796 | + } |
|
| 759 | 797 | |
| 760 | 798 | call_integration_hook('integrate_user_info'); |
| 761 | 799 | } |
@@ -813,9 +851,9 @@ discard block |
||
| 813 | 851 | } |
| 814 | 852 | |
| 815 | 853 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 816 | - if (!empty($topic)) |
|
| 817 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 818 | - else |
|
| 854 | + if (!empty($topic)) { |
|
| 855 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 856 | + } else |
|
| 819 | 857 | { |
| 820 | 858 | loadPermissions(); |
| 821 | 859 | loadTheme(); |
@@ -833,10 +871,11 @@ discard block |
||
| 833 | 871 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 834 | 872 | { |
| 835 | 873 | // @todo SLOW? |
| 836 | - if (!empty($topic)) |
|
| 837 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 838 | - else |
|
| 839 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 874 | + if (!empty($topic)) { |
|
| 875 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 876 | + } else { |
|
| 877 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 878 | + } |
|
| 840 | 879 | |
| 841 | 880 | if (!empty($temp)) |
| 842 | 881 | { |
@@ -874,8 +913,9 @@ discard block |
||
| 874 | 913 | $row = $smcFunc['db_fetch_assoc']($request); |
| 875 | 914 | |
| 876 | 915 | // Set the current board. |
| 877 | - if (!empty($row['id_board'])) |
|
| 878 | - $board = $row['id_board']; |
|
| 916 | + if (!empty($row['id_board'])) { |
|
| 917 | + $board = $row['id_board']; |
|
| 918 | + } |
|
| 879 | 919 | |
| 880 | 920 | // Basic operating information. (globals... :/) |
| 881 | 921 | $board_info = array( |
@@ -911,21 +951,23 @@ discard block |
||
| 911 | 951 | |
| 912 | 952 | do |
| 913 | 953 | { |
| 914 | - if (!empty($row['id_moderator'])) |
|
| 915 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 954 | + if (!empty($row['id_moderator'])) { |
|
| 955 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 916 | 956 | 'id' => $row['id_moderator'], |
| 917 | 957 | 'name' => $row['real_name'], |
| 918 | 958 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 919 | 959 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 920 | 960 | ); |
| 961 | + } |
|
| 921 | 962 | |
| 922 | - if (!empty($row['id_moderator_group'])) |
|
| 923 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 963 | + if (!empty($row['id_moderator_group'])) { |
|
| 964 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 924 | 965 | 'id' => $row['id_moderator_group'], |
| 925 | 966 | 'name' => $row['group_name'], |
| 926 | 967 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 927 | 968 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 928 | 969 | ); |
| 970 | + } |
|
| 929 | 971 | } |
| 930 | 972 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 931 | 973 | |
@@ -957,12 +999,12 @@ discard block |
||
| 957 | 999 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 958 | 1000 | { |
| 959 | 1001 | // @todo SLOW? |
| 960 | - if (!empty($topic)) |
|
| 961 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1002 | + if (!empty($topic)) { |
|
| 1003 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1004 | + } |
|
| 962 | 1005 | cache_put_data('board-' . $board, $board_info, 120); |
| 963 | 1006 | } |
| 964 | - } |
|
| 965 | - else |
|
| 1007 | + } else |
|
| 966 | 1008 | { |
| 967 | 1009 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 968 | 1010 | $board_info = array( |
@@ -976,8 +1018,9 @@ discard block |
||
| 976 | 1018 | $smcFunc['db_free_result']($request); |
| 977 | 1019 | } |
| 978 | 1020 | |
| 979 | - if (!empty($topic)) |
|
| 980 | - $_GET['board'] = (int) $board; |
|
| 1021 | + if (!empty($topic)) { |
|
| 1022 | + $_GET['board'] = (int) $board; |
|
| 1023 | + } |
|
| 981 | 1024 | |
| 982 | 1025 | if (!empty($board)) |
| 983 | 1026 | { |
@@ -987,10 +1030,12 @@ discard block |
||
| 987 | 1030 | // Now check if the user is a moderator. |
| 988 | 1031 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 989 | 1032 | |
| 990 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 991 | - $board_info['error'] = 'access'; |
|
| 992 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 993 | - $board_info['error'] = 'access'; |
|
| 1033 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1034 | + $board_info['error'] = 'access'; |
|
| 1035 | + } |
|
| 1036 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1037 | + $board_info['error'] = 'access'; |
|
| 1038 | + } |
|
| 994 | 1039 | |
| 995 | 1040 | // Build up the linktree. |
| 996 | 1041 | $context['linktree'] = array_merge( |
@@ -1013,8 +1058,9 @@ discard block |
||
| 1013 | 1058 | $context['current_board'] = $board; |
| 1014 | 1059 | |
| 1015 | 1060 | // No posting in redirection boards! |
| 1016 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1017 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1061 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1062 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1063 | + } |
|
| 1018 | 1064 | |
| 1019 | 1065 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1020 | 1066 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1040,24 +1086,23 @@ discard block |
||
| 1040 | 1086 | ob_end_clean(); |
| 1041 | 1087 | header('HTTP/1.1 403 Forbidden'); |
| 1042 | 1088 | die; |
| 1043 | - } |
|
| 1044 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1089 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1045 | 1090 | { |
| 1046 | 1091 | // Slightly different error message here... |
| 1047 | 1092 | fatal_lang_error('cannot_post_redirect', false); |
| 1048 | - } |
|
| 1049 | - elseif ($user_info['is_guest']) |
|
| 1093 | + } elseif ($user_info['is_guest']) |
|
| 1050 | 1094 | { |
| 1051 | 1095 | loadLanguage('Errors'); |
| 1052 | 1096 | is_not_guest($txt['topic_gone']); |
| 1097 | + } else { |
|
| 1098 | + fatal_lang_error('topic_gone', false); |
|
| 1053 | 1099 | } |
| 1054 | - else |
|
| 1055 | - fatal_lang_error('topic_gone', false); |
|
| 1056 | 1100 | } |
| 1057 | 1101 | |
| 1058 | - if ($user_info['is_mod']) |
|
| 1059 | - $user_info['groups'][] = 3; |
|
| 1060 | -} |
|
| 1102 | + if ($user_info['is_mod']) { |
|
| 1103 | + $user_info['groups'][] = 3; |
|
| 1104 | + } |
|
| 1105 | + } |
|
| 1061 | 1106 | |
| 1062 | 1107 | /** |
| 1063 | 1108 | * Load this user's permissions. |
@@ -1078,8 +1123,9 @@ discard block |
||
| 1078 | 1123 | asort($cache_groups); |
| 1079 | 1124 | $cache_groups = implode(',', $cache_groups); |
| 1080 | 1125 | // If it's a spider then cache it different. |
| 1081 | - if ($user_info['possibly_robot']) |
|
| 1082 | - $cache_groups .= '-spider'; |
|
| 1126 | + if ($user_info['possibly_robot']) { |
|
| 1127 | + $cache_groups .= '-spider'; |
|
| 1128 | + } |
|
| 1083 | 1129 | |
| 1084 | 1130 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1085 | 1131 | { |
@@ -1087,9 +1133,9 @@ discard block |
||
| 1087 | 1133 | banPermissions(); |
| 1088 | 1134 | |
| 1089 | 1135 | return; |
| 1136 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1137 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1090 | 1138 | } |
| 1091 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1092 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1093 | 1139 | } |
| 1094 | 1140 | |
| 1095 | 1141 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1111,23 +1157,26 @@ discard block |
||
| 1111 | 1157 | $removals = array(); |
| 1112 | 1158 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1113 | 1159 | { |
| 1114 | - if (empty($row['add_deny'])) |
|
| 1115 | - $removals[] = $row['permission']; |
|
| 1116 | - else |
|
| 1117 | - $user_info['permissions'][] = $row['permission']; |
|
| 1160 | + if (empty($row['add_deny'])) { |
|
| 1161 | + $removals[] = $row['permission']; |
|
| 1162 | + } else { |
|
| 1163 | + $user_info['permissions'][] = $row['permission']; |
|
| 1164 | + } |
|
| 1118 | 1165 | } |
| 1119 | 1166 | $smcFunc['db_free_result']($request); |
| 1120 | 1167 | |
| 1121 | - if (isset($cache_groups)) |
|
| 1122 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1168 | + if (isset($cache_groups)) { |
|
| 1169 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1170 | + } |
|
| 1123 | 1171 | } |
| 1124 | 1172 | |
| 1125 | 1173 | // Get the board permissions. |
| 1126 | 1174 | if (!empty($board)) |
| 1127 | 1175 | { |
| 1128 | 1176 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1129 | - if (!isset($board_info['profile'])) |
|
| 1130 | - fatal_lang_error('no_board'); |
|
| 1177 | + if (!isset($board_info['profile'])) { |
|
| 1178 | + fatal_lang_error('no_board'); |
|
| 1179 | + } |
|
| 1131 | 1180 | |
| 1132 | 1181 | $request = $smcFunc['db_query']('', ' |
| 1133 | 1182 | SELECT permission, add_deny |
@@ -1143,20 +1192,23 @@ discard block |
||
| 1143 | 1192 | ); |
| 1144 | 1193 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1145 | 1194 | { |
| 1146 | - if (empty($row['add_deny'])) |
|
| 1147 | - $removals[] = $row['permission']; |
|
| 1148 | - else |
|
| 1149 | - $user_info['permissions'][] = $row['permission']; |
|
| 1195 | + if (empty($row['add_deny'])) { |
|
| 1196 | + $removals[] = $row['permission']; |
|
| 1197 | + } else { |
|
| 1198 | + $user_info['permissions'][] = $row['permission']; |
|
| 1199 | + } |
|
| 1150 | 1200 | } |
| 1151 | 1201 | $smcFunc['db_free_result']($request); |
| 1152 | 1202 | } |
| 1153 | 1203 | |
| 1154 | 1204 | // Remove all the permissions they shouldn't have ;). |
| 1155 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1156 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1205 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1206 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1207 | + } |
|
| 1157 | 1208 | |
| 1158 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1159 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1209 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1210 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1211 | + } |
|
| 1160 | 1212 | |
| 1161 | 1213 | // Banned? Watch, don't touch.. |
| 1162 | 1214 | banPermissions(); |
@@ -1168,17 +1220,18 @@ discard block |
||
| 1168 | 1220 | { |
| 1169 | 1221 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1170 | 1222 | rebuildModCache(); |
| 1223 | + } else { |
|
| 1224 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1171 | 1225 | } |
| 1172 | - else |
|
| 1173 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1174 | 1226 | |
| 1175 | 1227 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1176 | 1228 | // For example this drastically simplifies certain changes to the profile area. |
| 1177 | 1229 | $user_info['permissions'][] = 'is_not_guest'; |
| 1178 | 1230 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1179 | 1231 | $user_info['permissions'][] = 'profile_view_own'; |
| 1180 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1181 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1232 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1233 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1234 | + } |
|
| 1182 | 1235 | } |
| 1183 | 1236 | } |
| 1184 | 1237 | |
@@ -1196,8 +1249,9 @@ discard block |
||
| 1196 | 1249 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1197 | 1250 | |
| 1198 | 1251 | // Can't just look for no users :P. |
| 1199 | - if (empty($users)) |
|
| 1200 | - return array(); |
|
| 1252 | + if (empty($users)) { |
|
| 1253 | + return array(); |
|
| 1254 | + } |
|
| 1201 | 1255 | |
| 1202 | 1256 | // Pass the set value |
| 1203 | 1257 | $context['loadMemberContext_set'] = $set; |
@@ -1212,8 +1266,9 @@ discard block |
||
| 1212 | 1266 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1213 | 1267 | { |
| 1214 | 1268 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1215 | - if ($data == null) |
|
| 1216 | - continue; |
|
| 1269 | + if ($data == null) { |
|
| 1270 | + continue; |
|
| 1271 | + } |
|
| 1217 | 1272 | |
| 1218 | 1273 | $loaded_ids[] = $data['id_member']; |
| 1219 | 1274 | $user_profile[$data['id_member']] = $data; |
@@ -1280,13 +1335,16 @@ discard block |
||
| 1280 | 1335 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
| 1281 | 1336 | |
| 1282 | 1337 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1283 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
| 1284 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1338 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
| 1339 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1340 | + } |
|
| 1285 | 1341 | |
| 1286 | - if (isset($row['member_ip'])) |
|
| 1287 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1288 | - if (isset($row['member_ip2'])) |
|
| 1289 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1342 | + if (isset($row['member_ip'])) { |
|
| 1343 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1344 | + } |
|
| 1345 | + if (isset($row['member_ip2'])) { |
|
| 1346 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1347 | + } |
|
| 1290 | 1348 | $new_loaded_ids[] = $row['id_member']; |
| 1291 | 1349 | $loaded_ids[] = $row['id_member']; |
| 1292 | 1350 | $row['options'] = array(); |
@@ -1305,8 +1363,9 @@ discard block |
||
| 1305 | 1363 | 'loaded_ids' => $new_loaded_ids, |
| 1306 | 1364 | ) |
| 1307 | 1365 | ); |
| 1308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1309 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1367 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1368 | + } |
|
| 1310 | 1369 | $smcFunc['db_free_result']($request); |
| 1311 | 1370 | } |
| 1312 | 1371 | |
@@ -1317,10 +1376,11 @@ discard block |
||
| 1317 | 1376 | { |
| 1318 | 1377 | foreach ($loaded_ids as $a_member) |
| 1319 | 1378 | { |
| 1320 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1321 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1322 | - else |
|
| 1323 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1379 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1380 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1381 | + } else { |
|
| 1382 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1383 | + } |
|
| 1324 | 1384 | |
| 1325 | 1385 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1326 | 1386 | |
@@ -1333,8 +1393,9 @@ discard block |
||
| 1333 | 1393 | |
| 1334 | 1394 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1335 | 1395 | { |
| 1336 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1337 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1396 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1397 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1398 | + } |
|
| 1338 | 1399 | } |
| 1339 | 1400 | |
| 1340 | 1401 | // Are we loading any moderators? If so, fix their group data... |
@@ -1360,14 +1421,17 @@ discard block |
||
| 1360 | 1421 | foreach ($temp_mods as $id) |
| 1361 | 1422 | { |
| 1362 | 1423 | // By popular demand, don't show admins or global moderators as moderators. |
| 1363 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1364 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1424 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1425 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1426 | + } |
|
| 1365 | 1427 | |
| 1366 | 1428 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1367 | - if (!empty($row['icons'])) |
|
| 1368 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1369 | - if (!empty($row['member_group_color'])) |
|
| 1370 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1429 | + if (!empty($row['icons'])) { |
|
| 1430 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1431 | + } |
|
| 1432 | + if (!empty($row['member_group_color'])) { |
|
| 1433 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1434 | + } |
|
| 1371 | 1435 | } |
| 1372 | 1436 | } |
| 1373 | 1437 | |
@@ -1389,12 +1453,14 @@ discard block |
||
| 1389 | 1453 | static $loadedLanguages = array(); |
| 1390 | 1454 | |
| 1391 | 1455 | // If this person's data is already loaded, skip it. |
| 1392 | - if (isset($dataLoaded[$user])) |
|
| 1393 | - return true; |
|
| 1456 | + if (isset($dataLoaded[$user])) { |
|
| 1457 | + return true; |
|
| 1458 | + } |
|
| 1394 | 1459 | |
| 1395 | 1460 | // We can't load guests or members not loaded by loadMemberData()! |
| 1396 | - if ($user == 0) |
|
| 1397 | - return false; |
|
| 1461 | + if ($user == 0) { |
|
| 1462 | + return false; |
|
| 1463 | + } |
|
| 1398 | 1464 | if (!isset($user_profile[$user])) |
| 1399 | 1465 | { |
| 1400 | 1466 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1420,12 +1486,16 @@ discard block |
||
| 1420 | 1486 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1421 | 1487 | |
| 1422 | 1488 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1423 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1489 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1490 | + //icon is set and exists |
|
| 1424 | 1491 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1425 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1492 | + } elseif (isset($profile['icons'][1])) { |
|
| 1493 | + //icon is set and doesn't exist, fallback to default |
|
| 1426 | 1494 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1427 | - else //not set, bye bye |
|
| 1495 | + } else { |
|
| 1496 | + //not set, bye bye |
|
| 1428 | 1497 | $group_icon_url = ''; |
| 1498 | + } |
|
| 1429 | 1499 | |
| 1430 | 1500 | // These minimal values are always loaded |
| 1431 | 1501 | $memberContext[$user] = array( |
@@ -1444,8 +1514,9 @@ discard block |
||
| 1444 | 1514 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1445 | 1515 | { |
| 1446 | 1516 | // Go the extra mile and load the user's native language name. |
| 1447 | - if (empty($loadedLanguages)) |
|
| 1448 | - $loadedLanguages = getLanguages(); |
|
| 1517 | + if (empty($loadedLanguages)) { |
|
| 1518 | + $loadedLanguages = getLanguages(); |
|
| 1519 | + } |
|
| 1449 | 1520 | |
| 1450 | 1521 | $memberContext[$user] += array( |
| 1451 | 1522 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1499,31 +1570,33 @@ discard block |
||
| 1499 | 1570 | { |
| 1500 | 1571 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1501 | 1572 | { |
| 1502 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1503 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1504 | - else |
|
| 1505 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1506 | - } |
|
| 1507 | - 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 |
|
| 1508 | 1579 | { |
| 1509 | 1580 | // So it's stored in the member table? |
| 1510 | 1581 | if (!empty($profile['avatar'])) |
| 1511 | 1582 | { |
| 1512 | 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']; |
|
| 1513 | 1586 | } |
| 1514 | - elseif (!empty($profile['filename'])) |
|
| 1515 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1516 | 1587 | // Right... no avatar...use the default one |
| 1517 | - else |
|
| 1518 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1588 | + else { |
|
| 1589 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1590 | + } |
|
| 1519 | 1591 | } |
| 1520 | - if (!empty($image)) |
|
| 1521 | - $memberContext[$user]['avatar'] = array( |
|
| 1592 | + if (!empty($image)) { |
|
| 1593 | + $memberContext[$user]['avatar'] = array( |
|
| 1522 | 1594 | 'name' => $profile['avatar'], |
| 1523 | 1595 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1524 | 1596 | 'href' => $image, |
| 1525 | 1597 | 'url' => $image, |
| 1526 | 1598 | ); |
| 1599 | + } |
|
| 1527 | 1600 | } |
| 1528 | 1601 | |
| 1529 | 1602 | // Are we also loading the members custom fields into context? |
@@ -1531,35 +1604,41 @@ discard block |
||
| 1531 | 1604 | { |
| 1532 | 1605 | $memberContext[$user]['custom_fields'] = array(); |
| 1533 | 1606 | |
| 1534 | - if (!isset($context['display_fields'])) |
|
| 1535 | - $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 | + } |
|
| 1536 | 1610 | |
| 1537 | 1611 | foreach ($context['display_fields'] as $custom) |
| 1538 | 1612 | { |
| 1539 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1540 | - continue; |
|
| 1613 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1614 | + continue; |
|
| 1615 | + } |
|
| 1541 | 1616 | |
| 1542 | 1617 | $value = $profile['options'][$custom['col_name']]; |
| 1543 | 1618 | |
| 1544 | 1619 | // Don't show the "disabled" option for the "gender" field. |
| 1545 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 1546 | - continue; |
|
| 1620 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 1621 | + continue; |
|
| 1622 | + } |
|
| 1547 | 1623 | |
| 1548 | 1624 | // BBC? |
| 1549 | - if ($custom['bbc']) |
|
| 1550 | - $value = parse_bbc($value); |
|
| 1625 | + if ($custom['bbc']) { |
|
| 1626 | + $value = parse_bbc($value); |
|
| 1627 | + } |
|
| 1551 | 1628 | // ... or checkbox? |
| 1552 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1553 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1629 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1630 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1631 | + } |
|
| 1554 | 1632 | |
| 1555 | 1633 | // Enclosing the user input within some other text? |
| 1556 | - if (!empty($custom['enclose'])) |
|
| 1557 | - $value = strtr($custom['enclose'], array( |
|
| 1634 | + if (!empty($custom['enclose'])) { |
|
| 1635 | + $value = strtr($custom['enclose'], array( |
|
| 1558 | 1636 | '{SCRIPTURL}' => $scripturl, |
| 1559 | 1637 | '{IMAGES_URL}' => $settings['images_url'], |
| 1560 | 1638 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1561 | 1639 | '{INPUT}' => $value, |
| 1562 | 1640 | )); |
| 1641 | + } |
|
| 1563 | 1642 | |
| 1564 | 1643 | $memberContext[$user]['custom_fields'][] = array( |
| 1565 | 1644 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1586,8 +1665,9 @@ discard block |
||
| 1586 | 1665 | global $smcFunc, $txt, $scripturl, $settings; |
| 1587 | 1666 | |
| 1588 | 1667 | // Do not waste my time... |
| 1589 | - if (empty($users) || empty($params)) |
|
| 1590 | - return false; |
|
| 1668 | + if (empty($users) || empty($params)) { |
|
| 1669 | + return false; |
|
| 1670 | + } |
|
| 1591 | 1671 | |
| 1592 | 1672 | // Make sure it's an array. |
| 1593 | 1673 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1611,31 +1691,36 @@ discard block |
||
| 1611 | 1691 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1612 | 1692 | { |
| 1613 | 1693 | // BBC? |
| 1614 | - if (!empty($row['bbc'])) |
|
| 1615 | - $row['value'] = parse_bbc($row['value']); |
|
| 1694 | + if (!empty($row['bbc'])) { |
|
| 1695 | + $row['value'] = parse_bbc($row['value']); |
|
| 1696 | + } |
|
| 1616 | 1697 | |
| 1617 | 1698 | // ... or checkbox? |
| 1618 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1619 | - $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 | + } |
|
| 1620 | 1702 | |
| 1621 | 1703 | // Enclosing the user input within some other text? |
| 1622 | - if (!empty($row['enclose'])) |
|
| 1623 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1704 | + if (!empty($row['enclose'])) { |
|
| 1705 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1624 | 1706 | '{SCRIPTURL}' => $scripturl, |
| 1625 | 1707 | '{IMAGES_URL}' => $settings['images_url'], |
| 1626 | 1708 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1627 | 1709 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1628 | 1710 | )); |
| 1711 | + } |
|
| 1629 | 1712 | |
| 1630 | 1713 | // Send a simple array if there is just 1 param |
| 1631 | - if (count($params) == 1) |
|
| 1632 | - $return[$row['id_member']] = $row; |
|
| 1714 | + if (count($params) == 1) { |
|
| 1715 | + $return[$row['id_member']] = $row; |
|
| 1716 | + } |
|
| 1633 | 1717 | |
| 1634 | 1718 | // More than 1? knock yourself out... |
| 1635 | 1719 | else |
| 1636 | 1720 | { |
| 1637 | - if (!isset($return[$row['id_member']])) |
|
| 1638 | - $return[$row['id_member']] = array(); |
|
| 1721 | + if (!isset($return[$row['id_member']])) { |
|
| 1722 | + $return[$row['id_member']] = array(); |
|
| 1723 | + } |
|
| 1639 | 1724 | |
| 1640 | 1725 | $return[$row['id_member']][$row['variable']] = $row; |
| 1641 | 1726 | } |
@@ -1669,8 +1754,9 @@ discard block |
||
| 1669 | 1754 | global $context; |
| 1670 | 1755 | |
| 1671 | 1756 | // Don't know any browser! |
| 1672 | - if (empty($context['browser'])) |
|
| 1673 | - detectBrowser(); |
|
| 1757 | + if (empty($context['browser'])) { |
|
| 1758 | + detectBrowser(); |
|
| 1759 | + } |
|
| 1674 | 1760 | |
| 1675 | 1761 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1676 | 1762 | } |
@@ -1688,8 +1774,9 @@ discard block |
||
| 1688 | 1774 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1689 | 1775 | |
| 1690 | 1776 | // The theme was specified by parameter. |
| 1691 | - if (!empty($id_theme)) |
|
| 1692 | - $id_theme = (int) $id_theme; |
|
| 1777 | + if (!empty($id_theme)) { |
|
| 1778 | + $id_theme = (int) $id_theme; |
|
| 1779 | + } |
|
| 1693 | 1780 | // The theme was specified by REQUEST. |
| 1694 | 1781 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1695 | 1782 | { |
@@ -1697,51 +1784,58 @@ discard block |
||
| 1697 | 1784 | $_SESSION['id_theme'] = $id_theme; |
| 1698 | 1785 | } |
| 1699 | 1786 | // The theme was specified by REQUEST... previously. |
| 1700 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1701 | - $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 | + } |
|
| 1702 | 1790 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1703 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1704 | - $id_theme = $user_info['theme']; |
|
| 1791 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1792 | + $id_theme = $user_info['theme']; |
|
| 1793 | + } |
|
| 1705 | 1794 | // The theme was specified by the board. |
| 1706 | - elseif (!empty($board_info['theme'])) |
|
| 1707 | - $id_theme = $board_info['theme']; |
|
| 1795 | + elseif (!empty($board_info['theme'])) { |
|
| 1796 | + $id_theme = $board_info['theme']; |
|
| 1797 | + } |
|
| 1708 | 1798 | // The theme is the forum's default. |
| 1709 | - else |
|
| 1710 | - $id_theme = $modSettings['theme_guests']; |
|
| 1799 | + else { |
|
| 1800 | + $id_theme = $modSettings['theme_guests']; |
|
| 1801 | + } |
|
| 1711 | 1802 | |
| 1712 | 1803 | // Verify the id_theme... no foul play. |
| 1713 | 1804 | // Always allow the board specific theme, if they are overriding. |
| 1714 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1715 | - $id_theme = $board_info['theme']; |
|
| 1805 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1806 | + $id_theme = $board_info['theme']; |
|
| 1807 | + } |
|
| 1716 | 1808 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1717 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1718 | - $id_theme = (int) $id_theme; |
|
| 1719 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1809 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1810 | + $id_theme = (int) $id_theme; |
|
| 1811 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1720 | 1812 | { |
| 1721 | 1813 | $themes = explode(',', $modSettings['enableThemes']); |
| 1722 | - if (!in_array($id_theme, $themes)) |
|
| 1723 | - $id_theme = $modSettings['theme_guests']; |
|
| 1724 | - else |
|
| 1814 | + if (!in_array($id_theme, $themes)) { |
|
| 1815 | + $id_theme = $modSettings['theme_guests']; |
|
| 1816 | + } else { |
|
| 1817 | + $id_theme = (int) $id_theme; |
|
| 1818 | + } |
|
| 1819 | + } else { |
|
| 1725 | 1820 | $id_theme = (int) $id_theme; |
| 1726 | 1821 | } |
| 1727 | - else |
|
| 1728 | - $id_theme = (int) $id_theme; |
|
| 1729 | 1822 | |
| 1730 | 1823 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1731 | 1824 | |
| 1732 | 1825 | // Disable image proxy if we don't have SSL enabled |
| 1733 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
| 1734 | - $image_proxy_enabled = false; |
|
| 1826 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
| 1827 | + $image_proxy_enabled = false; |
|
| 1828 | + } |
|
| 1735 | 1829 | |
| 1736 | 1830 | 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']) |
| 1737 | 1831 | { |
| 1738 | 1832 | $themeData = $temp; |
| 1739 | 1833 | $flag = true; |
| 1834 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1835 | + $themeData = $temp + array($member => array()); |
|
| 1836 | + } else { |
|
| 1837 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1740 | 1838 | } |
| 1741 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1742 | - $themeData = $temp + array($member => array()); |
|
| 1743 | - else |
|
| 1744 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1745 | 1839 | |
| 1746 | 1840 | if (empty($flag)) |
| 1747 | 1841 | { |
@@ -1760,31 +1854,37 @@ discard block |
||
| 1760 | 1854 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1761 | 1855 | { |
| 1762 | 1856 | // There are just things we shouldn't be able to change as members. |
| 1763 | - 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'))) |
|
| 1764 | - continue; |
|
| 1857 | + 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'))) { |
|
| 1858 | + continue; |
|
| 1859 | + } |
|
| 1765 | 1860 | |
| 1766 | 1861 | // If this is the theme_dir of the default theme, store it. |
| 1767 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1768 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1862 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1863 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1864 | + } |
|
| 1769 | 1865 | |
| 1770 | 1866 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1771 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1772 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1867 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1868 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1869 | + } |
|
| 1773 | 1870 | } |
| 1774 | 1871 | $smcFunc['db_free_result']($result); |
| 1775 | 1872 | |
| 1776 | - if (!empty($themeData[-1])) |
|
| 1777 | - foreach ($themeData[-1] as $k => $v) |
|
| 1873 | + if (!empty($themeData[-1])) { |
|
| 1874 | + foreach ($themeData[-1] as $k => $v) |
|
| 1778 | 1875 | { |
| 1779 | 1876 | if (!isset($themeData[$member][$k])) |
| 1780 | 1877 | $themeData[$member][$k] = $v; |
| 1878 | + } |
|
| 1781 | 1879 | } |
| 1782 | 1880 | |
| 1783 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1784 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1881 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1882 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1883 | + } |
|
| 1785 | 1884 | // Only if we didn't already load that part of the cache... |
| 1786 | - elseif (!isset($temp)) |
|
| 1787 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1885 | + elseif (!isset($temp)) { |
|
| 1886 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1887 | + } |
|
| 1788 | 1888 | } |
| 1789 | 1889 | |
| 1790 | 1890 | $settings = $themeData[0]; |
@@ -1801,20 +1901,24 @@ discard block |
||
| 1801 | 1901 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1802 | 1902 | |
| 1803 | 1903 | // Based on theme (if there is one). |
| 1804 | - if (!empty($settings['base_theme_dir'])) |
|
| 1805 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1904 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1905 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1906 | + } |
|
| 1806 | 1907 | |
| 1807 | 1908 | // Lastly the default theme. |
| 1808 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1809 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1909 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1910 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1911 | + } |
|
| 1810 | 1912 | |
| 1811 | - if (!$initialize) |
|
| 1812 | - return; |
|
| 1913 | + if (!$initialize) { |
|
| 1914 | + return; |
|
| 1915 | + } |
|
| 1813 | 1916 | |
| 1814 | 1917 | // Check to see if we're forcing SSL |
| 1815 | 1918 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
| 1816 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
| 1817 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1919 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
| 1920 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1921 | + } |
|
| 1818 | 1922 | |
| 1819 | 1923 | // Check to see if they're accessing it from the wrong place. |
| 1820 | 1924 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1822,8 +1926,9 @@ discard block |
||
| 1822 | 1926 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
| 1823 | 1927 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1824 | 1928 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1825 | - if ($temp != '/') |
|
| 1826 | - $detected_url .= $temp; |
|
| 1929 | + if ($temp != '/') { |
|
| 1930 | + $detected_url .= $temp; |
|
| 1931 | + } |
|
| 1827 | 1932 | } |
| 1828 | 1933 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1829 | 1934 | { |
@@ -1835,8 +1940,9 @@ discard block |
||
| 1835 | 1940 | foreach ($aliases as $alias) |
| 1836 | 1941 | { |
| 1837 | 1942 | // Rip off all the boring parts, spaces, etc. |
| 1838 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1839 | - $do_fix = true; |
|
| 1943 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1944 | + $do_fix = true; |
|
| 1945 | + } |
|
| 1840 | 1946 | } |
| 1841 | 1947 | } |
| 1842 | 1948 | |
@@ -1844,20 +1950,22 @@ discard block |
||
| 1844 | 1950 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1845 | 1951 | { |
| 1846 | 1952 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1847 | - if (empty($_GET)) |
|
| 1848 | - redirectexit('wwwRedirect'); |
|
| 1849 | - else |
|
| 1953 | + if (empty($_GET)) { |
|
| 1954 | + redirectexit('wwwRedirect'); |
|
| 1955 | + } else |
|
| 1850 | 1956 | { |
| 1851 | 1957 | list ($k, $v) = each($_GET); |
| 1852 | 1958 | |
| 1853 | - if ($k != 'wwwRedirect') |
|
| 1854 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1959 | + if ($k != 'wwwRedirect') { |
|
| 1960 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1961 | + } |
|
| 1855 | 1962 | } |
| 1856 | 1963 | } |
| 1857 | 1964 | |
| 1858 | 1965 | // #3 is just a check for SSL... |
| 1859 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1860 | - $do_fix = true; |
|
| 1966 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1967 | + $do_fix = true; |
|
| 1968 | + } |
|
| 1861 | 1969 | |
| 1862 | 1970 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1863 | 1971 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1891,8 +1999,9 @@ discard block |
||
| 1891 | 1999 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1892 | 2000 | } |
| 1893 | 2001 | } |
| 1894 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1895 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2002 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2003 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2004 | + } |
|
| 1896 | 2005 | } |
| 1897 | 2006 | } |
| 1898 | 2007 | // Set up the contextual user array. |
@@ -1911,16 +2020,16 @@ discard block |
||
| 1911 | 2020 | 'email' => $user_info['email'], |
| 1912 | 2021 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1913 | 2022 | ); |
| 1914 | - if (!$context['user']['is_guest']) |
|
| 1915 | - $context['user']['name'] = $user_info['name']; |
|
| 1916 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1917 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2023 | + if (!$context['user']['is_guest']) { |
|
| 2024 | + $context['user']['name'] = $user_info['name']; |
|
| 2025 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2026 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2027 | + } |
|
| 1918 | 2028 | |
| 1919 | 2029 | // Determine the current smiley set. |
| 1920 | 2030 | $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']; |
| 1921 | 2031 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1922 | - } |
|
| 1923 | - else |
|
| 2032 | + } else |
|
| 1924 | 2033 | { |
| 1925 | 2034 | $context['user'] = array( |
| 1926 | 2035 | 'id' => -1, |
@@ -1936,18 +2045,24 @@ discard block |
||
| 1936 | 2045 | } |
| 1937 | 2046 | |
| 1938 | 2047 | // Some basic information... |
| 1939 | - if (!isset($context['html_headers'])) |
|
| 1940 | - $context['html_headers'] = ''; |
|
| 1941 | - if (!isset($context['javascript_files'])) |
|
| 1942 | - $context['javascript_files'] = array(); |
|
| 1943 | - if (!isset($context['css_files'])) |
|
| 1944 | - $context['css_files'] = array(); |
|
| 1945 | - if (!isset($context['css_header'])) |
|
| 1946 | - $context['css_header'] = array(); |
|
| 1947 | - if (!isset($context['javascript_inline'])) |
|
| 1948 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1949 | - if (!isset($context['javascript_vars'])) |
|
| 1950 | - $context['javascript_vars'] = array(); |
|
| 2048 | + if (!isset($context['html_headers'])) { |
|
| 2049 | + $context['html_headers'] = ''; |
|
| 2050 | + } |
|
| 2051 | + if (!isset($context['javascript_files'])) { |
|
| 2052 | + $context['javascript_files'] = array(); |
|
| 2053 | + } |
|
| 2054 | + if (!isset($context['css_files'])) { |
|
| 2055 | + $context['css_files'] = array(); |
|
| 2056 | + } |
|
| 2057 | + if (!isset($context['css_header'])) { |
|
| 2058 | + $context['css_header'] = array(); |
|
| 2059 | + } |
|
| 2060 | + if (!isset($context['javascript_inline'])) { |
|
| 2061 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2062 | + } |
|
| 2063 | + if (!isset($context['javascript_vars'])) { |
|
| 2064 | + $context['javascript_vars'] = array(); |
|
| 2065 | + } |
|
| 1951 | 2066 | |
| 1952 | 2067 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
| 1953 | 2068 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1959,8 +2074,9 @@ discard block |
||
| 1959 | 2074 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 1960 | 2075 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 1961 | 2076 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 1962 | - if (isset($modSettings['load_average'])) |
|
| 1963 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2077 | + if (isset($modSettings['load_average'])) { |
|
| 2078 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2079 | + } |
|
| 1964 | 2080 | |
| 1965 | 2081 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 1966 | 2082 | detectBrowser(); |
@@ -1974,8 +2090,9 @@ discard block |
||
| 1974 | 2090 | // This allows sticking some HTML on the page output - useful for controls. |
| 1975 | 2091 | $context['insert_after_template'] = ''; |
| 1976 | 2092 | |
| 1977 | - if (!isset($txt)) |
|
| 1978 | - $txt = array(); |
|
| 2093 | + if (!isset($txt)) { |
|
| 2094 | + $txt = array(); |
|
| 2095 | + } |
|
| 1979 | 2096 | |
| 1980 | 2097 | $simpleActions = array( |
| 1981 | 2098 | 'findmember', |
@@ -2021,9 +2138,10 @@ discard block |
||
| 2021 | 2138 | |
| 2022 | 2139 | // See if theres any extra param to check. |
| 2023 | 2140 | $requiresXML = false; |
| 2024 | - foreach ($extraParams as $key => $extra) |
|
| 2025 | - if (isset($_REQUEST[$extra])) |
|
| 2141 | + foreach ($extraParams as $key => $extra) { |
|
| 2142 | + if (isset($_REQUEST[$extra])) |
|
| 2026 | 2143 | $requiresXML = true; |
| 2144 | + } |
|
| 2027 | 2145 | |
| 2028 | 2146 | // Output is fully XML, so no need for the index template. |
| 2029 | 2147 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2038,37 +2156,39 @@ discard block |
||
| 2038 | 2156 | { |
| 2039 | 2157 | loadLanguage('index+Modifications'); |
| 2040 | 2158 | $context['template_layers'] = array(); |
| 2041 | - } |
|
| 2042 | - |
|
| 2043 | - else |
|
| 2159 | + } else |
|
| 2044 | 2160 | { |
| 2045 | 2161 | // Custom templates to load, or just default? |
| 2046 | - if (isset($settings['theme_templates'])) |
|
| 2047 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2048 | - else |
|
| 2049 | - $templates = array('index'); |
|
| 2162 | + if (isset($settings['theme_templates'])) { |
|
| 2163 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2164 | + } else { |
|
| 2165 | + $templates = array('index'); |
|
| 2166 | + } |
|
| 2050 | 2167 | |
| 2051 | 2168 | // Load each template... |
| 2052 | - foreach ($templates as $template) |
|
| 2053 | - loadTemplate($template); |
|
| 2169 | + foreach ($templates as $template) { |
|
| 2170 | + loadTemplate($template); |
|
| 2171 | + } |
|
| 2054 | 2172 | |
| 2055 | 2173 | // ...and attempt to load their associated language files. |
| 2056 | 2174 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2057 | 2175 | loadLanguage($required_files, '', false); |
| 2058 | 2176 | |
| 2059 | 2177 | // Custom template layers? |
| 2060 | - if (isset($settings['theme_layers'])) |
|
| 2061 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2062 | - else |
|
| 2063 | - $context['template_layers'] = array('html', 'body'); |
|
| 2178 | + if (isset($settings['theme_layers'])) { |
|
| 2179 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2180 | + } else { |
|
| 2181 | + $context['template_layers'] = array('html', 'body'); |
|
| 2182 | + } |
|
| 2064 | 2183 | } |
| 2065 | 2184 | |
| 2066 | 2185 | // Initialize the theme. |
| 2067 | 2186 | loadSubTemplate('init', 'ignore'); |
| 2068 | 2187 | |
| 2069 | 2188 | // Allow overriding the board wide time/number formats. |
| 2070 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2071 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2189 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2190 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2191 | + } |
|
| 2072 | 2192 | |
| 2073 | 2193 | // Set the character set from the template. |
| 2074 | 2194 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2076,12 +2196,14 @@ discard block |
||
| 2076 | 2196 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2077 | 2197 | |
| 2078 | 2198 | // Guests may still need a name. |
| 2079 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2080 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2199 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2200 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2201 | + } |
|
| 2081 | 2202 | |
| 2082 | 2203 | // Any theme-related strings that need to be loaded? |
| 2083 | - if (!empty($settings['require_theme_strings'])) |
|
| 2084 | - loadLanguage('ThemeStrings', '', false); |
|
| 2204 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2205 | + loadLanguage('ThemeStrings', '', false); |
|
| 2206 | + } |
|
| 2085 | 2207 | |
| 2086 | 2208 | // Make a special URL for the language. |
| 2087 | 2209 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2092,8 +2214,9 @@ discard block |
||
| 2092 | 2214 | // Here is my luvly Responsive CSS |
| 2093 | 2215 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
| 2094 | 2216 | |
| 2095 | - if ($context['right_to_left']) |
|
| 2096 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2217 | + if ($context['right_to_left']) { |
|
| 2218 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2219 | + } |
|
| 2097 | 2220 | |
| 2098 | 2221 | // We allow theme variants, because we're cool. |
| 2099 | 2222 | $context['theme_variant'] = ''; |
@@ -2101,14 +2224,17 @@ discard block |
||
| 2101 | 2224 | if (!empty($settings['theme_variants'])) |
| 2102 | 2225 | { |
| 2103 | 2226 | // Overriding - for previews and that ilk. |
| 2104 | - if (!empty($_REQUEST['variant'])) |
|
| 2105 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2227 | + if (!empty($_REQUEST['variant'])) { |
|
| 2228 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2229 | + } |
|
| 2106 | 2230 | // User selection? |
| 2107 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2108 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2231 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2232 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2233 | + } |
|
| 2109 | 2234 | // If not a user variant, select the default. |
| 2110 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2111 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2235 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2236 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2237 | + } |
|
| 2112 | 2238 | |
| 2113 | 2239 | // Do this to keep things easier in the templates. |
| 2114 | 2240 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2117,20 +2243,23 @@ discard block |
||
| 2117 | 2243 | if (!empty($context['theme_variant'])) |
| 2118 | 2244 | { |
| 2119 | 2245 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
| 2120 | - if ($context['right_to_left']) |
|
| 2121 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2246 | + if ($context['right_to_left']) { |
|
| 2247 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2248 | + } |
|
| 2122 | 2249 | } |
| 2123 | 2250 | } |
| 2124 | 2251 | |
| 2125 | 2252 | // Let's be compatible with old themes! |
| 2126 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2127 | - $context['template_layers'] = array('main'); |
|
| 2253 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2254 | + $context['template_layers'] = array('main'); |
|
| 2255 | + } |
|
| 2128 | 2256 | |
| 2129 | 2257 | $context['tabindex'] = 1; |
| 2130 | 2258 | |
| 2131 | 2259 | // Compatibility. |
| 2132 | - if (!isset($settings['theme_version'])) |
|
| 2133 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2260 | + if (!isset($settings['theme_version'])) { |
|
| 2261 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2262 | + } |
|
| 2134 | 2263 | |
| 2135 | 2264 | // Default JS variables for use in every theme |
| 2136 | 2265 | $context['javascript_vars'] = array( |
@@ -2149,18 +2278,18 @@ discard block |
||
| 2149 | 2278 | ); |
| 2150 | 2279 | |
| 2151 | 2280 | // Add the JQuery library to the list of files to load. |
| 2152 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2153 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2154 | - |
|
| 2155 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2156 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2157 | - |
|
| 2158 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2159 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2281 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2282 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2283 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2284 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2285 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2286 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2287 | + } |
|
| 2160 | 2288 | |
| 2161 | 2289 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2162 | - else |
|
| 2163 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2290 | + else { |
|
| 2291 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2292 | + } |
|
| 2164 | 2293 | |
| 2165 | 2294 | // Queue our JQuery plugins! |
| 2166 | 2295 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2183,12 +2312,12 @@ discard block |
||
| 2183 | 2312 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2184 | 2313 | |
| 2185 | 2314 | // What to do, what to do?! |
| 2186 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2187 | - AutoTask(); |
|
| 2188 | - else |
|
| 2189 | - ReduceMailQueue(); |
|
| 2190 | - } |
|
| 2191 | - else |
|
| 2315 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2316 | + AutoTask(); |
|
| 2317 | + } else { |
|
| 2318 | + ReduceMailQueue(); |
|
| 2319 | + } |
|
| 2320 | + } else |
|
| 2192 | 2321 | { |
| 2193 | 2322 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2194 | 2323 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2239,8 +2368,9 @@ discard block |
||
| 2239 | 2368 | foreach ($theme_includes as $include) |
| 2240 | 2369 | { |
| 2241 | 2370 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2242 | - if (file_exists($include)) |
|
| 2243 | - require_once($include); |
|
| 2371 | + if (file_exists($include)) { |
|
| 2372 | + require_once($include); |
|
| 2373 | + } |
|
| 2244 | 2374 | } |
| 2245 | 2375 | } |
| 2246 | 2376 | |
@@ -2270,16 +2400,19 @@ discard block |
||
| 2270 | 2400 | // Do any style sheets first, cause we're easy with those. |
| 2271 | 2401 | if (!empty($style_sheets)) |
| 2272 | 2402 | { |
| 2273 | - if (!is_array($style_sheets)) |
|
| 2274 | - $style_sheets = array($style_sheets); |
|
| 2403 | + if (!is_array($style_sheets)) { |
|
| 2404 | + $style_sheets = array($style_sheets); |
|
| 2405 | + } |
|
| 2275 | 2406 | |
| 2276 | - foreach ($style_sheets as $sheet) |
|
| 2277 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2407 | + foreach ($style_sheets as $sheet) { |
|
| 2408 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2409 | + } |
|
| 2278 | 2410 | } |
| 2279 | 2411 | |
| 2280 | 2412 | // No template to load? |
| 2281 | - if ($template_name === false) |
|
| 2282 | - return true; |
|
| 2413 | + if ($template_name === false) { |
|
| 2414 | + return true; |
|
| 2415 | + } |
|
| 2283 | 2416 | |
| 2284 | 2417 | $loaded = false; |
| 2285 | 2418 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2294,12 +2427,14 @@ discard block |
||
| 2294 | 2427 | |
| 2295 | 2428 | if ($loaded) |
| 2296 | 2429 | { |
| 2297 | - if ($db_show_debug === true) |
|
| 2298 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2430 | + if ($db_show_debug === true) { |
|
| 2431 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2432 | + } |
|
| 2299 | 2433 | |
| 2300 | 2434 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2301 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2302 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2435 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2436 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2437 | + } |
|
| 2303 | 2438 | } |
| 2304 | 2439 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2305 | 2440 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2319,13 +2454,14 @@ discard block |
||
| 2319 | 2454 | loadTemplate($template_name); |
| 2320 | 2455 | } |
| 2321 | 2456 | // Cause an error otherwise. |
| 2322 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2323 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2324 | - elseif ($fatal) |
|
| 2325 | - 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')); |
|
| 2326 | - else |
|
| 2327 | - return false; |
|
| 2328 | -} |
|
| 2457 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2458 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2459 | + } elseif ($fatal) { |
|
| 2460 | + 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')); |
|
| 2461 | + } else { |
|
| 2462 | + return false; |
|
| 2463 | + } |
|
| 2464 | + } |
|
| 2329 | 2465 | |
| 2330 | 2466 | /** |
| 2331 | 2467 | * Load a sub-template. |
@@ -2343,17 +2479,19 @@ discard block |
||
| 2343 | 2479 | { |
| 2344 | 2480 | global $context, $txt, $db_show_debug; |
| 2345 | 2481 | |
| 2346 | - if ($db_show_debug === true) |
|
| 2347 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2482 | + if ($db_show_debug === true) { |
|
| 2483 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2484 | + } |
|
| 2348 | 2485 | |
| 2349 | 2486 | // Figure out what the template function is named. |
| 2350 | 2487 | $theme_function = 'template_' . $sub_template_name; |
| 2351 | - if (function_exists($theme_function)) |
|
| 2352 | - $theme_function(); |
|
| 2353 | - elseif ($fatal === false) |
|
| 2354 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2355 | - elseif ($fatal !== 'ignore') |
|
| 2356 | - 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')); |
|
| 2488 | + if (function_exists($theme_function)) { |
|
| 2489 | + $theme_function(); |
|
| 2490 | + } elseif ($fatal === false) { |
|
| 2491 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2492 | + } elseif ($fatal !== 'ignore') { |
|
| 2493 | + 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')); |
|
| 2494 | + } |
|
| 2357 | 2495 | |
| 2358 | 2496 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2359 | 2497 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2390,8 +2528,9 @@ discard block |
||
| 2390 | 2528 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2391 | 2529 | |
| 2392 | 2530 | // If this is an external file, automatically set this to false. |
| 2393 | - if (!empty($params['external'])) |
|
| 2394 | - $params['minimize'] = false; |
|
| 2531 | + if (!empty($params['external'])) { |
|
| 2532 | + $params['minimize'] = false; |
|
| 2533 | + } |
|
| 2395 | 2534 | |
| 2396 | 2535 | // Account for shorthand like admin.css?alp21 filenames |
| 2397 | 2536 | $has_seed = strpos($fileName, '.css?'); |
@@ -2408,13 +2547,10 @@ discard block |
||
| 2408 | 2547 | { |
| 2409 | 2548 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2410 | 2549 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2550 | + } else { |
|
| 2551 | + $fileUrl = false; |
|
| 2411 | 2552 | } |
| 2412 | - |
|
| 2413 | - else |
|
| 2414 | - $fileUrl = false; |
|
| 2415 | - } |
|
| 2416 | - |
|
| 2417 | - else |
|
| 2553 | + } else |
|
| 2418 | 2554 | { |
| 2419 | 2555 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2420 | 2556 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2429,12 +2565,14 @@ discard block |
||
| 2429 | 2565 | } |
| 2430 | 2566 | |
| 2431 | 2567 | // Add it to the array for use in the template |
| 2432 | - if (!empty($fileName)) |
|
| 2433 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2568 | + if (!empty($fileName)) { |
|
| 2569 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2570 | + } |
|
| 2434 | 2571 | |
| 2435 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2436 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2437 | -} |
|
| 2572 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2573 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2574 | + } |
|
| 2575 | + } |
|
| 2438 | 2576 | |
| 2439 | 2577 | /** |
| 2440 | 2578 | * Add a block of inline css code to be executed later |
@@ -2451,8 +2589,9 @@ discard block |
||
| 2451 | 2589 | global $context; |
| 2452 | 2590 | |
| 2453 | 2591 | // Gotta add something... |
| 2454 | - if (empty($css)) |
|
| 2455 | - return false; |
|
| 2592 | + if (empty($css)) { |
|
| 2593 | + return false; |
|
| 2594 | + } |
|
| 2456 | 2595 | |
| 2457 | 2596 | $context['css_header'][] = $css; |
| 2458 | 2597 | } |
@@ -2487,8 +2626,9 @@ discard block |
||
| 2487 | 2626 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2488 | 2627 | |
| 2489 | 2628 | // If this is an external file, automatically set this to false. |
| 2490 | - if (!empty($params['external'])) |
|
| 2491 | - $params['minimize'] = false; |
|
| 2629 | + if (!empty($params['external'])) { |
|
| 2630 | + $params['minimize'] = false; |
|
| 2631 | + } |
|
| 2492 | 2632 | |
| 2493 | 2633 | // Account for shorthand like admin.js?alp21 filenames |
| 2494 | 2634 | $has_seed = strpos($fileName, '.js?'); |
@@ -2505,16 +2645,12 @@ discard block |
||
| 2505 | 2645 | { |
| 2506 | 2646 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2507 | 2647 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2508 | - } |
|
| 2509 | - |
|
| 2510 | - else |
|
| 2648 | + } else |
|
| 2511 | 2649 | { |
| 2512 | 2650 | $fileUrl = false; |
| 2513 | 2651 | $filePath = false; |
| 2514 | 2652 | } |
| 2515 | - } |
|
| 2516 | - |
|
| 2517 | - else |
|
| 2653 | + } else |
|
| 2518 | 2654 | { |
| 2519 | 2655 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2520 | 2656 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2529,9 +2665,10 @@ discard block |
||
| 2529 | 2665 | } |
| 2530 | 2666 | |
| 2531 | 2667 | // Add it to the array for use in the template |
| 2532 | - if (!empty($fileName)) |
|
| 2533 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2534 | -} |
|
| 2668 | + if (!empty($fileName)) { |
|
| 2669 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2670 | + } |
|
| 2671 | + } |
|
| 2535 | 2672 | |
| 2536 | 2673 | /** |
| 2537 | 2674 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2545,9 +2682,10 @@ discard block |
||
| 2545 | 2682 | { |
| 2546 | 2683 | global $context; |
| 2547 | 2684 | |
| 2548 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2549 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2550 | -} |
|
| 2685 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2686 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2687 | + } |
|
| 2688 | + } |
|
| 2551 | 2689 | |
| 2552 | 2690 | /** |
| 2553 | 2691 | * Add a block of inline Javascript code to be executed later |
@@ -2564,8 +2702,9 @@ discard block |
||
| 2564 | 2702 | { |
| 2565 | 2703 | global $context; |
| 2566 | 2704 | |
| 2567 | - if (empty($javascript)) |
|
| 2568 | - return false; |
|
| 2705 | + if (empty($javascript)) { |
|
| 2706 | + return false; |
|
| 2707 | + } |
|
| 2569 | 2708 | |
| 2570 | 2709 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2571 | 2710 | } |
@@ -2586,15 +2725,18 @@ discard block |
||
| 2586 | 2725 | static $already_loaded = array(); |
| 2587 | 2726 | |
| 2588 | 2727 | // Default to the user's language. |
| 2589 | - if ($lang == '') |
|
| 2590 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2728 | + if ($lang == '') { |
|
| 2729 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2730 | + } |
|
| 2591 | 2731 | |
| 2592 | 2732 | // Do we want the English version of language file as fallback? |
| 2593 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2594 | - loadLanguage($template_name, 'english', false); |
|
| 2733 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2734 | + loadLanguage($template_name, 'english', false); |
|
| 2735 | + } |
|
| 2595 | 2736 | |
| 2596 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2597 | - return $lang; |
|
| 2737 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2738 | + return $lang; |
|
| 2739 | + } |
|
| 2598 | 2740 | |
| 2599 | 2741 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2600 | 2742 | if (empty($settings['default_theme_dir'])) |
@@ -2605,8 +2747,9 @@ discard block |
||
| 2605 | 2747 | |
| 2606 | 2748 | // What theme are we in? |
| 2607 | 2749 | $theme_name = basename($settings['theme_url']); |
| 2608 | - if (empty($theme_name)) |
|
| 2609 | - $theme_name = 'unknown'; |
|
| 2750 | + if (empty($theme_name)) { |
|
| 2751 | + $theme_name = 'unknown'; |
|
| 2752 | + } |
|
| 2610 | 2753 | |
| 2611 | 2754 | // For each file open it up and write it out! |
| 2612 | 2755 | foreach (explode('+', $template_name) as $template) |
@@ -2648,8 +2791,9 @@ discard block |
||
| 2648 | 2791 | $found = true; |
| 2649 | 2792 | |
| 2650 | 2793 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 2651 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
| 2652 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2794 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
| 2795 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2796 | + } |
|
| 2653 | 2797 | |
| 2654 | 2798 | break; |
| 2655 | 2799 | } |
@@ -2689,8 +2833,9 @@ discard block |
||
| 2689 | 2833 | } |
| 2690 | 2834 | |
| 2691 | 2835 | // Keep track of what we're up to soldier. |
| 2692 | - if ($db_show_debug === true) |
|
| 2693 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2836 | + if ($db_show_debug === true) { |
|
| 2837 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2838 | + } |
|
| 2694 | 2839 | |
| 2695 | 2840 | // Remember what we have loaded, and in which language. |
| 2696 | 2841 | $already_loaded[$template_name] = $lang; |
@@ -2736,8 +2881,9 @@ discard block |
||
| 2736 | 2881 | ) |
| 2737 | 2882 | ); |
| 2738 | 2883 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2739 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2740 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2884 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2885 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2886 | + } |
|
| 2741 | 2887 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2742 | 2888 | { |
| 2743 | 2889 | if (!isset($boards[$row['id_board']])) |
@@ -2754,8 +2900,8 @@ discard block |
||
| 2754 | 2900 | ); |
| 2755 | 2901 | } |
| 2756 | 2902 | // If a moderator exists for this board, add that moderator for all children too. |
| 2757 | - if (!empty($row['id_moderator'])) |
|
| 2758 | - foreach ($boards as $id => $dummy) |
|
| 2903 | + if (!empty($row['id_moderator'])) { |
|
| 2904 | + foreach ($boards as $id => $dummy) |
|
| 2759 | 2905 | { |
| 2760 | 2906 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2761 | 2907 | 'id' => $row['id_moderator'], |
@@ -2763,11 +2909,12 @@ discard block |
||
| 2763 | 2909 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2764 | 2910 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2765 | 2911 | ); |
| 2912 | + } |
|
| 2766 | 2913 | } |
| 2767 | 2914 | |
| 2768 | 2915 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2769 | - if (!empty($row['id_moderator_group'])) |
|
| 2770 | - foreach ($boards as $id => $dummy) |
|
| 2916 | + if (!empty($row['id_moderator_group'])) { |
|
| 2917 | + foreach ($boards as $id => $dummy) |
|
| 2771 | 2918 | { |
| 2772 | 2919 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2773 | 2920 | 'id' => $row['id_moderator_group'], |
@@ -2775,6 +2922,7 @@ discard block |
||
| 2775 | 2922 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2776 | 2923 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2777 | 2924 | ); |
| 2925 | + } |
|
| 2778 | 2926 | } |
| 2779 | 2927 | } |
| 2780 | 2928 | $smcFunc['db_free_result']($result); |
@@ -2801,23 +2949,27 @@ discard block |
||
| 2801 | 2949 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2802 | 2950 | { |
| 2803 | 2951 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2804 | - if (empty($smcFunc['ucwords'])) |
|
| 2805 | - reloadSettings(); |
|
| 2952 | + if (empty($smcFunc['ucwords'])) { |
|
| 2953 | + reloadSettings(); |
|
| 2954 | + } |
|
| 2806 | 2955 | |
| 2807 | 2956 | // If we don't have our theme information yet, let's get it. |
| 2808 | - if (empty($settings['default_theme_dir'])) |
|
| 2809 | - loadTheme(0, false); |
|
| 2957 | + if (empty($settings['default_theme_dir'])) { |
|
| 2958 | + loadTheme(0, false); |
|
| 2959 | + } |
|
| 2810 | 2960 | |
| 2811 | 2961 | // Default language directories to try. |
| 2812 | 2962 | $language_directories = array( |
| 2813 | 2963 | $settings['default_theme_dir'] . '/languages', |
| 2814 | 2964 | ); |
| 2815 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2816 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2965 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 2966 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2967 | + } |
|
| 2817 | 2968 | |
| 2818 | 2969 | // We possibly have a base theme directory. |
| 2819 | - if (!empty($settings['base_theme_dir'])) |
|
| 2820 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2970 | + if (!empty($settings['base_theme_dir'])) { |
|
| 2971 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2972 | + } |
|
| 2821 | 2973 | |
| 2822 | 2974 | // Remove any duplicates. |
| 2823 | 2975 | $language_directories = array_unique($language_directories); |
@@ -2831,20 +2983,21 @@ discard block |
||
| 2831 | 2983 | foreach ($language_directories as $language_dir) |
| 2832 | 2984 | { |
| 2833 | 2985 | // Can't look in here... doesn't exist! |
| 2834 | - if (!file_exists($language_dir)) |
|
| 2835 | - continue; |
|
| 2986 | + if (!file_exists($language_dir)) { |
|
| 2987 | + continue; |
|
| 2988 | + } |
|
| 2836 | 2989 | |
| 2837 | 2990 | $dir = dir($language_dir); |
| 2838 | 2991 | while ($entry = $dir->read()) |
| 2839 | 2992 | { |
| 2840 | 2993 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 2841 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
| 2842 | - continue; |
|
| 2843 | - |
|
| 2844 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2845 | - $langName = $langList[$matches[1]]; |
|
| 2994 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
| 2995 | + continue; |
|
| 2996 | + } |
|
| 2846 | 2997 | |
| 2847 | - else |
|
| 2998 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 2999 | + $langName = $langList[$matches[1]]; |
|
| 3000 | + } else |
|
| 2848 | 3001 | { |
| 2849 | 3002 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2850 | 3003 | |
@@ -2885,12 +3038,14 @@ discard block |
||
| 2885 | 3038 | } |
| 2886 | 3039 | |
| 2887 | 3040 | // Do we need to store the lang list? |
| 2888 | - if (empty($langList)) |
|
| 2889 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3041 | + if (empty($langList)) { |
|
| 3042 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3043 | + } |
|
| 2890 | 3044 | |
| 2891 | 3045 | // Let's cash in on this deal. |
| 2892 | - if (!empty($modSettings['cache_enable'])) |
|
| 2893 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3046 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3047 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3048 | + } |
|
| 2894 | 3049 | } |
| 2895 | 3050 | |
| 2896 | 3051 | return $context['languages']; |
@@ -2913,8 +3068,9 @@ discard block |
||
| 2913 | 3068 | global $modSettings, $options, $txt; |
| 2914 | 3069 | static $censor_vulgar = null, $censor_proper; |
| 2915 | 3070 | |
| 2916 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2917 | - return $text; |
|
| 3071 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3072 | + return $text; |
|
| 3073 | + } |
|
| 2918 | 3074 | |
| 2919 | 3075 | // If they haven't yet been loaded, load them. |
| 2920 | 3076 | if ($censor_vulgar == null) |
@@ -2942,9 +3098,9 @@ discard block |
||
| 2942 | 3098 | { |
| 2943 | 3099 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 2944 | 3100 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3101 | + } else { |
|
| 3102 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2945 | 3103 | } |
| 2946 | - else |
|
| 2947 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2948 | 3104 | |
| 2949 | 3105 | return $text; |
| 2950 | 3106 | } |
@@ -2970,38 +3126,42 @@ discard block |
||
| 2970 | 3126 | @ini_set('track_errors', '1'); |
| 2971 | 3127 | |
| 2972 | 3128 | // Don't include the file more than once, if $once is true. |
| 2973 | - if ($once && in_array($filename, $templates)) |
|
| 2974 | - return; |
|
| 3129 | + if ($once && in_array($filename, $templates)) { |
|
| 3130 | + return; |
|
| 3131 | + } |
|
| 2975 | 3132 | // Add this file to the include list, whether $once is true or not. |
| 2976 | - else |
|
| 2977 | - $templates[] = $filename; |
|
| 3133 | + else { |
|
| 3134 | + $templates[] = $filename; |
|
| 3135 | + } |
|
| 2978 | 3136 | |
| 2979 | 3137 | // Are we going to use eval? |
| 2980 | 3138 | if (empty($modSettings['disableTemplateEval'])) |
| 2981 | 3139 | { |
| 2982 | 3140 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
| 2983 | 3141 | $settings['current_include_filename'] = $filename; |
| 2984 | - } |
|
| 2985 | - else |
|
| 3142 | + } else |
|
| 2986 | 3143 | { |
| 2987 | 3144 | $file_found = file_exists($filename); |
| 2988 | 3145 | |
| 2989 | - if ($once && $file_found) |
|
| 2990 | - require_once($filename); |
|
| 2991 | - elseif ($file_found) |
|
| 2992 | - require($filename); |
|
| 3146 | + if ($once && $file_found) { |
|
| 3147 | + require_once($filename); |
|
| 3148 | + } elseif ($file_found) { |
|
| 3149 | + require($filename); |
|
| 3150 | + } |
|
| 2993 | 3151 | } |
| 2994 | 3152 | |
| 2995 | 3153 | if ($file_found !== true) |
| 2996 | 3154 | { |
| 2997 | 3155 | ob_end_clean(); |
| 2998 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 2999 | - @ob_start('ob_gzhandler'); |
|
| 3000 | - else |
|
| 3001 | - ob_start(); |
|
| 3156 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3157 | + @ob_start('ob_gzhandler'); |
|
| 3158 | + } else { |
|
| 3159 | + ob_start(); |
|
| 3160 | + } |
|
| 3002 | 3161 | |
| 3003 | - if (isset($_GET['debug'])) |
|
| 3004 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3162 | + if (isset($_GET['debug'])) { |
|
| 3163 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3164 | + } |
|
| 3005 | 3165 | |
| 3006 | 3166 | // Don't cache error pages!! |
| 3007 | 3167 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3020,12 +3180,13 @@ discard block |
||
| 3020 | 3180 | echo '<!DOCTYPE html> |
| 3021 | 3181 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3022 | 3182 | <head>'; |
| 3023 | - if (isset($context['character_set'])) |
|
| 3024 | - echo ' |
|
| 3183 | + if (isset($context['character_set'])) { |
|
| 3184 | + echo ' |
|
| 3025 | 3185 | <meta charset="', $context['character_set'], '">'; |
| 3186 | + } |
|
| 3026 | 3187 | |
| 3027 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3028 | - echo ' |
|
| 3188 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3189 | + echo ' |
|
| 3029 | 3190 | <title>', $mtitle, '</title> |
| 3030 | 3191 | </head> |
| 3031 | 3192 | <body> |
@@ -3033,8 +3194,8 @@ discard block |
||
| 3033 | 3194 | ', $mmessage, ' |
| 3034 | 3195 | </body> |
| 3035 | 3196 | </html>'; |
| 3036 | - elseif (!allowedTo('admin_forum')) |
|
| 3037 | - echo ' |
|
| 3197 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3198 | + echo ' |
|
| 3038 | 3199 | <title>', $txt['template_parse_error'], '</title> |
| 3039 | 3200 | </head> |
| 3040 | 3201 | <body> |
@@ -3042,16 +3203,18 @@ discard block |
||
| 3042 | 3203 | ', $txt['template_parse_error_message'], ' |
| 3043 | 3204 | </body> |
| 3044 | 3205 | </html>'; |
| 3045 | - else |
|
| 3206 | + } else |
|
| 3046 | 3207 | { |
| 3047 | 3208 | require_once($sourcedir . '/Subs-Package.php'); |
| 3048 | 3209 | |
| 3049 | 3210 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3050 | 3211 | $error_array = error_get_last(); |
| 3051 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
| 3052 | - $error = $error_array['message']; |
|
| 3053 | - if (empty($error)) |
|
| 3054 | - $error = $txt['template_parse_errmsg']; |
|
| 3212 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
| 3213 | + $error = $error_array['message']; |
|
| 3214 | + } |
|
| 3215 | + if (empty($error)) { |
|
| 3216 | + $error = $txt['template_parse_errmsg']; |
|
| 3217 | + } |
|
| 3055 | 3218 | |
| 3056 | 3219 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3057 | 3220 | |
@@ -3062,11 +3225,12 @@ discard block |
||
| 3062 | 3225 | <h3>', $txt['template_parse_error'], '</h3> |
| 3063 | 3226 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3064 | 3227 | |
| 3065 | - if (!empty($error)) |
|
| 3066 | - echo ' |
|
| 3228 | + if (!empty($error)) { |
|
| 3229 | + echo ' |
|
| 3067 | 3230 | <hr> |
| 3068 | 3231 | |
| 3069 | 3232 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3233 | + } |
|
| 3070 | 3234 | |
| 3071 | 3235 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3072 | 3236 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3076,10 +3240,11 @@ discard block |
||
| 3076 | 3240 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3077 | 3241 | |
| 3078 | 3242 | // Fix the PHP code stuff... |
| 3079 | - if (!isBrowser('gecko')) |
|
| 3080 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3081 | - else |
|
| 3082 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3243 | + if (!isBrowser('gecko')) { |
|
| 3244 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3245 | + } else { |
|
| 3246 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3247 | + } |
|
| 3083 | 3248 | |
| 3084 | 3249 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3085 | 3250 | $j = -1; |
@@ -3087,8 +3252,9 @@ discard block |
||
| 3087 | 3252 | { |
| 3088 | 3253 | $j++; |
| 3089 | 3254 | |
| 3090 | - if (substr_count($line, '<br>') == 0) |
|
| 3091 | - continue; |
|
| 3255 | + if (substr_count($line, '<br>') == 0) { |
|
| 3256 | + continue; |
|
| 3257 | + } |
|
| 3092 | 3258 | |
| 3093 | 3259 | $n = substr_count($line, '<br>'); |
| 3094 | 3260 | for ($i = 0; $i < $n; $i++) |
@@ -3107,38 +3273,42 @@ discard block |
||
| 3107 | 3273 | // Figure out what the color coding was before... |
| 3108 | 3274 | $line = max($match[1] - 9, 1); |
| 3109 | 3275 | $last_line = ''; |
| 3110 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3111 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3276 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3277 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3112 | 3278 | { |
| 3113 | 3279 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3114 | 3280 | $last_line = $color_match[1]; |
| 3281 | + } |
|
| 3115 | 3282 | break; |
| 3116 | 3283 | } |
| 3117 | 3284 | |
| 3118 | 3285 | // Show the relevant lines... |
| 3119 | 3286 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3120 | 3287 | { |
| 3121 | - if ($line == $match[1]) |
|
| 3122 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3288 | + if ($line == $match[1]) { |
|
| 3289 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3290 | + } |
|
| 3123 | 3291 | |
| 3124 | 3292 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3125 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3126 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3293 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3294 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3295 | + } |
|
| 3127 | 3296 | |
| 3128 | 3297 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3129 | 3298 | { |
| 3130 | 3299 | $last_line = $color_match[1]; |
| 3131 | 3300 | echo '</', substr($last_line, 1, 4), '>'; |
| 3301 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3302 | + $last_line = ''; |
|
| 3303 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3304 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3132 | 3305 | } |
| 3133 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3134 | - $last_line = ''; |
|
| 3135 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3136 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3137 | 3306 | |
| 3138 | - if ($line == $match[1]) |
|
| 3139 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3140 | - else |
|
| 3141 | - echo "\n"; |
|
| 3307 | + if ($line == $match[1]) { |
|
| 3308 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3309 | + } else { |
|
| 3310 | + echo "\n"; |
|
| 3311 | + } |
|
| 3142 | 3312 | } |
| 3143 | 3313 | |
| 3144 | 3314 | echo '</pre></div>'; |
@@ -3162,8 +3332,9 @@ discard block |
||
| 3162 | 3332 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
| 3163 | 3333 | |
| 3164 | 3334 | // Figure out what type of database we are using. |
| 3165 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3166 | - $db_type = 'mysql'; |
|
| 3335 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3336 | + $db_type = 'mysql'; |
|
| 3337 | + } |
|
| 3167 | 3338 | |
| 3168 | 3339 | // Load the file for the database. |
| 3169 | 3340 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3171,8 +3342,9 @@ discard block |
||
| 3171 | 3342 | $db_options = array(); |
| 3172 | 3343 | |
| 3173 | 3344 | // Add in the port if needed |
| 3174 | - if (!empty($db_port)) |
|
| 3175 | - $db_options['port'] = $db_port; |
|
| 3345 | + if (!empty($db_port)) { |
|
| 3346 | + $db_options['port'] = $db_port; |
|
| 3347 | + } |
|
| 3176 | 3348 | |
| 3177 | 3349 | // 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. |
| 3178 | 3350 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3191,13 +3363,15 @@ discard block |
||
| 3191 | 3363 | } |
| 3192 | 3364 | |
| 3193 | 3365 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3194 | - if (!$db_connection) |
|
| 3195 | - display_db_error(); |
|
| 3366 | + if (!$db_connection) { |
|
| 3367 | + display_db_error(); |
|
| 3368 | + } |
|
| 3196 | 3369 | |
| 3197 | 3370 | // If in SSI mode fix up the prefix. |
| 3198 | - if (SMF == 'SSI') |
|
| 3199 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3200 | -} |
|
| 3371 | + if (SMF == 'SSI') { |
|
| 3372 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3373 | + } |
|
| 3374 | + } |
|
| 3201 | 3375 | |
| 3202 | 3376 | /** |
| 3203 | 3377 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3211,10 +3385,11 @@ discard block |
||
| 3211 | 3385 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3212 | 3386 | |
| 3213 | 3387 | // Not overriding this and we have a cacheAPI, send it back. |
| 3214 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3215 | - return $cacheAPI; |
|
| 3216 | - elseif (is_null($cacheAPI)) |
|
| 3217 | - $cacheAPI = false; |
|
| 3388 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3389 | + return $cacheAPI; |
|
| 3390 | + } elseif (is_null($cacheAPI)) { |
|
| 3391 | + $cacheAPI = false; |
|
| 3392 | + } |
|
| 3218 | 3393 | |
| 3219 | 3394 | // Make sure our class is in session. |
| 3220 | 3395 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3235,8 +3410,9 @@ discard block |
||
| 3235 | 3410 | if (!$testAPI->isSupported()) |
| 3236 | 3411 | { |
| 3237 | 3412 | // Can we save ourselves? |
| 3238 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3239 | - return loadCacheAccelerator(null, false); |
|
| 3413 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3414 | + return loadCacheAccelerator(null, false); |
|
| 3415 | + } |
|
| 3240 | 3416 | return false; |
| 3241 | 3417 | } |
| 3242 | 3418 | |
@@ -3248,9 +3424,9 @@ discard block |
||
| 3248 | 3424 | { |
| 3249 | 3425 | $cacheAPI = $testAPI; |
| 3250 | 3426 | return $cacheAPI; |
| 3427 | + } else { |
|
| 3428 | + return $testAPI; |
|
| 3251 | 3429 | } |
| 3252 | - else |
|
| 3253 | - return $testAPI; |
|
| 3254 | 3430 | } |
| 3255 | 3431 | } |
| 3256 | 3432 | |
@@ -3270,8 +3446,9 @@ discard block |
||
| 3270 | 3446 | |
| 3271 | 3447 | // @todo Why are we doing this if caching is disabled? |
| 3272 | 3448 | |
| 3273 | - if (function_exists('call_integration_hook')) |
|
| 3274 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3449 | + if (function_exists('call_integration_hook')) { |
|
| 3450 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3451 | + } |
|
| 3275 | 3452 | |
| 3276 | 3453 | /* Refresh the cache if either: |
| 3277 | 3454 | 1. Caching is disabled. |
@@ -3285,16 +3462,19 @@ discard block |
||
| 3285 | 3462 | require_once($sourcedir . '/' . $file); |
| 3286 | 3463 | $cache_block = call_user_func_array($function, $params); |
| 3287 | 3464 | |
| 3288 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3289 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3465 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3466 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3467 | + } |
|
| 3290 | 3468 | } |
| 3291 | 3469 | |
| 3292 | 3470 | // Some cached data may need a freshening up after retrieval. |
| 3293 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3294 | - eval($cache_block['post_retri_eval']); |
|
| 3471 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3472 | + eval($cache_block['post_retri_eval']); |
|
| 3473 | + } |
|
| 3295 | 3474 | |
| 3296 | - if (function_exists('call_integration_hook')) |
|
| 3297 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3475 | + if (function_exists('call_integration_hook')) { |
|
| 3476 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3477 | + } |
|
| 3298 | 3478 | |
| 3299 | 3479 | return $cache_block['data']; |
| 3300 | 3480 | } |
@@ -3321,8 +3501,9 @@ discard block |
||
| 3321 | 3501 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3322 | 3502 | global $cache_hits, $cache_count, $db_show_debug; |
| 3323 | 3503 | |
| 3324 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3325 | - return; |
|
| 3504 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3505 | + return; |
|
| 3506 | + } |
|
| 3326 | 3507 | |
| 3327 | 3508 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3328 | 3509 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3335,12 +3516,14 @@ discard block |
||
| 3335 | 3516 | $value = $value === null ? null : $smcFunc['json_encode']($value); |
| 3336 | 3517 | $cacheAPI->putData($key, $value, $ttl); |
| 3337 | 3518 | |
| 3338 | - if (function_exists('call_integration_hook')) |
|
| 3339 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3519 | + if (function_exists('call_integration_hook')) { |
|
| 3520 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3521 | + } |
|
| 3340 | 3522 | |
| 3341 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3342 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3343 | -} |
|
| 3523 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3524 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3525 | + } |
|
| 3526 | + } |
|
| 3344 | 3527 | |
| 3345 | 3528 | /** |
| 3346 | 3529 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3356,8 +3539,9 @@ discard block |
||
| 3356 | 3539 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3357 | 3540 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3358 | 3541 | |
| 3359 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3360 | - return; |
|
| 3542 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3543 | + return; |
|
| 3544 | + } |
|
| 3361 | 3545 | |
| 3362 | 3546 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3363 | 3547 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3377,16 +3561,18 @@ discard block |
||
| 3377 | 3561 | |
| 3378 | 3562 | if (empty($value)) |
| 3379 | 3563 | { |
| 3380 | - if (!is_array($cache_misses)) |
|
| 3381 | - $cache_misses = array(); |
|
| 3564 | + if (!is_array($cache_misses)) { |
|
| 3565 | + $cache_misses = array(); |
|
| 3566 | + } |
|
| 3382 | 3567 | |
| 3383 | 3568 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3384 | 3569 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3385 | 3570 | } |
| 3386 | 3571 | } |
| 3387 | 3572 | |
| 3388 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3389 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3573 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3574 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3575 | + } |
|
| 3390 | 3576 | |
| 3391 | 3577 | return empty($value) ? null : $smcFunc['json_decode']($value, true); |
| 3392 | 3578 | } |
@@ -3408,8 +3594,9 @@ discard block |
||
| 3408 | 3594 | global $cacheAPI; |
| 3409 | 3595 | |
| 3410 | 3596 | // If we can't get to the API, can't do this. |
| 3411 | - if (empty($cacheAPI)) |
|
| 3412 | - return; |
|
| 3597 | + if (empty($cacheAPI)) { |
|
| 3598 | + return; |
|
| 3599 | + } |
|
| 3413 | 3600 | |
| 3414 | 3601 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3415 | 3602 | $cacheAPI->cleanCache($type); |
@@ -3434,8 +3621,9 @@ discard block |
||
| 3434 | 3621 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
| 3435 | 3622 | |
| 3436 | 3623 | // Come on! |
| 3437 | - if (empty($data)) |
|
| 3438 | - return array(); |
|
| 3624 | + if (empty($data)) { |
|
| 3625 | + return array(); |
|
| 3626 | + } |
|
| 3439 | 3627 | |
| 3440 | 3628 | // Set a nice default var. |
| 3441 | 3629 | $image = ''; |
@@ -3443,11 +3631,11 @@ discard block |
||
| 3443 | 3631 | // Gravatar has been set as mandatory! |
| 3444 | 3632 | if (!empty($modSettings['gravatarOverride'])) |
| 3445 | 3633 | { |
| 3446 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3447 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3448 | - |
|
| 3449 | - else if (!empty($data['email'])) |
|
| 3450 | - $image = get_gravatar_url($data['email']); |
|
| 3634 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3635 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3636 | + } else if (!empty($data['email'])) { |
|
| 3637 | + $image = get_gravatar_url($data['email']); |
|
| 3638 | + } |
|
| 3451 | 3639 | } |
| 3452 | 3640 | |
| 3453 | 3641 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3459,54 +3647,60 @@ discard block |
||
| 3459 | 3647 | // Gravatar. |
| 3460 | 3648 | if (stristr($data['avatar'], 'gravatar://')) |
| 3461 | 3649 | { |
| 3462 | - if ($data['avatar'] == 'gravatar://') |
|
| 3463 | - $image = get_gravatar_url($data['email']); |
|
| 3464 | - |
|
| 3465 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3466 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3650 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3651 | + $image = get_gravatar_url($data['email']); |
|
| 3652 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3653 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3654 | + } |
|
| 3467 | 3655 | } |
| 3468 | 3656 | |
| 3469 | 3657 | // External url. |
| 3470 | 3658 | else |
| 3471 | 3659 | { |
| 3472 | 3660 | // Using ssl? |
| 3473 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
| 3474 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3661 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
| 3662 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3663 | + } |
|
| 3475 | 3664 | |
| 3476 | 3665 | // Just a plain external url. |
| 3477 | - else |
|
| 3478 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3666 | + else { |
|
| 3667 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3668 | + } |
|
| 3479 | 3669 | } |
| 3480 | 3670 | } |
| 3481 | 3671 | |
| 3482 | 3672 | // Perhaps this user has an attachment as avatar... |
| 3483 | - else if (!empty($data['filename'])) |
|
| 3484 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3673 | + else if (!empty($data['filename'])) { |
|
| 3674 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3675 | + } |
|
| 3485 | 3676 | |
| 3486 | 3677 | // Right... no avatar... use our default image. |
| 3487 | - else |
|
| 3488 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3678 | + else { |
|
| 3679 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3680 | + } |
|
| 3489 | 3681 | } |
| 3490 | 3682 | |
| 3491 | 3683 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3492 | 3684 | |
| 3493 | 3685 | // 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. |
| 3494 | - if (!empty($image)) |
|
| 3495 | - return array( |
|
| 3686 | + if (!empty($image)) { |
|
| 3687 | + return array( |
|
| 3496 | 3688 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3497 | 3689 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3498 | 3690 | 'href' => $image, |
| 3499 | 3691 | 'url' => $image, |
| 3500 | 3692 | ); |
| 3693 | + } |
|
| 3501 | 3694 | |
| 3502 | 3695 | // Fallback to make life easier for everyone... |
| 3503 | - else |
|
| 3504 | - return array( |
|
| 3696 | + else { |
|
| 3697 | + return array( |
|
| 3505 | 3698 | 'name' => '', |
| 3506 | 3699 | 'image' => '', |
| 3507 | 3700 | 'href' => '', |
| 3508 | 3701 | 'url' => '', |
| 3509 | 3702 | ); |
| 3510 | -} |
|
| 3703 | + } |
|
| 3704 | + } |
|
| 3511 | 3705 | |
| 3512 | 3706 | ?> |
| 3513 | 3707 | \ No newline at end of file |
@@ -41,37 +41,43 @@ discard block |
||
| 41 | 41 | define('TIME_START', microtime(true)); |
| 42 | 42 | |
| 43 | 43 | // Just being safe... |
| 44 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 44 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 45 | 45 | if (isset($GLOBALS[$variable])) |
| 46 | 46 | unset($GLOBALS[$variable]); |
| 47 | +} |
|
| 47 | 48 | |
| 48 | 49 | // Get the forum's settings for database and file paths. |
| 49 | 50 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 50 | 51 | |
| 51 | 52 | // Make absolutely sure the cache directory is defined. |
| 52 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 53 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 53 | 54 | $cachedir = $boarddir . '/cache'; |
| 55 | +} |
|
| 54 | 56 | |
| 55 | 57 | // Don't do john didley if the forum's been shut down competely. |
| 56 | -if ($maintenance == 2) |
|
| 58 | +if ($maintenance == 2) { |
|
| 57 | 59 | die($mmessage); |
| 60 | +} |
|
| 58 | 61 | |
| 59 | 62 | // Fix for using the current directory as a path. |
| 60 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 61 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 65 | +} |
|
| 62 | 66 | |
| 63 | 67 | // Have we already turned this off? If so, exist gracefully. |
| 64 | -if (file_exists($cachedir . '/cron.lock')) |
|
| 68 | +if (file_exists($cachedir . '/cron.lock')) { |
|
| 65 | 69 | obExit_cron(); |
| 70 | +} |
|
| 66 | 71 | |
| 67 | 72 | // Before we go any further, if this is not a CLI request, we need to do some checking. |
| 68 | 73 | if (!FROM_CLI) |
| 69 | 74 | { |
| 70 | 75 | // We will clean up $_GET shortly. But we want to this ASAP. |
| 71 | 76 | $ts = isset($_GET['ts']) ? (int) $_GET['ts'] : 0; |
| 72 | - if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) |
|
| 73 | - obExit_cron(); |
|
| 74 | -} |
|
| 77 | + if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) { |
|
| 78 | + obExit_cron(); |
|
| 79 | + } |
|
| 80 | + } |
|
| 75 | 81 | |
| 76 | 82 | // Load the most important includes. In general, a background should be loading its own dependencies. |
| 77 | 83 | require_once($sourcedir . '/Errors.php'); |
@@ -123,8 +129,9 @@ discard block |
||
| 123 | 129 | global $smcFunc; |
| 124 | 130 | |
| 125 | 131 | // Check we haven't run over our time limit. |
| 126 | - if (microtime(true) - TIME_START > MAX_CRON_TIME) |
|
| 127 | - return false; |
|
| 132 | + if (microtime(true) - TIME_START > MAX_CRON_TIME) { |
|
| 133 | + return false; |
|
| 134 | + } |
|
| 128 | 135 | |
| 129 | 136 | // Try to find a task. Specifically, try to find one that hasn't been claimed previously, or failing that, |
| 130 | 137 | // a task that was claimed but failed for whatever reason and failed long enough ago. We should not care |
@@ -159,14 +166,12 @@ discard block |
||
| 159 | 166 | // Update the time and go back. |
| 160 | 167 | $row['claimed_time'] = time(); |
| 161 | 168 | return $row; |
| 162 | - } |
|
| 163 | - else |
|
| 169 | + } else |
|
| 164 | 170 | { |
| 165 | 171 | // Uh oh, we just missed it. Try to claim another one, and let it fall through if there aren't any. |
| 166 | 172 | return fetch_task(); |
| 167 | 173 | } |
| 168 | - } |
|
| 169 | - else |
|
| 174 | + } else |
|
| 170 | 175 | { |
| 171 | 176 | // No dice. Clean up and go home. |
| 172 | 177 | $smcFunc['db_free_result']($request); |
@@ -187,8 +192,9 @@ discard block |
||
| 187 | 192 | if (!empty($task_details['task_file'])) |
| 188 | 193 | { |
| 189 | 194 | $include = strtr(trim($task_details['task_file']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 190 | - if (file_exists($include)) |
|
| 191 | - require_once($include); |
|
| 195 | + if (file_exists($include)) { |
|
| 196 | + require_once($include); |
|
| 197 | + } |
|
| 192 | 198 | } |
| 193 | 199 | |
| 194 | 200 | if (empty($task_details['task_class'])) |
@@ -204,8 +210,7 @@ discard block |
||
| 204 | 210 | $details = empty($task_details['task_data']) ? array() : $smcFunc['json_decode']($task_details['task_data'], true); |
| 205 | 211 | $bgtask = new $task_details['task_class']($details); |
| 206 | 212 | return $bgtask->execute(); |
| 207 | - } |
|
| 208 | - else |
|
| 213 | + } else |
|
| 209 | 214 | { |
| 210 | 215 | log_error('Invalid background task specified: (class: ' . $task_details['task_class'] . ', ' . (empty($task_details['task_file']) ? ' no file' : ' to load ' . $task_details['task_file']) . ')'); |
| 211 | 216 | return true; // So we clear it from the queue. |
@@ -224,8 +229,9 @@ discard block |
||
| 224 | 229 | $scripturl = $boardurl . '/index.php'; |
| 225 | 230 | |
| 226 | 231 | // These keys shouldn't be set...ever. |
| 227 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 228 | - die('Invalid request variable.'); |
|
| 232 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 233 | + die('Invalid request variable.'); |
|
| 234 | + } |
|
| 229 | 235 | |
| 230 | 236 | // Save some memory.. (since we don't use these anyway.) |
| 231 | 237 | unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_VARS']); |
@@ -246,26 +252,28 @@ discard block |
||
| 246 | 252 | global $modSettings; |
| 247 | 253 | |
| 248 | 254 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
| 249 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
| 250 | - return; |
|
| 255 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 251 | 258 | |
| 252 | 259 | $error_type = 'cron'; |
| 253 | 260 | |
| 254 | 261 | log_error($error_level . ': ' . $error_string, $error_type, $file, $line); |
| 255 | 262 | |
| 256 | 263 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 257 | - if ($error_level % 255 == E_ERROR) |
|
| 258 | - die('No direct access...'); |
|
| 259 | -} |
|
| 264 | + if ($error_level % 255 == E_ERROR) { |
|
| 265 | + die('No direct access...'); |
|
| 266 | + } |
|
| 267 | + } |
|
| 260 | 268 | |
| 261 | 269 | /** |
| 262 | 270 | * The exit function |
| 263 | 271 | */ |
| 264 | 272 | function obExit_cron() |
| 265 | 273 | { |
| 266 | - if (FROM_CLI) |
|
| 267 | - die(0); |
|
| 268 | - else |
|
| 274 | + if (FROM_CLI) { |
|
| 275 | + die(0); |
|
| 276 | + } else |
|
| 269 | 277 | { |
| 270 | 278 | header('Content-Type: image/gif'); |
| 271 | 279 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
@@ -31,12 +31,13 @@ discard block |
||
| 31 | 31 | </div> |
| 32 | 32 | <div class="information">'; |
| 33 | 33 | |
| 34 | - if ($context['is_installed']) |
|
| 35 | - echo ' |
|
| 34 | + if ($context['is_installed']) { |
|
| 35 | + echo ' |
|
| 36 | 36 | <strong>', $txt['package_installed_warning1'], '</strong><br> |
| 37 | 37 | <br> |
| 38 | 38 | ', $txt['package_installed_warning2'], '<br> |
| 39 | 39 | <br>'; |
| 40 | + } |
|
| 40 | 41 | |
| 41 | 42 | echo $txt['package_installed_warning3'], ' |
| 42 | 43 | </div><br>'; |
@@ -63,8 +64,9 @@ discard block |
||
| 63 | 64 | ', $context['package_readme'], ' |
| 64 | 65 | <span class="floatright">', $txt['package_available_readme_language'], ' |
| 65 | 66 | <select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">'; |
| 66 | - foreach ($context['readmes'] as $a => $b) |
|
| 67 | - echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
|
| 67 | + foreach ($context['readmes'] as $a => $b) { |
|
| 68 | + echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
|
| 69 | + } |
|
| 68 | 70 | echo ' |
| 69 | 71 | </select> |
| 70 | 72 | </span> |
@@ -83,8 +85,9 @@ discard block |
||
| 83 | 85 | ', $context['package_license'], ' |
| 84 | 86 | <span class="floatright">', $txt['package_available_license_language'], ' |
| 85 | 87 | <select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">'; |
| 86 | - foreach ($context['licenses'] as $a => $b) |
|
| 87 | - echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
|
| 88 | + foreach ($context['licenses'] as $a => $b) { |
|
| 89 | + echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
|
| 90 | + } |
|
| 88 | 91 | echo ' |
| 89 | 92 | </select> |
| 90 | 93 | </span> |
@@ -111,9 +114,10 @@ discard block |
||
| 111 | 114 | ', $txt['package_db_uninstall_actions'], ': |
| 112 | 115 | <ul>'; |
| 113 | 116 | |
| 114 | - foreach ($context['database_changes'] as $change) |
|
| 115 | - echo ' |
|
| 117 | + foreach ($context['database_changes'] as $change) { |
|
| 118 | + echo ' |
|
| 116 | 119 | <li>', $change, '</li>'; |
| 120 | + } |
|
| 117 | 121 | echo ' |
| 118 | 122 | </ul> |
| 119 | 123 | </div> |
@@ -123,14 +127,14 @@ discard block |
||
| 123 | 127 | echo ' |
| 124 | 128 | <div class="information">'; |
| 125 | 129 | |
| 126 | - if (empty($context['actions']) && empty($context['database_changes'])) |
|
| 127 | - echo ' |
|
| 130 | + if (empty($context['actions']) && empty($context['database_changes'])) { |
|
| 131 | + echo ' |
|
| 128 | 132 | <br> |
| 129 | 133 | <div class="errorbox"> |
| 130 | 134 | ', $txt['corrupt_compatible'], ' |
| 131 | 135 | </div> |
| 132 | 136 | </div>'; |
| 133 | - else |
|
| 137 | + } else |
|
| 134 | 138 | { |
| 135 | 139 | echo ' |
| 136 | 140 | ', $txt['perform_actions'], ' |
@@ -230,9 +234,10 @@ discard block |
||
| 230 | 234 | <tr class="title_bar"> |
| 231 | 235 | <td></td> |
| 232 | 236 | <td>'; |
| 233 | - if (!empty($context['themes_locked'])) |
|
| 234 | - echo ' |
|
| 237 | + if (!empty($context['themes_locked'])) { |
|
| 238 | + echo ' |
|
| 235 | 239 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
| 240 | + } |
|
| 236 | 241 | echo ' |
| 237 | 242 | <input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" class="input_check" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '> |
| 238 | 243 | </td> |
@@ -373,14 +378,15 @@ discard block |
||
| 373 | 378 | </script>'; |
| 374 | 379 | |
| 375 | 380 | // And a bit more for database changes. |
| 376 | - if (!empty($context['database_changes'])) |
|
| 377 | - echo ' |
|
| 381 | + if (!empty($context['database_changes'])) { |
|
| 382 | + echo ' |
|
| 378 | 383 | <script> |
| 379 | 384 | var database_changes_area = document.getElementById(\'db_changes_div\'); |
| 380 | 385 | var db_vis = false; |
| 381 | 386 | database_changes_area.style.display = "none"; |
| 382 | 387 | </script>'; |
| 383 | -} |
|
| 388 | + } |
|
| 389 | + } |
|
| 384 | 390 | |
| 385 | 391 | /** |
| 386 | 392 | * Extract package contents |
@@ -412,12 +418,12 @@ discard block |
||
| 412 | 418 | <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3> |
| 413 | 419 | </div> |
| 414 | 420 | <div class="information">', $txt['package_installed_extract'], '</div>'; |
| 415 | - } |
|
| 416 | - else |
|
| 417 | - echo ' |
|
| 421 | + } else { |
|
| 422 | + echo ' |
|
| 418 | 423 | <div class="cat_bar"> |
| 419 | 424 | <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3> |
| 420 | 425 | </div>'; |
| 426 | + } |
|
| 421 | 427 | |
| 422 | 428 | echo ' |
| 423 | 429 | <div class="windowbg">'; |
@@ -428,25 +434,25 @@ discard block |
||
| 428 | 434 | echo ' |
| 429 | 435 | ', $context['redirect_text'], '<br><br> |
| 430 | 436 | <a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>'; |
| 431 | - } |
|
| 432 | - elseif ($context['uninstalling']) |
|
| 433 | - echo ' |
|
| 437 | + } elseif ($context['uninstalling']) { |
|
| 438 | + echo ' |
|
| 434 | 439 | ', $txt['package_uninstall_done']; |
| 435 | - elseif ($context['install_finished']) |
|
| 440 | + } elseif ($context['install_finished']) |
|
| 436 | 441 | { |
| 437 | - if ($context['extract_type'] == 'avatar') |
|
| 438 | - echo ' |
|
| 442 | + if ($context['extract_type'] == 'avatar') { |
|
| 443 | + echo ' |
|
| 439 | 444 | ', $txt['avatars_extracted']; |
| 440 | - elseif ($context['extract_type'] == 'language') |
|
| 441 | - echo ' |
|
| 445 | + } elseif ($context['extract_type'] == 'language') { |
|
| 446 | + echo ' |
|
| 442 | 447 | ', $txt['language_extracted']; |
| 443 | - else |
|
| 444 | - echo ' |
|
| 448 | + } else { |
|
| 449 | + echo ' |
|
| 445 | 450 | ', $txt['package_installed_done']; |
| 446 | - } |
|
| 447 | - else |
|
| 448 | - echo ' |
|
| 451 | + } |
|
| 452 | + } else { |
|
| 453 | + echo ' |
|
| 449 | 454 | ', $txt['corrupt_compatible']; |
| 455 | + } |
|
| 450 | 456 | |
| 451 | 457 | echo ' |
| 452 | 458 | </div>'; |
@@ -480,9 +486,10 @@ discard block |
||
| 480 | 486 | <div class="windowbg"> |
| 481 | 487 | <ol>'; |
| 482 | 488 | |
| 483 | - foreach ($context['files'] as $fileinfo) |
|
| 484 | - echo ' |
|
| 489 | + foreach ($context['files'] as $fileinfo) { |
|
| 490 | + echo ' |
|
| 485 | 491 | <li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>'; |
| 492 | + } |
|
| 486 | 493 | |
| 487 | 494 | echo ' |
| 488 | 495 | </ol> |
@@ -546,9 +553,10 @@ discard block |
||
| 546 | 553 | </script> |
| 547 | 554 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
| 548 | 555 | |
| 549 | - if (empty($modSettings['disable_smf_js'])) |
|
| 550 | - echo ' |
|
| 556 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 557 | + echo ' |
|
| 551 | 558 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 559 | + } |
|
| 552 | 560 | |
| 553 | 561 | // This sets the announcements and current versions themselves ;). |
| 554 | 562 | echo ' |
@@ -587,12 +595,13 @@ discard block |
||
| 587 | 595 | } |
| 588 | 596 | } |
| 589 | 597 | |
| 590 | - if (!$mods_available) |
|
| 591 | - echo ' |
|
| 598 | + if (!$mods_available) { |
|
| 599 | + echo ' |
|
| 592 | 600 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
| 593 | - else |
|
| 594 | - echo ' |
|
| 601 | + } else { |
|
| 602 | + echo ' |
|
| 595 | 603 | <br>'; |
| 604 | + } |
|
| 596 | 605 | |
| 597 | 606 | // the advanced (emulation) box, collapsed by default |
| 598 | 607 | echo ' |
@@ -681,11 +690,12 @@ discard block |
||
| 681 | 690 | { |
| 682 | 691 | global $context, $txt, $scripturl; |
| 683 | 692 | |
| 684 | - if (!empty($context['package_ftp']['error'])) |
|
| 685 | - echo ' |
|
| 693 | + if (!empty($context['package_ftp']['error'])) { |
|
| 694 | + echo ' |
|
| 686 | 695 | <div class="errorbox"> |
| 687 | 696 | <pre>', $context['package_ftp']['error'], '</pre> |
| 688 | 697 | </div>'; |
| 698 | + } |
|
| 689 | 699 | |
| 690 | 700 | echo ' |
| 691 | 701 | <div id="admin_form_wrapper"> |
@@ -766,13 +776,14 @@ discard block |
||
| 766 | 776 | <fieldset> |
| 767 | 777 | <legend>' . $txt['package_servers'] . '</legend> |
| 768 | 778 | <ul class="package_servers">'; |
| 769 | - foreach ($context['servers'] as $server) |
|
| 770 | - echo ' |
|
| 779 | + foreach ($context['servers'] as $server) { |
|
| 780 | + echo ' |
|
| 771 | 781 | <li class="flow_auto"> |
| 772 | 782 | <span class="floatleft">' . $server['name'] . '</span> |
| 773 | 783 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span> |
| 774 | 784 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
| 775 | 785 | </li>'; |
| 786 | + } |
|
| 776 | 787 | echo ' |
| 777 | 788 | </ul> |
| 778 | 789 | </fieldset> |
@@ -859,11 +870,12 @@ discard block |
||
| 859 | 870 | <div class="windowbg2">'; |
| 860 | 871 | |
| 861 | 872 | // No packages, as yet. |
| 862 | - if (empty($context['package_list'])) |
|
| 863 | - echo ' |
|
| 873 | + if (empty($context['package_list'])) { |
|
| 874 | + echo ' |
|
| 864 | 875 | <ul> |
| 865 | 876 | <li>', $txt['no_packages'], '</li> |
| 866 | 877 | </ul>'; |
| 878 | + } |
|
| 867 | 879 | // List out the packages... |
| 868 | 880 | else |
| 869 | 881 | { |
@@ -875,11 +887,12 @@ discard block |
||
| 875 | 887 | <li> |
| 876 | 888 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
| 877 | 889 | |
| 878 | - if (!empty($packageSection['text'])) |
|
| 879 | - echo ' |
|
| 890 | + if (!empty($packageSection['text'])) { |
|
| 891 | + echo ' |
|
| 880 | 892 | <div class="sub_bar"> |
| 881 | 893 | <h3 class="subbg">', $packageSection['text'], '</h3> |
| 882 | 894 | </div>'; |
| 895 | + } |
|
| 883 | 896 | |
| 884 | 897 | echo ' |
| 885 | 898 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
@@ -889,13 +902,15 @@ discard block |
||
| 889 | 902 | echo ' |
| 890 | 903 | <li>'; |
| 891 | 904 | // Textual message. Could be empty just for a blank line... |
| 892 | - if ($package['is_text']) |
|
| 893 | - echo ' |
|
| 905 | + if ($package['is_text']) { |
|
| 906 | + echo ' |
|
| 894 | 907 | ', empty($package['name']) ? ' ' : $package['name']; |
| 908 | + } |
|
| 895 | 909 | // This is supposed to be a rule.. |
| 896 | - elseif ($package['is_line']) |
|
| 897 | - echo ' |
|
| 910 | + elseif ($package['is_line']) { |
|
| 911 | + echo ' |
|
| 898 | 912 | <hr>'; |
| 913 | + } |
|
| 899 | 914 | // A remote link. |
| 900 | 915 | elseif ($package['is_remote']) |
| 901 | 916 | { |
@@ -917,21 +932,25 @@ discard block |
||
| 917 | 932 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
| 918 | 933 | |
| 919 | 934 | // Show the mod type? |
| 920 | - if ($package['type'] != '') |
|
| 921 | - echo ' |
|
| 935 | + if ($package['type'] != '') { |
|
| 936 | + echo ' |
|
| 922 | 937 | <li class="package_section">', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>'; |
| 938 | + } |
|
| 923 | 939 | // Show the version number? |
| 924 | - if ($package['version'] != '') |
|
| 925 | - echo ' |
|
| 940 | + if ($package['version'] != '') { |
|
| 941 | + echo ' |
|
| 926 | 942 | <li class="package_section">', $txt['mod_version'], ': ', $package['version'], '</li>'; |
| 943 | + } |
|
| 927 | 944 | // How 'bout the author? |
| 928 | - if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
|
| 929 | - echo ' |
|
| 945 | + if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) { |
|
| 946 | + echo ' |
|
| 930 | 947 | <li class="package_section">', $txt['mod_author'], ': ', $package['author']['link'], '</li>'; |
| 948 | + } |
|
| 931 | 949 | // The homepage.... |
| 932 | - if ($package['author']['website']['link'] != '') |
|
| 933 | - echo ' |
|
| 950 | + if ($package['author']['website']['link'] != '') { |
|
| 951 | + echo ' |
|
| 934 | 952 | <li class="package_section">', $txt['author_website'], ': ', $package['author']['website']['link'], '</li>'; |
| 953 | + } |
|
| 935 | 954 | |
| 936 | 955 | // Desciption: bleh bleh! |
| 937 | 956 | // Location of file: http://someplace/. |
@@ -984,8 +1003,8 @@ discard block |
||
| 984 | 1003 | |
| 985 | 1004 | foreach ($ps['items'] as $id => $package) |
| 986 | 1005 | { |
| 987 | - if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
|
| 988 | - echo ' |
|
| 1006 | + if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) { |
|
| 1007 | + echo ' |
|
| 989 | 1008 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
| 990 | 1009 | bToggleEnabled: true, |
| 991 | 1010 | bCurrentlyCollapsed: true, |
@@ -1000,6 +1019,7 @@ discard block |
||
| 1000 | 1019 | } |
| 1001 | 1020 | ] |
| 1002 | 1021 | });'; |
| 1022 | + } |
|
| 1003 | 1023 | } |
| 1004 | 1024 | } |
| 1005 | 1025 | echo ' |
@@ -1040,9 +1060,10 @@ discard block |
||
| 1040 | 1060 | { |
| 1041 | 1061 | global $context, $txt, $scripturl; |
| 1042 | 1062 | |
| 1043 | - if (!empty($context['saved_successful'])) |
|
| 1044 | - echo ' |
|
| 1063 | + if (!empty($context['saved_successful'])) { |
|
| 1064 | + echo ' |
|
| 1045 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1066 | + } |
|
| 1046 | 1067 | |
| 1047 | 1068 | echo ' |
| 1048 | 1069 | <div id="admincenter"> |
@@ -1104,8 +1125,9 @@ discard block |
||
| 1104 | 1125 | global $context, $txt; |
| 1105 | 1126 | |
| 1106 | 1127 | // Nothing to do? Brilliant! |
| 1107 | - if (empty($context['package_ftp'])) |
|
| 1108 | - return false; |
|
| 1128 | + if (empty($context['package_ftp'])) { |
|
| 1129 | + return false; |
|
| 1130 | + } |
|
| 1109 | 1131 | |
| 1110 | 1132 | if (empty($context['package_ftp']['form_elements_only'])) |
| 1111 | 1133 | { |
@@ -1114,19 +1136,21 @@ discard block |
||
| 1114 | 1136 | <div id="need_writable_list" class="smalltext"> |
| 1115 | 1137 | ', $txt['package_ftp_why_file_list'], ' |
| 1116 | 1138 | <ul style="display: inline;">'; |
| 1117 | - if (!empty($context['notwritable_files'])) |
|
| 1118 | - foreach ($context['notwritable_files'] as $file) |
|
| 1139 | + if (!empty($context['notwritable_files'])) { |
|
| 1140 | + foreach ($context['notwritable_files'] as $file) |
|
| 1119 | 1141 | echo ' |
| 1120 | 1142 | <li>', $file, '</li>'; |
| 1143 | + } |
|
| 1121 | 1144 | |
| 1122 | 1145 | echo ' |
| 1123 | 1146 | </ul>'; |
| 1124 | 1147 | |
| 1125 | - if (!$context['server']['is_windows']) |
|
| 1126 | - echo ' |
|
| 1148 | + if (!$context['server']['is_windows']) { |
|
| 1149 | + echo ' |
|
| 1127 | 1150 | <hr> |
| 1128 | 1151 | ', $txt['package_chmod_linux'], '<br /> |
| 1129 | 1152 | <tt># chmod a+w ', implode(' ', $context['notwritable_files']), '</tt>'; |
| 1153 | + } |
|
| 1130 | 1154 | |
| 1131 | 1155 | echo ' |
| 1132 | 1156 | </div>'; |
@@ -1137,9 +1161,10 @@ discard block |
||
| 1137 | 1161 | <tt id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</tt> |
| 1138 | 1162 | </div></div>'; |
| 1139 | 1163 | |
| 1140 | - if (!empty($context['package_ftp']['destination'])) |
|
| 1141 | - echo ' |
|
| 1164 | + if (!empty($context['package_ftp']['destination'])) { |
|
| 1165 | + echo ' |
|
| 1142 | 1166 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">'; |
| 1167 | + } |
|
| 1143 | 1168 | |
| 1144 | 1169 | echo ' |
| 1145 | 1170 | <fieldset> |
@@ -1172,25 +1197,28 @@ discard block |
||
| 1172 | 1197 | </dl> |
| 1173 | 1198 | </fieldset>'; |
| 1174 | 1199 | |
| 1175 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
| 1176 | - echo ' |
|
| 1200 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
| 1201 | + echo ' |
|
| 1177 | 1202 | |
| 1178 | 1203 | <div class="righttext" style="margin: 1ex;"> |
| 1179 | 1204 | <span id="test_ftp_placeholder_full"></span> |
| 1180 | 1205 | <input type="submit" value="', $txt['package_proceed'], '" class="button_submit"> |
| 1181 | 1206 | </div>'; |
| 1207 | + } |
|
| 1182 | 1208 | |
| 1183 | - if (!empty($context['package_ftp']['destination'])) |
|
| 1184 | - echo ' |
|
| 1209 | + if (!empty($context['package_ftp']['destination'])) { |
|
| 1210 | + echo ' |
|
| 1185 | 1211 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1186 | 1212 | </form>'; |
| 1213 | + } |
|
| 1187 | 1214 | |
| 1188 | 1215 | // Hide the details of the list. |
| 1189 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
| 1190 | - echo ' |
|
| 1216 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
| 1217 | + echo ' |
|
| 1191 | 1218 | <script> |
| 1192 | 1219 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
| 1193 | 1220 | </script>'; |
| 1221 | + } |
|
| 1194 | 1222 | |
| 1195 | 1223 | // Quick generate the test button. |
| 1196 | 1224 | echo ' |
@@ -1546,9 +1574,10 @@ discard block |
||
| 1546 | 1574 | <tr class="windowbg"> |
| 1547 | 1575 | <td width="30%"><strong>'; |
| 1548 | 1576 | |
| 1549 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
| 1550 | - echo ' |
|
| 1577 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
| 1578 | + echo ' |
|
| 1551 | 1579 | <span class="generic_icons folder"></span>'; |
| 1580 | + } |
|
| 1552 | 1581 | |
| 1553 | 1582 | echo ' |
| 1554 | 1583 | ', $name, ' |
@@ -1565,8 +1594,9 @@ discard block |
||
| 1565 | 1594 | </tr> |
| 1566 | 1595 | '; |
| 1567 | 1596 | |
| 1568 | - if (!empty($dir['contents'])) |
|
| 1569 | - template_permission_show_contents($name, $dir['contents'], 1); |
|
| 1597 | + if (!empty($dir['contents'])) { |
|
| 1598 | + template_permission_show_contents($name, $dir['contents'], 1); |
|
| 1599 | + } |
|
| 1570 | 1600 | } |
| 1571 | 1601 | |
| 1572 | 1602 | echo ' |
@@ -1602,13 +1632,14 @@ discard block |
||
| 1602 | 1632 | </fieldset>'; |
| 1603 | 1633 | |
| 1604 | 1634 | // Likely to need FTP? |
| 1605 | - if (empty($context['ftp_connected'])) |
|
| 1606 | - echo ' |
|
| 1635 | + if (empty($context['ftp_connected'])) { |
|
| 1636 | + echo ' |
|
| 1607 | 1637 | <p> |
| 1608 | 1638 | ', $txt['package_file_perms_ftp_details'], ': |
| 1609 | 1639 | </p> |
| 1610 | 1640 | ', template_control_chmod(), ' |
| 1611 | 1641 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
| 1642 | + } |
|
| 1612 | 1643 | |
| 1613 | 1644 | echo ' |
| 1614 | 1645 | <span id="test_ftp_placeholder_full"></span> |
@@ -1617,9 +1648,10 @@ discard block |
||
| 1617 | 1648 | </div>'; |
| 1618 | 1649 | |
| 1619 | 1650 | // Any looks fors we've already done? |
| 1620 | - foreach ($context['look_for'] as $path) |
|
| 1621 | - echo ' |
|
| 1651 | + foreach ($context['look_for'] as $path) { |
|
| 1652 | + echo ' |
|
| 1622 | 1653 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
| 1654 | + } |
|
| 1623 | 1655 | echo ' |
| 1624 | 1656 | </form><br>'; |
| 1625 | 1657 | } |
@@ -1658,9 +1690,10 @@ discard block |
||
| 1658 | 1690 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
| 1659 | 1691 | ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : ''; |
| 1660 | 1692 | |
| 1661 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
| 1662 | - echo ' |
|
| 1693 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
| 1694 | + echo ' |
|
| 1663 | 1695 | <span class="generic_icons folder"></span>'; |
| 1696 | + } |
|
| 1664 | 1697 | |
| 1665 | 1698 | echo ' |
| 1666 | 1699 | ', $name, ' |
@@ -1686,14 +1719,15 @@ discard block |
||
| 1686 | 1719 | } |
| 1687 | 1720 | |
| 1688 | 1721 | // We have more files to show? |
| 1689 | - if ($has_more) |
|
| 1690 | - echo ' |
|
| 1722 | + if ($has_more) { |
|
| 1723 | + echo ' |
|
| 1691 | 1724 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
| 1692 | 1725 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
| 1693 | 1726 | « <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> » |
| 1694 | 1727 | </td> |
| 1695 | 1728 | <td colspan="6"></td> |
| 1696 | 1729 | </tr>'; |
| 1730 | + } |
|
| 1697 | 1731 | |
| 1698 | 1732 | if ($drawn_div) |
| 1699 | 1733 | { |
@@ -1701,15 +1735,17 @@ discard block |
||
| 1701 | 1735 | $isFound = false; |
| 1702 | 1736 | foreach ($context['look_for'] as $tree) |
| 1703 | 1737 | { |
| 1704 | - if (substr($tree, 0, strlen($ident)) == $ident) |
|
| 1705 | - $isFound = true; |
|
| 1738 | + if (substr($tree, 0, strlen($ident)) == $ident) { |
|
| 1739 | + $isFound = true; |
|
| 1740 | + } |
|
| 1706 | 1741 | } |
| 1707 | 1742 | |
| 1708 | - if ($level > 1 && !$isFound) |
|
| 1709 | - echo ' |
|
| 1743 | + if ($level > 1 && !$isFound) { |
|
| 1744 | + echo ' |
|
| 1710 | 1745 | <script> |
| 1711 | 1746 | expandFolder(\'', $js_ident, '\', \'\'); |
| 1712 | 1747 | </script>'; |
| 1748 | + } |
|
| 1713 | 1749 | } |
| 1714 | 1750 | } |
| 1715 | 1751 | |
@@ -1729,11 +1765,12 @@ discard block |
||
| 1729 | 1765 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
| 1730 | 1766 | </div>'; |
| 1731 | 1767 | |
| 1732 | - if (!empty($context['skip_ftp'])) |
|
| 1733 | - echo ' |
|
| 1768 | + if (!empty($context['skip_ftp'])) { |
|
| 1769 | + echo ' |
|
| 1734 | 1770 | <div class="errorbox"> |
| 1735 | 1771 | ', $txt['package_file_perms_skipping_ftp'], ' |
| 1736 | 1772 | </div>'; |
| 1773 | + } |
|
| 1737 | 1774 | |
| 1738 | 1775 | // How many have we done? |
| 1739 | 1776 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
@@ -1771,28 +1808,31 @@ discard block |
||
| 1771 | 1808 | <br>'; |
| 1772 | 1809 | |
| 1773 | 1810 | // Put out the right hidden data. |
| 1774 | - if ($context['method'] == 'individual') |
|
| 1775 | - echo ' |
|
| 1811 | + if ($context['method'] == 'individual') { |
|
| 1812 | + echo ' |
|
| 1776 | 1813 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
| 1777 | 1814 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
| 1778 | 1815 | <input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">'; |
| 1779 | - else |
|
| 1780 | - echo ' |
|
| 1816 | + } else { |
|
| 1817 | + echo ' |
|
| 1781 | 1818 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
| 1782 | 1819 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
| 1783 | 1820 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
| 1784 | 1821 | <input type="hidden" name="dirList" value="', $context['directory_list_encode'], '"> |
| 1785 | 1822 | <input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">'; |
| 1823 | + } |
|
| 1786 | 1824 | |
| 1787 | 1825 | // Are we not using FTP for whatever reason. |
| 1788 | - if (!empty($context['skip_ftp'])) |
|
| 1789 | - echo ' |
|
| 1826 | + if (!empty($context['skip_ftp'])) { |
|
| 1827 | + echo ' |
|
| 1790 | 1828 | <input type="hidden" name="skip_ftp" value="1">'; |
| 1829 | + } |
|
| 1791 | 1830 | |
| 1792 | 1831 | // Retain state. |
| 1793 | - foreach ($context['back_look_data'] as $path) |
|
| 1794 | - echo ' |
|
| 1832 | + foreach ($context['back_look_data'] as $path) { |
|
| 1833 | + echo ' |
|
| 1795 | 1834 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
| 1835 | + } |
|
| 1796 | 1836 | |
| 1797 | 1837 | echo ' |
| 1798 | 1838 | <input type="hidden" name="method" value="', $context['method'], '"> |
@@ -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 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
| 122 | 123 | $smcFunc['db_free_result']($result); |
| 123 | 124 | |
| 124 | 125 | // Add this to the number of unapproved members |
| 125 | - if (!empty($changes['unapprovedMembers'])) |
|
| 126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 127 | - else |
|
| 128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 126 | + if (!empty($changes['unapprovedMembers'])) { |
|
| 127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 128 | + } else { |
|
| 129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 130 | + } |
|
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
| 133 | 135 | break; |
| 134 | 136 | |
| 135 | 137 | case 'message': |
| 136 | - if ($parameter1 === true && $parameter2 !== null) |
|
| 137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 138 | - else |
|
| 138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
| 139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 140 | + } else |
|
| 139 | 141 | { |
| 140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
| 141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
| 175 | 177 | $parameter2 = text2words($parameter2); |
| 176 | 178 | |
| 177 | 179 | $inserts = array(); |
| 178 | - foreach ($parameter2 as $word) |
|
| 179 | - $inserts[] = array($word, $parameter1); |
|
| 180 | + foreach ($parameter2 as $word) { |
|
| 181 | + $inserts[] = array($word, $parameter1); |
|
| 182 | + } |
|
| 180 | 183 | |
| 181 | - if (!empty($inserts)) |
|
| 182 | - $smcFunc['db_insert']('ignore', |
|
| 184 | + if (!empty($inserts)) { |
|
| 185 | + $smcFunc['db_insert']('ignore', |
|
| 183 | 186 | '{db_prefix}log_search_subjects', |
| 184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
| 185 | 188 | $inserts, |
| 186 | 189 | array('word', 'id_topic') |
| 187 | 190 | ); |
| 191 | + } |
|
| 188 | 192 | } |
| 189 | 193 | break; |
| 190 | 194 | |
| 191 | 195 | case 'topic': |
| 192 | - if ($parameter1 === true) |
|
| 193 | - updateSettings(array('totalTopics' => true), true); |
|
| 194 | - else |
|
| 196 | + if ($parameter1 === true) { |
|
| 197 | + updateSettings(array('totalTopics' => true), true); |
|
| 198 | + } else |
|
| 195 | 199 | { |
| 196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
| 197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
| 212 | 216 | |
| 213 | 217 | case 'postgroups': |
| 214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
| 215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
| 216 | - return; |
|
| 219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 217 | 222 | |
| 218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
| 219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
| 228 | 233 | ) |
| 229 | 234 | ); |
| 230 | 235 | $postgroups = array(); |
| 231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 238 | + } |
|
| 233 | 239 | $smcFunc['db_free_result']($request); |
| 234 | 240 | |
| 235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // Oh great, they've screwed their post groups. |
| 242 | - if (empty($postgroups)) |
|
| 243 | - return; |
|
| 248 | + if (empty($postgroups)) { |
|
| 249 | + return; |
|
| 250 | + } |
|
| 244 | 251 | |
| 245 | 252 | // Set all membergroups from most posts to least posts. |
| 246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
| 298 | 305 | { |
| 299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
| 300 | 307 | $parameters['members'] = $members; |
| 301 | - } |
|
| 302 | - elseif ($members === null) |
|
| 303 | - $condition = '1=1'; |
|
| 304 | - else |
|
| 308 | + } elseif ($members === null) { |
|
| 309 | + $condition = '1=1'; |
|
| 310 | + } else |
|
| 305 | 311 | { |
| 306 | 312 | $condition = 'id_member = {int:member}'; |
| 307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
| 341 | 347 | if (count($vars_to_integrate) != 0) |
| 342 | 348 | { |
| 343 | 349 | // Fetch a list of member_names if necessary |
| 344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
| 345 | - $member_names = array($user_info['username']); |
|
| 346 | - else |
|
| 350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
| 351 | + $member_names = array($user_info['username']); |
|
| 352 | + } else |
|
| 347 | 353 | { |
| 348 | 354 | $member_names = array(); |
| 349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
| 352 | 358 | WHERE ' . $condition, |
| 353 | 359 | $parameters |
| 354 | 360 | ); |
| 355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 356 | - $member_names[] = $row['member_name']; |
|
| 361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 362 | + $member_names[] = $row['member_name']; |
|
| 363 | + } |
|
| 357 | 364 | $smcFunc['db_free_result']($request); |
| 358 | 365 | } |
| 359 | 366 | |
| 360 | - if (!empty($member_names)) |
|
| 361 | - foreach ($vars_to_integrate as $var) |
|
| 367 | + if (!empty($member_names)) { |
|
| 368 | + foreach ($vars_to_integrate as $var) |
|
| 362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
| 370 | + } |
|
| 363 | 371 | } |
| 364 | 372 | } |
| 365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
| 367 | 375 | foreach ($data as $var => $val) |
| 368 | 376 | { |
| 369 | 377 | $type = 'string'; |
| 370 | - if (in_array($var, $knownInts)) |
|
| 371 | - $type = 'int'; |
|
| 372 | - elseif (in_array($var, $knownFloats)) |
|
| 373 | - $type = 'float'; |
|
| 374 | - elseif ($var == 'birthdate') |
|
| 375 | - $type = 'date'; |
|
| 376 | - elseif ($var == 'member_ip') |
|
| 377 | - $type = 'inet'; |
|
| 378 | - elseif ($var == 'member_ip2') |
|
| 379 | - $type = 'inet'; |
|
| 378 | + if (in_array($var, $knownInts)) { |
|
| 379 | + $type = 'int'; |
|
| 380 | + } elseif (in_array($var, $knownFloats)) { |
|
| 381 | + $type = 'float'; |
|
| 382 | + } elseif ($var == 'birthdate') { |
|
| 383 | + $type = 'date'; |
|
| 384 | + } elseif ($var == 'member_ip') { |
|
| 385 | + $type = 'inet'; |
|
| 386 | + } elseif ($var == 'member_ip2') { |
|
| 387 | + $type = 'inet'; |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | // Doing an increment? |
| 382 | 391 | if ($type == 'int' && ($val === '+' || $val === '-')) |
@@ -390,8 +399,9 @@ discard block |
||
| 390 | 399 | { |
| 391 | 400 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 392 | 401 | { |
| 393 | - if ($match[1] != '+ ') |
|
| 394 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 402 | + if ($match[1] != '+ ') { |
|
| 403 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 404 | + } |
|
| 395 | 405 | $type = 'raw'; |
| 396 | 406 | } |
| 397 | 407 | } |
@@ -412,8 +422,9 @@ discard block |
||
| 412 | 422 | // Clear any caching? |
| 413 | 423 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
| 414 | 424 | { |
| 415 | - if (!is_array($members)) |
|
| 416 | - $members = array($members); |
|
| 425 | + if (!is_array($members)) { |
|
| 426 | + $members = array($members); |
|
| 427 | + } |
|
| 417 | 428 | |
| 418 | 429 | foreach ($members as $member) |
| 419 | 430 | { |
@@ -446,29 +457,32 @@ discard block |
||
| 446 | 457 | { |
| 447 | 458 | global $modSettings, $smcFunc; |
| 448 | 459 | |
| 449 | - if (empty($changeArray) || !is_array($changeArray)) |
|
| 450 | - return; |
|
| 460 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
| 461 | + return; |
|
| 462 | + } |
|
| 451 | 463 | |
| 452 | 464 | $toRemove = array(); |
| 453 | 465 | |
| 454 | 466 | // Go check if there is any setting to be removed. |
| 455 | - foreach ($changeArray as $k => $v) |
|
| 456 | - if ($v === null) |
|
| 467 | + foreach ($changeArray as $k => $v) { |
|
| 468 | + if ($v === null) |
|
| 457 | 469 | { |
| 458 | 470 | // Found some, remove them from the original array and add them to ours. |
| 459 | 471 | unset($changeArray[$k]); |
| 472 | + } |
|
| 460 | 473 | $toRemove[] = $k; |
| 461 | 474 | } |
| 462 | 475 | |
| 463 | 476 | // Proceed with the deletion. |
| 464 | - if (!empty($toRemove)) |
|
| 465 | - $smcFunc['db_query']('', ' |
|
| 477 | + if (!empty($toRemove)) { |
|
| 478 | + $smcFunc['db_query']('', ' |
|
| 466 | 479 | DELETE FROM {db_prefix}settings |
| 467 | 480 | WHERE variable IN ({array_string:remove})', |
| 468 | 481 | array( |
| 469 | 482 | 'remove' => $toRemove, |
| 470 | 483 | ) |
| 471 | 484 | ); |
| 485 | + } |
|
| 472 | 486 | |
| 473 | 487 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 474 | 488 | if ($update) |
@@ -497,19 +511,22 @@ discard block |
||
| 497 | 511 | foreach ($changeArray as $variable => $value) |
| 498 | 512 | { |
| 499 | 513 | // Don't bother if it's already like that ;). |
| 500 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
| 501 | - continue; |
|
| 514 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
| 515 | + continue; |
|
| 516 | + } |
|
| 502 | 517 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 503 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
| 504 | - continue; |
|
| 518 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
| 519 | + continue; |
|
| 520 | + } |
|
| 505 | 521 | |
| 506 | 522 | $replaceArray[] = array($variable, $value); |
| 507 | 523 | |
| 508 | 524 | $modSettings[$variable] = $value; |
| 509 | 525 | } |
| 510 | 526 | |
| 511 | - if (empty($replaceArray)) |
|
| 512 | - return; |
|
| 527 | + if (empty($replaceArray)) { |
|
| 528 | + return; |
|
| 529 | + } |
|
| 513 | 530 | |
| 514 | 531 | $smcFunc['db_insert']('replace', |
| 515 | 532 | '{db_prefix}settings', |
@@ -555,20 +572,25 @@ discard block |
||
| 555 | 572 | $start = (int) $start; |
| 556 | 573 | $start_invalid = $start < 0; |
| 557 | 574 | |
| 558 | - if (!empty($options['low_id'])) |
|
| 559 | - $low_id = $options['low_id']; |
|
| 560 | - if (!empty($options['max_id'])) |
|
| 561 | - $max_id = $options['max_id']; |
|
| 575 | + if (!empty($options['low_id'])) { |
|
| 576 | + $low_id = $options['low_id']; |
|
| 577 | + } |
|
| 578 | + if (!empty($options['max_id'])) { |
|
| 579 | + $max_id = $options['max_id']; |
|
| 580 | + } |
|
| 562 | 581 | |
| 563 | 582 | // Make sure $start is a proper variable - not less than 0. |
| 564 | - if ($start_invalid) |
|
| 565 | - $start = 0; |
|
| 583 | + if ($start_invalid) { |
|
| 584 | + $start = 0; |
|
| 585 | + } |
|
| 566 | 586 | // Not greater than the upper bound. |
| 567 | - elseif ($start >= $max_value) |
|
| 568 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 587 | + elseif ($start >= $max_value) { |
|
| 588 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 589 | + } |
|
| 569 | 590 | // And it has to be a multiple of $num_per_page! |
| 570 | - else |
|
| 571 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 591 | + else { |
|
| 592 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 593 | + } |
|
| 572 | 594 | |
| 573 | 595 | $context['current_page'] = $start / $num_per_page; |
| 574 | 596 | |
@@ -596,101 +618,115 @@ discard block |
||
| 596 | 618 | if (empty($modSettings['compactTopicPagesEnable'])) |
| 597 | 619 | { |
| 598 | 620 | // Show the left arrow. |
| 599 | - if (empty($low_id)) |
|
| 600 | - $pageindex .= $start == 0 ? ' ' : sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 601 | - else |
|
| 602 | - $pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L'.$low_id); |
|
| 621 | + if (empty($low_id)) { |
|
| 622 | + $pageindex .= $start == 0 ? ' ' : sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 623 | + } else { |
|
| 624 | + $pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L'.$low_id); |
|
| 625 | + } |
|
| 603 | 626 | |
| 604 | 627 | // Show all the pages. |
| 605 | 628 | $display_page = 1; |
| 606 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
| 607 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 629 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
| 630 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 631 | + } |
|
| 608 | 632 | |
| 609 | 633 | // Show the right arrow. |
| 610 | 634 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 611 | 635 | if ($start != $counter - $max_value && !$start_invalid){ |
| 612 | - if (empty($max_id)) |
|
| 613 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 614 | - else |
|
| 615 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page , $settings['page_index']['next_page'], 'M'.$max_id); |
|
| 636 | + if (empty($max_id)) { |
|
| 637 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 638 | + } else { |
|
| 639 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page , $settings['page_index']['next_page'], 'M'.$max_id); |
|
| 640 | + } |
|
| 616 | 641 | } |
| 617 | 642 | |
| 618 | - } |
|
| 619 | - else |
|
| 643 | + } else |
|
| 620 | 644 | { |
| 621 | 645 | // If they didn't enter an odd value, pretend they did. |
| 622 | 646 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
| 623 | 647 | |
| 624 | 648 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 625 | - if (!empty($start) && $show_prevnext) |
|
| 626 | - if (empty($low_id)) |
|
| 649 | + if (!empty($start) && $show_prevnext) { |
|
| 650 | + if (empty($low_id)) |
|
| 627 | 651 | $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
| 628 | - else |
|
| 629 | - $pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L'.$low_id); |
|
| 630 | - else |
|
| 631 | - $pageindex .= ''; |
|
| 652 | + } else { |
|
| 653 | + $pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L'.$low_id); |
|
| 654 | + } |
|
| 655 | + else { |
|
| 656 | + $pageindex .= ''; |
|
| 657 | + } |
|
| 632 | 658 | |
| 633 | 659 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 634 | - if ($start > $num_per_page * $PageContiguous) |
|
| 635 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 660 | + if ($start > $num_per_page * $PageContiguous) { |
|
| 661 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 662 | + } |
|
| 636 | 663 | |
| 637 | 664 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 638 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
| 639 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 665 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
| 666 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 640 | 667 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 641 | 668 | '{FIRST_PAGE}' => $num_per_page, |
| 642 | 669 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
| 643 | 670 | '{PER_PAGE}' => $num_per_page, |
| 644 | 671 | )); |
| 672 | + } |
|
| 645 | 673 | |
| 646 | 674 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 647 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
| 648 | - if ($start >= $num_per_page * $nCont) |
|
| 675 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
| 676 | + if ($start >= $num_per_page * $nCont) |
|
| 649 | 677 | { |
| 650 | 678 | $tmpStart = $start - $num_per_page * $nCont; |
| 651 | - if($nCont != 1 || empty($low_id)) |
|
| 652 | - $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
|
| 653 | - else |
|
| 654 | - $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L'.$low_id); |
|
| 679 | + } |
|
| 680 | + if($nCont != 1 || empty($low_id)) { |
|
| 681 | + $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
|
| 682 | + } else { |
|
| 683 | + $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L'.$low_id); |
|
| 684 | + } |
|
| 655 | 685 | } |
| 656 | 686 | |
| 657 | 687 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 658 | - if (!$start_invalid) |
|
| 659 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 660 | - else |
|
| 661 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 688 | + if (!$start_invalid) { |
|
| 689 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 690 | + } else { |
|
| 691 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 692 | + } |
|
| 662 | 693 | |
| 663 | 694 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 664 | 695 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 665 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
| 666 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 696 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
| 697 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 667 | 698 | { |
| 668 | 699 | $tmpStart = $start + $num_per_page * $nCont; |
| 669 | - if($nCont != 1 || empty($max_id)) |
|
| 670 | - $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
|
| 671 | - else |
|
| 672 | - $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M'.$max_id); |
|
| 700 | + } |
|
| 701 | + if($nCont != 1 || empty($max_id)) { |
|
| 702 | + $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
|
| 703 | + } else { |
|
| 704 | + $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M'.$max_id); |
|
| 705 | + } |
|
| 673 | 706 | } |
| 674 | 707 | |
| 675 | 708 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 676 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
| 677 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 709 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
| 710 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 678 | 711 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 679 | 712 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
| 680 | 713 | '{LAST_PAGE}' => $tmpMaxPages, |
| 681 | 714 | '{PER_PAGE}' => $num_per_page, |
| 682 | 715 | )); |
| 716 | + } |
|
| 683 | 717 | |
| 684 | 718 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 685 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
| 686 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 719 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
| 720 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 721 | + } |
|
| 687 | 722 | |
| 688 | 723 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 689 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
| 690 | - if (empty($max_id)) |
|
| 724 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
| 725 | + if (empty($max_id)) |
|
| 691 | 726 | $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
| 692 | - else |
|
| 693 | - $pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M'.$max_id); |
|
| 727 | + } else { |
|
| 728 | + $pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M'.$max_id); |
|
| 729 | + } |
|
| 694 | 730 | } |
| 695 | 731 | $pageindex .= $settings['page_index']['extra_after']; |
| 696 | 732 | |
@@ -716,8 +752,9 @@ discard block |
||
| 716 | 752 | if ($decimal_separator === null) |
| 717 | 753 | { |
| 718 | 754 | // Not set for whatever reason? |
| 719 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
| 720 | - return $number; |
|
| 755 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
| 756 | + return $number; |
|
| 757 | + } |
|
| 721 | 758 | |
| 722 | 759 | // Cache these each load... |
| 723 | 760 | $thousands_separator = $matches[1]; |
@@ -751,17 +788,20 @@ discard block |
||
| 751 | 788 | static $local_cache; |
| 752 | 789 | |
| 753 | 790 | // Offset the time. |
| 754 | - if (!$offset_type) |
|
| 755 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 791 | + if (!$offset_type) { |
|
| 792 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 793 | + } |
|
| 756 | 794 | // Just the forum offset? |
| 757 | - elseif ($offset_type == 'forum') |
|
| 758 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 759 | - else |
|
| 760 | - $time = $log_time; |
|
| 795 | + elseif ($offset_type == 'forum') { |
|
| 796 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 797 | + } else { |
|
| 798 | + $time = $log_time; |
|
| 799 | + } |
|
| 761 | 800 | |
| 762 | 801 | // We can't have a negative date (on Windows, at least.) |
| 763 | - if ($log_time < 0) |
|
| 764 | - $log_time = 0; |
|
| 802 | + if ($log_time < 0) { |
|
| 803 | + $log_time = 0; |
|
| 804 | + } |
|
| 765 | 805 | |
| 766 | 806 | // Today and Yesterday? |
| 767 | 807 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -778,56 +818,65 @@ discard block |
||
| 778 | 818 | { |
| 779 | 819 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 780 | 820 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 821 | + } else { |
|
| 822 | + $today_fmt = '%H:%M' . $s; |
|
| 781 | 823 | } |
| 782 | - else |
|
| 783 | - $today_fmt = '%H:%M' . $s; |
|
| 784 | 824 | |
| 785 | 825 | // Same day of the year, same year.... Today! |
| 786 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
| 787 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 826 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
| 827 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 828 | + } |
|
| 788 | 829 | |
| 789 | 830 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
| 790 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
| 791 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 831 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
| 832 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 833 | + } |
|
| 792 | 834 | } |
| 793 | 835 | |
| 794 | 836 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
| 795 | 837 | |
| 796 | - if (!isset($local_cache)) |
|
| 797 | - $local_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
| 838 | + if (!isset($local_cache)) { |
|
| 839 | + $local_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
| 840 | + } |
|
| 798 | 841 | |
| 799 | 842 | if ($local_cache !== false) |
| 800 | 843 | { |
| 801 | 844 | //check if other process change the local |
| 802 | 845 | if ($process_safe === true) |
| 803 | 846 | { |
| 804 | - if (setlocale(LC_TIME, '0') != $local_cache) |
|
| 805 | - setlocale(LC_TIME, $txt['lang_locale']); |
|
| 847 | + if (setlocale(LC_TIME, '0') != $local_cache) { |
|
| 848 | + setlocale(LC_TIME, $txt['lang_locale']); |
|
| 849 | + } |
|
| 806 | 850 | } |
| 807 | 851 | |
| 808 | - if (!isset($non_twelve_hour)) |
|
| 809 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 810 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
| 811 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 852 | + if (!isset($non_twelve_hour)) { |
|
| 853 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 854 | + } |
|
| 855 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
| 856 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 857 | + } |
|
| 812 | 858 | |
| 813 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
| 814 | - if (strpos($str, $token) !== false) |
|
| 859 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
| 860 | + if (strpos($str, $token) !== false) |
|
| 815 | 861 | $str = str_replace($token, strftime($token, $time), $str); |
| 816 | - } |
|
| 817 | - else |
|
| 862 | + } |
|
| 863 | + } else |
|
| 818 | 864 | { |
| 819 | 865 | // Do-it-yourself time localization. Fun. |
| 820 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
| 821 | - if (strpos($str, $token) !== false) |
|
| 866 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
| 867 | + if (strpos($str, $token) !== false) |
|
| 822 | 868 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 869 | + } |
|
| 823 | 870 | |
| 824 | - if (strpos($str, '%p') !== false) |
|
| 825 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 871 | + if (strpos($str, '%p') !== false) { |
|
| 872 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 873 | + } |
|
| 826 | 874 | } |
| 827 | 875 | |
| 828 | 876 | // Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that. |
| 829 | - if ($context['server']['is_windows'] && strpos($str, '%e') !== false) |
|
| 830 | - $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
| 877 | + if ($context['server']['is_windows'] && strpos($str, '%e') !== false) { |
|
| 878 | + $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
| 879 | + } |
|
| 831 | 880 | |
| 832 | 881 | // Format any other characters.. |
| 833 | 882 | return strftime($str, $time); |
@@ -849,16 +898,19 @@ discard block |
||
| 849 | 898 | static $translation = array(); |
| 850 | 899 | |
| 851 | 900 | // Determine the character set... Default to UTF-8 |
| 852 | - if (empty($context['character_set'])) |
|
| 853 | - $charset = 'UTF-8'; |
|
| 901 | + if (empty($context['character_set'])) { |
|
| 902 | + $charset = 'UTF-8'; |
|
| 903 | + } |
|
| 854 | 904 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
| 855 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
| 856 | - $charset = 'ISO-8859-1'; |
|
| 857 | - else |
|
| 858 | - $charset = $context['character_set']; |
|
| 905 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
| 906 | + $charset = 'ISO-8859-1'; |
|
| 907 | + } else { |
|
| 908 | + $charset = $context['character_set']; |
|
| 909 | + } |
|
| 859 | 910 | |
| 860 | - if (empty($translation)) |
|
| 861 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 911 | + if (empty($translation)) { |
|
| 912 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 913 | + } |
|
| 862 | 914 | |
| 863 | 915 | return strtr($string, $translation); |
| 864 | 916 | } |
@@ -880,8 +932,9 @@ discard block |
||
| 880 | 932 | global $smcFunc; |
| 881 | 933 | |
| 882 | 934 | // It was already short enough! |
| 883 | - if ($smcFunc['strlen']($subject) <= $len) |
|
| 884 | - return $subject; |
|
| 935 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
| 936 | + return $subject; |
|
| 937 | + } |
|
| 885 | 938 | |
| 886 | 939 | // Shorten it by the length it was too long, and strip off junk from the end. |
| 887 | 940 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -900,10 +953,11 @@ discard block |
||
| 900 | 953 | { |
| 901 | 954 | global $user_info, $modSettings; |
| 902 | 955 | |
| 903 | - if ($timestamp === null) |
|
| 904 | - $timestamp = time(); |
|
| 905 | - elseif ($timestamp == 0) |
|
| 906 | - return 0; |
|
| 956 | + if ($timestamp === null) { |
|
| 957 | + $timestamp = time(); |
|
| 958 | + } elseif ($timestamp == 0) { |
|
| 959 | + return 0; |
|
| 960 | + } |
|
| 907 | 961 | |
| 908 | 962 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 909 | 963 | } |
@@ -932,8 +986,9 @@ discard block |
||
| 932 | 986 | $array[$i] = $array[$j]; |
| 933 | 987 | $array[$j] = $temp; |
| 934 | 988 | |
| 935 | - for ($i = 1; $p[$i] == 0; $i++) |
|
| 936 | - $p[$i] = 1; |
|
| 989 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
| 990 | + $p[$i] = 1; |
|
| 991 | + } |
|
| 937 | 992 | |
| 938 | 993 | $orders[] = $array; |
| 939 | 994 | } |
@@ -965,12 +1020,14 @@ discard block |
||
| 965 | 1020 | static $disabled; |
| 966 | 1021 | |
| 967 | 1022 | // Don't waste cycles |
| 968 | - if ($message === '') |
|
| 969 | - return ''; |
|
| 1023 | + if ($message === '') { |
|
| 1024 | + return ''; |
|
| 1025 | + } |
|
| 970 | 1026 | |
| 971 | 1027 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
| 972 | - if (!isset($context['utf8'])) |
|
| 973 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1028 | + if (!isset($context['utf8'])) { |
|
| 1029 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1030 | + } |
|
| 974 | 1031 | |
| 975 | 1032 | // Clean up any cut/paste issues we may have |
| 976 | 1033 | $message = sanitizeMSCutPaste($message); |
@@ -982,13 +1039,15 @@ discard block |
||
| 982 | 1039 | return $message; |
| 983 | 1040 | } |
| 984 | 1041 | |
| 985 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
| 986 | - $smileys = (bool) $smileys; |
|
| 1042 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
| 1043 | + $smileys = (bool) $smileys; |
|
| 1044 | + } |
|
| 987 | 1045 | |
| 988 | 1046 | if (empty($modSettings['enableBBC']) && $message !== false) |
| 989 | 1047 | { |
| 990 | - if ($smileys === true) |
|
| 991 | - parsesmileys($message); |
|
| 1048 | + if ($smileys === true) { |
|
| 1049 | + parsesmileys($message); |
|
| 1050 | + } |
|
| 992 | 1051 | |
| 993 | 1052 | return $message; |
| 994 | 1053 | } |
@@ -1001,8 +1060,9 @@ discard block |
||
| 1001 | 1060 | } |
| 1002 | 1061 | |
| 1003 | 1062 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
| 1004 | - if (!empty($modSettings['autoLinkUrls'])) |
|
| 1005 | - set_tld_regex(); |
|
| 1063 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
| 1064 | + set_tld_regex(); |
|
| 1065 | + } |
|
| 1006 | 1066 | |
| 1007 | 1067 | // Allow mods access before entering the main parse_bbc loop |
| 1008 | 1068 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1016,12 +1076,14 @@ discard block |
||
| 1016 | 1076 | |
| 1017 | 1077 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
| 1018 | 1078 | |
| 1019 | - foreach ($temp as $tag) |
|
| 1020 | - $disabled[trim($tag)] = true; |
|
| 1079 | + foreach ($temp as $tag) { |
|
| 1080 | + $disabled[trim($tag)] = true; |
|
| 1081 | + } |
|
| 1021 | 1082 | } |
| 1022 | 1083 | |
| 1023 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1024 | - $disabled['flash'] = true; |
|
| 1084 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1085 | + $disabled['flash'] = true; |
|
| 1086 | + } |
|
| 1025 | 1087 | |
| 1026 | 1088 | /* The following bbc are formatted as an array, with keys as follows: |
| 1027 | 1089 | |
@@ -1142,8 +1204,9 @@ discard block |
||
| 1142 | 1204 | $returnContext = ''; |
| 1143 | 1205 | |
| 1144 | 1206 | // BBC or the entire attachments feature is disabled |
| 1145 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1146 | - return $data; |
|
| 1207 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1208 | + return $data; |
|
| 1209 | + } |
|
| 1147 | 1210 | |
| 1148 | 1211 | // Save the attach ID. |
| 1149 | 1212 | $attachID = $data; |
@@ -1154,8 +1217,9 @@ discard block |
||
| 1154 | 1217 | $currentAttachment = parseAttachBBC($attachID); |
| 1155 | 1218 | |
| 1156 | 1219 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
| 1157 | - if (is_string($currentAttachment)) |
|
| 1158 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1220 | + if (is_string($currentAttachment)) { |
|
| 1221 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1222 | + } |
|
| 1159 | 1223 | |
| 1160 | 1224 | if (!empty($currentAttachment['is_image'])) |
| 1161 | 1225 | { |
@@ -1171,15 +1235,17 @@ discard block |
||
| 1171 | 1235 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1172 | 1236 | } |
| 1173 | 1237 | |
| 1174 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1175 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1176 | - else |
|
| 1177 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1238 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1239 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1240 | + } else { |
|
| 1241 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1242 | + } |
|
| 1178 | 1243 | } |
| 1179 | 1244 | |
| 1180 | 1245 | // No image. Show a link. |
| 1181 | - else |
|
| 1182 | - $returnContext .= $currentAttachment['link']; |
|
| 1246 | + else { |
|
| 1247 | + $returnContext .= $currentAttachment['link']; |
|
| 1248 | + } |
|
| 1183 | 1249 | |
| 1184 | 1250 | // Gotta append what we just did. |
| 1185 | 1251 | $data = $returnContext; |
@@ -1210,8 +1276,9 @@ discard block |
||
| 1210 | 1276 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1211 | 1277 | { |
| 1212 | 1278 | // Do PHP code coloring? |
| 1213 | - if ($php_parts[$php_i] != '<?php') |
|
| 1214 | - continue; |
|
| 1279 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1280 | + continue; |
|
| 1281 | + } |
|
| 1215 | 1282 | |
| 1216 | 1283 | $php_string = ''; |
| 1217 | 1284 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1227,8 +1294,9 @@ discard block |
||
| 1227 | 1294 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1228 | 1295 | |
| 1229 | 1296 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1230 | - if ($context['browser']['is_opera']) |
|
| 1231 | - $data .= ' '; |
|
| 1297 | + if ($context['browser']['is_opera']) { |
|
| 1298 | + $data .= ' '; |
|
| 1299 | + } |
|
| 1232 | 1300 | } |
| 1233 | 1301 | }, |
| 1234 | 1302 | 'block_level' => true, |
@@ -1247,8 +1315,9 @@ discard block |
||
| 1247 | 1315 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1248 | 1316 | { |
| 1249 | 1317 | // Do PHP code coloring? |
| 1250 | - if ($php_parts[$php_i] != '<?php') |
|
| 1251 | - continue; |
|
| 1318 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1319 | + continue; |
|
| 1320 | + } |
|
| 1252 | 1321 | |
| 1253 | 1322 | $php_string = ''; |
| 1254 | 1323 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1264,8 +1333,9 @@ discard block |
||
| 1264 | 1333 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1265 | 1334 | |
| 1266 | 1335 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1267 | - if ($context['browser']['is_opera']) |
|
| 1268 | - $data[0] .= ' '; |
|
| 1336 | + if ($context['browser']['is_opera']) { |
|
| 1337 | + $data[0] .= ' '; |
|
| 1338 | + } |
|
| 1269 | 1339 | } |
| 1270 | 1340 | }, |
| 1271 | 1341 | 'block_level' => true, |
@@ -1303,11 +1373,13 @@ discard block |
||
| 1303 | 1373 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1304 | 1374 | 'validate' => function (&$tag, &$data, $disabled) |
| 1305 | 1375 | { |
| 1306 | - if (isset($disabled['url'])) |
|
| 1307 | - $tag['content'] = '$1'; |
|
| 1376 | + if (isset($disabled['url'])) { |
|
| 1377 | + $tag['content'] = '$1'; |
|
| 1378 | + } |
|
| 1308 | 1379 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
| 1309 | - if (empty($scheme)) |
|
| 1310 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1380 | + if (empty($scheme)) { |
|
| 1381 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1382 | + } |
|
| 1311 | 1383 | }, |
| 1312 | 1384 | 'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>', |
| 1313 | 1385 | ), |
@@ -1321,10 +1393,11 @@ discard block |
||
| 1321 | 1393 | { |
| 1322 | 1394 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1323 | 1395 | |
| 1324 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
| 1325 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1326 | - else |
|
| 1327 | - $css = ''; |
|
| 1396 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
| 1397 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1398 | + } else { |
|
| 1399 | + $css = ''; |
|
| 1400 | + } |
|
| 1328 | 1401 | |
| 1329 | 1402 | $data = $class . $css; |
| 1330 | 1403 | }, |
@@ -1374,14 +1447,16 @@ discard block |
||
| 1374 | 1447 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1375 | 1448 | if ($image_proxy_enabled) |
| 1376 | 1449 | { |
| 1377 | - if (empty($scheme)) |
|
| 1378 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1450 | + if (empty($scheme)) { |
|
| 1451 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1452 | + } |
|
| 1379 | 1453 | |
| 1380 | - if ($scheme != 'https') |
|
| 1381 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1454 | + if ($scheme != 'https') { |
|
| 1455 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1456 | + } |
|
| 1457 | + } elseif (empty($scheme)) { |
|
| 1458 | + $data = '//' . ltrim($data, ':/'); |
|
| 1382 | 1459 | } |
| 1383 | - elseif (empty($scheme)) |
|
| 1384 | - $data = '//' . ltrim($data, ':/'); |
|
| 1385 | 1460 | }, |
| 1386 | 1461 | 'disabled_content' => '($1)', |
| 1387 | 1462 | ), |
@@ -1397,14 +1472,16 @@ discard block |
||
| 1397 | 1472 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1398 | 1473 | if ($image_proxy_enabled) |
| 1399 | 1474 | { |
| 1400 | - if (empty($scheme)) |
|
| 1401 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1475 | + if (empty($scheme)) { |
|
| 1476 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1477 | + } |
|
| 1402 | 1478 | |
| 1403 | - if ($scheme != 'https') |
|
| 1404 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1479 | + if ($scheme != 'https') { |
|
| 1480 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1481 | + } |
|
| 1482 | + } elseif (empty($scheme)) { |
|
| 1483 | + $data = '//' . ltrim($data, ':/'); |
|
| 1405 | 1484 | } |
| 1406 | - elseif (empty($scheme)) |
|
| 1407 | - $data = '//' . ltrim($data, ':/'); |
|
| 1408 | 1485 | }, |
| 1409 | 1486 | 'disabled_content' => '($1)', |
| 1410 | 1487 | ), |
@@ -1416,8 +1493,9 @@ discard block |
||
| 1416 | 1493 | { |
| 1417 | 1494 | $data = strtr($data, array('<br>' => '')); |
| 1418 | 1495 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1419 | - if (empty($scheme)) |
|
| 1420 | - $data = '//' . ltrim($data, ':/'); |
|
| 1496 | + if (empty($scheme)) { |
|
| 1497 | + $data = '//' . ltrim($data, ':/'); |
|
| 1498 | + } |
|
| 1421 | 1499 | }, |
| 1422 | 1500 | ), |
| 1423 | 1501 | array( |
@@ -1428,13 +1506,14 @@ discard block |
||
| 1428 | 1506 | 'after' => '</a>', |
| 1429 | 1507 | 'validate' => function (&$tag, &$data, $disabled) |
| 1430 | 1508 | { |
| 1431 | - if (substr($data, 0, 1) == '#') |
|
| 1432 | - $data = '#post_' . substr($data, 1); |
|
| 1433 | - else |
|
| 1509 | + if (substr($data, 0, 1) == '#') { |
|
| 1510 | + $data = '#post_' . substr($data, 1); |
|
| 1511 | + } else |
|
| 1434 | 1512 | { |
| 1435 | 1513 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1436 | - if (empty($scheme)) |
|
| 1437 | - $data = '//' . ltrim($data, ':/'); |
|
| 1514 | + if (empty($scheme)) { |
|
| 1515 | + $data = '//' . ltrim($data, ':/'); |
|
| 1516 | + } |
|
| 1438 | 1517 | } |
| 1439 | 1518 | }, |
| 1440 | 1519 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1512,8 +1591,9 @@ discard block |
||
| 1512 | 1591 | { |
| 1513 | 1592 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1514 | 1593 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1515 | - if ($add_begin) |
|
| 1516 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1594 | + if ($add_begin) { |
|
| 1595 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1596 | + } |
|
| 1517 | 1597 | } |
| 1518 | 1598 | }, |
| 1519 | 1599 | 'block_level' => false, |
@@ -1644,10 +1724,11 @@ discard block |
||
| 1644 | 1724 | 'content' => '$1', |
| 1645 | 1725 | 'validate' => function (&$tag, &$data, $disabled) |
| 1646 | 1726 | { |
| 1647 | - if (is_numeric($data)) |
|
| 1648 | - $data = timeformat($data); |
|
| 1649 | - else |
|
| 1650 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1727 | + if (is_numeric($data)) { |
|
| 1728 | + $data = timeformat($data); |
|
| 1729 | + } else { |
|
| 1730 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1731 | + } |
|
| 1651 | 1732 | }, |
| 1652 | 1733 | ), |
| 1653 | 1734 | array( |
@@ -1674,8 +1755,9 @@ discard block |
||
| 1674 | 1755 | { |
| 1675 | 1756 | $data = strtr($data, array('<br>' => '')); |
| 1676 | 1757 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1677 | - if (empty($scheme)) |
|
| 1678 | - $data = '//' . ltrim($data, ':/'); |
|
| 1758 | + if (empty($scheme)) { |
|
| 1759 | + $data = '//' . ltrim($data, ':/'); |
|
| 1760 | + } |
|
| 1679 | 1761 | }, |
| 1680 | 1762 | ), |
| 1681 | 1763 | array( |
@@ -1687,8 +1769,9 @@ discard block |
||
| 1687 | 1769 | 'validate' => function (&$tag, &$data, $disabled) |
| 1688 | 1770 | { |
| 1689 | 1771 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1690 | - if (empty($scheme)) |
|
| 1691 | - $data = '//' . ltrim($data, ':/'); |
|
| 1772 | + if (empty($scheme)) { |
|
| 1773 | + $data = '//' . ltrim($data, ':/'); |
|
| 1774 | + } |
|
| 1692 | 1775 | }, |
| 1693 | 1776 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1694 | 1777 | 'disabled_after' => ' ($1)', |
@@ -1708,8 +1791,9 @@ discard block |
||
| 1708 | 1791 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1709 | 1792 | if ($message === false) |
| 1710 | 1793 | { |
| 1711 | - if (isset($temp_bbc)) |
|
| 1712 | - $bbc_codes = $temp_bbc; |
|
| 1794 | + if (isset($temp_bbc)) { |
|
| 1795 | + $bbc_codes = $temp_bbc; |
|
| 1796 | + } |
|
| 1713 | 1797 | usort($codes, function ($a, $b) { |
| 1714 | 1798 | return strcmp($a['tag'], $b['tag']); |
| 1715 | 1799 | }); |
@@ -1729,8 +1813,9 @@ discard block |
||
| 1729 | 1813 | ); |
| 1730 | 1814 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1731 | 1815 | { |
| 1732 | - foreach ($itemcodes as $c => $dummy) |
|
| 1733 | - $bbc_codes[$c] = array(); |
|
| 1816 | + foreach ($itemcodes as $c => $dummy) { |
|
| 1817 | + $bbc_codes[$c] = array(); |
|
| 1818 | + } |
|
| 1734 | 1819 | } |
| 1735 | 1820 | |
| 1736 | 1821 | // Shhhh! |
@@ -1751,12 +1836,14 @@ discard block |
||
| 1751 | 1836 | foreach ($codes as $code) |
| 1752 | 1837 | { |
| 1753 | 1838 | // Make it easier to process parameters later |
| 1754 | - if (!empty($code['parameters'])) |
|
| 1755 | - ksort($code['parameters'], SORT_STRING); |
|
| 1839 | + if (!empty($code['parameters'])) { |
|
| 1840 | + ksort($code['parameters'], SORT_STRING); |
|
| 1841 | + } |
|
| 1756 | 1842 | |
| 1757 | 1843 | // If we are not doing every tag only do ones we are interested in. |
| 1758 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1759 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1844 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 1845 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1846 | + } |
|
| 1760 | 1847 | } |
| 1761 | 1848 | $codes = null; |
| 1762 | 1849 | } |
@@ -1767,8 +1854,9 @@ discard block |
||
| 1767 | 1854 | // It's likely this will change if the message is modified. |
| 1768 | 1855 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
| 1769 | 1856 | |
| 1770 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1771 | - return $temp; |
|
| 1857 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 1858 | + return $temp; |
|
| 1859 | + } |
|
| 1772 | 1860 | |
| 1773 | 1861 | $cache_t = microtime(); |
| 1774 | 1862 | } |
@@ -1800,8 +1888,9 @@ discard block |
||
| 1800 | 1888 | $disabled['flash'] = true; |
| 1801 | 1889 | |
| 1802 | 1890 | // @todo Change maybe? |
| 1803 | - if (!isset($_GET['images'])) |
|
| 1804 | - $disabled['img'] = true; |
|
| 1891 | + if (!isset($_GET['images'])) { |
|
| 1892 | + $disabled['img'] = true; |
|
| 1893 | + } |
|
| 1805 | 1894 | |
| 1806 | 1895 | // @todo Interface/setting to add more? |
| 1807 | 1896 | } |
@@ -1825,8 +1914,9 @@ discard block |
||
| 1825 | 1914 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 1826 | 1915 | |
| 1827 | 1916 | // Failsafe. |
| 1828 | - if ($pos === false || $last_pos > $pos) |
|
| 1829 | - $pos = strlen($message) + 1; |
|
| 1917 | + if ($pos === false || $last_pos > $pos) { |
|
| 1918 | + $pos = strlen($message) + 1; |
|
| 1919 | + } |
|
| 1830 | 1920 | |
| 1831 | 1921 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 1832 | 1922 | if ($last_pos < $pos - 1) |
@@ -1845,8 +1935,9 @@ discard block |
||
| 1845 | 1935 | |
| 1846 | 1936 | // <br> should be empty. |
| 1847 | 1937 | $empty_tags = array('br', 'hr'); |
| 1848 | - foreach ($empty_tags as $tag) |
|
| 1849 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
| 1938 | + foreach ($empty_tags as $tag) { |
|
| 1939 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
| 1940 | + } |
|
| 1850 | 1941 | |
| 1851 | 1942 | // b, u, i, s, pre... basic tags. |
| 1852 | 1943 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote'); |
@@ -1855,8 +1946,9 @@ discard block |
||
| 1855 | 1946 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 1856 | 1947 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 1857 | 1948 | |
| 1858 | - if ($diff > 0) |
|
| 1859 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1949 | + if ($diff > 0) { |
|
| 1950 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1951 | + } |
|
| 1860 | 1952 | } |
| 1861 | 1953 | |
| 1862 | 1954 | // Do <img ...> - with security... action= -> action-. |
@@ -1869,8 +1961,9 @@ discard block |
||
| 1869 | 1961 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 1870 | 1962 | |
| 1871 | 1963 | // Remove action= from the URL - no funny business, now. |
| 1872 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 1873 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 1964 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 1965 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 1966 | + } |
|
| 1874 | 1967 | |
| 1875 | 1968 | // Check if the image is larger than allowed. |
| 1876 | 1969 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1891,9 +1984,9 @@ discard block |
||
| 1891 | 1984 | |
| 1892 | 1985 | // Set the new image tag. |
| 1893 | 1986 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
| 1987 | + } else { |
|
| 1988 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1894 | 1989 | } |
| 1895 | - else |
|
| 1896 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1897 | 1990 | } |
| 1898 | 1991 | |
| 1899 | 1992 | $data = strtr($data, $replaces); |
@@ -1906,16 +1999,18 @@ discard block |
||
| 1906 | 1999 | $no_autolink_area = false; |
| 1907 | 2000 | if (!empty($open_tags)) |
| 1908 | 2001 | { |
| 1909 | - foreach ($open_tags as $open_tag) |
|
| 1910 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2002 | + foreach ($open_tags as $open_tag) { |
|
| 2003 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1911 | 2004 | $no_autolink_area = true; |
| 2005 | + } |
|
| 1912 | 2006 | } |
| 1913 | 2007 | |
| 1914 | 2008 | // Don't go backwards. |
| 1915 | 2009 | // @todo Don't think is the real solution.... |
| 1916 | 2010 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 1917 | - if ($pos < $lastAutoPos) |
|
| 1918 | - $no_autolink_area = true; |
|
| 2011 | + if ($pos < $lastAutoPos) { |
|
| 2012 | + $no_autolink_area = true; |
|
| 2013 | + } |
|
| 1919 | 2014 | $lastAutoPos = $pos; |
| 1920 | 2015 | |
| 1921 | 2016 | if (!$no_autolink_area) |
@@ -2024,17 +2119,19 @@ discard block |
||
| 2024 | 2119 | if ($scheme == 'mailto') |
| 2025 | 2120 | { |
| 2026 | 2121 | $email_address = str_replace('mailto:', '', $url); |
| 2027 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 2028 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2029 | - else |
|
| 2030 | - return $url; |
|
| 2122 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2123 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2124 | + } else { |
|
| 2125 | + return $url; |
|
| 2126 | + } |
|
| 2031 | 2127 | } |
| 2032 | 2128 | |
| 2033 | 2129 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 2034 | - if (empty($scheme)) |
|
| 2035 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2036 | - else |
|
| 2037 | - $fullUrl = $url; |
|
| 2130 | + if (empty($scheme)) { |
|
| 2131 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2132 | + } else { |
|
| 2133 | + $fullUrl = $url; |
|
| 2134 | + } |
|
| 2038 | 2135 | |
| 2039 | 2136 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 2040 | 2137 | }, $data); |
@@ -2083,16 +2180,18 @@ discard block |
||
| 2083 | 2180 | } |
| 2084 | 2181 | |
| 2085 | 2182 | // Are we there yet? Are we there yet? |
| 2086 | - if ($pos >= strlen($message) - 1) |
|
| 2087 | - break; |
|
| 2183 | + if ($pos >= strlen($message) - 1) { |
|
| 2184 | + break; |
|
| 2185 | + } |
|
| 2088 | 2186 | |
| 2089 | 2187 | $tags = strtolower($message[$pos + 1]); |
| 2090 | 2188 | |
| 2091 | 2189 | if ($tags == '/' && !empty($open_tags)) |
| 2092 | 2190 | { |
| 2093 | 2191 | $pos2 = strpos($message, ']', $pos + 1); |
| 2094 | - if ($pos2 == $pos + 2) |
|
| 2095 | - continue; |
|
| 2192 | + if ($pos2 == $pos + 2) { |
|
| 2193 | + continue; |
|
| 2194 | + } |
|
| 2096 | 2195 | |
| 2097 | 2196 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2098 | 2197 | |
@@ -2102,8 +2201,9 @@ discard block |
||
| 2102 | 2201 | do |
| 2103 | 2202 | { |
| 2104 | 2203 | $tag = array_pop($open_tags); |
| 2105 | - if (!$tag) |
|
| 2106 | - break; |
|
| 2204 | + if (!$tag) { |
|
| 2205 | + break; |
|
| 2206 | + } |
|
| 2107 | 2207 | |
| 2108 | 2208 | if (!empty($tag['block_level'])) |
| 2109 | 2209 | { |
@@ -2117,10 +2217,11 @@ discard block |
||
| 2117 | 2217 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2118 | 2218 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2119 | 2219 | { |
| 2120 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2121 | - if ($temp['tag'] == $look_for) |
|
| 2220 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2221 | + if ($temp['tag'] == $look_for) |
|
| 2122 | 2222 | { |
| 2123 | 2223 | $block_level = !empty($temp['block_level']); |
| 2224 | + } |
|
| 2124 | 2225 | break; |
| 2125 | 2226 | } |
| 2126 | 2227 | } |
@@ -2142,15 +2243,15 @@ discard block |
||
| 2142 | 2243 | { |
| 2143 | 2244 | $open_tags = $to_close; |
| 2144 | 2245 | continue; |
| 2145 | - } |
|
| 2146 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2246 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2147 | 2247 | { |
| 2148 | 2248 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2149 | 2249 | { |
| 2150 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2151 | - if ($temp['tag'] == $look_for) |
|
| 2250 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2251 | + if ($temp['tag'] == $look_for) |
|
| 2152 | 2252 | { |
| 2153 | 2253 | $block_level = !empty($temp['block_level']); |
| 2254 | + } |
|
| 2154 | 2255 | break; |
| 2155 | 2256 | } |
| 2156 | 2257 | } |
@@ -2158,8 +2259,9 @@ discard block |
||
| 2158 | 2259 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2159 | 2260 | if (!$block_level) |
| 2160 | 2261 | { |
| 2161 | - foreach ($to_close as $tag) |
|
| 2162 | - array_push($open_tags, $tag); |
|
| 2262 | + foreach ($to_close as $tag) { |
|
| 2263 | + array_push($open_tags, $tag); |
|
| 2264 | + } |
|
| 2163 | 2265 | continue; |
| 2164 | 2266 | } |
| 2165 | 2267 | } |
@@ -2172,14 +2274,17 @@ discard block |
||
| 2172 | 2274 | |
| 2173 | 2275 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2174 | 2276 | $whitespace_regex = ''; |
| 2175 | - if (!empty($tag['block_level'])) |
|
| 2176 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2277 | + if (!empty($tag['block_level'])) { |
|
| 2278 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2279 | + } |
|
| 2177 | 2280 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
| 2178 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2179 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2281 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2282 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2283 | + } |
|
| 2180 | 2284 | |
| 2181 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2182 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2285 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2286 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2287 | + } |
|
| 2183 | 2288 | } |
| 2184 | 2289 | |
| 2185 | 2290 | if (!empty($to_close)) |
@@ -2192,8 +2297,9 @@ discard block |
||
| 2192 | 2297 | } |
| 2193 | 2298 | |
| 2194 | 2299 | // No tags for this character, so just keep going (fastest possible course.) |
| 2195 | - if (!isset($bbc_codes[$tags])) |
|
| 2196 | - continue; |
|
| 2300 | + if (!isset($bbc_codes[$tags])) { |
|
| 2301 | + continue; |
|
| 2302 | + } |
|
| 2197 | 2303 | |
| 2198 | 2304 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2199 | 2305 | $tag = null; |
@@ -2202,44 +2308,52 @@ discard block |
||
| 2202 | 2308 | $pt_strlen = strlen($possible['tag']); |
| 2203 | 2309 | |
| 2204 | 2310 | // Not a match? |
| 2205 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2206 | - continue; |
|
| 2311 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2312 | + continue; |
|
| 2313 | + } |
|
| 2207 | 2314 | |
| 2208 | 2315 | $next_c = $message[$pos + 1 + $pt_strlen]; |
| 2209 | 2316 | |
| 2210 | 2317 | // A test validation? |
| 2211 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2212 | - continue; |
|
| 2318 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2319 | + continue; |
|
| 2320 | + } |
|
| 2213 | 2321 | // Do we want parameters? |
| 2214 | 2322 | elseif (!empty($possible['parameters'])) |
| 2215 | 2323 | { |
| 2216 | - if ($next_c != ' ') |
|
| 2217 | - continue; |
|
| 2218 | - } |
|
| 2219 | - elseif (isset($possible['type'])) |
|
| 2324 | + if ($next_c != ' ') { |
|
| 2325 | + continue; |
|
| 2326 | + } |
|
| 2327 | + } elseif (isset($possible['type'])) |
|
| 2220 | 2328 | { |
| 2221 | 2329 | // Do we need an equal sign? |
| 2222 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2223 | - continue; |
|
| 2330 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2331 | + continue; |
|
| 2332 | + } |
|
| 2224 | 2333 | // Maybe we just want a /... |
| 2225 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2226 | - continue; |
|
| 2334 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2335 | + continue; |
|
| 2336 | + } |
|
| 2227 | 2337 | // An immediate ]? |
| 2228 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2229 | - continue; |
|
| 2338 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2339 | + continue; |
|
| 2340 | + } |
|
| 2230 | 2341 | } |
| 2231 | 2342 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2232 | - elseif ($next_c != ']') |
|
| 2233 | - continue; |
|
| 2343 | + elseif ($next_c != ']') { |
|
| 2344 | + continue; |
|
| 2345 | + } |
|
| 2234 | 2346 | |
| 2235 | 2347 | // Check allowed tree? |
| 2236 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2237 | - continue; |
|
| 2238 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2239 | - continue; |
|
| 2348 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2349 | + continue; |
|
| 2350 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2351 | + continue; |
|
| 2352 | + } |
|
| 2240 | 2353 | // If this is in the list of disallowed child tags, don't parse it. |
| 2241 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2242 | - continue; |
|
| 2354 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2355 | + continue; |
|
| 2356 | + } |
|
| 2243 | 2357 | |
| 2244 | 2358 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2245 | 2359 | |
@@ -2251,8 +2365,9 @@ discard block |
||
| 2251 | 2365 | foreach ($open_tags as $open_quote) |
| 2252 | 2366 | { |
| 2253 | 2367 | // Every parent quote this quote has flips the styling |
| 2254 | - if ($open_quote['tag'] == 'quote') |
|
| 2255 | - $quote_alt = !$quote_alt; |
|
| 2368 | + if ($open_quote['tag'] == 'quote') { |
|
| 2369 | + $quote_alt = !$quote_alt; |
|
| 2370 | + } |
|
| 2256 | 2371 | } |
| 2257 | 2372 | // Add a class to the quote to style alternating blockquotes |
| 2258 | 2373 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2263,8 +2378,9 @@ discard block |
||
| 2263 | 2378 | { |
| 2264 | 2379 | // Build a regular expression for each parameter for the current tag. |
| 2265 | 2380 | $preg = array(); |
| 2266 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2267 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2381 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2382 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2383 | + } |
|
| 2268 | 2384 | |
| 2269 | 2385 | // Extract the string that potentially holds our parameters. |
| 2270 | 2386 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2284,24 +2400,27 @@ discard block |
||
| 2284 | 2400 | |
| 2285 | 2401 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2286 | 2402 | |
| 2287 | - if ($match) |
|
| 2288 | - $blob_counter = count($blobs) + 1; |
|
| 2403 | + if ($match) { |
|
| 2404 | + $blob_counter = count($blobs) + 1; |
|
| 2405 | + } |
|
| 2289 | 2406 | } |
| 2290 | 2407 | |
| 2291 | 2408 | // Didn't match our parameter list, try the next possible. |
| 2292 | - if (!$match) |
|
| 2293 | - continue; |
|
| 2409 | + if (!$match) { |
|
| 2410 | + continue; |
|
| 2411 | + } |
|
| 2294 | 2412 | |
| 2295 | 2413 | $params = array(); |
| 2296 | 2414 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2297 | 2415 | { |
| 2298 | 2416 | $key = strtok(ltrim($matches[$i]), '='); |
| 2299 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2300 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2301 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2302 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2303 | - else |
|
| 2304 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2417 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2418 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2419 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2420 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2421 | + } else { |
|
| 2422 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2423 | + } |
|
| 2305 | 2424 | |
| 2306 | 2425 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2307 | 2426 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2309,23 +2428,26 @@ discard block |
||
| 2309 | 2428 | |
| 2310 | 2429 | foreach ($possible['parameters'] as $p => $info) |
| 2311 | 2430 | { |
| 2312 | - if (!isset($params['{' . $p . '}'])) |
|
| 2313 | - $params['{' . $p . '}'] = ''; |
|
| 2431 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2432 | + $params['{' . $p . '}'] = ''; |
|
| 2433 | + } |
|
| 2314 | 2434 | } |
| 2315 | 2435 | |
| 2316 | 2436 | $tag = $possible; |
| 2317 | 2437 | |
| 2318 | 2438 | // Put the parameters into the string. |
| 2319 | - if (isset($tag['before'])) |
|
| 2320 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2321 | - if (isset($tag['after'])) |
|
| 2322 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2323 | - if (isset($tag['content'])) |
|
| 2324 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2439 | + if (isset($tag['before'])) { |
|
| 2440 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2441 | + } |
|
| 2442 | + if (isset($tag['after'])) { |
|
| 2443 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2444 | + } |
|
| 2445 | + if (isset($tag['content'])) { |
|
| 2446 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2447 | + } |
|
| 2325 | 2448 | |
| 2326 | 2449 | $pos1 += strlen($given_param_string); |
| 2327 | - } |
|
| 2328 | - else |
|
| 2450 | + } else |
|
| 2329 | 2451 | { |
| 2330 | 2452 | $tag = $possible; |
| 2331 | 2453 | $params = array(); |
@@ -2336,8 +2458,9 @@ discard block |
||
| 2336 | 2458 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2337 | 2459 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2338 | 2460 | { |
| 2339 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2340 | - continue; |
|
| 2461 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2462 | + continue; |
|
| 2463 | + } |
|
| 2341 | 2464 | |
| 2342 | 2465 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2343 | 2466 | |
@@ -2358,9 +2481,9 @@ discard block |
||
| 2358 | 2481 | { |
| 2359 | 2482 | array_pop($open_tags); |
| 2360 | 2483 | $code = '</li>'; |
| 2484 | + } else { |
|
| 2485 | + $code = ''; |
|
| 2361 | 2486 | } |
| 2362 | - else |
|
| 2363 | - $code = ''; |
|
| 2364 | 2487 | |
| 2365 | 2488 | // Now we open a new tag. |
| 2366 | 2489 | $open_tags[] = array( |
@@ -2407,12 +2530,14 @@ discard block |
||
| 2407 | 2530 | } |
| 2408 | 2531 | |
| 2409 | 2532 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2410 | - if ($tag === null) |
|
| 2411 | - continue; |
|
| 2533 | + if ($tag === null) { |
|
| 2534 | + continue; |
|
| 2535 | + } |
|
| 2412 | 2536 | |
| 2413 | 2537 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2414 | - if (isset($inside['disallow_children'])) |
|
| 2415 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2538 | + if (isset($inside['disallow_children'])) { |
|
| 2539 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2540 | + } |
|
| 2416 | 2541 | |
| 2417 | 2542 | // Is this tag disabled? |
| 2418 | 2543 | if (isset($disabled[$tag['tag']])) |
@@ -2422,14 +2547,13 @@ discard block |
||
| 2422 | 2547 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2423 | 2548 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2424 | 2549 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2425 | - } |
|
| 2426 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2550 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2427 | 2551 | { |
| 2428 | 2552 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2429 | 2553 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2554 | + } else { |
|
| 2555 | + $tag['content'] = $tag['disabled_content']; |
|
| 2430 | 2556 | } |
| 2431 | - else |
|
| 2432 | - $tag['content'] = $tag['disabled_content']; |
|
| 2433 | 2557 | } |
| 2434 | 2558 | |
| 2435 | 2559 | // we use this a lot |
@@ -2439,8 +2563,9 @@ discard block |
||
| 2439 | 2563 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2440 | 2564 | { |
| 2441 | 2565 | $n = count($open_tags) - 1; |
| 2442 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2443 | - $n--; |
|
| 2566 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2567 | + $n--; |
|
| 2568 | + } |
|
| 2444 | 2569 | |
| 2445 | 2570 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2446 | 2571 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2452,12 +2577,15 @@ discard block |
||
| 2452 | 2577 | |
| 2453 | 2578 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2454 | 2579 | $whitespace_regex = ''; |
| 2455 | - if (!empty($tag['block_level'])) |
|
| 2456 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2457 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2458 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2459 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2460 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2580 | + if (!empty($tag['block_level'])) { |
|
| 2581 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2582 | + } |
|
| 2583 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2584 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2585 | + } |
|
| 2586 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2587 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2588 | + } |
|
| 2461 | 2589 | |
| 2462 | 2590 | array_pop($open_tags); |
| 2463 | 2591 | } |
@@ -2475,16 +2603,19 @@ discard block |
||
| 2475 | 2603 | elseif ($tag['type'] == 'unparsed_content') |
| 2476 | 2604 | { |
| 2477 | 2605 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2478 | - if ($pos2 === false) |
|
| 2479 | - continue; |
|
| 2606 | + if ($pos2 === false) { |
|
| 2607 | + continue; |
|
| 2608 | + } |
|
| 2480 | 2609 | |
| 2481 | 2610 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2482 | 2611 | |
| 2483 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2484 | - $data = substr($data, 4); |
|
| 2612 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2613 | + $data = substr($data, 4); |
|
| 2614 | + } |
|
| 2485 | 2615 | |
| 2486 | - if (isset($tag['validate'])) |
|
| 2487 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2616 | + if (isset($tag['validate'])) { |
|
| 2617 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2618 | + } |
|
| 2488 | 2619 | |
| 2489 | 2620 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2490 | 2621 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2500,34 +2631,40 @@ discard block |
||
| 2500 | 2631 | if (isset($tag['quoted'])) |
| 2501 | 2632 | { |
| 2502 | 2633 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2503 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2504 | - continue; |
|
| 2634 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2635 | + continue; |
|
| 2636 | + } |
|
| 2505 | 2637 | |
| 2506 | - if ($quoted) |
|
| 2507 | - $pos1 += 6; |
|
| 2638 | + if ($quoted) { |
|
| 2639 | + $pos1 += 6; |
|
| 2640 | + } |
|
| 2641 | + } else { |
|
| 2642 | + $quoted = false; |
|
| 2508 | 2643 | } |
| 2509 | - else |
|
| 2510 | - $quoted = false; |
|
| 2511 | 2644 | |
| 2512 | 2645 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2513 | - if ($pos2 === false) |
|
| 2514 | - continue; |
|
| 2646 | + if ($pos2 === false) { |
|
| 2647 | + continue; |
|
| 2648 | + } |
|
| 2515 | 2649 | |
| 2516 | 2650 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2517 | - if ($pos3 === false) |
|
| 2518 | - continue; |
|
| 2651 | + if ($pos3 === false) { |
|
| 2652 | + continue; |
|
| 2653 | + } |
|
| 2519 | 2654 | |
| 2520 | 2655 | $data = array( |
| 2521 | 2656 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2522 | 2657 | substr($message, $pos1, $pos2 - $pos1) |
| 2523 | 2658 | ); |
| 2524 | 2659 | |
| 2525 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2526 | - $data[0] = substr($data[0], 4); |
|
| 2660 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2661 | + $data[0] = substr($data[0], 4); |
|
| 2662 | + } |
|
| 2527 | 2663 | |
| 2528 | 2664 | // Validation for my parking, please! |
| 2529 | - if (isset($tag['validate'])) |
|
| 2530 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2665 | + if (isset($tag['validate'])) { |
|
| 2666 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2667 | + } |
|
| 2531 | 2668 | |
| 2532 | 2669 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2533 | 2670 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2544,23 +2681,27 @@ discard block |
||
| 2544 | 2681 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2545 | 2682 | { |
| 2546 | 2683 | $pos2 = strpos($message, ']', $pos1); |
| 2547 | - if ($pos2 === false) |
|
| 2548 | - continue; |
|
| 2684 | + if ($pos2 === false) { |
|
| 2685 | + continue; |
|
| 2686 | + } |
|
| 2549 | 2687 | |
| 2550 | 2688 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2551 | - if ($pos3 === false) |
|
| 2552 | - continue; |
|
| 2689 | + if ($pos3 === false) { |
|
| 2690 | + continue; |
|
| 2691 | + } |
|
| 2553 | 2692 | |
| 2554 | 2693 | // We want $1 to be the content, and the rest to be csv. |
| 2555 | 2694 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2556 | 2695 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2557 | 2696 | |
| 2558 | - if (isset($tag['validate'])) |
|
| 2559 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2697 | + if (isset($tag['validate'])) { |
|
| 2698 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2699 | + } |
|
| 2560 | 2700 | |
| 2561 | 2701 | $code = $tag['content']; |
| 2562 | - foreach ($data as $k => $d) |
|
| 2563 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2702 | + foreach ($data as $k => $d) { |
|
| 2703 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2704 | + } |
|
| 2564 | 2705 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2565 | 2706 | $pos += strlen($code) - 1 + 2; |
| 2566 | 2707 | } |
@@ -2568,24 +2709,28 @@ discard block |
||
| 2568 | 2709 | elseif ($tag['type'] == 'unparsed_commas') |
| 2569 | 2710 | { |
| 2570 | 2711 | $pos2 = strpos($message, ']', $pos1); |
| 2571 | - if ($pos2 === false) |
|
| 2572 | - continue; |
|
| 2712 | + if ($pos2 === false) { |
|
| 2713 | + continue; |
|
| 2714 | + } |
|
| 2573 | 2715 | |
| 2574 | 2716 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2575 | 2717 | |
| 2576 | - if (isset($tag['validate'])) |
|
| 2577 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2718 | + if (isset($tag['validate'])) { |
|
| 2719 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2720 | + } |
|
| 2578 | 2721 | |
| 2579 | 2722 | // Fix after, for disabled code mainly. |
| 2580 | - foreach ($data as $k => $d) |
|
| 2581 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2723 | + foreach ($data as $k => $d) { |
|
| 2724 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2725 | + } |
|
| 2582 | 2726 | |
| 2583 | 2727 | $open_tags[] = $tag; |
| 2584 | 2728 | |
| 2585 | 2729 | // Replace them out, $1, $2, $3, $4, etc. |
| 2586 | 2730 | $code = $tag['before']; |
| 2587 | - foreach ($data as $k => $d) |
|
| 2588 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2731 | + foreach ($data as $k => $d) { |
|
| 2732 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2733 | + } |
|
| 2589 | 2734 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2590 | 2735 | $pos += strlen($code) - 1 + 2; |
| 2591 | 2736 | } |
@@ -2596,28 +2741,33 @@ discard block |
||
| 2596 | 2741 | if (isset($tag['quoted'])) |
| 2597 | 2742 | { |
| 2598 | 2743 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2599 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2600 | - continue; |
|
| 2744 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2745 | + continue; |
|
| 2746 | + } |
|
| 2601 | 2747 | |
| 2602 | - if ($quoted) |
|
| 2603 | - $pos1 += 6; |
|
| 2748 | + if ($quoted) { |
|
| 2749 | + $pos1 += 6; |
|
| 2750 | + } |
|
| 2751 | + } else { |
|
| 2752 | + $quoted = false; |
|
| 2604 | 2753 | } |
| 2605 | - else |
|
| 2606 | - $quoted = false; |
|
| 2607 | 2754 | |
| 2608 | 2755 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2609 | - if ($pos2 === false) |
|
| 2610 | - continue; |
|
| 2756 | + if ($pos2 === false) { |
|
| 2757 | + continue; |
|
| 2758 | + } |
|
| 2611 | 2759 | |
| 2612 | 2760 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2613 | 2761 | |
| 2614 | 2762 | // Validation for my parking, please! |
| 2615 | - if (isset($tag['validate'])) |
|
| 2616 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2763 | + if (isset($tag['validate'])) { |
|
| 2764 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2765 | + } |
|
| 2617 | 2766 | |
| 2618 | 2767 | // For parsed content, we must recurse to avoid security problems. |
| 2619 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2620 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2768 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2769 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2770 | + } |
|
| 2621 | 2771 | |
| 2622 | 2772 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2623 | 2773 | |
@@ -2629,34 +2779,40 @@ discard block |
||
| 2629 | 2779 | } |
| 2630 | 2780 | |
| 2631 | 2781 | // If this is block level, eat any breaks after it. |
| 2632 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2633 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2782 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2783 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2784 | + } |
|
| 2634 | 2785 | |
| 2635 | 2786 | // Are we trimming outside this tag? |
| 2636 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2637 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2787 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 2788 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2789 | + } |
|
| 2638 | 2790 | } |
| 2639 | 2791 | |
| 2640 | 2792 | // Close any remaining tags. |
| 2641 | - while ($tag = array_pop($open_tags)) |
|
| 2642 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 2793 | + while ($tag = array_pop($open_tags)) { |
|
| 2794 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 2795 | + } |
|
| 2643 | 2796 | |
| 2644 | 2797 | // Parse the smileys within the parts where it can be done safely. |
| 2645 | 2798 | if ($smileys === true) |
| 2646 | 2799 | { |
| 2647 | 2800 | $message_parts = explode("\n", $message); |
| 2648 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2649 | - parsesmileys($message_parts[$i]); |
|
| 2801 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 2802 | + parsesmileys($message_parts[$i]); |
|
| 2803 | + } |
|
| 2650 | 2804 | |
| 2651 | 2805 | $message = implode('', $message_parts); |
| 2652 | 2806 | } |
| 2653 | 2807 | |
| 2654 | 2808 | // No smileys, just get rid of the markers. |
| 2655 | - else |
|
| 2656 | - $message = strtr($message, array("\n" => '')); |
|
| 2809 | + else { |
|
| 2810 | + $message = strtr($message, array("\n" => '')); |
|
| 2811 | + } |
|
| 2657 | 2812 | |
| 2658 | - if ($message !== '' && $message[0] === ' ') |
|
| 2659 | - $message = ' ' . substr($message, 1); |
|
| 2813 | + if ($message !== '' && $message[0] === ' ') { |
|
| 2814 | + $message = ' ' . substr($message, 1); |
|
| 2815 | + } |
|
| 2660 | 2816 | |
| 2661 | 2817 | // Cleanup whitespace. |
| 2662 | 2818 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2665,15 +2821,16 @@ discard block |
||
| 2665 | 2821 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2666 | 2822 | |
| 2667 | 2823 | // Cache the output if it took some time... |
| 2668 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2669 | - cache_put_data($cache_key, $message, 240); |
|
| 2824 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 2825 | + cache_put_data($cache_key, $message, 240); |
|
| 2826 | + } |
|
| 2670 | 2827 | |
| 2671 | 2828 | // If this was a force parse revert if needed. |
| 2672 | 2829 | if (!empty($parse_tags)) |
| 2673 | 2830 | { |
| 2674 | - if (empty($temp_bbc)) |
|
| 2675 | - $bbc_codes = array(); |
|
| 2676 | - else |
|
| 2831 | + if (empty($temp_bbc)) { |
|
| 2832 | + $bbc_codes = array(); |
|
| 2833 | + } else |
|
| 2677 | 2834 | { |
| 2678 | 2835 | $bbc_codes = $temp_bbc; |
| 2679 | 2836 | unset($temp_bbc); |
@@ -2700,8 +2857,9 @@ discard block |
||
| 2700 | 2857 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2701 | 2858 | |
| 2702 | 2859 | // No smiley set at all?! |
| 2703 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2704 | - return; |
|
| 2860 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 2861 | + return; |
|
| 2862 | + } |
|
| 2705 | 2863 | |
| 2706 | 2864 | // If smileyPregSearch hasn't been set, do it now. |
| 2707 | 2865 | if (empty($smileyPregSearch)) |
@@ -2712,8 +2870,7 @@ discard block |
||
| 2712 | 2870 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
| 2713 | 2871 | $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif'); |
| 2714 | 2872 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
| 2715 | - } |
|
| 2716 | - else |
|
| 2873 | + } else |
|
| 2717 | 2874 | { |
| 2718 | 2875 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2719 | 2876 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2737,9 +2894,9 @@ discard block |
||
| 2737 | 2894 | $smcFunc['db_free_result']($result); |
| 2738 | 2895 | |
| 2739 | 2896 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 2897 | + } else { |
|
| 2898 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2740 | 2899 | } |
| 2741 | - else |
|
| 2742 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2743 | 2900 | } |
| 2744 | 2901 | |
| 2745 | 2902 | // The non-breaking-space is a complex thing... |
@@ -2816,35 +2973,41 @@ discard block |
||
| 2816 | 2973 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 2817 | 2974 | |
| 2818 | 2975 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 2819 | - if (!empty($context['flush_mail'])) |
|
| 2820 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2976 | + if (!empty($context['flush_mail'])) { |
|
| 2977 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2821 | 2978 | AddMailQueue(true); |
| 2979 | + } |
|
| 2822 | 2980 | |
| 2823 | 2981 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 2824 | 2982 | |
| 2825 | - if ($add) |
|
| 2826 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 2983 | + if ($add) { |
|
| 2984 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 2985 | + } |
|
| 2827 | 2986 | |
| 2828 | 2987 | // Put the session ID in. |
| 2829 | - if (defined('SID') && SID != '') |
|
| 2830 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 2988 | + if (defined('SID') && SID != '') { |
|
| 2989 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 2990 | + } |
|
| 2831 | 2991 | // Keep that debug in their for template debugging! |
| 2832 | - elseif (isset($_GET['debug'])) |
|
| 2833 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 2992 | + elseif (isset($_GET['debug'])) { |
|
| 2993 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 2994 | + } |
|
| 2834 | 2995 | |
| 2835 | 2996 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
| 2836 | 2997 | { |
| 2837 | - if (defined('SID') && SID != '') |
|
| 2838 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2998 | + if (defined('SID') && SID != '') { |
|
| 2999 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2839 | 3000 | function ($m) use ($scripturl) |
| 2840 | 3001 | { |
| 2841 | 3002 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 3003 | + } |
|
| 2842 | 3004 | }, $setLocation); |
| 2843 | - else |
|
| 2844 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3005 | + else { |
|
| 3006 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2845 | 3007 | function ($m) use ($scripturl) |
| 2846 | 3008 | { |
| 2847 | 3009 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 3010 | + } |
|
| 2848 | 3011 | }, $setLocation); |
| 2849 | 3012 | } |
| 2850 | 3013 | |
@@ -2855,8 +3018,9 @@ discard block |
||
| 2855 | 3018 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 2856 | 3019 | |
| 2857 | 3020 | // Debugging. |
| 2858 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 2859 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 3021 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3022 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 3023 | + } |
|
| 2860 | 3024 | |
| 2861 | 3025 | obExit(false); |
| 2862 | 3026 | } |
@@ -2875,51 +3039,60 @@ discard block |
||
| 2875 | 3039 | |
| 2876 | 3040 | // Attempt to prevent a recursive loop. |
| 2877 | 3041 | ++$level; |
| 2878 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 2879 | - exit; |
|
| 2880 | - if ($from_fatal_error) |
|
| 2881 | - $has_fatal_error = true; |
|
| 3042 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 3043 | + exit; |
|
| 3044 | + } |
|
| 3045 | + if ($from_fatal_error) { |
|
| 3046 | + $has_fatal_error = true; |
|
| 3047 | + } |
|
| 2882 | 3048 | |
| 2883 | 3049 | // Clear out the stat cache. |
| 2884 | 3050 | trackStats(); |
| 2885 | 3051 | |
| 2886 | 3052 | // If we have mail to send, send it. |
| 2887 | - if (!empty($context['flush_mail'])) |
|
| 2888 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3053 | + if (!empty($context['flush_mail'])) { |
|
| 3054 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2889 | 3055 | AddMailQueue(true); |
| 3056 | + } |
|
| 2890 | 3057 | |
| 2891 | 3058 | $do_header = $header === null ? !$header_done : $header; |
| 2892 | - if ($do_footer === null) |
|
| 2893 | - $do_footer = $do_header; |
|
| 3059 | + if ($do_footer === null) { |
|
| 3060 | + $do_footer = $do_header; |
|
| 3061 | + } |
|
| 2894 | 3062 | |
| 2895 | 3063 | // Has the template/header been done yet? |
| 2896 | 3064 | if ($do_header) |
| 2897 | 3065 | { |
| 2898 | 3066 | // Was the page title set last minute? Also update the HTML safe one. |
| 2899 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 2900 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3067 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 3068 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3069 | + } |
|
| 2901 | 3070 | |
| 2902 | 3071 | // Start up the session URL fixer. |
| 2903 | 3072 | ob_start('ob_sessrewrite'); |
| 2904 | 3073 | |
| 2905 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 2906 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 2907 | - elseif (!empty($settings['output_buffers'])) |
|
| 2908 | - $buffers = $settings['output_buffers']; |
|
| 2909 | - else |
|
| 2910 | - $buffers = array(); |
|
| 3074 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 3075 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 3076 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 3077 | + $buffers = $settings['output_buffers']; |
|
| 3078 | + } else { |
|
| 3079 | + $buffers = array(); |
|
| 3080 | + } |
|
| 2911 | 3081 | |
| 2912 | - if (isset($modSettings['integrate_buffer'])) |
|
| 2913 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3082 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3083 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3084 | + } |
|
| 2914 | 3085 | |
| 2915 | - if (!empty($buffers)) |
|
| 2916 | - foreach ($buffers as $function) |
|
| 3086 | + if (!empty($buffers)) { |
|
| 3087 | + foreach ($buffers as $function) |
|
| 2917 | 3088 | { |
| 2918 | 3089 | $call = call_helper($function, true); |
| 3090 | + } |
|
| 2919 | 3091 | |
| 2920 | 3092 | // Is it valid? |
| 2921 | - if (!empty($call)) |
|
| 2922 | - ob_start($call); |
|
| 3093 | + if (!empty($call)) { |
|
| 3094 | + ob_start($call); |
|
| 3095 | + } |
|
| 2923 | 3096 | } |
| 2924 | 3097 | |
| 2925 | 3098 | // Display the screen in the logical order. |
@@ -2931,8 +3104,9 @@ discard block |
||
| 2931 | 3104 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 2932 | 3105 | |
| 2933 | 3106 | // Anything special to put out? |
| 2934 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 2935 | - echo $context['insert_after_template']; |
|
| 3107 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3108 | + echo $context['insert_after_template']; |
|
| 3109 | + } |
|
| 2936 | 3110 | |
| 2937 | 3111 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 2938 | 3112 | if (!$footer_done) |
@@ -2941,14 +3115,16 @@ discard block |
||
| 2941 | 3115 | template_footer(); |
| 2942 | 3116 | |
| 2943 | 3117 | // (since this is just debugging... it's okay that it's after </html>.) |
| 2944 | - if (!isset($_REQUEST['xml'])) |
|
| 2945 | - displayDebug(); |
|
| 3118 | + if (!isset($_REQUEST['xml'])) { |
|
| 3119 | + displayDebug(); |
|
| 3120 | + } |
|
| 2946 | 3121 | } |
| 2947 | 3122 | } |
| 2948 | 3123 | |
| 2949 | 3124 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 2950 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 2951 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3125 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3126 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3127 | + } |
|
| 2952 | 3128 | |
| 2953 | 3129 | // For session check verification.... don't switch browsers... |
| 2954 | 3130 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -2957,9 +3133,10 @@ discard block |
||
| 2957 | 3133 | call_integration_hook('integrate_exit', array($do_footer)); |
| 2958 | 3134 | |
| 2959 | 3135 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 2960 | - if (!$from_index) |
|
| 2961 | - exit; |
|
| 2962 | -} |
|
| 3136 | + if (!$from_index) { |
|
| 3137 | + exit; |
|
| 3138 | + } |
|
| 3139 | + } |
|
| 2963 | 3140 | |
| 2964 | 3141 | /** |
| 2965 | 3142 | * Get the size of a specified image with better error handling. |
@@ -2978,8 +3155,9 @@ discard block |
||
| 2978 | 3155 | $url = str_replace(' ', '%20', $url); |
| 2979 | 3156 | |
| 2980 | 3157 | // Can we pull this from the cache... please please? |
| 2981 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 2982 | - return $temp; |
|
| 3158 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3159 | + return $temp; |
|
| 3160 | + } |
|
| 2983 | 3161 | $t = microtime(); |
| 2984 | 3162 | |
| 2985 | 3163 | // Get the host to pester... |
@@ -2989,12 +3167,10 @@ discard block |
||
| 2989 | 3167 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 2990 | 3168 | { |
| 2991 | 3169 | return false; |
| 2992 | - } |
|
| 2993 | - elseif (!isset($match[1])) |
|
| 3170 | + } elseif (!isset($match[1])) |
|
| 2994 | 3171 | { |
| 2995 | 3172 | $size = @getimagesize($url); |
| 2996 | - } |
|
| 2997 | - else |
|
| 3173 | + } else |
|
| 2998 | 3174 | { |
| 2999 | 3175 | // Try to connect to the server... give it half a second. |
| 3000 | 3176 | $temp = 0; |
@@ -3033,12 +3209,14 @@ discard block |
||
| 3033 | 3209 | } |
| 3034 | 3210 | |
| 3035 | 3211 | // If we didn't get it, we failed. |
| 3036 | - if (!isset($size)) |
|
| 3037 | - $size = false; |
|
| 3212 | + if (!isset($size)) { |
|
| 3213 | + $size = false; |
|
| 3214 | + } |
|
| 3038 | 3215 | |
| 3039 | 3216 | // If this took a long time, we may never have to do it again, but then again we might... |
| 3040 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 3041 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3217 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3218 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3219 | + } |
|
| 3042 | 3220 | |
| 3043 | 3221 | // Didn't work. |
| 3044 | 3222 | return $size; |
@@ -3056,8 +3234,9 @@ discard block |
||
| 3056 | 3234 | |
| 3057 | 3235 | // Under SSI this function can be called more then once. That can cause some problems. |
| 3058 | 3236 | // So only run the function once unless we are forced to run it again. |
| 3059 | - if ($loaded && !$forceload) |
|
| 3060 | - return; |
|
| 3237 | + if ($loaded && !$forceload) { |
|
| 3238 | + return; |
|
| 3239 | + } |
|
| 3061 | 3240 | |
| 3062 | 3241 | $loaded = true; |
| 3063 | 3242 | |
@@ -3069,14 +3248,16 @@ discard block |
||
| 3069 | 3248 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 3070 | 3249 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3071 | 3250 | { |
| 3072 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3073 | - continue; |
|
| 3251 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3252 | + continue; |
|
| 3253 | + } |
|
| 3074 | 3254 | |
| 3075 | 3255 | // Clean it up for presentation ;). |
| 3076 | 3256 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3077 | 3257 | } |
| 3078 | - if (!empty($context['news_lines'])) |
|
| 3079 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3258 | + if (!empty($context['news_lines'])) { |
|
| 3259 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3260 | + } |
|
| 3080 | 3261 | |
| 3081 | 3262 | if (!$user_info['is_guest']) |
| 3082 | 3263 | { |
@@ -3085,40 +3266,48 @@ discard block |
||
| 3085 | 3266 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3086 | 3267 | |
| 3087 | 3268 | // Personal message popup... |
| 3088 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3089 | - $context['user']['popup_messages'] = true; |
|
| 3090 | - else |
|
| 3091 | - $context['user']['popup_messages'] = false; |
|
| 3269 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3270 | + $context['user']['popup_messages'] = true; |
|
| 3271 | + } else { |
|
| 3272 | + $context['user']['popup_messages'] = false; |
|
| 3273 | + } |
|
| 3092 | 3274 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3093 | 3275 | |
| 3094 | - if (allowedTo('moderate_forum')) |
|
| 3095 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3276 | + if (allowedTo('moderate_forum')) { |
|
| 3277 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3278 | + } |
|
| 3096 | 3279 | |
| 3097 | 3280 | $context['user']['avatar'] = array(); |
| 3098 | 3281 | |
| 3099 | 3282 | // Check for gravatar first since we might be forcing them... |
| 3100 | 3283 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3101 | 3284 | { |
| 3102 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3103 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3104 | - else |
|
| 3105 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3285 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3286 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3287 | + } else { |
|
| 3288 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3289 | + } |
|
| 3106 | 3290 | } |
| 3107 | 3291 | // Uploaded? |
| 3108 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3109 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3292 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3293 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3294 | + } |
|
| 3110 | 3295 | // Full URL? |
| 3111 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3112 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3296 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3297 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3298 | + } |
|
| 3113 | 3299 | // Otherwise we assume it's server stored. |
| 3114 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3115 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3300 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3301 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3302 | + } |
|
| 3116 | 3303 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3117 | - else |
|
| 3118 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3304 | + else { |
|
| 3305 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3306 | + } |
|
| 3119 | 3307 | |
| 3120 | - if (!empty($context['user']['avatar'])) |
|
| 3121 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3308 | + if (!empty($context['user']['avatar'])) { |
|
| 3309 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3310 | + } |
|
| 3122 | 3311 | |
| 3123 | 3312 | // Figure out how long they've been logged in. |
| 3124 | 3313 | $context['user']['total_time_logged_in'] = array( |
@@ -3126,8 +3315,7 @@ discard block |
||
| 3126 | 3315 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3127 | 3316 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3128 | 3317 | ); |
| 3129 | - } |
|
| 3130 | - else |
|
| 3318 | + } else |
|
| 3131 | 3319 | { |
| 3132 | 3320 | $context['user']['messages'] = 0; |
| 3133 | 3321 | $context['user']['unread_messages'] = 0; |
@@ -3135,12 +3323,14 @@ discard block |
||
| 3135 | 3323 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3136 | 3324 | $context['user']['popup_messages'] = false; |
| 3137 | 3325 | |
| 3138 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3139 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3326 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3327 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3328 | + } |
|
| 3140 | 3329 | |
| 3141 | 3330 | // If we've upgraded recently, go easy on the passwords. |
| 3142 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3143 | - $context['disable_login_hashing'] = true; |
|
| 3331 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3332 | + $context['disable_login_hashing'] = true; |
|
| 3333 | + } |
|
| 3144 | 3334 | } |
| 3145 | 3335 | |
| 3146 | 3336 | // Setup the main menu items. |
@@ -3153,8 +3343,8 @@ discard block |
||
| 3153 | 3343 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3154 | 3344 | |
| 3155 | 3345 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3156 | - if ($context['show_pm_popup']) |
|
| 3157 | - addInlineJavaScript(' |
|
| 3346 | + if ($context['show_pm_popup']) { |
|
| 3347 | + addInlineJavaScript(' |
|
| 3158 | 3348 | jQuery(document).ready(function($) { |
| 3159 | 3349 | new smc_Popup({ |
| 3160 | 3350 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3162,15 +3352,17 @@ discard block |
||
| 3162 | 3352 | icon_class: \'generic_icons mail_new\' |
| 3163 | 3353 | }); |
| 3164 | 3354 | });'); |
| 3355 | + } |
|
| 3165 | 3356 | |
| 3166 | 3357 | // Add a generic "Are you sure?" confirmation message. |
| 3167 | 3358 | addInlineJavaScript(' |
| 3168 | 3359 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3169 | 3360 | |
| 3170 | 3361 | // Now add the capping code for avatars. |
| 3171 | - if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
|
| 3172 | - addInlineCss(' |
|
| 3362 | + if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') { |
|
| 3363 | + addInlineCss(' |
|
| 3173 | 3364 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3365 | + } |
|
| 3174 | 3366 | |
| 3175 | 3367 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3176 | 3368 | $context['common_stats']['latest_member'] = array( |
@@ -3187,11 +3379,13 @@ discard block |
||
| 3187 | 3379 | ); |
| 3188 | 3380 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
| 3189 | 3381 | |
| 3190 | - if (empty($settings['theme_version'])) |
|
| 3191 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3382 | + if (empty($settings['theme_version'])) { |
|
| 3383 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3384 | + } |
|
| 3192 | 3385 | |
| 3193 | - if (!isset($context['page_title'])) |
|
| 3194 | - $context['page_title'] = ''; |
|
| 3386 | + if (!isset($context['page_title'])) { |
|
| 3387 | + $context['page_title'] = ''; |
|
| 3388 | + } |
|
| 3195 | 3389 | |
| 3196 | 3390 | // Set some specific vars. |
| 3197 | 3391 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3201,21 +3395,23 @@ discard block |
||
| 3201 | 3395 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3202 | 3396 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3203 | 3397 | |
| 3204 | - if (!empty($context['meta_keywords'])) |
|
| 3205 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3398 | + if (!empty($context['meta_keywords'])) { |
|
| 3399 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3400 | + } |
|
| 3206 | 3401 | |
| 3207 | - if (!empty($context['canonical_url'])) |
|
| 3208 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3402 | + if (!empty($context['canonical_url'])) { |
|
| 3403 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3404 | + } |
|
| 3209 | 3405 | |
| 3210 | - if (!empty($settings['og_image'])) |
|
| 3211 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3406 | + if (!empty($settings['og_image'])) { |
|
| 3407 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3408 | + } |
|
| 3212 | 3409 | |
| 3213 | 3410 | if (!empty($context['meta_description'])) |
| 3214 | 3411 | { |
| 3215 | 3412 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3216 | 3413 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3217 | - } |
|
| 3218 | - else |
|
| 3414 | + } else |
|
| 3219 | 3415 | { |
| 3220 | 3416 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3221 | 3417 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3240,8 +3436,9 @@ discard block |
||
| 3240 | 3436 | $memory_needed = memoryReturnBytes($needed); |
| 3241 | 3437 | |
| 3242 | 3438 | // should we account for how much is currently being used? |
| 3243 | - if ($in_use) |
|
| 3244 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3439 | + if ($in_use) { |
|
| 3440 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3441 | + } |
|
| 3245 | 3442 | |
| 3246 | 3443 | // if more is needed, request it |
| 3247 | 3444 | if ($memory_current < $memory_needed) |
@@ -3264,8 +3461,9 @@ discard block |
||
| 3264 | 3461 | */ |
| 3265 | 3462 | function memoryReturnBytes($val) |
| 3266 | 3463 | { |
| 3267 | - if (is_integer($val)) |
|
| 3268 | - return $val; |
|
| 3464 | + if (is_integer($val)) { |
|
| 3465 | + return $val; |
|
| 3466 | + } |
|
| 3269 | 3467 | |
| 3270 | 3468 | // Separate the number from the designator |
| 3271 | 3469 | $val = trim($val); |
@@ -3301,10 +3499,11 @@ discard block |
||
| 3301 | 3499 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3302 | 3500 | |
| 3303 | 3501 | // Are we debugging the template/html content? |
| 3304 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3305 | - header('Content-Type: application/xhtml+xml'); |
|
| 3306 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3307 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3502 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3503 | + header('Content-Type: application/xhtml+xml'); |
|
| 3504 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3505 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3506 | + } |
|
| 3308 | 3507 | } |
| 3309 | 3508 | |
| 3310 | 3509 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3313,8 +3512,9 @@ discard block |
||
| 3313 | 3512 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3314 | 3513 | { |
| 3315 | 3514 | $position = array_search('body', $context['template_layers']); |
| 3316 | - if ($position === false) |
|
| 3317 | - $position = array_search('main', $context['template_layers']); |
|
| 3515 | + if ($position === false) { |
|
| 3516 | + $position = array_search('main', $context['template_layers']); |
|
| 3517 | + } |
|
| 3318 | 3518 | |
| 3319 | 3519 | if ($position !== false) |
| 3320 | 3520 | { |
@@ -3342,23 +3542,25 @@ discard block |
||
| 3342 | 3542 | |
| 3343 | 3543 | foreach ($securityFiles as $i => $securityFile) |
| 3344 | 3544 | { |
| 3345 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3346 | - unset($securityFiles[$i]); |
|
| 3545 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3546 | + unset($securityFiles[$i]); |
|
| 3547 | + } |
|
| 3347 | 3548 | } |
| 3348 | 3549 | |
| 3349 | 3550 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3350 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3351 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3352 | - |
|
| 3353 | - else |
|
| 3354 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3551 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3552 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3553 | + } else { |
|
| 3554 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3555 | + } |
|
| 3355 | 3556 | |
| 3356 | 3557 | secureDirectory($path, true); |
| 3357 | 3558 | secureDirectory($cachedir); |
| 3358 | 3559 | |
| 3359 | 3560 | // If agreement is enabled, at least the english version shall exists |
| 3360 | - if ($modSettings['requireAgreement']) |
|
| 3361 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3561 | + if ($modSettings['requireAgreement']) { |
|
| 3562 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3563 | + } |
|
| 3362 | 3564 | |
| 3363 | 3565 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3364 | 3566 | { |
@@ -3373,18 +3575,21 @@ discard block |
||
| 3373 | 3575 | echo ' |
| 3374 | 3576 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3375 | 3577 | |
| 3376 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3377 | - echo ' |
|
| 3578 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3579 | + echo ' |
|
| 3378 | 3580 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3581 | + } |
|
| 3379 | 3582 | } |
| 3380 | 3583 | |
| 3381 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3382 | - echo ' |
|
| 3584 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3585 | + echo ' |
|
| 3383 | 3586 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3587 | + } |
|
| 3384 | 3588 | |
| 3385 | - if (!empty($agreement)) |
|
| 3386 | - echo ' |
|
| 3589 | + if (!empty($agreement)) { |
|
| 3590 | + echo ' |
|
| 3387 | 3591 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3592 | + } |
|
| 3388 | 3593 | |
| 3389 | 3594 | echo ' |
| 3390 | 3595 | </p> |
@@ -3399,16 +3604,18 @@ discard block |
||
| 3399 | 3604 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3400 | 3605 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3401 | 3606 | |
| 3402 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3403 | - echo ' |
|
| 3607 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3608 | + echo ' |
|
| 3404 | 3609 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3610 | + } |
|
| 3405 | 3611 | |
| 3406 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3407 | - echo ' |
|
| 3612 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3613 | + echo ' |
|
| 3408 | 3614 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3409 | - else |
|
| 3410 | - echo ' |
|
| 3615 | + } else { |
|
| 3616 | + echo ' |
|
| 3411 | 3617 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3618 | + } |
|
| 3412 | 3619 | |
| 3413 | 3620 | echo ' |
| 3414 | 3621 | </div>'; |
@@ -3424,8 +3631,9 @@ discard block |
||
| 3424 | 3631 | global $forum_copyright, $software_year, $forum_version; |
| 3425 | 3632 | |
| 3426 | 3633 | // Don't display copyright for things like SSI. |
| 3427 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3428 | - return; |
|
| 3634 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3635 | + return; |
|
| 3636 | + } |
|
| 3429 | 3637 | |
| 3430 | 3638 | // Put in the version... |
| 3431 | 3639 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3443,9 +3651,10 @@ discard block |
||
| 3443 | 3651 | $context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3)); |
| 3444 | 3652 | $context['load_queries'] = $db_count; |
| 3445 | 3653 | |
| 3446 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3447 | - loadSubTemplate($layer . '_below', true); |
|
| 3448 | -} |
|
| 3654 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3655 | + loadSubTemplate($layer . '_below', true); |
|
| 3656 | + } |
|
| 3657 | + } |
|
| 3449 | 3658 | |
| 3450 | 3659 | /** |
| 3451 | 3660 | * Output the Javascript files |
@@ -3476,8 +3685,7 @@ discard block |
||
| 3476 | 3685 | { |
| 3477 | 3686 | echo ' |
| 3478 | 3687 | var ', $key, ';'; |
| 3479 | - } |
|
| 3480 | - else |
|
| 3688 | + } else |
|
| 3481 | 3689 | { |
| 3482 | 3690 | echo ' |
| 3483 | 3691 | var ', $key, ' = ', $value, ';'; |
@@ -3492,26 +3700,27 @@ discard block |
||
| 3492 | 3700 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3493 | 3701 | { |
| 3494 | 3702 | // Last minute call! allow theme authors to disable single files. |
| 3495 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3496 | - continue; |
|
| 3703 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3704 | + continue; |
|
| 3705 | + } |
|
| 3497 | 3706 | |
| 3498 | 3707 | // By default all files don't get minimized unless the file explicitly says so! |
| 3499 | 3708 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3500 | 3709 | { |
| 3501 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
| 3502 | - $toMinifyDefer[] = $js_file; |
|
| 3503 | - |
|
| 3504 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
| 3505 | - $toMinify[] = $js_file; |
|
| 3710 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
| 3711 | + $toMinifyDefer[] = $js_file; |
|
| 3712 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
| 3713 | + $toMinify[] = $js_file; |
|
| 3714 | + } |
|
| 3506 | 3715 | |
| 3507 | 3716 | // Grab a random seed. |
| 3508 | - if (!isset($minSeed)) |
|
| 3509 | - $minSeed = $js_file['options']['seed']; |
|
| 3510 | - } |
|
| 3511 | - |
|
| 3512 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
| 3513 | - echo ' |
|
| 3717 | + if (!isset($minSeed)) { |
|
| 3718 | + $minSeed = $js_file['options']['seed']; |
|
| 3719 | + } |
|
| 3720 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
| 3721 | + echo ' |
|
| 3514 | 3722 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3723 | + } |
|
| 3515 | 3724 | } |
| 3516 | 3725 | |
| 3517 | 3726 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3519,14 +3728,14 @@ discard block |
||
| 3519 | 3728 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
| 3520 | 3729 | |
| 3521 | 3730 | // Minify process couldn't work, print each individual files. |
| 3522 | - if (!empty($result) && is_array($result)) |
|
| 3523 | - foreach ($result as $minFailedFile) |
|
| 3731 | + if (!empty($result) && is_array($result)) { |
|
| 3732 | + foreach ($result as $minFailedFile) |
|
| 3524 | 3733 | echo ' |
| 3525 | 3734 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3526 | - |
|
| 3527 | - else |
|
| 3528 | - echo ' |
|
| 3735 | + } else { |
|
| 3736 | + echo ' |
|
| 3529 | 3737 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
| 3738 | + } |
|
| 3530 | 3739 | } |
| 3531 | 3740 | |
| 3532 | 3741 | // Inline JavaScript - Actually useful some times! |
@@ -3537,8 +3746,9 @@ discard block |
||
| 3537 | 3746 | echo ' |
| 3538 | 3747 | <script>'; |
| 3539 | 3748 | |
| 3540 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3541 | - echo $js_code; |
|
| 3749 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 3750 | + echo $js_code; |
|
| 3751 | + } |
|
| 3542 | 3752 | |
| 3543 | 3753 | echo ' |
| 3544 | 3754 | </script>'; |
@@ -3549,8 +3759,9 @@ discard block |
||
| 3549 | 3759 | echo ' |
| 3550 | 3760 | <script>'; |
| 3551 | 3761 | |
| 3552 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3553 | - echo $js_code; |
|
| 3762 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 3763 | + echo $js_code; |
|
| 3764 | + } |
|
| 3554 | 3765 | |
| 3555 | 3766 | echo ' |
| 3556 | 3767 | </script>'; |
@@ -3575,8 +3786,9 @@ discard block |
||
| 3575 | 3786 | foreach ($context['css_files'] as $id => $file) |
| 3576 | 3787 | { |
| 3577 | 3788 | // Last minute call! allow theme authors to disable single files. |
| 3578 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3579 | - continue; |
|
| 3789 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3790 | + continue; |
|
| 3791 | + } |
|
| 3580 | 3792 | |
| 3581 | 3793 | // By default all files don't get minimized unless the file explicitly says so! |
| 3582 | 3794 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3584,12 +3796,12 @@ discard block |
||
| 3584 | 3796 | $toMinify[] = $file; |
| 3585 | 3797 | |
| 3586 | 3798 | // Grab a random seed. |
| 3587 | - if (!isset($minSeed)) |
|
| 3588 | - $minSeed = $file['options']['seed']; |
|
| 3799 | + if (!isset($minSeed)) { |
|
| 3800 | + $minSeed = $file['options']['seed']; |
|
| 3801 | + } |
|
| 3802 | + } else { |
|
| 3803 | + $normal[] = $file['fileUrl']; |
|
| 3589 | 3804 | } |
| 3590 | - |
|
| 3591 | - else |
|
| 3592 | - $normal[] = $file['fileUrl']; |
|
| 3593 | 3805 | } |
| 3594 | 3806 | |
| 3595 | 3807 | if (!empty($toMinify)) |
@@ -3597,28 +3809,30 @@ discard block |
||
| 3597 | 3809 | $result = custMinify($toMinify, 'css'); |
| 3598 | 3810 | |
| 3599 | 3811 | // Minify process couldn't work, print each individual files. |
| 3600 | - if (!empty($result) && is_array($result)) |
|
| 3601 | - foreach ($result as $minFailedFile) |
|
| 3812 | + if (!empty($result) && is_array($result)) { |
|
| 3813 | + foreach ($result as $minFailedFile) |
|
| 3602 | 3814 | echo ' |
| 3603 | 3815 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
| 3604 | - |
|
| 3605 | - else |
|
| 3606 | - echo ' |
|
| 3816 | + } else { |
|
| 3817 | + echo ' |
|
| 3607 | 3818 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
| 3819 | + } |
|
| 3608 | 3820 | } |
| 3609 | 3821 | |
| 3610 | 3822 | // Print the rest after the minified files. |
| 3611 | - if (!empty($normal)) |
|
| 3612 | - foreach ($normal as $nf) |
|
| 3823 | + if (!empty($normal)) { |
|
| 3824 | + foreach ($normal as $nf) |
|
| 3613 | 3825 | echo ' |
| 3614 | 3826 | <link rel="stylesheet" href="', $nf ,'">'; |
| 3827 | + } |
|
| 3615 | 3828 | |
| 3616 | 3829 | if ($db_show_debug === true) |
| 3617 | 3830 | { |
| 3618 | 3831 | // Try to keep only what's useful. |
| 3619 | 3832 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3620 | - foreach ($context['css_files'] as $file) |
|
| 3621 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3833 | + foreach ($context['css_files'] as $file) { |
|
| 3834 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3835 | + } |
|
| 3622 | 3836 | } |
| 3623 | 3837 | |
| 3624 | 3838 | if (!empty($context['css_header'])) |
@@ -3626,9 +3840,10 @@ discard block |
||
| 3626 | 3840 | echo ' |
| 3627 | 3841 | <style>'; |
| 3628 | 3842 | |
| 3629 | - foreach ($context['css_header'] as $css) |
|
| 3630 | - echo $css .' |
|
| 3843 | + foreach ($context['css_header'] as $css) { |
|
| 3844 | + echo $css .' |
|
| 3631 | 3845 | '; |
| 3846 | + } |
|
| 3632 | 3847 | |
| 3633 | 3848 | echo' |
| 3634 | 3849 | </style>'; |
@@ -3652,15 +3867,17 @@ discard block |
||
| 3652 | 3867 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
| 3653 | 3868 | $data = !empty($data) ? $data : false; |
| 3654 | 3869 | |
| 3655 | - if (empty($type) || empty($data)) |
|
| 3656 | - return false; |
|
| 3870 | + if (empty($type) || empty($data)) { |
|
| 3871 | + return false; |
|
| 3872 | + } |
|
| 3657 | 3873 | |
| 3658 | 3874 | // Did we already did this? |
| 3659 | 3875 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
| 3660 | 3876 | |
| 3661 | 3877 | // Already done? |
| 3662 | - if (!empty($toCache)) |
|
| 3663 | - return true; |
|
| 3878 | + if (!empty($toCache)) { |
|
| 3879 | + return true; |
|
| 3880 | + } |
|
| 3664 | 3881 | |
| 3665 | 3882 | // No namespaces, sorry! |
| 3666 | 3883 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3742,8 +3959,9 @@ discard block |
||
| 3742 | 3959 | global $modSettings, $smcFunc; |
| 3743 | 3960 | |
| 3744 | 3961 | // Just make up a nice hash... |
| 3745 | - if ($new) |
|
| 3746 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 3962 | + if ($new) { |
|
| 3963 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 3964 | + } |
|
| 3747 | 3965 | |
| 3748 | 3966 | // Just make sure that attachment id is only a int |
| 3749 | 3967 | $attachment_id = (int) $attachment_id; |
@@ -3760,23 +3978,25 @@ discard block |
||
| 3760 | 3978 | 'id_attach' => $attachment_id, |
| 3761 | 3979 | )); |
| 3762 | 3980 | |
| 3763 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 3764 | - return false; |
|
| 3981 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 3982 | + return false; |
|
| 3983 | + } |
|
| 3765 | 3984 | |
| 3766 | 3985 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 3767 | 3986 | $smcFunc['db_free_result']($request); |
| 3768 | 3987 | } |
| 3769 | 3988 | |
| 3770 | 3989 | // Still no hash? mmm... |
| 3771 | - if (empty($file_hash)) |
|
| 3772 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 3990 | + if (empty($file_hash)) { |
|
| 3991 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 3992 | + } |
|
| 3773 | 3993 | |
| 3774 | 3994 | // Are we using multiple directories? |
| 3775 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
| 3776 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3777 | - |
|
| 3778 | - else |
|
| 3779 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3995 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
| 3996 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3997 | + } else { |
|
| 3998 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3999 | + } |
|
| 3780 | 4000 | |
| 3781 | 4001 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 3782 | 4002 | } |
@@ -3791,8 +4011,9 @@ discard block |
||
| 3791 | 4011 | function ip2range($fullip) |
| 3792 | 4012 | { |
| 3793 | 4013 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 3794 | - if ($fullip == 'unknown') |
|
| 3795 | - $fullip = '255.255.255.255'; |
|
| 4014 | + if ($fullip == 'unknown') { |
|
| 4015 | + $fullip = '255.255.255.255'; |
|
| 4016 | + } |
|
| 3796 | 4017 | |
| 3797 | 4018 | $ip_parts = explode('-', $fullip); |
| 3798 | 4019 | $ip_array = array(); |
@@ -3816,10 +4037,11 @@ discard block |
||
| 3816 | 4037 | $ip_array['low'] = $ip_parts[0]; |
| 3817 | 4038 | $ip_array['high'] = $ip_parts[1]; |
| 3818 | 4039 | return $ip_array; |
| 3819 | - } |
|
| 3820 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 4040 | + } elseif (count($ip_parts) == 2) { |
|
| 4041 | + // if ip 22.22.*-22.22.* |
|
| 3821 | 4042 | { |
| 3822 | 4043 | $valid_low = isValidIP($ip_parts[0]); |
| 4044 | + } |
|
| 3823 | 4045 | $valid_high = isValidIP($ip_parts[1]); |
| 3824 | 4046 | $count = 0; |
| 3825 | 4047 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3834,7 +4056,9 @@ discard block |
||
| 3834 | 4056 | $ip_parts[0] .= $mode . $min; |
| 3835 | 4057 | $valid_low = isValidIP($ip_parts[0]); |
| 3836 | 4058 | $count++; |
| 3837 | - if ($count > 9) break; |
|
| 4059 | + if ($count > 9) { |
|
| 4060 | + break; |
|
| 4061 | + } |
|
| 3838 | 4062 | } |
| 3839 | 4063 | } |
| 3840 | 4064 | |
@@ -3848,7 +4072,9 @@ discard block |
||
| 3848 | 4072 | $ip_parts[1] .= $mode . $max; |
| 3849 | 4073 | $valid_high = isValidIP($ip_parts[1]); |
| 3850 | 4074 | $count++; |
| 3851 | - if ($count > 9) break; |
|
| 4075 | + if ($count > 9) { |
|
| 4076 | + break; |
|
| 4077 | + } |
|
| 3852 | 4078 | } |
| 3853 | 4079 | } |
| 3854 | 4080 | |
@@ -3873,46 +4099,54 @@ discard block |
||
| 3873 | 4099 | { |
| 3874 | 4100 | global $modSettings; |
| 3875 | 4101 | |
| 3876 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 3877 | - return $host; |
|
| 4102 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4103 | + return $host; |
|
| 4104 | + } |
|
| 3878 | 4105 | $t = microtime(); |
| 3879 | 4106 | |
| 3880 | 4107 | // Try the Linux host command, perhaps? |
| 3881 | 4108 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 3882 | 4109 | { |
| 3883 | - if (!isset($modSettings['host_to_dis'])) |
|
| 3884 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 3885 | - else |
|
| 3886 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4110 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4111 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4112 | + } else { |
|
| 4113 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4114 | + } |
|
| 3887 | 4115 | |
| 3888 | 4116 | // Did host say it didn't find anything? |
| 3889 | - if (strpos($test, 'not found') !== false) |
|
| 3890 | - $host = ''; |
|
| 4117 | + if (strpos($test, 'not found') !== false) { |
|
| 4118 | + $host = ''; |
|
| 4119 | + } |
|
| 3891 | 4120 | // Invalid server option? |
| 3892 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 3893 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4121 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4122 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4123 | + } |
|
| 3894 | 4124 | // Maybe it found something, after all? |
| 3895 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 3896 | - $host = $match[1]; |
|
| 4125 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4126 | + $host = $match[1]; |
|
| 4127 | + } |
|
| 3897 | 4128 | } |
| 3898 | 4129 | |
| 3899 | 4130 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 3900 | 4131 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 3901 | 4132 | { |
| 3902 | 4133 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 3903 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 3904 | - $host = ''; |
|
| 3905 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 3906 | - $host = $match[1]; |
|
| 4134 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4135 | + $host = ''; |
|
| 4136 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4137 | + $host = $match[1]; |
|
| 4138 | + } |
|
| 3907 | 4139 | } |
| 3908 | 4140 | |
| 3909 | 4141 | // This is the last try :/. |
| 3910 | - if (!isset($host) || $host === false) |
|
| 3911 | - $host = @gethostbyaddr($ip); |
|
| 4142 | + if (!isset($host) || $host === false) { |
|
| 4143 | + $host = @gethostbyaddr($ip); |
|
| 4144 | + } |
|
| 3912 | 4145 | |
| 3913 | 4146 | // It took a long time, so let's cache it! |
| 3914 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 3915 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4147 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4148 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4149 | + } |
|
| 3916 | 4150 | |
| 3917 | 4151 | return $host; |
| 3918 | 4152 | } |
@@ -3948,20 +4182,21 @@ discard block |
||
| 3948 | 4182 | { |
| 3949 | 4183 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 3950 | 4184 | $total = 0; |
| 3951 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 3952 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4185 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4186 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4187 | + } |
|
| 3953 | 4188 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 3954 | 4189 | } |
| 3955 | 4190 | } |
| 3956 | 4191 | return array_unique($returned_ints); |
| 3957 | - } |
|
| 3958 | - else |
|
| 4192 | + } else |
|
| 3959 | 4193 | { |
| 3960 | 4194 | // Trim characters before and after and add slashes for database insertion. |
| 3961 | 4195 | $returned_words = array(); |
| 3962 | - foreach ($words as $word) |
|
| 3963 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4196 | + foreach ($words as $word) { |
|
| 4197 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 3964 | 4198 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4199 | + } |
|
| 3965 | 4200 | |
| 3966 | 4201 | // Filter out all words that occur more than once. |
| 3967 | 4202 | return array_unique($returned_words); |
@@ -3983,16 +4218,18 @@ discard block |
||
| 3983 | 4218 | global $settings, $txt; |
| 3984 | 4219 | |
| 3985 | 4220 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 3986 | - if (function_exists('template_create_button') && !$force_use) |
|
| 3987 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4221 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4222 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4223 | + } |
|
| 3988 | 4224 | |
| 3989 | - if (!$settings['use_image_buttons']) |
|
| 3990 | - return $txt[$alt]; |
|
| 3991 | - elseif (!empty($settings['use_buttons'])) |
|
| 3992 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 3993 | - else |
|
| 3994 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 3995 | -} |
|
| 4225 | + if (!$settings['use_image_buttons']) { |
|
| 4226 | + return $txt[$alt]; |
|
| 4227 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4228 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4229 | + } else { |
|
| 4230 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4231 | + } |
|
| 4232 | + } |
|
| 3996 | 4233 | |
| 3997 | 4234 | /** |
| 3998 | 4235 | * Sets up all of the top menu buttons |
@@ -4035,9 +4272,10 @@ discard block |
||
| 4035 | 4272 | var user_menus = new smc_PopupMenu(); |
| 4036 | 4273 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4037 | 4274 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 4038 | - if ($context['allow_pm']) |
|
| 4039 | - addInlineJavaScript(' |
|
| 4275 | + if ($context['allow_pm']) { |
|
| 4276 | + addInlineJavaScript(' |
|
| 4040 | 4277 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4278 | + } |
|
| 4041 | 4279 | |
| 4042 | 4280 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 4043 | 4281 | { |
@@ -4197,88 +4435,96 @@ discard block |
||
| 4197 | 4435 | |
| 4198 | 4436 | // Now we put the buttons in the context so the theme can use them. |
| 4199 | 4437 | $menu_buttons = array(); |
| 4200 | - foreach ($buttons as $act => $button) |
|
| 4201 | - if (!empty($button['show'])) |
|
| 4438 | + foreach ($buttons as $act => $button) { |
|
| 4439 | + if (!empty($button['show'])) |
|
| 4202 | 4440 | { |
| 4203 | 4441 | $button['active_button'] = false; |
| 4442 | + } |
|
| 4204 | 4443 | |
| 4205 | 4444 | // This button needs some action. |
| 4206 | - if (isset($button['action_hook'])) |
|
| 4207 | - $needs_action_hook = true; |
|
| 4445 | + if (isset($button['action_hook'])) { |
|
| 4446 | + $needs_action_hook = true; |
|
| 4447 | + } |
|
| 4208 | 4448 | |
| 4209 | 4449 | // Make sure the last button truly is the last button. |
| 4210 | 4450 | if (!empty($button['is_last'])) |
| 4211 | 4451 | { |
| 4212 | - if (isset($last_button)) |
|
| 4213 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4452 | + if (isset($last_button)) { |
|
| 4453 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4454 | + } |
|
| 4214 | 4455 | $last_button = $act; |
| 4215 | 4456 | } |
| 4216 | 4457 | |
| 4217 | 4458 | // Go through the sub buttons if there are any. |
| 4218 | - if (!empty($button['sub_buttons'])) |
|
| 4219 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4459 | + if (!empty($button['sub_buttons'])) { |
|
| 4460 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4220 | 4461 | { |
| 4221 | 4462 | if (empty($subbutton['show'])) |
| 4222 | 4463 | unset($button['sub_buttons'][$key]); |
| 4464 | + } |
|
| 4223 | 4465 | |
| 4224 | 4466 | // 2nd level sub buttons next... |
| 4225 | 4467 | if (!empty($subbutton['sub_buttons'])) |
| 4226 | 4468 | { |
| 4227 | 4469 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4228 | 4470 | { |
| 4229 | - if (empty($sub_button2['show'])) |
|
| 4230 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4471 | + if (empty($sub_button2['show'])) { |
|
| 4472 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4473 | + } |
|
| 4231 | 4474 | } |
| 4232 | 4475 | } |
| 4233 | 4476 | } |
| 4234 | 4477 | |
| 4235 | 4478 | // Does this button have its own icon? |
| 4236 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4237 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4238 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4239 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4240 | - elseif (isset($button['icon'])) |
|
| 4241 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4242 | - else |
|
| 4243 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4479 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4480 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4481 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4482 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4483 | + } elseif (isset($button['icon'])) { |
|
| 4484 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4485 | + } else { |
|
| 4486 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4487 | + } |
|
| 4244 | 4488 | |
| 4245 | 4489 | $menu_buttons[$act] = $button; |
| 4246 | 4490 | } |
| 4247 | 4491 | |
| 4248 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4249 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4492 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4493 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4494 | + } |
|
| 4250 | 4495 | } |
| 4251 | 4496 | |
| 4252 | 4497 | $context['menu_buttons'] = $menu_buttons; |
| 4253 | 4498 | |
| 4254 | 4499 | // Logging out requires the session id in the url. |
| 4255 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4256 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4500 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4501 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4502 | + } |
|
| 4257 | 4503 | |
| 4258 | 4504 | // Figure out which action we are doing so we can set the active tab. |
| 4259 | 4505 | // Default to home. |
| 4260 | 4506 | $current_action = 'home'; |
| 4261 | 4507 | |
| 4262 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4263 | - $current_action = $context['current_action']; |
|
| 4264 | - elseif ($context['current_action'] == 'search2') |
|
| 4265 | - $current_action = 'search'; |
|
| 4266 | - elseif ($context['current_action'] == 'theme') |
|
| 4267 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4268 | - elseif ($context['current_action'] == 'register2') |
|
| 4269 | - $current_action = 'register'; |
|
| 4270 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4271 | - $current_action = 'login'; |
|
| 4272 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4273 | - $current_action = 'moderate'; |
|
| 4508 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4509 | + $current_action = $context['current_action']; |
|
| 4510 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4511 | + $current_action = 'search'; |
|
| 4512 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4513 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4514 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4515 | + $current_action = 'register'; |
|
| 4516 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4517 | + $current_action = 'login'; |
|
| 4518 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4519 | + $current_action = 'moderate'; |
|
| 4520 | + } |
|
| 4274 | 4521 | |
| 4275 | 4522 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4276 | 4523 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4277 | 4524 | { |
| 4278 | 4525 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4279 | 4526 | $context[$current_action] = true; |
| 4280 | - } |
|
| 4281 | - elseif ($context['current_action'] == 'pm') |
|
| 4527 | + } elseif ($context['current_action'] == 'pm') |
|
| 4282 | 4528 | { |
| 4283 | 4529 | $current_action = 'self_pm'; |
| 4284 | 4530 | $context['self_pm'] = true; |
@@ -4319,12 +4565,14 @@ discard block |
||
| 4319 | 4565 | } |
| 4320 | 4566 | |
| 4321 | 4567 | // Not all actions are simple. |
| 4322 | - if (!empty($needs_action_hook)) |
|
| 4323 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4568 | + if (!empty($needs_action_hook)) { |
|
| 4569 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4570 | + } |
|
| 4324 | 4571 | |
| 4325 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4326 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4327 | -} |
|
| 4572 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4573 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4574 | + } |
|
| 4575 | + } |
|
| 4328 | 4576 | |
| 4329 | 4577 | /** |
| 4330 | 4578 | * Generate a random seed and ensure it's stored in settings. |
@@ -4348,30 +4596,35 @@ discard block |
||
| 4348 | 4596 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4349 | 4597 | global $context, $txt; |
| 4350 | 4598 | |
| 4351 | - if ($db_show_debug === true) |
|
| 4352 | - $context['debug']['hooks'][] = $hook; |
|
| 4599 | + if ($db_show_debug === true) { |
|
| 4600 | + $context['debug']['hooks'][] = $hook; |
|
| 4601 | + } |
|
| 4353 | 4602 | |
| 4354 | 4603 | // Need to have some control. |
| 4355 | - if (!isset($context['instances'])) |
|
| 4356 | - $context['instances'] = array(); |
|
| 4604 | + if (!isset($context['instances'])) { |
|
| 4605 | + $context['instances'] = array(); |
|
| 4606 | + } |
|
| 4357 | 4607 | |
| 4358 | 4608 | $results = array(); |
| 4359 | - if (empty($modSettings[$hook])) |
|
| 4360 | - return $results; |
|
| 4609 | + if (empty($modSettings[$hook])) { |
|
| 4610 | + return $results; |
|
| 4611 | + } |
|
| 4361 | 4612 | |
| 4362 | 4613 | $functions = explode(',', $modSettings[$hook]); |
| 4363 | 4614 | // Loop through each function. |
| 4364 | 4615 | foreach ($functions as $function) |
| 4365 | 4616 | { |
| 4366 | 4617 | // Hook has been marked as "disabled". Skip it! |
| 4367 | - if (strpos($function, '!') !== false) |
|
| 4368 | - continue; |
|
| 4618 | + if (strpos($function, '!') !== false) { |
|
| 4619 | + continue; |
|
| 4620 | + } |
|
| 4369 | 4621 | |
| 4370 | 4622 | $call = call_helper($function, true); |
| 4371 | 4623 | |
| 4372 | 4624 | // Is it valid? |
| 4373 | - if (!empty($call)) |
|
| 4374 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 4625 | + if (!empty($call)) { |
|
| 4626 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 4627 | + } |
|
| 4375 | 4628 | |
| 4376 | 4629 | // Whatever it was suppose to call, it failed :( |
| 4377 | 4630 | elseif (!empty($function)) |
@@ -4387,8 +4640,9 @@ discard block |
||
| 4387 | 4640 | } |
| 4388 | 4641 | |
| 4389 | 4642 | // "Assume" the file resides on $boarddir somewhere... |
| 4390 | - else |
|
| 4391 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4643 | + else { |
|
| 4644 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4645 | + } |
|
| 4392 | 4646 | } |
| 4393 | 4647 | } |
| 4394 | 4648 | |
@@ -4410,12 +4664,14 @@ discard block |
||
| 4410 | 4664 | global $smcFunc, $modSettings; |
| 4411 | 4665 | |
| 4412 | 4666 | // Any objects? |
| 4413 | - if ($object) |
|
| 4414 | - $function = $function . '#'; |
|
| 4667 | + if ($object) { |
|
| 4668 | + $function = $function . '#'; |
|
| 4669 | + } |
|
| 4415 | 4670 | |
| 4416 | 4671 | // Any files to load? |
| 4417 | - if (!empty($file) && is_string($file)) |
|
| 4418 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4672 | + if (!empty($file) && is_string($file)) { |
|
| 4673 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4674 | + } |
|
| 4419 | 4675 | |
| 4420 | 4676 | // Get the correct string. |
| 4421 | 4677 | $integration_call = $function; |
@@ -4437,13 +4693,14 @@ discard block |
||
| 4437 | 4693 | if (!empty($current_functions)) |
| 4438 | 4694 | { |
| 4439 | 4695 | $current_functions = explode(',', $current_functions); |
| 4440 | - if (in_array($integration_call, $current_functions)) |
|
| 4441 | - return; |
|
| 4696 | + if (in_array($integration_call, $current_functions)) { |
|
| 4697 | + return; |
|
| 4698 | + } |
|
| 4442 | 4699 | |
| 4443 | 4700 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 4701 | + } else { |
|
| 4702 | + $permanent_functions = array($integration_call); |
|
| 4444 | 4703 | } |
| 4445 | - else |
|
| 4446 | - $permanent_functions = array($integration_call); |
|
| 4447 | 4704 | |
| 4448 | 4705 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4449 | 4706 | } |
@@ -4452,8 +4709,9 @@ discard block |
||
| 4452 | 4709 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4453 | 4710 | |
| 4454 | 4711 | // Do nothing, if it's already there. |
| 4455 | - if (in_array($integration_call, $functions)) |
|
| 4456 | - return; |
|
| 4712 | + if (in_array($integration_call, $functions)) { |
|
| 4713 | + return; |
|
| 4714 | + } |
|
| 4457 | 4715 | |
| 4458 | 4716 | $functions[] = $integration_call; |
| 4459 | 4717 | $modSettings[$hook] = implode(',', $functions); |
@@ -4476,12 +4734,14 @@ discard block |
||
| 4476 | 4734 | global $smcFunc, $modSettings; |
| 4477 | 4735 | |
| 4478 | 4736 | // Any objects? |
| 4479 | - if ($object) |
|
| 4480 | - $function = $function . '#'; |
|
| 4737 | + if ($object) { |
|
| 4738 | + $function = $function . '#'; |
|
| 4739 | + } |
|
| 4481 | 4740 | |
| 4482 | 4741 | // Any files to load? |
| 4483 | - if (!empty($file) && is_string($file)) |
|
| 4484 | - $function = $file . '|' . $function; |
|
| 4742 | + if (!empty($file) && is_string($file)) { |
|
| 4743 | + $function = $file . '|' . $function; |
|
| 4744 | + } |
|
| 4485 | 4745 | |
| 4486 | 4746 | // Get the correct string. |
| 4487 | 4747 | $integration_call = $function; |
@@ -4502,16 +4762,18 @@ discard block |
||
| 4502 | 4762 | { |
| 4503 | 4763 | $current_functions = explode(',', $current_functions); |
| 4504 | 4764 | |
| 4505 | - if (in_array($integration_call, $current_functions)) |
|
| 4506 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4765 | + if (in_array($integration_call, $current_functions)) { |
|
| 4766 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4767 | + } |
|
| 4507 | 4768 | } |
| 4508 | 4769 | |
| 4509 | 4770 | // Turn the function list into something usable. |
| 4510 | 4771 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4511 | 4772 | |
| 4512 | 4773 | // You can only remove it if it's available. |
| 4513 | - if (!in_array($integration_call, $functions)) |
|
| 4514 | - return; |
|
| 4774 | + if (!in_array($integration_call, $functions)) { |
|
| 4775 | + return; |
|
| 4776 | + } |
|
| 4515 | 4777 | |
| 4516 | 4778 | $functions = array_diff($functions, array($integration_call)); |
| 4517 | 4779 | $modSettings[$hook] = implode(',', $functions); |
@@ -4532,17 +4794,20 @@ discard block |
||
| 4532 | 4794 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4533 | 4795 | |
| 4534 | 4796 | // Really? |
| 4535 | - if (empty($string)) |
|
| 4536 | - return false; |
|
| 4797 | + if (empty($string)) { |
|
| 4798 | + return false; |
|
| 4799 | + } |
|
| 4537 | 4800 | |
| 4538 | 4801 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4539 | 4802 | // A closure? should be a callable one. |
| 4540 | - if (is_array($string) || $string instanceof Closure) |
|
| 4541 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4803 | + if (is_array($string) || $string instanceof Closure) { |
|
| 4804 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4805 | + } |
|
| 4542 | 4806 | |
| 4543 | 4807 | // No full objects, sorry! pass a method or a property instead! |
| 4544 | - if (is_object($string)) |
|
| 4545 | - return false; |
|
| 4808 | + if (is_object($string)) { |
|
| 4809 | + return false; |
|
| 4810 | + } |
|
| 4546 | 4811 | |
| 4547 | 4812 | // Stay vitaminized my friends... |
| 4548 | 4813 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4551,8 +4816,9 @@ discard block |
||
| 4551 | 4816 | $string = load_file($string); |
| 4552 | 4817 | |
| 4553 | 4818 | // Loaded file failed |
| 4554 | - if (empty($string)) |
|
| 4555 | - return false; |
|
| 4819 | + if (empty($string)) { |
|
| 4820 | + return false; |
|
| 4821 | + } |
|
| 4556 | 4822 | |
| 4557 | 4823 | // Found a method. |
| 4558 | 4824 | if (strpos($string, '::') !== false) |
@@ -4573,8 +4839,9 @@ discard block |
||
| 4573 | 4839 | // Add another one to the list. |
| 4574 | 4840 | if ($db_show_debug === true) |
| 4575 | 4841 | { |
| 4576 | - if (!isset($context['debug']['instances'])) |
|
| 4577 | - $context['debug']['instances'] = array(); |
|
| 4842 | + if (!isset($context['debug']['instances'])) { |
|
| 4843 | + $context['debug']['instances'] = array(); |
|
| 4844 | + } |
|
| 4578 | 4845 | |
| 4579 | 4846 | $context['debug']['instances'][$class] = $class; |
| 4580 | 4847 | } |
@@ -4584,13 +4851,15 @@ discard block |
||
| 4584 | 4851 | } |
| 4585 | 4852 | |
| 4586 | 4853 | // Right then. This is a call to a static method. |
| 4587 | - else |
|
| 4588 | - $func = array($class, $method); |
|
| 4854 | + else { |
|
| 4855 | + $func = array($class, $method); |
|
| 4856 | + } |
|
| 4589 | 4857 | } |
| 4590 | 4858 | |
| 4591 | 4859 | // Nope! just a plain regular function. |
| 4592 | - else |
|
| 4593 | - $func = $string; |
|
| 4860 | + else { |
|
| 4861 | + $func = $string; |
|
| 4862 | + } |
|
| 4594 | 4863 | |
| 4595 | 4864 | // Right, we got what we need, time to do some checks. |
| 4596 | 4865 | if (!is_callable($func, false, $callable_name)) |
@@ -4606,17 +4875,18 @@ discard block |
||
| 4606 | 4875 | else |
| 4607 | 4876 | { |
| 4608 | 4877 | // What are we gonna do about it? |
| 4609 | - if ($return) |
|
| 4610 | - return $func; |
|
| 4878 | + if ($return) { |
|
| 4879 | + return $func; |
|
| 4880 | + } |
|
| 4611 | 4881 | |
| 4612 | 4882 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4613 | 4883 | else |
| 4614 | 4884 | { |
| 4615 | - if (is_array($func)) |
|
| 4616 | - call_user_func($func); |
|
| 4617 | - |
|
| 4618 | - else |
|
| 4619 | - $func(); |
|
| 4885 | + if (is_array($func)) { |
|
| 4886 | + call_user_func($func); |
|
| 4887 | + } else { |
|
| 4888 | + $func(); |
|
| 4889 | + } |
|
| 4620 | 4890 | } |
| 4621 | 4891 | } |
| 4622 | 4892 | } |
@@ -4633,31 +4903,34 @@ discard block |
||
| 4633 | 4903 | { |
| 4634 | 4904 | global $sourcedir, $txt, $boarddir, $settings; |
| 4635 | 4905 | |
| 4636 | - if (empty($string)) |
|
| 4637 | - return false; |
|
| 4906 | + if (empty($string)) { |
|
| 4907 | + return false; |
|
| 4908 | + } |
|
| 4638 | 4909 | |
| 4639 | 4910 | if (strpos($string, '|') !== false) |
| 4640 | 4911 | { |
| 4641 | 4912 | list ($file, $string) = explode('|', $string); |
| 4642 | 4913 | |
| 4643 | 4914 | // Match the wildcards to their regular vars. |
| 4644 | - if (empty($settings['theme_dir'])) |
|
| 4645 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4646 | - |
|
| 4647 | - else |
|
| 4648 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4915 | + if (empty($settings['theme_dir'])) { |
|
| 4916 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4917 | + } else { |
|
| 4918 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4919 | + } |
|
| 4649 | 4920 | |
| 4650 | 4921 | // Load the file if it can be loaded. |
| 4651 | - if (file_exists($absPath)) |
|
| 4652 | - require_once($absPath); |
|
| 4922 | + if (file_exists($absPath)) { |
|
| 4923 | + require_once($absPath); |
|
| 4924 | + } |
|
| 4653 | 4925 | |
| 4654 | 4926 | // No? try a fallback to $sourcedir |
| 4655 | 4927 | else |
| 4656 | 4928 | { |
| 4657 | 4929 | $absPath = $sourcedir .'/'. $file; |
| 4658 | 4930 | |
| 4659 | - if (file_exists($absPath)) |
|
| 4660 | - require_once($absPath); |
|
| 4931 | + if (file_exists($absPath)) { |
|
| 4932 | + require_once($absPath); |
|
| 4933 | + } |
|
| 4661 | 4934 | |
| 4662 | 4935 | // Sorry, can't do much for you at this point. |
| 4663 | 4936 | else |
@@ -4684,8 +4957,9 @@ discard block |
||
| 4684 | 4957 | global $user_info, $smcFunc; |
| 4685 | 4958 | |
| 4686 | 4959 | // Make sure we have something to work with. |
| 4687 | - if (empty($topic)) |
|
| 4688 | - return array(); |
|
| 4960 | + if (empty($topic)) { |
|
| 4961 | + return array(); |
|
| 4962 | + } |
|
| 4689 | 4963 | |
| 4690 | 4964 | |
| 4691 | 4965 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4708,8 +4982,9 @@ discard block |
||
| 4708 | 4982 | 'topic' => $topic, |
| 4709 | 4983 | ) |
| 4710 | 4984 | ); |
| 4711 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4712 | - $temp[] = (int) $row['content_id']; |
|
| 4985 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4986 | + $temp[] = (int) $row['content_id']; |
|
| 4987 | + } |
|
| 4713 | 4988 | |
| 4714 | 4989 | cache_put_data($cache_key, $temp, $ttl); |
| 4715 | 4990 | } |
@@ -4730,8 +5005,9 @@ discard block |
||
| 4730 | 5005 | { |
| 4731 | 5006 | global $context; |
| 4732 | 5007 | |
| 4733 | - if (empty($string)) |
|
| 4734 | - return $string; |
|
| 5008 | + if (empty($string)) { |
|
| 5009 | + return $string; |
|
| 5010 | + } |
|
| 4735 | 5011 | |
| 4736 | 5012 | // UTF-8 occurences of MS special characters |
| 4737 | 5013 | $findchars_utf8 = array( |
@@ -4772,10 +5048,11 @@ discard block |
||
| 4772 | 5048 | '--', // — |
| 4773 | 5049 | ); |
| 4774 | 5050 | |
| 4775 | - if ($context['utf8']) |
|
| 4776 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 4777 | - else |
|
| 4778 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5051 | + if ($context['utf8']) { |
|
| 5052 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5053 | + } else { |
|
| 5054 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5055 | + } |
|
| 4779 | 5056 | |
| 4780 | 5057 | return $string; |
| 4781 | 5058 | } |
@@ -4794,49 +5071,59 @@ discard block |
||
| 4794 | 5071 | { |
| 4795 | 5072 | global $context; |
| 4796 | 5073 | |
| 4797 | - if (!isset($matches[2])) |
|
| 4798 | - return ''; |
|
| 5074 | + if (!isset($matches[2])) { |
|
| 5075 | + return ''; |
|
| 5076 | + } |
|
| 4799 | 5077 | |
| 4800 | 5078 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4801 | 5079 | |
| 4802 | 5080 | // remove left to right / right to left overrides |
| 4803 | - if ($num === 0x202D || $num === 0x202E) |
|
| 4804 | - return ''; |
|
| 5081 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5082 | + return ''; |
|
| 5083 | + } |
|
| 4805 | 5084 | |
| 4806 | 5085 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 4807 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 4808 | - return '&#' . $num . ';'; |
|
| 5086 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5087 | + return '&#' . $num . ';'; |
|
| 5088 | + } |
|
| 4809 | 5089 | |
| 4810 | 5090 | if (empty($context['utf8'])) |
| 4811 | 5091 | { |
| 4812 | 5092 | // no control characters |
| 4813 | - if ($num < 0x20) |
|
| 4814 | - return ''; |
|
| 5093 | + if ($num < 0x20) { |
|
| 5094 | + return ''; |
|
| 5095 | + } |
|
| 4815 | 5096 | // text is text |
| 4816 | - elseif ($num < 0x80) |
|
| 4817 | - return chr($num); |
|
| 5097 | + elseif ($num < 0x80) { |
|
| 5098 | + return chr($num); |
|
| 5099 | + } |
|
| 4818 | 5100 | // all others get html-ised |
| 4819 | - else |
|
| 4820 | - return '&#' . $matches[2] . ';'; |
|
| 4821 | - } |
|
| 4822 | - else |
|
| 5101 | + else { |
|
| 5102 | + return '&#' . $matches[2] . ';'; |
|
| 5103 | + } |
|
| 5104 | + } else |
|
| 4823 | 5105 | { |
| 4824 | 5106 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 4825 | 5107 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 4826 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 4827 | - return ''; |
|
| 5108 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5109 | + return ''; |
|
| 5110 | + } |
|
| 4828 | 5111 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4829 | - elseif ($num < 0x80) |
|
| 4830 | - return chr($num); |
|
| 5112 | + elseif ($num < 0x80) { |
|
| 5113 | + return chr($num); |
|
| 5114 | + } |
|
| 4831 | 5115 | // <0x800 (2048) |
| 4832 | - elseif ($num < 0x800) |
|
| 4833 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5116 | + elseif ($num < 0x800) { |
|
| 5117 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5118 | + } |
|
| 4834 | 5119 | // < 0x10000 (65536) |
| 4835 | - elseif ($num < 0x10000) |
|
| 4836 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5120 | + elseif ($num < 0x10000) { |
|
| 5121 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5122 | + } |
|
| 4837 | 5123 | // <= 0x10FFFF (1114111) |
| 4838 | - else |
|
| 4839 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5124 | + else { |
|
| 5125 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5126 | + } |
|
| 4840 | 5127 | } |
| 4841 | 5128 | } |
| 4842 | 5129 | |
@@ -4852,28 +5139,34 @@ discard block |
||
| 4852 | 5139 | */ |
| 4853 | 5140 | function fixchar__callback($matches) |
| 4854 | 5141 | { |
| 4855 | - if (!isset($matches[1])) |
|
| 4856 | - return ''; |
|
| 5142 | + if (!isset($matches[1])) { |
|
| 5143 | + return ''; |
|
| 5144 | + } |
|
| 4857 | 5145 | |
| 4858 | 5146 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 4859 | 5147 | |
| 4860 | 5148 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 4861 | 5149 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 4862 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 4863 | - return ''; |
|
| 5150 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5151 | + return ''; |
|
| 5152 | + } |
|
| 4864 | 5153 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4865 | - elseif ($num < 0x80) |
|
| 4866 | - return chr($num); |
|
| 5154 | + elseif ($num < 0x80) { |
|
| 5155 | + return chr($num); |
|
| 5156 | + } |
|
| 4867 | 5157 | // <0x800 (2048) |
| 4868 | - elseif ($num < 0x800) |
|
| 4869 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5158 | + elseif ($num < 0x800) { |
|
| 5159 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5160 | + } |
|
| 4870 | 5161 | // < 0x10000 (65536) |
| 4871 | - elseif ($num < 0x10000) |
|
| 4872 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5162 | + elseif ($num < 0x10000) { |
|
| 5163 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5164 | + } |
|
| 4873 | 5165 | // <= 0x10FFFF (1114111) |
| 4874 | - else |
|
| 4875 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 4876 | -} |
|
| 5166 | + else { |
|
| 5167 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5168 | + } |
|
| 5169 | + } |
|
| 4877 | 5170 | |
| 4878 | 5171 | /** |
| 4879 | 5172 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4886,17 +5179,19 @@ discard block |
||
| 4886 | 5179 | */ |
| 4887 | 5180 | function entity_fix__callback($matches) |
| 4888 | 5181 | { |
| 4889 | - if (!isset($matches[2])) |
|
| 4890 | - return ''; |
|
| 5182 | + if (!isset($matches[2])) { |
|
| 5183 | + return ''; |
|
| 5184 | + } |
|
| 4891 | 5185 | |
| 4892 | 5186 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4893 | 5187 | |
| 4894 | 5188 | // we don't allow control characters, characters out of range, byte markers, etc |
| 4895 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 4896 | - return ''; |
|
| 4897 | - else |
|
| 4898 | - return '&#' . $num . ';'; |
|
| 4899 | -} |
|
| 5189 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5190 | + return ''; |
|
| 5191 | + } else { |
|
| 5192 | + return '&#' . $num . ';'; |
|
| 5193 | + } |
|
| 5194 | + } |
|
| 4900 | 5195 | |
| 4901 | 5196 | /** |
| 4902 | 5197 | * Return a Gravatar URL based on |
@@ -4920,18 +5215,23 @@ discard block |
||
| 4920 | 5215 | $ratings = array('G', 'PG', 'R', 'X'); |
| 4921 | 5216 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 4922 | 5217 | $url_params = array(); |
| 4923 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 4924 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 4925 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 4926 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 4927 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 4928 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 4929 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 4930 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5218 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5219 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5220 | + } |
|
| 5221 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5222 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5223 | + } |
|
| 5224 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5225 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5226 | + } |
|
| 5227 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5228 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 4931 | 5229 | $size_string = $modSettings['avatar_max_height_external']; |
| 5230 | + } |
|
| 4932 | 5231 | |
| 4933 | - if (!empty($size_string)) |
|
| 4934 | - $url_params[] = 's=' . $size_string; |
|
| 5232 | + if (!empty($size_string)) { |
|
| 5233 | + $url_params[] = 's=' . $size_string; |
|
| 5234 | + } |
|
| 4935 | 5235 | } |
| 4936 | 5236 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
| 4937 | 5237 | |
@@ -4950,22 +5250,26 @@ discard block |
||
| 4950 | 5250 | static $timezones = null, $lastwhen = null; |
| 4951 | 5251 | |
| 4952 | 5252 | // No point doing this over if we already did it once |
| 4953 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 4954 | - return $timezones; |
|
| 4955 | - else |
|
| 4956 | - $lastwhen = $when; |
|
| 5253 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5254 | + return $timezones; |
|
| 5255 | + } else { |
|
| 5256 | + $lastwhen = $when; |
|
| 5257 | + } |
|
| 4957 | 5258 | |
| 4958 | 5259 | // Parseable datetime string? |
| 4959 | - if (is_int($timestamp = strtotime($when))) |
|
| 4960 | - $when = $timestamp; |
|
| 5260 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5261 | + $when = $timestamp; |
|
| 5262 | + } |
|
| 4961 | 5263 | |
| 4962 | 5264 | // A Unix timestamp? |
| 4963 | - elseif (is_numeric($when)) |
|
| 4964 | - $when = intval($when); |
|
| 5265 | + elseif (is_numeric($when)) { |
|
| 5266 | + $when = intval($when); |
|
| 5267 | + } |
|
| 4965 | 5268 | |
| 4966 | 5269 | // Invalid value? Just get current Unix timestamp. |
| 4967 | - else |
|
| 4968 | - $when = time(); |
|
| 5270 | + else { |
|
| 5271 | + $when = time(); |
|
| 5272 | + } |
|
| 4969 | 5273 | |
| 4970 | 5274 | // We'll need these too |
| 4971 | 5275 | $date_when = date_create('@' . $when); |
@@ -5029,8 +5333,9 @@ discard block |
||
| 5029 | 5333 | foreach ($priority_countries as $country) |
| 5030 | 5334 | { |
| 5031 | 5335 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 5032 | - if (!empty($country_tzids)) |
|
| 5033 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5336 | + if (!empty($country_tzids)) { |
|
| 5337 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5338 | + } |
|
| 5034 | 5339 | } |
| 5035 | 5340 | |
| 5036 | 5341 | // Process the preferred timezones first, then the rest. |
@@ -5040,8 +5345,9 @@ discard block |
||
| 5040 | 5345 | foreach ($tzids as $tzid) |
| 5041 | 5346 | { |
| 5042 | 5347 | // We don't want UTC right now |
| 5043 | - if ($tzid == 'UTC') |
|
| 5044 | - continue; |
|
| 5348 | + if ($tzid == 'UTC') { |
|
| 5349 | + continue; |
|
| 5350 | + } |
|
| 5045 | 5351 | |
| 5046 | 5352 | $tz = timezone_open($tzid); |
| 5047 | 5353 | |
@@ -5056,12 +5362,14 @@ discard block |
||
| 5056 | 5362 | $tzgeo = timezone_location_get($tz); |
| 5057 | 5363 | |
| 5058 | 5364 | // Don't overwrite our preferred tzids |
| 5059 | - if (empty($zones[$tzkey]['tzid'])) |
|
| 5060 | - $zones[$tzkey]['tzid'] = $tzid; |
|
| 5365 | + if (empty($zones[$tzkey]['tzid'])) { |
|
| 5366 | + $zones[$tzkey]['tzid'] = $tzid; |
|
| 5367 | + } |
|
| 5061 | 5368 | |
| 5062 | 5369 | // A time zone from a prioritized country? |
| 5063 | - if (in_array($tzid, $priority_tzids)) |
|
| 5064 | - $priority_zones[$tzkey] = true; |
|
| 5370 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5371 | + $priority_zones[$tzkey] = true; |
|
| 5372 | + } |
|
| 5065 | 5373 | |
| 5066 | 5374 | // Keep track of the location and offset for this tzid |
| 5067 | 5375 | $tzid_parts = explode('/', $tzid); |
@@ -5083,15 +5391,17 @@ discard block |
||
| 5083 | 5391 | |
| 5084 | 5392 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
| 5085 | 5393 | |
| 5086 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
| 5087 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5088 | - else |
|
| 5089 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5394 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
| 5395 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5396 | + } else { |
|
| 5397 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5398 | + } |
|
| 5090 | 5399 | |
| 5091 | - if (isset($priority_zones[$tzkey])) |
|
| 5092 | - $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5093 | - else |
|
| 5094 | - $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5400 | + if (isset($priority_zones[$tzkey])) { |
|
| 5401 | + $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5402 | + } else { |
|
| 5403 | + $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5404 | + } |
|
| 5095 | 5405 | } |
| 5096 | 5406 | |
| 5097 | 5407 | $timezones = array_merge( |
@@ -5145,9 +5455,9 @@ discard block |
||
| 5145 | 5455 | 'Indian/Kerguelen' => 'TFT', |
| 5146 | 5456 | ); |
| 5147 | 5457 | |
| 5148 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
| 5149 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
| 5150 | - else |
|
| 5458 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
| 5459 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
| 5460 | + } else |
|
| 5151 | 5461 | { |
| 5152 | 5462 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
| 5153 | 5463 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5175,8 +5485,9 @@ discard block |
||
| 5175 | 5485 | */ |
| 5176 | 5486 | function inet_ptod($ip_address) |
| 5177 | 5487 | { |
| 5178 | - if (!isValidIP($ip_address)) |
|
| 5179 | - return $ip_address; |
|
| 5488 | + if (!isValidIP($ip_address)) { |
|
| 5489 | + return $ip_address; |
|
| 5490 | + } |
|
| 5180 | 5491 | |
| 5181 | 5492 | $bin = inet_pton($ip_address); |
| 5182 | 5493 | return $bin; |
@@ -5188,13 +5499,15 @@ discard block |
||
| 5188 | 5499 | */ |
| 5189 | 5500 | function inet_dtop($bin) |
| 5190 | 5501 | { |
| 5191 | - if(empty($bin)) |
|
| 5192 | - return ''; |
|
| 5502 | + if(empty($bin)) { |
|
| 5503 | + return ''; |
|
| 5504 | + } |
|
| 5193 | 5505 | |
| 5194 | 5506 | global $db_type; |
| 5195 | 5507 | |
| 5196 | - if ($db_type == 'postgresql') |
|
| 5197 | - return $bin; |
|
| 5508 | + if ($db_type == 'postgresql') { |
|
| 5509 | + return $bin; |
|
| 5510 | + } |
|
| 5198 | 5511 | |
| 5199 | 5512 | $ip_address = inet_ntop($bin); |
| 5200 | 5513 | |
@@ -5219,26 +5532,32 @@ discard block |
||
| 5219 | 5532 | */ |
| 5220 | 5533 | function _safe_serialize($value) |
| 5221 | 5534 | { |
| 5222 | - if(is_null($value)) |
|
| 5223 | - return 'N;'; |
|
| 5535 | + if(is_null($value)) { |
|
| 5536 | + return 'N;'; |
|
| 5537 | + } |
|
| 5224 | 5538 | |
| 5225 | - if(is_bool($value)) |
|
| 5226 | - return 'b:'. (int) $value .';'; |
|
| 5539 | + if(is_bool($value)) { |
|
| 5540 | + return 'b:'. (int) $value .';'; |
|
| 5541 | + } |
|
| 5227 | 5542 | |
| 5228 | - if(is_int($value)) |
|
| 5229 | - return 'i:'. $value .';'; |
|
| 5543 | + if(is_int($value)) { |
|
| 5544 | + return 'i:'. $value .';'; |
|
| 5545 | + } |
|
| 5230 | 5546 | |
| 5231 | - if(is_float($value)) |
|
| 5232 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5547 | + if(is_float($value)) { |
|
| 5548 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5549 | + } |
|
| 5233 | 5550 | |
| 5234 | - if(is_string($value)) |
|
| 5235 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5551 | + if(is_string($value)) { |
|
| 5552 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5553 | + } |
|
| 5236 | 5554 | |
| 5237 | 5555 | if(is_array($value)) |
| 5238 | 5556 | { |
| 5239 | 5557 | $out = ''; |
| 5240 | - foreach($value as $k => $v) |
|
| 5241 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5558 | + foreach($value as $k => $v) { |
|
| 5559 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5560 | + } |
|
| 5242 | 5561 | |
| 5243 | 5562 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5244 | 5563 | } |
@@ -5264,8 +5583,9 @@ discard block |
||
| 5264 | 5583 | |
| 5265 | 5584 | $out = _safe_serialize($value); |
| 5266 | 5585 | |
| 5267 | - if (isset($mbIntEnc)) |
|
| 5268 | - mb_internal_encoding($mbIntEnc); |
|
| 5586 | + if (isset($mbIntEnc)) { |
|
| 5587 | + mb_internal_encoding($mbIntEnc); |
|
| 5588 | + } |
|
| 5269 | 5589 | |
| 5270 | 5590 | return $out; |
| 5271 | 5591 | } |
@@ -5282,8 +5602,9 @@ discard block |
||
| 5282 | 5602 | function _safe_unserialize($str) |
| 5283 | 5603 | { |
| 5284 | 5604 | // Input is not a string. |
| 5285 | - if(empty($str) || !is_string($str)) |
|
| 5286 | - return false; |
|
| 5605 | + if(empty($str) || !is_string($str)) { |
|
| 5606 | + return false; |
|
| 5607 | + } |
|
| 5287 | 5608 | |
| 5288 | 5609 | $stack = array(); |
| 5289 | 5610 | $expected = array(); |
@@ -5299,43 +5620,38 @@ discard block |
||
| 5299 | 5620 | while($state != 1) |
| 5300 | 5621 | { |
| 5301 | 5622 | $type = isset($str[0]) ? $str[0] : ''; |
| 5302 | - if($type == '}') |
|
| 5303 | - $str = substr($str, 1); |
|
| 5304 | - |
|
| 5305 | - else if($type == 'N' && $str[1] == ';') |
|
| 5623 | + if($type == '}') { |
|
| 5624 | + $str = substr($str, 1); |
|
| 5625 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5306 | 5626 | { |
| 5307 | 5627 | $value = null; |
| 5308 | 5628 | $str = substr($str, 2); |
| 5309 | - } |
|
| 5310 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5629 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5311 | 5630 | { |
| 5312 | 5631 | $value = $matches[1] == '1' ? true : false; |
| 5313 | 5632 | $str = substr($str, 4); |
| 5314 | - } |
|
| 5315 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5633 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5316 | 5634 | { |
| 5317 | 5635 | $value = (int)$matches[1]; |
| 5318 | 5636 | $str = $matches[2]; |
| 5319 | - } |
|
| 5320 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5637 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5321 | 5638 | { |
| 5322 | 5639 | $value = (float)$matches[1]; |
| 5323 | 5640 | $str = $matches[3]; |
| 5324 | - } |
|
| 5325 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5641 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5326 | 5642 | { |
| 5327 | 5643 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5328 | 5644 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5329 | - } |
|
| 5330 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5645 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5331 | 5646 | { |
| 5332 | 5647 | $expectedLength = (int)$matches[1]; |
| 5333 | 5648 | $str = $matches[2]; |
| 5334 | 5649 | } |
| 5335 | 5650 | |
| 5336 | 5651 | // Object or unknown/malformed type. |
| 5337 | - else |
|
| 5338 | - return false; |
|
| 5652 | + else { |
|
| 5653 | + return false; |
|
| 5654 | + } |
|
| 5339 | 5655 | |
| 5340 | 5656 | switch($state) |
| 5341 | 5657 | { |
@@ -5363,8 +5679,9 @@ discard block |
||
| 5363 | 5679 | if($type == '}') |
| 5364 | 5680 | { |
| 5365 | 5681 | // Array size is less than expected. |
| 5366 | - if(count($list) < end($expected)) |
|
| 5367 | - return false; |
|
| 5682 | + if(count($list) < end($expected)) { |
|
| 5683 | + return false; |
|
| 5684 | + } |
|
| 5368 | 5685 | |
| 5369 | 5686 | unset($list); |
| 5370 | 5687 | $list = &$stack[count($stack)-1]; |
@@ -5373,8 +5690,9 @@ discard block |
||
| 5373 | 5690 | // Go to terminal state if we're at the end of the root array. |
| 5374 | 5691 | array_pop($expected); |
| 5375 | 5692 | |
| 5376 | - if(count($expected) == 0) |
|
| 5377 | - $state = 1; |
|
| 5693 | + if(count($expected) == 0) { |
|
| 5694 | + $state = 1; |
|
| 5695 | + } |
|
| 5378 | 5696 | |
| 5379 | 5697 | break; |
| 5380 | 5698 | } |
@@ -5382,8 +5700,9 @@ discard block |
||
| 5382 | 5700 | if($type == 'i' || $type == 's') |
| 5383 | 5701 | { |
| 5384 | 5702 | // Array size exceeds expected length. |
| 5385 | - if(count($list) >= end($expected)) |
|
| 5386 | - return false; |
|
| 5703 | + if(count($list) >= end($expected)) { |
|
| 5704 | + return false; |
|
| 5705 | + } |
|
| 5387 | 5706 | |
| 5388 | 5707 | $key = $value; |
| 5389 | 5708 | $state = 3; |
@@ -5417,8 +5736,9 @@ discard block |
||
| 5417 | 5736 | } |
| 5418 | 5737 | |
| 5419 | 5738 | // Trailing data in input. |
| 5420 | - if(!empty($str)) |
|
| 5421 | - return false; |
|
| 5739 | + if(!empty($str)) { |
|
| 5740 | + return false; |
|
| 5741 | + } |
|
| 5422 | 5742 | |
| 5423 | 5743 | return $data; |
| 5424 | 5744 | } |
@@ -5441,8 +5761,9 @@ discard block |
||
| 5441 | 5761 | |
| 5442 | 5762 | $out = _safe_unserialize($str); |
| 5443 | 5763 | |
| 5444 | - if (isset($mbIntEnc)) |
|
| 5445 | - mb_internal_encoding($mbIntEnc); |
|
| 5764 | + if (isset($mbIntEnc)) { |
|
| 5765 | + mb_internal_encoding($mbIntEnc); |
|
| 5766 | + } |
|
| 5446 | 5767 | |
| 5447 | 5768 | return $out; |
| 5448 | 5769 | } |
@@ -5457,12 +5778,14 @@ discard block |
||
| 5457 | 5778 | function smf_chmod($file, $value = 0) |
| 5458 | 5779 | { |
| 5459 | 5780 | // No file? no checks! |
| 5460 | - if (empty($file)) |
|
| 5461 | - return false; |
|
| 5781 | + if (empty($file)) { |
|
| 5782 | + return false; |
|
| 5783 | + } |
|
| 5462 | 5784 | |
| 5463 | 5785 | // Already writable? |
| 5464 | - if (is_writable($file)) |
|
| 5465 | - return true; |
|
| 5786 | + if (is_writable($file)) { |
|
| 5787 | + return true; |
|
| 5788 | + } |
|
| 5466 | 5789 | |
| 5467 | 5790 | // Do we have a file or a dir? |
| 5468 | 5791 | $isDir = is_dir($file); |
@@ -5478,10 +5801,9 @@ discard block |
||
| 5478 | 5801 | { |
| 5479 | 5802 | $isWritable = true; |
| 5480 | 5803 | break; |
| 5804 | + } else { |
|
| 5805 | + @chmod($file, $val); |
|
| 5481 | 5806 | } |
| 5482 | - |
|
| 5483 | - else |
|
| 5484 | - @chmod($file, $val); |
|
| 5485 | 5807 | } |
| 5486 | 5808 | |
| 5487 | 5809 | return $isWritable; |
@@ -5500,8 +5822,9 @@ discard block |
||
| 5500 | 5822 | global $txt; |
| 5501 | 5823 | |
| 5502 | 5824 | // Come on... |
| 5503 | - if (empty($json) || !is_string($json)) |
|
| 5504 | - return array(); |
|
| 5825 | + if (empty($json) || !is_string($json)) { |
|
| 5826 | + return array(); |
|
| 5827 | + } |
|
| 5505 | 5828 | |
| 5506 | 5829 | $returnArray = @json_decode($json, $returnAsArray); |
| 5507 | 5830 | |
@@ -5539,11 +5862,11 @@ discard block |
||
| 5539 | 5862 | $jsonDebug = $jsonDebug[0]; |
| 5540 | 5863 | loadLanguage('Errors'); |
| 5541 | 5864 | |
| 5542 | - if (!empty($jsonDebug)) |
|
| 5543 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5544 | - |
|
| 5545 | - else |
|
| 5546 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5865 | + if (!empty($jsonDebug)) { |
|
| 5866 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5867 | + } else { |
|
| 5868 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5869 | + } |
|
| 5547 | 5870 | |
| 5548 | 5871 | // Everyone expects an array. |
| 5549 | 5872 | return array(); |
@@ -5573,8 +5896,9 @@ discard block |
||
| 5573 | 5896 | global $db_show_debug, $modSettings; |
| 5574 | 5897 | |
| 5575 | 5898 | // Defensive programming anyone? |
| 5576 | - if (empty($data)) |
|
| 5577 | - return false; |
|
| 5899 | + if (empty($data)) { |
|
| 5900 | + return false; |
|
| 5901 | + } |
|
| 5578 | 5902 | |
| 5579 | 5903 | // Don't need extra stuff... |
| 5580 | 5904 | $db_show_debug = false; |
@@ -5582,11 +5906,11 @@ discard block |
||
| 5582 | 5906 | // Kill anything else. |
| 5583 | 5907 | ob_end_clean(); |
| 5584 | 5908 | |
| 5585 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 5586 | - @ob_start('ob_gzhandler'); |
|
| 5587 | - |
|
| 5588 | - else |
|
| 5589 | - ob_start(); |
|
| 5909 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 5910 | + @ob_start('ob_gzhandler'); |
|
| 5911 | + } else { |
|
| 5912 | + ob_start(); |
|
| 5913 | + } |
|
| 5590 | 5914 | |
| 5591 | 5915 | // Set the header. |
| 5592 | 5916 | header($type); |
@@ -5618,8 +5942,9 @@ discard block |
||
| 5618 | 5942 | static $done = false; |
| 5619 | 5943 | |
| 5620 | 5944 | // If we don't need to do anything, don't |
| 5621 | - if (!$update && $done) |
|
| 5622 | - return; |
|
| 5945 | + if (!$update && $done) { |
|
| 5946 | + return; |
|
| 5947 | + } |
|
| 5623 | 5948 | |
| 5624 | 5949 | // Should we get a new copy of the official list of TLDs? |
| 5625 | 5950 | if ($update) |
@@ -5640,10 +5965,11 @@ discard block |
||
| 5640 | 5965 | // Clean $tlds and convert it to an array |
| 5641 | 5966 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 5642 | 5967 | $line = trim($line); |
| 5643 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 5644 | - return false; |
|
| 5645 | - else |
|
| 5646 | - return true; |
|
| 5968 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 5969 | + return false; |
|
| 5970 | + } else { |
|
| 5971 | + return true; |
|
| 5972 | + } |
|
| 5647 | 5973 | }); |
| 5648 | 5974 | |
| 5649 | 5975 | // Convert Punycode to Unicode |
@@ -5697,8 +6023,9 @@ discard block |
||
| 5697 | 6023 | $idx += $digit * $w; |
| 5698 | 6024 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
| 5699 | 6025 | |
| 5700 | - if ($digit < $t) |
|
| 5701 | - break; |
|
| 6026 | + if ($digit < $t) { |
|
| 6027 | + break; |
|
| 6028 | + } |
|
| 5702 | 6029 | |
| 5703 | 6030 | $w = (int) ($w * ($base - $t)); |
| 5704 | 6031 | } |
@@ -5707,8 +6034,9 @@ discard block |
||
| 5707 | 6034 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
| 5708 | 6035 | $delta += intval($delta / ($deco_len + 1)); |
| 5709 | 6036 | |
| 5710 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
| 5711 | - $delta = intval($delta / ($base - $tmin)); |
|
| 6037 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
| 6038 | + $delta = intval($delta / ($base - $tmin)); |
|
| 6039 | + } |
|
| 5712 | 6040 | |
| 5713 | 6041 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
| 5714 | 6042 | $is_first = false; |
@@ -5717,8 +6045,9 @@ discard block |
||
| 5717 | 6045 | |
| 5718 | 6046 | if ($deco_len > 0) |
| 5719 | 6047 | { |
| 5720 | - for ($i = $deco_len; $i > $idx; $i--) |
|
| 5721 | - $decoded[$i] = $decoded[($i - 1)]; |
|
| 6048 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
| 6049 | + $decoded[$i] = $decoded[($i - 1)]; |
|
| 6050 | + } |
|
| 5722 | 6051 | } |
| 5723 | 6052 | $decoded[$idx++] = $char; |
| 5724 | 6053 | } |
@@ -5726,24 +6055,29 @@ discard block |
||
| 5726 | 6055 | foreach ($decoded as $k => $v) |
| 5727 | 6056 | { |
| 5728 | 6057 | // 7bit are transferred literally |
| 5729 | - if ($v < 128) |
|
| 5730 | - $output .= chr($v); |
|
| 6058 | + if ($v < 128) { |
|
| 6059 | + $output .= chr($v); |
|
| 6060 | + } |
|
| 5731 | 6061 | |
| 5732 | 6062 | // 2 bytes |
| 5733 | - elseif ($v < (1 << 11)) |
|
| 5734 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 6063 | + elseif ($v < (1 << 11)) { |
|
| 6064 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 6065 | + } |
|
| 5735 | 6066 | |
| 5736 | 6067 | // 3 bytes |
| 5737 | - elseif ($v < (1 << 16)) |
|
| 5738 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6068 | + elseif ($v < (1 << 16)) { |
|
| 6069 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6070 | + } |
|
| 5739 | 6071 | |
| 5740 | 6072 | // 4 bytes |
| 5741 | - elseif ($v < (1 << 21)) |
|
| 5742 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6073 | + elseif ($v < (1 << 21)) { |
|
| 6074 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6075 | + } |
|
| 5743 | 6076 | |
| 5744 | 6077 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5745 | - else |
|
| 5746 | - $output .= $safe_char; |
|
| 6078 | + else { |
|
| 6079 | + $output .= $safe_char; |
|
| 6080 | + } |
|
| 5747 | 6081 | } |
| 5748 | 6082 | |
| 5749 | 6083 | $output_parts[] = $output; |
@@ -5838,8 +6172,7 @@ discard block |
||
| 5838 | 6172 | |
| 5839 | 6173 | $strlen = 'mb_strlen'; |
| 5840 | 6174 | $substr = 'mb_substr'; |
| 5841 | - } |
|
| 5842 | - else |
|
| 6175 | + } else |
|
| 5843 | 6176 | { |
| 5844 | 6177 | $strlen = $smcFunc['strlen']; |
| 5845 | 6178 | $substr = $smcFunc['substr']; |
@@ -5853,20 +6186,21 @@ discard block |
||
| 5853 | 6186 | |
| 5854 | 6187 | $first = $substr($string, 0, 1); |
| 5855 | 6188 | |
| 5856 | - if (empty($index[$first])) |
|
| 5857 | - $index[$first] = array(); |
|
| 6189 | + if (empty($index[$first])) { |
|
| 6190 | + $index[$first] = array(); |
|
| 6191 | + } |
|
| 5858 | 6192 | |
| 5859 | 6193 | if ($strlen($string) > 1) |
| 5860 | 6194 | { |
| 5861 | 6195 | // Sanity check on recursion |
| 5862 | - if ($depth > 99) |
|
| 5863 | - $index[$first][$substr($string, 1)] = ''; |
|
| 5864 | - |
|
| 5865 | - else |
|
| 5866 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6196 | + if ($depth > 99) { |
|
| 6197 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6198 | + } else { |
|
| 6199 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6200 | + } |
|
| 6201 | + } else { |
|
| 6202 | + $index[$first][''] = ''; |
|
| 5867 | 6203 | } |
| 5868 | - else |
|
| 5869 | - $index[$first][''] = ''; |
|
| 5870 | 6204 | |
| 5871 | 6205 | $depth--; |
| 5872 | 6206 | return $index; |
@@ -5889,9 +6223,9 @@ discard block |
||
| 5889 | 6223 | $key_regex = preg_quote($key, $delim); |
| 5890 | 6224 | $new_key = $key; |
| 5891 | 6225 | |
| 5892 | - if (empty($value)) |
|
| 5893 | - $sub_regex = ''; |
|
| 5894 | - else |
|
| 6226 | + if (empty($value)) { |
|
| 6227 | + $sub_regex = ''; |
|
| 6228 | + } else |
|
| 5895 | 6229 | { |
| 5896 | 6230 | $sub_regex = $index_to_regex($value, $delim); |
| 5897 | 6231 | |
@@ -5899,22 +6233,22 @@ discard block |
||
| 5899 | 6233 | { |
| 5900 | 6234 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 5901 | 6235 | $new_key .= $new_key_array[0]; |
| 6236 | + } else { |
|
| 6237 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5902 | 6238 | } |
| 5903 | - else |
|
| 5904 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5905 | 6239 | } |
| 5906 | 6240 | |
| 5907 | - if ($depth > 1) |
|
| 5908 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 5909 | - else |
|
| 6241 | + if ($depth > 1) { |
|
| 6242 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6243 | + } else |
|
| 5910 | 6244 | { |
| 5911 | 6245 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 5912 | 6246 | { |
| 5913 | 6247 | $regex[$new_key] = $key_regex . $sub_regex; |
| 5914 | 6248 | unset($index[$key]); |
| 6249 | + } else { |
|
| 6250 | + break; |
|
| 5915 | 6251 | } |
| 5916 | - else |
|
| 5917 | - break; |
|
| 5918 | 6252 | } |
| 5919 | 6253 | } |
| 5920 | 6254 | |
@@ -5923,10 +6257,11 @@ discard block |
||
| 5923 | 6257 | $l1 = $strlen($k1); |
| 5924 | 6258 | $l2 = $strlen($k2); |
| 5925 | 6259 | |
| 5926 | - if ($l1 == $l2) |
|
| 5927 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 5928 | - else |
|
| 5929 | - return $l1 > $l2 ? -1 : 1; |
|
| 6260 | + if ($l1 == $l2) { |
|
| 6261 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6262 | + } else { |
|
| 6263 | + return $l1 > $l2 ? -1 : 1; |
|
| 6264 | + } |
|
| 5930 | 6265 | }); |
| 5931 | 6266 | |
| 5932 | 6267 | $depth--; |
@@ -5937,15 +6272,18 @@ discard block |
||
| 5937 | 6272 | $index = array(); |
| 5938 | 6273 | $regexes = array(); |
| 5939 | 6274 | |
| 5940 | - foreach ($strings as $string) |
|
| 5941 | - $index = $add_string_to_index($string, $index); |
|
| 6275 | + foreach ($strings as $string) { |
|
| 6276 | + $index = $add_string_to_index($string, $index); |
|
| 6277 | + } |
|
| 5942 | 6278 | |
| 5943 | - while (!empty($index)) |
|
| 5944 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6279 | + while (!empty($index)) { |
|
| 6280 | + $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6281 | + } |
|
| 5945 | 6282 | |
| 5946 | 6283 | // Restore PHP's internal character encoding to whatever it was originally |
| 5947 | - if (!empty($current_encoding)) |
|
| 5948 | - mb_internal_encoding($current_encoding); |
|
| 6284 | + if (!empty($current_encoding)) { |
|
| 6285 | + mb_internal_encoding($current_encoding); |
|
| 6286 | + } |
|
| 5949 | 6287 | |
| 5950 | 6288 | return $regexes; |
| 5951 | 6289 | } |
@@ -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 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
| 24 | 25 | global $time_start, $smcFunc; |
| 25 | 26 | |
| 26 | 27 | // Special case for doing the mail queue. |
| 27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
| 28 | - ReduceMailQueue(); |
|
| 29 | - else |
|
| 28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
| 29 | + ReduceMailQueue(); |
|
| 30 | + } else |
|
| 30 | 31 | { |
| 31 | 32 | $task_string = ''; |
| 32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
| 53 | 54 | |
| 54 | 55 | // How long in seconds it the gap? |
| 55 | 56 | $duration = $row['time_regularity']; |
| 56 | - if ($row['time_unit'] == 'm') |
|
| 57 | - $duration *= 60; |
|
| 58 | - elseif ($row['time_unit'] == 'h') |
|
| 59 | - $duration *= 3600; |
|
| 60 | - elseif ($row['time_unit'] == 'd') |
|
| 61 | - $duration *= 86400; |
|
| 62 | - elseif ($row['time_unit'] == 'w') |
|
| 63 | - $duration *= 604800; |
|
| 57 | + if ($row['time_unit'] == 'm') { |
|
| 58 | + $duration *= 60; |
|
| 59 | + } elseif ($row['time_unit'] == 'h') { |
|
| 60 | + $duration *= 3600; |
|
| 61 | + } elseif ($row['time_unit'] == 'd') { |
|
| 62 | + $duration *= 86400; |
|
| 63 | + } elseif ($row['time_unit'] == 'w') { |
|
| 64 | + $duration *= 604800; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // If we were really late running this task actually skip the next one. |
| 66 | - if (time() + ($duration / 2) > $next_time) |
|
| 67 | - $next_time += $duration; |
|
| 68 | + if (time() + ($duration / 2) > $next_time) { |
|
| 69 | + $next_time += $duration; |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Update it now, so no others run this! |
| 70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
| 81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
| 82 | 85 | |
| 83 | 86 | // What kind of task are we handling? |
| 84 | - if (!empty($row['callable'])) |
|
| 85 | - $task_string = $row['callable']; |
|
| 87 | + if (!empty($row['callable'])) { |
|
| 88 | + $task_string = $row['callable']; |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | // Default SMF task or old mods? |
| 88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 89 | - $task_string = 'scheduled_' . $row['task']; |
|
| 92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 93 | + $task_string = 'scheduled_' . $row['task']; |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | // One last resource, the task name. |
| 92 | - elseif (!empty($row['task'])) |
|
| 93 | - $task_string = $row['task']; |
|
| 97 | + elseif (!empty($row['task'])) { |
|
| 98 | + $task_string = $row['task']; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
| 96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
| 101 | 107 | $callable_task = call_helper($task_string, true); |
| 102 | 108 | |
| 103 | 109 | // Perform the task. |
| 104 | - if (!empty($callable_task)) |
|
| 105 | - $completed = call_user_func($callable_task); |
|
| 106 | - |
|
| 107 | - else |
|
| 108 | - $completed = false; |
|
| 110 | + if (!empty($callable_task)) { |
|
| 111 | + $completed = call_user_func($callable_task); |
|
| 112 | + } else { |
|
| 113 | + $completed = false; |
|
| 114 | + } |
|
| 109 | 115 | |
| 110 | 116 | // Log that we did it ;) |
| 111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
| 138 | 144 | ) |
| 139 | 145 | ); |
| 140 | 146 | // No new task scheduled yet? |
| 141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 142 | - $nextEvent = time() + 86400; |
|
| 143 | - else |
|
| 144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 148 | + $nextEvent = time() + 86400; |
|
| 149 | + } else { |
|
| 150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 151 | + } |
|
| 145 | 152 | $smcFunc['db_free_result']($request); |
| 146 | 153 | |
| 147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
| 148 | 155 | } |
| 149 | 156 | |
| 150 | 157 | // Shall we return? |
| 151 | - if (!isset($_GET['scheduled'])) |
|
| 152 | - return true; |
|
| 158 | + if (!isset($_GET['scheduled'])) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | 162 | // Finally, send some stuff... |
| 155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
| 181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 182 | 190 | { |
| 183 | 191 | // If this is no longer around we'll ignore it. |
| 184 | - if (empty($row['id_topic'])) |
|
| 185 | - continue; |
|
| 192 | + if (empty($row['id_topic'])) { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 186 | 195 | |
| 187 | 196 | // What type is it? |
| 188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
| 189 | - $type = 'topic'; |
|
| 190 | - elseif ($row['id_attach']) |
|
| 191 | - $type = 'attach'; |
|
| 192 | - else |
|
| 193 | - $type = 'msg'; |
|
| 197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
| 198 | + $type = 'topic'; |
|
| 199 | + } elseif ($row['id_attach']) { |
|
| 200 | + $type = 'attach'; |
|
| 201 | + } else { |
|
| 202 | + $type = 'msg'; |
|
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | // Add it to the array otherwise. |
| 196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
| 211 | 221 | ); |
| 212 | 222 | |
| 213 | 223 | // If nothing quit now. |
| 214 | - if (empty($notices)) |
|
| 215 | - return true; |
|
| 224 | + if (empty($notices)) { |
|
| 225 | + return true; |
|
| 226 | + } |
|
| 216 | 227 | |
| 217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
| 218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
| 231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 232 | 243 | { |
| 233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
| 234 | - if ($row['id_group'] < 2) |
|
| 235 | - continue; |
|
| 245 | + if ($row['id_group'] < 2) { |
|
| 246 | + continue; |
|
| 247 | + } |
|
| 236 | 248 | |
| 237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
| 238 | 250 | |
| 239 | 251 | // Anyone who can access has to be considered. |
| 240 | - if ($row['add_deny']) |
|
| 241 | - $addGroups[] = $row['id_group']; |
|
| 252 | + if ($row['add_deny']) { |
|
| 253 | + $addGroups[] = $row['id_group']; |
|
| 254 | + } |
|
| 242 | 255 | } |
| 243 | 256 | $smcFunc['db_free_result']($request); |
| 244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | if (!empty($row['mod_prefs'])) |
| 284 | 297 | { |
| 285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
| 286 | - if (!($pref_binary & 4)) |
|
| 287 | - continue; |
|
| 299 | + if (!($pref_binary & 4)) { |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | |
| 290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
| 309 | 323 | $emailbody = ''; |
| 310 | 324 | |
| 311 | 325 | // Load the language file as required. |
| 312 | - if (empty($current_language) || $current_language != $member['language']) |
|
| 313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
| 327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | // Loop through each notice... |
| 316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
| 318 | 333 | $access = false; |
| 319 | 334 | |
| 320 | 335 | // Can they mod in this board? |
| 321 | - if (isset($mods[$id][$board])) |
|
| 322 | - $access = true; |
|
| 336 | + if (isset($mods[$id][$board])) { |
|
| 337 | + $access = true; |
|
| 338 | + } |
|
| 323 | 339 | |
| 324 | 340 | // Do the group check... |
| 325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
| 326 | 342 | { |
| 327 | 343 | // They can access?! |
| 328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
| 329 | - $access = true; |
|
| 344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
| 345 | + $access = true; |
|
| 346 | + } |
|
| 330 | 347 | |
| 331 | 348 | // If they have deny rights don't consider them! |
| 332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
| 333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
| 350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 334 | 351 | $access = false; |
| 352 | + } |
|
| 335 | 353 | } |
| 336 | 354 | |
| 337 | 355 | // Finally, fix it for admins! |
| 338 | - if (in_array(1, $member['groups'])) |
|
| 339 | - $access = true; |
|
| 356 | + if (in_array(1, $member['groups'])) { |
|
| 357 | + $access = true; |
|
| 358 | + } |
|
| 340 | 359 | |
| 341 | 360 | // If they can't access it then give it a break! |
| 342 | - if (!$access) |
|
| 343 | - continue; |
|
| 361 | + if (!$access) { |
|
| 362 | + continue; |
|
| 363 | + } |
|
| 344 | 364 | |
| 345 | 365 | foreach ($notice as $type => $items) |
| 346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
| 348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
| 349 | 369 | '------------------------------------------------------' . "\n"; |
| 350 | 370 | |
| 351 | - foreach ($items as $item) |
|
| 352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 371 | + foreach ($items as $item) { |
|
| 372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 373 | + } |
|
| 353 | 374 | |
| 354 | 375 | $emailbody .= "\n"; |
| 355 | 376 | } |
| 356 | 377 | } |
| 357 | 378 | |
| 358 | - if ($emailbody == '') |
|
| 359 | - continue; |
|
| 379 | + if ($emailbody == '') { |
|
| 380 | + continue; |
|
| 381 | + } |
|
| 360 | 382 | |
| 361 | 383 | $replacements = array( |
| 362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
| 397 | 419 | ) |
| 398 | 420 | ); |
| 399 | 421 | $members = array(); |
| 400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 401 | - $members[$row['id_member']] = $row['warning']; |
|
| 422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 423 | + $members[$row['id_member']] = $row['warning']; |
|
| 424 | + } |
|
| 402 | 425 | $smcFunc['db_free_result']($request); |
| 403 | 426 | |
| 404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
| 420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 421 | 444 | { |
| 422 | 445 | // More than 24 hours ago? |
| 423 | - if ($row['last_warning'] <= time() - 86400) |
|
| 424 | - $member_changes[] = array( |
|
| 446 | + if ($row['last_warning'] <= time() - 86400) { |
|
| 447 | + $member_changes[] = array( |
|
| 425 | 448 | 'id' => $row['id_recipient'], |
| 426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
| 427 | 450 | ); |
| 451 | + } |
|
| 428 | 452 | } |
| 429 | 453 | $smcFunc['db_free_result']($request); |
| 430 | 454 | |
| 431 | 455 | // Have some members to change? |
| 432 | - if (!empty($member_changes)) |
|
| 433 | - foreach ($member_changes as $change) |
|
| 456 | + if (!empty($member_changes)) { |
|
| 457 | + foreach ($member_changes as $change) |
|
| 434 | 458 | $smcFunc['db_query']('', ' |
| 435 | 459 | UPDATE {db_prefix}members |
| 436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
| 440 | 464 | 'id_member' => $change['id'], |
| 441 | 465 | ) |
| 442 | 466 | ); |
| 467 | + } |
|
| 443 | 468 | } |
| 444 | 469 | } |
| 445 | 470 | |
@@ -506,15 +531,17 @@ discard block |
||
| 506 | 531 | |
| 507 | 532 | // Store this useful data! |
| 508 | 533 | $boards[$row['id_board']] = $row['id_board']; |
| 509 | - if ($row['id_topic']) |
|
| 510 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 511 | - else |
|
| 512 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 534 | + if ($row['id_topic']) { |
|
| 535 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 536 | + } else { |
|
| 537 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 538 | + } |
|
| 513 | 539 | } |
| 514 | 540 | $smcFunc['db_free_result']($request); |
| 515 | 541 | |
| 516 | - if (empty($boards)) |
|
| 517 | - return true; |
|
| 542 | + if (empty($boards)) { |
|
| 543 | + return true; |
|
| 544 | + } |
|
| 518 | 545 | |
| 519 | 546 | // Just get the board names. |
| 520 | 547 | $request = $smcFunc['db_query']('', ' |
@@ -526,12 +553,14 @@ discard block |
||
| 526 | 553 | ) |
| 527 | 554 | ); |
| 528 | 555 | $boards = array(); |
| 529 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 530 | - $boards[$row['id_board']] = $row['name']; |
|
| 556 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 557 | + $boards[$row['id_board']] = $row['name']; |
|
| 558 | + } |
|
| 531 | 559 | $smcFunc['db_free_result']($request); |
| 532 | 560 | |
| 533 | - if (empty($boards)) |
|
| 534 | - return true; |
|
| 561 | + if (empty($boards)) { |
|
| 562 | + return true; |
|
| 563 | + } |
|
| 535 | 564 | |
| 536 | 565 | // Get the actual topics... |
| 537 | 566 | $request = $smcFunc['db_query']('', ' |
@@ -551,52 +580,57 @@ discard block |
||
| 551 | 580 | $types = array(); |
| 552 | 581 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 553 | 582 | { |
| 554 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
| 555 | - $types[$row['note_type']][$row['id_board']] = array( |
|
| 583 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
| 584 | + $types[$row['note_type']][$row['id_board']] = array( |
|
| 556 | 585 | 'lines' => array(), |
| 557 | 586 | 'name' => $row['board_name'], |
| 558 | 587 | 'id' => $row['id_board'], |
| 559 | 588 | ); |
| 589 | + } |
|
| 560 | 590 | |
| 561 | 591 | if ($row['note_type'] == 'reply') |
| 562 | 592 | { |
| 563 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 564 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 565 | - else |
|
| 566 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 593 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 594 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 595 | + } else { |
|
| 596 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 567 | 597 | 'id' => $row['id_topic'], |
| 568 | 598 | 'subject' => un_htmlspecialchars($row['subject']), |
| 569 | 599 | 'count' => 1, |
| 570 | 600 | ); |
| 571 | - } |
|
| 572 | - elseif ($row['note_type'] == 'topic') |
|
| 601 | + } |
|
| 602 | + } elseif ($row['note_type'] == 'topic') |
|
| 573 | 603 | { |
| 574 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 575 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 604 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 605 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 576 | 606 | 'id' => $row['id_topic'], |
| 577 | 607 | 'subject' => un_htmlspecialchars($row['subject']), |
| 578 | 608 | ); |
| 579 | - } |
|
| 580 | - else |
|
| 609 | + } |
|
| 610 | + } else |
|
| 581 | 611 | { |
| 582 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 583 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 612 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 613 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 584 | 614 | 'id' => $row['id_topic'], |
| 585 | 615 | 'subject' => un_htmlspecialchars($row['subject']), |
| 586 | 616 | 'starter' => $row['id_member_started'], |
| 587 | 617 | ); |
| 618 | + } |
|
| 588 | 619 | } |
| 589 | 620 | |
| 590 | 621 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
| 591 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
| 592 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 593 | - if (!empty($notify['boards'][$row['id_board']])) |
|
| 594 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 622 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
| 623 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 624 | + } |
|
| 625 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
| 626 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 627 | + } |
|
| 595 | 628 | } |
| 596 | 629 | $smcFunc['db_free_result']($request); |
| 597 | 630 | |
| 598 | - if (empty($types)) |
|
| 599 | - return true; |
|
| 631 | + if (empty($types)) { |
|
| 632 | + return true; |
|
| 633 | + } |
|
| 600 | 634 | |
| 601 | 635 | // Let's load all the languages into a cache thingy. |
| 602 | 636 | $langtxt = array(); |
@@ -637,8 +671,9 @@ discard block |
||
| 637 | 671 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
| 638 | 672 | |
| 639 | 673 | // Did they not elect to choose this? |
| 640 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
| 641 | - continue; |
|
| 674 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 642 | 677 | |
| 643 | 678 | // Right character set! |
| 644 | 679 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -654,39 +689,43 @@ discard block |
||
| 654 | 689 | if (isset($types['topic'])) |
| 655 | 690 | { |
| 656 | 691 | $titled = false; |
| 657 | - foreach ($types['topic'] as $id => $board) |
|
| 658 | - foreach ($board['lines'] as $topic) |
|
| 692 | + foreach ($types['topic'] as $id => $board) { |
|
| 693 | + foreach ($board['lines'] as $topic) |
|
| 659 | 694 | if (in_array($mid, $topic['members'])) |
| 660 | 695 | { |
| 661 | 696 | if (!$titled) |
| 662 | 697 | { |
| 663 | 698 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
| 699 | + } |
|
| 664 | 700 | $titled = true; |
| 665 | 701 | } |
| 666 | 702 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
| 667 | 703 | } |
| 668 | - if ($titled) |
|
| 669 | - $email['body'] .= "\n"; |
|
| 704 | + if ($titled) { |
|
| 705 | + $email['body'] .= "\n"; |
|
| 706 | + } |
|
| 670 | 707 | } |
| 671 | 708 | |
| 672 | 709 | // What about replies? |
| 673 | 710 | if (isset($types['reply'])) |
| 674 | 711 | { |
| 675 | 712 | $titled = false; |
| 676 | - foreach ($types['reply'] as $id => $board) |
|
| 677 | - foreach ($board['lines'] as $topic) |
|
| 713 | + foreach ($types['reply'] as $id => $board) { |
|
| 714 | + foreach ($board['lines'] as $topic) |
|
| 678 | 715 | if (in_array($mid, $topic['members'])) |
| 679 | 716 | { |
| 680 | 717 | if (!$titled) |
| 681 | 718 | { |
| 682 | 719 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
| 720 | + } |
|
| 683 | 721 | $titled = true; |
| 684 | 722 | } |
| 685 | 723 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
| 686 | 724 | } |
| 687 | 725 | |
| 688 | - if ($titled) |
|
| 689 | - $email['body'] .= "\n"; |
|
| 726 | + if ($titled) { |
|
| 727 | + $email['body'] .= "\n"; |
|
| 728 | + } |
|
| 690 | 729 | } |
| 691 | 730 | |
| 692 | 731 | // Finally, moderation actions! |
@@ -695,24 +734,27 @@ discard block |
||
| 695 | 734 | $titled = false; |
| 696 | 735 | foreach ($types as $note_type => $type) |
| 697 | 736 | { |
| 698 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
| 699 | - continue; |
|
| 737 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
| 738 | + continue; |
|
| 739 | + } |
|
| 700 | 740 | |
| 701 | - foreach ($type as $id => $board) |
|
| 702 | - foreach ($board['lines'] as $topic) |
|
| 741 | + foreach ($type as $id => $board) { |
|
| 742 | + foreach ($board['lines'] as $topic) |
|
| 703 | 743 | if (in_array($mid, $topic['members'])) |
| 704 | 744 | { |
| 705 | 745 | if (!$titled) |
| 706 | 746 | { |
| 707 | 747 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
| 748 | + } |
|
| 708 | 749 | $titled = true; |
| 709 | 750 | } |
| 710 | 751 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
| 711 | 752 | } |
| 712 | 753 | } |
| 713 | 754 | } |
| 714 | - if ($titled) |
|
| 715 | - $email['body'] .= "\n"; |
|
| 755 | + if ($titled) { |
|
| 756 | + $email['body'] .= "\n"; |
|
| 757 | + } |
|
| 716 | 758 | |
| 717 | 759 | // Then just say our goodbyes! |
| 718 | 760 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -740,8 +782,7 @@ discard block |
||
| 740 | 782 | 'not_daily' => 0, |
| 741 | 783 | ) |
| 742 | 784 | ); |
| 743 | - } |
|
| 744 | - else |
|
| 785 | + } else |
|
| 745 | 786 | { |
| 746 | 787 | // Clear any only weekly ones, and stop us from sending daily again. |
| 747 | 788 | $smcFunc['db_query']('', ' |
@@ -803,16 +844,19 @@ discard block |
||
| 803 | 844 | global $modSettings, $smcFunc, $sourcedir; |
| 804 | 845 | |
| 805 | 846 | // Are we intending another script to be sending out the queue? |
| 806 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
| 807 | - return false; |
|
| 847 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
| 848 | + return false; |
|
| 849 | + } |
|
| 808 | 850 | |
| 809 | 851 | // By default send 5 at once. |
| 810 | - if (!$number) |
|
| 811 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 852 | + if (!$number) { |
|
| 853 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 854 | + } |
|
| 812 | 855 | |
| 813 | 856 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
| 814 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
| 815 | - return false; |
|
| 857 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
| 858 | + return false; |
|
| 859 | + } |
|
| 816 | 860 | |
| 817 | 861 | // By default move the next sending on by 10 seconds, and require an affected row. |
| 818 | 862 | if (!$override_limit) |
@@ -829,8 +873,9 @@ discard block |
||
| 829 | 873 | 'last_send' => $modSettings['mail_next_send'], |
| 830 | 874 | ) |
| 831 | 875 | ); |
| 832 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 833 | - return false; |
|
| 876 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 877 | + return false; |
|
| 878 | + } |
|
| 834 | 879 | $modSettings['mail_next_send'] = time() + $delay; |
| 835 | 880 | } |
| 836 | 881 | |
@@ -851,8 +896,9 @@ discard block |
||
| 851 | 896 | $mn += $number; |
| 852 | 897 | } |
| 853 | 898 | // No more I'm afraid, return! |
| 854 | - else |
|
| 855 | - return false; |
|
| 899 | + else { |
|
| 900 | + return false; |
|
| 901 | + } |
|
| 856 | 902 | |
| 857 | 903 | // Reflect that we're about to send some, do it now to be safe. |
| 858 | 904 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -887,14 +933,15 @@ discard block |
||
| 887 | 933 | $smcFunc['db_free_result']($request); |
| 888 | 934 | |
| 889 | 935 | // Delete, delete, delete!!! |
| 890 | - if (!empty($ids)) |
|
| 891 | - $smcFunc['db_query']('', ' |
|
| 936 | + if (!empty($ids)) { |
|
| 937 | + $smcFunc['db_query']('', ' |
|
| 892 | 938 | DELETE FROM {db_prefix}mail_queue |
| 893 | 939 | WHERE id_mail IN ({array_int:mail_list})', |
| 894 | 940 | array( |
| 895 | 941 | 'mail_list' => $ids, |
| 896 | 942 | ) |
| 897 | 943 | ); |
| 944 | + } |
|
| 898 | 945 | |
| 899 | 946 | // Don't believe we have any left? |
| 900 | 947 | if (count($ids) < $number) |
@@ -912,11 +959,13 @@ discard block |
||
| 912 | 959 | ); |
| 913 | 960 | } |
| 914 | 961 | |
| 915 | - if (empty($ids)) |
|
| 916 | - return false; |
|
| 962 | + if (empty($ids)) { |
|
| 963 | + return false; |
|
| 964 | + } |
|
| 917 | 965 | |
| 918 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
| 919 | - require_once($sourcedir . '/Subs-Post.php'); |
|
| 966 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
| 967 | + require_once($sourcedir . '/Subs-Post.php'); |
|
| 968 | + } |
|
| 920 | 969 | |
| 921 | 970 | // Send each email, yea! |
| 922 | 971 | $failed_emails = array(); |
@@ -936,15 +985,17 @@ discard block |
||
| 936 | 985 | |
| 937 | 986 | // Try to stop a timeout, this would be bad... |
| 938 | 987 | @set_time_limit(300); |
| 939 | - if (function_exists('apache_reset_timeout')) |
|
| 940 | - @apache_reset_timeout(); |
|
| 988 | + if (function_exists('apache_reset_timeout')) { |
|
| 989 | + @apache_reset_timeout(); |
|
| 990 | + } |
|
| 991 | + } else { |
|
| 992 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 941 | 993 | } |
| 942 | - else |
|
| 943 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 944 | 994 | |
| 945 | 995 | // Hopefully it sent? |
| 946 | - if (!$result) |
|
| 947 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 996 | + if (!$result) { |
|
| 997 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 998 | + } |
|
| 948 | 999 | } |
| 949 | 1000 | |
| 950 | 1001 | // Any emails that didn't send? |
@@ -959,8 +1010,8 @@ discard block |
||
| 959 | 1010 | ); |
| 960 | 1011 | |
| 961 | 1012 | // If we have failed to many times, tell mail to wait a bit and try again. |
| 962 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
| 963 | - $smcFunc['db_query']('', ' |
|
| 1013 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
| 1014 | + $smcFunc['db_query']('', ' |
|
| 964 | 1015 | UPDATE {db_prefix}settings |
| 965 | 1016 | SET value = {string:next_mail_send} |
| 966 | 1017 | WHERE variable = {literal:mail_next_send} |
@@ -969,6 +1020,7 @@ discard block |
||
| 969 | 1020 | 'next_mail_send' => time() + 60, |
| 970 | 1021 | 'last_send' => $modSettings['mail_next_send'], |
| 971 | 1022 | )); |
| 1023 | + } |
|
| 972 | 1024 | |
| 973 | 1025 | // Add our email back to the queue, manually. |
| 974 | 1026 | $smcFunc['db_insert']('insert', |
@@ -981,8 +1033,8 @@ discard block |
||
| 981 | 1033 | return false; |
| 982 | 1034 | } |
| 983 | 1035 | // We where unable to send the email, clear our failed attempts. |
| 984 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
| 985 | - $smcFunc['db_query']('', ' |
|
| 1036 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
| 1037 | + $smcFunc['db_query']('', ' |
|
| 986 | 1038 | UPDATE {db_prefix}settings |
| 987 | 1039 | SET value = {string:zero} |
| 988 | 1040 | WHERE variable = {string:mail_failed_attempts}', |
@@ -990,6 +1042,7 @@ discard block |
||
| 990 | 1042 | 'zero' => '0', |
| 991 | 1043 | 'mail_failed_attempts' => 'mail_failed_attempts', |
| 992 | 1044 | )); |
| 1045 | + } |
|
| 993 | 1046 | |
| 994 | 1047 | // Had something to send... |
| 995 | 1048 | return true; |
@@ -1006,16 +1059,18 @@ discard block |
||
| 1006 | 1059 | global $modSettings, $smcFunc; |
| 1007 | 1060 | |
| 1008 | 1061 | $task_query = ''; |
| 1009 | - if (!is_array($tasks)) |
|
| 1010 | - $tasks = array($tasks); |
|
| 1062 | + if (!is_array($tasks)) { |
|
| 1063 | + $tasks = array($tasks); |
|
| 1064 | + } |
|
| 1011 | 1065 | |
| 1012 | 1066 | // Actually have something passed? |
| 1013 | 1067 | if (!empty($tasks)) |
| 1014 | 1068 | { |
| 1015 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
| 1016 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1017 | - else |
|
| 1018 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1069 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
| 1070 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1071 | + } else { |
|
| 1072 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1073 | + } |
|
| 1019 | 1074 | } |
| 1020 | 1075 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
| 1021 | 1076 | |
@@ -1036,20 +1091,22 @@ discard block |
||
| 1036 | 1091 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
| 1037 | 1092 | |
| 1038 | 1093 | // Only bother moving the task if it's out of place or we're forcing it! |
| 1039 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
| 1040 | - $tasks[$row['id_task']] = $next_time; |
|
| 1041 | - else |
|
| 1042 | - $next_time = $row['next_time']; |
|
| 1094 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
| 1095 | + $tasks[$row['id_task']] = $next_time; |
|
| 1096 | + } else { |
|
| 1097 | + $next_time = $row['next_time']; |
|
| 1098 | + } |
|
| 1043 | 1099 | |
| 1044 | 1100 | // If this is sooner than the current next task, make this the next task. |
| 1045 | - if ($next_time < $nextTaskTime) |
|
| 1046 | - $nextTaskTime = $next_time; |
|
| 1101 | + if ($next_time < $nextTaskTime) { |
|
| 1102 | + $nextTaskTime = $next_time; |
|
| 1103 | + } |
|
| 1047 | 1104 | } |
| 1048 | 1105 | $smcFunc['db_free_result']($request); |
| 1049 | 1106 | |
| 1050 | 1107 | // Now make the changes! |
| 1051 | - foreach ($tasks as $id => $time) |
|
| 1052 | - $smcFunc['db_query']('', ' |
|
| 1108 | + foreach ($tasks as $id => $time) { |
|
| 1109 | + $smcFunc['db_query']('', ' |
|
| 1053 | 1110 | UPDATE {db_prefix}scheduled_tasks |
| 1054 | 1111 | SET next_time = {int:next_time} |
| 1055 | 1112 | WHERE id_task = {int:id_task}', |
@@ -1058,11 +1115,13 @@ discard block |
||
| 1058 | 1115 | 'id_task' => $id, |
| 1059 | 1116 | ) |
| 1060 | 1117 | ); |
| 1118 | + } |
|
| 1061 | 1119 | |
| 1062 | 1120 | // If the next task is now different update. |
| 1063 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
| 1064 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1065 | -} |
|
| 1121 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
| 1122 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1066 | 1125 | |
| 1067 | 1126 | /** |
| 1068 | 1127 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1075,8 +1134,9 @@ discard block |
||
| 1075 | 1134 | function next_time($regularity, $unit, $offset) |
| 1076 | 1135 | { |
| 1077 | 1136 | // Just in case! |
| 1078 | - if ($regularity == 0) |
|
| 1079 | - $regularity = 2; |
|
| 1137 | + if ($regularity == 0) { |
|
| 1138 | + $regularity = 2; |
|
| 1139 | + } |
|
| 1080 | 1140 | |
| 1081 | 1141 | $curMin = date('i', time()); |
| 1082 | 1142 | |
@@ -1086,15 +1146,16 @@ discard block |
||
| 1086 | 1146 | $off = date('i', $offset); |
| 1087 | 1147 | |
| 1088 | 1148 | // If it's now just pretend it ain't, |
| 1089 | - if ($off == $curMin) |
|
| 1090 | - $next_time = time() + $regularity; |
|
| 1091 | - else |
|
| 1149 | + if ($off == $curMin) { |
|
| 1150 | + $next_time = time() + $regularity; |
|
| 1151 | + } else |
|
| 1092 | 1152 | { |
| 1093 | 1153 | // Make sure that the offset is always in the past. |
| 1094 | 1154 | $off = $off > $curMin ? $off - 60 : $off; |
| 1095 | 1155 | |
| 1096 | - while ($off <= $curMin) |
|
| 1097 | - $off += $regularity; |
|
| 1156 | + while ($off <= $curMin) { |
|
| 1157 | + $off += $regularity; |
|
| 1158 | + } |
|
| 1098 | 1159 | |
| 1099 | 1160 | // Now we know when the time should be! |
| 1100 | 1161 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1114,11 +1175,13 @@ discard block |
||
| 1114 | 1175 | // Default we'll jump in hours. |
| 1115 | 1176 | $applyOffset = 3600; |
| 1116 | 1177 | // 24 hours = 1 day. |
| 1117 | - if ($unit == 'd') |
|
| 1118 | - $applyOffset = 86400; |
|
| 1178 | + if ($unit == 'd') { |
|
| 1179 | + $applyOffset = 86400; |
|
| 1180 | + } |
|
| 1119 | 1181 | // Otherwise a week. |
| 1120 | - if ($unit == 'w') |
|
| 1121 | - $applyOffset = 604800; |
|
| 1182 | + if ($unit == 'w') { |
|
| 1183 | + $applyOffset = 604800; |
|
| 1184 | + } |
|
| 1122 | 1185 | |
| 1123 | 1186 | $applyOffset *= $regularity; |
| 1124 | 1187 | |
@@ -1155,8 +1218,9 @@ discard block |
||
| 1155 | 1218 | $settings[$row['variable']] = $row['value']; |
| 1156 | 1219 | |
| 1157 | 1220 | // Is this the default theme? |
| 1158 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
| 1159 | - $settings['default_' . $row['variable']] = $row['value']; |
|
| 1221 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
| 1222 | + $settings['default_' . $row['variable']] = $row['value']; |
|
| 1223 | + } |
|
| 1160 | 1224 | } |
| 1161 | 1225 | $smcFunc['db_free_result']($result); |
| 1162 | 1226 | |
@@ -1166,12 +1230,14 @@ discard block |
||
| 1166 | 1230 | $settings['template_dirs'] = array($settings['theme_dir']); |
| 1167 | 1231 | |
| 1168 | 1232 | // Based on theme (if there is one). |
| 1169 | - if (!empty($settings['base_theme_dir'])) |
|
| 1170 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1233 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1234 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1235 | + } |
|
| 1171 | 1236 | |
| 1172 | 1237 | // Lastly the default theme. |
| 1173 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1174 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1238 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1239 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1240 | + } |
|
| 1175 | 1241 | } |
| 1176 | 1242 | |
| 1177 | 1243 | // Assume we want this. |
@@ -1318,8 +1384,9 @@ discard block |
||
| 1318 | 1384 | // Ok should we prune the logs? |
| 1319 | 1385 | if (!empty($modSettings['pruningOptions'])) |
| 1320 | 1386 | { |
| 1321 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
| 1322 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1387 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
| 1388 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1389 | + } |
|
| 1323 | 1390 | |
| 1324 | 1391 | if (!empty($modSettings['pruneErrorLog'])) |
| 1325 | 1392 | { |
@@ -1385,8 +1452,9 @@ discard block |
||
| 1385 | 1452 | ) |
| 1386 | 1453 | ); |
| 1387 | 1454 | |
| 1388 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
| 1389 | - $reports[] = $row[0]; |
|
| 1455 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
| 1456 | + $reports[] = $row[0]; |
|
| 1457 | + } |
|
| 1390 | 1458 | |
| 1391 | 1459 | $smcFunc['db_free_result']($result); |
| 1392 | 1460 | |
@@ -1548,8 +1616,9 @@ discard block |
||
| 1548 | 1616 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
| 1549 | 1617 | |
| 1550 | 1618 | // Send the actual email. |
| 1551 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
| 1552 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1619 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
| 1620 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1621 | + } |
|
| 1553 | 1622 | |
| 1554 | 1623 | if ($notifyPrefs[$row['id_member']] & 0x01) |
| 1555 | 1624 | { |
@@ -1572,18 +1641,19 @@ discard block |
||
| 1572 | 1641 | } |
| 1573 | 1642 | |
| 1574 | 1643 | // Insert the alerts if any |
| 1575 | - if (!empty($alert_rows)) |
|
| 1576 | - $smcFunc['db_insert']('', |
|
| 1644 | + if (!empty($alert_rows)) { |
|
| 1645 | + $smcFunc['db_insert']('', |
|
| 1577 | 1646 | '{db_prefix}user_alerts', |
| 1578 | 1647 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 1579 | 1648 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 1580 | 1649 | $alert_rows, |
| 1581 | 1650 | array() |
| 1582 | 1651 | ); |
| 1652 | + } |
|
| 1583 | 1653 | |
| 1584 | 1654 | // Mark the reminder as sent. |
| 1585 | - if (!empty($subs_reminded)) |
|
| 1586 | - $smcFunc['db_query']('', ' |
|
| 1655 | + if (!empty($subs_reminded)) { |
|
| 1656 | + $smcFunc['db_query']('', ' |
|
| 1587 | 1657 | UPDATE {db_prefix}log_subscribed |
| 1588 | 1658 | SET reminder_sent = {int:reminder_sent} |
| 1589 | 1659 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1592,6 +1662,7 @@ discard block |
||
| 1592 | 1662 | 'reminder_sent' => 1, |
| 1593 | 1663 | ) |
| 1594 | 1664 | ); |
| 1665 | + } |
|
| 1595 | 1666 | |
| 1596 | 1667 | return true; |
| 1597 | 1668 | } |
@@ -1607,13 +1678,13 @@ discard block |
||
| 1607 | 1678 | // We need to know where this thing is going. |
| 1608 | 1679 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 1609 | 1680 | { |
| 1610 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 1611 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 1681 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 1682 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 1683 | + } |
|
| 1612 | 1684 | |
| 1613 | 1685 | // Just use the current path for temp files. |
| 1614 | 1686 | $attach_dirs = $modSettings['attachmentUploadDir']; |
| 1615 | - } |
|
| 1616 | - else |
|
| 1687 | + } else |
|
| 1617 | 1688 | { |
| 1618 | 1689 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
| 1619 | 1690 | } |
@@ -1632,14 +1703,16 @@ discard block |
||
| 1632 | 1703 | |
| 1633 | 1704 | while ($file = readdir($dir)) |
| 1634 | 1705 | { |
| 1635 | - if ($file == '.' || $file == '..') |
|
| 1636 | - continue; |
|
| 1706 | + if ($file == '.' || $file == '..') { |
|
| 1707 | + continue; |
|
| 1708 | + } |
|
| 1637 | 1709 | |
| 1638 | 1710 | if (strpos($file, 'post_tmp_') !== false) |
| 1639 | 1711 | { |
| 1640 | 1712 | // Temp file is more than 5 hours old! |
| 1641 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1642 | - @unlink($attach_dir . '/' . $file); |
|
| 1713 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1714 | + @unlink($attach_dir . '/' . $file); |
|
| 1715 | + } |
|
| 1643 | 1716 | } |
| 1644 | 1717 | } |
| 1645 | 1718 | closedir($dir); |
@@ -1672,8 +1745,9 @@ discard block |
||
| 1672 | 1745 | ) |
| 1673 | 1746 | ); |
| 1674 | 1747 | |
| 1675 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1676 | - $topics[] = $row[0]; |
|
| 1748 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1749 | + $topics[] = $row[0]; |
|
| 1750 | + } |
|
| 1677 | 1751 | $smcFunc['db_free_result']($request); |
| 1678 | 1752 | |
| 1679 | 1753 | // Zap, your gone |
@@ -1693,8 +1767,9 @@ discard block |
||
| 1693 | 1767 | { |
| 1694 | 1768 | global $smcFunc, $sourcedir, $modSettings; |
| 1695 | 1769 | |
| 1696 | - if (empty($modSettings['drafts_keep_days'])) |
|
| 1697 | - return true; |
|
| 1770 | + if (empty($modSettings['drafts_keep_days'])) { |
|
| 1771 | + return true; |
|
| 1772 | + } |
|
| 1698 | 1773 | |
| 1699 | 1774 | // init |
| 1700 | 1775 | $drafts = array(); |
@@ -1712,8 +1787,9 @@ discard block |
||
| 1712 | 1787 | ) |
| 1713 | 1788 | ); |
| 1714 | 1789 | |
| 1715 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1716 | - $drafts[] = (int) $row[0]; |
|
| 1790 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1791 | + $drafts[] = (int) $row[0]; |
|
| 1792 | + } |
|
| 1717 | 1793 | $smcFunc['db_free_result']($request); |
| 1718 | 1794 | |
| 1719 | 1795 | // If we have old one, remove them |
@@ -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 main entrance point for the 'Paid Subscription' screen, calling |
@@ -32,18 +33,19 @@ discard block |
||
| 32 | 33 | loadLanguage('ManagePaid'); |
| 33 | 34 | loadTemplate('ManagePaid'); |
| 34 | 35 | |
| 35 | - if (!empty($modSettings['paid_enabled'])) |
|
| 36 | - $subActions = array( |
|
| 36 | + if (!empty($modSettings['paid_enabled'])) { |
|
| 37 | + $subActions = array( |
|
| 37 | 38 | 'modify' => array('ModifySubscription', 'admin_forum'), |
| 38 | 39 | 'modifyuser' => array('ModifyUserSubscription', 'admin_forum'), |
| 39 | 40 | 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), |
| 40 | 41 | 'view' => array('ViewSubscriptions', 'admin_forum'), |
| 41 | 42 | 'viewsub' => array('ViewSubscribedUsers', 'admin_forum'), |
| 42 | 43 | ); |
| 43 | - else |
|
| 44 | - $subActions = array( |
|
| 44 | + } else { |
|
| 45 | + $subActions = array( |
|
| 45 | 46 | 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), |
| 46 | 47 | ); |
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Default the sub-action to 'view subscriptions', but only if they have already set things up.. |
| 49 | 51 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($modSettings['paid_currency_symbol']) && !empty($modSettings['paid_enabled']) ? 'view' : 'settings'); |
@@ -59,8 +61,8 @@ discard block |
||
| 59 | 61 | 'help' => '', |
| 60 | 62 | 'description' => $txt['paid_subscriptions_desc'], |
| 61 | 63 | ); |
| 62 | - if (!empty($modSettings['paid_enabled'])) |
|
| 63 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 64 | + if (!empty($modSettings['paid_enabled'])) { |
|
| 65 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 64 | 66 | 'view' => array( |
| 65 | 67 | 'description' => $txt['paid_subs_view_desc'], |
| 66 | 68 | ), |
@@ -68,6 +70,7 @@ discard block |
||
| 68 | 70 | 'description' => $txt['paid_subs_settings_desc'], |
| 69 | 71 | ), |
| 70 | 72 | ); |
| 73 | + } |
|
| 71 | 74 | |
| 72 | 75 | call_integration_hook('integrate_manage_subscriptions', array(&$subActions)); |
| 73 | 76 | |
@@ -92,8 +95,9 @@ discard block |
||
| 92 | 95 | { |
| 93 | 96 | // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. |
| 94 | 97 | $modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : ''; |
| 95 | - if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) |
|
| 96 | - $modSettings['paid_currency'] = 'other'; |
|
| 98 | + if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) { |
|
| 99 | + $modSettings['paid_currency'] = 'other'; |
|
| 100 | + } |
|
| 97 | 101 | |
| 98 | 102 | // These are all the default settings. |
| 99 | 103 | $config_vars = array( |
@@ -156,8 +160,7 @@ discard block |
||
| 156 | 160 | } |
| 157 | 161 | } |
| 158 | 162 | toggleOther();', true); |
| 159 | - } |
|
| 160 | - else |
|
| 163 | + } else |
|
| 161 | 164 | { |
| 162 | 165 | $config_vars = array( |
| 163 | 166 | array('check', 'paid_enabled'), |
@@ -166,8 +169,9 @@ discard block |
||
| 166 | 169 | } |
| 167 | 170 | |
| 168 | 171 | // Just searching? |
| 169 | - if ($return_config) |
|
| 170 | - return $config_vars; |
|
| 172 | + if ($return_config) { |
|
| 173 | + return $config_vars; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | // Get the settings template fired up. |
| 173 | 177 | require_once($sourcedir . '/ManageServer.php'); |
@@ -211,8 +215,9 @@ discard block |
||
| 211 | 215 | foreach (explode(',', $_POST['paid_email_to']) as $email) |
| 212 | 216 | { |
| 213 | 217 | $email = trim($email); |
| 214 | - if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 215 | - $email_addresses[] = $email; |
|
| 218 | + if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 219 | + $email_addresses[] = $email; |
|
| 220 | + } |
|
| 216 | 221 | $_POST['paid_email_to'] = implode(',', $email_addresses); |
| 217 | 222 | } |
| 218 | 223 | } |
@@ -249,8 +254,9 @@ discard block |
||
| 249 | 254 | global $context, $txt, $modSettings, $sourcedir, $scripturl; |
| 250 | 255 | |
| 251 | 256 | // Not made the settings yet? |
| 252 | - if (empty($modSettings['paid_currency_symbol'])) |
|
| 253 | - fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); |
|
| 257 | + if (empty($modSettings['paid_currency_symbol'])) { |
|
| 258 | + fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); |
|
| 259 | + } |
|
| 254 | 260 | |
| 255 | 261 | // Some basic stuff. |
| 256 | 262 | $context['page_title'] = $txt['paid_subs_view']; |
@@ -270,10 +276,11 @@ discard block |
||
| 270 | 276 | |
| 271 | 277 | foreach ($context['subscriptions'] as $data) |
| 272 | 278 | { |
| 273 | - if (++$counter < $start) |
|
| 274 | - continue; |
|
| 275 | - elseif ($counter == $start + $items_per_page) |
|
| 276 | - break; |
|
| 279 | + if (++$counter < $start) { |
|
| 280 | + continue; |
|
| 281 | + } elseif ($counter == $start + $items_per_page) { |
|
| 282 | + break; |
|
| 283 | + } |
|
| 277 | 284 | |
| 278 | 285 | $subscriptions[] = $data; |
| 279 | 286 | } |
@@ -450,8 +457,9 @@ discard block |
||
| 450 | 457 | ); |
| 451 | 458 | $id_group = 0; |
| 452 | 459 | $add_groups = ''; |
| 453 | - if ($smcFunc['db_num_rows']($request)) |
|
| 454 | - list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); |
|
| 460 | + if ($smcFunc['db_num_rows']($request)) { |
|
| 461 | + list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); |
|
| 462 | + } |
|
| 455 | 463 | $smcFunc['db_free_result']($request); |
| 456 | 464 | |
| 457 | 465 | $changes = array(); |
@@ -463,8 +471,9 @@ discard block |
||
| 463 | 471 | { |
| 464 | 472 | // If their current primary group isn't what they had before the subscription, and their current group was |
| 465 | 473 | // granted by the sub, remove it. |
| 466 | - if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) |
|
| 467 | - $changes[$id_member]['id_group'] = $member_data['old_id_group']; |
|
| 474 | + if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) { |
|
| 475 | + $changes[$id_member]['id_group'] = $member_data['old_id_group']; |
|
| 476 | + } |
|
| 468 | 477 | } |
| 469 | 478 | } |
| 470 | 479 | |
@@ -477,15 +486,17 @@ discard block |
||
| 477 | 486 | // First let's get their groups sorted. |
| 478 | 487 | $current_groups = explode(',', $member_data['additional_groups']); |
| 479 | 488 | $new_groups = implode(',', array_diff($current_groups, $add_groups)); |
| 480 | - if ($new_groups != $member_data['additional_groups']) |
|
| 481 | - $changes[$id_member]['additional_groups'] = $new_groups; |
|
| 489 | + if ($new_groups != $member_data['additional_groups']) { |
|
| 490 | + $changes[$id_member]['additional_groups'] = $new_groups; |
|
| 491 | + } |
|
| 482 | 492 | } |
| 483 | 493 | } |
| 484 | 494 | |
| 485 | 495 | // We're going through changes... |
| 486 | - if (!empty($changes)) |
|
| 487 | - foreach ($changes as $id_member => $new_values) |
|
| 496 | + if (!empty($changes)) { |
|
| 497 | + foreach ($changes as $id_member => $new_values) |
|
| 488 | 498 | updateMemberData($id_member, $new_values); |
| 499 | + } |
|
| 489 | 500 | } |
| 490 | 501 | |
| 491 | 502 | // Delete the subscription |
@@ -533,11 +544,13 @@ discard block |
||
| 533 | 544 | 'M' => 24, |
| 534 | 545 | 'Y' => 5, |
| 535 | 546 | ); |
| 536 | - if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) |
|
| 537 | - fatal_lang_error('paid_invalid_duration', false); |
|
| 547 | + if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) { |
|
| 548 | + fatal_lang_error('paid_invalid_duration', false); |
|
| 549 | + } |
|
| 538 | 550 | |
| 539 | - if ($_POST['span_value'] > $limits[$_POST['span_unit']]) |
|
| 540 | - fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); |
|
| 551 | + if ($_POST['span_value'] > $limits[$_POST['span_unit']]) { |
|
| 552 | + fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); |
|
| 553 | + } |
|
| 541 | 554 | |
| 542 | 555 | // Clean the span. |
| 543 | 556 | $span = $_POST['span_value'] . $_POST['span_unit']; |
@@ -546,8 +559,9 @@ discard block |
||
| 546 | 559 | $cost = array('fixed' => sprintf('%01.2f', strtr($_POST['cost'], ',', '.'))); |
| 547 | 560 | |
| 548 | 561 | // There needs to be something. |
| 549 | - if (empty($_POST['span_value']) || empty($_POST['cost'])) |
|
| 550 | - fatal_lang_error('paid_no_cost_value'); |
|
| 562 | + if (empty($_POST['span_value']) || empty($_POST['cost'])) { |
|
| 563 | + fatal_lang_error('paid_no_cost_value'); |
|
| 564 | + } |
|
| 551 | 565 | } |
| 552 | 566 | // Flexible is harder but more fun ;) |
| 553 | 567 | else |
@@ -561,8 +575,9 @@ discard block |
||
| 561 | 575 | 'year' => sprintf('%01.2f', strtr($_POST['cost_year'], ',', '.')), |
| 562 | 576 | ); |
| 563 | 577 | |
| 564 | - if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) |
|
| 565 | - fatal_lang_error('paid_all_freq_blank'); |
|
| 578 | + if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) { |
|
| 579 | + fatal_lang_error('paid_all_freq_blank'); |
|
| 580 | + } |
|
| 566 | 581 | } |
| 567 | 582 | $cost = $smcFunc['json_encode']($cost); |
| 568 | 583 | |
@@ -571,9 +586,10 @@ discard block |
||
| 571 | 586 | |
| 572 | 587 | // Yep, time to do additional groups. |
| 573 | 588 | $addgroups = array(); |
| 574 | - if (!empty($_POST['addgroup'])) |
|
| 575 | - foreach ($_POST['addgroup'] as $id => $dummy) |
|
| 589 | + if (!empty($_POST['addgroup'])) { |
|
| 590 | + foreach ($_POST['addgroup'] as $id => $dummy) |
|
| 576 | 591 | $addgroups[] = (int) $id; |
| 592 | + } |
|
| 577 | 593 | $addgroups = implode(',', $addgroups); |
| 578 | 594 | |
| 579 | 595 | // Is it new?! |
@@ -683,18 +699,18 @@ discard block |
||
| 683 | 699 | { |
| 684 | 700 | $span_value = $match[1]; |
| 685 | 701 | $span_unit = $match[2]; |
| 686 | - } |
|
| 687 | - else |
|
| 702 | + } else |
|
| 688 | 703 | { |
| 689 | 704 | $span_value = 0; |
| 690 | 705 | $span_unit = 'D'; |
| 691 | 706 | } |
| 692 | 707 | |
| 693 | 708 | // Is this a flexible one? |
| 694 | - if ($row['length'] == 'F') |
|
| 695 | - $isFlexible = true; |
|
| 696 | - else |
|
| 697 | - $isFlexible = false; |
|
| 709 | + if ($row['length'] == 'F') { |
|
| 710 | + $isFlexible = true; |
|
| 711 | + } else { |
|
| 712 | + $isFlexible = false; |
|
| 713 | + } |
|
| 698 | 714 | |
| 699 | 715 | $context['sub'] = array( |
| 700 | 716 | 'name' => $row['name'], |
@@ -743,8 +759,9 @@ discard block |
||
| 743 | 759 | ) |
| 744 | 760 | ); |
| 745 | 761 | $context['groups'] = array(); |
| 746 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 747 | - $context['groups'][$row['id_group']] = $row['group_name']; |
|
| 762 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 763 | + $context['groups'][$row['id_group']] = $row['group_name']; |
|
| 764 | + } |
|
| 748 | 765 | $smcFunc['db_free_result']($request); |
| 749 | 766 | |
| 750 | 767 | // This always happens. |
@@ -778,8 +795,9 @@ discard block |
||
| 778 | 795 | ) |
| 779 | 796 | ); |
| 780 | 797 | // Something wrong? |
| 781 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 782 | - fatal_lang_error('no_access', false); |
|
| 798 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 799 | + fatal_lang_error('no_access', false); |
|
| 800 | + } |
|
| 783 | 801 | // Do the subscription context. |
| 784 | 802 | $row = $smcFunc['db_fetch_assoc']($request); |
| 785 | 803 | $context['subscription'] = array( |
@@ -1014,8 +1032,8 @@ discard block |
||
| 1014 | 1032 | )) |
| 1015 | 1033 | ); |
| 1016 | 1034 | $subscribers = array(); |
| 1017 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1018 | - $subscribers[] = array( |
|
| 1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1036 | + $subscribers[] = array( |
|
| 1019 | 1037 | 'id' => $row['id_sublog'], |
| 1020 | 1038 | 'id_member' => $row['id_member'], |
| 1021 | 1039 | 'name' => $row['name'], |
@@ -1025,6 +1043,7 @@ discard block |
||
| 1025 | 1043 | 'status' => $row['status'], |
| 1026 | 1044 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] == 0 ? $txt['paid_finished'] : $txt['paid_pending']) : $txt['paid_active'], |
| 1027 | 1045 | ); |
| 1046 | + } |
|
| 1028 | 1047 | $smcFunc['db_free_result']($request); |
| 1029 | 1048 | |
| 1030 | 1049 | return $subscribers; |
@@ -1059,14 +1078,16 @@ discard block |
||
| 1059 | 1078 | 'current_log_item' => $context['log_id'], |
| 1060 | 1079 | ) |
| 1061 | 1080 | ); |
| 1062 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1063 | - fatal_lang_error('no_access', false); |
|
| 1081 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1082 | + fatal_lang_error('no_access', false); |
|
| 1083 | + } |
|
| 1064 | 1084 | list ($context['sub_id']) = $smcFunc['db_fetch_row']($request); |
| 1065 | 1085 | $smcFunc['db_free_result']($request); |
| 1066 | 1086 | } |
| 1067 | 1087 | |
| 1068 | - if (!isset($context['subscriptions'][$context['sub_id']])) |
|
| 1069 | - fatal_lang_error('no_access', false); |
|
| 1088 | + if (!isset($context['subscriptions'][$context['sub_id']])) { |
|
| 1089 | + fatal_lang_error('no_access', false); |
|
| 1090 | + } |
|
| 1070 | 1091 | $context['current_subscription'] = $context['subscriptions'][$context['sub_id']]; |
| 1071 | 1092 | |
| 1072 | 1093 | // Searching? |
@@ -1099,8 +1120,9 @@ discard block |
||
| 1099 | 1120 | 'name' => $_POST['name'], |
| 1100 | 1121 | ) |
| 1101 | 1122 | ); |
| 1102 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1103 | - fatal_lang_error('error_member_not_found'); |
|
| 1123 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1124 | + fatal_lang_error('error_member_not_found'); |
|
| 1125 | + } |
|
| 1104 | 1126 | |
| 1105 | 1127 | list ($id_member, $id_group) = $smcFunc['db_fetch_row']($request); |
| 1106 | 1128 | $smcFunc['db_free_result']($request); |
@@ -1116,14 +1138,15 @@ discard block |
||
| 1116 | 1138 | 'current_member' => $id_member, |
| 1117 | 1139 | ) |
| 1118 | 1140 | ); |
| 1119 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1120 | - fatal_lang_error('member_already_subscribed'); |
|
| 1141 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1142 | + fatal_lang_error('member_already_subscribed'); |
|
| 1143 | + } |
|
| 1121 | 1144 | $smcFunc['db_free_result']($request); |
| 1122 | 1145 | |
| 1123 | 1146 | // Actually put the subscription in place. |
| 1124 | - if ($status == 1) |
|
| 1125 | - addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
|
| 1126 | - else |
|
| 1147 | + if ($status == 1) { |
|
| 1148 | + addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
|
| 1149 | + } else |
|
| 1127 | 1150 | { |
| 1128 | 1151 | $smcFunc['db_insert']('', |
| 1129 | 1152 | '{db_prefix}log_subscribed', |
@@ -1150,20 +1173,20 @@ discard block |
||
| 1150 | 1173 | 'current_log_item' => $context['log_id'], |
| 1151 | 1174 | ) |
| 1152 | 1175 | ); |
| 1153 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1154 | - fatal_lang_error('no_access', false); |
|
| 1176 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1177 | + fatal_lang_error('no_access', false); |
|
| 1178 | + } |
|
| 1155 | 1179 | |
| 1156 | 1180 | list ($id_member, $old_status) = $smcFunc['db_fetch_row']($request); |
| 1157 | 1181 | $smcFunc['db_free_result']($request); |
| 1158 | 1182 | |
| 1159 | 1183 | // Pick the right permission stuff depending on what the status is changing from/to. |
| 1160 | - if ($old_status == 1 && $status != 1) |
|
| 1161 | - removeSubscription($context['sub_id'], $id_member); |
|
| 1162 | - elseif ($status == 1 && $old_status != 1) |
|
| 1184 | + if ($old_status == 1 && $status != 1) { |
|
| 1185 | + removeSubscription($context['sub_id'], $id_member); |
|
| 1186 | + } elseif ($status == 1 && $old_status != 1) |
|
| 1163 | 1187 | { |
| 1164 | 1188 | addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
| 1165 | - } |
|
| 1166 | - else |
|
| 1189 | + } else |
|
| 1167 | 1190 | { |
| 1168 | 1191 | $smcFunc['db_query']('', ' |
| 1169 | 1192 | UPDATE {db_prefix}log_subscribed |
@@ -1191,8 +1214,9 @@ discard block |
||
| 1191 | 1214 | if (!empty($_REQUEST['delsub'])) |
| 1192 | 1215 | { |
| 1193 | 1216 | $toDelete = array(); |
| 1194 | - foreach ($_REQUEST['delsub'] as $id => $dummy) |
|
| 1195 | - $toDelete[] = (int) $id; |
|
| 1217 | + foreach ($_REQUEST['delsub'] as $id => $dummy) { |
|
| 1218 | + $toDelete[] = (int) $id; |
|
| 1219 | + } |
|
| 1196 | 1220 | |
| 1197 | 1221 | $request = $smcFunc['db_query']('', ' |
| 1198 | 1222 | SELECT id_subscribe, id_member |
@@ -1202,8 +1226,9 @@ discard block |
||
| 1202 | 1226 | 'subscription_list' => $toDelete, |
| 1203 | 1227 | ) |
| 1204 | 1228 | ); |
| 1205 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1206 | - removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); |
|
| 1229 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1230 | + removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); |
|
| 1231 | + } |
|
| 1207 | 1232 | $smcFunc['db_free_result']($request); |
| 1208 | 1233 | } |
| 1209 | 1234 | redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']); |
@@ -1247,9 +1272,9 @@ discard block |
||
| 1247 | 1272 | ); |
| 1248 | 1273 | list ($context['sub']['username']) = $smcFunc['db_fetch_row']($request); |
| 1249 | 1274 | $smcFunc['db_free_result']($request); |
| 1275 | + } else { |
|
| 1276 | + $context['sub']['username'] = ''; |
|
| 1250 | 1277 | } |
| 1251 | - else |
|
| 1252 | - $context['sub']['username'] = ''; |
|
| 1253 | 1278 | } |
| 1254 | 1279 | // Otherwise load the existing info. |
| 1255 | 1280 | else |
@@ -1266,8 +1291,9 @@ discard block |
||
| 1266 | 1291 | 'blank_string' => '', |
| 1267 | 1292 | ) |
| 1268 | 1293 | ); |
| 1269 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1270 | - fatal_lang_error('no_access', false); |
|
| 1294 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1295 | + fatal_lang_error('no_access', false); |
|
| 1296 | + } |
|
| 1271 | 1297 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1272 | 1298 | $smcFunc['db_free_result']($request); |
| 1273 | 1299 | |
@@ -1288,13 +1314,13 @@ discard block |
||
| 1288 | 1314 | { |
| 1289 | 1315 | foreach ($costs as $duration => $cost) |
| 1290 | 1316 | { |
| 1291 | - if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) |
|
| 1292 | - $context['pending_payments'][$id] = array( |
|
| 1317 | + if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) { |
|
| 1318 | + $context['pending_payments'][$id] = array( |
|
| 1293 | 1319 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]), |
| 1294 | 1320 | ); |
| 1321 | + } |
|
| 1295 | 1322 | } |
| 1296 | - } |
|
| 1297 | - elseif ($costs['fixed'] == $pending[1]) |
|
| 1323 | + } elseif ($costs['fixed'] == $pending[1]) |
|
| 1298 | 1324 | { |
| 1299 | 1325 | $context['pending_payments'][$id] = array( |
| 1300 | 1326 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $costs['fixed']), |
@@ -1312,8 +1338,9 @@ discard block |
||
| 1312 | 1338 | if ($_GET['pending'] == $id && $pending[3] == 'payback' && isset($context['pending_payments'][$id])) |
| 1313 | 1339 | { |
| 1314 | 1340 | // Flexible? |
| 1315 | - if (isset($_GET['accept'])) |
|
| 1316 | - addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1341 | + if (isset($_GET['accept'])) { |
|
| 1342 | + addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1343 | + } |
|
| 1317 | 1344 | unset($pending_details[$id]); |
| 1318 | 1345 | |
| 1319 | 1346 | $new_details = $smcFunc['json_encode']($pending_details); |
@@ -1375,8 +1402,9 @@ discard block |
||
| 1375 | 1402 | global $smcFunc; |
| 1376 | 1403 | |
| 1377 | 1404 | // Make it an array. |
| 1378 | - if (!is_array($users)) |
|
| 1379 | - $users = array($users); |
|
| 1405 | + if (!is_array($users)) { |
|
| 1406 | + $users = array($users); |
|
| 1407 | + } |
|
| 1380 | 1408 | |
| 1381 | 1409 | // Get all the members current groups. |
| 1382 | 1410 | $groups = array(); |
@@ -1414,14 +1442,16 @@ discard block |
||
| 1414 | 1442 | if ($row['id_group'] != 0) |
| 1415 | 1443 | { |
| 1416 | 1444 | // If this is changing - add the old one to the additional groups so it's not lost. |
| 1417 | - if ($row['id_group'] != $groups[$row['id_member']]['primary']) |
|
| 1418 | - $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; |
|
| 1445 | + if ($row['id_group'] != $groups[$row['id_member']]['primary']) { |
|
| 1446 | + $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; |
|
| 1447 | + } |
|
| 1419 | 1448 | $groups[$row['id_member']]['primary'] = $row['id_group']; |
| 1420 | 1449 | } |
| 1421 | 1450 | |
| 1422 | 1451 | // Additional groups. |
| 1423 | - if (!empty($row['add_groups'])) |
|
| 1424 | - $groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); |
|
| 1452 | + if (!empty($row['add_groups'])) { |
|
| 1453 | + $groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); |
|
| 1454 | + } |
|
| 1425 | 1455 | } |
| 1426 | 1456 | $smcFunc['db_free_result']($request); |
| 1427 | 1457 | |
@@ -1429,9 +1459,10 @@ discard block |
||
| 1429 | 1459 | foreach ($groups as $id => $group) |
| 1430 | 1460 | { |
| 1431 | 1461 | $group['additional'] = array_unique($group['additional']); |
| 1432 | - foreach ($group['additional'] as $key => $value) |
|
| 1433 | - if (empty($value)) |
|
| 1462 | + foreach ($group['additional'] as $key => $value) { |
|
| 1463 | + if (empty($value)) |
|
| 1434 | 1464 | unset($group['additional'][$key]); |
| 1465 | + } |
|
| 1435 | 1466 | $addgroups = implode(',', $group['additional']); |
| 1436 | 1467 | |
| 1437 | 1468 | $smcFunc['db_query']('', ' |
@@ -1465,8 +1496,9 @@ discard block |
||
| 1465 | 1496 | loadSubscriptions(); |
| 1466 | 1497 | |
| 1467 | 1498 | // Exists, yes? |
| 1468 | - if (!isset($context['subscriptions'][$id_subscribe])) |
|
| 1469 | - return; |
|
| 1499 | + if (!isset($context['subscriptions'][$id_subscribe])) { |
|
| 1500 | + return; |
|
| 1501 | + } |
|
| 1470 | 1502 | |
| 1471 | 1503 | $curSub = $context['subscriptions'][$id_subscribe]; |
| 1472 | 1504 | |
@@ -1514,16 +1546,19 @@ discard block |
||
| 1514 | 1546 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); |
| 1515 | 1547 | |
| 1516 | 1548 | // If this has already expired but is active, extension means the period from now. |
| 1517 | - if ($endtime < time()) |
|
| 1518 | - $endtime = time(); |
|
| 1519 | - if ($starttime == 0) |
|
| 1520 | - $starttime = time(); |
|
| 1549 | + if ($endtime < time()) { |
|
| 1550 | + $endtime = time(); |
|
| 1551 | + } |
|
| 1552 | + if ($starttime == 0) { |
|
| 1553 | + $starttime = time(); |
|
| 1554 | + } |
|
| 1521 | 1555 | |
| 1522 | 1556 | // Work out the new expiry date. |
| 1523 | 1557 | $endtime += $duration; |
| 1524 | 1558 | |
| 1525 | - if ($forceEndTime != 0) |
|
| 1526 | - $endtime = $forceEndTime; |
|
| 1559 | + if ($forceEndTime != 0) { |
|
| 1560 | + $endtime = $forceEndTime; |
|
| 1561 | + } |
|
| 1527 | 1562 | |
| 1528 | 1563 | // As everything else should be good, just update! |
| 1529 | 1564 | $smcFunc['db_query']('', ' |
@@ -1553,8 +1588,9 @@ discard block |
||
| 1553 | 1588 | ); |
| 1554 | 1589 | |
| 1555 | 1590 | // Just in case the member doesn't exist. |
| 1556 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1557 | - return; |
|
| 1591 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1592 | + return; |
|
| 1593 | + } |
|
| 1558 | 1594 | |
| 1559 | 1595 | list ($old_id_group, $additional_groups) = $smcFunc['db_fetch_row']($request); |
| 1560 | 1596 | $smcFunc['db_free_result']($request); |
@@ -1571,16 +1607,18 @@ discard block |
||
| 1571 | 1607 | $id_group = $curSub['prim_group']; |
| 1572 | 1608 | |
| 1573 | 1609 | // Ensure their old privileges are maintained. |
| 1574 | - if ($old_id_group != 0) |
|
| 1575 | - $newAddGroups[] = $old_id_group; |
|
| 1610 | + if ($old_id_group != 0) { |
|
| 1611 | + $newAddGroups[] = $old_id_group; |
|
| 1612 | + } |
|
| 1613 | + } else { |
|
| 1614 | + $id_group = $old_id_group; |
|
| 1576 | 1615 | } |
| 1577 | - else |
|
| 1578 | - $id_group = $old_id_group; |
|
| 1579 | 1616 | |
| 1580 | 1617 | // Yep, make sure it's unique, and no empties. |
| 1581 | - foreach ($newAddGroups as $k => $v) |
|
| 1582 | - if (empty($v)) |
|
| 1618 | + foreach ($newAddGroups as $k => $v) { |
|
| 1619 | + if (empty($v)) |
|
| 1583 | 1620 | unset($newAddGroups[$k]); |
| 1621 | + } |
|
| 1584 | 1622 | $newAddGroups = array_unique($newAddGroups); |
| 1585 | 1623 | $newAddGroups = implode(',', $newAddGroups); |
| 1586 | 1624 | |
@@ -1616,16 +1654,19 @@ discard block |
||
| 1616 | 1654 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); |
| 1617 | 1655 | |
| 1618 | 1656 | // If this has already expired but is active, extension means the period from now. |
| 1619 | - if ($endtime < time()) |
|
| 1620 | - $endtime = time(); |
|
| 1621 | - if ($starttime == 0) |
|
| 1622 | - $starttime = time(); |
|
| 1657 | + if ($endtime < time()) { |
|
| 1658 | + $endtime = time(); |
|
| 1659 | + } |
|
| 1660 | + if ($starttime == 0) { |
|
| 1661 | + $starttime = time(); |
|
| 1662 | + } |
|
| 1623 | 1663 | |
| 1624 | 1664 | // Work out the new expiry date. |
| 1625 | 1665 | $endtime += $duration; |
| 1626 | 1666 | |
| 1627 | - if ($forceEndTime != 0) |
|
| 1628 | - $endtime = $forceEndTime; |
|
| 1667 | + if ($forceEndTime != 0) { |
|
| 1668 | + $endtime = $forceEndTime; |
|
| 1669 | + } |
|
| 1629 | 1670 | |
| 1630 | 1671 | // As everything else should be good, just update! |
| 1631 | 1672 | $smcFunc['db_query']('', ' |
@@ -1648,13 +1689,15 @@ discard block |
||
| 1648 | 1689 | |
| 1649 | 1690 | // Otherwise a very simple insert. |
| 1650 | 1691 | $endtime = time() + $duration; |
| 1651 | - if ($forceEndTime != 0) |
|
| 1652 | - $endtime = $forceEndTime; |
|
| 1692 | + if ($forceEndTime != 0) { |
|
| 1693 | + $endtime = $forceEndTime; |
|
| 1694 | + } |
|
| 1653 | 1695 | |
| 1654 | - if ($forceStartTime == 0) |
|
| 1655 | - $starttime = time(); |
|
| 1656 | - else |
|
| 1657 | - $starttime = $forceStartTime; |
|
| 1696 | + if ($forceStartTime == 0) { |
|
| 1697 | + $starttime = time(); |
|
| 1698 | + } else { |
|
| 1699 | + $starttime = $forceStartTime; |
|
| 1700 | + } |
|
| 1658 | 1701 | |
| 1659 | 1702 | $smcFunc['db_insert']('', |
| 1660 | 1703 | '{db_prefix}log_subscribed', |
@@ -1727,15 +1770,17 @@ discard block |
||
| 1727 | 1770 | $new_id_group = -1; |
| 1728 | 1771 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1729 | 1772 | { |
| 1730 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1731 | - continue; |
|
| 1773 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1774 | + continue; |
|
| 1775 | + } |
|
| 1732 | 1776 | |
| 1733 | 1777 | // The one we're removing? |
| 1734 | 1778 | if ($row['id_subscribe'] == $id_subscribe) |
| 1735 | 1779 | { |
| 1736 | 1780 | $removals = explode(',', $context['subscriptions'][$row['id_subscribe']]['add_groups']); |
| 1737 | - if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) |
|
| 1738 | - $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; |
|
| 1781 | + if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) { |
|
| 1782 | + $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; |
|
| 1783 | + } |
|
| 1739 | 1784 | $old_id_group = $row['old_id_group']; |
| 1740 | 1785 | } |
| 1741 | 1786 | // Otherwise things we allow. |
@@ -1753,30 +1798,33 @@ discard block |
||
| 1753 | 1798 | |
| 1754 | 1799 | // Now, for everything we are removing check they definitely are not allowed it. |
| 1755 | 1800 | $existingGroups = explode(',', $additional_groups); |
| 1756 | - foreach ($existingGroups as $key => $group) |
|
| 1757 | - if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) |
|
| 1801 | + foreach ($existingGroups as $key => $group) { |
|
| 1802 | + if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) |
|
| 1758 | 1803 | unset($existingGroups[$key]); |
| 1804 | + } |
|
| 1759 | 1805 | |
| 1760 | 1806 | // Finally, do something with the current primary group. |
| 1761 | 1807 | if (in_array($id_group, $removals)) |
| 1762 | 1808 | { |
| 1763 | 1809 | // If this primary group is actually allowed keep it. |
| 1764 | - if (in_array($id_group, $allowed)) |
|
| 1765 | - $existingGroups[] = $id_group; |
|
| 1810 | + if (in_array($id_group, $allowed)) { |
|
| 1811 | + $existingGroups[] = $id_group; |
|
| 1812 | + } |
|
| 1766 | 1813 | |
| 1767 | 1814 | // Either way, change the id_group back. |
| 1768 | 1815 | if ($new_id_group < 1) |
| 1769 | 1816 | { |
| 1770 | 1817 | // If we revert to the old id-group we need to ensure it wasn't from a subscription. |
| 1771 | - foreach ($context['subscriptions'] as $id => $group) |
|
| 1772 | - // It was? Make them a regular member then! |
|
| 1818 | + foreach ($context['subscriptions'] as $id => $group) { |
|
| 1819 | + // It was? Make them a regular member then! |
|
| 1773 | 1820 | if ($group['prim_group'] == $old_id_group) |
| 1774 | 1821 | $old_id_group = 0; |
| 1822 | + } |
|
| 1775 | 1823 | |
| 1776 | 1824 | $id_group = $old_id_group; |
| 1825 | + } else { |
|
| 1826 | + $id_group = $new_id_group; |
|
| 1777 | 1827 | } |
| 1778 | - else |
|
| 1779 | - $id_group = $new_id_group; |
|
| 1780 | 1828 | } |
| 1781 | 1829 | |
| 1782 | 1830 | // Crazy stuff, we seem to have our groups fixed, just make them unique |
@@ -1796,8 +1844,8 @@ discard block |
||
| 1796 | 1844 | ); |
| 1797 | 1845 | |
| 1798 | 1846 | // Disable the subscription. |
| 1799 | - if (!$delete) |
|
| 1800 | - $smcFunc['db_query']('', ' |
|
| 1847 | + if (!$delete) { |
|
| 1848 | + $smcFunc['db_query']('', ' |
|
| 1801 | 1849 | UPDATE {db_prefix}log_subscribed |
| 1802 | 1850 | SET status = {int:not_active} |
| 1803 | 1851 | WHERE id_member = {int:current_member} |
@@ -1808,9 +1856,10 @@ discard block |
||
| 1808 | 1856 | 'current_subscription' => $id_subscribe, |
| 1809 | 1857 | ) |
| 1810 | 1858 | ); |
| 1859 | + } |
|
| 1811 | 1860 | // Otherwise delete it! |
| 1812 | - else |
|
| 1813 | - $smcFunc['db_query']('', ' |
|
| 1861 | + else { |
|
| 1862 | + $smcFunc['db_query']('', ' |
|
| 1814 | 1863 | DELETE FROM {db_prefix}log_subscribed |
| 1815 | 1864 | WHERE id_member = {int:current_member} |
| 1816 | 1865 | AND id_subscribe = {int:current_subscription}', |
@@ -1819,7 +1868,8 @@ discard block |
||
| 1819 | 1868 | 'current_subscription' => $id_subscribe, |
| 1820 | 1869 | ) |
| 1821 | 1870 | ); |
| 1822 | -} |
|
| 1871 | + } |
|
| 1872 | + } |
|
| 1823 | 1873 | |
| 1824 | 1874 | /** |
| 1825 | 1875 | * This just kind of caches all the subscription data. |
@@ -1828,8 +1878,9 @@ discard block |
||
| 1828 | 1878 | { |
| 1829 | 1879 | global $context, $txt, $modSettings, $smcFunc; |
| 1830 | 1880 | |
| 1831 | - if (!empty($context['subscriptions'])) |
|
| 1832 | - return; |
|
| 1881 | + if (!empty($context['subscriptions'])) { |
|
| 1882 | + return; |
|
| 1883 | + } |
|
| 1833 | 1884 | |
| 1834 | 1885 | // Make sure this is loaded, just in case. |
| 1835 | 1886 | loadLanguage('ManagePaid'); |
@@ -1846,10 +1897,11 @@ discard block |
||
| 1846 | 1897 | // Pick a cost. |
| 1847 | 1898 | $costs = $smcFunc['json_decode']($row['cost'], true); |
| 1848 | 1899 | |
| 1849 | - if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) |
|
| 1850 | - $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); |
|
| 1851 | - else |
|
| 1852 | - $cost = '???'; |
|
| 1900 | + if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) { |
|
| 1901 | + $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); |
|
| 1902 | + } else { |
|
| 1903 | + $cost = '???'; |
|
| 1904 | + } |
|
| 1853 | 1905 | |
| 1854 | 1906 | // Do the span. |
| 1855 | 1907 | preg_match('~(\d*)(\w)~', $row['length'], $match); |
@@ -1876,9 +1928,9 @@ discard block |
||
| 1876 | 1928 | $num_length *= 31556926; |
| 1877 | 1929 | break; |
| 1878 | 1930 | } |
| 1931 | + } else { |
|
| 1932 | + $length = '??'; |
|
| 1879 | 1933 | } |
| 1880 | - else |
|
| 1881 | - $length = '??'; |
|
| 1882 | 1934 | |
| 1883 | 1935 | $context['subscriptions'][$row['id_subscribe']] = array( |
| 1884 | 1936 | 'id' => $row['id_subscribe'], |
@@ -1913,8 +1965,9 @@ discard block |
||
| 1913 | 1965 | { |
| 1914 | 1966 | $ind = $row['status'] == 0 ? 'finished' : 'total'; |
| 1915 | 1967 | |
| 1916 | - if (isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1917 | - $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; |
|
| 1968 | + if (isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1969 | + $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; |
|
| 1970 | + } |
|
| 1918 | 1971 | } |
| 1919 | 1972 | $smcFunc['db_free_result']($request); |
| 1920 | 1973 | |
@@ -1928,8 +1981,9 @@ discard block |
||
| 1928 | 1981 | ); |
| 1929 | 1982 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1930 | 1983 | { |
| 1931 | - if (isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1932 | - $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; |
|
| 1984 | + if (isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1985 | + $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; |
|
| 1986 | + } |
|
| 1933 | 1987 | } |
| 1934 | 1988 | $smcFunc['db_free_result']($request); |
| 1935 | 1989 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | class EventNew_Notify_Background extends SMF_BackgroundTask |
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 24 | 24 | * @return bool Always returns true |
| 25 | 25 | */ |
| 26 | 26 | public function execute() |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | 'content_action' => empty($this->_details['sender_id']) ? 'new_guest' : 'new', |
| 82 | 82 | 'is_read' => 0, |
| 83 | 83 | 'extra' => $smcFunc['json_encode']( |
| 84 | - array( |
|
| 85 | - "event_id" => $this->_details['event_id'], |
|
| 84 | + array( |
|
| 85 | + "event_id" => $this->_details['event_id'], |
|
| 86 | 86 | "event_title" => $this->_details['event_title'] |
| 87 | 87 | ) |
| 88 | 88 | ), |
@@ -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 | * Entry point for this section. |
@@ -38,8 +39,7 @@ discard block |
||
| 38 | 39 | 'stats' => 'SpiderStats', |
| 39 | 40 | ); |
| 40 | 41 | $default = 'stats'; |
| 41 | - } |
|
| 42 | - else |
|
| 42 | + } else |
|
| 43 | 43 | { |
| 44 | 44 | $subActions = array( |
| 45 | 45 | 'settings' => 'ManageSearchEngineSettings', |
@@ -90,11 +90,12 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | disabledState = document.getElementById(\'spider_mode\').value == 0;'; |
| 92 | 92 | |
| 93 | - foreach ($config_vars as $variable) |
|
| 94 | - if ($variable[1] != 'spider_mode') |
|
| 93 | + foreach ($config_vars as $variable) { |
|
| 94 | + if ($variable[1] != 'spider_mode') |
|
| 95 | 95 | $javascript_function .= ' |
| 96 | 96 | if (document.getElementById(\'' . $variable[1] . '\')) |
| 97 | 97 | document.getElementById(\'' . $variable[1] . '\').disabled = disabledState;'; |
| 98 | + } |
|
| 98 | 99 | |
| 99 | 100 | $javascript_function .= ' |
| 100 | 101 | } |
@@ -102,8 +103,9 @@ discard block |
||
| 102 | 103 | |
| 103 | 104 | call_integration_hook('integrate_modify_search_engine_settings', array(&$config_vars)); |
| 104 | 105 | |
| 105 | - if ($return_config) |
|
| 106 | - return $config_vars; |
|
| 106 | + if ($return_config) { |
|
| 107 | + return $config_vars; |
|
| 108 | + } |
|
| 107 | 109 | |
| 108 | 110 | // We need to load the groups for the spider group thingy. |
| 109 | 111 | $request = $smcFunc['db_query']('', ' |
@@ -116,13 +118,15 @@ discard block |
||
| 116 | 118 | 'moderator_group' => 3, |
| 117 | 119 | ) |
| 118 | 120 | ); |
| 119 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 120 | - $config_vars['spider_group'][2][$row['id_group']] = $row['group_name']; |
|
| 121 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 122 | + $config_vars['spider_group'][2][$row['id_group']] = $row['group_name']; |
|
| 123 | + } |
|
| 121 | 124 | $smcFunc['db_free_result']($request); |
| 122 | 125 | |
| 123 | 126 | // Make sure it's valid - note that regular members are given id_group = 1 which is reversed in Load.php - no admins here! |
| 124 | - if (isset($_POST['spider_group']) && !isset($config_vars['spider_group'][2][$_POST['spider_group']])) |
|
| 125 | - $_POST['spider_group'] = 0; |
|
| 127 | + if (isset($_POST['spider_group']) && !isset($config_vars['spider_group'][2][$_POST['spider_group']])) { |
|
| 128 | + $_POST['spider_group'] = 0; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | // We'll want this for our easy save. |
| 128 | 132 | require_once($sourcedir . '/ManageServer.php'); |
@@ -166,8 +170,9 @@ discard block |
||
| 166 | 170 | } |
| 167 | 171 | |
| 168 | 172 | // Are we adding a new one? |
| 169 | - if (!empty($_POST['addSpider'])) |
|
| 170 | - return EditSpider(); |
|
| 173 | + if (!empty($_POST['addSpider'])) { |
|
| 174 | + return EditSpider(); |
|
| 175 | + } |
|
| 171 | 176 | // User pressed the 'remove selection button'. |
| 172 | 177 | elseif (!empty($_POST['removeSpiders']) && !empty($_POST['remove']) && is_array($_POST['remove'])) |
| 173 | 178 | { |
@@ -175,8 +180,9 @@ discard block |
||
| 175 | 180 | validateToken('admin-ser'); |
| 176 | 181 | |
| 177 | 182 | // Make sure every entry is a proper integer. |
| 178 | - foreach ($_POST['remove'] as $index => $spider_id) |
|
| 179 | - $_POST['remove'][(int) $index] = (int) $spider_id; |
|
| 183 | + foreach ($_POST['remove'] as $index => $spider_id) { |
|
| 184 | + $_POST['remove'][(int) $index] = (int) $spider_id; |
|
| 185 | + } |
|
| 180 | 186 | |
| 181 | 187 | // Delete them all! |
| 182 | 188 | $smcFunc['db_query']('', ' |
@@ -215,8 +221,9 @@ discard block |
||
| 215 | 221 | ); |
| 216 | 222 | |
| 217 | 223 | $context['spider_last_seen'] = array(); |
| 218 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 219 | - $context['spider_last_seen'][$row['id_spider']] = $row['last_seen_time']; |
|
| 224 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 225 | + $context['spider_last_seen'][$row['id_spider']] = $row['last_seen_time']; |
|
| 226 | + } |
|
| 220 | 227 | $smcFunc['db_free_result']($request); |
| 221 | 228 | |
| 222 | 229 | createToken('admin-ser'); |
@@ -346,8 +353,9 @@ discard block |
||
| 346 | 353 | ) |
| 347 | 354 | ); |
| 348 | 355 | $spiders = array(); |
| 349 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 350 | - $spiders[$row['id_spider']] = $row; |
|
| 356 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 357 | + $spiders[$row['id_spider']] = $row; |
|
| 358 | + } |
|
| 351 | 359 | $smcFunc['db_free_result']($request); |
| 352 | 360 | |
| 353 | 361 | return $spiders; |
@@ -397,14 +405,15 @@ discard block |
||
| 397 | 405 | foreach ($ip_sets as $set) |
| 398 | 406 | { |
| 399 | 407 | $test = ip2range(trim($set)); |
| 400 | - if (!empty($test)) |
|
| 401 | - $ips[] = $set; |
|
| 408 | + if (!empty($test)) { |
|
| 409 | + $ips[] = $set; |
|
| 410 | + } |
|
| 402 | 411 | } |
| 403 | 412 | $ips = implode(',', $ips); |
| 404 | 413 | |
| 405 | 414 | // Goes in as it is... |
| 406 | - if ($context['id_spider']) |
|
| 407 | - $smcFunc['db_query']('', ' |
|
| 415 | + if ($context['id_spider']) { |
|
| 416 | + $smcFunc['db_query']('', ' |
|
| 408 | 417 | UPDATE {db_prefix}spiders |
| 409 | 418 | SET spider_name = {string:spider_name}, user_agent = {string:spider_agent}, |
| 410 | 419 | ip_info = {string:ip_info} |
@@ -416,8 +425,8 @@ discard block |
||
| 416 | 425 | 'ip_info' => $ips, |
| 417 | 426 | ) |
| 418 | 427 | ); |
| 419 | - else |
|
| 420 | - $smcFunc['db_insert']('insert', |
|
| 428 | + } else { |
|
| 429 | + $smcFunc['db_insert']('insert', |
|
| 421 | 430 | '{db_prefix}spiders', |
| 422 | 431 | array( |
| 423 | 432 | 'spider_name' => 'string', 'user_agent' => 'string', 'ip_info' => 'string', |
@@ -427,6 +436,7 @@ discard block |
||
| 427 | 436 | ), |
| 428 | 437 | array('id_spider') |
| 429 | 438 | ); |
| 439 | + } |
|
| 430 | 440 | |
| 431 | 441 | |
| 432 | 442 | cache_put_data('spider_search', null); |
@@ -454,13 +464,14 @@ discard block |
||
| 454 | 464 | 'current_spider' => $context['id_spider'], |
| 455 | 465 | ) |
| 456 | 466 | ); |
| 457 | - if ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 458 | - $context['spider'] = array( |
|
| 467 | + if ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 468 | + $context['spider'] = array( |
|
| 459 | 469 | 'id' => $row['id_spider'], |
| 460 | 470 | 'name' => $row['spider_name'], |
| 461 | 471 | 'agent' => $row['user_agent'], |
| 462 | 472 | 'ip_info' => $row['ip_info'], |
| 463 | 473 | ); |
| 474 | + } |
|
| 464 | 475 | $smcFunc['db_free_result']($request); |
| 465 | 476 | } |
| 466 | 477 | |
@@ -477,8 +488,9 @@ discard block |
||
| 477 | 488 | { |
| 478 | 489 | global $modSettings, $smcFunc; |
| 479 | 490 | |
| 480 | - if (isset($_SESSION['id_robot'])) |
|
| 481 | - unset($_SESSION['id_robot']); |
|
| 491 | + if (isset($_SESSION['id_robot'])) { |
|
| 492 | + unset($_SESSION['id_robot']); |
|
| 493 | + } |
|
| 482 | 494 | $_SESSION['robot_check'] = time(); |
| 483 | 495 | |
| 484 | 496 | // We cache the spider data for ten minutes if we can. |
@@ -492,15 +504,17 @@ discard block |
||
| 492 | 504 | ) |
| 493 | 505 | ); |
| 494 | 506 | $spider_data = array(); |
| 495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 496 | - $spider_data[] = $row; |
|
| 507 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 508 | + $spider_data[] = $row; |
|
| 509 | + } |
|
| 497 | 510 | $smcFunc['db_free_result']($request); |
| 498 | 511 | |
| 499 | 512 | cache_put_data('spider_search', $spider_data, 600); |
| 500 | 513 | } |
| 501 | 514 | |
| 502 | - if (empty($spider_data)) |
|
| 503 | - return false; |
|
| 515 | + if (empty($spider_data)) { |
|
| 516 | + return false; |
|
| 517 | + } |
|
| 504 | 518 | |
| 505 | 519 | // Only do these bits once. |
| 506 | 520 | $ci_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); |
@@ -508,33 +522,38 @@ discard block |
||
| 508 | 522 | foreach ($spider_data as $spider) |
| 509 | 523 | { |
| 510 | 524 | // User agent is easy. |
| 511 | - if (!empty($spider['user_agent']) && strpos($ci_user_agent, strtolower($spider['user_agent'])) !== false) |
|
| 512 | - $_SESSION['id_robot'] = $spider['id_spider']; |
|
| 525 | + if (!empty($spider['user_agent']) && strpos($ci_user_agent, strtolower($spider['user_agent'])) !== false) { |
|
| 526 | + $_SESSION['id_robot'] = $spider['id_spider']; |
|
| 527 | + } |
|
| 513 | 528 | // IP stuff is harder. |
| 514 | 529 | elseif ($_SERVER['REMOTE_ADDR']) |
| 515 | 530 | { |
| 516 | 531 | $ips = explode(',', $spider['ip_info']); |
| 517 | 532 | foreach ($ips as $ip) |
| 518 | 533 | { |
| 519 | - if ($ip === '') |
|
| 520 | - continue; |
|
| 534 | + if ($ip === '') { |
|
| 535 | + continue; |
|
| 536 | + } |
|
| 521 | 537 | |
| 522 | 538 | $ip = ip2range($ip); |
| 523 | 539 | if (!empty($ip)) |
| 524 | 540 | { |
| 525 | - if (inet_ptod($ip['low']) <= inet_ptod($_SERVER['REMOTE_ADDR']) && inet_ptod($ip['high']) >= inet_ptod($_SERVER['REMOTE_ADDR'])) |
|
| 526 | - $_SESSION['id_robot'] = $spider['id_spider']; |
|
| 541 | + if (inet_ptod($ip['low']) <= inet_ptod($_SERVER['REMOTE_ADDR']) && inet_ptod($ip['high']) >= inet_ptod($_SERVER['REMOTE_ADDR'])) { |
|
| 542 | + $_SESSION['id_robot'] = $spider['id_spider']; |
|
| 543 | + } |
|
| 527 | 544 | } |
| 528 | 545 | } |
| 529 | 546 | } |
| 530 | 547 | |
| 531 | - if (isset($_SESSION['id_robot'])) |
|
| 532 | - break; |
|
| 548 | + if (isset($_SESSION['id_robot'])) { |
|
| 549 | + break; |
|
| 550 | + } |
|
| 533 | 551 | } |
| 534 | 552 | |
| 535 | 553 | // If this is low server tracking then log the spider here as opposed to the main logging function. |
| 536 | - if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] == 1 && !empty($_SESSION['id_robot'])) |
|
| 537 | - logSpider(); |
|
| 554 | + if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] == 1 && !empty($_SESSION['id_robot'])) { |
|
| 555 | + logSpider(); |
|
| 556 | + } |
|
| 538 | 557 | |
| 539 | 558 | return !empty($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
| 540 | 559 | } |
@@ -548,8 +567,9 @@ discard block |
||
| 548 | 567 | { |
| 549 | 568 | global $smcFunc, $modSettings, $context; |
| 550 | 569 | |
| 551 | - if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot'])) |
|
| 552 | - return; |
|
| 570 | + if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot'])) { |
|
| 571 | + return; |
|
| 572 | + } |
|
| 553 | 573 | |
| 554 | 574 | // Attempt to update today's entry. |
| 555 | 575 | if ($modSettings['spider_mode'] == 1) |
@@ -590,9 +610,9 @@ discard block |
||
| 590 | 610 | $url = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 591 | 611 | unset($url['sesc'], $url[$context['session_var']]); |
| 592 | 612 | $url = $smcFunc['json_encode']($url); |
| 613 | + } else { |
|
| 614 | + $url = ''; |
|
| 593 | 615 | } |
| 594 | - else |
|
| 595 | - $url = ''; |
|
| 596 | 616 | |
| 597 | 617 | $smcFunc['db_insert']('insert', |
| 598 | 618 | '{db_prefix}log_spider_hits', |
@@ -620,12 +640,14 @@ discard block |
||
| 620 | 640 | ) |
| 621 | 641 | ); |
| 622 | 642 | $spider_hits = array(); |
| 623 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 624 | - $spider_hits[] = $row; |
|
| 643 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 644 | + $spider_hits[] = $row; |
|
| 645 | + } |
|
| 625 | 646 | $smcFunc['db_free_result']($request); |
| 626 | 647 | |
| 627 | - if (empty($spider_hits)) |
|
| 628 | - return; |
|
| 648 | + if (empty($spider_hits)) { |
|
| 649 | + return; |
|
| 650 | + } |
|
| 629 | 651 | |
| 630 | 652 | // Attempt to update the master data. |
| 631 | 653 | $stat_inserts = array(); |
@@ -646,18 +668,20 @@ discard block |
||
| 646 | 668 | 'hits' => $stat['num_hits'], |
| 647 | 669 | ) |
| 648 | 670 | ); |
| 649 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 650 | - $stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']); |
|
| 671 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 672 | + $stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']); |
|
| 673 | + } |
|
| 651 | 674 | } |
| 652 | 675 | |
| 653 | 676 | // New stats? |
| 654 | - if (!empty($stat_inserts)) |
|
| 655 | - $smcFunc['db_insert']('ignore', |
|
| 677 | + if (!empty($stat_inserts)) { |
|
| 678 | + $smcFunc['db_insert']('ignore', |
|
| 656 | 679 | '{db_prefix}log_spider_stats', |
| 657 | 680 | array('stat_date' => 'date', 'id_spider' => 'int', 'page_hits' => 'int', 'last_seen' => 'int'), |
| 658 | 681 | $stat_inserts, |
| 659 | 682 | array('stat_date', 'id_spider') |
| 660 | 683 | ); |
| 684 | + } |
|
| 661 | 685 | |
| 662 | 686 | // All processed. |
| 663 | 687 | $smcFunc['db_query']('', ' |
@@ -700,8 +724,7 @@ discard block |
||
| 700 | 724 | 'delete_period' => $deleteTime, |
| 701 | 725 | ) |
| 702 | 726 | ); |
| 703 | - } |
|
| 704 | - else |
|
| 727 | + } else |
|
| 705 | 728 | { |
| 706 | 729 | // Deleting all of them |
| 707 | 730 | $smcFunc['db_query']('', ' |
@@ -791,10 +814,11 @@ discard block |
||
| 791 | 814 | foreach ($context['spider_logs']['rows'] as $k => $row) |
| 792 | 815 | { |
| 793 | 816 | // Feature disabled? |
| 794 | - if (empty($row['data']['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) |
|
| 795 | - $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>'; |
|
| 796 | - else |
|
| 797 | - $urls[$k] = array($row['data']['viewing']['value'], -1); |
|
| 817 | + if (empty($row['data']['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) { |
|
| 818 | + $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>'; |
|
| 819 | + } else { |
|
| 820 | + $urls[$k] = array($row['data']['viewing']['value'], -1); |
|
| 821 | + } |
|
| 798 | 822 | } |
| 799 | 823 | |
| 800 | 824 | // Now stick in the new URLs. |
@@ -836,8 +860,9 @@ discard block |
||
| 836 | 860 | ) |
| 837 | 861 | ); |
| 838 | 862 | $spider_logs = array(); |
| 839 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 840 | - $spider_logs[] = $row; |
|
| 863 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 864 | + $spider_logs[] = $row; |
|
| 865 | + } |
|
| 841 | 866 | $smcFunc['db_free_result']($request); |
| 842 | 867 | |
| 843 | 868 | return $spider_logs; |
@@ -913,14 +938,18 @@ discard block |
||
| 913 | 938 | |
| 914 | 939 | // Prepare the dates for the drop down. |
| 915 | 940 | $date_choices = array(); |
| 916 | - for ($y = $min_year; $y <= $max_year; $y++) |
|
| 917 | - for ($m = 1; $m <= 12; $m++) |
|
| 941 | + for ($y = $min_year; $y <= $max_year; $y++) { |
|
| 942 | + for ($m = 1; |
|
| 943 | + } |
|
| 944 | + $m <= 12; $m++) |
|
| 918 | 945 | { |
| 919 | 946 | // This doesn't count? |
| 920 | - if ($y == $min_year && $m < $min_month) |
|
| 921 | - continue; |
|
| 922 | - if ($y == $max_year && $m > $max_month) |
|
| 923 | - break; |
|
| 947 | + if ($y == $min_year && $m < $min_month) { |
|
| 948 | + continue; |
|
| 949 | + } |
|
| 950 | + if ($y == $max_year && $m > $max_month) { |
|
| 951 | + break; |
|
| 952 | + } |
|
| 924 | 953 | |
| 925 | 954 | $date_choices[$y . $m] = $txt['months_short'][$m] . ' ' . $y; |
| 926 | 955 | } |
@@ -933,13 +962,14 @@ discard block |
||
| 933 | 962 | ' . $txt['spider_stats_select_month'] . ': |
| 934 | 963 | <select name="new_date" onchange="document.spider_stat_list.submit();">'; |
| 935 | 964 | |
| 936 | - if (empty($date_choices)) |
|
| 937 | - $date_select .= ' |
|
| 965 | + if (empty($date_choices)) { |
|
| 966 | + $date_select .= ' |
|
| 938 | 967 | <option></option>'; |
| 939 | - else |
|
| 940 | - foreach ($date_choices as $id => $text) |
|
| 968 | + } else { |
|
| 969 | + foreach ($date_choices as $id => $text) |
|
| 941 | 970 | $date_select .= ' |
| 942 | 971 | <option value="' . $id . '"' . ($current_date == $id ? ' selected' : '') . '>' . $text . '</option>'; |
| 972 | + } |
|
| 943 | 973 | |
| 944 | 974 | $date_select .= ' |
| 945 | 975 | </select> |
@@ -1063,8 +1093,9 @@ discard block |
||
| 1063 | 1093 | ) |
| 1064 | 1094 | ); |
| 1065 | 1095 | $spider_stats = array(); |
| 1066 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1067 | - $spider_stats[] = $row; |
|
| 1096 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1097 | + $spider_stats[] = $row; |
|
| 1098 | + } |
|
| 1068 | 1099 | $smcFunc['db_free_result']($request); |
| 1069 | 1100 | |
| 1070 | 1101 | return $spider_stats; |
@@ -1105,8 +1136,9 @@ discard block |
||
| 1105 | 1136 | array() |
| 1106 | 1137 | ); |
| 1107 | 1138 | $spiders = array(); |
| 1108 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1109 | - $spiders[$row['id_spider']] = $row['spider_name']; |
|
| 1139 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1140 | + $spiders[$row['id_spider']] = $row['spider_name']; |
|
| 1141 | + } |
|
| 1110 | 1142 | $smcFunc['db_free_result']($request); |
| 1111 | 1143 | |
| 1112 | 1144 | updateSettings(array('spider_name_cache' => $smcFunc['json_encode']($spiders))); |
@@ -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 | * !!!Compatibility!!! |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | { |
| 31 | 32 | global $modSettings; |
| 32 | 33 | |
| 33 | - if (!$compat_mode) |
|
| 34 | - return $text; |
|
| 34 | + if (!$compat_mode) { |
|
| 35 | + return $text; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Turn line breaks back into br's. |
| 37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
| 48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 49 | 51 | { |
| 50 | 52 | // Value of 2 means we're inside the tag. |
| 51 | - if ($i % 4 == 2) |
|
| 52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
| 53 | + if ($i % 4 == 2) { |
|
| 54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
| 55 | + } |
|
| 53 | 56 | } |
| 54 | 57 | // Put our humpty dumpty message back together again. |
| 55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
| 107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
| 108 | 111 | |
| 109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
| 110 | - if (isBrowser('webkit')) |
|
| 111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
| 113 | + if (isBrowser('webkit')) { |
|
| 114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
| 114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
| 123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 124 | 128 | { |
| 125 | 129 | // Value of 2 means we're inside the tag. |
| 126 | - if ($i % 4 == 2) |
|
| 127 | - $parts[$i] = strip_tags($parts[$i]); |
|
| 130 | + if ($i % 4 == 2) { |
|
| 131 | + $parts[$i] = strip_tags($parts[$i]); |
|
| 132 | + } |
|
| 128 | 133 | } |
| 129 | 134 | |
| 130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
| 150 | 155 | { |
| 151 | 156 | $found = array_search($file, $smileysto); |
| 152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
| 153 | - if ($found) |
|
| 154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
| 155 | - else |
|
| 156 | - $matches[1][$k] = ''; |
|
| 158 | + if ($found) { |
|
| 159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
| 160 | + } else { |
|
| 161 | + $matches[1][$k] = ''; |
|
| 162 | + } |
|
| 157 | 163 | } |
| 158 | - } |
|
| 159 | - else |
|
| 164 | + } else |
|
| 160 | 165 | { |
| 161 | 166 | // Load all the smileys. |
| 162 | 167 | $names = array(); |
| 163 | - foreach ($matches[1] as $file) |
|
| 164 | - $names[] = $file; |
|
| 168 | + foreach ($matches[1] as $file) { |
|
| 169 | + $names[] = $file; |
|
| 170 | + } |
|
| 165 | 171 | $names = array_unique($names); |
| 166 | 172 | |
| 167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
| 175 | 181 | ) |
| 176 | 182 | ); |
| 177 | 183 | $mappings = array(); |
| 178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
| 184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
| 186 | + } |
|
| 180 | 187 | $smcFunc['db_free_result']($request); |
| 181 | 188 | |
| 182 | - foreach ($matches[1] as $k => $file) |
|
| 183 | - if (isset($mappings[$file])) |
|
| 189 | + foreach ($matches[1] as $k => $file) { |
|
| 190 | + if (isset($mappings[$file])) |
|
| 184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
| 192 | + } |
|
| 185 | 193 | } |
| 186 | 194 | } |
| 187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
| 193 | 201 | } |
| 194 | 202 | |
| 195 | 203 | // Only try to buy more time if the client didn't quit. |
| 196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 197 | - @apache_reset_timeout(); |
|
| 204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 205 | + @apache_reset_timeout(); |
|
| 206 | + } |
|
| 198 | 207 | |
| 199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
| 205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
| 206 | 215 | { |
| 207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
| 208 | - if ($matches[5] === '/') |
|
| 209 | - continue; |
|
| 210 | - else |
|
| 217 | + if ($matches[5] === '/') { |
|
| 218 | + continue; |
|
| 219 | + } else |
|
| 211 | 220 | { |
| 212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
| 213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
| 223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
| 224 | 233 | |
| 225 | 234 | // Something like 'font-weight: bold' is expected here. |
| 226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
| 227 | - continue; |
|
| 235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
| 236 | + continue; |
|
| 237 | + } |
|
| 228 | 238 | |
| 229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
| 230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
| 246 | 256 | { |
| 247 | 257 | $curCloseTags .= '[/u]'; |
| 248 | 258 | $replacement .= '[u]'; |
| 249 | - } |
|
| 250 | - elseif ($style_value == 'line-through') |
|
| 259 | + } elseif ($style_value == 'line-through') |
|
| 251 | 260 | { |
| 252 | 261 | $curCloseTags .= '[/s]'; |
| 253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
| 259 | 268 | { |
| 260 | 269 | $curCloseTags .= '[/left]'; |
| 261 | 270 | $replacement .= '[left]'; |
| 262 | - } |
|
| 263 | - elseif ($style_value == 'center') |
|
| 271 | + } elseif ($style_value == 'center') |
|
| 264 | 272 | { |
| 265 | 273 | $curCloseTags .= '[/center]'; |
| 266 | 274 | $replacement .= '[center]'; |
| 267 | - } |
|
| 268 | - elseif ($style_value == 'right') |
|
| 275 | + } elseif ($style_value == 'right') |
|
| 269 | 276 | { |
| 270 | 277 | $curCloseTags .= '[/right]'; |
| 271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
| 287 | 294 | |
| 288 | 295 | case 'font-size': |
| 289 | 296 | // Sometimes people put decimals where decimals should not be. |
| 290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
| 291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
| 297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
| 298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
| 299 | + } |
|
| 292 | 300 | |
| 293 | 301 | $curCloseTags .= '[/size]'; |
| 294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
| 296 | 304 | |
| 297 | 305 | case 'font-family': |
| 298 | 306 | // Only get the first freaking font if there's a list! |
| 299 | - if (strpos($style_value, ',') !== false) |
|
| 300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
| 307 | + if (strpos($style_value, ',') !== false) { |
|
| 308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
| 309 | + } |
|
| 301 | 310 | |
| 302 | 311 | $curCloseTags .= '[/font]'; |
| 303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
| 306 | 315 | // This is a hack for images with dimensions embedded. |
| 307 | 316 | case 'width': |
| 308 | 317 | case 'height': |
| 309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
| 310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
| 318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
| 319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
| 320 | + } |
|
| 311 | 321 | break; |
| 312 | 322 | |
| 313 | 323 | case 'list-style-type': |
| 314 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
| 315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
| 324 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
| 325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
| 326 | + } |
|
| 316 | 327 | break; |
| 317 | 328 | } |
| 318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
| 325 | 336 | } |
| 326 | 337 | |
| 327 | 338 | // If there's something that still needs closing, push it to the stack. |
| 328 | - if (!empty($curCloseTags)) |
|
| 329 | - array_push($stack, array( |
|
| 339 | + if (!empty($curCloseTags)) { |
|
| 340 | + array_push($stack, array( |
|
| 330 | 341 | 'element' => strtolower($curElement), |
| 331 | 342 | 'closeTags' => $curCloseTags |
| 332 | 343 | ) |
| 333 | 344 | ); |
| 334 | - elseif (!empty($extra_attr)) |
|
| 335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
| 345 | + } elseif (!empty($extra_attr)) { |
|
| 346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
| 347 | + } |
|
| 336 | 348 | } |
| 337 | - } |
|
| 338 | - |
|
| 339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
| 349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
| 340 | 350 | { |
| 341 | 351 | // Is this the element that we've been waiting for to be closed? |
| 342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
| 346 | 356 | } |
| 347 | 357 | |
| 348 | 358 | // Must've been something else. |
| 349 | - else |
|
| 350 | - $replacement .= $part; |
|
| 359 | + else { |
|
| 360 | + $replacement .= $part; |
|
| 361 | + } |
|
| 351 | 362 | } |
| 352 | 363 | // In all other cases, just add the part to the replacement. |
| 353 | - else |
|
| 354 | - $replacement .= $part; |
|
| 364 | + else { |
|
| 365 | + $replacement .= $part; |
|
| 366 | + } |
|
| 355 | 367 | } |
| 356 | 368 | |
| 357 | 369 | // Now put back the replacement in the text. |
| 358 | 370 | $text = $replacement; |
| 359 | 371 | |
| 360 | 372 | // We are not finished yet, request more time. |
| 361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 362 | - @apache_reset_timeout(); |
|
| 373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 374 | + @apache_reset_timeout(); |
|
| 375 | + } |
|
| 363 | 376 | |
| 364 | 377 | // Let's pull out any legacy alignments. |
| 365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
| 366 | 379 | { |
| 367 | 380 | // Find the position in the text of this tag over again. |
| 368 | 381 | $start_pos = strpos($text, $matches[0]); |
| 369 | - if ($start_pos === false) |
|
| 370 | - break; |
|
| 382 | + if ($start_pos === false) { |
|
| 383 | + break; |
|
| 384 | + } |
|
| 371 | 385 | |
| 372 | 386 | // End tag? |
| 373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -381,8 +395,7 @@ discard block |
||
| 381 | 395 | |
| 382 | 396 | // Put the tags back into the body. |
| 383 | 397 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
| 384 | - } |
|
| 385 | - else |
|
| 398 | + } else |
|
| 386 | 399 | { |
| 387 | 400 | // Just get rid of this evil tag. |
| 388 | 401 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -395,8 +408,9 @@ discard block |
||
| 395 | 408 | // Find the position of this again. |
| 396 | 409 | $start_pos = strpos($text, $matches[0]); |
| 397 | 410 | $end_pos = false; |
| 398 | - if ($start_pos === false) |
|
| 399 | - break; |
|
| 411 | + if ($start_pos === false) { |
|
| 412 | + break; |
|
| 413 | + } |
|
| 400 | 414 | |
| 401 | 415 | // This must have an end tag - and we must find the right one. |
| 402 | 416 | $lower_text = strtolower($text); |
@@ -429,8 +443,9 @@ discard block |
||
| 429 | 443 | break; |
| 430 | 444 | } |
| 431 | 445 | } |
| 432 | - if ($end_pos === false) |
|
| 433 | - break; |
|
| 446 | + if ($end_pos === false) { |
|
| 447 | + break; |
|
| 448 | + } |
|
| 434 | 449 | |
| 435 | 450 | // Now work out what the attributes are. |
| 436 | 451 | $attribs = fetchTagAttributes($matches[1]); |
@@ -444,11 +459,11 @@ discard block |
||
| 444 | 459 | $v = (int) trim($v); |
| 445 | 460 | $v = empty($v) ? 1 : $v; |
| 446 | 461 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
| 462 | + } elseif ($s == 'face') { |
|
| 463 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 464 | + } elseif ($s == 'color') { |
|
| 465 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 447 | 466 | } |
| 448 | - elseif ($s == 'face') |
|
| 449 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 450 | - elseif ($s == 'color') |
|
| 451 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 452 | 467 | } |
| 453 | 468 | |
| 454 | 469 | // As before add in our tags. |
@@ -456,8 +471,9 @@ discard block |
||
| 456 | 471 | foreach ($tags as $tag) |
| 457 | 472 | { |
| 458 | 473 | $before .= $tag[0]; |
| 459 | - if (isset($tag[1])) |
|
| 460 | - $after = $tag[1] . $after; |
|
| 474 | + if (isset($tag[1])) { |
|
| 475 | + $after = $tag[1] . $after; |
|
| 476 | + } |
|
| 461 | 477 | } |
| 462 | 478 | |
| 463 | 479 | // Remove the tag so it's never checked again. |
@@ -468,8 +484,9 @@ discard block |
||
| 468 | 484 | } |
| 469 | 485 | |
| 470 | 486 | // Almost there, just a little more time. |
| 471 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 472 | - @apache_reset_timeout(); |
|
| 487 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 488 | + @apache_reset_timeout(); |
|
| 489 | + } |
|
| 473 | 490 | |
| 474 | 491 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
| 475 | 492 | { |
@@ -525,12 +542,13 @@ discard block |
||
| 525 | 542 | { |
| 526 | 543 | $inList = true; |
| 527 | 544 | |
| 528 | - if ($tag === 'ol') |
|
| 529 | - $listType = 'decimal'; |
|
| 530 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
| 531 | - $listType = $listTypeMapping[$match[1]]; |
|
| 532 | - else |
|
| 533 | - $listType = null; |
|
| 545 | + if ($tag === 'ol') { |
|
| 546 | + $listType = 'decimal'; |
|
| 547 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
| 548 | + $listType = $listTypeMapping[$match[1]]; |
|
| 549 | + } else { |
|
| 550 | + $listType = null; |
|
| 551 | + } |
|
| 534 | 552 | |
| 535 | 553 | $listDepth++; |
| 536 | 554 | |
@@ -594,9 +612,7 @@ discard block |
||
| 594 | 612 | $parts[$i + 1] = ''; |
| 595 | 613 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
| 596 | 614 | $parts[$i + 3] = ''; |
| 597 | - } |
|
| 598 | - |
|
| 599 | - else |
|
| 615 | + } else |
|
| 600 | 616 | { |
| 601 | 617 | // We're in a list item. |
| 602 | 618 | if ($listDepth > 0) |
@@ -633,9 +649,7 @@ discard block |
||
| 633 | 649 | $parts[$i + 1] = ''; |
| 634 | 650 | $parts[$i + 2] = ''; |
| 635 | 651 | $parts[$i + 3] = ''; |
| 636 | - } |
|
| 637 | - |
|
| 638 | - else |
|
| 652 | + } else |
|
| 639 | 653 | { |
| 640 | 654 | // Remove the trailing breaks from the list item. |
| 641 | 655 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -673,8 +687,9 @@ discard block |
||
| 673 | 687 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
| 674 | 688 | } |
| 675 | 689 | |
| 676 | - for ($i = $listDepth; $i > 0; $i--) |
|
| 677 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 690 | + for ($i = $listDepth; $i > 0; $i--) { |
|
| 691 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 692 | + } |
|
| 678 | 693 | |
| 679 | 694 | } |
| 680 | 695 | |
@@ -683,8 +698,9 @@ discard block |
||
| 683 | 698 | { |
| 684 | 699 | // Find the position of the image. |
| 685 | 700 | $start_pos = strpos($text, $matches[0]); |
| 686 | - if ($start_pos === false) |
|
| 687 | - break; |
|
| 701 | + if ($start_pos === false) { |
|
| 702 | + break; |
|
| 703 | + } |
|
| 688 | 704 | $end_pos = $start_pos + strlen($matches[0]); |
| 689 | 705 | |
| 690 | 706 | $params = ''; |
@@ -693,12 +709,13 @@ discard block |
||
| 693 | 709 | $attrs = fetchTagAttributes($matches[1]); |
| 694 | 710 | foreach ($attrs as $attrib => $value) |
| 695 | 711 | { |
| 696 | - if (in_array($attrib, array('width', 'height'))) |
|
| 697 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 698 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
| 699 | - $params .= ' alt=' . trim($value); |
|
| 700 | - elseif ($attrib == 'src') |
|
| 701 | - $src = trim($value); |
|
| 712 | + if (in_array($attrib, array('width', 'height'))) { |
|
| 713 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 714 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
| 715 | + $params .= ' alt=' . trim($value); |
|
| 716 | + } elseif ($attrib == 'src') { |
|
| 717 | + $src = trim($value); |
|
| 718 | + } |
|
| 702 | 719 | } |
| 703 | 720 | |
| 704 | 721 | $tag = ''; |
@@ -709,10 +726,11 @@ discard block |
||
| 709 | 726 | { |
| 710 | 727 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 711 | 728 | |
| 712 | - if (substr($src, 0, 1) === '/') |
|
| 713 | - $src = $baseURL . $src; |
|
| 714 | - else |
|
| 715 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 729 | + if (substr($src, 0, 1) === '/') { |
|
| 730 | + $src = $baseURL . $src; |
|
| 731 | + } else { |
|
| 732 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 733 | + } |
|
| 716 | 734 | } |
| 717 | 735 | |
| 718 | 736 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -890,20 +908,23 @@ discard block |
||
| 890 | 908 | }, |
| 891 | 909 | ); |
| 892 | 910 | |
| 893 | - foreach ($tags as $tag => $replace) |
|
| 894 | - $text = preg_replace_callback($tag, $replace, $text); |
|
| 911 | + foreach ($tags as $tag => $replace) { |
|
| 912 | + $text = preg_replace_callback($tag, $replace, $text); |
|
| 913 | + } |
|
| 895 | 914 | |
| 896 | 915 | // Please give us just a little more time. |
| 897 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 898 | - @apache_reset_timeout(); |
|
| 916 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 917 | + @apache_reset_timeout(); |
|
| 918 | + } |
|
| 899 | 919 | |
| 900 | 920 | // What about URL's - the pain in the ass of the tag world. |
| 901 | 921 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
| 902 | 922 | { |
| 903 | 923 | // Find the position of the URL. |
| 904 | 924 | $start_pos = strpos($text, $matches[0]); |
| 905 | - if ($start_pos === false) |
|
| 906 | - break; |
|
| 925 | + if ($start_pos === false) { |
|
| 926 | + break; |
|
| 927 | + } |
|
| 907 | 928 | $end_pos = $start_pos + strlen($matches[0]); |
| 908 | 929 | |
| 909 | 930 | $tag_type = 'url'; |
@@ -917,8 +938,9 @@ discard block |
||
| 917 | 938 | $href = trim($value); |
| 918 | 939 | |
| 919 | 940 | // Are we dealing with an FTP link? |
| 920 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
| 921 | - $tag_type = 'ftp'; |
|
| 941 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
| 942 | + $tag_type = 'ftp'; |
|
| 943 | + } |
|
| 922 | 944 | |
| 923 | 945 | // Or is this a link to an email address? |
| 924 | 946 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -932,28 +954,31 @@ discard block |
||
| 932 | 954 | { |
| 933 | 955 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 934 | 956 | |
| 935 | - if (substr($href, 0, 1) === '/') |
|
| 936 | - $href = $baseURL . $href; |
|
| 937 | - else |
|
| 938 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 957 | + if (substr($href, 0, 1) === '/') { |
|
| 958 | + $href = $baseURL . $href; |
|
| 959 | + } else { |
|
| 960 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 961 | + } |
|
| 939 | 962 | } |
| 940 | 963 | } |
| 941 | 964 | |
| 942 | 965 | // External URL? |
| 943 | 966 | if ($attrib == 'target' && $tag_type == 'url') |
| 944 | 967 | { |
| 945 | - if (trim($value) == '_blank') |
|
| 946 | - $tag_type == 'iurl'; |
|
| 968 | + if (trim($value) == '_blank') { |
|
| 969 | + $tag_type == 'iurl'; |
|
| 970 | + } |
|
| 947 | 971 | } |
| 948 | 972 | } |
| 949 | 973 | |
| 950 | 974 | $tag = ''; |
| 951 | 975 | if ($href != '') |
| 952 | 976 | { |
| 953 | - if ($matches[2] == $href) |
|
| 954 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 955 | - else |
|
| 956 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 977 | + if ($matches[2] == $href) { |
|
| 978 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 979 | + } else { |
|
| 980 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 981 | + } |
|
| 957 | 982 | } |
| 958 | 983 | |
| 959 | 984 | // Replace the tag |
@@ -992,17 +1017,18 @@ discard block |
||
| 992 | 1017 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
| 993 | 1018 | if ($text[$i] == '=') |
| 994 | 1019 | { |
| 995 | - if ($tag_state == 0) |
|
| 996 | - $tag_state = 1; |
|
| 997 | - elseif ($tag_state == 2) |
|
| 998 | - $value .= '='; |
|
| 1020 | + if ($tag_state == 0) { |
|
| 1021 | + $tag_state = 1; |
|
| 1022 | + } elseif ($tag_state == 2) { |
|
| 1023 | + $value .= '='; |
|
| 1024 | + } |
|
| 999 | 1025 | } |
| 1000 | 1026 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
| 1001 | 1027 | elseif ($text[$i] == ' ') |
| 1002 | 1028 | { |
| 1003 | - if ($tag_state == 2) |
|
| 1004 | - $value .= ' '; |
|
| 1005 | - elseif ($tag_state == 1) |
|
| 1029 | + if ($tag_state == 2) { |
|
| 1030 | + $value .= ' '; |
|
| 1031 | + } elseif ($tag_state == 1) |
|
| 1006 | 1032 | { |
| 1007 | 1033 | $attribs[$key] = $value; |
| 1008 | 1034 | $key = $value = ''; |
@@ -1013,24 +1039,27 @@ discard block |
||
| 1013 | 1039 | elseif ($text[$i] == '"') |
| 1014 | 1040 | { |
| 1015 | 1041 | // Must be either going into or out of a string. |
| 1016 | - if ($tag_state == 1) |
|
| 1017 | - $tag_state = 2; |
|
| 1018 | - else |
|
| 1019 | - $tag_state = 1; |
|
| 1042 | + if ($tag_state == 1) { |
|
| 1043 | + $tag_state = 2; |
|
| 1044 | + } else { |
|
| 1045 | + $tag_state = 1; |
|
| 1046 | + } |
|
| 1020 | 1047 | } |
| 1021 | 1048 | // Otherwise it's fine. |
| 1022 | 1049 | else |
| 1023 | 1050 | { |
| 1024 | - if ($tag_state == 0) |
|
| 1025 | - $key .= $text[$i]; |
|
| 1026 | - else |
|
| 1027 | - $value .= $text[$i]; |
|
| 1051 | + if ($tag_state == 0) { |
|
| 1052 | + $key .= $text[$i]; |
|
| 1053 | + } else { |
|
| 1054 | + $value .= $text[$i]; |
|
| 1055 | + } |
|
| 1028 | 1056 | } |
| 1029 | 1057 | } |
| 1030 | 1058 | |
| 1031 | 1059 | // Anything left? |
| 1032 | - if ($key != '' && $value != '') |
|
| 1033 | - $attribs[$key] = $value; |
|
| 1060 | + if ($key != '' && $value != '') { |
|
| 1061 | + $attribs[$key] = $value; |
|
| 1062 | + } |
|
| 1034 | 1063 | |
| 1035 | 1064 | return $attribs; |
| 1036 | 1065 | } |
@@ -1046,15 +1075,17 @@ discard block |
||
| 1046 | 1075 | global $modSettings; |
| 1047 | 1076 | |
| 1048 | 1077 | // Don't care about the texts that are too short. |
| 1049 | - if (strlen($text) < 3) |
|
| 1050 | - return $text; |
|
| 1078 | + if (strlen($text) < 3) { |
|
| 1079 | + return $text; |
|
| 1080 | + } |
|
| 1051 | 1081 | |
| 1052 | 1082 | // A list of tags that's disabled by the admin. |
| 1053 | 1083 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
| 1054 | 1084 | |
| 1055 | 1085 | // Add flash if it's disabled as embedded tag. |
| 1056 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1057 | - $disabled['flash'] = true; |
|
| 1086 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1087 | + $disabled['flash'] = true; |
|
| 1088 | + } |
|
| 1058 | 1089 | |
| 1059 | 1090 | // Get a list of all the tags that are not disabled. |
| 1060 | 1091 | $all_tags = parse_bbc(false); |
@@ -1062,10 +1093,12 @@ discard block |
||
| 1062 | 1093 | $self_closing_tags = array(); |
| 1063 | 1094 | foreach ($all_tags as $tag) |
| 1064 | 1095 | { |
| 1065 | - if (!isset($disabled[$tag['tag']])) |
|
| 1066 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1067 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
| 1068 | - $self_closing_tags[] = $tag['tag']; |
|
| 1096 | + if (!isset($disabled[$tag['tag']])) { |
|
| 1097 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1098 | + } |
|
| 1099 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
| 1100 | + $self_closing_tags[] = $tag['tag']; |
|
| 1101 | + } |
|
| 1069 | 1102 | } |
| 1070 | 1103 | |
| 1071 | 1104 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1092,16 +1125,19 @@ discard block |
||
| 1092 | 1125 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
| 1093 | 1126 | |
| 1094 | 1127 | // We're closing the exact same tag that we opened. |
| 1095 | - if ($isClosingTag && $insideTag === $tagName) |
|
| 1096 | - $insideTag = null; |
|
| 1128 | + if ($isClosingTag && $insideTag === $tagName) { |
|
| 1129 | + $insideTag = null; |
|
| 1130 | + } |
|
| 1097 | 1131 | |
| 1098 | 1132 | // We're opening a tag and we're not yet inside one either |
| 1099 | - elseif (!$isClosingTag && $insideTag === null) |
|
| 1100 | - $insideTag = $tagName; |
|
| 1133 | + elseif (!$isClosingTag && $insideTag === null) { |
|
| 1134 | + $insideTag = $tagName; |
|
| 1135 | + } |
|
| 1101 | 1136 | |
| 1102 | 1137 | // In all other cases, this tag must be invalid |
| 1103 | - else |
|
| 1104 | - unset($matches[$i]); |
|
| 1138 | + else { |
|
| 1139 | + unset($matches[$i]); |
|
| 1140 | + } |
|
| 1105 | 1141 | } |
| 1106 | 1142 | |
| 1107 | 1143 | // The next one is gonna be the other one. |
@@ -1109,8 +1145,9 @@ discard block |
||
| 1109 | 1145 | } |
| 1110 | 1146 | |
| 1111 | 1147 | // We're still inside a tag and had no chance for closure? |
| 1112 | - if ($insideTag !== null) |
|
| 1113 | - $matches[] = '[/' . $insideTag . ']'; |
|
| 1148 | + if ($insideTag !== null) { |
|
| 1149 | + $matches[] = '[/' . $insideTag . ']'; |
|
| 1150 | + } |
|
| 1114 | 1151 | |
| 1115 | 1152 | // And a complete text string again. |
| 1116 | 1153 | $text = implode('', $matches); |
@@ -1119,8 +1156,9 @@ discard block |
||
| 1119 | 1156 | // Quickly remove any tags which are back to back. |
| 1120 | 1157 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
| 1121 | 1158 | $lastlen = 0; |
| 1122 | - while (strlen($text) !== $lastlen) |
|
| 1123 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1159 | + while (strlen($text) !== $lastlen) { |
|
| 1160 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1161 | + } |
|
| 1124 | 1162 | |
| 1125 | 1163 | // Need to sort the tags my name length. |
| 1126 | 1164 | uksort($valid_tags, 'sort_array_length'); |
@@ -1157,8 +1195,9 @@ discard block |
||
| 1157 | 1195 | $isCompetingTag = in_array($tag, $competing_tags); |
| 1158 | 1196 | |
| 1159 | 1197 | // Check if this might be one of those cleaned out tags. |
| 1160 | - if ($tag === '') |
|
| 1161 | - continue; |
|
| 1198 | + if ($tag === '') { |
|
| 1199 | + continue; |
|
| 1200 | + } |
|
| 1162 | 1201 | |
| 1163 | 1202 | // Special case: inside [code] blocks any code is left untouched. |
| 1164 | 1203 | elseif ($tag === 'code') |
@@ -1169,8 +1208,9 @@ discard block |
||
| 1169 | 1208 | $inCode = false; |
| 1170 | 1209 | |
| 1171 | 1210 | // Reopen tags that were closed before the code block. |
| 1172 | - if (!empty($inlineElements)) |
|
| 1173 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1211 | + if (!empty($inlineElements)) { |
|
| 1212 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1213 | + } |
|
| 1174 | 1214 | } |
| 1175 | 1215 | |
| 1176 | 1216 | // We're outside a coding and nobbc block and opening it. |
@@ -1199,8 +1239,9 @@ discard block |
||
| 1199 | 1239 | $inNoBbc = false; |
| 1200 | 1240 | |
| 1201 | 1241 | // Some inline elements might've been closed that need reopening. |
| 1202 | - if (!empty($inlineElements)) |
|
| 1203 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1242 | + if (!empty($inlineElements)) { |
|
| 1243 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1244 | + } |
|
| 1204 | 1245 | } |
| 1205 | 1246 | |
| 1206 | 1247 | // We're outside a nobbc and coding block and opening it. |
@@ -1220,8 +1261,9 @@ discard block |
||
| 1220 | 1261 | } |
| 1221 | 1262 | |
| 1222 | 1263 | // So, we're inside one of the special blocks: ignore any tag. |
| 1223 | - elseif ($inCode || $inNoBbc) |
|
| 1224 | - continue; |
|
| 1264 | + elseif ($inCode || $inNoBbc) { |
|
| 1265 | + continue; |
|
| 1266 | + } |
|
| 1225 | 1267 | |
| 1226 | 1268 | // We're dealing with an opening tag. |
| 1227 | 1269 | if ($isOpeningTag) |
@@ -1262,8 +1304,9 @@ discard block |
||
| 1262 | 1304 | if ($parts[$j + 3] === $tag) |
| 1263 | 1305 | { |
| 1264 | 1306 | // If it's an opening tag, increase the level. |
| 1265 | - if ($parts[$j + 2] === '') |
|
| 1266 | - $curLevel++; |
|
| 1307 | + if ($parts[$j + 2] === '') { |
|
| 1308 | + $curLevel++; |
|
| 1309 | + } |
|
| 1267 | 1310 | |
| 1268 | 1311 | // A closing tag, decrease the level. |
| 1269 | 1312 | else |
@@ -1286,13 +1329,15 @@ discard block |
||
| 1286 | 1329 | { |
| 1287 | 1330 | if ($isCompetingTag) |
| 1288 | 1331 | { |
| 1289 | - if (!isset($competingElements[$tag])) |
|
| 1290 | - $competingElements[$tag] = array(); |
|
| 1332 | + if (!isset($competingElements[$tag])) { |
|
| 1333 | + $competingElements[$tag] = array(); |
|
| 1334 | + } |
|
| 1291 | 1335 | |
| 1292 | 1336 | $competingElements[$tag][] = $parts[$i + 4]; |
| 1293 | 1337 | |
| 1294 | - if (count($competingElements[$tag]) > 1) |
|
| 1295 | - $parts[$i] .= '[/' . $tag . ']'; |
|
| 1338 | + if (count($competingElements[$tag]) > 1) { |
|
| 1339 | + $parts[$i] .= '[/' . $tag . ']'; |
|
| 1340 | + } |
|
| 1296 | 1341 | } |
| 1297 | 1342 | |
| 1298 | 1343 | $inlineElements[$elementContent] = $tag; |
@@ -1313,15 +1358,17 @@ discard block |
||
| 1313 | 1358 | $addClosingTags = array(); |
| 1314 | 1359 | while ($element = array_pop($blockElements)) |
| 1315 | 1360 | { |
| 1316 | - if ($element === $tag) |
|
| 1317 | - break; |
|
| 1361 | + if ($element === $tag) { |
|
| 1362 | + break; |
|
| 1363 | + } |
|
| 1318 | 1364 | |
| 1319 | 1365 | // Still a block tag was open not equal to this tag. |
| 1320 | 1366 | $addClosingTags[] = $element['type']; |
| 1321 | 1367 | } |
| 1322 | 1368 | |
| 1323 | - if (!empty($addClosingTags)) |
|
| 1324 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1369 | + if (!empty($addClosingTags)) { |
|
| 1370 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1371 | + } |
|
| 1325 | 1372 | |
| 1326 | 1373 | // Apparently the closing tag was not found on the stack. |
| 1327 | 1374 | if (!is_string($element) || $element !== $tag) |
@@ -1331,8 +1378,7 @@ discard block |
||
| 1331 | 1378 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
| 1332 | 1379 | continue; |
| 1333 | 1380 | } |
| 1334 | - } |
|
| 1335 | - else |
|
| 1381 | + } else |
|
| 1336 | 1382 | { |
| 1337 | 1383 | // Get rid of this closing tag! |
| 1338 | 1384 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1361,53 +1407,62 @@ discard block |
||
| 1361 | 1407 | unset($inlineElements[$tagContentToBeClosed]); |
| 1362 | 1408 | |
| 1363 | 1409 | // Was this the tag we were looking for? |
| 1364 | - if ($tagToBeClosed === $tag) |
|
| 1365 | - break; |
|
| 1410 | + if ($tagToBeClosed === $tag) { |
|
| 1411 | + break; |
|
| 1412 | + } |
|
| 1366 | 1413 | |
| 1367 | 1414 | // Nope, close it and look further! |
| 1368 | - else |
|
| 1369 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1415 | + else { |
|
| 1416 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1417 | + } |
|
| 1370 | 1418 | } |
| 1371 | 1419 | |
| 1372 | 1420 | if ($isCompetingTag && !empty($competingElements[$tag])) |
| 1373 | 1421 | { |
| 1374 | 1422 | array_pop($competingElements[$tag]); |
| 1375 | 1423 | |
| 1376 | - if (count($competingElements[$tag]) > 0) |
|
| 1377 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1424 | + if (count($competingElements[$tag]) > 0) { |
|
| 1425 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1426 | + } |
|
| 1378 | 1427 | } |
| 1379 | 1428 | } |
| 1380 | 1429 | |
| 1381 | 1430 | // Unexpected closing tag, ex-ter-mi-nate. |
| 1382 | - else |
|
| 1383 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1431 | + else { |
|
| 1432 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1433 | + } |
|
| 1384 | 1434 | } |
| 1385 | 1435 | } |
| 1386 | 1436 | } |
| 1387 | 1437 | |
| 1388 | 1438 | // Close the code tags. |
| 1389 | - if ($inCode) |
|
| 1390 | - $parts[$i] .= '[/code]'; |
|
| 1439 | + if ($inCode) { |
|
| 1440 | + $parts[$i] .= '[/code]'; |
|
| 1441 | + } |
|
| 1391 | 1442 | |
| 1392 | 1443 | // The same for nobbc tags. |
| 1393 | - elseif ($inNoBbc) |
|
| 1394 | - $parts[$i] .= '[/nobbc]'; |
|
| 1444 | + elseif ($inNoBbc) { |
|
| 1445 | + $parts[$i] .= '[/nobbc]'; |
|
| 1446 | + } |
|
| 1395 | 1447 | |
| 1396 | 1448 | // Still inline tags left unclosed? Close them now, better late than never. |
| 1397 | - elseif (!empty($inlineElements)) |
|
| 1398 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1449 | + elseif (!empty($inlineElements)) { |
|
| 1450 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1451 | + } |
|
| 1399 | 1452 | |
| 1400 | 1453 | // Now close the block elements. |
| 1401 | - if (!empty($blockElements)) |
|
| 1402 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1454 | + if (!empty($blockElements)) { |
|
| 1455 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1456 | + } |
|
| 1403 | 1457 | |
| 1404 | 1458 | $text = implode('', $parts); |
| 1405 | 1459 | } |
| 1406 | 1460 | |
| 1407 | 1461 | // Final clean up of back to back tags. |
| 1408 | 1462 | $lastlen = 0; |
| 1409 | - while (strlen($text) !== $lastlen) |
|
| 1410 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1463 | + while (strlen($text) !== $lastlen) { |
|
| 1464 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1465 | + } |
|
| 1411 | 1466 | |
| 1412 | 1467 | return $text; |
| 1413 | 1468 | } |
@@ -1436,22 +1491,25 @@ discard block |
||
| 1436 | 1491 | $context['template_layers'] = array(); |
| 1437 | 1492 | // Lets make sure we aren't going to output anything nasty. |
| 1438 | 1493 | @ob_end_clean(); |
| 1439 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 1440 | - @ob_start('ob_gzhandler'); |
|
| 1441 | - else |
|
| 1442 | - @ob_start(); |
|
| 1494 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 1495 | + @ob_start('ob_gzhandler'); |
|
| 1496 | + } else { |
|
| 1497 | + @ob_start(); |
|
| 1498 | + } |
|
| 1443 | 1499 | |
| 1444 | 1500 | // If we don't have any locale better avoid broken js |
| 1445 | - if (empty($txt['lang_locale'])) |
|
| 1446 | - die(); |
|
| 1501 | + if (empty($txt['lang_locale'])) { |
|
| 1502 | + die(); |
|
| 1503 | + } |
|
| 1447 | 1504 | |
| 1448 | 1505 | $file_data = '(function ($) { |
| 1449 | 1506 | \'use strict\'; |
| 1450 | 1507 | |
| 1451 | 1508 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
| 1452 | - foreach ($editortxt as $key => $val) |
|
| 1453 | - $file_data .= ' |
|
| 1509 | + foreach ($editortxt as $key => $val) { |
|
| 1510 | + $file_data .= ' |
|
| 1454 | 1511 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
| 1512 | + } |
|
| 1455 | 1513 | |
| 1456 | 1514 | $file_data .= ' |
| 1457 | 1515 | dateFormat: "day.month.year" |
@@ -1519,8 +1577,9 @@ discard block |
||
| 1519 | 1577 | ) |
| 1520 | 1578 | ); |
| 1521 | 1579 | $icon_data = array(); |
| 1522 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1523 | - $icon_data[] = $row; |
|
| 1580 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1581 | + $icon_data[] = $row; |
|
| 1582 | + } |
|
| 1524 | 1583 | $smcFunc['db_free_result']($request); |
| 1525 | 1584 | |
| 1526 | 1585 | $icons = array(); |
@@ -1535,9 +1594,9 @@ discard block |
||
| 1535 | 1594 | } |
| 1536 | 1595 | |
| 1537 | 1596 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
| 1597 | + } else { |
|
| 1598 | + $icons = $temp; |
|
| 1538 | 1599 | } |
| 1539 | - else |
|
| 1540 | - $icons = $temp; |
|
| 1541 | 1600 | } |
| 1542 | 1601 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
| 1543 | 1602 | |
@@ -1578,8 +1637,9 @@ discard block |
||
| 1578 | 1637 | { |
| 1579 | 1638 | // Some general stuff. |
| 1580 | 1639 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
| 1581 | - if (!empty($context['drafts_autosave'])) |
|
| 1582 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1640 | + if (!empty($context['drafts_autosave'])) { |
|
| 1641 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1642 | + } |
|
| 1583 | 1643 | |
| 1584 | 1644 | // This really has some WYSIWYG stuff. |
| 1585 | 1645 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1595,8 +1655,9 @@ discard block |
||
| 1595 | 1655 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
| 1596 | 1656 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
| 1597 | 1657 | // editor language file |
| 1598 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
| 1599 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1658 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
| 1659 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1660 | + } |
|
| 1600 | 1661 | |
| 1601 | 1662 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
| 1602 | 1663 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1605,11 +1666,12 @@ discard block |
||
| 1605 | 1666 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
| 1606 | 1667 | |
| 1607 | 1668 | // Some hidden information is needed in order to make the spell checking work. |
| 1608 | - if (!isset($_REQUEST['xml'])) |
|
| 1609 | - $context['insert_after_template'] .= ' |
|
| 1669 | + if (!isset($_REQUEST['xml'])) { |
|
| 1670 | + $context['insert_after_template'] .= ' |
|
| 1610 | 1671 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
| 1611 | 1672 | <input type="hidden" name="spellstring" value=""> |
| 1612 | 1673 | </form>'; |
| 1674 | + } |
|
| 1613 | 1675 | } |
| 1614 | 1676 | } |
| 1615 | 1677 | |
@@ -1775,10 +1837,12 @@ discard block |
||
| 1775 | 1837 | |
| 1776 | 1838 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
| 1777 | 1839 | $disabled_tags = array(); |
| 1778 | - if (!empty($modSettings['disabledBBC'])) |
|
| 1779 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1780 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1781 | - $disabled_tags[] = 'flash'; |
|
| 1840 | + if (!empty($modSettings['disabledBBC'])) { |
|
| 1841 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1842 | + } |
|
| 1843 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1844 | + $disabled_tags[] = 'flash'; |
|
| 1845 | + } |
|
| 1782 | 1846 | |
| 1783 | 1847 | foreach ($disabled_tags as $tag) |
| 1784 | 1848 | { |
@@ -1788,9 +1852,10 @@ discard block |
||
| 1788 | 1852 | $context['disabled_tags']['orderedlist'] = true; |
| 1789 | 1853 | } |
| 1790 | 1854 | |
| 1791 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
| 1792 | - if ($tag === $thisTag) |
|
| 1855 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
| 1856 | + if ($tag === $thisTag) |
|
| 1793 | 1857 | $context['disabled_tags'][$tagNameBBC] = true; |
| 1858 | + } |
|
| 1794 | 1859 | |
| 1795 | 1860 | $context['disabled_tags'][trim($tag)] = true; |
| 1796 | 1861 | } |
@@ -1800,19 +1865,21 @@ discard block |
||
| 1800 | 1865 | $context['bbc_toolbar'] = array(); |
| 1801 | 1866 | foreach ($context['bbc_tags'] as $row => $tagRow) |
| 1802 | 1867 | { |
| 1803 | - if (!isset($context['bbc_toolbar'][$row])) |
|
| 1804 | - $context['bbc_toolbar'][$row] = array(); |
|
| 1868 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
| 1869 | + $context['bbc_toolbar'][$row] = array(); |
|
| 1870 | + } |
|
| 1805 | 1871 | $tagsRow = array(); |
| 1806 | 1872 | foreach ($tagRow as $tag) |
| 1807 | 1873 | { |
| 1808 | 1874 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
| 1809 | 1875 | { |
| 1810 | 1876 | $tagsRow[] = $tag['code']; |
| 1811 | - if (isset($tag['image'])) |
|
| 1812 | - $bbcodes_styles .= ' |
|
| 1877 | + if (isset($tag['image'])) { |
|
| 1878 | + $bbcodes_styles .= ' |
|
| 1813 | 1879 | .sceditor-button-' . $tag['code'] . ' div { |
| 1814 | 1880 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
| 1815 | 1881 | }'; |
| 1882 | + } |
|
| 1816 | 1883 | if (isset($tag['before'])) |
| 1817 | 1884 | { |
| 1818 | 1885 | $context['bbcodes_handlers'] .= ' |
@@ -1826,8 +1893,7 @@ discard block |
||
| 1826 | 1893 | });'; |
| 1827 | 1894 | } |
| 1828 | 1895 | |
| 1829 | - } |
|
| 1830 | - else |
|
| 1896 | + } else |
|
| 1831 | 1897 | { |
| 1832 | 1898 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1833 | 1899 | $tagsRow = array(); |
@@ -1838,14 +1904,16 @@ discard block |
||
| 1838 | 1904 | { |
| 1839 | 1905 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1840 | 1906 | $tagsRow = array(); |
| 1841 | - if (!isset($context['disabled_tags']['font'])) |
|
| 1842 | - $tagsRow[] = 'font'; |
|
| 1843 | - if (!isset($context['disabled_tags']['size'])) |
|
| 1844 | - $tagsRow[] = 'size'; |
|
| 1845 | - if (!isset($context['disabled_tags']['color'])) |
|
| 1846 | - $tagsRow[] = 'color'; |
|
| 1847 | - } |
|
| 1848 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1907 | + if (!isset($context['disabled_tags']['font'])) { |
|
| 1908 | + $tagsRow[] = 'font'; |
|
| 1909 | + } |
|
| 1910 | + if (!isset($context['disabled_tags']['size'])) { |
|
| 1911 | + $tagsRow[] = 'size'; |
|
| 1912 | + } |
|
| 1913 | + if (!isset($context['disabled_tags']['color'])) { |
|
| 1914 | + $tagsRow[] = 'color'; |
|
| 1915 | + } |
|
| 1916 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1849 | 1917 | { |
| 1850 | 1918 | $tmp = array(); |
| 1851 | 1919 | $tagsRow[] = 'removeformat'; |
@@ -1856,13 +1924,15 @@ discard block |
||
| 1856 | 1924 | } |
| 1857 | 1925 | } |
| 1858 | 1926 | |
| 1859 | - if (!empty($tagsRow)) |
|
| 1860 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1927 | + if (!empty($tagsRow)) { |
|
| 1928 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1929 | + } |
|
| 1861 | 1930 | } |
| 1862 | - if (!empty($bbcodes_styles)) |
|
| 1863 | - $context['html_headers'] .= ' |
|
| 1931 | + if (!empty($bbcodes_styles)) { |
|
| 1932 | + $context['html_headers'] .= ' |
|
| 1864 | 1933 | <style>' . $bbcodes_styles . ' |
| 1865 | 1934 | </style>'; |
| 1935 | + } |
|
| 1866 | 1936 | } |
| 1867 | 1937 | |
| 1868 | 1938 | // Initialize smiley array... if not loaded before. |
@@ -1874,8 +1944,8 @@ discard block |
||
| 1874 | 1944 | ); |
| 1875 | 1945 | |
| 1876 | 1946 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
| 1877 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
| 1878 | - $context['smileys']['postform'][] = array( |
|
| 1947 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
| 1948 | + $context['smileys']['postform'][] = array( |
|
| 1879 | 1949 | 'smileys' => array( |
| 1880 | 1950 | array( |
| 1881 | 1951 | 'code' => ':)', |
@@ -1961,7 +2031,7 @@ discard block |
||
| 1961 | 2031 | ), |
| 1962 | 2032 | 'isLast' => true, |
| 1963 | 2033 | ); |
| 1964 | - elseif ($user_info['smiley_set'] != 'none') |
|
| 2034 | + } elseif ($user_info['smiley_set'] != 'none') |
|
| 1965 | 2035 | { |
| 1966 | 2036 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
| 1967 | 2037 | { |
@@ -1984,17 +2054,19 @@ discard block |
||
| 1984 | 2054 | |
| 1985 | 2055 | foreach ($context['smileys'] as $section => $smileyRows) |
| 1986 | 2056 | { |
| 1987 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
| 1988 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2057 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
| 2058 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2059 | + } |
|
| 1989 | 2060 | |
| 1990 | - if (!empty($smileyRows)) |
|
| 1991 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2061 | + if (!empty($smileyRows)) { |
|
| 2062 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2063 | + } |
|
| 1992 | 2064 | } |
| 1993 | 2065 | |
| 1994 | 2066 | cache_put_data('posting_smileys', $context['smileys'], 480); |
| 2067 | + } else { |
|
| 2068 | + $context['smileys'] = $temp; |
|
| 1995 | 2069 | } |
| 1996 | - else |
|
| 1997 | - $context['smileys'] = $temp; |
|
| 1998 | 2070 | } |
| 1999 | 2071 | } |
| 2000 | 2072 | |
@@ -2020,8 +2092,9 @@ discard block |
||
| 2020 | 2092 | loadTemplate('GenericControls'); |
| 2021 | 2093 | |
| 2022 | 2094 | // Some javascript ma'am? |
| 2023 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
| 2024 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2095 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
| 2096 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2097 | + } |
|
| 2025 | 2098 | |
| 2026 | 2099 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
| 2027 | 2100 | |
@@ -2034,8 +2107,8 @@ discard block |
||
| 2034 | 2107 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
| 2035 | 2108 | |
| 2036 | 2109 | // Log this into our collection. |
| 2037 | - if ($isNew) |
|
| 2038 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2110 | + if ($isNew) { |
|
| 2111 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2039 | 2112 | 'id' => $verificationOptions['id'], |
| 2040 | 2113 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
| 2041 | 2114 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2046,13 +2119,15 @@ discard block |
||
| 2046 | 2119 | 'questions' => array(), |
| 2047 | 2120 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
| 2048 | 2121 | ); |
| 2122 | + } |
|
| 2049 | 2123 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
| 2050 | 2124 | |
| 2051 | 2125 | // Is there actually going to be anything? |
| 2052 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
| 2053 | - return false; |
|
| 2054 | - elseif (!$isNew && !$do_test) |
|
| 2055 | - return true; |
|
| 2126 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
| 2127 | + return false; |
|
| 2128 | + } elseif (!$isNew && !$do_test) { |
|
| 2129 | + return true; |
|
| 2130 | + } |
|
| 2056 | 2131 | |
| 2057 | 2132 | // Sanitize reCAPTCHA fields? |
| 2058 | 2133 | if ($thisVerification['can_recaptcha']) |
@@ -2065,11 +2140,12 @@ discard block |
||
| 2065 | 2140 | } |
| 2066 | 2141 | |
| 2067 | 2142 | // Add javascript for the object. |
| 2068 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
| 2069 | - $context['insert_after_template'] .= ' |
|
| 2143 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
| 2144 | + $context['insert_after_template'] .= ' |
|
| 2070 | 2145 | <script> |
| 2071 | 2146 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
| 2072 | 2147 | </script>'; |
| 2148 | + } |
|
| 2073 | 2149 | |
| 2074 | 2150 | // If we want questions do we have a cache of all the IDs? |
| 2075 | 2151 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2092,8 +2168,9 @@ discard block |
||
| 2092 | 2168 | unset ($row['id_question']); |
| 2093 | 2169 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
| 2094 | 2170 | $row['answers'] = $smcFunc['json_decode']($row['answers'], true); |
| 2095 | - foreach ($row['answers'] as $k => $v) |
|
| 2096 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2171 | + foreach ($row['answers'] as $k => $v) { |
|
| 2172 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2173 | + } |
|
| 2097 | 2174 | |
| 2098 | 2175 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
| 2099 | 2176 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2104,35 +2181,42 @@ discard block |
||
| 2104 | 2181 | } |
| 2105 | 2182 | } |
| 2106 | 2183 | |
| 2107 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
| 2108 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2184 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
| 2185 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2186 | + } |
|
| 2109 | 2187 | |
| 2110 | 2188 | // Do we need to refresh the verification? |
| 2111 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
| 2112 | - $force_refresh = true; |
|
| 2113 | - else |
|
| 2114 | - $force_refresh = false; |
|
| 2189 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
| 2190 | + $force_refresh = true; |
|
| 2191 | + } else { |
|
| 2192 | + $force_refresh = false; |
|
| 2193 | + } |
|
| 2115 | 2194 | |
| 2116 | 2195 | // This can also force a fresh, although unlikely. |
| 2117 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2118 | - $force_refresh = true; |
|
| 2196 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2197 | + $force_refresh = true; |
|
| 2198 | + } |
|
| 2119 | 2199 | |
| 2120 | 2200 | $verification_errors = array(); |
| 2121 | 2201 | // Start with any testing. |
| 2122 | 2202 | if ($do_test) |
| 2123 | 2203 | { |
| 2124 | 2204 | // This cannot happen! |
| 2125 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
| 2126 | - fatal_lang_error('no_access', false); |
|
| 2205 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
| 2206 | + fatal_lang_error('no_access', false); |
|
| 2207 | + } |
|
| 2127 | 2208 | // ... nor this! |
| 2128 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2129 | - fatal_lang_error('no_access', false); |
|
| 2209 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2210 | + fatal_lang_error('no_access', false); |
|
| 2211 | + } |
|
| 2130 | 2212 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
| 2131 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
| 2132 | - fatal_lang_error('no_access', false); |
|
| 2213 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
| 2214 | + fatal_lang_error('no_access', false); |
|
| 2215 | + } |
|
| 2133 | 2216 | // While we're here, did the user do something bad? |
| 2134 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
| 2135 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2217 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
| 2218 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2219 | + } |
|
| 2136 | 2220 | |
| 2137 | 2221 | if ($thisVerification['can_recaptcha']) |
| 2138 | 2222 | { |
@@ -2143,22 +2227,25 @@ discard block |
||
| 2143 | 2227 | { |
| 2144 | 2228 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
| 2145 | 2229 | |
| 2146 | - if (!$resp->isSuccess()) |
|
| 2147 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2230 | + if (!$resp->isSuccess()) { |
|
| 2231 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2232 | + } |
|
| 2233 | + } else { |
|
| 2234 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2148 | 2235 | } |
| 2149 | - else |
|
| 2150 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2151 | 2236 | } |
| 2152 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
| 2153 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2237 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
| 2238 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2239 | + } |
|
| 2154 | 2240 | if ($thisVerification['number_questions']) |
| 2155 | 2241 | { |
| 2156 | 2242 | $incorrectQuestions = array(); |
| 2157 | 2243 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
| 2158 | 2244 | { |
| 2159 | 2245 | // We don't have this question any more, thus no answers. |
| 2160 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
| 2161 | - continue; |
|
| 2246 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
| 2247 | + continue; |
|
| 2248 | + } |
|
| 2162 | 2249 | // This is quite complex. We have our question but it might have multiple answers. |
| 2163 | 2250 | // First, did they actually answer this question? |
| 2164 | 2251 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2170,24 +2257,28 @@ discard block |
||
| 2170 | 2257 | else |
| 2171 | 2258 | { |
| 2172 | 2259 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
| 2173 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
| 2174 | - $incorrectQuestions[] = $q; |
|
| 2260 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
| 2261 | + $incorrectQuestions[] = $q; |
|
| 2262 | + } |
|
| 2175 | 2263 | } |
| 2176 | 2264 | } |
| 2177 | 2265 | |
| 2178 | - if (!empty($incorrectQuestions)) |
|
| 2179 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2266 | + if (!empty($incorrectQuestions)) { |
|
| 2267 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2268 | + } |
|
| 2180 | 2269 | } |
| 2181 | 2270 | } |
| 2182 | 2271 | |
| 2183 | 2272 | // Any errors means we refresh potentially. |
| 2184 | 2273 | if (!empty($verification_errors)) |
| 2185 | 2274 | { |
| 2186 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
| 2187 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2275 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
| 2276 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2277 | + } |
|
| 2188 | 2278 | // Too many errors? |
| 2189 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
| 2190 | - $force_refresh = true; |
|
| 2279 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
| 2280 | + $force_refresh = true; |
|
| 2281 | + } |
|
| 2191 | 2282 | |
| 2192 | 2283 | // Keep a track of these. |
| 2193 | 2284 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2220,8 +2311,9 @@ discard block |
||
| 2220 | 2311 | // Are we overriding the range? |
| 2221 | 2312 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
| 2222 | 2313 | |
| 2223 | - for ($i = 0; $i < 6; $i++) |
|
| 2224 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2314 | + for ($i = 0; $i < 6; $i++) { |
|
| 2315 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2316 | + } |
|
| 2225 | 2317 | } |
| 2226 | 2318 | |
| 2227 | 2319 | // Getting some new questions? |
@@ -2229,8 +2321,9 @@ discard block |
||
| 2229 | 2321 | { |
| 2230 | 2322 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
| 2231 | 2323 | $possible_langs = array(); |
| 2232 | - if (isset($_SESSION['language'])) |
|
| 2233 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2324 | + if (isset($_SESSION['language'])) { |
|
| 2325 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2326 | + } |
|
| 2234 | 2327 | if (!empty($user_info['language'])); |
| 2235 | 2328 | $possible_langs[] = $user_info['language']; |
| 2236 | 2329 | $possible_langs[] = $language; |
@@ -2249,8 +2342,7 @@ discard block |
||
| 2249 | 2342 | } |
| 2250 | 2343 | } |
| 2251 | 2344 | } |
| 2252 | - } |
|
| 2253 | - else |
|
| 2345 | + } else |
|
| 2254 | 2346 | { |
| 2255 | 2347 | // Same questions as before. |
| 2256 | 2348 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2260,8 +2352,9 @@ discard block |
||
| 2260 | 2352 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
| 2261 | 2353 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
| 2262 | 2354 | { |
| 2263 | - if (!isset($context['html_headers'])) |
|
| 2264 | - $context['html_headers'] = ''; |
|
| 2355 | + if (!isset($context['html_headers'])) { |
|
| 2356 | + $context['html_headers'] = ''; |
|
| 2357 | + } |
|
| 2265 | 2358 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
| 2266 | 2359 | } |
| 2267 | 2360 | |
@@ -2287,11 +2380,13 @@ discard block |
||
| 2287 | 2380 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
| 2288 | 2381 | |
| 2289 | 2382 | // Return errors if we have them. |
| 2290 | - if (!empty($verification_errors)) |
|
| 2291 | - return $verification_errors; |
|
| 2383 | + if (!empty($verification_errors)) { |
|
| 2384 | + return $verification_errors; |
|
| 2385 | + } |
|
| 2292 | 2386 | // If we had a test that one, make a note. |
| 2293 | - elseif ($do_test) |
|
| 2294 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2387 | + elseif ($do_test) { |
|
| 2388 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2389 | + } |
|
| 2295 | 2390 | |
| 2296 | 2391 | // Say that everything went well chaps. |
| 2297 | 2392 | return true; |
@@ -2316,8 +2411,9 @@ discard block |
||
| 2316 | 2411 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
| 2317 | 2412 | |
| 2318 | 2413 | // If we're just checking the callback function is registered return true or false. |
| 2319 | - if ($checkRegistered != null) |
|
| 2320 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2414 | + if ($checkRegistered != null) { |
|
| 2415 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2416 | + } |
|
| 2321 | 2417 | |
| 2322 | 2418 | checkSession('get'); |
| 2323 | 2419 | loadTemplate('Xml'); |
@@ -2468,24 +2564,27 @@ discard block |
||
| 2468 | 2564 | foreach ($possible_versions as $ver) |
| 2469 | 2565 | { |
| 2470 | 2566 | $ver = trim($ver); |
| 2471 | - if (strpos($ver, 'SMF') === 0) |
|
| 2472 | - $versions[] = $ver; |
|
| 2567 | + if (strpos($ver, 'SMF') === 0) { |
|
| 2568 | + $versions[] = $ver; |
|
| 2569 | + } |
|
| 2473 | 2570 | } |
| 2474 | 2571 | } |
| 2475 | 2572 | $smcFunc['db_free_result']($request); |
| 2476 | 2573 | |
| 2477 | 2574 | // Just in case we don't have ANYthing. |
| 2478 | - if (empty($versions)) |
|
| 2479 | - $versions = array('SMF 2.0'); |
|
| 2575 | + if (empty($versions)) { |
|
| 2576 | + $versions = array('SMF 2.0'); |
|
| 2577 | + } |
|
| 2480 | 2578 | |
| 2481 | - foreach ($versions as $id => $version) |
|
| 2482 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2579 | + foreach ($versions as $id => $version) { |
|
| 2580 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2483 | 2581 | $xml_data['items']['children'][] = array( |
| 2484 | 2582 | 'attributes' => array( |
| 2485 | 2583 | 'id' => $id, |
| 2486 | 2584 | ), |
| 2487 | 2585 | 'value' => $version, |
| 2488 | 2586 | ); |
| 2587 | + } |
|
| 2489 | 2588 | |
| 2490 | 2589 | return $xml_data; |
| 2491 | 2590 | } |