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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
set_up_database.php
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 $schema_name .= '_41';
106 }
107
108 $this->schema_file_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql';
109
110 return $this->filesystem->exists($this->schema_file_path);
111 }
112
113 /**
114 * {@inheritdoc}
115 */
116 public function run()
117 {
118 $this->db->sql_return_on_error(true);
119
120 $dbms = $this->config->get('dbms');
121 $dbms_info = $this->database_helper->get_available_dbms($dbms);
122 $delimiter = $dbms_info[$dbms]['DELIM'];
123 $table_prefix = $this->config->get('table_prefix');
124
125 $sql_query = @file_get_contents($this->schema_file_path);
126 $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
127 $sql_query = $this->database_helper->remove_comments($sql_query);
128 $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter);
129
130 foreach ($sql_query as $sql)
131 {
132 if (!$this->db->sql_query($sql))
133 {
134 $error = $this->db->sql_error($this->db->get_sql_error_sql());
135 $this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
136 }
137 }
138
139 unset($sql_query);
140 }
141
142 /**
143 * {@inheritdoc}
144 */
145 static public function get_step_count()
146 {
147 return 1;
148 }
149
150 /**
151 * {@inheritdoc}
152 */
153 public function get_task_lang_name()
154 {
155 return 'TASK_SETUP_DATABASE';
156 }
157 }
158