@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | { |
387 | 387 | $val = 'CASE '; |
388 | 388 | foreach ($members as $k => $v) |
389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
389 | + $val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
390 | 390 | $val = $val . ' END'; |
391 | 391 | $type = 'raw'; |
392 | 392 | } |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
818 | 818 | if (empty($unsupportedFormats)) |
819 | 819 | { |
820 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
820 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
821 | 821 | { |
822 | 822 | $value = @strftime('%' . $format); |
823 | 823 | |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
1183 | 1183 | ), |
1184 | 1184 | 'content' => '$1', |
1185 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1185 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1186 | 1186 | { |
1187 | 1187 | $returnContext = ''; |
1188 | 1188 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
1220 | - $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>'; |
|
1220 | + $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>'; |
|
1221 | 1221 | else |
1222 | 1222 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
1223 | 1223 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | 'type' => 'unparsed_content', |
1247 | 1247 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
1248 | 1248 | // @todo Maybe this can be simplified? |
1249 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1249 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1250 | 1250 | { |
1251 | 1251 | if (!isset($disabled['code'])) |
1252 | 1252 | { |
@@ -1283,7 +1283,7 @@ discard block |
||
1283 | 1283 | 'type' => 'unparsed_equals_content', |
1284 | 1284 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
1285 | 1285 | // @todo Maybe this can be simplified? |
1286 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1286 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1287 | 1287 | { |
1288 | 1288 | if (!isset($disabled['code'])) |
1289 | 1289 | { |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | 'type' => 'unparsed_content', |
1328 | 1328 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
1329 | 1329 | // @todo Should this respect guest_hideContacts? |
1330 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1330 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1331 | 1331 | { |
1332 | 1332 | $data = strtr($data, array('<br>' => '')); |
1333 | 1333 | }, |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | 'type' => 'unparsed_commas_content', |
1347 | 1347 | 'test' => '\d+,\d+\]', |
1348 | 1348 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1349 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1349 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1350 | 1350 | { |
1351 | 1351 | if (isset($disabled['url'])) |
1352 | 1352 | $tag['content'] = '$1'; |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
1363 | 1363 | 'before' => '<div $1>', |
1364 | 1364 | 'after' => '</div>', |
1365 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1365 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1366 | 1366 | { |
1367 | 1367 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1368 | 1368 | |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
1412 | 1412 | ), |
1413 | 1413 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
1414 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1414 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1415 | 1415 | { |
1416 | 1416 | global $image_proxy_enabled, $image_proxy_secret, $boardurl, $user_info; |
1417 | 1417 | |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | 'tag' => 'img', |
1438 | 1438 | 'type' => 'unparsed_content', |
1439 | 1439 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
1440 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1440 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1441 | 1441 | { |
1442 | 1442 | global $image_proxy_enabled, $image_proxy_secret, $boardurl, $user_info; |
1443 | 1443 | |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | 'tag' => 'iurl', |
1464 | 1464 | 'type' => 'unparsed_content', |
1465 | 1465 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
1466 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1466 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1467 | 1467 | { |
1468 | 1468 | $data = strtr($data, array('<br>' => '')); |
1469 | 1469 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | 'quoted' => 'optional', |
1478 | 1478 | 'before' => '<a href="$1" class="bbc_link">', |
1479 | 1479 | 'after' => '</a>', |
1480 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1480 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1481 | 1481 | { |
1482 | 1482 | if (substr($data, 0, 1) == '#') |
1483 | 1483 | $data = '#post_' . substr($data, 1); |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | 'tag' => 'php', |
1558 | 1558 | 'type' => 'unparsed_content', |
1559 | 1559 | 'content' => '<span class="phpcode">$1</span>', |
1560 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
1560 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
1561 | 1561 | { |
1562 | 1562 | if (!isset($disabled['php'])) |
1563 | 1563 | { |
@@ -1655,7 +1655,7 @@ discard block |
||
1655 | 1655 | 'test' => '[1-7]\]', |
1656 | 1656 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
1657 | 1657 | 'after' => '</span>', |
1658 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1658 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1659 | 1659 | { |
1660 | 1660 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
1661 | 1661 | $data = $sizes[$data] . 'em'; |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | 'tag' => 'time', |
1694 | 1694 | 'type' => 'unparsed_content', |
1695 | 1695 | 'content' => '$1', |
1696 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1696 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1697 | 1697 | { |
1698 | 1698 | if (is_numeric($data)) |
1699 | 1699 | $data = timeformat($data); |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | 'tag' => 'url', |
1722 | 1722 | 'type' => 'unparsed_content', |
1723 | 1723 | 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', |
1724 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1724 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1725 | 1725 | { |
1726 | 1726 | $data = strtr($data, array('<br>' => '')); |
1727 | 1727 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | 'quoted' => 'optional', |
1736 | 1736 | 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', |
1737 | 1737 | 'after' => '</a>', |
1738 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1738 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1739 | 1739 | { |
1740 | 1740 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1741 | 1741 | if (empty($scheme)) |
@@ -1761,7 +1761,7 @@ discard block |
||
1761 | 1761 | { |
1762 | 1762 | if (isset($temp_bbc)) |
1763 | 1763 | $bbc_codes = $temp_bbc; |
1764 | - usort($codes, function ($a, $b) { |
|
1764 | + usort($codes, function($a, $b) { |
|
1765 | 1765 | return strcmp($a['tag'], $b['tag']); |
1766 | 1766 | }); |
1767 | 1767 | return $codes; |
@@ -1998,7 +1998,7 @@ discard block |
||
1998 | 1998 | # a run of Unicode domain name characters and a dot |
1999 | 1999 | [\p{L}\p{M}\p{N}\-.:@]+\. |
2000 | 2000 | # and then a TLD valid in the DNS or the reserved "local" TLD |
2001 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
2001 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
2002 | 2002 | ) |
2003 | 2003 | # followed by a non-domain character or end of line |
2004 | 2004 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2066,7 +2066,7 @@ discard block |
||
2066 | 2066 | )? |
2067 | 2067 | '; |
2068 | 2068 | |
2069 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
2069 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
2070 | 2070 | $url = array_shift($matches); |
2071 | 2071 | |
2072 | 2072 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2147,7 +2147,7 @@ discard block |
||
2147 | 2147 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2148 | 2148 | |
2149 | 2149 | // A closing tag that doesn't match any open tags? Skip it. |
2150 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2150 | + if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags))) |
|
2151 | 2151 | continue; |
2152 | 2152 | |
2153 | 2153 | $to_close = array(); |
@@ -2810,7 +2810,7 @@ discard block |
||
2810 | 2810 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
2811 | 2811 | { |
2812 | 2812 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
2813 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2813 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2814 | 2814 | |
2815 | 2815 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
2816 | 2816 | |
@@ -2827,7 +2827,7 @@ discard block |
||
2827 | 2827 | |
2828 | 2828 | // Replace away! |
2829 | 2829 | $message = preg_replace_callback($smileyPregSearch, |
2830 | - function ($matches) use ($smileyPregReplacements) |
|
2830 | + function($matches) use ($smileyPregReplacements) |
|
2831 | 2831 | { |
2832 | 2832 | return $smileyPregReplacements[$matches[1]]; |
2833 | 2833 | }, $message); |
@@ -2893,13 +2893,13 @@ discard block |
||
2893 | 2893 | { |
2894 | 2894 | if (defined('SID') && SID != '') |
2895 | 2895 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
2896 | - function ($m) use ($scripturl) |
|
2896 | + function($m) use ($scripturl) |
|
2897 | 2897 | { |
2898 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
2898 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
2899 | 2899 | }, $setLocation); |
2900 | 2900 | else |
2901 | 2901 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
2902 | - function ($m) use ($scripturl) |
|
2902 | + function($m) use ($scripturl) |
|
2903 | 2903 | { |
2904 | 2904 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
2905 | 2905 | }, $setLocation); |
@@ -3222,7 +3222,7 @@ discard block |
||
3222 | 3222 | |
3223 | 3223 | // Add a generic "Are you sure?" confirmation message. |
3224 | 3224 | addInlineJavaScript(' |
3225 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
3225 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
3226 | 3226 | |
3227 | 3227 | // Now add the capping code for avatars. |
3228 | 3228 | 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') |
@@ -3583,7 +3583,7 @@ discard block |
||
3583 | 3583 | |
3584 | 3584 | else |
3585 | 3585 | echo ' |
3586 | - <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
|
3586 | + <script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>'; |
|
3587 | 3587 | } |
3588 | 3588 | |
3589 | 3589 | // Inline JavaScript - Actually useful some times! |
@@ -3661,14 +3661,14 @@ discard block |
||
3661 | 3661 | |
3662 | 3662 | else |
3663 | 3663 | echo ' |
3664 | - <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
|
3664 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">'; |
|
3665 | 3665 | } |
3666 | 3666 | |
3667 | 3667 | // Print the rest after the minified files. |
3668 | 3668 | if (!empty($normal)) |
3669 | 3669 | foreach ($normal as $nf) |
3670 | 3670 | echo ' |
3671 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
3671 | + <link rel="stylesheet" href="', $nf, '">'; |
|
3672 | 3672 | |
3673 | 3673 | if ($db_show_debug === true) |
3674 | 3674 | { |
@@ -3684,7 +3684,7 @@ discard block |
||
3684 | 3684 | <style>'; |
3685 | 3685 | |
3686 | 3686 | foreach ($context['css_header'] as $css) |
3687 | - echo $css .' |
|
3687 | + echo $css . ' |
|
3688 | 3688 | '; |
3689 | 3689 | |
3690 | 3690 | echo' |
@@ -3713,27 +3713,27 @@ discard block |
||
3713 | 3713 | return false; |
3714 | 3714 | |
3715 | 3715 | // Did we already did this? |
3716 | - $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
|
3716 | + $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400); |
|
3717 | 3717 | |
3718 | 3718 | // Already done? |
3719 | 3719 | if (!empty($toCache)) |
3720 | 3720 | return true; |
3721 | 3721 | |
3722 | 3722 | // No namespaces, sorry! |
3723 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
3723 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
3724 | 3724 | |
3725 | 3725 | // Temp path. |
3726 | - $cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/'; |
|
3726 | + $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
|
3727 | 3727 | |
3728 | 3728 | // What kind of file are we going to create? |
3729 | - $toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type; |
|
3729 | + $toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type; |
|
3730 | 3730 | |
3731 | 3731 | // File has to exists, if it isn't try to create it. |
3732 | 3732 | if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate)) |
3733 | 3733 | { |
3734 | 3734 | loadLanguage('Errors'); |
3735 | 3735 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
3736 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
3736 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
3737 | 3737 | |
3738 | 3738 | // The process failed so roll back to print each individual file. |
3739 | 3739 | return $data; |
@@ -3768,14 +3768,14 @@ discard block |
||
3768 | 3768 | { |
3769 | 3769 | loadLanguage('Errors'); |
3770 | 3770 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
3771 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
3771 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
3772 | 3772 | |
3773 | 3773 | // The process failed so roll back to print each individual file. |
3774 | 3774 | return $data; |
3775 | 3775 | } |
3776 | 3776 | |
3777 | 3777 | // And create a long lived cache entry. |
3778 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400); |
|
3778 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400); |
|
3779 | 3779 | |
3780 | 3780 | return true; |
3781 | 3781 | } |
@@ -3835,7 +3835,7 @@ discard block |
||
3835 | 3835 | else |
3836 | 3836 | $path = $modSettings['attachmentUploadDir']; |
3837 | 3837 | |
3838 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
3838 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
3839 | 3839 | } |
3840 | 3840 | |
3841 | 3841 | /** |
@@ -3879,10 +3879,10 @@ discard block |
||
3879 | 3879 | $valid_low = isValidIP($ip_parts[0]); |
3880 | 3880 | $valid_high = isValidIP($ip_parts[1]); |
3881 | 3881 | $count = 0; |
3882 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
3882 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
3883 | 3883 | $max = ($mode == ':' ? 'ffff' : '255'); |
3884 | 3884 | $min = 0; |
3885 | - if(!$valid_low) |
|
3885 | + if (!$valid_low) |
|
3886 | 3886 | { |
3887 | 3887 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
3888 | 3888 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3896,7 +3896,7 @@ discard block |
||
3896 | 3896 | } |
3897 | 3897 | |
3898 | 3898 | $count = 0; |
3899 | - if(!$valid_high) |
|
3899 | + if (!$valid_high) |
|
3900 | 3900 | { |
3901 | 3901 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
3902 | 3902 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3909,7 +3909,7 @@ discard block |
||
3909 | 3909 | } |
3910 | 3910 | } |
3911 | 3911 | |
3912 | - if($valid_high && $valid_low) |
|
3912 | + if ($valid_high && $valid_low) |
|
3913 | 3913 | { |
3914 | 3914 | $ip_array['low'] = $ip_parts[0]; |
3915 | 3915 | $ip_array['high'] = $ip_parts[1]; |
@@ -4091,7 +4091,7 @@ discard block |
||
4091 | 4091 | addInlineJavaScript(' |
4092 | 4092 | var user_menus = new smc_PopupMenu(); |
4093 | 4093 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4094 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
4094 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
4095 | 4095 | if ($context['allow_pm']) |
4096 | 4096 | addInlineJavaScript(' |
4097 | 4097 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4727,7 +4727,7 @@ discard block |
||
4727 | 4727 | // No? try a fallback to $sourcedir |
4728 | 4728 | else |
4729 | 4729 | { |
4730 | - $absPath = $sourcedir .'/'. $file; |
|
4730 | + $absPath = $sourcedir . '/' . $file; |
|
4731 | 4731 | |
4732 | 4732 | if (file_exists($absPath)) |
4733 | 4733 | require_once($absPath); |
@@ -4808,15 +4808,15 @@ discard block |
||
4808 | 4808 | |
4809 | 4809 | // UTF-8 occurences of MS special characters |
4810 | 4810 | $findchars_utf8 = array( |
4811 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
4812 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
4813 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
4814 | - "\xe2\x80\x98", // left single curly quote |
|
4815 | - "\xe2\x80\x99", // right single curly quote |
|
4816 | - "\xe2\x80\x9c", // left double curly quote |
|
4817 | - "\xe2\x80\x9d", // right double curly quote |
|
4818 | - "\xe2\x80\x93", // en dash |
|
4819 | - "\xe2\x80\x94", // em dash |
|
4811 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
4812 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
4813 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
4814 | + "\xe2\x80\x98", // left single curly quote |
|
4815 | + "\xe2\x80\x99", // right single curly quote |
|
4816 | + "\xe2\x80\x9c", // left double curly quote |
|
4817 | + "\xe2\x80\x9d", // right double curly quote |
|
4818 | + "\xe2\x80\x93", // en dash |
|
4819 | + "\xe2\x80\x94", // em dash |
|
4820 | 4820 | ); |
4821 | 4821 | |
4822 | 4822 | // windows 1252 / iso equivalents |
@@ -4834,15 +4834,15 @@ discard block |
||
4834 | 4834 | |
4835 | 4835 | // safe replacements |
4836 | 4836 | $replacechars = array( |
4837 | - ',', // ‚ |
|
4838 | - ',,', // „ |
|
4839 | - '...', // … |
|
4840 | - "'", // ‘ |
|
4841 | - "'", // ’ |
|
4842 | - '"', // “ |
|
4843 | - '"', // ” |
|
4844 | - '-', // – |
|
4845 | - '--', // — |
|
4837 | + ',', // ‚ |
|
4838 | + ',,', // „ |
|
4839 | + '...', // … |
|
4840 | + "'", // ‘ |
|
4841 | + "'", // ’ |
|
4842 | + '"', // “ |
|
4843 | + '"', // ” |
|
4844 | + '-', // – |
|
4845 | + '--', // — |
|
4846 | 4846 | ); |
4847 | 4847 | |
4848 | 4848 | if ($context['utf8']) |
@@ -5260,7 +5260,7 @@ discard block |
||
5260 | 5260 | */ |
5261 | 5261 | function inet_dtop($bin) |
5262 | 5262 | { |
5263 | - if(empty($bin)) |
|
5263 | + if (empty($bin)) |
|
5264 | 5264 | return ''; |
5265 | 5265 | |
5266 | 5266 | global $db_type; |
@@ -5291,28 +5291,28 @@ discard block |
||
5291 | 5291 | */ |
5292 | 5292 | function _safe_serialize($value) |
5293 | 5293 | { |
5294 | - if(is_null($value)) |
|
5294 | + if (is_null($value)) |
|
5295 | 5295 | return 'N;'; |
5296 | 5296 | |
5297 | - if(is_bool($value)) |
|
5298 | - return 'b:'. (int) $value .';'; |
|
5297 | + if (is_bool($value)) |
|
5298 | + return 'b:' . (int) $value . ';'; |
|
5299 | 5299 | |
5300 | - if(is_int($value)) |
|
5301 | - return 'i:'. $value .';'; |
|
5300 | + if (is_int($value)) |
|
5301 | + return 'i:' . $value . ';'; |
|
5302 | 5302 | |
5303 | - if(is_float($value)) |
|
5304 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5303 | + if (is_float($value)) |
|
5304 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
5305 | 5305 | |
5306 | - if(is_string($value)) |
|
5307 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5306 | + if (is_string($value)) |
|
5307 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
5308 | 5308 | |
5309 | - if(is_array($value)) |
|
5309 | + if (is_array($value)) |
|
5310 | 5310 | { |
5311 | 5311 | $out = ''; |
5312 | - foreach($value as $k => $v) |
|
5312 | + foreach ($value as $k => $v) |
|
5313 | 5313 | $out .= _safe_serialize($k) . _safe_serialize($v); |
5314 | 5314 | |
5315 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
5315 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
5316 | 5316 | } |
5317 | 5317 | |
5318 | 5318 | // safe_serialize cannot serialize resources or objects. |
@@ -5354,7 +5354,7 @@ discard block |
||
5354 | 5354 | function _safe_unserialize($str) |
5355 | 5355 | { |
5356 | 5356 | // Input is not a string. |
5357 | - if(empty($str) || !is_string($str)) |
|
5357 | + if (empty($str) || !is_string($str)) |
|
5358 | 5358 | return false; |
5359 | 5359 | |
5360 | 5360 | $stack = array(); |
@@ -5368,40 +5368,40 @@ discard block |
||
5368 | 5368 | * 3 - in array, expecting value or another array |
5369 | 5369 | */ |
5370 | 5370 | $state = 0; |
5371 | - while($state != 1) |
|
5371 | + while ($state != 1) |
|
5372 | 5372 | { |
5373 | 5373 | $type = isset($str[0]) ? $str[0] : ''; |
5374 | - if($type == '}') |
|
5374 | + if ($type == '}') |
|
5375 | 5375 | $str = substr($str, 1); |
5376 | 5376 | |
5377 | - else if($type == 'N' && $str[1] == ';') |
|
5377 | + else if ($type == 'N' && $str[1] == ';') |
|
5378 | 5378 | { |
5379 | 5379 | $value = null; |
5380 | 5380 | $str = substr($str, 2); |
5381 | 5381 | } |
5382 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5382 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5383 | 5383 | { |
5384 | 5384 | $value = $matches[1] == '1' ? true : false; |
5385 | 5385 | $str = substr($str, 4); |
5386 | 5386 | } |
5387 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5387 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5388 | 5388 | { |
5389 | - $value = (int)$matches[1]; |
|
5389 | + $value = (int) $matches[1]; |
|
5390 | 5390 | $str = $matches[2]; |
5391 | 5391 | } |
5392 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5392 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5393 | 5393 | { |
5394 | - $value = (float)$matches[1]; |
|
5394 | + $value = (float) $matches[1]; |
|
5395 | 5395 | $str = $matches[3]; |
5396 | 5396 | } |
5397 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5397 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
5398 | 5398 | { |
5399 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
5400 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
5399 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
5400 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
5401 | 5401 | } |
5402 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5402 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5403 | 5403 | { |
5404 | - $expectedLength = (int)$matches[1]; |
|
5404 | + $expectedLength = (int) $matches[1]; |
|
5405 | 5405 | $str = $matches[2]; |
5406 | 5406 | } |
5407 | 5407 | |
@@ -5409,10 +5409,10 @@ discard block |
||
5409 | 5409 | else |
5410 | 5410 | return false; |
5411 | 5411 | |
5412 | - switch($state) |
|
5412 | + switch ($state) |
|
5413 | 5413 | { |
5414 | 5414 | case 3: // In array, expecting value or another array. |
5415 | - if($type == 'a') |
|
5415 | + if ($type == 'a') |
|
5416 | 5416 | { |
5417 | 5417 | $stack[] = &$list; |
5418 | 5418 | $list[$key] = array(); |
@@ -5421,7 +5421,7 @@ discard block |
||
5421 | 5421 | $state = 2; |
5422 | 5422 | break; |
5423 | 5423 | } |
5424 | - if($type != '}') |
|
5424 | + if ($type != '}') |
|
5425 | 5425 | { |
5426 | 5426 | $list[$key] = $value; |
5427 | 5427 | $state = 2; |
@@ -5432,29 +5432,29 @@ discard block |
||
5432 | 5432 | return false; |
5433 | 5433 | |
5434 | 5434 | case 2: // in array, expecting end of array or a key |
5435 | - if($type == '}') |
|
5435 | + if ($type == '}') |
|
5436 | 5436 | { |
5437 | 5437 | // Array size is less than expected. |
5438 | - if(count($list) < end($expected)) |
|
5438 | + if (count($list) < end($expected)) |
|
5439 | 5439 | return false; |
5440 | 5440 | |
5441 | 5441 | unset($list); |
5442 | - $list = &$stack[count($stack)-1]; |
|
5442 | + $list = &$stack[count($stack) - 1]; |
|
5443 | 5443 | array_pop($stack); |
5444 | 5444 | |
5445 | 5445 | // Go to terminal state if we're at the end of the root array. |
5446 | 5446 | array_pop($expected); |
5447 | 5447 | |
5448 | - if(count($expected) == 0) |
|
5448 | + if (count($expected) == 0) |
|
5449 | 5449 | $state = 1; |
5450 | 5450 | |
5451 | 5451 | break; |
5452 | 5452 | } |
5453 | 5453 | |
5454 | - if($type == 'i' || $type == 's') |
|
5454 | + if ($type == 'i' || $type == 's') |
|
5455 | 5455 | { |
5456 | 5456 | // Array size exceeds expected length. |
5457 | - if(count($list) >= end($expected)) |
|
5457 | + if (count($list) >= end($expected)) |
|
5458 | 5458 | return false; |
5459 | 5459 | |
5460 | 5460 | $key = $value; |
@@ -5467,7 +5467,7 @@ discard block |
||
5467 | 5467 | |
5468 | 5468 | // Expecting array or value. |
5469 | 5469 | case 0: |
5470 | - if($type == 'a') |
|
5470 | + if ($type == 'a') |
|
5471 | 5471 | { |
5472 | 5472 | $data = array(); |
5473 | 5473 | $list = &$data; |
@@ -5476,7 +5476,7 @@ discard block |
||
5476 | 5476 | break; |
5477 | 5477 | } |
5478 | 5478 | |
5479 | - if($type != '}') |
|
5479 | + if ($type != '}') |
|
5480 | 5480 | { |
5481 | 5481 | $data = $value; |
5482 | 5482 | $state = 1; |
@@ -5489,7 +5489,7 @@ discard block |
||
5489 | 5489 | } |
5490 | 5490 | |
5491 | 5491 | // Trailing data in input. |
5492 | - if(!empty($str)) |
|
5492 | + if (!empty($str)) |
|
5493 | 5493 | return false; |
5494 | 5494 | |
5495 | 5495 | return $data; |
@@ -5543,7 +5543,7 @@ discard block |
||
5543 | 5543 | // Set different modes. |
5544 | 5544 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
5545 | 5545 | |
5546 | - foreach($chmodValues as $val) |
|
5546 | + foreach ($chmodValues as $val) |
|
5547 | 5547 | { |
5548 | 5548 | // If it's writable, break out of the loop. |
5549 | 5549 | if (is_writable($file)) |
@@ -5578,13 +5578,13 @@ discard block |
||
5578 | 5578 | $returnArray = @json_decode($json, $returnAsArray); |
5579 | 5579 | |
5580 | 5580 | // PHP 5.3 so no json_last_error_msg() |
5581 | - switch(json_last_error()) |
|
5581 | + switch (json_last_error()) |
|
5582 | 5582 | { |
5583 | 5583 | case JSON_ERROR_NONE: |
5584 | 5584 | $jsonError = false; |
5585 | 5585 | break; |
5586 | 5586 | case JSON_ERROR_DEPTH: |
5587 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
5587 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
5588 | 5588 | break; |
5589 | 5589 | case JSON_ERROR_STATE_MISMATCH: |
5590 | 5590 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5612,10 +5612,10 @@ discard block |
||
5612 | 5612 | loadLanguage('Errors'); |
5613 | 5613 | |
5614 | 5614 | if (!empty($jsonDebug)) |
5615 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5615 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5616 | 5616 | |
5617 | 5617 | else |
5618 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5618 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
5619 | 5619 | |
5620 | 5620 | // Everyone expects an array. |
5621 | 5621 | return array(); |
@@ -5727,7 +5727,7 @@ discard block |
||
5727 | 5727 | }); |
5728 | 5728 | |
5729 | 5729 | // Convert Punycode to Unicode |
5730 | - $tlds = array_map(function ($input) { |
|
5730 | + $tlds = array_map(function($input) { |
|
5731 | 5731 | $prefix = 'xn--'; |
5732 | 5732 | $safe_char = 0xFFFC; |
5733 | 5733 | $base = 36; |
@@ -5743,7 +5743,7 @@ discard block |
||
5743 | 5743 | |
5744 | 5744 | foreach ($enco_parts as $encoded) |
5745 | 5745 | { |
5746 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
5746 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
5747 | 5747 | { |
5748 | 5748 | $output_parts[] = $encoded; |
5749 | 5749 | continue; |
@@ -5754,7 +5754,7 @@ discard block |
||
5754 | 5754 | $idx = 0; |
5755 | 5755 | $char = 0x80; |
5756 | 5756 | $decoded = array(); |
5757 | - $output=''; |
|
5757 | + $output = ''; |
|
5758 | 5758 | $delim_pos = strrpos($encoded, '-'); |
5759 | 5759 | |
5760 | 5760 | if ($delim_pos > strlen($prefix)) |
@@ -5770,7 +5770,7 @@ discard block |
||
5770 | 5770 | |
5771 | 5771 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
5772 | 5772 | { |
5773 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
5773 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
5774 | 5774 | { |
5775 | 5775 | $cp = ord($encoded{$enco_idx++}); |
5776 | 5776 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5811,15 +5811,15 @@ discard block |
||
5811 | 5811 | |
5812 | 5812 | // 2 bytes |
5813 | 5813 | elseif ($v < (1 << 11)) |
5814 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
5814 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
5815 | 5815 | |
5816 | 5816 | // 3 bytes |
5817 | 5817 | elseif ($v < (1 << 16)) |
5818 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5818 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5819 | 5819 | |
5820 | 5820 | // 4 bytes |
5821 | 5821 | elseif ($v < (1 << 21)) |
5822 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5822 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5823 | 5823 | |
5824 | 5824 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5825 | 5825 | else |
@@ -5924,7 +5924,7 @@ discard block |
||
5924 | 5924 | } |
5925 | 5925 | |
5926 | 5926 | // This recursive function creates the index array from the strings |
5927 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5927 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5928 | 5928 | { |
5929 | 5929 | static $depth = 0; |
5930 | 5930 | $depth++; |
@@ -5951,7 +5951,7 @@ discard block |
||
5951 | 5951 | }; |
5952 | 5952 | |
5953 | 5953 | // This recursive function turns the index array into a regular expression |
5954 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5954 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5955 | 5955 | { |
5956 | 5956 | static $depth = 0; |
5957 | 5957 | $depth++; |
@@ -5975,11 +5975,11 @@ discard block |
||
5975 | 5975 | |
5976 | 5976 | if (count(array_keys($value)) == 1) |
5977 | 5977 | { |
5978 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
5978 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
5979 | 5979 | $new_key .= $new_key_array[0]; |
5980 | 5980 | } |
5981 | 5981 | else |
5982 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5982 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
5983 | 5983 | } |
5984 | 5984 | |
5985 | 5985 | if ($depth > 1) |
@@ -6022,10 +6022,10 @@ discard block |
||
6022 | 6022 | { |
6023 | 6023 | $regex = array(); |
6024 | 6024 | while (!empty($index)) |
6025 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6025 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
6026 | 6026 | } |
6027 | 6027 | else |
6028 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6028 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
6029 | 6029 | |
6030 | 6030 | // Restore PHP's internal character encoding to whatever it was originally |
6031 | 6031 | if (!empty($current_encoding)) |
@@ -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 ($var == 'alerts' && ($val === '+' || $val === '-')) |
@@ -385,18 +394,17 @@ discard block |
||
385 | 394 | if (is_array($members)) |
386 | 395 | { |
387 | 396 | $val = 'CASE '; |
388 | - foreach ($members as $k => $v) |
|
389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
397 | + foreach ($members as $k => $v) { |
|
398 | + $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
399 | + } |
|
390 | 400 | $val = $val . ' END'; |
391 | 401 | $type = 'raw'; |
392 | - } |
|
393 | - else |
|
402 | + } else |
|
394 | 403 | { |
395 | 404 | $blub = fetch_alerts($members, false, 0, array(), false); |
396 | 405 | $val = count($blub); |
397 | 406 | } |
398 | - } |
|
399 | - else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
407 | + } else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
400 | 408 | { |
401 | 409 | $val = $var . ' ' . $val . ' 1'; |
402 | 410 | $type = 'raw'; |
@@ -407,8 +415,9 @@ discard block |
||
407 | 415 | { |
408 | 416 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
409 | 417 | { |
410 | - if ($match[1] != '+ ') |
|
411 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
418 | + if ($match[1] != '+ ') { |
|
419 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
420 | + } |
|
412 | 421 | $type = 'raw'; |
413 | 422 | } |
414 | 423 | } |
@@ -429,8 +438,9 @@ discard block |
||
429 | 438 | // Clear any caching? |
430 | 439 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
431 | 440 | { |
432 | - if (!is_array($members)) |
|
433 | - $members = array($members); |
|
441 | + if (!is_array($members)) { |
|
442 | + $members = array($members); |
|
443 | + } |
|
434 | 444 | |
435 | 445 | foreach ($members as $member) |
436 | 446 | { |
@@ -463,29 +473,32 @@ discard block |
||
463 | 473 | { |
464 | 474 | global $modSettings, $smcFunc; |
465 | 475 | |
466 | - if (empty($changeArray) || !is_array($changeArray)) |
|
467 | - return; |
|
476 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
477 | + return; |
|
478 | + } |
|
468 | 479 | |
469 | 480 | $toRemove = array(); |
470 | 481 | |
471 | 482 | // Go check if there is any setting to be removed. |
472 | - foreach ($changeArray as $k => $v) |
|
473 | - if ($v === null) |
|
483 | + foreach ($changeArray as $k => $v) { |
|
484 | + if ($v === null) |
|
474 | 485 | { |
475 | 486 | // Found some, remove them from the original array and add them to ours. |
476 | 487 | unset($changeArray[$k]); |
488 | + } |
|
477 | 489 | $toRemove[] = $k; |
478 | 490 | } |
479 | 491 | |
480 | 492 | // Proceed with the deletion. |
481 | - if (!empty($toRemove)) |
|
482 | - $smcFunc['db_query']('', ' |
|
493 | + if (!empty($toRemove)) { |
|
494 | + $smcFunc['db_query']('', ' |
|
483 | 495 | DELETE FROM {db_prefix}settings |
484 | 496 | WHERE variable IN ({array_string:remove})', |
485 | 497 | array( |
486 | 498 | 'remove' => $toRemove, |
487 | 499 | ) |
488 | 500 | ); |
501 | + } |
|
489 | 502 | |
490 | 503 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
491 | 504 | if ($update) |
@@ -514,19 +527,22 @@ discard block |
||
514 | 527 | foreach ($changeArray as $variable => $value) |
515 | 528 | { |
516 | 529 | // Don't bother if it's already like that ;). |
517 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
518 | - continue; |
|
530 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
531 | + continue; |
|
532 | + } |
|
519 | 533 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
520 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
521 | - continue; |
|
534 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
535 | + continue; |
|
536 | + } |
|
522 | 537 | |
523 | 538 | $replaceArray[] = array($variable, $value); |
524 | 539 | |
525 | 540 | $modSettings[$variable] = $value; |
526 | 541 | } |
527 | 542 | |
528 | - if (empty($replaceArray)) |
|
529 | - return; |
|
543 | + if (empty($replaceArray)) { |
|
544 | + return; |
|
545 | + } |
|
530 | 546 | |
531 | 547 | $smcFunc['db_insert']('replace', |
532 | 548 | '{db_prefix}settings', |
@@ -572,14 +588,17 @@ discard block |
||
572 | 588 | $start_invalid = $start < 0; |
573 | 589 | |
574 | 590 | // Make sure $start is a proper variable - not less than 0. |
575 | - if ($start_invalid) |
|
576 | - $start = 0; |
|
591 | + if ($start_invalid) { |
|
592 | + $start = 0; |
|
593 | + } |
|
577 | 594 | // Not greater than the upper bound. |
578 | - elseif ($start >= $max_value) |
|
579 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
595 | + elseif ($start >= $max_value) { |
|
596 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
597 | + } |
|
580 | 598 | // And it has to be a multiple of $num_per_page! |
581 | - else |
|
582 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
599 | + else { |
|
600 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
601 | + } |
|
583 | 602 | |
584 | 603 | $context['current_page'] = $start / $num_per_page; |
585 | 604 | |
@@ -609,77 +628,87 @@ discard block |
||
609 | 628 | |
610 | 629 | // Show all the pages. |
611 | 630 | $display_page = 1; |
612 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
613 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
631 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
632 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
633 | + } |
|
614 | 634 | |
615 | 635 | // Show the right arrow. |
616 | 636 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
617 | - if ($start != $counter - $max_value && !$start_invalid) |
|
618 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
619 | - } |
|
620 | - else |
|
637 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
638 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
639 | + } |
|
640 | + } else |
|
621 | 641 | { |
622 | 642 | // If they didn't enter an odd value, pretend they did. |
623 | 643 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
624 | 644 | |
625 | 645 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
626 | - if (!empty($start) && $show_prevnext) |
|
627 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
628 | - else |
|
629 | - $pageindex .= ''; |
|
646 | + if (!empty($start) && $show_prevnext) { |
|
647 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
648 | + } else { |
|
649 | + $pageindex .= ''; |
|
650 | + } |
|
630 | 651 | |
631 | 652 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
632 | - if ($start > $num_per_page * $PageContiguous) |
|
633 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
653 | + if ($start > $num_per_page * $PageContiguous) { |
|
654 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
655 | + } |
|
634 | 656 | |
635 | 657 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
636 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
637 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
658 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
659 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
638 | 660 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
639 | 661 | '{FIRST_PAGE}' => $num_per_page, |
640 | 662 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
641 | 663 | '{PER_PAGE}' => $num_per_page, |
642 | 664 | )); |
665 | + } |
|
643 | 666 | |
644 | 667 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
645 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
646 | - if ($start >= $num_per_page * $nCont) |
|
668 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
669 | + if ($start >= $num_per_page * $nCont) |
|
647 | 670 | { |
648 | 671 | $tmpStart = $start - $num_per_page * $nCont; |
672 | + } |
|
649 | 673 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
650 | 674 | } |
651 | 675 | |
652 | 676 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
653 | - if (!$start_invalid) |
|
654 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
655 | - else |
|
656 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
677 | + if (!$start_invalid) { |
|
678 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
679 | + } else { |
|
680 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
681 | + } |
|
657 | 682 | |
658 | 683 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
659 | 684 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
660 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
661 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
685 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
686 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
662 | 687 | { |
663 | 688 | $tmpStart = $start + $num_per_page * $nCont; |
689 | + } |
|
664 | 690 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
665 | 691 | } |
666 | 692 | |
667 | 693 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
668 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
669 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
694 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
695 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
670 | 696 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
671 | 697 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
672 | 698 | '{LAST_PAGE}' => $tmpMaxPages, |
673 | 699 | '{PER_PAGE}' => $num_per_page, |
674 | 700 | )); |
701 | + } |
|
675 | 702 | |
676 | 703 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
677 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
678 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
704 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
705 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
706 | + } |
|
679 | 707 | |
680 | 708 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
681 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
682 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
709 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
710 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
711 | + } |
|
683 | 712 | } |
684 | 713 | $pageindex .= $settings['page_index']['extra_after']; |
685 | 714 | |
@@ -705,8 +734,9 @@ discard block |
||
705 | 734 | if ($decimal_separator === null) |
706 | 735 | { |
707 | 736 | // Not set for whatever reason? |
708 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
709 | - return $number; |
|
737 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
738 | + return $number; |
|
739 | + } |
|
710 | 740 | |
711 | 741 | // Cache these each load... |
712 | 742 | $thousands_separator = $matches[1]; |
@@ -740,17 +770,20 @@ discard block |
||
740 | 770 | static $unsupportedFormats, $finalizedFormats; |
741 | 771 | |
742 | 772 | // Offset the time. |
743 | - if (!$offset_type) |
|
744 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
773 | + if (!$offset_type) { |
|
774 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
775 | + } |
|
745 | 776 | // Just the forum offset? |
746 | - elseif ($offset_type == 'forum') |
|
747 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
748 | - else |
|
749 | - $time = $log_time; |
|
777 | + elseif ($offset_type == 'forum') { |
|
778 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
779 | + } else { |
|
780 | + $time = $log_time; |
|
781 | + } |
|
750 | 782 | |
751 | 783 | // We can't have a negative date (on Windows, at least.) |
752 | - if ($log_time < 0) |
|
753 | - $log_time = 0; |
|
784 | + if ($log_time < 0) { |
|
785 | + $log_time = 0; |
|
786 | + } |
|
754 | 787 | |
755 | 788 | // Today and Yesterday? |
756 | 789 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -767,24 +800,27 @@ discard block |
||
767 | 800 | { |
768 | 801 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
769 | 802 | $today_fmt = $h . ':%M' . $s . ' %p'; |
803 | + } else { |
|
804 | + $today_fmt = '%H:%M' . $s; |
|
770 | 805 | } |
771 | - else |
|
772 | - $today_fmt = '%H:%M' . $s; |
|
773 | 806 | |
774 | 807 | // Same day of the year, same year.... Today! |
775 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
776 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
808 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
809 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
810 | + } |
|
777 | 811 | |
778 | 812 | // 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... |
779 | - 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)) |
|
780 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
813 | + 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)) { |
|
814 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
815 | + } |
|
781 | 816 | } |
782 | 817 | |
783 | 818 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
784 | 819 | |
785 | 820 | // Use the cached formats if available |
786 | - if (is_null($finalizedFormats)) |
|
787 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
821 | + if (is_null($finalizedFormats)) { |
|
822 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
823 | + } |
|
788 | 824 | |
789 | 825 | // Make a supported version for this format if we don't already have one |
790 | 826 | if (empty($finalizedFormats[$str])) |
@@ -813,8 +849,9 @@ discard block |
||
813 | 849 | ); |
814 | 850 | |
815 | 851 | // No need to do this part again if we already did it once |
816 | - if (is_null($unsupportedFormats)) |
|
817 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
852 | + if (is_null($unsupportedFormats)) { |
|
853 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
854 | + } |
|
818 | 855 | if (empty($unsupportedFormats)) |
819 | 856 | { |
820 | 857 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -823,20 +860,23 @@ discard block |
||
823 | 860 | |
824 | 861 | // Windows will return false for unsupported formats |
825 | 862 | // Other operating systems return the format string as a literal |
826 | - if ($value === false || $value === $format) |
|
827 | - $unsupportedFormats[] = $format; |
|
863 | + if ($value === false || $value === $format) { |
|
864 | + $unsupportedFormats[] = $format; |
|
865 | + } |
|
828 | 866 | } |
829 | 867 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
830 | 868 | } |
831 | 869 | |
832 | 870 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
833 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
834 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
871 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
872 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
873 | + } |
|
835 | 874 | |
836 | 875 | // Substitute unsupported formats with supported ones |
837 | - if (!empty($unsupportedFormats)) |
|
838 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
876 | + if (!empty($unsupportedFormats)) { |
|
877 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
839 | 878 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
879 | + } |
|
840 | 880 | |
841 | 881 | // Remember this so we don't need to do it again |
842 | 882 | $finalizedFormats[$str] = $timeformat; |
@@ -845,33 +885,39 @@ discard block |
||
845 | 885 | |
846 | 886 | $str = $finalizedFormats[$str]; |
847 | 887 | |
848 | - if (!isset($locale_cache)) |
|
849 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
888 | + if (!isset($locale_cache)) { |
|
889 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
890 | + } |
|
850 | 891 | |
851 | 892 | if ($locale_cache !== false) |
852 | 893 | { |
853 | 894 | // Check if another process changed the locale |
854 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
855 | - setlocale(LC_TIME, $txt['lang_locale']); |
|
895 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
896 | + setlocale(LC_TIME, $txt['lang_locale']); |
|
897 | + } |
|
856 | 898 | |
857 | - if (!isset($non_twelve_hour)) |
|
858 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
859 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
860 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
899 | + if (!isset($non_twelve_hour)) { |
|
900 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
901 | + } |
|
902 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
903 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
904 | + } |
|
861 | 905 | |
862 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
863 | - if (strpos($str, $token) !== false) |
|
906 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
907 | + if (strpos($str, $token) !== false) |
|
864 | 908 | $str = str_replace($token, strftime($token, $time), $str); |
865 | - } |
|
866 | - else |
|
909 | + } |
|
910 | + } else |
|
867 | 911 | { |
868 | 912 | // Do-it-yourself time localization. Fun. |
869 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
870 | - if (strpos($str, $token) !== false) |
|
913 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
914 | + if (strpos($str, $token) !== false) |
|
871 | 915 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
916 | + } |
|
872 | 917 | |
873 | - if (strpos($str, '%p') !== false) |
|
874 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
918 | + if (strpos($str, '%p') !== false) { |
|
919 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
920 | + } |
|
875 | 921 | } |
876 | 922 | |
877 | 923 | // Format the time and then restore any literal percent characters |
@@ -894,16 +940,19 @@ discard block |
||
894 | 940 | static $translation = array(); |
895 | 941 | |
896 | 942 | // Determine the character set... Default to UTF-8 |
897 | - if (empty($context['character_set'])) |
|
898 | - $charset = 'UTF-8'; |
|
943 | + if (empty($context['character_set'])) { |
|
944 | + $charset = 'UTF-8'; |
|
945 | + } |
|
899 | 946 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
900 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
901 | - $charset = 'ISO-8859-1'; |
|
902 | - else |
|
903 | - $charset = $context['character_set']; |
|
947 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
948 | + $charset = 'ISO-8859-1'; |
|
949 | + } else { |
|
950 | + $charset = $context['character_set']; |
|
951 | + } |
|
904 | 952 | |
905 | - if (empty($translation)) |
|
906 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
953 | + if (empty($translation)) { |
|
954 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
955 | + } |
|
907 | 956 | |
908 | 957 | return strtr($string, $translation); |
909 | 958 | } |
@@ -925,8 +974,9 @@ discard block |
||
925 | 974 | global $smcFunc; |
926 | 975 | |
927 | 976 | // It was already short enough! |
928 | - if ($smcFunc['strlen']($subject) <= $len) |
|
929 | - return $subject; |
|
977 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
978 | + return $subject; |
|
979 | + } |
|
930 | 980 | |
931 | 981 | // Shorten it by the length it was too long, and strip off junk from the end. |
932 | 982 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -945,10 +995,11 @@ discard block |
||
945 | 995 | { |
946 | 996 | global $user_info, $modSettings; |
947 | 997 | |
948 | - if ($timestamp === null) |
|
949 | - $timestamp = time(); |
|
950 | - elseif ($timestamp == 0) |
|
951 | - return 0; |
|
998 | + if ($timestamp === null) { |
|
999 | + $timestamp = time(); |
|
1000 | + } elseif ($timestamp == 0) { |
|
1001 | + return 0; |
|
1002 | + } |
|
952 | 1003 | |
953 | 1004 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
954 | 1005 | } |
@@ -977,8 +1028,9 @@ discard block |
||
977 | 1028 | $array[$i] = $array[$j]; |
978 | 1029 | $array[$j] = $temp; |
979 | 1030 | |
980 | - for ($i = 1; $p[$i] == 0; $i++) |
|
981 | - $p[$i] = 1; |
|
1031 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
1032 | + $p[$i] = 1; |
|
1033 | + } |
|
982 | 1034 | |
983 | 1035 | $orders[] = $array; |
984 | 1036 | } |
@@ -1010,12 +1062,14 @@ discard block |
||
1010 | 1062 | static $disabled; |
1011 | 1063 | |
1012 | 1064 | // Don't waste cycles |
1013 | - if ($message === '') |
|
1014 | - return ''; |
|
1065 | + if ($message === '') { |
|
1066 | + return ''; |
|
1067 | + } |
|
1015 | 1068 | |
1016 | 1069 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
1017 | - if (!isset($context['utf8'])) |
|
1018 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1070 | + if (!isset($context['utf8'])) { |
|
1071 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1072 | + } |
|
1019 | 1073 | |
1020 | 1074 | // Clean up any cut/paste issues we may have |
1021 | 1075 | $message = sanitizeMSCutPaste($message); |
@@ -1027,13 +1081,15 @@ discard block |
||
1027 | 1081 | return $message; |
1028 | 1082 | } |
1029 | 1083 | |
1030 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
1031 | - $smileys = (bool) $smileys; |
|
1084 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
1085 | + $smileys = (bool) $smileys; |
|
1086 | + } |
|
1032 | 1087 | |
1033 | 1088 | if (empty($modSettings['enableBBC']) && $message !== false) |
1034 | 1089 | { |
1035 | - if ($smileys === true) |
|
1036 | - parsesmileys($message); |
|
1090 | + if ($smileys === true) { |
|
1091 | + parsesmileys($message); |
|
1092 | + } |
|
1037 | 1093 | |
1038 | 1094 | return $message; |
1039 | 1095 | } |
@@ -1046,8 +1102,9 @@ discard block |
||
1046 | 1102 | } |
1047 | 1103 | |
1048 | 1104 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
1049 | - if (!empty($modSettings['autoLinkUrls'])) |
|
1050 | - set_tld_regex(); |
|
1105 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
1106 | + set_tld_regex(); |
|
1107 | + } |
|
1051 | 1108 | |
1052 | 1109 | // Allow mods access before entering the main parse_bbc loop |
1053 | 1110 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1061,12 +1118,14 @@ discard block |
||
1061 | 1118 | |
1062 | 1119 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
1063 | 1120 | |
1064 | - foreach ($temp as $tag) |
|
1065 | - $disabled[trim($tag)] = true; |
|
1121 | + foreach ($temp as $tag) { |
|
1122 | + $disabled[trim($tag)] = true; |
|
1123 | + } |
|
1066 | 1124 | } |
1067 | 1125 | |
1068 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1069 | - $disabled['flash'] = true; |
|
1126 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1127 | + $disabled['flash'] = true; |
|
1128 | + } |
|
1070 | 1129 | |
1071 | 1130 | /* The following bbc are formatted as an array, with keys as follows: |
1072 | 1131 | |
@@ -1187,8 +1246,9 @@ discard block |
||
1187 | 1246 | $returnContext = ''; |
1188 | 1247 | |
1189 | 1248 | // BBC or the entire attachments feature is disabled |
1190 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
1191 | - return $data; |
|
1249 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
1250 | + return $data; |
|
1251 | + } |
|
1192 | 1252 | |
1193 | 1253 | // Save the attach ID. |
1194 | 1254 | $attachID = $data; |
@@ -1199,8 +1259,9 @@ discard block |
||
1199 | 1259 | $currentAttachment = parseAttachBBC($attachID); |
1200 | 1260 | |
1201 | 1261 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
1202 | - if (is_string($currentAttachment)) |
|
1203 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1262 | + if (is_string($currentAttachment)) { |
|
1263 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1264 | + } |
|
1204 | 1265 | |
1205 | 1266 | if (!empty($currentAttachment['is_image'])) |
1206 | 1267 | { |
@@ -1216,15 +1277,17 @@ discard block |
||
1216 | 1277 | $height = ' height="' . $currentAttachment['height'] . '"'; |
1217 | 1278 | } |
1218 | 1279 | |
1219 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
1220 | - $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>'; |
|
1221 | - else |
|
1222 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1280 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
1281 | + $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>'; |
|
1282 | + } else { |
|
1283 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1284 | + } |
|
1223 | 1285 | } |
1224 | 1286 | |
1225 | 1287 | // No image. Show a link. |
1226 | - else |
|
1227 | - $returnContext .= $currentAttachment['link']; |
|
1288 | + else { |
|
1289 | + $returnContext .= $currentAttachment['link']; |
|
1290 | + } |
|
1228 | 1291 | |
1229 | 1292 | // Gotta append what we just did. |
1230 | 1293 | $data = $returnContext; |
@@ -1255,8 +1318,9 @@ discard block |
||
1255 | 1318 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1256 | 1319 | { |
1257 | 1320 | // Do PHP code coloring? |
1258 | - if ($php_parts[$php_i] != '<?php') |
|
1259 | - continue; |
|
1321 | + if ($php_parts[$php_i] != '<?php') { |
|
1322 | + continue; |
|
1323 | + } |
|
1260 | 1324 | |
1261 | 1325 | $php_string = ''; |
1262 | 1326 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1272,8 +1336,9 @@ discard block |
||
1272 | 1336 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
1273 | 1337 | |
1274 | 1338 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1275 | - if ($context['browser']['is_opera']) |
|
1276 | - $data .= ' '; |
|
1339 | + if ($context['browser']['is_opera']) { |
|
1340 | + $data .= ' '; |
|
1341 | + } |
|
1277 | 1342 | } |
1278 | 1343 | }, |
1279 | 1344 | 'block_level' => true, |
@@ -1292,8 +1357,9 @@ discard block |
||
1292 | 1357 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1293 | 1358 | { |
1294 | 1359 | // Do PHP code coloring? |
1295 | - if ($php_parts[$php_i] != '<?php') |
|
1296 | - continue; |
|
1360 | + if ($php_parts[$php_i] != '<?php') { |
|
1361 | + continue; |
|
1362 | + } |
|
1297 | 1363 | |
1298 | 1364 | $php_string = ''; |
1299 | 1365 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1309,8 +1375,9 @@ discard block |
||
1309 | 1375 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
1310 | 1376 | |
1311 | 1377 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1312 | - if ($context['browser']['is_opera']) |
|
1313 | - $data[0] .= ' '; |
|
1378 | + if ($context['browser']['is_opera']) { |
|
1379 | + $data[0] .= ' '; |
|
1380 | + } |
|
1314 | 1381 | } |
1315 | 1382 | }, |
1316 | 1383 | 'block_level' => true, |
@@ -1348,11 +1415,13 @@ discard block |
||
1348 | 1415 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1349 | 1416 | 'validate' => function (&$tag, &$data, $disabled) |
1350 | 1417 | { |
1351 | - if (isset($disabled['url'])) |
|
1352 | - $tag['content'] = '$1'; |
|
1418 | + if (isset($disabled['url'])) { |
|
1419 | + $tag['content'] = '$1'; |
|
1420 | + } |
|
1353 | 1421 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
1354 | - if (empty($scheme)) |
|
1355 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
1422 | + if (empty($scheme)) { |
|
1423 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
1424 | + } |
|
1356 | 1425 | }, |
1357 | 1426 | 'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>', |
1358 | 1427 | ), |
@@ -1366,10 +1435,11 @@ discard block |
||
1366 | 1435 | { |
1367 | 1436 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1368 | 1437 | |
1369 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
1370 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1371 | - else |
|
1372 | - $css = ''; |
|
1438 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
1439 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1440 | + } else { |
|
1441 | + $css = ''; |
|
1442 | + } |
|
1373 | 1443 | |
1374 | 1444 | $data = $class . $css; |
1375 | 1445 | }, |
@@ -1419,17 +1489,20 @@ discard block |
||
1419 | 1489 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1420 | 1490 | if ($image_proxy_enabled) |
1421 | 1491 | { |
1422 | - if (!empty($user_info['possibly_robot'])) |
|
1423 | - return; |
|
1492 | + if (!empty($user_info['possibly_robot'])) { |
|
1493 | + return; |
|
1494 | + } |
|
1424 | 1495 | |
1425 | - if (empty($scheme)) |
|
1426 | - $data = 'http://' . ltrim($data, ':/'); |
|
1496 | + if (empty($scheme)) { |
|
1497 | + $data = 'http://' . ltrim($data, ':/'); |
|
1498 | + } |
|
1427 | 1499 | |
1428 | - if ($scheme != 'https') |
|
1429 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1500 | + if ($scheme != 'https') { |
|
1501 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1502 | + } |
|
1503 | + } elseif (empty($scheme)) { |
|
1504 | + $data = '//' . ltrim($data, ':/'); |
|
1430 | 1505 | } |
1431 | - elseif (empty($scheme)) |
|
1432 | - $data = '//' . ltrim($data, ':/'); |
|
1433 | 1506 | }, |
1434 | 1507 | 'disabled_content' => '($1)', |
1435 | 1508 | ), |
@@ -1445,17 +1518,20 @@ discard block |
||
1445 | 1518 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1446 | 1519 | if ($image_proxy_enabled) |
1447 | 1520 | { |
1448 | - if (!empty($user_info['possibly_robot'])) |
|
1449 | - return; |
|
1521 | + if (!empty($user_info['possibly_robot'])) { |
|
1522 | + return; |
|
1523 | + } |
|
1450 | 1524 | |
1451 | - if (empty($scheme)) |
|
1452 | - $data = 'http://' . ltrim($data, ':/'); |
|
1525 | + if (empty($scheme)) { |
|
1526 | + $data = 'http://' . ltrim($data, ':/'); |
|
1527 | + } |
|
1453 | 1528 | |
1454 | - if ($scheme != 'https') |
|
1455 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1529 | + if ($scheme != 'https') { |
|
1530 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1531 | + } |
|
1532 | + } elseif (empty($scheme)) { |
|
1533 | + $data = '//' . ltrim($data, ':/'); |
|
1456 | 1534 | } |
1457 | - elseif (empty($scheme)) |
|
1458 | - $data = '//' . ltrim($data, ':/'); |
|
1459 | 1535 | }, |
1460 | 1536 | 'disabled_content' => '($1)', |
1461 | 1537 | ), |
@@ -1467,8 +1543,9 @@ discard block |
||
1467 | 1543 | { |
1468 | 1544 | $data = strtr($data, array('<br>' => '')); |
1469 | 1545 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1470 | - if (empty($scheme)) |
|
1471 | - $data = '//' . ltrim($data, ':/'); |
|
1546 | + if (empty($scheme)) { |
|
1547 | + $data = '//' . ltrim($data, ':/'); |
|
1548 | + } |
|
1472 | 1549 | }, |
1473 | 1550 | ), |
1474 | 1551 | array( |
@@ -1479,13 +1556,14 @@ discard block |
||
1479 | 1556 | 'after' => '</a>', |
1480 | 1557 | 'validate' => function (&$tag, &$data, $disabled) |
1481 | 1558 | { |
1482 | - if (substr($data, 0, 1) == '#') |
|
1483 | - $data = '#post_' . substr($data, 1); |
|
1484 | - else |
|
1559 | + if (substr($data, 0, 1) == '#') { |
|
1560 | + $data = '#post_' . substr($data, 1); |
|
1561 | + } else |
|
1485 | 1562 | { |
1486 | 1563 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1487 | - if (empty($scheme)) |
|
1488 | - $data = '//' . ltrim($data, ':/'); |
|
1564 | + if (empty($scheme)) { |
|
1565 | + $data = '//' . ltrim($data, ':/'); |
|
1566 | + } |
|
1489 | 1567 | } |
1490 | 1568 | }, |
1491 | 1569 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1563,8 +1641,9 @@ discard block |
||
1563 | 1641 | { |
1564 | 1642 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
1565 | 1643 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
1566 | - if ($add_begin) |
|
1567 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1644 | + if ($add_begin) { |
|
1645 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1646 | + } |
|
1568 | 1647 | } |
1569 | 1648 | }, |
1570 | 1649 | 'block_level' => false, |
@@ -1695,10 +1774,11 @@ discard block |
||
1695 | 1774 | 'content' => '$1', |
1696 | 1775 | 'validate' => function (&$tag, &$data, $disabled) |
1697 | 1776 | { |
1698 | - if (is_numeric($data)) |
|
1699 | - $data = timeformat($data); |
|
1700 | - else |
|
1701 | - $tag['content'] = '[time]$1[/time]'; |
|
1777 | + if (is_numeric($data)) { |
|
1778 | + $data = timeformat($data); |
|
1779 | + } else { |
|
1780 | + $tag['content'] = '[time]$1[/time]'; |
|
1781 | + } |
|
1702 | 1782 | }, |
1703 | 1783 | ), |
1704 | 1784 | array( |
@@ -1725,8 +1805,9 @@ discard block |
||
1725 | 1805 | { |
1726 | 1806 | $data = strtr($data, array('<br>' => '')); |
1727 | 1807 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1728 | - if (empty($scheme)) |
|
1729 | - $data = '//' . ltrim($data, ':/'); |
|
1808 | + if (empty($scheme)) { |
|
1809 | + $data = '//' . ltrim($data, ':/'); |
|
1810 | + } |
|
1730 | 1811 | }, |
1731 | 1812 | ), |
1732 | 1813 | array( |
@@ -1738,8 +1819,9 @@ discard block |
||
1738 | 1819 | 'validate' => function (&$tag, &$data, $disabled) |
1739 | 1820 | { |
1740 | 1821 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1741 | - if (empty($scheme)) |
|
1742 | - $data = '//' . ltrim($data, ':/'); |
|
1822 | + if (empty($scheme)) { |
|
1823 | + $data = '//' . ltrim($data, ':/'); |
|
1824 | + } |
|
1743 | 1825 | }, |
1744 | 1826 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
1745 | 1827 | 'disabled_after' => ' ($1)', |
@@ -1759,8 +1841,9 @@ discard block |
||
1759 | 1841 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
1760 | 1842 | if ($message === false) |
1761 | 1843 | { |
1762 | - if (isset($temp_bbc)) |
|
1763 | - $bbc_codes = $temp_bbc; |
|
1844 | + if (isset($temp_bbc)) { |
|
1845 | + $bbc_codes = $temp_bbc; |
|
1846 | + } |
|
1764 | 1847 | usort($codes, function ($a, $b) { |
1765 | 1848 | return strcmp($a['tag'], $b['tag']); |
1766 | 1849 | }); |
@@ -1780,8 +1863,9 @@ discard block |
||
1780 | 1863 | ); |
1781 | 1864 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
1782 | 1865 | { |
1783 | - foreach ($itemcodes as $c => $dummy) |
|
1784 | - $bbc_codes[$c] = array(); |
|
1866 | + foreach ($itemcodes as $c => $dummy) { |
|
1867 | + $bbc_codes[$c] = array(); |
|
1868 | + } |
|
1785 | 1869 | } |
1786 | 1870 | |
1787 | 1871 | // Shhhh! |
@@ -1802,12 +1886,14 @@ discard block |
||
1802 | 1886 | foreach ($codes as $code) |
1803 | 1887 | { |
1804 | 1888 | // Make it easier to process parameters later |
1805 | - if (!empty($code['parameters'])) |
|
1806 | - ksort($code['parameters'], SORT_STRING); |
|
1889 | + if (!empty($code['parameters'])) { |
|
1890 | + ksort($code['parameters'], SORT_STRING); |
|
1891 | + } |
|
1807 | 1892 | |
1808 | 1893 | // If we are not doing every tag only do ones we are interested in. |
1809 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
1810 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1894 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
1895 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1896 | + } |
|
1811 | 1897 | } |
1812 | 1898 | $codes = null; |
1813 | 1899 | } |
@@ -1818,8 +1904,9 @@ discard block |
||
1818 | 1904 | // It's likely this will change if the message is modified. |
1819 | 1905 | $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']); |
1820 | 1906 | |
1821 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
1822 | - return $temp; |
|
1907 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
1908 | + return $temp; |
|
1909 | + } |
|
1823 | 1910 | |
1824 | 1911 | $cache_t = microtime(); |
1825 | 1912 | } |
@@ -1851,8 +1938,9 @@ discard block |
||
1851 | 1938 | $disabled['flash'] = true; |
1852 | 1939 | |
1853 | 1940 | // @todo Change maybe? |
1854 | - if (!isset($_GET['images'])) |
|
1855 | - $disabled['img'] = true; |
|
1941 | + if (!isset($_GET['images'])) { |
|
1942 | + $disabled['img'] = true; |
|
1943 | + } |
|
1856 | 1944 | |
1857 | 1945 | // @todo Interface/setting to add more? |
1858 | 1946 | } |
@@ -1876,8 +1964,9 @@ discard block |
||
1876 | 1964 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
1877 | 1965 | |
1878 | 1966 | // Failsafe. |
1879 | - if ($pos === false || $last_pos > $pos) |
|
1880 | - $pos = strlen($message) + 1; |
|
1967 | + if ($pos === false || $last_pos > $pos) { |
|
1968 | + $pos = strlen($message) + 1; |
|
1969 | + } |
|
1881 | 1970 | |
1882 | 1971 | // Can't have a one letter smiley, URL, or email! (sorry.) |
1883 | 1972 | if ($last_pos < $pos - 1) |
@@ -1895,8 +1984,9 @@ discard block |
||
1895 | 1984 | |
1896 | 1985 | // <br> should be empty. |
1897 | 1986 | $empty_tags = array('br', 'hr'); |
1898 | - foreach ($empty_tags as $tag) |
|
1899 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
1987 | + foreach ($empty_tags as $tag) { |
|
1988 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
1989 | + } |
|
1900 | 1990 | |
1901 | 1991 | // b, u, i, s, pre... basic tags. |
1902 | 1992 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -1905,8 +1995,9 @@ discard block |
||
1905 | 1995 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
1906 | 1996 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
1907 | 1997 | |
1908 | - if ($diff > 0) |
|
1909 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1998 | + if ($diff > 0) { |
|
1999 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
2000 | + } |
|
1910 | 2001 | } |
1911 | 2002 | |
1912 | 2003 | // Do <img ...> - with security... action= -> action-. |
@@ -1919,8 +2010,9 @@ discard block |
||
1919 | 2010 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
1920 | 2011 | |
1921 | 2012 | // Remove action= from the URL - no funny business, now. |
1922 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
1923 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2013 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
2014 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2015 | + } |
|
1924 | 2016 | |
1925 | 2017 | // Check if the image is larger than allowed. |
1926 | 2018 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1941,9 +2033,9 @@ discard block |
||
1941 | 2033 | |
1942 | 2034 | // Set the new image tag. |
1943 | 2035 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
2036 | + } else { |
|
2037 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1944 | 2038 | } |
1945 | - else |
|
1946 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1947 | 2039 | } |
1948 | 2040 | |
1949 | 2041 | $data = strtr($data, $replaces); |
@@ -1956,16 +2048,18 @@ discard block |
||
1956 | 2048 | $no_autolink_area = false; |
1957 | 2049 | if (!empty($open_tags)) |
1958 | 2050 | { |
1959 | - foreach ($open_tags as $open_tag) |
|
1960 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
2051 | + foreach ($open_tags as $open_tag) { |
|
2052 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1961 | 2053 | $no_autolink_area = true; |
2054 | + } |
|
1962 | 2055 | } |
1963 | 2056 | |
1964 | 2057 | // Don't go backwards. |
1965 | 2058 | // @todo Don't think is the real solution.... |
1966 | 2059 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
1967 | - if ($pos < $lastAutoPos) |
|
1968 | - $no_autolink_area = true; |
|
2060 | + if ($pos < $lastAutoPos) { |
|
2061 | + $no_autolink_area = true; |
|
2062 | + } |
|
1969 | 2063 | $lastAutoPos = $pos; |
1970 | 2064 | |
1971 | 2065 | if (!$no_autolink_area) |
@@ -2074,17 +2168,19 @@ discard block |
||
2074 | 2168 | if ($scheme == 'mailto') |
2075 | 2169 | { |
2076 | 2170 | $email_address = str_replace('mailto:', '', $url); |
2077 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
2078 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2079 | - else |
|
2080 | - return $url; |
|
2171 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
2172 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2173 | + } else { |
|
2174 | + return $url; |
|
2175 | + } |
|
2081 | 2176 | } |
2082 | 2177 | |
2083 | 2178 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
2084 | - if (empty($scheme)) |
|
2085 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
2086 | - else |
|
2087 | - $fullUrl = $url; |
|
2179 | + if (empty($scheme)) { |
|
2180 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
2181 | + } else { |
|
2182 | + $fullUrl = $url; |
|
2183 | + } |
|
2088 | 2184 | |
2089 | 2185 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
2090 | 2186 | }, $data); |
@@ -2133,22 +2229,25 @@ discard block |
||
2133 | 2229 | } |
2134 | 2230 | |
2135 | 2231 | // Are we there yet? Are we there yet? |
2136 | - if ($pos >= strlen($message) - 1) |
|
2137 | - break; |
|
2232 | + if ($pos >= strlen($message) - 1) { |
|
2233 | + break; |
|
2234 | + } |
|
2138 | 2235 | |
2139 | 2236 | $tags = strtolower($message[$pos + 1]); |
2140 | 2237 | |
2141 | 2238 | if ($tags == '/' && !empty($open_tags)) |
2142 | 2239 | { |
2143 | 2240 | $pos2 = strpos($message, ']', $pos + 1); |
2144 | - if ($pos2 == $pos + 2) |
|
2145 | - continue; |
|
2241 | + if ($pos2 == $pos + 2) { |
|
2242 | + continue; |
|
2243 | + } |
|
2146 | 2244 | |
2147 | 2245 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2148 | 2246 | |
2149 | 2247 | // A closing tag that doesn't match any open tags? Skip it. |
2150 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2151 | - continue; |
|
2248 | + if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) { |
|
2249 | + continue; |
|
2250 | + } |
|
2152 | 2251 | |
2153 | 2252 | $to_close = array(); |
2154 | 2253 | $block_level = null; |
@@ -2156,8 +2255,9 @@ discard block |
||
2156 | 2255 | do |
2157 | 2256 | { |
2158 | 2257 | $tag = array_pop($open_tags); |
2159 | - if (!$tag) |
|
2160 | - break; |
|
2258 | + if (!$tag) { |
|
2259 | + break; |
|
2260 | + } |
|
2161 | 2261 | |
2162 | 2262 | if (!empty($tag['block_level'])) |
2163 | 2263 | { |
@@ -2171,10 +2271,11 @@ discard block |
||
2171 | 2271 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
2172 | 2272 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
2173 | 2273 | { |
2174 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2175 | - if ($temp['tag'] == $look_for) |
|
2274 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2275 | + if ($temp['tag'] == $look_for) |
|
2176 | 2276 | { |
2177 | 2277 | $block_level = !empty($temp['block_level']); |
2278 | + } |
|
2178 | 2279 | break; |
2179 | 2280 | } |
2180 | 2281 | } |
@@ -2196,15 +2297,15 @@ discard block |
||
2196 | 2297 | { |
2197 | 2298 | $open_tags = $to_close; |
2198 | 2299 | continue; |
2199 | - } |
|
2200 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2300 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2201 | 2301 | { |
2202 | 2302 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
2203 | 2303 | { |
2204 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2205 | - if ($temp['tag'] == $look_for) |
|
2304 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2305 | + if ($temp['tag'] == $look_for) |
|
2206 | 2306 | { |
2207 | 2307 | $block_level = !empty($temp['block_level']); |
2308 | + } |
|
2208 | 2309 | break; |
2209 | 2310 | } |
2210 | 2311 | } |
@@ -2212,8 +2313,9 @@ discard block |
||
2212 | 2313 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
2213 | 2314 | if (!$block_level) |
2214 | 2315 | { |
2215 | - foreach ($to_close as $tag) |
|
2216 | - array_push($open_tags, $tag); |
|
2316 | + foreach ($to_close as $tag) { |
|
2317 | + array_push($open_tags, $tag); |
|
2318 | + } |
|
2217 | 2319 | continue; |
2218 | 2320 | } |
2219 | 2321 | } |
@@ -2226,14 +2328,17 @@ discard block |
||
2226 | 2328 | |
2227 | 2329 | // See the comment at the end of the big loop - just eating whitespace ;). |
2228 | 2330 | $whitespace_regex = ''; |
2229 | - if (!empty($tag['block_level'])) |
|
2230 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2331 | + if (!empty($tag['block_level'])) { |
|
2332 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2333 | + } |
|
2231 | 2334 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
2232 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2233 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2335 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2336 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2337 | + } |
|
2234 | 2338 | |
2235 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2236 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2339 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2340 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2341 | + } |
|
2237 | 2342 | } |
2238 | 2343 | |
2239 | 2344 | if (!empty($to_close)) |
@@ -2246,8 +2351,9 @@ discard block |
||
2246 | 2351 | } |
2247 | 2352 | |
2248 | 2353 | // No tags for this character, so just keep going (fastest possible course.) |
2249 | - if (!isset($bbc_codes[$tags])) |
|
2250 | - continue; |
|
2354 | + if (!isset($bbc_codes[$tags])) { |
|
2355 | + continue; |
|
2356 | + } |
|
2251 | 2357 | |
2252 | 2358 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
2253 | 2359 | $tag = null; |
@@ -2256,44 +2362,52 @@ discard block |
||
2256 | 2362 | $pt_strlen = strlen($possible['tag']); |
2257 | 2363 | |
2258 | 2364 | // Not a match? |
2259 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
2260 | - continue; |
|
2365 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
2366 | + continue; |
|
2367 | + } |
|
2261 | 2368 | |
2262 | 2369 | $next_c = $message[$pos + 1 + $pt_strlen]; |
2263 | 2370 | |
2264 | 2371 | // A test validation? |
2265 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
2266 | - continue; |
|
2372 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
2373 | + continue; |
|
2374 | + } |
|
2267 | 2375 | // Do we want parameters? |
2268 | 2376 | elseif (!empty($possible['parameters'])) |
2269 | 2377 | { |
2270 | - if ($next_c != ' ') |
|
2271 | - continue; |
|
2272 | - } |
|
2273 | - elseif (isset($possible['type'])) |
|
2378 | + if ($next_c != ' ') { |
|
2379 | + continue; |
|
2380 | + } |
|
2381 | + } elseif (isset($possible['type'])) |
|
2274 | 2382 | { |
2275 | 2383 | // Do we need an equal sign? |
2276 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
2277 | - continue; |
|
2384 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
2385 | + continue; |
|
2386 | + } |
|
2278 | 2387 | // Maybe we just want a /... |
2279 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
2280 | - continue; |
|
2388 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
2389 | + continue; |
|
2390 | + } |
|
2281 | 2391 | // An immediate ]? |
2282 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
2283 | - continue; |
|
2392 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
2393 | + continue; |
|
2394 | + } |
|
2284 | 2395 | } |
2285 | 2396 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
2286 | - elseif ($next_c != ']') |
|
2287 | - continue; |
|
2397 | + elseif ($next_c != ']') { |
|
2398 | + continue; |
|
2399 | + } |
|
2288 | 2400 | |
2289 | 2401 | // Check allowed tree? |
2290 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
2291 | - continue; |
|
2292 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
2293 | - continue; |
|
2402 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
2403 | + continue; |
|
2404 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
2405 | + continue; |
|
2406 | + } |
|
2294 | 2407 | // If this is in the list of disallowed child tags, don't parse it. |
2295 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
2296 | - continue; |
|
2408 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
2409 | + continue; |
|
2410 | + } |
|
2297 | 2411 | |
2298 | 2412 | $pos1 = $pos + 1 + $pt_strlen + 1; |
2299 | 2413 | |
@@ -2305,8 +2419,9 @@ discard block |
||
2305 | 2419 | foreach ($open_tags as $open_quote) |
2306 | 2420 | { |
2307 | 2421 | // Every parent quote this quote has flips the styling |
2308 | - if ($open_quote['tag'] == 'quote') |
|
2309 | - $quote_alt = !$quote_alt; |
|
2422 | + if ($open_quote['tag'] == 'quote') { |
|
2423 | + $quote_alt = !$quote_alt; |
|
2424 | + } |
|
2310 | 2425 | } |
2311 | 2426 | // Add a class to the quote to style alternating blockquotes |
2312 | 2427 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2317,8 +2432,9 @@ discard block |
||
2317 | 2432 | { |
2318 | 2433 | // Build a regular expression for each parameter for the current tag. |
2319 | 2434 | $preg = array(); |
2320 | - foreach ($possible['parameters'] as $p => $info) |
|
2321 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2435 | + foreach ($possible['parameters'] as $p => $info) { |
|
2436 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2437 | + } |
|
2322 | 2438 | |
2323 | 2439 | // Extract the string that potentially holds our parameters. |
2324 | 2440 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2338,24 +2454,27 @@ discard block |
||
2338 | 2454 | |
2339 | 2455 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
2340 | 2456 | |
2341 | - if ($match) |
|
2342 | - $blob_counter = count($blobs) + 1; |
|
2457 | + if ($match) { |
|
2458 | + $blob_counter = count($blobs) + 1; |
|
2459 | + } |
|
2343 | 2460 | } |
2344 | 2461 | |
2345 | 2462 | // Didn't match our parameter list, try the next possible. |
2346 | - if (!$match) |
|
2347 | - continue; |
|
2463 | + if (!$match) { |
|
2464 | + continue; |
|
2465 | + } |
|
2348 | 2466 | |
2349 | 2467 | $params = array(); |
2350 | 2468 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
2351 | 2469 | { |
2352 | 2470 | $key = strtok(ltrim($matches[$i]), '='); |
2353 | - if (isset($possible['parameters'][$key]['value'])) |
|
2354 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2355 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
2356 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2357 | - else |
|
2358 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2471 | + if (isset($possible['parameters'][$key]['value'])) { |
|
2472 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2473 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
2474 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2475 | + } else { |
|
2476 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2477 | + } |
|
2359 | 2478 | |
2360 | 2479 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
2361 | 2480 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2363,23 +2482,26 @@ discard block |
||
2363 | 2482 | |
2364 | 2483 | foreach ($possible['parameters'] as $p => $info) |
2365 | 2484 | { |
2366 | - if (!isset($params['{' . $p . '}'])) |
|
2367 | - $params['{' . $p . '}'] = ''; |
|
2485 | + if (!isset($params['{' . $p . '}'])) { |
|
2486 | + $params['{' . $p . '}'] = ''; |
|
2487 | + } |
|
2368 | 2488 | } |
2369 | 2489 | |
2370 | 2490 | $tag = $possible; |
2371 | 2491 | |
2372 | 2492 | // Put the parameters into the string. |
2373 | - if (isset($tag['before'])) |
|
2374 | - $tag['before'] = strtr($tag['before'], $params); |
|
2375 | - if (isset($tag['after'])) |
|
2376 | - $tag['after'] = strtr($tag['after'], $params); |
|
2377 | - if (isset($tag['content'])) |
|
2378 | - $tag['content'] = strtr($tag['content'], $params); |
|
2493 | + if (isset($tag['before'])) { |
|
2494 | + $tag['before'] = strtr($tag['before'], $params); |
|
2495 | + } |
|
2496 | + if (isset($tag['after'])) { |
|
2497 | + $tag['after'] = strtr($tag['after'], $params); |
|
2498 | + } |
|
2499 | + if (isset($tag['content'])) { |
|
2500 | + $tag['content'] = strtr($tag['content'], $params); |
|
2501 | + } |
|
2379 | 2502 | |
2380 | 2503 | $pos1 += strlen($given_param_string); |
2381 | - } |
|
2382 | - else |
|
2504 | + } else |
|
2383 | 2505 | { |
2384 | 2506 | $tag = $possible; |
2385 | 2507 | $params = array(); |
@@ -2390,8 +2512,9 @@ discard block |
||
2390 | 2512 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
2391 | 2513 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
2392 | 2514 | { |
2393 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
2394 | - continue; |
|
2515 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
2516 | + continue; |
|
2517 | + } |
|
2395 | 2518 | |
2396 | 2519 | $tag = $itemcodes[$message[$pos + 1]]; |
2397 | 2520 | |
@@ -2412,9 +2535,9 @@ discard block |
||
2412 | 2535 | { |
2413 | 2536 | array_pop($open_tags); |
2414 | 2537 | $code = '</li>'; |
2538 | + } else { |
|
2539 | + $code = ''; |
|
2415 | 2540 | } |
2416 | - else |
|
2417 | - $code = ''; |
|
2418 | 2541 | |
2419 | 2542 | // Now we open a new tag. |
2420 | 2543 | $open_tags[] = array( |
@@ -2461,12 +2584,14 @@ discard block |
||
2461 | 2584 | } |
2462 | 2585 | |
2463 | 2586 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
2464 | - if ($tag === null) |
|
2465 | - continue; |
|
2587 | + if ($tag === null) { |
|
2588 | + continue; |
|
2589 | + } |
|
2466 | 2590 | |
2467 | 2591 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
2468 | - if (isset($inside['disallow_children'])) |
|
2469 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2592 | + if (isset($inside['disallow_children'])) { |
|
2593 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2594 | + } |
|
2470 | 2595 | |
2471 | 2596 | // Is this tag disabled? |
2472 | 2597 | if (isset($disabled[$tag['tag']])) |
@@ -2476,14 +2601,13 @@ discard block |
||
2476 | 2601 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
2477 | 2602 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
2478 | 2603 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
2479 | - } |
|
2480 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2604 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2481 | 2605 | { |
2482 | 2606 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
2483 | 2607 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
2608 | + } else { |
|
2609 | + $tag['content'] = $tag['disabled_content']; |
|
2484 | 2610 | } |
2485 | - else |
|
2486 | - $tag['content'] = $tag['disabled_content']; |
|
2487 | 2611 | } |
2488 | 2612 | |
2489 | 2613 | // we use this a lot |
@@ -2493,8 +2617,9 @@ discard block |
||
2493 | 2617 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
2494 | 2618 | { |
2495 | 2619 | $n = count($open_tags) - 1; |
2496 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
2497 | - $n--; |
|
2620 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
2621 | + $n--; |
|
2622 | + } |
|
2498 | 2623 | |
2499 | 2624 | // Close all the non block level tags so this tag isn't surrounded by them. |
2500 | 2625 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2506,12 +2631,15 @@ discard block |
||
2506 | 2631 | |
2507 | 2632 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
2508 | 2633 | $whitespace_regex = ''; |
2509 | - if (!empty($tag['block_level'])) |
|
2510 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2511 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2512 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2513 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2514 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2634 | + if (!empty($tag['block_level'])) { |
|
2635 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2636 | + } |
|
2637 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2638 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2639 | + } |
|
2640 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2641 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2642 | + } |
|
2515 | 2643 | |
2516 | 2644 | array_pop($open_tags); |
2517 | 2645 | } |
@@ -2532,16 +2660,19 @@ discard block |
||
2532 | 2660 | elseif ($tag['type'] == 'unparsed_content') |
2533 | 2661 | { |
2534 | 2662 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
2535 | - if ($pos2 === false) |
|
2536 | - continue; |
|
2663 | + if ($pos2 === false) { |
|
2664 | + continue; |
|
2665 | + } |
|
2537 | 2666 | |
2538 | 2667 | $data = substr($message, $pos1, $pos2 - $pos1); |
2539 | 2668 | |
2540 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
2541 | - $data = substr($data, 4); |
|
2669 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
2670 | + $data = substr($data, 4); |
|
2671 | + } |
|
2542 | 2672 | |
2543 | - if (isset($tag['validate'])) |
|
2544 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2673 | + if (isset($tag['validate'])) { |
|
2674 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2675 | + } |
|
2545 | 2676 | |
2546 | 2677 | $code = strtr($tag['content'], array('$1' => $data)); |
2547 | 2678 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2557,34 +2688,40 @@ discard block |
||
2557 | 2688 | if (isset($tag['quoted'])) |
2558 | 2689 | { |
2559 | 2690 | $quoted = substr($message, $pos1, 6) == '"'; |
2560 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2561 | - continue; |
|
2691 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2692 | + continue; |
|
2693 | + } |
|
2562 | 2694 | |
2563 | - if ($quoted) |
|
2564 | - $pos1 += 6; |
|
2695 | + if ($quoted) { |
|
2696 | + $pos1 += 6; |
|
2697 | + } |
|
2698 | + } else { |
|
2699 | + $quoted = false; |
|
2565 | 2700 | } |
2566 | - else |
|
2567 | - $quoted = false; |
|
2568 | 2701 | |
2569 | 2702 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2570 | - if ($pos2 === false) |
|
2571 | - continue; |
|
2703 | + if ($pos2 === false) { |
|
2704 | + continue; |
|
2705 | + } |
|
2572 | 2706 | |
2573 | 2707 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2574 | - if ($pos3 === false) |
|
2575 | - continue; |
|
2708 | + if ($pos3 === false) { |
|
2709 | + continue; |
|
2710 | + } |
|
2576 | 2711 | |
2577 | 2712 | $data = array( |
2578 | 2713 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
2579 | 2714 | substr($message, $pos1, $pos2 - $pos1) |
2580 | 2715 | ); |
2581 | 2716 | |
2582 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
2583 | - $data[0] = substr($data[0], 4); |
|
2717 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
2718 | + $data[0] = substr($data[0], 4); |
|
2719 | + } |
|
2584 | 2720 | |
2585 | 2721 | // Validation for my parking, please! |
2586 | - if (isset($tag['validate'])) |
|
2587 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2722 | + if (isset($tag['validate'])) { |
|
2723 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2724 | + } |
|
2588 | 2725 | |
2589 | 2726 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
2590 | 2727 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2601,23 +2738,27 @@ discard block |
||
2601 | 2738 | elseif ($tag['type'] == 'unparsed_commas_content') |
2602 | 2739 | { |
2603 | 2740 | $pos2 = strpos($message, ']', $pos1); |
2604 | - if ($pos2 === false) |
|
2605 | - continue; |
|
2741 | + if ($pos2 === false) { |
|
2742 | + continue; |
|
2743 | + } |
|
2606 | 2744 | |
2607 | 2745 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2608 | - if ($pos3 === false) |
|
2609 | - continue; |
|
2746 | + if ($pos3 === false) { |
|
2747 | + continue; |
|
2748 | + } |
|
2610 | 2749 | |
2611 | 2750 | // We want $1 to be the content, and the rest to be csv. |
2612 | 2751 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
2613 | 2752 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
2614 | 2753 | |
2615 | - if (isset($tag['validate'])) |
|
2616 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2754 | + if (isset($tag['validate'])) { |
|
2755 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2756 | + } |
|
2617 | 2757 | |
2618 | 2758 | $code = $tag['content']; |
2619 | - foreach ($data as $k => $d) |
|
2620 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2759 | + foreach ($data as $k => $d) { |
|
2760 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2761 | + } |
|
2621 | 2762 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
2622 | 2763 | $pos += strlen($code) - 1 + 2; |
2623 | 2764 | } |
@@ -2625,24 +2766,28 @@ discard block |
||
2625 | 2766 | elseif ($tag['type'] == 'unparsed_commas') |
2626 | 2767 | { |
2627 | 2768 | $pos2 = strpos($message, ']', $pos1); |
2628 | - if ($pos2 === false) |
|
2629 | - continue; |
|
2769 | + if ($pos2 === false) { |
|
2770 | + continue; |
|
2771 | + } |
|
2630 | 2772 | |
2631 | 2773 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
2632 | 2774 | |
2633 | - if (isset($tag['validate'])) |
|
2634 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2775 | + if (isset($tag['validate'])) { |
|
2776 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2777 | + } |
|
2635 | 2778 | |
2636 | 2779 | // Fix after, for disabled code mainly. |
2637 | - foreach ($data as $k => $d) |
|
2638 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2780 | + foreach ($data as $k => $d) { |
|
2781 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2782 | + } |
|
2639 | 2783 | |
2640 | 2784 | $open_tags[] = $tag; |
2641 | 2785 | |
2642 | 2786 | // Replace them out, $1, $2, $3, $4, etc. |
2643 | 2787 | $code = $tag['before']; |
2644 | - foreach ($data as $k => $d) |
|
2645 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2788 | + foreach ($data as $k => $d) { |
|
2789 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2790 | + } |
|
2646 | 2791 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
2647 | 2792 | $pos += strlen($code) - 1 + 2; |
2648 | 2793 | } |
@@ -2653,28 +2798,33 @@ discard block |
||
2653 | 2798 | if (isset($tag['quoted'])) |
2654 | 2799 | { |
2655 | 2800 | $quoted = substr($message, $pos1, 6) == '"'; |
2656 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2657 | - continue; |
|
2801 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2802 | + continue; |
|
2803 | + } |
|
2658 | 2804 | |
2659 | - if ($quoted) |
|
2660 | - $pos1 += 6; |
|
2805 | + if ($quoted) { |
|
2806 | + $pos1 += 6; |
|
2807 | + } |
|
2808 | + } else { |
|
2809 | + $quoted = false; |
|
2661 | 2810 | } |
2662 | - else |
|
2663 | - $quoted = false; |
|
2664 | 2811 | |
2665 | 2812 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2666 | - if ($pos2 === false) |
|
2667 | - continue; |
|
2813 | + if ($pos2 === false) { |
|
2814 | + continue; |
|
2815 | + } |
|
2668 | 2816 | |
2669 | 2817 | $data = substr($message, $pos1, $pos2 - $pos1); |
2670 | 2818 | |
2671 | 2819 | // Validation for my parking, please! |
2672 | - if (isset($tag['validate'])) |
|
2673 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2820 | + if (isset($tag['validate'])) { |
|
2821 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2822 | + } |
|
2674 | 2823 | |
2675 | 2824 | // For parsed content, we must recurse to avoid security problems. |
2676 | - if ($tag['type'] != 'unparsed_equals') |
|
2677 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2825 | + if ($tag['type'] != 'unparsed_equals') { |
|
2826 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2827 | + } |
|
2678 | 2828 | |
2679 | 2829 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
2680 | 2830 | |
@@ -2686,34 +2836,40 @@ discard block |
||
2686 | 2836 | } |
2687 | 2837 | |
2688 | 2838 | // If this is block level, eat any breaks after it. |
2689 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
2690 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2839 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
2840 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2841 | + } |
|
2691 | 2842 | |
2692 | 2843 | // Are we trimming outside this tag? |
2693 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
2694 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2844 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
2845 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2846 | + } |
|
2695 | 2847 | } |
2696 | 2848 | |
2697 | 2849 | // Close any remaining tags. |
2698 | - while ($tag = array_pop($open_tags)) |
|
2699 | - $message .= "\n" . $tag['after'] . "\n"; |
|
2850 | + while ($tag = array_pop($open_tags)) { |
|
2851 | + $message .= "\n" . $tag['after'] . "\n"; |
|
2852 | + } |
|
2700 | 2853 | |
2701 | 2854 | // Parse the smileys within the parts where it can be done safely. |
2702 | 2855 | if ($smileys === true) |
2703 | 2856 | { |
2704 | 2857 | $message_parts = explode("\n", $message); |
2705 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
2706 | - parsesmileys($message_parts[$i]); |
|
2858 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
2859 | + parsesmileys($message_parts[$i]); |
|
2860 | + } |
|
2707 | 2861 | |
2708 | 2862 | $message = implode('', $message_parts); |
2709 | 2863 | } |
2710 | 2864 | |
2711 | 2865 | // No smileys, just get rid of the markers. |
2712 | - else |
|
2713 | - $message = strtr($message, array("\n" => '')); |
|
2866 | + else { |
|
2867 | + $message = strtr($message, array("\n" => '')); |
|
2868 | + } |
|
2714 | 2869 | |
2715 | - if ($message !== '' && $message[0] === ' ') |
|
2716 | - $message = ' ' . substr($message, 1); |
|
2870 | + if ($message !== '' && $message[0] === ' ') { |
|
2871 | + $message = ' ' . substr($message, 1); |
|
2872 | + } |
|
2717 | 2873 | |
2718 | 2874 | // Cleanup whitespace. |
2719 | 2875 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2722,15 +2878,16 @@ discard block |
||
2722 | 2878 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
2723 | 2879 | |
2724 | 2880 | // Cache the output if it took some time... |
2725 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
2726 | - cache_put_data($cache_key, $message, 240); |
|
2881 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
2882 | + cache_put_data($cache_key, $message, 240); |
|
2883 | + } |
|
2727 | 2884 | |
2728 | 2885 | // If this was a force parse revert if needed. |
2729 | 2886 | if (!empty($parse_tags)) |
2730 | 2887 | { |
2731 | - if (empty($temp_bbc)) |
|
2732 | - $bbc_codes = array(); |
|
2733 | - else |
|
2888 | + if (empty($temp_bbc)) { |
|
2889 | + $bbc_codes = array(); |
|
2890 | + } else |
|
2734 | 2891 | { |
2735 | 2892 | $bbc_codes = $temp_bbc; |
2736 | 2893 | unset($temp_bbc); |
@@ -2757,8 +2914,9 @@ discard block |
||
2757 | 2914 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
2758 | 2915 | |
2759 | 2916 | // No smiley set at all?! |
2760 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
2761 | - return; |
|
2917 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
2918 | + return; |
|
2919 | + } |
|
2762 | 2920 | |
2763 | 2921 | // If smileyPregSearch hasn't been set, do it now. |
2764 | 2922 | if (empty($smileyPregSearch)) |
@@ -2769,8 +2927,7 @@ discard block |
||
2769 | 2927 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
2770 | 2928 | $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'); |
2771 | 2929 | $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'], '', '', '', ''); |
2772 | - } |
|
2773 | - else |
|
2930 | + } else |
|
2774 | 2931 | { |
2775 | 2932 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
2776 | 2933 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2794,9 +2951,9 @@ discard block |
||
2794 | 2951 | $smcFunc['db_free_result']($result); |
2795 | 2952 | |
2796 | 2953 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
2954 | + } else { |
|
2955 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2797 | 2956 | } |
2798 | - else |
|
2799 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2800 | 2957 | } |
2801 | 2958 | |
2802 | 2959 | // The non-breaking-space is a complex thing... |
@@ -2873,35 +3030,41 @@ discard block |
||
2873 | 3030 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
2874 | 3031 | |
2875 | 3032 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
2876 | - if (!empty($context['flush_mail'])) |
|
2877 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3033 | + if (!empty($context['flush_mail'])) { |
|
3034 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2878 | 3035 | AddMailQueue(true); |
3036 | + } |
|
2879 | 3037 | |
2880 | 3038 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
2881 | 3039 | |
2882 | - if ($add) |
|
2883 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3040 | + if ($add) { |
|
3041 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3042 | + } |
|
2884 | 3043 | |
2885 | 3044 | // Put the session ID in. |
2886 | - if (defined('SID') && SID != '') |
|
2887 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3045 | + if (defined('SID') && SID != '') { |
|
3046 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3047 | + } |
|
2888 | 3048 | // Keep that debug in their for template debugging! |
2889 | - elseif (isset($_GET['debug'])) |
|
2890 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3049 | + elseif (isset($_GET['debug'])) { |
|
3050 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3051 | + } |
|
2891 | 3052 | |
2892 | 3053 | 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']))) |
2893 | 3054 | { |
2894 | - if (defined('SID') && SID != '') |
|
2895 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
3055 | + if (defined('SID') && SID != '') { |
|
3056 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2896 | 3057 | function ($m) use ($scripturl) |
2897 | 3058 | { |
2898 | 3059 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
3060 | + } |
|
2899 | 3061 | }, $setLocation); |
2900 | - else |
|
2901 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
3062 | + else { |
|
3063 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2902 | 3064 | function ($m) use ($scripturl) |
2903 | 3065 | { |
2904 | 3066 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
3067 | + } |
|
2905 | 3068 | }, $setLocation); |
2906 | 3069 | } |
2907 | 3070 | |
@@ -2912,8 +3075,9 @@ discard block |
||
2912 | 3075 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
2913 | 3076 | |
2914 | 3077 | // Debugging. |
2915 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
2916 | - $_SESSION['debug_redirect'] = $db_cache; |
|
3078 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3079 | + $_SESSION['debug_redirect'] = $db_cache; |
|
3080 | + } |
|
2917 | 3081 | |
2918 | 3082 | obExit(false); |
2919 | 3083 | } |
@@ -2932,51 +3096,60 @@ discard block |
||
2932 | 3096 | |
2933 | 3097 | // Attempt to prevent a recursive loop. |
2934 | 3098 | ++$level; |
2935 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
2936 | - exit; |
|
2937 | - if ($from_fatal_error) |
|
2938 | - $has_fatal_error = true; |
|
3099 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
3100 | + exit; |
|
3101 | + } |
|
3102 | + if ($from_fatal_error) { |
|
3103 | + $has_fatal_error = true; |
|
3104 | + } |
|
2939 | 3105 | |
2940 | 3106 | // Clear out the stat cache. |
2941 | 3107 | trackStats(); |
2942 | 3108 | |
2943 | 3109 | // If we have mail to send, send it. |
2944 | - if (!empty($context['flush_mail'])) |
|
2945 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3110 | + if (!empty($context['flush_mail'])) { |
|
3111 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2946 | 3112 | AddMailQueue(true); |
3113 | + } |
|
2947 | 3114 | |
2948 | 3115 | $do_header = $header === null ? !$header_done : $header; |
2949 | - if ($do_footer === null) |
|
2950 | - $do_footer = $do_header; |
|
3116 | + if ($do_footer === null) { |
|
3117 | + $do_footer = $do_header; |
|
3118 | + } |
|
2951 | 3119 | |
2952 | 3120 | // Has the template/header been done yet? |
2953 | 3121 | if ($do_header) |
2954 | 3122 | { |
2955 | 3123 | // Was the page title set last minute? Also update the HTML safe one. |
2956 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
2957 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3124 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
3125 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3126 | + } |
|
2958 | 3127 | |
2959 | 3128 | // Start up the session URL fixer. |
2960 | 3129 | ob_start('ob_sessrewrite'); |
2961 | 3130 | |
2962 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
2963 | - $buffers = explode(',', $settings['output_buffers']); |
|
2964 | - elseif (!empty($settings['output_buffers'])) |
|
2965 | - $buffers = $settings['output_buffers']; |
|
2966 | - else |
|
2967 | - $buffers = array(); |
|
3131 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
3132 | + $buffers = explode(',', $settings['output_buffers']); |
|
3133 | + } elseif (!empty($settings['output_buffers'])) { |
|
3134 | + $buffers = $settings['output_buffers']; |
|
3135 | + } else { |
|
3136 | + $buffers = array(); |
|
3137 | + } |
|
2968 | 3138 | |
2969 | - if (isset($modSettings['integrate_buffer'])) |
|
2970 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3139 | + if (isset($modSettings['integrate_buffer'])) { |
|
3140 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3141 | + } |
|
2971 | 3142 | |
2972 | - if (!empty($buffers)) |
|
2973 | - foreach ($buffers as $function) |
|
3143 | + if (!empty($buffers)) { |
|
3144 | + foreach ($buffers as $function) |
|
2974 | 3145 | { |
2975 | 3146 | $call = call_helper($function, true); |
3147 | + } |
|
2976 | 3148 | |
2977 | 3149 | // Is it valid? |
2978 | - if (!empty($call)) |
|
2979 | - ob_start($call); |
|
3150 | + if (!empty($call)) { |
|
3151 | + ob_start($call); |
|
3152 | + } |
|
2980 | 3153 | } |
2981 | 3154 | |
2982 | 3155 | // Display the screen in the logical order. |
@@ -2988,8 +3161,9 @@ discard block |
||
2988 | 3161 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
2989 | 3162 | |
2990 | 3163 | // Anything special to put out? |
2991 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
2992 | - echo $context['insert_after_template']; |
|
3164 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
3165 | + echo $context['insert_after_template']; |
|
3166 | + } |
|
2993 | 3167 | |
2994 | 3168 | // Just so we don't get caught in an endless loop of errors from the footer... |
2995 | 3169 | if (!$footer_done) |
@@ -2998,14 +3172,16 @@ discard block |
||
2998 | 3172 | template_footer(); |
2999 | 3173 | |
3000 | 3174 | // (since this is just debugging... it's okay that it's after </html>.) |
3001 | - if (!isset($_REQUEST['xml'])) |
|
3002 | - displayDebug(); |
|
3175 | + if (!isset($_REQUEST['xml'])) { |
|
3176 | + displayDebug(); |
|
3177 | + } |
|
3003 | 3178 | } |
3004 | 3179 | } |
3005 | 3180 | |
3006 | 3181 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
3007 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
3008 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3182 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
3183 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3184 | + } |
|
3009 | 3185 | |
3010 | 3186 | // For session check verification.... don't switch browsers... |
3011 | 3187 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3014,9 +3190,10 @@ discard block |
||
3014 | 3190 | call_integration_hook('integrate_exit', array($do_footer)); |
3015 | 3191 | |
3016 | 3192 | // Don't exit if we're coming from index.php; that will pass through normally. |
3017 | - if (!$from_index) |
|
3018 | - exit; |
|
3019 | -} |
|
3193 | + if (!$from_index) { |
|
3194 | + exit; |
|
3195 | + } |
|
3196 | + } |
|
3020 | 3197 | |
3021 | 3198 | /** |
3022 | 3199 | * Get the size of a specified image with better error handling. |
@@ -3035,8 +3212,9 @@ discard block |
||
3035 | 3212 | $url = str_replace(' ', '%20', $url); |
3036 | 3213 | |
3037 | 3214 | // Can we pull this from the cache... please please? |
3038 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
3039 | - return $temp; |
|
3215 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
3216 | + return $temp; |
|
3217 | + } |
|
3040 | 3218 | $t = microtime(); |
3041 | 3219 | |
3042 | 3220 | // Get the host to pester... |
@@ -3046,12 +3224,10 @@ discard block |
||
3046 | 3224 | if ($url == '' || $url == 'http://' || $url == 'https://') |
3047 | 3225 | { |
3048 | 3226 | return false; |
3049 | - } |
|
3050 | - elseif (!isset($match[1])) |
|
3227 | + } elseif (!isset($match[1])) |
|
3051 | 3228 | { |
3052 | 3229 | $size = @getimagesize($url); |
3053 | - } |
|
3054 | - else |
|
3230 | + } else |
|
3055 | 3231 | { |
3056 | 3232 | // Try to connect to the server... give it half a second. |
3057 | 3233 | $temp = 0; |
@@ -3090,12 +3266,14 @@ discard block |
||
3090 | 3266 | } |
3091 | 3267 | |
3092 | 3268 | // If we didn't get it, we failed. |
3093 | - if (!isset($size)) |
|
3094 | - $size = false; |
|
3269 | + if (!isset($size)) { |
|
3270 | + $size = false; |
|
3271 | + } |
|
3095 | 3272 | |
3096 | 3273 | // If this took a long time, we may never have to do it again, but then again we might... |
3097 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
3098 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3274 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
3275 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3276 | + } |
|
3099 | 3277 | |
3100 | 3278 | // Didn't work. |
3101 | 3279 | return $size; |
@@ -3113,8 +3291,9 @@ discard block |
||
3113 | 3291 | |
3114 | 3292 | // Under SSI this function can be called more then once. That can cause some problems. |
3115 | 3293 | // So only run the function once unless we are forced to run it again. |
3116 | - if ($loaded && !$forceload) |
|
3117 | - return; |
|
3294 | + if ($loaded && !$forceload) { |
|
3295 | + return; |
|
3296 | + } |
|
3118 | 3297 | |
3119 | 3298 | $loaded = true; |
3120 | 3299 | |
@@ -3126,14 +3305,16 @@ discard block |
||
3126 | 3305 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
3127 | 3306 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
3128 | 3307 | { |
3129 | - if (trim($context['news_lines'][$i]) == '') |
|
3130 | - continue; |
|
3308 | + if (trim($context['news_lines'][$i]) == '') { |
|
3309 | + continue; |
|
3310 | + } |
|
3131 | 3311 | |
3132 | 3312 | // Clean it up for presentation ;). |
3133 | 3313 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
3134 | 3314 | } |
3135 | - if (!empty($context['news_lines'])) |
|
3136 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3315 | + if (!empty($context['news_lines'])) { |
|
3316 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3317 | + } |
|
3137 | 3318 | |
3138 | 3319 | if (!$user_info['is_guest']) |
3139 | 3320 | { |
@@ -3142,40 +3323,48 @@ discard block |
||
3142 | 3323 | $context['user']['alerts'] = &$user_info['alerts']; |
3143 | 3324 | |
3144 | 3325 | // Personal message popup... |
3145 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
3146 | - $context['user']['popup_messages'] = true; |
|
3147 | - else |
|
3148 | - $context['user']['popup_messages'] = false; |
|
3326 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
3327 | + $context['user']['popup_messages'] = true; |
|
3328 | + } else { |
|
3329 | + $context['user']['popup_messages'] = false; |
|
3330 | + } |
|
3149 | 3331 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
3150 | 3332 | |
3151 | - if (allowedTo('moderate_forum')) |
|
3152 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3333 | + if (allowedTo('moderate_forum')) { |
|
3334 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3335 | + } |
|
3153 | 3336 | |
3154 | 3337 | $context['user']['avatar'] = array(); |
3155 | 3338 | |
3156 | 3339 | // Check for gravatar first since we might be forcing them... |
3157 | 3340 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
3158 | 3341 | { |
3159 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
3160 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3161 | - else |
|
3162 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3342 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
3343 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3344 | + } else { |
|
3345 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3346 | + } |
|
3163 | 3347 | } |
3164 | 3348 | // Uploaded? |
3165 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
3166 | - $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'; |
|
3349 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
3350 | + $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'; |
|
3351 | + } |
|
3167 | 3352 | // Full URL? |
3168 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
3169 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3353 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
3354 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3355 | + } |
|
3170 | 3356 | // Otherwise we assume it's server stored. |
3171 | - elseif ($user_info['avatar']['url'] != '') |
|
3172 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3357 | + elseif ($user_info['avatar']['url'] != '') { |
|
3358 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3359 | + } |
|
3173 | 3360 | // No avatar at all? Fine, we have a big fat default avatar ;) |
3174 | - else |
|
3175 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3361 | + else { |
|
3362 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3363 | + } |
|
3176 | 3364 | |
3177 | - if (!empty($context['user']['avatar'])) |
|
3178 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3365 | + if (!empty($context['user']['avatar'])) { |
|
3366 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3367 | + } |
|
3179 | 3368 | |
3180 | 3369 | // Figure out how long they've been logged in. |
3181 | 3370 | $context['user']['total_time_logged_in'] = array( |
@@ -3183,8 +3372,7 @@ discard block |
||
3183 | 3372 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
3184 | 3373 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
3185 | 3374 | ); |
3186 | - } |
|
3187 | - else |
|
3375 | + } else |
|
3188 | 3376 | { |
3189 | 3377 | $context['user']['messages'] = 0; |
3190 | 3378 | $context['user']['unread_messages'] = 0; |
@@ -3192,12 +3380,14 @@ discard block |
||
3192 | 3380 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
3193 | 3381 | $context['user']['popup_messages'] = false; |
3194 | 3382 | |
3195 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
3196 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3383 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
3384 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3385 | + } |
|
3197 | 3386 | |
3198 | 3387 | // If we've upgraded recently, go easy on the passwords. |
3199 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
3200 | - $context['disable_login_hashing'] = true; |
|
3388 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
3389 | + $context['disable_login_hashing'] = true; |
|
3390 | + } |
|
3201 | 3391 | } |
3202 | 3392 | |
3203 | 3393 | // Setup the main menu items. |
@@ -3210,8 +3400,8 @@ discard block |
||
3210 | 3400 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
3211 | 3401 | |
3212 | 3402 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
3213 | - if ($context['show_pm_popup']) |
|
3214 | - addInlineJavaScript(' |
|
3403 | + if ($context['show_pm_popup']) { |
|
3404 | + addInlineJavaScript(' |
|
3215 | 3405 | jQuery(document).ready(function($) { |
3216 | 3406 | new smc_Popup({ |
3217 | 3407 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3219,15 +3409,17 @@ discard block |
||
3219 | 3409 | icon_class: \'generic_icons mail_new\' |
3220 | 3410 | }); |
3221 | 3411 | });'); |
3412 | + } |
|
3222 | 3413 | |
3223 | 3414 | // Add a generic "Are you sure?" confirmation message. |
3224 | 3415 | addInlineJavaScript(' |
3225 | 3416 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
3226 | 3417 | |
3227 | 3418 | // Now add the capping code for avatars. |
3228 | - 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') |
|
3229 | - addInlineCss(' |
|
3419 | + 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') { |
|
3420 | + addInlineCss(' |
|
3230 | 3421 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
3422 | + } |
|
3231 | 3423 | |
3232 | 3424 | // This looks weird, but it's because BoardIndex.php references the variable. |
3233 | 3425 | $context['common_stats']['latest_member'] = array( |
@@ -3244,11 +3436,13 @@ discard block |
||
3244 | 3436 | ); |
3245 | 3437 | $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']); |
3246 | 3438 | |
3247 | - if (empty($settings['theme_version'])) |
|
3248 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
3439 | + if (empty($settings['theme_version'])) { |
|
3440 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
3441 | + } |
|
3249 | 3442 | |
3250 | - if (!isset($context['page_title'])) |
|
3251 | - $context['page_title'] = ''; |
|
3443 | + if (!isset($context['page_title'])) { |
|
3444 | + $context['page_title'] = ''; |
|
3445 | + } |
|
3252 | 3446 | |
3253 | 3447 | // Set some specific vars. |
3254 | 3448 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3258,21 +3452,23 @@ discard block |
||
3258 | 3452 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
3259 | 3453 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
3260 | 3454 | |
3261 | - if (!empty($context['meta_keywords'])) |
|
3262 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3455 | + if (!empty($context['meta_keywords'])) { |
|
3456 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3457 | + } |
|
3263 | 3458 | |
3264 | - if (!empty($context['canonical_url'])) |
|
3265 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3459 | + if (!empty($context['canonical_url'])) { |
|
3460 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3461 | + } |
|
3266 | 3462 | |
3267 | - if (!empty($settings['og_image'])) |
|
3268 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3463 | + if (!empty($settings['og_image'])) { |
|
3464 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3465 | + } |
|
3269 | 3466 | |
3270 | 3467 | if (!empty($context['meta_description'])) |
3271 | 3468 | { |
3272 | 3469 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
3273 | 3470 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
3274 | - } |
|
3275 | - else |
|
3471 | + } else |
|
3276 | 3472 | { |
3277 | 3473 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
3278 | 3474 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3297,8 +3493,9 @@ discard block |
||
3297 | 3493 | $memory_needed = memoryReturnBytes($needed); |
3298 | 3494 | |
3299 | 3495 | // should we account for how much is currently being used? |
3300 | - if ($in_use) |
|
3301 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3496 | + if ($in_use) { |
|
3497 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3498 | + } |
|
3302 | 3499 | |
3303 | 3500 | // if more is needed, request it |
3304 | 3501 | if ($memory_current < $memory_needed) |
@@ -3321,8 +3518,9 @@ discard block |
||
3321 | 3518 | */ |
3322 | 3519 | function memoryReturnBytes($val) |
3323 | 3520 | { |
3324 | - if (is_integer($val)) |
|
3325 | - return $val; |
|
3521 | + if (is_integer($val)) { |
|
3522 | + return $val; |
|
3523 | + } |
|
3326 | 3524 | |
3327 | 3525 | // Separate the number from the designator |
3328 | 3526 | $val = trim($val); |
@@ -3358,10 +3556,11 @@ discard block |
||
3358 | 3556 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
3359 | 3557 | |
3360 | 3558 | // Are we debugging the template/html content? |
3361 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
3362 | - header('Content-Type: application/xhtml+xml'); |
|
3363 | - elseif (!isset($_REQUEST['xml'])) |
|
3364 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3559 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
3560 | + header('Content-Type: application/xhtml+xml'); |
|
3561 | + } elseif (!isset($_REQUEST['xml'])) { |
|
3562 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3563 | + } |
|
3365 | 3564 | } |
3366 | 3565 | |
3367 | 3566 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3370,8 +3569,9 @@ discard block |
||
3370 | 3569 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
3371 | 3570 | { |
3372 | 3571 | $position = array_search('body', $context['template_layers']); |
3373 | - if ($position === false) |
|
3374 | - $position = array_search('main', $context['template_layers']); |
|
3572 | + if ($position === false) { |
|
3573 | + $position = array_search('main', $context['template_layers']); |
|
3574 | + } |
|
3375 | 3575 | |
3376 | 3576 | if ($position !== false) |
3377 | 3577 | { |
@@ -3399,23 +3599,25 @@ discard block |
||
3399 | 3599 | |
3400 | 3600 | foreach ($securityFiles as $i => $securityFile) |
3401 | 3601 | { |
3402 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
3403 | - unset($securityFiles[$i]); |
|
3602 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
3603 | + unset($securityFiles[$i]); |
|
3604 | + } |
|
3404 | 3605 | } |
3405 | 3606 | |
3406 | 3607 | // We are already checking so many files...just few more doesn't make any difference! :P |
3407 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
3408 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3409 | - |
|
3410 | - else |
|
3411 | - $path = $modSettings['attachmentUploadDir']; |
|
3608 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
3609 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3610 | + } else { |
|
3611 | + $path = $modSettings['attachmentUploadDir']; |
|
3612 | + } |
|
3412 | 3613 | |
3413 | 3614 | secureDirectory($path, true); |
3414 | 3615 | secureDirectory($cachedir); |
3415 | 3616 | |
3416 | 3617 | // If agreement is enabled, at least the english version shall exists |
3417 | - if ($modSettings['requireAgreement']) |
|
3418 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3618 | + if ($modSettings['requireAgreement']) { |
|
3619 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3620 | + } |
|
3419 | 3621 | |
3420 | 3622 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
3421 | 3623 | { |
@@ -3430,18 +3632,21 @@ discard block |
||
3430 | 3632 | echo ' |
3431 | 3633 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
3432 | 3634 | |
3433 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
3434 | - echo ' |
|
3635 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
3636 | + echo ' |
|
3435 | 3637 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
3638 | + } |
|
3436 | 3639 | } |
3437 | 3640 | |
3438 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
3439 | - echo ' |
|
3641 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
3642 | + echo ' |
|
3440 | 3643 | <strong>', $txt['cache_writable'], '</strong><br>'; |
3644 | + } |
|
3441 | 3645 | |
3442 | - if (!empty($agreement)) |
|
3443 | - echo ' |
|
3646 | + if (!empty($agreement)) { |
|
3647 | + echo ' |
|
3444 | 3648 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
3649 | + } |
|
3445 | 3650 | |
3446 | 3651 | echo ' |
3447 | 3652 | </p> |
@@ -3456,16 +3661,18 @@ discard block |
||
3456 | 3661 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
3457 | 3662 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
3458 | 3663 | |
3459 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
3460 | - echo ' |
|
3664 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
3665 | + echo ' |
|
3461 | 3666 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
3667 | + } |
|
3462 | 3668 | |
3463 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
3464 | - echo ' |
|
3669 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
3670 | + echo ' |
|
3465 | 3671 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
3466 | - else |
|
3467 | - echo ' |
|
3672 | + } else { |
|
3673 | + echo ' |
|
3468 | 3674 | <div>', $txt['your_ban_expires_never'], '</div>'; |
3675 | + } |
|
3469 | 3676 | |
3470 | 3677 | echo ' |
3471 | 3678 | </div>'; |
@@ -3481,8 +3688,9 @@ discard block |
||
3481 | 3688 | global $forum_copyright, $software_year, $forum_version; |
3482 | 3689 | |
3483 | 3690 | // Don't display copyright for things like SSI. |
3484 | - if (!isset($forum_version) || !isset($software_year)) |
|
3485 | - return; |
|
3691 | + if (!isset($forum_version) || !isset($software_year)) { |
|
3692 | + return; |
|
3693 | + } |
|
3486 | 3694 | |
3487 | 3695 | // Put in the version... |
3488 | 3696 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3500,9 +3708,10 @@ discard block |
||
3500 | 3708 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
3501 | 3709 | $context['load_queries'] = $db_count; |
3502 | 3710 | |
3503 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
3504 | - loadSubTemplate($layer . '_below', true); |
|
3505 | -} |
|
3711 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
3712 | + loadSubTemplate($layer . '_below', true); |
|
3713 | + } |
|
3714 | + } |
|
3506 | 3715 | |
3507 | 3716 | /** |
3508 | 3717 | * Output the Javascript files |
@@ -3533,8 +3742,7 @@ discard block |
||
3533 | 3742 | { |
3534 | 3743 | echo ' |
3535 | 3744 | var ', $key, ';'; |
3536 | - } |
|
3537 | - else |
|
3745 | + } else |
|
3538 | 3746 | { |
3539 | 3747 | echo ' |
3540 | 3748 | var ', $key, ' = ', $value, ';'; |
@@ -3549,26 +3757,27 @@ discard block |
||
3549 | 3757 | foreach ($context['javascript_files'] as $id => $js_file) |
3550 | 3758 | { |
3551 | 3759 | // Last minute call! allow theme authors to disable single files. |
3552 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3553 | - continue; |
|
3760 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3761 | + continue; |
|
3762 | + } |
|
3554 | 3763 | |
3555 | 3764 | // By default all files don't get minimized unless the file explicitly says so! |
3556 | 3765 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3557 | 3766 | { |
3558 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
3559 | - $toMinifyDefer[] = $js_file; |
|
3560 | - |
|
3561 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
3562 | - $toMinify[] = $js_file; |
|
3767 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
3768 | + $toMinifyDefer[] = $js_file; |
|
3769 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
3770 | + $toMinify[] = $js_file; |
|
3771 | + } |
|
3563 | 3772 | |
3564 | 3773 | // Grab a random seed. |
3565 | - if (!isset($minSeed)) |
|
3566 | - $minSeed = $js_file['options']['seed']; |
|
3567 | - } |
|
3568 | - |
|
3569 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
3570 | - echo ' |
|
3774 | + if (!isset($minSeed)) { |
|
3775 | + $minSeed = $js_file['options']['seed']; |
|
3776 | + } |
|
3777 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
3778 | + echo ' |
|
3571 | 3779 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
3780 | + } |
|
3572 | 3781 | } |
3573 | 3782 | |
3574 | 3783 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3576,14 +3785,14 @@ discard block |
||
3576 | 3785 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
3577 | 3786 | |
3578 | 3787 | // Minify process couldn't work, print each individual files. |
3579 | - if (!empty($result) && is_array($result)) |
|
3580 | - foreach ($result as $minFailedFile) |
|
3788 | + if (!empty($result) && is_array($result)) { |
|
3789 | + foreach ($result as $minFailedFile) |
|
3581 | 3790 | echo ' |
3582 | 3791 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
3583 | - |
|
3584 | - else |
|
3585 | - echo ' |
|
3792 | + } else { |
|
3793 | + echo ' |
|
3586 | 3794 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
3795 | + } |
|
3587 | 3796 | } |
3588 | 3797 | |
3589 | 3798 | // Inline JavaScript - Actually useful some times! |
@@ -3594,8 +3803,9 @@ discard block |
||
3594 | 3803 | echo ' |
3595 | 3804 | <script>'; |
3596 | 3805 | |
3597 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
3598 | - echo $js_code; |
|
3806 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
3807 | + echo $js_code; |
|
3808 | + } |
|
3599 | 3809 | |
3600 | 3810 | echo ' |
3601 | 3811 | </script>'; |
@@ -3606,8 +3816,9 @@ discard block |
||
3606 | 3816 | echo ' |
3607 | 3817 | <script>'; |
3608 | 3818 | |
3609 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
3610 | - echo $js_code; |
|
3819 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
3820 | + echo $js_code; |
|
3821 | + } |
|
3611 | 3822 | |
3612 | 3823 | echo ' |
3613 | 3824 | </script>'; |
@@ -3632,8 +3843,9 @@ discard block |
||
3632 | 3843 | foreach ($context['css_files'] as $id => $file) |
3633 | 3844 | { |
3634 | 3845 | // Last minute call! allow theme authors to disable single files. |
3635 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3636 | - continue; |
|
3846 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3847 | + continue; |
|
3848 | + } |
|
3637 | 3849 | |
3638 | 3850 | // By default all files don't get minimized unless the file explicitly says so! |
3639 | 3851 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3641,12 +3853,12 @@ discard block |
||
3641 | 3853 | $toMinify[] = $file; |
3642 | 3854 | |
3643 | 3855 | // Grab a random seed. |
3644 | - if (!isset($minSeed)) |
|
3645 | - $minSeed = $file['options']['seed']; |
|
3856 | + if (!isset($minSeed)) { |
|
3857 | + $minSeed = $file['options']['seed']; |
|
3858 | + } |
|
3859 | + } else { |
|
3860 | + $normal[] = $file['fileUrl']; |
|
3646 | 3861 | } |
3647 | - |
|
3648 | - else |
|
3649 | - $normal[] = $file['fileUrl']; |
|
3650 | 3862 | } |
3651 | 3863 | |
3652 | 3864 | if (!empty($toMinify)) |
@@ -3654,28 +3866,30 @@ discard block |
||
3654 | 3866 | $result = custMinify($toMinify, 'css'); |
3655 | 3867 | |
3656 | 3868 | // Minify process couldn't work, print each individual files. |
3657 | - if (!empty($result) && is_array($result)) |
|
3658 | - foreach ($result as $minFailedFile) |
|
3869 | + if (!empty($result) && is_array($result)) { |
|
3870 | + foreach ($result as $minFailedFile) |
|
3659 | 3871 | echo ' |
3660 | 3872 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
3661 | - |
|
3662 | - else |
|
3663 | - echo ' |
|
3873 | + } else { |
|
3874 | + echo ' |
|
3664 | 3875 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
3876 | + } |
|
3665 | 3877 | } |
3666 | 3878 | |
3667 | 3879 | // Print the rest after the minified files. |
3668 | - if (!empty($normal)) |
|
3669 | - foreach ($normal as $nf) |
|
3880 | + if (!empty($normal)) { |
|
3881 | + foreach ($normal as $nf) |
|
3670 | 3882 | echo ' |
3671 | 3883 | <link rel="stylesheet" href="', $nf ,'">'; |
3884 | + } |
|
3672 | 3885 | |
3673 | 3886 | if ($db_show_debug === true) |
3674 | 3887 | { |
3675 | 3888 | // Try to keep only what's useful. |
3676 | 3889 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
3677 | - foreach ($context['css_files'] as $file) |
|
3678 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3890 | + foreach ($context['css_files'] as $file) { |
|
3891 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3892 | + } |
|
3679 | 3893 | } |
3680 | 3894 | |
3681 | 3895 | if (!empty($context['css_header'])) |
@@ -3683,9 +3897,10 @@ discard block |
||
3683 | 3897 | echo ' |
3684 | 3898 | <style>'; |
3685 | 3899 | |
3686 | - foreach ($context['css_header'] as $css) |
|
3687 | - echo $css .' |
|
3900 | + foreach ($context['css_header'] as $css) { |
|
3901 | + echo $css .' |
|
3688 | 3902 | '; |
3903 | + } |
|
3689 | 3904 | |
3690 | 3905 | echo' |
3691 | 3906 | </style>'; |
@@ -3709,15 +3924,17 @@ discard block |
||
3709 | 3924 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
3710 | 3925 | $data = !empty($data) ? $data : false; |
3711 | 3926 | |
3712 | - if (empty($type) || empty($data)) |
|
3713 | - return false; |
|
3927 | + if (empty($type) || empty($data)) { |
|
3928 | + return false; |
|
3929 | + } |
|
3714 | 3930 | |
3715 | 3931 | // Did we already did this? |
3716 | 3932 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
3717 | 3933 | |
3718 | 3934 | // Already done? |
3719 | - if (!empty($toCache)) |
|
3720 | - return true; |
|
3935 | + if (!empty($toCache)) { |
|
3936 | + return true; |
|
3937 | + } |
|
3721 | 3938 | |
3722 | 3939 | // No namespaces, sorry! |
3723 | 3940 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3799,8 +4016,9 @@ discard block |
||
3799 | 4016 | global $modSettings, $smcFunc; |
3800 | 4017 | |
3801 | 4018 | // Just make up a nice hash... |
3802 | - if ($new) |
|
3803 | - return sha1(md5($filename . time()) . mt_rand()); |
|
4019 | + if ($new) { |
|
4020 | + return sha1(md5($filename . time()) . mt_rand()); |
|
4021 | + } |
|
3804 | 4022 | |
3805 | 4023 | // Just make sure that attachment id is only a int |
3806 | 4024 | $attachment_id = (int) $attachment_id; |
@@ -3817,23 +4035,25 @@ discard block |
||
3817 | 4035 | 'id_attach' => $attachment_id, |
3818 | 4036 | )); |
3819 | 4037 | |
3820 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
3821 | - return false; |
|
4038 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
4039 | + return false; |
|
4040 | + } |
|
3822 | 4041 | |
3823 | 4042 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
3824 | 4043 | $smcFunc['db_free_result']($request); |
3825 | 4044 | } |
3826 | 4045 | |
3827 | 4046 | // Still no hash? mmm... |
3828 | - if (empty($file_hash)) |
|
3829 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4047 | + if (empty($file_hash)) { |
|
4048 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4049 | + } |
|
3830 | 4050 | |
3831 | 4051 | // Are we using multiple directories? |
3832 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
3833 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3834 | - |
|
3835 | - else |
|
3836 | - $path = $modSettings['attachmentUploadDir']; |
|
4052 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
4053 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
4054 | + } else { |
|
4055 | + $path = $modSettings['attachmentUploadDir']; |
|
4056 | + } |
|
3837 | 4057 | |
3838 | 4058 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
3839 | 4059 | } |
@@ -3848,8 +4068,9 @@ discard block |
||
3848 | 4068 | function ip2range($fullip) |
3849 | 4069 | { |
3850 | 4070 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
3851 | - if ($fullip == 'unknown') |
|
3852 | - $fullip = '255.255.255.255'; |
|
4071 | + if ($fullip == 'unknown') { |
|
4072 | + $fullip = '255.255.255.255'; |
|
4073 | + } |
|
3853 | 4074 | |
3854 | 4075 | $ip_parts = explode('-', $fullip); |
3855 | 4076 | $ip_array = array(); |
@@ -3873,10 +4094,11 @@ discard block |
||
3873 | 4094 | $ip_array['low'] = $ip_parts[0]; |
3874 | 4095 | $ip_array['high'] = $ip_parts[1]; |
3875 | 4096 | return $ip_array; |
3876 | - } |
|
3877 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
4097 | + } elseif (count($ip_parts) == 2) { |
|
4098 | + // if ip 22.22.*-22.22.* |
|
3878 | 4099 | { |
3879 | 4100 | $valid_low = isValidIP($ip_parts[0]); |
4101 | + } |
|
3880 | 4102 | $valid_high = isValidIP($ip_parts[1]); |
3881 | 4103 | $count = 0; |
3882 | 4104 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3891,7 +4113,9 @@ discard block |
||
3891 | 4113 | $ip_parts[0] .= $mode . $min; |
3892 | 4114 | $valid_low = isValidIP($ip_parts[0]); |
3893 | 4115 | $count++; |
3894 | - if ($count > 9) break; |
|
4116 | + if ($count > 9) { |
|
4117 | + break; |
|
4118 | + } |
|
3895 | 4119 | } |
3896 | 4120 | } |
3897 | 4121 | |
@@ -3905,7 +4129,9 @@ discard block |
||
3905 | 4129 | $ip_parts[1] .= $mode . $max; |
3906 | 4130 | $valid_high = isValidIP($ip_parts[1]); |
3907 | 4131 | $count++; |
3908 | - if ($count > 9) break; |
|
4132 | + if ($count > 9) { |
|
4133 | + break; |
|
4134 | + } |
|
3909 | 4135 | } |
3910 | 4136 | } |
3911 | 4137 | |
@@ -3930,46 +4156,54 @@ discard block |
||
3930 | 4156 | { |
3931 | 4157 | global $modSettings; |
3932 | 4158 | |
3933 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
3934 | - return $host; |
|
4159 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
4160 | + return $host; |
|
4161 | + } |
|
3935 | 4162 | $t = microtime(); |
3936 | 4163 | |
3937 | 4164 | // Try the Linux host command, perhaps? |
3938 | 4165 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
3939 | 4166 | { |
3940 | - if (!isset($modSettings['host_to_dis'])) |
|
3941 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
3942 | - else |
|
3943 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4167 | + if (!isset($modSettings['host_to_dis'])) { |
|
4168 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4169 | + } else { |
|
4170 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4171 | + } |
|
3944 | 4172 | |
3945 | 4173 | // Did host say it didn't find anything? |
3946 | - if (strpos($test, 'not found') !== false) |
|
3947 | - $host = ''; |
|
4174 | + if (strpos($test, 'not found') !== false) { |
|
4175 | + $host = ''; |
|
4176 | + } |
|
3948 | 4177 | // Invalid server option? |
3949 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
3950 | - updateSettings(array('host_to_dis' => 1)); |
|
4178 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
4179 | + updateSettings(array('host_to_dis' => 1)); |
|
4180 | + } |
|
3951 | 4181 | // Maybe it found something, after all? |
3952 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
3953 | - $host = $match[1]; |
|
4182 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
4183 | + $host = $match[1]; |
|
4184 | + } |
|
3954 | 4185 | } |
3955 | 4186 | |
3956 | 4187 | // This is nslookup; usually only Windows, but possibly some Unix? |
3957 | 4188 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
3958 | 4189 | { |
3959 | 4190 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
3960 | - if (strpos($test, 'Non-existent domain') !== false) |
|
3961 | - $host = ''; |
|
3962 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
3963 | - $host = $match[1]; |
|
4191 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
4192 | + $host = ''; |
|
4193 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
4194 | + $host = $match[1]; |
|
4195 | + } |
|
3964 | 4196 | } |
3965 | 4197 | |
3966 | 4198 | // This is the last try :/. |
3967 | - if (!isset($host) || $host === false) |
|
3968 | - $host = @gethostbyaddr($ip); |
|
4199 | + if (!isset($host) || $host === false) { |
|
4200 | + $host = @gethostbyaddr($ip); |
|
4201 | + } |
|
3969 | 4202 | |
3970 | 4203 | // It took a long time, so let's cache it! |
3971 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
3972 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4204 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
4205 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4206 | + } |
|
3973 | 4207 | |
3974 | 4208 | return $host; |
3975 | 4209 | } |
@@ -4005,20 +4239,21 @@ discard block |
||
4005 | 4239 | { |
4006 | 4240 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
4007 | 4241 | $total = 0; |
4008 | - for ($i = 0; $i < $max_chars; $i++) |
|
4009 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4242 | + for ($i = 0; $i < $max_chars; $i++) { |
|
4243 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4244 | + } |
|
4010 | 4245 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
4011 | 4246 | } |
4012 | 4247 | } |
4013 | 4248 | return array_unique($returned_ints); |
4014 | - } |
|
4015 | - else |
|
4249 | + } else |
|
4016 | 4250 | { |
4017 | 4251 | // Trim characters before and after and add slashes for database insertion. |
4018 | 4252 | $returned_words = array(); |
4019 | - foreach ($words as $word) |
|
4020 | - if (($word = trim($word, '-_\'')) !== '') |
|
4253 | + foreach ($words as $word) { |
|
4254 | + if (($word = trim($word, '-_\'')) !== '') |
|
4021 | 4255 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
4256 | + } |
|
4022 | 4257 | |
4023 | 4258 | // Filter out all words that occur more than once. |
4024 | 4259 | return array_unique($returned_words); |
@@ -4040,16 +4275,18 @@ discard block |
||
4040 | 4275 | global $settings, $txt; |
4041 | 4276 | |
4042 | 4277 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
4043 | - if (function_exists('template_create_button') && !$force_use) |
|
4044 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4278 | + if (function_exists('template_create_button') && !$force_use) { |
|
4279 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4280 | + } |
|
4045 | 4281 | |
4046 | - if (!$settings['use_image_buttons']) |
|
4047 | - return $txt[$alt]; |
|
4048 | - elseif (!empty($settings['use_buttons'])) |
|
4049 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4050 | - else |
|
4051 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4052 | -} |
|
4282 | + if (!$settings['use_image_buttons']) { |
|
4283 | + return $txt[$alt]; |
|
4284 | + } elseif (!empty($settings['use_buttons'])) { |
|
4285 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4286 | + } else { |
|
4287 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4288 | + } |
|
4289 | + } |
|
4053 | 4290 | |
4054 | 4291 | /** |
4055 | 4292 | * Sets up all of the top menu buttons |
@@ -4092,9 +4329,10 @@ discard block |
||
4092 | 4329 | var user_menus = new smc_PopupMenu(); |
4093 | 4330 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4094 | 4331 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
4095 | - if ($context['allow_pm']) |
|
4096 | - addInlineJavaScript(' |
|
4332 | + if ($context['allow_pm']) { |
|
4333 | + addInlineJavaScript(' |
|
4097 | 4334 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
4335 | + } |
|
4098 | 4336 | |
4099 | 4337 | if (!empty($modSettings['enable_ajax_alerts'])) |
4100 | 4338 | { |
@@ -4254,88 +4492,96 @@ discard block |
||
4254 | 4492 | |
4255 | 4493 | // Now we put the buttons in the context so the theme can use them. |
4256 | 4494 | $menu_buttons = array(); |
4257 | - foreach ($buttons as $act => $button) |
|
4258 | - if (!empty($button['show'])) |
|
4495 | + foreach ($buttons as $act => $button) { |
|
4496 | + if (!empty($button['show'])) |
|
4259 | 4497 | { |
4260 | 4498 | $button['active_button'] = false; |
4499 | + } |
|
4261 | 4500 | |
4262 | 4501 | // This button needs some action. |
4263 | - if (isset($button['action_hook'])) |
|
4264 | - $needs_action_hook = true; |
|
4502 | + if (isset($button['action_hook'])) { |
|
4503 | + $needs_action_hook = true; |
|
4504 | + } |
|
4265 | 4505 | |
4266 | 4506 | // Make sure the last button truly is the last button. |
4267 | 4507 | if (!empty($button['is_last'])) |
4268 | 4508 | { |
4269 | - if (isset($last_button)) |
|
4270 | - unset($menu_buttons[$last_button]['is_last']); |
|
4509 | + if (isset($last_button)) { |
|
4510 | + unset($menu_buttons[$last_button]['is_last']); |
|
4511 | + } |
|
4271 | 4512 | $last_button = $act; |
4272 | 4513 | } |
4273 | 4514 | |
4274 | 4515 | // Go through the sub buttons if there are any. |
4275 | - if (!empty($button['sub_buttons'])) |
|
4276 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4516 | + if (!empty($button['sub_buttons'])) { |
|
4517 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4277 | 4518 | { |
4278 | 4519 | if (empty($subbutton['show'])) |
4279 | 4520 | unset($button['sub_buttons'][$key]); |
4521 | + } |
|
4280 | 4522 | |
4281 | 4523 | // 2nd level sub buttons next... |
4282 | 4524 | if (!empty($subbutton['sub_buttons'])) |
4283 | 4525 | { |
4284 | 4526 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
4285 | 4527 | { |
4286 | - if (empty($sub_button2['show'])) |
|
4287 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4528 | + if (empty($sub_button2['show'])) { |
|
4529 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4530 | + } |
|
4288 | 4531 | } |
4289 | 4532 | } |
4290 | 4533 | } |
4291 | 4534 | |
4292 | 4535 | // Does this button have its own icon? |
4293 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
4294 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4295 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
4296 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4297 | - elseif (isset($button['icon'])) |
|
4298 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4299 | - else |
|
4300 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4536 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
4537 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4538 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
4539 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4540 | + } elseif (isset($button['icon'])) { |
|
4541 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4542 | + } else { |
|
4543 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4544 | + } |
|
4301 | 4545 | |
4302 | 4546 | $menu_buttons[$act] = $button; |
4303 | 4547 | } |
4304 | 4548 | |
4305 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
4306 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4549 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
4550 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4551 | + } |
|
4307 | 4552 | } |
4308 | 4553 | |
4309 | 4554 | $context['menu_buttons'] = $menu_buttons; |
4310 | 4555 | |
4311 | 4556 | // Logging out requires the session id in the url. |
4312 | - if (isset($context['menu_buttons']['logout'])) |
|
4313 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4557 | + if (isset($context['menu_buttons']['logout'])) { |
|
4558 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4559 | + } |
|
4314 | 4560 | |
4315 | 4561 | // Figure out which action we are doing so we can set the active tab. |
4316 | 4562 | // Default to home. |
4317 | 4563 | $current_action = 'home'; |
4318 | 4564 | |
4319 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
4320 | - $current_action = $context['current_action']; |
|
4321 | - elseif ($context['current_action'] == 'search2') |
|
4322 | - $current_action = 'search'; |
|
4323 | - elseif ($context['current_action'] == 'theme') |
|
4324 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4325 | - elseif ($context['current_action'] == 'register2') |
|
4326 | - $current_action = 'register'; |
|
4327 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
4328 | - $current_action = 'login'; |
|
4329 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
4330 | - $current_action = 'moderate'; |
|
4565 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
4566 | + $current_action = $context['current_action']; |
|
4567 | + } elseif ($context['current_action'] == 'search2') { |
|
4568 | + $current_action = 'search'; |
|
4569 | + } elseif ($context['current_action'] == 'theme') { |
|
4570 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4571 | + } elseif ($context['current_action'] == 'register2') { |
|
4572 | + $current_action = 'register'; |
|
4573 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
4574 | + $current_action = 'login'; |
|
4575 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
4576 | + $current_action = 'moderate'; |
|
4577 | + } |
|
4331 | 4578 | |
4332 | 4579 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
4333 | 4580 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
4334 | 4581 | { |
4335 | 4582 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
4336 | 4583 | $context[$current_action] = true; |
4337 | - } |
|
4338 | - elseif ($context['current_action'] == 'pm') |
|
4584 | + } elseif ($context['current_action'] == 'pm') |
|
4339 | 4585 | { |
4340 | 4586 | $current_action = 'self_pm'; |
4341 | 4587 | $context['self_pm'] = true; |
@@ -4392,12 +4638,14 @@ discard block |
||
4392 | 4638 | } |
4393 | 4639 | |
4394 | 4640 | // Not all actions are simple. |
4395 | - if (!empty($needs_action_hook)) |
|
4396 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4641 | + if (!empty($needs_action_hook)) { |
|
4642 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4643 | + } |
|
4397 | 4644 | |
4398 | - if (isset($context['menu_buttons'][$current_action])) |
|
4399 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4400 | -} |
|
4645 | + if (isset($context['menu_buttons'][$current_action])) { |
|
4646 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4647 | + } |
|
4648 | + } |
|
4401 | 4649 | |
4402 | 4650 | /** |
4403 | 4651 | * Generate a random seed and ensure it's stored in settings. |
@@ -4421,30 +4669,35 @@ discard block |
||
4421 | 4669 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
4422 | 4670 | global $context, $txt; |
4423 | 4671 | |
4424 | - if ($db_show_debug === true) |
|
4425 | - $context['debug']['hooks'][] = $hook; |
|
4672 | + if ($db_show_debug === true) { |
|
4673 | + $context['debug']['hooks'][] = $hook; |
|
4674 | + } |
|
4426 | 4675 | |
4427 | 4676 | // Need to have some control. |
4428 | - if (!isset($context['instances'])) |
|
4429 | - $context['instances'] = array(); |
|
4677 | + if (!isset($context['instances'])) { |
|
4678 | + $context['instances'] = array(); |
|
4679 | + } |
|
4430 | 4680 | |
4431 | 4681 | $results = array(); |
4432 | - if (empty($modSettings[$hook])) |
|
4433 | - return $results; |
|
4682 | + if (empty($modSettings[$hook])) { |
|
4683 | + return $results; |
|
4684 | + } |
|
4434 | 4685 | |
4435 | 4686 | $functions = explode(',', $modSettings[$hook]); |
4436 | 4687 | // Loop through each function. |
4437 | 4688 | foreach ($functions as $function) |
4438 | 4689 | { |
4439 | 4690 | // Hook has been marked as "disabled". Skip it! |
4440 | - if (strpos($function, '!') !== false) |
|
4441 | - continue; |
|
4691 | + if (strpos($function, '!') !== false) { |
|
4692 | + continue; |
|
4693 | + } |
|
4442 | 4694 | |
4443 | 4695 | $call = call_helper($function, true); |
4444 | 4696 | |
4445 | 4697 | // Is it valid? |
4446 | - if (!empty($call)) |
|
4447 | - $results[$function] = call_user_func_array($call, $parameters); |
|
4698 | + if (!empty($call)) { |
|
4699 | + $results[$function] = call_user_func_array($call, $parameters); |
|
4700 | + } |
|
4448 | 4701 | |
4449 | 4702 | // Whatever it was suppose to call, it failed :( |
4450 | 4703 | elseif (!empty($function)) |
@@ -4460,8 +4713,9 @@ discard block |
||
4460 | 4713 | } |
4461 | 4714 | |
4462 | 4715 | // "Assume" the file resides on $boarddir somewhere... |
4463 | - else |
|
4464 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4716 | + else { |
|
4717 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4718 | + } |
|
4465 | 4719 | } |
4466 | 4720 | } |
4467 | 4721 | |
@@ -4483,12 +4737,14 @@ discard block |
||
4483 | 4737 | global $smcFunc, $modSettings; |
4484 | 4738 | |
4485 | 4739 | // Any objects? |
4486 | - if ($object) |
|
4487 | - $function = $function . '#'; |
|
4740 | + if ($object) { |
|
4741 | + $function = $function . '#'; |
|
4742 | + } |
|
4488 | 4743 | |
4489 | 4744 | // Any files to load? |
4490 | - if (!empty($file) && is_string($file)) |
|
4491 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4745 | + if (!empty($file) && is_string($file)) { |
|
4746 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4747 | + } |
|
4492 | 4748 | |
4493 | 4749 | // Get the correct string. |
4494 | 4750 | $integration_call = $function; |
@@ -4510,13 +4766,14 @@ discard block |
||
4510 | 4766 | if (!empty($current_functions)) |
4511 | 4767 | { |
4512 | 4768 | $current_functions = explode(',', $current_functions); |
4513 | - if (in_array($integration_call, $current_functions)) |
|
4514 | - return; |
|
4769 | + if (in_array($integration_call, $current_functions)) { |
|
4770 | + return; |
|
4771 | + } |
|
4515 | 4772 | |
4516 | 4773 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
4774 | + } else { |
|
4775 | + $permanent_functions = array($integration_call); |
|
4517 | 4776 | } |
4518 | - else |
|
4519 | - $permanent_functions = array($integration_call); |
|
4520 | 4777 | |
4521 | 4778 | updateSettings(array($hook => implode(',', $permanent_functions))); |
4522 | 4779 | } |
@@ -4525,8 +4782,9 @@ discard block |
||
4525 | 4782 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4526 | 4783 | |
4527 | 4784 | // Do nothing, if it's already there. |
4528 | - if (in_array($integration_call, $functions)) |
|
4529 | - return; |
|
4785 | + if (in_array($integration_call, $functions)) { |
|
4786 | + return; |
|
4787 | + } |
|
4530 | 4788 | |
4531 | 4789 | $functions[] = $integration_call; |
4532 | 4790 | $modSettings[$hook] = implode(',', $functions); |
@@ -4549,12 +4807,14 @@ discard block |
||
4549 | 4807 | global $smcFunc, $modSettings; |
4550 | 4808 | |
4551 | 4809 | // Any objects? |
4552 | - if ($object) |
|
4553 | - $function = $function . '#'; |
|
4810 | + if ($object) { |
|
4811 | + $function = $function . '#'; |
|
4812 | + } |
|
4554 | 4813 | |
4555 | 4814 | // Any files to load? |
4556 | - if (!empty($file) && is_string($file)) |
|
4557 | - $function = $file . '|' . $function; |
|
4815 | + if (!empty($file) && is_string($file)) { |
|
4816 | + $function = $file . '|' . $function; |
|
4817 | + } |
|
4558 | 4818 | |
4559 | 4819 | // Get the correct string. |
4560 | 4820 | $integration_call = $function; |
@@ -4575,16 +4835,18 @@ discard block |
||
4575 | 4835 | { |
4576 | 4836 | $current_functions = explode(',', $current_functions); |
4577 | 4837 | |
4578 | - if (in_array($integration_call, $current_functions)) |
|
4579 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4838 | + if (in_array($integration_call, $current_functions)) { |
|
4839 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4840 | + } |
|
4580 | 4841 | } |
4581 | 4842 | |
4582 | 4843 | // Turn the function list into something usable. |
4583 | 4844 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4584 | 4845 | |
4585 | 4846 | // You can only remove it if it's available. |
4586 | - if (!in_array($integration_call, $functions)) |
|
4587 | - return; |
|
4847 | + if (!in_array($integration_call, $functions)) { |
|
4848 | + return; |
|
4849 | + } |
|
4588 | 4850 | |
4589 | 4851 | $functions = array_diff($functions, array($integration_call)); |
4590 | 4852 | $modSettings[$hook] = implode(',', $functions); |
@@ -4605,17 +4867,20 @@ discard block |
||
4605 | 4867 | global $context, $smcFunc, $txt, $db_show_debug; |
4606 | 4868 | |
4607 | 4869 | // Really? |
4608 | - if (empty($string)) |
|
4609 | - return false; |
|
4870 | + if (empty($string)) { |
|
4871 | + return false; |
|
4872 | + } |
|
4610 | 4873 | |
4611 | 4874 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
4612 | 4875 | // A closure? should be a callable one. |
4613 | - if (is_array($string) || $string instanceof Closure) |
|
4614 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4876 | + if (is_array($string) || $string instanceof Closure) { |
|
4877 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4878 | + } |
|
4615 | 4879 | |
4616 | 4880 | // No full objects, sorry! pass a method or a property instead! |
4617 | - if (is_object($string)) |
|
4618 | - return false; |
|
4881 | + if (is_object($string)) { |
|
4882 | + return false; |
|
4883 | + } |
|
4619 | 4884 | |
4620 | 4885 | // Stay vitaminized my friends... |
4621 | 4886 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4624,8 +4889,9 @@ discard block |
||
4624 | 4889 | $string = load_file($string); |
4625 | 4890 | |
4626 | 4891 | // Loaded file failed |
4627 | - if (empty($string)) |
|
4628 | - return false; |
|
4892 | + if (empty($string)) { |
|
4893 | + return false; |
|
4894 | + } |
|
4629 | 4895 | |
4630 | 4896 | // Found a method. |
4631 | 4897 | if (strpos($string, '::') !== false) |
@@ -4646,8 +4912,9 @@ discard block |
||
4646 | 4912 | // Add another one to the list. |
4647 | 4913 | if ($db_show_debug === true) |
4648 | 4914 | { |
4649 | - if (!isset($context['debug']['instances'])) |
|
4650 | - $context['debug']['instances'] = array(); |
|
4915 | + if (!isset($context['debug']['instances'])) { |
|
4916 | + $context['debug']['instances'] = array(); |
|
4917 | + } |
|
4651 | 4918 | |
4652 | 4919 | $context['debug']['instances'][$class] = $class; |
4653 | 4920 | } |
@@ -4657,13 +4924,15 @@ discard block |
||
4657 | 4924 | } |
4658 | 4925 | |
4659 | 4926 | // Right then. This is a call to a static method. |
4660 | - else |
|
4661 | - $func = array($class, $method); |
|
4927 | + else { |
|
4928 | + $func = array($class, $method); |
|
4929 | + } |
|
4662 | 4930 | } |
4663 | 4931 | |
4664 | 4932 | // Nope! just a plain regular function. |
4665 | - else |
|
4666 | - $func = $string; |
|
4933 | + else { |
|
4934 | + $func = $string; |
|
4935 | + } |
|
4667 | 4936 | |
4668 | 4937 | // Right, we got what we need, time to do some checks. |
4669 | 4938 | if (!is_callable($func, false, $callable_name)) |
@@ -4679,17 +4948,18 @@ discard block |
||
4679 | 4948 | else |
4680 | 4949 | { |
4681 | 4950 | // What are we gonna do about it? |
4682 | - if ($return) |
|
4683 | - return $func; |
|
4951 | + if ($return) { |
|
4952 | + return $func; |
|
4953 | + } |
|
4684 | 4954 | |
4685 | 4955 | // If this is a plain function, avoid the heat of calling call_user_func(). |
4686 | 4956 | else |
4687 | 4957 | { |
4688 | - if (is_array($func)) |
|
4689 | - call_user_func($func); |
|
4690 | - |
|
4691 | - else |
|
4692 | - $func(); |
|
4958 | + if (is_array($func)) { |
|
4959 | + call_user_func($func); |
|
4960 | + } else { |
|
4961 | + $func(); |
|
4962 | + } |
|
4693 | 4963 | } |
4694 | 4964 | } |
4695 | 4965 | } |
@@ -4706,31 +4976,34 @@ discard block |
||
4706 | 4976 | { |
4707 | 4977 | global $sourcedir, $txt, $boarddir, $settings; |
4708 | 4978 | |
4709 | - if (empty($string)) |
|
4710 | - return false; |
|
4979 | + if (empty($string)) { |
|
4980 | + return false; |
|
4981 | + } |
|
4711 | 4982 | |
4712 | 4983 | if (strpos($string, '|') !== false) |
4713 | 4984 | { |
4714 | 4985 | list ($file, $string) = explode('|', $string); |
4715 | 4986 | |
4716 | 4987 | // Match the wildcards to their regular vars. |
4717 | - if (empty($settings['theme_dir'])) |
|
4718 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4719 | - |
|
4720 | - else |
|
4721 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
4988 | + if (empty($settings['theme_dir'])) { |
|
4989 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4990 | + } else { |
|
4991 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
4992 | + } |
|
4722 | 4993 | |
4723 | 4994 | // Load the file if it can be loaded. |
4724 | - if (file_exists($absPath)) |
|
4725 | - require_once($absPath); |
|
4995 | + if (file_exists($absPath)) { |
|
4996 | + require_once($absPath); |
|
4997 | + } |
|
4726 | 4998 | |
4727 | 4999 | // No? try a fallback to $sourcedir |
4728 | 5000 | else |
4729 | 5001 | { |
4730 | 5002 | $absPath = $sourcedir .'/'. $file; |
4731 | 5003 | |
4732 | - if (file_exists($absPath)) |
|
4733 | - require_once($absPath); |
|
5004 | + if (file_exists($absPath)) { |
|
5005 | + require_once($absPath); |
|
5006 | + } |
|
4734 | 5007 | |
4735 | 5008 | // Sorry, can't do much for you at this point. |
4736 | 5009 | else |
@@ -4757,8 +5030,9 @@ discard block |
||
4757 | 5030 | global $user_info, $smcFunc; |
4758 | 5031 | |
4759 | 5032 | // Make sure we have something to work with. |
4760 | - if (empty($topic)) |
|
4761 | - return array(); |
|
5033 | + if (empty($topic)) { |
|
5034 | + return array(); |
|
5035 | + } |
|
4762 | 5036 | |
4763 | 5037 | |
4764 | 5038 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4781,8 +5055,9 @@ discard block |
||
4781 | 5055 | 'topic' => $topic, |
4782 | 5056 | ) |
4783 | 5057 | ); |
4784 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4785 | - $temp[] = (int) $row['content_id']; |
|
5058 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5059 | + $temp[] = (int) $row['content_id']; |
|
5060 | + } |
|
4786 | 5061 | |
4787 | 5062 | cache_put_data($cache_key, $temp, $ttl); |
4788 | 5063 | } |
@@ -4803,8 +5078,9 @@ discard block |
||
4803 | 5078 | { |
4804 | 5079 | global $context; |
4805 | 5080 | |
4806 | - if (empty($string)) |
|
4807 | - return $string; |
|
5081 | + if (empty($string)) { |
|
5082 | + return $string; |
|
5083 | + } |
|
4808 | 5084 | |
4809 | 5085 | // UTF-8 occurences of MS special characters |
4810 | 5086 | $findchars_utf8 = array( |
@@ -4845,10 +5121,11 @@ discard block |
||
4845 | 5121 | '--', // — |
4846 | 5122 | ); |
4847 | 5123 | |
4848 | - if ($context['utf8']) |
|
4849 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
4850 | - else |
|
4851 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
5124 | + if ($context['utf8']) { |
|
5125 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5126 | + } else { |
|
5127 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
5128 | + } |
|
4852 | 5129 | |
4853 | 5130 | return $string; |
4854 | 5131 | } |
@@ -4867,49 +5144,59 @@ discard block |
||
4867 | 5144 | { |
4868 | 5145 | global $context; |
4869 | 5146 | |
4870 | - if (!isset($matches[2])) |
|
4871 | - return ''; |
|
5147 | + if (!isset($matches[2])) { |
|
5148 | + return ''; |
|
5149 | + } |
|
4872 | 5150 | |
4873 | 5151 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4874 | 5152 | |
4875 | 5153 | // remove left to right / right to left overrides |
4876 | - if ($num === 0x202D || $num === 0x202E) |
|
4877 | - return ''; |
|
5154 | + if ($num === 0x202D || $num === 0x202E) { |
|
5155 | + return ''; |
|
5156 | + } |
|
4878 | 5157 | |
4879 | 5158 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
4880 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
4881 | - return '&#' . $num . ';'; |
|
5159 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
5160 | + return '&#' . $num . ';'; |
|
5161 | + } |
|
4882 | 5162 | |
4883 | 5163 | if (empty($context['utf8'])) |
4884 | 5164 | { |
4885 | 5165 | // no control characters |
4886 | - if ($num < 0x20) |
|
4887 | - return ''; |
|
5166 | + if ($num < 0x20) { |
|
5167 | + return ''; |
|
5168 | + } |
|
4888 | 5169 | // text is text |
4889 | - elseif ($num < 0x80) |
|
4890 | - return chr($num); |
|
5170 | + elseif ($num < 0x80) { |
|
5171 | + return chr($num); |
|
5172 | + } |
|
4891 | 5173 | // all others get html-ised |
4892 | - else |
|
4893 | - return '&#' . $matches[2] . ';'; |
|
4894 | - } |
|
4895 | - else |
|
5174 | + else { |
|
5175 | + return '&#' . $matches[2] . ';'; |
|
5176 | + } |
|
5177 | + } else |
|
4896 | 5178 | { |
4897 | 5179 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
4898 | 5180 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
4899 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
4900 | - return ''; |
|
5181 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
5182 | + return ''; |
|
5183 | + } |
|
4901 | 5184 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4902 | - elseif ($num < 0x80) |
|
4903 | - return chr($num); |
|
5185 | + elseif ($num < 0x80) { |
|
5186 | + return chr($num); |
|
5187 | + } |
|
4904 | 5188 | // <0x800 (2048) |
4905 | - elseif ($num < 0x800) |
|
4906 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5189 | + elseif ($num < 0x800) { |
|
5190 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5191 | + } |
|
4907 | 5192 | // < 0x10000 (65536) |
4908 | - elseif ($num < 0x10000) |
|
4909 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5193 | + elseif ($num < 0x10000) { |
|
5194 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5195 | + } |
|
4910 | 5196 | // <= 0x10FFFF (1114111) |
4911 | - else |
|
4912 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5197 | + else { |
|
5198 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5199 | + } |
|
4913 | 5200 | } |
4914 | 5201 | } |
4915 | 5202 | |
@@ -4925,28 +5212,34 @@ discard block |
||
4925 | 5212 | */ |
4926 | 5213 | function fixchar__callback($matches) |
4927 | 5214 | { |
4928 | - if (!isset($matches[1])) |
|
4929 | - return ''; |
|
5215 | + if (!isset($matches[1])) { |
|
5216 | + return ''; |
|
5217 | + } |
|
4930 | 5218 | |
4931 | 5219 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
4932 | 5220 | |
4933 | 5221 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
4934 | 5222 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
4935 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
4936 | - return ''; |
|
5223 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
5224 | + return ''; |
|
5225 | + } |
|
4937 | 5226 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4938 | - elseif ($num < 0x80) |
|
4939 | - return chr($num); |
|
5227 | + elseif ($num < 0x80) { |
|
5228 | + return chr($num); |
|
5229 | + } |
|
4940 | 5230 | // <0x800 (2048) |
4941 | - elseif ($num < 0x800) |
|
4942 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5231 | + elseif ($num < 0x800) { |
|
5232 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5233 | + } |
|
4943 | 5234 | // < 0x10000 (65536) |
4944 | - elseif ($num < 0x10000) |
|
4945 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5235 | + elseif ($num < 0x10000) { |
|
5236 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5237 | + } |
|
4946 | 5238 | // <= 0x10FFFF (1114111) |
4947 | - else |
|
4948 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
4949 | -} |
|
5239 | + else { |
|
5240 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5241 | + } |
|
5242 | + } |
|
4950 | 5243 | |
4951 | 5244 | /** |
4952 | 5245 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4959,17 +5252,19 @@ discard block |
||
4959 | 5252 | */ |
4960 | 5253 | function entity_fix__callback($matches) |
4961 | 5254 | { |
4962 | - if (!isset($matches[2])) |
|
4963 | - return ''; |
|
5255 | + if (!isset($matches[2])) { |
|
5256 | + return ''; |
|
5257 | + } |
|
4964 | 5258 | |
4965 | 5259 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4966 | 5260 | |
4967 | 5261 | // we don't allow control characters, characters out of range, byte markers, etc |
4968 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
4969 | - return ''; |
|
4970 | - else |
|
4971 | - return '&#' . $num . ';'; |
|
4972 | -} |
|
5262 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
5263 | + return ''; |
|
5264 | + } else { |
|
5265 | + return '&#' . $num . ';'; |
|
5266 | + } |
|
5267 | + } |
|
4973 | 5268 | |
4974 | 5269 | /** |
4975 | 5270 | * Return a Gravatar URL based on |
@@ -4993,18 +5288,23 @@ discard block |
||
4993 | 5288 | $ratings = array('G', 'PG', 'R', 'X'); |
4994 | 5289 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
4995 | 5290 | $url_params = array(); |
4996 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
4997 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
4998 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
4999 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5000 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
5001 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5002 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
5003 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5291 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
5292 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5293 | + } |
|
5294 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
5295 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5296 | + } |
|
5297 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
5298 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5299 | + } |
|
5300 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
5301 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5004 | 5302 | $size_string = $modSettings['avatar_max_height_external']; |
5303 | + } |
|
5005 | 5304 | |
5006 | - if (!empty($size_string)) |
|
5007 | - $url_params[] = 's=' . $size_string; |
|
5305 | + if (!empty($size_string)) { |
|
5306 | + $url_params[] = 's=' . $size_string; |
|
5307 | + } |
|
5008 | 5308 | } |
5009 | 5309 | $http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www'; |
5010 | 5310 | |
@@ -5023,22 +5323,26 @@ discard block |
||
5023 | 5323 | static $timezones = null, $lastwhen = null; |
5024 | 5324 | |
5025 | 5325 | // No point doing this over if we already did it once |
5026 | - if (!empty($timezones) && $when == $lastwhen) |
|
5027 | - return $timezones; |
|
5028 | - else |
|
5029 | - $lastwhen = $when; |
|
5326 | + if (!empty($timezones) && $when == $lastwhen) { |
|
5327 | + return $timezones; |
|
5328 | + } else { |
|
5329 | + $lastwhen = $when; |
|
5330 | + } |
|
5030 | 5331 | |
5031 | 5332 | // Parseable datetime string? |
5032 | - if (is_int($timestamp = strtotime($when))) |
|
5033 | - $when = $timestamp; |
|
5333 | + if (is_int($timestamp = strtotime($when))) { |
|
5334 | + $when = $timestamp; |
|
5335 | + } |
|
5034 | 5336 | |
5035 | 5337 | // A Unix timestamp? |
5036 | - elseif (is_numeric($when)) |
|
5037 | - $when = intval($when); |
|
5338 | + elseif (is_numeric($when)) { |
|
5339 | + $when = intval($when); |
|
5340 | + } |
|
5038 | 5341 | |
5039 | 5342 | // Invalid value? Just get current Unix timestamp. |
5040 | - else |
|
5041 | - $when = time(); |
|
5343 | + else { |
|
5344 | + $when = time(); |
|
5345 | + } |
|
5042 | 5346 | |
5043 | 5347 | // We'll need these too |
5044 | 5348 | $date_when = date_create('@' . $when); |
@@ -5102,8 +5406,9 @@ discard block |
||
5102 | 5406 | foreach ($priority_countries as $country) |
5103 | 5407 | { |
5104 | 5408 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
5105 | - if (!empty($country_tzids)) |
|
5106 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5409 | + if (!empty($country_tzids)) { |
|
5410 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5411 | + } |
|
5107 | 5412 | } |
5108 | 5413 | |
5109 | 5414 | // Process the preferred timezones first, then the rest. |
@@ -5113,8 +5418,9 @@ discard block |
||
5113 | 5418 | foreach ($tzids as $tzid) |
5114 | 5419 | { |
5115 | 5420 | // We don't want UTC right now |
5116 | - if ($tzid == 'UTC') |
|
5117 | - continue; |
|
5421 | + if ($tzid == 'UTC') { |
|
5422 | + continue; |
|
5423 | + } |
|
5118 | 5424 | |
5119 | 5425 | $tz = timezone_open($tzid); |
5120 | 5426 | |
@@ -5135,8 +5441,9 @@ discard block |
||
5135 | 5441 | } |
5136 | 5442 | |
5137 | 5443 | // A time zone from a prioritized country? |
5138 | - if (in_array($tzid, $priority_tzids)) |
|
5139 | - $priority_zones[$tzkey] = true; |
|
5444 | + if (in_array($tzid, $priority_tzids)) { |
|
5445 | + $priority_zones[$tzkey] = true; |
|
5446 | + } |
|
5140 | 5447 | |
5141 | 5448 | // Keep track of the location and offset for this tzid |
5142 | 5449 | $tzid_parts = explode('/', $tzid); |
@@ -5155,15 +5462,17 @@ discard block |
||
5155 | 5462 | { |
5156 | 5463 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
5157 | 5464 | |
5158 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
5159 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5160 | - else |
|
5161 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5465 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
5466 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5467 | + } else { |
|
5468 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5469 | + } |
|
5162 | 5470 | |
5163 | - if (isset($priority_zones[$tzkey])) |
|
5164 | - $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5165 | - else |
|
5166 | - $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5471 | + if (isset($priority_zones[$tzkey])) { |
|
5472 | + $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5473 | + } else { |
|
5474 | + $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5475 | + } |
|
5167 | 5476 | } |
5168 | 5477 | |
5169 | 5478 | $timezones = array_merge( |
@@ -5217,9 +5526,9 @@ discard block |
||
5217 | 5526 | 'Indian/Kerguelen' => 'TFT', |
5218 | 5527 | ); |
5219 | 5528 | |
5220 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
5221 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5222 | - else |
|
5529 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
5530 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5531 | + } else |
|
5223 | 5532 | { |
5224 | 5533 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
5225 | 5534 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5247,8 +5556,9 @@ discard block |
||
5247 | 5556 | */ |
5248 | 5557 | function inet_ptod($ip_address) |
5249 | 5558 | { |
5250 | - if (!isValidIP($ip_address)) |
|
5251 | - return $ip_address; |
|
5559 | + if (!isValidIP($ip_address)) { |
|
5560 | + return $ip_address; |
|
5561 | + } |
|
5252 | 5562 | |
5253 | 5563 | $bin = inet_pton($ip_address); |
5254 | 5564 | return $bin; |
@@ -5260,13 +5570,15 @@ discard block |
||
5260 | 5570 | */ |
5261 | 5571 | function inet_dtop($bin) |
5262 | 5572 | { |
5263 | - if(empty($bin)) |
|
5264 | - return ''; |
|
5573 | + if(empty($bin)) { |
|
5574 | + return ''; |
|
5575 | + } |
|
5265 | 5576 | |
5266 | 5577 | global $db_type; |
5267 | 5578 | |
5268 | - if ($db_type == 'postgresql') |
|
5269 | - return $bin; |
|
5579 | + if ($db_type == 'postgresql') { |
|
5580 | + return $bin; |
|
5581 | + } |
|
5270 | 5582 | |
5271 | 5583 | $ip_address = inet_ntop($bin); |
5272 | 5584 | |
@@ -5291,26 +5603,32 @@ discard block |
||
5291 | 5603 | */ |
5292 | 5604 | function _safe_serialize($value) |
5293 | 5605 | { |
5294 | - if(is_null($value)) |
|
5295 | - return 'N;'; |
|
5606 | + if(is_null($value)) { |
|
5607 | + return 'N;'; |
|
5608 | + } |
|
5296 | 5609 | |
5297 | - if(is_bool($value)) |
|
5298 | - return 'b:'. (int) $value .';'; |
|
5610 | + if(is_bool($value)) { |
|
5611 | + return 'b:'. (int) $value .';'; |
|
5612 | + } |
|
5299 | 5613 | |
5300 | - if(is_int($value)) |
|
5301 | - return 'i:'. $value .';'; |
|
5614 | + if(is_int($value)) { |
|
5615 | + return 'i:'. $value .';'; |
|
5616 | + } |
|
5302 | 5617 | |
5303 | - if(is_float($value)) |
|
5304 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5618 | + if(is_float($value)) { |
|
5619 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
5620 | + } |
|
5305 | 5621 | |
5306 | - if(is_string($value)) |
|
5307 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5622 | + if(is_string($value)) { |
|
5623 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
5624 | + } |
|
5308 | 5625 | |
5309 | 5626 | if(is_array($value)) |
5310 | 5627 | { |
5311 | 5628 | $out = ''; |
5312 | - foreach($value as $k => $v) |
|
5313 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5629 | + foreach($value as $k => $v) { |
|
5630 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5631 | + } |
|
5314 | 5632 | |
5315 | 5633 | return 'a:'. count($value) .':{'. $out .'}'; |
5316 | 5634 | } |
@@ -5336,8 +5654,9 @@ discard block |
||
5336 | 5654 | |
5337 | 5655 | $out = _safe_serialize($value); |
5338 | 5656 | |
5339 | - if (isset($mbIntEnc)) |
|
5340 | - mb_internal_encoding($mbIntEnc); |
|
5657 | + if (isset($mbIntEnc)) { |
|
5658 | + mb_internal_encoding($mbIntEnc); |
|
5659 | + } |
|
5341 | 5660 | |
5342 | 5661 | return $out; |
5343 | 5662 | } |
@@ -5354,8 +5673,9 @@ discard block |
||
5354 | 5673 | function _safe_unserialize($str) |
5355 | 5674 | { |
5356 | 5675 | // Input is not a string. |
5357 | - if(empty($str) || !is_string($str)) |
|
5358 | - return false; |
|
5676 | + if(empty($str) || !is_string($str)) { |
|
5677 | + return false; |
|
5678 | + } |
|
5359 | 5679 | |
5360 | 5680 | $stack = array(); |
5361 | 5681 | $expected = array(); |
@@ -5371,43 +5691,38 @@ discard block |
||
5371 | 5691 | while($state != 1) |
5372 | 5692 | { |
5373 | 5693 | $type = isset($str[0]) ? $str[0] : ''; |
5374 | - if($type == '}') |
|
5375 | - $str = substr($str, 1); |
|
5376 | - |
|
5377 | - else if($type == 'N' && $str[1] == ';') |
|
5694 | + if($type == '}') { |
|
5695 | + $str = substr($str, 1); |
|
5696 | + } else if($type == 'N' && $str[1] == ';') |
|
5378 | 5697 | { |
5379 | 5698 | $value = null; |
5380 | 5699 | $str = substr($str, 2); |
5381 | - } |
|
5382 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5700 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5383 | 5701 | { |
5384 | 5702 | $value = $matches[1] == '1' ? true : false; |
5385 | 5703 | $str = substr($str, 4); |
5386 | - } |
|
5387 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5704 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5388 | 5705 | { |
5389 | 5706 | $value = (int)$matches[1]; |
5390 | 5707 | $str = $matches[2]; |
5391 | - } |
|
5392 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5708 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5393 | 5709 | { |
5394 | 5710 | $value = (float)$matches[1]; |
5395 | 5711 | $str = $matches[3]; |
5396 | - } |
|
5397 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5712 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5398 | 5713 | { |
5399 | 5714 | $value = substr($matches[2], 0, (int)$matches[1]); |
5400 | 5715 | $str = substr($matches[2], (int)$matches[1] + 2); |
5401 | - } |
|
5402 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5716 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5403 | 5717 | { |
5404 | 5718 | $expectedLength = (int)$matches[1]; |
5405 | 5719 | $str = $matches[2]; |
5406 | 5720 | } |
5407 | 5721 | |
5408 | 5722 | // Object or unknown/malformed type. |
5409 | - else |
|
5410 | - return false; |
|
5723 | + else { |
|
5724 | + return false; |
|
5725 | + } |
|
5411 | 5726 | |
5412 | 5727 | switch($state) |
5413 | 5728 | { |
@@ -5435,8 +5750,9 @@ discard block |
||
5435 | 5750 | if($type == '}') |
5436 | 5751 | { |
5437 | 5752 | // Array size is less than expected. |
5438 | - if(count($list) < end($expected)) |
|
5439 | - return false; |
|
5753 | + if(count($list) < end($expected)) { |
|
5754 | + return false; |
|
5755 | + } |
|
5440 | 5756 | |
5441 | 5757 | unset($list); |
5442 | 5758 | $list = &$stack[count($stack)-1]; |
@@ -5445,8 +5761,9 @@ discard block |
||
5445 | 5761 | // Go to terminal state if we're at the end of the root array. |
5446 | 5762 | array_pop($expected); |
5447 | 5763 | |
5448 | - if(count($expected) == 0) |
|
5449 | - $state = 1; |
|
5764 | + if(count($expected) == 0) { |
|
5765 | + $state = 1; |
|
5766 | + } |
|
5450 | 5767 | |
5451 | 5768 | break; |
5452 | 5769 | } |
@@ -5454,8 +5771,9 @@ discard block |
||
5454 | 5771 | if($type == 'i' || $type == 's') |
5455 | 5772 | { |
5456 | 5773 | // Array size exceeds expected length. |
5457 | - if(count($list) >= end($expected)) |
|
5458 | - return false; |
|
5774 | + if(count($list) >= end($expected)) { |
|
5775 | + return false; |
|
5776 | + } |
|
5459 | 5777 | |
5460 | 5778 | $key = $value; |
5461 | 5779 | $state = 3; |
@@ -5489,8 +5807,9 @@ discard block |
||
5489 | 5807 | } |
5490 | 5808 | |
5491 | 5809 | // Trailing data in input. |
5492 | - if(!empty($str)) |
|
5493 | - return false; |
|
5810 | + if(!empty($str)) { |
|
5811 | + return false; |
|
5812 | + } |
|
5494 | 5813 | |
5495 | 5814 | return $data; |
5496 | 5815 | } |
@@ -5513,8 +5832,9 @@ discard block |
||
5513 | 5832 | |
5514 | 5833 | $out = _safe_unserialize($str); |
5515 | 5834 | |
5516 | - if (isset($mbIntEnc)) |
|
5517 | - mb_internal_encoding($mbIntEnc); |
|
5835 | + if (isset($mbIntEnc)) { |
|
5836 | + mb_internal_encoding($mbIntEnc); |
|
5837 | + } |
|
5518 | 5838 | |
5519 | 5839 | return $out; |
5520 | 5840 | } |
@@ -5529,12 +5849,14 @@ discard block |
||
5529 | 5849 | function smf_chmod($file, $value = 0) |
5530 | 5850 | { |
5531 | 5851 | // No file? no checks! |
5532 | - if (empty($file)) |
|
5533 | - return false; |
|
5852 | + if (empty($file)) { |
|
5853 | + return false; |
|
5854 | + } |
|
5534 | 5855 | |
5535 | 5856 | // Already writable? |
5536 | - if (is_writable($file)) |
|
5537 | - return true; |
|
5857 | + if (is_writable($file)) { |
|
5858 | + return true; |
|
5859 | + } |
|
5538 | 5860 | |
5539 | 5861 | // Do we have a file or a dir? |
5540 | 5862 | $isDir = is_dir($file); |
@@ -5550,10 +5872,9 @@ discard block |
||
5550 | 5872 | { |
5551 | 5873 | $isWritable = true; |
5552 | 5874 | break; |
5875 | + } else { |
|
5876 | + @chmod($file, $val); |
|
5553 | 5877 | } |
5554 | - |
|
5555 | - else |
|
5556 | - @chmod($file, $val); |
|
5557 | 5878 | } |
5558 | 5879 | |
5559 | 5880 | return $isWritable; |
@@ -5572,8 +5893,9 @@ discard block |
||
5572 | 5893 | global $txt; |
5573 | 5894 | |
5574 | 5895 | // Come on... |
5575 | - if (empty($json) || !is_string($json)) |
|
5576 | - return array(); |
|
5896 | + if (empty($json) || !is_string($json)) { |
|
5897 | + return array(); |
|
5898 | + } |
|
5577 | 5899 | |
5578 | 5900 | $returnArray = @json_decode($json, $returnAsArray); |
5579 | 5901 | |
@@ -5611,11 +5933,11 @@ discard block |
||
5611 | 5933 | $jsonDebug = $jsonDebug[0]; |
5612 | 5934 | loadLanguage('Errors'); |
5613 | 5935 | |
5614 | - if (!empty($jsonDebug)) |
|
5615 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5616 | - |
|
5617 | - else |
|
5618 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5936 | + if (!empty($jsonDebug)) { |
|
5937 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5938 | + } else { |
|
5939 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
5940 | + } |
|
5619 | 5941 | |
5620 | 5942 | // Everyone expects an array. |
5621 | 5943 | return array(); |
@@ -5649,8 +5971,9 @@ discard block |
||
5649 | 5971 | global $db_show_debug, $modSettings; |
5650 | 5972 | |
5651 | 5973 | // Defensive programming anyone? |
5652 | - if (empty($data)) |
|
5653 | - return false; |
|
5974 | + if (empty($data)) { |
|
5975 | + return false; |
|
5976 | + } |
|
5654 | 5977 | |
5655 | 5978 | // Don't need extra stuff... |
5656 | 5979 | $db_show_debug = false; |
@@ -5658,11 +5981,11 @@ discard block |
||
5658 | 5981 | // Kill anything else. |
5659 | 5982 | ob_end_clean(); |
5660 | 5983 | |
5661 | - if (!empty($modSettings['CompressedOutput'])) |
|
5662 | - @ob_start('ob_gzhandler'); |
|
5663 | - |
|
5664 | - else |
|
5665 | - ob_start(); |
|
5984 | + if (!empty($modSettings['CompressedOutput'])) { |
|
5985 | + @ob_start('ob_gzhandler'); |
|
5986 | + } else { |
|
5987 | + ob_start(); |
|
5988 | + } |
|
5666 | 5989 | |
5667 | 5990 | // Set the header. |
5668 | 5991 | header($type); |
@@ -5694,8 +6017,9 @@ discard block |
||
5694 | 6017 | static $done = false; |
5695 | 6018 | |
5696 | 6019 | // If we don't need to do anything, don't |
5697 | - if (!$update && $done) |
|
5698 | - return; |
|
6020 | + if (!$update && $done) { |
|
6021 | + return; |
|
6022 | + } |
|
5699 | 6023 | |
5700 | 6024 | // Should we get a new copy of the official list of TLDs? |
5701 | 6025 | if ($update) |
@@ -5704,8 +6028,9 @@ discard block |
||
5704 | 6028 | $tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt'); |
5705 | 6029 | |
5706 | 6030 | // If the Internet Assigned Numbers Authority can't be reached, the Internet is gone. We're probably running on a server hidden in a bunker deep underground to protect it from marauding bandits roaming on the surface. We don't want to waste precious electricity on pointlessly repeating background tasks, so we'll wait until the next regularly scheduled update to see if civilization has been restored. |
5707 | - if ($tlds === false) |
|
5708 | - $postapocalypticNightmare = true; |
|
6031 | + if ($tlds === false) { |
|
6032 | + $postapocalypticNightmare = true; |
|
6033 | + } |
|
5709 | 6034 | } |
5710 | 6035 | // If we aren't updating and the regex is valid, we're done |
5711 | 6036 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -5720,10 +6045,11 @@ discard block |
||
5720 | 6045 | // Clean $tlds and convert it to an array |
5721 | 6046 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
5722 | 6047 | $line = trim($line); |
5723 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
5724 | - return false; |
|
5725 | - else |
|
5726 | - return true; |
|
6048 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
6049 | + return false; |
|
6050 | + } else { |
|
6051 | + return true; |
|
6052 | + } |
|
5727 | 6053 | }); |
5728 | 6054 | |
5729 | 6055 | // Convert Punycode to Unicode |
@@ -5777,8 +6103,9 @@ discard block |
||
5777 | 6103 | $idx += $digit * $w; |
5778 | 6104 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
5779 | 6105 | |
5780 | - if ($digit < $t) |
|
5781 | - break; |
|
6106 | + if ($digit < $t) { |
|
6107 | + break; |
|
6108 | + } |
|
5782 | 6109 | |
5783 | 6110 | $w = (int) ($w * ($base - $t)); |
5784 | 6111 | } |
@@ -5787,8 +6114,9 @@ discard block |
||
5787 | 6114 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
5788 | 6115 | $delta += intval($delta / ($deco_len + 1)); |
5789 | 6116 | |
5790 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
5791 | - $delta = intval($delta / ($base - $tmin)); |
|
6117 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
6118 | + $delta = intval($delta / ($base - $tmin)); |
|
6119 | + } |
|
5792 | 6120 | |
5793 | 6121 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
5794 | 6122 | $is_first = false; |
@@ -5797,8 +6125,9 @@ discard block |
||
5797 | 6125 | |
5798 | 6126 | if ($deco_len > 0) |
5799 | 6127 | { |
5800 | - for ($i = $deco_len; $i > $idx; $i--) |
|
5801 | - $decoded[$i] = $decoded[($i - 1)]; |
|
6128 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
6129 | + $decoded[$i] = $decoded[($i - 1)]; |
|
6130 | + } |
|
5802 | 6131 | } |
5803 | 6132 | $decoded[$idx++] = $char; |
5804 | 6133 | } |
@@ -5806,24 +6135,29 @@ discard block |
||
5806 | 6135 | foreach ($decoded as $k => $v) |
5807 | 6136 | { |
5808 | 6137 | // 7bit are transferred literally |
5809 | - if ($v < 128) |
|
5810 | - $output .= chr($v); |
|
6138 | + if ($v < 128) { |
|
6139 | + $output .= chr($v); |
|
6140 | + } |
|
5811 | 6141 | |
5812 | 6142 | // 2 bytes |
5813 | - elseif ($v < (1 << 11)) |
|
5814 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6143 | + elseif ($v < (1 << 11)) { |
|
6144 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6145 | + } |
|
5815 | 6146 | |
5816 | 6147 | // 3 bytes |
5817 | - elseif ($v < (1 << 16)) |
|
5818 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6148 | + elseif ($v < (1 << 16)) { |
|
6149 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6150 | + } |
|
5819 | 6151 | |
5820 | 6152 | // 4 bytes |
5821 | - elseif ($v < (1 << 21)) |
|
5822 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6153 | + elseif ($v < (1 << 21)) { |
|
6154 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6155 | + } |
|
5823 | 6156 | |
5824 | 6157 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5825 | - else |
|
5826 | - $output .= $safe_char; |
|
6158 | + else { |
|
6159 | + $output .= $safe_char; |
|
6160 | + } |
|
5827 | 6161 | } |
5828 | 6162 | |
5829 | 6163 | $output_parts[] = $output; |
@@ -5916,8 +6250,7 @@ discard block |
||
5916 | 6250 | |
5917 | 6251 | $strlen = 'mb_strlen'; |
5918 | 6252 | $substr = 'mb_substr'; |
5919 | - } |
|
5920 | - else |
|
6253 | + } else |
|
5921 | 6254 | { |
5922 | 6255 | $strlen = $smcFunc['strlen']; |
5923 | 6256 | $substr = $smcFunc['substr']; |
@@ -5931,20 +6264,21 @@ discard block |
||
5931 | 6264 | |
5932 | 6265 | $first = $substr($string, 0, 1); |
5933 | 6266 | |
5934 | - if (empty($index[$first])) |
|
5935 | - $index[$first] = array(); |
|
6267 | + if (empty($index[$first])) { |
|
6268 | + $index[$first] = array(); |
|
6269 | + } |
|
5936 | 6270 | |
5937 | 6271 | if ($strlen($string) > 1) |
5938 | 6272 | { |
5939 | 6273 | // Sanity check on recursion |
5940 | - if ($depth > 99) |
|
5941 | - $index[$first][$substr($string, 1)] = ''; |
|
5942 | - |
|
5943 | - else |
|
5944 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6274 | + if ($depth > 99) { |
|
6275 | + $index[$first][$substr($string, 1)] = ''; |
|
6276 | + } else { |
|
6277 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6278 | + } |
|
6279 | + } else { |
|
6280 | + $index[$first][''] = ''; |
|
5945 | 6281 | } |
5946 | - else |
|
5947 | - $index[$first][''] = ''; |
|
5948 | 6282 | |
5949 | 6283 | $depth--; |
5950 | 6284 | return $index; |
@@ -5967,9 +6301,9 @@ discard block |
||
5967 | 6301 | $key_regex = preg_quote($key, $delim); |
5968 | 6302 | $new_key = $key; |
5969 | 6303 | |
5970 | - if (empty($value)) |
|
5971 | - $sub_regex = ''; |
|
5972 | - else |
|
6304 | + if (empty($value)) { |
|
6305 | + $sub_regex = ''; |
|
6306 | + } else |
|
5973 | 6307 | { |
5974 | 6308 | $sub_regex = $index_to_regex($value, $delim); |
5975 | 6309 | |
@@ -5977,22 +6311,22 @@ discard block |
||
5977 | 6311 | { |
5978 | 6312 | $new_key_array = explode('(?'.'>', $sub_regex); |
5979 | 6313 | $new_key .= $new_key_array[0]; |
6314 | + } else { |
|
6315 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5980 | 6316 | } |
5981 | - else |
|
5982 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5983 | 6317 | } |
5984 | 6318 | |
5985 | - if ($depth > 1) |
|
5986 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
5987 | - else |
|
6319 | + if ($depth > 1) { |
|
6320 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
6321 | + } else |
|
5988 | 6322 | { |
5989 | 6323 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
5990 | 6324 | { |
5991 | 6325 | $regex[$new_key] = $key_regex . $sub_regex; |
5992 | 6326 | unset($index[$key]); |
6327 | + } else { |
|
6328 | + break; |
|
5993 | 6329 | } |
5994 | - else |
|
5995 | - break; |
|
5996 | 6330 | } |
5997 | 6331 | } |
5998 | 6332 | |
@@ -6001,10 +6335,11 @@ discard block |
||
6001 | 6335 | $l1 = $strlen($k1); |
6002 | 6336 | $l2 = $strlen($k2); |
6003 | 6337 | |
6004 | - if ($l1 == $l2) |
|
6005 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6006 | - else |
|
6007 | - return $l1 > $l2 ? -1 : 1; |
|
6338 | + if ($l1 == $l2) { |
|
6339 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6340 | + } else { |
|
6341 | + return $l1 > $l2 ? -1 : 1; |
|
6342 | + } |
|
6008 | 6343 | }); |
6009 | 6344 | |
6010 | 6345 | $depth--; |
@@ -6015,21 +6350,24 @@ discard block |
||
6015 | 6350 | $index = array(); |
6016 | 6351 | $regex = ''; |
6017 | 6352 | |
6018 | - foreach ($strings as $string) |
|
6019 | - $index = $add_string_to_index($string, $index); |
|
6353 | + foreach ($strings as $string) { |
|
6354 | + $index = $add_string_to_index($string, $index); |
|
6355 | + } |
|
6020 | 6356 | |
6021 | 6357 | if ($returnArray === true) |
6022 | 6358 | { |
6023 | 6359 | $regex = array(); |
6024 | - while (!empty($index)) |
|
6025 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6360 | + while (!empty($index)) { |
|
6361 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6362 | + } |
|
6363 | + } else { |
|
6364 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6026 | 6365 | } |
6027 | - else |
|
6028 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6029 | 6366 | |
6030 | 6367 | // Restore PHP's internal character encoding to whatever it was originally |
6031 | - if (!empty($current_encoding)) |
|
6032 | - mb_internal_encoding($current_encoding); |
|
6368 | + if (!empty($current_encoding)) { |
|
6369 | + mb_internal_encoding($current_encoding); |
|
6370 | + } |
|
6033 | 6371 | |
6034 | 6372 | return $regex; |
6035 | 6373 | } |
@@ -6072,13 +6410,15 @@ discard block |
||
6072 | 6410 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
6073 | 6411 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
6074 | 6412 | $headers = @get_headers($url); |
6075 | - if ($headers === false) |
|
6076 | - return false; |
|
6413 | + if ($headers === false) { |
|
6414 | + return false; |
|
6415 | + } |
|
6077 | 6416 | |
6078 | 6417 | // Now to see if it came back https... |
6079 | 6418 | // First check for a redirect status code in first row (301, 302, 307) |
6080 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
6081 | - return false; |
|
6419 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
6420 | + return false; |
|
6421 | + } |
|
6082 | 6422 | |
6083 | 6423 | // Search for the location entry to confirm https |
6084 | 6424 | $result = false; |
@@ -6114,8 +6454,7 @@ discard block |
||
6114 | 6454 | $is_admin = $user_info['is_admin']; |
6115 | 6455 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
6116 | 6456 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
6117 | - } |
|
6118 | - else |
|
6457 | + } else |
|
6119 | 6458 | { |
6120 | 6459 | $request = $smcFunc['db_query']('', ' |
6121 | 6460 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6129,17 +6468,19 @@ discard block |
||
6129 | 6468 | |
6130 | 6469 | $row = $smcFunc['db_fetch_assoc']($request); |
6131 | 6470 | |
6132 | - if (empty($row['additional_groups'])) |
|
6133 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
6134 | - else |
|
6135 | - $groups = array_merge( |
|
6471 | + if (empty($row['additional_groups'])) { |
|
6472 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
6473 | + } else { |
|
6474 | + $groups = array_merge( |
|
6136 | 6475 | array($row['id_group'], $row['id_post_group']), |
6137 | 6476 | explode(',', $row['additional_groups']) |
6138 | 6477 | ); |
6478 | + } |
|
6139 | 6479 | |
6140 | 6480 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
6141 | - foreach ($groups as $k => $v) |
|
6142 | - $groups[$k] = (int) $v; |
|
6481 | + foreach ($groups as $k => $v) { |
|
6482 | + $groups[$k] = (int) $v; |
|
6483 | + } |
|
6143 | 6484 | |
6144 | 6485 | $is_admin = in_array(1, $groups); |
6145 | 6486 | |
@@ -6156,8 +6497,9 @@ discard block |
||
6156 | 6497 | 'current_member' => $userid, |
6157 | 6498 | ) |
6158 | 6499 | ); |
6159 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6160 | - $boards_mod[] = $row['id_board']; |
|
6500 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6501 | + $boards_mod[] = $row['id_board']; |
|
6502 | + } |
|
6161 | 6503 | $smcFunc['db_free_result']($request); |
6162 | 6504 | |
6163 | 6505 | // Can any of the groups they're in moderate any of the boards? |
@@ -6169,8 +6511,9 @@ discard block |
||
6169 | 6511 | 'groups' => $groups, |
6170 | 6512 | ) |
6171 | 6513 | ); |
6172 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6173 | - $boards_mod[] = $row['id_board']; |
|
6514 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6515 | + $boards_mod[] = $row['id_board']; |
|
6516 | + } |
|
6174 | 6517 | $smcFunc['db_free_result']($request); |
6175 | 6518 | |
6176 | 6519 | // Just in case we've got duplicates here... |
@@ -6180,21 +6523,25 @@ discard block |
||
6180 | 6523 | } |
6181 | 6524 | |
6182 | 6525 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
6183 | - if ($is_admin) |
|
6184 | - $query_part['query_see_board'] = '1=1'; |
|
6526 | + if ($is_admin) { |
|
6527 | + $query_part['query_see_board'] = '1=1'; |
|
6528 | + } |
|
6185 | 6529 | // Otherwise just the groups in $user_info['groups']. |
6186 | - else |
|
6187 | - $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
6530 | + else { |
|
6531 | + $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
6532 | + } |
|
6188 | 6533 | |
6189 | 6534 | // Build the list of boards they WANT to see. |
6190 | 6535 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
6191 | 6536 | |
6192 | 6537 | // If they aren't ignoring any boards then they want to see all the boards they can see |
6193 | - if (empty($ignoreboards)) |
|
6194 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6538 | + if (empty($ignoreboards)) { |
|
6539 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6540 | + } |
|
6195 | 6541 | // Ok I guess they don't want to see all the boards |
6196 | - else |
|
6197 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6542 | + else { |
|
6543 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6544 | + } |
|
6198 | 6545 | |
6199 | 6546 | return $query_part; |
6200 | 6547 | } |
@@ -6208,10 +6555,11 @@ discard block |
||
6208 | 6555 | { |
6209 | 6556 | $secure = false; |
6210 | 6557 | |
6211 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
6212 | - $secure = true; |
|
6213 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
6214 | - $secure = true; |
|
6558 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
6559 | + $secure = true; |
|
6560 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
6561 | + $secure = true; |
|
6562 | + } |
|
6215 | 6563 | |
6216 | 6564 | return $secure; |
6217 | 6565 | } |