@@ -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']])) |
@@ -285,7 +285,7 @@ |
||
285 | 285 | { |
286 | 286 | /** |
287 | 287 | * Constants for notfication types. |
288 | - */ |
|
288 | + */ |
|
289 | 289 | const RECEIVE_NOTIFY_EMAIL = 0x02; |
290 | 290 | const RECEIVE_NOTIFY_ALERT = 0x01; |
291 | 291 |
@@ -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; |
@@ -1756,8 +1756,7 @@ |
||
1756 | 1756 | updateStats('topic'); |
1757 | 1757 | |
1758 | 1758 | // This function is needed to do the updateStats('subject') call. |
1759 | - $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
|
1760 | - function($string) |
|
1759 | + $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) |
|
1761 | 1760 | { |
1762 | 1761 | global $sourcedir; |
1763 | 1762 | if (function_exists('mb_strtolower')) |