Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

add_config_settings.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 11.83 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  use phpbb\install\exception\resource_limit_reached_exception;
 017   
 018  /**
 019   * Create database schema
 020   */
 021  class add_config_settings extends \phpbb\install\task_base
 022  {
 023      /**
 024       * @var \phpbb\db\driver\driver_interface
 025       */
 026      protected $db;
 027   
 028      /**
 029       * @var \phpbb\filesystem\filesystem_interface
 030       */
 031      protected $filesystem;
 032   
 033      /**
 034       * @var \phpbb\install\helper\config
 035       */
 036      protected $install_config;
 037   
 038      /**
 039       * @var \phpbb\install\helper\iohandler\iohandler_interface
 040       */
 041      protected $iohandler;
 042   
 043      /**
 044       * @var \phpbb\language\language
 045       */
 046      protected $language;
 047   
 048      /**
 049       * @var \phpbb\passwords\manager
 050       */
 051      protected $password_manager;
 052   
 053      /**
 054       * @var string
 055       */
 056      protected $phpbb_root_path;
 057   
 058      /**
 059       * @var string
 060       */
 061      protected $config_table;
 062   
 063      /**
 064       * @var string
 065       */
 066      protected $user_table;
 067   
 068      /**
 069       * @var string
 070       */
 071      protected $topics_table;
 072   
 073      /**
 074       * @var string
 075       */
 076      protected $forums_table;
 077   
 078      /**
 079       * @var string
 080       */
 081      protected $posts_table;
 082   
 083      /**
 084       * @var string
 085       */
 086      protected $moderator_cache_table;
 087   
 088      /**
 089       * Constructor
 090       *
 091       * @param \phpbb\filesystem\filesystem_interface                $filesystem            Filesystem service
 092       * @param \phpbb\install\helper\config                            $install_config        Installer's config helper
 093       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler            Installer's input-output handler
 094       * @param \phpbb\install\helper\container_factory                $container            Installer's DI container
 095       * @param \phpbb\language\language                                $language            Language service
 096       * @param string                                                $phpbb_root_path    Path to phpBB's root
 097       */
 098      public function __construct(\phpbb\filesystem\filesystem_interface $filesystem,
 099                                  \phpbb\install\helper\config $install_config,
 100                                  \phpbb\install\helper\iohandler\iohandler_interface $iohandler,
 101                                  \phpbb\install\helper\container_factory $container,
 102                                  \phpbb\language\language $language,
 103                                  $phpbb_root_path)
 104      {
 105          $this->db                = $container->get('dbal.conn');
 106          $this->filesystem        = $filesystem;
 107          $this->install_config    = $install_config;
 108          $this->iohandler        = $iohandler;
 109          $this->language            = $language;
 110          $this->password_manager    = $container->get('passwords.manager');
 111          $this->phpbb_root_path    = $phpbb_root_path;
 112   
 113          // Table names
 114          $this->config_table                = $container->get_parameter('tables.config');
 115          $this->forums_table                = $container->get_parameter('tables.forums');
 116          $this->topics_table                = $container->get_parameter('tables.topics');
 117          $this->user_table                = $container->get_parameter('tables.users');
 118          $this->moderator_cache_table    = $container->get_parameter('tables.moderator_cache');
 119          $this->posts_table                = $container->get_parameter('tables.posts');
 120   
 121          parent::__construct(true);
 122      }
 123   
 124      /**
 125       * {@inheritdoc}
 126       */
 127      public function run()
 128      {
 129          $this->db->sql_return_on_error(true);
 130   
 131          $server_name    = $this->install_config->get('server_name');
 132          $current_time     = time();
 133          $user_ip        = phpbb_ip_normalise($this->iohandler->get_server_variable('REMOTE_ADDR'));
 134          $user_ip        = ($user_ip === false) ? '' : $user_ip;
 135          $referer        = $this->iohandler->get_server_variable('REFERER');
 136   
 137          // Calculate cookie domain
 138          $cookie_domain = $server_name;
 139   
 140          if (strpos($cookie_domain, 'www.') === 0)
 141          {
 142              $cookie_domain = substr($cookie_domain, 3);
 143          }
 144   
 145          // Set default config and post data, this applies to all DB's
 146          $sql_ary = array(
 147              'INSERT INTO ' . $this->config_table . " (config_name, config_value)
 148                  VALUES ('board_startdate', '$current_time')",
 149   
 150              'INSERT INTO ' . $this->config_table . " (config_name, config_value)
 151                  VALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')",
 152   
 153              'UPDATE ' . $this->config_table . "
 154                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "'
 155                  WHERE config_name = 'server_name'",
 156   
 157              'UPDATE ' . $this->config_table . "
 158                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_port')) . "'
 159                  WHERE config_name = 'server_port'",
 160   
 161              'UPDATE ' . $this->config_table . "
 162                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "'
 163                  WHERE config_name = 'board_email'",
 164   
 165              'UPDATE ' . $this->config_table . "
 166                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "'
 167                  WHERE config_name = 'board_contact'",
 168   
 169              'UPDATE ' . $this->config_table . "
 170                  SET config_value = '" . $this->db->sql_escape($cookie_domain) . "'
 171                  WHERE config_name = 'cookie_domain'",
 172   
 173              'UPDATE ' . $this->config_table . "
 174                  SET config_value = '" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "'
 175                  WHERE config_name = 'default_dateformat'",
 176   
 177              'UPDATE ' . $this->config_table . "
 178                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('email_enable')) . "'
 179                  WHERE config_name = 'email_enable'",
 180   
 181              'UPDATE ' . $this->config_table . "
 182                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_delivery')) . "'
 183                  WHERE config_name = 'smtp_delivery'",
 184   
 185              'UPDATE ' . $this->config_table . "
 186                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_host')) . "'
 187                  WHERE config_name = 'smtp_host'",
 188   
 189              'UPDATE ' . $this->config_table . "
 190                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_port')) . "'
 191                  WHERE config_name = 'smtp_port'",
 192   
 193              'UPDATE ' . $this->config_table . "
 194                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_auth')) . "'
 195                  WHERE config_name = 'smtp_auth_method'",
 196   
 197              'UPDATE ' . $this->config_table . "
 198                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_user')) . "'
 199                  WHERE config_name = 'smtp_username'",
 200   
 201              'UPDATE ' . $this->config_table . "
 202                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_pass')) . "'
 203                  WHERE config_name = 'smtp_password'",
 204   
 205              'UPDATE ' . $this->config_table . "
 206                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('cookie_secure')) . "'
 207                  WHERE config_name = 'cookie_secure'",
 208   
 209              'UPDATE ' . $this->config_table . "
 210                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('force_server_vars')) . "'
 211                  WHERE config_name = 'force_server_vars'",
 212   
 213              'UPDATE ' . $this->config_table . "
 214                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('script_path')) . "'
 215                  WHERE config_name = 'script_path'",
 216   
 217              'UPDATE ' . $this->config_table . "
 218                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_protocol')) . "'
 219                  WHERE config_name = 'server_protocol'",
 220   
 221              'UPDATE ' . $this->config_table . "
 222                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'
 223                  WHERE config_name = 'newest_username'",
 224   
 225              'UPDATE ' . $this->config_table . "
 226                  SET config_value = '" . md5(mt_rand()) . "'
 227                  WHERE config_name = 'avatar_salt'",
 228   
 229              'UPDATE ' . $this->config_table . "
 230                  SET config_value = '" . md5(mt_rand()) . "'
 231                  WHERE config_name = 'plupload_salt'",
 232   
 233              'UPDATE ' . $this->config_table . "
 234                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_name')) . "'
 235                  WHERE config_name = 'sitename'",
 236   
 237              'UPDATE ' . $this->config_table . "
 238                  SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_description')) . "'
 239                  WHERE config_name = 'site_desc'",
 240   
 241              'UPDATE ' . $this->user_table . "
 242                  SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "',
 243                      user_password='" . $this->password_manager->hash($this->install_config->get('admin_passwd')) . "',
 244                      user_ip = '" . $this->db->sql_escape($user_ip) . "',
 245                      user_lang = '" . $this->db->sql_escape($this->install_config->get('user_language', 'en')) . "',
 246                      user_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "',
 247                      user_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "',
 248                      username_clean = '" . $this->db->sql_escape(utf8_clean_string($this->install_config->get('admin_name'))) . "'
 249                  WHERE username = 'Admin'",
 250   
 251              'UPDATE ' . $this->moderator_cache_table . "
 252                  SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'
 253                  WHERE username = 'Admin'",
 254   
 255              'UPDATE ' . $this->forums_table . "
 256                  SET forum_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'
 257                  WHERE forum_last_poster_name = 'Admin'",
 258   
 259              'UPDATE ' . $this->topics_table . "
 260                  SET topic_first_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "',
 261                  topic_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'
 262                  WHERE topic_first_poster_name = 'Admin'
 263                      OR topic_last_poster_name = 'Admin'",
 264   
 265              'UPDATE ' . $this->user_table . "
 266                  SET user_regdate = $current_time",
 267   
 268              'UPDATE ' . $this->posts_table . "
 269                  SET post_time = $current_time, poster_ip = '" . $this->db->sql_escape($user_ip) . "'",
 270   
 271              'UPDATE ' . $this->topics_table . "
 272                  SET topic_time = $current_time, topic_last_post_time = $current_time",
 273   
 274              'UPDATE ' . $this->forums_table . "
 275                  SET forum_last_post_time = $current_time",
 276   
 277              'UPDATE ' . $this->config_table . "
 278                  SET config_value = '" . $this->db->sql_escape($this->db->sql_server_info(true)) . "'
 279                  WHERE config_name = 'dbms_version'",
 280          );
 281   
 282          if (@extension_loaded('gd'))
 283          {
 284              $sql_ary[] = 'UPDATE ' . $this->config_table . "
 285                  SET config_value = 'core.captcha.plugins.gd'
 286                  WHERE config_name = 'captcha_plugin'";
 287   
 288              $sql_ary[] = 'UPDATE ' . $this->config_table . "
 289                  SET config_value = '1'
 290                  WHERE config_name = 'captcha_gd'";
 291          }
 292   
 293          $ref = substr($referer, strpos($referer, '://') + 3);
 294          if (!(stripos($ref, $server_name) === 0))
 295          {
 296              $sql_ary[] = 'UPDATE ' . $this->config_table . "
 297                  SET config_value = '0'
 298                  WHERE config_name = 'referer_validation'";
 299          }
 300   
 301          // We set a (semi-)unique cookie name to bypass login issues related to the cookie name.
 302          $cookie_name = 'phpbb3_';
 303          $rand_str = md5(mt_rand());
 304          $rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35));
 305          $rand_str = substr($rand_str, 0, 5);
 306          $cookie_name .= strtolower($rand_str);
 307   
 308          $sql_ary[] = 'UPDATE ' . $this->config_table . "
 309              SET config_value = '" . $this->db->sql_escape($cookie_name) . "'
 310              WHERE config_name = 'cookie_name'";
 311   
 312          // Disable avatars if upload directory is not writable
 313          if (!$this->filesystem->is_writable($this->phpbb_root_path . 'images/avatars/upload/'))
 314          {
 315              $sql_ary[] = 'UPDATE ' . $this->config_table . "
 316                  SET config_value = '0'
 317                  WHERE config_name = 'allow_avatar'";
 318   
 319              $sql_ary[] = 'UPDATE ' . $this->config_table . "
 320                  SET config_value = '0'
 321                  WHERE config_name = 'allow_avatar_upload'";
 322          }
 323   
 324          $i = $this->install_config->get('add_config_settings_index', 0);
 325          $total = count($sql_ary);
 326          $sql_ary = array_slice($sql_ary, $i);
 327   
 328          foreach ($sql_ary as $sql)
 329          {
 330              if (!$this->db->sql_query($sql))
 331              {
 332                  $error = $this->db->sql_error($this->db->get_sql_error_sql());
 333                  $this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
 334              }
 335   
 336              $i++;
 337   
 338              // Stop execution if resource limit is reached
 339              if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
 340              {
 341                  break;
 342              }
 343          }
 344   
 345          if ($i < $total)
 346          {
 347              $this->install_config->set('add_config_settings_index', $i);
 348              throw new resource_limit_reached_exception();
 349          }
 350      }
 351   
 352      /**
 353       * {@inheritdoc}
 354       */
 355      static public function get_step_count()
 356      {
 357          return 1;
 358      }
 359   
 360      /**
 361       * {@inheritdoc}
 362       */
 363      public function get_task_lang_name()
 364      {
 365          return 'TASK_ADD_CONFIG_SETTINGS';
 366      }
 367  }
 368