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

helper.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 4.81 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\routing;
015   
016  use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
017  use Symfony\Component\Routing\RequestContext;
018   
019  /**
020  * Controller helper class, contains methods that do things for controllers
021  */
022  class helper
023  {
024      /**
025       * config object
026       * @var \phpbb\config\config
027       */
028      protected $config;
029   
030      /**
031       * phpBB router
032       * @var \phpbb\routing\router
033       */
034      protected $router;
035   
036      /**
037       * @var \phpbb\symfony_request
038       */
039      protected $symfony_request;
040   
041      /**
042       * @var \phpbb\request\request_interface
043       */
044      protected $request;
045   
046      /**
047       * @var \phpbb\filesystem The filesystem object
048       */
049      protected $filesystem;
050   
051      /**
052       * phpBB root path
053       * @var string
054       */
055      protected $phpbb_root_path;
056   
057      /**
058       * PHP file extension
059       * @var string
060       */
061      protected $php_ext;
062   
063      /**
064       * Constructor
065       *
066       * @param \phpbb\config\config $config Config object
067       * @param \phpbb\routing\router $router phpBB router
068       * @param \phpbb\symfony_request $symfony_request Symfony Request object
069       * @param \phpbb\request\request_interface $request phpBB request object
070       * @param \phpbb\filesystem\filesystem $filesystem The filesystem object
071       * @param string $phpbb_root_path phpBB root path
072       * @param string $php_ext PHP file extension
073       */
074      public function __construct(\phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem\filesystem $filesystem, $phpbb_root_path, $php_ext)
075      {
076          $this->config = $config;
077          $this->router = $router;
078          $this->symfony_request = $symfony_request;
079          $this->request = $request;
080          $this->filesystem = $filesystem;
081          $this->phpbb_root_path = $phpbb_root_path;
082          $this->php_ext = $php_ext;
083      }
084   
085      /**
086       * Generate a URL to a route
087       *
088       * @param string    $route        Name of the route to travel
089       * @param array    $params        String or array of additional url parameters
090       * @param bool    $is_amp        Is url using &amp; (true) or & (false)
091       * @param string|bool        $session_id    Possibility to use a custom session id instead of the global one
092       * @param bool|string        $reference_type The type of reference to be generated (one of the constants)
093       * @return string The URL already passed through append_sid()
094       */
095      public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)
096      {
097          $anchor = '';
098          if (isset($params['#']))
099          {
100              $anchor = '#' . $params['#'];
101              unset($params['#']);
102          }
103   
104          $context = new RequestContext();
105          $context->fromRequest($this->symfony_request);
106   
107          if ($this->config['force_server_vars'])
108          {
109              $context->setHost($this->config['server_name']);
110              $context->setScheme(substr($this->config['server_protocol'], 0, -3));
111              $context->setHttpPort($this->config['server_port']);
112              $context->setHttpsPort($this->config['server_port']);
113              $context->setBaseUrl(rtrim($this->config['script_path'], '/'));
114          }
115   
116          $script_name = $this->symfony_request->getScriptName();
117          $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name);
118   
119          $base_url = $context->getBaseUrl();
120   
121          // Append page name if base URL does not contain it
122          if (!empty($page_name) && strpos($base_url, '/' . $page_name) === false)
123          {
124              $base_url .= '/' . $page_name;
125          }
126   
127          // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it.
128          $base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url);
129   
130          // We need to update the base url to move to the directory of the app.php file if the current script is not app.php
131          if ($page_name !== 'app.php' && !$this->config['force_server_vars'])
132          {
133              if (empty($this->config['enable_mod_rewrite']))
134              {
135                  $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url);
136              }
137              else
138              {
139                  $base_url .= preg_replace(get_preg_expression('path_remove_dot_trailing_slash'), '$2', $this->phpbb_root_path);
140              }
141          }
142   
143          $base_url = $this->request->escape($this->filesystem->clean_path($base_url), true);
144   
145          $context->setBaseUrl($base_url);
146   
147          $this->router->setContext($context);
148          $route_url = $this->router->generate($route, $params, $reference_type);
149   
150          if ($is_amp)
151          {
152              $route_url = str_replace(array('&amp;', '&'), array('&', '&amp;'), $route_url);
153          }
154   
155          if ($reference_type === UrlGeneratorInterface::RELATIVE_PATH && empty($this->config['enable_mod_rewrite']))
156          {
157              $route_url = 'app.' . $this->php_ext . '/' . $route_url;
158          }
159   
160          return append_sid($route_url . $anchor, false, $is_amp, $session_id, true);
161      }
162  }
163