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

install.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 6.05 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\console\command\install;
015   
016  use phpbb\install\exception\installer_exception;
017  use phpbb\install\helper\install_helper;
018  use phpbb\install\helper\iohandler\cli_iohandler;
019  use phpbb\install\helper\iohandler\factory;
020  use phpbb\install\installer;
021  use phpbb\install\installer_configuration;
022  use phpbb\language\language;
023  use Symfony\Component\Config\Definition\Exception\Exception;
024  use Symfony\Component\Config\Definition\Processor;
025  use Symfony\Component\Console\Input\InputArgument;
026  use Symfony\Component\Console\Input\InputInterface;
027  use Symfony\Component\Console\Output\OutputInterface;
028  use Symfony\Component\Console\Style\SymfonyStyle;
029  use Symfony\Component\Yaml\Exception\ParseException;
030  use Symfony\Component\Yaml\Yaml;
031   
032  class install extends \phpbb\console\command\command
033  {
034      /**
035       * @var factory
036       */
037      protected $iohandler_factory;
038   
039      /**
040       * @var installer
041       */
042      protected $installer;
043   
044      /**
045       * @var install_helper
046       */
047      protected $install_helper;
048   
049      /**
050       * @var language
051       */
052      protected $language;
053   
054      /**
055       * Constructor
056       *
057       * @param language            $language
058       * @param factory            $factory
059       * @param installer            $installer
060       * @param install_helper    $install_helper
061       */
062      public function __construct(language $language, factory $factory, installer $installer, install_helper $install_helper)
063      {
064          $this->iohandler_factory = $factory;
065          $this->installer = $installer;
066          $this->language = $language;
067          $this->install_helper = $install_helper;
068   
069          parent::__construct(new \phpbb\user($language, 'datetime'));
070      }
071   
072      /**
073       * {@inheritdoc}
074       */
075      protected function configure()
076      {
077          $this
078              ->setName('install')
079              ->addArgument(
080                  'config-file',
081                  InputArgument::REQUIRED,
082                  $this->language->lang('CLI_CONFIG_FILE'))
083              ->setDescription($this->language->lang('CLI_INSTALL_BOARD'))
084          ;
085      }
086   
087      /**
088       * Executes the command install.
089       *
090       * Install the board
091       *
092       * @param InputInterface  $input  An InputInterface instance
093       * @param OutputInterface $output An OutputInterface instance
094       *
095       * @return null
096       */
097      protected function execute(InputInterface $input, OutputInterface $output)
098      {
099          $this->iohandler_factory->set_environment('cli');
100   
101          /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */
102          $iohandler = $this->iohandler_factory->get();
103          $style = new SymfonyStyle($input, $output);
104          $iohandler->set_style($style, $output);
105   
106          $this->installer->set_iohandler($iohandler);
107   
108          $config_file = $input->getArgument('config-file');
109   
110          if ($this->install_helper->is_phpbb_installed())
111          {
112              $iohandler->add_error_message('INSTALL_PHPBB_INSTALLED');
113   
114              return 1;
115          }
116   
117          if (!is_file($config_file))
118          {
119              $iohandler->add_error_message(array('MISSING_FILE', $config_file));
120   
121              return 1;
122          }
123   
124          try
125          {
126              $config = Yaml::parse(file_get_contents($config_file), true, false);
127          }
128          catch (ParseException $e)
129          {
130              $iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file));
131   
132              return 1;
133          }
134   
135          $processor = new Processor();
136          $configuration = new installer_configuration();
137   
138          try
139          {
140              $config = $processor->processConfiguration($configuration, $config);
141          }
142          catch (Exception $e)
143          {
144              $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
145   
146              return 1;
147          }
148   
149          $this->register_configuration($iohandler, $config);
150   
151          try
152          {
153              $this->installer->run();
154              return 0;
155          }
156          catch (installer_exception $e)
157          {
158              $iohandler->add_error_message($e->getMessage());
159              return 1;
160          }
161      }
162   
163      /**
164       * Register the configuration to simulate the forms.
165       *
166       * @param cli_iohandler $iohandler
167       * @param array $config
168       */
169      private function register_configuration(cli_iohandler $iohandler, $config)
170      {
171          $iohandler->set_input('admin_name', $config['admin']['name']);
172          $iohandler->set_input('admin_pass1', $config['admin']['password']);
173          $iohandler->set_input('admin_pass2', $config['admin']['password']);
174          $iohandler->set_input('board_email', $config['admin']['email']);
175          $iohandler->set_input('submit_admin', 'submit');
176   
177          $iohandler->set_input('default_lang', $config['board']['lang']);
178          $iohandler->set_input('board_name', $config['board']['name']);
179          $iohandler->set_input('board_description', $config['board']['description']);
180          $iohandler->set_input('submit_board', 'submit');
181   
182          $iohandler->set_input('dbms', $config['database']['dbms']);
183          $iohandler->set_input('dbhost', $config['database']['dbhost']);
184          $iohandler->set_input('dbport', $config['database']['dbport']);
185          $iohandler->set_input('dbuser', $config['database']['dbuser']);
186          $iohandler->set_input('dbpasswd', $config['database']['dbpasswd']);
187          $iohandler->set_input('dbname', $config['database']['dbname']);
188          $iohandler->set_input('table_prefix', $config['database']['table_prefix']);
189          $iohandler->set_input('submit_database', 'submit');
190   
191          $iohandler->set_input('email_enable', $config['email']['enabled']);
192          $iohandler->set_input('smtp_delivery', $config['email']['smtp_delivery']);
193          $iohandler->set_input('smtp_host', $config['email']['smtp_host']);
194          $iohandler->set_input('smtp_port', $config['email']['smtp_port']);
195          $iohandler->set_input('smtp_auth', $config['email']['smtp_auth']);
196          $iohandler->set_input('smtp_user', $config['email']['smtp_user']);
197          $iohandler->set_input('smtp_pass', $config['email']['smtp_pass']);
198          $iohandler->set_input('submit_email', 'submit');
199   
200          $iohandler->set_input('cookie_secure', $config['server']['cookie_secure']);
201          $iohandler->set_input('server_protocol', $config['server']['server_protocol']);
202          $iohandler->set_input('force_server_vars', $config['server']['force_server_vars']);
203          $iohandler->set_input('server_name', $config['server']['server_name']);
204          $iohandler->set_input('server_port', $config['server']['server_port']);
205          $iohandler->set_input('script_path', $config['server']['script_path']);
206          $iohandler->set_input('submit_server', 'submit');
207   
208          $iohandler->set_input('install-extensions', $config['extensions']);
209      }
210  }
211