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

AbstractSessionHandler.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 5.45 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of the Symfony package.
 005   *
 006   * (c) Fabien Potencier <fabien@symfony.com>
 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 Symfony\Component\HttpFoundation\Session\Storage\Handler;
 013   
 014  use Symfony\Component\HttpFoundation\Session\SessionUtils;
 015   
 016  /**
 017   * This abstract session handler provides a generic implementation
 018   * of the PHP 7.0 SessionUpdateTimestampHandlerInterface,
 019   * enabling strict and lazy session handling.
 020   *
 021   * @author Nicolas Grekas <p@tchwork.com>
 022   */
 023  abstract class AbstractSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
 024  {
 025      private $sessionName;
 026      private $prefetchId;
 027      private $prefetchData;
 028      private $newSessionId;
 029      private $igbinaryEmptyData;
 030   
 031      /**
 032       * @return bool
 033       */
 034      public function open($savePath, $sessionName)
 035      {
 036          $this->sessionName = $sessionName;
 037          if (!headers_sent() && !ini_get('session.cache_limiter') && '0' !== ini_get('session.cache_limiter')) {
 038              header(sprintf('Cache-Control: max-age=%d, private, must-revalidate', 60 * (int) ini_get('session.cache_expire')));
 039          }
 040   
 041          return true;
 042      }
 043   
 044      /**
 045       * @param string $sessionId
 046       *
 047       * @return string
 048       */
 049      abstract protected function doRead($sessionId);
 050   
 051      /**
 052       * @param string $sessionId
 053       * @param string $data
 054       *
 055       * @return bool
 056       */
 057      abstract protected function doWrite($sessionId, $data);
 058   
 059      /**
 060       * @param string $sessionId
 061       *
 062       * @return bool
 063       */
 064      abstract protected function doDestroy($sessionId);
 065   
 066      /**
 067       * @return bool
 068       */
 069      public function validateId($sessionId)
 070      {
 071          $this->prefetchData = $this->read($sessionId);
 072          $this->prefetchId = $sessionId;
 073   
 074          if (\PHP_VERSION_ID < 70317 || (70400 <= \PHP_VERSION_ID && \PHP_VERSION_ID < 70405)) {
 075              // work around https://bugs.php.net/79413
 076              foreach (debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
 077                  if (!isset($frame['class']) && isset($frame['function']) && \in_array($frame['function'], ['session_regenerate_id', 'session_create_id'], true)) {
 078                      return '' === $this->prefetchData;
 079                  }
 080              }
 081          }
 082   
 083          return '' !== $this->prefetchData;
 084      }
 085   
 086      /**
 087       * @return string
 088       */
 089      public function read($sessionId)
 090      {
 091          if (null !== $this->prefetchId) {
 092              $prefetchId = $this->prefetchId;
 093              $prefetchData = $this->prefetchData;
 094              $this->prefetchId = $this->prefetchData = null;
 095   
 096              if ($prefetchId === $sessionId || '' === $prefetchData) {
 097                  $this->newSessionId = '' === $prefetchData ? $sessionId : null;
 098   
 099                  return $prefetchData;
 100              }
 101          }
 102   
 103          $data = $this->doRead($sessionId);
 104          $this->newSessionId = '' === $data ? $sessionId : null;
 105          if (\PHP_VERSION_ID < 70000) {
 106              $this->prefetchData = $data;
 107          }
 108   
 109          return $data;
 110      }
 111   
 112      /**
 113       * @return bool
 114       */
 115      public function write($sessionId, $data)
 116      {
 117          if (\PHP_VERSION_ID < 70000 && $this->prefetchData) {
 118              $readData = $this->prefetchData;
 119              $this->prefetchData = null;
 120   
 121              if ($readData === $data) {
 122                  return $this->updateTimestamp($sessionId, $data);
 123              }
 124          }
 125          if (null === $this->igbinaryEmptyData) {
 126              // see https://github.com/igbinary/igbinary/issues/146
 127              $this->igbinaryEmptyData = \function_exists('igbinary_serialize') ? igbinary_serialize([]) : '';
 128          }
 129          if ('' === $data || $this->igbinaryEmptyData === $data) {
 130              return $this->destroy($sessionId);
 131          }
 132          $this->newSessionId = null;
 133   
 134          return $this->doWrite($sessionId, $data);
 135      }
 136   
 137      /**
 138       * @return bool
 139       */
 140      public function destroy($sessionId)
 141      {
 142          if (\PHP_VERSION_ID < 70000) {
 143              $this->prefetchData = null;
 144          }
 145          if (!headers_sent() && filter_var(ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN)) {
 146              if (!$this->sessionName) {
 147                  throw new \LogicException(sprintf('Session name cannot be empty, did you forget to call "parent::open()" in "%s"?.', static::class));
 148              }
 149              $cookie = SessionUtils::popSessionCookie($this->sessionName, $sessionId);
 150   
 151              /*
 152               * We send an invalidation Set-Cookie header (zero lifetime)
 153               * when either the session was started or a cookie with
 154               * the session name was sent by the client (in which case
 155               * we know it's invalid as a valid session cookie would've
 156               * started the session).
 157               */
 158              if (null === $cookie || isset($_COOKIE[$this->sessionName])) {
 159                  if (\PHP_VERSION_ID < 70300) {
 160                      setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), filter_var(ini_get('session.cookie_secure'), \FILTER_VALIDATE_BOOLEAN), filter_var(ini_get('session.cookie_httponly'), \FILTER_VALIDATE_BOOLEAN));
 161                  } else {
 162                      $params = session_get_cookie_params();
 163                      unset($params['lifetime']);
 164                      setcookie($this->sessionName, '', $params);
 165                  }
 166              }
 167          }
 168   
 169          return $this->newSessionId === $sessionId || $this->doDestroy($sessionId);
 170      }
 171  }
 172