@@ -5265,7 +5265,6 @@ discard block |
||
5265 | 5265 | |
5266 | 5266 | /** |
5267 | 5267 | * Tries different modes to make file/dirs writable. Wrapper function for chmod() |
5268 | - |
|
5269 | 5268 | * @param string $file The file/dir full path. |
5270 | 5269 | * @param int $value Not needed, added for legacy reasons. |
5271 | 5270 | * @return boolean true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable. |
@@ -5305,7 +5304,6 @@ discard block |
||
5305 | 5304 | |
5306 | 5305 | /** |
5307 | 5306 | * Wrapper function for json_decode() with error handling. |
5308 | - |
|
5309 | 5307 | * @param string $json The string to decode. |
5310 | 5308 | * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default. |
5311 | 5309 | * @param bool $logIt To specify if the error will be logged if theres any. |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | * - caches the formatting data from the setting for optimization. |
677 | 677 | * |
678 | 678 | * @param float $number A number |
679 | - * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
679 | + * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
680 | 680 | * @return string A formatted number |
681 | 681 | */ |
682 | 682 | function comma_format($number, $override_decimal_count = false) |
@@ -5530,7 +5530,7 @@ discard block |
||
5530 | 5530 | * It assumes the data is already a string. |
5531 | 5531 | * @param string $data The data to print |
5532 | 5532 | * @param string $type The content type. Defaults to Json. |
5533 | - * @return void |
|
5533 | + * @return false|null |
|
5534 | 5534 | */ |
5535 | 5535 | function smf_serverResponse($data = '', $type = 'Content-Type: application/json') |
5536 | 5536 | { |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | if (empty($low_id)) |
600 | 600 | $pageindex .= $start == 0 ? ' ' : sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
601 | 601 | else |
602 | - $pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L'.$low_id); |
|
602 | + $pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L' . $low_id); |
|
603 | 603 | |
604 | 604 | // Show all the pages. |
605 | 605 | $display_page = 1; |
@@ -608,11 +608,11 @@ discard block |
||
608 | 608 | |
609 | 609 | // Show the right arrow. |
610 | 610 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
611 | - if ($start != $counter - $max_value && !$start_invalid){ |
|
611 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
612 | 612 | if (empty($max_id)) |
613 | 613 | $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
614 | 614 | else |
615 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page , $settings['page_index']['next_page'], 'M'.$max_id); |
|
615 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page, $settings['page_index']['next_page'], 'M' . $max_id); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | if (empty($low_id)) |
627 | 627 | $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
628 | 628 | else |
629 | - $pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L'.$low_id); |
|
629 | + $pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L' . $low_id); |
|
630 | 630 | else |
631 | 631 | $pageindex .= ''; |
632 | 632 | |
@@ -648,10 +648,10 @@ discard block |
||
648 | 648 | if ($start >= $num_per_page * $nCont) |
649 | 649 | { |
650 | 650 | $tmpStart = $start - $num_per_page * $nCont; |
651 | - if($nCont != 1 || empty($low_id)) |
|
651 | + if ($nCont != 1 || empty($low_id)) |
|
652 | 652 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
653 | 653 | else |
654 | - $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L'.$low_id); |
|
654 | + $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L' . $low_id); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
@@ -666,10 +666,10 @@ discard block |
||
666 | 666 | if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
667 | 667 | { |
668 | 668 | $tmpStart = $start + $num_per_page * $nCont; |
669 | - if($nCont != 1 || empty($max_id)) |
|
669 | + if ($nCont != 1 || empty($max_id)) |
|
670 | 670 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
671 | 671 | else |
672 | - $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M'.$max_id); |
|
672 | + $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M' . $max_id); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | if (empty($max_id)) |
691 | 691 | $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
692 | 692 | else |
693 | - $pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M'.$max_id); |
|
693 | + $pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M' . $max_id); |
|
694 | 694 | } |
695 | 695 | $pageindex .= $settings['page_index']['extra_after']; |
696 | 696 | |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
1126 | 1126 | ), |
1127 | 1127 | 'content' => '$1', |
1128 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1128 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1129 | 1129 | { |
1130 | 1130 | $returnContext = ''; |
1131 | 1131 | |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
1163 | - $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>'; |
|
1163 | + $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>'; |
|
1164 | 1164 | else |
1165 | 1165 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
1166 | 1166 | } |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | 'type' => 'unparsed_content', |
1190 | 1190 | '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>', |
1191 | 1191 | // @todo Maybe this can be simplified? |
1192 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1192 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1193 | 1193 | { |
1194 | 1194 | if (!isset($disabled['code'])) |
1195 | 1195 | { |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | 'type' => 'unparsed_equals_content', |
1227 | 1227 | '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>', |
1228 | 1228 | // @todo Maybe this can be simplified? |
1229 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1229 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1230 | 1230 | { |
1231 | 1231 | if (!isset($disabled['code'])) |
1232 | 1232 | { |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | 'type' => 'unparsed_content', |
1271 | 1271 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
1272 | 1272 | // @todo Should this respect guest_hideContacts? |
1273 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1273 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1274 | 1274 | { |
1275 | 1275 | $data = strtr($data, array('<br>' => '')); |
1276 | 1276 | }, |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | 'type' => 'unparsed_commas_content', |
1290 | 1290 | 'test' => '\d+,\d+\]', |
1291 | 1291 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1292 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1292 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1293 | 1293 | { |
1294 | 1294 | if (isset($disabled['url'])) |
1295 | 1295 | $tag['content'] = '$1'; |
@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
1306 | 1306 | 'before' => '<div $1>', |
1307 | 1307 | 'after' => '</div>', |
1308 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1308 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1309 | 1309 | { |
1310 | 1310 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1311 | 1311 | |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
1355 | 1355 | ), |
1356 | 1356 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
1357 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1357 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1358 | 1358 | { |
1359 | 1359 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1360 | 1360 | |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | 'tag' => 'img', |
1378 | 1378 | 'type' => 'unparsed_content', |
1379 | 1379 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
1380 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1380 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1381 | 1381 | { |
1382 | 1382 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1383 | 1383 | |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | 'tag' => 'iurl', |
1401 | 1401 | 'type' => 'unparsed_content', |
1402 | 1402 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
1403 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1403 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1404 | 1404 | { |
1405 | 1405 | $data = strtr($data, array('<br>' => '')); |
1406 | 1406 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1414,7 +1414,7 @@ discard block |
||
1414 | 1414 | 'quoted' => 'optional', |
1415 | 1415 | 'before' => '<a href="$1" class="bbc_link">', |
1416 | 1416 | 'after' => '</a>', |
1417 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1417 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1418 | 1418 | { |
1419 | 1419 | if (substr($data, 0, 1) == '#') |
1420 | 1420 | $data = '#post_' . substr($data, 1); |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | 'tag' => 'php', |
1495 | 1495 | 'type' => 'unparsed_content', |
1496 | 1496 | 'content' => '<span class="phpcode">$1</span>', |
1497 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
1497 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
1498 | 1498 | { |
1499 | 1499 | if (!isset($disabled['php'])) |
1500 | 1500 | { |
@@ -1592,7 +1592,7 @@ discard block |
||
1592 | 1592 | 'test' => '[1-7]\]', |
1593 | 1593 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
1594 | 1594 | 'after' => '</span>', |
1595 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1595 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1596 | 1596 | { |
1597 | 1597 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
1598 | 1598 | $data = $sizes[$data] . 'em'; |
@@ -1630,7 +1630,7 @@ discard block |
||
1630 | 1630 | 'tag' => 'time', |
1631 | 1631 | 'type' => 'unparsed_content', |
1632 | 1632 | 'content' => '$1', |
1633 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1633 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1634 | 1634 | { |
1635 | 1635 | if (is_numeric($data)) |
1636 | 1636 | $data = timeformat($data); |
@@ -1658,7 +1658,7 @@ discard block |
||
1658 | 1658 | 'tag' => 'url', |
1659 | 1659 | 'type' => 'unparsed_content', |
1660 | 1660 | 'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>', |
1661 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1661 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1662 | 1662 | { |
1663 | 1663 | $data = strtr($data, array('<br>' => '')); |
1664 | 1664 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1672,7 +1672,7 @@ discard block |
||
1672 | 1672 | 'quoted' => 'optional', |
1673 | 1673 | 'before' => '<a href="$1" class="bbc_link" target="_blank">', |
1674 | 1674 | 'after' => '</a>', |
1675 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1675 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1676 | 1676 | { |
1677 | 1677 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1678 | 1678 | if (empty($scheme)) |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | { |
1699 | 1699 | if (isset($temp_bbc)) |
1700 | 1700 | $bbc_codes = $temp_bbc; |
1701 | - usort($codes, function ($a, $b) { |
|
1701 | + usort($codes, function($a, $b) { |
|
1702 | 1702 | return strcmp($a['tag'], $b['tag']); |
1703 | 1703 | }); |
1704 | 1704 | return $codes; |
@@ -1936,7 +1936,7 @@ discard block |
||
1936 | 1936 | # a run of Unicode domain name characters and a dot |
1937 | 1937 | [\p{L}\p{M}\p{N}\-.:@]+\. |
1938 | 1938 | # and then a TLD valid in the DNS or the reserved "local" TLD |
1939 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
1939 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
1940 | 1940 | ) |
1941 | 1941 | # followed by a non-domain character or end of line |
1942 | 1942 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | )? |
2005 | 2005 | '; |
2006 | 2006 | |
2007 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
2007 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
2008 | 2008 | $url = array_shift($matches); |
2009 | 2009 | |
2010 | 2010 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2741,7 +2741,7 @@ discard block |
||
2741 | 2741 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
2742 | 2742 | { |
2743 | 2743 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
2744 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2744 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2745 | 2745 | |
2746 | 2746 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
2747 | 2747 | |
@@ -2758,7 +2758,7 @@ discard block |
||
2758 | 2758 | |
2759 | 2759 | // Replace away! |
2760 | 2760 | $message = preg_replace_callback($smileyPregSearch, |
2761 | - function ($matches) use ($smileyPregReplacements) |
|
2761 | + function($matches) use ($smileyPregReplacements) |
|
2762 | 2762 | { |
2763 | 2763 | return $smileyPregReplacements[$matches[1]]; |
2764 | 2764 | }, $message); |
@@ -2824,13 +2824,13 @@ discard block |
||
2824 | 2824 | { |
2825 | 2825 | if (defined('SID') && SID != '') |
2826 | 2826 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
2827 | - function ($m) use ($scripturl) |
|
2827 | + function($m) use ($scripturl) |
|
2828 | 2828 | { |
2829 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
2829 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
2830 | 2830 | }, $setLocation); |
2831 | 2831 | else |
2832 | 2832 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
2833 | - function ($m) use ($scripturl) |
|
2833 | + function($m) use ($scripturl) |
|
2834 | 2834 | { |
2835 | 2835 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
2836 | 2836 | }, $setLocation); |
@@ -3153,7 +3153,7 @@ discard block |
||
3153 | 3153 | |
3154 | 3154 | // Add a generic "Are you sure?" confirmation message. |
3155 | 3155 | addInlineJavaScript(' |
3156 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
3156 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
3157 | 3157 | |
3158 | 3158 | // Now add the capping code for avatars. |
3159 | 3159 | 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') |
@@ -3514,7 +3514,7 @@ discard block |
||
3514 | 3514 | |
3515 | 3515 | else |
3516 | 3516 | echo ' |
3517 | - <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
|
3517 | + <script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>'; |
|
3518 | 3518 | } |
3519 | 3519 | |
3520 | 3520 | // Inline JavaScript - Actually useful some times! |
@@ -3592,14 +3592,14 @@ discard block |
||
3592 | 3592 | |
3593 | 3593 | else |
3594 | 3594 | echo ' |
3595 | - <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
|
3595 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">'; |
|
3596 | 3596 | } |
3597 | 3597 | |
3598 | 3598 | // Print the rest after the minified files. |
3599 | 3599 | if (!empty($normal)) |
3600 | 3600 | foreach ($normal as $nf) |
3601 | 3601 | echo ' |
3602 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
3602 | + <link rel="stylesheet" href="', $nf, '">'; |
|
3603 | 3603 | |
3604 | 3604 | if ($db_show_debug === true) |
3605 | 3605 | { |
@@ -3615,7 +3615,7 @@ discard block |
||
3615 | 3615 | <style>'; |
3616 | 3616 | |
3617 | 3617 | foreach ($context['css_header'] as $css) |
3618 | - echo $css .' |
|
3618 | + echo $css . ' |
|
3619 | 3619 | '; |
3620 | 3620 | |
3621 | 3621 | echo' |
@@ -3644,27 +3644,27 @@ discard block |
||
3644 | 3644 | return false; |
3645 | 3645 | |
3646 | 3646 | // Did we already did this? |
3647 | - $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
|
3647 | + $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400); |
|
3648 | 3648 | |
3649 | 3649 | // Already done? |
3650 | 3650 | if (!empty($toCache)) |
3651 | 3651 | return true; |
3652 | 3652 | |
3653 | 3653 | // No namespaces, sorry! |
3654 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
3654 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
3655 | 3655 | |
3656 | 3656 | // Temp path. |
3657 | - $cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/'; |
|
3657 | + $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
|
3658 | 3658 | |
3659 | 3659 | // What kind of file are we going to create? |
3660 | - $toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type; |
|
3660 | + $toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type; |
|
3661 | 3661 | |
3662 | 3662 | // File has to exists, if it isn't try to create it. |
3663 | 3663 | if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate)) |
3664 | 3664 | { |
3665 | 3665 | loadLanguage('Errors'); |
3666 | 3666 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
3667 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
3667 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
3668 | 3668 | |
3669 | 3669 | // The process failed so roll back to print each individual file. |
3670 | 3670 | return $data; |
@@ -3699,14 +3699,14 @@ discard block |
||
3699 | 3699 | { |
3700 | 3700 | loadLanguage('Errors'); |
3701 | 3701 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
3702 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
3702 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
3703 | 3703 | |
3704 | 3704 | // The process failed so roll back to print each individual file. |
3705 | 3705 | return $data; |
3706 | 3706 | } |
3707 | 3707 | |
3708 | 3708 | // And create a long lived cache entry. |
3709 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400); |
|
3709 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400); |
|
3710 | 3710 | |
3711 | 3711 | return true; |
3712 | 3712 | } |
@@ -3766,7 +3766,7 @@ discard block |
||
3766 | 3766 | else |
3767 | 3767 | $path = $modSettings['attachmentUploadDir']; |
3768 | 3768 | |
3769 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
3769 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
3770 | 3770 | } |
3771 | 3771 | |
3772 | 3772 | /** |
@@ -3810,10 +3810,10 @@ discard block |
||
3810 | 3810 | $valid_low = isValidIP($ip_parts[0]); |
3811 | 3811 | $valid_high = isValidIP($ip_parts[1]); |
3812 | 3812 | $count = 0; |
3813 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
3813 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
3814 | 3814 | $max = ($mode == ':' ? 'ffff' : '255'); |
3815 | 3815 | $min = 0; |
3816 | - if(!$valid_low) |
|
3816 | + if (!$valid_low) |
|
3817 | 3817 | { |
3818 | 3818 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
3819 | 3819 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3827,7 +3827,7 @@ discard block |
||
3827 | 3827 | } |
3828 | 3828 | |
3829 | 3829 | $count = 0; |
3830 | - if(!$valid_high) |
|
3830 | + if (!$valid_high) |
|
3831 | 3831 | { |
3832 | 3832 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
3833 | 3833 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3840,7 +3840,7 @@ discard block |
||
3840 | 3840 | } |
3841 | 3841 | } |
3842 | 3842 | |
3843 | - if($valid_high && $valid_low) |
|
3843 | + if ($valid_high && $valid_low) |
|
3844 | 3844 | { |
3845 | 3845 | $ip_array['low'] = $ip_parts[0]; |
3846 | 3846 | $ip_array['high'] = $ip_parts[1]; |
@@ -4022,7 +4022,7 @@ discard block |
||
4022 | 4022 | addInlineJavaScript(' |
4023 | 4023 | var user_menus = new smc_PopupMenu(); |
4024 | 4024 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4025 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
4025 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
4026 | 4026 | if ($context['allow_pm']) |
4027 | 4027 | addInlineJavaScript(' |
4028 | 4028 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4644,7 +4644,7 @@ discard block |
||
4644 | 4644 | // No? try a fallback to $sourcedir |
4645 | 4645 | else |
4646 | 4646 | { |
4647 | - $absPath = $sourcedir .'/'. $file; |
|
4647 | + $absPath = $sourcedir . '/' . $file; |
|
4648 | 4648 | |
4649 | 4649 | if (file_exists($absPath)) |
4650 | 4650 | require_once($absPath); |
@@ -4725,15 +4725,15 @@ discard block |
||
4725 | 4725 | |
4726 | 4726 | // UTF-8 occurences of MS special characters |
4727 | 4727 | $findchars_utf8 = array( |
4728 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
4729 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
4730 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
4731 | - "\xe2\x80\x98", // left single curly quote |
|
4732 | - "\xe2\x80\x99", // right single curly quote |
|
4733 | - "\xe2\x80\x9c", // left double curly quote |
|
4734 | - "\xe2\x80\x9d", // right double curly quote |
|
4735 | - "\xe2\x80\x93", // en dash |
|
4736 | - "\xe2\x80\x94", // em dash |
|
4728 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
4729 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
4730 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
4731 | + "\xe2\x80\x98", // left single curly quote |
|
4732 | + "\xe2\x80\x99", // right single curly quote |
|
4733 | + "\xe2\x80\x9c", // left double curly quote |
|
4734 | + "\xe2\x80\x9d", // right double curly quote |
|
4735 | + "\xe2\x80\x93", // en dash |
|
4736 | + "\xe2\x80\x94", // em dash |
|
4737 | 4737 | ); |
4738 | 4738 | |
4739 | 4739 | // windows 1252 / iso equivalents |
@@ -4751,15 +4751,15 @@ discard block |
||
4751 | 4751 | |
4752 | 4752 | // safe replacements |
4753 | 4753 | $replacechars = array( |
4754 | - ',', // ‚ |
|
4755 | - ',,', // „ |
|
4756 | - '...', // … |
|
4757 | - "'", // ‘ |
|
4758 | - "'", // ’ |
|
4759 | - '"', // “ |
|
4760 | - '"', // ” |
|
4761 | - '-', // – |
|
4762 | - '--', // — |
|
4754 | + ',', // ‚ |
|
4755 | + ',,', // „ |
|
4756 | + '...', // … |
|
4757 | + "'", // ‘ |
|
4758 | + "'", // ’ |
|
4759 | + '"', // “ |
|
4760 | + '"', // ” |
|
4761 | + '-', // – |
|
4762 | + '--', // — |
|
4763 | 4763 | ); |
4764 | 4764 | |
4765 | 4765 | if ($context['utf8']) |
@@ -5177,7 +5177,7 @@ discard block |
||
5177 | 5177 | */ |
5178 | 5178 | function inet_dtop($bin) |
5179 | 5179 | { |
5180 | - if(empty($bin)) |
|
5180 | + if (empty($bin)) |
|
5181 | 5181 | return ''; |
5182 | 5182 | |
5183 | 5183 | global $db_type; |
@@ -5208,28 +5208,28 @@ discard block |
||
5208 | 5208 | */ |
5209 | 5209 | function _safe_serialize($value) |
5210 | 5210 | { |
5211 | - if(is_null($value)) |
|
5211 | + if (is_null($value)) |
|
5212 | 5212 | return 'N;'; |
5213 | 5213 | |
5214 | - if(is_bool($value)) |
|
5215 | - return 'b:'. (int) $value .';'; |
|
5214 | + if (is_bool($value)) |
|
5215 | + return 'b:' . (int) $value . ';'; |
|
5216 | 5216 | |
5217 | - if(is_int($value)) |
|
5218 | - return 'i:'. $value .';'; |
|
5217 | + if (is_int($value)) |
|
5218 | + return 'i:' . $value . ';'; |
|
5219 | 5219 | |
5220 | - if(is_float($value)) |
|
5221 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5220 | + if (is_float($value)) |
|
5221 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
5222 | 5222 | |
5223 | - if(is_string($value)) |
|
5224 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5223 | + if (is_string($value)) |
|
5224 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
5225 | 5225 | |
5226 | - if(is_array($value)) |
|
5226 | + if (is_array($value)) |
|
5227 | 5227 | { |
5228 | 5228 | $out = ''; |
5229 | - foreach($value as $k => $v) |
|
5229 | + foreach ($value as $k => $v) |
|
5230 | 5230 | $out .= _safe_serialize($k) . _safe_serialize($v); |
5231 | 5231 | |
5232 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
5232 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
5233 | 5233 | } |
5234 | 5234 | |
5235 | 5235 | // safe_serialize cannot serialize resources or objects. |
@@ -5271,7 +5271,7 @@ discard block |
||
5271 | 5271 | function _safe_unserialize($str) |
5272 | 5272 | { |
5273 | 5273 | // Input is not a string. |
5274 | - if(empty($str) || !is_string($str)) |
|
5274 | + if (empty($str) || !is_string($str)) |
|
5275 | 5275 | return false; |
5276 | 5276 | |
5277 | 5277 | $stack = array(); |
@@ -5285,40 +5285,40 @@ discard block |
||
5285 | 5285 | * 3 - in array, expecting value or another array |
5286 | 5286 | */ |
5287 | 5287 | $state = 0; |
5288 | - while($state != 1) |
|
5288 | + while ($state != 1) |
|
5289 | 5289 | { |
5290 | 5290 | $type = isset($str[0]) ? $str[0] : ''; |
5291 | - if($type == '}') |
|
5291 | + if ($type == '}') |
|
5292 | 5292 | $str = substr($str, 1); |
5293 | 5293 | |
5294 | - else if($type == 'N' && $str[1] == ';') |
|
5294 | + else if ($type == 'N' && $str[1] == ';') |
|
5295 | 5295 | { |
5296 | 5296 | $value = null; |
5297 | 5297 | $str = substr($str, 2); |
5298 | 5298 | } |
5299 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5299 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5300 | 5300 | { |
5301 | 5301 | $value = $matches[1] == '1' ? true : false; |
5302 | 5302 | $str = substr($str, 4); |
5303 | 5303 | } |
5304 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5304 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5305 | 5305 | { |
5306 | - $value = (int)$matches[1]; |
|
5306 | + $value = (int) $matches[1]; |
|
5307 | 5307 | $str = $matches[2]; |
5308 | 5308 | } |
5309 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5309 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5310 | 5310 | { |
5311 | - $value = (float)$matches[1]; |
|
5311 | + $value = (float) $matches[1]; |
|
5312 | 5312 | $str = $matches[3]; |
5313 | 5313 | } |
5314 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5314 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
5315 | 5315 | { |
5316 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
5317 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
5316 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
5317 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
5318 | 5318 | } |
5319 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5319 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5320 | 5320 | { |
5321 | - $expectedLength = (int)$matches[1]; |
|
5321 | + $expectedLength = (int) $matches[1]; |
|
5322 | 5322 | $str = $matches[2]; |
5323 | 5323 | } |
5324 | 5324 | |
@@ -5326,10 +5326,10 @@ discard block |
||
5326 | 5326 | else |
5327 | 5327 | return false; |
5328 | 5328 | |
5329 | - switch($state) |
|
5329 | + switch ($state) |
|
5330 | 5330 | { |
5331 | 5331 | case 3: // In array, expecting value or another array. |
5332 | - if($type == 'a') |
|
5332 | + if ($type == 'a') |
|
5333 | 5333 | { |
5334 | 5334 | $stack[] = &$list; |
5335 | 5335 | $list[$key] = array(); |
@@ -5338,7 +5338,7 @@ discard block |
||
5338 | 5338 | $state = 2; |
5339 | 5339 | break; |
5340 | 5340 | } |
5341 | - if($type != '}') |
|
5341 | + if ($type != '}') |
|
5342 | 5342 | { |
5343 | 5343 | $list[$key] = $value; |
5344 | 5344 | $state = 2; |
@@ -5349,29 +5349,29 @@ discard block |
||
5349 | 5349 | return false; |
5350 | 5350 | |
5351 | 5351 | case 2: // in array, expecting end of array or a key |
5352 | - if($type == '}') |
|
5352 | + if ($type == '}') |
|
5353 | 5353 | { |
5354 | 5354 | // Array size is less than expected. |
5355 | - if(count($list) < end($expected)) |
|
5355 | + if (count($list) < end($expected)) |
|
5356 | 5356 | return false; |
5357 | 5357 | |
5358 | 5358 | unset($list); |
5359 | - $list = &$stack[count($stack)-1]; |
|
5359 | + $list = &$stack[count($stack) - 1]; |
|
5360 | 5360 | array_pop($stack); |
5361 | 5361 | |
5362 | 5362 | // Go to terminal state if we're at the end of the root array. |
5363 | 5363 | array_pop($expected); |
5364 | 5364 | |
5365 | - if(count($expected) == 0) |
|
5365 | + if (count($expected) == 0) |
|
5366 | 5366 | $state = 1; |
5367 | 5367 | |
5368 | 5368 | break; |
5369 | 5369 | } |
5370 | 5370 | |
5371 | - if($type == 'i' || $type == 's') |
|
5371 | + if ($type == 'i' || $type == 's') |
|
5372 | 5372 | { |
5373 | 5373 | // Array size exceeds expected length. |
5374 | - if(count($list) >= end($expected)) |
|
5374 | + if (count($list) >= end($expected)) |
|
5375 | 5375 | return false; |
5376 | 5376 | |
5377 | 5377 | $key = $value; |
@@ -5384,7 +5384,7 @@ discard block |
||
5384 | 5384 | |
5385 | 5385 | // Expecting array or value. |
5386 | 5386 | case 0: |
5387 | - if($type == 'a') |
|
5387 | + if ($type == 'a') |
|
5388 | 5388 | { |
5389 | 5389 | $data = array(); |
5390 | 5390 | $list = &$data; |
@@ -5393,7 +5393,7 @@ discard block |
||
5393 | 5393 | break; |
5394 | 5394 | } |
5395 | 5395 | |
5396 | - if($type != '}') |
|
5396 | + if ($type != '}') |
|
5397 | 5397 | { |
5398 | 5398 | $data = $value; |
5399 | 5399 | $state = 1; |
@@ -5406,7 +5406,7 @@ discard block |
||
5406 | 5406 | } |
5407 | 5407 | |
5408 | 5408 | // Trailing data in input. |
5409 | - if(!empty($str)) |
|
5409 | + if (!empty($str)) |
|
5410 | 5410 | return false; |
5411 | 5411 | |
5412 | 5412 | return $data; |
@@ -5460,7 +5460,7 @@ discard block |
||
5460 | 5460 | // Set different modes. |
5461 | 5461 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
5462 | 5462 | |
5463 | - foreach($chmodValues as $val) |
|
5463 | + foreach ($chmodValues as $val) |
|
5464 | 5464 | { |
5465 | 5465 | // If it's writable, break out of the loop. |
5466 | 5466 | if (is_writable($file)) |
@@ -5495,13 +5495,13 @@ discard block |
||
5495 | 5495 | $returnArray = @json_decode($json, $returnAsArray); |
5496 | 5496 | |
5497 | 5497 | // PHP 5.3 so no json_last_error_msg() |
5498 | - switch(json_last_error()) |
|
5498 | + switch (json_last_error()) |
|
5499 | 5499 | { |
5500 | 5500 | case JSON_ERROR_NONE: |
5501 | 5501 | $jsonError = false; |
5502 | 5502 | break; |
5503 | 5503 | case JSON_ERROR_DEPTH: |
5504 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
5504 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
5505 | 5505 | break; |
5506 | 5506 | case JSON_ERROR_STATE_MISMATCH: |
5507 | 5507 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5529,10 +5529,10 @@ discard block |
||
5529 | 5529 | loadLanguage('Errors'); |
5530 | 5530 | |
5531 | 5531 | if (!empty($jsonDebug)) |
5532 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5532 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5533 | 5533 | |
5534 | 5534 | else |
5535 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5535 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
5536 | 5536 | |
5537 | 5537 | // Everyone expects an array. |
5538 | 5538 | return array(); |
@@ -5636,7 +5636,7 @@ discard block |
||
5636 | 5636 | }); |
5637 | 5637 | |
5638 | 5638 | // Convert Punycode to Unicode |
5639 | - $tlds = array_map(function ($input) { |
|
5639 | + $tlds = array_map(function($input) { |
|
5640 | 5640 | $prefix = 'xn--'; |
5641 | 5641 | $safe_char = 0xFFFC; |
5642 | 5642 | $base = 36; |
@@ -5652,7 +5652,7 @@ discard block |
||
5652 | 5652 | |
5653 | 5653 | foreach ($enco_parts as $encoded) |
5654 | 5654 | { |
5655 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
5655 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
5656 | 5656 | { |
5657 | 5657 | $output_parts[] = $encoded; |
5658 | 5658 | continue; |
@@ -5663,7 +5663,7 @@ discard block |
||
5663 | 5663 | $idx = 0; |
5664 | 5664 | $char = 0x80; |
5665 | 5665 | $decoded = array(); |
5666 | - $output=''; |
|
5666 | + $output = ''; |
|
5667 | 5667 | $delim_pos = strrpos($encoded, '-'); |
5668 | 5668 | |
5669 | 5669 | if ($delim_pos > strlen($prefix)) |
@@ -5679,7 +5679,7 @@ discard block |
||
5679 | 5679 | |
5680 | 5680 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
5681 | 5681 | { |
5682 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
5682 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
5683 | 5683 | { |
5684 | 5684 | $cp = ord($encoded{$enco_idx++}); |
5685 | 5685 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5720,15 +5720,15 @@ discard block |
||
5720 | 5720 | |
5721 | 5721 | // 2 bytes |
5722 | 5722 | elseif ($v < (1 << 11)) |
5723 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
5723 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
5724 | 5724 | |
5725 | 5725 | // 3 bytes |
5726 | 5726 | elseif ($v < (1 << 16)) |
5727 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5727 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5728 | 5728 | |
5729 | 5729 | // 4 bytes |
5730 | 5730 | elseif ($v < (1 << 21)) |
5731 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5731 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5732 | 5732 | |
5733 | 5733 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5734 | 5734 | else |
@@ -5835,7 +5835,7 @@ discard block |
||
5835 | 5835 | } |
5836 | 5836 | |
5837 | 5837 | // This recursive function creates the index array from the strings |
5838 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5838 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5839 | 5839 | { |
5840 | 5840 | static $depth = 0; |
5841 | 5841 | $depth++; |
@@ -5862,7 +5862,7 @@ discard block |
||
5862 | 5862 | }; |
5863 | 5863 | |
5864 | 5864 | // This recursive function turns the index array into a regular expression |
5865 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5865 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5866 | 5866 | { |
5867 | 5867 | static $depth = 0; |
5868 | 5868 | $depth++; |
@@ -5886,11 +5886,11 @@ discard block |
||
5886 | 5886 | |
5887 | 5887 | if (count(array_keys($value)) == 1) |
5888 | 5888 | { |
5889 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
5889 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
5890 | 5890 | $new_key .= $new_key_array[0]; |
5891 | 5891 | } |
5892 | 5892 | else |
5893 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5893 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
5894 | 5894 | } |
5895 | 5895 | |
5896 | 5896 | if ($depth > 1) |
@@ -5930,7 +5930,7 @@ discard block |
||
5930 | 5930 | $index = $add_string_to_index($string, $index); |
5931 | 5931 | |
5932 | 5932 | while (!empty($index)) |
5933 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
5933 | + $regexes[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
5934 | 5934 | |
5935 | 5935 | // Restore PHP's internal character encoding to whatever it was originally |
5936 | 5936 | if (!empty($current_encoding)) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
122 | 123 | $smcFunc['db_free_result']($result); |
123 | 124 | |
124 | 125 | // Add this to the number of unapproved members |
125 | - if (!empty($changes['unapprovedMembers'])) |
|
126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
127 | - else |
|
128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
126 | + if (!empty($changes['unapprovedMembers'])) { |
|
127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
128 | + } else { |
|
129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
130 | + } |
|
129 | 131 | } |
130 | 132 | } |
131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
133 | 135 | break; |
134 | 136 | |
135 | 137 | case 'message': |
136 | - if ($parameter1 === true && $parameter2 !== null) |
|
137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
138 | - else |
|
138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
140 | + } else |
|
139 | 141 | { |
140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
175 | 177 | $parameter2 = text2words($parameter2); |
176 | 178 | |
177 | 179 | $inserts = array(); |
178 | - foreach ($parameter2 as $word) |
|
179 | - $inserts[] = array($word, $parameter1); |
|
180 | + foreach ($parameter2 as $word) { |
|
181 | + $inserts[] = array($word, $parameter1); |
|
182 | + } |
|
180 | 183 | |
181 | - if (!empty($inserts)) |
|
182 | - $smcFunc['db_insert']('ignore', |
|
184 | + if (!empty($inserts)) { |
|
185 | + $smcFunc['db_insert']('ignore', |
|
183 | 186 | '{db_prefix}log_search_subjects', |
184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
185 | 188 | $inserts, |
186 | 189 | array('word', 'id_topic') |
187 | 190 | ); |
191 | + } |
|
188 | 192 | } |
189 | 193 | break; |
190 | 194 | |
191 | 195 | case 'topic': |
192 | - if ($parameter1 === true) |
|
193 | - updateSettings(array('totalTopics' => true), true); |
|
194 | - else |
|
196 | + if ($parameter1 === true) { |
|
197 | + updateSettings(array('totalTopics' => true), true); |
|
198 | + } else |
|
195 | 199 | { |
196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
212 | 216 | |
213 | 217 | case 'postgroups': |
214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
216 | - return; |
|
219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
220 | + return; |
|
221 | + } |
|
217 | 222 | |
218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
228 | 233 | ) |
229 | 234 | ); |
230 | 235 | $postgroups = array(); |
231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
238 | + } |
|
233 | 239 | $smcFunc['db_free_result']($request); |
234 | 240 | |
235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
239 | 245 | } |
240 | 246 | |
241 | 247 | // Oh great, they've screwed their post groups. |
242 | - if (empty($postgroups)) |
|
243 | - return; |
|
248 | + if (empty($postgroups)) { |
|
249 | + return; |
|
250 | + } |
|
244 | 251 | |
245 | 252 | // Set all membergroups from most posts to least posts. |
246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
298 | 305 | { |
299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
300 | 307 | $parameters['members'] = $members; |
301 | - } |
|
302 | - elseif ($members === null) |
|
303 | - $condition = '1=1'; |
|
304 | - else |
|
308 | + } elseif ($members === null) { |
|
309 | + $condition = '1=1'; |
|
310 | + } else |
|
305 | 311 | { |
306 | 312 | $condition = 'id_member = {int:member}'; |
307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
341 | 347 | if (count($vars_to_integrate) != 0) |
342 | 348 | { |
343 | 349 | // Fetch a list of member_names if necessary |
344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
345 | - $member_names = array($user_info['username']); |
|
346 | - else |
|
350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
351 | + $member_names = array($user_info['username']); |
|
352 | + } else |
|
347 | 353 | { |
348 | 354 | $member_names = array(); |
349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
352 | 358 | WHERE ' . $condition, |
353 | 359 | $parameters |
354 | 360 | ); |
355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
356 | - $member_names[] = $row['member_name']; |
|
361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
362 | + $member_names[] = $row['member_name']; |
|
363 | + } |
|
357 | 364 | $smcFunc['db_free_result']($request); |
358 | 365 | } |
359 | 366 | |
360 | - if (!empty($member_names)) |
|
361 | - foreach ($vars_to_integrate as $var) |
|
367 | + if (!empty($member_names)) { |
|
368 | + foreach ($vars_to_integrate as $var) |
|
362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
370 | + } |
|
363 | 371 | } |
364 | 372 | } |
365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
367 | 375 | foreach ($data as $var => $val) |
368 | 376 | { |
369 | 377 | $type = 'string'; |
370 | - if (in_array($var, $knownInts)) |
|
371 | - $type = 'int'; |
|
372 | - elseif (in_array($var, $knownFloats)) |
|
373 | - $type = 'float'; |
|
374 | - elseif ($var == 'birthdate') |
|
375 | - $type = 'date'; |
|
376 | - elseif ($var == 'member_ip') |
|
377 | - $type = 'inet'; |
|
378 | - elseif ($var == 'member_ip2') |
|
379 | - $type = 'inet'; |
|
378 | + if (in_array($var, $knownInts)) { |
|
379 | + $type = 'int'; |
|
380 | + } elseif (in_array($var, $knownFloats)) { |
|
381 | + $type = 'float'; |
|
382 | + } elseif ($var == 'birthdate') { |
|
383 | + $type = 'date'; |
|
384 | + } elseif ($var == 'member_ip') { |
|
385 | + $type = 'inet'; |
|
386 | + } elseif ($var == 'member_ip2') { |
|
387 | + $type = 'inet'; |
|
388 | + } |
|
380 | 389 | |
381 | 390 | // Doing an increment? |
382 | 391 | if ($type == 'int' && ($val === '+' || $val === '-')) |
@@ -390,8 +399,9 @@ discard block |
||
390 | 399 | { |
391 | 400 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
392 | 401 | { |
393 | - if ($match[1] != '+ ') |
|
394 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
402 | + if ($match[1] != '+ ') { |
|
403 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
404 | + } |
|
395 | 405 | $type = 'raw'; |
396 | 406 | } |
397 | 407 | } |
@@ -412,8 +422,9 @@ discard block |
||
412 | 422 | // Clear any caching? |
413 | 423 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
414 | 424 | { |
415 | - if (!is_array($members)) |
|
416 | - $members = array($members); |
|
425 | + if (!is_array($members)) { |
|
426 | + $members = array($members); |
|
427 | + } |
|
417 | 428 | |
418 | 429 | foreach ($members as $member) |
419 | 430 | { |
@@ -446,29 +457,32 @@ discard block |
||
446 | 457 | { |
447 | 458 | global $modSettings, $smcFunc; |
448 | 459 | |
449 | - if (empty($changeArray) || !is_array($changeArray)) |
|
450 | - return; |
|
460 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
461 | + return; |
|
462 | + } |
|
451 | 463 | |
452 | 464 | $toRemove = array(); |
453 | 465 | |
454 | 466 | // Go check if there is any setting to be removed. |
455 | - foreach ($changeArray as $k => $v) |
|
456 | - if ($v === null) |
|
467 | + foreach ($changeArray as $k => $v) { |
|
468 | + if ($v === null) |
|
457 | 469 | { |
458 | 470 | // Found some, remove them from the original array and add them to ours. |
459 | 471 | unset($changeArray[$k]); |
472 | + } |
|
460 | 473 | $toRemove[] = $k; |
461 | 474 | } |
462 | 475 | |
463 | 476 | // Proceed with the deletion. |
464 | - if (!empty($toRemove)) |
|
465 | - $smcFunc['db_query']('', ' |
|
477 | + if (!empty($toRemove)) { |
|
478 | + $smcFunc['db_query']('', ' |
|
466 | 479 | DELETE FROM {db_prefix}settings |
467 | 480 | WHERE variable IN ({array_string:remove})', |
468 | 481 | array( |
469 | 482 | 'remove' => $toRemove, |
470 | 483 | ) |
471 | 484 | ); |
485 | + } |
|
472 | 486 | |
473 | 487 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
474 | 488 | if ($update) |
@@ -497,19 +511,22 @@ discard block |
||
497 | 511 | foreach ($changeArray as $variable => $value) |
498 | 512 | { |
499 | 513 | // Don't bother if it's already like that ;). |
500 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
501 | - continue; |
|
514 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
515 | + continue; |
|
516 | + } |
|
502 | 517 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
503 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
504 | - continue; |
|
518 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
519 | + continue; |
|
520 | + } |
|
505 | 521 | |
506 | 522 | $replaceArray[] = array($variable, $value); |
507 | 523 | |
508 | 524 | $modSettings[$variable] = $value; |
509 | 525 | } |
510 | 526 | |
511 | - if (empty($replaceArray)) |
|
512 | - return; |
|
527 | + if (empty($replaceArray)) { |
|
528 | + return; |
|
529 | + } |
|
513 | 530 | |
514 | 531 | $smcFunc['db_insert']('replace', |
515 | 532 | '{db_prefix}settings', |
@@ -555,20 +572,25 @@ discard block |
||
555 | 572 | $start = (int) $start; |
556 | 573 | $start_invalid = $start < 0; |
557 | 574 | |
558 | - if (!empty($options['low_id'])) |
|
559 | - $low_id = $options['low_id']; |
|
560 | - if (!empty($options['max_id'])) |
|
561 | - $max_id = $options['max_id']; |
|
575 | + if (!empty($options['low_id'])) { |
|
576 | + $low_id = $options['low_id']; |
|
577 | + } |
|
578 | + if (!empty($options['max_id'])) { |
|
579 | + $max_id = $options['max_id']; |
|
580 | + } |
|
562 | 581 | |
563 | 582 | // Make sure $start is a proper variable - not less than 0. |
564 | - if ($start_invalid) |
|
565 | - $start = 0; |
|
583 | + if ($start_invalid) { |
|
584 | + $start = 0; |
|
585 | + } |
|
566 | 586 | // Not greater than the upper bound. |
567 | - elseif ($start >= $max_value) |
|
568 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
587 | + elseif ($start >= $max_value) { |
|
588 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
589 | + } |
|
569 | 590 | // And it has to be a multiple of $num_per_page! |
570 | - else |
|
571 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
591 | + else { |
|
592 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
593 | + } |
|
572 | 594 | |
573 | 595 | $context['current_page'] = $start / $num_per_page; |
574 | 596 | |
@@ -596,101 +618,115 @@ discard block |
||
596 | 618 | if (empty($modSettings['compactTopicPagesEnable'])) |
597 | 619 | { |
598 | 620 | // Show the left arrow. |
599 | - if (empty($low_id)) |
|
600 | - $pageindex .= $start == 0 ? ' ' : sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
601 | - else |
|
602 | - $pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L'.$low_id); |
|
621 | + if (empty($low_id)) { |
|
622 | + $pageindex .= $start == 0 ? ' ' : sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
623 | + } else { |
|
624 | + $pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L'.$low_id); |
|
625 | + } |
|
603 | 626 | |
604 | 627 | // Show all the pages. |
605 | 628 | $display_page = 1; |
606 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
607 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
629 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
630 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
631 | + } |
|
608 | 632 | |
609 | 633 | // Show the right arrow. |
610 | 634 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
611 | 635 | if ($start != $counter - $max_value && !$start_invalid){ |
612 | - if (empty($max_id)) |
|
613 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
614 | - else |
|
615 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page , $settings['page_index']['next_page'], 'M'.$max_id); |
|
636 | + if (empty($max_id)) { |
|
637 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
638 | + } else { |
|
639 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page , $settings['page_index']['next_page'], 'M'.$max_id); |
|
640 | + } |
|
616 | 641 | } |
617 | 642 | |
618 | - } |
|
619 | - else |
|
643 | + } else |
|
620 | 644 | { |
621 | 645 | // If they didn't enter an odd value, pretend they did. |
622 | 646 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
623 | 647 | |
624 | 648 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
625 | - if (!empty($start) && $show_prevnext) |
|
626 | - if (empty($low_id)) |
|
649 | + if (!empty($start) && $show_prevnext) { |
|
650 | + if (empty($low_id)) |
|
627 | 651 | $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
628 | - else |
|
629 | - $pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L'.$low_id); |
|
630 | - else |
|
631 | - $pageindex .= ''; |
|
652 | + } else { |
|
653 | + $pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L'.$low_id); |
|
654 | + } |
|
655 | + else { |
|
656 | + $pageindex .= ''; |
|
657 | + } |
|
632 | 658 | |
633 | 659 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
634 | - if ($start > $num_per_page * $PageContiguous) |
|
635 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
660 | + if ($start > $num_per_page * $PageContiguous) { |
|
661 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
662 | + } |
|
636 | 663 | |
637 | 664 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
638 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
639 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
665 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
666 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
640 | 667 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
641 | 668 | '{FIRST_PAGE}' => $num_per_page, |
642 | 669 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
643 | 670 | '{PER_PAGE}' => $num_per_page, |
644 | 671 | )); |
672 | + } |
|
645 | 673 | |
646 | 674 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
647 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
648 | - if ($start >= $num_per_page * $nCont) |
|
675 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
676 | + if ($start >= $num_per_page * $nCont) |
|
649 | 677 | { |
650 | 678 | $tmpStart = $start - $num_per_page * $nCont; |
651 | - if($nCont != 1 || empty($low_id)) |
|
652 | - $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
|
653 | - else |
|
654 | - $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L'.$low_id); |
|
679 | + } |
|
680 | + if($nCont != 1 || empty($low_id)) { |
|
681 | + $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
|
682 | + } else { |
|
683 | + $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L'.$low_id); |
|
684 | + } |
|
655 | 685 | } |
656 | 686 | |
657 | 687 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
658 | - if (!$start_invalid) |
|
659 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
660 | - else |
|
661 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
688 | + if (!$start_invalid) { |
|
689 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
690 | + } else { |
|
691 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
692 | + } |
|
662 | 693 | |
663 | 694 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
664 | 695 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
665 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
666 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
696 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
697 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
667 | 698 | { |
668 | 699 | $tmpStart = $start + $num_per_page * $nCont; |
669 | - if($nCont != 1 || empty($max_id)) |
|
670 | - $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
|
671 | - else |
|
672 | - $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M'.$max_id); |
|
700 | + } |
|
701 | + if($nCont != 1 || empty($max_id)) { |
|
702 | + $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
|
703 | + } else { |
|
704 | + $pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M'.$max_id); |
|
705 | + } |
|
673 | 706 | } |
674 | 707 | |
675 | 708 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
676 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
677 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
709 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
710 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
678 | 711 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
679 | 712 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
680 | 713 | '{LAST_PAGE}' => $tmpMaxPages, |
681 | 714 | '{PER_PAGE}' => $num_per_page, |
682 | 715 | )); |
716 | + } |
|
683 | 717 | |
684 | 718 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
685 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
686 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
719 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
720 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
721 | + } |
|
687 | 722 | |
688 | 723 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
689 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
690 | - if (empty($max_id)) |
|
724 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
725 | + if (empty($max_id)) |
|
691 | 726 | $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
692 | - else |
|
693 | - $pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M'.$max_id); |
|
727 | + } else { |
|
728 | + $pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M'.$max_id); |
|
729 | + } |
|
694 | 730 | } |
695 | 731 | $pageindex .= $settings['page_index']['extra_after']; |
696 | 732 | |
@@ -716,8 +752,9 @@ discard block |
||
716 | 752 | if ($decimal_separator === null) |
717 | 753 | { |
718 | 754 | // Not set for whatever reason? |
719 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
720 | - return $number; |
|
755 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
756 | + return $number; |
|
757 | + } |
|
721 | 758 | |
722 | 759 | // Cache these each load... |
723 | 760 | $thousands_separator = $matches[1]; |
@@ -749,17 +786,20 @@ discard block |
||
749 | 786 | static $non_twelve_hour; |
750 | 787 | |
751 | 788 | // Offset the time. |
752 | - if (!$offset_type) |
|
753 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
789 | + if (!$offset_type) { |
|
790 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
791 | + } |
|
754 | 792 | // Just the forum offset? |
755 | - elseif ($offset_type == 'forum') |
|
756 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
757 | - else |
|
758 | - $time = $log_time; |
|
793 | + elseif ($offset_type == 'forum') { |
|
794 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
795 | + } else { |
|
796 | + $time = $log_time; |
|
797 | + } |
|
759 | 798 | |
760 | 799 | // We can't have a negative date (on Windows, at least.) |
761 | - if ($log_time < 0) |
|
762 | - $log_time = 0; |
|
800 | + if ($log_time < 0) { |
|
801 | + $log_time = 0; |
|
802 | + } |
|
763 | 803 | |
764 | 804 | // Today and Yesterday? |
765 | 805 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -776,46 +816,53 @@ discard block |
||
776 | 816 | { |
777 | 817 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
778 | 818 | $today_fmt = $h . ':%M' . $s . ' %p'; |
819 | + } else { |
|
820 | + $today_fmt = '%H:%M' . $s; |
|
779 | 821 | } |
780 | - else |
|
781 | - $today_fmt = '%H:%M' . $s; |
|
782 | 822 | |
783 | 823 | // Same day of the year, same year.... Today! |
784 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
785 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
824 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
825 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
826 | + } |
|
786 | 827 | |
787 | 828 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
788 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
789 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
829 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
830 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
831 | + } |
|
790 | 832 | } |
791 | 833 | |
792 | 834 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
793 | 835 | |
794 | 836 | if (setlocale(LC_TIME, $txt['lang_locale'])) |
795 | 837 | { |
796 | - if (!isset($non_twelve_hour)) |
|
797 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
798 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
799 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
838 | + if (!isset($non_twelve_hour)) { |
|
839 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
840 | + } |
|
841 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
842 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
843 | + } |
|
800 | 844 | |
801 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
802 | - if (strpos($str, $token) !== false) |
|
845 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
846 | + if (strpos($str, $token) !== false) |
|
803 | 847 | $str = str_replace($token, strftime($token, $time), $str); |
804 | - } |
|
805 | - else |
|
848 | + } |
|
849 | + } else |
|
806 | 850 | { |
807 | 851 | // Do-it-yourself time localization. Fun. |
808 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
809 | - if (strpos($str, $token) !== false) |
|
852 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
853 | + if (strpos($str, $token) !== false) |
|
810 | 854 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
855 | + } |
|
811 | 856 | |
812 | - if (strpos($str, '%p') !== false) |
|
813 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
857 | + if (strpos($str, '%p') !== false) { |
|
858 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
859 | + } |
|
814 | 860 | } |
815 | 861 | |
816 | 862 | // Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that. |
817 | - if ($context['server']['is_windows'] && strpos($str, '%e') !== false) |
|
818 | - $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
863 | + if ($context['server']['is_windows'] && strpos($str, '%e') !== false) { |
|
864 | + $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
865 | + } |
|
819 | 866 | |
820 | 867 | // Format any other characters.. |
821 | 868 | return strftime($str, $time); |
@@ -837,16 +884,19 @@ discard block |
||
837 | 884 | static $translation = array(); |
838 | 885 | |
839 | 886 | // Determine the character set... Default to UTF-8 |
840 | - if (empty($context['character_set'])) |
|
841 | - $charset = 'UTF-8'; |
|
887 | + if (empty($context['character_set'])) { |
|
888 | + $charset = 'UTF-8'; |
|
889 | + } |
|
842 | 890 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
843 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
844 | - $charset = 'ISO-8859-1'; |
|
845 | - else |
|
846 | - $charset = $context['character_set']; |
|
891 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
892 | + $charset = 'ISO-8859-1'; |
|
893 | + } else { |
|
894 | + $charset = $context['character_set']; |
|
895 | + } |
|
847 | 896 | |
848 | - if (empty($translation)) |
|
849 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
897 | + if (empty($translation)) { |
|
898 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
899 | + } |
|
850 | 900 | |
851 | 901 | return strtr($string, $translation); |
852 | 902 | } |
@@ -868,8 +918,9 @@ discard block |
||
868 | 918 | global $smcFunc; |
869 | 919 | |
870 | 920 | // It was already short enough! |
871 | - if ($smcFunc['strlen']($subject) <= $len) |
|
872 | - return $subject; |
|
921 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
922 | + return $subject; |
|
923 | + } |
|
873 | 924 | |
874 | 925 | // Shorten it by the length it was too long, and strip off junk from the end. |
875 | 926 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -888,10 +939,11 @@ discard block |
||
888 | 939 | { |
889 | 940 | global $user_info, $modSettings; |
890 | 941 | |
891 | - if ($timestamp === null) |
|
892 | - $timestamp = time(); |
|
893 | - elseif ($timestamp == 0) |
|
894 | - return 0; |
|
942 | + if ($timestamp === null) { |
|
943 | + $timestamp = time(); |
|
944 | + } elseif ($timestamp == 0) { |
|
945 | + return 0; |
|
946 | + } |
|
895 | 947 | |
896 | 948 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
897 | 949 | } |
@@ -920,8 +972,9 @@ discard block |
||
920 | 972 | $array[$i] = $array[$j]; |
921 | 973 | $array[$j] = $temp; |
922 | 974 | |
923 | - for ($i = 1; $p[$i] == 0; $i++) |
|
924 | - $p[$i] = 1; |
|
975 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
976 | + $p[$i] = 1; |
|
977 | + } |
|
925 | 978 | |
926 | 979 | $orders[] = $array; |
927 | 980 | } |
@@ -953,12 +1006,14 @@ discard block |
||
953 | 1006 | static $disabled; |
954 | 1007 | |
955 | 1008 | // Don't waste cycles |
956 | - if ($message === '') |
|
957 | - return ''; |
|
1009 | + if ($message === '') { |
|
1010 | + return ''; |
|
1011 | + } |
|
958 | 1012 | |
959 | 1013 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
960 | - if (!isset($context['utf8'])) |
|
961 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1014 | + if (!isset($context['utf8'])) { |
|
1015 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1016 | + } |
|
962 | 1017 | |
963 | 1018 | // Clean up any cut/paste issues we may have |
964 | 1019 | $message = sanitizeMSCutPaste($message); |
@@ -970,13 +1025,15 @@ discard block |
||
970 | 1025 | return $message; |
971 | 1026 | } |
972 | 1027 | |
973 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
974 | - $smileys = (bool) $smileys; |
|
1028 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
1029 | + $smileys = (bool) $smileys; |
|
1030 | + } |
|
975 | 1031 | |
976 | 1032 | if (empty($modSettings['enableBBC']) && $message !== false) |
977 | 1033 | { |
978 | - if ($smileys === true) |
|
979 | - parsesmileys($message); |
|
1034 | + if ($smileys === true) { |
|
1035 | + parsesmileys($message); |
|
1036 | + } |
|
980 | 1037 | |
981 | 1038 | return $message; |
982 | 1039 | } |
@@ -989,8 +1046,9 @@ discard block |
||
989 | 1046 | } |
990 | 1047 | |
991 | 1048 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
992 | - if (!empty($modSettings['autoLinkUrls'])) |
|
993 | - set_tld_regex(); |
|
1049 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
1050 | + set_tld_regex(); |
|
1051 | + } |
|
994 | 1052 | |
995 | 1053 | // Allow mods access before entering the main parse_bbc loop |
996 | 1054 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1004,12 +1062,14 @@ discard block |
||
1004 | 1062 | |
1005 | 1063 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
1006 | 1064 | |
1007 | - foreach ($temp as $tag) |
|
1008 | - $disabled[trim($tag)] = true; |
|
1065 | + foreach ($temp as $tag) { |
|
1066 | + $disabled[trim($tag)] = true; |
|
1067 | + } |
|
1009 | 1068 | } |
1010 | 1069 | |
1011 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1012 | - $disabled['flash'] = true; |
|
1070 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1071 | + $disabled['flash'] = true; |
|
1072 | + } |
|
1013 | 1073 | |
1014 | 1074 | /* The following bbc are formatted as an array, with keys as follows: |
1015 | 1075 | |
@@ -1130,8 +1190,9 @@ discard block |
||
1130 | 1190 | $returnContext = ''; |
1131 | 1191 | |
1132 | 1192 | // BBC or the entire attachments feature is disabled |
1133 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
1134 | - return $data; |
|
1193 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
1194 | + return $data; |
|
1195 | + } |
|
1135 | 1196 | |
1136 | 1197 | // Save the attach ID. |
1137 | 1198 | $attachID = $data; |
@@ -1142,8 +1203,9 @@ discard block |
||
1142 | 1203 | $currentAttachment = parseAttachBBC($attachID); |
1143 | 1204 | |
1144 | 1205 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
1145 | - if (is_string($currentAttachment)) |
|
1146 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1206 | + if (is_string($currentAttachment)) { |
|
1207 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1208 | + } |
|
1147 | 1209 | |
1148 | 1210 | if (!empty($currentAttachment['is_image'])) |
1149 | 1211 | { |
@@ -1159,15 +1221,17 @@ discard block |
||
1159 | 1221 | $height = ' height="' . $currentAttachment['height'] . '"'; |
1160 | 1222 | } |
1161 | 1223 | |
1162 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
1163 | - $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>'; |
|
1164 | - else |
|
1165 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1224 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
1225 | + $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>'; |
|
1226 | + } else { |
|
1227 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1228 | + } |
|
1166 | 1229 | } |
1167 | 1230 | |
1168 | 1231 | // No image. Show a link. |
1169 | - else |
|
1170 | - $returnContext .= $currentAttachment['link']; |
|
1232 | + else { |
|
1233 | + $returnContext .= $currentAttachment['link']; |
|
1234 | + } |
|
1171 | 1235 | |
1172 | 1236 | // Gotta append what we just did. |
1173 | 1237 | $data = $returnContext; |
@@ -1198,8 +1262,9 @@ discard block |
||
1198 | 1262 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1199 | 1263 | { |
1200 | 1264 | // Do PHP code coloring? |
1201 | - if ($php_parts[$php_i] != '<?php') |
|
1202 | - continue; |
|
1265 | + if ($php_parts[$php_i] != '<?php') { |
|
1266 | + continue; |
|
1267 | + } |
|
1203 | 1268 | |
1204 | 1269 | $php_string = ''; |
1205 | 1270 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1215,8 +1280,9 @@ discard block |
||
1215 | 1280 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
1216 | 1281 | |
1217 | 1282 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1218 | - if ($context['browser']['is_opera']) |
|
1219 | - $data .= ' '; |
|
1283 | + if ($context['browser']['is_opera']) { |
|
1284 | + $data .= ' '; |
|
1285 | + } |
|
1220 | 1286 | } |
1221 | 1287 | }, |
1222 | 1288 | 'block_level' => true, |
@@ -1235,8 +1301,9 @@ discard block |
||
1235 | 1301 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1236 | 1302 | { |
1237 | 1303 | // Do PHP code coloring? |
1238 | - if ($php_parts[$php_i] != '<?php') |
|
1239 | - continue; |
|
1304 | + if ($php_parts[$php_i] != '<?php') { |
|
1305 | + continue; |
|
1306 | + } |
|
1240 | 1307 | |
1241 | 1308 | $php_string = ''; |
1242 | 1309 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1252,8 +1319,9 @@ discard block |
||
1252 | 1319 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
1253 | 1320 | |
1254 | 1321 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1255 | - if ($context['browser']['is_opera']) |
|
1256 | - $data[0] .= ' '; |
|
1322 | + if ($context['browser']['is_opera']) { |
|
1323 | + $data[0] .= ' '; |
|
1324 | + } |
|
1257 | 1325 | } |
1258 | 1326 | }, |
1259 | 1327 | 'block_level' => true, |
@@ -1291,11 +1359,13 @@ discard block |
||
1291 | 1359 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1292 | 1360 | 'validate' => function (&$tag, &$data, $disabled) |
1293 | 1361 | { |
1294 | - if (isset($disabled['url'])) |
|
1295 | - $tag['content'] = '$1'; |
|
1362 | + if (isset($disabled['url'])) { |
|
1363 | + $tag['content'] = '$1'; |
|
1364 | + } |
|
1296 | 1365 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
1297 | - if (empty($scheme)) |
|
1298 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
1366 | + if (empty($scheme)) { |
|
1367 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
1368 | + } |
|
1299 | 1369 | }, |
1300 | 1370 | 'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>', |
1301 | 1371 | ), |
@@ -1309,10 +1379,11 @@ discard block |
||
1309 | 1379 | { |
1310 | 1380 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1311 | 1381 | |
1312 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
1313 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1314 | - else |
|
1315 | - $css = ''; |
|
1382 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
1383 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1384 | + } else { |
|
1385 | + $css = ''; |
|
1386 | + } |
|
1316 | 1387 | |
1317 | 1388 | $data = $class . $css; |
1318 | 1389 | }, |
@@ -1362,14 +1433,16 @@ discard block |
||
1362 | 1433 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1363 | 1434 | if ($image_proxy_enabled) |
1364 | 1435 | { |
1365 | - if (empty($scheme)) |
|
1366 | - $data = 'http://' . ltrim($data, ':/'); |
|
1436 | + if (empty($scheme)) { |
|
1437 | + $data = 'http://' . ltrim($data, ':/'); |
|
1438 | + } |
|
1367 | 1439 | |
1368 | - if ($scheme != 'https') |
|
1369 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1440 | + if ($scheme != 'https') { |
|
1441 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1442 | + } |
|
1443 | + } elseif (empty($scheme)) { |
|
1444 | + $data = '//' . ltrim($data, ':/'); |
|
1370 | 1445 | } |
1371 | - elseif (empty($scheme)) |
|
1372 | - $data = '//' . ltrim($data, ':/'); |
|
1373 | 1446 | }, |
1374 | 1447 | 'disabled_content' => '($1)', |
1375 | 1448 | ), |
@@ -1385,14 +1458,16 @@ discard block |
||
1385 | 1458 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1386 | 1459 | if ($image_proxy_enabled) |
1387 | 1460 | { |
1388 | - if (empty($scheme)) |
|
1389 | - $data = 'http://' . ltrim($data, ':/'); |
|
1461 | + if (empty($scheme)) { |
|
1462 | + $data = 'http://' . ltrim($data, ':/'); |
|
1463 | + } |
|
1390 | 1464 | |
1391 | - if ($scheme != 'https') |
|
1392 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1465 | + if ($scheme != 'https') { |
|
1466 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1467 | + } |
|
1468 | + } elseif (empty($scheme)) { |
|
1469 | + $data = '//' . ltrim($data, ':/'); |
|
1393 | 1470 | } |
1394 | - elseif (empty($scheme)) |
|
1395 | - $data = '//' . ltrim($data, ':/'); |
|
1396 | 1471 | }, |
1397 | 1472 | 'disabled_content' => '($1)', |
1398 | 1473 | ), |
@@ -1404,8 +1479,9 @@ discard block |
||
1404 | 1479 | { |
1405 | 1480 | $data = strtr($data, array('<br>' => '')); |
1406 | 1481 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1407 | - if (empty($scheme)) |
|
1408 | - $data = '//' . ltrim($data, ':/'); |
|
1482 | + if (empty($scheme)) { |
|
1483 | + $data = '//' . ltrim($data, ':/'); |
|
1484 | + } |
|
1409 | 1485 | }, |
1410 | 1486 | ), |
1411 | 1487 | array( |
@@ -1416,13 +1492,14 @@ discard block |
||
1416 | 1492 | 'after' => '</a>', |
1417 | 1493 | 'validate' => function (&$tag, &$data, $disabled) |
1418 | 1494 | { |
1419 | - if (substr($data, 0, 1) == '#') |
|
1420 | - $data = '#post_' . substr($data, 1); |
|
1421 | - else |
|
1495 | + if (substr($data, 0, 1) == '#') { |
|
1496 | + $data = '#post_' . substr($data, 1); |
|
1497 | + } else |
|
1422 | 1498 | { |
1423 | 1499 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1424 | - if (empty($scheme)) |
|
1425 | - $data = '//' . ltrim($data, ':/'); |
|
1500 | + if (empty($scheme)) { |
|
1501 | + $data = '//' . ltrim($data, ':/'); |
|
1502 | + } |
|
1426 | 1503 | } |
1427 | 1504 | }, |
1428 | 1505 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1500,8 +1577,9 @@ discard block |
||
1500 | 1577 | { |
1501 | 1578 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
1502 | 1579 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
1503 | - if ($add_begin) |
|
1504 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1580 | + if ($add_begin) { |
|
1581 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1582 | + } |
|
1505 | 1583 | } |
1506 | 1584 | }, |
1507 | 1585 | 'block_level' => false, |
@@ -1632,10 +1710,11 @@ discard block |
||
1632 | 1710 | 'content' => '$1', |
1633 | 1711 | 'validate' => function (&$tag, &$data, $disabled) |
1634 | 1712 | { |
1635 | - if (is_numeric($data)) |
|
1636 | - $data = timeformat($data); |
|
1637 | - else |
|
1638 | - $tag['content'] = '[time]$1[/time]'; |
|
1713 | + if (is_numeric($data)) { |
|
1714 | + $data = timeformat($data); |
|
1715 | + } else { |
|
1716 | + $tag['content'] = '[time]$1[/time]'; |
|
1717 | + } |
|
1639 | 1718 | }, |
1640 | 1719 | ), |
1641 | 1720 | array( |
@@ -1662,8 +1741,9 @@ discard block |
||
1662 | 1741 | { |
1663 | 1742 | $data = strtr($data, array('<br>' => '')); |
1664 | 1743 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1665 | - if (empty($scheme)) |
|
1666 | - $data = '//' . ltrim($data, ':/'); |
|
1744 | + if (empty($scheme)) { |
|
1745 | + $data = '//' . ltrim($data, ':/'); |
|
1746 | + } |
|
1667 | 1747 | }, |
1668 | 1748 | ), |
1669 | 1749 | array( |
@@ -1675,8 +1755,9 @@ discard block |
||
1675 | 1755 | 'validate' => function (&$tag, &$data, $disabled) |
1676 | 1756 | { |
1677 | 1757 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1678 | - if (empty($scheme)) |
|
1679 | - $data = '//' . ltrim($data, ':/'); |
|
1758 | + if (empty($scheme)) { |
|
1759 | + $data = '//' . ltrim($data, ':/'); |
|
1760 | + } |
|
1680 | 1761 | }, |
1681 | 1762 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
1682 | 1763 | 'disabled_after' => ' ($1)', |
@@ -1696,8 +1777,9 @@ discard block |
||
1696 | 1777 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
1697 | 1778 | if ($message === false) |
1698 | 1779 | { |
1699 | - if (isset($temp_bbc)) |
|
1700 | - $bbc_codes = $temp_bbc; |
|
1780 | + if (isset($temp_bbc)) { |
|
1781 | + $bbc_codes = $temp_bbc; |
|
1782 | + } |
|
1701 | 1783 | usort($codes, function ($a, $b) { |
1702 | 1784 | return strcmp($a['tag'], $b['tag']); |
1703 | 1785 | }); |
@@ -1717,8 +1799,9 @@ discard block |
||
1717 | 1799 | ); |
1718 | 1800 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
1719 | 1801 | { |
1720 | - foreach ($itemcodes as $c => $dummy) |
|
1721 | - $bbc_codes[$c] = array(); |
|
1802 | + foreach ($itemcodes as $c => $dummy) { |
|
1803 | + $bbc_codes[$c] = array(); |
|
1804 | + } |
|
1722 | 1805 | } |
1723 | 1806 | |
1724 | 1807 | // Shhhh! |
@@ -1739,12 +1822,14 @@ discard block |
||
1739 | 1822 | foreach ($codes as $code) |
1740 | 1823 | { |
1741 | 1824 | // Make it easier to process parameters later |
1742 | - if (!empty($code['parameters'])) |
|
1743 | - ksort($code['parameters'], SORT_STRING); |
|
1825 | + if (!empty($code['parameters'])) { |
|
1826 | + ksort($code['parameters'], SORT_STRING); |
|
1827 | + } |
|
1744 | 1828 | |
1745 | 1829 | // If we are not doing every tag only do ones we are interested in. |
1746 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
1747 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1830 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
1831 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1832 | + } |
|
1748 | 1833 | } |
1749 | 1834 | $codes = null; |
1750 | 1835 | } |
@@ -1755,8 +1840,9 @@ discard block |
||
1755 | 1840 | // It's likely this will change if the message is modified. |
1756 | 1841 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . json_encode($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
1757 | 1842 | |
1758 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
1759 | - return $temp; |
|
1843 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
1844 | + return $temp; |
|
1845 | + } |
|
1760 | 1846 | |
1761 | 1847 | $cache_t = microtime(); |
1762 | 1848 | } |
@@ -1788,8 +1874,9 @@ discard block |
||
1788 | 1874 | $disabled['flash'] = true; |
1789 | 1875 | |
1790 | 1876 | // @todo Change maybe? |
1791 | - if (!isset($_GET['images'])) |
|
1792 | - $disabled['img'] = true; |
|
1877 | + if (!isset($_GET['images'])) { |
|
1878 | + $disabled['img'] = true; |
|
1879 | + } |
|
1793 | 1880 | |
1794 | 1881 | // @todo Interface/setting to add more? |
1795 | 1882 | } |
@@ -1813,8 +1900,9 @@ discard block |
||
1813 | 1900 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
1814 | 1901 | |
1815 | 1902 | // Failsafe. |
1816 | - if ($pos === false || $last_pos > $pos) |
|
1817 | - $pos = strlen($message) + 1; |
|
1903 | + if ($pos === false || $last_pos > $pos) { |
|
1904 | + $pos = strlen($message) + 1; |
|
1905 | + } |
|
1818 | 1906 | |
1819 | 1907 | // Can't have a one letter smiley, URL, or email! (sorry.) |
1820 | 1908 | if ($last_pos < $pos - 1) |
@@ -1833,8 +1921,9 @@ discard block |
||
1833 | 1921 | |
1834 | 1922 | // <br> should be empty. |
1835 | 1923 | $empty_tags = array('br', 'hr'); |
1836 | - foreach ($empty_tags as $tag) |
|
1837 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
1924 | + foreach ($empty_tags as $tag) { |
|
1925 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
1926 | + } |
|
1838 | 1927 | |
1839 | 1928 | // b, u, i, s, pre... basic tags. |
1840 | 1929 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote'); |
@@ -1843,8 +1932,9 @@ discard block |
||
1843 | 1932 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
1844 | 1933 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
1845 | 1934 | |
1846 | - if ($diff > 0) |
|
1847 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1935 | + if ($diff > 0) { |
|
1936 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1937 | + } |
|
1848 | 1938 | } |
1849 | 1939 | |
1850 | 1940 | // Do <img ...> - with security... action= -> action-. |
@@ -1857,8 +1947,9 @@ discard block |
||
1857 | 1947 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
1858 | 1948 | |
1859 | 1949 | // Remove action= from the URL - no funny business, now. |
1860 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
1861 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
1950 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
1951 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
1952 | + } |
|
1862 | 1953 | |
1863 | 1954 | // Check if the image is larger than allowed. |
1864 | 1955 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1879,9 +1970,9 @@ discard block |
||
1879 | 1970 | |
1880 | 1971 | // Set the new image tag. |
1881 | 1972 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
1973 | + } else { |
|
1974 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1882 | 1975 | } |
1883 | - else |
|
1884 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1885 | 1976 | } |
1886 | 1977 | |
1887 | 1978 | $data = strtr($data, $replaces); |
@@ -1894,16 +1985,18 @@ discard block |
||
1894 | 1985 | $no_autolink_area = false; |
1895 | 1986 | if (!empty($open_tags)) |
1896 | 1987 | { |
1897 | - foreach ($open_tags as $open_tag) |
|
1898 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1988 | + foreach ($open_tags as $open_tag) { |
|
1989 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1899 | 1990 | $no_autolink_area = true; |
1991 | + } |
|
1900 | 1992 | } |
1901 | 1993 | |
1902 | 1994 | // Don't go backwards. |
1903 | 1995 | // @todo Don't think is the real solution.... |
1904 | 1996 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
1905 | - if ($pos < $lastAutoPos) |
|
1906 | - $no_autolink_area = true; |
|
1997 | + if ($pos < $lastAutoPos) { |
|
1998 | + $no_autolink_area = true; |
|
1999 | + } |
|
1907 | 2000 | $lastAutoPos = $pos; |
1908 | 2001 | |
1909 | 2002 | if (!$no_autolink_area) |
@@ -2012,17 +2105,19 @@ discard block |
||
2012 | 2105 | if ($scheme == 'mailto') |
2013 | 2106 | { |
2014 | 2107 | $email_address = str_replace('mailto:', '', $url); |
2015 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
2016 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2017 | - else |
|
2018 | - return $url; |
|
2108 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
2109 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2110 | + } else { |
|
2111 | + return $url; |
|
2112 | + } |
|
2019 | 2113 | } |
2020 | 2114 | |
2021 | 2115 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
2022 | - if (empty($scheme)) |
|
2023 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
2024 | - else |
|
2025 | - $fullUrl = $url; |
|
2116 | + if (empty($scheme)) { |
|
2117 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
2118 | + } else { |
|
2119 | + $fullUrl = $url; |
|
2120 | + } |
|
2026 | 2121 | |
2027 | 2122 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
2028 | 2123 | }, $data); |
@@ -2071,16 +2166,18 @@ discard block |
||
2071 | 2166 | } |
2072 | 2167 | |
2073 | 2168 | // Are we there yet? Are we there yet? |
2074 | - if ($pos >= strlen($message) - 1) |
|
2075 | - break; |
|
2169 | + if ($pos >= strlen($message) - 1) { |
|
2170 | + break; |
|
2171 | + } |
|
2076 | 2172 | |
2077 | 2173 | $tags = strtolower($message[$pos + 1]); |
2078 | 2174 | |
2079 | 2175 | if ($tags == '/' && !empty($open_tags)) |
2080 | 2176 | { |
2081 | 2177 | $pos2 = strpos($message, ']', $pos + 1); |
2082 | - if ($pos2 == $pos + 2) |
|
2083 | - continue; |
|
2178 | + if ($pos2 == $pos + 2) { |
|
2179 | + continue; |
|
2180 | + } |
|
2084 | 2181 | |
2085 | 2182 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2086 | 2183 | |
@@ -2090,8 +2187,9 @@ discard block |
||
2090 | 2187 | do |
2091 | 2188 | { |
2092 | 2189 | $tag = array_pop($open_tags); |
2093 | - if (!$tag) |
|
2094 | - break; |
|
2190 | + if (!$tag) { |
|
2191 | + break; |
|
2192 | + } |
|
2095 | 2193 | |
2096 | 2194 | if (!empty($tag['block_level'])) |
2097 | 2195 | { |
@@ -2105,10 +2203,11 @@ discard block |
||
2105 | 2203 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
2106 | 2204 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
2107 | 2205 | { |
2108 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2109 | - if ($temp['tag'] == $look_for) |
|
2206 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2207 | + if ($temp['tag'] == $look_for) |
|
2110 | 2208 | { |
2111 | 2209 | $block_level = !empty($temp['block_level']); |
2210 | + } |
|
2112 | 2211 | break; |
2113 | 2212 | } |
2114 | 2213 | } |
@@ -2130,15 +2229,15 @@ discard block |
||
2130 | 2229 | { |
2131 | 2230 | $open_tags = $to_close; |
2132 | 2231 | continue; |
2133 | - } |
|
2134 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2232 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2135 | 2233 | { |
2136 | 2234 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
2137 | 2235 | { |
2138 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2139 | - if ($temp['tag'] == $look_for) |
|
2236 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2237 | + if ($temp['tag'] == $look_for) |
|
2140 | 2238 | { |
2141 | 2239 | $block_level = !empty($temp['block_level']); |
2240 | + } |
|
2142 | 2241 | break; |
2143 | 2242 | } |
2144 | 2243 | } |
@@ -2146,8 +2245,9 @@ discard block |
||
2146 | 2245 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
2147 | 2246 | if (!$block_level) |
2148 | 2247 | { |
2149 | - foreach ($to_close as $tag) |
|
2150 | - array_push($open_tags, $tag); |
|
2248 | + foreach ($to_close as $tag) { |
|
2249 | + array_push($open_tags, $tag); |
|
2250 | + } |
|
2151 | 2251 | continue; |
2152 | 2252 | } |
2153 | 2253 | } |
@@ -2160,14 +2260,17 @@ discard block |
||
2160 | 2260 | |
2161 | 2261 | // See the comment at the end of the big loop - just eating whitespace ;). |
2162 | 2262 | $whitespace_regex = ''; |
2163 | - if (!empty($tag['block_level'])) |
|
2164 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2263 | + if (!empty($tag['block_level'])) { |
|
2264 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2265 | + } |
|
2165 | 2266 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
2166 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2167 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2267 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2268 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2269 | + } |
|
2168 | 2270 | |
2169 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2170 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2271 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2272 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2273 | + } |
|
2171 | 2274 | } |
2172 | 2275 | |
2173 | 2276 | if (!empty($to_close)) |
@@ -2180,8 +2283,9 @@ discard block |
||
2180 | 2283 | } |
2181 | 2284 | |
2182 | 2285 | // No tags for this character, so just keep going (fastest possible course.) |
2183 | - if (!isset($bbc_codes[$tags])) |
|
2184 | - continue; |
|
2286 | + if (!isset($bbc_codes[$tags])) { |
|
2287 | + continue; |
|
2288 | + } |
|
2185 | 2289 | |
2186 | 2290 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
2187 | 2291 | $tag = null; |
@@ -2190,44 +2294,52 @@ discard block |
||
2190 | 2294 | $pt_strlen = strlen($possible['tag']); |
2191 | 2295 | |
2192 | 2296 | // Not a match? |
2193 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
2194 | - continue; |
|
2297 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
2298 | + continue; |
|
2299 | + } |
|
2195 | 2300 | |
2196 | 2301 | $next_c = $message[$pos + 1 + $pt_strlen]; |
2197 | 2302 | |
2198 | 2303 | // A test validation? |
2199 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
2200 | - continue; |
|
2304 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
2305 | + continue; |
|
2306 | + } |
|
2201 | 2307 | // Do we want parameters? |
2202 | 2308 | elseif (!empty($possible['parameters'])) |
2203 | 2309 | { |
2204 | - if ($next_c != ' ') |
|
2205 | - continue; |
|
2206 | - } |
|
2207 | - elseif (isset($possible['type'])) |
|
2310 | + if ($next_c != ' ') { |
|
2311 | + continue; |
|
2312 | + } |
|
2313 | + } elseif (isset($possible['type'])) |
|
2208 | 2314 | { |
2209 | 2315 | // Do we need an equal sign? |
2210 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
2211 | - continue; |
|
2316 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
2317 | + continue; |
|
2318 | + } |
|
2212 | 2319 | // Maybe we just want a /... |
2213 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
2214 | - continue; |
|
2320 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
2321 | + continue; |
|
2322 | + } |
|
2215 | 2323 | // An immediate ]? |
2216 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
2217 | - continue; |
|
2324 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
2325 | + continue; |
|
2326 | + } |
|
2218 | 2327 | } |
2219 | 2328 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
2220 | - elseif ($next_c != ']') |
|
2221 | - continue; |
|
2329 | + elseif ($next_c != ']') { |
|
2330 | + continue; |
|
2331 | + } |
|
2222 | 2332 | |
2223 | 2333 | // Check allowed tree? |
2224 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
2225 | - continue; |
|
2226 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
2227 | - continue; |
|
2334 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
2335 | + continue; |
|
2336 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
2337 | + continue; |
|
2338 | + } |
|
2228 | 2339 | // If this is in the list of disallowed child tags, don't parse it. |
2229 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
2230 | - continue; |
|
2340 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
2341 | + continue; |
|
2342 | + } |
|
2231 | 2343 | |
2232 | 2344 | $pos1 = $pos + 1 + $pt_strlen + 1; |
2233 | 2345 | |
@@ -2239,8 +2351,9 @@ discard block |
||
2239 | 2351 | foreach ($open_tags as $open_quote) |
2240 | 2352 | { |
2241 | 2353 | // Every parent quote this quote has flips the styling |
2242 | - if ($open_quote['tag'] == 'quote') |
|
2243 | - $quote_alt = !$quote_alt; |
|
2354 | + if ($open_quote['tag'] == 'quote') { |
|
2355 | + $quote_alt = !$quote_alt; |
|
2356 | + } |
|
2244 | 2357 | } |
2245 | 2358 | // Add a class to the quote to style alternating blockquotes |
2246 | 2359 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2251,8 +2364,9 @@ discard block |
||
2251 | 2364 | { |
2252 | 2365 | // Build a regular expression for each parameter for the current tag. |
2253 | 2366 | $preg = array(); |
2254 | - foreach ($possible['parameters'] as $p => $info) |
|
2255 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2367 | + foreach ($possible['parameters'] as $p => $info) { |
|
2368 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2369 | + } |
|
2256 | 2370 | |
2257 | 2371 | // Extract the string that potentially holds our parameters. |
2258 | 2372 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2272,24 +2386,27 @@ discard block |
||
2272 | 2386 | |
2273 | 2387 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
2274 | 2388 | |
2275 | - if ($match) |
|
2276 | - $blob_counter = count($blobs) + 1; |
|
2389 | + if ($match) { |
|
2390 | + $blob_counter = count($blobs) + 1; |
|
2391 | + } |
|
2277 | 2392 | } |
2278 | 2393 | |
2279 | 2394 | // Didn't match our parameter list, try the next possible. |
2280 | - if (!$match) |
|
2281 | - continue; |
|
2395 | + if (!$match) { |
|
2396 | + continue; |
|
2397 | + } |
|
2282 | 2398 | |
2283 | 2399 | $params = array(); |
2284 | 2400 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
2285 | 2401 | { |
2286 | 2402 | $key = strtok(ltrim($matches[$i]), '='); |
2287 | - if (isset($possible['parameters'][$key]['value'])) |
|
2288 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2289 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
2290 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2291 | - else |
|
2292 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2403 | + if (isset($possible['parameters'][$key]['value'])) { |
|
2404 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2405 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
2406 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2407 | + } else { |
|
2408 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2409 | + } |
|
2293 | 2410 | |
2294 | 2411 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
2295 | 2412 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2297,23 +2414,26 @@ discard block |
||
2297 | 2414 | |
2298 | 2415 | foreach ($possible['parameters'] as $p => $info) |
2299 | 2416 | { |
2300 | - if (!isset($params['{' . $p . '}'])) |
|
2301 | - $params['{' . $p . '}'] = ''; |
|
2417 | + if (!isset($params['{' . $p . '}'])) { |
|
2418 | + $params['{' . $p . '}'] = ''; |
|
2419 | + } |
|
2302 | 2420 | } |
2303 | 2421 | |
2304 | 2422 | $tag = $possible; |
2305 | 2423 | |
2306 | 2424 | // Put the parameters into the string. |
2307 | - if (isset($tag['before'])) |
|
2308 | - $tag['before'] = strtr($tag['before'], $params); |
|
2309 | - if (isset($tag['after'])) |
|
2310 | - $tag['after'] = strtr($tag['after'], $params); |
|
2311 | - if (isset($tag['content'])) |
|
2312 | - $tag['content'] = strtr($tag['content'], $params); |
|
2425 | + if (isset($tag['before'])) { |
|
2426 | + $tag['before'] = strtr($tag['before'], $params); |
|
2427 | + } |
|
2428 | + if (isset($tag['after'])) { |
|
2429 | + $tag['after'] = strtr($tag['after'], $params); |
|
2430 | + } |
|
2431 | + if (isset($tag['content'])) { |
|
2432 | + $tag['content'] = strtr($tag['content'], $params); |
|
2433 | + } |
|
2313 | 2434 | |
2314 | 2435 | $pos1 += strlen($given_param_string); |
2315 | - } |
|
2316 | - else |
|
2436 | + } else |
|
2317 | 2437 | { |
2318 | 2438 | $tag = $possible; |
2319 | 2439 | $params = array(); |
@@ -2324,8 +2444,9 @@ discard block |
||
2324 | 2444 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
2325 | 2445 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
2326 | 2446 | { |
2327 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
2328 | - continue; |
|
2447 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
2448 | + continue; |
|
2449 | + } |
|
2329 | 2450 | |
2330 | 2451 | $tag = $itemcodes[$message[$pos + 1]]; |
2331 | 2452 | |
@@ -2346,9 +2467,9 @@ discard block |
||
2346 | 2467 | { |
2347 | 2468 | array_pop($open_tags); |
2348 | 2469 | $code = '</li>'; |
2470 | + } else { |
|
2471 | + $code = ''; |
|
2349 | 2472 | } |
2350 | - else |
|
2351 | - $code = ''; |
|
2352 | 2473 | |
2353 | 2474 | // Now we open a new tag. |
2354 | 2475 | $open_tags[] = array( |
@@ -2395,12 +2516,14 @@ discard block |
||
2395 | 2516 | } |
2396 | 2517 | |
2397 | 2518 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
2398 | - if ($tag === null) |
|
2399 | - continue; |
|
2519 | + if ($tag === null) { |
|
2520 | + continue; |
|
2521 | + } |
|
2400 | 2522 | |
2401 | 2523 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
2402 | - if (isset($inside['disallow_children'])) |
|
2403 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2524 | + if (isset($inside['disallow_children'])) { |
|
2525 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2526 | + } |
|
2404 | 2527 | |
2405 | 2528 | // Is this tag disabled? |
2406 | 2529 | if (isset($disabled[$tag['tag']])) |
@@ -2410,14 +2533,13 @@ discard block |
||
2410 | 2533 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
2411 | 2534 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
2412 | 2535 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
2413 | - } |
|
2414 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2536 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2415 | 2537 | { |
2416 | 2538 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
2417 | 2539 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
2540 | + } else { |
|
2541 | + $tag['content'] = $tag['disabled_content']; |
|
2418 | 2542 | } |
2419 | - else |
|
2420 | - $tag['content'] = $tag['disabled_content']; |
|
2421 | 2543 | } |
2422 | 2544 | |
2423 | 2545 | // we use this a lot |
@@ -2427,8 +2549,9 @@ discard block |
||
2427 | 2549 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
2428 | 2550 | { |
2429 | 2551 | $n = count($open_tags) - 1; |
2430 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
2431 | - $n--; |
|
2552 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
2553 | + $n--; |
|
2554 | + } |
|
2432 | 2555 | |
2433 | 2556 | // Close all the non block level tags so this tag isn't surrounded by them. |
2434 | 2557 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2440,12 +2563,15 @@ discard block |
||
2440 | 2563 | |
2441 | 2564 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
2442 | 2565 | $whitespace_regex = ''; |
2443 | - if (!empty($tag['block_level'])) |
|
2444 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2445 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2446 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2447 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2448 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2566 | + if (!empty($tag['block_level'])) { |
|
2567 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2568 | + } |
|
2569 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2570 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2571 | + } |
|
2572 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2573 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2574 | + } |
|
2449 | 2575 | |
2450 | 2576 | array_pop($open_tags); |
2451 | 2577 | } |
@@ -2463,16 +2589,19 @@ discard block |
||
2463 | 2589 | elseif ($tag['type'] == 'unparsed_content') |
2464 | 2590 | { |
2465 | 2591 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
2466 | - if ($pos2 === false) |
|
2467 | - continue; |
|
2592 | + if ($pos2 === false) { |
|
2593 | + continue; |
|
2594 | + } |
|
2468 | 2595 | |
2469 | 2596 | $data = substr($message, $pos1, $pos2 - $pos1); |
2470 | 2597 | |
2471 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
2472 | - $data = substr($data, 4); |
|
2598 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
2599 | + $data = substr($data, 4); |
|
2600 | + } |
|
2473 | 2601 | |
2474 | - if (isset($tag['validate'])) |
|
2475 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2602 | + if (isset($tag['validate'])) { |
|
2603 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2604 | + } |
|
2476 | 2605 | |
2477 | 2606 | $code = strtr($tag['content'], array('$1' => $data)); |
2478 | 2607 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2488,34 +2617,40 @@ discard block |
||
2488 | 2617 | if (isset($tag['quoted'])) |
2489 | 2618 | { |
2490 | 2619 | $quoted = substr($message, $pos1, 6) == '"'; |
2491 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2492 | - continue; |
|
2620 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2621 | + continue; |
|
2622 | + } |
|
2493 | 2623 | |
2494 | - if ($quoted) |
|
2495 | - $pos1 += 6; |
|
2624 | + if ($quoted) { |
|
2625 | + $pos1 += 6; |
|
2626 | + } |
|
2627 | + } else { |
|
2628 | + $quoted = false; |
|
2496 | 2629 | } |
2497 | - else |
|
2498 | - $quoted = false; |
|
2499 | 2630 | |
2500 | 2631 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2501 | - if ($pos2 === false) |
|
2502 | - continue; |
|
2632 | + if ($pos2 === false) { |
|
2633 | + continue; |
|
2634 | + } |
|
2503 | 2635 | |
2504 | 2636 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2505 | - if ($pos3 === false) |
|
2506 | - continue; |
|
2637 | + if ($pos3 === false) { |
|
2638 | + continue; |
|
2639 | + } |
|
2507 | 2640 | |
2508 | 2641 | $data = array( |
2509 | 2642 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
2510 | 2643 | substr($message, $pos1, $pos2 - $pos1) |
2511 | 2644 | ); |
2512 | 2645 | |
2513 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
2514 | - $data[0] = substr($data[0], 4); |
|
2646 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
2647 | + $data[0] = substr($data[0], 4); |
|
2648 | + } |
|
2515 | 2649 | |
2516 | 2650 | // Validation for my parking, please! |
2517 | - if (isset($tag['validate'])) |
|
2518 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2651 | + if (isset($tag['validate'])) { |
|
2652 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2653 | + } |
|
2519 | 2654 | |
2520 | 2655 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
2521 | 2656 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2532,23 +2667,27 @@ discard block |
||
2532 | 2667 | elseif ($tag['type'] == 'unparsed_commas_content') |
2533 | 2668 | { |
2534 | 2669 | $pos2 = strpos($message, ']', $pos1); |
2535 | - if ($pos2 === false) |
|
2536 | - continue; |
|
2670 | + if ($pos2 === false) { |
|
2671 | + continue; |
|
2672 | + } |
|
2537 | 2673 | |
2538 | 2674 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2539 | - if ($pos3 === false) |
|
2540 | - continue; |
|
2675 | + if ($pos3 === false) { |
|
2676 | + continue; |
|
2677 | + } |
|
2541 | 2678 | |
2542 | 2679 | // We want $1 to be the content, and the rest to be csv. |
2543 | 2680 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
2544 | 2681 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
2545 | 2682 | |
2546 | - if (isset($tag['validate'])) |
|
2547 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2683 | + if (isset($tag['validate'])) { |
|
2684 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2685 | + } |
|
2548 | 2686 | |
2549 | 2687 | $code = $tag['content']; |
2550 | - foreach ($data as $k => $d) |
|
2551 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2688 | + foreach ($data as $k => $d) { |
|
2689 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2690 | + } |
|
2552 | 2691 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
2553 | 2692 | $pos += strlen($code) - 1 + 2; |
2554 | 2693 | } |
@@ -2556,24 +2695,28 @@ discard block |
||
2556 | 2695 | elseif ($tag['type'] == 'unparsed_commas') |
2557 | 2696 | { |
2558 | 2697 | $pos2 = strpos($message, ']', $pos1); |
2559 | - if ($pos2 === false) |
|
2560 | - continue; |
|
2698 | + if ($pos2 === false) { |
|
2699 | + continue; |
|
2700 | + } |
|
2561 | 2701 | |
2562 | 2702 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
2563 | 2703 | |
2564 | - if (isset($tag['validate'])) |
|
2565 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2704 | + if (isset($tag['validate'])) { |
|
2705 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2706 | + } |
|
2566 | 2707 | |
2567 | 2708 | // Fix after, for disabled code mainly. |
2568 | - foreach ($data as $k => $d) |
|
2569 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2709 | + foreach ($data as $k => $d) { |
|
2710 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2711 | + } |
|
2570 | 2712 | |
2571 | 2713 | $open_tags[] = $tag; |
2572 | 2714 | |
2573 | 2715 | // Replace them out, $1, $2, $3, $4, etc. |
2574 | 2716 | $code = $tag['before']; |
2575 | - foreach ($data as $k => $d) |
|
2576 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2717 | + foreach ($data as $k => $d) { |
|
2718 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2719 | + } |
|
2577 | 2720 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
2578 | 2721 | $pos += strlen($code) - 1 + 2; |
2579 | 2722 | } |
@@ -2584,28 +2727,33 @@ discard block |
||
2584 | 2727 | if (isset($tag['quoted'])) |
2585 | 2728 | { |
2586 | 2729 | $quoted = substr($message, $pos1, 6) == '"'; |
2587 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2588 | - continue; |
|
2730 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2731 | + continue; |
|
2732 | + } |
|
2589 | 2733 | |
2590 | - if ($quoted) |
|
2591 | - $pos1 += 6; |
|
2734 | + if ($quoted) { |
|
2735 | + $pos1 += 6; |
|
2736 | + } |
|
2737 | + } else { |
|
2738 | + $quoted = false; |
|
2592 | 2739 | } |
2593 | - else |
|
2594 | - $quoted = false; |
|
2595 | 2740 | |
2596 | 2741 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2597 | - if ($pos2 === false) |
|
2598 | - continue; |
|
2742 | + if ($pos2 === false) { |
|
2743 | + continue; |
|
2744 | + } |
|
2599 | 2745 | |
2600 | 2746 | $data = substr($message, $pos1, $pos2 - $pos1); |
2601 | 2747 | |
2602 | 2748 | // Validation for my parking, please! |
2603 | - if (isset($tag['validate'])) |
|
2604 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2749 | + if (isset($tag['validate'])) { |
|
2750 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2751 | + } |
|
2605 | 2752 | |
2606 | 2753 | // For parsed content, we must recurse to avoid security problems. |
2607 | - if ($tag['type'] != 'unparsed_equals') |
|
2608 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2754 | + if ($tag['type'] != 'unparsed_equals') { |
|
2755 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2756 | + } |
|
2609 | 2757 | |
2610 | 2758 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
2611 | 2759 | |
@@ -2617,34 +2765,40 @@ discard block |
||
2617 | 2765 | } |
2618 | 2766 | |
2619 | 2767 | // If this is block level, eat any breaks after it. |
2620 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
2621 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2768 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
2769 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2770 | + } |
|
2622 | 2771 | |
2623 | 2772 | // Are we trimming outside this tag? |
2624 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
2625 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2773 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
2774 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2775 | + } |
|
2626 | 2776 | } |
2627 | 2777 | |
2628 | 2778 | // Close any remaining tags. |
2629 | - while ($tag = array_pop($open_tags)) |
|
2630 | - $message .= "\n" . $tag['after'] . "\n"; |
|
2779 | + while ($tag = array_pop($open_tags)) { |
|
2780 | + $message .= "\n" . $tag['after'] . "\n"; |
|
2781 | + } |
|
2631 | 2782 | |
2632 | 2783 | // Parse the smileys within the parts where it can be done safely. |
2633 | 2784 | if ($smileys === true) |
2634 | 2785 | { |
2635 | 2786 | $message_parts = explode("\n", $message); |
2636 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
2637 | - parsesmileys($message_parts[$i]); |
|
2787 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
2788 | + parsesmileys($message_parts[$i]); |
|
2789 | + } |
|
2638 | 2790 | |
2639 | 2791 | $message = implode('', $message_parts); |
2640 | 2792 | } |
2641 | 2793 | |
2642 | 2794 | // No smileys, just get rid of the markers. |
2643 | - else |
|
2644 | - $message = strtr($message, array("\n" => '')); |
|
2795 | + else { |
|
2796 | + $message = strtr($message, array("\n" => '')); |
|
2797 | + } |
|
2645 | 2798 | |
2646 | - if ($message !== '' && $message[0] === ' ') |
|
2647 | - $message = ' ' . substr($message, 1); |
|
2799 | + if ($message !== '' && $message[0] === ' ') { |
|
2800 | + $message = ' ' . substr($message, 1); |
|
2801 | + } |
|
2648 | 2802 | |
2649 | 2803 | // Cleanup whitespace. |
2650 | 2804 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2653,15 +2807,16 @@ discard block |
||
2653 | 2807 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
2654 | 2808 | |
2655 | 2809 | // Cache the output if it took some time... |
2656 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
2657 | - cache_put_data($cache_key, $message, 240); |
|
2810 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
2811 | + cache_put_data($cache_key, $message, 240); |
|
2812 | + } |
|
2658 | 2813 | |
2659 | 2814 | // If this was a force parse revert if needed. |
2660 | 2815 | if (!empty($parse_tags)) |
2661 | 2816 | { |
2662 | - if (empty($temp_bbc)) |
|
2663 | - $bbc_codes = array(); |
|
2664 | - else |
|
2817 | + if (empty($temp_bbc)) { |
|
2818 | + $bbc_codes = array(); |
|
2819 | + } else |
|
2665 | 2820 | { |
2666 | 2821 | $bbc_codes = $temp_bbc; |
2667 | 2822 | unset($temp_bbc); |
@@ -2688,8 +2843,9 @@ discard block |
||
2688 | 2843 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
2689 | 2844 | |
2690 | 2845 | // No smiley set at all?! |
2691 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
2692 | - return; |
|
2846 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
2847 | + return; |
|
2848 | + } |
|
2693 | 2849 | |
2694 | 2850 | // If smileyPregSearch hasn't been set, do it now. |
2695 | 2851 | if (empty($smileyPregSearch)) |
@@ -2700,8 +2856,7 @@ discard block |
||
2700 | 2856 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
2701 | 2857 | $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif'); |
2702 | 2858 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
2703 | - } |
|
2704 | - else |
|
2859 | + } else |
|
2705 | 2860 | { |
2706 | 2861 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
2707 | 2862 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2725,9 +2880,9 @@ discard block |
||
2725 | 2880 | $smcFunc['db_free_result']($result); |
2726 | 2881 | |
2727 | 2882 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
2883 | + } else { |
|
2884 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2728 | 2885 | } |
2729 | - else |
|
2730 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2731 | 2886 | } |
2732 | 2887 | |
2733 | 2888 | // The non-breaking-space is a complex thing... |
@@ -2804,35 +2959,41 @@ discard block |
||
2804 | 2959 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
2805 | 2960 | |
2806 | 2961 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
2807 | - if (!empty($context['flush_mail'])) |
|
2808 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2962 | + if (!empty($context['flush_mail'])) { |
|
2963 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2809 | 2964 | AddMailQueue(true); |
2965 | + } |
|
2810 | 2966 | |
2811 | 2967 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
2812 | 2968 | |
2813 | - if ($add) |
|
2814 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
2969 | + if ($add) { |
|
2970 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
2971 | + } |
|
2815 | 2972 | |
2816 | 2973 | // Put the session ID in. |
2817 | - if (defined('SID') && SID != '') |
|
2818 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
2974 | + if (defined('SID') && SID != '') { |
|
2975 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
2976 | + } |
|
2819 | 2977 | // Keep that debug in their for template debugging! |
2820 | - elseif (isset($_GET['debug'])) |
|
2821 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
2978 | + elseif (isset($_GET['debug'])) { |
|
2979 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
2980 | + } |
|
2822 | 2981 | |
2823 | 2982 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
2824 | 2983 | { |
2825 | - if (defined('SID') && SID != '') |
|
2826 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2984 | + if (defined('SID') && SID != '') { |
|
2985 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2827 | 2986 | function ($m) use ($scripturl) |
2828 | 2987 | { |
2829 | 2988 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
2989 | + } |
|
2830 | 2990 | }, $setLocation); |
2831 | - else |
|
2832 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2991 | + else { |
|
2992 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2833 | 2993 | function ($m) use ($scripturl) |
2834 | 2994 | { |
2835 | 2995 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
2996 | + } |
|
2836 | 2997 | }, $setLocation); |
2837 | 2998 | } |
2838 | 2999 | |
@@ -2843,8 +3004,9 @@ discard block |
||
2843 | 3004 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
2844 | 3005 | |
2845 | 3006 | // Debugging. |
2846 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
2847 | - $_SESSION['debug_redirect'] = $db_cache; |
|
3007 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3008 | + $_SESSION['debug_redirect'] = $db_cache; |
|
3009 | + } |
|
2848 | 3010 | |
2849 | 3011 | obExit(false); |
2850 | 3012 | } |
@@ -2863,51 +3025,60 @@ discard block |
||
2863 | 3025 | |
2864 | 3026 | // Attempt to prevent a recursive loop. |
2865 | 3027 | ++$level; |
2866 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
2867 | - exit; |
|
2868 | - if ($from_fatal_error) |
|
2869 | - $has_fatal_error = true; |
|
3028 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
3029 | + exit; |
|
3030 | + } |
|
3031 | + if ($from_fatal_error) { |
|
3032 | + $has_fatal_error = true; |
|
3033 | + } |
|
2870 | 3034 | |
2871 | 3035 | // Clear out the stat cache. |
2872 | 3036 | trackStats(); |
2873 | 3037 | |
2874 | 3038 | // If we have mail to send, send it. |
2875 | - if (!empty($context['flush_mail'])) |
|
2876 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3039 | + if (!empty($context['flush_mail'])) { |
|
3040 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2877 | 3041 | AddMailQueue(true); |
3042 | + } |
|
2878 | 3043 | |
2879 | 3044 | $do_header = $header === null ? !$header_done : $header; |
2880 | - if ($do_footer === null) |
|
2881 | - $do_footer = $do_header; |
|
3045 | + if ($do_footer === null) { |
|
3046 | + $do_footer = $do_header; |
|
3047 | + } |
|
2882 | 3048 | |
2883 | 3049 | // Has the template/header been done yet? |
2884 | 3050 | if ($do_header) |
2885 | 3051 | { |
2886 | 3052 | // Was the page title set last minute? Also update the HTML safe one. |
2887 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
2888 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3053 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
3054 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3055 | + } |
|
2889 | 3056 | |
2890 | 3057 | // Start up the session URL fixer. |
2891 | 3058 | ob_start('ob_sessrewrite'); |
2892 | 3059 | |
2893 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
2894 | - $buffers = explode(',', $settings['output_buffers']); |
|
2895 | - elseif (!empty($settings['output_buffers'])) |
|
2896 | - $buffers = $settings['output_buffers']; |
|
2897 | - else |
|
2898 | - $buffers = array(); |
|
3060 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
3061 | + $buffers = explode(',', $settings['output_buffers']); |
|
3062 | + } elseif (!empty($settings['output_buffers'])) { |
|
3063 | + $buffers = $settings['output_buffers']; |
|
3064 | + } else { |
|
3065 | + $buffers = array(); |
|
3066 | + } |
|
2899 | 3067 | |
2900 | - if (isset($modSettings['integrate_buffer'])) |
|
2901 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3068 | + if (isset($modSettings['integrate_buffer'])) { |
|
3069 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3070 | + } |
|
2902 | 3071 | |
2903 | - if (!empty($buffers)) |
|
2904 | - foreach ($buffers as $function) |
|
3072 | + if (!empty($buffers)) { |
|
3073 | + foreach ($buffers as $function) |
|
2905 | 3074 | { |
2906 | 3075 | $call = call_helper($function, true); |
3076 | + } |
|
2907 | 3077 | |
2908 | 3078 | // Is it valid? |
2909 | - if (!empty($call)) |
|
2910 | - ob_start($call); |
|
3079 | + if (!empty($call)) { |
|
3080 | + ob_start($call); |
|
3081 | + } |
|
2911 | 3082 | } |
2912 | 3083 | |
2913 | 3084 | // Display the screen in the logical order. |
@@ -2919,8 +3090,9 @@ discard block |
||
2919 | 3090 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
2920 | 3091 | |
2921 | 3092 | // Anything special to put out? |
2922 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
2923 | - echo $context['insert_after_template']; |
|
3093 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
3094 | + echo $context['insert_after_template']; |
|
3095 | + } |
|
2924 | 3096 | |
2925 | 3097 | // Just so we don't get caught in an endless loop of errors from the footer... |
2926 | 3098 | if (!$footer_done) |
@@ -2929,14 +3101,16 @@ discard block |
||
2929 | 3101 | template_footer(); |
2930 | 3102 | |
2931 | 3103 | // (since this is just debugging... it's okay that it's after </html>.) |
2932 | - if (!isset($_REQUEST['xml'])) |
|
2933 | - displayDebug(); |
|
3104 | + if (!isset($_REQUEST['xml'])) { |
|
3105 | + displayDebug(); |
|
3106 | + } |
|
2934 | 3107 | } |
2935 | 3108 | } |
2936 | 3109 | |
2937 | 3110 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
2938 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
2939 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3111 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
3112 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3113 | + } |
|
2940 | 3114 | |
2941 | 3115 | // For session check verification.... don't switch browsers... |
2942 | 3116 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -2945,9 +3119,10 @@ discard block |
||
2945 | 3119 | call_integration_hook('integrate_exit', array($do_footer)); |
2946 | 3120 | |
2947 | 3121 | // Don't exit if we're coming from index.php; that will pass through normally. |
2948 | - if (!$from_index) |
|
2949 | - exit; |
|
2950 | -} |
|
3122 | + if (!$from_index) { |
|
3123 | + exit; |
|
3124 | + } |
|
3125 | + } |
|
2951 | 3126 | |
2952 | 3127 | /** |
2953 | 3128 | * Get the size of a specified image with better error handling. |
@@ -2966,8 +3141,9 @@ discard block |
||
2966 | 3141 | $url = str_replace(' ', '%20', $url); |
2967 | 3142 | |
2968 | 3143 | // Can we pull this from the cache... please please? |
2969 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
2970 | - return $temp; |
|
3144 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
3145 | + return $temp; |
|
3146 | + } |
|
2971 | 3147 | $t = microtime(); |
2972 | 3148 | |
2973 | 3149 | // Get the host to pester... |
@@ -2977,12 +3153,10 @@ discard block |
||
2977 | 3153 | if ($url == '' || $url == 'http://' || $url == 'https://') |
2978 | 3154 | { |
2979 | 3155 | return false; |
2980 | - } |
|
2981 | - elseif (!isset($match[1])) |
|
3156 | + } elseif (!isset($match[1])) |
|
2982 | 3157 | { |
2983 | 3158 | $size = @getimagesize($url); |
2984 | - } |
|
2985 | - else |
|
3159 | + } else |
|
2986 | 3160 | { |
2987 | 3161 | // Try to connect to the server... give it half a second. |
2988 | 3162 | $temp = 0; |
@@ -3021,12 +3195,14 @@ discard block |
||
3021 | 3195 | } |
3022 | 3196 | |
3023 | 3197 | // If we didn't get it, we failed. |
3024 | - if (!isset($size)) |
|
3025 | - $size = false; |
|
3198 | + if (!isset($size)) { |
|
3199 | + $size = false; |
|
3200 | + } |
|
3026 | 3201 | |
3027 | 3202 | // If this took a long time, we may never have to do it again, but then again we might... |
3028 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
3029 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3203 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
3204 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3205 | + } |
|
3030 | 3206 | |
3031 | 3207 | // Didn't work. |
3032 | 3208 | return $size; |
@@ -3044,8 +3220,9 @@ discard block |
||
3044 | 3220 | |
3045 | 3221 | // Under SSI this function can be called more then once. That can cause some problems. |
3046 | 3222 | // So only run the function once unless we are forced to run it again. |
3047 | - if ($loaded && !$forceload) |
|
3048 | - return; |
|
3223 | + if ($loaded && !$forceload) { |
|
3224 | + return; |
|
3225 | + } |
|
3049 | 3226 | |
3050 | 3227 | $loaded = true; |
3051 | 3228 | |
@@ -3057,14 +3234,16 @@ discard block |
||
3057 | 3234 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
3058 | 3235 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
3059 | 3236 | { |
3060 | - if (trim($context['news_lines'][$i]) == '') |
|
3061 | - continue; |
|
3237 | + if (trim($context['news_lines'][$i]) == '') { |
|
3238 | + continue; |
|
3239 | + } |
|
3062 | 3240 | |
3063 | 3241 | // Clean it up for presentation ;). |
3064 | 3242 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
3065 | 3243 | } |
3066 | - if (!empty($context['news_lines'])) |
|
3067 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3244 | + if (!empty($context['news_lines'])) { |
|
3245 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3246 | + } |
|
3068 | 3247 | |
3069 | 3248 | if (!$user_info['is_guest']) |
3070 | 3249 | { |
@@ -3073,40 +3252,48 @@ discard block |
||
3073 | 3252 | $context['user']['alerts'] = &$user_info['alerts']; |
3074 | 3253 | |
3075 | 3254 | // Personal message popup... |
3076 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
3077 | - $context['user']['popup_messages'] = true; |
|
3078 | - else |
|
3079 | - $context['user']['popup_messages'] = false; |
|
3255 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
3256 | + $context['user']['popup_messages'] = true; |
|
3257 | + } else { |
|
3258 | + $context['user']['popup_messages'] = false; |
|
3259 | + } |
|
3080 | 3260 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
3081 | 3261 | |
3082 | - if (allowedTo('moderate_forum')) |
|
3083 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3262 | + if (allowedTo('moderate_forum')) { |
|
3263 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3264 | + } |
|
3084 | 3265 | |
3085 | 3266 | $context['user']['avatar'] = array(); |
3086 | 3267 | |
3087 | 3268 | // Check for gravatar first since we might be forcing them... |
3088 | 3269 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
3089 | 3270 | { |
3090 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
3091 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3092 | - else |
|
3093 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3271 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
3272 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3273 | + } else { |
|
3274 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3275 | + } |
|
3094 | 3276 | } |
3095 | 3277 | // Uploaded? |
3096 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
3097 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
3278 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
3279 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
3280 | + } |
|
3098 | 3281 | // Full URL? |
3099 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
3100 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3282 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
3283 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3284 | + } |
|
3101 | 3285 | // Otherwise we assume it's server stored. |
3102 | - elseif ($user_info['avatar']['url'] != '') |
|
3103 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3286 | + elseif ($user_info['avatar']['url'] != '') { |
|
3287 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3288 | + } |
|
3104 | 3289 | // No avatar at all? Fine, we have a big fat default avatar ;) |
3105 | - else |
|
3106 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3290 | + else { |
|
3291 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3292 | + } |
|
3107 | 3293 | |
3108 | - if (!empty($context['user']['avatar'])) |
|
3109 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3294 | + if (!empty($context['user']['avatar'])) { |
|
3295 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3296 | + } |
|
3110 | 3297 | |
3111 | 3298 | // Figure out how long they've been logged in. |
3112 | 3299 | $context['user']['total_time_logged_in'] = array( |
@@ -3114,8 +3301,7 @@ discard block |
||
3114 | 3301 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
3115 | 3302 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
3116 | 3303 | ); |
3117 | - } |
|
3118 | - else |
|
3304 | + } else |
|
3119 | 3305 | { |
3120 | 3306 | $context['user']['messages'] = 0; |
3121 | 3307 | $context['user']['unread_messages'] = 0; |
@@ -3123,12 +3309,14 @@ discard block |
||
3123 | 3309 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
3124 | 3310 | $context['user']['popup_messages'] = false; |
3125 | 3311 | |
3126 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
3127 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3312 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
3313 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3314 | + } |
|
3128 | 3315 | |
3129 | 3316 | // If we've upgraded recently, go easy on the passwords. |
3130 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
3131 | - $context['disable_login_hashing'] = true; |
|
3317 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
3318 | + $context['disable_login_hashing'] = true; |
|
3319 | + } |
|
3132 | 3320 | } |
3133 | 3321 | |
3134 | 3322 | // Setup the main menu items. |
@@ -3141,8 +3329,8 @@ discard block |
||
3141 | 3329 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
3142 | 3330 | |
3143 | 3331 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
3144 | - if ($context['show_pm_popup']) |
|
3145 | - addInlineJavaScript(' |
|
3332 | + if ($context['show_pm_popup']) { |
|
3333 | + addInlineJavaScript(' |
|
3146 | 3334 | jQuery(document).ready(function($) { |
3147 | 3335 | new smc_Popup({ |
3148 | 3336 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3150,15 +3338,17 @@ discard block |
||
3150 | 3338 | icon_class: \'generic_icons mail_new\' |
3151 | 3339 | }); |
3152 | 3340 | });'); |
3341 | + } |
|
3153 | 3342 | |
3154 | 3343 | // Add a generic "Are you sure?" confirmation message. |
3155 | 3344 | addInlineJavaScript(' |
3156 | 3345 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
3157 | 3346 | |
3158 | 3347 | // Now add the capping code for avatars. |
3159 | - 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') |
|
3160 | - addInlineCss(' |
|
3348 | + 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') { |
|
3349 | + addInlineCss(' |
|
3161 | 3350 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
3351 | + } |
|
3162 | 3352 | |
3163 | 3353 | // This looks weird, but it's because BoardIndex.php references the variable. |
3164 | 3354 | $context['common_stats']['latest_member'] = array( |
@@ -3175,11 +3365,13 @@ discard block |
||
3175 | 3365 | ); |
3176 | 3366 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
3177 | 3367 | |
3178 | - if (empty($settings['theme_version'])) |
|
3179 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
3368 | + if (empty($settings['theme_version'])) { |
|
3369 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
3370 | + } |
|
3180 | 3371 | |
3181 | - if (!isset($context['page_title'])) |
|
3182 | - $context['page_title'] = ''; |
|
3372 | + if (!isset($context['page_title'])) { |
|
3373 | + $context['page_title'] = ''; |
|
3374 | + } |
|
3183 | 3375 | |
3184 | 3376 | // Set some specific vars. |
3185 | 3377 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3189,21 +3381,23 @@ discard block |
||
3189 | 3381 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
3190 | 3382 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
3191 | 3383 | |
3192 | - if (!empty($context['meta_keywords'])) |
|
3193 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3384 | + if (!empty($context['meta_keywords'])) { |
|
3385 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3386 | + } |
|
3194 | 3387 | |
3195 | - if (!empty($context['canonical_url'])) |
|
3196 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3388 | + if (!empty($context['canonical_url'])) { |
|
3389 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3390 | + } |
|
3197 | 3391 | |
3198 | - if (!empty($settings['og_image'])) |
|
3199 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3392 | + if (!empty($settings['og_image'])) { |
|
3393 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3394 | + } |
|
3200 | 3395 | |
3201 | 3396 | if (!empty($context['meta_description'])) |
3202 | 3397 | { |
3203 | 3398 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
3204 | 3399 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
3205 | - } |
|
3206 | - else |
|
3400 | + } else |
|
3207 | 3401 | { |
3208 | 3402 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
3209 | 3403 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3228,8 +3422,9 @@ discard block |
||
3228 | 3422 | $memory_needed = memoryReturnBytes($needed); |
3229 | 3423 | |
3230 | 3424 | // should we account for how much is currently being used? |
3231 | - if ($in_use) |
|
3232 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3425 | + if ($in_use) { |
|
3426 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3427 | + } |
|
3233 | 3428 | |
3234 | 3429 | // if more is needed, request it |
3235 | 3430 | if ($memory_current < $memory_needed) |
@@ -3252,8 +3447,9 @@ discard block |
||
3252 | 3447 | */ |
3253 | 3448 | function memoryReturnBytes($val) |
3254 | 3449 | { |
3255 | - if (is_integer($val)) |
|
3256 | - return $val; |
|
3450 | + if (is_integer($val)) { |
|
3451 | + return $val; |
|
3452 | + } |
|
3257 | 3453 | |
3258 | 3454 | // Separate the number from the designator |
3259 | 3455 | $val = trim($val); |
@@ -3289,10 +3485,11 @@ discard block |
||
3289 | 3485 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
3290 | 3486 | |
3291 | 3487 | // Are we debugging the template/html content? |
3292 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
3293 | - header('Content-Type: application/xhtml+xml'); |
|
3294 | - elseif (!isset($_REQUEST['xml'])) |
|
3295 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3488 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
3489 | + header('Content-Type: application/xhtml+xml'); |
|
3490 | + } elseif (!isset($_REQUEST['xml'])) { |
|
3491 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3492 | + } |
|
3296 | 3493 | } |
3297 | 3494 | |
3298 | 3495 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3301,8 +3498,9 @@ discard block |
||
3301 | 3498 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
3302 | 3499 | { |
3303 | 3500 | $position = array_search('body', $context['template_layers']); |
3304 | - if ($position === false) |
|
3305 | - $position = array_search('main', $context['template_layers']); |
|
3501 | + if ($position === false) { |
|
3502 | + $position = array_search('main', $context['template_layers']); |
|
3503 | + } |
|
3306 | 3504 | |
3307 | 3505 | if ($position !== false) |
3308 | 3506 | { |
@@ -3330,23 +3528,25 @@ discard block |
||
3330 | 3528 | |
3331 | 3529 | foreach ($securityFiles as $i => $securityFile) |
3332 | 3530 | { |
3333 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
3334 | - unset($securityFiles[$i]); |
|
3531 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
3532 | + unset($securityFiles[$i]); |
|
3533 | + } |
|
3335 | 3534 | } |
3336 | 3535 | |
3337 | 3536 | // We are already checking so many files...just few more doesn't make any difference! :P |
3338 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
3339 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3340 | - |
|
3341 | - else |
|
3342 | - $path = $modSettings['attachmentUploadDir']; |
|
3537 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
3538 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3539 | + } else { |
|
3540 | + $path = $modSettings['attachmentUploadDir']; |
|
3541 | + } |
|
3343 | 3542 | |
3344 | 3543 | secureDirectory($path, true); |
3345 | 3544 | secureDirectory($cachedir); |
3346 | 3545 | |
3347 | 3546 | // If agreement is enabled, at least the english version shall exists |
3348 | - if ($modSettings['requireAgreement']) |
|
3349 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3547 | + if ($modSettings['requireAgreement']) { |
|
3548 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3549 | + } |
|
3350 | 3550 | |
3351 | 3551 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
3352 | 3552 | { |
@@ -3361,18 +3561,21 @@ discard block |
||
3361 | 3561 | echo ' |
3362 | 3562 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
3363 | 3563 | |
3364 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
3365 | - echo ' |
|
3564 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
3565 | + echo ' |
|
3366 | 3566 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
3567 | + } |
|
3367 | 3568 | } |
3368 | 3569 | |
3369 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
3370 | - echo ' |
|
3570 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
3571 | + echo ' |
|
3371 | 3572 | <strong>', $txt['cache_writable'], '</strong><br>'; |
3573 | + } |
|
3372 | 3574 | |
3373 | - if (!empty($agreement)) |
|
3374 | - echo ' |
|
3575 | + if (!empty($agreement)) { |
|
3576 | + echo ' |
|
3375 | 3577 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
3578 | + } |
|
3376 | 3579 | |
3377 | 3580 | echo ' |
3378 | 3581 | </p> |
@@ -3387,16 +3590,18 @@ discard block |
||
3387 | 3590 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
3388 | 3591 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
3389 | 3592 | |
3390 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
3391 | - echo ' |
|
3593 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
3594 | + echo ' |
|
3392 | 3595 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
3596 | + } |
|
3393 | 3597 | |
3394 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
3395 | - echo ' |
|
3598 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
3599 | + echo ' |
|
3396 | 3600 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
3397 | - else |
|
3398 | - echo ' |
|
3601 | + } else { |
|
3602 | + echo ' |
|
3399 | 3603 | <div>', $txt['your_ban_expires_never'], '</div>'; |
3604 | + } |
|
3400 | 3605 | |
3401 | 3606 | echo ' |
3402 | 3607 | </div>'; |
@@ -3412,8 +3617,9 @@ discard block |
||
3412 | 3617 | global $forum_copyright, $software_year, $forum_version; |
3413 | 3618 | |
3414 | 3619 | // Don't display copyright for things like SSI. |
3415 | - if (!isset($forum_version) || !isset($software_year)) |
|
3416 | - return; |
|
3620 | + if (!isset($forum_version) || !isset($software_year)) { |
|
3621 | + return; |
|
3622 | + } |
|
3417 | 3623 | |
3418 | 3624 | // Put in the version... |
3419 | 3625 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3431,9 +3637,10 @@ discard block |
||
3431 | 3637 | $context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3)); |
3432 | 3638 | $context['load_queries'] = $db_count; |
3433 | 3639 | |
3434 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
3435 | - loadSubTemplate($layer . '_below', true); |
|
3436 | -} |
|
3640 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
3641 | + loadSubTemplate($layer . '_below', true); |
|
3642 | + } |
|
3643 | + } |
|
3437 | 3644 | |
3438 | 3645 | /** |
3439 | 3646 | * Output the Javascript files |
@@ -3464,8 +3671,7 @@ discard block |
||
3464 | 3671 | { |
3465 | 3672 | echo ' |
3466 | 3673 | var ', $key, ';'; |
3467 | - } |
|
3468 | - else |
|
3674 | + } else |
|
3469 | 3675 | { |
3470 | 3676 | echo ' |
3471 | 3677 | var ', $key, ' = ', $value, ';'; |
@@ -3480,26 +3686,27 @@ discard block |
||
3480 | 3686 | foreach ($context['javascript_files'] as $id => $js_file) |
3481 | 3687 | { |
3482 | 3688 | // Last minute call! allow theme authors to disable single files. |
3483 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3484 | - continue; |
|
3689 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3690 | + continue; |
|
3691 | + } |
|
3485 | 3692 | |
3486 | 3693 | // By default all files don't get minimized unless the file explicitly says so! |
3487 | 3694 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3488 | 3695 | { |
3489 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
3490 | - $toMinifyDefer[] = $js_file; |
|
3491 | - |
|
3492 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
3493 | - $toMinify[] = $js_file; |
|
3696 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
3697 | + $toMinifyDefer[] = $js_file; |
|
3698 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
3699 | + $toMinify[] = $js_file; |
|
3700 | + } |
|
3494 | 3701 | |
3495 | 3702 | // Grab a random seed. |
3496 | - if (!isset($minSeed)) |
|
3497 | - $minSeed = $js_file['options']['seed']; |
|
3498 | - } |
|
3499 | - |
|
3500 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
3501 | - echo ' |
|
3703 | + if (!isset($minSeed)) { |
|
3704 | + $minSeed = $js_file['options']['seed']; |
|
3705 | + } |
|
3706 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
3707 | + echo ' |
|
3502 | 3708 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
3709 | + } |
|
3503 | 3710 | } |
3504 | 3711 | |
3505 | 3712 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3507,14 +3714,14 @@ discard block |
||
3507 | 3714 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
3508 | 3715 | |
3509 | 3716 | // Minify process couldn't work, print each individual files. |
3510 | - if (!empty($result) && is_array($result)) |
|
3511 | - foreach ($result as $minFailedFile) |
|
3717 | + if (!empty($result) && is_array($result)) { |
|
3718 | + foreach ($result as $minFailedFile) |
|
3512 | 3719 | echo ' |
3513 | 3720 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
3514 | - |
|
3515 | - else |
|
3516 | - echo ' |
|
3721 | + } else { |
|
3722 | + echo ' |
|
3517 | 3723 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
3724 | + } |
|
3518 | 3725 | } |
3519 | 3726 | |
3520 | 3727 | // Inline JavaScript - Actually useful some times! |
@@ -3525,8 +3732,9 @@ discard block |
||
3525 | 3732 | echo ' |
3526 | 3733 | <script>'; |
3527 | 3734 | |
3528 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
3529 | - echo $js_code; |
|
3735 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
3736 | + echo $js_code; |
|
3737 | + } |
|
3530 | 3738 | |
3531 | 3739 | echo ' |
3532 | 3740 | </script>'; |
@@ -3537,8 +3745,9 @@ discard block |
||
3537 | 3745 | echo ' |
3538 | 3746 | <script>'; |
3539 | 3747 | |
3540 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
3541 | - echo $js_code; |
|
3748 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
3749 | + echo $js_code; |
|
3750 | + } |
|
3542 | 3751 | |
3543 | 3752 | echo ' |
3544 | 3753 | </script>'; |
@@ -3563,8 +3772,9 @@ discard block |
||
3563 | 3772 | foreach ($context['css_files'] as $id => $file) |
3564 | 3773 | { |
3565 | 3774 | // Last minute call! allow theme authors to disable single files. |
3566 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3567 | - continue; |
|
3775 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3776 | + continue; |
|
3777 | + } |
|
3568 | 3778 | |
3569 | 3779 | // By default all files don't get minimized unless the file explicitly says so! |
3570 | 3780 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3572,12 +3782,12 @@ discard block |
||
3572 | 3782 | $toMinify[] = $file; |
3573 | 3783 | |
3574 | 3784 | // Grab a random seed. |
3575 | - if (!isset($minSeed)) |
|
3576 | - $minSeed = $file['options']['seed']; |
|
3785 | + if (!isset($minSeed)) { |
|
3786 | + $minSeed = $file['options']['seed']; |
|
3787 | + } |
|
3788 | + } else { |
|
3789 | + $normal[] = $file['fileUrl']; |
|
3577 | 3790 | } |
3578 | - |
|
3579 | - else |
|
3580 | - $normal[] = $file['fileUrl']; |
|
3581 | 3791 | } |
3582 | 3792 | |
3583 | 3793 | if (!empty($toMinify)) |
@@ -3585,28 +3795,30 @@ discard block |
||
3585 | 3795 | $result = custMinify($toMinify, 'css'); |
3586 | 3796 | |
3587 | 3797 | // Minify process couldn't work, print each individual files. |
3588 | - if (!empty($result) && is_array($result)) |
|
3589 | - foreach ($result as $minFailedFile) |
|
3798 | + if (!empty($result) && is_array($result)) { |
|
3799 | + foreach ($result as $minFailedFile) |
|
3590 | 3800 | echo ' |
3591 | 3801 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
3592 | - |
|
3593 | - else |
|
3594 | - echo ' |
|
3802 | + } else { |
|
3803 | + echo ' |
|
3595 | 3804 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
3805 | + } |
|
3596 | 3806 | } |
3597 | 3807 | |
3598 | 3808 | // Print the rest after the minified files. |
3599 | - if (!empty($normal)) |
|
3600 | - foreach ($normal as $nf) |
|
3809 | + if (!empty($normal)) { |
|
3810 | + foreach ($normal as $nf) |
|
3601 | 3811 | echo ' |
3602 | 3812 | <link rel="stylesheet" href="', $nf ,'">'; |
3813 | + } |
|
3603 | 3814 | |
3604 | 3815 | if ($db_show_debug === true) |
3605 | 3816 | { |
3606 | 3817 | // Try to keep only what's useful. |
3607 | 3818 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
3608 | - foreach ($context['css_files'] as $file) |
|
3609 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3819 | + foreach ($context['css_files'] as $file) { |
|
3820 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3821 | + } |
|
3610 | 3822 | } |
3611 | 3823 | |
3612 | 3824 | if (!empty($context['css_header'])) |
@@ -3614,9 +3826,10 @@ discard block |
||
3614 | 3826 | echo ' |
3615 | 3827 | <style>'; |
3616 | 3828 | |
3617 | - foreach ($context['css_header'] as $css) |
|
3618 | - echo $css .' |
|
3829 | + foreach ($context['css_header'] as $css) { |
|
3830 | + echo $css .' |
|
3619 | 3831 | '; |
3832 | + } |
|
3620 | 3833 | |
3621 | 3834 | echo' |
3622 | 3835 | </style>'; |
@@ -3640,15 +3853,17 @@ discard block |
||
3640 | 3853 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
3641 | 3854 | $data = !empty($data) ? $data : false; |
3642 | 3855 | |
3643 | - if (empty($type) || empty($data)) |
|
3644 | - return false; |
|
3856 | + if (empty($type) || empty($data)) { |
|
3857 | + return false; |
|
3858 | + } |
|
3645 | 3859 | |
3646 | 3860 | // Did we already did this? |
3647 | 3861 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
3648 | 3862 | |
3649 | 3863 | // Already done? |
3650 | - if (!empty($toCache)) |
|
3651 | - return true; |
|
3864 | + if (!empty($toCache)) { |
|
3865 | + return true; |
|
3866 | + } |
|
3652 | 3867 | |
3653 | 3868 | // No namespaces, sorry! |
3654 | 3869 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3730,8 +3945,9 @@ discard block |
||
3730 | 3945 | global $modSettings, $smcFunc; |
3731 | 3946 | |
3732 | 3947 | // Just make up a nice hash... |
3733 | - if ($new) |
|
3734 | - return sha1(md5($filename . time()) . mt_rand()); |
|
3948 | + if ($new) { |
|
3949 | + return sha1(md5($filename . time()) . mt_rand()); |
|
3950 | + } |
|
3735 | 3951 | |
3736 | 3952 | // Just make sure that attachment id is only a int |
3737 | 3953 | $attachment_id = (int) $attachment_id; |
@@ -3748,23 +3964,25 @@ discard block |
||
3748 | 3964 | 'id_attach' => $attachment_id, |
3749 | 3965 | )); |
3750 | 3966 | |
3751 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
3752 | - return false; |
|
3967 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
3968 | + return false; |
|
3969 | + } |
|
3753 | 3970 | |
3754 | 3971 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
3755 | 3972 | $smcFunc['db_free_result']($request); |
3756 | 3973 | } |
3757 | 3974 | |
3758 | 3975 | // Still no hash? mmm... |
3759 | - if (empty($file_hash)) |
|
3760 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
3976 | + if (empty($file_hash)) { |
|
3977 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
3978 | + } |
|
3761 | 3979 | |
3762 | 3980 | // Are we using multiple directories? |
3763 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
3764 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3765 | - |
|
3766 | - else |
|
3767 | - $path = $modSettings['attachmentUploadDir']; |
|
3981 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
3982 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3983 | + } else { |
|
3984 | + $path = $modSettings['attachmentUploadDir']; |
|
3985 | + } |
|
3768 | 3986 | |
3769 | 3987 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
3770 | 3988 | } |
@@ -3779,8 +3997,9 @@ discard block |
||
3779 | 3997 | function ip2range($fullip) |
3780 | 3998 | { |
3781 | 3999 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
3782 | - if ($fullip == 'unknown') |
|
3783 | - $fullip = '255.255.255.255'; |
|
4000 | + if ($fullip == 'unknown') { |
|
4001 | + $fullip = '255.255.255.255'; |
|
4002 | + } |
|
3784 | 4003 | |
3785 | 4004 | $ip_parts = explode('-', $fullip); |
3786 | 4005 | $ip_array = array(); |
@@ -3804,10 +4023,11 @@ discard block |
||
3804 | 4023 | $ip_array['low'] = $ip_parts[0]; |
3805 | 4024 | $ip_array['high'] = $ip_parts[1]; |
3806 | 4025 | return $ip_array; |
3807 | - } |
|
3808 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
4026 | + } elseif (count($ip_parts) == 2) { |
|
4027 | + // if ip 22.22.*-22.22.* |
|
3809 | 4028 | { |
3810 | 4029 | $valid_low = isValidIP($ip_parts[0]); |
4030 | + } |
|
3811 | 4031 | $valid_high = isValidIP($ip_parts[1]); |
3812 | 4032 | $count = 0; |
3813 | 4033 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3822,7 +4042,9 @@ discard block |
||
3822 | 4042 | $ip_parts[0] .= $mode . $min; |
3823 | 4043 | $valid_low = isValidIP($ip_parts[0]); |
3824 | 4044 | $count++; |
3825 | - if ($count > 9) break; |
|
4045 | + if ($count > 9) { |
|
4046 | + break; |
|
4047 | + } |
|
3826 | 4048 | } |
3827 | 4049 | } |
3828 | 4050 | |
@@ -3836,7 +4058,9 @@ discard block |
||
3836 | 4058 | $ip_parts[1] .= $mode . $max; |
3837 | 4059 | $valid_high = isValidIP($ip_parts[1]); |
3838 | 4060 | $count++; |
3839 | - if ($count > 9) break; |
|
4061 | + if ($count > 9) { |
|
4062 | + break; |
|
4063 | + } |
|
3840 | 4064 | } |
3841 | 4065 | } |
3842 | 4066 | |
@@ -3861,46 +4085,54 @@ discard block |
||
3861 | 4085 | { |
3862 | 4086 | global $modSettings; |
3863 | 4087 | |
3864 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
3865 | - return $host; |
|
4088 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
4089 | + return $host; |
|
4090 | + } |
|
3866 | 4091 | $t = microtime(); |
3867 | 4092 | |
3868 | 4093 | // Try the Linux host command, perhaps? |
3869 | 4094 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
3870 | 4095 | { |
3871 | - if (!isset($modSettings['host_to_dis'])) |
|
3872 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
3873 | - else |
|
3874 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4096 | + if (!isset($modSettings['host_to_dis'])) { |
|
4097 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4098 | + } else { |
|
4099 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4100 | + } |
|
3875 | 4101 | |
3876 | 4102 | // Did host say it didn't find anything? |
3877 | - if (strpos($test, 'not found') !== false) |
|
3878 | - $host = ''; |
|
4103 | + if (strpos($test, 'not found') !== false) { |
|
4104 | + $host = ''; |
|
4105 | + } |
|
3879 | 4106 | // Invalid server option? |
3880 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
3881 | - updateSettings(array('host_to_dis' => 1)); |
|
4107 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
4108 | + updateSettings(array('host_to_dis' => 1)); |
|
4109 | + } |
|
3882 | 4110 | // Maybe it found something, after all? |
3883 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
3884 | - $host = $match[1]; |
|
4111 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
4112 | + $host = $match[1]; |
|
4113 | + } |
|
3885 | 4114 | } |
3886 | 4115 | |
3887 | 4116 | // This is nslookup; usually only Windows, but possibly some Unix? |
3888 | 4117 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
3889 | 4118 | { |
3890 | 4119 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
3891 | - if (strpos($test, 'Non-existent domain') !== false) |
|
3892 | - $host = ''; |
|
3893 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
3894 | - $host = $match[1]; |
|
4120 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
4121 | + $host = ''; |
|
4122 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
4123 | + $host = $match[1]; |
|
4124 | + } |
|
3895 | 4125 | } |
3896 | 4126 | |
3897 | 4127 | // This is the last try :/. |
3898 | - if (!isset($host) || $host === false) |
|
3899 | - $host = @gethostbyaddr($ip); |
|
4128 | + if (!isset($host) || $host === false) { |
|
4129 | + $host = @gethostbyaddr($ip); |
|
4130 | + } |
|
3900 | 4131 | |
3901 | 4132 | // It took a long time, so let's cache it! |
3902 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
3903 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4133 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
4134 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4135 | + } |
|
3904 | 4136 | |
3905 | 4137 | return $host; |
3906 | 4138 | } |
@@ -3936,20 +4168,21 @@ discard block |
||
3936 | 4168 | { |
3937 | 4169 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
3938 | 4170 | $total = 0; |
3939 | - for ($i = 0; $i < $max_chars; $i++) |
|
3940 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4171 | + for ($i = 0; $i < $max_chars; $i++) { |
|
4172 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4173 | + } |
|
3941 | 4174 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
3942 | 4175 | } |
3943 | 4176 | } |
3944 | 4177 | return array_unique($returned_ints); |
3945 | - } |
|
3946 | - else |
|
4178 | + } else |
|
3947 | 4179 | { |
3948 | 4180 | // Trim characters before and after and add slashes for database insertion. |
3949 | 4181 | $returned_words = array(); |
3950 | - foreach ($words as $word) |
|
3951 | - if (($word = trim($word, '-_\'')) !== '') |
|
4182 | + foreach ($words as $word) { |
|
4183 | + if (($word = trim($word, '-_\'')) !== '') |
|
3952 | 4184 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
4185 | + } |
|
3953 | 4186 | |
3954 | 4187 | // Filter out all words that occur more than once. |
3955 | 4188 | return array_unique($returned_words); |
@@ -3971,16 +4204,18 @@ discard block |
||
3971 | 4204 | global $settings, $txt; |
3972 | 4205 | |
3973 | 4206 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
3974 | - if (function_exists('template_create_button') && !$force_use) |
|
3975 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4207 | + if (function_exists('template_create_button') && !$force_use) { |
|
4208 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4209 | + } |
|
3976 | 4210 | |
3977 | - if (!$settings['use_image_buttons']) |
|
3978 | - return $txt[$alt]; |
|
3979 | - elseif (!empty($settings['use_buttons'])) |
|
3980 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
3981 | - else |
|
3982 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
3983 | -} |
|
4211 | + if (!$settings['use_image_buttons']) { |
|
4212 | + return $txt[$alt]; |
|
4213 | + } elseif (!empty($settings['use_buttons'])) { |
|
4214 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4215 | + } else { |
|
4216 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4217 | + } |
|
4218 | + } |
|
3984 | 4219 | |
3985 | 4220 | /** |
3986 | 4221 | * Sets up all of the top menu buttons |
@@ -4023,9 +4258,10 @@ discard block |
||
4023 | 4258 | var user_menus = new smc_PopupMenu(); |
4024 | 4259 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4025 | 4260 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
4026 | - if ($context['allow_pm']) |
|
4027 | - addInlineJavaScript(' |
|
4261 | + if ($context['allow_pm']) { |
|
4262 | + addInlineJavaScript(' |
|
4028 | 4263 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
4264 | + } |
|
4029 | 4265 | |
4030 | 4266 | if (!empty($modSettings['enable_ajax_alerts'])) |
4031 | 4267 | { |
@@ -4185,88 +4421,96 @@ discard block |
||
4185 | 4421 | |
4186 | 4422 | // Now we put the buttons in the context so the theme can use them. |
4187 | 4423 | $menu_buttons = array(); |
4188 | - foreach ($buttons as $act => $button) |
|
4189 | - if (!empty($button['show'])) |
|
4424 | + foreach ($buttons as $act => $button) { |
|
4425 | + if (!empty($button['show'])) |
|
4190 | 4426 | { |
4191 | 4427 | $button['active_button'] = false; |
4428 | + } |
|
4192 | 4429 | |
4193 | 4430 | // This button needs some action. |
4194 | - if (isset($button['action_hook'])) |
|
4195 | - $needs_action_hook = true; |
|
4431 | + if (isset($button['action_hook'])) { |
|
4432 | + $needs_action_hook = true; |
|
4433 | + } |
|
4196 | 4434 | |
4197 | 4435 | // Make sure the last button truly is the last button. |
4198 | 4436 | if (!empty($button['is_last'])) |
4199 | 4437 | { |
4200 | - if (isset($last_button)) |
|
4201 | - unset($menu_buttons[$last_button]['is_last']); |
|
4438 | + if (isset($last_button)) { |
|
4439 | + unset($menu_buttons[$last_button]['is_last']); |
|
4440 | + } |
|
4202 | 4441 | $last_button = $act; |
4203 | 4442 | } |
4204 | 4443 | |
4205 | 4444 | // Go through the sub buttons if there are any. |
4206 | - if (!empty($button['sub_buttons'])) |
|
4207 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4445 | + if (!empty($button['sub_buttons'])) { |
|
4446 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4208 | 4447 | { |
4209 | 4448 | if (empty($subbutton['show'])) |
4210 | 4449 | unset($button['sub_buttons'][$key]); |
4450 | + } |
|
4211 | 4451 | |
4212 | 4452 | // 2nd level sub buttons next... |
4213 | 4453 | if (!empty($subbutton['sub_buttons'])) |
4214 | 4454 | { |
4215 | 4455 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
4216 | 4456 | { |
4217 | - if (empty($sub_button2['show'])) |
|
4218 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4457 | + if (empty($sub_button2['show'])) { |
|
4458 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4459 | + } |
|
4219 | 4460 | } |
4220 | 4461 | } |
4221 | 4462 | } |
4222 | 4463 | |
4223 | 4464 | // Does this button have its own icon? |
4224 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
4225 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4226 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
4227 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4228 | - elseif (isset($button['icon'])) |
|
4229 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4230 | - else |
|
4231 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4465 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
4466 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4467 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
4468 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4469 | + } elseif (isset($button['icon'])) { |
|
4470 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4471 | + } else { |
|
4472 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4473 | + } |
|
4232 | 4474 | |
4233 | 4475 | $menu_buttons[$act] = $button; |
4234 | 4476 | } |
4235 | 4477 | |
4236 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
4237 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4478 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
4479 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4480 | + } |
|
4238 | 4481 | } |
4239 | 4482 | |
4240 | 4483 | $context['menu_buttons'] = $menu_buttons; |
4241 | 4484 | |
4242 | 4485 | // Logging out requires the session id in the url. |
4243 | - if (isset($context['menu_buttons']['logout'])) |
|
4244 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4486 | + if (isset($context['menu_buttons']['logout'])) { |
|
4487 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4488 | + } |
|
4245 | 4489 | |
4246 | 4490 | // Figure out which action we are doing so we can set the active tab. |
4247 | 4491 | // Default to home. |
4248 | 4492 | $current_action = 'home'; |
4249 | 4493 | |
4250 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
4251 | - $current_action = $context['current_action']; |
|
4252 | - elseif ($context['current_action'] == 'search2') |
|
4253 | - $current_action = 'search'; |
|
4254 | - elseif ($context['current_action'] == 'theme') |
|
4255 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4256 | - elseif ($context['current_action'] == 'register2') |
|
4257 | - $current_action = 'register'; |
|
4258 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
4259 | - $current_action = 'login'; |
|
4260 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
4261 | - $current_action = 'moderate'; |
|
4494 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
4495 | + $current_action = $context['current_action']; |
|
4496 | + } elseif ($context['current_action'] == 'search2') { |
|
4497 | + $current_action = 'search'; |
|
4498 | + } elseif ($context['current_action'] == 'theme') { |
|
4499 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4500 | + } elseif ($context['current_action'] == 'register2') { |
|
4501 | + $current_action = 'register'; |
|
4502 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
4503 | + $current_action = 'login'; |
|
4504 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
4505 | + $current_action = 'moderate'; |
|
4506 | + } |
|
4262 | 4507 | |
4263 | 4508 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
4264 | 4509 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
4265 | 4510 | { |
4266 | 4511 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
4267 | 4512 | $context[$current_action] = true; |
4268 | - } |
|
4269 | - elseif ($context['current_action'] == 'pm') |
|
4513 | + } elseif ($context['current_action'] == 'pm') |
|
4270 | 4514 | { |
4271 | 4515 | $current_action = 'self_pm'; |
4272 | 4516 | $context['self_pm'] = true; |
@@ -4309,12 +4553,14 @@ discard block |
||
4309 | 4553 | } |
4310 | 4554 | |
4311 | 4555 | // Not all actions are simple. |
4312 | - if (!empty($needs_action_hook)) |
|
4313 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4556 | + if (!empty($needs_action_hook)) { |
|
4557 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4558 | + } |
|
4314 | 4559 | |
4315 | - if (isset($context['menu_buttons'][$current_action])) |
|
4316 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4317 | -} |
|
4560 | + if (isset($context['menu_buttons'][$current_action])) { |
|
4561 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4562 | + } |
|
4563 | + } |
|
4318 | 4564 | |
4319 | 4565 | /** |
4320 | 4566 | * Generate a random seed and ensure it's stored in settings. |
@@ -4338,30 +4584,35 @@ discard block |
||
4338 | 4584 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
4339 | 4585 | global $context, $txt; |
4340 | 4586 | |
4341 | - if ($db_show_debug === true) |
|
4342 | - $context['debug']['hooks'][] = $hook; |
|
4587 | + if ($db_show_debug === true) { |
|
4588 | + $context['debug']['hooks'][] = $hook; |
|
4589 | + } |
|
4343 | 4590 | |
4344 | 4591 | // Need to have some control. |
4345 | - if (!isset($context['instances'])) |
|
4346 | - $context['instances'] = array(); |
|
4592 | + if (!isset($context['instances'])) { |
|
4593 | + $context['instances'] = array(); |
|
4594 | + } |
|
4347 | 4595 | |
4348 | 4596 | $results = array(); |
4349 | - if (empty($modSettings[$hook])) |
|
4350 | - return $results; |
|
4597 | + if (empty($modSettings[$hook])) { |
|
4598 | + return $results; |
|
4599 | + } |
|
4351 | 4600 | |
4352 | 4601 | $functions = explode(',', $modSettings[$hook]); |
4353 | 4602 | // Loop through each function. |
4354 | 4603 | foreach ($functions as $function) |
4355 | 4604 | { |
4356 | 4605 | // Hook has been marked as "disabled". Skip it! |
4357 | - if (strpos($function, '!') !== false) |
|
4358 | - continue; |
|
4606 | + if (strpos($function, '!') !== false) { |
|
4607 | + continue; |
|
4608 | + } |
|
4359 | 4609 | |
4360 | 4610 | $call = call_helper($function, true); |
4361 | 4611 | |
4362 | 4612 | // Is it valid? |
4363 | - if (!empty($call)) |
|
4364 | - $results[$function] = call_user_func_array($call, $parameters); |
|
4613 | + if (!empty($call)) { |
|
4614 | + $results[$function] = call_user_func_array($call, $parameters); |
|
4615 | + } |
|
4365 | 4616 | |
4366 | 4617 | // Whatever it was suppose to call, it failed :( |
4367 | 4618 | elseif (!empty($function)) |
@@ -4377,8 +4628,9 @@ discard block |
||
4377 | 4628 | } |
4378 | 4629 | |
4379 | 4630 | // "Assume" the file resides on $boarddir somewhere... |
4380 | - else |
|
4381 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4631 | + else { |
|
4632 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4633 | + } |
|
4382 | 4634 | } |
4383 | 4635 | } |
4384 | 4636 | |
@@ -4400,12 +4652,14 @@ discard block |
||
4400 | 4652 | global $smcFunc, $modSettings; |
4401 | 4653 | |
4402 | 4654 | // Any objects? |
4403 | - if ($object) |
|
4404 | - $function = $function . '#'; |
|
4655 | + if ($object) { |
|
4656 | + $function = $function . '#'; |
|
4657 | + } |
|
4405 | 4658 | |
4406 | 4659 | // Any files to load? |
4407 | - if (!empty($file) && is_string($file)) |
|
4408 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4660 | + if (!empty($file) && is_string($file)) { |
|
4661 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4662 | + } |
|
4409 | 4663 | |
4410 | 4664 | // Get the correct string. |
4411 | 4665 | $integration_call = $function; |
@@ -4427,13 +4681,14 @@ discard block |
||
4427 | 4681 | if (!empty($current_functions)) |
4428 | 4682 | { |
4429 | 4683 | $current_functions = explode(',', $current_functions); |
4430 | - if (in_array($integration_call, $current_functions)) |
|
4431 | - return; |
|
4684 | + if (in_array($integration_call, $current_functions)) { |
|
4685 | + return; |
|
4686 | + } |
|
4432 | 4687 | |
4433 | 4688 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
4689 | + } else { |
|
4690 | + $permanent_functions = array($integration_call); |
|
4434 | 4691 | } |
4435 | - else |
|
4436 | - $permanent_functions = array($integration_call); |
|
4437 | 4692 | |
4438 | 4693 | updateSettings(array($hook => implode(',', $permanent_functions))); |
4439 | 4694 | } |
@@ -4442,8 +4697,9 @@ discard block |
||
4442 | 4697 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4443 | 4698 | |
4444 | 4699 | // Do nothing, if it's already there. |
4445 | - if (in_array($integration_call, $functions)) |
|
4446 | - return; |
|
4700 | + if (in_array($integration_call, $functions)) { |
|
4701 | + return; |
|
4702 | + } |
|
4447 | 4703 | |
4448 | 4704 | $functions[] = $integration_call; |
4449 | 4705 | $modSettings[$hook] = implode(',', $functions); |
@@ -4466,12 +4722,14 @@ discard block |
||
4466 | 4722 | global $smcFunc, $modSettings; |
4467 | 4723 | |
4468 | 4724 | // Any objects? |
4469 | - if ($object) |
|
4470 | - $function = $function . '#'; |
|
4725 | + if ($object) { |
|
4726 | + $function = $function . '#'; |
|
4727 | + } |
|
4471 | 4728 | |
4472 | 4729 | // Any files to load? |
4473 | - if (!empty($file) && is_string($file)) |
|
4474 | - $function = $file . '|' . $function; |
|
4730 | + if (!empty($file) && is_string($file)) { |
|
4731 | + $function = $file . '|' . $function; |
|
4732 | + } |
|
4475 | 4733 | |
4476 | 4734 | // Get the correct string. |
4477 | 4735 | $integration_call = $function; |
@@ -4492,16 +4750,18 @@ discard block |
||
4492 | 4750 | { |
4493 | 4751 | $current_functions = explode(',', $current_functions); |
4494 | 4752 | |
4495 | - if (in_array($integration_call, $current_functions)) |
|
4496 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4753 | + if (in_array($integration_call, $current_functions)) { |
|
4754 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4755 | + } |
|
4497 | 4756 | } |
4498 | 4757 | |
4499 | 4758 | // Turn the function list into something usable. |
4500 | 4759 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4501 | 4760 | |
4502 | 4761 | // You can only remove it if it's available. |
4503 | - if (!in_array($integration_call, $functions)) |
|
4504 | - return; |
|
4762 | + if (!in_array($integration_call, $functions)) { |
|
4763 | + return; |
|
4764 | + } |
|
4505 | 4765 | |
4506 | 4766 | $functions = array_diff($functions, array($integration_call)); |
4507 | 4767 | $modSettings[$hook] = implode(',', $functions); |
@@ -4522,17 +4782,20 @@ discard block |
||
4522 | 4782 | global $context, $smcFunc, $txt, $db_show_debug; |
4523 | 4783 | |
4524 | 4784 | // Really? |
4525 | - if (empty($string)) |
|
4526 | - return false; |
|
4785 | + if (empty($string)) { |
|
4786 | + return false; |
|
4787 | + } |
|
4527 | 4788 | |
4528 | 4789 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
4529 | 4790 | // A closure? should be a callable one. |
4530 | - if (is_array($string) || $string instanceof Closure) |
|
4531 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4791 | + if (is_array($string) || $string instanceof Closure) { |
|
4792 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4793 | + } |
|
4532 | 4794 | |
4533 | 4795 | // No full objects, sorry! pass a method or a property instead! |
4534 | - if (is_object($string)) |
|
4535 | - return false; |
|
4796 | + if (is_object($string)) { |
|
4797 | + return false; |
|
4798 | + } |
|
4536 | 4799 | |
4537 | 4800 | // Stay vitaminized my friends... |
4538 | 4801 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4541,8 +4804,9 @@ discard block |
||
4541 | 4804 | $string = load_file($string); |
4542 | 4805 | |
4543 | 4806 | // Loaded file failed |
4544 | - if (empty($string)) |
|
4545 | - return false; |
|
4807 | + if (empty($string)) { |
|
4808 | + return false; |
|
4809 | + } |
|
4546 | 4810 | |
4547 | 4811 | // Found a method. |
4548 | 4812 | if (strpos($string, '::') !== false) |
@@ -4563,8 +4827,9 @@ discard block |
||
4563 | 4827 | // Add another one to the list. |
4564 | 4828 | if ($db_show_debug === true) |
4565 | 4829 | { |
4566 | - if (!isset($context['debug']['instances'])) |
|
4567 | - $context['debug']['instances'] = array(); |
|
4830 | + if (!isset($context['debug']['instances'])) { |
|
4831 | + $context['debug']['instances'] = array(); |
|
4832 | + } |
|
4568 | 4833 | |
4569 | 4834 | $context['debug']['instances'][$class] = $class; |
4570 | 4835 | } |
@@ -4574,13 +4839,15 @@ discard block |
||
4574 | 4839 | } |
4575 | 4840 | |
4576 | 4841 | // Right then. This is a call to a static method. |
4577 | - else |
|
4578 | - $func = array($class, $method); |
|
4842 | + else { |
|
4843 | + $func = array($class, $method); |
|
4844 | + } |
|
4579 | 4845 | } |
4580 | 4846 | |
4581 | 4847 | // Nope! just a plain regular function. |
4582 | - else |
|
4583 | - $func = $string; |
|
4848 | + else { |
|
4849 | + $func = $string; |
|
4850 | + } |
|
4584 | 4851 | |
4585 | 4852 | // Right, we got what we need, time to do some checks. |
4586 | 4853 | if (!is_callable($func, false, $callable_name)) |
@@ -4596,17 +4863,18 @@ discard block |
||
4596 | 4863 | else |
4597 | 4864 | { |
4598 | 4865 | // What are we gonna do about it? |
4599 | - if ($return) |
|
4600 | - return $func; |
|
4866 | + if ($return) { |
|
4867 | + return $func; |
|
4868 | + } |
|
4601 | 4869 | |
4602 | 4870 | // If this is a plain function, avoid the heat of calling call_user_func(). |
4603 | 4871 | else |
4604 | 4872 | { |
4605 | - if (is_array($func)) |
|
4606 | - call_user_func($func); |
|
4607 | - |
|
4608 | - else |
|
4609 | - $func(); |
|
4873 | + if (is_array($func)) { |
|
4874 | + call_user_func($func); |
|
4875 | + } else { |
|
4876 | + $func(); |
|
4877 | + } |
|
4610 | 4878 | } |
4611 | 4879 | } |
4612 | 4880 | } |
@@ -4623,31 +4891,34 @@ discard block |
||
4623 | 4891 | { |
4624 | 4892 | global $sourcedir, $txt, $boarddir, $settings; |
4625 | 4893 | |
4626 | - if (empty($string)) |
|
4627 | - return false; |
|
4894 | + if (empty($string)) { |
|
4895 | + return false; |
|
4896 | + } |
|
4628 | 4897 | |
4629 | 4898 | if (strpos($string, '|') !== false) |
4630 | 4899 | { |
4631 | 4900 | list ($file, $string) = explode('|', $string); |
4632 | 4901 | |
4633 | 4902 | // Match the wildcards to their regular vars. |
4634 | - if (empty($settings['theme_dir'])) |
|
4635 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4636 | - |
|
4637 | - else |
|
4638 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
4903 | + if (empty($settings['theme_dir'])) { |
|
4904 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4905 | + } else { |
|
4906 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
4907 | + } |
|
4639 | 4908 | |
4640 | 4909 | // Load the file if it can be loaded. |
4641 | - if (file_exists($absPath)) |
|
4642 | - require_once($absPath); |
|
4910 | + if (file_exists($absPath)) { |
|
4911 | + require_once($absPath); |
|
4912 | + } |
|
4643 | 4913 | |
4644 | 4914 | // No? try a fallback to $sourcedir |
4645 | 4915 | else |
4646 | 4916 | { |
4647 | 4917 | $absPath = $sourcedir .'/'. $file; |
4648 | 4918 | |
4649 | - if (file_exists($absPath)) |
|
4650 | - require_once($absPath); |
|
4919 | + if (file_exists($absPath)) { |
|
4920 | + require_once($absPath); |
|
4921 | + } |
|
4651 | 4922 | |
4652 | 4923 | // Sorry, can't do much for you at this point. |
4653 | 4924 | else |
@@ -4674,8 +4945,9 @@ discard block |
||
4674 | 4945 | global $user_info, $smcFunc; |
4675 | 4946 | |
4676 | 4947 | // Make sure we have something to work with. |
4677 | - if (empty($topic)) |
|
4678 | - return array(); |
|
4948 | + if (empty($topic)) { |
|
4949 | + return array(); |
|
4950 | + } |
|
4679 | 4951 | |
4680 | 4952 | |
4681 | 4953 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4698,8 +4970,9 @@ discard block |
||
4698 | 4970 | 'topic' => $topic, |
4699 | 4971 | ) |
4700 | 4972 | ); |
4701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4702 | - $temp[] = (int) $row['content_id']; |
|
4973 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4974 | + $temp[] = (int) $row['content_id']; |
|
4975 | + } |
|
4703 | 4976 | |
4704 | 4977 | cache_put_data($cache_key, $temp, $ttl); |
4705 | 4978 | } |
@@ -4720,8 +4993,9 @@ discard block |
||
4720 | 4993 | { |
4721 | 4994 | global $context; |
4722 | 4995 | |
4723 | - if (empty($string)) |
|
4724 | - return $string; |
|
4996 | + if (empty($string)) { |
|
4997 | + return $string; |
|
4998 | + } |
|
4725 | 4999 | |
4726 | 5000 | // UTF-8 occurences of MS special characters |
4727 | 5001 | $findchars_utf8 = array( |
@@ -4762,10 +5036,11 @@ discard block |
||
4762 | 5036 | '--', // — |
4763 | 5037 | ); |
4764 | 5038 | |
4765 | - if ($context['utf8']) |
|
4766 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
4767 | - else |
|
4768 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
5039 | + if ($context['utf8']) { |
|
5040 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5041 | + } else { |
|
5042 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
5043 | + } |
|
4769 | 5044 | |
4770 | 5045 | return $string; |
4771 | 5046 | } |
@@ -4784,49 +5059,59 @@ discard block |
||
4784 | 5059 | { |
4785 | 5060 | global $context; |
4786 | 5061 | |
4787 | - if (!isset($matches[2])) |
|
4788 | - return ''; |
|
5062 | + if (!isset($matches[2])) { |
|
5063 | + return ''; |
|
5064 | + } |
|
4789 | 5065 | |
4790 | 5066 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4791 | 5067 | |
4792 | 5068 | // remove left to right / right to left overrides |
4793 | - if ($num === 0x202D || $num === 0x202E) |
|
4794 | - return ''; |
|
5069 | + if ($num === 0x202D || $num === 0x202E) { |
|
5070 | + return ''; |
|
5071 | + } |
|
4795 | 5072 | |
4796 | 5073 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
4797 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
4798 | - return '&#' . $num . ';'; |
|
5074 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
5075 | + return '&#' . $num . ';'; |
|
5076 | + } |
|
4799 | 5077 | |
4800 | 5078 | if (empty($context['utf8'])) |
4801 | 5079 | { |
4802 | 5080 | // no control characters |
4803 | - if ($num < 0x20) |
|
4804 | - return ''; |
|
5081 | + if ($num < 0x20) { |
|
5082 | + return ''; |
|
5083 | + } |
|
4805 | 5084 | // text is text |
4806 | - elseif ($num < 0x80) |
|
4807 | - return chr($num); |
|
5085 | + elseif ($num < 0x80) { |
|
5086 | + return chr($num); |
|
5087 | + } |
|
4808 | 5088 | // all others get html-ised |
4809 | - else |
|
4810 | - return '&#' . $matches[2] . ';'; |
|
4811 | - } |
|
4812 | - else |
|
5089 | + else { |
|
5090 | + return '&#' . $matches[2] . ';'; |
|
5091 | + } |
|
5092 | + } else |
|
4813 | 5093 | { |
4814 | 5094 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
4815 | 5095 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
4816 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
4817 | - return ''; |
|
5096 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
5097 | + return ''; |
|
5098 | + } |
|
4818 | 5099 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4819 | - elseif ($num < 0x80) |
|
4820 | - return chr($num); |
|
5100 | + elseif ($num < 0x80) { |
|
5101 | + return chr($num); |
|
5102 | + } |
|
4821 | 5103 | // <0x800 (2048) |
4822 | - elseif ($num < 0x800) |
|
4823 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5104 | + elseif ($num < 0x800) { |
|
5105 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5106 | + } |
|
4824 | 5107 | // < 0x10000 (65536) |
4825 | - elseif ($num < 0x10000) |
|
4826 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5108 | + elseif ($num < 0x10000) { |
|
5109 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5110 | + } |
|
4827 | 5111 | // <= 0x10FFFF (1114111) |
4828 | - else |
|
4829 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5112 | + else { |
|
5113 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5114 | + } |
|
4830 | 5115 | } |
4831 | 5116 | } |
4832 | 5117 | |
@@ -4842,28 +5127,34 @@ discard block |
||
4842 | 5127 | */ |
4843 | 5128 | function fixchar__callback($matches) |
4844 | 5129 | { |
4845 | - if (!isset($matches[1])) |
|
4846 | - return ''; |
|
5130 | + if (!isset($matches[1])) { |
|
5131 | + return ''; |
|
5132 | + } |
|
4847 | 5133 | |
4848 | 5134 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
4849 | 5135 | |
4850 | 5136 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
4851 | 5137 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
4852 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
4853 | - return ''; |
|
5138 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
5139 | + return ''; |
|
5140 | + } |
|
4854 | 5141 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4855 | - elseif ($num < 0x80) |
|
4856 | - return chr($num); |
|
5142 | + elseif ($num < 0x80) { |
|
5143 | + return chr($num); |
|
5144 | + } |
|
4857 | 5145 | // <0x800 (2048) |
4858 | - elseif ($num < 0x800) |
|
4859 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5146 | + elseif ($num < 0x800) { |
|
5147 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5148 | + } |
|
4860 | 5149 | // < 0x10000 (65536) |
4861 | - elseif ($num < 0x10000) |
|
4862 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5150 | + elseif ($num < 0x10000) { |
|
5151 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5152 | + } |
|
4863 | 5153 | // <= 0x10FFFF (1114111) |
4864 | - else |
|
4865 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
4866 | -} |
|
5154 | + else { |
|
5155 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5156 | + } |
|
5157 | + } |
|
4867 | 5158 | |
4868 | 5159 | /** |
4869 | 5160 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4876,17 +5167,19 @@ discard block |
||
4876 | 5167 | */ |
4877 | 5168 | function entity_fix__callback($matches) |
4878 | 5169 | { |
4879 | - if (!isset($matches[2])) |
|
4880 | - return ''; |
|
5170 | + if (!isset($matches[2])) { |
|
5171 | + return ''; |
|
5172 | + } |
|
4881 | 5173 | |
4882 | 5174 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4883 | 5175 | |
4884 | 5176 | // we don't allow control characters, characters out of range, byte markers, etc |
4885 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
4886 | - return ''; |
|
4887 | - else |
|
4888 | - return '&#' . $num . ';'; |
|
4889 | -} |
|
5177 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
5178 | + return ''; |
|
5179 | + } else { |
|
5180 | + return '&#' . $num . ';'; |
|
5181 | + } |
|
5182 | + } |
|
4890 | 5183 | |
4891 | 5184 | /** |
4892 | 5185 | * Return a Gravatar URL based on |
@@ -4910,18 +5203,23 @@ discard block |
||
4910 | 5203 | $ratings = array('G', 'PG', 'R', 'X'); |
4911 | 5204 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
4912 | 5205 | $url_params = array(); |
4913 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
4914 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
4915 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
4916 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
4917 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
4918 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
4919 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
4920 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5206 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
5207 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5208 | + } |
|
5209 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
5210 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5211 | + } |
|
5212 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
5213 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5214 | + } |
|
5215 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
5216 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
4921 | 5217 | $size_string = $modSettings['avatar_max_height_external']; |
5218 | + } |
|
4922 | 5219 | |
4923 | - if (!empty($size_string)) |
|
4924 | - $url_params[] = 's=' . $size_string; |
|
5220 | + if (!empty($size_string)) { |
|
5221 | + $url_params[] = 's=' . $size_string; |
|
5222 | + } |
|
4925 | 5223 | } |
4926 | 5224 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
4927 | 5225 | |
@@ -4940,22 +5238,26 @@ discard block |
||
4940 | 5238 | static $timezones = null, $lastwhen = null; |
4941 | 5239 | |
4942 | 5240 | // No point doing this over if we already did it once |
4943 | - if (!empty($timezones) && $when == $lastwhen) |
|
4944 | - return $timezones; |
|
4945 | - else |
|
4946 | - $lastwhen = $when; |
|
5241 | + if (!empty($timezones) && $when == $lastwhen) { |
|
5242 | + return $timezones; |
|
5243 | + } else { |
|
5244 | + $lastwhen = $when; |
|
5245 | + } |
|
4947 | 5246 | |
4948 | 5247 | // Parseable datetime string? |
4949 | - if (is_int($timestamp = strtotime($when))) |
|
4950 | - $when = $timestamp; |
|
5248 | + if (is_int($timestamp = strtotime($when))) { |
|
5249 | + $when = $timestamp; |
|
5250 | + } |
|
4951 | 5251 | |
4952 | 5252 | // A Unix timestamp? |
4953 | - elseif (is_numeric($when)) |
|
4954 | - $when = intval($when); |
|
5253 | + elseif (is_numeric($when)) { |
|
5254 | + $when = intval($when); |
|
5255 | + } |
|
4955 | 5256 | |
4956 | 5257 | // Invalid value? Just get current Unix timestamp. |
4957 | - else |
|
4958 | - $when = time(); |
|
5258 | + else { |
|
5259 | + $when = time(); |
|
5260 | + } |
|
4959 | 5261 | |
4960 | 5262 | // We'll need these too |
4961 | 5263 | $date_when = date_create('@' . $when); |
@@ -5019,8 +5321,9 @@ discard block |
||
5019 | 5321 | foreach ($priority_countries as $country) |
5020 | 5322 | { |
5021 | 5323 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
5022 | - if (!empty($country_tzids)) |
|
5023 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5324 | + if (!empty($country_tzids)) { |
|
5325 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5326 | + } |
|
5024 | 5327 | } |
5025 | 5328 | |
5026 | 5329 | // Process the preferred timezones first, then the rest. |
@@ -5030,8 +5333,9 @@ discard block |
||
5030 | 5333 | foreach ($tzids as $tzid) |
5031 | 5334 | { |
5032 | 5335 | // We don't want UTC right now |
5033 | - if ($tzid == 'UTC') |
|
5034 | - continue; |
|
5336 | + if ($tzid == 'UTC') { |
|
5337 | + continue; |
|
5338 | + } |
|
5035 | 5339 | |
5036 | 5340 | $tz = timezone_open($tzid); |
5037 | 5341 | |
@@ -5046,12 +5350,14 @@ discard block |
||
5046 | 5350 | $tzgeo = timezone_location_get($tz); |
5047 | 5351 | |
5048 | 5352 | // Don't overwrite our preferred tzids |
5049 | - if (empty($zones[$tzkey]['tzid'])) |
|
5050 | - $zones[$tzkey]['tzid'] = $tzid; |
|
5353 | + if (empty($zones[$tzkey]['tzid'])) { |
|
5354 | + $zones[$tzkey]['tzid'] = $tzid; |
|
5355 | + } |
|
5051 | 5356 | |
5052 | 5357 | // A time zone from a prioritized country? |
5053 | - if (in_array($tzid, $priority_tzids)) |
|
5054 | - $priority_zones[$tzkey] = true; |
|
5358 | + if (in_array($tzid, $priority_tzids)) { |
|
5359 | + $priority_zones[$tzkey] = true; |
|
5360 | + } |
|
5055 | 5361 | |
5056 | 5362 | // Keep track of the location and offset for this tzid |
5057 | 5363 | $tzid_parts = explode('/', $tzid); |
@@ -5072,15 +5378,17 @@ discard block |
||
5072 | 5378 | |
5073 | 5379 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
5074 | 5380 | |
5075 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
5076 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5077 | - else |
|
5078 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5381 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
5382 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5383 | + } else { |
|
5384 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5385 | + } |
|
5079 | 5386 | |
5080 | - if (isset($priority_zones[$tzkey])) |
|
5081 | - $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5082 | - else |
|
5083 | - $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5387 | + if (isset($priority_zones[$tzkey])) { |
|
5388 | + $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5389 | + } else { |
|
5390 | + $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5391 | + } |
|
5084 | 5392 | } |
5085 | 5393 | |
5086 | 5394 | $timezones = array_merge( |
@@ -5134,9 +5442,9 @@ discard block |
||
5134 | 5442 | 'Indian/Kerguelen' => 'TFT', |
5135 | 5443 | ); |
5136 | 5444 | |
5137 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
5138 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5139 | - else |
|
5445 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
5446 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5447 | + } else |
|
5140 | 5448 | { |
5141 | 5449 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
5142 | 5450 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5164,8 +5472,9 @@ discard block |
||
5164 | 5472 | */ |
5165 | 5473 | function inet_ptod($ip_address) |
5166 | 5474 | { |
5167 | - if (!isValidIP($ip_address)) |
|
5168 | - return $ip_address; |
|
5475 | + if (!isValidIP($ip_address)) { |
|
5476 | + return $ip_address; |
|
5477 | + } |
|
5169 | 5478 | |
5170 | 5479 | $bin = inet_pton($ip_address); |
5171 | 5480 | return $bin; |
@@ -5177,13 +5486,15 @@ discard block |
||
5177 | 5486 | */ |
5178 | 5487 | function inet_dtop($bin) |
5179 | 5488 | { |
5180 | - if(empty($bin)) |
|
5181 | - return ''; |
|
5489 | + if(empty($bin)) { |
|
5490 | + return ''; |
|
5491 | + } |
|
5182 | 5492 | |
5183 | 5493 | global $db_type; |
5184 | 5494 | |
5185 | - if ($db_type == 'postgresql') |
|
5186 | - return $bin; |
|
5495 | + if ($db_type == 'postgresql') { |
|
5496 | + return $bin; |
|
5497 | + } |
|
5187 | 5498 | |
5188 | 5499 | $ip_address = inet_ntop($bin); |
5189 | 5500 | |
@@ -5208,26 +5519,32 @@ discard block |
||
5208 | 5519 | */ |
5209 | 5520 | function _safe_serialize($value) |
5210 | 5521 | { |
5211 | - if(is_null($value)) |
|
5212 | - return 'N;'; |
|
5522 | + if(is_null($value)) { |
|
5523 | + return 'N;'; |
|
5524 | + } |
|
5213 | 5525 | |
5214 | - if(is_bool($value)) |
|
5215 | - return 'b:'. (int) $value .';'; |
|
5526 | + if(is_bool($value)) { |
|
5527 | + return 'b:'. (int) $value .';'; |
|
5528 | + } |
|
5216 | 5529 | |
5217 | - if(is_int($value)) |
|
5218 | - return 'i:'. $value .';'; |
|
5530 | + if(is_int($value)) { |
|
5531 | + return 'i:'. $value .';'; |
|
5532 | + } |
|
5219 | 5533 | |
5220 | - if(is_float($value)) |
|
5221 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5534 | + if(is_float($value)) { |
|
5535 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
5536 | + } |
|
5222 | 5537 | |
5223 | - if(is_string($value)) |
|
5224 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5538 | + if(is_string($value)) { |
|
5539 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
5540 | + } |
|
5225 | 5541 | |
5226 | 5542 | if(is_array($value)) |
5227 | 5543 | { |
5228 | 5544 | $out = ''; |
5229 | - foreach($value as $k => $v) |
|
5230 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5545 | + foreach($value as $k => $v) { |
|
5546 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5547 | + } |
|
5231 | 5548 | |
5232 | 5549 | return 'a:'. count($value) .':{'. $out .'}'; |
5233 | 5550 | } |
@@ -5253,8 +5570,9 @@ discard block |
||
5253 | 5570 | |
5254 | 5571 | $out = _safe_serialize($value); |
5255 | 5572 | |
5256 | - if (isset($mbIntEnc)) |
|
5257 | - mb_internal_encoding($mbIntEnc); |
|
5573 | + if (isset($mbIntEnc)) { |
|
5574 | + mb_internal_encoding($mbIntEnc); |
|
5575 | + } |
|
5258 | 5576 | |
5259 | 5577 | return $out; |
5260 | 5578 | } |
@@ -5271,8 +5589,9 @@ discard block |
||
5271 | 5589 | function _safe_unserialize($str) |
5272 | 5590 | { |
5273 | 5591 | // Input is not a string. |
5274 | - if(empty($str) || !is_string($str)) |
|
5275 | - return false; |
|
5592 | + if(empty($str) || !is_string($str)) { |
|
5593 | + return false; |
|
5594 | + } |
|
5276 | 5595 | |
5277 | 5596 | $stack = array(); |
5278 | 5597 | $expected = array(); |
@@ -5288,43 +5607,38 @@ discard block |
||
5288 | 5607 | while($state != 1) |
5289 | 5608 | { |
5290 | 5609 | $type = isset($str[0]) ? $str[0] : ''; |
5291 | - if($type == '}') |
|
5292 | - $str = substr($str, 1); |
|
5293 | - |
|
5294 | - else if($type == 'N' && $str[1] == ';') |
|
5610 | + if($type == '}') { |
|
5611 | + $str = substr($str, 1); |
|
5612 | + } else if($type == 'N' && $str[1] == ';') |
|
5295 | 5613 | { |
5296 | 5614 | $value = null; |
5297 | 5615 | $str = substr($str, 2); |
5298 | - } |
|
5299 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5616 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5300 | 5617 | { |
5301 | 5618 | $value = $matches[1] == '1' ? true : false; |
5302 | 5619 | $str = substr($str, 4); |
5303 | - } |
|
5304 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5620 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5305 | 5621 | { |
5306 | 5622 | $value = (int)$matches[1]; |
5307 | 5623 | $str = $matches[2]; |
5308 | - } |
|
5309 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5624 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5310 | 5625 | { |
5311 | 5626 | $value = (float)$matches[1]; |
5312 | 5627 | $str = $matches[3]; |
5313 | - } |
|
5314 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5628 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5315 | 5629 | { |
5316 | 5630 | $value = substr($matches[2], 0, (int)$matches[1]); |
5317 | 5631 | $str = substr($matches[2], (int)$matches[1] + 2); |
5318 | - } |
|
5319 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5632 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5320 | 5633 | { |
5321 | 5634 | $expectedLength = (int)$matches[1]; |
5322 | 5635 | $str = $matches[2]; |
5323 | 5636 | } |
5324 | 5637 | |
5325 | 5638 | // Object or unknown/malformed type. |
5326 | - else |
|
5327 | - return false; |
|
5639 | + else { |
|
5640 | + return false; |
|
5641 | + } |
|
5328 | 5642 | |
5329 | 5643 | switch($state) |
5330 | 5644 | { |
@@ -5352,8 +5666,9 @@ discard block |
||
5352 | 5666 | if($type == '}') |
5353 | 5667 | { |
5354 | 5668 | // Array size is less than expected. |
5355 | - if(count($list) < end($expected)) |
|
5356 | - return false; |
|
5669 | + if(count($list) < end($expected)) { |
|
5670 | + return false; |
|
5671 | + } |
|
5357 | 5672 | |
5358 | 5673 | unset($list); |
5359 | 5674 | $list = &$stack[count($stack)-1]; |
@@ -5362,8 +5677,9 @@ discard block |
||
5362 | 5677 | // Go to terminal state if we're at the end of the root array. |
5363 | 5678 | array_pop($expected); |
5364 | 5679 | |
5365 | - if(count($expected) == 0) |
|
5366 | - $state = 1; |
|
5680 | + if(count($expected) == 0) { |
|
5681 | + $state = 1; |
|
5682 | + } |
|
5367 | 5683 | |
5368 | 5684 | break; |
5369 | 5685 | } |
@@ -5371,8 +5687,9 @@ discard block |
||
5371 | 5687 | if($type == 'i' || $type == 's') |
5372 | 5688 | { |
5373 | 5689 | // Array size exceeds expected length. |
5374 | - if(count($list) >= end($expected)) |
|
5375 | - return false; |
|
5690 | + if(count($list) >= end($expected)) { |
|
5691 | + return false; |
|
5692 | + } |
|
5376 | 5693 | |
5377 | 5694 | $key = $value; |
5378 | 5695 | $state = 3; |
@@ -5406,8 +5723,9 @@ discard block |
||
5406 | 5723 | } |
5407 | 5724 | |
5408 | 5725 | // Trailing data in input. |
5409 | - if(!empty($str)) |
|
5410 | - return false; |
|
5726 | + if(!empty($str)) { |
|
5727 | + return false; |
|
5728 | + } |
|
5411 | 5729 | |
5412 | 5730 | return $data; |
5413 | 5731 | } |
@@ -5430,8 +5748,9 @@ discard block |
||
5430 | 5748 | |
5431 | 5749 | $out = _safe_unserialize($str); |
5432 | 5750 | |
5433 | - if (isset($mbIntEnc)) |
|
5434 | - mb_internal_encoding($mbIntEnc); |
|
5751 | + if (isset($mbIntEnc)) { |
|
5752 | + mb_internal_encoding($mbIntEnc); |
|
5753 | + } |
|
5435 | 5754 | |
5436 | 5755 | return $out; |
5437 | 5756 | } |
@@ -5446,12 +5765,14 @@ discard block |
||
5446 | 5765 | function smf_chmod($file, $value = 0) |
5447 | 5766 | { |
5448 | 5767 | // No file? no checks! |
5449 | - if (empty($file)) |
|
5450 | - return false; |
|
5768 | + if (empty($file)) { |
|
5769 | + return false; |
|
5770 | + } |
|
5451 | 5771 | |
5452 | 5772 | // Already writable? |
5453 | - if (is_writable($file)) |
|
5454 | - return true; |
|
5773 | + if (is_writable($file)) { |
|
5774 | + return true; |
|
5775 | + } |
|
5455 | 5776 | |
5456 | 5777 | // Do we have a file or a dir? |
5457 | 5778 | $isDir = is_dir($file); |
@@ -5467,10 +5788,9 @@ discard block |
||
5467 | 5788 | { |
5468 | 5789 | $isWritable = true; |
5469 | 5790 | break; |
5791 | + } else { |
|
5792 | + @chmod($file, $val); |
|
5470 | 5793 | } |
5471 | - |
|
5472 | - else |
|
5473 | - @chmod($file, $val); |
|
5474 | 5794 | } |
5475 | 5795 | |
5476 | 5796 | return $isWritable; |
@@ -5489,8 +5809,9 @@ discard block |
||
5489 | 5809 | global $txt; |
5490 | 5810 | |
5491 | 5811 | // Come on... |
5492 | - if (empty($json) || !is_string($json)) |
|
5493 | - return array(); |
|
5812 | + if (empty($json) || !is_string($json)) { |
|
5813 | + return array(); |
|
5814 | + } |
|
5494 | 5815 | |
5495 | 5816 | $returnArray = @json_decode($json, $returnAsArray); |
5496 | 5817 | |
@@ -5528,11 +5849,11 @@ discard block |
||
5528 | 5849 | $jsonDebug = $jsonDebug[0]; |
5529 | 5850 | loadLanguage('Errors'); |
5530 | 5851 | |
5531 | - if (!empty($jsonDebug)) |
|
5532 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5533 | - |
|
5534 | - else |
|
5535 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5852 | + if (!empty($jsonDebug)) { |
|
5853 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5854 | + } else { |
|
5855 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
5856 | + } |
|
5536 | 5857 | |
5537 | 5858 | // Everyone expects an array. |
5538 | 5859 | return array(); |
@@ -5562,8 +5883,9 @@ discard block |
||
5562 | 5883 | global $db_show_debug, $modSettings; |
5563 | 5884 | |
5564 | 5885 | // Defensive programming anyone? |
5565 | - if (empty($data)) |
|
5566 | - return false; |
|
5886 | + if (empty($data)) { |
|
5887 | + return false; |
|
5888 | + } |
|
5567 | 5889 | |
5568 | 5890 | // Don't need extra stuff... |
5569 | 5891 | $db_show_debug = false; |
@@ -5571,11 +5893,11 @@ discard block |
||
5571 | 5893 | // Kill anything else. |
5572 | 5894 | ob_end_clean(); |
5573 | 5895 | |
5574 | - if (!empty($modSettings['CompressedOutput'])) |
|
5575 | - @ob_start('ob_gzhandler'); |
|
5576 | - |
|
5577 | - else |
|
5578 | - ob_start(); |
|
5896 | + if (!empty($modSettings['CompressedOutput'])) { |
|
5897 | + @ob_start('ob_gzhandler'); |
|
5898 | + } else { |
|
5899 | + ob_start(); |
|
5900 | + } |
|
5579 | 5901 | |
5580 | 5902 | // Set the header. |
5581 | 5903 | header($type); |
@@ -5607,8 +5929,9 @@ discard block |
||
5607 | 5929 | static $done = false; |
5608 | 5930 | |
5609 | 5931 | // If we don't need to do anything, don't |
5610 | - if (!$update && $done) |
|
5611 | - return; |
|
5932 | + if (!$update && $done) { |
|
5933 | + return; |
|
5934 | + } |
|
5612 | 5935 | |
5613 | 5936 | // Should we get a new copy of the official list of TLDs? |
5614 | 5937 | if ($update) |
@@ -5629,10 +5952,11 @@ discard block |
||
5629 | 5952 | // Clean $tlds and convert it to an array |
5630 | 5953 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
5631 | 5954 | $line = trim($line); |
5632 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
5633 | - return false; |
|
5634 | - else |
|
5635 | - return true; |
|
5955 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
5956 | + return false; |
|
5957 | + } else { |
|
5958 | + return true; |
|
5959 | + } |
|
5636 | 5960 | }); |
5637 | 5961 | |
5638 | 5962 | // Convert Punycode to Unicode |
@@ -5686,8 +6010,9 @@ discard block |
||
5686 | 6010 | $idx += $digit * $w; |
5687 | 6011 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
5688 | 6012 | |
5689 | - if ($digit < $t) |
|
5690 | - break; |
|
6013 | + if ($digit < $t) { |
|
6014 | + break; |
|
6015 | + } |
|
5691 | 6016 | |
5692 | 6017 | $w = (int) ($w * ($base - $t)); |
5693 | 6018 | } |
@@ -5696,8 +6021,9 @@ discard block |
||
5696 | 6021 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
5697 | 6022 | $delta += intval($delta / ($deco_len + 1)); |
5698 | 6023 | |
5699 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
5700 | - $delta = intval($delta / ($base - $tmin)); |
|
6024 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
6025 | + $delta = intval($delta / ($base - $tmin)); |
|
6026 | + } |
|
5701 | 6027 | |
5702 | 6028 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
5703 | 6029 | $is_first = false; |
@@ -5706,8 +6032,9 @@ discard block |
||
5706 | 6032 | |
5707 | 6033 | if ($deco_len > 0) |
5708 | 6034 | { |
5709 | - for ($i = $deco_len; $i > $idx; $i--) |
|
5710 | - $decoded[$i] = $decoded[($i - 1)]; |
|
6035 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
6036 | + $decoded[$i] = $decoded[($i - 1)]; |
|
6037 | + } |
|
5711 | 6038 | } |
5712 | 6039 | $decoded[$idx++] = $char; |
5713 | 6040 | } |
@@ -5715,24 +6042,29 @@ discard block |
||
5715 | 6042 | foreach ($decoded as $k => $v) |
5716 | 6043 | { |
5717 | 6044 | // 7bit are transferred literally |
5718 | - if ($v < 128) |
|
5719 | - $output .= chr($v); |
|
6045 | + if ($v < 128) { |
|
6046 | + $output .= chr($v); |
|
6047 | + } |
|
5720 | 6048 | |
5721 | 6049 | // 2 bytes |
5722 | - elseif ($v < (1 << 11)) |
|
5723 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6050 | + elseif ($v < (1 << 11)) { |
|
6051 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6052 | + } |
|
5724 | 6053 | |
5725 | 6054 | // 3 bytes |
5726 | - elseif ($v < (1 << 16)) |
|
5727 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6055 | + elseif ($v < (1 << 16)) { |
|
6056 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6057 | + } |
|
5728 | 6058 | |
5729 | 6059 | // 4 bytes |
5730 | - elseif ($v < (1 << 21)) |
|
5731 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6060 | + elseif ($v < (1 << 21)) { |
|
6061 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6062 | + } |
|
5732 | 6063 | |
5733 | 6064 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5734 | - else |
|
5735 | - $output .= $safe_char; |
|
6065 | + else { |
|
6066 | + $output .= $safe_char; |
|
6067 | + } |
|
5736 | 6068 | } |
5737 | 6069 | |
5738 | 6070 | $output_parts[] = $output; |
@@ -5827,8 +6159,7 @@ discard block |
||
5827 | 6159 | |
5828 | 6160 | $strlen = 'mb_strlen'; |
5829 | 6161 | $substr = 'mb_substr'; |
5830 | - } |
|
5831 | - else |
|
6162 | + } else |
|
5832 | 6163 | { |
5833 | 6164 | $strlen = $smcFunc['strlen']; |
5834 | 6165 | $substr = $smcFunc['substr']; |
@@ -5842,20 +6173,21 @@ discard block |
||
5842 | 6173 | |
5843 | 6174 | $first = $substr($string, 0, 1); |
5844 | 6175 | |
5845 | - if (empty($index[$first])) |
|
5846 | - $index[$first] = array(); |
|
6176 | + if (empty($index[$first])) { |
|
6177 | + $index[$first] = array(); |
|
6178 | + } |
|
5847 | 6179 | |
5848 | 6180 | if ($strlen($string) > 1) |
5849 | 6181 | { |
5850 | 6182 | // Sanity check on recursion |
5851 | - if ($depth > 99) |
|
5852 | - $index[$first][$substr($string, 1)] = ''; |
|
5853 | - |
|
5854 | - else |
|
5855 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6183 | + if ($depth > 99) { |
|
6184 | + $index[$first][$substr($string, 1)] = ''; |
|
6185 | + } else { |
|
6186 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6187 | + } |
|
6188 | + } else { |
|
6189 | + $index[$first][''] = ''; |
|
5856 | 6190 | } |
5857 | - else |
|
5858 | - $index[$first][''] = ''; |
|
5859 | 6191 | |
5860 | 6192 | $depth--; |
5861 | 6193 | return $index; |
@@ -5878,9 +6210,9 @@ discard block |
||
5878 | 6210 | $key_regex = preg_quote($key, $delim); |
5879 | 6211 | $new_key = $key; |
5880 | 6212 | |
5881 | - if (empty($value)) |
|
5882 | - $sub_regex = ''; |
|
5883 | - else |
|
6213 | + if (empty($value)) { |
|
6214 | + $sub_regex = ''; |
|
6215 | + } else |
|
5884 | 6216 | { |
5885 | 6217 | $sub_regex = $index_to_regex($value, $delim); |
5886 | 6218 | |
@@ -5888,22 +6220,22 @@ discard block |
||
5888 | 6220 | { |
5889 | 6221 | $new_key_array = explode('(?'.'>', $sub_regex); |
5890 | 6222 | $new_key .= $new_key_array[0]; |
6223 | + } else { |
|
6224 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5891 | 6225 | } |
5892 | - else |
|
5893 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5894 | 6226 | } |
5895 | 6227 | |
5896 | - if ($depth > 1) |
|
5897 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
5898 | - else |
|
6228 | + if ($depth > 1) { |
|
6229 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
6230 | + } else |
|
5899 | 6231 | { |
5900 | 6232 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
5901 | 6233 | { |
5902 | 6234 | $regex[$new_key] = $key_regex . $sub_regex; |
5903 | 6235 | unset($index[$key]); |
6236 | + } else { |
|
6237 | + break; |
|
5904 | 6238 | } |
5905 | - else |
|
5906 | - break; |
|
5907 | 6239 | } |
5908 | 6240 | } |
5909 | 6241 | |
@@ -5912,10 +6244,11 @@ discard block |
||
5912 | 6244 | $l1 = $strlen($k1); |
5913 | 6245 | $l2 = $strlen($k2); |
5914 | 6246 | |
5915 | - if ($l1 == $l2) |
|
5916 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
5917 | - else |
|
5918 | - return $l1 > $l2 ? -1 : 1; |
|
6247 | + if ($l1 == $l2) { |
|
6248 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6249 | + } else { |
|
6250 | + return $l1 > $l2 ? -1 : 1; |
|
6251 | + } |
|
5919 | 6252 | }); |
5920 | 6253 | |
5921 | 6254 | $depth--; |
@@ -5926,15 +6259,18 @@ discard block |
||
5926 | 6259 | $index = array(); |
5927 | 6260 | $regexes = array(); |
5928 | 6261 | |
5929 | - foreach ($strings as $string) |
|
5930 | - $index = $add_string_to_index($string, $index); |
|
6262 | + foreach ($strings as $string) { |
|
6263 | + $index = $add_string_to_index($string, $index); |
|
6264 | + } |
|
5931 | 6265 | |
5932 | - while (!empty($index)) |
|
5933 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6266 | + while (!empty($index)) { |
|
6267 | + $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6268 | + } |
|
5934 | 6269 | |
5935 | 6270 | // Restore PHP's internal character encoding to whatever it was originally |
5936 | - if (!empty($current_encoding)) |
|
5937 | - mb_internal_encoding($current_encoding); |
|
6271 | + if (!empty($current_encoding)) { |
|
6272 | + mb_internal_encoding($current_encoding); |
|
6273 | + } |
|
5938 | 6274 | |
5939 | 6275 | return $regexes; |
5940 | 6276 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | // Just send a generic message. |
77 | 77 | else |
78 | 78 | $this->setResponse(array( |
79 | - 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
79 | + 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
80 | 80 | 'type' => 'error', |
81 | 81 | 'data' => false, |
82 | 82 | )); |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | // Gotta urlencode the filename. |
405 | 405 | if ($this->_attachResults) |
406 | 406 | foreach ($this->_attachResults as $k => $v) |
407 | - $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
407 | + $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
408 | 408 | |
409 | 409 | $this->_response = array( |
410 | 410 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | ob_start(); |
432 | 432 | |
433 | 433 | // Set the header. |
434 | - header('Content-Type: application/json; charset='. $context['character_set'] .''); |
|
434 | + header('Content-Type: application/json; charset=' . $context['character_set'] . ''); |
|
435 | 435 | |
436 | 436 | echo json_encode($this->_response ? $this->_response : array()); |
437 | 437 |
@@ -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 | class Attachments |
20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
70 | 71 | |
71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
72 | 73 | |
73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
74 | - $this->{$this->_sa}(); |
|
74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
75 | + $this->{$this->_sa}(); |
|
76 | + } |
|
75 | 77 | |
76 | 78 | // Just send a generic message. |
77 | - else |
|
78 | - $this->setResponse(array( |
|
79 | + else { |
|
80 | + $this->setResponse(array( |
|
79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
80 | 82 | 'type' => 'error', |
81 | 83 | 'data' => false, |
82 | 84 | )); |
85 | + } |
|
83 | 86 | |
84 | 87 | // Back to the future, oh, to the browser! |
85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
96 | 99 | |
97 | 100 | // Need something to work with. |
98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
99 | - return $this->setResponse(array( |
|
101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
102 | + return $this->setResponse(array( |
|
100 | 103 | 'text' => 'attached_file_deleted_error', |
101 | 104 | 'type' => 'error', |
102 | 105 | 'data' => false, |
103 | 106 | )); |
107 | + } |
|
104 | 108 | |
105 | 109 | // Lets pass some params and see what happens :P |
106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
119 | 123 | public function add() |
120 | 124 | { |
121 | 125 | // You gotta be able to post attachments. |
122 | - if (!$this->_canPostAttachment) |
|
123 | - return $this->setResponse(array( |
|
126 | + if (!$this->_canPostAttachment) { |
|
127 | + return $this->setResponse(array( |
|
124 | 128 | 'text' => 'attached_file_cannot', |
125 | 129 | 'type' => 'error', |
126 | 130 | 'data' => false, |
127 | 131 | )); |
132 | + } |
|
128 | 133 | |
129 | 134 | // Process them at once! |
130 | 135 | $this->processAttachments(); |
131 | 136 | |
132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
133 | - if (!empty($_SESSION['temp_attachments'])) |
|
134 | - $this->createAtttach(); |
|
138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
139 | + $this->createAtttach(); |
|
140 | + } |
|
135 | 141 | |
136 | 142 | // Set the response. |
137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
144 | 150 | { |
145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
146 | 152 | |
147 | - if (!isset($_FILES['attachment']['name'])) |
|
148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
153 | + if (!isset($_FILES['attachment']['name'])) { |
|
154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // If there are attachments, calculate the total size and how many. |
151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
155 | 162 | if (isset($_REQUEST['msg'])) |
156 | 163 | { |
157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
158 | - foreach ($context['current_attachments'] as $attachment) |
|
159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
165 | + foreach ($context['current_attachments'] as $attachment) { |
|
166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | |
162 | 170 | // A bit of house keeping first. |
163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
164 | - unset($_SESSION['temp_attachments']); |
|
171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
172 | + unset($_SESSION['temp_attachments']); |
|
173 | + } |
|
165 | 174 | |
166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
167 | - if (!isset($_SESSION['temp_attachments'])) |
|
168 | - $_SESSION['temp_attachments'] = array(); |
|
176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
177 | + $_SESSION['temp_attachments'] = array(); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // Make sure we're uploading to the right place. |
171 | - if (!empty($modSettings['automanage_attachments'])) |
|
172 | - automanage_attachments_check_directory(); |
|
181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
182 | + automanage_attachments_check_directory(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | // Is the attachments folder actually there? |
175 | - if (!empty($context['dir_creation_error'])) |
|
176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
186 | + if (!empty($context['dir_creation_error'])) { |
|
187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
188 | + } |
|
177 | 189 | |
178 | 190 | // The current attach folder ha some issues... |
179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
198 | 210 | ); |
199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
200 | 212 | $smcFunc['db_free_result']($request); |
201 | - } |
|
202 | - |
|
203 | - else |
|
204 | - $context['attachments'] = array( |
|
213 | + } else { |
|
214 | + $context['attachments'] = array( |
|
205 | 215 | 'quantity' => 0, |
206 | 216 | 'total_size' => 0, |
207 | 217 | ); |
218 | + } |
|
208 | 219 | |
209 | 220 | // Check for other general errors here. |
210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
212 | 223 | if (!empty($this->_generalErrors)) |
213 | 224 | { |
214 | 225 | // And delete the files 'cos they ain't going nowhere. |
215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
229 | + } |
|
218 | 230 | |
219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
227 | 239 | { |
228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
229 | - continue; |
|
240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
241 | + continue; |
|
242 | + } |
|
230 | 243 | |
231 | 244 | // First, let's first check for PHP upload errors. |
232 | 245 | $errors = array(); |
233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
234 | 247 | { |
235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
237 | - |
|
238 | - else |
|
239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
250 | + } else { |
|
251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
252 | + } |
|
240 | 253 | |
241 | 254 | // Log this one, because... |
242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
257 | + } |
|
244 | 258 | |
245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
246 | - if (empty($errors)) |
|
247 | - $errors[] = 'attach_php_error'; |
|
260 | + if (empty($errors)) { |
|
261 | + $errors[] = 'attach_php_error'; |
|
262 | + } |
|
248 | 263 | } |
249 | 264 | |
250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
256 | 271 | { |
257 | 272 | // The reported MIME type of the attachment might not be reliable. |
258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
259 | - if (function_exists('mime_content_type')) |
|
260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
274 | + if (function_exists('mime_content_type')) { |
|
275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
276 | + } |
|
261 | 277 | |
262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
269 | 285 | ); |
270 | 286 | |
271 | 287 | // Move the file to the attachments folder with a temp name for now. |
272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
273 | - smf_chmod($destName, 0644); |
|
288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
289 | + smf_chmod($destName, 0644); |
|
290 | + } |
|
274 | 291 | |
275 | 292 | // This is madness!! |
276 | 293 | else |
277 | 294 | { |
278 | 295 | // File couldn't be moved. |
279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
299 | + } |
|
282 | 300 | } |
283 | 301 | } |
284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
291 | 309 | 'errors' => $errors, |
292 | 310 | ); |
293 | 311 | |
294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
314 | + } |
|
296 | 315 | } |
297 | 316 | |
298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
300 | - attachmentChecks($attachID); |
|
318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
319 | + attachmentChecks($attachID); |
|
320 | + } |
|
301 | 321 | } |
302 | 322 | |
303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
344 | 364 | |
345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
346 | 366 | |
347 | - if (!empty($attachmentOptions['thumb'])) |
|
348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
367 | + if (!empty($attachmentOptions['thumb'])) { |
|
368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
369 | + } |
|
349 | 370 | |
350 | - if ($this->_msg) |
|
351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
371 | + if ($this->_msg) { |
|
372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
373 | + } |
|
352 | 374 | } |
353 | - } |
|
354 | - else |
|
375 | + } else |
|
355 | 376 | { |
356 | 377 | // Sort out the errors for display and delete any associated files. |
357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
363 | 384 | if (!is_array($error)) |
364 | 385 | { |
365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
366 | - if (in_array($error, $log_these)) |
|
367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
387 | + if (in_array($error, $log_these)) { |
|
388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
389 | + } |
|
390 | + } else { |
|
391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
368 | 392 | } |
369 | - else |
|
370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
371 | 393 | } |
372 | - if (file_exists($attachment['tmp_name'])) |
|
373 | - unlink($attachment['tmp_name']); |
|
394 | + if (file_exists($attachment['tmp_name'])) { |
|
395 | + unlink($attachment['tmp_name']); |
|
396 | + } |
|
374 | 397 | } |
375 | 398 | |
376 | 399 | // Regardless of errors, pass the results. |
@@ -378,8 +401,9 @@ discard block |
||
378 | 401 | } |
379 | 402 | |
380 | 403 | // Temp save this on the db. |
381 | - if (!empty($_SESSION['already_attached'])) |
|
382 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
404 | + if (!empty($_SESSION['already_attached'])) { |
|
405 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
406 | + } |
|
383 | 407 | |
384 | 408 | unset($_SESSION['temp_attachments']); |
385 | 409 | } |
@@ -399,14 +423,16 @@ discard block |
||
399 | 423 | if ($this->_sa == 'add') |
400 | 424 | { |
401 | 425 | // Is there any generic errors? made some sense out of them! |
402 | - if ($this->_generalErrors) |
|
403 | - foreach ($this->_generalErrors as $k => $v) |
|
426 | + if ($this->_generalErrors) { |
|
427 | + foreach ($this->_generalErrors as $k => $v) |
|
404 | 428 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
429 | + } |
|
405 | 430 | |
406 | 431 | // Gotta urlencode the filename. |
407 | - if ($this->_attachResults) |
|
408 | - foreach ($this->_attachResults as $k => $v) |
|
432 | + if ($this->_attachResults) { |
|
433 | + foreach ($this->_attachResults as $k => $v) |
|
409 | 434 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
435 | + } |
|
410 | 436 | |
411 | 437 | $this->_response = array( |
412 | 438 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -415,9 +441,10 @@ discard block |
||
415 | 441 | } |
416 | 442 | |
417 | 443 | // Rest of us mere mortals gets no special treatment... |
418 | - elseif (!empty($data)) |
|
419 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
444 | + elseif (!empty($data)) { |
|
445 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
420 | 446 | $this->_response['text'] = $txt[$data['text']]; |
447 | + } |
|
421 | 448 | } |
422 | 449 | |
423 | 450 | protected function sendResponse() |
@@ -426,11 +453,11 @@ discard block |
||
426 | 453 | |
427 | 454 | ob_end_clean(); |
428 | 455 | |
429 | - if (!empty($modSettings['CompressedOutput'])) |
|
430 | - @ob_start('ob_gzhandler'); |
|
431 | - |
|
432 | - else |
|
433 | - ob_start(); |
|
456 | + if (!empty($modSettings['CompressedOutput'])) { |
|
457 | + @ob_start('ob_gzhandler'); |
|
458 | + } else { |
|
459 | + ob_start(); |
|
460 | + } |
|
434 | 461 | |
435 | 462 | // Set the header. |
436 | 463 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -61,7 +61,7 @@ |
||
61 | 61 | $server = trim($servers[array_rand($servers)]); |
62 | 62 | |
63 | 63 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
64 | + if (strpos($server, '/') !== false) |
|
65 | 65 | $host = $server; |
66 | 66 | else |
67 | 67 | { |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcache'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
61 | 63 | $server = trim($servers[array_rand($servers)]); |
62 | 64 | |
63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
65 | - $host = $server; |
|
66 | - else |
|
66 | + if (strpos($server,'/') !== false) { |
|
67 | + $host = $server; |
|
68 | + } else |
|
67 | 69 | { |
68 | 70 | $server = explode(':', $server); |
69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
71 | 73 | } |
72 | 74 | |
73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
74 | - if (empty($db_persist)) |
|
75 | - $connected = $this->memcache->connect($host, $port); |
|
76 | - else |
|
77 | - $connected = $this->memcache->pconnect($host, $port); |
|
76 | + if (empty($db_persist)) { |
|
77 | + $connected = $this->memcache->connect($host, $port); |
|
78 | + } else { |
|
79 | + $connected = $this->memcache->pconnect($host, $port); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
90 | 93 | $value = $this->memcache->get($key); |
91 | 94 | |
92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
93 | - if ($value === false) |
|
94 | - return null; |
|
96 | + if ($value === false) { |
|
97 | + return null; |
|
98 | + } |
|
95 | 99 | return $value; |
96 | 100 | } |
97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
134 | 138 | |
135 | - if (!isset($context['settings_post_javascript'])) |
|
136 | - $context['settings_post_javascript'] = ''; |
|
139 | + if (!isset($context['settings_post_javascript'])) { |
|
140 | + $context['settings_post_javascript'] = ''; |
|
141 | + } |
|
137 | 142 | |
138 | 143 | $context['settings_post_javascript'] .= ' |
139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -19,10 +19,10 @@ |
||
19 | 19 | */ |
20 | 20 | class GroupAct_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | - /** |
|
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | - * @return bool Always returns true |
|
25 | - */ |
|
22 | + /** |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | + * @return bool Always returns true |
|
25 | + */ |
|
26 | 26 | public function execute() |
27 | 27 | { |
28 | 28 | global $sourcedir, $smcFunc, $language, $modSettings; |
@@ -132,8 +132,9 @@ discard block |
||
132 | 132 | 'GROUPNAME' => $user['group_name'], |
133 | 133 | ); |
134 | 134 | |
135 | - if (!empty($custom_reason)) |
|
136 | - $replacements['REASON'] = $custom_reason; |
|
135 | + if (!empty($custom_reason)) { |
|
136 | + $replacements['REASON'] = $custom_reason; |
|
137 | + } |
|
137 | 138 | |
138 | 139 | $emaildata = loadEmailTemplate($email_template_name, $replacements, $user['language']); |
139 | 140 | |
@@ -142,8 +143,8 @@ discard block |
||
142 | 143 | } |
143 | 144 | |
144 | 145 | // Insert the alerts if any |
145 | - if (!empty($alert_rows)) |
|
146 | - $smcFunc['db_insert']('', |
|
146 | + if (!empty($alert_rows)) { |
|
147 | + $smcFunc['db_insert']('', |
|
147 | 148 | '{db_prefix}user_alerts', |
148 | 149 | array( |
149 | 150 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -152,6 +153,7 @@ discard block |
||
152 | 153 | $alert_rows, |
153 | 154 | array() |
154 | 155 | ); |
156 | + } |
|
155 | 157 | } |
156 | 158 | |
157 | 159 | return true; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | class MsgReportReply_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | 22 | /** |
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | 24 | * @return bool Always returns true. |
25 | 25 | */ |
26 | 26 | public function execute() |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | 'last_comment' => $this->_details['comment_id'], |
41 | 41 | ) |
42 | 42 | ); |
43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
44 | - $possible_members[] = $row[0]; |
|
43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
44 | + $possible_members[] = $row[0]; |
|
45 | + } |
|
45 | 46 | $smcFunc['db_free_result']($request); |
46 | 47 | |
47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
52 | 53 | } |
53 | - if (empty($possible_members)) |
|
54 | - return true; |
|
54 | + if (empty($possible_members)) { |
|
55 | + return true; |
|
56 | + } |
|
55 | 57 | |
56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -67,8 +69,9 @@ discard block |
||
67 | 69 | 'current_board' => $this->_details['board_id'], |
68 | 70 | ) |
69 | 71 | ); |
70 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
71 | - $members[] = $row['id_member']; |
|
72 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
73 | + $members[] = $row['id_member']; |
|
74 | + } |
|
72 | 75 | $smcFunc['db_free_result']($request); |
73 | 76 | |
74 | 77 | // Thirdly, anyone assigned to be a moderator of this group as a group->board moderator. |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | ) |
86 | 89 | ); |
87 | 90 | |
88 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
89 | - $members[] = $row['id_member']; |
|
91 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
92 | + $members[] = $row['id_member']; |
|
93 | + } |
|
90 | 94 | $smcFunc['db_free_result']($request); |
91 | 95 | |
92 | 96 | // So now we have two lists: the people who replied to a report in the past, |
@@ -108,8 +112,9 @@ discard block |
||
108 | 112 | { |
109 | 113 | foreach ($alert_bits as $type => $bitvalue) |
110 | 114 | { |
111 | - if ($pref_option['msg_report_reply'] & $bitvalue) |
|
112 | - $notifies[$type][] = $member; |
|
115 | + if ($pref_option['msg_report_reply'] & $bitvalue) { |
|
116 | + $notifies[$type][] = $member; |
|
117 | + } |
|
113 | 118 | } |
114 | 119 | } |
115 | 120 | |
@@ -170,8 +175,9 @@ discard block |
||
170 | 175 | ); |
171 | 176 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
172 | 177 | { |
173 | - if (empty($row['lngfile'])) |
|
174 | - $row['lngfile'] = $language; |
|
178 | + if (empty($row['lngfile'])) { |
|
179 | + $row['lngfile'] = $language; |
|
180 | + } |
|
175 | 181 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
176 | 182 | } |
177 | 183 | $smcFunc['db_free_result']($request); |
@@ -203,8 +209,9 @@ discard block |
||
203 | 209 | $emaildata = loadEmailTemplate('reply_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
204 | 210 | |
205 | 211 | // And do the actual sending... |
206 | - foreach ($recipients as $id_member => $email_address) |
|
207 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
212 | + foreach ($recipients as $id_member => $email_address) { |
|
213 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
214 | + } |
|
208 | 215 | } |
209 | 216 | } |
210 | 217 |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class Buddy_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | 21 | /** |
22 | - * This executes the task - loads up the info, sets the alerts and loads up the email queue. |
|
22 | + * This executes the task - loads up the info, sets the alerts and loads up the email queue. |
|
23 | 23 | * @return bool Always returns true |
24 | 24 | */ |
25 | 25 | public function execute() |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | $birthdays = array(); |
52 | 52 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
53 | 53 | { |
54 | - if (!isset($birthdays[$row['lngfile']])) |
|
55 | - $birthdays[$row['lngfile']] = array(); |
|
54 | + if (!isset($birthdays[$row['lngfile']])) { |
|
55 | + $birthdays[$row['lngfile']] = array(); |
|
56 | + } |
|
56 | 57 | $birthdays[$row['lngfile']][$row['id_member']] = array( |
57 | 58 | 'name' => $row['real_name'], |
58 | 59 | 'email' => $row['email_address'] |
@@ -117,8 +118,8 @@ discard block |
||
117 | 118 | AddMailQueue(true); |
118 | 119 | |
119 | 120 | // Insert the alerts if any |
120 | - if (!empty($alert_rows)) |
|
121 | - $smcFunc['db_insert']('', |
|
121 | + if (!empty($alert_rows)) { |
|
122 | + $smcFunc['db_insert']('', |
|
122 | 123 | '{db_prefix}user_alerts', |
123 | 124 | array( |
124 | 125 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -127,6 +128,7 @@ discard block |
||
127 | 128 | $alert_rows, |
128 | 129 | array() |
129 | 130 | ); |
131 | + } |
|
130 | 132 | } |
131 | 133 | |
132 | 134 | return true; |
@@ -18,10 +18,10 @@ |
||
18 | 18 | */ |
19 | 19 | class Birthday_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | - /** |
|
22 | - * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
23 | - * @return bool Always returns true |
|
24 | - */ |
|
21 | + /** |
|
22 | + * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
23 | + * @return bool Always returns true |
|
24 | + */ |
|
25 | 25 | public function execute() |
26 | 26 | { |
27 | 27 | global $txt, $smcFunc, $txtBirthdayEmails, $modSettings, $sourcedir; |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class MemberReport_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | 21 | /** |
22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | 23 | * @return bool Always returns true. |
24 | 24 | */ |
25 | 25 | public function execute() |
@@ -46,9 +46,10 @@ discard block |
||
46 | 46 | |
47 | 47 | foreach ($prefs as $member => $pref_option) |
48 | 48 | { |
49 | - foreach ($alert_bits as $type => $bitvalue) |
|
50 | - if ($pref_option['member_report'] & $bitvalue) |
|
49 | + foreach ($alert_bits as $type => $bitvalue) { |
|
50 | + if ($pref_option['member_report'] & $bitvalue) |
|
51 | 51 | $notifies[$type][] = $member; |
52 | + } |
|
52 | 53 | } |
53 | 54 | |
54 | 55 | // Firstly, anyone who wants alerts. |
@@ -109,8 +110,9 @@ discard block |
||
109 | 110 | ); |
110 | 111 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
111 | 112 | { |
112 | - if (empty($row['lngfile'])) |
|
113 | - $row['lngfile'] = $language; |
|
113 | + if (empty($row['lngfile'])) { |
|
114 | + $row['lngfile'] = $language; |
|
115 | + } |
|
114 | 116 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
115 | 117 | } |
116 | 118 | $smcFunc['db_free_result']($request); |
@@ -129,8 +131,9 @@ discard block |
||
129 | 131 | $emaildata = loadEmailTemplate('report_member_profile', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
130 | 132 | |
131 | 133 | // And do the actual sending... |
132 | - foreach ($recipients as $id_member => $email_address) |
|
133 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
134 | + foreach ($recipients as $id_member => $email_address) { |
|
135 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
136 | + } |
|
134 | 137 | } |
135 | 138 | } |
136 | 139 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | class ApprovePost_Notify_Background extends SMF_BackgroundTask |
19 | 19 | { |
20 | 20 | /** |
21 | - * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed. |
|
21 | + * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed. |
|
22 | 22 | * @return bool Always returns true |
23 | 23 | */ |
24 | 24 | public function execute() |
@@ -54,8 +54,9 @@ discard block |
||
54 | 54 | } |
55 | 55 | $smcFunc['db_free_result']($request); |
56 | 56 | |
57 | - if (empty($members)) |
|
58 | - return true; |
|
57 | + if (empty($members)) { |
|
58 | + return true; |
|
59 | + } |
|
59 | 60 | |
60 | 61 | require_once($sourcedir . '/Subs-Notify.php'); |
61 | 62 | $members = array_unique($members); |
@@ -103,14 +104,15 @@ discard block |
||
103 | 104 | } |
104 | 105 | |
105 | 106 | // Insert the alerts if any |
106 | - if (!empty($alert_rows)) |
|
107 | - $smcFunc['db_insert']('', |
|
107 | + if (!empty($alert_rows)) { |
|
108 | + $smcFunc['db_insert']('', |
|
108 | 109 | '{db_prefix}user_alerts', |
109 | 110 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
110 | 111 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
111 | 112 | $alert_rows, |
112 | 113 | array() |
113 | 114 | ); |
115 | + } |
|
114 | 116 | |
115 | 117 | return true; |
116 | 118 | } |