Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

ImageReader.php

Zuletzt modifiziert: 01.05.2026, 11:26 - Dateigröße: 2.66 KiB


 001  <?php
 002   
 003  /**
 004   * fast-image-size image reader
 005   * @package fast-image-size
 006   * @copyright (c) Marc Alexander <admin@m-a-styles.de>
 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 FastImageSize;
 013   
 014  class ImageReader
 015  {
 016      /** @var string Data retrieved from remote */
 017      protected $data = '';
 018   
 019      /** @var array Stream context options for retrieving remote images */
 020      protected $streamContextOptions = [
 021          'http' => [
 022              'timeout' => 5.0,
 023              'ignore_errors' => true,
 024          ],
 025      ];
 026   
 027      /**
 028       * Get image from specified path/source
 029       *
 030       * @param string $filename Path to image
 031       * @param int $offset Offset at which reading of the image should start
 032       * @param int $length Maximum length that should be read, must be greater than 0
 033       * @param bool $forceLength True if the length needs to be the specified
 034       *            length, false if not. Default: true
 035       *
 036       * @return false|string Image data or false if result was empty
 037       */
 038      public function getImage(string $filename, int $offset, int $length, bool $forceLength = true)
 039      {
 040          if (empty($this->data))
 041          {
 042              $this->data = $this->retrieveImageData($filename, $offset, $length) ?: '';
 043          }
 044   
 045          // Force length to expected one. Return false if data length
 046          // is smaller than expected length
 047          if ($forceLength === true)
 048          {
 049              return (strlen($this->data) < $length) ? false : substr($this->data, $offset, $length) ;
 050          }
 051   
 052          return empty($this->data) ? false : $this->data;
 053      }
 054   
 055      /**
 056       * Retrieve image data from specified path/source
 057       *
 058       * @param string $filename Path to image
 059       * @param int $offset Offset at which reading of the image should start
 060       * @param int $max_length Maximum length that should be read
 061       *
 062       * @return false|string Image data or false if result was empty
 063       */
 064      protected function retrieveImageData(string $filename, int $offset, int $max_length)
 065      {
 066          $context = $this->create_stream_context();
 067   
 068          // Use @ to suppress warnings from connection/DNS/SSL failures
 069          return @file_get_contents($filename, false, $context, $offset, $max_length);
 070      }
 071   
 072      /**
 073       * Set stream context options for retrieving remote images
 074       *
 075       * @param array $options Stream context options
 076       */
 077      public function setStreamContextOptions(array $options)
 078      {
 079          $this->streamContextOptions = $options;
 080      }
 081   
 082      /**
 083       * Create stream context for retrieving remote images
 084       *
 085       * @return resource Stream context
 086       */
 087      protected function create_stream_context()
 088      {
 089          return stream_context_create($this->streamContextOptions);
 090      }
 091   
 092      /**
 093       * Reset image data
 094       */
 095      public function reset(): void
 096      {
 097          $this->data = '';
 098      }
 099  }
 100