@@ -707,7 +707,6 @@ |
||
| 707 | 707 | $cache_level = array($txt['cache_off']); |
| 708 | 708 | $apis_names['none'] = $txt['cache_off']; |
| 709 | 709 | } |
| 710 | - |
|
| 711 | 710 | else |
| 712 | 711 | { |
| 713 | 712 | $txt['cache_settings_message'] = '<strong class="success">' . |
@@ -26,11 +26,13 @@ discard block |
||
| 26 | 26 | * SOFTWARE. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!defined('RANDOM_COMPAT_READ_BUFFER')) { |
|
| 29 | +if (!defined('RANDOM_COMPAT_READ_BUFFER')) |
|
| 30 | +{ |
|
| 30 | 31 | define('RANDOM_COMPAT_READ_BUFFER', 8); |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | -if (!is_callable('random_bytes')) { |
|
| 34 | +if (!is_callable('random_bytes')) |
|
| 35 | +{ |
|
| 34 | 36 | /** |
| 35 | 37 | * Unless open_basedir is enabled, use /dev/urandom for |
| 36 | 38 | * random numbers in accordance with best practices |
@@ -53,7 +55,8 @@ discard block |
||
| 53 | 55 | /** |
| 54 | 56 | * This block should only be run once |
| 55 | 57 | */ |
| 56 | - if (empty($fp)) { |
|
| 58 | + if (empty($fp)) |
|
| 59 | + { |
|
| 57 | 60 | /** |
| 58 | 61 | * We don't want to ever read C:\dev\random, only /dev/urandom on |
| 59 | 62 | * Unix-like operating systems. While we guard against this |
@@ -64,8 +67,10 @@ discard block |
||
| 64 | 67 | * like operating system (which means the directory separator is set |
| 65 | 68 | * to "/" not "\". |
| 66 | 69 | */ |
| 67 | - if (DIRECTORY_SEPARATOR === '/') { |
|
| 68 | - if (!is_readable('/dev/urandom')) { |
|
| 70 | + if (DIRECTORY_SEPARATOR === '/') |
|
| 71 | + { |
|
| 72 | + if (!is_readable('/dev/urandom')) |
|
| 73 | + { |
|
| 69 | 74 | throw new Exception( |
| 70 | 75 | 'Environment misconfiguration: ' . |
| 71 | 76 | '/dev/urandom cannot be read.' |
@@ -77,17 +82,20 @@ discard block |
||
| 77 | 82 | */ |
| 78 | 83 | /** @var resource|bool $fp */ |
| 79 | 84 | $fp = fopen('/dev/urandom', 'rb'); |
| 80 | - if (is_resource($fp)) { |
|
| 85 | + if (is_resource($fp)) |
|
| 86 | + { |
|
| 81 | 87 | /** @var array<string, int> $st */ |
| 82 | 88 | $st = fstat($fp); |
| 83 | - if (($st['mode'] & 0170000) !== 020000) { |
|
| 89 | + if (($st['mode'] & 0170000) !== 020000) |
|
| 90 | + { |
|
| 84 | 91 | fclose($fp); |
| 85 | 92 | $fp = false; |
| 86 | 93 | } |
| 87 | 94 | } |
| 88 | 95 | } |
| 89 | 96 | |
| 90 | - if (is_resource($fp)) { |
|
| 97 | + if (is_resource($fp)) |
|
| 98 | + { |
|
| 91 | 99 | /** |
| 92 | 100 | * stream_set_read_buffer() does not exist in HHVM |
| 93 | 101 | * |
@@ -96,25 +104,31 @@ discard block |
||
| 96 | 104 | * |
| 97 | 105 | * stream_set_read_buffer returns 0 on success |
| 98 | 106 | */ |
| 99 | - if (is_callable('stream_set_read_buffer')) { |
|
| 107 | + if (is_callable('stream_set_read_buffer')) |
|
| 108 | + { |
|
| 100 | 109 | stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER); |
| 101 | 110 | } |
| 102 | - if (is_callable('stream_set_chunk_size')) { |
|
| 111 | + if (is_callable('stream_set_chunk_size')) |
|
| 112 | + { |
|
| 103 | 113 | stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER); |
| 104 | 114 | } |
| 105 | 115 | } |
| 106 | 116 | } |
| 107 | 117 | |
| 108 | - try { |
|
| 118 | + try |
|
| 119 | + { |
|
| 109 | 120 | /** @var int $bytes */ |
| 110 | 121 | $bytes = RandomCompat_intval($bytes); |
| 111 | - } catch (TypeError $ex) { |
|
| 122 | + } |
|
| 123 | + catch (TypeError $ex) |
|
| 124 | + { |
|
| 112 | 125 | throw new TypeError( |
| 113 | 126 | 'random_bytes(): $bytes must be an integer' |
| 114 | 127 | ); |
| 115 | 128 | } |
| 116 | 129 | |
| 117 | - if ($bytes < 1) { |
|
| 130 | + if ($bytes < 1) |
|
| 131 | + { |
|
| 118 | 132 | throw new Error( |
| 119 | 133 | 'Length must be greater than 0' |
| 120 | 134 | ); |
@@ -127,7 +141,8 @@ discard block |
||
| 127 | 141 | * if (empty($fp)) line is logic that should only be run once per |
| 128 | 142 | * page load. |
| 129 | 143 | */ |
| 130 | - if (is_resource($fp)) { |
|
| 144 | + if (is_resource($fp)) |
|
| 145 | + { |
|
| 131 | 146 | /** |
| 132 | 147 | * @var int |
| 133 | 148 | */ |
@@ -146,7 +161,8 @@ discard block |
||
| 146 | 161 | * @var string|bool |
| 147 | 162 | */ |
| 148 | 163 | $read = fread($fp, $remaining); |
| 149 | - if (!is_string($read)) { |
|
| 164 | + if (!is_string($read)) |
|
| 165 | + { |
|
| 150 | 166 | /** |
| 151 | 167 | * We cannot safely read from the file. Exit the |
| 152 | 168 | * do-while loop and trigger the exception condition |
@@ -170,8 +186,10 @@ discard block |
||
| 170 | 186 | * Is our result valid? |
| 171 | 187 | * @var string|bool $buf |
| 172 | 188 | */ |
| 173 | - if (is_string($buf)) { |
|
| 174 | - if (RandomCompat_strlen($buf) === $bytes) { |
|
| 189 | + if (is_string($buf)) |
|
| 190 | + { |
|
| 191 | + if (RandomCompat_strlen($buf) === $bytes) |
|
| 192 | + { |
|
| 175 | 193 | /** |
| 176 | 194 | * Return our random entropy buffer here: |
| 177 | 195 | */ |
@@ -280,7 +280,6 @@ discard block |
||
| 280 | 280 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
| 281 | 281 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
| 282 | 282 | } |
| 283 | - |
|
| 284 | 283 | else |
| 285 | 284 | { |
| 286 | 285 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
@@ -415,7 +414,6 @@ discard block |
||
| 415 | 414 | $this_last_post['href'] = $scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new'; |
| 416 | 415 | $this_last_post['link'] = '<a href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>'; |
| 417 | 416 | } |
| 418 | - |
|
| 419 | 417 | else |
| 420 | 418 | { |
| 421 | 419 | $this_last_post['href'] = ''; |
@@ -510,8 +508,7 @@ discard block |
||
| 510 | 508 | $board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']); |
| 511 | 509 | } |
| 512 | 510 | } |
| 513 | - |
|
| 514 | - else |
|
| 511 | + else |
|
| 515 | 512 | foreach ($this_category as &$board) |
| 516 | 513 | { |
| 517 | 514 | if (isset($boards_parsed_data_by_cat_id[$board['id_cat']][$board['id']])) |
@@ -279,7 +279,6 @@ discard block |
||
| 279 | 279 | $condition = 'id_member IN ({array_int:members})'; |
| 280 | 280 | $parameters['members'] = $members; |
| 281 | 281 | } |
| 282 | - |
|
| 283 | 282 | elseif ($members === null) |
| 284 | 283 | $condition = '1=1'; |
| 285 | 284 | |
@@ -382,11 +381,9 @@ discard block |
||
| 382 | 381 | $val = $val . ' END'; |
| 383 | 382 | $type = 'raw'; |
| 384 | 383 | } |
| 385 | - |
|
| 386 | 384 | else |
| 387 | 385 | $val = alert_count($members, true); |
| 388 | 386 | } |
| 389 | - |
|
| 390 | 387 | elseif ($type == 'int' && ($val === '+' || $val === '-')) |
| 391 | 388 | { |
| 392 | 389 | $val = $var . ' ' . $val . ' 1'; |
@@ -2178,12 +2175,12 @@ discard block |
||
| 2178 | 2175 | 'tag' => 'cowsay', |
| 2179 | 2176 | 'parameters' => array( |
| 2180 | 2177 | 'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function ($eyes) use ($smcFunc) |
| 2181 | - { |
|
| 2178 | + { |
|
| 2182 | 2179 | return $smcFunc['substr']($eyes . 'oo', 0, 2); |
| 2183 | 2180 | }, |
| 2184 | 2181 | ), |
| 2185 | 2182 | 't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => ' ', 'validate' => function ($tongue) use ($smcFunc) |
| 2186 | - { |
|
| 2183 | + { |
|
| 2187 | 2184 | return $smcFunc['substr']($tongue . ' ', 0, 2); |
| 2188 | 2185 | }, |
| 2189 | 2186 | ), |
@@ -3290,7 +3287,7 @@ discard block |
||
| 3290 | 3287 | |
| 3291 | 3288 | // Replace away! |
| 3292 | 3289 | $message = preg_replace_callback($smileyPregSearch, function($matches) use ($smileyPregReplacements) |
| 3293 | - { |
|
| 3290 | + { |
|
| 3294 | 3291 | return $smileyPregReplacements[$matches[1]]; |
| 3295 | 3292 | }, $message); |
| 3296 | 3293 | } |
@@ -4085,7 +4082,6 @@ discard block |
||
| 4085 | 4082 | if (!isset($minSeed) && isset($js_file['options']['seed'])) |
| 4086 | 4083 | $minSeed = $js_file['options']['seed']; |
| 4087 | 4084 | } |
| 4088 | - |
|
| 4089 | 4085 | else |
| 4090 | 4086 | { |
| 4091 | 4087 | echo ' |
@@ -6005,7 +6001,8 @@ discard block |
||
| 6005 | 6001 | $zones[$tzkey]['tzid'] = $tzid; |
| 6006 | 6002 | $zones[$tzkey]['dst_type'] = count($tzinfo) > 1 ? 1 : ($tzinfo[0]['isdst'] ? 2 : 0); |
| 6007 | 6003 | |
| 6008 | - foreach ($tzinfo as $transition) { |
|
| 6004 | + foreach ($tzinfo as $transition) |
|
| 6005 | + { |
|
| 6009 | 6006 | $zones[$tzkey]['abbrs'][] = $transition['abbr']; |
| 6010 | 6007 | } |
| 6011 | 6008 | |
@@ -6090,7 +6087,8 @@ discard block |
||
| 6090 | 6087 | $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
| 6091 | 6088 | |
| 6092 | 6089 | // We don't want abbreviations like '+03' or '-11'. |
| 6093 | - $abbrs = array_filter($tzvalue['abbrs'], function ($abbr) { |
|
| 6090 | + $abbrs = array_filter($tzvalue['abbrs'], function ($abbr) |
|
| 6091 | + { |
|
| 6094 | 6092 | return !strspn($abbr, '+-'); |
| 6095 | 6093 | }); |
| 6096 | 6094 | $abbrs = count($abbrs) == count($tzvalue['abbrs']) ? array_unique($abbrs) : array(); |
@@ -6491,7 +6489,6 @@ discard block |
||
| 6491 | 6489 | $isWritable = true; |
| 6492 | 6490 | break; |
| 6493 | 6491 | } |
| 6494 | - |
|
| 6495 | 6492 | else |
| 6496 | 6493 | @chmod($file, $val); |
| 6497 | 6494 | } |
@@ -1229,7 +1229,8 @@ discard block |
||
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | // It's important to do the numbered ones before the named ones, or messes happen. |
| 1232 | - uksort($substitutions, function($a, $b) { |
|
| 1232 | + uksort($substitutions, function($a, $b) |
|
| 1233 | + { |
|
| 1233 | 1234 | if (is_int($a) && is_int($b)) |
| 1234 | 1235 | return $a > $b ? 1 : ($a < $b ? -1 : 0); |
| 1235 | 1236 | elseif (is_int($a)) |
@@ -1768,8 +1769,12 @@ discard block |
||
| 1768 | 1769 | unset($mtime, $settingsFile, $settingsText); |
| 1769 | 1770 | $defined_vars = get_defined_vars(); |
| 1770 | 1771 | } |
| 1771 | - catch (Throwable $e) {} |
|
| 1772 | - catch (ErrorException $e) {} |
|
| 1772 | + catch (Throwable $e) |
|
| 1773 | + { |
|
| 1774 | +} |
|
| 1775 | + catch (ErrorException $e) |
|
| 1776 | + { |
|
| 1777 | +} |
|
| 1773 | 1778 | if (isset($e)) |
| 1774 | 1779 | return false; |
| 1775 | 1780 | |
@@ -1925,7 +1930,8 @@ discard block |
||
| 1925 | 1930 | // For the same reason, replace literal returns and newlines with "\r" and "\n" |
| 1926 | 1931 | elseif (is_string($var) && (strpos($var, "\n") !== false || strpos($var, "\r") !== false)) |
| 1927 | 1932 | { |
| 1928 | - return strtr(preg_replace_callback('/[\r\n]+/', function($m) { |
|
| 1933 | + return strtr(preg_replace_callback('/[\r\n]+/', function($m) |
|
| 1934 | + { |
|
| 1929 | 1935 | return '\' . "' . strtr($m[0], array("\r" => '\r', "\n" => '\n')) . '" . \''; |
| 1930 | 1936 | }, $var), array("'' . " => '', " . ''" => '')); |
| 1931 | 1937 | } |