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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

FragmentListener.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.60 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\HttpKernel\EventListener;
013   
014  use Symfony\Component\HttpFoundation\Request;
015  use Symfony\Component\HttpKernel\Event\GetResponseEvent;
016  use Symfony\Component\HttpKernel\KernelEvents;
017  use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
018  use Symfony\Component\HttpKernel\UriSigner;
019  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
020   
021  /**
022   * Handles content fragments represented by special URIs.
023   *
024   * All URL paths starting with /_fragment are handled as
025   * content fragments by this listener.
026   *
027   * If throws an AccessDeniedHttpException exception if the request
028   * is not signed or if it is not an internal sub-request.
029   *
030   * @author Fabien Potencier <fabien@symfony.com>
031   */
032  class FragmentListener implements EventSubscriberInterface
033  {
034      private $signer;
035      private $fragmentPath;
036   
037      /**
038       * Constructor.
039       *
040       * @param UriSigner $signer       A UriSigner instance
041       * @param string    $fragmentPath The path that triggers this listener
042       */
043      public function __construct(UriSigner $signer, $fragmentPath = '/_fragment')
044      {
045          $this->signer = $signer;
046          $this->fragmentPath = $fragmentPath;
047      }
048   
049      /**
050       * Fixes request attributes when the path is '/_fragment'.
051       *
052       * @param GetResponseEvent $event A GetResponseEvent instance
053       *
054       * @throws AccessDeniedHttpException if the request does not come from a trusted IP.
055       */
056      public function onKernelRequest(GetResponseEvent $event)
057      {
058          $request = $event->getRequest();
059   
060          if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) {
061              return;
062          }
063   
064          if ($request->attributes->has('_controller')) {
065              // Is a sub-request: no need to parse _path but it should still be removed from query parameters as below.
066              $request->query->remove('_path');
067   
068              return;
069          }
070   
071          if ($event->isMasterRequest()) {
072              $this->validateRequest($request);
073          }
074   
075          parse_str($request->query->get('_path', ''), $attributes);
076          $request->attributes->add($attributes);
077          $request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', array()), $attributes));
078          $request->query->remove('_path');
079      }
080   
081      protected function validateRequest(Request $request)
082      {
083          // is the Request safe?
084          if (!$request->isMethodSafe()) {
085              throw new AccessDeniedHttpException();
086          }
087   
088          // is the Request signed?
089          // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering)
090          if ($this->signer->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().(null !== ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''))) {
091              return;
092          }
093   
094          throw new AccessDeniedHttpException();
095      }
096   
097      /**
098       * @deprecated since version 2.3.19, to be removed in 3.0.
099       *
100       * @return string[]
101       */
102      protected function getLocalIpAddresses()
103      {
104          @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3.19 and will be removed in 3.0.', E_USER_DEPRECATED);
105   
106          return array('127.0.0.1', 'fe80::1', '::1');
107      }
108   
109      public static function getSubscribedEvents()
110      {
111          return array(
112              KernelEvents::REQUEST => array(array('onKernelRequest', 48)),
113          );
114      }
115  }
116