@@ -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">' . |
@@ -128,7 +128,6 @@ |
||
| 128 | 128 | |
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | - |
|
| 132 | 131 | else |
| 133 | 132 | return true; |
| 134 | 133 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | // Set a list of common functions. |
| 108 | 108 | $ent_list = '&(?:#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . '|quot|amp|lt|gt|nbsp);'; |
| 109 | 109 | $ent_check = empty($modSettings['disableEntityCheck']) ? function($string) |
| 110 | - { |
|
| 110 | + { |
|
| 111 | 111 | $string = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string); |
| 112 | 112 | return $string; |
| 113 | 113 | } : function($string) |
@@ -941,7 +941,6 @@ discard block |
||
| 941 | 941 | $user_info_min[$row['id_member']]['time_offset'] = ($tz_user->getOffset($time_user) - |
| 942 | 942 | $tz_system->getOffset($time_system)) / 3600; |
| 943 | 943 | } |
| 944 | - |
|
| 945 | 944 | else |
| 946 | 945 | $user_info_min[$row['id_member']]['time_offset'] = empty($row['time_offset']) ? 0 : $row['time_offset']; |
| 947 | 946 | } |
@@ -1669,7 +1668,6 @@ discard block |
||
| 1669 | 1668 | $time_user = new DateTime('now', $tz_user); |
| 1670 | 1669 | $profile['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 1671 | 1670 | } |
| 1672 | - |
|
| 1673 | 1671 | else |
| 1674 | 1672 | { |
| 1675 | 1673 | // !!! Compatibility. |
@@ -2363,7 +2361,6 @@ discard block |
||
| 2363 | 2361 | loadLanguage('index+Modifications'); |
| 2364 | 2362 | $context['template_layers'] = array(); |
| 2365 | 2363 | } |
| 2366 | - |
|
| 2367 | 2364 | else |
| 2368 | 2365 | { |
| 2369 | 2366 | // Custom templates to load, or just default? |
@@ -3619,7 +3616,6 @@ discard block |
||
| 3619 | 3616 | |
| 3620 | 3617 | return $cacheAPI; |
| 3621 | 3618 | } |
| 3622 | - |
|
| 3623 | 3619 | else |
| 3624 | 3620 | return $cache_api; |
| 3625 | 3621 | } |
@@ -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 | */ |