Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

MetadataBag.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.57 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;
013   
014  use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
015   
016  /**
017   * Metadata container.
018   *
019   * Adds metadata to the session.
020   *
021   * @author Drak <drak@zikula.org>
022   */
023  class MetadataBag implements SessionBagInterface
024  {
025      const CREATED = 'c';
026      const UPDATED = 'u';
027      const LIFETIME = 'l';
028   
029      /**
030       * @var string
031       */
032      private $name = '__metadata';
033   
034      /**
035       * @var string
036       */
037      private $storageKey;
038   
039      /**
040       * @var array
041       */
042      protected $meta = [self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0];
043   
044      /**
045       * Unix timestamp.
046       *
047       * @var int
048       */
049      private $lastUsed;
050   
051      /**
052       * @var int
053       */
054      private $updateThreshold;
055   
056      /**
057       * @param string $storageKey      The key used to store bag in the session
058       * @param int    $updateThreshold The time to wait between two UPDATED updates
059       */
060      public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0)
061      {
062          $this->storageKey = $storageKey;
063          $this->updateThreshold = $updateThreshold;
064      }
065   
066      /**
067       * {@inheritdoc}
068       */
069      public function initialize(array &$array)
070      {
071          $this->meta = &$array;
072   
073          if (isset($array[self::CREATED])) {
074              $this->lastUsed = $this->meta[self::UPDATED];
075   
076              $timeStamp = time();
077              if ($timeStamp - $array[self::UPDATED] >= $this->updateThreshold) {
078                  $this->meta[self::UPDATED] = $timeStamp;
079              }
080          } else {
081              $this->stampCreated();
082          }
083      }
084   
085      /**
086       * Gets the lifetime that the session cookie was set with.
087       *
088       * @return int
089       */
090      public function getLifetime()
091      {
092          return $this->meta[self::LIFETIME];
093      }
094   
095      /**
096       * Stamps a new session's metadata.
097       *
098       * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value
099       *                      will leave the system settings unchanged, 0 sets the cookie
100       *                      to expire with browser session. Time is in seconds, and is
101       *                      not a Unix timestamp.
102       */
103      public function stampNew($lifetime = null)
104      {
105          $this->stampCreated($lifetime);
106      }
107   
108      /**
109       * {@inheritdoc}
110       */
111      public function getStorageKey()
112      {
113          return $this->storageKey;
114      }
115   
116      /**
117       * Gets the created timestamp metadata.
118       *
119       * @return int Unix timestamp
120       */
121      public function getCreated()
122      {
123          return $this->meta[self::CREATED];
124      }
125   
126      /**
127       * Gets the last used metadata.
128       *
129       * @return int Unix timestamp
130       */
131      public function getLastUsed()
132      {
133          return $this->lastUsed;
134      }
135   
136      /**
137       * {@inheritdoc}
138       */
139      public function clear()
140      {
141          // nothing to do
142      }
143   
144      /**
145       * {@inheritdoc}
146       */
147      public function getName()
148      {
149          return $this->name;
150      }
151   
152      /**
153       * Sets name.
154       *
155       * @param string $name
156       */
157      public function setName($name)
158      {
159          $this->name = $name;
160      }
161   
162      private function stampCreated($lifetime = null)
163      {
164          $timeStamp = time();
165          $this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
166          $this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime;
167      }
168  }
169