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

Cookie.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 4.93 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;
013   
014  /**
015   * Represents a cookie
016   *
017   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
018   *
019   * @api
020   */
021  class Cookie
022  {
023      protected $name;
024      protected $value;
025      protected $domain;
026      protected $expire;
027      protected $path;
028      protected $secure;
029      protected $httpOnly;
030   
031      /**
032       * Constructor.
033       *
034       * @param string                   $name     The name of the cookie
035       * @param string                   $value    The value of the cookie
036       * @param int|string|\DateTime     $expire   The time the cookie expires
037       * @param string                   $path     The path on the server in which the cookie will be available on
038       * @param string                   $domain   The domain that the cookie is available to
039       * @param bool                     $secure   Whether the cookie should only be transmitted over a secure HTTPS connection from the client
040       * @param bool                     $httpOnly Whether the cookie will be made accessible only through the HTTP protocol
041       *
042       * @throws \InvalidArgumentException
043       *
044       * @api
045       */
046      public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true)
047      {
048          // from PHP source code
049          if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
050              throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
051          }
052   
053          if (empty($name)) {
054              throw new \InvalidArgumentException('The cookie name cannot be empty.');
055          }
056   
057          // convert expiration time to a Unix timestamp
058          if ($expire instanceof \DateTime) {
059              $expire = $expire->format('U');
060          } elseif (!is_numeric($expire)) {
061              $expire = strtotime($expire);
062   
063              if (false === $expire || -1 === $expire) {
064                  throw new \InvalidArgumentException('The cookie expiration time is not valid.');
065              }
066          }
067   
068          $this->name = $name;
069          $this->value = $value;
070          $this->domain = $domain;
071          $this->expire = $expire;
072          $this->path = empty($path) ? '/' : $path;
073          $this->secure = (bool) $secure;
074          $this->httpOnly = (bool) $httpOnly;
075      }
076   
077      /**
078       * Returns the cookie as a string.
079       *
080       * @return string The cookie
081       */
082      public function __toString()
083      {
084          $str = urlencode($this->getName()).'=';
085   
086          if ('' === (string) $this->getValue()) {
087              $str .= 'deleted; expires='.gmdate("D, d-M-Y H:i:s T", time() - 31536001);
088          } else {
089              $str .= urlencode($this->getValue());
090   
091              if ($this->getExpiresTime() !== 0) {
092                  $str .= '; expires='.gmdate("D, d-M-Y H:i:s T", $this->getExpiresTime());
093              }
094          }
095   
096          if ($this->path) {
097              $str .= '; path='.$this->path;
098          }
099   
100          if ($this->getDomain()) {
101              $str .= '; domain='.$this->getDomain();
102          }
103   
104          if (true === $this->isSecure()) {
105              $str .= '; secure';
106          }
107   
108          if (true === $this->isHttpOnly()) {
109              $str .= '; httponly';
110          }
111   
112          return $str;
113      }
114   
115      /**
116       * Gets the name of the cookie.
117       *
118       * @return string
119       *
120       * @api
121       */
122      public function getName()
123      {
124          return $this->name;
125      }
126   
127      /**
128       * Gets the value of the cookie.
129       *
130       * @return string
131       *
132       * @api
133       */
134      public function getValue()
135      {
136          return $this->value;
137      }
138   
139      /**
140       * Gets the domain that the cookie is available to.
141       *
142       * @return string
143       *
144       * @api
145       */
146      public function getDomain()
147      {
148          return $this->domain;
149      }
150   
151      /**
152       * Gets the time the cookie expires.
153       *
154       * @return int
155       *
156       * @api
157       */
158      public function getExpiresTime()
159      {
160          return $this->expire;
161      }
162   
163      /**
164       * Gets the path on the server in which the cookie will be available on.
165       *
166       * @return string
167       *
168       * @api
169       */
170      public function getPath()
171      {
172          return $this->path;
173      }
174   
175      /**
176       * Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
177       *
178       * @return bool
179       *
180       * @api
181       */
182      public function isSecure()
183      {
184          return $this->secure;
185      }
186   
187      /**
188       * Checks whether the cookie will be made accessible only through the HTTP protocol.
189       *
190       * @return bool
191       *
192       * @api
193       */
194      public function isHttpOnly()
195      {
196          return $this->httpOnly;
197      }
198   
199      /**
200       * Whether this cookie is about to be cleared
201       *
202       * @return bool
203       *
204       * @api
205       */
206      public function isCleared()
207      {
208          return $this->expire < time();
209      }
210  }
211