mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/14039] Revamp updater
PHPBB3-14039
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace phpbb\install\module\obtain_data;
|
||||
|
||||
class module extends \phpbb\install\module_base
|
||||
class install_module extends \phpbb\install\module_base
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
@@ -155,7 +155,7 @@ class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||
$data_valid = true;
|
||||
|
||||
// Check if none of admin data is empty
|
||||
if (in_array('', array($username, $pass1, $pass2, $email)))
|
||||
if (in_array('', array($username, $pass1, $pass2, $email), true))
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_MISSING_DATA');
|
||||
$data_valid = false;
|
||||
|
@@ -165,7 +165,7 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||
$this->io_handler->add_user_form_group('BOARD_CONFIG', $board_form);
|
||||
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception;
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,168 @@
|
||||
<?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;
|
||||
use phpbb\install\helper\config;
|
||||
use phpbb\install\helper\iohandler\iohandler_interface;
|
||||
use phpbb\install\task_base;
|
||||
|
||||
class obtain_file_updater_method extends task_base
|
||||
{
|
||||
/**
|
||||
* @var array Supported compression methods
|
||||
*
|
||||
* Note: .tar is assumed to be supported, but not in the list
|
||||
*/
|
||||
protected $available_methods;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $installer_config
|
||||
* @param iohandler_interface $iohandler
|
||||
*/
|
||||
public function __construct(config $installer_config, iohandler_interface $iohandler)
|
||||
{
|
||||
$this->installer_config = $installer_config;
|
||||
$this->iohandler = $iohandler;
|
||||
|
||||
$this->available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
|
||||
|
||||
parent::__construct(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function check_requirements()
|
||||
{
|
||||
return $this->installer_config->get('do_update_files', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Check if data is sent
|
||||
if ($this->iohandler->get_input('submit_update_file', false))
|
||||
{
|
||||
$supported_methods = array('compression', 'ftp', 'direct_file');
|
||||
$method = $this->iohandler->get_input('method', 'compression');
|
||||
$update_method = (in_array($method, $supported_methods, true)) ? $method : 'compression';
|
||||
$this->installer_config->set('file_update_method', $update_method);
|
||||
|
||||
$compression = $this->iohandler->get_input('compression_method', '.zip');
|
||||
$supported_methods = array_keys($this->available_methods);
|
||||
$supported_methods[] = '.tar';
|
||||
$compression = (in_array($compression, $supported_methods, true)) ? $compression : '.zip';
|
||||
$this->installer_config->set('file_update_compression', $compression);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->iohandler->add_user_form_group('UPDATE_FILE_METHOD_TITLE', array(
|
||||
'method' => array(
|
||||
'label' => 'UPDATE_FILE_METHOD',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
array(
|
||||
'value' => 'compression',
|
||||
'label' => 'UPDATE_FILE_METHOD_DOWNLOAD',
|
||||
'selected' => true,
|
||||
),
|
||||
array(
|
||||
'value' => 'ftp',
|
||||
'label' => 'UPDATE_FILE_METHOD_FTP',
|
||||
'selected' => false,
|
||||
),
|
||||
array(
|
||||
'value' => 'direct_file',
|
||||
'label' => 'UPDATE_FILE_METHOD_FILESYSTEM',
|
||||
'selected' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
'compression_method' => array(
|
||||
'label' => 'SELECT_DOWNLOAD_FORMAT',
|
||||
'type' => 'select',
|
||||
'options' => $this->get_available_compression_methods(),
|
||||
),
|
||||
'submit_update_file' => array(
|
||||
'label' => 'SUBMIT',
|
||||
'type' => 'submit',
|
||||
),
|
||||
));
|
||||
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns form elements in an array of available compression methods
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_available_compression_methods()
|
||||
{
|
||||
$methods[] = array(
|
||||
'value' => '.tar',
|
||||
'label' => '.tar',
|
||||
'selected' => true,
|
||||
);
|
||||
|
||||
foreach ($this->available_methods as $type => $module)
|
||||
{
|
||||
if (!@extension_loaded($module))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$methods[] = array(
|
||||
'value' => $type,
|
||||
'label' => $type,
|
||||
'selected' => false,
|
||||
);
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
static public function get_step_count()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
<?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;
|
||||
use phpbb\install\helper\config;
|
||||
use phpbb\install\helper\iohandler\iohandler_interface;
|
||||
use phpbb\install\task_base;
|
||||
|
||||
class obtain_update_files extends task_base
|
||||
{
|
||||
/**
|
||||
* @var config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* @var iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $config
|
||||
* @param iohandler_interface $iohandler
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(config $config, iohandler_interface $iohandler, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->installer_config = $config;
|
||||
$this->iohandler = $iohandler;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
||||
parent::__construct(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function check_requirements()
|
||||
{
|
||||
return $this->installer_config->get('do_update_files', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Load update info file
|
||||
// The file should be checked in the requirements, so we assume that it exists
|
||||
$update_info_file = $this->phpbb_root_path . 'install/update/index.' . $this->php_ext;
|
||||
include($update_info_file);
|
||||
$info = (empty($update_info) || !is_array($update_info)) ? false : $update_info;
|
||||
|
||||
// If the file is invalid, abort mission
|
||||
if (!$info)
|
||||
{
|
||||
$this->iohandler->add_error_message('WRONG_INFO_FILE_FORMAT');
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
// Replace .php with $this->php_ext if needed
|
||||
if ($this->php_ext !== 'php')
|
||||
{
|
||||
$custom_extension = '.' . $this->php_ext;
|
||||
$info['files'] = preg_replace('#\.php$#i', $custom_extension, $info['files']);
|
||||
}
|
||||
|
||||
// Save update info
|
||||
$this->installer_config->set('update_info_unprocessed', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
static public function get_step_count()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
@@ -0,0 +1,164 @@
|
||||
<?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;
|
||||
use phpbb\install\helper\config;
|
||||
use phpbb\install\helper\iohandler\iohandler_interface;
|
||||
use phpbb\install\helper\update_helper;
|
||||
use phpbb\install\task_base;
|
||||
|
||||
class obtain_update_ftp_data extends task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var update_helper
|
||||
*/
|
||||
protected $update_helper;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $installer_config
|
||||
* @param iohandler_interface $iohandler
|
||||
* @param update_helper $update_helper
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(config $installer_config, iohandler_interface $iohandler, update_helper $update_helper, $php_ext)
|
||||
{
|
||||
$this->installer_config = $installer_config;
|
||||
$this->iohandler = $iohandler;
|
||||
$this->update_helper = $update_helper;
|
||||
$this->php_ext = $php_ext;
|
||||
|
||||
parent::__construct(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function check_requirements()
|
||||
{
|
||||
return ($this->installer_config->get('do_update_files', false) &&
|
||||
($this->installer_config->get('file_update_method', '') === 'ftp')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if ($this->iohandler->get_input('submit_ftp', false))
|
||||
{
|
||||
$this->update_helper->include_file('includes/functions_transfer.' . $this->php_ext);
|
||||
|
||||
$method = 'ftp';
|
||||
$methods = \transfer::methods();
|
||||
if (!in_array($method, $methods, true))
|
||||
{
|
||||
$method = $methods[0];
|
||||
}
|
||||
|
||||
$ftp_host = $this->iohandler->get_input('ftp_host', '');
|
||||
$ftp_user = $this->iohandler->get_input('ftp_user', '');
|
||||
$ftp_pass = htmlspecialchars_decode($this->iohandler->get_input('ftp_pass', ''));
|
||||
$ftp_path = $this->iohandler->get_input('ftp_path', '');
|
||||
$ftp_port = $this->iohandler->get_input('ftp_port', 21);
|
||||
$ftp_time = $this->iohandler->get_input('ftp_timeout', 10);
|
||||
|
||||
$this->installer_config->set('ftp_host', $ftp_host);
|
||||
$this->installer_config->set('ftp_user', $ftp_user);
|
||||
$this->installer_config->set('ftp_pass', $ftp_pass);
|
||||
$this->installer_config->set('ftp_path', $ftp_path);
|
||||
$this->installer_config->set('ftp_port', (int) $ftp_port);
|
||||
$this->installer_config->set('ftp_timeout', (int) $ftp_time);
|
||||
$this->installer_config->set('ftp_method', $method);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->iohandler->add_user_form_group('FTP_SETTINGS', array(
|
||||
'ftp_host' => array(
|
||||
'label' => 'FTP_HOST',
|
||||
'description' => 'FTP_HOST_EXPLAIN',
|
||||
'type' => 'text',
|
||||
),
|
||||
'ftp_user' => array(
|
||||
'label' => 'FTP_USERNAME',
|
||||
'description' => 'FTP_USERNAME_EXPLAIN',
|
||||
'type' => 'text',
|
||||
),
|
||||
'ftp_pass' => array(
|
||||
'label' => 'FTP_PASSWORD',
|
||||
'description' => 'FTP_PASSWORD_EXPLAIN',
|
||||
'type' => 'password',
|
||||
),
|
||||
'ftp_path' => array(
|
||||
'label' => 'FTP_ROOT_PATH',
|
||||
'description' => 'FTP_ROOT_PATH_EXPLAIN',
|
||||
'type' => 'text',
|
||||
),
|
||||
'ftp_port' => array(
|
||||
'label' => 'FTP_PORT',
|
||||
'description' => 'FTP_PORT_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => 21,
|
||||
),
|
||||
'ftp_timeout' => array(
|
||||
'label' => 'FTP_TIMEOUT',
|
||||
'description' => 'FTP_TIMEOUT_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => 10,
|
||||
),
|
||||
'submit_ftp' => array(
|
||||
'label' => 'SUBMIT',
|
||||
'type' => 'submit',
|
||||
),
|
||||
));
|
||||
|
||||
$this->iohandler->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 '';
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
<?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;
|
||||
use phpbb\install\helper\config;
|
||||
use phpbb\install\helper\iohandler\iohandler_interface;
|
||||
use phpbb\install\task_base;
|
||||
|
||||
class obtain_update_settings extends task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $installer_config
|
||||
* @param iohandler_interface $iohandler
|
||||
*/
|
||||
public function __construct(config $installer_config, iohandler_interface $iohandler)
|
||||
{
|
||||
$this->installer_config = $installer_config;
|
||||
$this->iohandler = $iohandler;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Check if data is sent
|
||||
if ($this->iohandler->get_input('submit_update', false))
|
||||
{
|
||||
$update_files = $this->iohandler->get_input('update_type', 'all') === 'all';
|
||||
$this->installer_config->set('do_update_files', $update_files);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->iohandler->add_user_form_group('UPDATE_TYPE', array(
|
||||
'update_type' => array(
|
||||
'label' => 'UPDATE_TYPE',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
array(
|
||||
'value' => 'all',
|
||||
'label' => 'UPDATE_TYPE_ALL',
|
||||
'selected' => true,
|
||||
),
|
||||
array(
|
||||
'value' => 'db_only',
|
||||
'label' => 'UPDATE_TYPE_DB_ONLY',
|
||||
'selected' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
'submit_update' => array(
|
||||
'label' => 'SUBMIT',
|
||||
'type' => 'submit',
|
||||
),
|
||||
));
|
||||
|
||||
$this->iohandler->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 '';
|
||||
}
|
||||
}
|
33
phpBB/phpbb/install/module/obtain_data/update_module.php
Normal file
33
phpBB/phpbb/install/module/obtain_data/update_module.php
Normal file
@@ -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 update_module extends \phpbb\install\module_base
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_navigation_stage_path()
|
||||
{
|
||||
return array('update', 0, 'obtain_data');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_step_count()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user