Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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

ini.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 3.75 KiB


 001  <?php
 002  /**
 003  *
 004  * This file is part of the phpBB Forum Software package.
 005  *
 006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007  * @license GNU General Public License, version 2 (GPL-2.0)
 008  *
 009  * For full copyright and license information, please see
 010  * the docs/CREDITS.txt file.
 011  *
 012  */
 013   
 014  namespace phpbb\php;
 015   
 016  /**
 017  * Wrapper class for ini_get function.
 018  *
 019  * Provides easier handling of the different interpretations of ini values.
 020  */
 021  class ini
 022  {
 023      /**
 024      * Simple wrapper for ini_get()
 025      * See http://php.net/manual/en/function.ini-get.php
 026      *
 027      * @param string $varname    The configuration option name.
 028      * @return bool|string        False if configuration option does not exist,
 029      *                            the configuration option value (string) otherwise.
 030      */
 031      public function get($varname)
 032      {
 033          return ini_get($varname);
 034      }
 035   
 036      /**
 037      * Gets the configuration option value as a trimmed string.
 038      *
 039      * @param string $varname    The configuration option name.
 040      * @return bool|string        False if configuration option does not exist,
 041      *                            the configuration option value (string) otherwise.
 042      */
 043      public function get_string($varname)
 044      {
 045          $value = $this->get($varname);
 046   
 047          if ($value === false)
 048          {
 049              return false;
 050          }
 051   
 052          return trim($value);
 053      }
 054   
 055      /**
 056      * Gets configuration option value as a boolean.
 057      * Interprets the string value 'off' as false.
 058      *
 059      * @param string $varname    The configuration option name.
 060      * @return bool                False if configuration option does not exist.
 061      *                            False if configuration option is disabled.
 062      *                            True otherwise.
 063      */
 064      public function get_bool($varname)
 065      {
 066          $value = $this->get_string($varname);
 067   
 068          if (empty($value) || strtolower($value) == 'off')
 069          {
 070              return false;
 071          }
 072   
 073          return true;
 074      }
 075   
 076      /**
 077      * Gets configuration option value as an integer.
 078      *
 079      * @param string $varname    The configuration option name.
 080      * @return bool|int            False if configuration option does not exist,
 081      *                            false if configuration option value is not numeric,
 082      *                            the configuration option value (integer) otherwise.
 083      */
 084      public function get_int($varname)
 085      {
 086          $value = $this->get_string($varname);
 087   
 088          if (!is_numeric($value))
 089          {
 090              return false;
 091          }
 092   
 093          return (int) $value;
 094      }
 095   
 096      /**
 097      * Gets configuration option value as a float.
 098      *
 099      * @param string $varname    The configuration option name.
 100      * @return bool|float        False if configuration option does not exist,
 101      *                            false if configuration option value is not numeric,
 102      *                            the configuration option value (float) otherwise.
 103      */
 104      public function get_float($varname)
 105      {
 106          $value = $this->get_string($varname);
 107   
 108          if (!is_numeric($value))
 109          {
 110              return false;
 111          }
 112   
 113          return (float) $value;
 114      }
 115   
 116      /**
 117      * Gets configuration option value in bytes.
 118      * Converts strings like '128M' to bytes (integer or float).
 119      *
 120      * @param string $varname    The configuration option name.
 121      * @return bool|int|float    False if configuration option does not exist,
 122      *                            false if configuration option value is not well-formed,
 123      *                            the configuration option value otherwise.
 124      */
 125      public function get_bytes($varname)
 126      {
 127          $value = $this->get_string($varname);
 128   
 129          if ($value === false)
 130          {
 131              return false;
 132          }
 133   
 134          if (is_numeric($value))
 135          {
 136              // Already in bytes.
 137              return phpbb_to_numeric($value);
 138          }
 139          else if (strlen($value) < 2)
 140          {
 141              // Single character.
 142              return false;
 143          }
 144          else if (strlen($value) < 3 && $value[0] === '-')
 145          {
 146              // Two characters but the first one is a minus.
 147              return false;
 148          }
 149   
 150          $value_lower = strtolower($value);
 151          $value_numeric = phpbb_to_numeric($value);
 152   
 153          switch ($value_lower[strlen($value_lower) - 1])
 154          {
 155              case 'g':
 156                  $value_numeric *= 1024;
 157              case 'm':
 158                  $value_numeric *= 1024;
 159              case 'k':
 160                  $value_numeric *= 1024;
 161              break;
 162   
 163              default:
 164                  // It's not already in bytes (and thus numeric)
 165                  // and does not carry a unit.
 166                  return false;
 167          }
 168   
 169          return $value_numeric;
 170      }
 171  }
 172