@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | { |
| 392 | 392 | $val = 'CASE '; |
| 393 | 393 | foreach ($members as $k => $v) |
| 394 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 394 | + $val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 395 | 395 | $val = $val . ' END'; |
| 396 | 396 | $type = 'raw'; |
| 397 | 397 | } |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | static $non_twelve_hour, $locale_cache, $now; |
| 745 | 745 | static $unsupportedFormats, $finalizedFormats; |
| 746 | 746 | |
| 747 | - $unsupportedFormatsWindows = array('z','Z'); |
|
| 747 | + $unsupportedFormatsWindows = array('z', 'Z'); |
|
| 748 | 748 | |
| 749 | 749 | // Ensure required values are set |
| 750 | 750 | $user_info['time_offset'] = !empty($user_info['time_offset']) ? $user_info['time_offset'] : 0; |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
| 827 | 827 | if (empty($unsupportedFormats)) |
| 828 | 828 | { |
| 829 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
| 829 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
| 830 | 830 | { |
| 831 | 831 | // Avoid a crashing bug with PHP 7 on certain versions of Windows |
| 832 | 832 | if ($context['server']['is_windows'] && in_array($format, $unsupportedFormatsWindows)) |
@@ -1206,7 +1206,7 @@ discard block |
||
| 1206 | 1206 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
| 1207 | 1207 | ), |
| 1208 | 1208 | 'content' => '$1', |
| 1209 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1209 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1210 | 1210 | { |
| 1211 | 1211 | $returnContext = ''; |
| 1212 | 1212 | |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
| 1244 | - $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>'; |
|
| 1244 | + $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>'; |
|
| 1245 | 1245 | else |
| 1246 | 1246 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
| 1247 | 1247 | } |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | 'type' => 'unparsed_content', |
| 1294 | 1294 | '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>', |
| 1295 | 1295 | // @todo Maybe this can be simplified? |
| 1296 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1296 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1297 | 1297 | { |
| 1298 | 1298 | if (!isset($disabled['code'])) |
| 1299 | 1299 | { |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | 'type' => 'unparsed_equals_content', |
| 1331 | 1331 | '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>', |
| 1332 | 1332 | // @todo Maybe this can be simplified? |
| 1333 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1333 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1334 | 1334 | { |
| 1335 | 1335 | if (!isset($disabled['code'])) |
| 1336 | 1336 | { |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | 'type' => 'unparsed_content', |
| 1375 | 1375 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
| 1376 | 1376 | // @todo Should this respect guest_hideContacts? |
| 1377 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1377 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1378 | 1378 | { |
| 1379 | 1379 | $data = strtr($data, array('<br>' => '')); |
| 1380 | 1380 | }, |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
| 1395 | 1395 | 'before' => '<div $1>', |
| 1396 | 1396 | 'after' => '</div>', |
| 1397 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1397 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1398 | 1398 | { |
| 1399 | 1399 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1400 | 1400 | |
@@ -1480,7 +1480,7 @@ discard block |
||
| 1480 | 1480 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
| 1481 | 1481 | ), |
| 1482 | 1482 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
| 1483 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1483 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1484 | 1484 | { |
| 1485 | 1485 | global $image_proxy_enabled, $user_info; |
| 1486 | 1486 | |
@@ -1506,7 +1506,7 @@ discard block |
||
| 1506 | 1506 | 'tag' => 'img', |
| 1507 | 1507 | 'type' => 'unparsed_content', |
| 1508 | 1508 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
| 1509 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1509 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1510 | 1510 | { |
| 1511 | 1511 | global $image_proxy_enabled, $user_info; |
| 1512 | 1512 | |
@@ -1532,7 +1532,7 @@ discard block |
||
| 1532 | 1532 | 'tag' => 'iurl', |
| 1533 | 1533 | 'type' => 'unparsed_content', |
| 1534 | 1534 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
| 1535 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1535 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1536 | 1536 | { |
| 1537 | 1537 | $data = strtr($data, array('<br>' => '')); |
| 1538 | 1538 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1546,7 +1546,7 @@ discard block |
||
| 1546 | 1546 | 'quoted' => 'optional', |
| 1547 | 1547 | 'before' => '<a href="$1" class="bbc_link">', |
| 1548 | 1548 | 'after' => '</a>', |
| 1549 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1549 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1550 | 1550 | { |
| 1551 | 1551 | if (substr($data, 0, 1) == '#') |
| 1552 | 1552 | $data = '#post_' . substr($data, 1); |
@@ -1639,7 +1639,7 @@ discard block |
||
| 1639 | 1639 | 'tag' => 'php', |
| 1640 | 1640 | 'type' => 'unparsed_content', |
| 1641 | 1641 | 'content' => '<span class="phpcode">$1</span>', |
| 1642 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
| 1642 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
| 1643 | 1643 | { |
| 1644 | 1644 | if (!isset($disabled['php'])) |
| 1645 | 1645 | { |
@@ -1767,7 +1767,7 @@ discard block |
||
| 1767 | 1767 | 'test' => '[1-7]\]', |
| 1768 | 1768 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
| 1769 | 1769 | 'after' => '</span>', |
| 1770 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1770 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1771 | 1771 | { |
| 1772 | 1772 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
| 1773 | 1773 | $data = $sizes[$data] . 'em'; |
@@ -1805,7 +1805,7 @@ discard block |
||
| 1805 | 1805 | 'tag' => 'time', |
| 1806 | 1806 | 'type' => 'unparsed_content', |
| 1807 | 1807 | 'content' => '$1', |
| 1808 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1808 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1809 | 1809 | { |
| 1810 | 1810 | if (is_numeric($data)) |
| 1811 | 1811 | $data = timeformat($data); |
@@ -1838,7 +1838,7 @@ discard block |
||
| 1838 | 1838 | 'tag' => 'url', |
| 1839 | 1839 | 'type' => 'unparsed_content', |
| 1840 | 1840 | 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', |
| 1841 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1841 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1842 | 1842 | { |
| 1843 | 1843 | $data = strtr($data, array('<br>' => '')); |
| 1844 | 1844 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1852,7 +1852,7 @@ discard block |
||
| 1852 | 1852 | 'quoted' => 'optional', |
| 1853 | 1853 | 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', |
| 1854 | 1854 | 'after' => '</a>', |
| 1855 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1855 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1856 | 1856 | { |
| 1857 | 1857 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1858 | 1858 | if (empty($scheme)) |
@@ -1898,7 +1898,7 @@ discard block |
||
| 1898 | 1898 | { |
| 1899 | 1899 | if (isset($temp_bbc)) |
| 1900 | 1900 | $bbc_codes = $temp_bbc; |
| 1901 | - usort($codes, function ($a, $b) { |
|
| 1901 | + usort($codes, function($a, $b) { |
|
| 1902 | 1902 | return strcmp($a['tag'], $b['tag']); |
| 1903 | 1903 | }); |
| 1904 | 1904 | return $codes; |
@@ -2114,7 +2114,7 @@ discard block |
||
| 2114 | 2114 | # a run of Unicode domain name characters and a dot |
| 2115 | 2115 | [\p{L}\p{M}\p{N}\-.:@]+\. |
| 2116 | 2116 | # and then a TLD valid in the DNS or the reserved "local" TLD |
| 2117 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
| 2117 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
| 2118 | 2118 | ) |
| 2119 | 2119 | # followed by a non-domain character or end of line |
| 2120 | 2120 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2182,7 +2182,7 @@ discard block |
||
| 2182 | 2182 | )? |
| 2183 | 2183 | '; |
| 2184 | 2184 | |
| 2185 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
| 2185 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
| 2186 | 2186 | $url = array_shift($matches); |
| 2187 | 2187 | |
| 2188 | 2188 | // If this isn't a clean URL, bail out |
@@ -2207,7 +2207,7 @@ discard block |
||
| 2207 | 2207 | $fullUrl = $url; |
| 2208 | 2208 | |
| 2209 | 2209 | // Make sure that $fullUrl really is valid |
| 2210 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
| 2210 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '') . $fullUrl) === false) |
|
| 2211 | 2211 | return $url; |
| 2212 | 2212 | |
| 2213 | 2213 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
@@ -2271,7 +2271,7 @@ discard block |
||
| 2271 | 2271 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2272 | 2272 | |
| 2273 | 2273 | // A closing tag that doesn't match any open tags? Skip it. |
| 2274 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
| 2274 | + if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags))) |
|
| 2275 | 2275 | continue; |
| 2276 | 2276 | |
| 2277 | 2277 | $to_close = array(); |
@@ -2929,7 +2929,7 @@ discard block |
||
| 2929 | 2929 | } |
| 2930 | 2930 | |
| 2931 | 2931 | // Set proper extensions; do this post caching so cache doesn't become extension-specific |
| 2932 | - foreach($smileysto AS $ix=>$file) |
|
| 2932 | + foreach ($smileysto AS $ix=>$file) |
|
| 2933 | 2933 | // Need to use the default if user selection is disabled |
| 2934 | 2934 | if (empty($modSettings['smiley_sets_enable'])) |
| 2935 | 2935 | $smileysto[$ix] = $file . $context['user']['smiley_set_default_ext']; |
@@ -2947,7 +2947,7 @@ discard block |
||
| 2947 | 2947 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
| 2948 | 2948 | { |
| 2949 | 2949 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
| 2950 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2950 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2951 | 2951 | |
| 2952 | 2952 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
| 2953 | 2953 | |
@@ -2972,7 +2972,7 @@ discard block |
||
| 2972 | 2972 | |
| 2973 | 2973 | // Replace away! |
| 2974 | 2974 | $message = preg_replace_callback($smileyPregSearch, |
| 2975 | - function ($matches) use ($smileyPregReplacements) |
|
| 2975 | + function($matches) use ($smileyPregReplacements) |
|
| 2976 | 2976 | { |
| 2977 | 2977 | return $smileyPregReplacements[$matches[1]]; |
| 2978 | 2978 | }, $message); |
@@ -3069,13 +3069,13 @@ discard block |
||
| 3069 | 3069 | { |
| 3070 | 3070 | if (defined('SID') && SID != '') |
| 3071 | 3071 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
| 3072 | - function ($m) use ($scripturl) |
|
| 3072 | + function($m) use ($scripturl) |
|
| 3073 | 3073 | { |
| 3074 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
| 3074 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
| 3075 | 3075 | }, $setLocation); |
| 3076 | 3076 | else |
| 3077 | 3077 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
| 3078 | - function ($m) use ($scripturl) |
|
| 3078 | + function($m) use ($scripturl) |
|
| 3079 | 3079 | { |
| 3080 | 3080 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 3081 | 3081 | }, $setLocation); |
@@ -3396,7 +3396,7 @@ discard block |
||
| 3396 | 3396 | |
| 3397 | 3397 | // Add a generic "Are you sure?" confirmation message. |
| 3398 | 3398 | addInlineJavaScript(' |
| 3399 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
| 3399 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
| 3400 | 3400 | |
| 3401 | 3401 | // Now add the capping code for avatars. |
| 3402 | 3402 | 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') |
@@ -3862,7 +3862,7 @@ discard block |
||
| 3862 | 3862 | if (!empty($normal)) |
| 3863 | 3863 | foreach ($normal as $nf) |
| 3864 | 3864 | echo ' |
| 3865 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
| 3865 | + <link rel="stylesheet" href="', $nf, '">'; |
|
| 3866 | 3866 | |
| 3867 | 3867 | if ($db_show_debug === true) |
| 3868 | 3868 | { |
@@ -3878,7 +3878,7 @@ discard block |
||
| 3878 | 3878 | <style>'; |
| 3879 | 3879 | |
| 3880 | 3880 | foreach ($context['css_header'] as $css) |
| 3881 | - echo $css .' |
|
| 3881 | + echo $css . ' |
|
| 3882 | 3882 | '; |
| 3883 | 3883 | |
| 3884 | 3884 | echo' |
@@ -3922,7 +3922,7 @@ discard block |
||
| 3922 | 3922 | |
| 3923 | 3923 | |
| 3924 | 3924 | // No namespaces, sorry! |
| 3925 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
| 3925 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
| 3926 | 3926 | |
| 3927 | 3927 | // Temp path. |
| 3928 | 3928 | $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
@@ -4102,7 +4102,7 @@ discard block |
||
| 4102 | 4102 | else |
| 4103 | 4103 | $path = $modSettings['attachmentUploadDir']; |
| 4104 | 4104 | |
| 4105 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
| 4105 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
| 4106 | 4106 | } |
| 4107 | 4107 | |
| 4108 | 4108 | /** |
@@ -4146,10 +4146,10 @@ discard block |
||
| 4146 | 4146 | $valid_low = isValidIP($ip_parts[0]); |
| 4147 | 4147 | $valid_high = isValidIP($ip_parts[1]); |
| 4148 | 4148 | $count = 0; |
| 4149 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
| 4149 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
| 4150 | 4150 | $max = ($mode == ':' ? 'ffff' : '255'); |
| 4151 | 4151 | $min = 0; |
| 4152 | - if(!$valid_low) |
|
| 4152 | + if (!$valid_low) |
|
| 4153 | 4153 | { |
| 4154 | 4154 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
| 4155 | 4155 | $valid_low = isValidIP($ip_parts[0]); |
@@ -4163,7 +4163,7 @@ discard block |
||
| 4163 | 4163 | } |
| 4164 | 4164 | |
| 4165 | 4165 | $count = 0; |
| 4166 | - if(!$valid_high) |
|
| 4166 | + if (!$valid_high) |
|
| 4167 | 4167 | { |
| 4168 | 4168 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
| 4169 | 4169 | $valid_high = isValidIP($ip_parts[1]); |
@@ -4176,7 +4176,7 @@ discard block |
||
| 4176 | 4176 | } |
| 4177 | 4177 | } |
| 4178 | 4178 | |
| 4179 | - if($valid_high && $valid_low) |
|
| 4179 | + if ($valid_high && $valid_low) |
|
| 4180 | 4180 | { |
| 4181 | 4181 | $ip_array['low'] = $ip_parts[0]; |
| 4182 | 4182 | $ip_array['high'] = $ip_parts[1]; |
@@ -4357,7 +4357,7 @@ discard block |
||
| 4357 | 4357 | addInlineJavaScript(' |
| 4358 | 4358 | var user_menus = new smc_PopupMenu(); |
| 4359 | 4359 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4360 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
| 4360 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
| 4361 | 4361 | if ($context['allow_pm']) |
| 4362 | 4362 | addInlineJavaScript(' |
| 4363 | 4363 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4652,7 +4652,7 @@ discard block |
||
| 4652 | 4652 | $context['total_admin_reports'] += $context['unapproved_members']; |
| 4653 | 4653 | } |
| 4654 | 4654 | |
| 4655 | - if($context['total_admin_reports'] > 0 && !empty($context['menu_buttons']['admin'])) |
|
| 4655 | + if ($context['total_admin_reports'] > 0 && !empty($context['menu_buttons']['admin'])) |
|
| 4656 | 4656 | { |
| 4657 | 4657 | $context['menu_buttons']['admin']['amt'] = $context['total_admin_reports']; |
| 4658 | 4658 | } |
@@ -4999,7 +4999,7 @@ discard block |
||
| 4999 | 4999 | // No? try a fallback to $sourcedir |
| 5000 | 5000 | else |
| 5001 | 5001 | { |
| 5002 | - $absPath = $sourcedir .'/'. $file; |
|
| 5002 | + $absPath = $sourcedir . '/' . $file; |
|
| 5003 | 5003 | |
| 5004 | 5004 | if (file_exists($absPath)) |
| 5005 | 5005 | require_once($absPath); |
@@ -5266,15 +5266,15 @@ discard block |
||
| 5266 | 5266 | |
| 5267 | 5267 | // UTF-8 occurences of MS special characters |
| 5268 | 5268 | $findchars_utf8 = array( |
| 5269 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 5270 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 5271 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
| 5272 | - "\xe2\x80\x98", // left single curly quote |
|
| 5273 | - "\xe2\x80\x99", // right single curly quote |
|
| 5274 | - "\xe2\x80\x9c", // left double curly quote |
|
| 5275 | - "\xe2\x80\x9d", // right double curly quote |
|
| 5276 | - "\xe2\x80\x93", // en dash |
|
| 5277 | - "\xe2\x80\x94", // em dash |
|
| 5269 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 5270 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 5271 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
| 5272 | + "\xe2\x80\x98", // left single curly quote |
|
| 5273 | + "\xe2\x80\x99", // right single curly quote |
|
| 5274 | + "\xe2\x80\x9c", // left double curly quote |
|
| 5275 | + "\xe2\x80\x9d", // right double curly quote |
|
| 5276 | + "\xe2\x80\x93", // en dash |
|
| 5277 | + "\xe2\x80\x94", // em dash |
|
| 5278 | 5278 | ); |
| 5279 | 5279 | |
| 5280 | 5280 | // windows 1252 / iso equivalents |
@@ -5292,15 +5292,15 @@ discard block |
||
| 5292 | 5292 | |
| 5293 | 5293 | // safe replacements |
| 5294 | 5294 | $replacechars = array( |
| 5295 | - ',', // ‚ |
|
| 5296 | - ',,', // „ |
|
| 5297 | - '...', // … |
|
| 5298 | - "'", // ‘ |
|
| 5299 | - "'", // ’ |
|
| 5300 | - '"', // “ |
|
| 5301 | - '"', // ” |
|
| 5302 | - '-', // – |
|
| 5303 | - '--', // — |
|
| 5295 | + ',', // ‚ |
|
| 5296 | + ',,', // „ |
|
| 5297 | + '...', // … |
|
| 5298 | + "'", // ‘ |
|
| 5299 | + "'", // ’ |
|
| 5300 | + '"', // “ |
|
| 5301 | + '"', // ” |
|
| 5302 | + '-', // – |
|
| 5303 | + '--', // — |
|
| 5304 | 5304 | ); |
| 5305 | 5305 | |
| 5306 | 5306 | if ($context['utf8']) |
@@ -5620,7 +5620,7 @@ discard block |
||
| 5620 | 5620 | */ |
| 5621 | 5621 | function inet_dtop($bin) |
| 5622 | 5622 | { |
| 5623 | - if(empty($bin)) |
|
| 5623 | + if (empty($bin)) |
|
| 5624 | 5624 | return ''; |
| 5625 | 5625 | |
| 5626 | 5626 | global $db_type; |
@@ -5651,28 +5651,28 @@ discard block |
||
| 5651 | 5651 | */ |
| 5652 | 5652 | function _safe_serialize($value) |
| 5653 | 5653 | { |
| 5654 | - if(is_null($value)) |
|
| 5654 | + if (is_null($value)) |
|
| 5655 | 5655 | return 'N;'; |
| 5656 | 5656 | |
| 5657 | - if(is_bool($value)) |
|
| 5658 | - return 'b:'. (int) $value .';'; |
|
| 5657 | + if (is_bool($value)) |
|
| 5658 | + return 'b:' . (int) $value . ';'; |
|
| 5659 | 5659 | |
| 5660 | - if(is_int($value)) |
|
| 5661 | - return 'i:'. $value .';'; |
|
| 5660 | + if (is_int($value)) |
|
| 5661 | + return 'i:' . $value . ';'; |
|
| 5662 | 5662 | |
| 5663 | - if(is_float($value)) |
|
| 5664 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5663 | + if (is_float($value)) |
|
| 5664 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
| 5665 | 5665 | |
| 5666 | - if(is_string($value)) |
|
| 5667 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5666 | + if (is_string($value)) |
|
| 5667 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
| 5668 | 5668 | |
| 5669 | - if(is_array($value)) |
|
| 5669 | + if (is_array($value)) |
|
| 5670 | 5670 | { |
| 5671 | 5671 | $out = ''; |
| 5672 | - foreach($value as $k => $v) |
|
| 5672 | + foreach ($value as $k => $v) |
|
| 5673 | 5673 | $out .= _safe_serialize($k) . _safe_serialize($v); |
| 5674 | 5674 | |
| 5675 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
| 5675 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
| 5676 | 5676 | } |
| 5677 | 5677 | |
| 5678 | 5678 | // safe_serialize cannot serialize resources or objects. |
@@ -5714,7 +5714,7 @@ discard block |
||
| 5714 | 5714 | function _safe_unserialize($str) |
| 5715 | 5715 | { |
| 5716 | 5716 | // Input is not a string. |
| 5717 | - if(empty($str) || !is_string($str)) |
|
| 5717 | + if (empty($str) || !is_string($str)) |
|
| 5718 | 5718 | return false; |
| 5719 | 5719 | |
| 5720 | 5720 | $stack = array(); |
@@ -5728,40 +5728,40 @@ discard block |
||
| 5728 | 5728 | * 3 - in array, expecting value or another array |
| 5729 | 5729 | */ |
| 5730 | 5730 | $state = 0; |
| 5731 | - while($state != 1) |
|
| 5731 | + while ($state != 1) |
|
| 5732 | 5732 | { |
| 5733 | 5733 | $type = isset($str[0]) ? $str[0] : ''; |
| 5734 | - if($type == '}') |
|
| 5734 | + if ($type == '}') |
|
| 5735 | 5735 | $str = substr($str, 1); |
| 5736 | 5736 | |
| 5737 | - else if($type == 'N' && $str[1] == ';') |
|
| 5737 | + else if ($type == 'N' && $str[1] == ';') |
|
| 5738 | 5738 | { |
| 5739 | 5739 | $value = null; |
| 5740 | 5740 | $str = substr($str, 2); |
| 5741 | 5741 | } |
| 5742 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5742 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5743 | 5743 | { |
| 5744 | 5744 | $value = $matches[1] == '1' ? true : false; |
| 5745 | 5745 | $str = substr($str, 4); |
| 5746 | 5746 | } |
| 5747 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5747 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5748 | 5748 | { |
| 5749 | - $value = (int)$matches[1]; |
|
| 5749 | + $value = (int) $matches[1]; |
|
| 5750 | 5750 | $str = $matches[2]; |
| 5751 | 5751 | } |
| 5752 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5752 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5753 | 5753 | { |
| 5754 | - $value = (float)$matches[1]; |
|
| 5754 | + $value = (float) $matches[1]; |
|
| 5755 | 5755 | $str = $matches[3]; |
| 5756 | 5756 | } |
| 5757 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5757 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
| 5758 | 5758 | { |
| 5759 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
| 5760 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
| 5759 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
| 5760 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
| 5761 | 5761 | } |
| 5762 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5762 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5763 | 5763 | { |
| 5764 | - $expectedLength = (int)$matches[1]; |
|
| 5764 | + $expectedLength = (int) $matches[1]; |
|
| 5765 | 5765 | $str = $matches[2]; |
| 5766 | 5766 | } |
| 5767 | 5767 | |
@@ -5769,10 +5769,10 @@ discard block |
||
| 5769 | 5769 | else |
| 5770 | 5770 | return false; |
| 5771 | 5771 | |
| 5772 | - switch($state) |
|
| 5772 | + switch ($state) |
|
| 5773 | 5773 | { |
| 5774 | 5774 | case 3: // In array, expecting value or another array. |
| 5775 | - if($type == 'a') |
|
| 5775 | + if ($type == 'a') |
|
| 5776 | 5776 | { |
| 5777 | 5777 | $stack[] = &$list; |
| 5778 | 5778 | $list[$key] = array(); |
@@ -5781,7 +5781,7 @@ discard block |
||
| 5781 | 5781 | $state = 2; |
| 5782 | 5782 | break; |
| 5783 | 5783 | } |
| 5784 | - if($type != '}') |
|
| 5784 | + if ($type != '}') |
|
| 5785 | 5785 | { |
| 5786 | 5786 | $list[$key] = $value; |
| 5787 | 5787 | $state = 2; |
@@ -5792,29 +5792,29 @@ discard block |
||
| 5792 | 5792 | return false; |
| 5793 | 5793 | |
| 5794 | 5794 | case 2: // in array, expecting end of array or a key |
| 5795 | - if($type == '}') |
|
| 5795 | + if ($type == '}') |
|
| 5796 | 5796 | { |
| 5797 | 5797 | // Array size is less than expected. |
| 5798 | - if(count($list) < end($expected)) |
|
| 5798 | + if (count($list) < end($expected)) |
|
| 5799 | 5799 | return false; |
| 5800 | 5800 | |
| 5801 | 5801 | unset($list); |
| 5802 | - $list = &$stack[count($stack)-1]; |
|
| 5802 | + $list = &$stack[count($stack) - 1]; |
|
| 5803 | 5803 | array_pop($stack); |
| 5804 | 5804 | |
| 5805 | 5805 | // Go to terminal state if we're at the end of the root array. |
| 5806 | 5806 | array_pop($expected); |
| 5807 | 5807 | |
| 5808 | - if(count($expected) == 0) |
|
| 5808 | + if (count($expected) == 0) |
|
| 5809 | 5809 | $state = 1; |
| 5810 | 5810 | |
| 5811 | 5811 | break; |
| 5812 | 5812 | } |
| 5813 | 5813 | |
| 5814 | - if($type == 'i' || $type == 's') |
|
| 5814 | + if ($type == 'i' || $type == 's') |
|
| 5815 | 5815 | { |
| 5816 | 5816 | // Array size exceeds expected length. |
| 5817 | - if(count($list) >= end($expected)) |
|
| 5817 | + if (count($list) >= end($expected)) |
|
| 5818 | 5818 | return false; |
| 5819 | 5819 | |
| 5820 | 5820 | $key = $value; |
@@ -5827,7 +5827,7 @@ discard block |
||
| 5827 | 5827 | |
| 5828 | 5828 | // Expecting array or value. |
| 5829 | 5829 | case 0: |
| 5830 | - if($type == 'a') |
|
| 5830 | + if ($type == 'a') |
|
| 5831 | 5831 | { |
| 5832 | 5832 | $data = array(); |
| 5833 | 5833 | $list = &$data; |
@@ -5836,7 +5836,7 @@ discard block |
||
| 5836 | 5836 | break; |
| 5837 | 5837 | } |
| 5838 | 5838 | |
| 5839 | - if($type != '}') |
|
| 5839 | + if ($type != '}') |
|
| 5840 | 5840 | { |
| 5841 | 5841 | $data = $value; |
| 5842 | 5842 | $state = 1; |
@@ -5849,7 +5849,7 @@ discard block |
||
| 5849 | 5849 | } |
| 5850 | 5850 | |
| 5851 | 5851 | // Trailing data in input. |
| 5852 | - if(!empty($str)) |
|
| 5852 | + if (!empty($str)) |
|
| 5853 | 5853 | return false; |
| 5854 | 5854 | |
| 5855 | 5855 | return $data; |
@@ -5903,7 +5903,7 @@ discard block |
||
| 5903 | 5903 | // Set different modes. |
| 5904 | 5904 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
| 5905 | 5905 | |
| 5906 | - foreach($chmodValues as $val) |
|
| 5906 | + foreach ($chmodValues as $val) |
|
| 5907 | 5907 | { |
| 5908 | 5908 | // If it's writable, break out of the loop. |
| 5909 | 5909 | if (is_writable($file)) |
@@ -5938,13 +5938,13 @@ discard block |
||
| 5938 | 5938 | $returnArray = @json_decode($json, $returnAsArray); |
| 5939 | 5939 | |
| 5940 | 5940 | // PHP 5.3 so no json_last_error_msg() |
| 5941 | - switch(json_last_error()) |
|
| 5941 | + switch (json_last_error()) |
|
| 5942 | 5942 | { |
| 5943 | 5943 | case JSON_ERROR_NONE: |
| 5944 | 5944 | $jsonError = false; |
| 5945 | 5945 | break; |
| 5946 | 5946 | case JSON_ERROR_DEPTH: |
| 5947 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5947 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5948 | 5948 | break; |
| 5949 | 5949 | case JSON_ERROR_STATE_MISMATCH: |
| 5950 | 5950 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5972,10 +5972,10 @@ discard block |
||
| 5972 | 5972 | loadLanguage('Errors'); |
| 5973 | 5973 | |
| 5974 | 5974 | if (!empty($jsonDebug)) |
| 5975 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5975 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5976 | 5976 | |
| 5977 | 5977 | else |
| 5978 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5978 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
| 5979 | 5979 | |
| 5980 | 5980 | // Everyone expects an array. |
| 5981 | 5981 | return array(); |
@@ -6092,7 +6092,7 @@ discard block |
||
| 6092 | 6092 | // Convert Punycode to Unicode |
| 6093 | 6093 | require_once($sourcedir . '/Class-Punycode.php'); |
| 6094 | 6094 | $Punycode = new Punycode(); |
| 6095 | - $tlds = array_map(function ($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds); |
|
| 6095 | + $tlds = array_map(function($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds); |
|
| 6096 | 6096 | } |
| 6097 | 6097 | // Otherwise, use the 2012 list of gTLDs and ccTLDs for now and schedule a background update |
| 6098 | 6098 | else |
@@ -6186,7 +6186,7 @@ discard block |
||
| 6186 | 6186 | } |
| 6187 | 6187 | |
| 6188 | 6188 | // This recursive function creates the index array from the strings |
| 6189 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 6189 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 6190 | 6190 | { |
| 6191 | 6191 | static $depth = 0; |
| 6192 | 6192 | $depth++; |
@@ -6213,7 +6213,7 @@ discard block |
||
| 6213 | 6213 | }; |
| 6214 | 6214 | |
| 6215 | 6215 | // This recursive function turns the index array into a regular expression |
| 6216 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 6216 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 6217 | 6217 | { |
| 6218 | 6218 | static $depth = 0; |
| 6219 | 6219 | $depth++; |
@@ -6237,11 +6237,11 @@ discard block |
||
| 6237 | 6237 | |
| 6238 | 6238 | if (count(array_keys($value)) == 1) |
| 6239 | 6239 | { |
| 6240 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
| 6240 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
| 6241 | 6241 | $new_key .= $new_key_array[0]; |
| 6242 | 6242 | } |
| 6243 | 6243 | else |
| 6244 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6244 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
| 6245 | 6245 | } |
| 6246 | 6246 | |
| 6247 | 6247 | if ($depth > 1) |
@@ -6284,10 +6284,10 @@ discard block |
||
| 6284 | 6284 | { |
| 6285 | 6285 | $regex = array(); |
| 6286 | 6286 | while (!empty($index)) |
| 6287 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6287 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6288 | 6288 | } |
| 6289 | 6289 | else |
| 6290 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6290 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6291 | 6291 | |
| 6292 | 6292 | // Restore PHP's internal character encoding to whatever it was originally |
| 6293 | 6293 | if (!empty($current_encoding)) |
@@ -6448,8 +6448,8 @@ discard block |
||
| 6448 | 6448 | $query_part['query_see_board'] = '1=1'; |
| 6449 | 6449 | // Otherwise just the groups in $user_info['groups']. |
| 6450 | 6450 | else |
| 6451 | - $query_part['query_see_board'] = 'EXISTS (SELECT DISTINCT bpv.id_board FROM ' . $db_prefix . 'board_permissions_view bpv WHERE (bpv.id_group IN ( '. implode(',', $groups) .') AND bpv.deny = 0) ' |
|
| 6452 | - . ( !empty($deny_boards_access) ? ' AND (bpv.id_group NOT IN ( '. implode(',', $groups) .') and bpv.deny = 1)' : '') |
|
| 6451 | + $query_part['query_see_board'] = 'EXISTS (SELECT DISTINCT bpv.id_board FROM ' . $db_prefix . 'board_permissions_view bpv WHERE (bpv.id_group IN ( ' . implode(',', $groups) . ') AND bpv.deny = 0) ' |
|
| 6452 | + . (!empty($deny_boards_access) ? ' AND (bpv.id_group NOT IN ( ' . implode(',', $groups) . ') and bpv.deny = 1)' : '') |
|
| 6453 | 6453 | . ' AND bpv.id_board = b.id_board)'; |
| 6454 | 6454 | |
| 6455 | 6455 | // Build the list of boards they WANT to see. |
@@ -6513,7 +6513,7 @@ discard block |
||
| 6513 | 6513 | function sanitize_iri($iri) |
| 6514 | 6514 | { |
| 6515 | 6515 | // Encode any non-ASCII characters (but not space or control characters of any sort) |
| 6516 | - $iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function ($matches) { |
|
| 6516 | + $iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function($matches) { |
|
| 6517 | 6517 | return rawurlencode($matches[0]); |
| 6518 | 6518 | }, $iri); |
| 6519 | 6519 | |
@@ -6555,7 +6555,7 @@ discard block |
||
| 6555 | 6555 | $unescaped = array( |
| 6556 | 6556 | '%21'=>'!', '%23'=>'#', '%24'=>'$', '%26'=>'&', |
| 6557 | 6557 | '%27'=>"'", '%28'=>'(', '%29'=>')', '%2A'=>'*', |
| 6558 | - '%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':', |
|
| 6558 | + '%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':', |
|
| 6559 | 6559 | '%3B'=>';', '%3D'=>'=', '%3F'=>'?', '%40'=>'@', |
| 6560 | 6560 | ); |
| 6561 | 6561 | $iri = strtr(rawurlencode($iri), $unescaped); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
| 25 | 26 | global $cache_enable, $sourcedir, $context; |
| 26 | 27 | |
| 27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
| 28 | - if (!empty($db_character_set)) |
|
| 29 | - $smcFunc['db_query']('', ' |
|
| 29 | + if (!empty($db_character_set)) { |
|
| 30 | + $smcFunc['db_query']('', ' |
|
| 30 | 31 | SET NAMES {string:db_character_set}', |
| 31 | 32 | array( |
| 32 | 33 | 'db_character_set' => $db_character_set, |
| 33 | 34 | ) |
| 34 | 35 | ); |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // We need some caching support, maybe. |
| 37 | 39 | loadCacheAccelerator(); |
@@ -46,8 +48,9 @@ discard block |
||
| 46 | 48 | ) |
| 47 | 49 | ); |
| 48 | 50 | $modSettings = array(); |
| 49 | - if (!$request) |
|
| 50 | - display_db_error(); |
|
| 51 | + if (!$request) { |
|
| 52 | + display_db_error(); |
|
| 53 | + } |
|
| 51 | 54 | foreach ($smcFunc['db_fetch_all']($request) as $row) |
| 52 | 55 | { |
| 53 | 56 | $modSettings[$row['variable']] = $row['value']; |
@@ -55,21 +58,27 @@ discard block |
||
| 55 | 58 | $smcFunc['db_free_result']($request); |
| 56 | 59 | |
| 57 | 60 | // Do a few things to protect against missing settings or settings with invalid values... |
| 58 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
| 59 | - $modSettings['defaultMaxTopics'] = 20; |
|
| 60 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
| 61 | - $modSettings['defaultMaxMessages'] = 15; |
|
| 62 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
| 63 | - $modSettings['defaultMaxMembers'] = 30; |
|
| 64 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
| 65 | - $modSettings['defaultMaxListItems'] = 15; |
|
| 61 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
| 62 | + $modSettings['defaultMaxTopics'] = 20; |
|
| 63 | + } |
|
| 64 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
| 65 | + $modSettings['defaultMaxMessages'] = 15; |
|
| 66 | + } |
|
| 67 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
| 68 | + $modSettings['defaultMaxMembers'] = 30; |
|
| 69 | + } |
|
| 70 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
| 71 | + $modSettings['defaultMaxListItems'] = 15; |
|
| 72 | + } |
|
| 66 | 73 | |
| 67 | 74 | // We explicitly do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
| 68 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 69 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 75 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 76 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 77 | + } |
|
| 70 | 78 | |
| 71 | - if (!empty($cache_enable)) |
|
| 72 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 79 | + if (!empty($cache_enable)) { |
|
| 80 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 81 | + } |
|
| 73 | 82 | } |
| 74 | 83 | |
| 75 | 84 | $modSettings['cache_enable'] = $cache_enable; |
@@ -89,8 +98,9 @@ discard block |
||
| 89 | 98 | }; |
| 90 | 99 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
| 91 | 100 | { |
| 92 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
| 93 | - return $string; |
|
| 101 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
| 102 | + return $string; |
|
| 103 | + } |
|
| 94 | 104 | |
| 95 | 105 | $i = 0; |
| 96 | 106 | $len = strlen($string); |
@@ -102,18 +112,15 @@ discard block |
||
| 102 | 112 | { |
| 103 | 113 | $new_string .= $string[$i]; |
| 104 | 114 | $i++; |
| 105 | - } |
|
| 106 | - elseif ($ord < 224) |
|
| 115 | + } elseif ($ord < 224) |
|
| 107 | 116 | { |
| 108 | 117 | $new_string .= $string[$i] . $string[$i + 1]; |
| 109 | 118 | $i += 2; |
| 110 | - } |
|
| 111 | - elseif ($ord < 240) |
|
| 119 | + } elseif ($ord < 240) |
|
| 112 | 120 | { |
| 113 | 121 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 114 | 122 | $i += 3; |
| 115 | - } |
|
| 116 | - elseif ($ord < 248) |
|
| 123 | + } elseif ($ord < 248) |
|
| 117 | 124 | { |
| 118 | 125 | // Magic happens. |
| 119 | 126 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -157,8 +164,7 @@ discard block |
||
| 157 | 164 | { |
| 158 | 165 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 159 | 166 | return is_int($result) ? $result + $offset : false; |
| 160 | - } |
|
| 161 | - else |
|
| 167 | + } else |
|
| 162 | 168 | { |
| 163 | 169 | $needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 164 | 170 | $needle_size = count($needle_arr); |
@@ -167,8 +173,9 @@ discard block |
||
| 167 | 173 | while ((int) $result === $result) |
| 168 | 174 | { |
| 169 | 175 | $offset += $result; |
| 170 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 171 | - return $offset; |
|
| 176 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 177 | + return $offset; |
|
| 178 | + } |
|
| 172 | 179 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 173 | 180 | } |
| 174 | 181 | return false; |
@@ -206,8 +213,9 @@ discard block |
||
| 206 | 213 | $string = $ent_check($string); |
| 207 | 214 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 208 | 215 | $string = $matches[0]; |
| 209 | - while (strlen($string) > $length) |
|
| 210 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 216 | + while (strlen($string) > $length) { |
|
| 217 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 218 | + } |
|
| 211 | 219 | return $string; |
| 212 | 220 | }, |
| 213 | 221 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -217,8 +225,9 @@ discard block |
||
| 217 | 225 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 218 | 226 | { |
| 219 | 227 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 220 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 221 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 228 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 229 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 230 | + } |
|
| 222 | 231 | return implode('', $words); |
| 223 | 232 | } : 'ucwords', |
| 224 | 233 | 'json_decode' => 'smf_json_decode', |
@@ -226,16 +235,17 @@ discard block |
||
| 226 | 235 | ); |
| 227 | 236 | |
| 228 | 237 | // Setting the timezone is a requirement for some functions. |
| 229 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 230 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 231 | - else |
|
| 238 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 239 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 240 | + } else |
|
| 232 | 241 | { |
| 233 | 242 | // Get PHP's default timezone, if set |
| 234 | 243 | $ini_tz = ini_get('date.timezone'); |
| 235 | - if (!empty($ini_tz)) |
|
| 236 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 237 | - else |
|
| 238 | - $modSettings['default_timezone'] = ''; |
|
| 244 | + if (!empty($ini_tz)) { |
|
| 245 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 246 | + } else { |
|
| 247 | + $modSettings['default_timezone'] = ''; |
|
| 248 | + } |
|
| 239 | 249 | |
| 240 | 250 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 241 | 251 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -253,22 +263,26 @@ discard block |
||
| 253 | 263 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 254 | 264 | { |
| 255 | 265 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 256 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 258 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 259 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 260 | - else |
|
| 261 | - unset($modSettings['load_average']); |
|
| 266 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 267 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 268 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 269 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 270 | + } else { |
|
| 271 | + unset($modSettings['load_average']); |
|
| 272 | + } |
|
| 262 | 273 | |
| 263 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 264 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 274 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 275 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 276 | + } |
|
| 265 | 277 | } |
| 266 | 278 | |
| 267 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 268 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 279 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 280 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 281 | + } |
|
| 269 | 282 | |
| 270 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 271 | - display_loadavg_error(); |
|
| 283 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 284 | + display_loadavg_error(); |
|
| 285 | + } |
|
| 272 | 286 | } |
| 273 | 287 | |
| 274 | 288 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -289,8 +303,9 @@ discard block |
||
| 289 | 303 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 290 | 304 | { |
| 291 | 305 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
| 292 | - foreach ($integration_settings as $hook => $function) |
|
| 293 | - add_integration_function($hook, $function, '', false); |
|
| 306 | + foreach ($integration_settings as $hook => $function) { |
|
| 307 | + add_integration_function($hook, $function, '', false); |
|
| 308 | + } |
|
| 294 | 309 | } |
| 295 | 310 | |
| 296 | 311 | // Any files to pre include? |
@@ -300,8 +315,9 @@ discard block |
||
| 300 | 315 | foreach ($pre_includes as $include) |
| 301 | 316 | { |
| 302 | 317 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 303 | - if (file_exists($include)) |
|
| 304 | - require_once($include); |
|
| 318 | + if (file_exists($include)) { |
|
| 319 | + require_once($include); |
|
| 320 | + } |
|
| 305 | 321 | } |
| 306 | 322 | } |
| 307 | 323 | |
@@ -412,9 +428,9 @@ discard block |
||
| 412 | 428 | break; |
| 413 | 429 | } |
| 414 | 430 | } |
| 431 | + } else { |
|
| 432 | + $id_member = 0; |
|
| 415 | 433 | } |
| 416 | - else |
|
| 417 | - $id_member = 0; |
|
| 418 | 434 | |
| 419 | 435 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 420 | 436 | { |
@@ -422,8 +438,9 @@ discard block |
||
| 422 | 438 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
| 423 | 439 | |
| 424 | 440 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
| 425 | - if (empty($cookie_data)) |
|
| 426 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 441 | + if (empty($cookie_data)) { |
|
| 442 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 443 | + } |
|
| 427 | 444 | |
| 428 | 445 | list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, ''); |
| 429 | 446 | |
@@ -431,16 +448,17 @@ discard block |
||
| 431 | 448 | |
| 432 | 449 | // Make sure the cookie is set to the correct domain and path |
| 433 | 450 | require_once($sourcedir . '/Subs-Auth.php'); |
| 434 | - if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) |
|
| 435 | - setLoginCookie((int) $login_span - time(), $id_member); |
|
| 436 | - } |
|
| 437 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 451 | + if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) { |
|
| 452 | + setLoginCookie((int) $login_span - time(), $id_member); |
|
| 453 | + } |
|
| 454 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 438 | 455 | { |
| 439 | 456 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 440 | 457 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true); |
| 441 | 458 | |
| 442 | - if (empty($cookie_data)) |
|
| 443 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 459 | + if (empty($cookie_data)) { |
|
| 460 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 461 | + } |
|
| 444 | 462 | |
| 445 | 463 | list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, ''); |
| 446 | 464 | $id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0; |
@@ -465,30 +483,34 @@ discard block |
||
| 465 | 483 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 466 | 484 | $smcFunc['db_free_result']($request); |
| 467 | 485 | |
| 468 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 469 | - $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
| 486 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 487 | + $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
| 488 | + } |
|
| 470 | 489 | |
| 471 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 472 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 490 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 491 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 492 | + } |
|
| 473 | 493 | } |
| 474 | 494 | |
| 475 | 495 | // Did we find 'im? If not, junk it. |
| 476 | 496 | if (!empty($user_settings)) |
| 477 | 497 | { |
| 478 | 498 | // As much as the password should be right, we can assume the integration set things up. |
| 479 | - if (!empty($already_verified) && $already_verified === true) |
|
| 480 | - $check = true; |
|
| 499 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 500 | + $check = true; |
|
| 501 | + } |
|
| 481 | 502 | // SHA-512 hash should be 128 characters long. |
| 482 | - elseif (strlen($password) == 128) |
|
| 483 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 484 | - else |
|
| 485 | - $check = false; |
|
| 503 | + elseif (strlen($password) == 128) { |
|
| 504 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 505 | + } else { |
|
| 506 | + $check = false; |
|
| 507 | + } |
|
| 486 | 508 | |
| 487 | 509 | // Wrong password or not activated - either way, you're going nowhere. |
| 488 | 510 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
| 511 | + } else { |
|
| 512 | + $id_member = 0; |
|
| 489 | 513 | } |
| 490 | - else |
|
| 491 | - $id_member = 0; |
|
| 492 | 514 | |
| 493 | 515 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 494 | 516 | if (!$id_member) |
@@ -517,8 +539,9 @@ discard block |
||
| 517 | 539 | |
| 518 | 540 | list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, ''); |
| 519 | 541 | |
| 520 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
| 521 | - $tfasecret = null; |
|
| 542 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
| 543 | + $tfasecret = null; |
|
| 544 | + } |
|
| 522 | 545 | } |
| 523 | 546 | |
| 524 | 547 | // They didn't finish logging in before coming here? Then they're no one to us. |
@@ -540,10 +563,12 @@ discard block |
||
| 540 | 563 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 541 | 564 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 542 | 565 | { |
| 543 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 566 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 567 | + //only do this if we are just forcing SOME membergroups |
|
| 544 | 568 | { |
| 545 | 569 | //Build an array of ALL user membergroups. |
| 546 | 570 | $full_groups = array($user_settings['id_group']); |
| 571 | + } |
|
| 547 | 572 | if (!empty($user_settings['additional_groups'])) |
| 548 | 573 | { |
| 549 | 574 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -563,15 +588,17 @@ discard block |
||
| 563 | 588 | ); |
| 564 | 589 | $row = $smcFunc['db_fetch_assoc']($request); |
| 565 | 590 | $smcFunc['db_free_result']($request); |
| 591 | + } else { |
|
| 592 | + $row['total'] = 1; |
|
| 566 | 593 | } |
| 567 | - else |
|
| 568 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 594 | + //simplifies logics in the next "if" |
|
| 569 | 595 | |
| 570 | 596 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 571 | 597 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 572 | 598 | |
| 573 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 574 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 599 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 600 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 601 | + } |
|
| 575 | 602 | } |
| 576 | 603 | } |
| 577 | 604 | |
@@ -608,29 +635,32 @@ discard block |
||
| 608 | 635 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
| 609 | 636 | $user_settings['last_login'] = time(); |
| 610 | 637 | |
| 611 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 612 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 638 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 639 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 640 | + } |
|
| 613 | 641 | |
| 614 | - if (!empty($modSettings['cache_enable'])) |
|
| 615 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 642 | + if (!empty($modSettings['cache_enable'])) { |
|
| 643 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 644 | + } |
|
| 616 | 645 | } |
| 646 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 647 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 617 | 648 | } |
| 618 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 619 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 620 | 649 | |
| 621 | 650 | $username = $user_settings['member_name']; |
| 622 | 651 | |
| 623 | - if (empty($user_settings['additional_groups'])) |
|
| 624 | - $user_info = array( |
|
| 652 | + if (empty($user_settings['additional_groups'])) { |
|
| 653 | + $user_info = array( |
|
| 625 | 654 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 626 | 655 | ); |
| 627 | - else |
|
| 628 | - $user_info = array( |
|
| 656 | + } else { |
|
| 657 | + $user_info = array( |
|
| 629 | 658 | 'groups' => array_merge( |
| 630 | 659 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 631 | 660 | explode(',', $user_settings['additional_groups']) |
| 632 | 661 | ) |
| 633 | 662 | ); |
| 663 | + } |
|
| 634 | 664 | |
| 635 | 665 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 636 | 666 | $user_info['groups'] = array_map('intval', $user_info['groups']); |
@@ -647,8 +677,7 @@ discard block |
||
| 647 | 677 | $time_system = new DateTime('now', $tz_system); |
| 648 | 678 | $time_user = new DateTime('now', $tz_user); |
| 649 | 679 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 650 | - } |
|
| 651 | - else |
|
| 680 | + } else |
|
| 652 | 681 | { |
| 653 | 682 | // !!! Compatibility. |
| 654 | 683 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -662,8 +691,9 @@ discard block |
||
| 662 | 691 | $user_info = array('groups' => array(-1)); |
| 663 | 692 | $user_settings = array(); |
| 664 | 693 | |
| 665 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 666 | - $_COOKIE[$cookiename] = ''; |
|
| 694 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 695 | + $_COOKIE[$cookiename] = ''; |
|
| 696 | + } |
|
| 667 | 697 | |
| 668 | 698 | // Expire the 2FA cookie |
| 669 | 699 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -680,19 +710,20 @@ discard block |
||
| 680 | 710 | } |
| 681 | 711 | |
| 682 | 712 | // Create a login token if it doesn't exist yet. |
| 683 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 684 | - createToken('login'); |
|
| 685 | - else |
|
| 686 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 713 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 714 | + createToken('login'); |
|
| 715 | + } else { |
|
| 716 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 717 | + } |
|
| 687 | 718 | |
| 688 | 719 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 689 | 720 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 690 | 721 | { |
| 691 | 722 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 692 | 723 | $user_info['possibly_robot'] = SpiderCheck(); |
| 724 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 725 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 693 | 726 | } |
| 694 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 695 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 696 | 727 | // If we haven't turned on proper spider hunts then have a guess! |
| 697 | 728 | else |
| 698 | 729 | { |
@@ -749,8 +780,9 @@ discard block |
||
| 749 | 780 | $user_info['groups'] = array_unique($user_info['groups']); |
| 750 | 781 | |
| 751 | 782 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
| 752 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 753 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 783 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 784 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 785 | + } |
|
| 754 | 786 | |
| 755 | 787 | // Allow the user to change their language. |
| 756 | 788 | if (!empty($modSettings['userLanguage'])) |
@@ -763,13 +795,14 @@ discard block |
||
| 763 | 795 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 764 | 796 | |
| 765 | 797 | // Make it permanent for members. |
| 766 | - if (!empty($user_info['id'])) |
|
| 767 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 768 | - else |
|
| 769 | - $_SESSION['language'] = $user_info['language']; |
|
| 798 | + if (!empty($user_info['id'])) { |
|
| 799 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 800 | + } else { |
|
| 801 | + $_SESSION['language'] = $user_info['language']; |
|
| 802 | + } |
|
| 803 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 804 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 770 | 805 | } |
| 771 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 772 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 773 | 806 | } |
| 774 | 807 | |
| 775 | 808 | $temp = build_query_board($user_info['id']); |
@@ -832,9 +865,9 @@ discard block |
||
| 832 | 865 | } |
| 833 | 866 | |
| 834 | 867 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 835 | - if (!empty($topic)) |
|
| 836 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 837 | - else |
|
| 868 | + if (!empty($topic)) { |
|
| 869 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 870 | + } else |
|
| 838 | 871 | { |
| 839 | 872 | loadPermissions(); |
| 840 | 873 | loadTheme(); |
@@ -852,10 +885,11 @@ discard block |
||
| 852 | 885 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 853 | 886 | { |
| 854 | 887 | // @todo SLOW? |
| 855 | - if (!empty($topic)) |
|
| 856 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 857 | - else |
|
| 858 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 888 | + if (!empty($topic)) { |
|
| 889 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 890 | + } else { |
|
| 891 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 892 | + } |
|
| 859 | 893 | |
| 860 | 894 | if (!empty($temp)) |
| 861 | 895 | { |
@@ -893,8 +927,9 @@ discard block |
||
| 893 | 927 | $row = $smcFunc['db_fetch_assoc']($request); |
| 894 | 928 | |
| 895 | 929 | // Set the current board. |
| 896 | - if (!empty($row['id_board'])) |
|
| 897 | - $board = $row['id_board']; |
|
| 930 | + if (!empty($row['id_board'])) { |
|
| 931 | + $board = $row['id_board']; |
|
| 932 | + } |
|
| 898 | 933 | |
| 899 | 934 | // Basic operating information. (globals... :/) |
| 900 | 935 | $board_info = array( |
@@ -930,21 +965,23 @@ discard block |
||
| 930 | 965 | |
| 931 | 966 | do |
| 932 | 967 | { |
| 933 | - if (!empty($row['id_moderator'])) |
|
| 934 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 968 | + if (!empty($row['id_moderator'])) { |
|
| 969 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 935 | 970 | 'id' => $row['id_moderator'], |
| 936 | 971 | 'name' => $row['real_name'], |
| 937 | 972 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 938 | 973 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 939 | 974 | ); |
| 975 | + } |
|
| 940 | 976 | |
| 941 | - if (!empty($row['id_moderator_group'])) |
|
| 942 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 977 | + if (!empty($row['id_moderator_group'])) { |
|
| 978 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 943 | 979 | 'id' => $row['id_moderator_group'], |
| 944 | 980 | 'name' => $row['group_name'], |
| 945 | 981 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 946 | 982 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 947 | 983 | ); |
| 984 | + } |
|
| 948 | 985 | } |
| 949 | 986 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 950 | 987 | |
@@ -976,12 +1013,12 @@ discard block |
||
| 976 | 1013 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 977 | 1014 | { |
| 978 | 1015 | // @todo SLOW? |
| 979 | - if (!empty($topic)) |
|
| 980 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1016 | + if (!empty($topic)) { |
|
| 1017 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1018 | + } |
|
| 981 | 1019 | cache_put_data('board-' . $board, $board_info, 120); |
| 982 | 1020 | } |
| 983 | - } |
|
| 984 | - else |
|
| 1021 | + } else |
|
| 985 | 1022 | { |
| 986 | 1023 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 987 | 1024 | $board_info = array( |
@@ -995,8 +1032,9 @@ discard block |
||
| 995 | 1032 | $smcFunc['db_free_result']($request); |
| 996 | 1033 | } |
| 997 | 1034 | |
| 998 | - if (!empty($topic)) |
|
| 999 | - $_GET['board'] = (int) $board; |
|
| 1035 | + if (!empty($topic)) { |
|
| 1036 | + $_GET['board'] = (int) $board; |
|
| 1037 | + } |
|
| 1000 | 1038 | |
| 1001 | 1039 | if (!empty($board)) |
| 1002 | 1040 | { |
@@ -1006,10 +1044,12 @@ discard block |
||
| 1006 | 1044 | // Now check if the user is a moderator. |
| 1007 | 1045 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 1008 | 1046 | |
| 1009 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 1010 | - $board_info['error'] = 'access'; |
|
| 1011 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 1012 | - $board_info['error'] = 'access'; |
|
| 1047 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1048 | + $board_info['error'] = 'access'; |
|
| 1049 | + } |
|
| 1050 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1051 | + $board_info['error'] = 'access'; |
|
| 1052 | + } |
|
| 1013 | 1053 | |
| 1014 | 1054 | // Build up the linktree. |
| 1015 | 1055 | $context['linktree'] = array_merge( |
@@ -1032,8 +1072,9 @@ discard block |
||
| 1032 | 1072 | $context['current_board'] = $board; |
| 1033 | 1073 | |
| 1034 | 1074 | // No posting in redirection boards! |
| 1035 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1036 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1075 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1076 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1077 | + } |
|
| 1037 | 1078 | |
| 1038 | 1079 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1039 | 1080 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1059,24 +1100,23 @@ discard block |
||
| 1059 | 1100 | ob_end_clean(); |
| 1060 | 1101 | send_http_status(403); |
| 1061 | 1102 | die; |
| 1062 | - } |
|
| 1063 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1103 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1064 | 1104 | { |
| 1065 | 1105 | // Slightly different error message here... |
| 1066 | 1106 | fatal_lang_error('cannot_post_redirect', false); |
| 1067 | - } |
|
| 1068 | - elseif ($user_info['is_guest']) |
|
| 1107 | + } elseif ($user_info['is_guest']) |
|
| 1069 | 1108 | { |
| 1070 | 1109 | loadLanguage('Errors'); |
| 1071 | 1110 | is_not_guest($txt['topic_gone']); |
| 1111 | + } else { |
|
| 1112 | + fatal_lang_error('topic_gone', false); |
|
| 1072 | 1113 | } |
| 1073 | - else |
|
| 1074 | - fatal_lang_error('topic_gone', false); |
|
| 1075 | 1114 | } |
| 1076 | 1115 | |
| 1077 | - if ($user_info['is_mod']) |
|
| 1078 | - $user_info['groups'][] = 3; |
|
| 1079 | -} |
|
| 1116 | + if ($user_info['is_mod']) { |
|
| 1117 | + $user_info['groups'][] = 3; |
|
| 1118 | + } |
|
| 1119 | + } |
|
| 1080 | 1120 | |
| 1081 | 1121 | /** |
| 1082 | 1122 | * Load this user's permissions. |
@@ -1097,8 +1137,9 @@ discard block |
||
| 1097 | 1137 | asort($cache_groups); |
| 1098 | 1138 | $cache_groups = implode(',', $cache_groups); |
| 1099 | 1139 | // If it's a spider then cache it different. |
| 1100 | - if ($user_info['possibly_robot']) |
|
| 1101 | - $cache_groups .= '-spider'; |
|
| 1140 | + if ($user_info['possibly_robot']) { |
|
| 1141 | + $cache_groups .= '-spider'; |
|
| 1142 | + } |
|
| 1102 | 1143 | |
| 1103 | 1144 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1104 | 1145 | { |
@@ -1106,9 +1147,9 @@ discard block |
||
| 1106 | 1147 | banPermissions(); |
| 1107 | 1148 | |
| 1108 | 1149 | return; |
| 1150 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1151 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1109 | 1152 | } |
| 1110 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1111 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1112 | 1153 | } |
| 1113 | 1154 | |
| 1114 | 1155 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1130,23 +1171,26 @@ discard block |
||
| 1130 | 1171 | $removals = array(); |
| 1131 | 1172 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1132 | 1173 | { |
| 1133 | - if (empty($row['add_deny'])) |
|
| 1134 | - $removals[] = $row['permission']; |
|
| 1135 | - else |
|
| 1136 | - $user_info['permissions'][] = $row['permission']; |
|
| 1174 | + if (empty($row['add_deny'])) { |
|
| 1175 | + $removals[] = $row['permission']; |
|
| 1176 | + } else { |
|
| 1177 | + $user_info['permissions'][] = $row['permission']; |
|
| 1178 | + } |
|
| 1137 | 1179 | } |
| 1138 | 1180 | $smcFunc['db_free_result']($request); |
| 1139 | 1181 | |
| 1140 | - if (isset($cache_groups)) |
|
| 1141 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1182 | + if (isset($cache_groups)) { |
|
| 1183 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1184 | + } |
|
| 1142 | 1185 | } |
| 1143 | 1186 | |
| 1144 | 1187 | // Get the board permissions. |
| 1145 | 1188 | if (!empty($board)) |
| 1146 | 1189 | { |
| 1147 | 1190 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1148 | - if (!isset($board_info['profile'])) |
|
| 1149 | - fatal_lang_error('no_board'); |
|
| 1191 | + if (!isset($board_info['profile'])) { |
|
| 1192 | + fatal_lang_error('no_board'); |
|
| 1193 | + } |
|
| 1150 | 1194 | |
| 1151 | 1195 | $request = $smcFunc['db_query']('', ' |
| 1152 | 1196 | SELECT permission, add_deny |
@@ -1162,20 +1206,23 @@ discard block |
||
| 1162 | 1206 | ); |
| 1163 | 1207 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1164 | 1208 | { |
| 1165 | - if (empty($row['add_deny'])) |
|
| 1166 | - $removals[] = $row['permission']; |
|
| 1167 | - else |
|
| 1168 | - $user_info['permissions'][] = $row['permission']; |
|
| 1209 | + if (empty($row['add_deny'])) { |
|
| 1210 | + $removals[] = $row['permission']; |
|
| 1211 | + } else { |
|
| 1212 | + $user_info['permissions'][] = $row['permission']; |
|
| 1213 | + } |
|
| 1169 | 1214 | } |
| 1170 | 1215 | $smcFunc['db_free_result']($request); |
| 1171 | 1216 | } |
| 1172 | 1217 | |
| 1173 | 1218 | // Remove all the permissions they shouldn't have ;). |
| 1174 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1175 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1219 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1220 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1221 | + } |
|
| 1176 | 1222 | |
| 1177 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1178 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1223 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1224 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1225 | + } |
|
| 1179 | 1226 | |
| 1180 | 1227 | // Banned? Watch, don't touch.. |
| 1181 | 1228 | banPermissions(); |
@@ -1187,17 +1234,18 @@ discard block |
||
| 1187 | 1234 | { |
| 1188 | 1235 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1189 | 1236 | rebuildModCache(); |
| 1237 | + } else { |
|
| 1238 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1190 | 1239 | } |
| 1191 | - else |
|
| 1192 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1193 | 1240 | |
| 1194 | 1241 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1195 | 1242 | // For example this drastically simplifies certain changes to the profile area. |
| 1196 | 1243 | $user_info['permissions'][] = 'is_not_guest'; |
| 1197 | 1244 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1198 | 1245 | $user_info['permissions'][] = 'profile_view_own'; |
| 1199 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1200 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1246 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1247 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1248 | + } |
|
| 1201 | 1249 | } |
| 1202 | 1250 | } |
| 1203 | 1251 | |
@@ -1215,8 +1263,9 @@ discard block |
||
| 1215 | 1263 | global $image_proxy_enabled, $user_info; |
| 1216 | 1264 | |
| 1217 | 1265 | // Can't just look for no users :P. |
| 1218 | - if (empty($users)) |
|
| 1219 | - return array(); |
|
| 1266 | + if (empty($users)) { |
|
| 1267 | + return array(); |
|
| 1268 | + } |
|
| 1220 | 1269 | |
| 1221 | 1270 | // Pass the set value |
| 1222 | 1271 | $context['loadMemberContext_set'] = $set; |
@@ -1231,8 +1280,9 @@ discard block |
||
| 1231 | 1280 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1232 | 1281 | { |
| 1233 | 1282 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1234 | - if ($data == null) |
|
| 1235 | - continue; |
|
| 1283 | + if ($data == null) { |
|
| 1284 | + continue; |
|
| 1285 | + } |
|
| 1236 | 1286 | |
| 1237 | 1287 | $loaded_ids[] = $data['id_member']; |
| 1238 | 1288 | $user_profile[$data['id_member']] = $data; |
@@ -1299,16 +1349,19 @@ discard block |
||
| 1299 | 1349 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
| 1300 | 1350 | |
| 1301 | 1351 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1302 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 1303 | - $row['avatar'] = get_proxied_url($row['avatar']); |
|
| 1352 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 1353 | + $row['avatar'] = get_proxied_url($row['avatar']); |
|
| 1354 | + } |
|
| 1304 | 1355 | |
| 1305 | 1356 | // Keep track of the member's normal member group |
| 1306 | 1357 | $row['primary_group'] = !empty($row['member_group']) ? $row['member_group'] : ''; |
| 1307 | 1358 | |
| 1308 | - if (isset($row['member_ip'])) |
|
| 1309 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1310 | - if (isset($row['member_ip2'])) |
|
| 1311 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1359 | + if (isset($row['member_ip'])) { |
|
| 1360 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1361 | + } |
|
| 1362 | + if (isset($row['member_ip2'])) { |
|
| 1363 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1364 | + } |
|
| 1312 | 1365 | $row['id_member'] = (int) $row['id_member']; |
| 1313 | 1366 | $new_loaded_ids[] = $row['id_member']; |
| 1314 | 1367 | $loaded_ids[] = $row['id_member']; |
@@ -1328,8 +1381,9 @@ discard block |
||
| 1328 | 1381 | 'loaded_ids' => $new_loaded_ids, |
| 1329 | 1382 | ) |
| 1330 | 1383 | ); |
| 1331 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1332 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1384 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1385 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1386 | + } |
|
| 1333 | 1387 | $smcFunc['db_free_result']($request); |
| 1334 | 1388 | } |
| 1335 | 1389 | |
@@ -1340,10 +1394,11 @@ discard block |
||
| 1340 | 1394 | { |
| 1341 | 1395 | foreach ($loaded_ids as $a_member) |
| 1342 | 1396 | { |
| 1343 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1344 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1345 | - else |
|
| 1346 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1397 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1398 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1399 | + } else { |
|
| 1400 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1401 | + } |
|
| 1347 | 1402 | |
| 1348 | 1403 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1349 | 1404 | |
@@ -1356,8 +1411,9 @@ discard block |
||
| 1356 | 1411 | |
| 1357 | 1412 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1358 | 1413 | { |
| 1359 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1360 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1414 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1415 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1416 | + } |
|
| 1361 | 1417 | } |
| 1362 | 1418 | |
| 1363 | 1419 | // Are we loading any moderators? If so, fix their group data... |
@@ -1383,14 +1439,17 @@ discard block |
||
| 1383 | 1439 | foreach ($temp_mods as $id) |
| 1384 | 1440 | { |
| 1385 | 1441 | // By popular demand, don't show admins or global moderators as moderators. |
| 1386 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1387 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1442 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1443 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1444 | + } |
|
| 1388 | 1445 | |
| 1389 | 1446 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1390 | - if (!empty($row['icons'])) |
|
| 1391 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1392 | - if (!empty($row['member_group_color'])) |
|
| 1393 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1447 | + if (!empty($row['icons'])) { |
|
| 1448 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1449 | + } |
|
| 1450 | + if (!empty($row['member_group_color'])) { |
|
| 1451 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1452 | + } |
|
| 1394 | 1453 | } |
| 1395 | 1454 | } |
| 1396 | 1455 | |
@@ -1412,12 +1471,14 @@ discard block |
||
| 1412 | 1471 | static $loadedLanguages = array(); |
| 1413 | 1472 | |
| 1414 | 1473 | // If this person's data is already loaded, skip it. |
| 1415 | - if (isset($dataLoaded[$user])) |
|
| 1416 | - return true; |
|
| 1474 | + if (isset($dataLoaded[$user])) { |
|
| 1475 | + return true; |
|
| 1476 | + } |
|
| 1417 | 1477 | |
| 1418 | 1478 | // We can't load guests or members not loaded by loadMemberData()! |
| 1419 | - if ($user == 0) |
|
| 1420 | - return false; |
|
| 1479 | + if ($user == 0) { |
|
| 1480 | + return false; |
|
| 1481 | + } |
|
| 1421 | 1482 | if (!isset($user_profile[$user])) |
| 1422 | 1483 | { |
| 1423 | 1484 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1443,12 +1504,16 @@ discard block |
||
| 1443 | 1504 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1444 | 1505 | |
| 1445 | 1506 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1446 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1507 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1508 | + //icon is set and exists |
|
| 1447 | 1509 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1448 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1510 | + } elseif (isset($profile['icons'][1])) { |
|
| 1511 | + //icon is set and doesn't exist, fallback to default |
|
| 1449 | 1512 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1450 | - else //not set, bye bye |
|
| 1513 | + } else { |
|
| 1514 | + //not set, bye bye |
|
| 1451 | 1515 | $group_icon_url = ''; |
| 1516 | + } |
|
| 1452 | 1517 | |
| 1453 | 1518 | // These minimal values are always loaded |
| 1454 | 1519 | $memberContext[$user] = array( |
@@ -1467,8 +1532,9 @@ discard block |
||
| 1467 | 1532 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1468 | 1533 | { |
| 1469 | 1534 | // Go the extra mile and load the user's native language name. |
| 1470 | - if (empty($loadedLanguages)) |
|
| 1471 | - $loadedLanguages = getLanguages(); |
|
| 1535 | + if (empty($loadedLanguages)) { |
|
| 1536 | + $loadedLanguages = getLanguages(); |
|
| 1537 | + } |
|
| 1472 | 1538 | |
| 1473 | 1539 | $memberContext[$user] += array( |
| 1474 | 1540 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1523,31 +1589,33 @@ discard block |
||
| 1523 | 1589 | { |
| 1524 | 1590 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1525 | 1591 | { |
| 1526 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1527 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1528 | - else |
|
| 1529 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1530 | - } |
|
| 1531 | - else |
|
| 1592 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1593 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1594 | + } else { |
|
| 1595 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1596 | + } |
|
| 1597 | + } else |
|
| 1532 | 1598 | { |
| 1533 | 1599 | // So it's stored in the member table? |
| 1534 | 1600 | if (!empty($profile['avatar'])) |
| 1535 | 1601 | { |
| 1536 | 1602 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1603 | + } elseif (!empty($profile['filename'])) { |
|
| 1604 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1537 | 1605 | } |
| 1538 | - elseif (!empty($profile['filename'])) |
|
| 1539 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1540 | 1606 | // Right... no avatar...use the default one |
| 1541 | - else |
|
| 1542 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1607 | + else { |
|
| 1608 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1609 | + } |
|
| 1543 | 1610 | } |
| 1544 | - if (!empty($image)) |
|
| 1545 | - $memberContext[$user]['avatar'] = array( |
|
| 1611 | + if (!empty($image)) { |
|
| 1612 | + $memberContext[$user]['avatar'] = array( |
|
| 1546 | 1613 | 'name' => $profile['avatar'], |
| 1547 | 1614 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1548 | 1615 | 'href' => $image, |
| 1549 | 1616 | 'url' => $image, |
| 1550 | 1617 | ); |
| 1618 | + } |
|
| 1551 | 1619 | } |
| 1552 | 1620 | |
| 1553 | 1621 | // Are we also loading the members custom fields into context? |
@@ -1555,13 +1623,15 @@ discard block |
||
| 1555 | 1623 | { |
| 1556 | 1624 | $memberContext[$user]['custom_fields'] = array(); |
| 1557 | 1625 | |
| 1558 | - if (!isset($context['display_fields'])) |
|
| 1559 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1626 | + if (!isset($context['display_fields'])) { |
|
| 1627 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1628 | + } |
|
| 1560 | 1629 | |
| 1561 | 1630 | foreach ($context['display_fields'] as $custom) |
| 1562 | 1631 | { |
| 1563 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1564 | - continue; |
|
| 1632 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1633 | + continue; |
|
| 1634 | + } |
|
| 1565 | 1635 | |
| 1566 | 1636 | $value = $profile['options'][$custom['col_name']]; |
| 1567 | 1637 | |
@@ -1569,31 +1639,36 @@ discard block |
||
| 1569 | 1639 | $currentKey = 0; |
| 1570 | 1640 | |
| 1571 | 1641 | // Create a key => value array for multiple options fields |
| 1572 | - if (!empty($custom['options'])) |
|
| 1573 | - foreach ($custom['options'] as $k => $v) |
|
| 1642 | + if (!empty($custom['options'])) { |
|
| 1643 | + foreach ($custom['options'] as $k => $v) |
|
| 1574 | 1644 | { |
| 1575 | 1645 | $fieldOptions[] = $v; |
| 1576 | - if (empty($currentKey)) |
|
| 1577 | - $currentKey = $v == $value ? $k : 0; |
|
| 1646 | + } |
|
| 1647 | + if (empty($currentKey)) { |
|
| 1648 | + $currentKey = $v == $value ? $k : 0; |
|
| 1649 | + } |
|
| 1578 | 1650 | } |
| 1579 | 1651 | |
| 1580 | 1652 | // BBC? |
| 1581 | - if ($custom['bbc']) |
|
| 1582 | - $value = parse_bbc($value); |
|
| 1653 | + if ($custom['bbc']) { |
|
| 1654 | + $value = parse_bbc($value); |
|
| 1655 | + } |
|
| 1583 | 1656 | |
| 1584 | 1657 | // ... or checkbox? |
| 1585 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1586 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1658 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1659 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1660 | + } |
|
| 1587 | 1661 | |
| 1588 | 1662 | // Enclosing the user input within some other text? |
| 1589 | - if (!empty($custom['enclose'])) |
|
| 1590 | - $value = strtr($custom['enclose'], array( |
|
| 1663 | + if (!empty($custom['enclose'])) { |
|
| 1664 | + $value = strtr($custom['enclose'], array( |
|
| 1591 | 1665 | '{SCRIPTURL}' => $scripturl, |
| 1592 | 1666 | '{IMAGES_URL}' => $settings['images_url'], |
| 1593 | 1667 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1594 | 1668 | '{INPUT}' => $value, |
| 1595 | 1669 | '{KEY}' => $currentKey, |
| 1596 | 1670 | )); |
| 1671 | + } |
|
| 1597 | 1672 | |
| 1598 | 1673 | $memberContext[$user]['custom_fields'][] = array( |
| 1599 | 1674 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1620,8 +1695,9 @@ discard block |
||
| 1620 | 1695 | global $smcFunc, $txt, $scripturl, $settings; |
| 1621 | 1696 | |
| 1622 | 1697 | // Do not waste my time... |
| 1623 | - if (empty($users) || empty($params)) |
|
| 1624 | - return false; |
|
| 1698 | + if (empty($users) || empty($params)) { |
|
| 1699 | + return false; |
|
| 1700 | + } |
|
| 1625 | 1701 | |
| 1626 | 1702 | // Make sure it's an array. |
| 1627 | 1703 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1648,41 +1724,48 @@ discard block |
||
| 1648 | 1724 | $currentKey = 0; |
| 1649 | 1725 | |
| 1650 | 1726 | // Create a key => value array for multiple options fields |
| 1651 | - if (!empty($row['field_options'])) |
|
| 1652 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1727 | + if (!empty($row['field_options'])) { |
|
| 1728 | + foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1653 | 1729 | { |
| 1654 | 1730 | $fieldOptions[] = $v; |
| 1655 | - if (empty($currentKey)) |
|
| 1656 | - $currentKey = $v == $row['value'] ? $k : 0; |
|
| 1731 | + } |
|
| 1732 | + if (empty($currentKey)) { |
|
| 1733 | + $currentKey = $v == $row['value'] ? $k : 0; |
|
| 1734 | + } |
|
| 1657 | 1735 | } |
| 1658 | 1736 | |
| 1659 | 1737 | // BBC? |
| 1660 | - if (!empty($row['bbc'])) |
|
| 1661 | - $row['value'] = parse_bbc($row['value']); |
|
| 1738 | + if (!empty($row['bbc'])) { |
|
| 1739 | + $row['value'] = parse_bbc($row['value']); |
|
| 1740 | + } |
|
| 1662 | 1741 | |
| 1663 | 1742 | // ... or checkbox? |
| 1664 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1665 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1743 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1744 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1745 | + } |
|
| 1666 | 1746 | |
| 1667 | 1747 | // Enclosing the user input within some other text? |
| 1668 | - if (!empty($row['enclose'])) |
|
| 1669 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1748 | + if (!empty($row['enclose'])) { |
|
| 1749 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1670 | 1750 | '{SCRIPTURL}' => $scripturl, |
| 1671 | 1751 | '{IMAGES_URL}' => $settings['images_url'], |
| 1672 | 1752 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1673 | 1753 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1674 | 1754 | '{KEY}' => $currentKey, |
| 1675 | 1755 | )); |
| 1756 | + } |
|
| 1676 | 1757 | |
| 1677 | 1758 | // Send a simple array if there is just 1 param |
| 1678 | - if (count($params) == 1) |
|
| 1679 | - $return[$row['id_member']] = $row; |
|
| 1759 | + if (count($params) == 1) { |
|
| 1760 | + $return[$row['id_member']] = $row; |
|
| 1761 | + } |
|
| 1680 | 1762 | |
| 1681 | 1763 | // More than 1? knock yourself out... |
| 1682 | 1764 | else |
| 1683 | 1765 | { |
| 1684 | - if (!isset($return[$row['id_member']])) |
|
| 1685 | - $return[$row['id_member']] = array(); |
|
| 1766 | + if (!isset($return[$row['id_member']])) { |
|
| 1767 | + $return[$row['id_member']] = array(); |
|
| 1768 | + } |
|
| 1686 | 1769 | |
| 1687 | 1770 | $return[$row['id_member']][$row['variable']] = $row; |
| 1688 | 1771 | } |
@@ -1716,8 +1799,9 @@ discard block |
||
| 1716 | 1799 | global $context; |
| 1717 | 1800 | |
| 1718 | 1801 | // Don't know any browser! |
| 1719 | - if (empty($context['browser'])) |
|
| 1720 | - detectBrowser(); |
|
| 1802 | + if (empty($context['browser'])) { |
|
| 1803 | + detectBrowser(); |
|
| 1804 | + } |
|
| 1721 | 1805 | |
| 1722 | 1806 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1723 | 1807 | } |
@@ -1735,8 +1819,9 @@ discard block |
||
| 1735 | 1819 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1736 | 1820 | |
| 1737 | 1821 | // The theme was specified by parameter. |
| 1738 | - if (!empty($id_theme)) |
|
| 1739 | - $id_theme = (int) $id_theme; |
|
| 1822 | + if (!empty($id_theme)) { |
|
| 1823 | + $id_theme = (int) $id_theme; |
|
| 1824 | + } |
|
| 1740 | 1825 | // The theme was specified by REQUEST. |
| 1741 | 1826 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1742 | 1827 | { |
@@ -1744,32 +1829,38 @@ discard block |
||
| 1744 | 1829 | $_SESSION['id_theme'] = $id_theme; |
| 1745 | 1830 | } |
| 1746 | 1831 | // The theme was specified by REQUEST... previously. |
| 1747 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1748 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1832 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1833 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1834 | + } |
|
| 1749 | 1835 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1750 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1751 | - $id_theme = $user_info['theme']; |
|
| 1836 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1837 | + $id_theme = $user_info['theme']; |
|
| 1838 | + } |
|
| 1752 | 1839 | // The theme was specified by the board. |
| 1753 | - elseif (!empty($board_info['theme'])) |
|
| 1754 | - $id_theme = $board_info['theme']; |
|
| 1840 | + elseif (!empty($board_info['theme'])) { |
|
| 1841 | + $id_theme = $board_info['theme']; |
|
| 1842 | + } |
|
| 1755 | 1843 | // The theme is the forum's default. |
| 1756 | - else |
|
| 1757 | - $id_theme = $modSettings['theme_guests']; |
|
| 1844 | + else { |
|
| 1845 | + $id_theme = $modSettings['theme_guests']; |
|
| 1846 | + } |
|
| 1758 | 1847 | |
| 1759 | 1848 | // Verify the id_theme... no foul play. |
| 1760 | 1849 | // Always allow the board specific theme, if they are overriding. |
| 1761 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1762 | - $id_theme = $board_info['theme']; |
|
| 1850 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1851 | + $id_theme = $board_info['theme']; |
|
| 1852 | + } |
|
| 1763 | 1853 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1764 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1765 | - $id_theme = (int) $id_theme; |
|
| 1766 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1854 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1855 | + $id_theme = (int) $id_theme; |
|
| 1856 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1767 | 1857 | { |
| 1768 | 1858 | $themes = explode(',', $modSettings['enableThemes']); |
| 1769 | - if (!in_array($id_theme, $themes)) |
|
| 1770 | - $id_theme = $modSettings['theme_guests']; |
|
| 1771 | - else |
|
| 1772 | - $id_theme = (int) $id_theme; |
|
| 1859 | + if (!in_array($id_theme, $themes)) { |
|
| 1860 | + $id_theme = $modSettings['theme_guests']; |
|
| 1861 | + } else { |
|
| 1862 | + $id_theme = (int) $id_theme; |
|
| 1863 | + } |
|
| 1773 | 1864 | } |
| 1774 | 1865 | |
| 1775 | 1866 | // Allow mod authors the option to override the theme id for custom page themes |
@@ -1781,18 +1872,19 @@ discard block |
||
| 1781 | 1872 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1782 | 1873 | |
| 1783 | 1874 | // Disable image proxy if we don't have SSL enabled |
| 1784 | - if (empty($modSettings['force_ssl'])) |
|
| 1785 | - $image_proxy_enabled = false; |
|
| 1875 | + if (empty($modSettings['force_ssl'])) { |
|
| 1876 | + $image_proxy_enabled = false; |
|
| 1877 | + } |
|
| 1786 | 1878 | |
| 1787 | 1879 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
| 1788 | 1880 | { |
| 1789 | 1881 | $themeData = $temp; |
| 1790 | 1882 | $flag = true; |
| 1883 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1884 | + $themeData = $temp + array($member => array()); |
|
| 1885 | + } else { |
|
| 1886 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1791 | 1887 | } |
| 1792 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1793 | - $themeData = $temp + array($member => array()); |
|
| 1794 | - else |
|
| 1795 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1796 | 1888 | |
| 1797 | 1889 | if (empty($flag)) |
| 1798 | 1890 | { |
@@ -1813,32 +1905,38 @@ discard block |
||
| 1813 | 1905 | foreach ($rows as $row) |
| 1814 | 1906 | { |
| 1815 | 1907 | // There are just things we shouldn't be able to change as members. |
| 1816 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
| 1817 | - continue; |
|
| 1908 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
| 1909 | + continue; |
|
| 1910 | + } |
|
| 1818 | 1911 | |
| 1819 | 1912 | // If this is the theme_dir of the default theme, store it. |
| 1820 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1821 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1913 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1914 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1915 | + } |
|
| 1822 | 1916 | |
| 1823 | 1917 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1824 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1825 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1918 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1919 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1920 | + } |
|
| 1826 | 1921 | } |
| 1827 | 1922 | $smcFunc['db_free_result']($result); |
| 1828 | 1923 | unset($rows); |
| 1829 | 1924 | |
| 1830 | - if (!empty($themeData[-1])) |
|
| 1831 | - foreach ($themeData[-1] as $k => $v) |
|
| 1925 | + if (!empty($themeData[-1])) { |
|
| 1926 | + foreach ($themeData[-1] as $k => $v) |
|
| 1832 | 1927 | { |
| 1833 | 1928 | if (!isset($themeData[$member][$k])) |
| 1834 | 1929 | $themeData[$member][$k] = $v; |
| 1930 | + } |
|
| 1835 | 1931 | } |
| 1836 | 1932 | |
| 1837 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1838 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1933 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1934 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1935 | + } |
|
| 1839 | 1936 | // Only if we didn't already load that part of the cache... |
| 1840 | - elseif (!isset($temp)) |
|
| 1841 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1937 | + elseif (!isset($temp)) { |
|
| 1938 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1939 | + } |
|
| 1842 | 1940 | } |
| 1843 | 1941 | |
| 1844 | 1942 | $settings = $themeData[0]; |
@@ -1855,17 +1953,20 @@ discard block |
||
| 1855 | 1953 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1856 | 1954 | |
| 1857 | 1955 | // Based on theme (if there is one). |
| 1858 | - if (!empty($settings['base_theme_dir'])) |
|
| 1859 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1956 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1957 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1958 | + } |
|
| 1860 | 1959 | |
| 1861 | 1960 | // Lastly the default theme. |
| 1862 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1863 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1961 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1962 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1963 | + } |
|
| 1864 | 1964 | } |
| 1865 | 1965 | |
| 1866 | 1966 | |
| 1867 | - if (!$initialize) |
|
| 1868 | - return; |
|
| 1967 | + if (!$initialize) { |
|
| 1968 | + return; |
|
| 1969 | + } |
|
| 1869 | 1970 | |
| 1870 | 1971 | // Check to see if we're forcing SSL |
| 1871 | 1972 | if (!empty($modSettings['force_ssl']) && empty($maintenance) && |
@@ -1886,8 +1987,9 @@ discard block |
||
| 1886 | 1987 | $detected_url = httpsOn() ? 'https://' : 'http://'; |
| 1887 | 1988 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1888 | 1989 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1889 | - if ($temp != '/') |
|
| 1890 | - $detected_url .= $temp; |
|
| 1990 | + if ($temp != '/') { |
|
| 1991 | + $detected_url .= $temp; |
|
| 1992 | + } |
|
| 1891 | 1993 | } |
| 1892 | 1994 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1893 | 1995 | { |
@@ -1899,8 +2001,9 @@ discard block |
||
| 1899 | 2001 | foreach ($aliases as $alias) |
| 1900 | 2002 | { |
| 1901 | 2003 | // Rip off all the boring parts, spaces, etc. |
| 1902 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1903 | - $do_fix = true; |
|
| 2004 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 2005 | + $do_fix = true; |
|
| 2006 | + } |
|
| 1904 | 2007 | } |
| 1905 | 2008 | } |
| 1906 | 2009 | |
@@ -1908,21 +2011,23 @@ discard block |
||
| 1908 | 2011 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1909 | 2012 | { |
| 1910 | 2013 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1911 | - if (empty($_GET)) |
|
| 1912 | - redirectexit('wwwRedirect'); |
|
| 1913 | - else |
|
| 2014 | + if (empty($_GET)) { |
|
| 2015 | + redirectexit('wwwRedirect'); |
|
| 2016 | + } else |
|
| 1914 | 2017 | { |
| 1915 | 2018 | $k = key($_GET); |
| 1916 | 2019 | $v = current($_GET); |
| 1917 | 2020 | |
| 1918 | - if ($k != 'wwwRedirect') |
|
| 1919 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 2021 | + if ($k != 'wwwRedirect') { |
|
| 2022 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 2023 | + } |
|
| 1920 | 2024 | } |
| 1921 | 2025 | } |
| 1922 | 2026 | |
| 1923 | 2027 | // #3 is just a check for SSL... |
| 1924 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1925 | - $do_fix = true; |
|
| 2028 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 2029 | + $do_fix = true; |
|
| 2030 | + } |
|
| 1926 | 2031 | |
| 1927 | 2032 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1928 | 2033 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1957,8 +2062,9 @@ discard block |
||
| 1957 | 2062 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1958 | 2063 | } |
| 1959 | 2064 | } |
| 1960 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1961 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2065 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2066 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2067 | + } |
|
| 1962 | 2068 | } |
| 1963 | 2069 | } |
| 1964 | 2070 | // Set up the contextual user array. |
@@ -1977,10 +2083,11 @@ discard block |
||
| 1977 | 2083 | 'email' => $user_info['email'], |
| 1978 | 2084 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1979 | 2085 | ); |
| 1980 | - if (!$context['user']['is_guest']) |
|
| 1981 | - $context['user']['name'] = $user_info['name']; |
|
| 1982 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1983 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2086 | + if (!$context['user']['is_guest']) { |
|
| 2087 | + $context['user']['name'] = $user_info['name']; |
|
| 2088 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2089 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2090 | + } |
|
| 1984 | 2091 | |
| 1985 | 2092 | // Determine the current smiley set. |
| 1986 | 2093 | $smiley_sets_known = explode(',', $modSettings['smiley_sets_known']); |
@@ -1994,8 +2101,7 @@ discard block |
||
| 1994 | 2101 | |
| 1995 | 2102 | // Determine global default smiley set extension |
| 1996 | 2103 | $context['user']['smiley_set_default_ext'] = $smiley_sets_exts[array_search($modSettings['smiley_sets_default'], $smiley_sets_known)]; |
| 1997 | - } |
|
| 1998 | - else |
|
| 2104 | + } else |
|
| 1999 | 2105 | { |
| 2000 | 2106 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
| 2001 | 2107 | $context['user'] = array( |
@@ -2029,18 +2135,24 @@ discard block |
||
| 2029 | 2135 | } |
| 2030 | 2136 | |
| 2031 | 2137 | // Some basic information... |
| 2032 | - if (!isset($context['html_headers'])) |
|
| 2033 | - $context['html_headers'] = ''; |
|
| 2034 | - if (!isset($context['javascript_files'])) |
|
| 2035 | - $context['javascript_files'] = array(); |
|
| 2036 | - if (!isset($context['css_files'])) |
|
| 2037 | - $context['css_files'] = array(); |
|
| 2038 | - if (!isset($context['css_header'])) |
|
| 2039 | - $context['css_header'] = array(); |
|
| 2040 | - if (!isset($context['javascript_inline'])) |
|
| 2041 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2042 | - if (!isset($context['javascript_vars'])) |
|
| 2043 | - $context['javascript_vars'] = array(); |
|
| 2138 | + if (!isset($context['html_headers'])) { |
|
| 2139 | + $context['html_headers'] = ''; |
|
| 2140 | + } |
|
| 2141 | + if (!isset($context['javascript_files'])) { |
|
| 2142 | + $context['javascript_files'] = array(); |
|
| 2143 | + } |
|
| 2144 | + if (!isset($context['css_files'])) { |
|
| 2145 | + $context['css_files'] = array(); |
|
| 2146 | + } |
|
| 2147 | + if (!isset($context['css_header'])) { |
|
| 2148 | + $context['css_header'] = array(); |
|
| 2149 | + } |
|
| 2150 | + if (!isset($context['javascript_inline'])) { |
|
| 2151 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2152 | + } |
|
| 2153 | + if (!isset($context['javascript_vars'])) { |
|
| 2154 | + $context['javascript_vars'] = array(); |
|
| 2155 | + } |
|
| 2044 | 2156 | |
| 2045 | 2157 | $context['login_url'] = $scripturl . '?action=login2'; |
| 2046 | 2158 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2052,16 +2164,18 @@ discard block |
||
| 2052 | 2164 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 2053 | 2165 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 2054 | 2166 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 2055 | - if (isset($modSettings['load_average'])) |
|
| 2056 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2167 | + if (isset($modSettings['load_average'])) { |
|
| 2168 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2169 | + } |
|
| 2057 | 2170 | |
| 2058 | 2171 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 2059 | 2172 | detectBrowser(); |
| 2060 | 2173 | |
| 2061 | 2174 | // Set the top level linktree up. |
| 2062 | 2175 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
| 2063 | - if (empty($context['linktree'])) |
|
| 2064 | - $context['linktree'] = array(); |
|
| 2176 | + if (empty($context['linktree'])) { |
|
| 2177 | + $context['linktree'] = array(); |
|
| 2178 | + } |
|
| 2065 | 2179 | array_unshift($context['linktree'], array( |
| 2066 | 2180 | 'url' => $scripturl, |
| 2067 | 2181 | 'name' => $context['forum_name_html_safe'] |
@@ -2070,8 +2184,9 @@ discard block |
||
| 2070 | 2184 | // This allows sticking some HTML on the page output - useful for controls. |
| 2071 | 2185 | $context['insert_after_template'] = ''; |
| 2072 | 2186 | |
| 2073 | - if (!isset($txt)) |
|
| 2074 | - $txt = array(); |
|
| 2187 | + if (!isset($txt)) { |
|
| 2188 | + $txt = array(); |
|
| 2189 | + } |
|
| 2075 | 2190 | |
| 2076 | 2191 | $simpleActions = array( |
| 2077 | 2192 | 'findmember', |
@@ -2117,9 +2232,10 @@ discard block |
||
| 2117 | 2232 | |
| 2118 | 2233 | // See if theres any extra param to check. |
| 2119 | 2234 | $requiresXML = false; |
| 2120 | - foreach ($extraParams as $key => $extra) |
|
| 2121 | - if (isset($_REQUEST[$extra])) |
|
| 2235 | + foreach ($extraParams as $key => $extra) { |
|
| 2236 | + if (isset($_REQUEST[$extra])) |
|
| 2122 | 2237 | $requiresXML = true; |
| 2238 | + } |
|
| 2123 | 2239 | |
| 2124 | 2240 | // Output is fully XML, so no need for the index template. |
| 2125 | 2241 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2134,37 +2250,39 @@ discard block |
||
| 2134 | 2250 | { |
| 2135 | 2251 | loadLanguage('index+Modifications'); |
| 2136 | 2252 | $context['template_layers'] = array(); |
| 2137 | - } |
|
| 2138 | - |
|
| 2139 | - else |
|
| 2253 | + } else |
|
| 2140 | 2254 | { |
| 2141 | 2255 | // Custom templates to load, or just default? |
| 2142 | - if (isset($settings['theme_templates'])) |
|
| 2143 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2144 | - else |
|
| 2145 | - $templates = array('index'); |
|
| 2256 | + if (isset($settings['theme_templates'])) { |
|
| 2257 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2258 | + } else { |
|
| 2259 | + $templates = array('index'); |
|
| 2260 | + } |
|
| 2146 | 2261 | |
| 2147 | 2262 | // Load each template... |
| 2148 | - foreach ($templates as $template) |
|
| 2149 | - loadTemplate($template); |
|
| 2263 | + foreach ($templates as $template) { |
|
| 2264 | + loadTemplate($template); |
|
| 2265 | + } |
|
| 2150 | 2266 | |
| 2151 | 2267 | // ...and attempt to load their associated language files. |
| 2152 | 2268 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2153 | 2269 | loadLanguage($required_files, '', false); |
| 2154 | 2270 | |
| 2155 | 2271 | // Custom template layers? |
| 2156 | - if (isset($settings['theme_layers'])) |
|
| 2157 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2158 | - else |
|
| 2159 | - $context['template_layers'] = array('html', 'body'); |
|
| 2272 | + if (isset($settings['theme_layers'])) { |
|
| 2273 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2274 | + } else { |
|
| 2275 | + $context['template_layers'] = array('html', 'body'); |
|
| 2276 | + } |
|
| 2160 | 2277 | } |
| 2161 | 2278 | |
| 2162 | 2279 | // Initialize the theme. |
| 2163 | 2280 | loadSubTemplate('init', 'ignore'); |
| 2164 | 2281 | |
| 2165 | 2282 | // Allow overriding the board wide time/number formats. |
| 2166 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2167 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2283 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2284 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2285 | + } |
|
| 2168 | 2286 | |
| 2169 | 2287 | // Set the character set from the template. |
| 2170 | 2288 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2172,12 +2290,14 @@ discard block |
||
| 2172 | 2290 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2173 | 2291 | |
| 2174 | 2292 | // Guests may still need a name. |
| 2175 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2176 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2293 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2294 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2295 | + } |
|
| 2177 | 2296 | |
| 2178 | 2297 | // Any theme-related strings that need to be loaded? |
| 2179 | - if (!empty($settings['require_theme_strings'])) |
|
| 2180 | - loadLanguage('ThemeStrings', '', false); |
|
| 2298 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2299 | + loadLanguage('ThemeStrings', '', false); |
|
| 2300 | + } |
|
| 2181 | 2301 | |
| 2182 | 2302 | // Make a special URL for the language. |
| 2183 | 2303 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2188,8 +2308,9 @@ discard block |
||
| 2188 | 2308 | // Here is my luvly Responsive CSS |
| 2189 | 2309 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive'); |
| 2190 | 2310 | |
| 2191 | - if ($context['right_to_left']) |
|
| 2192 | - loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
| 2311 | + if ($context['right_to_left']) { |
|
| 2312 | + loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
| 2313 | + } |
|
| 2193 | 2314 | |
| 2194 | 2315 | // We allow theme variants, because we're cool. |
| 2195 | 2316 | $context['theme_variant'] = ''; |
@@ -2197,14 +2318,17 @@ discard block |
||
| 2197 | 2318 | if (!empty($settings['theme_variants'])) |
| 2198 | 2319 | { |
| 2199 | 2320 | // Overriding - for previews and that ilk. |
| 2200 | - if (!empty($_REQUEST['variant'])) |
|
| 2201 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2321 | + if (!empty($_REQUEST['variant'])) { |
|
| 2322 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2323 | + } |
|
| 2202 | 2324 | // User selection? |
| 2203 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2204 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2325 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2326 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2327 | + } |
|
| 2205 | 2328 | // If not a user variant, select the default. |
| 2206 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2207 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2329 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2330 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2331 | + } |
|
| 2208 | 2332 | |
| 2209 | 2333 | // Do this to keep things easier in the templates. |
| 2210 | 2334 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2213,20 +2337,23 @@ discard block |
||
| 2213 | 2337 | if (!empty($context['theme_variant'])) |
| 2214 | 2338 | { |
| 2215 | 2339 | loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']); |
| 2216 | - if ($context['right_to_left']) |
|
| 2217 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
| 2340 | + if ($context['right_to_left']) { |
|
| 2341 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
| 2342 | + } |
|
| 2218 | 2343 | } |
| 2219 | 2344 | } |
| 2220 | 2345 | |
| 2221 | 2346 | // Let's be compatible with old themes! |
| 2222 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2223 | - $context['template_layers'] = array('main'); |
|
| 2347 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2348 | + $context['template_layers'] = array('main'); |
|
| 2349 | + } |
|
| 2224 | 2350 | |
| 2225 | 2351 | $context['tabindex'] = 1; |
| 2226 | 2352 | |
| 2227 | 2353 | // Compatibility. |
| 2228 | - if (!isset($settings['theme_version'])) |
|
| 2229 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2354 | + if (!isset($settings['theme_version'])) { |
|
| 2355 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2356 | + } |
|
| 2230 | 2357 | |
| 2231 | 2358 | // Default JS variables for use in every theme |
| 2232 | 2359 | $context['javascript_vars'] = array( |
@@ -2249,18 +2376,18 @@ discard block |
||
| 2249 | 2376 | ); |
| 2250 | 2377 | |
| 2251 | 2378 | // Add the JQuery library to the list of files to load. |
| 2252 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2253 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2254 | - |
|
| 2255 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2256 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2257 | - |
|
| 2258 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2259 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2379 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2380 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2381 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2382 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2383 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2384 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2385 | + } |
|
| 2260 | 2386 | |
| 2261 | 2387 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2262 | - else |
|
| 2263 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2388 | + else { |
|
| 2389 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2390 | + } |
|
| 2264 | 2391 | |
| 2265 | 2392 | // Queue our JQuery plugins! |
| 2266 | 2393 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2283,12 +2410,12 @@ discard block |
||
| 2283 | 2410 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2284 | 2411 | |
| 2285 | 2412 | // What to do, what to do?! |
| 2286 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2287 | - AutoTask(); |
|
| 2288 | - else |
|
| 2289 | - ReduceMailQueue(); |
|
| 2290 | - } |
|
| 2291 | - else |
|
| 2413 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2414 | + AutoTask(); |
|
| 2415 | + } else { |
|
| 2416 | + ReduceMailQueue(); |
|
| 2417 | + } |
|
| 2418 | + } else |
|
| 2292 | 2419 | { |
| 2293 | 2420 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2294 | 2421 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2339,8 +2466,9 @@ discard block |
||
| 2339 | 2466 | foreach ($theme_includes as $include) |
| 2340 | 2467 | { |
| 2341 | 2468 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2342 | - if (file_exists($include)) |
|
| 2343 | - require_once($include); |
|
| 2469 | + if (file_exists($include)) { |
|
| 2470 | + require_once($include); |
|
| 2471 | + } |
|
| 2344 | 2472 | } |
| 2345 | 2473 | } |
| 2346 | 2474 | |
@@ -2370,16 +2498,19 @@ discard block |
||
| 2370 | 2498 | // Do any style sheets first, cause we're easy with those. |
| 2371 | 2499 | if (!empty($style_sheets)) |
| 2372 | 2500 | { |
| 2373 | - if (!is_array($style_sheets)) |
|
| 2374 | - $style_sheets = array($style_sheets); |
|
| 2501 | + if (!is_array($style_sheets)) { |
|
| 2502 | + $style_sheets = array($style_sheets); |
|
| 2503 | + } |
|
| 2375 | 2504 | |
| 2376 | - foreach ($style_sheets as $sheet) |
|
| 2377 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2505 | + foreach ($style_sheets as $sheet) { |
|
| 2506 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2507 | + } |
|
| 2378 | 2508 | } |
| 2379 | 2509 | |
| 2380 | 2510 | // No template to load? |
| 2381 | - if ($template_name === false) |
|
| 2382 | - return true; |
|
| 2511 | + if ($template_name === false) { |
|
| 2512 | + return true; |
|
| 2513 | + } |
|
| 2383 | 2514 | |
| 2384 | 2515 | $loaded = false; |
| 2385 | 2516 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2394,12 +2525,14 @@ discard block |
||
| 2394 | 2525 | |
| 2395 | 2526 | if ($loaded) |
| 2396 | 2527 | { |
| 2397 | - if ($db_show_debug === true) |
|
| 2398 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2528 | + if ($db_show_debug === true) { |
|
| 2529 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2530 | + } |
|
| 2399 | 2531 | |
| 2400 | 2532 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2401 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2402 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2533 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2534 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2535 | + } |
|
| 2403 | 2536 | } |
| 2404 | 2537 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2405 | 2538 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2419,13 +2552,14 @@ discard block |
||
| 2419 | 2552 | loadTemplate($template_name); |
| 2420 | 2553 | } |
| 2421 | 2554 | // Cause an error otherwise. |
| 2422 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2423 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2424 | - elseif ($fatal) |
|
| 2425 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2426 | - else |
|
| 2427 | - return false; |
|
| 2428 | -} |
|
| 2555 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2556 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2557 | + } elseif ($fatal) { |
|
| 2558 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2559 | + } else { |
|
| 2560 | + return false; |
|
| 2561 | + } |
|
| 2562 | + } |
|
| 2429 | 2563 | |
| 2430 | 2564 | /** |
| 2431 | 2565 | * Load a sub-template. |
@@ -2443,17 +2577,19 @@ discard block |
||
| 2443 | 2577 | { |
| 2444 | 2578 | global $context, $txt, $db_show_debug; |
| 2445 | 2579 | |
| 2446 | - if ($db_show_debug === true) |
|
| 2447 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2580 | + if ($db_show_debug === true) { |
|
| 2581 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2582 | + } |
|
| 2448 | 2583 | |
| 2449 | 2584 | // Figure out what the template function is named. |
| 2450 | 2585 | $theme_function = 'template_' . $sub_template_name; |
| 2451 | - if (function_exists($theme_function)) |
|
| 2452 | - $theme_function(); |
|
| 2453 | - elseif ($fatal === false) |
|
| 2454 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2455 | - elseif ($fatal !== 'ignore') |
|
| 2456 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2586 | + if (function_exists($theme_function)) { |
|
| 2587 | + $theme_function(); |
|
| 2588 | + } elseif ($fatal === false) { |
|
| 2589 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2590 | + } elseif ($fatal !== 'ignore') { |
|
| 2591 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2592 | + } |
|
| 2457 | 2593 | |
| 2458 | 2594 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2459 | 2595 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2483,8 +2619,9 @@ discard block |
||
| 2483 | 2619 | { |
| 2484 | 2620 | global $settings, $context, $modSettings; |
| 2485 | 2621 | |
| 2486 | - if (empty($context['css_files_order'])) |
|
| 2487 | - $context['css_files_order'] = array(); |
|
| 2622 | + if (empty($context['css_files_order'])) { |
|
| 2623 | + $context['css_files_order'] = array(); |
|
| 2624 | + } |
|
| 2488 | 2625 | |
| 2489 | 2626 | $params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : ''); |
| 2490 | 2627 | $params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false; |
@@ -2495,8 +2632,9 @@ discard block |
||
| 2495 | 2632 | $params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000; |
| 2496 | 2633 | |
| 2497 | 2634 | // If this is an external file, automatically set this to false. |
| 2498 | - if (!empty($params['external'])) |
|
| 2499 | - $params['minimize'] = false; |
|
| 2635 | + if (!empty($params['external'])) { |
|
| 2636 | + $params['minimize'] = false; |
|
| 2637 | + } |
|
| 2500 | 2638 | |
| 2501 | 2639 | // Account for shorthand like admin.css?alp21 filenames |
| 2502 | 2640 | $has_seed = strpos($fileName, '.css?'); |
@@ -2513,16 +2651,12 @@ discard block |
||
| 2513 | 2651 | { |
| 2514 | 2652 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2515 | 2653 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2516 | - } |
|
| 2517 | - |
|
| 2518 | - else |
|
| 2654 | + } else |
|
| 2519 | 2655 | { |
| 2520 | 2656 | $fileUrl = false; |
| 2521 | 2657 | $filePath = false; |
| 2522 | 2658 | } |
| 2523 | - } |
|
| 2524 | - |
|
| 2525 | - else |
|
| 2659 | + } else |
|
| 2526 | 2660 | { |
| 2527 | 2661 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2528 | 2662 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2540,16 +2674,18 @@ discard block |
||
| 2540 | 2674 | if (!empty($fileName)) |
| 2541 | 2675 | { |
| 2542 | 2676 | // find a free number/position |
| 2543 | - while (isset($context['css_files_order'][$params['order_pos']])) |
|
| 2544 | - $params['order_pos']++; |
|
| 2677 | + while (isset($context['css_files_order'][$params['order_pos']])) { |
|
| 2678 | + $params['order_pos']++; |
|
| 2679 | + } |
|
| 2545 | 2680 | $context['css_files_order'][$params['order_pos']] = $id; |
| 2546 | 2681 | |
| 2547 | 2682 | $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
| 2548 | 2683 | } |
| 2549 | 2684 | |
| 2550 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2551 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2552 | -} |
|
| 2685 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2686 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2687 | + } |
|
| 2688 | + } |
|
| 2553 | 2689 | |
| 2554 | 2690 | /** |
| 2555 | 2691 | * Add a block of inline css code to be executed later |
@@ -2566,8 +2702,9 @@ discard block |
||
| 2566 | 2702 | global $context; |
| 2567 | 2703 | |
| 2568 | 2704 | // Gotta add something... |
| 2569 | - if (empty($css)) |
|
| 2570 | - return false; |
|
| 2705 | + if (empty($css)) { |
|
| 2706 | + return false; |
|
| 2707 | + } |
|
| 2571 | 2708 | |
| 2572 | 2709 | $context['css_header'][] = $css; |
| 2573 | 2710 | } |
@@ -2603,8 +2740,9 @@ discard block |
||
| 2603 | 2740 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2604 | 2741 | |
| 2605 | 2742 | // If this is an external file, automatically set this to false. |
| 2606 | - if (!empty($params['external'])) |
|
| 2607 | - $params['minimize'] = false; |
|
| 2743 | + if (!empty($params['external'])) { |
|
| 2744 | + $params['minimize'] = false; |
|
| 2745 | + } |
|
| 2608 | 2746 | |
| 2609 | 2747 | // Account for shorthand like admin.js?alp21 filenames |
| 2610 | 2748 | $has_seed = strpos($fileName, '.js?'); |
@@ -2621,16 +2759,12 @@ discard block |
||
| 2621 | 2759 | { |
| 2622 | 2760 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2623 | 2761 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2624 | - } |
|
| 2625 | - |
|
| 2626 | - else |
|
| 2762 | + } else |
|
| 2627 | 2763 | { |
| 2628 | 2764 | $fileUrl = false; |
| 2629 | 2765 | $filePath = false; |
| 2630 | 2766 | } |
| 2631 | - } |
|
| 2632 | - |
|
| 2633 | - else |
|
| 2767 | + } else |
|
| 2634 | 2768 | { |
| 2635 | 2769 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2636 | 2770 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2645,9 +2779,10 @@ discard block |
||
| 2645 | 2779 | } |
| 2646 | 2780 | |
| 2647 | 2781 | // Add it to the array for use in the template |
| 2648 | - if (!empty($fileName)) |
|
| 2649 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2650 | -} |
|
| 2782 | + if (!empty($fileName)) { |
|
| 2783 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2784 | + } |
|
| 2785 | + } |
|
| 2651 | 2786 | |
| 2652 | 2787 | /** |
| 2653 | 2788 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2661,9 +2796,10 @@ discard block |
||
| 2661 | 2796 | { |
| 2662 | 2797 | global $context; |
| 2663 | 2798 | |
| 2664 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2665 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2666 | -} |
|
| 2799 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2800 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2801 | + } |
|
| 2802 | + } |
|
| 2667 | 2803 | |
| 2668 | 2804 | /** |
| 2669 | 2805 | * Add a block of inline Javascript code to be executed later |
@@ -2680,8 +2816,9 @@ discard block |
||
| 2680 | 2816 | { |
| 2681 | 2817 | global $context; |
| 2682 | 2818 | |
| 2683 | - if (empty($javascript)) |
|
| 2684 | - return false; |
|
| 2819 | + if (empty($javascript)) { |
|
| 2820 | + return false; |
|
| 2821 | + } |
|
| 2685 | 2822 | |
| 2686 | 2823 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2687 | 2824 | } |
@@ -2702,15 +2839,18 @@ discard block |
||
| 2702 | 2839 | static $already_loaded = array(); |
| 2703 | 2840 | |
| 2704 | 2841 | // Default to the user's language. |
| 2705 | - if ($lang == '') |
|
| 2706 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2842 | + if ($lang == '') { |
|
| 2843 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2844 | + } |
|
| 2707 | 2845 | |
| 2708 | 2846 | // Do we want the English version of language file as fallback? |
| 2709 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2710 | - loadLanguage($template_name, 'english', false); |
|
| 2847 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2848 | + loadLanguage($template_name, 'english', false); |
|
| 2849 | + } |
|
| 2711 | 2850 | |
| 2712 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2713 | - return $lang; |
|
| 2851 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2852 | + return $lang; |
|
| 2853 | + } |
|
| 2714 | 2854 | |
| 2715 | 2855 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2716 | 2856 | if (empty($settings['default_theme_dir'])) |
@@ -2721,8 +2861,9 @@ discard block |
||
| 2721 | 2861 | |
| 2722 | 2862 | // What theme are we in? |
| 2723 | 2863 | $theme_name = basename($settings['theme_url']); |
| 2724 | - if (empty($theme_name)) |
|
| 2725 | - $theme_name = 'unknown'; |
|
| 2864 | + if (empty($theme_name)) { |
|
| 2865 | + $theme_name = 'unknown'; |
|
| 2866 | + } |
|
| 2726 | 2867 | |
| 2727 | 2868 | // For each file open it up and write it out! |
| 2728 | 2869 | foreach (explode('+', $template_name) as $template) |
@@ -2764,8 +2905,9 @@ discard block |
||
| 2764 | 2905 | $found = true; |
| 2765 | 2906 | |
| 2766 | 2907 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 2767 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
| 2768 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2908 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
| 2909 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2910 | + } |
|
| 2769 | 2911 | |
| 2770 | 2912 | break; |
| 2771 | 2913 | } |
@@ -2805,8 +2947,9 @@ discard block |
||
| 2805 | 2947 | } |
| 2806 | 2948 | |
| 2807 | 2949 | // Keep track of what we're up to soldier. |
| 2808 | - if ($db_show_debug === true) |
|
| 2809 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2950 | + if ($db_show_debug === true) { |
|
| 2951 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2952 | + } |
|
| 2810 | 2953 | |
| 2811 | 2954 | // Remember what we have loaded, and in which language. |
| 2812 | 2955 | $already_loaded[$template_name] = $lang; |
@@ -2852,8 +2995,9 @@ discard block |
||
| 2852 | 2995 | ) |
| 2853 | 2996 | ); |
| 2854 | 2997 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2855 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2856 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2998 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2999 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 3000 | + } |
|
| 2857 | 3001 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2858 | 3002 | { |
| 2859 | 3003 | if (!isset($boards[$row['id_board']])) |
@@ -2870,8 +3014,8 @@ discard block |
||
| 2870 | 3014 | ); |
| 2871 | 3015 | } |
| 2872 | 3016 | // If a moderator exists for this board, add that moderator for all children too. |
| 2873 | - if (!empty($row['id_moderator'])) |
|
| 2874 | - foreach ($boards as $id => $dummy) |
|
| 3017 | + if (!empty($row['id_moderator'])) { |
|
| 3018 | + foreach ($boards as $id => $dummy) |
|
| 2875 | 3019 | { |
| 2876 | 3020 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2877 | 3021 | 'id' => $row['id_moderator'], |
@@ -2879,11 +3023,12 @@ discard block |
||
| 2879 | 3023 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2880 | 3024 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2881 | 3025 | ); |
| 3026 | + } |
|
| 2882 | 3027 | } |
| 2883 | 3028 | |
| 2884 | 3029 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2885 | - if (!empty($row['id_moderator_group'])) |
|
| 2886 | - foreach ($boards as $id => $dummy) |
|
| 3030 | + if (!empty($row['id_moderator_group'])) { |
|
| 3031 | + foreach ($boards as $id => $dummy) |
|
| 2887 | 3032 | { |
| 2888 | 3033 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2889 | 3034 | 'id' => $row['id_moderator_group'], |
@@ -2891,6 +3036,7 @@ discard block |
||
| 2891 | 3036 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2892 | 3037 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2893 | 3038 | ); |
| 3039 | + } |
|
| 2894 | 3040 | } |
| 2895 | 3041 | } |
| 2896 | 3042 | $smcFunc['db_free_result']($result); |
@@ -2917,23 +3063,27 @@ discard block |
||
| 2917 | 3063 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2918 | 3064 | { |
| 2919 | 3065 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2920 | - if (empty($smcFunc['ucwords'])) |
|
| 2921 | - reloadSettings(); |
|
| 3066 | + if (empty($smcFunc['ucwords'])) { |
|
| 3067 | + reloadSettings(); |
|
| 3068 | + } |
|
| 2922 | 3069 | |
| 2923 | 3070 | // If we don't have our theme information yet, let's get it. |
| 2924 | - if (empty($settings['default_theme_dir'])) |
|
| 2925 | - loadTheme(0, false); |
|
| 3071 | + if (empty($settings['default_theme_dir'])) { |
|
| 3072 | + loadTheme(0, false); |
|
| 3073 | + } |
|
| 2926 | 3074 | |
| 2927 | 3075 | // Default language directories to try. |
| 2928 | 3076 | $language_directories = array( |
| 2929 | 3077 | $settings['default_theme_dir'] . '/languages', |
| 2930 | 3078 | ); |
| 2931 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2932 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 3079 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 3080 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 3081 | + } |
|
| 2933 | 3082 | |
| 2934 | 3083 | // We possibly have a base theme directory. |
| 2935 | - if (!empty($settings['base_theme_dir'])) |
|
| 2936 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 3084 | + if (!empty($settings['base_theme_dir'])) { |
|
| 3085 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 3086 | + } |
|
| 2937 | 3087 | |
| 2938 | 3088 | // Remove any duplicates. |
| 2939 | 3089 | $language_directories = array_unique($language_directories); |
@@ -2947,20 +3097,21 @@ discard block |
||
| 2947 | 3097 | foreach ($language_directories as $language_dir) |
| 2948 | 3098 | { |
| 2949 | 3099 | // Can't look in here... doesn't exist! |
| 2950 | - if (!file_exists($language_dir)) |
|
| 2951 | - continue; |
|
| 3100 | + if (!file_exists($language_dir)) { |
|
| 3101 | + continue; |
|
| 3102 | + } |
|
| 2952 | 3103 | |
| 2953 | 3104 | $dir = dir($language_dir); |
| 2954 | 3105 | while ($entry = $dir->read()) |
| 2955 | 3106 | { |
| 2956 | 3107 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 2957 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
| 2958 | - continue; |
|
| 2959 | - |
|
| 2960 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2961 | - $langName = $langList[$matches[1]]; |
|
| 3108 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
| 3109 | + continue; |
|
| 3110 | + } |
|
| 2962 | 3111 | |
| 2963 | - else |
|
| 3112 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 3113 | + $langName = $langList[$matches[1]]; |
|
| 3114 | + } else |
|
| 2964 | 3115 | { |
| 2965 | 3116 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2966 | 3117 | |
@@ -3001,12 +3152,14 @@ discard block |
||
| 3001 | 3152 | } |
| 3002 | 3153 | |
| 3003 | 3154 | // Do we need to store the lang list? |
| 3004 | - if (empty($langList)) |
|
| 3005 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3155 | + if (empty($langList)) { |
|
| 3156 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3157 | + } |
|
| 3006 | 3158 | |
| 3007 | 3159 | // Let's cash in on this deal. |
| 3008 | - if (!empty($modSettings['cache_enable'])) |
|
| 3009 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3160 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3161 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3162 | + } |
|
| 3010 | 3163 | } |
| 3011 | 3164 | |
| 3012 | 3165 | return $context['languages']; |
@@ -3029,8 +3182,9 @@ discard block |
||
| 3029 | 3182 | global $modSettings, $options, $txt; |
| 3030 | 3183 | static $censor_vulgar = null, $censor_proper; |
| 3031 | 3184 | |
| 3032 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 3033 | - return $text; |
|
| 3185 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3186 | + return $text; |
|
| 3187 | + } |
|
| 3034 | 3188 | |
| 3035 | 3189 | // If they haven't yet been loaded, load them. |
| 3036 | 3190 | if ($censor_vulgar == null) |
@@ -3061,9 +3215,9 @@ discard block |
||
| 3061 | 3215 | { |
| 3062 | 3216 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 3063 | 3217 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3218 | + } else { |
|
| 3219 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 3064 | 3220 | } |
| 3065 | - else |
|
| 3066 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 3067 | 3221 | |
| 3068 | 3222 | return $text; |
| 3069 | 3223 | } |
@@ -3089,30 +3243,35 @@ discard block |
||
| 3089 | 3243 | @ini_set('track_errors', '1'); |
| 3090 | 3244 | |
| 3091 | 3245 | // Don't include the file more than once, if $once is true. |
| 3092 | - if ($once && in_array($filename, $templates)) |
|
| 3093 | - return; |
|
| 3246 | + if ($once && in_array($filename, $templates)) { |
|
| 3247 | + return; |
|
| 3248 | + } |
|
| 3094 | 3249 | // Add this file to the include list, whether $once is true or not. |
| 3095 | - else |
|
| 3096 | - $templates[] = $filename; |
|
| 3250 | + else { |
|
| 3251 | + $templates[] = $filename; |
|
| 3252 | + } |
|
| 3097 | 3253 | |
| 3098 | 3254 | |
| 3099 | 3255 | $file_found = file_exists($filename); |
| 3100 | 3256 | |
| 3101 | - if ($once && $file_found) |
|
| 3102 | - require_once($filename); |
|
| 3103 | - elseif ($file_found) |
|
| 3104 | - require($filename); |
|
| 3257 | + if ($once && $file_found) { |
|
| 3258 | + require_once($filename); |
|
| 3259 | + } elseif ($file_found) { |
|
| 3260 | + require($filename); |
|
| 3261 | + } |
|
| 3105 | 3262 | |
| 3106 | 3263 | if ($file_found !== true) |
| 3107 | 3264 | { |
| 3108 | 3265 | ob_end_clean(); |
| 3109 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3110 | - @ob_start('ob_gzhandler'); |
|
| 3111 | - else |
|
| 3112 | - ob_start(); |
|
| 3266 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3267 | + @ob_start('ob_gzhandler'); |
|
| 3268 | + } else { |
|
| 3269 | + ob_start(); |
|
| 3270 | + } |
|
| 3113 | 3271 | |
| 3114 | - if (isset($_GET['debug'])) |
|
| 3115 | - header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3272 | + if (isset($_GET['debug'])) { |
|
| 3273 | + header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3274 | + } |
|
| 3116 | 3275 | |
| 3117 | 3276 | // Don't cache error pages!! |
| 3118 | 3277 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3131,12 +3290,13 @@ discard block |
||
| 3131 | 3290 | echo '<!DOCTYPE html> |
| 3132 | 3291 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3133 | 3292 | <head>'; |
| 3134 | - if (isset($context['character_set'])) |
|
| 3135 | - echo ' |
|
| 3293 | + if (isset($context['character_set'])) { |
|
| 3294 | + echo ' |
|
| 3136 | 3295 | <meta charset="', $context['character_set'], '">'; |
| 3296 | + } |
|
| 3137 | 3297 | |
| 3138 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3139 | - echo ' |
|
| 3298 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3299 | + echo ' |
|
| 3140 | 3300 | <title>', $mtitle, '</title> |
| 3141 | 3301 | </head> |
| 3142 | 3302 | <body> |
@@ -3144,8 +3304,8 @@ discard block |
||
| 3144 | 3304 | ', $mmessage, ' |
| 3145 | 3305 | </body> |
| 3146 | 3306 | </html>'; |
| 3147 | - elseif (!allowedTo('admin_forum')) |
|
| 3148 | - echo ' |
|
| 3307 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3308 | + echo ' |
|
| 3149 | 3309 | <title>', $txt['template_parse_error'], '</title> |
| 3150 | 3310 | </head> |
| 3151 | 3311 | <body> |
@@ -3153,14 +3313,16 @@ discard block |
||
| 3153 | 3313 | ', $txt['template_parse_error_message'], ' |
| 3154 | 3314 | </body> |
| 3155 | 3315 | </html>'; |
| 3156 | - else |
|
| 3316 | + } else |
|
| 3157 | 3317 | { |
| 3158 | 3318 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3159 | 3319 | $error_array = error_get_last(); |
| 3160 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
| 3161 | - $error = $error_array['message']; |
|
| 3162 | - if (empty($error)) |
|
| 3163 | - $error = $txt['template_parse_errmsg']; |
|
| 3320 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
| 3321 | + $error = $error_array['message']; |
|
| 3322 | + } |
|
| 3323 | + if (empty($error)) { |
|
| 3324 | + $error = $txt['template_parse_errmsg']; |
|
| 3325 | + } |
|
| 3164 | 3326 | |
| 3165 | 3327 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3166 | 3328 | |
@@ -3171,11 +3333,12 @@ discard block |
||
| 3171 | 3333 | <h3>', $txt['template_parse_error'], '</h3> |
| 3172 | 3334 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3173 | 3335 | |
| 3174 | - if (!empty($error)) |
|
| 3175 | - echo ' |
|
| 3336 | + if (!empty($error)) { |
|
| 3337 | + echo ' |
|
| 3176 | 3338 | <hr> |
| 3177 | 3339 | |
| 3178 | 3340 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3341 | + } |
|
| 3179 | 3342 | |
| 3180 | 3343 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3181 | 3344 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3185,10 +3348,11 @@ discard block |
||
| 3185 | 3348 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3186 | 3349 | |
| 3187 | 3350 | // Fix the PHP code stuff... |
| 3188 | - if (!isBrowser('gecko')) |
|
| 3189 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3190 | - else |
|
| 3191 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3351 | + if (!isBrowser('gecko')) { |
|
| 3352 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3353 | + } else { |
|
| 3354 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3355 | + } |
|
| 3192 | 3356 | |
| 3193 | 3357 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3194 | 3358 | $j = -1; |
@@ -3196,8 +3360,9 @@ discard block |
||
| 3196 | 3360 | { |
| 3197 | 3361 | $j++; |
| 3198 | 3362 | |
| 3199 | - if (substr_count($line, '<br>') == 0) |
|
| 3200 | - continue; |
|
| 3363 | + if (substr_count($line, '<br>') == 0) { |
|
| 3364 | + continue; |
|
| 3365 | + } |
|
| 3201 | 3366 | |
| 3202 | 3367 | $n = substr_count($line, '<br>'); |
| 3203 | 3368 | for ($i = 0; $i < $n; $i++) |
@@ -3216,38 +3381,42 @@ discard block |
||
| 3216 | 3381 | // Figure out what the color coding was before... |
| 3217 | 3382 | $line = max($match[1] - 9, 1); |
| 3218 | 3383 | $last_line = ''; |
| 3219 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3220 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3384 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3385 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3221 | 3386 | { |
| 3222 | 3387 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3223 | 3388 | $last_line = $color_match[1]; |
| 3389 | + } |
|
| 3224 | 3390 | break; |
| 3225 | 3391 | } |
| 3226 | 3392 | |
| 3227 | 3393 | // Show the relevant lines... |
| 3228 | 3394 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3229 | 3395 | { |
| 3230 | - if ($line == $match[1]) |
|
| 3231 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3396 | + if ($line == $match[1]) { |
|
| 3397 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3398 | + } |
|
| 3232 | 3399 | |
| 3233 | 3400 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3234 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3235 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3401 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3402 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3403 | + } |
|
| 3236 | 3404 | |
| 3237 | 3405 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3238 | 3406 | { |
| 3239 | 3407 | $last_line = $color_match[1]; |
| 3240 | 3408 | echo '</', substr($last_line, 1, 4), '>'; |
| 3409 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3410 | + $last_line = ''; |
|
| 3411 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3412 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3241 | 3413 | } |
| 3242 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3243 | - $last_line = ''; |
|
| 3244 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3245 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3246 | 3414 | |
| 3247 | - if ($line == $match[1]) |
|
| 3248 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3249 | - else |
|
| 3250 | - echo "\n"; |
|
| 3415 | + if ($line == $match[1]) { |
|
| 3416 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3417 | + } else { |
|
| 3418 | + echo "\n"; |
|
| 3419 | + } |
|
| 3251 | 3420 | } |
| 3252 | 3421 | |
| 3253 | 3422 | echo '</pre></div>'; |
@@ -3271,8 +3440,9 @@ discard block |
||
| 3271 | 3440 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port, $db_mb4; |
| 3272 | 3441 | |
| 3273 | 3442 | // Figure out what type of database we are using. |
| 3274 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3275 | - $db_type = 'mysql'; |
|
| 3443 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3444 | + $db_type = 'mysql'; |
|
| 3445 | + } |
|
| 3276 | 3446 | |
| 3277 | 3447 | // Load the file for the database. |
| 3278 | 3448 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3280,11 +3450,13 @@ discard block |
||
| 3280 | 3450 | $db_options = array(); |
| 3281 | 3451 | |
| 3282 | 3452 | // Add in the port if needed |
| 3283 | - if (!empty($db_port)) |
|
| 3284 | - $db_options['port'] = $db_port; |
|
| 3453 | + if (!empty($db_port)) { |
|
| 3454 | + $db_options['port'] = $db_port; |
|
| 3455 | + } |
|
| 3285 | 3456 | |
| 3286 | - if (!empty($db_mb4)) |
|
| 3287 | - $db_options['db_mb4'] = $db_mb4; |
|
| 3457 | + if (!empty($db_mb4)) { |
|
| 3458 | + $db_options['db_mb4'] = $db_mb4; |
|
| 3459 | + } |
|
| 3288 | 3460 | |
| 3289 | 3461 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
| 3290 | 3462 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3303,13 +3475,15 @@ discard block |
||
| 3303 | 3475 | } |
| 3304 | 3476 | |
| 3305 | 3477 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3306 | - if (!$db_connection) |
|
| 3307 | - display_db_error(); |
|
| 3478 | + if (!$db_connection) { |
|
| 3479 | + display_db_error(); |
|
| 3480 | + } |
|
| 3308 | 3481 | |
| 3309 | 3482 | // If in SSI mode fix up the prefix. |
| 3310 | - if (SMF == 'SSI') |
|
| 3311 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3312 | -} |
|
| 3483 | + if (SMF == 'SSI') { |
|
| 3484 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3485 | + } |
|
| 3486 | + } |
|
| 3313 | 3487 | |
| 3314 | 3488 | /** |
| 3315 | 3489 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3323,10 +3497,11 @@ discard block |
||
| 3323 | 3497 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3324 | 3498 | |
| 3325 | 3499 | // Not overriding this and we have a cacheAPI, send it back. |
| 3326 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3327 | - return $cacheAPI; |
|
| 3328 | - elseif (is_null($cacheAPI)) |
|
| 3329 | - $cacheAPI = false; |
|
| 3500 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3501 | + return $cacheAPI; |
|
| 3502 | + } elseif (is_null($cacheAPI)) { |
|
| 3503 | + $cacheAPI = false; |
|
| 3504 | + } |
|
| 3330 | 3505 | |
| 3331 | 3506 | // Make sure our class is in session. |
| 3332 | 3507 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3347,8 +3522,9 @@ discard block |
||
| 3347 | 3522 | if (!$testAPI->isSupported()) |
| 3348 | 3523 | { |
| 3349 | 3524 | // Can we save ourselves? |
| 3350 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3351 | - return loadCacheAccelerator(null, false); |
|
| 3525 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3526 | + return loadCacheAccelerator(null, false); |
|
| 3527 | + } |
|
| 3352 | 3528 | return false; |
| 3353 | 3529 | } |
| 3354 | 3530 | |
@@ -3360,9 +3536,9 @@ discard block |
||
| 3360 | 3536 | { |
| 3361 | 3537 | $cacheAPI = $testAPI; |
| 3362 | 3538 | return $cacheAPI; |
| 3539 | + } else { |
|
| 3540 | + return $testAPI; |
|
| 3363 | 3541 | } |
| 3364 | - else |
|
| 3365 | - return $testAPI; |
|
| 3366 | 3542 | } |
| 3367 | 3543 | } |
| 3368 | 3544 | |
@@ -3382,8 +3558,9 @@ discard block |
||
| 3382 | 3558 | |
| 3383 | 3559 | // @todo Why are we doing this if caching is disabled? |
| 3384 | 3560 | |
| 3385 | - if (function_exists('call_integration_hook')) |
|
| 3386 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3561 | + if (function_exists('call_integration_hook')) { |
|
| 3562 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3563 | + } |
|
| 3387 | 3564 | |
| 3388 | 3565 | /* Refresh the cache if either: |
| 3389 | 3566 | 1. Caching is disabled. |
@@ -3397,16 +3574,19 @@ discard block |
||
| 3397 | 3574 | require_once($sourcedir . '/' . $file); |
| 3398 | 3575 | $cache_block = call_user_func_array($function, $params); |
| 3399 | 3576 | |
| 3400 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3401 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3577 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3578 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3579 | + } |
|
| 3402 | 3580 | } |
| 3403 | 3581 | |
| 3404 | 3582 | // Some cached data may need a freshening up after retrieval. |
| 3405 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3406 | - eval($cache_block['post_retri_eval']); |
|
| 3583 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3584 | + eval($cache_block['post_retri_eval']); |
|
| 3585 | + } |
|
| 3407 | 3586 | |
| 3408 | - if (function_exists('call_integration_hook')) |
|
| 3409 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3587 | + if (function_exists('call_integration_hook')) { |
|
| 3588 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3589 | + } |
|
| 3410 | 3590 | |
| 3411 | 3591 | return $cache_block['data']; |
| 3412 | 3592 | } |
@@ -3433,8 +3613,9 @@ discard block |
||
| 3433 | 3613 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3434 | 3614 | global $cache_hits, $cache_count, $db_show_debug; |
| 3435 | 3615 | |
| 3436 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3437 | - return; |
|
| 3616 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3617 | + return; |
|
| 3618 | + } |
|
| 3438 | 3619 | |
| 3439 | 3620 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3440 | 3621 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3447,12 +3628,14 @@ discard block |
||
| 3447 | 3628 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
| 3448 | 3629 | $cacheAPI->putData($key, $value, $ttl); |
| 3449 | 3630 | |
| 3450 | - if (function_exists('call_integration_hook')) |
|
| 3451 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3631 | + if (function_exists('call_integration_hook')) { |
|
| 3632 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3633 | + } |
|
| 3452 | 3634 | |
| 3453 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3454 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3455 | -} |
|
| 3635 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3636 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3637 | + } |
|
| 3638 | + } |
|
| 3456 | 3639 | |
| 3457 | 3640 | /** |
| 3458 | 3641 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3468,8 +3651,9 @@ discard block |
||
| 3468 | 3651 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3469 | 3652 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3470 | 3653 | |
| 3471 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3472 | - return; |
|
| 3654 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3655 | + return; |
|
| 3656 | + } |
|
| 3473 | 3657 | |
| 3474 | 3658 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3475 | 3659 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3489,16 +3673,18 @@ discard block |
||
| 3489 | 3673 | |
| 3490 | 3674 | if (empty($value)) |
| 3491 | 3675 | { |
| 3492 | - if (!is_array($cache_misses)) |
|
| 3493 | - $cache_misses = array(); |
|
| 3676 | + if (!is_array($cache_misses)) { |
|
| 3677 | + $cache_misses = array(); |
|
| 3678 | + } |
|
| 3494 | 3679 | |
| 3495 | 3680 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3496 | 3681 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3497 | 3682 | } |
| 3498 | 3683 | } |
| 3499 | 3684 | |
| 3500 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3501 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3685 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3686 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3687 | + } |
|
| 3502 | 3688 | |
| 3503 | 3689 | return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
| 3504 | 3690 | } |
@@ -3520,8 +3706,9 @@ discard block |
||
| 3520 | 3706 | global $cacheAPI; |
| 3521 | 3707 | |
| 3522 | 3708 | // If we can't get to the API, can't do this. |
| 3523 | - if (empty($cacheAPI)) |
|
| 3524 | - return; |
|
| 3709 | + if (empty($cacheAPI)) { |
|
| 3710 | + return; |
|
| 3711 | + } |
|
| 3525 | 3712 | |
| 3526 | 3713 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3527 | 3714 | $cacheAPI->cleanCache($type); |
@@ -3546,8 +3733,9 @@ discard block |
||
| 3546 | 3733 | global $modSettings, $smcFunc, $image_proxy_enabled, $user_info; |
| 3547 | 3734 | |
| 3548 | 3735 | // Come on! |
| 3549 | - if (empty($data)) |
|
| 3550 | - return array(); |
|
| 3736 | + if (empty($data)) { |
|
| 3737 | + return array(); |
|
| 3738 | + } |
|
| 3551 | 3739 | |
| 3552 | 3740 | // Set a nice default var. |
| 3553 | 3741 | $image = ''; |
@@ -3555,11 +3743,11 @@ discard block |
||
| 3555 | 3743 | // Gravatar has been set as mandatory! |
| 3556 | 3744 | if (!empty($modSettings['gravatarOverride'])) |
| 3557 | 3745 | { |
| 3558 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3559 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3560 | - |
|
| 3561 | - else if (!empty($data['email'])) |
|
| 3562 | - $image = get_gravatar_url($data['email']); |
|
| 3746 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3747 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3748 | + } else if (!empty($data['email'])) { |
|
| 3749 | + $image = get_gravatar_url($data['email']); |
|
| 3750 | + } |
|
| 3563 | 3751 | } |
| 3564 | 3752 | |
| 3565 | 3753 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3571,54 +3759,60 @@ discard block |
||
| 3571 | 3759 | // Gravatar. |
| 3572 | 3760 | if (stristr($data['avatar'], 'gravatar://')) |
| 3573 | 3761 | { |
| 3574 | - if ($data['avatar'] == 'gravatar://') |
|
| 3575 | - $image = get_gravatar_url($data['email']); |
|
| 3576 | - |
|
| 3577 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3578 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3762 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3763 | + $image = get_gravatar_url($data['email']); |
|
| 3764 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3765 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3766 | + } |
|
| 3579 | 3767 | } |
| 3580 | 3768 | |
| 3581 | 3769 | // External url. |
| 3582 | 3770 | else |
| 3583 | 3771 | { |
| 3584 | 3772 | // Using ssl? |
| 3585 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 3586 | - $image = get_proxied_url($data['avatar']); |
|
| 3773 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 3774 | + $image = get_proxied_url($data['avatar']); |
|
| 3775 | + } |
|
| 3587 | 3776 | |
| 3588 | 3777 | // Just a plain external url. |
| 3589 | - else |
|
| 3590 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3778 | + else { |
|
| 3779 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3780 | + } |
|
| 3591 | 3781 | } |
| 3592 | 3782 | } |
| 3593 | 3783 | |
| 3594 | 3784 | // Perhaps this user has an attachment as avatar... |
| 3595 | - else if (!empty($data['filename'])) |
|
| 3596 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3785 | + else if (!empty($data['filename'])) { |
|
| 3786 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3787 | + } |
|
| 3597 | 3788 | |
| 3598 | 3789 | // Right... no avatar... use our default image. |
| 3599 | - else |
|
| 3600 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3790 | + else { |
|
| 3791 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3792 | + } |
|
| 3601 | 3793 | } |
| 3602 | 3794 | |
| 3603 | 3795 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3604 | 3796 | |
| 3605 | 3797 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
| 3606 | - if (!empty($image)) |
|
| 3607 | - return array( |
|
| 3798 | + if (!empty($image)) { |
|
| 3799 | + return array( |
|
| 3608 | 3800 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3609 | 3801 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3610 | 3802 | 'href' => $image, |
| 3611 | 3803 | 'url' => $image, |
| 3612 | 3804 | ); |
| 3805 | + } |
|
| 3613 | 3806 | |
| 3614 | 3807 | // Fallback to make life easier for everyone... |
| 3615 | - else |
|
| 3616 | - return array( |
|
| 3808 | + else { |
|
| 3809 | + return array( |
|
| 3617 | 3810 | 'name' => '', |
| 3618 | 3811 | 'image' => '', |
| 3619 | 3812 | 'href' => '', |
| 3620 | 3813 | 'url' => '', |
| 3621 | 3814 | ); |
| 3622 | -} |
|
| 3815 | + } |
|
| 3816 | + } |
|
| 3623 | 3817 | |
| 3624 | 3818 | ?> |
| 3625 | 3819 | \ No newline at end of file |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | $row_boards[$row['id_board']] = $row; |
| 138 | 138 | } |
| 139 | - $smcFunc['db_free_result']($result_boards);; |
|
| 139 | + $smcFunc['db_free_result']($result_boards); ; |
|
| 140 | 140 | |
| 141 | 141 | // Run through the categories and boards (or only boards).... |
| 142 | - for (reset($row_boards); key($row_boards)!==null; next($row_boards)) |
|
| 142 | + for (reset($row_boards); key($row_boards) !== null; next($row_boards)) |
|
| 143 | 143 | { |
| 144 | 144 | $row_board = current($row_boards); |
| 145 | 145 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $row_boards[$row_board['id_parent']]['id_msg'] = $row_board['id_msg']; |
| 308 | 308 | $row_boards[$row_board['id_parent']]['subject'] = $row_board['subject']; |
| 309 | 309 | $row_boards[$row_board['id_parent']]['poster_time'] = $row_board['poster_time']; |
| 310 | - $row_boards[$row_board['id_parent']]['short_subject'] = (!empty($row_board['short_subject']) ? $row_board['short_subject'] : '') ; |
|
| 310 | + $row_boards[$row_board['id_parent']]['short_subject'] = (!empty($row_board['short_subject']) ? $row_board['short_subject'] : ''); |
|
| 311 | 311 | $row_boards[$row_board['id_parent']]['poster_name'] = $row_board['poster_name']; |
| 312 | 312 | $row_boards[$row_board['id_parent']]['real_name'] = $row_board['real_name']; |
| 313 | 313 | $row_boards[$row_board['id_parent']]['id_member'] = $row_board['id_member']; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | |
| 378 | 378 | // Set the last post in the root board |
| 379 | 379 | if (!$isChild && !empty($row_board['poster_time']) |
| 380 | - && ( empty($this_category[$row_board['id_board']]['last_post']['timestamp']) |
|
| 380 | + && (empty($this_category[$row_board['id_board']]['last_post']['timestamp']) |
|
| 381 | 381 | || $this_category[$row_board['id_board']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']) |
| 382 | 382 | ) |
| 383 | 383 | ) |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Fetches a list of boards and (optional) categories including |
@@ -37,19 +38,21 @@ discard block |
||
| 37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
| 38 | 39 | |
| 39 | 40 | // For performance, track the latest post while going through the boards. |
| 40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
| 41 | - $latest_post = array( |
|
| 41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
| 42 | + $latest_post = array( |
|
| 42 | 43 | 'timestamp' => 0, |
| 43 | 44 | 'ref' => 0, |
| 44 | 45 | ); |
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | // This setting is not allowed to be empty |
| 47 | - if (empty($modSettings['boardindex_max_depth'])) |
|
| 48 | - $modSettings['boardindex_max_depth'] = 1; |
|
| 49 | + if (empty($modSettings['boardindex_max_depth'])) { |
|
| 50 | + $modSettings['boardindex_max_depth'] = 1; |
|
| 51 | + } |
|
| 49 | 52 | |
| 50 | 53 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
| 51 | - if ($boardIndexOptions['parent_id'] != 0 && $smcFunc['db_cte_support']()) |
|
| 52 | - $result_boards = $smcFunc['db_query']('', ' |
|
| 54 | + if ($boardIndexOptions['parent_id'] != 0 && $smcFunc['db_cte_support']()) { |
|
| 55 | + $result_boards = $smcFunc['db_query']('', ' |
|
| 53 | 56 | WITH RECURSIVE |
| 54 | 57 | boards_cte (child_level, id_board, name , description, redirect, num_posts, num_topics, unapproved_posts, unapproved_topics, id_parent, id_msg_updated, id_cat, id_last_msg, board_order) |
| 55 | 58 | as |
@@ -91,8 +94,8 @@ discard block |
||
| 91 | 94 | 'id_parent' => $boardIndexOptions['parent_id'], |
| 92 | 95 | ) |
| 93 | 96 | ); |
| 94 | - else |
|
| 95 | - $result_boards = $smcFunc['db_query']('', ' |
|
| 97 | + } else { |
|
| 98 | + $result_boards = $smcFunc['db_query']('', ' |
|
| 96 | 99 | SELECT' . ($boardIndexOptions['include_categories'] ? ' |
| 97 | 100 | c.id_cat, c.name AS cat_name, c.description AS cat_desc,' : '') . ' |
| 98 | 101 | b.id_board, b.name AS board_name, b.description, |
@@ -120,12 +123,14 @@ discard block |
||
| 120 | 123 | 'blank_string' => '', |
| 121 | 124 | ) |
| 122 | 125 | ); |
| 126 | + } |
|
| 123 | 127 | |
| 124 | 128 | // Start with an empty array. |
| 125 | - if ($boardIndexOptions['include_categories']) |
|
| 126 | - $categories = array(); |
|
| 127 | - else |
|
| 128 | - $this_category = array(); |
|
| 129 | + if ($boardIndexOptions['include_categories']) { |
|
| 130 | + $categories = array(); |
|
| 131 | + } else { |
|
| 132 | + $this_category = array(); |
|
| 133 | + } |
|
| 129 | 134 | $boards = array(); |
| 130 | 135 | |
| 131 | 136 | // Children can affect parents, so we need to gather all the boards first and then process them after. |
@@ -148,8 +153,9 @@ discard block |
||
| 148 | 153 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
| 149 | 154 | |
| 150 | 155 | // Add parent boards to the $boards list later used to fetch moderators |
| 151 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
| 152 | - $boards[] = $row_board['id_board']; |
|
| 156 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
| 157 | + $boards[] = $row_board['id_board']; |
|
| 158 | + } |
|
| 153 | 159 | |
| 154 | 160 | if ($boardIndexOptions['include_categories']) |
| 155 | 161 | { |
@@ -171,8 +177,9 @@ discard block |
||
| 171 | 177 | } |
| 172 | 178 | |
| 173 | 179 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
| 174 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
| 175 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']); |
|
| 180 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
| 181 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']); |
|
| 182 | + } |
|
| 176 | 183 | |
| 177 | 184 | // Avoid showing category unread link where it only has redirection boards. |
| 178 | 185 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -191,8 +198,9 @@ discard block |
||
| 191 | 198 | $isChild = false; |
| 192 | 199 | |
| 193 | 200 | // We might or might not have already added this board, so... |
| 194 | - if (!isset($this_category[$row_board['id_board']])) |
|
| 195 | - $this_category[$row_board['id_board']] = array(); |
|
| 201 | + if (!isset($this_category[$row_board['id_board']])) { |
|
| 202 | + $this_category[$row_board['id_board']] = array(); |
|
| 203 | + } |
|
| 196 | 204 | |
| 197 | 205 | $this_category[$row_board['id_board']] += array( |
| 198 | 206 | 'new' => empty($row_board['is_read']), |
@@ -225,14 +233,12 @@ discard block |
||
| 225 | 233 | { |
| 226 | 234 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
| 227 | 235 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
| 228 | - } |
|
| 229 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 236 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 230 | 237 | { |
| 231 | 238 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
| 232 | 239 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
| 233 | 240 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
| 234 | - } |
|
| 235 | - else |
|
| 241 | + } else |
|
| 236 | 242 | { |
| 237 | 243 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
| 238 | 244 | } |
@@ -244,12 +250,13 @@ discard block |
||
| 244 | 250 | $isChild = true; |
| 245 | 251 | |
| 246 | 252 | // Ensure the parent has at least the most important info defined |
| 247 | - if (!isset($this_category[$row_board['id_parent']])) |
|
| 248 | - $this_category[$row_board['id_parent']] = array( |
|
| 253 | + if (!isset($this_category[$row_board['id_parent']])) { |
|
| 254 | + $this_category[$row_board['id_parent']] = array( |
|
| 249 | 255 | 'children' => array(), |
| 250 | 256 | 'children_new' => false, |
| 251 | 257 | 'board_class' => 'off', |
| 252 | 258 | ); |
| 259 | + } |
|
| 253 | 260 | |
| 254 | 261 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']] = array( |
| 255 | 262 | 'id' => $row_board['id_board'], |
@@ -293,8 +300,9 @@ discard block |
||
| 293 | 300 | // Propagate some values to the parent board |
| 294 | 301 | if (isset($row_boards[$row_board['id_parent']])) |
| 295 | 302 | { |
| 296 | - if (empty($row_board['is_read'])) |
|
| 297 | - $row_boards[$row_board['id_parent']]['is_read'] = $row_board['is_read']; |
|
| 303 | + if (empty($row_board['is_read'])) { |
|
| 304 | + $row_boards[$row_board['id_parent']]['is_read'] = $row_board['is_read']; |
|
| 305 | + } |
|
| 298 | 306 | |
| 299 | 307 | if (!empty($boardIndexOptions['countChildPosts']) && !$row_board['is_redirect']) |
| 300 | 308 | { |
@@ -345,12 +353,13 @@ discard block |
||
| 345 | 353 | 'topic' => $row_board['id_topic'] |
| 346 | 354 | ); |
| 347 | 355 | |
| 348 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
| 349 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 356 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
| 357 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 350 | 358 | 'avatar' => $row_board['avatar'], |
| 351 | 359 | 'email' => $row_board['email_address'], |
| 352 | 360 | 'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '', |
| 353 | 361 | )); |
| 362 | + } |
|
| 354 | 363 | |
| 355 | 364 | // Provide the href and link. |
| 356 | 365 | if ($row_board['subject'] != '') |
@@ -362,8 +371,7 @@ discard block |
||
| 362 | 371 | link, href, subject, start (where they should go for the first unread post.), |
| 363 | 372 | and member. (which has id, name, link, href, username in it.) */ |
| 364 | 373 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
| 365 | - } |
|
| 366 | - else |
|
| 374 | + } else |
|
| 367 | 375 | { |
| 368 | 376 | $this_last_post['href'] = ''; |
| 369 | 377 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -372,27 +380,31 @@ discard block |
||
| 372 | 380 | |
| 373 | 381 | // Set the last post in the parent board. |
| 374 | 382 | if ($isChild && !empty($row_board['poster_time']) |
| 375 | - && $row_boards[$row_board['id_parent']]['poster_time'] < $row_board['poster_time']) |
|
| 376 | - $this_category[$row_board['id_parent']]['last_post'] = $this_last_post; |
|
| 383 | + && $row_boards[$row_board['id_parent']]['poster_time'] < $row_board['poster_time']) { |
|
| 384 | + $this_category[$row_board['id_parent']]['last_post'] = $this_last_post; |
|
| 385 | + } |
|
| 377 | 386 | |
| 378 | 387 | // Set the last post in the root board |
| 379 | 388 | if (!$isChild && !empty($row_board['poster_time']) |
| 380 | 389 | && ( empty($this_category[$row_board['id_board']]['last_post']['timestamp']) |
| 381 | 390 | || $this_category[$row_board['id_board']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']) |
| 382 | 391 | ) |
| 383 | - ) |
|
| 384 | - $this_category[$row_board['id_board']]['last_post'] = $this_last_post; |
|
| 392 | + ) { |
|
| 393 | + $this_category[$row_board['id_board']]['last_post'] = $this_last_post; |
|
| 394 | + } |
|
| 385 | 395 | |
| 386 | 396 | // Just in the child...? |
| 387 | - if ($isChild) |
|
| 388 | - $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post; |
|
| 397 | + if ($isChild) { |
|
| 398 | + $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post; |
|
| 399 | + } |
|
| 389 | 400 | |
| 390 | 401 | // Determine a global most recent topic. |
| 391 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
| 392 | - $latest_post = array( |
|
| 402 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
| 403 | + $latest_post = array( |
|
| 393 | 404 | 'timestamp' => $row_board['poster_time'], |
| 394 | 405 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
| 395 | 406 | ); |
| 407 | + } |
|
| 396 | 408 | } |
| 397 | 409 | |
| 398 | 410 | // Fetch the board's moderators and moderator groups |
@@ -408,8 +420,9 @@ discard block |
||
| 408 | 420 | if (!empty($moderators[$board['id']])) |
| 409 | 421 | { |
| 410 | 422 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
| 411 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 412 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 423 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 424 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 425 | + } |
|
| 413 | 426 | } |
| 414 | 427 | if (!empty($groups[$board['id']])) |
| 415 | 428 | { |
@@ -422,16 +435,16 @@ discard block |
||
| 422 | 435 | } |
| 423 | 436 | } |
| 424 | 437 | } |
| 425 | - } |
|
| 426 | - else |
|
| 438 | + } else |
|
| 427 | 439 | { |
| 428 | 440 | foreach ($this_category as $k => $board) |
| 429 | 441 | { |
| 430 | 442 | if (!empty($moderators[$board['id']])) |
| 431 | 443 | { |
| 432 | 444 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
| 433 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 434 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 445 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 446 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 447 | + } |
|
| 435 | 448 | } |
| 436 | 449 | if (!empty($groups[$board['id']])) |
| 437 | 450 | { |
@@ -445,20 +458,23 @@ discard block |
||
| 445 | 458 | } |
| 446 | 459 | } |
| 447 | 460 | |
| 448 | - if ($boardIndexOptions['include_categories']) |
|
| 449 | - sortCategories($categories); |
|
| 450 | - else |
|
| 451 | - sortBoards($this_category); |
|
| 461 | + if ($boardIndexOptions['include_categories']) { |
|
| 462 | + sortCategories($categories); |
|
| 463 | + } else { |
|
| 464 | + sortBoards($this_category); |
|
| 465 | + } |
|
| 452 | 466 | |
| 453 | 467 | // By now we should know the most recent post...if we wanna know it that is. |
| 454 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
| 455 | - $context['latest_post'] = $latest_post['ref']; |
|
| 468 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
| 469 | + $context['latest_post'] = $latest_post['ref']; |
|
| 470 | + } |
|
| 456 | 471 | |
| 457 | 472 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
| 458 | - if ($boardIndexOptions['include_categories']) |
|
| 459 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 460 | - else |
|
| 461 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 473 | + if ($boardIndexOptions['include_categories']) { |
|
| 474 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 475 | + } else { |
|
| 476 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 477 | + } |
|
| 462 | 478 | |
| 463 | 479 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
| 464 | 480 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
| 28 | 29 | global $user_info, $modSettings, $smcFunc; |
| 29 | 30 | |
| 30 | 31 | // Force $boards to be an array. |
| 31 | - if (!is_array($boards)) |
|
| 32 | - $boards = array($boards); |
|
| 33 | - else |
|
| 34 | - $boards = array_unique($boards); |
|
| 32 | + if (!is_array($boards)) { |
|
| 33 | + $boards = array($boards); |
|
| 34 | + } else { |
|
| 35 | + $boards = array_unique($boards); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // No boards, nothing to mark as read. |
| 37 | - if (empty($boards)) |
|
| 38 | - return; |
|
| 39 | + if (empty($boards)) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 39 | 42 | |
| 40 | 43 | // Allow the user to mark a board as unread. |
| 41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
| 65 | 68 | else |
| 66 | 69 | { |
| 67 | 70 | $markRead = array(); |
| 68 | - foreach ($boards as $board) |
|
| 69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
| 71 | + foreach ($boards as $board) { |
|
| 72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
| 73 | + } |
|
| 70 | 74 | |
| 71 | 75 | // Update log_mark_read and log_boards. |
| 72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
| 99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
| 100 | 104 | $smcFunc['db_free_result']($result); |
| 101 | 105 | |
| 102 | - if (empty($lowest_topic)) |
|
| 103 | - return; |
|
| 106 | + if (empty($lowest_topic)) { |
|
| 107 | + return; |
|
| 108 | + } |
|
| 104 | 109 | |
| 105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
| 106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
| 118 | 123 | ) |
| 119 | 124 | ); |
| 120 | 125 | $topics = array(); |
| 121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 122 | - $topics[] = $row['id_topic']; |
|
| 126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 127 | + $topics[] = $row['id_topic']; |
|
| 128 | + } |
|
| 123 | 129 | $smcFunc['db_free_result']($result); |
| 124 | 130 | |
| 125 | - if (!empty($topics)) |
|
| 126 | - $smcFunc['db_query']('', ' |
|
| 131 | + if (!empty($topics)) { |
|
| 132 | + $smcFunc['db_query']('', ' |
|
| 127 | 133 | DELETE FROM {db_prefix}log_topics |
| 128 | 134 | WHERE id_member = {int:current_member} |
| 129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
| 132 | 138 | 'topic_list' => $topics, |
| 133 | 139 | ) |
| 134 | 140 | ); |
| 135 | -} |
|
| 141 | + } |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | /** |
| 138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
| 157 | 164 | ) |
| 158 | 165 | ); |
| 159 | 166 | $boards = array(); |
| 160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 161 | - $boards[] = $row['id_board']; |
|
| 167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 168 | + $boards[] = $row['id_board']; |
|
| 169 | + } |
|
| 162 | 170 | $smcFunc['db_free_result']($result); |
| 163 | 171 | |
| 164 | - if (!empty($boards)) |
|
| 165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
| 172 | + if (!empty($boards)) { |
|
| 173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
| 174 | + } |
|
| 166 | 175 | |
| 167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
| 168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
| 169 | - redirectexit('action=unread'); |
|
| 177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
| 178 | + redirectexit('action=unread'); |
|
| 179 | + } |
|
| 170 | 180 | |
| 171 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 172 | - $_SESSION['topicseen_cache'] = array(); |
|
| 181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 182 | + $_SESSION['topicseen_cache'] = array(); |
|
| 183 | + } |
|
| 173 | 184 | |
| 174 | 185 | redirectexit(); |
| 175 | - } |
|
| 176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
| 186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
| 177 | 187 | { |
| 178 | 188 | // Make sure all the topics are integers! |
| 179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
| 189 | 199 | ) |
| 190 | 200 | ); |
| 191 | 201 | $logged_topics = array(); |
| 192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 204 | + } |
|
| 194 | 205 | $smcFunc['db_free_result']($request); |
| 195 | 206 | |
| 196 | 207 | $markRead = array(); |
| 197 | - foreach ($topics as $id_topic) |
|
| 198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 208 | + foreach ($topics as $id_topic) { |
|
| 209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 210 | + } |
|
| 199 | 211 | |
| 200 | 212 | $smcFunc['db_insert']('replace', |
| 201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
| 204 | 216 | array('id_member', 'id_topic') |
| 205 | 217 | ); |
| 206 | 218 | |
| 207 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 208 | - $_SESSION['topicseen_cache'] = array(); |
|
| 219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 220 | + $_SESSION['topicseen_cache'] = array(); |
|
| 221 | + } |
|
| 209 | 222 | |
| 210 | 223 | redirectexit('action=unreadreplies'); |
| 211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
| 230 | 243 | if (!empty($_GET['t'])) |
| 231 | 244 | { |
| 232 | 245 | // If they read the whole topic, go back to the beginning. |
| 233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
| 234 | - $earlyMsg = 0; |
|
| 246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
| 247 | + $earlyMsg = 0; |
|
| 248 | + } |
|
| 235 | 249 | // If they want to mark the whole thing read, same. |
| 236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
| 237 | - $earlyMsg = 0; |
|
| 250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
| 251 | + $earlyMsg = 0; |
|
| 252 | + } |
|
| 238 | 253 | // Otherwise, get the latest message before the named one. |
| 239 | 254 | else |
| 240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
| 255 | 270 | } |
| 256 | 271 | } |
| 257 | 272 | // Marking read from first page? That's the whole topic. |
| 258 | - elseif ($_REQUEST['start'] == 0) |
|
| 259 | - $earlyMsg = 0; |
|
| 260 | - else |
|
| 273 | + elseif ($_REQUEST['start'] == 0) { |
|
| 274 | + $earlyMsg = 0; |
|
| 275 | + } else |
|
| 261 | 276 | { |
| 262 | 277 | $result = $smcFunc['db_query']('', ' |
| 263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
| 285 | 300 | ); |
| 286 | 301 | |
| 287 | 302 | redirectexit('board=' . $board . '.0'); |
| 288 | - } |
|
| 289 | - else |
|
| 303 | + } else |
|
| 290 | 304 | { |
| 291 | 305 | $categories = array(); |
| 292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
| 294 | 308 | if (isset($_REQUEST['c'])) |
| 295 | 309 | { |
| 296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 297 | - foreach ($_REQUEST['c'] as $c) |
|
| 298 | - $categories[] = (int) $c; |
|
| 311 | + foreach ($_REQUEST['c'] as $c) { |
|
| 312 | + $categories[] = (int) $c; |
|
| 313 | + } |
|
| 299 | 314 | } |
| 300 | 315 | if (isset($_REQUEST['boards'])) |
| 301 | 316 | { |
| 302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 303 | - foreach ($_REQUEST['boards'] as $b) |
|
| 304 | - $boards[] = (int) $b; |
|
| 318 | + foreach ($_REQUEST['boards'] as $b) { |
|
| 319 | + $boards[] = (int) $b; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + if (!empty($board)) { |
|
| 323 | + $boards[] = (int) $board; |
|
| 305 | 324 | } |
| 306 | - if (!empty($board)) |
|
| 307 | - $boards[] = (int) $board; |
|
| 308 | 325 | |
| 309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
| 310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
| 324 | 341 | 'board_list' => $boards, |
| 325 | 342 | ) |
| 326 | 343 | ); |
| 327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 328 | - if (in_array($row['id_parent'], $boards)) |
|
| 344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 345 | + if (in_array($row['id_parent'], $boards)) |
|
| 329 | 346 | $boards[] = $row['id_board']; |
| 347 | + } |
|
| 330 | 348 | $smcFunc['db_free_result']($request); |
| 331 | 349 | } |
| 332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
| 343 | 361 | $clauseParameters['board_list'] = $boards; |
| 344 | 362 | } |
| 345 | 363 | |
| 346 | - if (empty($clauses)) |
|
| 347 | - redirectexit(); |
|
| 364 | + if (empty($clauses)) { |
|
| 365 | + redirectexit(); |
|
| 366 | + } |
|
| 348 | 367 | |
| 349 | 368 | $request = $smcFunc['db_query']('', ' |
| 350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
| 355 | 374 | )) |
| 356 | 375 | ); |
| 357 | 376 | $boards = array(); |
| 358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 359 | - $boards[] = $row['id_board']; |
|
| 377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 378 | + $boards[] = $row['id_board']; |
|
| 379 | + } |
|
| 360 | 380 | $smcFunc['db_free_result']($request); |
| 361 | 381 | |
| 362 | - if (empty($boards)) |
|
| 363 | - redirectexit(); |
|
| 382 | + if (empty($boards)) { |
|
| 383 | + redirectexit(); |
|
| 384 | + } |
|
| 364 | 385 | |
| 365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
| 366 | 387 | |
| 367 | 388 | foreach ($boards as $b) |
| 368 | 389 | { |
| 369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
| 370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
| 390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
| 391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
| 392 | + } |
|
| 371 | 393 | } |
| 372 | 394 | |
| 373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
| 385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
| 386 | 408 | { |
| 387 | 409 | $logBoardInserts = array(); |
| 388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
| 410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
| 412 | + } |
|
| 390 | 413 | |
| 391 | 414 | $smcFunc['db_insert']('replace', |
| 392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
| 397 | 420 | } |
| 398 | 421 | $smcFunc['db_free_result']($result); |
| 399 | 422 | |
| 400 | - if (empty($board)) |
|
| 401 | - redirectexit(); |
|
| 402 | - else |
|
| 403 | - redirectexit('board=' . $board . '.0'); |
|
| 404 | - } |
|
| 405 | - else |
|
| 423 | + if (empty($board)) { |
|
| 424 | + redirectexit(); |
|
| 425 | + } else { |
|
| 426 | + redirectexit('board=' . $board . '.0'); |
|
| 427 | + } |
|
| 428 | + } else |
|
| 406 | 429 | { |
| 407 | - if (empty($board_info['parent'])) |
|
| 408 | - redirectexit(); |
|
| 409 | - else |
|
| 410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
| 430 | + if (empty($board_info['parent'])) { |
|
| 431 | + redirectexit(); |
|
| 432 | + } else { |
|
| 433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
| 434 | + } |
|
| 411 | 435 | } |
| 412 | 436 | } |
| 413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
| 432 | 456 | 'selected_message' => (int) $messageID, |
| 433 | 457 | ) |
| 434 | 458 | ); |
| 435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
| 436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
| 459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
| 460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
| 461 | + } |
|
| 437 | 462 | // The message doesn't even exist. |
| 438 | - else |
|
| 439 | - $memberID = 0; |
|
| 463 | + else { |
|
| 464 | + $memberID = 0; |
|
| 465 | + } |
|
| 440 | 466 | $smcFunc['db_free_result']($result); |
| 441 | 467 | |
| 442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
| 457 | 483 | getBoardTree(); |
| 458 | 484 | |
| 459 | 485 | // Make sure given boards and categories exist. |
| 460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
| 461 | - fatal_lang_error('no_board'); |
|
| 486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
| 487 | + fatal_lang_error('no_board'); |
|
| 488 | + } |
|
| 462 | 489 | |
| 463 | 490 | $id = $board_id; |
| 464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
| 486 | 513 | $child_level = 0; |
| 487 | 514 | $id_parent = 0; |
| 488 | 515 | $after = 0; |
| 489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
| 490 | - $after = max($after, $boards[$id_board]['order']); |
|
| 516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
| 517 | + $after = max($after, $boards[$id_board]['order']); |
|
| 518 | + } |
|
| 491 | 519 | } |
| 492 | 520 | |
| 493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
| 498 | 526 | $id_parent = $boardOptions['target_board']; |
| 499 | 527 | |
| 500 | 528 | // People can be creative, in many ways... |
| 501 | - if (isChildOf($id_parent, $board_id)) |
|
| 502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
| 503 | - elseif ($id_parent == $board_id) |
|
| 504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
| 529 | + if (isChildOf($id_parent, $board_id)) { |
|
| 530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
| 531 | + } elseif ($id_parent == $board_id) { |
|
| 532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
| 533 | + } |
|
| 505 | 534 | |
| 506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
| 507 | 536 | |
| 508 | 537 | // Check if there are already children and (if so) get the max board order. |
| 509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
| 510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
| 538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
| 539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
| 511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
| 541 | + } |
|
| 512 | 542 | } |
| 513 | 543 | |
| 514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
| 521 | 551 | } |
| 522 | 552 | |
| 523 | 553 | // Oops...? |
| 524 | - else |
|
| 525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
| 554 | + else { |
|
| 555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
| 556 | + } |
|
| 526 | 557 | |
| 527 | 558 | // Get a list of children of this board. |
| 528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
| 531 | 562 | // See if there are changes that affect children. |
| 532 | 563 | $childUpdates = array(); |
| 533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
| 534 | - if ($levelDiff != 0) |
|
| 535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
| 536 | - if ($id_cat != $boards[$board_id]['category']) |
|
| 537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
| 565 | + if ($levelDiff != 0) { |
|
| 566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
| 567 | + } |
|
| 568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
| 569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
| 570 | + } |
|
| 538 | 571 | |
| 539 | 572 | // Fix the children of this board. |
| 540 | - if (!empty($childList) && !empty($childUpdates)) |
|
| 541 | - $smcFunc['db_query']('', ' |
|
| 573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
| 574 | + $smcFunc['db_query']('', ' |
|
| 542 | 575 | UPDATE {db_prefix}boards |
| 543 | 576 | SET ' . implode(', |
| 544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
| 549 | 582 | 'level_diff' => $levelDiff, |
| 550 | 583 | ) |
| 551 | 584 | ); |
| 585 | + } |
|
| 552 | 586 | |
| 553 | 587 | // Make some room for this spot. |
| 554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
| 644 | 678 | call_integration_hook('integrate_modify_board', array($id, $boardOptions, &$boardUpdates, &$boardUpdateParameters)); |
| 645 | 679 | |
| 646 | 680 | // Do the updates (if any). |
| 647 | - if (!empty($boardUpdates)) |
|
| 648 | - $smcFunc['db_query']('', ' |
|
| 681 | + if (!empty($boardUpdates)) { |
|
| 682 | + $smcFunc['db_query']('', ' |
|
| 649 | 683 | UPDATE {db_prefix}boards |
| 650 | 684 | SET |
| 651 | 685 | ' . implode(', |
@@ -655,13 +689,15 @@ discard block |
||
| 655 | 689 | 'selected_board' => $board_id, |
| 656 | 690 | )) |
| 657 | 691 | ); |
| 692 | + } |
|
| 658 | 693 | |
| 659 | 694 | // Do permission sync |
| 660 | 695 | if (!empty($boardUpdateParameters['deny_groups'])) |
| 661 | 696 | { |
| 662 | 697 | $insert = array(); |
| 663 | - foreach($boardOptions['deny_groups'] as $value) |
|
| 664 | - $insert[] = array($value, $board_id, 1); |
|
| 698 | + foreach($boardOptions['deny_groups'] as $value) { |
|
| 699 | + $insert[] = array($value, $board_id, 1); |
|
| 700 | + } |
|
| 665 | 701 | |
| 666 | 702 | $smcFunc['db_query']('', ' |
| 667 | 703 | DELETE FROM {db_prefix}board_permissions_view |
@@ -681,8 +717,9 @@ discard block |
||
| 681 | 717 | if (!empty($boardUpdateParameters['member_groups'])) |
| 682 | 718 | { |
| 683 | 719 | $insert = array(); |
| 684 | - foreach($boardOptions['access_groups'] as $value) |
|
| 685 | - $insert[] = array($value, $board_id, 0); |
|
| 720 | + foreach($boardOptions['access_groups'] as $value) { |
|
| 721 | + $insert[] = array($value, $board_id, 0); |
|
| 722 | + } |
|
| 686 | 723 | $smcFunc['db_query']('', ' |
| 687 | 724 | DELETE FROM {db_prefix}board_permissions_view |
| 688 | 725 | WHERE id_board = {int:selected_board} AND deny = 0', |
@@ -722,13 +759,15 @@ discard block |
||
| 722 | 759 | { |
| 723 | 760 | $moderators[$k] = trim($moderators[$k]); |
| 724 | 761 | |
| 725 | - if (strlen($moderators[$k]) == 0) |
|
| 726 | - unset($moderators[$k]); |
|
| 762 | + if (strlen($moderators[$k]) == 0) { |
|
| 763 | + unset($moderators[$k]); |
|
| 764 | + } |
|
| 727 | 765 | } |
| 728 | 766 | |
| 729 | 767 | // Find all the id_member's for the member_name's in the list. |
| 730 | - if (empty($boardOptions['moderators'])) |
|
| 731 | - $boardOptions['moderators'] = array(); |
|
| 768 | + if (empty($boardOptions['moderators'])) { |
|
| 769 | + $boardOptions['moderators'] = array(); |
|
| 770 | + } |
|
| 732 | 771 | if (!empty($moderators)) |
| 733 | 772 | { |
| 734 | 773 | $request = $smcFunc['db_query']('', ' |
@@ -741,8 +780,9 @@ discard block |
||
| 741 | 780 | 'limit' => count($moderators), |
| 742 | 781 | ) |
| 743 | 782 | ); |
| 744 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 745 | - $boardOptions['moderators'][] = $row['id_member']; |
|
| 783 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 784 | + $boardOptions['moderators'][] = $row['id_member']; |
|
| 785 | + } |
|
| 746 | 786 | $smcFunc['db_free_result']($request); |
| 747 | 787 | } |
| 748 | 788 | } |
@@ -751,8 +791,9 @@ discard block |
||
| 751 | 791 | if (!empty($boardOptions['moderators'])) |
| 752 | 792 | { |
| 753 | 793 | $inserts = array(); |
| 754 | - foreach ($boardOptions['moderators'] as $moderator) |
|
| 755 | - $inserts[] = array($board_id, $moderator); |
|
| 794 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
| 795 | + $inserts[] = array($board_id, $moderator); |
|
| 796 | + } |
|
| 756 | 797 | |
| 757 | 798 | $smcFunc['db_insert']('insert', |
| 758 | 799 | '{db_prefix}moderators', |
@@ -782,14 +823,16 @@ discard block |
||
| 782 | 823 | { |
| 783 | 824 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
| 784 | 825 | |
| 785 | - if (strlen($moderator_groups[$k]) == 0) |
|
| 786 | - unset($moderator_groups[$k]); |
|
| 826 | + if (strlen($moderator_groups[$k]) == 0) { |
|
| 827 | + unset($moderator_groups[$k]); |
|
| 828 | + } |
|
| 787 | 829 | } |
| 788 | 830 | |
| 789 | 831 | /* Find all the id_group's for all the group names in the list |
| 790 | 832 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
| 791 | - if (empty($boardOptions['moderator_groups'])) |
|
| 792 | - $boardOptions['moderator_groups'] = array(); |
|
| 833 | + if (empty($boardOptions['moderator_groups'])) { |
|
| 834 | + $boardOptions['moderator_groups'] = array(); |
|
| 835 | + } |
|
| 793 | 836 | if (!empty($moderator_groups)) |
| 794 | 837 | { |
| 795 | 838 | $request = $smcFunc['db_query']('', ' |
@@ -820,8 +863,9 @@ discard block |
||
| 820 | 863 | if (!empty($boardOptions['moderator_groups'])) |
| 821 | 864 | { |
| 822 | 865 | $inserts = array(); |
| 823 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
| 824 | - $inserts[] = array($board_id, $moderator_group); |
|
| 866 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
| 867 | + $inserts[] = array($board_id, $moderator_group); |
|
| 868 | + } |
|
| 825 | 869 | |
| 826 | 870 | $smcFunc['db_insert']('insert', |
| 827 | 871 | '{db_prefix}moderator_groups', |
@@ -835,14 +879,16 @@ discard block |
||
| 835 | 879 | updateSettings(array('settings_updated' => time())); |
| 836 | 880 | } |
| 837 | 881 | |
| 838 | - if (isset($boardOptions['move_to'])) |
|
| 839 | - reorderBoards(); |
|
| 882 | + if (isset($boardOptions['move_to'])) { |
|
| 883 | + reorderBoards(); |
|
| 884 | + } |
|
| 840 | 885 | |
| 841 | 886 | clean_cache('data'); |
| 842 | 887 | |
| 843 | - if (empty($boardOptions['dont_log'])) |
|
| 844 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
| 845 | -} |
|
| 888 | + if (empty($boardOptions['dont_log'])) { |
|
| 889 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
| 890 | + } |
|
| 891 | + } |
|
| 846 | 892 | |
| 847 | 893 | /** |
| 848 | 894 | * Create a new board and set its properties and position. |
@@ -858,11 +904,13 @@ discard block |
||
| 858 | 904 | global $boards, $smcFunc; |
| 859 | 905 | |
| 860 | 906 | // Trigger an error if one of the required values is not set. |
| 861 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
| 862 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
| 907 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
| 908 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
| 909 | + } |
|
| 863 | 910 | |
| 864 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
| 865 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
| 911 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
| 912 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
| 913 | + } |
|
| 866 | 914 | |
| 867 | 915 | // Set every optional value to its default value. |
| 868 | 916 | $boardOptions += array( |
@@ -901,8 +949,9 @@ discard block |
||
| 901 | 949 | |
| 902 | 950 | $insert = array(); |
| 903 | 951 | |
| 904 | - foreach(explode(',', $default_memgrps) as $value) |
|
| 905 | - $insert[] = array($value, $board_id, 0); |
|
| 952 | + foreach(explode(',', $default_memgrps) as $value) { |
|
| 953 | + $insert[] = array($value, $board_id, 0); |
|
| 954 | + } |
|
| 906 | 955 | |
| 907 | 956 | $smcFunc['db_insert']('', |
| 908 | 957 | '{db_prefix}board_permissions_view', |
@@ -912,8 +961,9 @@ discard block |
||
| 912 | 961 | 1 |
| 913 | 962 | ); |
| 914 | 963 | |
| 915 | - if (empty($board_id)) |
|
| 916 | - return 0; |
|
| 964 | + if (empty($board_id)) { |
|
| 965 | + return 0; |
|
| 966 | + } |
|
| 917 | 967 | |
| 918 | 968 | // Change the board according to the given specifications. |
| 919 | 969 | modifyBoard($board_id, $boardOptions); |
@@ -976,8 +1026,9 @@ discard block |
||
| 976 | 1026 | global $sourcedir, $boards, $smcFunc; |
| 977 | 1027 | |
| 978 | 1028 | // No boards to delete? Return! |
| 979 | - if (empty($boards_to_remove)) |
|
| 980 | - return; |
|
| 1029 | + if (empty($boards_to_remove)) { |
|
| 1030 | + return; |
|
| 1031 | + } |
|
| 981 | 1032 | |
| 982 | 1033 | getBoardTree(); |
| 983 | 1034 | |
@@ -988,12 +1039,14 @@ discard block |
||
| 988 | 1039 | { |
| 989 | 1040 | // Get a list of the child boards that will also be removed. |
| 990 | 1041 | $child_boards_to_remove = array(); |
| 991 | - foreach ($boards_to_remove as $board_to_remove) |
|
| 992 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
| 1042 | + foreach ($boards_to_remove as $board_to_remove) { |
|
| 1043 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
| 1044 | + } |
|
| 993 | 1045 | |
| 994 | 1046 | // Merge the children with their parents. |
| 995 | - if (!empty($child_boards_to_remove)) |
|
| 996 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
| 1047 | + if (!empty($child_boards_to_remove)) { |
|
| 1048 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
| 1049 | + } |
|
| 997 | 1050 | } |
| 998 | 1051 | // Move the children to a safe home. |
| 999 | 1052 | else |
@@ -1001,10 +1054,11 @@ discard block |
||
| 1001 | 1054 | foreach ($boards_to_remove as $id_board) |
| 1002 | 1055 | { |
| 1003 | 1056 | // @todo Separate category? |
| 1004 | - if ($moveChildrenTo === 0) |
|
| 1005 | - fixChildren($id_board, 0, 0); |
|
| 1006 | - else |
|
| 1007 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
| 1057 | + if ($moveChildrenTo === 0) { |
|
| 1058 | + fixChildren($id_board, 0, 0); |
|
| 1059 | + } else { |
|
| 1060 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
| 1061 | + } |
|
| 1008 | 1062 | } |
| 1009 | 1063 | } |
| 1010 | 1064 | |
@@ -1018,8 +1072,9 @@ discard block |
||
| 1018 | 1072 | ) |
| 1019 | 1073 | ); |
| 1020 | 1074 | $topics = array(); |
| 1021 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1022 | - $topics[] = $row['id_topic']; |
|
| 1075 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1076 | + $topics[] = $row['id_topic']; |
|
| 1077 | + } |
|
| 1023 | 1078 | $smcFunc['db_free_result']($request); |
| 1024 | 1079 | |
| 1025 | 1080 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1116,8 +1171,9 @@ discard block |
||
| 1116 | 1171 | clean_cache('data'); |
| 1117 | 1172 | |
| 1118 | 1173 | // Let's do some serious logging. |
| 1119 | - foreach ($boards_to_remove as $id_board) |
|
| 1120 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
| 1174 | + foreach ($boards_to_remove as $id_board) { |
|
| 1175 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
| 1176 | + } |
|
| 1121 | 1177 | |
| 1122 | 1178 | reorderBoards(); |
| 1123 | 1179 | } |
@@ -1136,8 +1192,8 @@ discard block |
||
| 1136 | 1192 | $board_order = 0; |
| 1137 | 1193 | foreach ($cat_tree as $catID => $dummy) |
| 1138 | 1194 | { |
| 1139 | - foreach ($boardList[$catID] as $boardID) |
|
| 1140 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
| 1195 | + foreach ($boardList[$catID] as $boardID) { |
|
| 1196 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
| 1141 | 1197 | $smcFunc['db_query']('', ' |
| 1142 | 1198 | UPDATE {db_prefix}boards |
| 1143 | 1199 | SET board_order = {int:new_order} |
@@ -1147,6 +1203,7 @@ discard block |
||
| 1147 | 1203 | 'selected_board' => $boardID, |
| 1148 | 1204 | ) |
| 1149 | 1205 | ); |
| 1206 | + } |
|
| 1150 | 1207 | } |
| 1151 | 1208 | |
| 1152 | 1209 | // Empty the board order cache |
@@ -1175,8 +1232,9 @@ discard block |
||
| 1175 | 1232 | ) |
| 1176 | 1233 | ); |
| 1177 | 1234 | $children = array(); |
| 1178 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1179 | - $children[] = $row['id_board']; |
|
| 1235 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1236 | + $children[] = $row['id_board']; |
|
| 1237 | + } |
|
| 1180 | 1238 | $smcFunc['db_free_result']($result); |
| 1181 | 1239 | |
| 1182 | 1240 | // ...and set it to a new parent and child_level. |
@@ -1192,9 +1250,10 @@ discard block |
||
| 1192 | 1250 | ); |
| 1193 | 1251 | |
| 1194 | 1252 | // Recursively fix the children of the children. |
| 1195 | - foreach ($children as $child) |
|
| 1196 | - fixChildren($child, $newLevel + 1, $child); |
|
| 1197 | -} |
|
| 1253 | + foreach ($children as $child) { |
|
| 1254 | + fixChildren($child, $newLevel + 1, $child); |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1198 | 1257 | |
| 1199 | 1258 | /** |
| 1200 | 1259 | * Tries to load up the entire board order and category very very quickly |
@@ -1211,8 +1270,9 @@ discard block |
||
| 1211 | 1270 | 'boards' => array(), |
| 1212 | 1271 | ); |
| 1213 | 1272 | |
| 1214 | - if (!empty($tree_order['boards'])) |
|
| 1215 | - return $tree_order; |
|
| 1273 | + if (!empty($tree_order['boards'])) { |
|
| 1274 | + return $tree_order; |
|
| 1275 | + } |
|
| 1216 | 1276 | |
| 1217 | 1277 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
| 1218 | 1278 | { |
@@ -1229,8 +1289,9 @@ discard block |
||
| 1229 | 1289 | |
| 1230 | 1290 | foreach ($smcFunc['db_fetch_all']($request) as $row) |
| 1231 | 1291 | { |
| 1232 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
| 1233 | - $tree_order['cats'][] = $row['id_cat']; |
|
| 1292 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
| 1293 | + $tree_order['cats'][] = $row['id_cat']; |
|
| 1294 | + } |
|
| 1234 | 1295 | $tree_order['boards'][] = $row['id_board']; |
| 1235 | 1296 | } |
| 1236 | 1297 | $smcFunc['db_free_result']($request); |
@@ -1250,16 +1311,19 @@ discard block |
||
| 1250 | 1311 | $tree = getTreeOrder(); |
| 1251 | 1312 | |
| 1252 | 1313 | $ordered = array(); |
| 1253 | - foreach ($tree['boards'] as $board) |
|
| 1254 | - if (!empty($boards[$board])) |
|
| 1314 | + foreach ($tree['boards'] as $board) { |
|
| 1315 | + if (!empty($boards[$board])) |
|
| 1255 | 1316 | { |
| 1256 | 1317 | $ordered[$board] = $boards[$board]; |
| 1318 | + } |
|
| 1257 | 1319 | |
| 1258 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
| 1259 | - sortBoards($ordered[$board]['boards']); |
|
| 1320 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
| 1321 | + sortBoards($ordered[$board]['boards']); |
|
| 1322 | + } |
|
| 1260 | 1323 | |
| 1261 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
| 1262 | - sortBoards($ordered[$board]['children']); |
|
| 1324 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
| 1325 | + sortBoards($ordered[$board]['children']); |
|
| 1326 | + } |
|
| 1263 | 1327 | } |
| 1264 | 1328 | |
| 1265 | 1329 | $boards = $ordered; |
@@ -1275,12 +1339,14 @@ discard block |
||
| 1275 | 1339 | $tree = getTreeOrder(); |
| 1276 | 1340 | |
| 1277 | 1341 | $ordered = array(); |
| 1278 | - foreach ($tree['cats'] as $cat) |
|
| 1279 | - if (!empty($categories[$cat])) |
|
| 1342 | + foreach ($tree['cats'] as $cat) { |
|
| 1343 | + if (!empty($categories[$cat])) |
|
| 1280 | 1344 | { |
| 1281 | 1345 | $ordered[$cat] = $categories[$cat]; |
| 1282 | - if (!empty($ordered[$cat]['boards'])) |
|
| 1283 | - sortBoards($ordered[$cat]['boards']); |
|
| 1346 | + } |
|
| 1347 | + if (!empty($ordered[$cat]['boards'])) { |
|
| 1348 | + sortBoards($ordered[$cat]['boards']); |
|
| 1349 | + } |
|
| 1284 | 1350 | } |
| 1285 | 1351 | |
| 1286 | 1352 | $categories = $ordered; |
@@ -1296,8 +1362,9 @@ discard block |
||
| 1296 | 1362 | { |
| 1297 | 1363 | global $smcFunc, $scripturl, $txt; |
| 1298 | 1364 | |
| 1299 | - if (empty($boards)) |
|
| 1300 | - return array(); |
|
| 1365 | + if (empty($boards)) { |
|
| 1366 | + return array(); |
|
| 1367 | + } |
|
| 1301 | 1368 | |
| 1302 | 1369 | $request = $smcFunc['db_query']('', ' |
| 1303 | 1370 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1311,8 +1378,9 @@ discard block |
||
| 1311 | 1378 | $moderators = array(); |
| 1312 | 1379 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1313 | 1380 | { |
| 1314 | - if (empty($moderators[$row['id_board']])) |
|
| 1315 | - $moderators[$row['id_board']] = array(); |
|
| 1381 | + if (empty($moderators[$row['id_board']])) { |
|
| 1382 | + $moderators[$row['id_board']] = array(); |
|
| 1383 | + } |
|
| 1316 | 1384 | |
| 1317 | 1385 | $moderators[$row['id_board']][] = array( |
| 1318 | 1386 | 'id' => $row['id_member'], |
@@ -1336,8 +1404,9 @@ discard block |
||
| 1336 | 1404 | { |
| 1337 | 1405 | global $smcFunc, $scripturl, $txt; |
| 1338 | 1406 | |
| 1339 | - if (empty($boards)) |
|
| 1340 | - return array(); |
|
| 1407 | + if (empty($boards)) { |
|
| 1408 | + return array(); |
|
| 1409 | + } |
|
| 1341 | 1410 | |
| 1342 | 1411 | $request = $smcFunc['db_query']('', ' |
| 1343 | 1412 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1351,8 +1420,9 @@ discard block |
||
| 1351 | 1420 | $groups = array(); |
| 1352 | 1421 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1353 | 1422 | { |
| 1354 | - if (empty($groups[$row['id_board']])) |
|
| 1355 | - $groups[$row['id_board']] = array(); |
|
| 1423 | + if (empty($groups[$row['id_board']])) { |
|
| 1424 | + $groups[$row['id_board']] = array(); |
|
| 1425 | + } |
|
| 1356 | 1426 | |
| 1357 | 1427 | $groups[$row['id_board']][] = array( |
| 1358 | 1428 | 'id' => $row['id_group'], |
@@ -1427,8 +1497,9 @@ discard block |
||
| 1427 | 1497 | |
| 1428 | 1498 | if (!empty($row['id_board'])) |
| 1429 | 1499 | { |
| 1430 | - if ($row['child_level'] != $curLevel) |
|
| 1431 | - $prevBoard = 0; |
|
| 1500 | + if ($row['child_level'] != $curLevel) { |
|
| 1501 | + $prevBoard = 0; |
|
| 1502 | + } |
|
| 1432 | 1503 | |
| 1433 | 1504 | $boards[$row['id_board']] = array( |
| 1434 | 1505 | 'id' => $row['id_board'], |
@@ -1460,16 +1531,16 @@ discard block |
||
| 1460 | 1531 | 'children' => array() |
| 1461 | 1532 | ); |
| 1462 | 1533 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
| 1463 | - } |
|
| 1464 | - else |
|
| 1534 | + } else |
|
| 1465 | 1535 | { |
| 1466 | 1536 | // Parent doesn't exist! |
| 1467 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
| 1468 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
| 1537 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
| 1538 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
| 1539 | + } |
|
| 1469 | 1540 | |
| 1470 | 1541 | // Wrong childlevel...we can silently fix this... |
| 1471 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
| 1472 | - $smcFunc['db_query']('', ' |
|
| 1542 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
| 1543 | + $smcFunc['db_query']('', ' |
|
| 1473 | 1544 | UPDATE {db_prefix}boards |
| 1474 | 1545 | SET child_level = {int:new_child_level} |
| 1475 | 1546 | WHERE id_board = {int:selected_board}', |
@@ -1478,6 +1549,7 @@ discard block |
||
| 1478 | 1549 | 'selected_board' => $row['id_board'], |
| 1479 | 1550 | ) |
| 1480 | 1551 | ); |
| 1552 | + } |
|
| 1481 | 1553 | |
| 1482 | 1554 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
| 1483 | 1555 | 'node' => &$boards[$row['id_board']], |
@@ -1511,8 +1583,9 @@ discard block |
||
| 1511 | 1583 | */ |
| 1512 | 1584 | function recursiveBoards(&$_boardList, &$_tree) |
| 1513 | 1585 | { |
| 1514 | - if (empty($_tree['children'])) |
|
| 1515 | - return; |
|
| 1586 | + if (empty($_tree['children'])) { |
|
| 1587 | + return; |
|
| 1588 | + } |
|
| 1516 | 1589 | |
| 1517 | 1590 | foreach ($_tree['children'] as $id => $node) |
| 1518 | 1591 | { |
@@ -1531,11 +1604,13 @@ discard block |
||
| 1531 | 1604 | { |
| 1532 | 1605 | global $boards; |
| 1533 | 1606 | |
| 1534 | - if (empty($boards[$child]['parent'])) |
|
| 1535 | - return false; |
|
| 1607 | + if (empty($boards[$child]['parent'])) { |
|
| 1608 | + return false; |
|
| 1609 | + } |
|
| 1536 | 1610 | |
| 1537 | - if ($boards[$child]['parent'] == $parent) |
|
| 1538 | - return true; |
|
| 1611 | + if ($boards[$child]['parent'] == $parent) { |
|
| 1612 | + return true; |
|
| 1613 | + } |
|
| 1539 | 1614 | |
| 1540 | 1615 | return isChildOf($boards[$child]['parent'], $parent); |
| 1541 | 1616 | } |