@@ -1638,7 +1638,7 @@ |
||
| 1638 | 1638 | $cacheAPIdir = $sourcedir . '/Cache'; |
| 1639 | 1639 | |
| 1640 | 1640 | $loadedApis = array(); |
| 1641 | - $apis_dir = $cacheAPIdir .'/'. CacheApi::APIS_FOLDER; |
|
| 1641 | + $apis_dir = $cacheAPIdir . '/' . CacheApi::APIS_FOLDER; |
|
| 1642 | 1642 | |
| 1643 | 1643 | $api_classes = new GlobIterator($apis_dir . '/*.php', FilesystemIterator::NEW_CURRENT_AND_KEY); |
| 1644 | 1644 | |
@@ -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">' . |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $class_name = $this->getImplementationClassKeyName(); |
| 185 | 185 | $class_name_txt_key = strtolower($class_name); |
| 186 | 186 | |
| 187 | - $config_vars[] = $txt['cache_'. $class_name_txt_key .'_settings']; |
|
| 187 | + $config_vars[] = $txt['cache_' . $class_name_txt_key . '_settings']; |
|
| 188 | 188 | $config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir'); |
| 189 | 189 | |
| 190 | 190 | if (!isset($context['settings_post_javascript'])) |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $context['settings_post_javascript'] .= ' |
| 194 | 194 | $("#cache_accelerator").change(function (e) { |
| 195 | 195 | var cache_type = e.currentTarget.value; |
| 196 | - $("#cachedir").prop("disabled", cache_type != "'. $class_name .'"); |
|
| 196 | + $("#cachedir").prop("disabled", cache_type != "'. $class_name . '"); |
|
| 197 | 197 | });'; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -128,7 +128,6 @@ |
||
| 128 | 128 | |
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | - |
|
| 132 | 131 | else |
| 133 | 132 | return true; |
| 134 | 133 | } |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | $class_name = $this->getImplementationClassKeyName(); |
| 170 | 170 | $class_name_txt_key = strtolower($class_name); |
| 171 | 171 | |
| 172 | - $config_vars[] = $txt['cache_'. $class_name_txt_key .'_settings']; |
|
| 172 | + $config_vars[] = $txt['cache_' . $class_name_txt_key . '_settings']; |
|
| 173 | 173 | $config_vars[] = array( |
| 174 | 174 | self::CLASS_KEY, |
| 175 | - $txt['cache_'. $class_name_txt_key .'_servers'], |
|
| 175 | + $txt['cache_' . $class_name_txt_key . '_servers'], |
|
| 176 | 176 | 'file', |
| 177 | 177 | 'text', |
| 178 | 178 | 0, |
| 179 | - 'cache_'. $class_name_txt_key, |
|
| 180 | - 'subtext' => $txt['cache_'. $class_name_txt_key .'_servers_subtext']); |
|
| 179 | + 'cache_' . $class_name_txt_key, |
|
| 180 | + 'subtext' => $txt['cache_' . $class_name_txt_key . '_servers_subtext']); |
|
| 181 | 181 | |
| 182 | 182 | if (!isset($context['settings_post_javascript'])) |
| 183 | 183 | $context['settings_post_javascript'] = ''; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $context['settings_post_javascript'] .= ' |
| 186 | 186 | $("#cache_accelerator").change(function (e) { |
| 187 | 187 | var cache_type = e.currentTarget.value; |
| 188 | - $("#'. self::CLASS_KEY .'").prop("disabled", cache_type != "'. $class_name .'"); |
|
| 188 | + $("#'. self::CLASS_KEY . '").prop("disabled", cache_type != "' . $class_name . '"); |
|
| 189 | 189 | });'; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | $class_name = $this->getImplementationClassKeyName(); |
| 132 | 132 | $class_name_txt_key = strtolower($class_name); |
| 133 | 133 | |
| 134 | - $config_vars[] = $txt['cache_'. $class_name_txt_key .'_settings']; |
|
| 134 | + $config_vars[] = $txt['cache_' . $class_name_txt_key . '_settings']; |
|
| 135 | 135 | $config_vars[] = array( |
| 136 | - 'cachedir_'. $class_name_txt_key, |
|
| 137 | - $txt['cachedir_'. $class_name_txt_key], |
|
| 136 | + 'cachedir_' . $class_name_txt_key, |
|
| 137 | + $txt['cachedir_' . $class_name_txt_key], |
|
| 138 | 138 | 'file', |
| 139 | 139 | 'text', |
| 140 | 140 | 36, |
| 141 | - 'cache_'. $class_name_txt_key .'_cachedir'); |
|
| 141 | + 'cache_' . $class_name_txt_key . '_cachedir'); |
|
| 142 | 142 | |
| 143 | 143 | if (!isset($context['settings_post_javascript'])) |
| 144 | 144 | $context['settings_post_javascript'] = ''; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $context['settings_post_javascript'] .= ' |
| 147 | 147 | $("#cache_accelerator").change(function (e) { |
| 148 | 148 | var cache_type = e.currentTarget.value; |
| 149 | - $("#cachedir_'. $class_name_txt_key .'").prop("disabled", cache_type != "'. $class_name .'"); |
|
| 149 | + $("#cachedir_'. $class_name_txt_key . '").prop("disabled", cache_type != "' . $class_name . '"); |
|
| 150 | 150 | });'; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | $class_name = $this->getImplementationClassKeyName(); |
| 153 | 153 | $class_name_txt_key = strtolower($class_name); |
| 154 | 154 | |
| 155 | - $config_vars[] = $txt['cache_'. $class_name_txt_key .'_settings']; |
|
| 155 | + $config_vars[] = $txt['cache_' . $class_name_txt_key . '_settings']; |
|
| 156 | 156 | $config_vars[] = array( |
| 157 | 157 | self::CLASS_KEY, |
| 158 | - $txt['cache_'. $class_name_txt_key .'_servers'], |
|
| 158 | + $txt['cache_' . $class_name_txt_key . '_servers'], |
|
| 159 | 159 | 'file', |
| 160 | 160 | 'text', |
| 161 | 161 | 0, |
| 162 | - 'cache_'. $class_name_txt_key, |
|
| 163 | - 'subtext' => $txt['cache_'. $class_name_txt_key .'_servers_subtext']); |
|
| 162 | + 'cache_' . $class_name_txt_key, |
|
| 163 | + 'subtext' => $txt['cache_' . $class_name_txt_key . '_servers_subtext']); |
|
| 164 | 164 | |
| 165 | 165 | if (!isset($context['settings_post_javascript'])) |
| 166 | 166 | $context['settings_post_javascript'] = ''; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $context['settings_post_javascript'] .= ' |
| 169 | 169 | $("#cache_accelerator").change(function (e) { |
| 170 | 170 | var cache_type = e.currentTarget.value; |
| 171 | - $("#'. self::CLASS_KEY .'").prop("disabled", cache_type != "'. $class_name .'"); |
|
| 171 | + $("#'. self::CLASS_KEY . '").prop("disabled", cache_type != "' . $class_name . '"); |
|
| 172 | 172 | });'; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | clean_cache(); |
| 170 | 170 | |
| 171 | 171 | // If warning decrement is enabled and we have people who have not had a new warning in 24 hours, lower their warning level. |
| 172 | - list (, , $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']); |
|
| 172 | + list (,, $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']); |
|
| 173 | 173 | if ($modSettings['warning_decrement']) |
| 174 | 174 | { |
| 175 | 175 | // Find every member who has a warning level... |
@@ -1665,7 +1665,7 @@ discard block |
||
| 1665 | 1665 | // Determine action based on last_login... |
| 1666 | 1666 | $purgeMembers = array(); |
| 1667 | 1667 | $markReadMembers = array(); |
| 1668 | - foreach($members as $member) |
|
| 1668 | + foreach ($members as $member) |
|
| 1669 | 1669 | { |
| 1670 | 1670 | if ($member['last_login'] <= $cleanupBeyond) |
| 1671 | 1671 | $purgeMembers[] = $member['id_member']; |
@@ -2717,8 +2717,7 @@ discard block |
||
| 2717 | 2717 | $context['css_files_order'] = array(); |
| 2718 | 2718 | |
| 2719 | 2719 | $params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? |
| 2720 | - (array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') : |
|
| 2721 | - (is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : ''); |
|
| 2720 | + (array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') : (is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : ''); |
|
| 2722 | 2721 | $params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false; |
| 2723 | 2722 | $themeRef = !empty($params['default_theme']) ? 'default_theme' : 'theme'; |
| 2724 | 2723 | $params['minimize'] = isset($params['minimize']) ? $params['minimize'] : true; |
@@ -2832,8 +2831,7 @@ discard block |
||
| 2832 | 2831 | global $settings, $context, $modSettings; |
| 2833 | 2832 | |
| 2834 | 2833 | $params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? |
| 2835 | - (array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') : |
|
| 2836 | - (is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : ''); |
|
| 2834 | + (array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') : (is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : ''); |
|
| 2837 | 2835 | $params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false; |
| 2838 | 2836 | $themeRef = !empty($params['default_theme']) ? 'default_theme' : 'theme'; |
| 2839 | 2837 | $params['async'] = isset($params['async']) ? $params['async'] : false; |
@@ -3573,10 +3571,10 @@ discard block |
||
| 3573 | 3571 | $cacheAPI = false; |
| 3574 | 3572 | |
| 3575 | 3573 | // Autoload hasn't been called yet :/ |
| 3576 | - require_once($cacheAPIdir .'/CacheApi.php'); |
|
| 3577 | - require_once($cacheAPIdir .'/CacheApiInterface.php'); |
|
| 3574 | + require_once($cacheAPIdir . '/CacheApi.php'); |
|
| 3575 | + require_once($cacheAPIdir . '/CacheApiInterface.php'); |
|
| 3578 | 3576 | |
| 3579 | - $apis_dir = $cacheAPIdir .'/'. CacheApi::APIS_FOLDER; |
|
| 3577 | + $apis_dir = $cacheAPIdir . '/' . CacheApi::APIS_FOLDER; |
|
| 3580 | 3578 | |
| 3581 | 3579 | // What accelerator we are going to try. |
| 3582 | 3580 | $cache_class_name = !empty($cache_accelerator) ? $cache_accelerator : CacheApi::APIS_DEFAULT; |
@@ -3588,8 +3586,7 @@ discard block |
||
| 3588 | 3586 | { |
| 3589 | 3587 | require_once($file_to_load); |
| 3590 | 3588 | |
| 3591 | - $fully_qualified_class_name = !empty($overrideCache) ? $overrideCache : |
|
| 3592 | - CacheApi::APIS_NAMESPACE . $cache_class_name; |
|
| 3589 | + $fully_qualified_class_name = !empty($overrideCache) ? $overrideCache : CacheApi::APIS_NAMESPACE . $cache_class_name; |
|
| 3593 | 3590 | |
| 3594 | 3591 | /* @var CacheApiInterface $cache_api */ |
| 3595 | 3592 | $cache_api = new $fully_qualified_class_name(); |
@@ -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 | */ |