aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/install/module/obtain_data
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/install/module/obtain_data')
-rw-r--r--phpBB/phpbb/install/module/obtain_data/module.php33
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php219
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php186
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php271
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php167
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php89
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php203
7 files changed, 1168 insertions, 0 deletions
diff --git a/phpBB/phpbb/install/module/obtain_data/module.php b/phpBB/phpbb/install/module/obtain_data/module.php
new file mode 100644
index 0000000000..0e008796c5
--- /dev/null
+++ b/phpBB/phpbb/install/module/obtain_data/module.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\module\obtain_data;
+
+class module extends \phpbb\install\module_base
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function get_navigation_stage_path()
+ {
+ return array('install', 0, 'obtain_data');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_step_count()
+ {
+ return 0;
+ }
+}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php
new file mode 100644
index 0000000000..b2250e524b
--- /dev/null
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php
@@ -0,0 +1,219 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\module\obtain_data\task;
+
+use phpbb\install\exception\user_interaction_required_exception;
+
+/**
+ * This class requests and validates admin account data from the user
+ */
+class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
+{
+ /**
+ * @var \phpbb\install\helper\config
+ */
+ protected $install_config;
+
+ /**
+ * @var \phpbb\install\helper\iohandler\iohandler_interface
+ */
+ protected $io_handler;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\install\helper\config $install_config Installer's config helper
+ * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
+ */
+ public function __construct(\phpbb\install\helper\config $install_config,
+ \phpbb\install\helper\iohandler\iohandler_interface $iohandler)
+ {
+ $this->install_config = $install_config;
+ $this->io_handler = $iohandler;
+
+ parent::__construct(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ // Check if data is sent
+ if ($this->io_handler->get_input('submit_admin', false))
+ {
+ $this->process_form();
+ }
+ else
+ {
+ $this->request_form_data();
+ }
+ }
+
+ /**
+ * Process form data
+ */
+ protected function process_form()
+ {
+ // Admin data
+ $admin_name = $this->io_handler->get_input('admin_name', '', true);
+ $admin_pass1 = $this->io_handler->get_input('admin_pass1', '', true);
+ $admin_pass2 = $this->io_handler->get_input('admin_pass2', '', true);
+ $board_email = $this->io_handler->get_input('board_email', '');
+
+ $admin_data_valid = $this->check_admin_data($admin_name, $admin_pass1, $admin_pass2, $board_email);
+
+ if ($admin_data_valid)
+ {
+ $this->install_config->set('admin_name', $admin_name);
+ $this->install_config->set('admin_passwd', $admin_pass1);
+ $this->install_config->set('board_email', $board_email);
+ }
+ else
+ {
+ $this->request_form_data(true);
+ }
+ }
+
+ /**
+ * Request data from the user
+ *
+ * @param bool $use_request_data Whether to use submited data
+ *
+ * @throws \phpbb\install\exception\user_interaction_required_exception When the user is required to provide data
+ */
+ protected function request_form_data($use_request_data = false)
+ {
+ if ($use_request_data)
+ {
+ $admin_username = $this->io_handler->get_input('admin_name', '', true);
+ $admin_email = $this->io_handler->get_input('board_email', '', true);
+ }
+ else
+ {
+ $admin_username = '';
+ $admin_email = '';
+ }
+
+ $admin_form = array(
+ 'admin_name' => array(
+ 'label' => 'ADMIN_USERNAME',
+ 'description' => 'ADMIN_USERNAME_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $admin_username,
+ ),
+ 'board_email' => array(
+ 'label' => 'CONTACT_EMAIL',
+ 'type' => 'email',
+ 'default' => $admin_email,
+ ),
+ 'admin_pass1' => array(
+ 'label' => 'ADMIN_PASSWORD',
+ 'description' => 'ADMIN_PASSWORD_EXPLAIN',
+ 'type' => 'password',
+ ),
+ 'admin_pass2' => array(
+ 'label' => 'ADMIN_PASSWORD_CONFIRM',
+ 'type' => 'password',
+ ),
+ 'submit_admin' => array(
+ 'label' => 'SUBMIT',
+ 'type' => 'submit',
+ ),
+ );
+
+ $this->io_handler->add_user_form_group('ADMIN_CONFIG', $admin_form);
+
+ // Require user interaction
+ $this->io_handler->send_response();
+ throw new user_interaction_required_exception();
+ }
+
+ /**
+ * Check admin data
+ *
+ * @param string $username Admin username
+ * @param string $pass1 Admin password
+ * @param string $pass2 Admin password confirmation
+ * @param string $email Admin e-mail address
+ *
+ * @return bool True if data is valid, false otherwise
+ */
+ protected function check_admin_data($username, $pass1, $pass2, $email)
+ {
+ $data_valid = true;
+
+ // Check if none of admin data is empty
+ if (in_array('', array($username, $pass1, $pass2, $email)))
+ {
+ $this->io_handler->add_error_message('INST_ERR_MISSING_DATA');
+ $data_valid = false;
+ }
+
+ if (utf8_strlen($username) < 3)
+ {
+ $this->io_handler->add_error_message('INST_ERR_USER_TOO_SHORT');
+ $data_valid = false;
+ }
+
+ if (utf8_strlen($username) > 20)
+ {
+ $this->io_handler->add_error_message('INST_ERR_USER_TOO_LONG');
+ $data_valid = false;
+ }
+
+ if ($pass1 !== $pass2 && $pass1 !== '')
+ {
+ $this->io_handler->add_error_message('INST_ERR_PASSWORD_MISMATCH');
+ $data_valid = false;
+ }
+
+ // Test against the default password rules
+ if (utf8_strlen($pass1) < 6)
+ {
+ $this->io_handler->add_error_message('INST_ERR_PASSWORD_TOO_SHORT');
+ $data_valid = false;
+ }
+
+ if (utf8_strlen($pass1) > 30)
+ {
+ $this->io_handler->add_error_message('INST_ERR_PASSWORD_TOO_LONG');
+ $data_valid = false;
+ }
+
+ if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email))
+ {
+ $this->io_handler->add_error_message('INST_ERR_EMAIL_INVALID');
+ $data_valid = false;
+ }
+
+ return $data_valid;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return '';
+ }
+}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php
new file mode 100644
index 0000000000..821c221123
--- /dev/null
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php
@@ -0,0 +1,186 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\module\obtain_data\task;
+
+use phpbb\install\exception\user_interaction_required_exception;
+
+/**
+ * This class obtains default data from the user related to board (Board name, Board descritpion, etc...)
+ */
+class obtain_board_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
+{
+ /**
+ * @var \phpbb\install\helper\config
+ */
+ protected $install_config;
+
+ /**
+ * @var \phpbb\install\helper\iohandler\iohandler_interface
+ */
+ protected $io_handler;
+
+ /**
+ * @var \phpbb\language\language_file_helper
+ */
+ protected $language_helper;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\install\helper\config $config Installer's config
+ * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
+ * @param \phpbb\language\language_file_helper $lang_helper Language file helper
+ */
+ public function __construct(\phpbb\install\helper\config $config,
+ \phpbb\install\helper\iohandler\iohandler_interface $iohandler,
+ \phpbb\language\language_file_helper $lang_helper)
+ {
+ $this->install_config = $config;
+ $this->io_handler = $iohandler;
+ $this->language_helper = $lang_helper;
+
+ parent::__construct(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ // Check if data is sent
+ if ($this->io_handler->get_input('submit_board', false))
+ {
+ $this->process_form();
+ }
+ else
+ {
+ $this->request_form_data();
+ }
+ }
+
+ /**
+ * Process form data
+ */
+ protected function process_form()
+ {
+ // Board data
+ $default_lang = $this->io_handler->get_input('default_lang', '');
+ $board_name = $this->io_handler->get_input('board_name', '');
+ $board_desc = $this->io_handler->get_input('board_description', '');
+
+ // Check default lang
+ $langs = $this->language_helper->get_available_languages();
+ $lang_valid = false;
+
+ foreach ($langs as $lang)
+ {
+ if ($lang['iso'] === $default_lang)
+ {
+ $lang_valid = true;
+ break;
+ }
+ }
+
+ $this->install_config->set('board_name', $board_name);
+ $this->install_config->set('board_description', $board_desc);
+
+ if ($lang_valid)
+ {
+ $this->install_config->set('default_lang', $default_lang);
+ }
+ else
+ {
+ $this->request_form_data(true);
+ }
+ }
+
+ /**
+ * Request data from the user
+ *
+ * @param bool $use_request_data Whether to use submited data
+ *
+ * @throws \phpbb\install\exception\user_interaction_required_exception When the user is required to provide data
+ */
+ protected function request_form_data($use_request_data = false)
+ {
+ if ($use_request_data)
+ {
+ $board_name = $this->io_handler->get_input('board_name', '');
+ $board_desc = $this->io_handler->get_input('board_description', '');
+ }
+ else
+ {
+ $board_name = '{L_CONFIG_SITENAME}';
+ $board_desc = '{L_CONFIG_SITE_DESC}';
+ }
+
+ // Use language because we only check this to be valid
+ $default_lang = $this->install_config->get('language', '');
+
+ $langs = $this->language_helper->get_available_languages();
+ $lang_options = array();
+
+ foreach ($langs as $lang)
+ {
+ $lang_options[] = array(
+ 'value' => $lang['iso'],
+ 'label' => $lang['local_name'],
+ 'selected' => ($default_lang === $lang['iso']),
+ );
+ }
+
+ $board_form = array(
+ 'default_lang' => array(
+ 'label' => 'DEFAULT_LANGUAGE',
+ 'type' => 'select',
+ 'options' => $lang_options,
+ ),
+ 'board_name' => array(
+ 'label' => 'BOARD_NAME',
+ 'type' => 'text',
+ 'default' => $board_name,
+ ),
+ 'board_description' => array(
+ 'label' => 'BOARD_DESCRIPTION',
+ 'type' => 'text',
+ 'default' => $board_desc,
+ ),
+ 'submit_board' => array(
+ 'label' => 'SUBMIT',
+ 'type' => 'submit',
+ ),
+ );
+
+ $this->io_handler->add_user_form_group('BOARD_CONFIG', $board_form);
+
+ $this->io_handler->send_response();
+ throw new user_interaction_required_exception;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return '';
+ }
+}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php
new file mode 100644
index 0000000000..f0e7f1f686
--- /dev/null
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php
@@ -0,0 +1,271 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\module\obtain_data\task;
+
+use phpbb\install\exception\user_interaction_required_exception;
+
+/**
+ * This class requests and validates database information from the user
+ */
+class obtain_database_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
+{
+ /**
+ * @var \phpbb\install\helper\database
+ */
+ protected $database_helper;
+
+ /**
+ * @var \phpbb\install\helper\config
+ */
+ protected $install_config;
+
+ /**
+ * @var \phpbb\install\helper\iohandler\iohandler_interface
+ */
+ protected $io_handler;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\install\helper\database $database_helper Installer's database helper
+ * @param \phpbb\install\helper\config $install_config Installer's config helper
+ * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
+ */
+ public function __construct(\phpbb\install\helper\database $database_helper,
+ \phpbb\install\helper\config $install_config,
+ \phpbb\install\helper\iohandler\iohandler_interface $iohandler)
+ {
+ $this->database_helper = $database_helper;
+ $this->install_config = $install_config;
+ $this->io_handler = $iohandler;
+
+ parent::__construct(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ // Check if data is sent
+ if ($this->io_handler->get_input('submit_database', false))
+ {
+ $this->process_form();
+ }
+ else
+ {
+ $this->request_form_data();
+ }
+ }
+
+ /**
+ * Process form data
+ */
+ protected function process_form()
+ {
+ // Collect database data
+ $dbms = $this->io_handler->get_input('dbms', '');
+ $dbhost = $this->io_handler->get_input('dbhost', '');
+ $dbport = $this->io_handler->get_input('dbport', '');
+ $dbuser = $this->io_handler->get_input('dbuser', '');
+ $dbpasswd = $this->io_handler->get_input('dbpasswd', '', true);
+ $dbname = $this->io_handler->get_input('dbname', '');
+ $table_prefix = $this->io_handler->get_input('table_prefix', '');
+
+ // Check database data
+ $user_data_vaild = $this->check_database_data($dbms, $dbhost, $dbport, $dbuser, $dbpasswd, $dbname, $table_prefix);
+
+ // Save database data if it is correct
+ if ($user_data_vaild)
+ {
+ $this->install_config->set('dbms', $dbms);
+ $this->install_config->set('dbhost', $dbhost);
+ $this->install_config->set('dbport', $dbport);
+ $this->install_config->set('dbuser', $dbuser);
+ $this->install_config->set('dbpasswd', $dbpasswd);
+ $this->install_config->set('dbname', $dbname);
+ $this->install_config->set('table_prefix', $table_prefix);
+ }
+ else
+ {
+ $this->request_form_data(true);
+ }
+ }
+
+ /**
+ * Request data from the user
+ *
+ * @param bool $use_request_data Whether to use submited data
+ *
+ * @throws \phpbb\install\exception\user_interaction_required_exception When the user is required to provide data
+ */
+ protected function request_form_data($use_request_data = false)
+ {
+ if ($use_request_data)
+ {
+ $dbms = $this->io_handler->get_input('dbms', '');
+ $dbhost = $this->io_handler->get_input('dbhost', '');
+ $dbport = $this->io_handler->get_input('dbport', '');
+ $dbuser = $this->io_handler->get_input('dbuser', '');
+ $dbname = $this->io_handler->get_input('dbname', '');
+ $table_prefix = $this->io_handler->get_input('table_prefix', 'phpbb_');
+ }
+ else
+ {
+ $dbms = '';
+ $dbhost = '';
+ $dbport = '';
+ $dbuser = '';
+ $dbname = '';
+ $table_prefix = 'phpbb_';
+ }
+
+ $dbms_select = array();
+ foreach ($this->database_helper->get_available_dbms() as $dbms_key => $dbms_array)
+ {
+ $dbms_select[] = array(
+ 'value' => $dbms_key,
+ 'label' => 'DB_OPTION_' . strtoupper($dbms_key),
+ 'selected' => ($dbms_key === $dbms),
+ );
+ }
+
+ $database_form = array(
+ 'dbms' => array(
+ 'label' => 'DBMS',
+ 'type' => 'select',
+ 'options' => $dbms_select,
+ ),
+ 'dbhost' => array(
+ 'label' => 'DB_HOST',
+ 'description' => 'DB_HOST_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $dbhost,
+ ),
+ 'dbport' => array(
+ 'label' => 'DB_PORT',
+ 'description' => 'DB_PORT_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $dbport,
+ ),
+ 'dbuser' => array(
+ 'label' => 'DB_USERNAME',
+ 'type' => 'text',
+ 'default' => $dbuser,
+ ),
+ 'dbpasswd' => array(
+ 'label' => 'DB_PASSWORD',
+ 'type' => 'password',
+ ),
+ 'dbname' => array(
+ 'label' => 'DB_NAME',
+ 'type' => 'text',
+ 'default' => $dbname,
+ ),
+ 'table_prefix' => array(
+ 'label' => 'TABLE_PREFIX',
+ 'description' => 'TABLE_PREFIX_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $table_prefix,
+ ),
+ 'submit_database' => array(
+ 'label' => 'SUBMIT',
+ 'type' => 'submit',
+ ),
+ );
+
+ $this->io_handler->add_user_form_group('DB_CONFIG', $database_form);
+
+ // Require user interaction
+ $this->io_handler->send_response();
+ throw new user_interaction_required_exception();
+ }
+
+ /**
+ * Check database data
+ *
+ * @param string $dbms Selected database type
+ * @param string $dbhost Database host address
+ * @param int $dbport Database port number
+ * @param string $dbuser Database username
+ * @param string $dbpass Database password
+ * @param string $dbname Database name
+ * @param string $table_prefix Database table prefix
+ *
+ * @return bool True if database data is correct, false otherwise
+ */
+ protected function check_database_data($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix)
+ {
+ $available_dbms = $this->database_helper->get_available_dbms();
+ $data_valid = true;
+
+ // Check if PHP has the database extensions for the specified DBMS
+ if (!isset($available_dbms[$dbms]))
+ {
+ $this->io_handler->add_error_message('INST_ERR_NO_DB');
+ $data_valid = false;
+ }
+
+ // Validate table prefix
+ $prefix_valid = $this->database_helper->validate_table_prefix($dbms, $table_prefix);
+ if (is_array($prefix_valid))
+ {
+ foreach ($prefix_valid as $error)
+ {
+ $this->io_handler->add_error_message(
+ $error['title'],
+ (isset($error['description'])) ? $error['description'] : false
+ );
+ }
+
+ $data_valid = false;
+ }
+
+ // Try to connect to database if all provided data is valid
+ if ($data_valid)
+ {
+ $connect_test = $this->database_helper->check_database_connection($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix);
+ if (is_array($connect_test))
+ {
+ foreach ($connect_test as $error)
+ {
+ $this->io_handler->add_error_message(
+ $error['title'],
+ (isset($error['description'])) ? $error['description'] : false
+ );
+ }
+
+ $data_valid = false;
+ }
+ }
+
+ return $data_valid;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return '';
+ }
+}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php
new file mode 100644
index 0000000000..ae7526a9e3
--- /dev/null
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php
@@ -0,0 +1,167 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\module\obtain_data\task;
+
+use phpbb\install\exception\user_interaction_required_exception;
+
+class obtain_email_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
+{
+ /**
+ * @var \phpbb\install\helper\config
+ */
+ protected $install_config;
+
+ /**
+ * @var \phpbb\install\helper\iohandler\iohandler_interface
+ */
+ protected $io_handler;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\install\helper\config $config Installer's config
+ * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
+ */
+ public function __construct(\phpbb\install\helper\config $config,
+ \phpbb\install\helper\iohandler\iohandler_interface $iohandler)
+ {
+ $this->install_config = $config;
+ $this->io_handler = $iohandler;
+
+ parent::__construct(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ // E-mail data
+ $email_enable = $this->io_handler->get_input('email_enable', true);
+ $smtp_delivery = $this->io_handler->get_input('smtp_delivery', '');
+ $smtp_host = $this->io_handler->get_input('smtp_host', '');
+ $smtp_auth = $this->io_handler->get_input('smtp_auth', '');
+ $smtp_user = $this->io_handler->get_input('smtp_user', '');
+ $smtp_passwd = $this->io_handler->get_input('smtp_pass', '');
+
+ $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
+
+ // Check if data is sent
+ if ($this->io_handler->get_input('submit_email', false))
+ {
+ $this->install_config->set('email_enable', $email_enable);
+ $this->install_config->set('smtp_delivery', $smtp_delivery);
+ $this->install_config->set('smtp_host', $smtp_host);
+ $this->install_config->set('smtp_auth', $smtp_auth);
+ $this->install_config->set('smtp_user', $smtp_user);
+ $this->install_config->set('smtp_pass', $smtp_passwd);
+ }
+ else
+ {
+ $auth_options = array();
+ foreach ($auth_methods as $method)
+ {
+ $auth_options[] = array(
+ 'value' => $method,
+ 'label' => 'SMTP_' . str_replace('-', '_', $method),
+ 'selected' => false,
+ );
+ }
+
+ $email_form = array(
+ 'email_enable' => array(
+ 'label' => 'ENABLE_EMAIL',
+ 'description' => 'COOKIE_SECURE_EXPLAIN',
+ 'type' => 'radio',
+ 'options' => array(
+ array(
+ 'value' => 1,
+ 'label' => 'ENABLE',
+ 'selected' => true,
+ ),
+ array(
+ 'value' => 0,
+ 'label' => 'DISABLE',
+ 'selected' => false,
+ ),
+ ),
+ ),
+ 'smtp_delivery' => array(
+ 'label' => 'USE_SMTP',
+ 'description' => 'USE_SMTP_EXPLAIN',
+ 'type' => 'radio',
+ 'options' => array(
+ array(
+ 'value' => 0,
+ 'label' => 'NO',
+ 'selected' => true,
+ ),
+ array(
+ 'value' => 1,
+ 'label' => 'YES',
+ 'selected' => false,
+ ),
+ ),
+ ),
+ 'smtp_host' => array(
+ 'label' => 'SMTP_SERVER',
+ 'description' => 'SMTP_SERVER_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $smtp_host,
+ ),
+ 'smtp_auth' => array(
+ 'label' => 'SMTP_AUTH_METHOD',
+ 'type' => 'select',
+ 'options' => $auth_options,
+ ),
+ 'smtp_user' => array(
+ 'label' => 'SMTP_USERNAME',
+ 'description' => 'SMTP_USERNAME_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $smtp_user,
+ ),
+ 'smtp_pass' => array(
+ 'label' => 'SMTP_PASSWORD',
+ 'description' => 'SMTP_PASSWORD_EXPLAIN',
+ 'type' => 'password',
+ ),
+ 'submit_email' => array(
+ 'label' => 'SUBMIT',
+ 'type' => 'submit',
+ ),
+ );
+
+ $this->io_handler->add_user_form_group('EMAIL_CONFIG', $email_form);
+
+ $this->io_handler->send_response();
+ throw new user_interaction_required_exception();
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return '';
+ }
+}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php
new file mode 100644
index 0000000000..9f74b61770
--- /dev/null
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\module\obtain_data\task;
+
+class obtain_imagick_path extends \phpbb\install\task_base implements \phpbb\install\task_interface
+{
+ /**
+ * @var \phpbb\install\helper\config
+ */
+ protected $config;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\install\helper\config $config Installer's config
+ */
+ public function __construct(\phpbb\install\helper\config $config)
+ {
+ $this->config = $config;
+
+ parent::__construct(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ // Can we find Imagemagick anywhere on the system?
+ $exe = (DIRECTORY_SEPARATOR == '\\') ? '.exe' : '';
+
+ $magic_home = getenv('MAGICK_HOME');
+ $img_imagick = '';
+ if (empty($magic_home))
+ {
+ $locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');
+ $path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));
+
+ $locations = array_merge($path_locations, $locations);
+ foreach ($locations as $location)
+ {
+ // The path might not end properly, fudge it
+ if (substr($location, -1, 1) !== '/')
+ {
+ $location .= '/';
+ }
+
+ if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000)
+ {
+ $img_imagick = str_replace('\\', '/', $location);
+ continue;
+ }
+ }
+ }
+ else
+ {
+ $img_imagick = str_replace('\\', '/', $magic_home);
+ }
+
+ $this->config->set('img_imagick', $img_imagick);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return '';
+ }
+}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php
new file mode 100644
index 0000000000..654b5534a9
--- /dev/null
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php
@@ -0,0 +1,203 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\module\obtain_data\task;
+
+use phpbb\install\exception\user_interaction_required_exception;
+
+/**
+ * This class requests and saves some information about the server
+ */
+class obtain_server_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
+{
+ /**
+ * @var \phpbb\install\helper\config
+ */
+ protected $install_config;
+
+ /**
+ * @var \phpbb\install\helper\iohandler\iohandler_interface
+ */
+ protected $io_handler;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\install\helper\config $config Installer's config
+ * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
+ */
+ public function __construct(\phpbb\install\helper\config $config,
+ \phpbb\install\helper\iohandler\iohandler_interface $iohandler)
+ {
+ $this->install_config = $config;
+ $this->io_handler = $iohandler;
+
+ parent::__construct(true);
+ }
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ $cookie_secure = $this->io_handler->is_secure();
+ $server_protocol = ($this->io_handler->is_secure()) ? 'https://' : 'http://';
+ $server_port = $this->io_handler->get_server_variable('SERVER_PORT', 0);
+
+ // HTTP_HOST is having the correct browser url in most cases...
+ $server_name = strtolower(htmlspecialchars_decode($this->io_handler->get_header_variable(
+ 'Host',
+ $this->io_handler->get_server_variable('SERVER_NAME')
+ )));
+
+ // HTTP HOST can carry a port number...
+ if (strpos($server_name, ':') !== false)
+ {
+ $server_name = substr($server_name, 0, strpos($server_name, ':'));
+ }
+
+ $script_path = htmlspecialchars_decode($this->io_handler->get_server_variable('PHP_SELF'));
+
+ if (!$script_path)
+ {
+ $script_path = htmlspecialchars_decode($this->io_handler->get_server_variable('REQUEST_URI'));
+ }
+
+ $script_path = str_replace(array('\\', '//'), '/', $script_path);
+ $script_path = trim(dirname(dirname(dirname($script_path)))); // Because we are in install/app.php/route_name
+
+ // Server data
+ $cookie_secure = $this->io_handler->get_input('cookie_secure', $cookie_secure);
+ $server_protocol = $this->io_handler->get_input('server_protocol', $server_protocol);
+ $force_server_vars = $this->io_handler->get_input('force_server_vars', 0);
+ $server_name = $this->io_handler->get_input('server_name', $server_name);
+ $server_port = $this->io_handler->get_input('server_port', $server_port);
+ $script_path = $this->io_handler->get_input('script_path', $script_path);
+
+ // Clean up script path
+ if ($script_path !== '/')
+ {
+ // Adjust destination path (no trailing slash)
+ if (substr($script_path, -1) === '/')
+ {
+ $script_path = substr($script_path, 0, -1);
+ }
+
+ $script_path = str_replace(array('../', './'), '', $script_path);
+
+ if ($script_path[0] !== '/')
+ {
+ $script_path = '/' . $script_path;
+ }
+ }
+
+ // Check if data is sent
+ if ($this->io_handler->get_input('submit_server', false))
+ {
+ $this->install_config->set('cookie_secure', $cookie_secure);
+ $this->install_config->set('server_protocol', $server_protocol);
+ $this->install_config->set('force_server_vars', $force_server_vars);
+ $this->install_config->set('server_name', $server_name);
+ $this->install_config->set('server_port', $server_port);
+ $this->install_config->set('script_path', $script_path);
+ }
+ else
+ {
+ // Render form
+ $server_form = array(
+ 'cookie_secure' => array(
+ 'label' => 'COOKIE_SECURE',
+ 'description' => 'COOKIE_SECURE_EXPLAIN',
+ 'type' => 'radio',
+ 'options' => array(
+ array(
+ 'value' => 0,
+ 'label' => 'NO',
+ 'selected' => (!$cookie_secure),
+ ),
+ array(
+ 'value' => 1,
+ 'label' => 'YES',
+ 'selected' => ($cookie_secure),
+ ),
+ ),
+ ),
+ 'force_server_vars' => array(
+ 'label' => 'FORCE_SERVER_VARS',
+ 'description' => 'FORCE_SERVER_VARS_EXPLAIN',
+ 'type' => 'radio',
+ 'options' => array(
+ array(
+ 'value' => 0,
+ 'label' => 'NO',
+ 'selected' => true,
+ ),
+ array(
+ 'value' => 1,
+ 'label' => 'YES',
+ 'selected' => false,
+ ),
+ ),
+ ),
+ 'server_protocol' => array(
+ 'label' => 'SERVER_PROTOCOL',
+ 'description' => 'SERVER_PROTOCOL_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $server_protocol,
+ ),
+ 'server_name' => array(
+ 'label' => 'SERVER_NAME',
+ 'description' => 'SERVER_NAME_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $server_name,
+ ),
+ 'server_port' => array(
+ 'label' => 'SERVER_PORT',
+ 'description' => 'SERVER_PORT_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $server_port,
+ ),
+ 'script_path' => array(
+ 'label' => 'SCRIPT_PATH',
+ 'description' => 'SCRIPT_PATH_EXPLAIN',
+ 'type' => 'text',
+ 'default' => $script_path,
+ ),
+ 'submit_server' => array(
+ 'label' => 'SUBMIT',
+ 'type' => 'submit',
+ )
+ );
+
+ $this->io_handler->add_user_form_group('SERVER_CONFIG', $server_form);
+
+ $this->io_handler->send_response();
+ throw new user_interaction_required_exception();
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return '';
+ }
+}