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

set_up_database.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 3.63 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\install_database\task;
015   
016  /**
017   * Set up database for table generation
018   */
019  class set_up_database extends \phpbb\install\task_base
020  {
021      /**
022       * @var \phpbb\install\helper\config
023       */
024      protected $config;
025   
026      /**
027       * @var \phpbb\db\driver\driver_interface
028       */
029      protected $db;
030   
031      /**
032       * @var \phpbb\install\helper\database
033       */
034      protected $database_helper;
035   
036      /**
037       * @var \phpbb\filesystem\filesystem_interface
038       */
039      protected $filesystem;
040   
041      /**
042       * @var \phpbb\install\helper\iohandler\iohandler_interface
043       */
044      protected $iohandler;
045   
046      /**
047       * @var string
048       */
049      protected $schema_file_path;
050   
051      /**
052       * @var string
053       */
054      protected $phpbb_root_path;
055   
056      /**
057       * Constructor
058       *
059       * @param \phpbb\install\helper\config                            $config
060       * @param \phpbb\install\helper\database                        $db_helper
061       * @param \phpbb\filesystem\filesystem_interface                $filesystem
062       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler
063       * @param string                                                $phpbb_root_path
064       */
065      public function __construct(\phpbb\install\helper\config $config,
066                                  \phpbb\install\helper\database $db_helper,
067                                  \phpbb\filesystem\filesystem_interface $filesystem,
068                                  \phpbb\install\helper\iohandler\iohandler_interface $iohandler,
069                                  $phpbb_root_path)
070      {
071          $dbms = $db_helper->get_available_dbms($config->get('dbms'));
072          $dbms = $dbms[$config->get('dbms')]['DRIVER'];
073   
074          $this->db                = new $dbms();
075          $this->db->sql_connect(
076              $config->get('dbhost'),
077              $config->get('dbuser'),
078              $config->get('dbpasswd'),
079              $config->get('dbname'),
080              $config->get('dbport'),
081              false,
082              false
083          );
084   
085          $this->config            = $config;
086          $this->database_helper    = $db_helper;
087          $this->filesystem        = $filesystem;
088          $this->iohandler        = $iohandler;
089          $this->phpbb_root_path    = $phpbb_root_path;
090   
091          parent::__construct(false);
092      }
093   
094      /**
095       * {@inheritdoc}
096       */
097      public function check_requirements()
098      {
099          $dbms = $this->config->get('dbms');
100          $dbms_info = $this->database_helper->get_available_dbms($dbms);
101          $schema_name = $dbms_info[$dbms]['SCHEMA'];
102   
103          if ($dbms === 'mysql')
104          {
105              if (version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
106              {
107                  $schema_name .= '_41';
108              }
109              else
110              {
111                  $schema_name .= '_40';
112              }
113          }
114   
115          $this->schema_file_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql';
116   
117          return $this->filesystem->exists($this->schema_file_path);
118      }
119   
120      /**
121       * {@inheritdoc}
122       */
123      public function run()
124      {
125          $this->db->sql_return_on_error(true);
126   
127          $dbms = $this->config->get('dbms');
128          $dbms_info = $this->database_helper->get_available_dbms($dbms);
129          $delimiter = $dbms_info[$dbms]['DELIM'];
130          $table_prefix = $this->config->get('table_prefix');
131   
132          $sql_query = @file_get_contents($this->schema_file_path);
133          $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
134          $sql_query = $this->database_helper->remove_comments($sql_query);
135          $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter);
136   
137          foreach ($sql_query as $sql)
138          {
139              if (!$this->db->sql_query($sql))
140              {
141                  $error = $this->db->sql_error($this->db->get_sql_error_sql());
142                  $this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
143              }
144          }
145   
146          unset($sql_query);
147      }
148   
149      /**
150       * {@inheritdoc}
151       */
152      static public function get_step_count()
153      {
154          return 1;
155      }
156   
157      /**
158       * {@inheritdoc}
159       */
160      public function get_task_lang_name()
161      {
162          return 'TASK_SETUP_DATABASE';
163      }
164  }
165