[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/install/module/install_finish/task/ -> notify_user.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of the phpBB Forum Software package.
   5   *
   6   * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7   * @license GNU General Public License, version 2 (GPL-2.0)
   8   *
   9   * For full copyright and license information, please see
  10   * the docs/CREDITS.txt file.
  11   *
  12   */
  13  
  14  namespace phpbb\install\module\install_finish\task;
  15  
  16  use phpbb\config\db;
  17  
  18  /**
  19   * Logs installation and sends an email to the admin
  20   */
  21  class notify_user extends \phpbb\install\task_base
  22  {
  23      /**
  24       * @var \phpbb\install\helper\config
  25       */
  26      protected $install_config;
  27  
  28      /**
  29       * @var \phpbb\install\helper\iohandler\iohandler_interface
  30       */
  31      protected $iohandler;
  32  
  33      /**
  34       * @var \phpbb\auth\auth
  35       */
  36      protected $auth;
  37  
  38      /**
  39       * @var \phpbb\config\db
  40       */
  41      protected $config;
  42  
  43      /**
  44       * @var \phpbb\language\language
  45       */
  46      protected $language;
  47  
  48      /**
  49       * @var \phpbb\log\log_interface
  50       */
  51      protected $log;
  52  
  53      /**
  54       * @var \phpbb\user
  55       */
  56      protected $user;
  57  
  58      /**
  59       * @var string
  60       */
  61      protected $phpbb_root_path;
  62  
  63      /**
  64       * @var string
  65       */
  66      protected $php_ext;
  67  
  68      /**
  69       * Constructor
  70       *
  71       * @param \phpbb\install\helper\container_factory                $container
  72       * @param \phpbb\install\helper\config                            $install_config
  73       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler
  74       * @param string                                                $phpbb_root_path
  75       * @param string                                                $php_ext
  76       */
  77  	public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, $phpbb_root_path, $php_ext)
  78      {
  79          $this->install_config    = $install_config;
  80          $this->iohandler        = $iohandler;
  81  
  82          $this->auth                = $container->get('auth');
  83          $this->language            = $container->get('language');
  84          $this->log                = $container->get('log');
  85          $this->user                = $container->get('user');
  86          $this->phpbb_root_path    = $phpbb_root_path;
  87          $this->php_ext            = $php_ext;
  88  
  89          // We need to reload config for cases when it doesn't have all values
  90          /** @var \phpbb\cache\driver\driver_interface $cache */
  91          $cache = $container->get('cache.driver');
  92          $cache->destroy('config');
  93  
  94          $this->config = new db(
  95              $container->get('dbal.conn'),
  96              $cache,
  97              $container->get_parameter('tables.config')
  98          );
  99  
 100          parent::__construct(true);
 101      }
 102  
 103      /**
 104       * {@inheritdoc}
 105       */
 106  	public function run()
 107      {
 108          $this->user->session_begin();
 109          $this->user->setup('common');
 110  
 111          if ($this->config['email_enable'])
 112          {
 113              include ($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
 114  
 115              // functions_messenger.php uses config to determine language paths
 116              // Remove when able
 117              global $config;
 118              $config = $this->config;
 119  
 120              $messenger = new \messenger(false);
 121              $messenger->template('installed', $this->install_config->get('user_language', 'en'));
 122              $messenger->to($this->config['board_email'], $this->install_config->get('admin_name'));
 123              $messenger->anti_abuse_headers($this->config, $this->user);
 124              $messenger->assign_vars(array(
 125                      'USERNAME'        => htmlspecialchars_decode($this->install_config->get('admin_name')),
 126                      'PASSWORD'        => htmlspecialchars_decode($this->install_config->get('admin_passwd')))
 127              );
 128              $messenger->send(NOTIFY_EMAIL);
 129          }
 130  
 131          // Login admin
 132          // Ugly but works
 133          $this->auth->login(
 134              $this->install_config->get('admin_name'),
 135              $this->install_config->get('admin_passwd'),
 136              false,
 137              true,
 138              true
 139          );
 140  
 141          $this->iohandler->set_cookie($this->config['cookie_name'] . '_sid', $this->user->session_id);
 142          $this->iohandler->set_cookie($this->config['cookie_name'] . '_u', $this->user->cookie_data['u']);
 143          $this->iohandler->set_cookie($this->config['cookie_name'] . '_k', $this->user->cookie_data['k']);
 144  
 145          // Create log
 146          $this->log->add(
 147              'admin',
 148              $this->user->data['user_id'],
 149              $this->user->ip,
 150              'LOG_INSTALL_INSTALLED',
 151              false,
 152              array($this->config['version'])
 153          );
 154  
 155          // Remove install_lock
 156          @unlink($this->phpbb_root_path . 'cache/install_lock');
 157      }
 158  
 159      /**
 160       * {@inheritdoc}
 161       */
 162  	static public function get_step_count()
 163      {
 164          return 1;
 165      }
 166  
 167      /**
 168       * {@inheritdoc}
 169       */
 170  	public function get_task_lang_name()
 171      {
 172          return 'TASK_NOTIFY_USER';
 173      }
 174  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1