Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Bootup.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 7.38 KiB


001  <?php
002   
003  /*
004   * Copyright (C) 2016 Nicolas Grekas - p@tchwork.com
005   *
006   * This library is free software; you can redistribute it and/or modify it
007   * under the terms of the (at your option):
008   * Apache License v2.0 (http://apache.org/licenses/LICENSE-2.0.txt), or
009   * GNU General Public License v2.0 (http://gnu.org/licenses/gpl-2.0.txt).
010   */
011   
012  namespace Patchwork\Utf8;
013   
014  use Normalizer as n;
015  use Patchwork\Utf8 as u;
016  use Patchwork\PHP\Shim as s;
017   
018  class Bootup
019  {
020      public static function initAll()
021      {
022          ini_set('default_charset', 'UTF-8');
023   
024          self::initUtf8Encode();
025          self::initIconv();
026          self::initMbstring();
027          self::initExif();
028          self::initIntl();
029          self::initLocale();
030      }
031   
032      public static function initUtf8Encode()
033      {
034          function_exists('utf8_encode') or require __DIR__.'/Bootup/utf8_encode.php';
035      }
036   
037      public static function initMbstring()
038      {
039          if (extension_loaded('mbstring')) {
040              if (((int) ini_get('mbstring.encoding_translation') || in_array(strtolower(ini_get('mbstring.encoding_translation')), array('on', 'yes', 'true')))
041                  && !in_array(strtolower(ini_get('mbstring.http_input')), array('pass', '8bit', 'utf-8'))) {
042                  user_error('php.ini settings: Please disable mbstring.encoding_translation or set mbstring.http_input to "pass"',  E_USER_WARNING);
043              }
044   
045              if (MB_OVERLOAD_STRING & (int) ini_get('mbstring.func_overload')) {
046                  user_error('php.ini settings: Please disable mbstring.func_overload', E_USER_WARNING);
047              }
048   
049              if (function_exists('mb_regex_encoding')) {
050                  mb_regex_encoding('UTF-8');
051              }
052              ini_set('mbstring.script_encoding', 'pass');
053   
054              if ('utf-8' !== strtolower(mb_internal_encoding())) {
055                  mb_internal_encoding('UTF-8');
056              }
057   
058              if ('none' !== strtolower(mb_substitute_character())) {
059                  mb_substitute_character('none');
060              }
061   
062              if (!in_array(strtolower(mb_http_output()), array('pass', '8bit'))) {
063                  mb_http_output('pass');
064              }
065   
066              if (!in_array(strtolower(mb_language()), array('uni', 'neutral'))) {
067                  mb_language('uni');
068              }
069          } elseif (!function_exists('mb_strlen')) {
070              extension_loaded('iconv') or static::initIconv();
071   
072              require __DIR__.'/Bootup/mbstring.php';
073          }
074      }
075   
076      public static function initIconv()
077      {
078          if (extension_loaded('iconv')) {
079              if ('UTF-8' !== strtoupper(iconv_get_encoding('input_encoding'))) {
080                  iconv_set_encoding('input_encoding', 'UTF-8');
081              }
082   
083              if ('UTF-8' !== strtoupper(iconv_get_encoding('internal_encoding'))) {
084                  iconv_set_encoding('internal_encoding', 'UTF-8');
085              }
086   
087              if ('UTF-8' !== strtoupper(iconv_get_encoding('output_encoding'))) {
088                  iconv_set_encoding('output_encoding', 'UTF-8');
089              }
090          } elseif (!function_exists('iconv')) {
091              require __DIR__.'/Bootup/iconv.php';
092          }
093      }
094   
095      public static function initExif()
096      {
097          if (extension_loaded('exif')) {
098              if (ini_get('exif.encode_unicode') && 'UTF-8' !== strtoupper(ini_get('exif.encode_unicode'))) {
099                  ini_set('exif.encode_unicode', 'UTF-8');
100              }
101   
102              if (ini_get('exif.encode_jis') && 'UTF-8' !== strtoupper(ini_get('exif.encode_jis'))) {
103                  ini_set('exif.encode_jis', 'UTF-8');
104              }
105          }
106      }
107   
108      public static function initIntl()
109      {
110          if (defined('GRAPHEME_CLUSTER_RX')) {
111              return;
112          }
113   
114          define('GRAPHEME_CLUSTER_RX', PCRE_VERSION >= '8.32' ? '\X' : s\Intl::GRAPHEME_CLUSTER_RX);
115   
116          if (!function_exists('grapheme_strlen')) {
117              extension_loaded('iconv') or static::initIconv();
118              extension_loaded('mbstring') or static::initMbstring();
119   
120              require __DIR__.'/Bootup/intl.php';
121          }
122      }
123   
124      public static function initLocale()
125      {
126          // With non-UTF-8 locale, basename() bugs.
127          // Be aware that setlocale() can be slow.
128          // You'd better properly configure your LANG environment variable to an UTF-8 locale.
129   
130          if ('' === basename('§')) {
131              setlocale(LC_ALL, 'C.UTF-8', 'C');
132              setlocale(LC_CTYPE, 'en_US.UTF-8', 'fr_FR.UTF-8', 'es_ES.UTF-8', 'de_DE.UTF-8', 'ru_RU.UTF-8', 'pt_BR.UTF-8', 'it_IT.UTF-8', 'ja_JP.UTF-8', 'zh_CN.UTF-8', '0');
133          }
134      }
135   
136      public static function filterRequestUri($uri = null, $exit = true)
137      {
138          if (!isset($uri)) {
139              if (!isset($_SERVER['REQUEST_URI'])) {
140                  return;
141              } else {
142                  $uri = $_SERVER['REQUEST_URI'];
143              }
144          }
145   
146          // Ensures the URL is well formed UTF-8
147          // When not, assumes Windows-1252 and redirects to the corresponding UTF-8 encoded URL
148   
149          if (!preg_match('//u', urldecode($uri))) {
150              $uri = preg_replace_callback(
151                  '/[\x80-\xFF]+/',
152                  function ($m) {return urlencode($m[0]);},
153                  $uri
154              );
155   
156              $uri = preg_replace_callback(
157                  '/(?:%[89A-F][0-9A-F])+/i',
158                  function ($m) {return urlencode(u::utf8_encode(urldecode($m[0])));},
159                  $uri
160              );
161   
162              if ($exit) {
163                  header('HTTP/1.1 301 Moved Permanently');
164                  header('Location: '.$uri);
165   
166                  exit; // TODO: remove this in 1.2 (BC)
167              }
168          }
169   
170          return $uri;
171      }
172   
173      public static function filterRequestInputs($normalization_form = 4 /* n::NFC */, $leading_combining = '◌')
174      {
175          // Ensures inputs are well formed UTF-8
176          // When not, assumes Windows-1252 and converts to UTF-8
177          // Tests only values, not keys
178   
179          $a = array(&$_FILES, &$_ENV, &$_GET, &$_POST, &$_COOKIE, &$_SERVER, &$_REQUEST);
180   
181          foreach ($a[0] as &$r) {
182              $a[] = array(&$r['name'], &$r['type']);
183          }
184          unset($a[0]);
185   
186          $len = count($a) + 1;
187          for ($i = 1; $i < $len; ++$i) {
188              foreach ($a[$i] as &$r) {
189                  $s = $r; // $r is a ref, $s a copy
190                  if (is_array($s)) {
191                      $a[$len++] = &$r;
192                  } else {
193                      $r = static::filterString($s, $normalization_form, $leading_combining);
194                  }
195              }
196   
197              unset($a[$i]);
198          }
199      }
200   
201      public static function filterString($s, $normalization_form = 4 /* n::NFC */, $leading_combining = '◌')
202      {
203          if (false !== strpos($s, "\r")) {
204              // Workaround https://bugs.php.net/65732
205              $s = str_replace("\r\n", "\n", $s);
206              $s = strtr($s, "\r", "\n");
207          }
208   
209          if (preg_match('/[\x80-\xFF]/', $s)) {
210              if (n::isNormalized($s, $normalization_form)) {
211                  $n = '-';
212              } else {
213                  $n = n::normalize($s, $normalization_form);
214                  if (isset($n[0])) {
215                      $s = $n;
216                  } else {
217                      $s = u::utf8_encode($s);
218                  }
219              }
220   
221              if ($s[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $s)) {
222                  // Prevent leading combining chars
223                  // for NFC-safe concatenations.
224                  $s = $leading_combining.$s;
225              }
226          }
227   
228          return $s;
229      }
230  }
231