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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
FragmentListener.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\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\HttpKernel\HttpKernelInterface;
020 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
021
022 /**
023 * Handles content fragments represented by special URIs.
024 *
025 * All URL paths starting with /_fragment are handled as
026 * content fragments by this listener.
027 *
028 * If throws an AccessDeniedHttpException exception if the request
029 * is not signed or if it is not an internal sub-request.
030 *
031 * @author Fabien Potencier <fabien@symfony.com>
032 */
033 class FragmentListener implements EventSubscriberInterface
034 {
035 private $signer;
036 private $fragmentPath;
037
038 /**
039 * Constructor.
040 *
041 * @param UriSigner $signer A UriSigner instance
042 * @param string $fragmentPath The path that triggers this listener
043 */
044 public function __construct(UriSigner $signer, $fragmentPath = '/_fragment')
045 {
046 $this->signer = $signer;
047 $this->fragmentPath = $fragmentPath;
048 }
049
050 /**
051 * Fixes request attributes when the path is '/_fragment'.
052 *
053 * @param GetResponseEvent $event A GetResponseEvent instance
054 *
055 * @throws AccessDeniedHttpException if the request does not come from a trusted IP.
056 */
057 public function onKernelRequest(GetResponseEvent $event)
058 {
059 $request = $event->getRequest();
060
061 if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) {
062 return;
063 }
064
065 if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
066 $this->validateRequest($request);
067 }
068
069 parse_str($request->query->get('_path', ''), $attributes);
070 $request->attributes->add($attributes);
071 $request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', array()), $attributes));
072 $request->query->remove('_path');
073 }
074
075 protected function validateRequest(Request $request)
076 {
077 // is the Request safe?
078 if (!$request->isMethodSafe()) {
079 throw new AccessDeniedHttpException();
080 }
081
082 // is the Request signed?
083 // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering)
084 if ($this->signer->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().(null !== ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''))) {
085 return;
086 }
087
088 throw new AccessDeniedHttpException();
089 }
090
091 /**
092 * @deprecated Deprecated since 2.3.19, to be removed in 3.0.
093 *
094 * @return string[]
095 */
096 protected function getLocalIpAddresses()
097 {
098 return array('127.0.0.1', 'fe80::1', '::1');
099 }
100
101 public static function getSubscribedEvents()
102 {
103 return array(
104 KernelEvents::REQUEST => array(array('onKernelRequest', 48)),
105 );
106 }
107 }
108