@@ -28,50 +28,50 @@ |
||
| 28 | 28 | |
| 29 | 29 | if (!is_callable('RandomCompat_intval')) { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Cast to an integer if we can, safely. |
|
| 33 | - * |
|
| 34 | - * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) |
|
| 35 | - * (non-inclusive), it will sanely cast it to an int. If you it's equal to |
|
| 36 | - * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats |
|
| 37 | - * lose precision, so the <= and => operators might accidentally let a float |
|
| 38 | - * through. |
|
| 39 | - * |
|
| 40 | - * @param int|float $number The number we want to convert to an int |
|
| 41 | - * @param bool $fail_open Set to true to not throw an exception |
|
| 42 | - * |
|
| 43 | - * @return float|int |
|
| 44 | - * @psalm-suppress InvalidReturnType |
|
| 45 | - * |
|
| 46 | - * @throws TypeError |
|
| 47 | - */ |
|
| 48 | - function RandomCompat_intval($number, $fail_open = false) |
|
| 49 | - { |
|
| 50 | - if (is_int($number) || is_float($number)) { |
|
| 51 | - $number += 0; |
|
| 52 | - } elseif (is_numeric($number)) { |
|
| 53 | - /** @psalm-suppress InvalidOperand */ |
|
| 54 | - $number += 0; |
|
| 55 | - } |
|
| 56 | - /** @var int|float $number */ |
|
| 31 | + /** |
|
| 32 | + * Cast to an integer if we can, safely. |
|
| 33 | + * |
|
| 34 | + * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) |
|
| 35 | + * (non-inclusive), it will sanely cast it to an int. If you it's equal to |
|
| 36 | + * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats |
|
| 37 | + * lose precision, so the <= and => operators might accidentally let a float |
|
| 38 | + * through. |
|
| 39 | + * |
|
| 40 | + * @param int|float $number The number we want to convert to an int |
|
| 41 | + * @param bool $fail_open Set to true to not throw an exception |
|
| 42 | + * |
|
| 43 | + * @return float|int |
|
| 44 | + * @psalm-suppress InvalidReturnType |
|
| 45 | + * |
|
| 46 | + * @throws TypeError |
|
| 47 | + */ |
|
| 48 | + function RandomCompat_intval($number, $fail_open = false) |
|
| 49 | + { |
|
| 50 | + if (is_int($number) || is_float($number)) { |
|
| 51 | + $number += 0; |
|
| 52 | + } elseif (is_numeric($number)) { |
|
| 53 | + /** @psalm-suppress InvalidOperand */ |
|
| 54 | + $number += 0; |
|
| 55 | + } |
|
| 56 | + /** @var int|float $number */ |
|
| 57 | 57 | |
| 58 | - if ( |
|
| 59 | - is_float($number) |
|
| 60 | - && |
|
| 61 | - $number > ~PHP_INT_MAX |
|
| 62 | - && |
|
| 63 | - $number < PHP_INT_MAX |
|
| 64 | - ) { |
|
| 65 | - $number = (int) $number; |
|
| 66 | - } |
|
| 58 | + if ( |
|
| 59 | + is_float($number) |
|
| 60 | + && |
|
| 61 | + $number > ~PHP_INT_MAX |
|
| 62 | + && |
|
| 63 | + $number < PHP_INT_MAX |
|
| 64 | + ) { |
|
| 65 | + $number = (int) $number; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - if (is_int($number)) { |
|
| 69 | - return (int) $number; |
|
| 70 | - } elseif (!$fail_open) { |
|
| 71 | - throw new TypeError( |
|
| 72 | - 'Expected an integer.' |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - return $number; |
|
| 76 | - } |
|
| 68 | + if (is_int($number)) { |
|
| 69 | + return (int) $number; |
|
| 70 | + } elseif (!$fail_open) { |
|
| 71 | + throw new TypeError( |
|
| 72 | + 'Expected an integer.' |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + return $number; |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * SOFTWARE. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!is_callable('RandomCompat_intval')) { |
|
| 29 | +if (!is_callable('RandomCompat_intval')) |
|
| 30 | +{ |
|
| 30 | 31 | |
| 31 | 32 | /** |
| 32 | 33 | * Cast to an integer if we can, safely. |
@@ -47,9 +48,12 @@ discard block |
||
| 47 | 48 | */ |
| 48 | 49 | function RandomCompat_intval($number, $fail_open = false) |
| 49 | 50 | { |
| 50 | - if (is_int($number) || is_float($number)) { |
|
| 51 | + if (is_int($number) || is_float($number)) |
|
| 52 | + { |
|
| 51 | 53 | $number += 0; |
| 52 | - } elseif (is_numeric($number)) { |
|
| 54 | + } |
|
| 55 | + elseif (is_numeric($number)) |
|
| 56 | + { |
|
| 53 | 57 | /** @psalm-suppress InvalidOperand */ |
| 54 | 58 | $number += 0; |
| 55 | 59 | } |
@@ -65,9 +69,12 @@ discard block |
||
| 65 | 69 | $number = (int) $number; |
| 66 | 70 | } |
| 67 | 71 | |
| 68 | - if (is_int($number)) { |
|
| 72 | + if (is_int($number)) |
|
| 73 | + { |
|
| 69 | 74 | return (int) $number; |
| 70 | - } elseif (!$fail_open) { |
|
| 75 | + } |
|
| 76 | + elseif (!$fail_open) |
|
| 77 | + { |
|
| 71 | 78 | throw new TypeError( |
| 72 | 79 | 'Expected an integer.' |
| 73 | 80 | ); |
@@ -27,65 +27,65 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | 29 | if (!is_callable('random_bytes')) { |
| 30 | - /** |
|
| 31 | - * If the libsodium PHP extension is loaded, we'll use it above any other |
|
| 32 | - * solution. |
|
| 33 | - * |
|
| 34 | - * libsodium-php project: |
|
| 35 | - * @ref https://github.com/jedisct1/libsodium-php |
|
| 36 | - * |
|
| 37 | - * @param int $bytes |
|
| 38 | - * |
|
| 39 | - * @throws Exception |
|
| 40 | - * |
|
| 41 | - * @return string |
|
| 42 | - */ |
|
| 43 | - function random_bytes($bytes) |
|
| 44 | - { |
|
| 45 | - try { |
|
| 46 | - /** @var int $bytes */ |
|
| 47 | - $bytes = RandomCompat_intval($bytes); |
|
| 48 | - } catch (TypeError $ex) { |
|
| 49 | - throw new TypeError( |
|
| 50 | - 'random_bytes(): $bytes must be an integer' |
|
| 51 | - ); |
|
| 52 | - } |
|
| 30 | + /** |
|
| 31 | + * If the libsodium PHP extension is loaded, we'll use it above any other |
|
| 32 | + * solution. |
|
| 33 | + * |
|
| 34 | + * libsodium-php project: |
|
| 35 | + * @ref https://github.com/jedisct1/libsodium-php |
|
| 36 | + * |
|
| 37 | + * @param int $bytes |
|
| 38 | + * |
|
| 39 | + * @throws Exception |
|
| 40 | + * |
|
| 41 | + * @return string |
|
| 42 | + */ |
|
| 43 | + function random_bytes($bytes) |
|
| 44 | + { |
|
| 45 | + try { |
|
| 46 | + /** @var int $bytes */ |
|
| 47 | + $bytes = RandomCompat_intval($bytes); |
|
| 48 | + } catch (TypeError $ex) { |
|
| 49 | + throw new TypeError( |
|
| 50 | + 'random_bytes(): $bytes must be an integer' |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - if ($bytes < 1) { |
|
| 55 | - throw new Error( |
|
| 56 | - 'Length must be greater than 0' |
|
| 57 | - ); |
|
| 58 | - } |
|
| 54 | + if ($bytes < 1) { |
|
| 55 | + throw new Error( |
|
| 56 | + 'Length must be greater than 0' |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be |
|
| 62 | - * generated in one invocation. |
|
| 63 | - */ |
|
| 64 | - /** @var string|bool $buf */ |
|
| 65 | - if ($bytes > 2147483647) { |
|
| 66 | - $buf = ''; |
|
| 67 | - for ($i = 0; $i < $bytes; $i += 1073741824) { |
|
| 68 | - $n = ($bytes - $i) > 1073741824 |
|
| 69 | - ? 1073741824 |
|
| 70 | - : $bytes - $i; |
|
| 71 | - $buf .= \Sodium\randombytes_buf($n); |
|
| 72 | - } |
|
| 73 | - } else { |
|
| 74 | - /** @var string|bool $buf */ |
|
| 75 | - $buf = \Sodium\randombytes_buf($bytes); |
|
| 76 | - } |
|
| 60 | + /** |
|
| 61 | + * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be |
|
| 62 | + * generated in one invocation. |
|
| 63 | + */ |
|
| 64 | + /** @var string|bool $buf */ |
|
| 65 | + if ($bytes > 2147483647) { |
|
| 66 | + $buf = ''; |
|
| 67 | + for ($i = 0; $i < $bytes; $i += 1073741824) { |
|
| 68 | + $n = ($bytes - $i) > 1073741824 |
|
| 69 | + ? 1073741824 |
|
| 70 | + : $bytes - $i; |
|
| 71 | + $buf .= \Sodium\randombytes_buf($n); |
|
| 72 | + } |
|
| 73 | + } else { |
|
| 74 | + /** @var string|bool $buf */ |
|
| 75 | + $buf = \Sodium\randombytes_buf($bytes); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - if (is_string($buf)) { |
|
| 79 | - if (RandomCompat_strlen($buf) === $bytes) { |
|
| 80 | - return $buf; |
|
| 81 | - } |
|
| 82 | - } |
|
| 78 | + if (is_string($buf)) { |
|
| 79 | + if (RandomCompat_strlen($buf) === $bytes) { |
|
| 80 | + return $buf; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * If we reach here, PHP has failed us. |
|
| 86 | - */ |
|
| 87 | - throw new Exception( |
|
| 88 | - 'Could not gather sufficient random data' |
|
| 89 | - ); |
|
| 90 | - } |
|
| 84 | + /** |
|
| 85 | + * If we reach here, PHP has failed us. |
|
| 86 | + */ |
|
| 87 | + throw new Exception( |
|
| 88 | + 'Could not gather sufficient random data' |
|
| 89 | + ); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -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 | } |
@@ -27,169 +27,169 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | 29 | if (!is_callable('RandomCompat_strlen')) { |
| 30 | - if ( |
|
| 31 | - defined('MB_OVERLOAD_STRING') |
|
| 32 | - && |
|
| 33 | - ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
| 34 | - ) { |
|
| 35 | - /** |
|
| 36 | - * strlen() implementation that isn't brittle to mbstring.func_overload |
|
| 37 | - * |
|
| 38 | - * This version uses mb_strlen() in '8bit' mode to treat strings as raw |
|
| 39 | - * binary rather than UTF-8, ISO-8859-1, etc |
|
| 40 | - * |
|
| 41 | - * @param string $binary_string |
|
| 42 | - * |
|
| 43 | - * @throws TypeError |
|
| 44 | - * |
|
| 45 | - * @return int |
|
| 46 | - */ |
|
| 47 | - function RandomCompat_strlen($binary_string) |
|
| 48 | - { |
|
| 49 | - if (!is_string($binary_string)) { |
|
| 50 | - throw new TypeError( |
|
| 51 | - 'RandomCompat_strlen() expects a string' |
|
| 52 | - ); |
|
| 53 | - } |
|
| 30 | + if ( |
|
| 31 | + defined('MB_OVERLOAD_STRING') |
|
| 32 | + && |
|
| 33 | + ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
| 34 | + ) { |
|
| 35 | + /** |
|
| 36 | + * strlen() implementation that isn't brittle to mbstring.func_overload |
|
| 37 | + * |
|
| 38 | + * This version uses mb_strlen() in '8bit' mode to treat strings as raw |
|
| 39 | + * binary rather than UTF-8, ISO-8859-1, etc |
|
| 40 | + * |
|
| 41 | + * @param string $binary_string |
|
| 42 | + * |
|
| 43 | + * @throws TypeError |
|
| 44 | + * |
|
| 45 | + * @return int |
|
| 46 | + */ |
|
| 47 | + function RandomCompat_strlen($binary_string) |
|
| 48 | + { |
|
| 49 | + if (!is_string($binary_string)) { |
|
| 50 | + throw new TypeError( |
|
| 51 | + 'RandomCompat_strlen() expects a string' |
|
| 52 | + ); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return (int) mb_strlen($binary_string, '8bit'); |
|
| 56 | - } |
|
| 55 | + return (int) mb_strlen($binary_string, '8bit'); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - } else { |
|
| 59 | - /** |
|
| 60 | - * strlen() implementation that isn't brittle to mbstring.func_overload |
|
| 61 | - * |
|
| 62 | - * This version just used the default strlen() |
|
| 63 | - * |
|
| 64 | - * @param string $binary_string |
|
| 65 | - * |
|
| 66 | - * @throws TypeError |
|
| 67 | - * |
|
| 68 | - * @return int |
|
| 69 | - */ |
|
| 70 | - function RandomCompat_strlen($binary_string) |
|
| 71 | - { |
|
| 72 | - if (!is_string($binary_string)) { |
|
| 73 | - throw new TypeError( |
|
| 74 | - 'RandomCompat_strlen() expects a string' |
|
| 75 | - ); |
|
| 76 | - } |
|
| 77 | - return (int) strlen($binary_string); |
|
| 78 | - } |
|
| 79 | - } |
|
| 58 | + } else { |
|
| 59 | + /** |
|
| 60 | + * strlen() implementation that isn't brittle to mbstring.func_overload |
|
| 61 | + * |
|
| 62 | + * This version just used the default strlen() |
|
| 63 | + * |
|
| 64 | + * @param string $binary_string |
|
| 65 | + * |
|
| 66 | + * @throws TypeError |
|
| 67 | + * |
|
| 68 | + * @return int |
|
| 69 | + */ |
|
| 70 | + function RandomCompat_strlen($binary_string) |
|
| 71 | + { |
|
| 72 | + if (!is_string($binary_string)) { |
|
| 73 | + throw new TypeError( |
|
| 74 | + 'RandomCompat_strlen() expects a string' |
|
| 75 | + ); |
|
| 76 | + } |
|
| 77 | + return (int) strlen($binary_string); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | if (!is_callable('RandomCompat_substr')) { |
| 83 | 83 | |
| 84 | - if ( |
|
| 85 | - defined('MB_OVERLOAD_STRING') |
|
| 86 | - && |
|
| 87 | - ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
| 88 | - ) { |
|
| 89 | - /** |
|
| 90 | - * substr() implementation that isn't brittle to mbstring.func_overload |
|
| 91 | - * |
|
| 92 | - * This version uses mb_substr() in '8bit' mode to treat strings as raw |
|
| 93 | - * binary rather than UTF-8, ISO-8859-1, etc |
|
| 94 | - * |
|
| 95 | - * @param string $binary_string |
|
| 96 | - * @param int $start |
|
| 97 | - * @param int|null $length (optional) |
|
| 98 | - * |
|
| 99 | - * @throws TypeError |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
| 104 | - { |
|
| 105 | - if (!is_string($binary_string)) { |
|
| 106 | - throw new TypeError( |
|
| 107 | - 'RandomCompat_substr(): First argument should be a string' |
|
| 108 | - ); |
|
| 109 | - } |
|
| 84 | + if ( |
|
| 85 | + defined('MB_OVERLOAD_STRING') |
|
| 86 | + && |
|
| 87 | + ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
| 88 | + ) { |
|
| 89 | + /** |
|
| 90 | + * substr() implementation that isn't brittle to mbstring.func_overload |
|
| 91 | + * |
|
| 92 | + * This version uses mb_substr() in '8bit' mode to treat strings as raw |
|
| 93 | + * binary rather than UTF-8, ISO-8859-1, etc |
|
| 94 | + * |
|
| 95 | + * @param string $binary_string |
|
| 96 | + * @param int $start |
|
| 97 | + * @param int|null $length (optional) |
|
| 98 | + * |
|
| 99 | + * @throws TypeError |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function RandomCompat_substr($binary_string, $start, $length = null) |
|
| 104 | + { |
|
| 105 | + if (!is_string($binary_string)) { |
|
| 106 | + throw new TypeError( |
|
| 107 | + 'RandomCompat_substr(): First argument should be a string' |
|
| 108 | + ); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - if (!is_int($start)) { |
|
| 112 | - throw new TypeError( |
|
| 113 | - 'RandomCompat_substr(): Second argument should be an integer' |
|
| 114 | - ); |
|
| 115 | - } |
|
| 111 | + if (!is_int($start)) { |
|
| 112 | + throw new TypeError( |
|
| 113 | + 'RandomCompat_substr(): Second argument should be an integer' |
|
| 114 | + ); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - if ($length === null) { |
|
| 118 | - /** |
|
| 119 | - * mb_substr($str, 0, NULL, '8bit') returns an empty string on |
|
| 120 | - * PHP 5.3, so we have to find the length ourselves. |
|
| 121 | - */ |
|
| 122 | - /** @var int $length */ |
|
| 123 | - $length = RandomCompat_strlen($binary_string) - $start; |
|
| 124 | - } elseif (!is_int($length)) { |
|
| 125 | - throw new TypeError( |
|
| 126 | - 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
| 127 | - ); |
|
| 128 | - } |
|
| 117 | + if ($length === null) { |
|
| 118 | + /** |
|
| 119 | + * mb_substr($str, 0, NULL, '8bit') returns an empty string on |
|
| 120 | + * PHP 5.3, so we have to find the length ourselves. |
|
| 121 | + */ |
|
| 122 | + /** @var int $length */ |
|
| 123 | + $length = RandomCompat_strlen($binary_string) - $start; |
|
| 124 | + } elseif (!is_int($length)) { |
|
| 125 | + throw new TypeError( |
|
| 126 | + 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
| 127 | + ); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - // Consistency with PHP's behavior |
|
| 131 | - if ($start === RandomCompat_strlen($binary_string) && $length === 0) { |
|
| 132 | - return ''; |
|
| 133 | - } |
|
| 134 | - if ($start > RandomCompat_strlen($binary_string)) { |
|
| 135 | - return ''; |
|
| 136 | - } |
|
| 130 | + // Consistency with PHP's behavior |
|
| 131 | + if ($start === RandomCompat_strlen($binary_string) && $length === 0) { |
|
| 132 | + return ''; |
|
| 133 | + } |
|
| 134 | + if ($start > RandomCompat_strlen($binary_string)) { |
|
| 135 | + return ''; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - return (string) mb_substr( |
|
| 139 | - (string) $binary_string, |
|
| 140 | - (int) $start, |
|
| 141 | - (int) $length, |
|
| 142 | - '8bit' |
|
| 143 | - ); |
|
| 144 | - } |
|
| 138 | + return (string) mb_substr( |
|
| 139 | + (string) $binary_string, |
|
| 140 | + (int) $start, |
|
| 141 | + (int) $length, |
|
| 142 | + '8bit' |
|
| 143 | + ); |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - } else { |
|
| 146 | + } else { |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * substr() implementation that isn't brittle to mbstring.func_overload |
|
| 150 | - * |
|
| 151 | - * This version just uses the default substr() |
|
| 152 | - * |
|
| 153 | - * @param string $binary_string |
|
| 154 | - * @param int $start |
|
| 155 | - * @param int|null $length (optional) |
|
| 156 | - * |
|
| 157 | - * @throws TypeError |
|
| 158 | - * |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
| 162 | - { |
|
| 163 | - if (!is_string($binary_string)) { |
|
| 164 | - throw new TypeError( |
|
| 165 | - 'RandomCompat_substr(): First argument should be a string' |
|
| 166 | - ); |
|
| 167 | - } |
|
| 148 | + /** |
|
| 149 | + * substr() implementation that isn't brittle to mbstring.func_overload |
|
| 150 | + * |
|
| 151 | + * This version just uses the default substr() |
|
| 152 | + * |
|
| 153 | + * @param string $binary_string |
|
| 154 | + * @param int $start |
|
| 155 | + * @param int|null $length (optional) |
|
| 156 | + * |
|
| 157 | + * @throws TypeError |
|
| 158 | + * |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + function RandomCompat_substr($binary_string, $start, $length = null) |
|
| 162 | + { |
|
| 163 | + if (!is_string($binary_string)) { |
|
| 164 | + throw new TypeError( |
|
| 165 | + 'RandomCompat_substr(): First argument should be a string' |
|
| 166 | + ); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if (!is_int($start)) { |
|
| 170 | - throw new TypeError( |
|
| 171 | - 'RandomCompat_substr(): Second argument should be an integer' |
|
| 172 | - ); |
|
| 173 | - } |
|
| 169 | + if (!is_int($start)) { |
|
| 170 | + throw new TypeError( |
|
| 171 | + 'RandomCompat_substr(): Second argument should be an integer' |
|
| 172 | + ); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - if ($length !== null) { |
|
| 176 | - if (!is_int($length)) { |
|
| 177 | - throw new TypeError( |
|
| 178 | - 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
| 179 | - ); |
|
| 180 | - } |
|
| 175 | + if ($length !== null) { |
|
| 176 | + if (!is_int($length)) { |
|
| 177 | + throw new TypeError( |
|
| 178 | + 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
| 179 | + ); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - return (string) substr( |
|
| 183 | - (string )$binary_string, |
|
| 184 | - (int) $start, |
|
| 185 | - (int) $length |
|
| 186 | - ); |
|
| 187 | - } |
|
| 182 | + return (string) substr( |
|
| 183 | + (string )$binary_string, |
|
| 184 | + (int) $start, |
|
| 185 | + (int) $length |
|
| 186 | + ); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - return (string) substr( |
|
| 190 | - (string) $binary_string, |
|
| 191 | - (int) $start |
|
| 192 | - ); |
|
| 193 | - } |
|
| 194 | - } |
|
| 189 | + return (string) substr( |
|
| 190 | + (string) $binary_string, |
|
| 191 | + (int) $start |
|
| 192 | + ); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | 195 | } |
@@ -180,7 +180,7 @@ |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | return (string) substr( |
| 183 | - (string )$binary_string, |
|
| 183 | + (string) $binary_string, |
|
| 184 | 184 | (int) $start, |
| 185 | 185 | (int) $length |
| 186 | 186 | ); |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * SOFTWARE. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!is_callable('RandomCompat_strlen')) { |
|
| 29 | +if (!is_callable('RandomCompat_strlen')) |
|
| 30 | +{ |
|
| 30 | 31 | if ( |
| 31 | 32 | defined('MB_OVERLOAD_STRING') |
| 32 | 33 | && |
@@ -46,7 +47,8 @@ discard block |
||
| 46 | 47 | */ |
| 47 | 48 | function RandomCompat_strlen($binary_string) |
| 48 | 49 | { |
| 49 | - if (!is_string($binary_string)) { |
|
| 50 | + if (!is_string($binary_string)) |
|
| 51 | + { |
|
| 50 | 52 | throw new TypeError( |
| 51 | 53 | 'RandomCompat_strlen() expects a string' |
| 52 | 54 | ); |
@@ -55,7 +57,9 @@ discard block |
||
| 55 | 57 | return (int) mb_strlen($binary_string, '8bit'); |
| 56 | 58 | } |
| 57 | 59 | |
| 58 | - } else { |
|
| 60 | + } |
|
| 61 | + else |
|
| 62 | + { |
|
| 59 | 63 | /** |
| 60 | 64 | * strlen() implementation that isn't brittle to mbstring.func_overload |
| 61 | 65 | * |
@@ -69,7 +73,8 @@ discard block |
||
| 69 | 73 | */ |
| 70 | 74 | function RandomCompat_strlen($binary_string) |
| 71 | 75 | { |
| 72 | - if (!is_string($binary_string)) { |
|
| 76 | + if (!is_string($binary_string)) |
|
| 77 | + { |
|
| 73 | 78 | throw new TypeError( |
| 74 | 79 | 'RandomCompat_strlen() expects a string' |
| 75 | 80 | ); |
@@ -79,7 +84,8 @@ discard block |
||
| 79 | 84 | } |
| 80 | 85 | } |
| 81 | 86 | |
| 82 | -if (!is_callable('RandomCompat_substr')) { |
|
| 87 | +if (!is_callable('RandomCompat_substr')) |
|
| 88 | +{ |
|
| 83 | 89 | |
| 84 | 90 | if ( |
| 85 | 91 | defined('MB_OVERLOAD_STRING') |
@@ -102,36 +108,43 @@ discard block |
||
| 102 | 108 | */ |
| 103 | 109 | function RandomCompat_substr($binary_string, $start, $length = null) |
| 104 | 110 | { |
| 105 | - if (!is_string($binary_string)) { |
|
| 111 | + if (!is_string($binary_string)) |
|
| 112 | + { |
|
| 106 | 113 | throw new TypeError( |
| 107 | 114 | 'RandomCompat_substr(): First argument should be a string' |
| 108 | 115 | ); |
| 109 | 116 | } |
| 110 | 117 | |
| 111 | - if (!is_int($start)) { |
|
| 118 | + if (!is_int($start)) |
|
| 119 | + { |
|
| 112 | 120 | throw new TypeError( |
| 113 | 121 | 'RandomCompat_substr(): Second argument should be an integer' |
| 114 | 122 | ); |
| 115 | 123 | } |
| 116 | 124 | |
| 117 | - if ($length === null) { |
|
| 125 | + if ($length === null) |
|
| 126 | + { |
|
| 118 | 127 | /** |
| 119 | 128 | * mb_substr($str, 0, NULL, '8bit') returns an empty string on |
| 120 | 129 | * PHP 5.3, so we have to find the length ourselves. |
| 121 | 130 | */ |
| 122 | 131 | /** @var int $length */ |
| 123 | 132 | $length = RandomCompat_strlen($binary_string) - $start; |
| 124 | - } elseif (!is_int($length)) { |
|
| 133 | + } |
|
| 134 | + elseif (!is_int($length)) |
|
| 135 | + { |
|
| 125 | 136 | throw new TypeError( |
| 126 | 137 | 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
| 127 | 138 | ); |
| 128 | 139 | } |
| 129 | 140 | |
| 130 | 141 | // Consistency with PHP's behavior |
| 131 | - if ($start === RandomCompat_strlen($binary_string) && $length === 0) { |
|
| 142 | + if ($start === RandomCompat_strlen($binary_string) && $length === 0) |
|
| 143 | + { |
|
| 132 | 144 | return ''; |
| 133 | 145 | } |
| 134 | - if ($start > RandomCompat_strlen($binary_string)) { |
|
| 146 | + if ($start > RandomCompat_strlen($binary_string)) |
|
| 147 | + { |
|
| 135 | 148 | return ''; |
| 136 | 149 | } |
| 137 | 150 | |
@@ -143,7 +156,9 @@ discard block |
||
| 143 | 156 | ); |
| 144 | 157 | } |
| 145 | 158 | |
| 146 | - } else { |
|
| 159 | + } |
|
| 160 | + else |
|
| 161 | + { |
|
| 147 | 162 | |
| 148 | 163 | /** |
| 149 | 164 | * substr() implementation that isn't brittle to mbstring.func_overload |
@@ -160,20 +175,24 @@ discard block |
||
| 160 | 175 | */ |
| 161 | 176 | function RandomCompat_substr($binary_string, $start, $length = null) |
| 162 | 177 | { |
| 163 | - if (!is_string($binary_string)) { |
|
| 178 | + if (!is_string($binary_string)) |
|
| 179 | + { |
|
| 164 | 180 | throw new TypeError( |
| 165 | 181 | 'RandomCompat_substr(): First argument should be a string' |
| 166 | 182 | ); |
| 167 | 183 | } |
| 168 | 184 | |
| 169 | - if (!is_int($start)) { |
|
| 185 | + if (!is_int($start)) |
|
| 186 | + { |
|
| 170 | 187 | throw new TypeError( |
| 171 | 188 | 'RandomCompat_substr(): Second argument should be an integer' |
| 172 | 189 | ); |
| 173 | 190 | } |
| 174 | 191 | |
| 175 | - if ($length !== null) { |
|
| 176 | - if (!is_int($length)) { |
|
| 192 | + if ($length !== null) |
|
| 193 | + { |
|
| 194 | + if (!is_int($length)) |
|
| 195 | + { |
|
| 177 | 196 | throw new TypeError( |
| 178 | 197 | 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
| 179 | 198 | ); |
@@ -420,7 +420,7 @@ |
||
| 420 | 420 | $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']); |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | - else |
|
| 423 | + else |
|
| 424 | 424 | foreach ($this_category as &$board) |
| 425 | 425 | { |
| 426 | 426 | if (!empty($moderators[$board['id']])) |
@@ -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); |
@@ -756,7 +756,7 @@ |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // Filter out any redundant separators before we start the loop |
| 759 | - $context['config_vars'] = array_filter($context['config_vars'], function ($v) use ($context) |
|
| 759 | + $context['config_vars'] = array_filter($context['config_vars'], function($v) use ($context) |
|
| 760 | 760 | { |
| 761 | 761 | static $config_vars, $prev; |
| 762 | 762 | |
@@ -107,7 +107,7 @@ |
||
| 107 | 107 | </div>'; |
| 108 | 108 | |
| 109 | 109 | // Show the last post if there is one. |
| 110 | - if(!empty($board['last_post']['id'])) |
|
| 110 | + if (!empty($board['last_post']['id'])) |
|
| 111 | 111 | echo' |
| 112 | 112 | <div class="lastpost lpr_border"> |
| 113 | 113 | ', function_exists('template_bi_' . $board['type'] . '_lastpost') ? call_user_func('template_bi_' . $board['type'] . '_lastpost', $board) : template_bi_board_lastpost($board), ' |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | </div>'; |
| 51 | 51 | |
| 52 | 52 | // Show the last post if there is one. |
| 53 | - if(!empty($board['last_post']['id'])) |
|
| 53 | + if (!empty($board['last_post']['id'])) |
|
| 54 | 54 | echo ' |
| 55 | 55 | <div class="lastpost lpr_border"> |
| 56 | 56 | ', function_exists('template_bi_' . $board['type'] . '_lastpost') ? call_user_func('template_bi_' . $board['type'] . '_lastpost', $board) : template_bi_board_lastpost($board), ' |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $to = explode('/', $lang_dir); |
| 502 | 502 | $relPath = $to; |
| 503 | 503 | |
| 504 | - foreach($from as $depth => $dir) |
|
| 504 | + foreach ($from as $depth => $dir) |
|
| 505 | 505 | { |
| 506 | 506 | if ($dir === $to[$depth]) |
| 507 | 507 | array_shift($relPath); |
@@ -2881,94 +2881,94 @@ discard block |
||
| 2881 | 2881 | // Translation table for the character sets not native for MySQL. |
| 2882 | 2882 | $translation_tables = array( |
| 2883 | 2883 | 'windows-1255' => array( |
| 2884 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2885 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2886 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2887 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2888 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2889 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2890 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2891 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2892 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2893 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2894 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2895 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2896 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2897 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2898 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2899 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2900 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2901 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2902 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2903 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2904 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2905 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2906 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2907 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2908 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2909 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2910 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2911 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2912 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2913 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2914 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2915 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2916 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2917 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2918 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2919 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2920 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2921 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2922 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2923 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2924 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2925 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2884 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2885 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2886 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2887 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2888 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2889 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2890 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2891 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2892 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2893 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2894 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2895 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2896 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2897 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2898 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2899 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2900 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2901 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2902 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2903 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2904 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2905 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2906 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2907 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2908 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2909 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2910 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2911 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2912 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2913 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2914 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2915 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2916 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2917 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2918 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2919 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2920 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2921 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2922 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2923 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2924 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2925 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2926 | 2926 | '0xFA' => '0xD7AA', |
| 2927 | 2927 | ), |
| 2928 | 2928 | 'windows-1253' => array( |
| 2929 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2930 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2931 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2932 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2933 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2934 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2935 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2936 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2937 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2938 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2939 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2940 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2941 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2942 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2943 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2944 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2945 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2946 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2947 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2948 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2949 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2950 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2951 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2952 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2953 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2954 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2955 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2956 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2957 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2958 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2959 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2960 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2961 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2962 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2963 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2964 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2965 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2966 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2967 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2968 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2969 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2970 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2971 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2929 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2930 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2931 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2932 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2933 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2934 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2935 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2936 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2937 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2938 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2939 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2940 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2941 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2942 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2943 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2944 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2945 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2946 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2947 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2948 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2949 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2950 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2951 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2952 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2953 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2954 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2955 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2956 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2957 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2958 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2959 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2960 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2961 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2962 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2963 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2964 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2965 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2966 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2967 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2968 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2969 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2970 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2971 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2972 | 2972 | ), |
| 2973 | 2973 | ); |
| 2974 | 2974 | |
@@ -3205,7 +3205,7 @@ discard block |
||
| 3205 | 3205 | return $string; |
| 3206 | 3206 | |
| 3207 | 3207 | // This bit fixes incorrect string lengths, which can happen if the character encoding was changed (e.g. conversion to UTF-8) |
| 3208 | - $new_string = preg_replace_callback('~\bs:(\d+):"(.*?)";(?=$|[bidsa]:|[{}]|N;)~s', function ($matches) {return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";';}, $string); |
|
| 3208 | + $new_string = preg_replace_callback('~\bs:(\d+):"(.*?)";(?=$|[bidsa]:|[{}]|N;)~s', function($matches) {return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";'; }, $string); |
|
| 3209 | 3209 | |
| 3210 | 3210 | // @todo Add more possible fixes here. For example, fix incorrect array lengths, try to handle truncated strings gracefully, etc. |
| 3211 | 3211 | |
@@ -3205,7 +3205,9 @@ |
||
| 3205 | 3205 | return $string; |
| 3206 | 3206 | |
| 3207 | 3207 | // This bit fixes incorrect string lengths, which can happen if the character encoding was changed (e.g. conversion to UTF-8) |
| 3208 | - $new_string = preg_replace_callback('~\bs:(\d+):"(.*?)";(?=$|[bidsa]:|[{}]|N;)~s', function ($matches) {return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";';}, $string); |
|
| 3208 | + $new_string = preg_replace_callback('~\bs:(\d+):"(.*?)";(?=$|[bidsa]:|[{}]|N;)~s', function ($matches) |
|
| 3209 | + { |
|
| 3210 | +return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";';}, $string); |
|
| 3209 | 3211 | |
| 3210 | 3212 | // @todo Add more possible fixes here. For example, fix incorrect array lengths, try to handle truncated strings gracefully, etc. |
| 3211 | 3213 | |
@@ -1826,7 +1826,7 @@ |
||
| 1826 | 1826 | if (!empty($excluded_groups)) |
| 1827 | 1827 | { |
| 1828 | 1828 | // Make sure this is an array of integers |
| 1829 | - $excluded_groups = array_filter((array) $excluded_groups, function ($v) |
|
| 1829 | + $excluded_groups = array_filter((array) $excluded_groups, function($v) |
|
| 1830 | 1830 | { |
| 1831 | 1831 | return is_int($v) || is_string($v) && (string) intval($v) === $v; |
| 1832 | 1832 | }); |
@@ -1827,7 +1827,7 @@ |
||
| 1827 | 1827 | { |
| 1828 | 1828 | // Make sure this is an array of integers |
| 1829 | 1829 | $excluded_groups = array_filter((array) $excluded_groups, function ($v) |
| 1830 | - { |
|
| 1830 | + { |
|
| 1831 | 1831 | return is_int($v) || is_string($v) && (string) intval($v) === $v; |
| 1832 | 1832 | }); |
| 1833 | 1833 | |