Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

obtain_server_data.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 5.46 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\install\module\obtain_data\task;
015   
016  use phpbb\install\exception\user_interaction_required_exception;
017   
018  /**
019   * This class requests and saves some information about the server
020   */
021  class obtain_server_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
022  {
023      /**
024       * @var \phpbb\install\helper\config
025       */
026      protected $install_config;
027   
028      /**
029       * @var \phpbb\install\helper\iohandler\iohandler_interface
030       */
031      protected $io_handler;
032   
033      /**
034       * Constructor
035       *
036       * @param \phpbb\install\helper\config                            $config        Installer's config
037       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler    Installer's input-output handler
038       */
039      public function __construct(\phpbb\install\helper\config $config,
040                                  \phpbb\install\helper\iohandler\iohandler_interface $iohandler)
041      {
042          $this->install_config    = $config;
043          $this->io_handler        = $iohandler;
044   
045          parent::__construct(true);
046      }
047      /**
048       * {@inheritdoc}
049       */
050      public function run()
051      {
052          $cookie_secure = $this->io_handler->is_secure();
053          $server_protocol = ($this->io_handler->is_secure()) ? 'https://' : 'http://';
054          $server_port = $this->io_handler->get_server_variable('SERVER_PORT', 0);
055   
056          // HTTP_HOST is having the correct browser url in most cases...
057          $server_name = strtolower(html_entity_decode($this->io_handler->get_header_variable(
058              'Host',
059              $this->io_handler->get_server_variable('SERVER_NAME')
060          ), ENT_COMPAT));
061   
062          // HTTP HOST can carry a port number...
063          if (strpos($server_name, ':') !== false)
064          {
065              $server_name = substr($server_name, 0, strpos($server_name, ':'));
066          }
067   
068          $script_path = html_entity_decode($this->io_handler->get_server_variable('REQUEST_URI'), ENT_COMPAT);
069   
070          if (!$script_path)
071          {
072              $script_path = html_entity_decode($this->io_handler->get_server_variable('PHP_SELF'), ENT_COMPAT);
073          }
074   
075          $script_path = str_replace(array('\\', '//'), '/', $script_path);
076          $script_path = trim(dirname(dirname(dirname($script_path)))); // Because we are in install/app.php/route_name
077   
078          // Server data
079          $cookie_secure        = $this->io_handler->get_input('cookie_secure', $cookie_secure);
080          $server_protocol    = $this->io_handler->get_input('server_protocol', $server_protocol);
081          $force_server_vars    = $this->io_handler->get_input('force_server_vars', 0);
082          $server_name        = $this->io_handler->get_input('server_name', $server_name, true);
083          $server_port        = $this->io_handler->get_input('server_port', $server_port);
084          $script_path        = $this->io_handler->get_input('script_path', $script_path, true);
085   
086          // Clean up script path
087          if ($script_path !== '/')
088          {
089              // Adjust destination path (no trailing slash)
090              if (substr($script_path, -1) === '/')
091              {
092                  $script_path = substr($script_path, 0, -1);
093              }
094   
095              $script_path = str_replace(array('../', './'), '', $script_path);
096   
097              if ($script_path[0] !== '/')
098              {
099                  $script_path = '/' . $script_path;
100              }
101          }
102   
103          // Check if data is sent
104          if ($this->io_handler->get_input('submit_server', false))
105          {
106              $this->install_config->set('cookie_secure', $cookie_secure);
107              $this->install_config->set('server_protocol', $server_protocol);
108              $this->install_config->set('force_server_vars', $force_server_vars);
109              $this->install_config->set('server_name', $server_name);
110              $this->install_config->set('server_port', $server_port);
111              $this->install_config->set('script_path', $script_path);
112          }
113          else
114          {
115              // Render form
116              $server_form = array(
117                  'cookie_secure' => array(
118                      'label'            => 'COOKIE_SECURE',
119                      'description'    => 'COOKIE_SECURE_EXPLAIN',
120                      'type'            => 'radio',
121                      'options'        => array(
122                          array(
123                              'value'        => 0,
124                              'label'        => 'NO',
125                              'selected'    => (!$cookie_secure),
126                          ),
127                          array(
128                              'value'        => 1,
129                              'label'        => 'YES',
130                              'selected'    => ($cookie_secure),
131                          ),
132                      ),
133                  ),
134                  'force_server_vars' => array(
135                      'label'            => 'FORCE_SERVER_VARS',
136                      'description'    => 'FORCE_SERVER_VARS_EXPLAIN',
137                      'type'            => 'radio',
138                      'options'        => array(
139                          array(
140                              'value'        => 0,
141                              'label'        => 'NO',
142                              'selected'    => true,
143                          ),
144                          array(
145                              'value'        => 1,
146                              'label'        => 'YES',
147                              'selected'    => false,
148                          ),
149                      ),
150                  ),
151                  'server_protocol' => array(
152                      'label'            => 'SERVER_PROTOCOL',
153                      'description'    => 'SERVER_PROTOCOL_EXPLAIN',
154                      'type'            => 'text',
155                      'default'        => $server_protocol,
156                  ),
157                  'server_name' => array(
158                      'label'            => 'SERVER_NAME',
159                      'description'    => 'SERVER_NAME_EXPLAIN',
160                      'type'            => 'text',
161                      'default'        => $server_name,
162                  ),
163                  'server_port' => array(
164                      'label'            => 'SERVER_PORT',
165                      'description'    => 'SERVER_PORT_EXPLAIN',
166                      'type'            => 'text',
167                      'default'        => $server_port,
168                  ),
169                  'script_path' => array(
170                      'label'            => 'SCRIPT_PATH',
171                      'description'    => 'SCRIPT_PATH_EXPLAIN',
172                      'type'            => 'text',
173                      'default'        => $script_path,
174                  ),
175                  'submit_server' => array(
176                      'label'    => 'SUBMIT',
177                      'type'    => 'submit',
178                  )
179              );
180   
181              $this->io_handler->add_user_form_group('SERVER_CONFIG', $server_form);
182   
183              throw new user_interaction_required_exception();
184          }
185      }
186   
187      /**
188       * {@inheritdoc}
189       */
190      static public function get_step_count()
191      {
192          return 0;
193      }
194   
195      /**
196       * {@inheritdoc}
197       */
198      public function get_task_lang_name()
199      {
200          return '';
201      }
202  }
203