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

ApacheUrlMatcher.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 3.36 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\Routing\Matcher;
013   
014  use Symfony\Component\Routing\Exception\MethodNotAllowedException;
015   
016  /**
017   * ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper).
018   *
019   * @author Fabien Potencier <fabien@symfony.com>
020   * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
021   */
022  class ApacheUrlMatcher extends UrlMatcher
023  {
024      /**
025       * Tries to match a URL based on Apache mod_rewrite matching.
026       *
027       * Returns false if no route matches the URL.
028       *
029       * @param string $pathinfo The pathinfo to be parsed
030       *
031       * @return array An array of parameters
032       *
033       * @throws MethodNotAllowedException If the current method is not allowed
034       */
035      public function match($pathinfo)
036      {
037          $parameters = array();
038          $defaults = array();
039          $allow = array();
040          $route = null;
041   
042          foreach ($this->denormalizeValues($_SERVER) as $key => $value) {
043              $name = $key;
044   
045              // skip non-routing variables
046              // this improves performance when $_SERVER contains many usual
047              // variables like HTTP_*, DOCUMENT_ROOT, REQUEST_URI, ...
048              if (false === strpos($name, '_ROUTING_')) {
049                  continue;
050              }
051   
052              while (0 === strpos($name, 'REDIRECT_')) {
053                  $name = substr($name, 9);
054              }
055   
056              // expect _ROUTING_<type>_<name>
057              // or _ROUTING_<type>
058   
059              if (0 !== strpos($name, '_ROUTING_')) {
060                  continue;
061              }
062              if (false !== $pos = strpos($name, '_', 9)) {
063                  $type = substr($name, 9, $pos-9);
064                  $name = substr($name, $pos+1);
065              } else {
066                  $type = substr($name, 9);
067              }
068   
069              if ('param' === $type) {
070                  if ('' !== $value) {
071                      $parameters[$name] = $value;
072                  }
073              } elseif ('default' === $type) {
074                  $defaults[$name] = $value;
075              } elseif ('route' === $type) {
076                  $route = $value;
077              } elseif ('allow' === $type) {
078                  $allow[] = $name;
079              }
080   
081              unset($_SERVER[$key]);
082          }
083   
084          if (null !== $route) {
085              $parameters['_route'] = $route;
086   
087              return $this->mergeDefaults($parameters, $defaults);
088          } elseif (0 < count($allow)) {
089              throw new MethodNotAllowedException($allow);
090          } else {
091              return parent::match($pathinfo);
092          }
093      }
094   
095      /**
096       * Denormalizes an array of values.
097       *
098       * @param string[] $values
099       *
100       * @return array
101       */
102      private function denormalizeValues(array $values)
103      {
104          $normalizedValues = array();
105          foreach ($values as $key => $value) {
106              if (preg_match('~^(.*)\[(\d+)\]$~', $key, $matches)) {
107                  if (!isset($normalizedValues[$matches[1]])) {
108                      $normalizedValues[$matches[1]] = array();
109                  }
110                  $normalizedValues[$matches[1]][(int) $matches[2]] = $value;
111              } else {
112                  $normalizedValues[$key] = $value;
113              }
114          }
115   
116          return $normalizedValues;
117      }
118  }
119