@@ -428,21 +428,28 @@ |
||
| 428 | 428 | * @param $index to use as index if specified |
| 429 | 429 | * @return array of values of specified $col from $array |
| 430 | 430 | */ |
| 431 | -if (!function_exists('array_column')) { |
|
| 432 | - function array_column($input, $column_key, $index_key = null) { |
|
| 433 | - $arr = array_map(function($d) use ($column_key, $index_key) { |
|
| 434 | - if (!isset($d[$column_key])) { |
|
| 431 | +if (!function_exists('array_column')) |
|
| 432 | +{ |
|
| 433 | + function array_column($input, $column_key, $index_key = null) |
|
| 434 | + { |
|
| 435 | + $arr = array_map(function($d) use ($column_key, $index_key) |
|
| 436 | + { |
|
| 437 | + if (!isset($d[$column_key])) |
|
| 438 | + { |
|
| 435 | 439 | return null; |
| 436 | 440 | } |
| 437 | - if ($index_key !== null) { |
|
| 441 | + if ($index_key !== null) |
|
| 442 | + { |
|
| 438 | 443 | return array($d[$index_key] => $d[$column_key]); |
| 439 | 444 | } |
| 440 | 445 | return $d[$column_key]; |
| 441 | 446 | }, $input); |
| 442 | 447 | |
| 443 | - if ($index_key !== null) { |
|
| 448 | + if ($index_key !== null) |
|
| 449 | + { |
|
| 444 | 450 | $tmp = array(); |
| 445 | - foreach ($arr as $ar) { |
|
| 451 | + foreach ($arr as $ar) |
|
| 452 | + { |
|
| 446 | 453 | $tmp[key($ar)] = current($ar); |
| 447 | 454 | } |
| 448 | 455 | $arr = $tmp; |
@@ -3204,7 +3204,9 @@ |
||
| 3204 | 3204 | return $string; |
| 3205 | 3205 | |
| 3206 | 3206 | // This bit fixes incorrect string lengths, which can happen if the character encoding was changed (e.g. conversion to UTF-8) |
| 3207 | - $new_string = preg_replace_callback('~\bs:(\d+):"(.*?)";(?=$|[bidsa]:|[{}]|N;)~s', function ($matches) {return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";';}, $string); |
|
| 3207 | + $new_string = preg_replace_callback('~\bs:(\d+):"(.*?)";(?=$|[bidsa]:|[{}]|N;)~s', function ($matches) |
|
| 3208 | + { |
|
| 3209 | +return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";';}, $string); |
|
| 3208 | 3210 | |
| 3209 | 3211 | // @todo Add more possible fixes here. For example, fix incorrect array lengths, try to handle truncated strings gracefully, etc. |
| 3210 | 3212 | |
@@ -89,7 +89,9 @@ |
||
| 89 | 89 | <li><a href="#" onclick="showSSIBlock('ssi_quickSearch'); return false;">Quick Search Box</a></li> |
| 90 | 90 | <li><a href="#" onclick="showSSIBlock('ssi_recentAttachments'); return false;">Recent Attachments</a></li> |
| 91 | 91 | </ul> |
| 92 | - <?php if ($user_info['is_admin']) { ?> |
|
| 92 | + <?php if ($user_info['is_admin']) |
|
| 93 | +{ |
|
| 94 | +?> |
|
| 93 | 95 | <h3>Advanced Functions <img class="help" title="Functions that require additional tweaking, not just copy and paste." src="<?php echo $settings['images_url']; ?>/helptopics.png" alt=""></h3> |
| 94 | 96 | <ul> |
| 95 | 97 | <li><a href="#" onclick="showSSIBlock('ssi_showPoll'); return false;">Show Single Poll</a></li> |
@@ -407,7 +407,8 @@ discard block |
||
| 407 | 407 | if (!empty($day['events'])) |
| 408 | 408 | { |
| 409 | 409 | // Sort events by start time (all day events will be listed first) |
| 410 | - uasort($day['events'], function($a, $b) { |
|
| 410 | + uasort($day['events'], function($a, $b) |
|
| 411 | + { |
|
| 411 | 412 | if ($a['start_timestamp'] == $b['start_timestamp']) |
| 412 | 413 | return 0; |
| 413 | 414 | |
@@ -600,7 +601,8 @@ discard block |
||
| 600 | 601 | if (!empty($day['events'])) |
| 601 | 602 | { |
| 602 | 603 | // Sort events by start time (all day events will be listed first) |
| 603 | - uasort($day['events'], function($a, $b) { |
|
| 604 | + uasort($day['events'], function($a, $b) |
|
| 605 | + { |
|
| 604 | 606 | if ($a['start_timestamp'] == $b['start_timestamp']) |
| 605 | 607 | return 0; |
| 606 | 608 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
@@ -100,18 +100,22 @@ |
||
| 100 | 100 | $tempTab++; |
| 101 | 101 | $context['tabindex'] = $tempTab; |
| 102 | 102 | |
| 103 | - foreach ($context['richedit_buttons'] as $name => $button) { |
|
| 104 | - if ($name == 'spell_check') { |
|
| 103 | + foreach ($context['richedit_buttons'] as $name => $button) |
|
| 104 | + { |
|
| 105 | + if ($name == 'spell_check') |
|
| 106 | + { |
|
| 105 | 107 | $button['onclick'] = 'oEditorHandle_' . $editor_id . '.spellCheckStart();'; |
| 106 | 108 | } |
| 107 | 109 | |
| 108 | - if ($name == 'preview') { |
|
| 110 | + if ($name == 'preview') |
|
| 111 | + { |
|
| 109 | 112 | $button['value'] = isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $button['value']; |
| 110 | 113 | $button['onclick'] = $editor_context['preview_type'] == 2 ? '' : 'return submitThisOnce(this);'; |
| 111 | 114 | $button['show'] = $editor_context['preview_type']; |
| 112 | 115 | } |
| 113 | 116 | |
| 114 | - if ($button['show']) { |
|
| 117 | + if ($button['show']) |
|
| 118 | + { |
|
| 115 | 119 | echo ' |
| 116 | 120 | <input type="', $button['type'], '"', $button['type'] == 'hidden' ? ' id="' . $name . '"' : '', ' name="', $name, '" value="', $button['value'], '"', $button['type'] != 'hidden' ? ' tabindex="' . --$tempTab . '"' : '', !empty($button['onclick']) ? ' onclick="' . $button['onclick'] . '"' : '', !empty($button['accessKey']) ? ' accesskey="' . $button['accessKey'] . '"' : '', $button['type'] != 'hidden' ? ' class="button"' : '', '>'; |
| 117 | 121 | } |
@@ -742,7 +742,7 @@ |
||
| 742 | 742 | |
| 743 | 743 | // Filter out any redundant separators before we start the loop |
| 744 | 744 | $context['config_vars'] = array_filter($context['config_vars'], function ($v) use ($context) |
| 745 | - { |
|
| 745 | + { |
|
| 746 | 746 | static $config_vars, $prev; |
| 747 | 747 | |
| 748 | 748 | $at_start = is_null($config_vars); |
@@ -498,7 +498,7 @@ |
||
| 498 | 498 | log_error(sprintf($txt['smiley_set_dir_not_found'], $set_names[array_search($set, $context['smiley_sets'])])); |
| 499 | 499 | |
| 500 | 500 | $context['smiley_sets'] = array_filter($context['smiley_sets'], function($v) use ($set) |
| 501 | - { |
|
| 501 | + { |
|
| 502 | 502 | return $v != $set; |
| 503 | 503 | }); |
| 504 | 504 | } |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * SOFTWARE. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!is_callable('random_bytes')) { |
|
| 29 | +if (!is_callable('random_bytes')) |
|
| 30 | +{ |
|
| 30 | 31 | /** |
| 31 | 32 | * If the libsodium PHP extension is loaded, we'll use it above any other |
| 32 | 33 | * solution. |
@@ -42,16 +43,20 @@ discard block |
||
| 42 | 43 | */ |
| 43 | 44 | function random_bytes($bytes) |
| 44 | 45 | { |
| 45 | - try { |
|
| 46 | + try |
|
| 47 | + { |
|
| 46 | 48 | /** @var int $bytes */ |
| 47 | 49 | $bytes = RandomCompat_intval($bytes); |
| 48 | - } catch (TypeError $ex) { |
|
| 50 | + } |
|
| 51 | + catch (TypeError $ex) |
|
| 52 | + { |
|
| 49 | 53 | throw new TypeError( |
| 50 | 54 | 'random_bytes(): $bytes must be an integer' |
| 51 | 55 | ); |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | - if ($bytes < 1) { |
|
| 58 | + if ($bytes < 1) |
|
| 59 | + { |
|
| 55 | 60 | throw new Error( |
| 56 | 61 | 'Length must be greater than 0' |
| 57 | 62 | ); |
@@ -62,21 +67,27 @@ discard block |
||
| 62 | 67 | * generated in one invocation. |
| 63 | 68 | */ |
| 64 | 69 | /** @var string|bool $buf */ |
| 65 | - if ($bytes > 2147483647) { |
|
| 70 | + if ($bytes > 2147483647) |
|
| 71 | + { |
|
| 66 | 72 | $buf = ''; |
| 67 | - for ($i = 0; $i < $bytes; $i += 1073741824) { |
|
| 73 | + for ($i = 0; $i < $bytes; $i += 1073741824) |
|
| 74 | + { |
|
| 68 | 75 | $n = ($bytes - $i) > 1073741824 |
| 69 | 76 | ? 1073741824 |
| 70 | 77 | : $bytes - $i; |
| 71 | 78 | $buf .= \Sodium\randombytes_buf($n); |
| 72 | 79 | } |
| 73 | - } else { |
|
| 80 | + } |
|
| 81 | + else |
|
| 82 | + { |
|
| 74 | 83 | /** @var string|bool $buf */ |
| 75 | 84 | $buf = \Sodium\randombytes_buf($bytes); |
| 76 | 85 | } |
| 77 | 86 | |
| 78 | - if (is_string($buf)) { |
|
| 79 | - if (RandomCompat_strlen($buf) === $bytes) { |
|
| 87 | + if (is_string($buf)) |
|
| 88 | + { |
|
| 89 | + if (RandomCompat_strlen($buf) === $bytes) |
|
| 90 | + { |
|
| 80 | 91 | return $buf; |
| 81 | 92 | } |
| 82 | 93 | } |
@@ -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 |
@@ -52,23 +54,27 @@ discard block |
||
| 52 | 54 | /** |
| 53 | 55 | * This block should only be run once |
| 54 | 56 | */ |
| 55 | - if (empty($fp)) { |
|
| 57 | + if (empty($fp)) |
|
| 58 | + { |
|
| 56 | 59 | /** |
| 57 | 60 | * We use /dev/urandom if it is a char device. |
| 58 | 61 | * We never fall back to /dev/random |
| 59 | 62 | */ |
| 60 | 63 | /** @var resource|bool $fp */ |
| 61 | 64 | $fp = fopen('/dev/urandom', 'rb'); |
| 62 | - if (is_resource($fp)) { |
|
| 65 | + if (is_resource($fp)) |
|
| 66 | + { |
|
| 63 | 67 | /** @var array<string, int> $st */ |
| 64 | 68 | $st = fstat($fp); |
| 65 | - if (($st['mode'] & 0170000) !== 020000) { |
|
| 69 | + if (($st['mode'] & 0170000) !== 020000) |
|
| 70 | + { |
|
| 66 | 71 | fclose($fp); |
| 67 | 72 | $fp = false; |
| 68 | 73 | } |
| 69 | 74 | } |
| 70 | 75 | |
| 71 | - if (is_resource($fp)) { |
|
| 76 | + if (is_resource($fp)) |
|
| 77 | + { |
|
| 72 | 78 | /** |
| 73 | 79 | * stream_set_read_buffer() does not exist in HHVM |
| 74 | 80 | * |
@@ -77,25 +83,31 @@ discard block |
||
| 77 | 83 | * |
| 78 | 84 | * stream_set_read_buffer returns 0 on success |
| 79 | 85 | */ |
| 80 | - if (is_callable('stream_set_read_buffer')) { |
|
| 86 | + if (is_callable('stream_set_read_buffer')) |
|
| 87 | + { |
|
| 81 | 88 | stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER); |
| 82 | 89 | } |
| 83 | - if (is_callable('stream_set_chunk_size')) { |
|
| 90 | + if (is_callable('stream_set_chunk_size')) |
|
| 91 | + { |
|
| 84 | 92 | stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER); |
| 85 | 93 | } |
| 86 | 94 | } |
| 87 | 95 | } |
| 88 | 96 | |
| 89 | - try { |
|
| 97 | + try |
|
| 98 | + { |
|
| 90 | 99 | /** @var int $bytes */ |
| 91 | 100 | $bytes = RandomCompat_intval($bytes); |
| 92 | - } catch (TypeError $ex) { |
|
| 101 | + } |
|
| 102 | + catch (TypeError $ex) |
|
| 103 | + { |
|
| 93 | 104 | throw new TypeError( |
| 94 | 105 | 'random_bytes(): $bytes must be an integer' |
| 95 | 106 | ); |
| 96 | 107 | } |
| 97 | 108 | |
| 98 | - if ($bytes < 1) { |
|
| 109 | + if ($bytes < 1) |
|
| 110 | + { |
|
| 99 | 111 | throw new Error( |
| 100 | 112 | 'Length must be greater than 0' |
| 101 | 113 | ); |
@@ -108,7 +120,8 @@ discard block |
||
| 108 | 120 | * if (empty($fp)) line is logic that should only be run once per |
| 109 | 121 | * page load. |
| 110 | 122 | */ |
| 111 | - if (is_resource($fp)) { |
|
| 123 | + if (is_resource($fp)) |
|
| 124 | + { |
|
| 112 | 125 | /** |
| 113 | 126 | * @var int |
| 114 | 127 | */ |
@@ -127,8 +140,10 @@ discard block |
||
| 127 | 140 | * @var string|bool |
| 128 | 141 | */ |
| 129 | 142 | $read = fread($fp, $remaining); |
| 130 | - if (!is_string($read)) { |
|
| 131 | - if ($read === false) { |
|
| 143 | + if (!is_string($read)) |
|
| 144 | + { |
|
| 145 | + if ($read === false) |
|
| 146 | + { |
|
| 132 | 147 | /** |
| 133 | 148 | * We cannot safely read from the file. Exit the |
| 134 | 149 | * do-while loop and trigger the exception condition |
@@ -152,8 +167,10 @@ discard block |
||
| 152 | 167 | /** |
| 153 | 168 | * Is our result valid? |
| 154 | 169 | */ |
| 155 | - if (is_string($buf)) { |
|
| 156 | - if (RandomCompat_strlen($buf) === $bytes) { |
|
| 170 | + if (is_string($buf)) |
|
| 171 | + { |
|
| 172 | + if (RandomCompat_strlen($buf) === $bytes) |
|
| 173 | + { |
|
| 157 | 174 | /** |
| 158 | 175 | * Return our random entropy buffer here: |
| 159 | 176 | */ |