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

byte_safe_strings.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 5.52 KiB


 001  <?php
 002  /**
 003   * Random_* Compatibility Library
 004   * for using the new PHP 7 random_* API in PHP 5 projects
 005   *
 006   * The MIT License (MIT)
 007   *
 008   * Copyright (c) 2015 Paragon Initiative Enterprises
 009   *
 010   * Permission is hereby granted, free of charge, to any person obtaining a copy
 011   * of this software and associated documentation files (the "Software"), to deal
 012   * in the Software without restriction, including without limitation the rights
 013   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 014   * copies of the Software, and to permit persons to whom the Software is
 015   * furnished to do so, subject to the following conditions:
 016   *
 017   * The above copyright notice and this permission notice shall be included in
 018   * all copies or substantial portions of the Software.
 019   *
 020   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 021   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 022   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 023   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 024   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 025   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 026   * SOFTWARE.
 027   */
 028   
 029  if (!function_exists('RandomCompat_strlen')) {
 030      if (
 031          defined('MB_OVERLOAD_STRING') &&
 032          ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
 033      ) {
 034          /**
 035           * strlen() implementation that isn't brittle to mbstring.func_overload
 036           *
 037           * This version uses mb_strlen() in '8bit' mode to treat strings as raw
 038           * binary rather than UTF-8, ISO-8859-1, etc
 039           *
 040           * @param string $binary_string
 041           *
 042           * @throws TypeError
 043           *
 044           * @return int
 045           */
 046          function RandomCompat_strlen($binary_string)
 047          {
 048              if (!is_string($binary_string)) {
 049                  throw new TypeError(
 050                      'RandomCompat_strlen() expects a string'
 051                  );
 052              }
 053   
 054              return mb_strlen($binary_string, '8bit');
 055          }
 056   
 057      } else {
 058          /**
 059           * strlen() implementation that isn't brittle to mbstring.func_overload
 060           *
 061           * This version just used the default strlen()
 062           *
 063           * @param string $binary_string
 064           *
 065           * @throws TypeError
 066           *
 067           * @return int
 068           */
 069          function RandomCompat_strlen($binary_string)
 070          {
 071              if (!is_string($binary_string)) {
 072                  throw new TypeError(
 073                      'RandomCompat_strlen() expects a string'
 074                  );
 075              }
 076              return strlen($binary_string);
 077          }
 078      }
 079  }
 080   
 081  if (!function_exists('RandomCompat_substr')) {
 082   
 083      if (
 084          defined('MB_OVERLOAD_STRING')
 085          &&
 086          ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
 087      ) {
 088          /**
 089           * substr() implementation that isn't brittle to mbstring.func_overload
 090           *
 091           * This version uses mb_substr() in '8bit' mode to treat strings as raw
 092           * binary rather than UTF-8, ISO-8859-1, etc
 093           *
 094           * @param string $binary_string
 095           * @param int $start
 096           * @param int $length (optional)
 097           *
 098           * @throws TypeError
 099           *
 100           * @return string
 101           */
 102          function RandomCompat_substr($binary_string, $start, $length = null)
 103          {
 104              if (!is_string($binary_string)) {
 105                  throw new TypeError(
 106                      'RandomCompat_substr(): First argument should be a string'
 107                  );
 108              }
 109   
 110              if (!is_int($start)) {
 111                  throw new TypeError(
 112                      'RandomCompat_substr(): Second argument should be an integer'
 113                  );
 114              }
 115   
 116              if ($length === null) {
 117                  /**
 118                   * mb_substr($str, 0, NULL, '8bit') returns an empty string on
 119                   * PHP 5.3, so we have to find the length ourselves.
 120                   */
 121                  $length = RandomCompat_strlen($length) - $start;
 122              } elseif (!is_int($length)) {
 123                  throw new TypeError(
 124                      'RandomCompat_substr(): Third argument should be an integer, or omitted'
 125                  );
 126              }
 127   
 128              return mb_substr($binary_string, $start, $length, '8bit');
 129          }
 130   
 131      } else {
 132   
 133          /**
 134           * substr() implementation that isn't brittle to mbstring.func_overload
 135           *
 136           * This version just uses the default substr()
 137           *
 138           * @param string $binary_string
 139           * @param int $start
 140           * @param int $length (optional)
 141           *
 142           * @throws TypeError
 143           *
 144           * @return string
 145           */
 146          function RandomCompat_substr($binary_string, $start, $length = null)
 147          {
 148              if (!is_string($binary_string)) {
 149                  throw new TypeError(
 150                      'RandomCompat_substr(): First argument should be a string'
 151                  );
 152              }
 153   
 154              if (!is_int($start)) {
 155                  throw new TypeError(
 156                      'RandomCompat_substr(): Second argument should be an integer'
 157                  );
 158              }
 159   
 160              if ($length !== null) {
 161                  if (!is_int($length)) {
 162                      throw new TypeError(
 163                          'RandomCompat_substr(): Third argument should be an integer, or omitted'
 164                      );
 165                  }
 166   
 167                  return substr($binary_string, $start, $length);
 168              }
 169   
 170              return substr($binary_string, $start);
 171          }
 172      }
 173  }
 174