Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Php72.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Polyfill\Php72;
013
014 /**
015 * @author Nicolas Grekas <p@tchwork.com>
016 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
017 *
018 * @internal
019 */
020 final class Php72
021 {
022 private static $hashMask;
023
024 public static function utf8_encode($s)
025 {
026 $s .= $s;
027 $len = \strlen($s);
028
029 for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) {
030 switch (true) {
031 case $s[$i] < "\x80": $s[$j] = $s[$i]; break;
032 case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break;
033 default: $s[$j] = "\xC3"; $s[++$j] = \chr(\ord($s[$i]) - 64); break;
034 }
035 }
036
037 return substr($s, 0, $j);
038 }
039
040 public static function utf8_decode($s)
041 {
042 $s = (string) $s;
043 $len = \strlen($s);
044
045 for ($i = 0, $j = 0; $i < $len; ++$i, ++$j) {
046 switch ($s[$i] & "\xF0") {
047 case "\xC0":
048 case "\xD0":
049 $c = (\ord($s[$i] & "\x1F") << 6) | \ord($s[++$i] & "\x3F");
050 $s[$j] = $c < 256 ? \chr($c) : '?';
051 break;
052
053 case "\xF0":
054 ++$i;
055 // no break
056
057 case "\xE0":
058 $s[$j] = '?';
059 $i += 2;
060 break;
061
062 default:
063 $s[$j] = $s[$i];
064 }
065 }
066
067 return substr($s, 0, $j);
068 }
069
070 public static function php_os_family()
071 {
072 if ('\\' === \DIRECTORY_SEPARATOR) {
073 return 'Windows';
074 }
075
076 $map = [
077 'Darwin' => 'Darwin',
078 'DragonFly' => 'BSD',
079 'FreeBSD' => 'BSD',
080 'NetBSD' => 'BSD',
081 'OpenBSD' => 'BSD',
082 'Linux' => 'Linux',
083 'SunOS' => 'Solaris',
084 ];
085
086 return $map[\PHP_OS] ?? 'Unknown';
087 }
088
089 public static function spl_object_id($object)
090 {
091 if (null === self::$hashMask) {
092 self::initHashMask();
093 }
094 if (null === $hash = spl_object_hash($object)) {
095 return;
096 }
097
098 // On 32-bit systems, PHP_INT_SIZE is 4,
099 return self::$hashMask ^ hexdec(substr($hash, 16 - (\PHP_INT_SIZE * 2 - 1), \PHP_INT_SIZE * 2 - 1));
100 }
101
102 public static function sapi_windows_vt100_support($stream, $enable = null)
103 {
104 if (!\is_resource($stream)) {
105 trigger_error('sapi_windows_vt100_support() expects parameter 1 to be resource, '.\gettype($stream).' given', \E_USER_WARNING);
106
107 return false;
108 }
109
110 $meta = stream_get_meta_data($stream);
111
112 if ('STDIO' !== $meta['stream_type']) {
113 trigger_error('sapi_windows_vt100_support() was not able to analyze the specified stream', \E_USER_WARNING);
114
115 return false;
116 }
117
118 // We cannot actually disable vt100 support if it is set
119 if (false === $enable || !self::stream_isatty($stream)) {
120 return false;
121 }
122
123 // The native function does not apply to stdin
124 $meta = array_map('strtolower', $meta);
125 $stdin = 'php://stdin' === $meta['uri'] || 'php://fd/0' === $meta['uri'];
126
127 return !$stdin
128 && (false !== getenv('ANSICON')
129 || 'ON' === getenv('ConEmuANSI')
130 || 'xterm' === getenv('TERM')
131 || 'Hyper' === getenv('TERM_PROGRAM'));
132 }
133
134 public static function stream_isatty($stream)
135 {
136 if (!\is_resource($stream)) {
137 trigger_error('stream_isatty() expects parameter 1 to be resource, '.\gettype($stream).' given', \E_USER_WARNING);
138
139 return false;
140 }
141
142 if ('\\' === \DIRECTORY_SEPARATOR) {
143 $stat = @fstat($stream);
144 // Check if formatted mode is S_IFCHR
145 return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
146 }
147
148 return \function_exists('posix_isatty') && @posix_isatty($stream);
149 }
150
151 private static function initHashMask()
152 {
153 $obj = (object) [];
154 self::$hashMask = -1;
155
156 // check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below
157 $obFuncs = ['ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush'];
158 foreach (debug_backtrace(\PHP_VERSION_ID >= 50400 ? \DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) {
159 if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && \in_array($frame['function'], $obFuncs)) {
160 $frame['line'] = 0;
161 break;
162 }
163 }
164 if (!empty($frame['line'])) {
165 ob_start();
166 debug_zval_dump($obj);
167 self::$hashMask = (int) substr(ob_get_clean(), 17);
168 }
169
170 self::$hashMask ^= hexdec(substr(spl_object_hash($obj), 16 - (\PHP_INT_SIZE * 2 - 1), \PHP_INT_SIZE * 2 - 1));
171 }
172
173 public static function mb_chr($code, $encoding = null)
174 {
175 if (0x80 > $code %= 0x200000) {
176 $s = \chr($code);
177 } elseif (0x800 > $code) {
178 $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
179 } elseif (0x10000 > $code) {
180 $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
181 } else {
182 $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
183 }
184
185 if ('UTF-8' !== $encoding = $encoding ?? mb_internal_encoding()) {
186 $s = mb_convert_encoding($s, $encoding, 'UTF-8');
187 }
188
189 return $s;
190 }
191
192 public static function mb_ord($s, $encoding = null)
193 {
194 if (null === $encoding) {
195 $s = mb_convert_encoding($s, 'UTF-8');
196 } elseif ('UTF-8' !== $encoding) {
197 $s = mb_convert_encoding($s, 'UTF-8', $encoding);
198 }
199
200 if (1 === \strlen($s)) {
201 return \ord($s);
202 }
203
204 $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
205 if (0xF0 <= $code) {
206 return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
207 }
208 if (0xE0 <= $code) {
209 return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
210 }
211 if (0xC0 <= $code) {
212 return (($code - 0xC0) << 6) + $s[2] - 0x80;
213 }
214
215 return $code;
216 }
217 }
218