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