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

random.php

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


001  <?php
002  /**
003   * Random_* Compatibility Library
004   * for using the new PHP 7 random_* API in PHP 5 projects
005   * 
006   * @version 1.4.1
007   * @released 2016-03-18
008   *
009   * The MIT License (MIT)
010   *
011   * Copyright (c) 2015 Paragon Initiative Enterprises
012   *
013   * Permission is hereby granted, free of charge, to any person obtaining a copy
014   * of this software and associated documentation files (the "Software"), to deal
015   * in the Software without restriction, including without limitation the rights
016   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
017   * copies of the Software, and to permit persons to whom the Software is
018   * furnished to do so, subject to the following conditions:
019   *
020   * The above copyright notice and this permission notice shall be included in
021   * all copies or substantial portions of the Software.
022   *
023   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
024   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
025   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
026   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
027   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
028   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
029   * SOFTWARE.
030   */
031   
032  if (!defined('PHP_VERSION_ID')) {
033      // This constant was introduced in PHP 5.2.7
034      $RandomCompatversion = explode('.', PHP_VERSION);
035      define(
036          'PHP_VERSION_ID',
037          $RandomCompatversion[0] * 10000
038          + $RandomCompatversion[1] * 100
039          + $RandomCompatversion[2]
040      );
041      $RandomCompatversion = null;
042  }
043   
044  if (PHP_VERSION_ID < 70000) {
045   
046      if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
047          define('RANDOM_COMPAT_READ_BUFFER', 8);
048      }
049   
050      $RandomCompatDIR = dirname(__FILE__);
051   
052      require_once $RandomCompatDIR.'/byte_safe_strings.php';
053      require_once $RandomCompatDIR.'/cast_to_int.php';
054      require_once $RandomCompatDIR.'/error_polyfill.php';
055   
056      if (!function_exists('random_bytes')) {
057          /**
058           * PHP 5.2.0 - 5.6.x way to implement random_bytes()
059           *
060           * We use conditional statements here to define the function in accordance
061           * to the operating environment. It's a micro-optimization.
062           *
063           * In order of preference:
064           *   1. Use libsodium if available.
065           *   2. fread() /dev/urandom if available (never on Windows)
066           *   3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
067           *   4. COM('CAPICOM.Utilities.1')->GetRandom()
068           *   5. openssl_random_pseudo_bytes() (absolute last resort)
069           *
070           * See ERRATA.md for our reasoning behind this particular order
071           */
072          if (extension_loaded('libsodium')) {
073              // See random_bytes_libsodium.php
074              if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) {
075                  require_once $RandomCompatDIR.'/random_bytes_libsodium.php';
076              } elseif (method_exists('Sodium', 'randombytes_buf')) {
077                  require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php';
078              }
079          }
080   
081          /**
082           * Reading directly from /dev/urandom:
083           */
084          if (DIRECTORY_SEPARATOR === '/') {
085              // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast
086              // way to exclude Windows.
087              $RandomCompatUrandom = true;
088              $RandomCompat_basedir = ini_get('open_basedir');
089   
090              if (!empty($RandomCompat_basedir)) {
091                  $RandomCompat_open_basedir = explode(
092                      PATH_SEPARATOR,
093                      strtolower($RandomCompat_basedir)
094                  );
095                  $RandomCompatUrandom = (array() !== array_intersect(
096                      array('/dev', '/dev/', '/dev/urandom'),
097                      $RandomCompat_open_basedir
098                  ));
099                  $RandomCompat_open_basedir = null;
100              }
101   
102              if (
103                  !function_exists('random_bytes')
104                  &&
105                  $RandomCompatUrandom
106                  &&
107                  @is_readable('/dev/urandom')
108              ) {
109                  // Error suppression on is_readable() in case of an open_basedir
110                  // or safe_mode failure. All we care about is whether or not we
111                  // can read it at this point. If the PHP environment is going to
112                  // panic over trying to see if the file can be read in the first
113                  // place, that is not helpful to us here.
114   
115                  // See random_bytes_dev_urandom.php
116                  require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php';
117              }
118              // Unset variables after use
119              $RandomCompat_basedir = null;
120          } else {
121              $RandomCompatUrandom = false;
122          }
123   
124          /**
125           * mcrypt_create_iv()
126           */
127          if (
128              !function_exists('random_bytes')
129              &&
130              PHP_VERSION_ID >= 50307
131              &&
132              extension_loaded('mcrypt')
133              &&
134              (DIRECTORY_SEPARATOR !== '/' || $RandomCompatUrandom)
135          ) {
136              // Prevent this code from hanging indefinitely on non-Windows;
137              // see https://bugs.php.net/bug.php?id=69833
138              if (
139                  DIRECTORY_SEPARATOR !== '/' || 
140                  (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613)
141              ) {
142                  // See random_bytes_mcrypt.php
143                  require_once $RandomCompatDIR.'/random_bytes_mcrypt.php';
144              }
145          }
146          $RandomCompatUrandom = null;
147   
148          if (
149              !function_exists('random_bytes')
150              &&
151              extension_loaded('com_dotnet')
152              &&
153              class_exists('COM')
154          ) {
155              $RandomCompat_disabled_classes = preg_split(
156                  '#\s*,\s*#',
157                  strtolower(ini_get('disable_classes'))
158              );
159   
160              if (!in_array('com', $RandomCompat_disabled_classes)) {
161                  try {
162                      $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
163                      if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
164                          // See random_bytes_com_dotnet.php
165                          require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php';
166                      }
167                  } catch (com_exception $e) {
168                      // Don't try to use it.
169                  }
170              }
171              $RandomCompat_disabled_classes = null;
172              $RandomCompatCOMtest = null;
173          }
174   
175          /**
176           * openssl_random_pseudo_bytes()
177           */
178          if (
179              (
180                  // Unix-like with PHP >= 5.3.0 or
181                  (
182                      DIRECTORY_SEPARATOR === '/'
183                      &&
184                      PHP_VERSION_ID >= 50300
185                  )
186                  ||
187                  // Windows with PHP >= 5.4.1
188                  PHP_VERSION_ID >= 50401
189              )
190              &&
191              !function_exists('random_bytes')
192              &&
193              extension_loaded('openssl')
194          ) {
195              // See random_bytes_openssl.php
196              require_once $RandomCompatDIR.'/random_bytes_openssl.php';
197          }
198   
199          /**
200           * throw new Exception
201           */
202          if (!function_exists('random_bytes')) {
203              /**
204               * We don't have any more options, so let's throw an exception right now
205               * and hope the developer won't let it fail silently.
206               */
207              function random_bytes($length)
208              {
209                  throw new Exception(
210                      'There is no suitable CSPRNG installed on your system'
211                  );
212              }
213          }
214      }
215   
216      if (!function_exists('random_int')) {
217          require_once $RandomCompatDIR.'/random_int.php';
218      }
219   
220      $RandomCompatDIR = null;
221  }
222