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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
MetadataBag.php
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 = array(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 * Constructor.
058 *
059 * @param string $storageKey The key used to store bag in the session
060 * @param int $updateThreshold The time to wait between two UPDATED updates
061 */
062 public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0)
063 {
064 $this->storageKey = $storageKey;
065 $this->updateThreshold = $updateThreshold;
066 }
067
068 /**
069 * {@inheritdoc}
070 */
071 public function initialize(array &$array)
072 {
073 $this->meta = &$array;
074
075 if (isset($array[self::CREATED])) {
076 $this->lastUsed = $this->meta[self::UPDATED];
077
078 $timeStamp = time();
079 if ($timeStamp - $array[self::UPDATED] >= $this->updateThreshold) {
080 $this->meta[self::UPDATED] = $timeStamp;
081 }
082 } else {
083 $this->stampCreated();
084 }
085 }
086
087 /**
088 * Gets the lifetime that the session cookie was set with.
089 *
090 * @return int
091 */
092 public function getLifetime()
093 {
094 return $this->meta[self::LIFETIME];
095 }
096
097 /**
098 * Stamps a new session's metadata.
099 *
100 * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value
101 * will leave the system settings unchanged, 0 sets the cookie
102 * to expire with browser session. Time is in seconds, and is
103 * not a Unix timestamp.
104 */
105 public function stampNew($lifetime = null)
106 {
107 $this->stampCreated($lifetime);
108 }
109
110 /**
111 * {@inheritdoc}
112 */
113 public function getStorageKey()
114 {
115 return $this->storageKey;
116 }
117
118 /**
119 * Gets the created timestamp metadata.
120 *
121 * @return int Unix timestamp
122 */
123 public function getCreated()
124 {
125 return $this->meta[self::CREATED];
126 }
127
128 /**
129 * Gets the last used metadata.
130 *
131 * @return int Unix timestamp
132 */
133 public function getLastUsed()
134 {
135 return $this->lastUsed;
136 }
137
138 /**
139 * {@inheritdoc}
140 */
141 public function clear()
142 {
143 // nothing to do
144 }
145
146 /**
147 * {@inheritdoc}
148 */
149 public function getName()
150 {
151 return $this->name;
152 }
153
154 /**
155 * Sets name.
156 *
157 * @param string $name
158 */
159 public function setName($name)
160 {
161 $this->name = $name;
162 }
163
164 private function stampCreated($lifetime = null)
165 {
166 $timeStamp = time();
167 $this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
168 $this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime;
169 }
170 }
171