From 3dcaa48850bf823b238391fbf9c3f085092010bc Mon Sep 17 00:00:00 2001 From: CHItA Date: Sat, 13 Jun 2015 15:35:19 +0200 Subject: [ticket/13740] Move installer files to phpbb/install directory PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 240 ++++++ phpBB/phpbb/install/controller/install.php | 185 +++++ phpBB/phpbb/install/controller/installer_index.php | 79 ++ .../exception/cannot_build_container_exception.php | 22 + .../installer_config_not_writable_exception.php | 22 + .../install/exception/installer_exception.php | 22 + .../install/exception/invalid_dbms_exception.php | 22 + .../exception/invalid_service_name_exception.php | 69 ++ .../exception/module_not_found_exception.php | 42 ++ .../install/exception/task_not_found_exception.php | 42 ++ .../user_interaction_required_exception.php | 25 + phpBB/phpbb/install/helper/config.php | 351 +++++++++ phpBB/phpbb/install/helper/container_factory.php | 149 ++++ phpBB/phpbb/install/helper/database.php | 459 ++++++++++++ .../install/helper/iohandler/ajax_iohandler.php | 272 +++++++ .../iohandler_not_implemented_exception.php | 19 + phpBB/phpbb/install/helper/iohandler/factory.php | 76 ++ .../install/helper/iohandler/iohandler_base.php | 158 ++++ .../helper/iohandler/iohandler_interface.php | 145 ++++ .../helper/navigation/install_navigation.php | 50 ++ .../install/helper/navigation/main_navigation.php | 45 ++ .../helper/navigation/navigation_interface.php | 43 ++ .../helper/navigation/navigation_provider.php | 115 +++ phpBB/phpbb/install/installer.php | 286 +++++++ phpBB/phpbb/install/module/install_data/module.php | 28 + .../install/module/install_data/task/add_bots.php | 240 ++++++ .../module/install_data/task/add_languages.php | 121 +++ .../module/install_data/task/add_modules.php | 468 ++++++++++++ .../install/module/install_database/module.php | 28 + .../install_database/task/add_config_settings.php | 341 +++++++++ .../install_database/task/add_default_data.php | 161 ++++ .../module/install_database/task/create_schema.php | 214 ++++++ .../install/module/install_filesystem/module.php | 28 + .../install_filesystem/task/create_config_file.php | 235 ++++++ .../phpbb/install/module/install_finish/module.php | 28 + .../module/install_finish/task/notify_user.php | 129 ++++ .../install_finish/task/populate_migrations.php | 70 ++ phpBB/phpbb/install/module/obtain_data/module.php | 33 + .../module/obtain_data/task/obtain_admin_data.php | 219 ++++++ .../module/obtain_data/task/obtain_board_data.php | 186 +++++ .../obtain_data/task/obtain_database_data.php | 271 +++++++ .../module/obtain_data/task/obtain_email_data.php | 167 +++++ .../obtain_data/task/obtain_imagick_path.php | 89 +++ .../module/obtain_data/task/obtain_server_data.php | 203 +++++ phpBB/phpbb/install/module/requirements/module.php | 97 +++ .../module/requirements/task/check_filesystem.php | 273 +++++++ .../requirements/task/check_server_environment.php | 190 +++++ phpBB/phpbb/install/module_base.php | 252 +++++++ phpBB/phpbb/install/module_interface.php | 63 ++ phpBB/phpbb/install/schemas/index.htm | 10 + phpBB/phpbb/install/schemas/oracle_schema.sql | 37 + phpBB/phpbb/install/schemas/postgres_schema.sql | 80 ++ phpBB/phpbb/install/schemas/schema_data.sql | 821 +++++++++++++++++++++ phpBB/phpbb/install/task_base.php | 53 ++ phpBB/phpbb/install/task_interface.php | 65 ++ 55 files changed, 8138 insertions(+) create mode 100644 phpBB/phpbb/install/controller/helper.php create mode 100644 phpBB/phpbb/install/controller/install.php create mode 100644 phpBB/phpbb/install/controller/installer_index.php create mode 100644 phpBB/phpbb/install/exception/cannot_build_container_exception.php create mode 100644 phpBB/phpbb/install/exception/installer_config_not_writable_exception.php create mode 100644 phpBB/phpbb/install/exception/installer_exception.php create mode 100644 phpBB/phpbb/install/exception/invalid_dbms_exception.php create mode 100644 phpBB/phpbb/install/exception/invalid_service_name_exception.php create mode 100644 phpBB/phpbb/install/exception/module_not_found_exception.php create mode 100644 phpBB/phpbb/install/exception/task_not_found_exception.php create mode 100644 phpBB/phpbb/install/exception/user_interaction_required_exception.php create mode 100644 phpBB/phpbb/install/helper/config.php create mode 100644 phpBB/phpbb/install/helper/container_factory.php create mode 100644 phpBB/phpbb/install/helper/database.php create mode 100644 phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php create mode 100644 phpBB/phpbb/install/helper/iohandler/exception/iohandler_not_implemented_exception.php create mode 100644 phpBB/phpbb/install/helper/iohandler/factory.php create mode 100644 phpBB/phpbb/install/helper/iohandler/iohandler_base.php create mode 100644 phpBB/phpbb/install/helper/iohandler/iohandler_interface.php create mode 100644 phpBB/phpbb/install/helper/navigation/install_navigation.php create mode 100644 phpBB/phpbb/install/helper/navigation/main_navigation.php create mode 100644 phpBB/phpbb/install/helper/navigation/navigation_interface.php create mode 100644 phpBB/phpbb/install/helper/navigation/navigation_provider.php create mode 100644 phpBB/phpbb/install/installer.php create mode 100644 phpBB/phpbb/install/module/install_data/module.php create mode 100644 phpBB/phpbb/install/module/install_data/task/add_bots.php create mode 100644 phpBB/phpbb/install/module/install_data/task/add_languages.php create mode 100644 phpBB/phpbb/install/module/install_data/task/add_modules.php create mode 100644 phpBB/phpbb/install/module/install_database/module.php create mode 100644 phpBB/phpbb/install/module/install_database/task/add_config_settings.php create mode 100644 phpBB/phpbb/install/module/install_database/task/add_default_data.php create mode 100644 phpBB/phpbb/install/module/install_database/task/create_schema.php create mode 100644 phpBB/phpbb/install/module/install_filesystem/module.php create mode 100644 phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php create mode 100644 phpBB/phpbb/install/module/install_finish/module.php create mode 100644 phpBB/phpbb/install/module/install_finish/task/notify_user.php create mode 100644 phpBB/phpbb/install/module/install_finish/task/populate_migrations.php create mode 100644 phpBB/phpbb/install/module/obtain_data/module.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php create mode 100644 phpBB/phpbb/install/module/requirements/module.php create mode 100644 phpBB/phpbb/install/module/requirements/task/check_filesystem.php create mode 100644 phpBB/phpbb/install/module/requirements/task/check_server_environment.php create mode 100644 phpBB/phpbb/install/module_base.php create mode 100644 phpBB/phpbb/install/module_interface.php create mode 100644 phpBB/phpbb/install/schemas/index.htm create mode 100644 phpBB/phpbb/install/schemas/oracle_schema.sql create mode 100644 phpBB/phpbb/install/schemas/postgres_schema.sql create mode 100644 phpBB/phpbb/install/schemas/schema_data.sql create mode 100644 phpBB/phpbb/install/task_base.php create mode 100644 phpBB/phpbb/install/task_interface.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php new file mode 100644 index 0000000000..0df1ae71a4 --- /dev/null +++ b/phpBB/phpbb/install/controller/helper.php @@ -0,0 +1,240 @@ + + * @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\controller; + +use Symfony\Component\HttpFoundation\Response; + +/** + * A duplicate of \phpbb\controller\helper + * + * This class is necessary because of controller\helper's legacy function calls + * to page_header() page_footer() functions which has unavailable dependencies. + */ +class helper +{ + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var \phpbb\language\language_file_helper + */ + protected $lang_helper; + + /** + * @var \phpbb\install\helper\navigation\navigation_provider + */ + protected $navigation_provider; + + /** + * @var \phpbb\template\template + */ + protected $template; + + /** + * @var \phpbb\path_helper + */ + protected $path_helper; + + /** + * @var \phpbb\symfony_request + */ + protected $request; + + /** + * @var \phpbb\routing\router + */ + protected $router; + + /** + * @var string + */ + protected $phpbb_admin_path; + + /** + * @var string + */ + protected $phpbb_root_path; + + public function __construct(\phpbb\language\language $language, \phpbb\language\language_file_helper $lang_helper, \phpbb\install\helper\navigation\navigation_provider $nav, \phpbb\template\template $template, \phpbb\path_helper $path_helper, \phpbb\symfony_request $request, \phpbb\routing\router $router, $phpbb_root_path) + { + $this->language = $language; + $this->lang_helper = $lang_helper; + $this->navigation_provider = $nav; + $this->template = $template; + $this->path_helper = $path_helper; + $this->request = $request; + $this->router = $router; + $this->phpbb_root_path = $phpbb_root_path; + $this->phpbb_admin_path = $phpbb_root_path . 'adm/'; + } + + /** + * Automate setting up the page and creating the response object. + * + * @param string $template_file The template handle to render + * @param string $page_title The title of the page to output + * @param int $status_code The status code to be sent to the page header + * + * @return Response object containing rendered page + */ + public function render($template_file, $page_title = '', $status_code = 200) + { + $this->page_header($page_title); + + $this->template->set_filenames(array( + 'body' => $template_file, + )); + + return new Response($this->template->assign_display('body'), $status_code); + } + + /** + * Set default template variables + * + * @param string $page_title + */ + protected function page_header($page_title) + { + $this->template->assign_vars(array( + 'L_CHANGE' => $this->language->lang('CHANGE'), + 'L_COLON' => $this->language->lang('COLON'), + 'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'), + 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'), + 'L_SKIP' => $this->language->lang('SKIP'), + 'PAGE_TITLE' => $this->language->lang($page_title), + 'T_IMAGE_PATH' => htmlspecialchars($this->phpbb_admin_path) . 'images/', + 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . 'assets/javascript/jquery.min.js', + 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . 'adm/style', + 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . 'assets/', + + 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), + 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right', + 'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left', + 'S_CONTENT_ENCODING' => 'UTF-8', + + 'S_USER_LANG' => $this->language->lang('USER_LANG'), + ) + ); + + $this->render_navigation(); + } + + /** + * Render navigation + */ + protected function render_navigation() + { + // Get navigation items + $nav_array = $this->navigation_provider->get(); + + // @todo Sort navs by order + + $active_main_menu = $this->get_active_main_menu($nav_array); + + // Pass navigation to template + foreach ($nav_array as $key => $entry) + { + $this->template->assign_block_vars('t_block1', array( + 'L_TITLE' => $this->language->lang($entry['label']), + 'S_SELECTED' => ($active_main_menu === $key), + 'U_TITLE' => $this->route($entry['route']), + )); + + if (is_array($entry[0]) && $active_main_menu === $key) + { + // @todo Sort navs by order + + foreach ($entry[0] as $name => $sub_entry) + { + if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) + { + $this->template->assign_block_vars('l_block2', array( + 'L_TITLE' => $this->language->lang($sub_entry['label']), + 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), + 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), + 'STAGE_NAME' => $name, + )); + } + else + { + $this->template->assign_block_vars('l_block1', array( + 'L_TITLE' => $this->language->lang($sub_entry['label']), + 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), + 'U_TITLE' => $this->route($sub_entry['route']), + )); + } + } + } + } + } + + /** + * Returns path from route name + * + * @param string $route_name + * + * @return string + */ + public function route($route_name) + { + $url = $this->router->generate($route_name); + + return $url; + } + + /** + * Render language select form + */ + protected function render_language_select() + { + $langs = $this->lang_helper->get_available_languages(); + } + + /** + * Returns the name of the active main menu item + * + * @param array $nav_array + * + * @return string|bool Returns the name of the active main menu element, if the element not found, returns false + */ + protected function get_active_main_menu($nav_array) + { + $active_route = $this->request->get('_route'); + + foreach ($nav_array as $nav_name => $nav_options) + { + $current_menu = $nav_name; + + if (isset($nav_options['route']) && $nav_options['route'] === $active_route) + { + return $nav_name; + } + + if (is_array($nav_options[0])) + { + foreach ($nav_options[0] as $sub_menus) + { + if (isset($sub_menus['route']) &&$sub_menus['route'] === $active_route) + { + return $current_menu; + } + } + } + } + + return false; + } +} diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php new file mode 100644 index 0000000000..c1329b6456 --- /dev/null +++ b/phpBB/phpbb/install/controller/install.php @@ -0,0 +1,185 @@ + + * @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\controller; + +use phpbb\install\helper\config; +use phpbb\install\helper\navigation\navigation_provider; +use Symfony\Component\HttpFoundation\StreamedResponse; +use Symfony\Component\HttpFoundation\Response; +use phpbb\install\helper\iohandler\factory; +use phpbb\install\controller\helper; +use phpbb\template\template; +use phpbb\request\request_interface; +use phpbb\install\installer; +use phpbb\language\language; + +/** + * Controller for installing phpBB + */ +class install +{ + /** + * @var helper + */ + protected $controller_helper; + + /** + * @var config + */ + protected $installer_config; + + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var navigation_provider + */ + protected $menu_provider; + + /** + * @var language + */ + protected $language; + + /** + * @var template + */ + protected $template; + + /** + * @var request_interface + */ + protected $request; + + /** + * @var installer + */ + protected $installer; + + /** + * Constructor + * + * @param helper $helper + * @param config $install_config + * @param factory $factory + * @param navigation_provider $nav_provider + * @param language $language + * @param request_interface $request + * @param installer $installer + */ + public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer) + { + $this->controller_helper = $helper; + $this->installer_config = $install_config; + $this->iohandler_factory = $factory; + $this->menu_provider = $nav_provider; + $this->language = $language; + $this->template = $template; + $this->request = $request; + $this->installer = $installer; + } + + /** + * Controller logic + * + * @return Response|StreamedResponse + */ + public function handle() + { + // @todo check that phpBB is not already installed + + $this->template->assign_vars(array( + 'U_ACTION' => $this->controller_helper->route('phpbb_installer_install'), + )); + + // Set up input-output handler + if ($this->request->is_ajax()) + { + $this->iohandler_factory->set_environment('ajax'); + } + else + { + $this->iohandler_factory->set_environment('nojs'); + } + + // Set the appropriate input-output handler + $this->installer->set_iohandler($this->iohandler_factory->get()); + + // Set up navigation + $nav_data = $this->installer_config->get_navigation_data(); + /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ + $iohandler = $this->iohandler_factory->get(); + + // Set active navigation stage + if (isset($nav_data['active']) && is_array($nav_data['active'])) + { + $iohandler->set_active_stage_menu($nav_data['active']); + $this->menu_provider->set_nav_property($nav_data['active'], array( + 'selected' => true, + 'completed' => false, + )); + } + + // Set finished navigation stages + if (isset($nav_data['finished']) && is_array($nav_data['finished'])) + { + foreach ($nav_data['finished'] as $finished_stage) + { + $iohandler->set_finished_stage_menu($finished_stage); + $this->menu_provider->set_nav_property($finished_stage, array( + 'selected' => false, + 'completed' => true, + )); + } + } + + if ($this->request->is_ajax()) + { + $installer = $this->installer; + $response = new StreamedResponse(); + $response->setCallback(function() use ($installer) { + $installer->run(); + }); + + return $response; + } + else + { + // Determine whether the installation was started or not + if (true) + { + // Set active stage + $this->menu_provider->set_nav_property( + array('install', 0, 'introduction'), + array( + 'selected' => true, + 'completed' => false, + ) + ); + + // If not, let's render the welcome page + $this->template->assign_vars(array( + 'SHOW_INSTALL_START_FORM' => true, + 'TITLE' => $this->language->lang('INSTALL_INTRO'), + 'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY'), + )); + return $this->controller_helper->render('installer_install.html', 'INSTALL'); + } + + // @todo: implement no js controller logic + } + } +} diff --git a/phpBB/phpbb/install/controller/installer_index.php b/phpBB/phpbb/install/controller/installer_index.php new file mode 100644 index 0000000000..3d5224f1be --- /dev/null +++ b/phpBB/phpbb/install/controller/installer_index.php @@ -0,0 +1,79 @@ + + * @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\controller; + +class installer_index +{ + /** + * @var helper + */ + protected $helper; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var \phpbb\template\template + */ + protected $template; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param helper $helper + * @param \phpbb\language\language $language + * @param \phpbb\template\template $template + * @param string $phpbb_root_path + */ + public function __construct(helper $helper, \phpbb\language\language $language, \phpbb\template\template $template, $phpbb_root_path) + { + $this->helper = $helper; + $this->language = $language; + $this->template = $template; + $this->phpbb_root_path = $phpbb_root_path; + } + + public function handle($mode) + { + switch ($mode) + { + case "intro": + $title = $this->language->lang('INTRODUCTION_TITLE'); + $body = $this->language->lang('INTRODUCTION_BODY'); + break; + case "support": + $title = $this->language->lang('SUPPORT_TITLE'); + $body = $this->language->lang('SUPPORT_BODY'); + break; + case "license": + $title = $this->language->lang('LICENSE_TITLE'); + $body = implode("
\n", file($this->phpbb_root_path . 'docs/LICENSE.txt')); + break; + } + + $this->template->assign_vars(array( + 'TITLE' => $title, + 'BODY' => $body, + )); + + return $this->helper->render('install_main.html', $title); + } +} diff --git a/phpBB/phpbb/install/exception/cannot_build_container_exception.php b/phpBB/phpbb/install/exception/cannot_build_container_exception.php new file mode 100644 index 0000000000..11be507bc9 --- /dev/null +++ b/phpBB/phpbb/install/exception/cannot_build_container_exception.php @@ -0,0 +1,22 @@ + + * @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\exception; + +/** + * This exception should be thrown when + */ +class cannot_build_container_exception extends installer_exception +{ + +} diff --git a/phpBB/phpbb/install/exception/installer_config_not_writable_exception.php b/phpBB/phpbb/install/exception/installer_config_not_writable_exception.php new file mode 100644 index 0000000000..3f3b03f178 --- /dev/null +++ b/phpBB/phpbb/install/exception/installer_config_not_writable_exception.php @@ -0,0 +1,22 @@ + + * @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\exception; + +/** + * Exception for the event when installer config is not writable to disk + */ +class installer_config_not_writable_exception extends installer_exception +{ + +} diff --git a/phpBB/phpbb/install/exception/installer_exception.php b/phpBB/phpbb/install/exception/installer_exception.php new file mode 100644 index 0000000000..c37950d05c --- /dev/null +++ b/phpBB/phpbb/install/exception/installer_exception.php @@ -0,0 +1,22 @@ + + * @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\exception; + +/** + * Installer's base exception + */ +class installer_exception extends \Exception +{ + +} diff --git a/phpBB/phpbb/install/exception/invalid_dbms_exception.php b/phpBB/phpbb/install/exception/invalid_dbms_exception.php new file mode 100644 index 0000000000..ccb35bc237 --- /dev/null +++ b/phpBB/phpbb/install/exception/invalid_dbms_exception.php @@ -0,0 +1,22 @@ + + * @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\exception; + +/** + * This exception should be thrown when + */ +class invalid_dbms_exception extends installer_exception +{ + +} diff --git a/phpBB/phpbb/install/exception/invalid_service_name_exception.php b/phpBB/phpbb/install/exception/invalid_service_name_exception.php new file mode 100644 index 0000000000..e64cd2026f --- /dev/null +++ b/phpBB/phpbb/install/exception/invalid_service_name_exception.php @@ -0,0 +1,69 @@ + + * @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\exception; + +class invalid_service_name_exception extends installer_exception +{ + /** + * @var string + */ + private $params; + + /** + * @var string + */ + private $error; + + /** + * Constructor + * + * @param string $error The name of the missing installer module + * @param array $params Additional values for message translation + */ + public function __construct($error, $params = array()) + { + $this->error = $error; + $this->params = $params; + } + + /** + * Returns the language entry's name for the error + * + * @return string + */ + public function get_error() + { + return $this->error; + } + + /** + * Returns parameters for the language entry, if there is any + * + * @return array + */ + public function get_params() + { + return $this->params; + } + + /** + * Returns true, if there are any parameters set + * + * @return bool + */ + public function has_params() + { + return (sizeof($this->params) !== 0); + } +} diff --git a/phpBB/phpbb/install/exception/module_not_found_exception.php b/phpBB/phpbb/install/exception/module_not_found_exception.php new file mode 100644 index 0000000000..9fa03fad6e --- /dev/null +++ b/phpBB/phpbb/install/exception/module_not_found_exception.php @@ -0,0 +1,42 @@ + + * @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\exception; + +class module_not_found_exception extends installer_exception +{ + /** + * @var string + */ + private $module_service_name; + + /** + * Constructor + * + * @param string $module_service_name The name of the missing installer module + */ + public function __construct($module_service_name) + { + $this->module_service_name = $module_service_name; + } + + /** + * Returns the missing installer module's service name + * + * @return string + */ + public function get_module_service_name() + { + return $this->module_service_name; + } +} diff --git a/phpBB/phpbb/install/exception/task_not_found_exception.php b/phpBB/phpbb/install/exception/task_not_found_exception.php new file mode 100644 index 0000000000..11486cc6b0 --- /dev/null +++ b/phpBB/phpbb/install/exception/task_not_found_exception.php @@ -0,0 +1,42 @@ + + * @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\exception; + +class task_not_found_exception extends installer_exception +{ + /** + * @var string + */ + private $task_service_name; + + /** + * Constructor + * + * @param string $task_service_name The name of the missing installer module + */ + public function __construct($task_service_name) + { + $this->task_service_name = $task_service_name; + } + + /** + * Returns the missing installer task's service name + * + * @return string + */ + public function get_task_service_name() + { + return $this->task_service_name; + } +} diff --git a/phpBB/phpbb/install/exception/user_interaction_required_exception.php b/phpBB/phpbb/install/exception/user_interaction_required_exception.php new file mode 100644 index 0000000000..d65a448841 --- /dev/null +++ b/phpBB/phpbb/install/exception/user_interaction_required_exception.php @@ -0,0 +1,25 @@ + + * @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\exception; + +/** + * This exception should be thrown when user interaction is inevitable + * + * Note: Please note that the output should already be setup for the user + * when you use throw this exception + */ +class user_interaction_required_exception extends installer_exception +{ + +} diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php new file mode 100644 index 0000000000..5c1348c06d --- /dev/null +++ b/phpBB/phpbb/install/helper/config.php @@ -0,0 +1,351 @@ + + * @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\helper; + +use phpbb\install\exception\installer_config_not_writable_exception; + +/** + * Stores common settings and installation status + */ +class config +{ + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * Array which contains config settings for the installer + * + * The array will also store all the user input, as well as any + * data that is passed to other tasks by a task. + * + * @var array + */ + protected $installer_config; + + /** + * @var string + */ + protected $install_config_file; + + /** + * @var \phpbb\php\ini + */ + protected $php_ini; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Array containing progress information + * + * @var array + */ + protected $progress_data; + + /** + * Array containing system information + * + * The array contains run time and memory limitations. + * + * @var array + */ + protected $system_data; + + /** + * Array containing navigation bar information + * + * @var array + */ + protected $navigation_data; + + /** + * Constructor + */ + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \phpbb\php\ini $php_ini, $phpbb_root_path) + { + $this->filesystem = $filesystem; + $this->php_ini = $php_ini; + $this->phpbb_root_path = $phpbb_root_path; + + // Set up data arrays + $this->navigation_data = array(); + $this->installer_config = array(); + $this->system_data = array(); + $this->progress_data = array( + 'last_task_module_index' => 0, + 'last_task_module_name' => '', // Stores the service name of the latest finished module + 'last_task_index' => 0, + 'last_task_name' => '', // Stores the service name of the latest finished task + 'max_task_progress' => 0, + 'current_task_progress' => 0, + ); + + $this->install_config_file = $this->phpbb_root_path . 'store/install_config.php'; + + $this->setup_system_data(); + } + + /** + * Returns data for a specified parameter + * + * @param string $param_name Name of the parameter to return + * @param mixed $default Default value to return when the specified data + * does not exist. + * + * @return mixed value of the specified parameter or the default value if the data + * cannot be recovered. + */ + public function get($param_name, $default = false) + { + return (isset($this->installer_config[$param_name])) ? $this->installer_config[$param_name] : $default; + } + + /** + * Sets a parameter in installer_config + * + * @param string $param_name Name of the parameter + * @param mixed $value Values to set the parameter + */ + public function set($param_name, $value) + { + $this->installer_config = array_merge($this->installer_config, array( + $param_name => $value, + )); + } + + /** + * Returns system parameter + * + * @param string $param_name Name of the parameter + * + * @return mixed Returns system parameter if it is defined, false otherwise + */ + public function system_get($param_name) + { + return (isset($this->system_data[$param_name])) ? $this->system_data[$param_name] : false; + } + + /** + * Returns remaining time until the run time limit + * + * @return int Remaining time until the run time limit in seconds + */ + public function get_time_remaining() + { + return ($this->system_data['start_time'] + $this->system_data['max_execution_time']) - time(); + } + + /** + * Returns remaining memory available for PHP + * + * @return int Remaining memory until reaching the limit + */ + public function get_memory_remaining() + { + if (function_exists('memory_get_usage')) + { + return ($this->system_data['memory_limit'] - memory_get_usage()); + } + + // If we cannot get the information then just return a positive number (and cross fingers) + return 1; + } + + /** + * Saves the latest executed task + * + * @param string $task_service_name Name of the installer task service + * @param int $task_index Index of the task in the task list array + */ + public function set_finished_task($task_service_name, $task_index) + { + $this->progress_data['last_task_name'] = $task_service_name; + $this->progress_data['last_task_index'] = $task_index; + } + + /** + * Set active module + * + * @param string $module_service_name Name of the installer module service + * @param int $module_index Index of the module in the module list array + */ + public function set_active_module($module_service_name, $module_index) + { + $this->progress_data['last_task_module_name'] = $module_service_name; + $this->progress_data['last_task_module_index'] = $module_index; + } + + /** + * Getter for progress data + * + * @return array + */ + public function get_progress_data() + { + return $this->progress_data; + } + + /** + * Recovers install configuration from file + */ + public function load_config() + { + if (!$this->filesystem->exists($this->install_config_file)) + { + return; + } + + $file_content = @file_get_contents($this->install_config_file); + $serialized_data = trim(substr($file_content, 8)); + $unserialized_data = unserialize($serialized_data); + + $this->installer_config = $unserialized_data['installer_config']; + $this->progress_data = $unserialized_data['progress_data']; + $this->navigation_data = $unserialized_data['navigation_data']; + } + + /** + * Dumps install configuration to disk + */ + public function save_config() + { + // Create array to save + $save_array = array( + 'installer_config' => $this->installer_config, + 'progress_data' => $this->progress_data, + 'navigation_data' => $this->navigation_data, + ); + + // Create file content + $file_content = 'install_config_file, 'w'); + if (!$fp) + { + throw new installer_config_not_writable_exception(); + } + + fwrite($fp, $file_content); + fclose($fp); + } + + /** + * Increments the task progress + * + * @param int $increment_by The amount to increment by + */ + public function increment_current_task_progress($increment_by = 1) + { + $this->progress_data['current_task_progress'] += $increment_by; + + if ($this->progress_data['current_task_progress'] > $this->progress_data['max_task_progress']) + { + $this->progress_data['current_task_progress'] = $this->progress_data['max_task_progress']; + } + } + + /** + * Sets the task progress to a specific number + * + * @param int $task_progress The task progress number to be set + */ + public function set_current_task_progress($task_progress) + { + $this->progress_data['current_task_progress'] = $task_progress; + } + + /** + * Sets the number of tasks belonging to the installer in the current mode. + * + * @param int $task_progress_count Number of tasks + */ + public function set_task_progress_count($task_progress_count) + { + $this->progress_data['max_task_progress'] = $task_progress_count; + } + + /** + * Returns the number of the current task being executed + * + * @return int + */ + public function get_current_task_progress() + { + return $this->progress_data['current_task_progress']; + } + + /** + * Returns the number of tasks belonging to the installer in the current mode. + * + * @return int + */ + public function get_task_progress_count() + { + return $this->progress_data['max_task_progress']; + } + + /** + * Marks stage as completed in the navigation bar + * + * @param array $nav_path Array to the navigation elem + */ + public function set_finished_navigation_stage($nav_path) + { + $this->navigation_data['finished'][] = $nav_path; + } + + /** + * Marks stage as active in the navigation bar + * + * @param array $nav_path Array to the navigation elem + */ + public function set_active_navigation_stage($nav_path) + { + $this->navigation_data['active'] = $nav_path; + } + + /** + * Returns navigation data + * + * @return array + */ + public function get_navigation_data() + { + return $this->navigation_data; + } + + /** + * Filling up system_data array + */ + protected function setup_system_data() + { + // Query maximum runtime from php.ini + $execution_time = $this->php_ini->get_int('max_execution_time'); + $execution_time = min(15, $execution_time / 2); + $this->system_data['max_execution_time'] = $execution_time; + + // Set start time + $this->system_data['start_time'] = time(); + + // Get memory limit + $this->system_data['memory_limit'] = $this->php_ini->get_bytes('memory_limit'); + } +} diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php new file mode 100644 index 0000000000..255f8f428e --- /dev/null +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -0,0 +1,149 @@ + + * @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\helper; + +use phpbb\install\exception\cannot_build_container_exception; + +class container_factory +{ + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * @var \phpbb\request\request + */ + protected $request; + + /** + * The full phpBB container + * + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; + + /** + * Constructor + * + * @param \phpbb\request\request $request Request interface + * @param string $phpbb_root_path Path to phpBB's root + * @param string $php_ext Extension of PHP files + */ + public function __construct(\phpbb\request\request $request, $phpbb_root_path, $php_ext) + { + $this->request = $request; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->container = null; + } + + /** + * Container getter + * + * @param null|string $service_name Name of the service to return + * + * @return \Symfony\Component\DependencyInjection\ContainerInterface|Object phpBB's dependency injection container + * or the service specified in $service_name + * + * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built + * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException If the service is not defined + * @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException When a circular reference is detected + * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException When the service is not defined + */ + public function get($service_name = null) + { + // Check if container was built, if not try to build it + if ($this->container === null) + { + // Check whether container can be built + // We need config.php for that so let's check if it has been set up yet + if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) + { + $this->build_container(); + } + else + { + throw new cannot_build_container_exception(); + } + } + + return ($service_name === null) ? $this->container : $this->container->get($service_name); + } + + /** + * Returns the specified parameter from the container + * + * @param string $param_name + * + * @return mixed + */ + public function get_parameter($param_name) + { + return $this->container->getParameter($param_name); + } + + /** + * Build dependency injection container + */ + protected function build_container() + { + // If the container has been already built just return. + // Although this should never happen + if ($this->container instanceof \Symfony\Component\DependencyInjection\ContainerInterface) + { + return; + } + + $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); + $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); + + // For BC with functions that we need during install + global $phpbb_container; + + $disable_super_globals = $this->request->super_globals_disabled(); + + // This is needed because container_builder::get_env_parameters() uses $_SERVER + if ($disable_super_globals) + { + $this->request->enable_super_globals(); + } + + $this->container = $phpbb_container = $phpbb_container_builder + ->with_config($phpbb_config_php_file) + ->without_cache() + ->without_compiled_container() + ->get_container(); + + // Setting request is required for the compatibility globals as those are generated from + // this container + $this->container->register('request')->setSynthetic(true); + $this->container->set('request', $this->request); + $this->container->compile(); + + // Restore super globals to previous state + if ($disable_super_globals) + { + $this->request->disable_super_globals(); + } + + // Get compatibilty globals + require ($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); + } +} diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php new file mode 100644 index 0000000000..d728c8b93b --- /dev/null +++ b/phpBB/phpbb/install/helper/database.php @@ -0,0 +1,459 @@ + + * @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\helper; + +use phpbb\install\exception\invalid_dbms_exception; + +/** + * Database related general functionality for installer + */ +class database +{ + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var array + */ + protected $supported_dbms; + + /** + * Constructor + * + * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem interface + * @param string $phpbb_root_path Path to phpBB's root + */ + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path) + { + $this->filesystem = $filesystem; + + // DBMS supported by phpBB + $this->supported_dbms = array( + // Note: php 5.5 alpha 2 deprecated mysql. + // Keep mysqli before mysql in this list. + 'mysqli' => array( + 'LABEL' => 'MySQL with MySQLi Extension', + 'SCHEMA' => 'mysql_41', + 'MODULE' => 'mysqli', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\mysqli', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mysql' => array( + 'LABEL' => 'MySQL', + 'SCHEMA' => 'mysql', + 'MODULE' => 'mysql', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\mysql', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssql' => array( + 'LABEL' => 'MS SQL Server 2000+', + 'SCHEMA' => 'mssql', + 'MODULE' => 'mssql', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssql', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssql_odbc'=> array( + 'LABEL' => 'MS SQL Server [ ODBC ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'odbc', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssql_odbc', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssqlnative' => array( + 'LABEL' => 'MS SQL Server 2005+ [ Native ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'sqlsrv', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssqlnative', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'oracle' => array( + 'LABEL' => 'Oracle', + 'SCHEMA' => 'oracle', + 'MODULE' => 'oci8', + 'DELIM' => '/', + 'DRIVER' => 'phpbb\db\driver\oracle', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'postgres' => array( + 'LABEL' => 'PostgreSQL 8.3+', + 'SCHEMA' => 'postgres', + 'MODULE' => 'pgsql', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\postgres', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'sqlite' => array( + 'LABEL' => 'SQLite', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'sqlite3' => array( + 'LABEL' => 'SQLite3', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite3', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite3', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + ); + } + + /** + * Returns an array of available DBMS supported by phpBB + * + * If a DBMS is specified it will only return data for that DBMS + * and will load its extension if necessary. + * + * @param mixed $dbms name of the DBMS that's info is required or false for all DBMS info + * @param bool $return_unavailable set it to true if you expect unavailable but supported DBMS + * returned as well + * @param bool $only_20x_options set it to true if you only want to recover 2.0.x options + * + * @return array Array of available and supported DBMS + */ + public function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false) + { + $available_dbms = $this->supported_dbms; + + if ($dbms) + { + if (isset($this->supported_dbms[$dbms])) + { + $available_dbms = array($dbms => $this->supported_dbms[$dbms]); + } + else + { + return array(); + } + } + + $any_dbms_available = false; + foreach ($available_dbms as $db_name => $db_array) + { + if ($only_20x_options && !$db_array['2.0.x']) + { + if ($return_unavailable) + { + $available_dbms[$db_name]['AVAILABLE'] = false; + } + else + { + unset($available_dbms[$db_name]); + } + + continue; + } + + $dll = $db_array['MODULE']; + if (!@extension_loaded($dll)) + { + if ($return_unavailable) + { + $available_dbms[$db_name]['AVAILABLE'] = false; + } + else + { + unset($available_dbms[$db_name]); + } + + continue; + } + + $any_dbms_available = true; + } + + if ($return_unavailable) + { + $available_dbms['ANY_DB_SUPPORT'] = $any_dbms_available; + } + + return $available_dbms; + } + + /** + * Removes "/* style" as well as "# style" comments from $input. + * + * @param string $sql_query Input string + * + * @return string Input string with comments removed + */ + public function remove_comments($sql_query) + { + // Remove /* */ comments (http://ostermiller.org/findcomment.html) + $sql_query = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $sql_query); + + // Remove # style comments + $sql_query = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql_query)); + + return $sql_query; + } + + /** + * split_sql_file() will split an uploaded sql file into single sql statements. + * + * Note: expects trim() to have already been run on $sql. + * + * @param string $sql SQL statements + * @param string $delimiter Delimiter between sql statements + * + * @return array Array of sql statements + */ + public function split_sql_file($sql, $delimiter) + { + $sql = str_replace("\r" , '', $sql); + $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql); + + $data = array_map('trim', $data); + + // The empty case + $end_data = end($data); + + if (empty($end_data)) + { + unset($data[key($data)]); + } + + return $data; + } + + /** + * Validates table prefix + * + * @param string $dbms The selected dbms + * @param string $table_prefix The table prefix to validate + * + * @return bool|array true if table prefix is valid, array of errors otherwise + * + * @throws \phpbb\install\exception\invalid_dbms_exception When $dbms is not a valid + */ + public function validate_table_prefix($dbms, $table_prefix) + { + $errors = array(); + + if (!preg_match('#^[a-zA-Z][a-zA-Z0-9_]*$#', $table_prefix)) + { + $errors[] = array( + 'title' => 'INST_ERR_DB_INVALID_PREFIX', + ); + } + + // Do dbms specific checks + $dbms_info = $this->get_available_dbms($dbms); + switch ($dbms_info[$dbms]['SCHEMA']) + { + case 'mysql': + case 'mysql_41': + $prefix_length = 36; + break; + case 'mssql': + $prefix_length = 90; + break; + case 'oracle': + $prefix_length = 6; + break; + case 'postgres': + $prefix_length = 36; + break; + case 'sqlite': + $prefix_length = 200; + break; + default: + throw new invalid_dbms_exception(); + break; + } + + // Check the prefix length to ensure that index names are not too long + if (strlen($table_prefix) > $prefix_length) + { + $errors[] = array( + 'title' => array('INST_ERR_PREFIX_TOO_LONG', $prefix_length), + ); + } + + return (empty($errors)) ? true : $errors; + } + + /** + * Check if the user provided database parameters are correct + * + * This function checks the database connection data and also checks for + * any other problems that could cause an error during the installation + * such as if there is any database table names conflicting. + * + * Note: The function assumes that $table_prefix has been already validated + * with validate_table_prefix(). + * + * @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 array|bool Returns true if test is successful, array of errors otherwise + */ + public function check_database_connection($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix) + { + $dbms_info = $this->get_available_dbms($dbms); + $dbms_info = $dbms_info[$dbms]; + $errors = array(); + + // Instantiate it and set return on error true + /** @var \phpbb\db\driver\driver_interface $db */ + $db = new $dbms_info['DRIVER']; + $db->sql_return_on_error(true); + + // Check that we actually have a database name before going any further + if (!in_array($dbms_info['SCHEMA'], array('sqlite', 'oracle')) && $dbname === '') + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_NAME', + ); + } + + // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea + if ($dbms_info['SCHEMA'] === 'sqlite' + && stripos($this->filesystem->realpath($dbhost), $this->filesystem->realpath($this->phpbb_root_path) === 0)) + { + $errors[] = array( + 'title' =>'INST_ERR_DB_FORUM_PATH', + ); + } + + // Try to connect to db + if (is_array($db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, false, true))) + { + $db_error = $db->sql_error(); + $errors[] = array( + 'title' => 'INST_ERR_DB_CONNECT', + 'description' => ($db_error['message']) ? utf8_convert_message($db_error['message']) : 'INST_ERR_DB_NO_ERROR', + ); + } + else + { + // Check if there is any table name collisions + $temp_prefix = strtolower($table_prefix); + $table_ary = array( + $temp_prefix . 'attachments', + $temp_prefix . 'config', + $temp_prefix . 'sessions', + $temp_prefix . 'topics', + $temp_prefix . 'users', + ); + + $db_tools_factory = new \phpbb\db\tools\factory(); + $db_tools = $db_tools_factory->get($db); + $tables = $db_tools->sql_list_tables(); + $tables = array_map('strtolower', $tables); + $table_intersect = array_intersect($tables, $table_ary); + + if (sizeof($table_intersect)) + { + $errors[] = array( + 'title' => 'INST_ERR_PREFIX', + ); + } + + // Check if database version is supported + switch ($dbms) + { + case 'mysqli': + if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<')) + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_MYSQLI', + ); + } + break; + case 'sqlite': + if (version_compare(sqlite_libversion(), '2.8.2', '<')) + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_SQLITE', + ); + } + break; + case 'sqlite3': + $version = \SQLite3::version(); + if (version_compare($version['versionString'], '3.6.15', '<')) + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_SQLITE3', + ); + } + break; + case 'oracle': + $sql = "SELECT * + FROM NLS_DATABASE_PARAMETERS + WHERE PARAMETER = 'NLS_RDBMS_VERSION' + OR PARAMETER = 'NLS_CHARACTERSET'"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $stats[$row['parameter']] = $row['value']; + } + $db->sql_freeresult($result); + + if (version_compare($stats['NLS_RDBMS_VERSION'], '9.2', '<') && $stats['NLS_CHARACTERSET'] !== 'UTF8') + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_ORACLE', + ); + } + break; + case 'postgres': + $sql = "SHOW server_encoding;"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row['server_encoding'] !== 'UNICODE' && $row['server_encoding'] !== 'UTF8') + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_POSTGRES', + ); + } + break; + } + } + + return (empty($errors)) ? true : $errors; + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php new file mode 100644 index 0000000000..71571fecba --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -0,0 +1,272 @@ + + * @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\helper\iohandler; + +/** + * Input-Output handler for the AJAX frontend + */ +class ajax_iohandler extends iohandler_base +{ + /** + * @var \phpbb\request\request_interface + */ + protected $request; + + /** + * @var \phpbb\template\template + */ + protected $template; + + /** + * @var string + */ + protected $form; + + /** + * @var bool + */ + protected $request_client_refresh; + + /** + * @var array + */ + protected $nav_data; + + /** + * Constructor + * + * @param \phpbb\request\request_interface $request HTTP request interface + * @param \phpbb\template\template $template Template engine + */ + public function __construct(\phpbb\request\request_interface $request, \phpbb\template\template $template) + { + $this->request = $request; + $this->template = $template; + $this->form = ''; + $this->nav_data = array(); + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + public function get_input($name, $default, $multibyte = false) + { + return $this->request->variable($name, $default, $multibyte); + } + + /** + * {@inheritdoc} + */ + public function get_server_variable($name, $default = '') + { + return $this->request->server($name, $default); + } + + /** + * {@inheritdoc} + */ + public function get_header_variable($name, $default = '') + { + return $this->request->header($name, $default); + } + + /** + * {@inheritdoc} + */ + public function is_secure() + { + return $this->request->is_secure(); + } + + /** + * {@inheritdoc} + */ + public function add_user_form_group($title, $form) + { + // + // This code is pretty ugly... but works + // + + $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); + + $this->template->assign_block_vars('options', array( + 'LEGEND' => $this->language->lang($title), + 'S_LEGEND' => true, + )); + + foreach ($form as $input_name => $input_options) + { + if (!isset($input_options['type'])) + { + continue; + } + + $tpl_ary = array(); + + $tpl_ary['TYPE'] = $input_options['type']; + $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); + $tpl_ary['KEY'] = $input_name; + $tpl_ary['S_EXPLAIN'] = false; + + if (isset($input_options['default'])) + { + $default = $input_options['default']; + $default = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', array($this, 'lang_replace_callback'), $default); + $tpl_ary['DEFAULT'] = $default; + } + + if (isset($input_options['description'])) + { + $tpl_ary['TITLE_EXPLAIN'] = $this->language->lang($input_options['description']); + $tpl_ary['S_EXPLAIN'] = true; + } + + if (in_array($input_options['type'], array('select', 'radio'))) + { + for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) + { + if (isset($input_options['options'][$i]['label'])) + { + $input_options['options'][$i]['label'] = $this->language->lang($input_options['options'][$i]['label']); + } + } + + $tpl_ary['OPTIONS'] = $input_options['options']; + } + + $this->template->assign_block_vars('options', $tpl_ary); + } + + $this->template->set_filenames(array( + 'form_install' => 'installer_form.html', + )); + + $this->form = $this->template->assign_display('form_install'); + } + + /** + * {@inheritdoc} + */ + public function send_response() + { + $json_data_array = $this->prepare_json_array(); + $json_data = json_encode($json_data_array); + + // Try to push content to the browser + print (str_pad(' ', 4096) . "\n"); + print ($json_data . "\n\n"); + flush(); + } + + /** + * Prepares iohandler's data to be sent out to the client. + * + * @return array + */ + protected function prepare_json_array() + { + $json_array = array( + 'errors' => $this->errors, + 'warnings' => $this->warnings, + 'logs' => $this->logs, + ); + + if (!empty($this->form)) + { + $json_array['form'] = $this->form; + $this->form = ''; + } + + // If current task name is set, we push progress message to the client side + if (!empty($this->current_task_name)) + { + $json_array['progress'] = array( + 'task_name' => $this->current_task_name, + 'task_num' => $this->current_task_progress, + 'task_count' => $this->task_progress_count, + ); + } + + if (!empty($this->nav_data)) + { + $json_array['nav'] = $this->nav_data; + } + + $this->errors = array(); + $this->warnings = array(); + $this->logs = array(); + $this->nav_data = array(); + + if ($this->request_client_refresh) + { + $json_array['refresh'] = true; + $this->request_client_refresh = false; + } + + return $json_array; + } + + /** + * {@inheritdoc} + */ + public function set_progress($task_lang_key, $task_number) + { + parent::set_progress($task_lang_key, $task_number); + $this->send_response(); + } + + /** + * {@inheritdoc} + */ + public function request_refresh() + { + $this->request_client_refresh = true; + } + + /** + * {@inheritdoc} + */ + public function set_active_stage_menu($menu_path) + { + $this->nav_data['active'] = $menu_path[sizeof($menu_path) - 1]; + $this->send_response(); + } + + /** + * {@inheritdoc} + */ + public function set_finished_stage_menu($menu_path) + { + $this->nav_data['finished'][] = $menu_path[sizeof($menu_path) - 1]; + $this->send_response(); + } + + /** + * Callback function for language replacing + * + * @param array $matches + * @return string + */ + public function lang_replace_callback($matches) + { + if (!empty($matches[1])) + { + return $this->language->lang($matches[1]); + } + + return ''; + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/exception/iohandler_not_implemented_exception.php b/phpBB/phpbb/install/helper/iohandler/exception/iohandler_not_implemented_exception.php new file mode 100644 index 0000000000..f2ddeda6f7 --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/exception/iohandler_not_implemented_exception.php @@ -0,0 +1,19 @@ + + * @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\helper\iohandler\exception; + +class iohandler_not_implemented_exception extends \Exception +{ + +} diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php new file mode 100644 index 0000000000..0af75b78ae --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -0,0 +1,76 @@ + + * @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\helper\iohandler; + +use phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception; + +/** + * Input-output handler factory + */ +class factory +{ + /** + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; + + /** + * @var string + */ + protected $environment; + + /** + * Constructor + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Dependency injection container + */ + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container) + { + $this->container = $container; + $this->environment = null; + } + + /** + * @param string $environment The name of the input-output handler to use + */ + public function set_environment($environment) + { + $this->environment = $environment; + } + + /** + * Factory getter for iohandler + * + * @return \phpbb\install\helper\iohandler\iohandler_interface + * + * @throws \phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception + * When the specified iohandler_interface does not exists + */ + public function get() + { + switch ($this->environment) + { + case 'ajax': + return $this->container->get('installer.helper.iohandler_ajax'); + break; + case 'nojs': + // @todo replace this + return $this->container->get('installer.helper.iohandler_ajax'); + break; + default: + throw new iohandler_not_implemented_exception(); + break; + } + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php new file mode 100644 index 0000000000..f767ecf4e9 --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -0,0 +1,158 @@ + + * @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\helper\iohandler; + +/** + * Base class for installer input-output handlers + */ +abstract class iohandler_base implements iohandler_interface +{ + /** + * Array of errors + * + * Errors should be added, when the installation cannot continue without + * user interaction. If the aim is to notify the user about something, please + * use a warning instead. + * + * @var array + */ + protected $errors; + + /** + * Array of warnings + * + * @var array + */ + protected $warnings; + + /** + * Array of logs + * + * @var array + */ + protected $logs; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var int + */ + protected $task_progress_count; + + /** + * @var int + */ + protected $current_task_progress; + + /** + * @var string + */ + protected $current_task_name; + + /** + * Constructor + */ + public function __construct() + { + $this->errors = array(); + $this->warnings = array(); + $this->logs = array(); + + $this->task_progress_count = 0; + $this->current_task_progress = 0; + $this->current_task_name = ''; + } + + /** + * Set language service + * + * @param \phpbb\language\language $language + */ + public function set_language(\phpbb\language\language $language) + { + $this->language = $language; + } + + /** + * {@inheritdoc} + */ + public function add_error_message($error_title, $error_description = false) + { + $this->errors[] = $this->translate_message($error_title, $error_description); + } + + /** + * {@inheritdoc} + */ + public function add_warning_message($warning_title, $warning_description = false) + { + $this->warnings[] = $this->translate_message($warning_title, $warning_description); + } + + /** + * {@inheritdoc} + */ + public function add_log_message($log_title, $log_description = false) + { + $this->logs[] = $this->translate_message($log_title, $log_description); + } + + /** + * {@inheritdoc} + */ + public function set_task_count($task_count) + { + $this->task_progress_count = $task_count; + } + + /** + * {@inheritdoc} + */ + public function set_progress($task_lang_key, $task_number) + { + if (!empty($task_lang_key)) + { + $this->current_task_name = $this->language->lang($task_lang_key); + $this->current_task_progress = $task_number; + } + } + + /** + * Localize message. + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param array|string $title Title of the message + * @param array|string|bool $description Description of the message + * + * @return array Localized message in an array + */ + protected function translate_message($title, $description) + { + $message_array = array(); + + $message_array['title'] = call_user_func_array(array($this->language, 'lang'), (array) $title); + + if ($description !== false) + { + $message_array['description'] = call_user_func_array(array($this->language, 'lang'), (array) $description); + } + + return $message_array; + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php new file mode 100644 index 0000000000..c40fea24ce --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -0,0 +1,145 @@ + + * @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\helper\iohandler; + +/** + * Input-Output handler interface for the installer + */ +interface iohandler_interface +{ + /** + * Renders or returns response message + */ + public function send_response(); + + /** + * Returns input variable + * + * @param string $name Name of the input variable to obtain + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * + * @return mixed Value of the input variable + */ + public function get_input($name, $default, $multibyte = false); + + /** + * Returns server variable + * + * This function should work the same as request_interterface::server(). + * + * @param string $name Name of the server variable + * @param mixed $default Default value to return when the requested variable does not exist + * + * @return mixed Value of the server variable + */ + public function get_server_variable($name, $default = ''); + + /** + * Wrapper function for request_interterface::header() + * + * @param string $name Name of the request header variable + * @param mixed $default Default value to return when the requested variable does not exist + * + * @return mixed + */ + public function get_header_variable($name, $default = ''); + + /** + * Returns true if the connection is encrypted + * + * @return bool + */ + public function is_secure(); + + /** + * Adds an error message to the rendering queue + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param string|array $error_title Title of the error message. + * @param string|bool|array $error_description Description of the error (and possibly guidelines to resolve it), + * or false if the error description is not available. + */ + public function add_error_message($error_title, $error_description = false); + + /** + * Adds a warning message to the rendering queue + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param string|array $warning_title Title of the warning message + * @param string|bool|array $warning_description Description of the warning (and possibly guidelines to resolve it), + * or false if the error description is not available + */ + public function add_warning_message($warning_title, $warning_description = false); + + /** + * Adds a log message to the rendering queue + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param string|array $log_title Title of the log message + * @param string|bool|array $log_description Description of the log (and possibly guidelines to resolve it), + * or false if the error description is not available + */ + public function add_log_message($log_title, $log_description = false); + + /** + * Adds a requested data group to the rendering queue + * + * @param string $title Language variable with the title of the form + * @param array $form An array describing the required data (options etc) + */ + public function add_user_form_group($title, $form); + + /** + * Sets the number of tasks belonging to the installer in the current mode. + * + * @param int $task_count Number of tasks + */ + public function set_task_count($task_count); + + /** + * Sets the progress information + * + * @param string $task_lang_key Language key for the name of the task + * @param int $task_number Position of the current task in the task queue + */ + public function set_progress($task_lang_key, $task_number); + + /** + * Sends refresh request to the client + */ + public function request_refresh(); + + /** + * Marks stage as active in the navigation bar + * + * @param array $menu_path Array to the navigation elem + */ + public function set_active_stage_menu($menu_path); + + /** + * Marks stage as completed in the navigation bar + * + * @param array $menu_path Array to the navigation elem + */ + public function set_finished_stage_menu($menu_path); +} diff --git a/phpBB/phpbb/install/helper/navigation/install_navigation.php b/phpBB/phpbb/install/helper/navigation/install_navigation.php new file mode 100644 index 0000000000..1389f11fa0 --- /dev/null +++ b/phpBB/phpbb/install/helper/navigation/install_navigation.php @@ -0,0 +1,50 @@ + + * @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\helper\navigation; + +class install_navigation implements navigation_interface +{ + public function get() + { + return array( + 'install' => array( + 'label' => 'INSTALL', + 'route' => 'phpbb_installer_install', + 'order' => 1, + array( + 'introduction' => array( + 'label' => 'INTRODUCTION_TITLE', + 'stage' => true, + 'order' => 0, + ), + 'requirements' => array( + 'label' => 'STAGE_REQUIREMENTS', + 'stage' => true, + 'order' => 1, + ), + 'obtain_data' => array( + 'label' => 'STAGE_OBTAIN_DATA', + 'stage' => true, + 'order' => 2, + ), + 'install' => array( + 'label' => 'STAGE_INSTALL', + 'stage' => true, + 'order' => 3, + ), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/install/helper/navigation/main_navigation.php b/phpBB/phpbb/install/helper/navigation/main_navigation.php new file mode 100644 index 0000000000..ad67840424 --- /dev/null +++ b/phpBB/phpbb/install/helper/navigation/main_navigation.php @@ -0,0 +1,45 @@ + + * @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\helper\navigation; + +class main_navigation implements navigation_interface +{ + public function get() + { + return array( + 'overview' => array( + 'label' => 'MENU_OVERVIEW', + 'route' => 'phpbb_installer_index', + 'order' => 0, + array( + 'introduction' => array( + 'label' => 'MENU_INTRO', + 'route' => 'phpbb_installer_index', + 'order' => 0, + ), + 'support' => array( + 'label' => 'MENU_SUPPORT', + 'route' => 'phpbb_installer_support', + 'order' => 1, + ), + 'license' => array( + 'label' => 'MENU_LICENSE', + 'route' => 'phpbb_installer_license', + 'order' => 2, + ), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/install/helper/navigation/navigation_interface.php b/phpBB/phpbb/install/helper/navigation/navigation_interface.php new file mode 100644 index 0000000000..eebdbe923f --- /dev/null +++ b/phpBB/phpbb/install/helper/navigation/navigation_interface.php @@ -0,0 +1,43 @@ + + * @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\helper\navigation; + +/** + * Interface for installer's navigation defining services + */ +interface navigation_interface +{ + /** + * Returns an array with the navigation items + * + * The returned array should have the following format: + * + * array( + * 'parent_nav_name' => array( + * 'nav_name' => array( + * 'label' => 'MY_MENU', + * 'route' => 'phpbb_route_name', + * ) + * ) + * ) + * + * + * Navigation item setting options: + * - label: The language variable name + * - route: Name of the route which it is belongs to + * + * @return array + */ + public function get(); +} diff --git a/phpBB/phpbb/install/helper/navigation/navigation_provider.php b/phpBB/phpbb/install/helper/navigation/navigation_provider.php new file mode 100644 index 0000000000..1f58cbea83 --- /dev/null +++ b/phpBB/phpbb/install/helper/navigation/navigation_provider.php @@ -0,0 +1,115 @@ + + * @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\helper\navigation; + +use phpbb\di\service_collection; + +/** + * Installers navigation provider + */ +class navigation_provider +{ + /** + * @var array + */ + private $menu_collection; + + /** + * Constructor + * + * @param service_collection $plugins + */ + public function __construct(service_collection $plugins) + { + $this->menu_collection = array(); + + foreach ($plugins as $plugin => $plugin_instance) + { + $this->register($plugin_instance); + } + } + + /** + * Returns navigation array + * + * @return array + */ + public function get() + { + return $this->menu_collection; + } + + /** + * Registers a navigation provider's navigation items + * + * @param navigation_interface $navigation + */ + public function register(navigation_interface $navigation) + { + $nav_arry = $navigation->get(); + $this->merge($nav_arry, $this->menu_collection); + } + + /** + * Set a property in the navigation array + * + * @param array $nav_element Array to the navigation elem + * @param array $property_array Array with the properties to set + */ + public function set_nav_property($nav_element, $property_array) + { + $array_pointer = array(); + $array_root_pointer = &$array_pointer; + foreach ($nav_element as $array_path) + { + $array_pointer[$array_path] = array(); + $array_pointer = &$array_pointer[$array_path]; + } + + $array_pointer = $property_array; + + $this->merge($array_root_pointer, $this->menu_collection); + } + + /** + * Recursive array merge + * + * This function is necessary to be able to replace the options of + * already set navigation items. + * + * @param array $array_to_merge + * @param array $array_to_merge_into + */ + private function merge(&$array_to_merge, &$array_to_merge_into) + { + foreach ($array_to_merge as $key => $value) + { + if (isset($array_to_merge_into[$key])) + { + if (is_array($array_to_merge_into[$key]) && is_array($value)) + { + $this->merge($value, $array_to_merge_into[$key]); + } + else + { + $array_to_merge_into[$key] = $value; + } + } + else + { + $array_to_merge_into[$key] = $value; + } + } + } +} diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php new file mode 100644 index 0000000000..f5da898a00 --- /dev/null +++ b/phpBB/phpbb/install/installer.php @@ -0,0 +1,286 @@ + + * @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; + +use phpbb\install\exception\installer_config_not_writable_exception; +use phpbb\install\exception\invalid_service_name_exception; +use phpbb\install\exception\module_not_found_exception; +use phpbb\install\exception\task_not_found_exception; +use phpbb\install\exception\user_interaction_required_exception; +use phpbb\install\helper\config; +use phpbb\install\helper\iohandler\iohandler_interface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; + +class installer +{ + /** + * @var ContainerInterface + */ + protected $container; + + /** + * @var config + */ + protected $install_config; + + /** + * @var array + */ + protected $installer_modules; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** + * Stores the number of steps that a given module has + * + * @var array + */ + protected $module_step_count; + + /** + * Constructor + * + * @param config $config Installer config handler + * @param ContainerInterface $container Dependency injection container + */ + public function __construct(config $config, ContainerInterface $container) + { + $this->install_config = $config; + $this->container = $container; + $this->installer_modules = array(); + } + + /** + * Sets modules to execute + * + * Note: The installer will run modules in the order they are set in + * the array. + * + * @param array $modules Array of module service names + */ + public function set_modules($modules) + { + $modules = (array) $modules; + + $this->installer_modules = $modules; + } + + /** + * Sets input-output handler objects + * + * @param iohandler_interface $iohandler + */ + public function set_iohandler(iohandler_interface $iohandler) + { + $this->iohandler = $iohandler; + } + + /** + * Run phpBB installer + */ + public function run() + { + // Load install progress + $this->install_config->load_config(); + + // Recover install progress + $module_index = $this->recover_progress(); + + // Variable used to check if the install process have been finished + $install_finished = false; + + // Flag used by exception handling, whether or not we need to flush output buffer once again + $flush_messages = false; + + // We are installing something, so the introduction stage can go now... + $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction')); + $this->iohandler->set_finished_stage_menu(array('install', 0, 'introduction')); + + try + { + if ($this->install_config->get_task_progress_count() === 0) + { + // Count all tasks in the current installer modules + $step_count = 0; + foreach ($this->installer_modules as $index => $name) + { + try + { + /** @var \phpbb\install\module_interface $module */ + $module = $this->container->get($name); + } + catch (InvalidArgumentException $e) + { + throw new module_not_found_exception($name); + } + + $module_step_count = $module->get_step_count(); + $step_count += $module_step_count; + $this->module_step_count[$index] = $module_step_count; + } + + // Set task count + $this->install_config->set_task_progress_count($step_count); + } + + // Set up progress information + $this->iohandler->set_task_count( + $this->install_config->get_task_progress_count() + ); + + // Run until there are available resources + while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0) + { + // Check if module exists, if not the install is completed + if (!isset($this->installer_modules[$module_index])) + { + $install_finished = true; + break; + } + + // Log progress + $module_service_name = $this->installer_modules[$module_index]; + $this->install_config->set_active_module($module_service_name, $module_index); + + // Get module from container + try + { + /** @var \phpbb\install\module_interface $module */ + $module = $this->container->get($module_service_name); + } + catch (InvalidArgumentException $e) + { + throw new module_not_found_exception($module_service_name); + } + + $module_index++; + + // Check if module should be executed + if (!$module->is_essential() && !$module->check_requirements()) + { + $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path()); + $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path()); + + $this->iohandler->add_log_message(array( + 'SKIP_MODULE', + $module_service_name, + )); + $this->install_config->increment_current_task_progress($this->module_step_count[$module_index - 1]); + continue; + } + + // Set the correct stage in the navigation bar + $this->install_config->set_active_navigation_stage($module->get_navigation_stage_path()); + $this->iohandler->set_active_stage_menu($module->get_navigation_stage_path()); + + $module->run(); + + $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path()); + $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path()); + + // Clear task progress + $this->install_config->set_finished_task('', 0); + } + + if ($install_finished) + { + // Send install finished message + $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count()); + } + else + { + $this->iohandler->request_refresh(); + } + } + catch (user_interaction_required_exception $e) + { + // Do nothing + } + catch (module_not_found_exception $e) + { + $this->iohandler->add_error_message('MODULE_NOT_FOUND', array( + 'MODULE_NOT_FOUND_DESCRIPTION', + $e->get_module_service_name(), + )); + $flush_messages = true; + } + catch (task_not_found_exception $e) + { + $this->iohandler->add_error_message('TASK_NOT_FOUND', array( + 'TASK_NOT_FOUND_DESCRIPTION', + $e->get_task_service_name(), + )); + $flush_messages = true; + } + catch (invalid_service_name_exception $e) + { + if ($e->has_params()) + { + $msg = $e->get_params(); + array_unshift($msg, $e->get_error()); + } + else + { + $msg = $e->get_error(); + } + + $this->iohandler->add_error_message($msg); + $flush_messages = true; + } + + if ($flush_messages) + { + $this->iohandler->send_response(); + } + + // Save install progress + try + { + $this->install_config->save_config(); + } + catch (installer_config_not_writable_exception $e) + { + // It is allowed to fail this test during requirements testing + $progress_data = $this->install_config->get_progress_data(); + + if ($progress_data['last_task_module_name'] !== 'installer.module.requirements_install') + { + $this->iohandler->add_error_message('INSTALLER_CONFIG_NOT_WRITABLE'); + } + } + } + + /** + * Recover install progress + * + * @return int Index of the next installer module to execute + */ + protected function recover_progress() + { + $progress_array = $this->install_config->get_progress_data(); + $module_service = $progress_array['last_task_module_name']; + $module_index = $progress_array['last_task_module_index']; + + if ($this->installer_modules[$module_index] === $module_service) + { + return $module_index; + } + + return 0; + } +} diff --git a/phpBB/phpbb/install/module/install_data/module.php b/phpBB/phpbb/install/module/install_data/module.php new file mode 100644 index 0000000000..77f1f73f1f --- /dev/null +++ b/phpBB/phpbb/install/module/install_data/module.php @@ -0,0 +1,28 @@ + + * @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\install_data; + +/** + * Installer module for recovering and installing default data installation + */ +class module extends \phpbb\install\module_base +{ + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('install', 0, 'install'); + } +} diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php new file mode 100644 index 0000000000..c31700e97f --- /dev/null +++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php @@ -0,0 +1,240 @@ + + * @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\install_data\task; + +class add_bots extends \phpbb\install\task_base +{ + /** + * @var array + */ + protected $bot_list; + + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\install\helper\config + */ + protected $install_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $io_handler; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * Constructor + * + * @param \phpbb\install\helper\config $install_config Installer's config + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Input-output handler for the installer + * @param \phpbb\install\helper\container_factory $container Installer's DI container + * @param \phpbb\language\language $language Language provider + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $php_ext PHP extension + */ + public function __construct(\phpbb\install\helper\config $install_config, + \phpbb\install\helper\iohandler\iohandler_interface $iohandler, + \phpbb\install\helper\container_factory $container, + \phpbb\language\language $language, + $phpbb_root_path, + $php_ext) + { + parent::__construct(true); + + $this->db = $container->get('dbal.conn'); + $this->install_config = $install_config; + $this->io_handler = $iohandler; + $this->language = $language; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + /** + * A list of the web-crawlers/bots we recognise by default + * + * Candidates but not included: + * 'Accoona [Bot]' 'Accoona-AI-Agent/' + * 'ASPseek [Crawler]' 'ASPseek/' + * 'Boitho [Crawler]' 'boitho.com-dc/' + * 'Bunnybot [Bot]' 'powered by www.buncat.de' + * 'Cosmix [Bot]' 'cfetch/' + * 'Crawler Search [Crawler]' '.Crawler-Search.de' + * 'Findexa [Crawler]' 'Findexa Crawler (' + * 'GBSpider [Spider]' 'GBSpider v' + * 'genie [Bot]' 'genieBot (' + * 'Hogsearch [Bot]' 'oegp v. 1.3.0' + * 'Insuranco [Bot]' 'InsurancoBot' + * 'IRLbot [Bot]' 'http://irl.cs.tamu.edu/crawler' + * 'ISC Systems [Bot]' 'ISC Systems iRc Search' + * 'Jyxobot [Bot]' 'Jyxobot/' + * 'Kraehe [Metasuche]' '-DIE-KRAEHE- META-SEARCH-ENGINE/' + * 'LinkWalker' 'LinkWalker' + * 'MMSBot [Bot]' 'http://www.mmsweb.at/bot.html' + * 'Naver [Bot]' 'nhnbot@naver.com)' + * 'NetResearchServer' 'NetResearchServer/' + * 'Nimble [Crawler]' 'NimbleCrawler' + * 'Ocelli [Bot]' 'Ocelli/' + * 'Onsearch [Bot]' 'onCHECK-Robot' + * 'Orange [Spider]' 'OrangeSpider' + * 'Sproose [Bot]' 'http://www.sproose.com/bot' + * 'Susie [Sync]' '!Susie (http://www.sync2it.com/susie)' + * 'Tbot [Bot]' 'Tbot/' + * 'Thumbshots [Capture]' 'thumbshots-de-Bot' + * 'Vagabondo [Crawler]' 'http://webagent.wise-guys.nl/' + * 'Walhello [Bot]' 'appie 1.1 (www.walhello.com)' + * 'WissenOnline [Bot]' 'WissenOnline-Bot' + * 'WWWeasel [Bot]' 'WWWeasel Robot v' + * 'Xaldon [Spider]' 'Xaldon WebSpider' + */ + $this->bot_list = array( + 'AdsBot [Google]' => array('AdsBot-Google', ''), + 'Alexa [Bot]' => array('ia_archiver', ''), + 'Alta Vista [Bot]' => array('Scooter/', ''), + 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''), + 'Baidu [Spider]' => array('Baiduspider', ''), + 'Bing [Bot]' => array('bingbot/', ''), + 'Exabot [Bot]' => array('Exabot', ''), + 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''), + 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''), + 'Francis [Bot]' => array('http://www.neomo.de/', ''), + 'Gigabot [Bot]' => array('Gigabot/', ''), + 'Google Adsense [Bot]' => array('Mediapartners-Google', ''), + 'Google Desktop' => array('Google Desktop', ''), + 'Google Feedfetcher' => array('Feedfetcher-Google', ''), + 'Google [Bot]' => array('Googlebot', ''), + 'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''), + 'Heritrix [Crawler]' => array('heritrix/1.', ''), + 'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''), + 'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''), + 'ichiro [Crawler]' => array('ichiro/', ''), + 'Majestic-12 [Bot]' => array('MJ12bot/', ''), + 'Metager [Bot]' => array('MetagerBot/', ''), + 'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''), + 'MSN [Bot]' => array('msnbot/', ''), + 'MSNbot Media' => array('msnbot-media/', ''), + 'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''), + 'Online link [Validator]' => array('online link validator', ''), + 'psbot [Picsearch]' => array('psbot/0', ''), + 'Sensis [Crawler]' => array('Sensis Web Crawler', ''), + 'SEO Crawler' => array('SEO search Crawler/', ''), + 'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''), + 'SEOSearch [Crawler]' => array('SEOsearch/', ''), + 'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''), + 'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''), + 'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''), + 'TurnitinBot [Bot]' => array('TurnitinBot/', ''), + 'Voyager [Bot]' => array('voyager/', ''), + 'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''), + 'W3C [Linkcheck]' => array('W3C-checklink/', ''), + 'W3C [Validator]' => array('W3C_Validator', ''), + 'YaCy [Bot]' => array('yacybot', ''), + 'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''), + 'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''), + 'Yahoo [Bot]' => array('Yahoo! Slurp', ''), + 'YahooSeeker [Bot]' => array('YahooSeeker/', ''), + ); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->db->sql_return_on_error(true); + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'BOTS'"; + $result = $this->db->sql_query($sql); + $group_id = (int) $this->db->sql_fetchfield('group_id'); + $this->db->sql_freeresult($result); + + if (!$group_id) + { + // If we reach this point then something has gone very wrong + $this->io_handler->add_error_message('NO_GROUP'); + } + + foreach ($this->bot_list as $bot_name => $bot_ary) + { + $user_row = array( + 'user_type' => USER_IGNORE, + 'group_id' => $group_id, + 'username' => $bot_name, + 'user_regdate' => time(), + 'user_password' => '', + 'user_colour' => '9E8DA7', + 'user_email' => '', + 'user_lang' => $this->install_config->get('default_lang'), + 'user_style' => 1, + 'user_timezone' => 'UTC', + 'user_dateformat' => $this->language->lang('default_dateformat'), + 'user_allow_massemail' => 0, + 'user_allow_pm' => 0, + ); + + $user_id = user_add($user_row); + + if (!$user_id) + { + // If we can't insert this user then continue to the next one to avoid inconsistent data + $this->io_handler->add_error_message('CONV_ERROR_INSERT_BOT'); + + continue; + } + + $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( + 'bot_active' => 1, + 'bot_name' => (string) $bot_name, + 'user_id' => (int) $user_id, + 'bot_agent' => (string) $bot_ary[0], + 'bot_ip' => (string) $bot_ary[1], + )); + + $this->db->sql_query($sql); + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_ADD_BOTS'; + } +} diff --git a/phpBB/phpbb/install/module/install_data/task/add_languages.php b/phpBB/phpbb/install/module/install_data/task/add_languages.php new file mode 100644 index 0000000000..7ffdf4f276 --- /dev/null +++ b/phpBB/phpbb/install/module/install_data/task/add_languages.php @@ -0,0 +1,121 @@ + + * @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\install_data\task; + +class add_languages extends \phpbb\install\task_base +{ + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\language\language_file_helper + */ + protected $language_helper; + + /** + * Constructor + * + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler + * @param \phpbb\install\helper\container_factory $container Installer's DI container + * @param \phpbb\language\language_file_helper $language_helper Language file helper service + */ + public function __construct(\phpbb\install\helper\iohandler\iohandler_interface $iohandler, + \phpbb\install\helper\container_factory $container, + \phpbb\language\language_file_helper $language_helper) + { + $this->db = $container->get('dbal.conn'); + $this->iohandler = $iohandler; + $this->language_helper = $language_helper; + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->db->sql_return_on_error(true); + + $languages = $this->language_helper->get_available_languages(); + $installed_languages = array(); + + foreach ($languages as $lang_info) + { + $lang_pack = array( + 'lang_iso' => $lang_info['iso'], + 'lang_dir' => $lang_info['iso'], + 'lang_english_name' => htmlspecialchars($lang_info['name']), + 'lang_local_name' => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'), + 'lang_author' => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8'), + ); + + $this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack)); + + $installed_languages[] = (int) $this->db->sql_nextid(); + if ($this->db->get_sql_error_triggered()) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message($error['message']); + } + } + + $sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE; + $result = $this->db->sql_query($sql); + + $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE); + while ($row = $this->db->sql_fetchrow($result)) + { + foreach ($installed_languages as $lang_id) + { + $insert_buffer->insert(array( + 'field_id' => $row['field_id'], + 'lang_id' => $lang_id, + + // Remove phpbb_ from field name + 'lang_name' => strtoupper(substr($row['field_name'], 6)), + 'lang_explain' => '', + 'lang_default_value' => '', + )); + } + } + + $this->db->sql_freeresult($result); + + $insert_buffer->flush(); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_ADD_LANGUAGES'; + } +} diff --git a/phpBB/phpbb/install/module/install_data/task/add_modules.php b/phpBB/phpbb/install/module/install_data/task/add_modules.php new file mode 100644 index 0000000000..6a77f8973b --- /dev/null +++ b/phpBB/phpbb/install/module/install_data/task/add_modules.php @@ -0,0 +1,468 @@ + + * @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\install_data\task; + +class add_modules extends \phpbb\install\task_base +{ + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\extension\manager + */ + protected $extension_manager; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\module\module_manager + */ + protected $module_manager; + + /** + * Define the module structure so that we can populate the database without + * needing to hard-code module_id values + * + * @var array + */ + protected $module_categories; + + /** + * @var array + */ + protected $module_categories_basenames; + + /** + * @var array + */ + protected $module_extras; + + /** + * Constructor + * + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler + * @param \phpbb\install\helper\container_factory $container Installer's DI container + */ + public function __construct(\phpbb\install\helper\iohandler\iohandler_interface $iohandler, + \phpbb\install\helper\container_factory $container) + { + $this->db = $container->get('dbal.conn'); + $this->extension_manager = $container->get('ext.manager'); + $this->iohandler = $iohandler; + $this->module_manager = $container->get('module.manager'); + + parent::__construct(true); + + $this->module_categories = array( + 'acp' => array( + 'ACP_CAT_GENERAL' => array( + 'ACP_QUICK_ACCESS', + 'ACP_BOARD_CONFIGURATION', + 'ACP_CLIENT_COMMUNICATION', + 'ACP_SERVER_CONFIGURATION', + ), + 'ACP_CAT_FORUMS' => array( + 'ACP_MANAGE_FORUMS', + 'ACP_FORUM_BASED_PERMISSIONS', + ), + 'ACP_CAT_POSTING' => array( + 'ACP_MESSAGES', + 'ACP_ATTACHMENTS', + ), + 'ACP_CAT_USERGROUP' => array( + 'ACP_CAT_USERS', + 'ACP_GROUPS', + 'ACP_USER_SECURITY', + ), + 'ACP_CAT_PERMISSIONS' => array( + 'ACP_GLOBAL_PERMISSIONS', + 'ACP_FORUM_BASED_PERMISSIONS', + 'ACP_PERMISSION_ROLES', + 'ACP_PERMISSION_MASKS', + ), + 'ACP_CAT_CUSTOMISE' => array( + 'ACP_STYLE_MANAGEMENT', + 'ACP_EXTENSION_MANAGEMENT', + 'ACP_LANGUAGE', + ), + 'ACP_CAT_MAINTENANCE' => array( + 'ACP_FORUM_LOGS', + 'ACP_CAT_DATABASE', + ), + 'ACP_CAT_SYSTEM' => array( + 'ACP_AUTOMATION', + 'ACP_GENERAL_TASKS', + 'ACP_MODULE_MANAGEMENT', + ), + 'ACP_CAT_DOT_MODS' => null, + ), + 'mcp' => array( + 'MCP_MAIN' => null, + 'MCP_QUEUE' => null, + 'MCP_REPORTS' => null, + 'MCP_NOTES' => null, + 'MCP_WARN' => null, + 'MCP_LOGS' => null, + 'MCP_BAN' => null, + ), + 'ucp' => array( + 'UCP_MAIN' => null, + 'UCP_PROFILE' => null, + 'UCP_PREFS' => null, + 'UCP_PM' => null, + 'UCP_USERGROUPS' => null, + 'UCP_ZEBRA' => null, + ), + ); + + $this->module_categories_basenames = array( + 'UCP_PM' => 'ucp_pm', + ); + + $this->module_extras = array( + 'acp' => array( + 'ACP_QUICK_ACCESS' => array( + 'ACP_MANAGE_USERS', + 'ACP_GROUPS_MANAGE', + 'ACP_MANAGE_FORUMS', + 'ACP_MOD_LOGS', + 'ACP_BOTS', + 'ACP_PHP_INFO', + ), + 'ACP_FORUM_BASED_PERMISSIONS' => array( + 'ACP_FORUM_PERMISSIONS', + 'ACP_FORUM_PERMISSIONS_COPY', + 'ACP_FORUM_MODERATORS', + 'ACP_USERS_FORUM_PERMISSIONS', + 'ACP_GROUPS_FORUM_PERMISSIONS', + ), + ), + ); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->db->sql_return_on_error(true); + + $module_classes = array('acp', 'mcp', 'ucp'); + foreach ($module_classes as $module_class) + { + $categories = array(); + + foreach ($this->module_categories[$module_class] as $cat_name => $subs) + { + // Check if this sub-category has a basename. If it has, use it. + $basename = (isset($this->module_categories_basenames[$cat_name])) ? $this->module_categories_basenames[$cat_name] : ''; + + $module_data = array( + 'module_basename' => $basename, + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => 0, + 'module_class' => $module_class, + 'module_langname' => $cat_name, + 'module_mode' => '', + 'module_auth' => '', + ); + + $this->module_manager->update_module_data($module_data); + + // Check for last sql error happened + if ($this->db->get_sql_error_triggered()) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); + } + + $categories[$cat_name]['id'] = (int)$module_data['module_id']; + $categories[$cat_name]['parent_id'] = 0; + + if (is_array($subs)) + { + foreach ($subs as $level2_name) + { + // Check if this sub-category has a basename. If it has, use it. + $basename = (isset($this->module_categories_basenames[$level2_name])) ? $this->module_categories_basenames[$level2_name] : ''; + + $module_data = array( + 'module_basename' => $basename, + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => (int)$categories[$cat_name]['id'], + 'module_class' => $module_class, + 'module_langname' => $level2_name, + 'module_mode' => '', + 'module_auth' => '', + ); + + $this->module_manager->update_module_data($module_data); + + // Check for last sql error happened + if ($this->db->get_sql_error_triggered()) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); + } + + $categories[$level2_name]['id'] = (int)$module_data['module_id']; + $categories[$level2_name]['parent_id'] = (int)$categories[$cat_name]['id']; + } + } + } + + // Get the modules we want to add... returned sorted by name + $module_info = $this->module_manager->get_module_infos($module_class); + + foreach ($module_info as $module_basename => $fileinfo) + { + foreach ($fileinfo['modes'] as $module_mode => $row) + { + foreach ($row['cat'] as $cat_name) + { + if (!isset($categories[$cat_name])) + { + continue; + } + + $module_data = array( + 'module_basename' => $module_basename, + 'module_enabled' => 1, + 'module_display' => (isset($row['display'])) ? (int) $row['display'] : 1, + 'parent_id' => (int) $categories[$cat_name]['id'], + 'module_class' => $module_class, + 'module_langname' => $row['title'], + 'module_mode' => $module_mode, + 'module_auth' => $row['auth'], + ); + + $this->module_manager->update_module_data($module_data); + + // Check for last sql error happened + if ($this->db->get_sql_error_triggered()) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); + } + } + } + } + + // Move some of the modules around since the code above will put them in the wrong place + if ($module_class === 'acp') + { + // Move main module 4 up... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_main' + AND module_class = 'acp' + AND module_mode = 'main'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'acp', 'move_up', 4); + + // Move permissions intro screen module 4 up... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_permissions' + AND module_class = 'acp' + AND module_mode = 'intro'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'acp', 'move_up', 4); + + // Move manage users screen module 5 up... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_users' + AND module_class = 'acp' + AND module_mode = 'overview'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'acp', 'move_up', 5); + + // Move extension management module 1 up... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_EXTENSION_MANAGEMENT' + AND module_class = 'acp' + AND module_mode = '' + AND module_basename = ''"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'acp', 'move_up', 1); + } + + if ($module_class == 'mcp') + { + // Move pm report details module 3 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'mcp_pm_reports' + AND module_class = 'mcp' + AND module_mode = 'pm_report_details'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + + // Move closed pm reports module 3 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'mcp_pm_reports' + AND module_class = 'mcp' + AND module_mode = 'pm_reports_closed'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + + // Move open pm reports module 3 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'mcp_pm_reports' + AND module_class = 'mcp' + AND module_mode = 'pm_reports'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + } + + if ($module_class == 'ucp') + { + // Move attachment module 4 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_attachments' + AND module_class = 'ucp' + AND module_mode = 'attachments'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4); + + // Move notification options module 4 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_notifications' + AND module_class = 'ucp' + AND module_mode = 'notification_options'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4); + + // Move OAuth module 5 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_auth_link' + AND module_class = 'ucp' + AND module_mode = 'auth_link'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'ucp', 'move_down', 5); + } + + // And now for the special ones + // (these are modules which appear in multiple categories and thus get added manually + // to some for more control) + if (isset($this->module_extras[$module_class])) + { + foreach ($this->module_extras[$module_class] as $cat_name => $mods) + { + $sql = 'SELECT module_id, left_id, right_id + FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($cat_name) . "' + AND module_class = '" . $this->db->sql_escape($module_class) . "'"; + $result = $this->db->sql_query_limit($sql, 1); + $row2 = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + foreach ($mods as $mod_name) + { + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($mod_name) . "' + AND module_class = '" . $this->db->sql_escape($module_class) . "' + AND module_basename <> ''"; + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $module_data = array( + 'module_basename' => $row['module_basename'], + 'module_enabled' => (int) $row['module_enabled'], + 'module_display' => (int) $row['module_display'], + 'parent_id' => (int) $row2['module_id'], + 'module_class' => $row['module_class'], + 'module_langname' => $row['module_langname'], + 'module_mode' => $row['module_mode'], + 'module_auth' => $row['module_auth'], + ); + + $this->module_manager->update_module_data($module_data); + + // Check for last sql error happened + if ($this->db->get_sql_error_triggered()) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); + } + } + } + } + + $this->module_manager->remove_cache_file($module_class); + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_ADD_MODULES'; + } +} diff --git a/phpBB/phpbb/install/module/install_database/module.php b/phpBB/phpbb/install/module/install_database/module.php new file mode 100644 index 0000000000..0d8b33087f --- /dev/null +++ b/phpBB/phpbb/install/module/install_database/module.php @@ -0,0 +1,28 @@ + + * @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\install_database; + +/** + * Installer module for database installation + */ +class module extends \phpbb\install\module_base +{ + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('install', 0, 'install'); + } +} diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php new file mode 100644 index 0000000000..25da36e01d --- /dev/null +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -0,0 +1,341 @@ + + * @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\install_database\task; + +/** + * Create database schema + */ +class add_config_settings extends \phpbb\install\task_base +{ + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var \phpbb\install\helper\config + */ + protected $install_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var \phpbb\passwords\manager + */ + protected $password_manager; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $config_table; + + /** + * @var string + */ + protected $user_table; + + /** + * @var string + */ + protected $topics_table; + + /** + * @var string + */ + protected $forums_table; + + /** + * @var string + */ + protected $posts_table; + + /** + * @var string + */ + protected $moderator_cache_table; + + /** + * Constructor + * + * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service + * @param \phpbb\install\helper\config $install_config Installer's config helper + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler + * @param \phpbb\install\helper\container_factory $container Installer's DI container + * @param \phpbb\language\language $language Language service + * @param string $phpbb_root_path Path to phpBB's root + */ + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, + \phpbb\install\helper\config $install_config, + \phpbb\install\helper\iohandler\iohandler_interface $iohandler, + \phpbb\install\helper\container_factory $container, + \phpbb\language\language $language, + $phpbb_root_path) + { + $this->db = $container->get('dbal.conn'); + $this->filesystem = $filesystem; + $this->install_config = $install_config; + $this->iohandler = $iohandler; + $this->language = $language; + $this->password_manager = $container->get('passwords.manager'); + $this->phpbb_root_path = $phpbb_root_path; + + // Table names + $this->config_table = $container->get_parameter('tables.config'); + $this->forums_table = $container->get_parameter('tables.forums'); + $this->topics_table = $container->get_parameter('tables.topics'); + $this->user_table = $container->get_parameter('tables.users'); + $this->moderator_cache_table = $container->get_parameter('tables.moderator_cache'); + $this->posts_table = $container->get_parameter('tables.posts'); + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->db->sql_return_on_error(true); + + $server_name = $this->install_config->get('server_name'); + $cookie_domain = $this->install_config->get('cookie_domain'); + $current_time = time(); + $user_ip = phpbb_ip_normalise($this->iohandler->get_server_variable('REMOTE_ADDR')); + $user_ip = ($user_ip === false) ? '' : $user_ip; + $referer = $this->iohandler->get_server_variable('REFERER'); + + // Set default config and post data, this applies to all DB's + $sql_ary = array( + 'INSERT INTO ' . $this->config_table . " (config_name, config_value) + VALUES ('board_startdate', '$current_time')", + + 'INSERT INTO ' . $this->config_table . " (config_name, config_value) + VALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('img_imagick')) . "' + WHERE config_name = 'img_imagick'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "' + WHERE config_name = 'server_name'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_port')) . "' + WHERE config_name = 'server_port'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "' + WHERE config_name = 'board_email'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "' + WHERE config_name = 'board_contact'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($cookie_domain) . "' + WHERE config_name = 'cookie_domain'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "' + WHERE config_name = 'default_dateformat'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('email_enable')) . "' + WHERE config_name = 'email_enable'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_delivery')) . "' + WHERE config_name = 'smtp_delivery'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_host')) . "' + WHERE config_name = 'smtp_host'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_auth')) . "' + WHERE config_name = 'smtp_auth_method'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_user')) . "' + WHERE config_name = 'smtp_username'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_pass')) . "' + WHERE config_name = 'smtp_password'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('cookie_secure')) . "' + WHERE config_name = 'cookie_secure'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('force_server_vars')) . "' + WHERE config_name = 'force_server_vars'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('script_path')) . "' + WHERE config_name = 'script_path'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_protocol')) . "' + WHERE config_name = 'server_protocol'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' + WHERE config_name = 'newest_username'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . md5(mt_rand()) . "' + WHERE config_name = 'avatar_salt'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . md5(mt_rand()) . "' + WHERE config_name = 'plupload_salt'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_name')) . "' + WHERE config_name = 'sitename'", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_description')) . "' + WHERE config_name = 'site_desc'", + + 'UPDATE ' . $this->user_table . " + SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "', + user_password='" . $this->password_manager->hash($this->install_config->get('admin_passwd')) . "', + user_ip = '" . $this->db->sql_escape($user_ip) . "', + user_lang = '" . $this->db->sql_escape($this->install_config->get('language')) . "', + user_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "', + user_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "', + user_email_hash = " . $this->db->sql_escape(phpbb_email_hash($this->install_config->get('board_email'))) . ", + username_clean = '" . $this->db->sql_escape(utf8_clean_string($this->install_config->get('admin_name'))) . "' + WHERE username = 'Admin'", + + 'UPDATE ' . $this->moderator_cache_table . " + SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' + WHERE username = 'Admin'", + + 'UPDATE ' . $this->forums_table . " + SET forum_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' + WHERE forum_last_poster_name = 'Admin'", + + 'UPDATE ' . $this->topics_table . " + SET topic_first_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "', + topic_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' + WHERE topic_first_poster_name = 'Admin' + OR topic_last_poster_name = 'Admin'", + + 'UPDATE ' . $this->user_table . " + SET user_regdate = $current_time", + + 'UPDATE ' . $this->posts_table . " + SET post_time = $current_time, poster_ip = '" . $this->db->sql_escape($user_ip) . "'", + + 'UPDATE ' . $this->topics_table . " + SET topic_time = $current_time, topic_last_post_time = $current_time", + + 'UPDATE ' . $this->forums_table . " + SET forum_last_post_time = $current_time", + + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->db->sql_server_info(true)) . "' + WHERE config_name = 'dbms_version'", + ); + + if (@extension_loaded('gd')) + { + $sql_ary[] = 'UPDATE ' . $this->config_table . " + SET config_value = 'core.captcha.plugins.gd' + WHERE config_name = 'captcha_plugin'"; + + $sql_ary[] = 'UPDATE ' . $this->config_table . " + SET config_value = '1' + WHERE config_name = 'captcha_gd'"; + } + + $ref = substr($referer, strpos($referer, '://') + 3); + if (!(stripos($ref, $server_name) === 0)) + { + $sql_ary[] = 'UPDATE ' . $this->config_table . " + SET config_value = '0' + WHERE config_name = 'referer_validation'"; + } + + // We set a (semi-)unique cookie name to bypass login issues related to the cookie name. + $cookie_name = 'phpbb3_'; + $rand_str = md5(mt_rand()); + $rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35)); + $rand_str = substr($rand_str, 0, 5); + $cookie_name .= strtolower($rand_str); + + $sql_ary[] = 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($cookie_name) . "' + WHERE config_name = 'cookie_name'"; + + // Disable avatars if upload directory is not writable + if (!$this->filesystem->is_writable($this->phpbb_root_path . 'images/avatars/upload/')) + { + $sql_ary[] = 'UPDATE ' . $this->config_table . " + SET config_value = '0' + WHERE config_name = 'allow_avatar'"; + + $sql_ary[] = 'UPDATE ' . $this->config_table . " + SET config_value = '0' + WHERE config_name = 'allow_avatar_upload'"; + } + + foreach ($sql_ary as $sql) + { + if (!$this->db->sql_query($sql)) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); + } + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_ADD_CONFIG_SETTINGS'; + } +} diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php new file mode 100644 index 0000000000..5dbfbb4478 --- /dev/null +++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php @@ -0,0 +1,161 @@ + + * @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\install_database\task; + +/** + * Create database schema + */ +class add_default_data extends \phpbb\install\task_base +{ + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\install\helper\database + */ + protected $database_helper; + + /** + * @var \phpbb\install\helper\config + */ + protected $config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * Constructor + * + * @param \phpbb\install\helper\database $db_helper Installer's database helper + * @param \phpbb\install\helper\config $config Installer config + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler + * @param \phpbb\install\helper\container_factory $container Installer's DI container + * @param \phpbb\language\language $language Language service + */ + public function __construct(\phpbb\install\helper\database $db_helper, + \phpbb\install\helper\config $config, + \phpbb\install\helper\iohandler\iohandler_interface $iohandler, + \phpbb\install\helper\container_factory $container, + \phpbb\language\language $language) + { + $dbms = $db_helper->get_available_dbms($config->get('dbms')); + $dbms = $dbms[$config->get('dbms')]['DRIVER']; + + $this->db = $container->get('dbal.conn'); //new $dbms(); + $this->database_helper = $db_helper; + $this->config = $config; + $this->iohandler = $iohandler; + $this->language = $language; + + parent::__construct(true); + + // Connect to DB + //$this->db->sql_connect($config->get('dbhost'), $config->get('dbuser'), $config->get('dbpasswd'), $config->get('dbname'), $config->get('dbport'), false, false); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->db->sql_return_on_error(true); + + $table_prefix = $this->config->get('table_prefix'); + $dbms = $this->config->get('dbms'); + $dbms_info = $this->database_helper->get_available_dbms($dbms); + + // Get schema data from file + $sql_query = @file_get_contents('schemas/schema_data.sql'); + + // Clean up SQL + $sql_query = $this->replace_dbms_specific_sql($sql_query); + $sql_query = preg_replace('# phpbb_([^\s]*) #i', ' ' . $table_prefix . '\1 ', $sql_query); + $sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', array($this, 'lang_replace_callback'), $sql_query); + $sql_query = $this->database_helper->remove_comments($sql_query); + $sql_query = $this->database_helper->split_sql_file($sql_query, $dbms_info[$dbms]['DELIM']); + + foreach ($sql_query as $sql) + { + if (!$this->db->sql_query($sql)) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); + } + } + } + + /** + * Process DB specific SQL + * + * @return string + */ + protected function replace_dbms_specific_sql($query) + { + if ($this->db instanceof \phpbb\db\driver\mssql_base || $this->db instanceof \phpbb\db\driver\mssql) + { + $query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $query); + } + else if ($this->db instanceof \phpbb\db\driver\postgres) + { + $query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $query); + } + else if ($this->db instanceof \phpbb\db\driver\mysql_base) + { + $query = str_replace('\\', '\\\\', $query); + } + + return $query; + } + + /** + * Callback function for language replacing + * + * @param array $matches + * @return string + */ + public function lang_replace_callback($matches) + { + if (!empty($matches[1])) + { + return $this->db->sql_escape($this->language->lang($matches[1])); + } + + return ''; + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_ADD_DEFAULT_DATA'; + } +} diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php new file mode 100644 index 0000000000..7cc521eee8 --- /dev/null +++ b/phpBB/phpbb/install/module/install_database/task/create_schema.php @@ -0,0 +1,214 @@ + + * @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\install_database\task; + +/** + * Create database schema + */ +class create_schema extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\config + */ + protected $config; + + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\db\tools\tools_interface + */ + protected $db_tools; + + /** + * @var \phpbb\install\helper\database + */ + protected $database_helper; + + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * Constructor + * + * @param \phpbb\install\helper\config $config Installer's config provider + * @param \phpbb\install\helper\database $db_helper Installer's database helper + * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler + * @param string $phpbb_root_path Path phpBB's root + * @param string $php_ext Extension of PHP files + */ + public function __construct(\phpbb\install\helper\config $config, + \phpbb\install\helper\database $db_helper, + \phpbb\filesystem\filesystem_interface $filesystem, + \phpbb\install\helper\iohandler\iohandler_interface $iohandler, + $phpbb_root_path, + $php_ext) + { + $dbms = $db_helper->get_available_dbms($config->get('dbms')); + $dbms = $dbms[$config->get('dbms')]['DRIVER']; + $factory = new \phpbb\db\tools\factory(); + + $this->db = new $dbms(); + $this->config = $config; + $this->db_tools = $factory->get($this->db); + $this->database_helper = $db_helper; + $this->filesystem = $filesystem; + $this->iohandler = $iohandler; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + parent::__construct(true); + + // Connect to DB + $this->db->sql_connect($config->get('dbhost'), $config->get('dbuser'), $config->get('dbpasswd'), $config->get('dbname'), $config->get('dbport'), false, false); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->db->sql_return_on_error(true); + + $dbms = $this->config->get('dbms'); + $dbms_info = $this->database_helper->get_available_dbms($dbms); + $schema_name = $dbms_info[$dbms]['SCHEMA']; + $delimiter = $dbms_info[$dbms]['DELIM']; + $table_prefix = $this->config->get('table_prefix'); + + if ($dbms === 'mysql') + { + if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) + { + $schema_name .= '_41'; + } + else + { + $schema_name .= '_40'; + } + } + + $db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; + + // Load database vendor specific code if there is any + if ($this->filesystem->exists($db_schema_path)) + { + $sql_query = @file_get_contents($db_schema_path); + $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); + $sql_query = $this->database_helper->remove_comments($sql_query); + $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); + + foreach ($sql_query as $sql) + { + if (!$this->db->sql_query($sql)) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); + } + } + + unset($sql_query); + } + + $change_prefix = false; + + // Generate database schema + if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) + { + $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); + $db_table_schema = json_decode($db_table_schema, true); + $change_prefix = true; + } + else + { + global $table_prefix; + + $table_prefix = $this->config->get('table_prefix'); + + if (!defined('CONFIG_TABLE')) + { + // We need to include the constants file for the table constants + // when we generate the schema from the migration files. + include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); + } + + $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); + $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($this->db, true); + $schema_generator = new \phpbb\db\migration\schema_generator( + $migrator_classes, + new \phpbb\config\config(array()), + $this->db, + $db_tools, + $this->phpbb_root_path, + $this->php_ext, + $table_prefix + ); + $db_table_schema = $schema_generator->get_schema(); + } + + if (!defined('CONFIG_TABLE')) + { + // CONFIG_TABLE is required by sql_create_index() to check the + // length of index names. However table_prefix is not defined + // here yet, so we need to create the constant ourselves. + define('CONFIG_TABLE', $table_prefix . 'config'); + } + + foreach ($db_table_schema as $table_name => $table_data) + { + $this->db_tools->sql_create_table( + ( ($change_prefix) ? ($table_prefix . substr($table_name, 6)) : $table_name ), + $table_data + ); + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_CREATE_DATABASE_SCHEMA'; + } +} diff --git a/phpBB/phpbb/install/module/install_filesystem/module.php b/phpBB/phpbb/install/module/install_filesystem/module.php new file mode 100644 index 0000000000..7215449664 --- /dev/null +++ b/phpBB/phpbb/install/module/install_filesystem/module.php @@ -0,0 +1,28 @@ + + * @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\install_filesystem; + +/** + * Installer module for filesystem installation + */ +class module extends \phpbb\install\module_base +{ + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('install', 0, 'install'); + } +} diff --git a/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php b/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php new file mode 100644 index 0000000000..337d401216 --- /dev/null +++ b/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php @@ -0,0 +1,235 @@ + + * @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\install_filesystem\task; + +use phpbb\install\exception\user_interaction_required_exception; + +/** + * Dumps config file + */ +class create_config_file extends \phpbb\install\task_base +{ + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var \phpbb\install\helper\database + */ + protected $db_helper; + + /** + * @var \phpbb\install\helper\config + */ + protected $install_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * Constructor + * + * @param \phpbb\filesystem\filesystem_interface $filesystem + * @param \phpbb\install\helper\config $install_config + * @param \phpbb\install\helper\database $db_helper + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler + * @param string $phpbb_root_path + * @param string $php_ext + */ + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, + \phpbb\install\helper\config $install_config, + \phpbb\install\helper\database $db_helper, + \phpbb\install\helper\iohandler\iohandler_interface $iohandler, + $phpbb_root_path, + $php_ext) + { + $this->install_config = $install_config; + $this->db_helper = $db_helper; + $this->filesystem = $filesystem; + $this->iohandler = $iohandler; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $config_written = true; + + // Create config.php + $path_to_config = $this->phpbb_root_path . 'config.' . $this->php_ext; + + $fp = @fopen($path_to_config, 'w'); + if (!$fp) + { + $config_written = false; + } + + $config_content = $this->get_config_data(); + + if (!@fwrite($fp, $config_content)) + { + $config_written = false; + } + + @fclose($fp); + + // chmod config.php to be only readable + if ($config_written) + { + try + { + $this->filesystem->phpbb_chmod($path_to_config, \phpbb\filesystem\filesystem_interface::CHMOD_READ); + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing, the user will get a notice later + } + } + else + { + $this->iohandler->add_error_message('UNABLE_TO_WRITE_CONFIG_FILE'); + $this->iohandler->send_response(); + throw new user_interaction_required_exception(); + } + + // Create a lock file to indicate that there is an install in progress + $fp = @fopen($this->phpbb_root_path . 'cache/install_lock', 'wb'); + if ($fp === false) + { + // We were unable to create the lock file - abort + $this->iohandler->add_error_message('UNABLE_TO_WRITE_LOCK'); + $this->iohandler->send_response(); + throw new user_interaction_required_exception(); + } + @fclose($fp); + + try + { + $this->filesystem->phpbb_chmod($this->phpbb_root_path . 'cache/install_lock', 0777); + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing, the user will get a notice later + } + } + + /** + * Returns the content which should be dumped to config.php + * + * @param bool $debug If the debug constants should be enabled by default or not + * @param bool $debug_container If the container should be compiled on + * every page load or not + * @param bool $debug_test If the DEBUG_TEST constant should be added + * NOTE: Only for use within the testing framework + * + * @return string content to be written to the config file + */ + protected function get_config_data($debug = false, $debug_container = false, $debug_test = false) + { + $config_content = "install_config->get('dbms'); + $db_driver = $this->db_helper->get_available_dbms($dbms); + $db_driver = $db_driver[$dbms]['DRIVER']; + + $config_data_array = array( + 'dbms' => $db_driver, + 'dbhost' => $this->install_config->get('dbhost'), + 'dbport' => $this->install_config->get('dbport'), + 'dbname' => $this->install_config->get('dbname'), + 'dbuser' => $this->install_config->get('dbuser'), + 'dbpasswd' => $this->install_config->get('dbpasswd'), + 'table_prefix' => $this->install_config->get('table_prefix'), + + 'phpbb_adm_relative_path' => 'adm/', + + 'acm_type' => 'phpbb\cache\driver\file', + ); + + foreach ($config_data_array as $key => $value) + { + $config_content .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n"; + } + + $config_content .= "\n@define('PHPBB_INSTALLED', true);\n"; + $config_content .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; + + if ($debug_test) + { + $config_content .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; + } + else if ($debug) + { + $config_content .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; + } + else + { + $config_content .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; + } + + if ($debug_container) + { + $config_content .= "@define('DEBUG_CONTAINER', true);\n"; + } + else + { + $config_content .= "// @define('DEBUG_CONTAINER', true);\n"; + } + + if ($debug_test) + { + $config_content .= "@define('DEBUG_TEST', true);\n"; + + // Mandatory for the functional tests, will be removed by PHPBB3-12623 + $config_content .= "@define('DEBUG', true);\n"; + } + + return $config_content; + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_CREATE_CONFIG_FILE'; + } +} diff --git a/phpBB/phpbb/install/module/install_finish/module.php b/phpBB/phpbb/install/module/install_finish/module.php new file mode 100644 index 0000000000..3a7544b84f --- /dev/null +++ b/phpBB/phpbb/install/module/install_finish/module.php @@ -0,0 +1,28 @@ + + * @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\install_finish; + +/** + * Installer module for filesystem installation + */ +class module extends \phpbb\install\module_base +{ + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('install', 0, 'install'); + } +} diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php new file mode 100644 index 0000000000..4ab6ec56c6 --- /dev/null +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -0,0 +1,129 @@ + + * @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\install_finish\task; + +/** + * Logs installation and sends an email to the admin + */ +class notify_user extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\config + */ + protected $install_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\auth\auth + */ + protected $auth; + + /** + * @var \phpbb\config\db + */ + protected $config; + + /** + * @var \phpbb\log\log_interface + */ + protected $log; + + /** + * @var \phpbb\user + */ + protected $user; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * Constructor + * + * @param \phpbb\install\helper\container_factory $container + * @param \phpbb\install\helper\config $install_config + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler + * @param string $phpbb_root_path + * @param string $php_ext + */ + 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) + { + $this->install_config = $install_config; + $this->iohandler = $iohandler; + + $this->auth = $container->get('auth'); + $this->config = $container->get('config'); + $this->log = $container->get('log'); + $this->user = $container->get('user'); + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * {@inheritdoc} + */ + public function run() + { + // @todo + //$this->user->setup('common'); + + //$this->user->session_begin(); + //$this->auth->login($this->install_config->get('admin_name'), $this->install_config->get('admin_pass1'), false, true, true); + + if ($this->config['email_enable']) + { + include ($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); + + $messenger = new \messenger(false); + $messenger->template('installed', $this->install_config->get('language')); + $messenger->to($this->config['board_email'], $this->install_config->get('admin_name')); + $messenger->anti_abuse_headers($this->config, $this->user); + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($this->install_config->get('admin_name')), + 'PASSWORD' => htmlspecialchars_decode($this->install_config->get('admin_passwd'))) + ); + $messenger->send(NOTIFY_EMAIL); + } + + $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_INSTALL_INSTALLED', false, array($this->config['version'])); + + @unlink($this->phpbb_root_path . 'cache/install_lock'); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_NOTIFY_USER'; + } +} diff --git a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php new file mode 100644 index 0000000000..b2a4800f86 --- /dev/null +++ b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php @@ -0,0 +1,70 @@ + + * @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\install_finish\task; + +/** + * Populates migrations + */ +class populate_migrations extends \phpbb\install\task_base +{ + /** + * @var \phpbb\extension\manager + */ + protected $extension_manager; + + /** + * @var \phpbb\db\migrator + */ + protected $migrator; + + /** + * Constructor + * + * @param \phpbb\install\helper\container_factory $container phpBB's DI contianer + */ + public function __construct(\phpbb\install\helper\container_factory $container) + { + $this->extension_manager = $container->get('ext.manager'); + $this->migrator = $container->get('migrator'); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $finder = $this->extension_manager->get_finder(); + + $migrations = $finder + ->core_path('phpbb/db/migration/data/') + ->get_classes(); + $this->migrator->populate_migrations($migrations); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_POPULATE_MIGRATIONS'; + } +} 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 @@ + + * @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 @@ + + * @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 @@ + + * @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..0c1146d9f5 --- /dev/null +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php @@ -0,0 +1,271 @@ + + * @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 ($prefix_valid 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 @@ + + * @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 @@ + + * @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..2d1e37b10e --- /dev/null +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php @@ -0,0 +1,203 @@ + + * @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($script_path))); + + // 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 ''; + } +} diff --git a/phpBB/phpbb/install/module/requirements/module.php b/phpBB/phpbb/install/module/requirements/module.php new file mode 100644 index 0000000000..d87ca15128 --- /dev/null +++ b/phpBB/phpbb/install/module/requirements/module.php @@ -0,0 +1,97 @@ + + * @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\requirements; + +use phpbb\install\exception\user_interaction_required_exception; + +class module extends \phpbb\install\module_base +{ + public function run() + { + $tests_passed = true; + + // Recover install progress + $task_index = 0; + + // Run until there are available resources + while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0) + { + // Check if task exists + if (!isset($this->task_collection[$task_index])) + { + break; + } + + // Recover task to be executed + try + { + /** @var \phpbb\install\task_interface $task */ + $task = $this->container->get($this->task_collection[$task_index]); + } + catch (InvalidArgumentException $e) + { + throw new task_not_found_exception($this->task_collection[$task_index]); + } + + // Iterate to the next task + $task_index++; + + // Check if we can run the task + if (!$task->is_essential() && !$task->check_requirements()) + { + continue; + } + + $test_result = $task->run(); + $tests_passed = ($tests_passed) ? $test_result : false; + } + + // Check if tests have failed + if (!$tests_passed) + { + // If requirements are not met, exit form installer + // Set up UI for retesting + $this->iohandler->add_user_form_group('', array( + 'install' => array( + 'label' => 'RETEST_REQUIREMENTS', + 'type' => 'submit', + ), + )); + + // Send the response and quit + $this->iohandler->send_response(); + throw new user_interaction_required_exception(); + } + + // Log install progress + $current_task_index = $task_index - 1; + $this->install_config->set_finished_task($this->task_collection[$current_task_index], $current_task_index); + } + + /** + * {@inheritdoc} + */ + public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('install', 0, 'requirements'); + } +} diff --git a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php new file mode 100644 index 0000000000..5b944b8415 --- /dev/null +++ b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php @@ -0,0 +1,273 @@ + + * @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\requirements\task; + +/** + * Checks filesystem requirements + */ +class check_filesystem extends \phpbb\install\task_base +{ + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var array + */ + protected $files_to_check; + + /** + * @var bool + */ + protected $tests_passed; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $response; + + /** + * Constructor + * + * @param \phpbb\filesystem\filesystem_interface $filesystem filesystem handler + * @parma \phpbb\install\helper\iohandler\iohandler_interface $response response helper + * @param string $phpbb_root_path relative path to phpBB's root + * @param string $php_ext extension of php files + */ + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, + \phpbb\install\helper\iohandler\iohandler_interface $response, + $phpbb_root_path, + $php_ext) + { + parent::__construct(true); + + $this->filesystem = $filesystem; + $this->response = $response; + $this->phpbb_root_path = $phpbb_root_path; + + $this->tests_passed = false; + + // Files/Directories to check + // All file/directory names must be relative to phpBB's root path + $this->files_to_check = array( + array( + 'path' => 'cache/', + 'failable' => false, + 'is_file' => false, + ), + array( + 'path' => 'store/', + 'failable' => false, + 'is_file' => false, + ), + array( + 'path' => 'files/', + 'failable' => false, + 'is_file' => false, + ), + array( + 'path' => 'images/avatars/upload/', + 'failable' => true, + 'is_file' => false, + ), + array( + 'path' => "config.$php_ext", + 'failable' => false, + 'is_file' => true, + ), + ); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->tests_passed = true; + + // Check files/directories to be writable + foreach ($this->files_to_check as $file) + { + if ($file['is_file']) + { + $this->check_file($file['path'], $file['failable']); + } + else + { + $this->check_dir($file['path'], $file['failable']); + } + } + + return $this->tests_passed; + } + + /** + * Sets $this->tests_passed + * + * @param bool $is_passed + */ + protected function set_test_passed($is_passed) + { + // If one test failed, tests_passed should be false + $this->tests_passed = (!$this->tests_passed) ? false : $is_passed; + } + + /** + * Check if a file is readable and writable + * + * @param string $file Filename + * @param bool $failable Whether failing test should interrupt installation process + */ + protected function check_file($file, $failable = false) + { + $path = $this->phpbb_root_path . $file; + $exists = $writable = true; + + // Try to create file if it does not exists + if (!file_exists($path)) + { + $fp = @fopen($path, 'w'); + @fclose($fp); + try + { + $this->filesystem->phpbb_chmod($path, + \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE + ); + $exists = true; + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing + } + } + + if (file_exists($path)) + { + if (!$this->filesystem->is_writable($path)) + { + $writable = false; + } + } + else + { + $exists = $writable = false; + } + + $this->set_test_passed(($exists && $writable) || $failable); + + if (!($exists && $writable)) + { + $title = ($exists) ? 'FILE_NOT_WRITABLE' : 'FILE_NOT_EXISTS'; + $description = array($title . '_EXPLAIN', $file); + + if ($failable) + { + $this->response->add_warning_message($title, $description); + } + else + { + $this->response->add_error_message($title, $description); + } + } + } + + /** + * Check if a directory is readable and writable + * + * @param string $dir Filename + * @param bool $failable Whether failing test should abort the installation process + */ + protected function check_dir($dir, $failable = false) + { + $path = $this->phpbb_root_path . $dir; + $exists = $writable = false; + + // Try to create the directory if it does not exist + if (!file_exists($path)) + { + try + { + $this->filesystem->mkdir($path, 0777); + $this->filesystem->phpbb_chmod($path, + \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE + ); + $exists = true; + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing + } + } + + // Now really check + if (file_exists($path) && is_dir($path)) + { + try + { + $exists = true; + $this->filesystem->phpbb_chmod($path, + \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE + ); + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing + } + } + + if ($this->filesystem->is_writable($path)) + { + $writable = true; + } + + $this->set_test_passed(($exists && $writable) || $failable); + + if (!($exists && $writable)) + { + $title = ($exists) ? 'DIRECTORY_NOT_WRITABLE' : 'DIRECTORY_NOT_EXISTS'; + $description = array($title . '_EXPLAIN', $dir); + + if ($failable) + { + $this->response->add_warning_message($title, $description); + } + else + { + $this->response->add_error_message($title, $description); + } + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} diff --git a/phpBB/phpbb/install/module/requirements/task/check_server_environment.php b/phpBB/phpbb/install/module/requirements/task/check_server_environment.php new file mode 100644 index 0000000000..50efdc55a2 --- /dev/null +++ b/phpBB/phpbb/install/module/requirements/task/check_server_environment.php @@ -0,0 +1,190 @@ + + * @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\requirements\task; + +/** + * Installer task that checks if the server meats phpBB requirements + */ +class check_server_environment extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\database + */ + protected $database_helper; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $response_helper; + + /** + * @var bool + */ + protected $tests_passed; + + /** + * Constructor + * + * @param \phpbb\install\helper\database $database_helper + * @param \phpbb\install\helper\iohandler\iohandler_interface $response + */ + public function __construct(\phpbb\install\helper\database $database_helper, + \phpbb\install\helper\iohandler\iohandler_interface $response) + { + $this->database_helper = $database_helper; + $this->response_helper = $response; + $this->tests_passed = true; + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + // + // Check requirements + // The error messages should be set in the check_ functions + // + + // Check PHP version + $this->check_php_version(); + + // Check for getimagesize() + $this->check_image_size(); + + // Check for PCRE support + $this->check_pcre(); + + // Check for JSON support + $this->check_json(); + + // Check for dbms support + $this->check_available_dbms(); + + return $this->tests_passed; + } + + /** + * Sets $this->tests_passed + * + * @param bool $is_passed + */ + protected function set_test_passed($is_passed) + { + // If one test failed, tests_passed should be false + $this->tests_passed = (!$this->tests_passed) ? false : $is_passed; + } + + /** + * Check if the requirements for PHP version is met + */ + protected function check_php_version() + { + $php_version = PHP_VERSION; + + if (version_compare($php_version, '5.3.9') < 0) + { + $this->response_helper->add_error_message('PHP_VERSION_REQD', 'PHP_VERSION_REQD_EXPLAIN'); + + $this->set_test_passed(false); + return; + } + + $this->set_test_passed(true); + } + + /** + * Checks if the installed PHP has getimagesize() available + */ + protected function check_image_size() + { + if (!@function_exists('getimagesize')) + { + $this->response_helper->add_error_message('PHP_GETIMAGESIZE_SUPPORT', 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'); + + $this->set_test_passed(false); + return; + } + + $this->set_test_passed(true); + } + + /** + * Checks if the installed PHP supports PCRE + */ + protected function check_pcre() + { + if (@preg_match('//u', '')) + { + $this->set_test_passed(true); + return; + } + + $this->response_helper->add_error_message('PCRE_UTF_SUPPORT', 'PCRE_UTF_SUPPORT_EXPLAIN'); + + $this->set_test_passed(false); + } + + /** + * Checks whether PHP's JSON extension is available or not + */ + protected function check_json() + { + if (@extension_loaded('json')) + { + $this->set_test_passed(true); + return; + } + + $this->response_helper->add_error_message('PHP_JSON_SUPPORT', 'PHP_JSON_SUPPORT_EXPLAIN'); + + $this->set_test_passed(false); + } + + /** + * Check if any supported DBMS is available + */ + protected function check_available_dbms() + { + $available_dbms = $this->database_helper->get_available_dbms(false, true); + + if ($available_dbms['ANY_DB_SUPPORT']) + { + $this->set_test_passed(true); + return; + } + + $this->response_helper->add_error_message('PHP_SUPPORTED_DB', 'PHP_SUPPORTED_DB_EXPLAIN'); + + $this->set_test_passed(false); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php new file mode 100644 index 0000000000..6c0c0e0c30 --- /dev/null +++ b/phpBB/phpbb/install/module_base.php @@ -0,0 +1,252 @@ + + * @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; + +use phpbb\install\exception\invalid_service_name_exception; +use phpbb\install\exception\task_not_found_exception; +use phpbb\install\helper\iohandler\iohandler_interface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; +use phpbb\install\helper\config; + +/** + * Base class for installer module + */ +abstract class module_base implements module_interface +{ + /** + * @var ContainerInterface + */ + protected $container; + + /** + * @var config + */ + protected $install_config; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** + * @var bool + */ + protected $is_essential; + + /** + * Array of tasks for installer module + * + * @var array + */ + protected $task_collection; + + /** + * @var bool + */ + protected $allow_progress_bar; + + /** + * Installer module constructor + * + * @param array $tasks array of installer tasks for installer module + * @param bool $essential flag indicating whether the module is essential or not + * @param bool $allow_progress_bar flag indicating whether or not to send progress information from within the module + */ + public function __construct(array $tasks, $essential = true, $allow_progress_bar = true) + { + $this->task_collection = $tasks; + $this->is_essential = $essential; + $this->allow_progress_bar = $allow_progress_bar; + } + + /** + * Dependency getter + * + * @param ContainerInterface $container + * @param config $config + * @param iohandler_interface $iohandler + */ + public function setup(ContainerInterface $container, config $config, iohandler_interface $iohandler) + { + $this->container = $container; + $this->install_config = $config; + $this->iohandler = $iohandler; + } + + /** + * {@inheritdoc} + */ + public function is_essential() + { + return $this->is_essential; + } + + /** + * {@inheritdoc} + * + * Overwrite this method if your task is non-essential! + */ + public function check_requirements() + { + return true; + } + + /** + * {@inheritdoc} + */ + public function run() + { + // Recover install progress + $task_index = $this->recover_progress(); + + // Run until there are available resources + while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0) + { + // Check if task exists + if (!isset($this->task_collection[$task_index])) + { + break; + } + + // Recover task to be executed + try + { + /** @var \phpbb\install\task_interface $task */ + $task = $this->container->get($this->task_collection[$task_index]); + } + catch (InvalidArgumentException $e) + { + throw new task_not_found_exception($this->task_collection[$task_index]); + } + + // Send progress information + if ($this->allow_progress_bar) + { + $this->iohandler->set_progress( + $task->get_task_lang_name(), + $this->install_config->get_current_task_progress() + ); + } + + // Iterate to the next task + $task_index++; + + // Check if we can run the task + if (!$task->is_essential() && !$task->check_requirements()) + { + $this->iohandler->add_log_message(array( + 'SKIP_TASK', + $this->task_collection[$task_index], + )); + $class_name = $this->get_class_from_service_name($this->task_collection[$task_index - 1]); + $this->install_config->increment_current_task_progress($class_name::get_step_count()); + continue; + } + + if ($this->allow_progress_bar) + { + $this->install_config->increment_current_task_progress(); + } + + $task->run(); + + // Send progress information + if ($this->allow_progress_bar) + { + $this->iohandler->set_progress( + $task->get_task_lang_name(), + $this->install_config->get_current_task_progress() + ); + } + + $this->iohandler->send_response(); + + // Log install progress + $current_task_index = $task_index - 1; + $this->install_config->set_finished_task($this->task_collection[$current_task_index], $current_task_index); + } + } + + /** + * Returns the next task's index + * + * @return int index of the array element of the next task + */ + protected function recover_progress() + { + $progress_array = $this->install_config->get_progress_data(); + $last_finished_task_name = $progress_array['last_task_name']; + $last_finished_task_index = $progress_array['last_task_index']; + + // Check if the data is relevant to this module + if (isset($this->task_collection[$last_finished_task_index])) + { + if ($this->task_collection[$last_finished_task_index] === $last_finished_task_name) + { + // Return the task index of the next task + return $last_finished_task_index + 1; + } + } + + // As of now if the progress has not been resolved we assume that it is because + // the task progress belongs to the previous module, + // so just default to the first task + // @todo make module aware of it's service name that way this can be improved + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_step_count() + { + $step_count = 0; + + foreach ($this->task_collection as $task_service_name) + { + $class_name = $this->get_class_from_service_name($task_service_name); + $step_count += $class_name::get_step_count(); + } + + return $step_count; + } + + /** + * Returns the name of the class form the service name + * + * @param string $task_service_name Name of the service + * + * @return string Name of the class + * + * @throws invalid_service_name_exception When the service name does not meet the requirements described in task_interface + */ + protected function get_class_from_service_name($task_service_name) + { + $task_service_name_parts = explode('.', $task_service_name); + + if ($task_service_name_parts[0] !== 'installer') + { + throw new invalid_service_name_exception('TASK_SERVICE_INSTALLER_MISSING'); + } + + $class_name = '\\phpbb\\install\\module\\' . $task_service_name_parts[1] . '\\task\\' . $task_service_name_parts[2]; + if (!class_exists($class_name)) + { + throw new invalid_service_name_exception('TASK_CLASS_NOT_FOUND', array($task_service_name, $class_name)); + } + + return $class_name; + } +} diff --git a/phpBB/phpbb/install/module_interface.php b/phpBB/phpbb/install/module_interface.php new file mode 100644 index 0000000000..a2d61e3958 --- /dev/null +++ b/phpBB/phpbb/install/module_interface.php @@ -0,0 +1,63 @@ + + * @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; + +/** + * Interface for installer modules + * + * An installer module is a task collection which executes installer tasks. + */ +interface module_interface +{ + /** + * Checks if the execution of the module is essential to install phpBB or it can be skipped + * + * Note: Please note that all the non-essential modules have to implement check_requirements() + * method. + * + * @return bool true if the module is essential, false otherwise + */ + public function is_essential(); + + /** + * Checks requirements for the tasks + * + * Note: Only need to be implemented for non-essential tasks, as essential tasks + * requirements should be checked in the requirements install module. + * + * @return bool true if the task's requirements are met + */ + public function check_requirements(); + + /** + * Executes the task + * + * @return null + */ + public function run(); + + /** + * Returns the number of tasks in the module + * + * @return int + */ + public function get_step_count(); + + /** + * Returns an array to the correct navigation stage + * + * @return array + */ + public function get_navigation_stage_path(); +} diff --git a/phpBB/phpbb/install/schemas/index.htm b/phpBB/phpbb/install/schemas/index.htm new file mode 100644 index 0000000000..ee1f723a7d --- /dev/null +++ b/phpBB/phpbb/install/schemas/index.htm @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/phpBB/phpbb/install/schemas/oracle_schema.sql b/phpBB/phpbb/install/schemas/oracle_schema.sql new file mode 100644 index 0000000000..2473d31aab --- /dev/null +++ b/phpBB/phpbb/install/schemas/oracle_schema.sql @@ -0,0 +1,37 @@ +/* + This first section is optional, however its probably the best method + of running phpBB on Oracle. If you already have a tablespace and user created + for phpBB you can leave this section commented out! + + The first set of statements create a phpBB tablespace and a phpBB user, + make sure you change the password of the phpBB user before you run this script!! +*/ + +/* +CREATE TABLESPACE "PHPBB" + LOGGING + DATAFILE 'E:\ORACLE\ORADATA\LOCAL\PHPBB.ora' + SIZE 10M + AUTOEXTEND ON NEXT 10M + MAXSIZE 100M; + +CREATE USER "PHPBB" + PROFILE "DEFAULT" + IDENTIFIED BY "phpbb_password" + DEFAULT TABLESPACE "PHPBB" + QUOTA UNLIMITED ON "PHPBB" + ACCOUNT UNLOCK; + +GRANT ANALYZE ANY TO "PHPBB"; +GRANT CREATE SEQUENCE TO "PHPBB"; +GRANT CREATE SESSION TO "PHPBB"; +GRANT CREATE TABLE TO "PHPBB"; +GRANT CREATE TRIGGER TO "PHPBB"; +GRANT CREATE VIEW TO "PHPBB"; +GRANT "CONNECT" TO "PHPBB"; + +COMMIT; +DISCONNECT; + +CONNECT phpbb/phpbb_password; +*/ diff --git a/phpBB/phpbb/install/schemas/postgres_schema.sql b/phpBB/phpbb/install/schemas/postgres_schema.sql new file mode 100644 index 0000000000..65caba8d1c --- /dev/null +++ b/phpBB/phpbb/install/schemas/postgres_schema.sql @@ -0,0 +1,80 @@ + +BEGIN; + +/* + Domain definition +*/ +CREATE DOMAIN varchar_ci AS varchar(255) NOT NULL DEFAULT ''::character varying; + +/* + Operation Functions +*/ +CREATE FUNCTION _varchar_ci_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) = LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_not_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) != LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_less_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) < LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_less_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) <= LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_greater_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) > LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_greater_equals(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) >= LOWER($2)' LANGUAGE SQL STRICT; + +/* + Operators +*/ +CREATE OPERATOR <( + PROCEDURE = _varchar_ci_less_than, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = >, + NEGATOR = >=, + RESTRICT = scalarltsel, + JOIN = scalarltjoinsel); + +CREATE OPERATOR <=( + PROCEDURE = _varchar_ci_less_equal, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = >=, + NEGATOR = >, + RESTRICT = scalarltsel, + JOIN = scalarltjoinsel); + +CREATE OPERATOR >( + PROCEDURE = _varchar_ci_greater_than, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = <, + NEGATOR = <=, + RESTRICT = scalargtsel, + JOIN = scalargtjoinsel); + +CREATE OPERATOR >=( + PROCEDURE = _varchar_ci_greater_equals, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = <=, + NEGATOR = <, + RESTRICT = scalargtsel, + JOIN = scalargtjoinsel); + +CREATE OPERATOR <>( + PROCEDURE = _varchar_ci_not_equal, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = <>, + NEGATOR = =, + RESTRICT = neqsel, + JOIN = neqjoinsel); + +CREATE OPERATOR =( + PROCEDURE = _varchar_ci_equal, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = =, + NEGATOR = <>, + RESTRICT = eqsel, + JOIN = eqjoinsel, + HASHES, + MERGES, + SORT1= <); + +COMMIT; + diff --git a/phpBB/phpbb/install/schemas/schema_data.sql b/phpBB/phpbb/install/schemas/schema_data.sql new file mode 100644 index 0000000000..1f856f016c --- /dev/null +++ b/phpBB/phpbb/install/schemas/schema_data.sql @@ -0,0 +1,821 @@ +# +# $Id$ +# + +# POSTGRES BEGIN # + +# -- Config +INSERT INTO phpbb_config (config_name, config_value) VALUES ('active_sessions', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_attachments', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_autologin', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_gravatar', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_local', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_upload', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote_upload', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bbcode', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_birthdays', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bookmarks', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_cdn', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_emailreuse', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_password_reset', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_forum_notify', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_live_searches', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_mass_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_name_chars', 'USERNAME_CHARS_ANY'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_namechange', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_nocensors', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_pm_attach', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_pm_report', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_post_flash', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_post_links', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_privmsg', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_quick_reply', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_bbcode', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_flash', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_img', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_links', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_smilies', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_smilies', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_topic_notify', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('assets_version', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('attachment_quota', '52428800'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_bbcode_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_flash_pm', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_img_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_method', 'db'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_smilies_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_filesize', '6144'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_gallery_path', 'images/avatars/gallery'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_max_height', '90'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_max_width', '90'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_min_height', '20'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_min_width', '20'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_path', 'images/avatars/upload'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_salt', 'phpbb_avatar'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact', 'contact@yourdomain.tld'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact_name', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable_msg', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email', 'address@yourdomain.tld'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_form', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_sig', '{L_CONFIG_BOARD_EMAIL_SIG}'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_hide_emails', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_index_text', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_timezone', 'UTC'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('browser_check', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('bump_interval', '10'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('bump_type', 'd'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('cache_gc', '7200'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_plugin', 'core.captcha.plugins.nogd'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_foreground_noise', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_x_grid', '25'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_y_grid', '25'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_wave', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_3d_noise', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_fonts', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('confirm_refresh', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_attachment_content', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_form_enable', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_domain', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_name', 'phpbb3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_path', '/'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_secure', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('coppa_enable', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('coppa_fax', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('coppa_mail', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('database_gc', '604800'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('dbms_version', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('default_dateformat', 'D M d, Y g:i a'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('default_style', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_edited', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_subject', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_order', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('edit_time', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('extension_force_unstable', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('delete_time', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_check_mx', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_enable', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_function_name', 'mail'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_max_chunk_size', '50'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_package_size', '20'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_confirm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_mod_rewrite', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_pm_icons', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_post_confirm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_enable', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_http_auth', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_limit_post', '15'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_limit_topic', '10'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_overall_forums', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_overall', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_forum', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_topic', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_topics_new', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_topics_active', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_item_statistics', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('flood_interval', '15'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('force_server_vars', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('form_token_lifetime', '7200'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('form_token_mintime', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('form_token_sid_guests', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('forward_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('forwarded_for_check', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('full_folder_action', '2'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_mysql_max_word_len', '254'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_mysql_min_word_len', '4'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_common_thres', '5'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_load_upd', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_max_chars', '14'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_min_chars', '3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_max_word_len', '254'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_min_word_len', '4'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_ts_name', 'simple'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_indexer_mem_limit', '512'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_stopwords', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('gzip_compress', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('hot_threshold', '25'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('icons_path', 'images/icons'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_create_thumbnail', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_display_inlined', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_imagick', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_link_height', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_link_width', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_height', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_thumb_width', '400'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_width', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_min_thumb_filesize', '12000'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_check', '3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_max', '50'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_time', '21600'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_use_forwarded', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_enable', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_host', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_password', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_package_size', '20'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_port', '5222'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_use_ssl', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_username', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_base_dn', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_email', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_password', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_port', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_server', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_uid', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_user', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_user_filter', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('legend_sort_groupname', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_load', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_search_load', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_anon_lastread', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_birthdays', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_memberlist', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofile', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewtopic', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_track', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jumpbox', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_moderators', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_notifications', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_guests', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time', '5'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_onlinetrack', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_tplcompile', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_unreads_search', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_user_activity', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments', '3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_autologin_time', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_filesize', '262144'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_filesize_pm', '262144'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_login_attempts', '3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_name_chars', '20'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_num_search_keywords', '10'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_pass_chars', '100'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_poll_options', '10'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_chars', '60000'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_font_size', '200'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_img_height', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_img_width', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_smilies', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_urls', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_quote_depth', '3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_reg_attempts', '5'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_chars', '255'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_font_size', '200'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_img_height', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_img_width', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_smilies', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_urls', '5'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_name_chars', '3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_pass_chars', '6'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_post_chars', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_search_author_chars', '3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('new_member_post_limit', '3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('new_member_group_default', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('override_user_style', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('pass_complex', 'PASS_TYPE_ANY'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('plupload_salt', 'phpbb_plupload'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_edit_time', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_boxes', '4'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_msgs', '50'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_recipients', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('posts_per_page', '10'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('print_pm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('queue_interval', '60'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('ranks_path', 'images/ranks'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('read_notification_expire_days', '30'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('read_notification_gc', '86400'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('referer_validation', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('script_path', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_block_size', '250'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_gc', '7200'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_interval', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_anonymous_interval', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_type', '\phpbb\search\fulltext_native'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_store_results', '1800'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_deny', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_empty_referer', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_downloads', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_name', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_port', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_protocol', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_gc', '3600'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_length', '3600'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_desc', '{L_CONFIG_SITE_DESC}'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_url', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_text', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('sitename', '{L_CONFIG_SITENAME}'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_path', 'images/smilies'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_per_page', '50'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_auth_method', 'PLAIN'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_delivery', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_host', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_password', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_port', '25'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_username', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('teampage_memberships', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('teampage_forums', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', '25'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_path', 'files'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('use_system_cron', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.2.0-a1-dev'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_expire_days', '90'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_gc', '14400'); + +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('cache_last_gc', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('cron_lock', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('database_last_gc', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('last_queue_run', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_colour', 'AA0000', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_id', '2', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_username', '', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_files', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_posts', '1', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_topics', '1', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_users', '1', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('plupload_last_gc', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('rand_seed', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('rand_seed_last_update', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('read_notification_last_gc', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_date', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_users', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_indexing_state', '', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_last_gc', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('session_last_gc', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('upload_dir_size', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('warnings_last_gc', '0', 1); + +# Config text +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_uid', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_bitfield', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_flags', '7'); + +# -- Forum related auth options +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_announce', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_attach', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_bbcode', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_bump', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_delete', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_download', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_edit', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_email', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_flash', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_icons', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_ignoreflood', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_img', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_list', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_noapprove', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_poll', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_post', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_postcount', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_print', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_read', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_reply', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_report', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_search', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_sigs', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_smilies', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_sticky', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_subscribe', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_user_lock', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_vote', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_votechg', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_softdelete', 1); + +# -- Moderator related auth options +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_approve', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_chgposter', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_delete', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_edit', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_info', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_lock', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_merge', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_move', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_report', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_split', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_softdelete', 1, 1); + +# -- Global moderator auth option (not a local option) +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_ban', 0, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_warn', 0, 1); + +# -- Admin related auth options +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_aauth', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_attach', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_authgroups', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_authusers', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_backup', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_ban', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_bbcode', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_board', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_bots', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_clearlogs', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_email', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_extensions', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_fauth', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forum', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forumadd', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forumdel', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_group', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_groupadd', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_groupdel', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_icons', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_jabber', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_language', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_mauth', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_modules', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_names', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_phpinfo', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_profile', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_prune', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_ranks', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_reasons', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_roles', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_search', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_server', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_styles', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_switchperm', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_uauth', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_user', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_userdel', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_viewauth', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_viewlogs', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_words', 1); + +# -- User related auth options +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_attach', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgavatar', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgcensors', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgemail', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chggrp', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgname', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgpasswd', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgprofileinfo', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_download', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_hideonline', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_ignoreflood', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_masspm', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_masspm_group', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_attach', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_bbcode', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_delete', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_download', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_edit', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_emailpm', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_flash', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_forward', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_img', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_printpm', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_smilies', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_readpm', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_savedrafts', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_search', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendemail', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendim', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendpm', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sig', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_viewonline', 1); +INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_viewprofile', 1); + + +# -- standard auth roles +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_ADMIN_STANDARD', 'ROLE_DESCRIPTION_ADMIN_STANDARD', 'a_', 1); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_ADMIN_FORUM', 'ROLE_DESCRIPTION_ADMIN_FORUM', 'a_', 3); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_ADMIN_USERGROUP', 'ROLE_DESCRIPTION_ADMIN_USERGROUP', 'a_', 4); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_ADMIN_FULL', 'ROLE_DESCRIPTION_ADMIN_FULL', 'a_', 2); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_FULL', 'ROLE_DESCRIPTION_USER_FULL', 'u_', 3); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_STANDARD', 'ROLE_DESCRIPTION_USER_STANDARD', 'u_', 1); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_LIMITED', 'ROLE_DESCRIPTION_USER_LIMITED', 'u_', 2); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NOPM', 'ROLE_DESCRIPTION_USER_NOPM', 'u_', 4); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NOAVATAR', 'ROLE_DESCRIPTION_USER_NOAVATAR', 'u_', 5); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_MOD_FULL', 'ROLE_DESCRIPTION_MOD_FULL', 'm_', 3); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_MOD_STANDARD', 'ROLE_DESCRIPTION_MOD_STANDARD', 'm_', 1); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_MOD_SIMPLE', 'ROLE_DESCRIPTION_MOD_SIMPLE', 'm_', 2); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_MOD_QUEUE', 'ROLE_DESCRIPTION_MOD_QUEUE', 'm_', 4); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_FULL', 'ROLE_DESCRIPTION_FORUM_FULL', 'f_', 7); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_STANDARD', 'ROLE_DESCRIPTION_FORUM_STANDARD', 'f_', 5); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NOACCESS', 'ROLE_DESCRIPTION_FORUM_NOACCESS', 'f_', 1); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_READONLY', 'ROLE_DESCRIPTION_FORUM_READONLY', 'f_', 2); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_LIMITED', 'ROLE_DESCRIPTION_FORUM_LIMITED', 'f_', 3); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_BOT', 'ROLE_DESCRIPTION_FORUM_BOT', 'f_', 9); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_ONQUEUE', 'ROLE_DESCRIPTION_FORUM_ONQUEUE', 'f_', 8); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_POLLS', 'ROLE_DESCRIPTION_FORUM_POLLS', 'f_', 6); +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_LIMITED_POLLS', 'ROLE_DESCRIPTION_FORUM_LIMITED_POLLS', 'f_', 4); + +# 23 +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', 6); + +# 24 +INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', 10); + +# -- phpbb_styles +INSERT INTO phpbb_styles (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Limited', 1, 'prosilver', 'kNg=', 0, ''); + +# -- Forums +INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents) VALUES ('{L_FORUMS_FIRST_CATEGORY}', '', 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 'Admin', 'AA0000', 972086460, '', '', '', '', '', '', '', 0, 0, ''); + +INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 0, 0, 1, 0, 0, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48); + +# -- Users / Anonymous user +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_jabber, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', 0); + +# -- username: Admin password: admin (change this or remove it once everything is working!) +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_jabber, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', ''); + +# -- Groups +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED', 3, 0, '', 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED_COPPA', 3, 0, '', 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GLOBAL_MODERATORS', 3, 0, '00AA00', 2, '', '', '', 0); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('ADMINISTRATORS', 3, 1, 'AA0000', 1, '', '', '', 0); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('BOTS', 3, 0, '9E8DA7', 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5); + +# -- Teampage +INSERT INTO phpbb_teampage (group_id, teampage_name, teampage_position, teampage_parent) VALUES (5, '', 1, 0); +INSERT INTO phpbb_teampage (group_id, teampage_name, teampage_position, teampage_parent) VALUES (4, '', 2, 0); + +# -- User -> Group +INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (1, 1, 0, 0); +INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (2, 2, 0, 0); +INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (4, 2, 0, 0); +INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (5, 2, 0, 1); + +# -- Ranks +INSERT INTO phpbb_ranks (rank_title, rank_min, rank_special, rank_image) VALUES ('{L_RANKS_SITE_ADMIN_TITLE}', 0, 1, ''); + +# -- Roles data + +# Standard Admin (a_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 1, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option NOT IN ('a_switchperm', 'a_jabber', 'a_phpinfo', 'a_server', 'a_backup', 'a_styles', 'a_clearlogs', 'a_modules', 'a_language', 'a_email', 'a_bots', 'a_search', 'a_aauth', 'a_roles'); + +# Forum admin (a_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 2, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option IN ('a_', 'a_authgroups', 'a_authusers', 'a_fauth', 'a_forum', 'a_forumadd', 'a_forumdel', 'a_mauth', 'a_prune', 'a_uauth', 'a_viewauth', 'a_viewlogs'); + +# User and Groups Admin (a_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 3, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option IN ('a_', 'a_authgroups', 'a_authusers', 'a_ban', 'a_group', 'a_groupadd', 'a_groupdel', 'a_ranks', 'a_uauth', 'a_user', 'a_viewauth', 'a_viewlogs'); + +# Full Admin (a_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 4, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%'; + +# All Features (u_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 5, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%'; + +# Standard Features (u_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 6, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_flash', 'u_pm_forward'); + +# Limited Features (u_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 7, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_pm_flash', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group'); + +# No Private Messages (u_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 8, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_', 'u_chgavatar', 'u_chgcensors', 'u_chgemail', 'u_chgpasswd', 'u_download', 'u_hideonline', 'u_sig', 'u_viewprofile'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 8, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_readpm', 'u_sendpm', 'u_masspm', 'u_masspm_group'); + +# No Avatar (u_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_chgavatar', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_pm_flash', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_chgavatar'); + +# Full Moderator (m_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 10, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%'; + +# Standard Moderator (m_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 11, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option NOT IN ('m_ban', 'm_chgposter'); + +# Simple Moderator (m_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 12, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option IN ('m_', 'm_delete', 'm_softdelete', 'm_edit', 'm_info', 'm_report'); + +# Queue Moderator (m_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 13, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option IN ('m_', 'm_approve', 'm_edit'); + +# Full Access (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 14, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%'; + +# Standard Access (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 15, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_flash', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock'); + +# No Access (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 16, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option = 'f_'; + +# Read Only Access (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 17, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_', 'f_download', 'f_list', 'f_read', 'f_search', 'f_subscribe', 'f_print'); + +# Limited Access (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 18, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg'); + +# Bot Access (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 19, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_', 'f_download', 'f_list', 'f_read', 'f_print'); + +# On Moderation Queue (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 20, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg', 'f_noapprove'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 20, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove'); + +# Standard Access + Polls (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 21, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_flash', 'f_ignoreflood', 'f_sticky', 'f_user_lock'); + +# Limited Access + Polls (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 22, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_sticky', 'f_user_lock', 'f_votechg'); + +# New Member (u_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 23, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group', 'u_chgprofileinfo'); + +# New Member (f_) +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 24, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove'); + + +# Permissions + +# GUESTS - u_download and u_search ability +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) SELECT 1, 0, auth_option_id, 0, 1 FROM phpbb_acl_options WHERE auth_option IN ('u_', 'u_download', 'u_search'); + +# Admin user - full user features +INSERT INTO phpbb_acl_users (user_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (2, 0, 0, 5, 0); + +# ADMINISTRATOR Group - full user features +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (5, 0, 0, 5, 0); + +# ADMINISTRATOR Group - standard admin +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (5, 0, 0, 1, 0); + +# REGISTERED and REGISTERED_COPPA having standard user features +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (2, 0, 0, 6, 0); +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (3, 0, 0, 6, 0); + +# GLOBAL_MODERATORS having full user features +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (4, 0, 0, 5, 0); + +# GLOBAL_MODERATORS having full global moderator access +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (4, 0, 0, 10, 0); + +# Giving all groups read only access to the first category +# since administrators and moderators are already within the registered users group we do not need to set them here +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (1, 1, 0, 17, 0); +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (2, 1, 0, 17, 0); +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (3, 1, 0, 17, 0); +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (6, 1, 0, 17, 0); + +# Giving access to the first forum + +# guests having read only access +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (1, 2, 0, 17, 0); + +# registered and registered_coppa having standard access +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (2, 2, 0, 15, 0); +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (3, 2, 0, 15, 0); + +# global moderators having standard access + polls +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (4, 2, 0, 21, 0); + +# administrators having full forum and full moderator access +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (5, 2, 0, 14, 0); +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (5, 2, 0, 10, 0); + +# Bots having bot access +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (6, 2, 0, 19, 0); + +# NEW MEMBERS are not allowed to send private messages +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 0, 0, 23, 0); + +# NEW MEMBERS on the queue +INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0); + + +# -- Demo Topic +INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title, topic_visibility) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 1, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, '', 1); + +# -- Demo Post +INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, icon_id, post_time, post_username, poster_ip, post_subject, post_text, post_checksum, bbcode_uid, post_visibility) VALUES (1, 2, 2, 0, 972086460, '', '127.0.0.1', '{L_TOPICS_TOPIC_TITLE}', '{L_DEFAULT_INSTALL_POST}', '5dd683b17f641daf84c040bfefc58ce9', '', 1); + +# -- Admin posted to the demo topic +INSERT INTO phpbb_topics_posted (user_id, topic_id, topic_posted) VALUES (2, 1, 1); + +# -- Smilies +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':D', 'icon_e_biggrin.gif', '{L_SMILIES_VERY_HAPPY}', 15, 17, 1); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-D', 'icon_e_biggrin.gif', '{L_SMILIES_VERY_HAPPY}', 15, 17, 2); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':grin:', 'icon_e_biggrin.gif', '{L_SMILIES_VERY_HAPPY}', 15, 17, 3); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':)', 'icon_e_smile.gif', '{L_SMILIES_SMILE}', 15, 17, 4); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-)', 'icon_e_smile.gif', '{L_SMILIES_SMILE}', 15, 17, 5); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':smile:', 'icon_e_smile.gif', '{L_SMILIES_SMILE}', 15, 17, 6); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (';)', 'icon_e_wink.gif', '{L_SMILIES_WINK}', 15, 17, 7); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (';-)', 'icon_e_wink.gif', '{L_SMILIES_WINK}', 15, 17, 8); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':wink:', 'icon_e_wink.gif', '{L_SMILIES_WINK}', 15, 17, 9); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':(', 'icon_e_sad.gif', '{L_SMILIES_SAD}', 15, 17, 10); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-(', 'icon_e_sad.gif', '{L_SMILIES_SAD}', 15, 17, 11); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':sad:', 'icon_e_sad.gif', '{L_SMILIES_SAD}', 15, 17, 12); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':o', 'icon_e_surprised.gif', '{L_SMILIES_SURPRISED}', 15, 17, 13); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-o', 'icon_e_surprised.gif', '{L_SMILIES_SURPRISED}', 15, 17, 14); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':eek:', 'icon_e_surprised.gif', '{L_SMILIES_SURPRISED}', 15, 17, 15); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':shock:', 'icon_eek.gif', '{L_SMILIES_SHOCKED}', 15, 17, 16); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':?', 'icon_e_confused.gif', '{L_SMILIES_CONFUSED}', 15, 17, 17); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-?', 'icon_e_confused.gif', '{L_SMILIES_CONFUSED}', 15, 17, 18); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':???:', 'icon_e_confused.gif', '{L_SMILIES_CONFUSED}', 15, 17, 19); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES ('8-)', 'icon_cool.gif', '{L_SMILIES_COOL}', 15, 17, 20); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':cool:', 'icon_cool.gif', '{L_SMILIES_COOL}', 15, 17, 21); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':lol:', 'icon_lol.gif', '{L_SMILIES_LAUGHING}', 15, 17, 22); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':x', 'icon_mad.gif', '{L_SMILIES_MAD}', 15, 17, 23); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-x', 'icon_mad.gif', '{L_SMILIES_MAD}', 15, 17, 24); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':mad:', 'icon_mad.gif', '{L_SMILIES_MAD}', 15, 17, 25); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':P', 'icon_razz.gif', '{L_SMILIES_RAZZ}', 15, 17, 26); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-P', 'icon_razz.gif', '{L_SMILIES_RAZZ}', 15, 17, 27); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':razz:', 'icon_razz.gif', '{L_SMILIES_RAZZ}', 15, 17, 28); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':oops:', 'icon_redface.gif', '{L_SMILIES_EMARRASSED}', 15, 17, 29); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':cry:', 'icon_cry.gif', '{L_SMILIES_CRYING}', 15, 17, 30); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':evil:', 'icon_evil.gif', '{L_SMILIES_EVIL}', 15, 17, 31); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':twisted:', 'icon_twisted.gif', '{L_SMILIES_TWISTED_EVIL}', 15, 17, 32); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':roll:', 'icon_rolleyes.gif', '{L_SMILIES_ROLLING_EYES}', 15, 17, 33); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':!:', 'icon_exclaim.gif', '{L_SMILIES_EXCLAMATION}', 15, 17, 34); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':?:', 'icon_question.gif', '{L_SMILIES_QUESTION}', 15, 17, 35); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':idea:', 'icon_idea.gif', '{L_SMILIES_IDEA}', 15, 17, 36); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':arrow:', 'icon_arrow.gif', '{L_SMILIES_ARROW}', 15, 17, 37); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':|', 'icon_neutral.gif', '{L_SMILIES_NEUTRAL}', 15, 17, 38); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-|', 'icon_neutral.gif', '{L_SMILIES_NEUTRAL}', 15, 17, 39); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':mrgreen:', 'icon_mrgreen.gif', '{L_SMILIES_MR_GREEN}', 15, 17, 40); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':geek:', 'icon_e_geek.gif', '{L_SMILIES_GEEK}', 17, 17, 41); +INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':ugeek:', 'icon_e_ugeek.gif', '{L_SMILIES_UBER_GEEK}', 17, 18, 42); + +# -- icons +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/fire.gif', 16, 16, 1, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/redface.gif', 16, 16, 9, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/mrgreen.gif', 16, 16, 10, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/heart.gif', 16, 16, 4, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/star.gif', 16, 16, 2, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/radioactive.gif', 16, 16, 3, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/thinking.gif', 16, 16, 5, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/info.gif', 16, 16, 8, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/question.gif', 16, 16, 6, 1); +INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/alert.gif', 16, 16, 7, 1); + +# -- reasons +INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('warez', '{L_REPORT_WAREZ}', 1); +INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('spam', '{L_REPORT_SPAM}', 2); +INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('off_topic', '{L_REPORT_OFF_TOPIC}', 3); +INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('other', '{L_REPORT_OTHER}', 4); + +# -- extension_groups +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('IMAGES', 1, 1, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('ARCHIVES', 0, 1, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('PLAIN_TEXT', 0, 0, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOCUMENTS', 0, 0, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('REAL_MEDIA', 3, 0, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('WINDOWS_MEDIA', 2, 0, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('FLASH_FILES', 5, 0, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('QUICKTIME_MEDIA', 6, 0, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOWNLOADABLE_FILES', 0, 0, 1, '', 0, ''); + +# -- extensions +INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'gif'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'png'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'jpeg'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'jpg'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'tif'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'tiff'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'tga'); + +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'gtar'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'gz'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'tar'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'zip'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'rar'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'ace'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'torrent'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'tgz'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'bz2'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, '7z'); + +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'txt'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'c'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'h'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'cpp'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'hpp'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'diz'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'csv'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'ini'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'log'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'js'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'xml'); + +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'xls'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'xlsx'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'xlsm'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'xlsb'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'doc'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'docx'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'docm'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'dot'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'dotx'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'dotm'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'pdf'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'ai'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'ps'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'ppt'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'pptx'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'pptm'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'odg'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'odp'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'ods'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'odt'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'rtf'); + +INSERT INTO phpbb_extensions (group_id, extension) VALUES (5, 'rm'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (5, 'ram'); + +INSERT INTO phpbb_extensions (group_id, extension) VALUES (6, 'wma'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (6, 'wmv'); + +INSERT INTO phpbb_extensions (group_id, extension) VALUES (7, 'swf'); + +INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'mov'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'm4v'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'm4a'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'mp4'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, '3gp'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, '3g2'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'qt'); + +INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mpeg'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mpg'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mp3'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg'); +INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm'); + +# Add default profile fields +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_location', 'profilefields.type.string', 'phpbb_location', '20', '2', '100', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, '', ''); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_website', 'profilefields.type.url', 'phpbb_website', '40', '12', '255', '', '', '', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 2, 1, 'VISIT_WEBSITE', '%s'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_interests', 'profilefields.type.text', 'phpbb_interests', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, '', ''); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_occupation', 'profilefields.type.text', 'phpbb_occupation', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 4, 0, '', ''); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_aol', 'profilefields.type.string', 'phpbb_aol', '40', '5', '255', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 5, 1, '', ''); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_icq', 'profilefields.type.string', 'phpbb_icq', '20', '3', '15', '', '', '[0-9]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 6, 1, 'SEND_ICQ_MESSAGE', 'https://www.icq.com/people/%s/'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_wlm', 'profilefields.type.string', 'phpbb_wlm', '40', '5', '255', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 7, 1, '', ''); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_yahoo', 'profilefields.type.string', 'phpbb_yahoo', '40', '5', '255', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 8, 1, 'SEND_YIM_MESSAGE', 'ymsgr:sendim?%s'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_facebook', 'profilefields.type.string', 'phpbb_facebook', '20', '5', '50', '', '', '[\w.]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 9, 1, 'VIEW_FACEBOOK_PROFILE', 'http://facebook.com/%s/'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_twitter', 'profilefields.type.string', 'phpbb_twitter', '20', '1', '15', '', '', '[\w_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 10, 1, 'VIEW_TWITTER_PROFILE', 'http://twitter.com/%s'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_skype', 'profilefields.type.string', 'phpbb_skype', '20', '6', '32', '', '', '[a-zA-Z][\w\.,\-_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 11, 1, 'VIEW_SKYPE_PROFILE', 'skype:%s?userinfo'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_youtube', 'profilefields.type.string', 'phpbb_youtube', '20', '3', '60', '', '', '[a-zA-Z][\w\.,\-_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 12, 1, 'VIEW_YOUTUBE_CHANNEL', 'http://youtube.com/user/%s'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_googleplus', 'profilefields.type.googleplus', 'phpbb_googleplus', '20', '3', '255', '', '', '[\w]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 13, 1, 'VIEW_GOOGLEPLUS_PROFILE', 'http://plus.google.com/%s'); + +# User Notification Options (for first user) +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.post', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.post', 0, 2, 'notification.method.email'); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.topic', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.topic', 0, 2, 'notification.method.email'); + +# POSTGRES COMMIT # diff --git a/phpBB/phpbb/install/task_base.php b/phpBB/phpbb/install/task_base.php new file mode 100644 index 0000000000..5946be8c52 --- /dev/null +++ b/phpBB/phpbb/install/task_base.php @@ -0,0 +1,53 @@ + + * @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; + +/** + * Base class for installer task + */ +abstract class task_base implements task_interface +{ + /** + * @var bool + */ + protected $is_essential; + + /** + * Constructor + * + * @param bool $essential + */ + public function __construct($essential = true) + { + $this->is_essential = $essential; + } + + /** + * {@inheritdoc} + */ + public function is_essential() + { + return $this->is_essential; + } + + /** + * {@inheritdoc} + * + * Overwrite this method if your task is non-essential! + */ + public function check_requirements() + { + return true; + } +} diff --git a/phpBB/phpbb/install/task_interface.php b/phpBB/phpbb/install/task_interface.php new file mode 100644 index 0000000000..14cde23a56 --- /dev/null +++ b/phpBB/phpbb/install/task_interface.php @@ -0,0 +1,65 @@ + + * @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; + +/** + * Interface for installer tasks + * + * Note: The task service ID must match up with the namespace and class name. + * For example: if your task is located at \phpbb\install\module\module_name\task\task_name + * then the service ID must be installer.module_name.task_name. + */ +interface task_interface +{ + /** + * Returns the number of steps the task contains + * + * This is a helper method to provide a better progress bar for the front-end. + * + * @return int The number of steps that the task contains + */ + static public function get_step_count(); + + /** + * Checks if the task is essential to install phpBB or it can be skipped + * + * Note: Please note that all the non-essential modules have to implement check_requirements() + * method. + * + * @return bool true if the task is essential, false otherwise + */ + public function is_essential(); + + /** + * Checks requirements for the tasks + * + * Note: Only need to be implemented for non-essential tasks, as essential tasks + * requirements should be checked in the requirements install module. + * + * @return bool true if the task's requirements are met + */ + public function check_requirements(); + + /** + * Executes the task + */ + public function run(); + + /** + * Returns the language key of the name of the task + * + * @return string + */ + public function get_task_lang_name(); +} -- cgit v1.2.1 From aa6a1c5939e4ae98d28e593ed2e09319c1341bba Mon Sep 17 00:00:00 2001 From: CHItA Date: Sat, 13 Jun 2015 15:38:51 +0200 Subject: [ticket/13740] Fix CS PHPBB3-13740 --- phpBB/phpbb/install/module/install_data/task/add_modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_data/task/add_modules.php b/phpBB/phpbb/install/module/install_data/task/add_modules.php index 6a77f8973b..8ca2b6b215 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_modules.php +++ b/phpBB/phpbb/install/module/install_data/task/add_modules.php @@ -193,7 +193,7 @@ class add_modules extends \phpbb\install\task_base $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); } - $categories[$cat_name]['id'] = (int)$module_data['module_id']; + $categories[$cat_name]['id'] = (int) $module_data['module_id']; $categories[$cat_name]['parent_id'] = 0; if (is_array($subs)) @@ -207,7 +207,7 @@ class add_modules extends \phpbb\install\task_base 'module_basename' => $basename, 'module_enabled' => 1, 'module_display' => 1, - 'parent_id' => (int)$categories[$cat_name]['id'], + 'parent_id' => (int) $categories[$cat_name]['id'], 'module_class' => $module_class, 'module_langname' => $level2_name, 'module_mode' => '', @@ -223,8 +223,8 @@ class add_modules extends \phpbb\install\task_base $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); } - $categories[$level2_name]['id'] = (int)$module_data['module_id']; - $categories[$level2_name]['parent_id'] = (int)$categories[$cat_name]['id']; + $categories[$level2_name]['id'] = (int) $module_data['module_id']; + $categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id']; } } } -- cgit v1.2.1 From c53ce3d5fbfcdc9924426aee74fb1097138a8a42 Mon Sep 17 00:00:00 2001 From: CHItA Date: Wed, 17 Jun 2015 11:00:07 +0200 Subject: [ticket/13740] Fix CS and extend phpbb extensions [ci skip] PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 21 ++++++++- .../install/exception/installer_exception.php | 4 +- .../exception/invalid_service_name_exception.php | 50 ---------------------- phpBB/phpbb/install/installer.php | 11 ++--- 4 files changed, 29 insertions(+), 57 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 0df1ae71a4..8445d80a41 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -13,6 +13,13 @@ namespace phpbb\install\controller; +use phpbb\install\helper\navigation\navigation_provider; +use phpbb\language\language; +use phpbb\language\language_file_helper; +use phpbb\path_helper; +use phpbb\routing\router; +use phpbb\symfony_request; +use phpbb\template\template; use Symfony\Component\HttpFoundation\Response; /** @@ -68,7 +75,19 @@ class helper */ protected $phpbb_root_path; - public function __construct(\phpbb\language\language $language, \phpbb\language\language_file_helper $lang_helper, \phpbb\install\helper\navigation\navigation_provider $nav, \phpbb\template\template $template, \phpbb\path_helper $path_helper, \phpbb\symfony_request $request, \phpbb\routing\router $router, $phpbb_root_path) + /** + * Constructor + * + * @param language $language + * @param language_file_helper $lang_helper + * @param navigation_provider $nav + * @param template $template + * @param path_helper $path_helper + * @param symfony_request $request + * @param router $router + * @param string $phpbb_root_path + */ + public function __construct(language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, symfony_request $request, router $router, $phpbb_root_path) { $this->language = $language; $this->lang_helper = $lang_helper; diff --git a/phpBB/phpbb/install/exception/installer_exception.php b/phpBB/phpbb/install/exception/installer_exception.php index c37950d05c..f17dca8f17 100644 --- a/phpBB/phpbb/install/exception/installer_exception.php +++ b/phpBB/phpbb/install/exception/installer_exception.php @@ -13,10 +13,12 @@ namespace phpbb\install\exception; +use phpbb\exception\runtime_exception; + /** * Installer's base exception */ -class installer_exception extends \Exception +class installer_exception extends runtime_exception { } diff --git a/phpBB/phpbb/install/exception/invalid_service_name_exception.php b/phpBB/phpbb/install/exception/invalid_service_name_exception.php index e64cd2026f..dff4873f3c 100644 --- a/phpBB/phpbb/install/exception/invalid_service_name_exception.php +++ b/phpBB/phpbb/install/exception/invalid_service_name_exception.php @@ -15,55 +15,5 @@ namespace phpbb\install\exception; class invalid_service_name_exception extends installer_exception { - /** - * @var string - */ - private $params; - /** - * @var string - */ - private $error; - - /** - * Constructor - * - * @param string $error The name of the missing installer module - * @param array $params Additional values for message translation - */ - public function __construct($error, $params = array()) - { - $this->error = $error; - $this->params = $params; - } - - /** - * Returns the language entry's name for the error - * - * @return string - */ - public function get_error() - { - return $this->error; - } - - /** - * Returns parameters for the language entry, if there is any - * - * @return array - */ - public function get_params() - { - return $this->params; - } - - /** - * Returns true, if there are any parameters set - * - * @return bool - */ - public function has_params() - { - return (sizeof($this->params) !== 0); - } } diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index f5da898a00..d64713e6a3 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -229,17 +229,18 @@ class installer } catch (invalid_service_name_exception $e) { - if ($e->has_params()) + $params = $e->get_parameters(); + + if (!empty($params)) { - $msg = $e->get_params(); - array_unshift($msg, $e->get_error()); + array_unshift($params, $e->getMessage()); } else { - $msg = $e->get_error(); + $params = $e->getMessage(); } - $this->iohandler->add_error_message($msg); + $this->iohandler->add_error_message($params); $flush_messages = true; } -- cgit v1.2.1 From 0f5f62f8db4fe5816329abaca7ad6ff10c8cf749 Mon Sep 17 00:00:00 2001 From: CHItA Date: Thu, 18 Jun 2015 02:12:49 +0200 Subject: [ticket/13740] Load schema_data.sql from the correct location [ci skip] PHPBB3-13740 --- .../module/install_database/task/add_default_data.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php index 5dbfbb4478..44b614f4de 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_default_data.php +++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php @@ -43,6 +43,11 @@ class add_default_data extends \phpbb\install\task_base */ protected $language; + /** + * @var string + */ + protected $phpbb_root_path; + /** * Constructor * @@ -51,26 +56,26 @@ class add_default_data extends \phpbb\install\task_base * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler * @param \phpbb\install\helper\container_factory $container Installer's DI container * @param \phpbb\language\language $language Language service + * @param string $root_path Root path of phpBB */ public function __construct(\phpbb\install\helper\database $db_helper, \phpbb\install\helper\config $config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, \phpbb\install\helper\container_factory $container, - \phpbb\language\language $language) + \phpbb\language\language $language, + $root_path) { $dbms = $db_helper->get_available_dbms($config->get('dbms')); $dbms = $dbms[$config->get('dbms')]['DRIVER']; - $this->db = $container->get('dbal.conn'); //new $dbms(); + $this->db = $container->get('dbal.conn'); $this->database_helper = $db_helper; $this->config = $config; $this->iohandler = $iohandler; $this->language = $language; + $this->phpbb_root_path = $root_path; parent::__construct(true); - - // Connect to DB - //$this->db->sql_connect($config->get('dbhost'), $config->get('dbuser'), $config->get('dbpasswd'), $config->get('dbname'), $config->get('dbport'), false, false); } /** @@ -85,7 +90,7 @@ class add_default_data extends \phpbb\install\task_base $dbms_info = $this->database_helper->get_available_dbms($dbms); // Get schema data from file - $sql_query = @file_get_contents('schemas/schema_data.sql'); + $sql_query = @file_get_contents($this->phpbb_root_path . 'phpbb/install/schemas/schema_data.sql'); // Clean up SQL $sql_query = $this->replace_dbms_specific_sql($sql_query); -- cgit v1.2.1 From 02029fe1610e5aa1792f24a4d748c6ed08bfc5fc Mon Sep 17 00:00:00 2001 From: CHItA Date: Thu, 18 Jun 2015 14:12:56 +0200 Subject: [ticket/13740] Use DBAL for retrieving DB version PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index d728c8b93b..38823c1231 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -394,7 +394,7 @@ class database switch ($dbms) { case 'mysqli': - if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<')) + if (version_compare($db->sql_server_info(), '4.1.3', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_MYSQLI', @@ -402,7 +402,7 @@ class database } break; case 'sqlite': - if (version_compare(sqlite_libversion(), '2.8.2', '<')) + if (version_compare($db->sql_server_info(), '2.8.2', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_SQLITE', @@ -410,8 +410,7 @@ class database } break; case 'sqlite3': - $version = \SQLite3::version(); - if (version_compare($version['versionString'], '3.6.15', '<')) + if (version_compare($db->sql_server_info(), '3.6.15', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_SQLITE3', -- cgit v1.2.1 From 08d9d567ca9fb52b18be5d8f709ba7b1699fd34f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 19 Jun 2015 01:26:15 +0200 Subject: [ticket/13740] Fix database installation PHPBB3-13740 --- .../phpbb/install/module/install_database/task/add_default_data.php | 5 +---- phpBB/phpbb/install/module/install_database/task/create_schema.php | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php index 44b614f4de..1e1eb10403 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_default_data.php +++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php @@ -65,10 +65,7 @@ class add_default_data extends \phpbb\install\task_base \phpbb\language\language $language, $root_path) { - $dbms = $db_helper->get_available_dbms($config->get('dbms')); - $dbms = $dbms[$config->get('dbms')]['DRIVER']; - - $this->db = $container->get('dbal.conn'); + $this->db = $container->get('dbal.conn.driver'); $this->database_helper = $db_helper; $this->config = $config; $this->iohandler = $iohandler; diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php index 7cc521eee8..556bfd5e81 100644 --- a/phpBB/phpbb/install/module/install_database/task/create_schema.php +++ b/phpBB/phpbb/install/module/install_database/task/create_schema.php @@ -119,7 +119,7 @@ class create_schema extends \phpbb\install\task_base } } - $db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; + $db_schema_path = $this->phpbb_root_path . 'phpbb/install/schemas/' . $schema_name . '_schema.sql'; // Load database vendor specific code if there is any if ($this->filesystem->exists($db_schema_path)) @@ -144,9 +144,9 @@ class create_schema extends \phpbb\install\task_base $change_prefix = false; // Generate database schema - if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) + if ($this->filesystem->exists($this->phpbb_root_path . 'phpbb/install/schemas/schema.json')) { - $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); + $db_table_schema = @file_get_contents($this->phpbb_root_path . 'phpbb/install/schemas/schema.json'); $db_table_schema = json_decode($db_table_schema, true); $change_prefix = true; } -- cgit v1.2.1 From 06f4ebce1b1cc8ecd5ddd84f7d2705007a685de3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 31 May 2015 17:19:42 +0200 Subject: [ticket/13740] CLI installer and fixes [ci skip] PHPBB3-13740 --- .../command/install/config/default_config.php | 103 +++++++++ .../console/command/install/config/show.php | 131 ++++++++++++ .../console/command/install/config/validate.php | 132 ++++++++++++ .../install/console/command/install/install.php | 194 +++++++++++++++++ phpBB/phpbb/install/helper/config.php | 10 + .../install/helper/iohandler/ajax_iohandler.php | 2 + .../install/helper/iohandler/cli_iohandler.php | 235 +++++++++++++++++++++ phpBB/phpbb/install/helper/iohandler/factory.php | 7 +- .../install/helper/iohandler/iohandler_base.php | 34 ++- .../helper/iohandler/iohandler_interface.php | 27 ++- phpBB/phpbb/install/installer_configuration.php | 140 ++++++++++++ .../obtain_data/task/obtain_database_data.php | 2 +- phpBB/phpbb/install/module/requirements/module.php | 1 + 13 files changed, 1012 insertions(+), 6 deletions(-) create mode 100644 phpBB/phpbb/install/console/command/install/config/default_config.php create mode 100644 phpBB/phpbb/install/console/command/install/config/show.php create mode 100644 phpBB/phpbb/install/console/command/install/config/validate.php create mode 100644 phpBB/phpbb/install/console/command/install/install.php create mode 100644 phpBB/phpbb/install/helper/iohandler/cli_iohandler.php create mode 100644 phpBB/phpbb/install/installer_configuration.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/config/default_config.php b/phpBB/phpbb/install/console/command/install/config/default_config.php new file mode 100644 index 0000000000..75c9f94901 --- /dev/null +++ b/phpBB/phpbb/install/console/command/install/config/default_config.php @@ -0,0 +1,103 @@ + +* @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\console\command\install\config; + +use phpbb\language\language; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Yaml\Yaml; + +class default_config extends \phpbb\console\command\command +{ + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + */ + public function __construct(language $language) + { + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('install:config:default') + ; + } + + /** + * Display the default configuration + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $default_config = <<writeln($default_config); + } +} diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php new file mode 100644 index 0000000000..4155440fc3 --- /dev/null +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -0,0 +1,131 @@ + +* @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\console\command\install\config; + +use phpbb\install\helper\iohandler\factory; +use phpbb\install\installer; +use phpbb\install\installer_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class show extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var installer + */ + protected $installer; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + * @param installer $installer + */ + public function __construct(language $language, factory $factory, installer $installer) + { + $this->iohandler_factory = $factory; + $this->installer = $installer; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('install:config:show') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_SHOW_CONFIG')) + ; + } + + /** + * Show the validated configuration + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + + return; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return; + } + + $processor = new Processor(); + $configuration = new installer_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return; + } + + $iohandler->add_log_message(Yaml::dump(array('installer' => $config), 10, 4, true, false)); + } +} diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php new file mode 100644 index 0000000000..19b6f99a8b --- /dev/null +++ b/phpBB/phpbb/install/console/command/install/config/validate.php @@ -0,0 +1,132 @@ + +* @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\console\command\install\config; + +use phpbb\install\helper\iohandler\factory; +use phpbb\install\installer; +use phpbb\install\installer_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class validate extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var installer + */ + protected $installer; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + * @param installer $installer + */ + public function __construct(language $language, factory $factory, installer $installer) + { + $this->iohandler_factory = $factory; + $this->installer = $installer; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('install:config:validate') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_VALIDATE_CONFIG')) + ; + } + + /** + * Validate the configuration file + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + + return 1; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return 1; + } + + $processor = new Processor(); + $configuration = new installer_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return 1; + } + + $iohandler->add_success_message('CONFIGURATION_VALID'); + return 0; + } +} diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php new file mode 100644 index 0000000000..d3f6d363f8 --- /dev/null +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -0,0 +1,194 @@ + +* @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\console\command\install; + +use phpbb\install\exception\installer_exception; +use phpbb\install\helper\iohandler\cli_iohandler; +use phpbb\install\helper\iohandler\factory; +use phpbb\install\installer; +use phpbb\install\installer_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class install extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var installer + */ + protected $installer; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + * @param installer $installer + */ + public function __construct(language $language, factory $factory, installer $installer) + { + $this->iohandler_factory = $factory; + $this->installer = $installer; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('install') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_BOARD')) + ; + } + + /** + * Executes the command install. + * + * Install the board + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + // @todo check that phpBB is not already installed + + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $this->installer->set_iohandler($iohandler); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + + return; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return; + } + + $processor = new Processor(); + $configuration = new installer_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return; + } + + $this->register_configuration($iohandler, $config); + + try + { + $this->installer->run(); + } + catch (installer_exception $e) + { + $iohandler->add_error_message($e->getMessage()); + return; + } + } + + /** + * Register the configuration to simulate the forms. + * + * @param cli_iohandler $iohandler + * @param array $config + */ + private function register_configuration(cli_iohandler $iohandler, $config) + { + $iohandler->set_input('admin_name', $config['admin']['name']); + $iohandler->set_input('admin_pass1', $config['admin']['password']); + $iohandler->set_input('admin_pass2', $config['admin']['password']); + $iohandler->set_input('board_email', $config['admin']['email']); + $iohandler->set_input('submit_admin', 'submit'); + + $iohandler->set_input('default_lang', $config['board']['lang']); + $iohandler->set_input('board_name', $config['board']['name']); + $iohandler->set_input('board_description', $config['board']['description']); + $iohandler->set_input('submit_board', 'submit'); + + $iohandler->set_input('dbms', $config['database']['dbms']); + $iohandler->set_input('dbhost', $config['database']['dbhost']); + $iohandler->set_input('dbport', $config['database']['dbport']); + $iohandler->set_input('dbuser', $config['database']['dbuser']); + $iohandler->set_input('dbpasswd', $config['database']['dbpasswd']); + $iohandler->set_input('dbname', $config['database']['dbname']); + $iohandler->set_input('table_prefix', $config['database']['table_prefix']); + $iohandler->set_input('submit_database', 'submit'); + + $iohandler->set_input('email_enable', $config['email']['enabled']); + $iohandler->set_input('smtp_delivery', $config['email']['smtp_delivery']); + $iohandler->set_input('smtp_host', $config['email']['smtp_host']); + $iohandler->set_input('smtp_auth', $config['email']['smtp_auth']); + $iohandler->set_input('smtp_user', $config['email']['smtp_user']); + $iohandler->set_input('smtp_pass', $config['email']['smtp_pass']); + $iohandler->set_input('submit_email', 'submit'); + + $iohandler->set_input('cookie_secure', $config['server']['cookie_secure']); + $iohandler->set_input('server_protocol', $config['server']['server_protocol']); + $iohandler->set_input('force_server_vars', $config['server']['force_server_vars']); + $iohandler->set_input('server_name', $config['server']['server_name']); + $iohandler->set_input('server_port', $config['server']['server_port']); + $iohandler->set_input('script_path', $config['server']['script_path']); + $iohandler->set_input('submit_server', 'submit'); + } +} diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index 5c1348c06d..cf51432332 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -147,6 +147,11 @@ class config */ public function get_time_remaining() { + if ($this->system_data['max_execution_time'] <= 0) + { + return 1; + } + return ($this->system_data['start_time'] + $this->system_data['max_execution_time']) - time(); } @@ -157,6 +162,11 @@ class config */ public function get_memory_remaining() { + if ($this->system_data['memory_limit'] <= 0) + { + return 1; + } + if (function_exists('memory_get_usage')) { return ($this->system_data['memory_limit'] - memory_get_usage()); diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 71571fecba..85cb2ca753 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -182,6 +182,7 @@ class ajax_iohandler extends iohandler_base 'errors' => $this->errors, 'warnings' => $this->warnings, 'logs' => $this->logs, + 'success' => $this->success, ); if (!empty($this->form)) @@ -208,6 +209,7 @@ class ajax_iohandler extends iohandler_base $this->errors = array(); $this->warnings = array(); $this->logs = array(); + $this->success = array(); $this->nav_data = array(); if ($this->request_client_refresh) diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php new file mode 100644 index 0000000000..d990f48925 --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -0,0 +1,235 @@ + + * @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\helper\iohandler; + +use phpbb\install\exception\installer_exception; +use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\OutputStyle; + +/** + * Input-Output handler for the CLI frontend + */ +class cli_iohandler extends iohandler_base +{ + /** + * @var OutputInterface + */ + protected $output; + + /** + * @var OutputStyle + */ + protected $io; + + /** + * @var array + */ + protected $input_values = array(); + + /** + * @var ProgressBar + */ + protected $progress_bar; + + /** + * Set the style and output used to display feedback; + * + * @param OutputStyle $style + */ + public function set_style(OutputStyle $style, OutputInterface $output) + { + $this->io = $style; + $this->output = $output; + } + + /** + * {@inheritdoc} + */ + public function get_input($name, $default, $multibyte = false) + { + $result = $default; + + if (isset($this->input_values[$name])) + { + $result = $this->input_values[$name]; + } + + + if ($multibyte) + { + return utf8_normalize_nfc($result); + } + + return $result; + } + + public function set_input($name, $value) + { + $this->input_values[$name] = $value; + } + + /** + * {@inheritdoc} + */ + public function get_server_variable($name, $default = '') + { + return $default; + } + + /** + * {@inheritdoc} + */ + public function get_header_variable($name, $default = '') + { + return $default; + } + + /** + * {@inheritdoc} + */ + public function is_secure() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function add_user_form_group($title, $form) + { + throw new installer_exception('MISSING_DATA'); + } + + /** + * {@inheritdoc} + */ + public function send_response() + { + } + + /** + * {@inheritdoc + */ + public function add_error_message($error_title, $error_description = false) + { + $this->io->newLine(); + + $message = $this->translate_message($error_title, $error_description); + $this->io->error($message['title'] . "\n" . $message['description']); + + if ($this->progress_bar !== null) + { + $this->io->newLine(2); + $this->progress_bar->display(); + } + } + + /** + * {@inheritdoc + */ + public function add_warning_message($warning_title, $warning_description = false) + { + $this->io->newLine(); + + $message = $this->translate_message($warning_title, $warning_description); + $this->io->warning($message['title'] . "\n" . $message['description']); + + if ($this->progress_bar !== null) + { + $this->io->newLine(2); + $this->progress_bar->display(); + } + } + + /** + * {@inheritdoc + */ + public function add_log_message($log_title, $log_description = false) + { + if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) + { + $this->output->writeln(sprintf('[%3d/%-3d] ---- %s', $this->current_task_progress, $this->task_progress_count, $this->translate_message($log_title, $log_description)['title'])); + } + } + + /** + * {@inheritdoc + */ + public function add_success_message($error_title, $error_description = false) + { + $this->io->newLine(); + + $message = $this->translate_message($error_title, $error_description); + $this->io->success($message['title'] . "\n" . $message['description']); + + if ($this->progress_bar !== null) + { + $this->io->newLine(2); + $this->progress_bar->display(); + } + } + + public function set_task_count($task_count) + { + parent::set_task_count($task_count); + + if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) + { + $this->progress_bar = $this->io->createProgressBar($task_count); + $this->progress_bar->setFormat( + " %current:3s%/%max:-3s% %bar% %percent:3s%%\n" . + " %message%\n"); + $this->progress_bar->setBarWidth(60); + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->progress_bar->setEmptyBarCharacter('â–‘'); // light shade character \u2591 + $this->progress_bar->setProgressCharacter(''); + $this->progress_bar->setBarCharacter('â–“'); // dark shade character \u2593 + } + $this->progress_bar->setMessage(''); + $this->io->newLine(2); + $this->progress_bar->start(); + } + } + + public function set_progress($task_lang_key, $task_number) + { + parent::set_progress($task_lang_key, $task_number); + + if ($this->progress_bar !== null) + { + $this->progress_bar->setProgress($this->current_task_progress); + $this->progress_bar->setMessage($this->current_task_name); + } + else + { + $this->output->writeln(sprintf('[%3d/%-3d] %s', $this->current_task_progress, $this->task_progress_count, $this->current_task_name)); + } + } + + /** + * {@inheritdoc} + */ + public function finish_progress($message_lang_key) + { + parent::finish_progress($message_lang_key); + + if ($this->progress_bar !== null) + { + $this->progress_bar->finish(); + $this->progress_bar = null; + } + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php index 0af75b78ae..7081af06a5 100644 --- a/phpBB/phpbb/install/helper/iohandler/factory.php +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -59,7 +59,7 @@ class factory */ public function get() { - switch ($this->environment) + if ($this->container->has('installer.helper.iohandler_' . $this->environment)) { case 'ajax': return $this->container->get('installer.helper.iohandler_ajax'); @@ -68,9 +68,14 @@ class factory // @todo replace this return $this->container->get('installer.helper.iohandler_ajax'); break; + case 'cli': + return $this->container->get('installer.helper.iohandler_cli'); + break; default: throw new iohandler_not_implemented_exception(); break; } + + throw new iohandler_not_implemented_exception(); } } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index f767ecf4e9..006411f1e3 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -43,6 +43,13 @@ abstract class iohandler_base implements iohandler_interface */ protected $logs; + /** + * Array of success messages + * + * @var array + */ + protected $success; + /** * @var \phpbb\language\language */ @@ -71,6 +78,7 @@ abstract class iohandler_base implements iohandler_interface $this->errors = array(); $this->warnings = array(); $this->logs = array(); + $this->success = array(); $this->task_progress_count = 0; $this->current_task_progress = 0; @@ -111,6 +119,14 @@ abstract class iohandler_base implements iohandler_interface $this->logs[] = $this->translate_message($log_title, $log_description); } + /** + * {@inheritdoc} + */ + public function add_success_message($success_title, $success_description = false) + { + $this->success[] = $this->translate_message($success_title, $success_description); + } + /** * {@inheritdoc} */ @@ -124,11 +140,27 @@ abstract class iohandler_base implements iohandler_interface */ public function set_progress($task_lang_key, $task_number) { + $this->current_task_name = ''; + if (!empty($task_lang_key)) { $this->current_task_name = $this->language->lang($task_lang_key); - $this->current_task_progress = $task_number; } + + $this->current_task_progress = $task_number; + } + + /** + * {@inheritdoc} + */ + public function finish_progress($message_lang_key) + { + if (!empty($message_lang_key)) + { + $this->current_task_name = $this->language->lang($message_lang_key); + } + + $this->current_task_progress = $this->task_progress_count; } /** diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index c40fea24ce..44b409bb0a 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -85,7 +85,7 @@ interface iohandler_interface * * @param string|array $warning_title Title of the warning message * @param string|bool|array $warning_description Description of the warning (and possibly guidelines to resolve it), - * or false if the error description is not available + * or false if the warning description is not available */ public function add_warning_message($warning_title, $warning_description = false); @@ -96,11 +96,25 @@ interface iohandler_interface * resolved as printf($param[0], $param[1], ...). * * @param string|array $log_title Title of the log message - * @param string|bool|array $log_description Description of the log (and possibly guidelines to resolve it), - * or false if the error description is not available + * @param string|bool|array $log_description Description of the log, + * or false if the log description is not available */ public function add_log_message($log_title, $log_description = false); + /** + * Adds a success message to the rendering queue + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param string|array $success_title Title of the success message + * @param string|bool|array $success_description Description of the success, + * or false if the success description is not available + * + * @return null + */ + public function add_success_message($success_title, $success_description = false); + /** * Adds a requested data group to the rendering queue * @@ -142,4 +156,11 @@ interface iohandler_interface * @param array $menu_path Array to the navigation elem */ public function set_finished_stage_menu($menu_path); + + /** + * Finish the progress bar + * + * @param string $message_lang_key Language key for the message + */ + public function finish_progress($message_lang_key); } diff --git a/phpBB/phpbb/install/installer_configuration.php b/phpBB/phpbb/install/installer_configuration.php new file mode 100644 index 0000000000..ab02da8686 --- /dev/null +++ b/phpBB/phpbb/install/installer_configuration.php @@ -0,0 +1,140 @@ + +* @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; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +class installer_configuration implements ConfigurationInterface +{ + + /** + * Generates the configuration tree builder. + * + * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('installer'); + $rootNode + ->children() + ->arrayNode('admin') + ->children() + ->scalarNode('name')->defaultValue('admin')->cannotBeEmpty()->end() + ->scalarNode('password')->defaultValue('adminadmin')->cannotBeEmpty()->end() + ->scalarNode('email')->defaultValue('admin@example.org')->cannotBeEmpty()->end() + ->end() + ->end() + ->arrayNode('board') + ->children() + ->scalarNode('lang') + ->defaultValue('en') + ->cannotBeEmpty() + ->end() + ->scalarNode('name') + ->defaultValue('My Board') + ->cannotBeEmpty() + ->end() + ->scalarNode('description') + ->defaultValue('My amazing new phpBB board') + ->cannotBeEmpty() + ->end() + ->end() + ->end() + ->arrayNode('database') + ->children() + ->scalarNode('dbms') + ->defaultValue('sqlite3') + ->cannotBeEmpty() + ->isRequired() + ->end() + ->scalarNode('dbhost') + ->defaultValue(null) + ->end() + ->scalarNode('dbport') + ->defaultValue(null) + ->end() + ->scalarNode('dbuser') + ->defaultValue(null) + ->end() + ->scalarNode('dbpasswd') + ->defaultValue(null) + ->end() + ->scalarNode('dbname') + ->defaultValue(null) + ->end() + ->scalarNode('table_prefix') + ->defaultValue('phpbb_') + ->cannotBeEmpty() + ->isRequired() + ->end() + ->end() + ->end() + ->arrayNode('email') + ->canBeEnabled() + ->addDefaultsIfNotSet() + ->children() + ->booleanNode('smtp_delivery') + ->defaultValue(false) + ->treatNullLike(false) + ->end() + ->scalarNode('smtp_host') + ->defaultValue(null) + ->end() + ->scalarNode('smtp_auth') + ->defaultValue(null) + ->end() + ->scalarNode('smtp_user') + ->defaultValue(null) + ->end() + ->scalarNode('smtp_pass') + ->defaultValue(null) + ->end() + ->end() + ->end() + ->arrayNode('server') + ->children() + ->booleanNode('cookie_secure') + ->defaultValue(false) + ->treatNullLike(false) + ->end() + ->scalarNode('server_protocol') + ->defaultValue('http://') + ->cannotBeEmpty() + ->end() + ->booleanNode('force_server_vars') + ->defaultValue(false) + ->treatNullLike(false) + ->end() + ->scalarNode('server_name') + ->defaultValue('localhost') + ->cannotBeEmpty() + ->end() + ->integerNode('server_port') + ->defaultValue(80) + ->min(1) + ->cannotBeEmpty() + ->end() + ->scalarNode('script_path') + ->defaultValue('/') + ->cannotBeEmpty() + ->end() + ->end() + ->end() + ->end() + ; + return $treeBuilder; + } +} 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 index 0c1146d9f5..f0e7f1f686 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php @@ -238,7 +238,7 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in $connect_test = $this->database_helper->check_database_connection($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix); if (is_array($connect_test)) { - foreach ($prefix_valid as $error) + foreach ($connect_test as $error) { $this->io_handler->add_error_message( $error['title'], diff --git a/phpBB/phpbb/install/module/requirements/module.php b/phpBB/phpbb/install/module/requirements/module.php index d87ca15128..208cb5aad6 100644 --- a/phpBB/phpbb/install/module/requirements/module.php +++ b/phpBB/phpbb/install/module/requirements/module.php @@ -14,6 +14,7 @@ namespace phpbb\install\module\requirements; use phpbb\install\exception\user_interaction_required_exception; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; class module extends \phpbb\install\module_base { -- cgit v1.2.1 From 249345d9cc6d6bff380436d6e05f24918d762c0d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 27 Jun 2015 17:10:42 +0200 Subject: [ticket/13740] Clean up CLI merge [ci skip] PHPBB3-13740 --- .../install/helper/iohandler/cli_iohandler.php | 21 +++++++++++++++++++++ phpBB/phpbb/install/helper/iohandler/factory.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index d990f48925..f711abe431 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -232,4 +232,25 @@ class cli_iohandler extends iohandler_base $this->progress_bar = null; } } + + /** + * {@inheritdoc} + */ + public function request_refresh() + { + } + + /** + * {@inheritdoc} + */ + public function set_active_stage_menu($menu_path) + { + } + + /** + * {@inheritdoc} + */ + public function set_finished_stage_menu($menu_path) + { + } } diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php index 7081af06a5..52d24e49b2 100644 --- a/phpBB/phpbb/install/helper/iohandler/factory.php +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -59,7 +59,7 @@ class factory */ public function get() { - if ($this->container->has('installer.helper.iohandler_' . $this->environment)) + switch ($this->environment) { case 'ajax': return $this->container->get('installer.helper.iohandler_ajax'); -- cgit v1.2.1 From 8bfd29e86dac675919d3572aac3ba5891d9d844e Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 30 Jun 2015 18:54:46 +0200 Subject: [ticket/13740] Clean up CLI CS PHPBB3-13740 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index f711abe431..f9c19f6d85 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -14,7 +14,6 @@ namespace phpbb\install\helper\iohandler; use phpbb\install\exception\installer_exception; -use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\OutputStyle; @@ -39,7 +38,7 @@ class cli_iohandler extends iohandler_base protected $input_values = array(); /** - * @var ProgressBar + * @var \Symfony\Component\Console\Helper\ProgressBar */ protected $progress_bar; @@ -66,7 +65,6 @@ class cli_iohandler extends iohandler_base $result = $this->input_values[$name]; } - if ($multibyte) { return utf8_normalize_nfc($result); @@ -160,7 +158,8 @@ class cli_iohandler extends iohandler_base { if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { - $this->output->writeln(sprintf('[%3d/%-3d] ---- %s', $this->current_task_progress, $this->task_progress_count, $this->translate_message($log_title, $log_description)['title'])); + $message = $this->translate_message($log_title, $log_description); + $this->output->writeln(sprintf('[%3d/%-3d] ---- %s', $this->current_task_progress, $this->task_progress_count, $message['title'])); } } @@ -193,11 +192,13 @@ class cli_iohandler extends iohandler_base " %message%\n"); $this->progress_bar->setBarWidth(60); - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + if (!defined('PHP_WINDOWS_VERSION_BUILD')) + { $this->progress_bar->setEmptyBarCharacter('â–‘'); // light shade character \u2591 $this->progress_bar->setProgressCharacter(''); $this->progress_bar->setBarCharacter('â–“'); // dark shade character \u2593 } + $this->progress_bar->setMessage(''); $this->io->newLine(2); $this->progress_bar->start(); -- cgit v1.2.1 From 5ad0af3d3df698f7c749fee1f65962e0ba3cf663 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 7 Jul 2015 19:16:58 +0200 Subject: [ticket/13740] Fixes and Tests for database helper PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 38823c1231..d8751582f7 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -43,7 +43,8 @@ class database */ public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path) { - $this->filesystem = $filesystem; + $this->filesystem = $filesystem; + $this->phpbb_root_path = $phpbb_root_path; // DBMS supported by phpBB $this->supported_dbms = array( -- cgit v1.2.1 From 62103cec300ddadb904862ee2a74d68f71eb32ca Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 9 Jul 2015 15:26:48 +0200 Subject: [ticket/13740] Use service collection instead of array of task names PHPBB3-13740 --- .../exception/module_not_found_exception.php | 42 ------ .../exception/resource_limit_reached_exception.php | 19 +++ .../install/exception/task_not_found_exception.php | 42 ------ phpBB/phpbb/install/helper/config.php | 10 +- phpBB/phpbb/install/installer.php | 146 ++++++++------------- phpBB/phpbb/install/module_base.php | 84 ++++++------ 6 files changed, 115 insertions(+), 228 deletions(-) delete mode 100644 phpBB/phpbb/install/exception/module_not_found_exception.php create mode 100644 phpBB/phpbb/install/exception/resource_limit_reached_exception.php delete mode 100644 phpBB/phpbb/install/exception/task_not_found_exception.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/exception/module_not_found_exception.php b/phpBB/phpbb/install/exception/module_not_found_exception.php deleted file mode 100644 index 9fa03fad6e..0000000000 --- a/phpBB/phpbb/install/exception/module_not_found_exception.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @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\exception; - -class module_not_found_exception extends installer_exception -{ - /** - * @var string - */ - private $module_service_name; - - /** - * Constructor - * - * @param string $module_service_name The name of the missing installer module - */ - public function __construct($module_service_name) - { - $this->module_service_name = $module_service_name; - } - - /** - * Returns the missing installer module's service name - * - * @return string - */ - public function get_module_service_name() - { - return $this->module_service_name; - } -} diff --git a/phpBB/phpbb/install/exception/resource_limit_reached_exception.php b/phpBB/phpbb/install/exception/resource_limit_reached_exception.php new file mode 100644 index 0000000000..0b841747e6 --- /dev/null +++ b/phpBB/phpbb/install/exception/resource_limit_reached_exception.php @@ -0,0 +1,19 @@ + + * @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\exception; + +class resource_limit_reached_exception extends installer_exception +{ + +} diff --git a/phpBB/phpbb/install/exception/task_not_found_exception.php b/phpBB/phpbb/install/exception/task_not_found_exception.php deleted file mode 100644 index 11486cc6b0..0000000000 --- a/phpBB/phpbb/install/exception/task_not_found_exception.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @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\exception; - -class task_not_found_exception extends installer_exception -{ - /** - * @var string - */ - private $task_service_name; - - /** - * Constructor - * - * @param string $task_service_name The name of the missing installer module - */ - public function __construct($task_service_name) - { - $this->task_service_name = $task_service_name; - } - - /** - * Returns the missing installer task's service name - * - * @return string - */ - public function get_task_service_name() - { - return $this->task_service_name; - } -} diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index cf51432332..38fdf960f7 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -87,9 +87,7 @@ class config $this->installer_config = array(); $this->system_data = array(); $this->progress_data = array( - 'last_task_module_index' => 0, 'last_task_module_name' => '', // Stores the service name of the latest finished module - 'last_task_index' => 0, 'last_task_name' => '', // Stores the service name of the latest finished task 'max_task_progress' => 0, 'current_task_progress' => 0, @@ -180,24 +178,20 @@ class config * Saves the latest executed task * * @param string $task_service_name Name of the installer task service - * @param int $task_index Index of the task in the task list array */ - public function set_finished_task($task_service_name, $task_index) + public function set_finished_task($task_service_name) { $this->progress_data['last_task_name'] = $task_service_name; - $this->progress_data['last_task_index'] = $task_index; } /** * Set active module * * @param string $module_service_name Name of the installer module service - * @param int $module_index Index of the module in the module list array */ - public function set_active_module($module_service_name, $module_index) + public function set_active_module($module_service_name) { $this->progress_data['last_task_module_name'] = $module_service_name; - $this->progress_data['last_task_module_index'] = $module_index; } /** diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index d64713e6a3..3e73d90453 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -13,10 +13,10 @@ namespace phpbb\install; +use phpbb\di\ordered_service_collection; use phpbb\install\exception\installer_config_not_writable_exception; use phpbb\install\exception\invalid_service_name_exception; -use phpbb\install\exception\module_not_found_exception; -use phpbb\install\exception\task_not_found_exception; +use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; @@ -62,7 +62,7 @@ class installer { $this->install_config = $config; $this->container = $container; - $this->installer_modules = array(); + $this->installer_modules = null; } /** @@ -71,12 +71,10 @@ class installer * Note: The installer will run modules in the order they are set in * the array. * - * @param array $modules Array of module service names + * @param ordered_service_collection $modules Service collection of module service names */ - public function set_modules($modules) + public function set_modules(ordered_service_collection $modules) { - $modules = (array) $modules; - $this->installer_modules = $modules; } @@ -99,7 +97,8 @@ class installer $this->install_config->load_config(); // Recover install progress - $module_index = $this->recover_progress(); + $module_name = $this->recover_progress(); + $module_found = false; // Variable used to check if the install process have been finished $install_finished = false; @@ -111,64 +110,53 @@ class installer $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction')); $this->iohandler->set_finished_stage_menu(array('install', 0, 'introduction')); + if ($this->install_config->get_task_progress_count() === 0) + { + // Count all tasks in the current installer modules + $step_count = 0; + + /** @var \phpbb\install\module_interface $module */ + foreach ($this->installer_modules as $name => $module) + { + $module_step_count = $module->get_step_count(); + $step_count += $module_step_count; + $this->module_step_count[$name] = $module_step_count; + } + + // Set task count + $this->install_config->set_task_progress_count($step_count); + } + + // Set up progress information + $this->iohandler->set_task_count( + $this->install_config->get_task_progress_count() + ); + try { - if ($this->install_config->get_task_progress_count() === 0) + foreach ($this->installer_modules as $name => $module) { - // Count all tasks in the current installer modules - $step_count = 0; - foreach ($this->installer_modules as $index => $name) + // Skip forward until the current task is reached + if (!empty($task_name) && !$module_found) { - try + if ($module_name === $name) { - /** @var \phpbb\install\module_interface $module */ - $module = $this->container->get($name); + $module_found = true; } - catch (InvalidArgumentException $e) + else { - throw new module_not_found_exception($name); + continue; } - - $module_step_count = $module->get_step_count(); - $step_count += $module_step_count; - $this->module_step_count[$index] = $module_step_count; - } - - // Set task count - $this->install_config->set_task_progress_count($step_count); - } - - // Set up progress information - $this->iohandler->set_task_count( - $this->install_config->get_task_progress_count() - ); - - // Run until there are available resources - while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0) - { - // Check if module exists, if not the install is completed - if (!isset($this->installer_modules[$module_index])) - { - $install_finished = true; - break; } // Log progress - $module_service_name = $this->installer_modules[$module_index]; - $this->install_config->set_active_module($module_service_name, $module_index); + $this->install_config->set_active_module($name); - // Get module from container - try + // Run until there are available resources + if ($this->install_config->get_time_remaining() <= 0 && $this->install_config->get_memory_remaining() <= 0) { - /** @var \phpbb\install\module_interface $module */ - $module = $this->container->get($module_service_name); + throw new resource_limit_reached_exception(); } - catch (InvalidArgumentException $e) - { - throw new module_not_found_exception($module_service_name); - } - - $module_index++; // Check if module should be executed if (!$module->is_essential() && !$module->check_requirements()) @@ -178,9 +166,9 @@ class installer $this->iohandler->add_log_message(array( 'SKIP_MODULE', - $module_service_name, + $name, )); - $this->install_config->increment_current_task_progress($this->module_step_count[$module_index - 1]); + $this->install_config->increment_current_task_progress($this->module_step_count[$name]); continue; } @@ -192,40 +180,18 @@ class installer $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path()); $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path()); - - // Clear task progress - $this->install_config->set_finished_task('', 0); } - if ($install_finished) - { - // Send install finished message - $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count()); - } - else - { - $this->iohandler->request_refresh(); - } + // Installation finished + $install_finished = true; } catch (user_interaction_required_exception $e) { // Do nothing } - catch (module_not_found_exception $e) + catch (resource_limit_reached_exception $e) { - $this->iohandler->add_error_message('MODULE_NOT_FOUND', array( - 'MODULE_NOT_FOUND_DESCRIPTION', - $e->get_module_service_name(), - )); - $flush_messages = true; - } - catch (task_not_found_exception $e) - { - $this->iohandler->add_error_message('TASK_NOT_FOUND', array( - 'TASK_NOT_FOUND_DESCRIPTION', - $e->get_task_service_name(), - )); - $flush_messages = true; + // Do nothing } catch (invalid_service_name_exception $e) { @@ -244,6 +210,16 @@ class installer $flush_messages = true; } + if ($install_finished) + { + // Send install finished message + $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count()); + } + else + { + $this->iohandler->request_refresh(); + } + if ($flush_messages) { $this->iohandler->send_response(); @@ -274,14 +250,6 @@ class installer protected function recover_progress() { $progress_array = $this->install_config->get_progress_data(); - $module_service = $progress_array['last_task_module_name']; - $module_index = $progress_array['last_task_module_index']; - - if ($this->installer_modules[$module_index] === $module_service) - { - return $module_index; - } - - return 0; + return $progress_array['last_task_module_name']; } } diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index 6c0c0e0c30..6099eb35f8 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -13,12 +13,13 @@ namespace phpbb\install; +use phpbb\di\ordered_service_collection; use phpbb\install\exception\invalid_service_name_exception; -use phpbb\install\exception\task_not_found_exception; +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use phpbb\install\helper\config; /** * Base class for installer module @@ -48,7 +49,7 @@ abstract class module_base implements module_interface /** * Array of tasks for installer module * - * @var array + * @var ordered_service_collection */ protected $task_collection; @@ -60,11 +61,11 @@ abstract class module_base implements module_interface /** * Installer module constructor * - * @param array $tasks array of installer tasks for installer module - * @param bool $essential flag indicating whether the module is essential or not - * @param bool $allow_progress_bar flag indicating whether or not to send progress information from within the module + * @param ordered_service_collection $tasks array of installer tasks for installer module + * @param bool $essential flag indicating whether the module is essential or not + * @param bool $allow_progress_bar flag indicating whether or not to send progress information from within the module */ - public function __construct(array $tasks, $essential = true, $allow_progress_bar = true) + public function __construct(ordered_service_collection $tasks, $essential = true, $allow_progress_bar = true) { $this->task_collection = $tasks; $this->is_essential = $essential; @@ -109,26 +110,30 @@ abstract class module_base implements module_interface public function run() { // Recover install progress - $task_index = $this->recover_progress(); - - // Run until there are available resources - while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0) + $task_name = $this->recover_progress(); + $name_found = false; + + /** + * @var string $name ID of the service + * @var \phpbb\install\task_interface $task Task object + */ + foreach ($this->task_collection as $name => $task) { - // Check if task exists - if (!isset($this->task_collection[$task_index])) + // Run until there are available resources + if ($this->install_config->get_time_remaining() <= 0 && $this->install_config->get_memory_remaining() <= 0) { - break; + throw new resource_limit_reached_exception(); } - // Recover task to be executed - try - { - /** @var \phpbb\install\task_interface $task */ - $task = $this->container->get($this->task_collection[$task_index]); - } - catch (InvalidArgumentException $e) + // Skip forward until the next task is reached + if (!empty($task_name) && !$name_found) { - throw new task_not_found_exception($this->task_collection[$task_index]); + if ($name === $task_name) + { + $name_found = true; + } + + continue; } // Send progress information @@ -140,17 +145,15 @@ abstract class module_base implements module_interface ); } - // Iterate to the next task - $task_index++; - // Check if we can run the task if (!$task->is_essential() && !$task->check_requirements()) { $this->iohandler->add_log_message(array( 'SKIP_TASK', - $this->task_collection[$task_index], + $name, )); - $class_name = $this->get_class_from_service_name($this->task_collection[$task_index - 1]); + + $class_name = $this->get_class_from_service_name($name); $this->install_config->increment_current_task_progress($class_name::get_step_count()); continue; } @@ -174,9 +177,11 @@ abstract class module_base implements module_interface $this->iohandler->send_response(); // Log install progress - $current_task_index = $task_index - 1; - $this->install_config->set_finished_task($this->task_collection[$current_task_index], $current_task_index); + $this->install_config->set_finished_task($name); } + + // Module finished, so clear task progress + $this->install_config->set_finished_task(''); } /** @@ -187,24 +192,7 @@ abstract class module_base implements module_interface protected function recover_progress() { $progress_array = $this->install_config->get_progress_data(); - $last_finished_task_name = $progress_array['last_task_name']; - $last_finished_task_index = $progress_array['last_task_index']; - - // Check if the data is relevant to this module - if (isset($this->task_collection[$last_finished_task_index])) - { - if ($this->task_collection[$last_finished_task_index] === $last_finished_task_name) - { - // Return the task index of the next task - return $last_finished_task_index + 1; - } - } - - // As of now if the progress has not been resolved we assume that it is because - // the task progress belongs to the previous module, - // so just default to the first task - // @todo make module aware of it's service name that way this can be improved - return 0; + return $progress_array['last_task_name']; } /** @@ -214,11 +202,13 @@ abstract class module_base implements module_interface { $step_count = 0; + /** @todo: Fix this foreach ($this->task_collection as $task_service_name) { $class_name = $this->get_class_from_service_name($task_service_name); $step_count += $class_name::get_step_count(); } + */ return $step_count; } -- cgit v1.2.1 From e967f3c1a81eab0f14daf314b7fb1b2001e4d220 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 9 Jul 2015 19:08:28 +0200 Subject: [ticket/13740] Fix itteration problems, implement class name aware collections PHPBB3-13740 --- phpBB/phpbb/install/installer.php | 6 +- phpBB/phpbb/install/module/requirements/module.php | 55 +++++++++------ phpBB/phpbb/install/module_base.php | 79 +++++++++------------- phpBB/phpbb/install/task_interface.php | 4 -- 4 files changed, 69 insertions(+), 75 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 3e73d90453..c1ac2de7f9 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -137,9 +137,9 @@ class installer foreach ($this->installer_modules as $name => $module) { // Skip forward until the current task is reached - if (!empty($task_name) && !$module_found) + if (!$module_found) { - if ($module_name === $name) + if ($module_name === $name || empty($module_name)) { $module_found = true; } @@ -245,7 +245,7 @@ class installer /** * Recover install progress * - * @return int Index of the next installer module to execute + * @return string Index of the next installer module to execute */ protected function recover_progress() { diff --git a/phpBB/phpbb/install/module/requirements/module.php b/phpBB/phpbb/install/module/requirements/module.php index 208cb5aad6..794a35bef5 100644 --- a/phpBB/phpbb/install/module/requirements/module.php +++ b/phpBB/phpbb/install/module/requirements/module.php @@ -13,6 +13,7 @@ namespace phpbb\install\module\requirements; +use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; @@ -23,30 +24,38 @@ class module extends \phpbb\install\module_base $tests_passed = true; // Recover install progress - $task_index = 0; + $task_name = $this->recover_progress(); + $task_found = false; - // Run until there are available resources - while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0) + /** + * @var string $name ID of the service + * @var \phpbb\install\task_interface $task Task object + */ + foreach ($this->task_collection as $name => $task) { - // Check if task exists - if (!isset($this->task_collection[$task_index])) + // Run until there are available resources + if ($this->install_config->get_time_remaining() <= 0 && $this->install_config->get_memory_remaining() <= 0) { - break; + throw new resource_limit_reached_exception(); } - // Recover task to be executed - try + // Skip forward until the next task is reached + if (!$task_found) { - /** @var \phpbb\install\task_interface $task */ - $task = $this->container->get($this->task_collection[$task_index]); - } - catch (InvalidArgumentException $e) - { - throw new task_not_found_exception($this->task_collection[$task_index]); - } + if ($name === $task_name || empty($task_name)) + { + $task_found = true; - // Iterate to the next task - $task_index++; + if ($name === $task_name) + { + continue; + } + } + else + { + continue; + } + } // Check if we can run the task if (!$task->is_essential() && !$task->check_requirements()) @@ -54,10 +63,18 @@ class module extends \phpbb\install\module_base continue; } + if ($this->allow_progress_bar) + { + $this->install_config->increment_current_task_progress(); + } + $test_result = $task->run(); $tests_passed = ($tests_passed) ? $test_result : false; } + // Module finished, so clear task progress + $this->install_config->set_finished_task(''); + // Check if tests have failed if (!$tests_passed) { @@ -74,10 +91,6 @@ class module extends \phpbb\install\module_base $this->iohandler->send_response(); throw new user_interaction_required_exception(); } - - // Log install progress - $current_task_index = $task_index - 1; - $this->install_config->set_finished_task($this->task_collection[$current_task_index], $current_task_index); } /** diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index 6099eb35f8..e0cb862be9 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -14,7 +14,6 @@ namespace phpbb\install; use phpbb\di\ordered_service_collection; -use phpbb\install\exception\invalid_service_name_exception; use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; @@ -53,6 +52,11 @@ abstract class module_base implements module_interface */ protected $task_collection; + /** + * @var array + */ + protected $task_step_count; + /** * @var bool */ @@ -111,7 +115,7 @@ abstract class module_base implements module_interface { // Recover install progress $task_name = $this->recover_progress(); - $name_found = false; + $task_found = false; /** * @var string $name ID of the service @@ -126,14 +130,21 @@ abstract class module_base implements module_interface } // Skip forward until the next task is reached - if (!empty($task_name) && !$name_found) + if (!$task_found) { - if ($name === $task_name) + if ($name === $task_name || empty($task_name)) { - $name_found = true; - } + $task_found = true; - continue; + if ($name === $task_name) + { + continue; + } + } + else + { + continue; + } } // Send progress information @@ -153,18 +164,22 @@ abstract class module_base implements module_interface $name, )); - $class_name = $this->get_class_from_service_name($name); - $this->install_config->increment_current_task_progress($class_name::get_step_count()); + $this->install_config->increment_current_task_progress($this->task_step_count[$name]); continue; } if ($this->allow_progress_bar) { + // Only increment progress by one, as if a task has more than one steps + // then that should be incremented in the task itself $this->install_config->increment_current_task_progress(); } $task->run(); + // Log install progress + $this->install_config->set_finished_task($name); + // Send progress information if ($this->allow_progress_bar) { @@ -175,9 +190,6 @@ abstract class module_base implements module_interface } $this->iohandler->send_response(); - - // Log install progress - $this->install_config->set_finished_task($name); } // Module finished, so clear task progress @@ -187,7 +199,7 @@ abstract class module_base implements module_interface /** * Returns the next task's index * - * @return int index of the array element of the next task + * @return string index of the array element of the next task */ protected function recover_progress() { @@ -200,43 +212,16 @@ abstract class module_base implements module_interface */ public function get_step_count() { - $step_count = 0; - - /** @todo: Fix this - foreach ($this->task_collection as $task_service_name) - { - $class_name = $this->get_class_from_service_name($task_service_name); - $step_count += $class_name::get_step_count(); - } - */ - - return $step_count; - } - - /** - * Returns the name of the class form the service name - * - * @param string $task_service_name Name of the service - * - * @return string Name of the class - * - * @throws invalid_service_name_exception When the service name does not meet the requirements described in task_interface - */ - protected function get_class_from_service_name($task_service_name) - { - $task_service_name_parts = explode('.', $task_service_name); - - if ($task_service_name_parts[0] !== 'installer') - { - throw new invalid_service_name_exception('TASK_SERVICE_INSTALLER_MISSING'); - } + $task_step_count = 0; + $task_class_names = $this->task_collection->get_service_classes(); - $class_name = '\\phpbb\\install\\module\\' . $task_service_name_parts[1] . '\\task\\' . $task_service_name_parts[2]; - if (!class_exists($class_name)) + foreach ($task_class_names as $name => $task_class) { - throw new invalid_service_name_exception('TASK_CLASS_NOT_FOUND', array($task_service_name, $class_name)); + $step_count = $task_class::get_step_count(); + $task_step_count += $step_count; + $this->task_step_count[$name] = $step_count; } - return $class_name; + return $task_step_count; } } diff --git a/phpBB/phpbb/install/task_interface.php b/phpBB/phpbb/install/task_interface.php index 14cde23a56..794cb16482 100644 --- a/phpBB/phpbb/install/task_interface.php +++ b/phpBB/phpbb/install/task_interface.php @@ -15,10 +15,6 @@ namespace phpbb\install; /** * Interface for installer tasks - * - * Note: The task service ID must match up with the namespace and class name. - * For example: if your task is located at \phpbb\install\module\module_name\task\task_name - * then the service ID must be installer.module_name.task_name. */ interface task_interface { -- cgit v1.2.1 From 3309c89b05a46a03d09ffef693ed309699a3f59b Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 9 Jul 2015 19:32:30 +0200 Subject: [ticket/13740] Fix CS PHPBB3-13740 --- phpBB/phpbb/install/installer.php | 1 - phpBB/phpbb/install/module/requirements/module.php | 1 - phpBB/phpbb/install/module_base.php | 1 - 3 files changed, 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index c1ac2de7f9..33b9214cfa 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -21,7 +21,6 @@ use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; class installer { diff --git a/phpBB/phpbb/install/module/requirements/module.php b/phpBB/phpbb/install/module/requirements/module.php index 794a35bef5..79a031bad9 100644 --- a/phpBB/phpbb/install/module/requirements/module.php +++ b/phpBB/phpbb/install/module/requirements/module.php @@ -15,7 +15,6 @@ namespace phpbb\install\module\requirements; use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; class module extends \phpbb\install\module_base { diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index e0cb862be9..eb04379f8e 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -18,7 +18,6 @@ use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; /** * Base class for installer module -- cgit v1.2.1 From 4d2212a3c2c8528e6d2adde6c57090bf8e26ba7d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 9 Jul 2015 21:52:36 +0200 Subject: [ticket/13740] Fix database version comparison PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index d8751582f7..27cb2dc828 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -395,7 +395,7 @@ class database switch ($dbms) { case 'mysqli': - if (version_compare($db->sql_server_info(), '4.1.3', '<')) + if (version_compare($db->sql_server_info(true), '4.1.3', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_MYSQLI', @@ -403,7 +403,7 @@ class database } break; case 'sqlite': - if (version_compare($db->sql_server_info(), '2.8.2', '<')) + if (version_compare($db->sql_server_info(true), '2.8.2', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_SQLITE', @@ -411,7 +411,7 @@ class database } break; case 'sqlite3': - if (version_compare($db->sql_server_info(), '3.6.15', '<')) + if (version_compare($db->sql_server_info(true), '3.6.15', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_SQLITE3', -- cgit v1.2.1 From e46689a0cdbb418673741234f55e843f1bdd8016 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 9 Jul 2015 23:23:40 +0200 Subject: [ticket/13740] Remove service container from modules PHPBB3-13740 --- phpBB/phpbb/install/installer.php | 4 +--- phpBB/phpbb/install/module_base.php | 9 +++------ 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 33b9214cfa..f69b48ce3b 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -55,12 +55,10 @@ class installer * Constructor * * @param config $config Installer config handler - * @param ContainerInterface $container Dependency injection container */ - public function __construct(config $config, ContainerInterface $container) + public function __construct(config $config) { $this->install_config = $config; - $this->container = $container; $this->installer_modules = null; } diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index eb04379f8e..60eaa79139 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -17,7 +17,6 @@ use phpbb\di\ordered_service_collection; use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Base class for installer module @@ -78,13 +77,11 @@ abstract class module_base implements module_interface /** * Dependency getter * - * @param ContainerInterface $container * @param config $config * @param iohandler_interface $iohandler */ - public function setup(ContainerInterface $container, config $config, iohandler_interface $iohandler) + public function setup(config $config, iohandler_interface $iohandler) { - $this->container = $container; $this->install_config = $config; $this->iohandler = $iohandler; } @@ -196,9 +193,9 @@ abstract class module_base implements module_interface } /** - * Returns the next task's index + * Returns the next task's name * - * @return string index of the array element of the next task + * @return string Index of the array element of the next task */ protected function recover_progress() { -- cgit v1.2.1 From 59d22eff497ea1107851067aa99eed4c979c0766 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 10 Jul 2015 00:47:28 +0200 Subject: [ticket/13740] Fix CS PHPBB3-13740 --- phpBB/phpbb/install/installer.php | 6 ------ phpBB/phpbb/install/module_base.php | 5 ----- 2 files changed, 11 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index f69b48ce3b..548615cb1d 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -20,15 +20,9 @@ use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; -use Symfony\Component\DependencyInjection\ContainerInterface; class installer { - /** - * @var ContainerInterface - */ - protected $container; - /** * @var config */ diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index 60eaa79139..a933d4987c 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -23,11 +23,6 @@ use phpbb\install\helper\iohandler\iohandler_interface; */ abstract class module_base implements module_interface { - /** - * @var ContainerInterface - */ - protected $container; - /** * @var config */ -- cgit v1.2.1 From c5c98b7ca2dfb85925bc3ec1d6057ec554f9b4f9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 14 Jul 2015 23:14:35 +0200 Subject: [ticket/13740] Implement navigation sorting PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 35 +++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 8445d80a41..5ef98ac2bb 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -158,8 +158,7 @@ class helper { // Get navigation items $nav_array = $this->navigation_provider->get(); - - // @todo Sort navs by order + $nav_array = $this->sort_navigation_level($nav_array); $active_main_menu = $this->get_active_main_menu($nav_array); @@ -174,7 +173,7 @@ class helper if (is_array($entry[0]) && $active_main_menu === $key) { - // @todo Sort navs by order + $entry[0] = $this->sort_navigation_level($entry[0]); foreach ($entry[0] as $name => $sub_entry) { @@ -220,6 +219,7 @@ class helper protected function render_language_select() { $langs = $this->lang_helper->get_available_languages(); + // @todo } /** @@ -246,7 +246,7 @@ class helper { foreach ($nav_options[0] as $sub_menus) { - if (isset($sub_menus['route']) &&$sub_menus['route'] === $active_route) + if (isset($sub_menus['route']) && $sub_menus['route'] === $active_route) { return $current_menu; } @@ -256,4 +256,31 @@ class helper return false; } + + /** + * Sorts the top level of navigation array + * + * @param array $nav_array Navigation array + * + * @return array + */ + protected function sort_navigation_level($nav_array) + { + $sorted = array(); + foreach ($nav_array as $nav) + { + $order = (isset($nav['order'])) ? $nav['order'] : 0; + $sorted[$order][] = $nav; + } + + // Linearization of navigation array + $nav_array = array(); + ksort($sorted); + foreach ($sorted as $nav) + { + $nav_array = array_merge($nav_array, $nav); + } + + return $nav_array; + } } -- cgit v1.2.1 From 88bf1d7f5802fc37bf77277a8ee65c6fb1f34c87 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 20 Jul 2015 18:22:53 +0200 Subject: [ticket/13740] Clean up install config file when installation has finished PHPBB3-13740 --- phpBB/phpbb/install/helper/config.php | 23 +++++++++++++++++++++++ phpBB/phpbb/install/installer.php | 9 ++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index 38fdf960f7..457b64b301 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -73,6 +73,13 @@ class config */ protected $navigation_data; + /** + * Flag indicating that config file should be cleaned up + * + * @var bool + */ + protected $do_clean_up; + /** * Constructor */ @@ -81,6 +88,7 @@ class config $this->filesystem = $filesystem; $this->php_ini = $php_ini; $this->phpbb_root_path = $phpbb_root_path; + $this->do_clean_up = false; // Set up data arrays $this->navigation_data = array(); @@ -228,6 +236,12 @@ class config */ public function save_config() { + if ($this->do_clean_up) + { + @unlink($this->install_config_file); + return; + } + // Create array to save $save_array = array( 'installer_config' => $this->installer_config, @@ -336,6 +350,15 @@ class config return $this->navigation_data; } + /** + * Removes install config file + */ + public function clean_up_config_file() + { + $this->do_clean_up = true; + @unlink($this->install_config_file); + } + /** * Filling up system_data array */ diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 548615cb1d..695632472a 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -219,7 +219,14 @@ class installer // Save install progress try { - $this->install_config->save_config(); + if ($install_finished) + { + $this->install_config->clean_up_config_file(); + } + else + { + $this->install_config->save_config(); + } } catch (installer_config_not_writable_exception $e) { -- cgit v1.2.1 From 6216007caaa884bdbca8bbb5e098ff231b5a36a6 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 20 Jul 2015 18:47:10 +0200 Subject: [ticket/13740] Fix docblocks and comments PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 1 + phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 3 ++- phpBB/phpbb/install/module/install_finish/task/notify_user.php | 2 +- phpBB/phpbb/install/module/requirements/task/check_filesystem.php | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index c1329b6456..c742906305 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -77,6 +77,7 @@ class install * @param factory $factory * @param navigation_provider $nav_provider * @param language $language + * @param template $template * @param request_interface $request * @param installer $installer */ diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index f9c19f6d85..bf68f363c3 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -45,7 +45,8 @@ class cli_iohandler extends iohandler_base /** * Set the style and output used to display feedback; * - * @param OutputStyle $style + * @param OutputStyle $style + * @param OutputInterface $output */ public function set_style(OutputStyle $style, OutputInterface $output) { diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php index 4ab6ec56c6..baffaf2228 100644 --- a/phpBB/phpbb/install/module/install_finish/task/notify_user.php +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -85,7 +85,7 @@ class notify_user extends \phpbb\install\task_base */ public function run() { - // @todo + // @todo Login user after installation has been finished //$this->user->setup('common'); //$this->user->session_begin(); diff --git a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php index 5b944b8415..ab6b1091e2 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php +++ b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php @@ -47,7 +47,7 @@ class check_filesystem extends \phpbb\install\task_base * Constructor * * @param \phpbb\filesystem\filesystem_interface $filesystem filesystem handler - * @parma \phpbb\install\helper\iohandler\iohandler_interface $response response helper + * @param \phpbb\install\helper\iohandler\iohandler_interface $response response helper * @param string $phpbb_root_path relative path to phpBB's root * @param string $php_ext extension of php files */ -- cgit v1.2.1 From 0488c49116f77de55da3ddf36aa2b08f6a5fd085 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 20 Jul 2015 19:26:07 +0200 Subject: [ticket/13740] Exit from installation if phpBB is already installed PHPBB3-13740 --- .../install/console/command/install/install.php | 24 ++++++--- phpBB/phpbb/install/controller/helper.php | 2 +- phpBB/phpbb/install/controller/install.php | 18 +++++-- phpBB/phpbb/install/helper/install_helper.php | 60 ++++++++++++++++++++++ 4 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 phpBB/phpbb/install/helper/install_helper.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index d3f6d363f8..e9b4192ded 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -14,6 +14,7 @@ namespace phpbb\install\console\command\install; use phpbb\install\exception\installer_exception; +use phpbb\install\helper\install_helper; use phpbb\install\helper\iohandler\cli_iohandler; use phpbb\install\helper\iohandler\factory; use phpbb\install\installer; @@ -40,6 +41,11 @@ class install extends \phpbb\console\command\command */ protected $installer; + /** + * @var install_helper + */ + protected $install_helper; + /** * @var language */ @@ -48,21 +54,22 @@ class install extends \phpbb\console\command\command /** * Constructor * - * @param language $language - * @param factory $factory - * @param installer $installer + * @param language $language + * @param factory $factory + * @param installer $installer + * @param install_helper $install_helper */ - public function __construct(language $language, factory $factory, installer $installer) + public function __construct(language $language, factory $factory, installer $installer, install_helper $install_helper) { $this->iohandler_factory = $factory; $this->installer = $installer; $this->language = $language; + $this->install_helper = $install_helper; parent::__construct(new \phpbb\user($language, 'datetime')); } /** - * * {@inheritdoc} */ protected function configure() @@ -89,8 +96,6 @@ class install extends \phpbb\console\command\command */ protected function execute(InputInterface $input, OutputInterface $output) { - // @todo check that phpBB is not already installed - $this->iohandler_factory->set_environment('cli'); /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ @@ -102,6 +107,11 @@ class install extends \phpbb\console\command\command $config_file = $input->getArgument('config-file'); + if ($this->install_helper->is_phpbb_installed()) + { + $iohandler->add_error_message('PHPBB_ALREADY_INSTALLED'); + } + if (!is_file($config_file)) { $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 5ef98ac2bb..a16298c525 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -219,7 +219,7 @@ class helper protected function render_language_select() { $langs = $this->lang_helper->get_available_languages(); - // @todo + // @todo Implement language change option } /** diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index c742906305..5cd42fcb84 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -13,7 +13,9 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\config; +use phpbb\install\helper\install_helper; use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\Response; @@ -69,6 +71,11 @@ class install */ protected $installer; + /** + * @var install_helper + */ + protected $install_helper; + /** * Constructor * @@ -80,8 +87,9 @@ class install * @param template $template * @param request_interface $request * @param installer $installer + * @param install_helper $install_helper */ - public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer) + public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper) { $this->controller_helper = $helper; $this->installer_config = $install_config; @@ -91,6 +99,7 @@ class install $this->template = $template; $this->request = $request; $this->installer = $installer; + $this->install_helper = $install_helper; } /** @@ -100,8 +109,6 @@ class install */ public function handle() { - // @todo check that phpBB is not already installed - $this->template->assign_vars(array( 'U_ACTION' => $this->controller_helper->route('phpbb_installer_install'), )); @@ -124,6 +131,11 @@ class install /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ $iohandler = $this->iohandler_factory->get(); + if ($this->install_helper->is_phpbb_installed()) + { + throw new http_exception(404, 'PAGE_NOT_FOUND'); + } + // Set active navigation stage if (isset($nav_data['active']) && is_array($nav_data['active'])) { diff --git a/phpBB/phpbb/install/helper/install_helper.php b/phpBB/phpbb/install/helper/install_helper.php new file mode 100644 index 0000000000..c1506de5bf --- /dev/null +++ b/phpBB/phpbb/install/helper/install_helper.php @@ -0,0 +1,60 @@ + + * @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\helper; + +/** + * General helper functionality for the installer + */ +class install_helper +{ + /** + * @var string + */ + protected $php_ext; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param string $phpbb_root_path path to phpBB's root + * @param string $php_ext Extension of PHP files + */ + public function __construct($phpbb_root_path, $php_ext) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * Check whether phpBB is installed. + * + * @return bool + */ + public function is_phpbb_installed() + { + $config_path = $this->phpbb_root_path . 'config' . $this->php_ext; + $install_lock_path = $this->phpbb_root_path . 'cache/install_lock'; + + if (file_exists($config_path) && !file_exists($install_lock_path)) + { + include_once $config_path; + } + + return defined('PHPBB_INSTALLED'); + } +} -- cgit v1.2.1 From b2b9fb1df2e6d37c8a327b7b6c380f19e1ff6496 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 14:42:15 +0200 Subject: [ticket/13740] Fix CS and docblocks PHPBB3-13740 --- .../install/console/command/install/install.php | 10 +++++---- phpBB/phpbb/install/controller/install.php | 10 ++++----- .../exception/cannot_build_container_exception.php | 2 +- .../installer_config_not_writable_exception.php | 2 +- .../install/exception/invalid_dbms_exception.php | 2 +- .../exception/invalid_service_name_exception.php | 19 ---------------- .../exception/resource_limit_reached_exception.php | 3 +++ phpBB/phpbb/install/helper/container_factory.php | 17 +++++++++++++++ .../install/helper/iohandler/ajax_iohandler.php | 8 ++----- phpBB/phpbb/install/installer.php | 25 ---------------------- 10 files changed, 36 insertions(+), 62 deletions(-) delete mode 100644 phpBB/phpbb/install/exception/invalid_service_name_exception.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index e9b4192ded..81ad1039f6 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -110,13 +110,15 @@ class install extends \phpbb\console\command\command if ($this->install_helper->is_phpbb_installed()) { $iohandler->add_error_message('PHPBB_ALREADY_INSTALLED'); + + return 1; } if (!is_file($config_file)) { $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); - return; + return 1; } try @@ -127,7 +129,7 @@ class install extends \phpbb\console\command\command { $iohandler->add_error_message('INVALID_YAML_FILE'); - return; + return 1; } $processor = new Processor(); @@ -141,7 +143,7 @@ class install extends \phpbb\console\command\command { $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); - return; + return 1; } $this->register_configuration($iohandler, $config); @@ -153,7 +155,7 @@ class install extends \phpbb\console\command\command catch (installer_exception $e) { $iohandler->add_error_message($e->getMessage()); - return; + return 1; } } diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 5cd42fcb84..b3103c8284 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -109,6 +109,11 @@ class install */ public function handle() { + if ($this->install_helper->is_phpbb_installed()) + { + throw new http_exception(404, 'PAGE_NOT_FOUND'); + } + $this->template->assign_vars(array( 'U_ACTION' => $this->controller_helper->route('phpbb_installer_install'), )); @@ -131,11 +136,6 @@ class install /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ $iohandler = $this->iohandler_factory->get(); - if ($this->install_helper->is_phpbb_installed()) - { - throw new http_exception(404, 'PAGE_NOT_FOUND'); - } - // Set active navigation stage if (isset($nav_data['active']) && is_array($nav_data['active'])) { diff --git a/phpBB/phpbb/install/exception/cannot_build_container_exception.php b/phpBB/phpbb/install/exception/cannot_build_container_exception.php index 11be507bc9..6cf12b008b 100644 --- a/phpBB/phpbb/install/exception/cannot_build_container_exception.php +++ b/phpBB/phpbb/install/exception/cannot_build_container_exception.php @@ -14,7 +14,7 @@ namespace phpbb\install\exception; /** - * This exception should be thrown when + * Thrown when the container cannot be built */ class cannot_build_container_exception extends installer_exception { diff --git a/phpBB/phpbb/install/exception/installer_config_not_writable_exception.php b/phpBB/phpbb/install/exception/installer_config_not_writable_exception.php index 3f3b03f178..51864c5dca 100644 --- a/phpBB/phpbb/install/exception/installer_config_not_writable_exception.php +++ b/phpBB/phpbb/install/exception/installer_config_not_writable_exception.php @@ -14,7 +14,7 @@ namespace phpbb\install\exception; /** - * Exception for the event when installer config is not writable to disk + * Thrown when installer config is not writable to disk */ class installer_config_not_writable_exception extends installer_exception { diff --git a/phpBB/phpbb/install/exception/invalid_dbms_exception.php b/phpBB/phpbb/install/exception/invalid_dbms_exception.php index ccb35bc237..38de5f613a 100644 --- a/phpBB/phpbb/install/exception/invalid_dbms_exception.php +++ b/phpBB/phpbb/install/exception/invalid_dbms_exception.php @@ -14,7 +14,7 @@ namespace phpbb\install\exception; /** - * This exception should be thrown when + * Thrown when an unavailable DBMS has been selected */ class invalid_dbms_exception extends installer_exception { diff --git a/phpBB/phpbb/install/exception/invalid_service_name_exception.php b/phpBB/phpbb/install/exception/invalid_service_name_exception.php deleted file mode 100644 index dff4873f3c..0000000000 --- a/phpBB/phpbb/install/exception/invalid_service_name_exception.php +++ /dev/null @@ -1,19 +0,0 @@ - - * @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\exception; - -class invalid_service_name_exception extends installer_exception -{ - -} diff --git a/phpBB/phpbb/install/exception/resource_limit_reached_exception.php b/phpBB/phpbb/install/exception/resource_limit_reached_exception.php index 0b841747e6..025e09fbd3 100644 --- a/phpBB/phpbb/install/exception/resource_limit_reached_exception.php +++ b/phpBB/phpbb/install/exception/resource_limit_reached_exception.php @@ -13,6 +13,9 @@ namespace phpbb\install\exception; +/** + * Thrown when the installer is out of memory or time + */ class resource_limit_reached_exception extends installer_exception { diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index 255f8f428e..eb44b470b7 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -93,9 +93,26 @@ class container_factory * @param string $param_name * * @return mixed + * + * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built */ public function get_parameter($param_name) { + // Check if container was built, if not try to build it + if ($this->container === null) + { + // Check whether container can be built + // We need config.php for that so let's check if it has been set up yet + if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) + { + $this->build_container(); + } + else + { + throw new cannot_build_container_exception(); + } + } + return $this->container->getParameter($param_name); } diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 85cb2ca753..ce1112c7a1 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -96,10 +96,6 @@ class ajax_iohandler extends iohandler_base */ public function add_user_form_group($title, $form) { - // - // This code is pretty ugly... but works - // - $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); $this->template->assign_block_vars('options', array( @@ -166,8 +162,8 @@ class ajax_iohandler extends iohandler_base $json_data = json_encode($json_data_array); // Try to push content to the browser - print (str_pad(' ', 4096) . "\n"); - print ($json_data . "\n\n"); + print(str_pad(' ', 4096) . "\n"); + print($json_data . "\n\n"); flush(); } diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 695632472a..0e19129247 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -15,7 +15,6 @@ namespace phpbb\install; use phpbb\di\ordered_service_collection; use phpbb\install\exception\installer_config_not_writable_exception; -use phpbb\install\exception\invalid_service_name_exception; use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; @@ -94,9 +93,6 @@ class installer // Variable used to check if the install process have been finished $install_finished = false; - // Flag used by exception handling, whether or not we need to flush output buffer once again - $flush_messages = false; - // We are installing something, so the introduction stage can go now... $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction')); $this->iohandler->set_finished_stage_menu(array('install', 0, 'introduction')); @@ -184,22 +180,6 @@ class installer { // Do nothing } - catch (invalid_service_name_exception $e) - { - $params = $e->get_parameters(); - - if (!empty($params)) - { - array_unshift($params, $e->getMessage()); - } - else - { - $params = $e->getMessage(); - } - - $this->iohandler->add_error_message($params); - $flush_messages = true; - } if ($install_finished) { @@ -211,11 +191,6 @@ class installer $this->iohandler->request_refresh(); } - if ($flush_messages) - { - $this->iohandler->send_response(); - } - // Save install progress try { -- cgit v1.2.1 From 3a3dd941452eca6f487bb8ab2d21c99f89846f24 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 15:06:15 +0200 Subject: [ticket/13740] Remove default config CLI command PHPBB3-13740 --- .../command/install/config/default_config.php | 103 --------------------- 1 file changed, 103 deletions(-) delete mode 100644 phpBB/phpbb/install/console/command/install/config/default_config.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/config/default_config.php b/phpBB/phpbb/install/console/command/install/config/default_config.php deleted file mode 100644 index 75c9f94901..0000000000 --- a/phpBB/phpbb/install/console/command/install/config/default_config.php +++ /dev/null @@ -1,103 +0,0 @@ - -* @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\console\command\install\config; - -use phpbb\language\language; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Yaml\Yaml; - -class default_config extends \phpbb\console\command\command -{ - /** - * @var language - */ - protected $language; - - /** - * Constructor - * - * @param language $language - */ - public function __construct(language $language) - { - $this->language = $language; - - parent::__construct(new \phpbb\user($language, 'datetime')); - } - - /** - * - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('install:config:default') - ; - } - - /** - * Display the default configuration - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - * - * @return null - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $default_config = <<writeln($default_config); - } -} -- cgit v1.2.1 From 3d4f21c1f87f88c6cf6efd6e3844672d7784f09f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 15:13:54 +0200 Subject: [ticket/13740] Check navigation requirements PHPBB3-13740 --- .../helper/navigation/install_navigation.php | 25 ++++++++++++++++++++++ .../install/helper/navigation/main_navigation.php | 3 +++ 2 files changed, 28 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/navigation/install_navigation.php b/phpBB/phpbb/install/helper/navigation/install_navigation.php index 1389f11fa0..f690f8de76 100644 --- a/phpBB/phpbb/install/helper/navigation/install_navigation.php +++ b/phpBB/phpbb/install/helper/navigation/install_navigation.php @@ -13,10 +13,35 @@ namespace phpbb\install\helper\navigation; +use phpbb\install\helper\install_helper; + class install_navigation implements navigation_interface { + /** + * @var install_helper + */ + private $install_helper; + + /** + * Constructor + * + * @param install_helper $install_helper + */ + public function __construct(install_helper $install_helper) + { + $this->install_helper = $install_helper; + } + + /** + * {@inheritdoc} + */ public function get() { + if ($this->install_helper->is_phpbb_installed()) + { + return array(); + } + return array( 'install' => array( 'label' => 'INSTALL', diff --git a/phpBB/phpbb/install/helper/navigation/main_navigation.php b/phpBB/phpbb/install/helper/navigation/main_navigation.php index ad67840424..214bb04963 100644 --- a/phpBB/phpbb/install/helper/navigation/main_navigation.php +++ b/phpBB/phpbb/install/helper/navigation/main_navigation.php @@ -15,6 +15,9 @@ namespace phpbb\install\helper\navigation; class main_navigation implements navigation_interface { + /** + * {@inheritdoc} + */ public function get() { return array( -- cgit v1.2.1 From 136ec8d7e25efe7b466cb41f80dc5a75a51eaa68 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 15:53:26 +0200 Subject: [ticket/13740] Keep keys when sorting navigation PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index a16298c525..569938be09 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -267,10 +267,10 @@ class helper protected function sort_navigation_level($nav_array) { $sorted = array(); - foreach ($nav_array as $nav) + foreach ($nav_array as $key => $nav) { $order = (isset($nav['order'])) ? $nav['order'] : 0; - $sorted[$order][] = $nav; + $sorted[$order][$key] = $nav; } // Linearization of navigation array -- cgit v1.2.1 From 97d08d6f56cf448fd4def8a4d29c570da91faa89 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 22 Jul 2015 03:16:16 +0200 Subject: [ticket/13740] Allow language change in the installer PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 165 +++++++++++++++------ phpBB/phpbb/install/controller/install.php | 2 +- phpBB/phpbb/install/controller/installer_index.php | 2 +- 3 files changed, 121 insertions(+), 48 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 569938be09..5fd0abf9c7 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -17,10 +17,13 @@ use phpbb\install\helper\navigation\navigation_provider; use phpbb\language\language; use phpbb\language\language_file_helper; use phpbb\path_helper; +use phpbb\request\request; +use phpbb\request\request_interface; use phpbb\routing\router; use phpbb\symfony_request; use phpbb\template\template; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Cookie; /** * A duplicate of \phpbb\controller\helper @@ -35,6 +38,11 @@ class helper */ protected $language; + /** + * @var bool|string + */ + protected $language_cookie; + /** * @var \phpbb\language\language_file_helper */ @@ -55,6 +63,11 @@ class helper */ protected $path_helper; + /** + * @var \phpbb\request\request + */ + protected $phpbb_request; + /** * @var \phpbb\symfony_request */ @@ -83,49 +96,117 @@ class helper * @param navigation_provider $nav * @param template $template * @param path_helper $path_helper + * @param request $phpbb_request * @param symfony_request $request * @param router $router * @param string $phpbb_root_path */ - public function __construct(language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, symfony_request $request, router $router, $phpbb_root_path) + public function __construct(language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path) { $this->language = $language; + $this->language_cookie = false; $this->lang_helper = $lang_helper; $this->navigation_provider = $nav; $this->template = $template; $this->path_helper = $path_helper; + $this->phpbb_request = $phpbb_request; $this->request = $request; $this->router = $router; $this->phpbb_root_path = $phpbb_root_path; $this->phpbb_admin_path = $phpbb_root_path . 'adm/'; + + $this->handle_language_select(); } /** * Automate setting up the page and creating the response object. * - * @param string $template_file The template handle to render - * @param string $page_title The title of the page to output - * @param int $status_code The status code to be sent to the page header + * @param string $template_file The template handle to render + * @param string $page_title The title of the page to output + * @param bool $selected_language True to enable language selector it, false otherwise + * @param int $status_code The status code to be sent to the page header * * @return Response object containing rendered page */ - public function render($template_file, $page_title = '', $status_code = 200) + public function render($template_file, $page_title = '', $selected_language = false, $status_code = 200) { - $this->page_header($page_title); + $this->page_header($page_title, $selected_language); $this->template->set_filenames(array( 'body' => $template_file, )); - return new Response($this->template->assign_display('body'), $status_code); + $response = new Response($this->template->assign_display('body'), $status_code); + + // Set language cookie + if ($this->language_cookie !== false) + { + $cookie = new Cookie('lang', $this->language_cookie, time() + 3600); + $response->headers->setCookie($cookie); + + $this->language_cookie = false; + } + + return $response; + } + + /** + * Returns path from route name + * + * @param string $route_name + * + * @return string + */ + public function route($route_name) + { + $url = $this->router->generate($route_name); + + return $url; + } + + /** + * Handles language selector form + */ + protected function handle_language_select() + { + $lang = null; + + // Check if language form has been submited + $submit = $this->phpbb_request->variable('change_lang', ''); + if (!empty($submit)) + { + $lang = $this->phpbb_request->variable('language', ''); + + if (!empty($lang)) + { + $this->language_cookie = $lang; + } + } + + // Retrive language from cookie + $lang_cookie = $this->phpbb_request->variable('lang', '', false, request_interface::COOKIE); + if (empty($lang) && !empty($lang_cookie)) + { + $lang = $lang_cookie; + $this->language_cookie = $lang; + } + + $lang = (!empty($lang)) ? $lang : null; + $this->render_language_select($lang); + + if ($lang !== null) + { + $this->language->set_user_language($lang, true); + } } /** * Set default template variables * - * @param string $page_title + * @param string $page_title Title of the page + * @param bool $selected_language True to enable language selector it, false otherwise */ - protected function page_header($page_title) + protected function page_header($page_title, $selected_language = false) { $this->template->assign_vars(array( 'L_CHANGE' => $this->language->lang('CHANGE'), @@ -143,6 +224,7 @@ class helper 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right', 'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', + 'S_LANG_SELECT' => $selected_language, 'S_USER_LANG' => $this->language->lang('USER_LANG'), ) @@ -151,6 +233,8 @@ class helper $this->render_navigation(); } + + /** * Render navigation */ @@ -163,35 +247,29 @@ class helper $active_main_menu = $this->get_active_main_menu($nav_array); // Pass navigation to template - foreach ($nav_array as $key => $entry) - { + foreach ($nav_array as $key => $entry) { $this->template->assign_block_vars('t_block1', array( - 'L_TITLE' => $this->language->lang($entry['label']), - 'S_SELECTED' => ($active_main_menu === $key), - 'U_TITLE' => $this->route($entry['route']), + 'L_TITLE' => $this->language->lang($entry['label']), + 'S_SELECTED' => ($active_main_menu === $key), + 'U_TITLE' => $this->route($entry['route']), )); - if (is_array($entry[0]) && $active_main_menu === $key) - { + if (is_array($entry[0]) && $active_main_menu === $key) { $entry[0] = $this->sort_navigation_level($entry[0]); - foreach ($entry[0] as $name => $sub_entry) - { - if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) - { + foreach ($entry[0] as $name => $sub_entry) { + if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) { $this->template->assign_block_vars('l_block2', array( - 'L_TITLE' => $this->language->lang($sub_entry['label']), - 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), - 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), - 'STAGE_NAME' => $name, + 'L_TITLE' => $this->language->lang($sub_entry['label']), + 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), + 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), + 'STAGE_NAME' => $name, )); - } - else - { + } else { $this->template->assign_block_vars('l_block1', array( - 'L_TITLE' => $this->language->lang($sub_entry['label']), - 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), - 'U_TITLE' => $this->route($sub_entry['route']), + 'L_TITLE' => $this->language->lang($sub_entry['label']), + 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), + 'U_TITLE' => $this->route($sub_entry['route']), )); } } @@ -199,27 +277,22 @@ class helper } } - /** - * Returns path from route name - * - * @param string $route_name - * - * @return string - */ - public function route($route_name) - { - $url = $this->router->generate($route_name); - - return $url; - } - /** * Render language select form + * + * @param string $selected_language */ - protected function render_language_select() + protected function render_language_select($selected_language = null) { $langs = $this->lang_helper->get_available_languages(); - // @todo Implement language change option + foreach ($langs as $lang) + { + $this->template->assign_block_vars('language_select_item', array( + 'VALUE' => $lang['iso'], + 'NAME' => $lang['local_name'], + 'SELECTED' => ($lang['iso'] === $selected_language), + )); + } } /** diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index b3103c8284..da806948fb 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -189,7 +189,7 @@ class install 'TITLE' => $this->language->lang('INSTALL_INTRO'), 'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY'), )); - return $this->controller_helper->render('installer_install.html', 'INSTALL'); + return $this->controller_helper->render('installer_install.html', 'INSTALL', true); } // @todo: implement no js controller logic diff --git a/phpBB/phpbb/install/controller/installer_index.php b/phpBB/phpbb/install/controller/installer_index.php index 3d5224f1be..0a1855f4e5 100644 --- a/phpBB/phpbb/install/controller/installer_index.php +++ b/phpBB/phpbb/install/controller/installer_index.php @@ -74,6 +74,6 @@ class installer_index 'BODY' => $body, )); - return $this->helper->render('install_main.html', $title); + return $this->helper->render('install_main.html', $title, true); } } -- cgit v1.2.1 From 0c49b88dde77894a91145314d2d3bf4388082075 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 22 Jul 2015 04:01:52 +0200 Subject: [ticket/13740] Fix CS PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 5fd0abf9c7..f3400e6ef0 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -233,8 +233,6 @@ class helper $this->render_navigation(); } - - /** * Render navigation */ @@ -247,25 +245,31 @@ class helper $active_main_menu = $this->get_active_main_menu($nav_array); // Pass navigation to template - foreach ($nav_array as $key => $entry) { + foreach ($nav_array as $key => $entry) + { $this->template->assign_block_vars('t_block1', array( 'L_TITLE' => $this->language->lang($entry['label']), 'S_SELECTED' => ($active_main_menu === $key), 'U_TITLE' => $this->route($entry['route']), )); - if (is_array($entry[0]) && $active_main_menu === $key) { + if (is_array($entry[0]) && $active_main_menu === $key) + { $entry[0] = $this->sort_navigation_level($entry[0]); - foreach ($entry[0] as $name => $sub_entry) { - if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) { + foreach ($entry[0] as $name => $sub_entry) + { + if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) + { $this->template->assign_block_vars('l_block2', array( 'L_TITLE' => $this->language->lang($sub_entry['label']), 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), 'STAGE_NAME' => $name, )); - } else { + } + else + { $this->template->assign_block_vars('l_block1', array( 'L_TITLE' => $this->language->lang($sub_entry['label']), 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), -- cgit v1.2.1 From 3356130ce2adf82248cf64fcaa81a47713ce7987 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 22 Jul 2015 12:43:17 +0200 Subject: [ticket/13740] Separate new installer style templates PHPBB3-13740 --- phpBB/phpbb/install/controller/installer_index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/installer_index.php b/phpBB/phpbb/install/controller/installer_index.php index 0a1855f4e5..8e1874984b 100644 --- a/phpBB/phpbb/install/controller/installer_index.php +++ b/phpBB/phpbb/install/controller/installer_index.php @@ -74,6 +74,6 @@ class installer_index 'BODY' => $body, )); - return $this->helper->render('install_main.html', $title, true); + return $this->helper->render('installer_main.html', $title, true); } } -- cgit v1.2.1 From 98d9d92aa7794316239fbda2a15a91618aef0879 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 04:27:31 +0200 Subject: [ticket/13740] Secure installer config against corrupted config data PHPBB3-13740 --- phpBB/phpbb/install/helper/config.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index 457b64b301..38376da82a 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -224,11 +224,19 @@ class config $file_content = @file_get_contents($this->install_config_file); $serialized_data = trim(substr($file_content, 8)); - $unserialized_data = unserialize($serialized_data); - $this->installer_config = $unserialized_data['installer_config']; - $this->progress_data = $unserialized_data['progress_data']; - $this->navigation_data = $unserialized_data['navigation_data']; + $this->installer_config = array(); + $this->progress_data = array(); + $this->navigation_data = array(); + + if (!empty($serialized_data)) + { + $unserialized_data = unserialize($serialized_data); + + $this->installer_config = (is_array($unserialized_data['installer_config'])) ? $unserialized_data['installer_config'] : array(); + $this->progress_data = (is_array($unserialized_data['progress_data'])) ? $unserialized_data['progress_data'] : array(); + $this->navigation_data = (is_array($unserialized_data['navigation_data'])) ? $unserialized_data['navigation_data'] : array(); + } } /** -- cgit v1.2.1 From dd31020fb3dd4ab96b48dd1854f73190900319b1 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 16:43:20 +0200 Subject: [ticket/13740] Enhance server output buffer bypass PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index da806948fb..469e2608a4 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -167,6 +167,9 @@ class install $installer->run(); }); + // Try to bypass any server output buffers + $response->headers->set('X-Accel-Buffering', 'no'); + return $response; } else -- cgit v1.2.1 From fbd5929606169d3f780f0a59760c171b20bd906d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 20:50:33 +0200 Subject: [ticket/13740] Login admin when install finished PHPBB3-13740 --- phpBB/phpbb/install/helper/container_factory.php | 5 +++ .../install/helper/iohandler/ajax_iohandler.php | 23 ++++++++++++ .../install/helper/iohandler/cli_iohandler.php | 7 ++++ .../helper/iohandler/iohandler_interface.php | 8 ++++ .../module/install_finish/task/notify_user.php | 43 ++++++++++++++++++---- 5 files changed, 78 insertions(+), 8 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index eb44b470b7..e09e43be34 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -13,6 +13,7 @@ namespace phpbb\install\helper; +use phpbb\cache\driver\dummy; use phpbb\install\exception\cannot_build_container_exception; class container_factory @@ -152,6 +153,10 @@ class container_factory // this container $this->container->register('request')->setSynthetic(true); $this->container->set('request', $this->request); + + // Replace cache service, as config gets cached, and we don't want that + $this->container->register('cache.driver')->setSynthetic(true); + $this->container->set('cache.driver', new dummy()); $this->container->compile(); // Restore super globals to previous state diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index ce1112c7a1..fa628f3365 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -43,6 +43,11 @@ class ajax_iohandler extends iohandler_base */ protected $nav_data; + /** + * @var array + */ + protected $cookies; + /** * Constructor * @@ -55,6 +60,7 @@ class ajax_iohandler extends iohandler_base $this->template = $template; $this->form = ''; $this->nav_data = array(); + $this->cookies = array(); parent::__construct(); } @@ -214,6 +220,12 @@ class ajax_iohandler extends iohandler_base $this->request_client_refresh = false; } + if (!empty($this->cookies)) + { + $json_array['cookies'] = $this->cookies; + $this->cookies = array(); + } + return $json_array; } @@ -252,6 +264,17 @@ class ajax_iohandler extends iohandler_base $this->send_response(); } + /** + * {@inheritdoc} + */ + public function set_cookie($cookie_name, $cookie_value) + { + $this->cookies[] = array( + 'name' => $cookie_name, + 'value' => $cookie_value + ); + } + /** * Callback function for language replacing * diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index bf68f363c3..c5b2bb06bc 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -255,4 +255,11 @@ class cli_iohandler extends iohandler_base public function set_finished_stage_menu($menu_path) { } + + /** + * {@inheritdoc} + */ + public function set_cookie($cookie_name, $cookie_value) + { + } } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index 44b409bb0a..5f5f8499d6 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -163,4 +163,12 @@ interface iohandler_interface * @param string $message_lang_key Language key for the message */ public function finish_progress($message_lang_key); + + /** + * Sends and sets cookies + * + * @param string $cookie_name Name of the cookie to set + * @param string $cookie_value Value of the cookie to set + */ + public function set_cookie($cookie_name, $cookie_value); } diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php index baffaf2228..a433d342d0 100644 --- a/phpBB/phpbb/install/module/install_finish/task/notify_user.php +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -12,6 +12,7 @@ */ namespace phpbb\install\module\install_finish\task; +use phpbb\config\db; /** * Logs installation and sends an email to the admin @@ -73,11 +74,17 @@ class notify_user extends \phpbb\install\task_base $this->iohandler = $iohandler; $this->auth = $container->get('auth'); - $this->config = $container->get('config'); $this->log = $container->get('log'); $this->user = $container->get('user'); $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + + // We need to reload config for cases when it doesn't have all values + $this->config = new db( + $container->get('dbal.conn'), + $container->get('cache.driver'), + $container->get_parameter('tables.config') + ); } /** @@ -85,11 +92,8 @@ class notify_user extends \phpbb\install\task_base */ public function run() { - // @todo Login user after installation has been finished - //$this->user->setup('common'); - - //$this->user->session_begin(); - //$this->auth->login($this->install_config->get('admin_name'), $this->install_config->get('admin_pass1'), false, true, true); + $this->user->session_begin(); + $this->user->setup('common'); if ($this->config['email_enable']) { @@ -106,8 +110,31 @@ class notify_user extends \phpbb\install\task_base $messenger->send(NOTIFY_EMAIL); } - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_INSTALL_INSTALLED', false, array($this->config['version'])); - + // Login admin + // Ugly but works + $this->auth->login( + $this->install_config->get('admin_name'), + $this->install_config->get('admin_passwd'), + false, + true, + true + ); + + $this->iohandler->set_cookie($this->config['cookie_name'] . '_sid', $this->user->session_id); + $this->iohandler->set_cookie($this->config['cookie_name'] . '_u', $this->user->cookie_data['u']); + $this->iohandler->set_cookie($this->config['cookie_name'] . '_k', $this->user->cookie_data['k']); + + // Create log + $this->log->add( + 'admin', + $this->user->data['user_id'], + $this->user->ip, + 'LOG_INSTALL_INSTALLED', + false, + array($this->config['version']) + ); + + // Remove install_lock @unlink($this->phpbb_root_path . 'cache/install_lock'); } -- cgit v1.2.1 From e08f1341127792e378580a10bbb0bdeafe93ff8d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 22:55:31 +0200 Subject: [ticket/13740] Fix is_phpbb_installed() method PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 2 +- phpBB/phpbb/install/helper/install_helper.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 469e2608a4..904f5920c2 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -111,7 +111,7 @@ class install { if ($this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'PAGE_NOT_FOUND'); + die ('phpBB is already installed'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/helper/install_helper.php b/phpBB/phpbb/install/helper/install_helper.php index c1506de5bf..ffe36cd645 100644 --- a/phpBB/phpbb/install/helper/install_helper.php +++ b/phpBB/phpbb/install/helper/install_helper.php @@ -47,14 +47,14 @@ class install_helper */ public function is_phpbb_installed() { - $config_path = $this->phpbb_root_path . 'config' . $this->php_ext; + $config_path = $this->phpbb_root_path . 'config.' . $this->php_ext; $install_lock_path = $this->phpbb_root_path . 'cache/install_lock'; - if (file_exists($config_path) && !file_exists($install_lock_path)) + if (file_exists($config_path) && !file_exists($install_lock_path) && filesize($config_path)) { - include_once $config_path; + return true; } - return defined('PHPBB_INSTALLED'); + return false; } } -- cgit v1.2.1 From 115029b6012d4adf11f773a31463c8f8daf9529e Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 23:23:06 +0200 Subject: [ticket/13740] Fix $script_path in obtain_data PHPBB3-13740 --- phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') 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 index 2d1e37b10e..654b5534a9 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php @@ -73,7 +73,7 @@ class obtain_server_data extends \phpbb\install\task_base implements \phpbb\inst } $script_path = str_replace(array('\\', '//'), '/', $script_path); - $script_path = trim(dirname(dirname($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); -- cgit v1.2.1 From 3840882b93e96f8f510d4086d650bb9df55873ca Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 23:35:20 +0200 Subject: [ticket/13740] Add success message when install finished PHPBB3-13740 --- phpBB/phpbb/install/installer.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 0e19129247..cb4ddb8783 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -18,6 +18,7 @@ use phpbb\install\exception\installer_config_not_writable_exception; use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; +use phpbb\install\helper\iohandler\cli_iohandler; use phpbb\install\helper\iohandler\iohandler_interface; class installer @@ -171,6 +172,34 @@ class installer // Installation finished $install_finished = true; + + if ($this->iohandler instanceof cli_iohandler) + { + $this->iohandler->add_success_message('INSTALLER_FINISHED'); + } + else + { + global $SID; + + // Construct ACP url + $acp_url = $protocol = $this->install_config->get('server_protocol'); + $acp_url .= $this->install_config->get('server_name'); + $port = $this->install_config->get('server_port'); + + if (!((strpos($protocol, 'https:') === 0 && $port === 443) + || (strpos($protocol, 'http:') === 0 && $port === 80))) + { + $acp_url .= ':' . $port; + } + + $acp_url .= $this->install_config->get('script_path'); + $acp_url .= '/adm/index.php' . $SID; + + $this->iohandler->add_success_message('INSTALLER_FINISHED', array( + 'ACP_LINK', + $acp_url, + )); + } } catch (user_interaction_required_exception $e) { -- cgit v1.2.1 From cb593c0e04fc9f3318443fe42b596d27498729c3 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 00:04:40 +0200 Subject: [ticket/13740] Filter basic directory change attempts in lang change PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index f3400e6ef0..8530a0defe 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -191,7 +191,8 @@ class helper $this->language_cookie = $lang; } - $lang = (!empty($lang)) ? $lang : null; + $lang = (!empty($lang) && strpos($lang, '/')) ? $lang : null; + $this->render_language_select($lang); if ($lang !== null) -- cgit v1.2.1 From 22786a5b6fcdab1610b609ae069065c5d6691496 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 02:37:00 +0200 Subject: [ticket/13740] Fix CS PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 1 - phpBB/phpbb/install/module/install_finish/task/notify_user.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 904f5920c2..c21b0d831b 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -13,7 +13,6 @@ namespace phpbb\install\controller; -use phpbb\exception\http_exception; use phpbb\install\helper\config; use phpbb\install\helper\install_helper; use phpbb\install\helper\navigation\navigation_provider; diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php index a433d342d0..0af76f6f60 100644 --- a/phpBB/phpbb/install/module/install_finish/task/notify_user.php +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -12,6 +12,7 @@ */ namespace phpbb\install\module\install_finish\task; + use phpbb\config\db; /** -- cgit v1.2.1 From 04186e8498c78d16f8eb5402c19d70e9e7795e83 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 25 Jul 2015 14:42:17 +0200 Subject: [ticket/13740] Fix comment PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 8530a0defe..6d591786c4 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -183,7 +183,7 @@ class helper } } - // Retrive language from cookie + // Retrieve language from cookie $lang_cookie = $this->phpbb_request->variable('lang', '', false, request_interface::COOKIE); if (empty($lang) && !empty($lang_cookie)) { -- cgit v1.2.1 From 723337d2f68940eff64586cc91151fad2c40ea6e Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 25 Jul 2015 14:42:37 +0200 Subject: [ticket/13740] Use JSON for installer config PHPBB3-13740 --- phpBB/phpbb/install/helper/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index 38376da82a..b0480e7e5b 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -231,7 +231,7 @@ class config if (!empty($serialized_data)) { - $unserialized_data = unserialize($serialized_data); + $unserialized_data = json_decode($serialized_data, true); $this->installer_config = (is_array($unserialized_data['installer_config'])) ? $unserialized_data['installer_config'] : array(); $this->progress_data = (is_array($unserialized_data['progress_data'])) ? $unserialized_data['progress_data'] : array(); @@ -259,7 +259,7 @@ class config // Create file content $file_content = ' Date: Sat, 25 Jul 2015 14:43:54 +0200 Subject: [ticket/13740] Deduplicate container builder's checks PHPBB3-13740 --- phpBB/phpbb/install/helper/container_factory.php | 35 ++++++++++-------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index e09e43be34..dab16b81fd 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -73,16 +73,7 @@ class container_factory // Check if container was built, if not try to build it if ($this->container === null) { - // Check whether container can be built - // We need config.php for that so let's check if it has been set up yet - if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) - { - $this->build_container(); - } - else - { - throw new cannot_build_container_exception(); - } + $this->build_container(); } return ($service_name === null) ? $this->container : $this->container->get($service_name); @@ -102,16 +93,7 @@ class container_factory // Check if container was built, if not try to build it if ($this->container === null) { - // Check whether container can be built - // We need config.php for that so let's check if it has been set up yet - if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) - { - $this->build_container(); - } - else - { - throw new cannot_build_container_exception(); - } + $this->build_container(); } return $this->container->getParameter($param_name); @@ -119,6 +101,8 @@ class container_factory /** * Build dependency injection container + * + * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built */ protected function build_container() { @@ -129,6 +113,17 @@ class container_factory return; } + // Check whether container can be built + // We need config.php for that so let's check if it has been set up yet + if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) + { + $this->build_container(); + } + else + { + throw new cannot_build_container_exception(); + } + $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); -- cgit v1.2.1 From 0befa9f10900238a2be2c3e50d85de3de9c5edec Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 25 Jul 2015 14:44:39 +0200 Subject: [ticket/13740] Move default data settings out of constructors PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 173 ++++++++++----------- .../install/module/install_data/task/add_bots.php | 169 ++++++++++---------- .../module/install_data/task/add_modules.php | 172 ++++++++++---------- 3 files changed, 251 insertions(+), 263 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 27cb2dc828..627e9ea9b0 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -33,7 +33,91 @@ class database /** * @var array */ - protected $supported_dbms; + protected $supported_dbms = array( + // Note: php 5.5 alpha 2 deprecated mysql. + // Keep mysqli before mysql in this list. + 'mysqli' => array( + 'LABEL' => 'MySQL with MySQLi Extension', + 'SCHEMA' => 'mysql_41', + 'MODULE' => 'mysqli', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\mysqli', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mysql' => array( + 'LABEL' => 'MySQL', + 'SCHEMA' => 'mysql', + 'MODULE' => 'mysql', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\mysql', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssql' => array( + 'LABEL' => 'MS SQL Server 2000+', + 'SCHEMA' => 'mssql', + 'MODULE' => 'mssql', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssql', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssql_odbc'=> array( + 'LABEL' => 'MS SQL Server [ ODBC ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'odbc', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssql_odbc', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssqlnative' => array( + 'LABEL' => 'MS SQL Server 2005+ [ Native ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'sqlsrv', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssqlnative', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'oracle' => array( + 'LABEL' => 'Oracle', + 'SCHEMA' => 'oracle', + 'MODULE' => 'oci8', + 'DELIM' => '/', + 'DRIVER' => 'phpbb\db\driver\oracle', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'postgres' => array( + 'LABEL' => 'PostgreSQL 8.3+', + 'SCHEMA' => 'postgres', + 'MODULE' => 'pgsql', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\postgres', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'sqlite' => array( + 'LABEL' => 'SQLite', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'sqlite3' => array( + 'LABEL' => 'SQLite3', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite3', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite3', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + ); /** * Constructor @@ -45,93 +129,6 @@ class database { $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; - - // DBMS supported by phpBB - $this->supported_dbms = array( - // Note: php 5.5 alpha 2 deprecated mysql. - // Keep mysqli before mysql in this list. - 'mysqli' => array( - 'LABEL' => 'MySQL with MySQLi Extension', - 'SCHEMA' => 'mysql_41', - 'MODULE' => 'mysqli', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysqli', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mysql' => array( - 'LABEL' => 'MySQL', - 'SCHEMA' => 'mysql', - 'MODULE' => 'mysql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssql' => array( - 'LABEL' => 'MS SQL Server 2000+', - 'SCHEMA' => 'mssql', - 'MODULE' => 'mssql', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssql_odbc'=> array( - 'LABEL' => 'MS SQL Server [ ODBC ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'odbc', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssql_odbc', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssqlnative' => array( - 'LABEL' => 'MS SQL Server 2005+ [ Native ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'sqlsrv', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssqlnative', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'oracle' => array( - 'LABEL' => 'Oracle', - 'SCHEMA' => 'oracle', - 'MODULE' => 'oci8', - 'DELIM' => '/', - 'DRIVER' => 'phpbb\db\driver\oracle', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'postgres' => array( - 'LABEL' => 'PostgreSQL 8.3+', - 'SCHEMA' => 'postgres', - 'MODULE' => 'pgsql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\postgres', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'sqlite' => array( - 'LABEL' => 'SQLite', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'sqlite3' => array( - 'LABEL' => 'SQLite3', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite3', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite3', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - ); } /** diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php index c31700e97f..b45d3808db 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_bots.php +++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php @@ -16,9 +16,91 @@ namespace phpbb\install\module\install_data\task; class add_bots extends \phpbb\install\task_base { /** + * A list of the web-crawlers/bots we recognise by default + * + * Candidates but not included: + * 'Accoona [Bot]' 'Accoona-AI-Agent/' + * 'ASPseek [Crawler]' 'ASPseek/' + * 'Boitho [Crawler]' 'boitho.com-dc/' + * 'Bunnybot [Bot]' 'powered by www.buncat.de' + * 'Cosmix [Bot]' 'cfetch/' + * 'Crawler Search [Crawler]' '.Crawler-Search.de' + * 'Findexa [Crawler]' 'Findexa Crawler (' + * 'GBSpider [Spider]' 'GBSpider v' + * 'genie [Bot]' 'genieBot (' + * 'Hogsearch [Bot]' 'oegp v. 1.3.0' + * 'Insuranco [Bot]' 'InsurancoBot' + * 'IRLbot [Bot]' 'http://irl.cs.tamu.edu/crawler' + * 'ISC Systems [Bot]' 'ISC Systems iRc Search' + * 'Jyxobot [Bot]' 'Jyxobot/' + * 'Kraehe [Metasuche]' '-DIE-KRAEHE- META-SEARCH-ENGINE/' + * 'LinkWalker' 'LinkWalker' + * 'MMSBot [Bot]' 'http://www.mmsweb.at/bot.html' + * 'Naver [Bot]' 'nhnbot@naver.com)' + * 'NetResearchServer' 'NetResearchServer/' + * 'Nimble [Crawler]' 'NimbleCrawler' + * 'Ocelli [Bot]' 'Ocelli/' + * 'Onsearch [Bot]' 'onCHECK-Robot' + * 'Orange [Spider]' 'OrangeSpider' + * 'Sproose [Bot]' 'http://www.sproose.com/bot' + * 'Susie [Sync]' '!Susie (http://www.sync2it.com/susie)' + * 'Tbot [Bot]' 'Tbot/' + * 'Thumbshots [Capture]' 'thumbshots-de-Bot' + * 'Vagabondo [Crawler]' 'http://webagent.wise-guys.nl/' + * 'Walhello [Bot]' 'appie 1.1 (www.walhello.com)' + * 'WissenOnline [Bot]' 'WissenOnline-Bot' + * 'WWWeasel [Bot]' 'WWWeasel Robot v' + * 'Xaldon [Spider]' 'Xaldon WebSpider' + * * @var array */ - protected $bot_list; + protected $bot_list = array( + 'AdsBot [Google]' => array('AdsBot-Google', ''), + 'Alexa [Bot]' => array('ia_archiver', ''), + 'Alta Vista [Bot]' => array('Scooter/', ''), + 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''), + 'Baidu [Spider]' => array('Baiduspider', ''), + 'Bing [Bot]' => array('bingbot/', ''), + 'Exabot [Bot]' => array('Exabot', ''), + 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''), + 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''), + 'Francis [Bot]' => array('http://www.neomo.de/', ''), + 'Gigabot [Bot]' => array('Gigabot/', ''), + 'Google Adsense [Bot]' => array('Mediapartners-Google', ''), + 'Google Desktop' => array('Google Desktop', ''), + 'Google Feedfetcher' => array('Feedfetcher-Google', ''), + 'Google [Bot]' => array('Googlebot', ''), + 'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''), + 'Heritrix [Crawler]' => array('heritrix/1.', ''), + 'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''), + 'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''), + 'ichiro [Crawler]' => array('ichiro/', ''), + 'Majestic-12 [Bot]' => array('MJ12bot/', ''), + 'Metager [Bot]' => array('MetagerBot/', ''), + 'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''), + 'MSN [Bot]' => array('msnbot/', ''), + 'MSNbot Media' => array('msnbot-media/', ''), + 'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''), + 'Online link [Validator]' => array('online link validator', ''), + 'psbot [Picsearch]' => array('psbot/0', ''), + 'Sensis [Crawler]' => array('Sensis Web Crawler', ''), + 'SEO Crawler' => array('SEO search Crawler/', ''), + 'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''), + 'SEOSearch [Crawler]' => array('SEOsearch/', ''), + 'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''), + 'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''), + 'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''), + 'TurnitinBot [Bot]' => array('TurnitinBot/', ''), + 'Voyager [Bot]' => array('voyager/', ''), + 'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''), + 'W3C [Linkcheck]' => array('W3C-checklink/', ''), + 'W3C [Validator]' => array('W3C_Validator', ''), + 'YaCy [Bot]' => array('yacybot', ''), + 'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''), + 'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''), + 'Yahoo [Bot]' => array('Yahoo! Slurp', ''), + 'YahooSeeker [Bot]' => array('YahooSeeker/', ''), + ); /** * @var \phpbb\db\driver\driver_interface @@ -75,91 +157,6 @@ class add_bots extends \phpbb\install\task_base $this->language = $language; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; - - /** - * A list of the web-crawlers/bots we recognise by default - * - * Candidates but not included: - * 'Accoona [Bot]' 'Accoona-AI-Agent/' - * 'ASPseek [Crawler]' 'ASPseek/' - * 'Boitho [Crawler]' 'boitho.com-dc/' - * 'Bunnybot [Bot]' 'powered by www.buncat.de' - * 'Cosmix [Bot]' 'cfetch/' - * 'Crawler Search [Crawler]' '.Crawler-Search.de' - * 'Findexa [Crawler]' 'Findexa Crawler (' - * 'GBSpider [Spider]' 'GBSpider v' - * 'genie [Bot]' 'genieBot (' - * 'Hogsearch [Bot]' 'oegp v. 1.3.0' - * 'Insuranco [Bot]' 'InsurancoBot' - * 'IRLbot [Bot]' 'http://irl.cs.tamu.edu/crawler' - * 'ISC Systems [Bot]' 'ISC Systems iRc Search' - * 'Jyxobot [Bot]' 'Jyxobot/' - * 'Kraehe [Metasuche]' '-DIE-KRAEHE- META-SEARCH-ENGINE/' - * 'LinkWalker' 'LinkWalker' - * 'MMSBot [Bot]' 'http://www.mmsweb.at/bot.html' - * 'Naver [Bot]' 'nhnbot@naver.com)' - * 'NetResearchServer' 'NetResearchServer/' - * 'Nimble [Crawler]' 'NimbleCrawler' - * 'Ocelli [Bot]' 'Ocelli/' - * 'Onsearch [Bot]' 'onCHECK-Robot' - * 'Orange [Spider]' 'OrangeSpider' - * 'Sproose [Bot]' 'http://www.sproose.com/bot' - * 'Susie [Sync]' '!Susie (http://www.sync2it.com/susie)' - * 'Tbot [Bot]' 'Tbot/' - * 'Thumbshots [Capture]' 'thumbshots-de-Bot' - * 'Vagabondo [Crawler]' 'http://webagent.wise-guys.nl/' - * 'Walhello [Bot]' 'appie 1.1 (www.walhello.com)' - * 'WissenOnline [Bot]' 'WissenOnline-Bot' - * 'WWWeasel [Bot]' 'WWWeasel Robot v' - * 'Xaldon [Spider]' 'Xaldon WebSpider' - */ - $this->bot_list = array( - 'AdsBot [Google]' => array('AdsBot-Google', ''), - 'Alexa [Bot]' => array('ia_archiver', ''), - 'Alta Vista [Bot]' => array('Scooter/', ''), - 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''), - 'Baidu [Spider]' => array('Baiduspider', ''), - 'Bing [Bot]' => array('bingbot/', ''), - 'Exabot [Bot]' => array('Exabot', ''), - 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''), - 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''), - 'Francis [Bot]' => array('http://www.neomo.de/', ''), - 'Gigabot [Bot]' => array('Gigabot/', ''), - 'Google Adsense [Bot]' => array('Mediapartners-Google', ''), - 'Google Desktop' => array('Google Desktop', ''), - 'Google Feedfetcher' => array('Feedfetcher-Google', ''), - 'Google [Bot]' => array('Googlebot', ''), - 'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''), - 'Heritrix [Crawler]' => array('heritrix/1.', ''), - 'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''), - 'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''), - 'ichiro [Crawler]' => array('ichiro/', ''), - 'Majestic-12 [Bot]' => array('MJ12bot/', ''), - 'Metager [Bot]' => array('MetagerBot/', ''), - 'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''), - 'MSN [Bot]' => array('msnbot/', ''), - 'MSNbot Media' => array('msnbot-media/', ''), - 'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''), - 'Online link [Validator]' => array('online link validator', ''), - 'psbot [Picsearch]' => array('psbot/0', ''), - 'Sensis [Crawler]' => array('Sensis Web Crawler', ''), - 'SEO Crawler' => array('SEO search Crawler/', ''), - 'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''), - 'SEOSearch [Crawler]' => array('SEOsearch/', ''), - 'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''), - 'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''), - 'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''), - 'TurnitinBot [Bot]' => array('TurnitinBot/', ''), - 'Voyager [Bot]' => array('voyager/', ''), - 'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''), - 'W3C [Linkcheck]' => array('W3C-checklink/', ''), - 'W3C [Validator]' => array('W3C_Validator', ''), - 'YaCy [Bot]' => array('yacybot', ''), - 'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''), - 'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''), - 'Yahoo [Bot]' => array('Yahoo! Slurp', ''), - 'YahooSeeker [Bot]' => array('YahooSeeker/', ''), - ); } /** diff --git a/phpBB/phpbb/install/module/install_data/task/add_modules.php b/phpBB/phpbb/install/module/install_data/task/add_modules.php index 8ca2b6b215..bfbe6282bc 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_modules.php +++ b/phpBB/phpbb/install/module/install_data/task/add_modules.php @@ -41,17 +41,97 @@ class add_modules extends \phpbb\install\task_base * * @var array */ - protected $module_categories; + protected $module_categories = array( + 'acp' => array( + 'ACP_CAT_GENERAL' => array( + 'ACP_QUICK_ACCESS', + 'ACP_BOARD_CONFIGURATION', + 'ACP_CLIENT_COMMUNICATION', + 'ACP_SERVER_CONFIGURATION', + ), + 'ACP_CAT_FORUMS' => array( + 'ACP_MANAGE_FORUMS', + 'ACP_FORUM_BASED_PERMISSIONS', + ), + 'ACP_CAT_POSTING' => array( + 'ACP_MESSAGES', + 'ACP_ATTACHMENTS', + ), + 'ACP_CAT_USERGROUP' => array( + 'ACP_CAT_USERS', + 'ACP_GROUPS', + 'ACP_USER_SECURITY', + ), + 'ACP_CAT_PERMISSIONS' => array( + 'ACP_GLOBAL_PERMISSIONS', + 'ACP_FORUM_BASED_PERMISSIONS', + 'ACP_PERMISSION_ROLES', + 'ACP_PERMISSION_MASKS', + ), + 'ACP_CAT_CUSTOMISE' => array( + 'ACP_STYLE_MANAGEMENT', + 'ACP_EXTENSION_MANAGEMENT', + 'ACP_LANGUAGE', + ), + 'ACP_CAT_MAINTENANCE' => array( + 'ACP_FORUM_LOGS', + 'ACP_CAT_DATABASE', + ), + 'ACP_CAT_SYSTEM' => array( + 'ACP_AUTOMATION', + 'ACP_GENERAL_TASKS', + 'ACP_MODULE_MANAGEMENT', + ), + 'ACP_CAT_DOT_MODS' => null, + ), + 'mcp' => array( + 'MCP_MAIN' => null, + 'MCP_QUEUE' => null, + 'MCP_REPORTS' => null, + 'MCP_NOTES' => null, + 'MCP_WARN' => null, + 'MCP_LOGS' => null, + 'MCP_BAN' => null, + ), + 'ucp' => array( + 'UCP_MAIN' => null, + 'UCP_PROFILE' => null, + 'UCP_PREFS' => null, + 'UCP_PM' => null, + 'UCP_USERGROUPS' => null, + 'UCP_ZEBRA' => null, + ), + ); /** * @var array */ - protected $module_categories_basenames; + protected $module_categories_basenames = array( + 'UCP_PM' => 'ucp_pm', + ); /** * @var array */ - protected $module_extras; + protected $module_extras = array( + 'acp' => array( + 'ACP_QUICK_ACCESS' => array( + 'ACP_MANAGE_USERS', + 'ACP_GROUPS_MANAGE', + 'ACP_MANAGE_FORUMS', + 'ACP_MOD_LOGS', + 'ACP_BOTS', + 'ACP_PHP_INFO', + ), + 'ACP_FORUM_BASED_PERMISSIONS' => array( + 'ACP_FORUM_PERMISSIONS', + 'ACP_FORUM_PERMISSIONS_COPY', + 'ACP_FORUM_MODERATORS', + 'ACP_USERS_FORUM_PERMISSIONS', + 'ACP_GROUPS_FORUM_PERMISSIONS', + ), + ), + ); /** * Constructor @@ -68,92 +148,6 @@ class add_modules extends \phpbb\install\task_base $this->module_manager = $container->get('module.manager'); parent::__construct(true); - - $this->module_categories = array( - 'acp' => array( - 'ACP_CAT_GENERAL' => array( - 'ACP_QUICK_ACCESS', - 'ACP_BOARD_CONFIGURATION', - 'ACP_CLIENT_COMMUNICATION', - 'ACP_SERVER_CONFIGURATION', - ), - 'ACP_CAT_FORUMS' => array( - 'ACP_MANAGE_FORUMS', - 'ACP_FORUM_BASED_PERMISSIONS', - ), - 'ACP_CAT_POSTING' => array( - 'ACP_MESSAGES', - 'ACP_ATTACHMENTS', - ), - 'ACP_CAT_USERGROUP' => array( - 'ACP_CAT_USERS', - 'ACP_GROUPS', - 'ACP_USER_SECURITY', - ), - 'ACP_CAT_PERMISSIONS' => array( - 'ACP_GLOBAL_PERMISSIONS', - 'ACP_FORUM_BASED_PERMISSIONS', - 'ACP_PERMISSION_ROLES', - 'ACP_PERMISSION_MASKS', - ), - 'ACP_CAT_CUSTOMISE' => array( - 'ACP_STYLE_MANAGEMENT', - 'ACP_EXTENSION_MANAGEMENT', - 'ACP_LANGUAGE', - ), - 'ACP_CAT_MAINTENANCE' => array( - 'ACP_FORUM_LOGS', - 'ACP_CAT_DATABASE', - ), - 'ACP_CAT_SYSTEM' => array( - 'ACP_AUTOMATION', - 'ACP_GENERAL_TASKS', - 'ACP_MODULE_MANAGEMENT', - ), - 'ACP_CAT_DOT_MODS' => null, - ), - 'mcp' => array( - 'MCP_MAIN' => null, - 'MCP_QUEUE' => null, - 'MCP_REPORTS' => null, - 'MCP_NOTES' => null, - 'MCP_WARN' => null, - 'MCP_LOGS' => null, - 'MCP_BAN' => null, - ), - 'ucp' => array( - 'UCP_MAIN' => null, - 'UCP_PROFILE' => null, - 'UCP_PREFS' => null, - 'UCP_PM' => null, - 'UCP_USERGROUPS' => null, - 'UCP_ZEBRA' => null, - ), - ); - - $this->module_categories_basenames = array( - 'UCP_PM' => 'ucp_pm', - ); - - $this->module_extras = array( - 'acp' => array( - 'ACP_QUICK_ACCESS' => array( - 'ACP_MANAGE_USERS', - 'ACP_GROUPS_MANAGE', - 'ACP_MANAGE_FORUMS', - 'ACP_MOD_LOGS', - 'ACP_BOTS', - 'ACP_PHP_INFO', - ), - 'ACP_FORUM_BASED_PERMISSIONS' => array( - 'ACP_FORUM_PERMISSIONS', - 'ACP_FORUM_PERMISSIONS_COPY', - 'ACP_FORUM_MODERATORS', - 'ACP_USERS_FORUM_PERMISSIONS', - 'ACP_GROUPS_FORUM_PERMISSIONS', - ), - ), - ); } /** -- cgit v1.2.1 From f7641cd506bd8ad98e923ce84f9f39960a938a69 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 25 Jul 2015 15:41:10 +0200 Subject: [ticket/13740] Fix infinite config.php check loop PHPBB3-13740 --- phpBB/phpbb/install/helper/container_factory.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index dab16b81fd..dc0eef6485 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -115,11 +115,7 @@ class container_factory // Check whether container can be built // We need config.php for that so let's check if it has been set up yet - if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) - { - $this->build_container(); - } - else + if (!filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) { throw new cannot_build_container_exception(); } -- cgit v1.2.1 From 495c0c6fb32ac0b720fccfeb640a0b3d5a32b98f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 26 Jul 2015 22:20:32 +0200 Subject: [ticket/13740] Move handle_language_select calls to the controllers PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 4 +--- phpBB/phpbb/install/controller/install.php | 2 ++ phpBB/phpbb/install/controller/installer_index.php | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 6d591786c4..fdfa6821ed 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -114,8 +114,6 @@ class helper $this->router = $router; $this->phpbb_root_path = $phpbb_root_path; $this->phpbb_admin_path = $phpbb_root_path . 'adm/'; - - $this->handle_language_select(); } /** @@ -167,7 +165,7 @@ class helper /** * Handles language selector form */ - protected function handle_language_select() + public function handle_language_select() { $lang = null; diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index c21b0d831b..80f6651a39 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -176,6 +176,8 @@ class install // Determine whether the installation was started or not if (true) { + $this->controller_helper->handle_language_select(); + // Set active stage $this->menu_provider->set_nav_property( array('install', 0, 'introduction'), diff --git a/phpBB/phpbb/install/controller/installer_index.php b/phpBB/phpbb/install/controller/installer_index.php index 8e1874984b..c2d9572284 100644 --- a/phpBB/phpbb/install/controller/installer_index.php +++ b/phpBB/phpbb/install/controller/installer_index.php @@ -53,6 +53,8 @@ class installer_index public function handle($mode) { + $this->helper->handle_language_select(); + switch ($mode) { case "intro": -- cgit v1.2.1 From 11dfe503aac699b88a333967a1d0e594998414ae Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 26 Jul 2015 23:00:40 +0200 Subject: [ticket/13740] Reduce number of references in nav provider PHPBB3-13740 --- .../install/helper/navigation/navigation_provider.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/navigation/navigation_provider.php b/phpBB/phpbb/install/helper/navigation/navigation_provider.php index 1f58cbea83..d52aec8999 100644 --- a/phpBB/phpbb/install/helper/navigation/navigation_provider.php +++ b/phpBB/phpbb/install/helper/navigation/navigation_provider.php @@ -58,7 +58,7 @@ class navigation_provider public function register(navigation_interface $navigation) { $nav_arry = $navigation->get(); - $this->merge($nav_arry, $this->menu_collection); + $this->menu_collection = $this->merge($nav_arry, $this->menu_collection); } /** @@ -79,7 +79,7 @@ class navigation_provider $array_pointer = $property_array; - $this->merge($array_root_pointer, $this->menu_collection); + $this->menu_collection = $this->merge($array_root_pointer, $this->menu_collection); } /** @@ -90,26 +90,32 @@ class navigation_provider * * @param array $array_to_merge * @param array $array_to_merge_into + * + * @return array Merged array */ - private function merge(&$array_to_merge, &$array_to_merge_into) + private function merge($array_to_merge, $array_to_merge_into) { + $merged_array = $array_to_merge_into; + foreach ($array_to_merge as $key => $value) { if (isset($array_to_merge_into[$key])) { if (is_array($array_to_merge_into[$key]) && is_array($value)) { - $this->merge($value, $array_to_merge_into[$key]); + $merged_array[$key] = $this->merge($value, $array_to_merge_into[$key]); } else { - $array_to_merge_into[$key] = $value; + $merged_array[$key] = $value; } } else { - $array_to_merge_into[$key] = $value; + $merged_array[$key] = $value; } } + + return $merged_array; } } -- cgit v1.2.1 From 6eb284b23af0568922e787e5875dc1ee8783e71f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 29 Jul 2015 20:24:52 +0200 Subject: [ticket/14056] Keep install schema resources in the install folder PHPBB3-14056 --- .../install_database/task/add_default_data.php | 2 +- .../module/install_database/task/create_schema.php | 4 +- phpBB/phpbb/install/schemas/index.htm | 10 - phpBB/phpbb/install/schemas/oracle_schema.sql | 37 - phpBB/phpbb/install/schemas/postgres_schema.sql | 80 -- phpBB/phpbb/install/schemas/schema_data.sql | 821 --------------------- 6 files changed, 3 insertions(+), 951 deletions(-) delete mode 100644 phpBB/phpbb/install/schemas/index.htm delete mode 100644 phpBB/phpbb/install/schemas/oracle_schema.sql delete mode 100644 phpBB/phpbb/install/schemas/postgres_schema.sql delete mode 100644 phpBB/phpbb/install/schemas/schema_data.sql (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php index 1e1eb10403..3d73a74618 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_default_data.php +++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php @@ -87,7 +87,7 @@ class add_default_data extends \phpbb\install\task_base $dbms_info = $this->database_helper->get_available_dbms($dbms); // Get schema data from file - $sql_query = @file_get_contents($this->phpbb_root_path . 'phpbb/install/schemas/schema_data.sql'); + $sql_query = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema_data.sql'); // Clean up SQL $sql_query = $this->replace_dbms_specific_sql($sql_query); diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php index 556bfd5e81..cbec5edb6d 100644 --- a/phpBB/phpbb/install/module/install_database/task/create_schema.php +++ b/phpBB/phpbb/install/module/install_database/task/create_schema.php @@ -144,9 +144,9 @@ class create_schema extends \phpbb\install\task_base $change_prefix = false; // Generate database schema - if ($this->filesystem->exists($this->phpbb_root_path . 'phpbb/install/schemas/schema.json')) + if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) { - $db_table_schema = @file_get_contents($this->phpbb_root_path . 'phpbb/install/schemas/schema.json'); + $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); $db_table_schema = json_decode($db_table_schema, true); $change_prefix = true; } diff --git a/phpBB/phpbb/install/schemas/index.htm b/phpBB/phpbb/install/schemas/index.htm deleted file mode 100644 index ee1f723a7d..0000000000 --- a/phpBB/phpbb/install/schemas/index.htm +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/phpBB/phpbb/install/schemas/oracle_schema.sql b/phpBB/phpbb/install/schemas/oracle_schema.sql deleted file mode 100644 index 2473d31aab..0000000000 --- a/phpBB/phpbb/install/schemas/oracle_schema.sql +++ /dev/null @@ -1,37 +0,0 @@ -/* - This first section is optional, however its probably the best method - of running phpBB on Oracle. If you already have a tablespace and user created - for phpBB you can leave this section commented out! - - The first set of statements create a phpBB tablespace and a phpBB user, - make sure you change the password of the phpBB user before you run this script!! -*/ - -/* -CREATE TABLESPACE "PHPBB" - LOGGING - DATAFILE 'E:\ORACLE\ORADATA\LOCAL\PHPBB.ora' - SIZE 10M - AUTOEXTEND ON NEXT 10M - MAXSIZE 100M; - -CREATE USER "PHPBB" - PROFILE "DEFAULT" - IDENTIFIED BY "phpbb_password" - DEFAULT TABLESPACE "PHPBB" - QUOTA UNLIMITED ON "PHPBB" - ACCOUNT UNLOCK; - -GRANT ANALYZE ANY TO "PHPBB"; -GRANT CREATE SEQUENCE TO "PHPBB"; -GRANT CREATE SESSION TO "PHPBB"; -GRANT CREATE TABLE TO "PHPBB"; -GRANT CREATE TRIGGER TO "PHPBB"; -GRANT CREATE VIEW TO "PHPBB"; -GRANT "CONNECT" TO "PHPBB"; - -COMMIT; -DISCONNECT; - -CONNECT phpbb/phpbb_password; -*/ diff --git a/phpBB/phpbb/install/schemas/postgres_schema.sql b/phpBB/phpbb/install/schemas/postgres_schema.sql deleted file mode 100644 index 65caba8d1c..0000000000 --- a/phpBB/phpbb/install/schemas/postgres_schema.sql +++ /dev/null @@ -1,80 +0,0 @@ - -BEGIN; - -/* - Domain definition -*/ -CREATE DOMAIN varchar_ci AS varchar(255) NOT NULL DEFAULT ''::character varying; - -/* - Operation Functions -*/ -CREATE FUNCTION _varchar_ci_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) = LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_not_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) != LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_less_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) < LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_less_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) <= LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_greater_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) > LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_greater_equals(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) >= LOWER($2)' LANGUAGE SQL STRICT; - -/* - Operators -*/ -CREATE OPERATOR <( - PROCEDURE = _varchar_ci_less_than, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = >, - NEGATOR = >=, - RESTRICT = scalarltsel, - JOIN = scalarltjoinsel); - -CREATE OPERATOR <=( - PROCEDURE = _varchar_ci_less_equal, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = >=, - NEGATOR = >, - RESTRICT = scalarltsel, - JOIN = scalarltjoinsel); - -CREATE OPERATOR >( - PROCEDURE = _varchar_ci_greater_than, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = <, - NEGATOR = <=, - RESTRICT = scalargtsel, - JOIN = scalargtjoinsel); - -CREATE OPERATOR >=( - PROCEDURE = _varchar_ci_greater_equals, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = <=, - NEGATOR = <, - RESTRICT = scalargtsel, - JOIN = scalargtjoinsel); - -CREATE OPERATOR <>( - PROCEDURE = _varchar_ci_not_equal, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = <>, - NEGATOR = =, - RESTRICT = neqsel, - JOIN = neqjoinsel); - -CREATE OPERATOR =( - PROCEDURE = _varchar_ci_equal, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = =, - NEGATOR = <>, - RESTRICT = eqsel, - JOIN = eqjoinsel, - HASHES, - MERGES, - SORT1= <); - -COMMIT; - diff --git a/phpBB/phpbb/install/schemas/schema_data.sql b/phpBB/phpbb/install/schemas/schema_data.sql deleted file mode 100644 index 1f856f016c..0000000000 --- a/phpBB/phpbb/install/schemas/schema_data.sql +++ /dev/null @@ -1,821 +0,0 @@ -# -# $Id$ -# - -# POSTGRES BEGIN # - -# -- Config -INSERT INTO phpbb_config (config_name, config_value) VALUES ('active_sessions', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_attachments', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_autologin', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_gravatar', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_local', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_upload', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote_upload', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bbcode', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_birthdays', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bookmarks', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_cdn', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_emailreuse', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_password_reset', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_forum_notify', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_live_searches', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_mass_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_name_chars', 'USERNAME_CHARS_ANY'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_namechange', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_nocensors', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_pm_attach', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_pm_report', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_post_flash', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_post_links', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_privmsg', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_quick_reply', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_bbcode', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_flash', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_img', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_links', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_smilies', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_smilies', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_topic_notify', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('assets_version', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('attachment_quota', '52428800'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_bbcode_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_flash_pm', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_img_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_method', 'db'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_smilies_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_filesize', '6144'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_gallery_path', 'images/avatars/gallery'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_max_height', '90'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_max_width', '90'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_min_height', '20'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_min_width', '20'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_path', 'images/avatars/upload'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_salt', 'phpbb_avatar'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact', 'contact@yourdomain.tld'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact_name', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable_msg', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email', 'address@yourdomain.tld'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_form', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_sig', '{L_CONFIG_BOARD_EMAIL_SIG}'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_hide_emails', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_index_text', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_timezone', 'UTC'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('browser_check', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('bump_interval', '10'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('bump_type', 'd'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('cache_gc', '7200'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_plugin', 'core.captcha.plugins.nogd'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_foreground_noise', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_x_grid', '25'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_y_grid', '25'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_wave', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_3d_noise', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_fonts', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('confirm_refresh', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_attachment_content', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_form_enable', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_domain', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_name', 'phpbb3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_path', '/'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_secure', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('coppa_enable', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('coppa_fax', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('coppa_mail', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('database_gc', '604800'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('dbms_version', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('default_dateformat', 'D M d, Y g:i a'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('default_style', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_edited', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_subject', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_order', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('edit_time', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('extension_force_unstable', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('delete_time', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_check_mx', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_enable', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_function_name', 'mail'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_max_chunk_size', '50'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_package_size', '20'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_confirm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_mod_rewrite', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_pm_icons', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_post_confirm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_enable', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_http_auth', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_limit_post', '15'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_limit_topic', '10'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_overall_forums', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_overall', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_forum', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_topic', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_topics_new', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_topics_active', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_item_statistics', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('flood_interval', '15'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('force_server_vars', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('form_token_lifetime', '7200'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('form_token_mintime', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('form_token_sid_guests', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('forward_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('forwarded_for_check', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('full_folder_action', '2'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_mysql_max_word_len', '254'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_mysql_min_word_len', '4'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_common_thres', '5'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_load_upd', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_max_chars', '14'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_min_chars', '3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_max_word_len', '254'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_min_word_len', '4'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_ts_name', 'simple'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_indexer_mem_limit', '512'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_stopwords', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('gzip_compress', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('hot_threshold', '25'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('icons_path', 'images/icons'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_create_thumbnail', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_display_inlined', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_imagick', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_link_height', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_link_width', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_height', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_thumb_width', '400'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_width', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_min_thumb_filesize', '12000'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_check', '3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_max', '50'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_time', '21600'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_use_forwarded', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_enable', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_host', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_password', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_package_size', '20'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_port', '5222'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_use_ssl', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_username', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_base_dn', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_email', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_password', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_port', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_server', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_uid', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_user', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_user_filter', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('legend_sort_groupname', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_load', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_search_load', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_anon_lastread', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_birthdays', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_memberlist', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofile', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewtopic', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_track', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jumpbox', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_moderators', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_notifications', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_guests', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time', '5'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_onlinetrack', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_tplcompile', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_unreads_search', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_user_activity', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments', '3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_autologin_time', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_filesize', '262144'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_filesize_pm', '262144'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_login_attempts', '3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_name_chars', '20'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_num_search_keywords', '10'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_pass_chars', '100'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_poll_options', '10'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_chars', '60000'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_font_size', '200'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_img_height', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_img_width', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_smilies', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_urls', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_quote_depth', '3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_reg_attempts', '5'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_chars', '255'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_font_size', '200'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_img_height', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_img_width', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_smilies', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_urls', '5'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_name_chars', '3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_pass_chars', '6'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_post_chars', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_search_author_chars', '3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('new_member_post_limit', '3'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('new_member_group_default', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('override_user_style', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('pass_complex', 'PASS_TYPE_ANY'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('plupload_salt', 'phpbb_plupload'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_edit_time', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_boxes', '4'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_msgs', '50'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_recipients', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('posts_per_page', '10'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('print_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('queue_interval', '60'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('ranks_path', 'images/ranks'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('read_notification_expire_days', '30'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('read_notification_gc', '86400'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('referer_validation', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('script_path', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_block_size', '250'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_gc', '7200'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_interval', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_anonymous_interval', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_type', '\phpbb\search\fulltext_native'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_store_results', '1800'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_deny', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_empty_referer', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_downloads', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_name', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_port', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_protocol', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_gc', '3600'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_length', '3600'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_desc', '{L_CONFIG_SITE_DESC}'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_url', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_text', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('sitename', '{L_CONFIG_SITENAME}'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_path', 'images/smilies'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_per_page', '50'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_auth_method', 'PLAIN'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_delivery', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_host', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_password', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_port', '25'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_username', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('teampage_memberships', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('teampage_forums', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', '25'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_path', 'files'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('use_system_cron', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.2.0-a1-dev'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_expire_days', '90'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_gc', '14400'); - -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('cache_last_gc', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('cron_lock', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('database_last_gc', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('last_queue_run', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_colour', 'AA0000', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_id', '2', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_username', '', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_files', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_posts', '1', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_topics', '1', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_users', '1', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('plupload_last_gc', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('rand_seed', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('rand_seed_last_update', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('read_notification_last_gc', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_date', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_users', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_indexing_state', '', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_last_gc', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('session_last_gc', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('upload_dir_size', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('warnings_last_gc', '0', 1); - -# Config text -INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info', ''); -INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_uid', ''); -INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_bitfield', ''); -INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_flags', '7'); - -# -- Forum related auth options -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_announce', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_attach', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_bbcode', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_bump', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_delete', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_download', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_edit', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_email', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_flash', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_icons', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_ignoreflood', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_img', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_list', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_noapprove', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_poll', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_post', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_postcount', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_print', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_read', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_reply', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_report', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_search', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_sigs', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_smilies', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_sticky', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_subscribe', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_user_lock', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_vote', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_votechg', 1); -INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_softdelete', 1); - -# -- Moderator related auth options -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_approve', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_chgposter', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_delete', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_edit', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_info', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_lock', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_merge', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_move', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_report', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_split', 1, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_softdelete', 1, 1); - -# -- Global moderator auth option (not a local option) -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_ban', 0, 1); -INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_warn', 0, 1); - -# -- Admin related auth options -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_aauth', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_attach', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_authgroups', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_authusers', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_backup', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_ban', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_bbcode', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_board', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_bots', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_clearlogs', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_email', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_extensions', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_fauth', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forum', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forumadd', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forumdel', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_group', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_groupadd', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_groupdel', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_icons', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_jabber', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_language', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_mauth', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_modules', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_names', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_phpinfo', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_profile', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_prune', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_ranks', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_reasons', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_roles', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_search', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_server', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_styles', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_switchperm', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_uauth', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_user', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_userdel', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_viewauth', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_viewlogs', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_words', 1); - -# -- User related auth options -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_attach', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgavatar', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgcensors', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgemail', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chggrp', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgname', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgpasswd', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgprofileinfo', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_download', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_hideonline', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_ignoreflood', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_masspm', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_masspm_group', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_attach', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_bbcode', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_delete', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_download', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_edit', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_emailpm', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_flash', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_forward', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_img', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_printpm', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_pm_smilies', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_readpm', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_savedrafts', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_search', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendemail', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendim', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendpm', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sig', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_viewonline', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_viewprofile', 1); - - -# -- standard auth roles -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_ADMIN_STANDARD', 'ROLE_DESCRIPTION_ADMIN_STANDARD', 'a_', 1); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_ADMIN_FORUM', 'ROLE_DESCRIPTION_ADMIN_FORUM', 'a_', 3); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_ADMIN_USERGROUP', 'ROLE_DESCRIPTION_ADMIN_USERGROUP', 'a_', 4); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_ADMIN_FULL', 'ROLE_DESCRIPTION_ADMIN_FULL', 'a_', 2); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_FULL', 'ROLE_DESCRIPTION_USER_FULL', 'u_', 3); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_STANDARD', 'ROLE_DESCRIPTION_USER_STANDARD', 'u_', 1); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_LIMITED', 'ROLE_DESCRIPTION_USER_LIMITED', 'u_', 2); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NOPM', 'ROLE_DESCRIPTION_USER_NOPM', 'u_', 4); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NOAVATAR', 'ROLE_DESCRIPTION_USER_NOAVATAR', 'u_', 5); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_MOD_FULL', 'ROLE_DESCRIPTION_MOD_FULL', 'm_', 3); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_MOD_STANDARD', 'ROLE_DESCRIPTION_MOD_STANDARD', 'm_', 1); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_MOD_SIMPLE', 'ROLE_DESCRIPTION_MOD_SIMPLE', 'm_', 2); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_MOD_QUEUE', 'ROLE_DESCRIPTION_MOD_QUEUE', 'm_', 4); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_FULL', 'ROLE_DESCRIPTION_FORUM_FULL', 'f_', 7); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_STANDARD', 'ROLE_DESCRIPTION_FORUM_STANDARD', 'f_', 5); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NOACCESS', 'ROLE_DESCRIPTION_FORUM_NOACCESS', 'f_', 1); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_READONLY', 'ROLE_DESCRIPTION_FORUM_READONLY', 'f_', 2); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_LIMITED', 'ROLE_DESCRIPTION_FORUM_LIMITED', 'f_', 3); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_BOT', 'ROLE_DESCRIPTION_FORUM_BOT', 'f_', 9); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_ONQUEUE', 'ROLE_DESCRIPTION_FORUM_ONQUEUE', 'f_', 8); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_POLLS', 'ROLE_DESCRIPTION_FORUM_POLLS', 'f_', 6); -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_LIMITED_POLLS', 'ROLE_DESCRIPTION_FORUM_LIMITED_POLLS', 'f_', 4); - -# 23 -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', 6); - -# 24 -INSERT INTO phpbb_acl_roles (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', 10); - -# -- phpbb_styles -INSERT INTO phpbb_styles (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Limited', 1, 'prosilver', 'kNg=', 0, ''); - -# -- Forums -INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents) VALUES ('{L_FORUMS_FIRST_CATEGORY}', '', 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 'Admin', 'AA0000', 972086460, '', '', '', '', '', '', '', 0, 0, ''); - -INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 0, 0, 1, 0, 0, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48); - -# -- Users / Anonymous user -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_jabber, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', 0); - -# -- username: Admin password: admin (change this or remove it once everything is working!) -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_jabber, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', ''); - -# -- Groups -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED_COPPA', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GLOBAL_MODERATORS', 3, 0, '00AA00', 2, '', '', '', 0); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('ADMINISTRATORS', 3, 1, 'AA0000', 1, '', '', '', 0); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('BOTS', 3, 0, '9E8DA7', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5); - -# -- Teampage -INSERT INTO phpbb_teampage (group_id, teampage_name, teampage_position, teampage_parent) VALUES (5, '', 1, 0); -INSERT INTO phpbb_teampage (group_id, teampage_name, teampage_position, teampage_parent) VALUES (4, '', 2, 0); - -# -- User -> Group -INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (1, 1, 0, 0); -INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (2, 2, 0, 0); -INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (4, 2, 0, 0); -INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (5, 2, 0, 1); - -# -- Ranks -INSERT INTO phpbb_ranks (rank_title, rank_min, rank_special, rank_image) VALUES ('{L_RANKS_SITE_ADMIN_TITLE}', 0, 1, ''); - -# -- Roles data - -# Standard Admin (a_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 1, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option NOT IN ('a_switchperm', 'a_jabber', 'a_phpinfo', 'a_server', 'a_backup', 'a_styles', 'a_clearlogs', 'a_modules', 'a_language', 'a_email', 'a_bots', 'a_search', 'a_aauth', 'a_roles'); - -# Forum admin (a_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 2, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option IN ('a_', 'a_authgroups', 'a_authusers', 'a_fauth', 'a_forum', 'a_forumadd', 'a_forumdel', 'a_mauth', 'a_prune', 'a_uauth', 'a_viewauth', 'a_viewlogs'); - -# User and Groups Admin (a_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 3, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option IN ('a_', 'a_authgroups', 'a_authusers', 'a_ban', 'a_group', 'a_groupadd', 'a_groupdel', 'a_ranks', 'a_uauth', 'a_user', 'a_viewauth', 'a_viewlogs'); - -# Full Admin (a_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 4, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%'; - -# All Features (u_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 5, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%'; - -# Standard Features (u_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 6, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_flash', 'u_pm_forward'); - -# Limited Features (u_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 7, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_pm_flash', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group'); - -# No Private Messages (u_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 8, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_', 'u_chgavatar', 'u_chgcensors', 'u_chgemail', 'u_chgpasswd', 'u_download', 'u_hideonline', 'u_sig', 'u_viewprofile'); -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 8, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_readpm', 'u_sendpm', 'u_masspm', 'u_masspm_group'); - -# No Avatar (u_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_chgavatar', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_pm_flash', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group'); -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_chgavatar'); - -# Full Moderator (m_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 10, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%'; - -# Standard Moderator (m_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 11, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option NOT IN ('m_ban', 'm_chgposter'); - -# Simple Moderator (m_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 12, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option IN ('m_', 'm_delete', 'm_softdelete', 'm_edit', 'm_info', 'm_report'); - -# Queue Moderator (m_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 13, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option IN ('m_', 'm_approve', 'm_edit'); - -# Full Access (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 14, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%'; - -# Standard Access (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 15, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_flash', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock'); - -# No Access (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 16, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option = 'f_'; - -# Read Only Access (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 17, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_', 'f_download', 'f_list', 'f_read', 'f_search', 'f_subscribe', 'f_print'); - -# Limited Access (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 18, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg'); - -# Bot Access (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 19, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_', 'f_download', 'f_list', 'f_read', 'f_print'); - -# On Moderation Queue (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 20, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg', 'f_noapprove'); -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 20, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove'); - -# Standard Access + Polls (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 21, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_flash', 'f_ignoreflood', 'f_sticky', 'f_user_lock'); - -# Limited Access + Polls (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 22, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_sticky', 'f_user_lock', 'f_votechg'); - -# New Member (u_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 23, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group', 'u_chgprofileinfo'); - -# New Member (f_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 24, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove'); - - -# Permissions - -# GUESTS - u_download and u_search ability -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) SELECT 1, 0, auth_option_id, 0, 1 FROM phpbb_acl_options WHERE auth_option IN ('u_', 'u_download', 'u_search'); - -# Admin user - full user features -INSERT INTO phpbb_acl_users (user_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (2, 0, 0, 5, 0); - -# ADMINISTRATOR Group - full user features -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (5, 0, 0, 5, 0); - -# ADMINISTRATOR Group - standard admin -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (5, 0, 0, 1, 0); - -# REGISTERED and REGISTERED_COPPA having standard user features -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (2, 0, 0, 6, 0); -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (3, 0, 0, 6, 0); - -# GLOBAL_MODERATORS having full user features -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (4, 0, 0, 5, 0); - -# GLOBAL_MODERATORS having full global moderator access -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (4, 0, 0, 10, 0); - -# Giving all groups read only access to the first category -# since administrators and moderators are already within the registered users group we do not need to set them here -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (1, 1, 0, 17, 0); -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (2, 1, 0, 17, 0); -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (3, 1, 0, 17, 0); -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (6, 1, 0, 17, 0); - -# Giving access to the first forum - -# guests having read only access -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (1, 2, 0, 17, 0); - -# registered and registered_coppa having standard access -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (2, 2, 0, 15, 0); -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (3, 2, 0, 15, 0); - -# global moderators having standard access + polls -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (4, 2, 0, 21, 0); - -# administrators having full forum and full moderator access -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (5, 2, 0, 14, 0); -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (5, 2, 0, 10, 0); - -# Bots having bot access -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (6, 2, 0, 19, 0); - -# NEW MEMBERS are not allowed to send private messages -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 0, 0, 23, 0); - -# NEW MEMBERS on the queue -INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0); - - -# -- Demo Topic -INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title, topic_visibility) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 1, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, '', 1); - -# -- Demo Post -INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, icon_id, post_time, post_username, poster_ip, post_subject, post_text, post_checksum, bbcode_uid, post_visibility) VALUES (1, 2, 2, 0, 972086460, '', '127.0.0.1', '{L_TOPICS_TOPIC_TITLE}', '{L_DEFAULT_INSTALL_POST}', '5dd683b17f641daf84c040bfefc58ce9', '', 1); - -# -- Admin posted to the demo topic -INSERT INTO phpbb_topics_posted (user_id, topic_id, topic_posted) VALUES (2, 1, 1); - -# -- Smilies -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':D', 'icon_e_biggrin.gif', '{L_SMILIES_VERY_HAPPY}', 15, 17, 1); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-D', 'icon_e_biggrin.gif', '{L_SMILIES_VERY_HAPPY}', 15, 17, 2); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':grin:', 'icon_e_biggrin.gif', '{L_SMILIES_VERY_HAPPY}', 15, 17, 3); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':)', 'icon_e_smile.gif', '{L_SMILIES_SMILE}', 15, 17, 4); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-)', 'icon_e_smile.gif', '{L_SMILIES_SMILE}', 15, 17, 5); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':smile:', 'icon_e_smile.gif', '{L_SMILIES_SMILE}', 15, 17, 6); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (';)', 'icon_e_wink.gif', '{L_SMILIES_WINK}', 15, 17, 7); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (';-)', 'icon_e_wink.gif', '{L_SMILIES_WINK}', 15, 17, 8); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':wink:', 'icon_e_wink.gif', '{L_SMILIES_WINK}', 15, 17, 9); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':(', 'icon_e_sad.gif', '{L_SMILIES_SAD}', 15, 17, 10); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-(', 'icon_e_sad.gif', '{L_SMILIES_SAD}', 15, 17, 11); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':sad:', 'icon_e_sad.gif', '{L_SMILIES_SAD}', 15, 17, 12); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':o', 'icon_e_surprised.gif', '{L_SMILIES_SURPRISED}', 15, 17, 13); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-o', 'icon_e_surprised.gif', '{L_SMILIES_SURPRISED}', 15, 17, 14); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':eek:', 'icon_e_surprised.gif', '{L_SMILIES_SURPRISED}', 15, 17, 15); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':shock:', 'icon_eek.gif', '{L_SMILIES_SHOCKED}', 15, 17, 16); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':?', 'icon_e_confused.gif', '{L_SMILIES_CONFUSED}', 15, 17, 17); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-?', 'icon_e_confused.gif', '{L_SMILIES_CONFUSED}', 15, 17, 18); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':???:', 'icon_e_confused.gif', '{L_SMILIES_CONFUSED}', 15, 17, 19); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES ('8-)', 'icon_cool.gif', '{L_SMILIES_COOL}', 15, 17, 20); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':cool:', 'icon_cool.gif', '{L_SMILIES_COOL}', 15, 17, 21); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':lol:', 'icon_lol.gif', '{L_SMILIES_LAUGHING}', 15, 17, 22); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':x', 'icon_mad.gif', '{L_SMILIES_MAD}', 15, 17, 23); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-x', 'icon_mad.gif', '{L_SMILIES_MAD}', 15, 17, 24); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':mad:', 'icon_mad.gif', '{L_SMILIES_MAD}', 15, 17, 25); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':P', 'icon_razz.gif', '{L_SMILIES_RAZZ}', 15, 17, 26); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-P', 'icon_razz.gif', '{L_SMILIES_RAZZ}', 15, 17, 27); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':razz:', 'icon_razz.gif', '{L_SMILIES_RAZZ}', 15, 17, 28); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':oops:', 'icon_redface.gif', '{L_SMILIES_EMARRASSED}', 15, 17, 29); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':cry:', 'icon_cry.gif', '{L_SMILIES_CRYING}', 15, 17, 30); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':evil:', 'icon_evil.gif', '{L_SMILIES_EVIL}', 15, 17, 31); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':twisted:', 'icon_twisted.gif', '{L_SMILIES_TWISTED_EVIL}', 15, 17, 32); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':roll:', 'icon_rolleyes.gif', '{L_SMILIES_ROLLING_EYES}', 15, 17, 33); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':!:', 'icon_exclaim.gif', '{L_SMILIES_EXCLAMATION}', 15, 17, 34); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':?:', 'icon_question.gif', '{L_SMILIES_QUESTION}', 15, 17, 35); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':idea:', 'icon_idea.gif', '{L_SMILIES_IDEA}', 15, 17, 36); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':arrow:', 'icon_arrow.gif', '{L_SMILIES_ARROW}', 15, 17, 37); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':|', 'icon_neutral.gif', '{L_SMILIES_NEUTRAL}', 15, 17, 38); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':-|', 'icon_neutral.gif', '{L_SMILIES_NEUTRAL}', 15, 17, 39); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':mrgreen:', 'icon_mrgreen.gif', '{L_SMILIES_MR_GREEN}', 15, 17, 40); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':geek:', 'icon_e_geek.gif', '{L_SMILIES_GEEK}', 17, 17, 41); -INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':ugeek:', 'icon_e_ugeek.gif', '{L_SMILIES_UBER_GEEK}', 17, 18, 42); - -# -- icons -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/fire.gif', 16, 16, 1, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/redface.gif', 16, 16, 9, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/mrgreen.gif', 16, 16, 10, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/heart.gif', 16, 16, 4, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/star.gif', 16, 16, 2, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/radioactive.gif', 16, 16, 3, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('misc/thinking.gif', 16, 16, 5, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/info.gif', 16, 16, 8, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/question.gif', 16, 16, 6, 1); -INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/alert.gif', 16, 16, 7, 1); - -# -- reasons -INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('warez', '{L_REPORT_WAREZ}', 1); -INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('spam', '{L_REPORT_SPAM}', 2); -INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('off_topic', '{L_REPORT_OFF_TOPIC}', 3); -INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('other', '{L_REPORT_OTHER}', 4); - -# -- extension_groups -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('IMAGES', 1, 1, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('ARCHIVES', 0, 1, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('PLAIN_TEXT', 0, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOCUMENTS', 0, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('REAL_MEDIA', 3, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('WINDOWS_MEDIA', 2, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('FLASH_FILES', 5, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('QUICKTIME_MEDIA', 6, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOWNLOADABLE_FILES', 0, 0, 1, '', 0, ''); - -# -- extensions -INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'gif'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'png'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'jpeg'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'jpg'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'tif'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'tiff'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'tga'); - -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'gtar'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'gz'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'tar'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'zip'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'rar'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'ace'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'torrent'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'tgz'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, 'bz2'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (2, '7z'); - -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'txt'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'c'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'h'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'cpp'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'hpp'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'diz'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'csv'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'ini'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'log'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'js'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (3, 'xml'); - -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'xls'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'xlsx'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'xlsm'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'xlsb'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'doc'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'docx'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'docm'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'dot'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'dotx'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'dotm'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'pdf'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'ai'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'ps'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'ppt'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'pptx'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'pptm'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'odg'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'odp'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'ods'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'odt'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (4, 'rtf'); - -INSERT INTO phpbb_extensions (group_id, extension) VALUES (5, 'rm'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (5, 'ram'); - -INSERT INTO phpbb_extensions (group_id, extension) VALUES (6, 'wma'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (6, 'wmv'); - -INSERT INTO phpbb_extensions (group_id, extension) VALUES (7, 'swf'); - -INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'mov'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'm4v'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'm4a'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'mp4'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, '3gp'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, '3g2'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (8, 'qt'); - -INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mpeg'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mpg'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mp3'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg'); -INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm'); - -# Add default profile fields -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_location', 'profilefields.type.string', 'phpbb_location', '20', '2', '100', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, '', ''); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_website', 'profilefields.type.url', 'phpbb_website', '40', '12', '255', '', '', '', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 2, 1, 'VISIT_WEBSITE', '%s'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_interests', 'profilefields.type.text', 'phpbb_interests', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, '', ''); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_occupation', 'profilefields.type.text', 'phpbb_occupation', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 4, 0, '', ''); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_aol', 'profilefields.type.string', 'phpbb_aol', '40', '5', '255', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 5, 1, '', ''); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_icq', 'profilefields.type.string', 'phpbb_icq', '20', '3', '15', '', '', '[0-9]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 6, 1, 'SEND_ICQ_MESSAGE', 'https://www.icq.com/people/%s/'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_wlm', 'profilefields.type.string', 'phpbb_wlm', '40', '5', '255', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 7, 1, '', ''); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_yahoo', 'profilefields.type.string', 'phpbb_yahoo', '40', '5', '255', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 8, 1, 'SEND_YIM_MESSAGE', 'ymsgr:sendim?%s'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_facebook', 'profilefields.type.string', 'phpbb_facebook', '20', '5', '50', '', '', '[\w.]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 9, 1, 'VIEW_FACEBOOK_PROFILE', 'http://facebook.com/%s/'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_twitter', 'profilefields.type.string', 'phpbb_twitter', '20', '1', '15', '', '', '[\w_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 10, 1, 'VIEW_TWITTER_PROFILE', 'http://twitter.com/%s'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_skype', 'profilefields.type.string', 'phpbb_skype', '20', '6', '32', '', '', '[a-zA-Z][\w\.,\-_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 11, 1, 'VIEW_SKYPE_PROFILE', 'skype:%s?userinfo'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_youtube', 'profilefields.type.string', 'phpbb_youtube', '20', '3', '60', '', '', '[a-zA-Z][\w\.,\-_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 12, 1, 'VIEW_YOUTUBE_CHANNEL', 'http://youtube.com/user/%s'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_googleplus', 'profilefields.type.googleplus', 'phpbb_googleplus', '20', '3', '255', '', '', '[\w]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 13, 1, 'VIEW_GOOGLEPLUS_PROFILE', 'http://plus.google.com/%s'); - -# User Notification Options (for first user) -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.post', 0, 2, ''); -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.post', 0, 2, 'notification.method.email'); -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.topic', 0, 2, ''); -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.topic', 0, 2, 'notification.method.email'); - -# POSTGRES COMMIT # -- cgit v1.2.1 From 4ae83e426663d129d7068b312097ad968242f41f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 29 Jul 2015 22:08:37 +0200 Subject: [ticket/14056] Fix remaining schema path PHPBB3-14056 --- phpBB/phpbb/install/module/install_database/task/create_schema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php index cbec5edb6d..7cc521eee8 100644 --- a/phpBB/phpbb/install/module/install_database/task/create_schema.php +++ b/phpBB/phpbb/install/module/install_database/task/create_schema.php @@ -119,7 +119,7 @@ class create_schema extends \phpbb\install\task_base } } - $db_schema_path = $this->phpbb_root_path . 'phpbb/install/schemas/' . $schema_name . '_schema.sql'; + $db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; // Load database vendor specific code if there is any if ($this->filesystem->exists($db_schema_path)) -- cgit v1.2.1 From f4f0ff0eec78c85b4ec2962a0de06d9aa2bd37a5 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 17 Aug 2015 18:38:07 +0200 Subject: [ticket/14097] Improve error and failure handling in the installer PHPBB3-14097 --- phpBB/phpbb/install/installer.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index cb4ddb8783..78a0de0241 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -92,7 +92,8 @@ class installer $module_found = false; // Variable used to check if the install process have been finished - $install_finished = false; + $install_finished = false; + $fail_cleanup = false; // We are installing something, so the introduction stage can go now... $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction')); @@ -209,6 +210,13 @@ class installer { // Do nothing } + catch (\Exception $e) + { + // Most likely there were a PHP failure, so let's die like a gentleman + $this->iohandler->add_error_message($e->getMessage()); + $this->iohandler->send_response(); + $fail_cleanup = true; + } if ($install_finished) { @@ -223,7 +231,7 @@ class installer // Save install progress try { - if ($install_finished) + if ($install_finished || $fail_cleanup) { $this->install_config->clean_up_config_file(); } -- cgit v1.2.1 From dd1b777ca779b60b3624e90a9c7a6831fbddf7c4 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 17 Aug 2015 20:24:01 +0200 Subject: [ticket/14097] Remove auto refresh on install failure PHPBB3-14097 --- phpBB/phpbb/install/installer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 78a0de0241..755edb5297 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -212,7 +212,6 @@ class installer } catch (\Exception $e) { - // Most likely there were a PHP failure, so let's die like a gentleman $this->iohandler->add_error_message($e->getMessage()); $this->iohandler->send_response(); $fail_cleanup = true; @@ -223,7 +222,7 @@ class installer // Send install finished message $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count()); } - else + else if (!$fail_cleanup) { $this->iohandler->request_refresh(); } -- cgit v1.2.1 From 16f3b8c2b9de388223cbe8ace9e1d9bcf0ba5e11 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 27 Aug 2015 10:51:10 +0200 Subject: [ticket/13904] Modify files for changes in ini wrapper PHPBB3-13904 --- phpBB/phpbb/install/helper/config.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index b0480e7e5b..d5653f1924 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -41,7 +41,7 @@ class config protected $install_config_file; /** - * @var \phpbb\php\ini + * @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; @@ -83,7 +83,7 @@ class config /** * Constructor */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \phpbb\php\ini $php_ini, $phpbb_root_path) + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \bantu\IniGetWrapper\IniGetWrapper $php_ini, $phpbb_root_path) { $this->filesystem = $filesystem; $this->php_ini = $php_ini; @@ -373,7 +373,7 @@ class config protected function setup_system_data() { // Query maximum runtime from php.ini - $execution_time = $this->php_ini->get_int('max_execution_time'); + $execution_time = $this->php_ini->getNumeric('max_execution_time'); $execution_time = min(15, $execution_time / 2); $this->system_data['max_execution_time'] = $execution_time; @@ -381,6 +381,6 @@ class config $this->system_data['start_time'] = time(); // Get memory limit - $this->system_data['memory_limit'] = $this->php_ini->get_bytes('memory_limit'); + $this->system_data['memory_limit'] = $this->php_ini->getBytes('memory_limit'); } } -- cgit v1.2.1 From f3dc2a801d7e077e5e10a143b8d450b0b4a3aa11 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 28 Sep 2015 17:40:24 +0200 Subject: [ticket/14205] Bump PHP requirement to PHP 5.4 PHPBB3-14205 --- .../phpbb/install/module/requirements/task/check_server_environment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/requirements/task/check_server_environment.php b/phpBB/phpbb/install/module/requirements/task/check_server_environment.php index 50efdc55a2..62485a2097 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_server_environment.php +++ b/phpBB/phpbb/install/module/requirements/task/check_server_environment.php @@ -95,7 +95,7 @@ class check_server_environment extends \phpbb\install\task_base { $php_version = PHP_VERSION; - if (version_compare($php_version, '5.3.9') < 0) + if (version_compare($php_version, '5.4') < 0) { $this->response_helper->add_error_message('PHP_VERSION_REQD', 'PHP_VERSION_REQD_EXPLAIN'); -- cgit v1.2.1 From 8f5a0ad6f73e7b7757b02c827436384c96069b5a Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 09:20:50 +0200 Subject: [ticket/14039] Revamp updater PHPBB3-14039 --- .../phpbb/install/controller/archive_download.php | 92 +++++++ phpBB/phpbb/install/controller/helper.php | 96 +++++-- phpBB/phpbb/install/controller/install.php | 43 +-- phpBB/phpbb/install/controller/update.php | 162 ++++++++++++ .../exception/file_updater_failure_exception.php | 22 ++ .../exception/jump_to_restart_point_exception.php | 44 +++ phpBB/phpbb/install/helper/config.php | 52 ++++ phpBB/phpbb/install/helper/container_factory.php | 19 +- phpBB/phpbb/install/helper/database.php | 2 +- .../file_updater/compression_file_updater.php | 131 +++++++++ .../phpbb/install/helper/file_updater/factory.php | 69 +++++ .../install/helper/file_updater/file_updater.php | 210 +++++++++++++++ .../helper/file_updater/file_updater_interface.php | 49 ++++ .../helper/file_updater/ftp_file_updater.php | 136 ++++++++++ .../install/helper/iohandler/ajax_iohandler.php | 119 ++++++++- .../install/helper/iohandler/cli_iohandler.php | 24 +- .../install/helper/iohandler/iohandler_base.php | 4 +- .../helper/iohandler/iohandler_interface.php | 19 +- .../helper/navigation/update_navigation.php | 80 ++++++ phpBB/phpbb/install/helper/update_helper.php | 118 +++++++++ phpBB/phpbb/install/installer.php | 14 +- .../install/module/obtain_data/install_module.php | 33 +++ phpBB/phpbb/install/module/obtain_data/module.php | 33 --- .../module/obtain_data/task/obtain_admin_data.php | 2 +- .../module/obtain_data/task/obtain_board_data.php | 2 +- .../task/obtain_file_updater_method.php | 168 ++++++++++++ .../obtain_data/task/obtain_update_files.php | 113 ++++++++ .../obtain_data/task/obtain_update_ftp_data.php | 164 ++++++++++++ .../obtain_data/task/obtain_update_settings.php | 103 ++++++++ .../install/module/obtain_data/update_module.php | 33 +++ .../requirements/abstract_requirements_module.php | 106 ++++++++ .../install/module/requirements/install_module.php | 25 ++ phpBB/phpbb/install/module/requirements/module.php | 110 -------- .../module/requirements/task/check_filesystem.php | 16 +- .../module/requirements/task/check_update.php | 185 +++++++++++++ .../install/module/requirements/update_module.php | 25 ++ .../install/module/update_database/module.php | 33 +++ .../install/module/update_database/task/update.php | 212 +++++++++++++++ .../install/module/update_filesystem/module.php | 33 +++ .../module/update_filesystem/task/diff_files.php | 205 ++++++++++++++ .../task/download_updated_files.php | 124 +++++++++ .../module/update_filesystem/task/file_check.php | 186 +++++++++++++ .../update_filesystem/task/show_file_status.php | 168 ++++++++++++ .../module/update_filesystem/task/update_files.php | 294 +++++++++++++++++++++ phpBB/phpbb/install/module_base.php | 2 +- phpBB/phpbb/install/task_base.php | 2 +- 46 files changed, 3647 insertions(+), 235 deletions(-) create mode 100644 phpBB/phpbb/install/controller/archive_download.php create mode 100644 phpBB/phpbb/install/controller/update.php create mode 100644 phpBB/phpbb/install/exception/file_updater_failure_exception.php create mode 100644 phpBB/phpbb/install/exception/jump_to_restart_point_exception.php create mode 100644 phpBB/phpbb/install/helper/file_updater/compression_file_updater.php create mode 100644 phpBB/phpbb/install/helper/file_updater/factory.php create mode 100644 phpBB/phpbb/install/helper/file_updater/file_updater.php create mode 100644 phpBB/phpbb/install/helper/file_updater/file_updater_interface.php create mode 100644 phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php create mode 100644 phpBB/phpbb/install/helper/navigation/update_navigation.php create mode 100644 phpBB/phpbb/install/helper/update_helper.php create mode 100644 phpBB/phpbb/install/module/obtain_data/install_module.php delete mode 100644 phpBB/phpbb/install/module/obtain_data/module.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_file_updater_method.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php create mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php create mode 100644 phpBB/phpbb/install/module/obtain_data/update_module.php create mode 100644 phpBB/phpbb/install/module/requirements/abstract_requirements_module.php create mode 100644 phpBB/phpbb/install/module/requirements/install_module.php delete mode 100644 phpBB/phpbb/install/module/requirements/module.php create mode 100644 phpBB/phpbb/install/module/requirements/task/check_update.php create mode 100644 phpBB/phpbb/install/module/requirements/update_module.php create mode 100644 phpBB/phpbb/install/module/update_database/module.php create mode 100644 phpBB/phpbb/install/module/update_database/task/update.php create mode 100644 phpBB/phpbb/install/module/update_filesystem/module.php create mode 100644 phpBB/phpbb/install/module/update_filesystem/task/diff_files.php create mode 100644 phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php create mode 100644 phpBB/phpbb/install/module/update_filesystem/task/file_check.php create mode 100644 phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php create mode 100644 phpBB/phpbb/install/module/update_filesystem/task/update_files.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php new file mode 100644 index 0000000000..711e1f2f0c --- /dev/null +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -0,0 +1,92 @@ + + * @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\controller; + +use phpbb\install\helper\config; +use Symfony\Component\HttpFoundation\BinaryFileResponse; +use Symfony\Component\HttpFoundation\ResponseHeaderBag; + +class archive_download +{ + /** + * @var config + */ + protected $installer_config; + + /** + * Constructor + * + * @param config $config + */ + public function __construct(config $config) + { + $this->installer_config = $config; + $this->installer_config->load_config(); + } + + /** + * Sends response with the merge conflict archive + * + * Merge conflicts are always have to be resolved manually, + * so we use a different archive for that. + * + * @return BinaryFileResponse + */ + public function conflict_archive() + { + $filename = $this->installer_config->get('update_file_conflict_archive', false); + + if (!$filename) + { + die ('The requested file is not exist.'); + } + + return $this->send_response($filename); + } + + /** + * Sends response with the updated files' archive + * + * @return BinaryFileResponse + */ + public function update_archive() + { + $filename = $this->installer_config->get('update_file_archive', ''); + + if (!$filename) + { + die ('The requested file is not exist.'); + } + + return $this->send_response($filename); + } + + /** + * Generates a download response + * + * @param string $filename Path to the file to download + * + * @return BinaryFileResponse Response object + */ + private function send_response($filename) + { + $response = new BinaryFileResponse($filename); + $response->setContentDisposition( + ResponseHeaderBag::DISPOSITION_ATTACHMENT, + basename($filename) + ); + + return $response; + } +} diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index fdfa6821ed..ef6b8ba3c2 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -13,6 +13,7 @@ namespace phpbb\install\controller; +use phpbb\install\helper\config; use phpbb\install\helper\navigation\navigation_provider; use phpbb\language\language; use phpbb\language\language_file_helper; @@ -33,6 +34,11 @@ use Symfony\Component\HttpFoundation\Cookie; */ class helper { + /** + * @var config + */ + protected $installer_config; + /** * @var \phpbb\language\language */ @@ -91,6 +97,7 @@ class helper /** * Constructor * + * @param config $config * @param language $language * @param language_file_helper $lang_helper * @param navigation_provider $nav @@ -101,8 +108,9 @@ class helper * @param router $router * @param string $phpbb_root_path */ - public function __construct(language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path) + public function __construct(config $config, language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path) { + $this->installer_config = $config; $this->language = $language; $this->language_cookie = false; $this->lang_helper = $lang_helper; @@ -199,6 +207,47 @@ class helper } } + /** + * Process navigation data to reflect active/completed stages + * + * @param \phpbb\install\helper\iohandler\iohandler_interface|null $iohandler + */ + public function handle_navigation($iohandler = null) + { + $nav_data = $this->installer_config->get_navigation_data(); + + // Set active navigation stage + if (isset($nav_data['active']) && is_array($nav_data['active'])) + { + if ($iohandler !== null) + { + $iohandler->set_active_stage_menu($nav_data['active']); + } + + $this->navigation_provider->set_nav_property($nav_data['active'], array( + 'selected' => true, + 'completed' => false, + )); + } + + // Set finished navigation stages + if (isset($nav_data['finished']) && is_array($nav_data['finished'])) + { + foreach ($nav_data['finished'] as $finished_stage) + { + if ($iohandler !== null) + { + $iohandler->set_finished_stage_menu($finished_stage); + } + + $this->navigation_provider->set_nav_property($finished_stage, array( + 'selected' => false, + 'completed' => true, + )); + } + } + } + /** * Set default template variables * @@ -207,27 +256,32 @@ class helper */ protected function page_header($page_title, $selected_language = false) { + // Path to templates + $paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path); + $paths = array_filter($paths, 'is_dir'); + $path = array_shift($paths); + $path = substr($path, strlen($this->phpbb_root_path)); + $this->template->assign_vars(array( - 'L_CHANGE' => $this->language->lang('CHANGE'), - 'L_COLON' => $this->language->lang('COLON'), - 'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'), - 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'), - 'L_SKIP' => $this->language->lang('SKIP'), - 'PAGE_TITLE' => $this->language->lang($page_title), - 'T_IMAGE_PATH' => htmlspecialchars($this->phpbb_admin_path) . 'images/', - 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . 'assets/javascript/jquery.min.js', - 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . 'adm/style', - 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . 'assets/', - - 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), - 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right', - 'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left', - 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_LANG_SELECT' => $selected_language, - - 'S_USER_LANG' => $this->language->lang('USER_LANG'), - ) - ); + 'L_CHANGE' => $this->language->lang('CHANGE'), + 'L_COLON' => $this->language->lang('COLON'), + 'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'), + 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'), + 'L_SKIP' => $this->language->lang('SKIP'), + 'PAGE_TITLE' => $this->language->lang($page_title), + 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images/', + 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js', + 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style', + 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets/', + + 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), + 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right', + 'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left', + 'S_CONTENT_ENCODING' => 'UTF-8', + 'S_LANG_SELECT' => $selected_language, + + 'S_USER_LANG' => $this->language->lang('USER_LANG'), + )); $this->render_navigation(); } diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 80f6651a39..8d5ff95958 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -13,7 +13,6 @@ namespace phpbb\install\controller; -use phpbb\install\helper\config; use phpbb\install\helper\install_helper; use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; @@ -35,11 +34,6 @@ class install */ protected $controller_helper; - /** - * @var config - */ - protected $installer_config; - /** * @var factory */ @@ -79,7 +73,6 @@ class install * Constructor * * @param helper $helper - * @param config $install_config * @param factory $factory * @param navigation_provider $nav_provider * @param language $language @@ -88,10 +81,9 @@ class install * @param installer $installer * @param install_helper $install_helper */ - public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper) + public function __construct(helper $helper, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper) { $this->controller_helper = $helper; - $this->installer_config = $install_config; $this->iohandler_factory = $factory; $this->menu_provider = $nav_provider; $this->language = $language; @@ -130,34 +122,6 @@ class install // Set the appropriate input-output handler $this->installer->set_iohandler($this->iohandler_factory->get()); - // Set up navigation - $nav_data = $this->installer_config->get_navigation_data(); - /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ - $iohandler = $this->iohandler_factory->get(); - - // Set active navigation stage - if (isset($nav_data['active']) && is_array($nav_data['active'])) - { - $iohandler->set_active_stage_menu($nav_data['active']); - $this->menu_provider->set_nav_property($nav_data['active'], array( - 'selected' => true, - 'completed' => false, - )); - } - - // Set finished navigation stages - if (isset($nav_data['finished']) && is_array($nav_data['finished'])) - { - foreach ($nav_data['finished'] as $finished_stage) - { - $iohandler->set_finished_stage_menu($finished_stage); - $this->menu_provider->set_nav_property($finished_stage, array( - 'selected' => false, - 'completed' => true, - )); - } - } - if ($this->request->is_ajax()) { $installer = $this->installer; @@ -193,6 +157,11 @@ class install 'TITLE' => $this->language->lang('INSTALL_INTRO'), 'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY'), )); + + /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $this->controller_helper->handle_navigation($iohandler); + return $this->controller_helper->render('installer_install.html', 'INSTALL', true); } diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php new file mode 100644 index 0000000000..5212ba7f26 --- /dev/null +++ b/phpBB/phpbb/install/controller/update.php @@ -0,0 +1,162 @@ + + * @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\controller; + +use phpbb\install\helper\install_helper; +use phpbb\install\helper\iohandler\factory; +use phpbb\install\helper\navigation\navigation_provider; +use phpbb\install\installer; +use phpbb\language\language; +use phpbb\request\request_interface; +use phpbb\template\template; +use Symfony\Component\HttpFoundation\StreamedResponse; + +/** + * Updater controller + */ +class update +{ + /** + * @var helper + */ + protected $controller_helper; + + /** + * @var installer + */ + protected $installer; + + /** + * @var install_helper + */ + protected $install_helper; + + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var language + */ + protected $language; + + /** + * @var navigation_provider + */ + protected $menu_provider; + + /** + * @var request_interface + */ + protected $request; + + /** + * @var template + */ + protected $template; + + /** + * Constructor + * + * @param helper $controller_helper + * @param installer $installer + * @param install_helper $install_helper + * @param factory $iohandler + * @param language $language + * @param navigation_provider $menu_provider + * @param request_interface $request + * @param template $template + */ + public function __construct(helper $controller_helper, installer $installer, install_helper $install_helper, factory $iohandler, language $language, navigation_provider $menu_provider, request_interface $request, template $template) + { + $this->controller_helper = $controller_helper; + $this->installer = $installer; + $this->install_helper = $install_helper; + $this->iohandler_factory = $iohandler; + $this->language = $language; + $this->menu_provider = $menu_provider; + $this->request = $request; + $this->template = $template; + } + + /** + * Controller entry point + */ + public function handle() + { + if (!$this->install_helper->is_phpbb_installed()) + { + die ('phpBB is not installed'); + } + + $this->template->assign_vars(array( + 'U_ACTION' => $this->controller_helper->route('phpbb_installer_update'), + )); + + // Set up input-output handler + if ($this->request->is_ajax()) + { + $this->iohandler_factory->set_environment('ajax'); + } + else + { + $this->iohandler_factory->set_environment('nojs'); + } + + // Set the appropriate input-output handler + $this->installer->set_iohandler($this->iohandler_factory->get()); + + // Render the intro page + if ($this->request->is_ajax()) + { + $installer = $this->installer; + $response = new StreamedResponse(); + $response->setCallback(function() use ($installer) { + $installer->run(); + }); + + // Try to bypass any server output buffers + $response->headers->set('X-Accel-Buffering', 'no'); + $response->headers->set('Content-type', 'application/json'); + + return $response; + } + else + { + $this->controller_helper->handle_language_select(); + + // Set active stage + $this->menu_provider->set_nav_property( + array('update', 0, 'introduction'), + array( + 'selected' => true, + 'completed' => false, + ) + ); + + $this->template->assign_vars(array( + 'SHOW_INSTALL_START_FORM' => true, + 'TITLE' => $this->language->lang('UPDATE_INSTALLATION'), + 'CONTENT' => $this->language->lang('UPDATE_INSTALLATION_EXPLAIN'), + )); + + /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $this->controller_helper->handle_navigation($iohandler); + + return $this->controller_helper->render('installer_update.html', 'UPDATE_INSTALLATION', true); + } + } +} diff --git a/phpBB/phpbb/install/exception/file_updater_failure_exception.php b/phpBB/phpbb/install/exception/file_updater_failure_exception.php new file mode 100644 index 0000000000..46ba2ed32d --- /dev/null +++ b/phpBB/phpbb/install/exception/file_updater_failure_exception.php @@ -0,0 +1,22 @@ + + * @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\exception; + +/** + * Thrown when the file updater fails + */ +class file_updater_failure_exception extends installer_exception +{ + +} diff --git a/phpBB/phpbb/install/exception/jump_to_restart_point_exception.php b/phpBB/phpbb/install/exception/jump_to_restart_point_exception.php new file mode 100644 index 0000000000..b628c4fbe3 --- /dev/null +++ b/phpBB/phpbb/install/exception/jump_to_restart_point_exception.php @@ -0,0 +1,44 @@ + + * @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\exception; + +class jump_to_restart_point_exception extends installer_exception +{ + /** + * @var string + */ + protected $restart_point_name; + + /** + * Constructor + * + * @param string $restart_point_name + */ + public function __construct($restart_point_name) + { + $this->restart_point_name = $restart_point_name; + + parent::__construct(); + } + + /** + * Returns the restart point's name + * + * @return string + */ + public function get_restart_point_name() + { + return $this->restart_point_name; + } +} diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index d5653f1924..e73e07208e 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -99,6 +99,8 @@ class config 'last_task_name' => '', // Stores the service name of the latest finished task 'max_task_progress' => 0, 'current_task_progress' => 0, + '_restart_points' => array(), + 'use_restart_point' => false, ); $this->install_config_file = $this->phpbb_root_path . 'store/install_config.php'; @@ -239,6 +241,56 @@ class config } } + /** + * Creates a progress restart point + * + * Restart points can be used to repeat certain tasks periodically. + * You need to call this method from the first task you want to repeat. + * + * @param string $name Name of the restart point + */ + public function create_progress_restart_point($name) + { + $tmp_progress_data = $this->progress_data; + unset($tmp_progress_data['_restart_points']); + + $this->progress_data['_restart_points'][$name] = $tmp_progress_data; + } + + /** + * Set restart point to continue from + * + * @param string $name Name of the restart point + * + * @return bool Returns false if the restart point name is not exist, true otherwise + */ + public function jump_to_restart_point($name) + { + if (!isset($this->progress_data['_restart_points'][$name]) || empty($this->progress_data['_restart_points'][$name])) + { + return false; + } + + foreach ($this->progress_data['_restart_points'][$name] as $key => $value) + { + $this->progress_data[$key] = $value; + } + + return true; + } + + /** + * Returns whether a restart point with a given name exists or not + * + * @param string $name Name of the restart point + * + * @return bool + */ + public function has_restart_point($name) + { + return isset($this->progress_data['_restart_points'][$name]); + } + /** * Dumps install configuration to disk */ diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index dc0eef6485..fd42d53c00 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -134,8 +134,13 @@ class container_factory $this->request->enable_super_globals(); } - $this->container = $phpbb_container = $phpbb_container_builder + $other_config_path = $this->phpbb_root_path . 'install/update/new/config'; + $config_path = (is_dir($other_config_path)) ? $other_config_path : $this->phpbb_root_path . 'config'; + + $this->container = $phpbb_container_builder + ->with_environment('production') ->with_config($phpbb_config_php_file) + ->with_config_path($config_path) ->without_cache() ->without_compiled_container() ->get_container(); @@ -145,11 +150,17 @@ class container_factory $this->container->register('request')->setSynthetic(true); $this->container->set('request', $this->request); - // Replace cache service, as config gets cached, and we don't want that - $this->container->register('cache.driver')->setSynthetic(true); - $this->container->set('cache.driver', new dummy()); + // Replace cache service, as config gets cached, and we don't want that when we are installing + if (!is_dir($other_config_path)) + { + $this->container->register('cache.driver')->setSynthetic(true); + $this->container->set('cache.driver', new dummy()); + } + $this->container->compile(); + $phpbb_container = $this->container; + // Restore super globals to previous state if ($disable_super_globals) { diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 627e9ea9b0..c4c90a01a4 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -338,7 +338,7 @@ class database $db->sql_return_on_error(true); // Check that we actually have a database name before going any further - if (!in_array($dbms_info['SCHEMA'], array('sqlite', 'oracle')) && $dbname === '') + if (!in_array($dbms_info['SCHEMA'], array('sqlite', 'oracle'), true) && $dbname === '') { $errors[] = array( 'title' => 'INST_ERR_DB_NO_NAME', diff --git a/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php b/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php new file mode 100644 index 0000000000..a6eca36653 --- /dev/null +++ b/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php @@ -0,0 +1,131 @@ + + * @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\helper\file_updater; + +use phpbb\install\helper\update_helper; + +/** + * File updater for generating archive with updated files + */ +class compression_file_updater implements file_updater_interface +{ + /** + * @var \compress + */ + protected $compress; + + /** + * @var update_helper + */ + protected $update_helper; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * Constructor + * + * @param update_helper $update_helper + * @param string $phpbb_root_path + * @param string $php_ext + */ + public function __construct(update_helper $update_helper, $phpbb_root_path, $php_ext) + { + $this->compress = null; + $this->update_helper = $update_helper; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * Set the compression method + * + * @param string $method Compression method's file extension + * + * @return string Archive's filename + */ + public function init($method) + { + $this->update_helper->include_file('includes/functions_compress.' . $this->php_ext); + + $archive_filename = 'update_archive_' . time() . '_' . uniqid(); + $path = $this->phpbb_root_path . 'store/' . $archive_filename . '' . $method; + + if ($method === '.zip') + { + $this->compress = new \compress_zip('w', $path); + } + else + { + $this->compress = new \compress_tar('w', $path, $method); + } + + return $path; + } + + /** + * Close archive writing process + */ + public function close() + { + $this->compress->close(); + } + + /** + * {@inheritdoc} + */ + public function delete_file($path_to_file) + { + // We do absolutely nothing here + } + + /** + * {@inheritdoc} + */ + public function create_new_file($path_to_file_to_create, $source, $create_from_content = false) + { + if ($create_from_content) + { + $this->compress->add_data($source, $path_to_file_to_create); + } + else + { + $this->compress->add_custom_file($source, $path_to_file_to_create); + } + } + + /** + * {@inheritdoc} + */ + public function update_file($path_to_file_to_update, $source, $create_from_content = false) + { + // Both functions are identical here + $this->create_new_file($path_to_file_to_update, $source, $create_from_content); + } + + /** + * {@inheritdoc} + */ + public function get_method_name() + { + return 'compression'; + } +} diff --git a/phpBB/phpbb/install/helper/file_updater/factory.php b/phpBB/phpbb/install/helper/file_updater/factory.php new file mode 100644 index 0000000000..d3a2f22782 --- /dev/null +++ b/phpBB/phpbb/install/helper/file_updater/factory.php @@ -0,0 +1,69 @@ + + * @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\helper\file_updater; + +use phpbb\di\service_collection; +use phpbb\install\exception\file_updater_failure_exception; + +/** + * File updater factory + */ +class factory +{ + /** + * @var array + */ + protected $file_updaters; + + /** + * Constructor + * + * @param service_collection $collection File updater service collection + */ + public function __construct(service_collection $collection) + { + foreach ($collection as $service) + { + $this->register($service); + } + } + + /** + * Register updater object + * + * @param file_updater_interface $updater Updater object + */ + public function register(file_updater_interface $updater) + { + $name = $updater->get_method_name(); + $this->file_updaters[$name] = $updater; + } + + /** + * Returns file updater object + * + * @param string $name Name of the updater method + * + * @throws file_updater_failure_exception When the specified file updater does not exist + */ + public function get($name) + { + if (!isset($this->file_updaters[$name])) + { + throw new file_updater_failure_exception(); + } + + return $this->file_updaters[$name]; + } +} diff --git a/phpBB/phpbb/install/helper/file_updater/file_updater.php b/phpBB/phpbb/install/helper/file_updater/file_updater.php new file mode 100644 index 0000000000..8ebbf64253 --- /dev/null +++ b/phpBB/phpbb/install/helper/file_updater/file_updater.php @@ -0,0 +1,210 @@ + + * @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\helper\file_updater; + +use phpbb\filesystem\exception\filesystem_exception; +use phpbb\filesystem\filesystem; +use phpbb\install\exception\file_updater_failure_exception; + +/** + * File updater for direct filesystem access + */ +class file_updater implements file_updater_interface +{ + /** + * @var filesystem + */ + protected $filesystem; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param filesystem $filesystem + * @param string $phpbb_root_path + */ + public function __construct(filesystem $filesystem, $phpbb_root_path) + { + $this->filesystem = $filesystem; + $this->phpbb_root_path = $phpbb_root_path; + } + + /** + * {@inheritdoc} + * + * @throws file_updater_failure_exception When the file is not writable + * @throws filesystem_exception When the filesystem class fails + */ + public function delete_file($path_to_file) + { + $this->filesystem->remove($this->phpbb_root_path . $path_to_file); + } + + /** + * {@inheritdoc} + * + * @throws file_updater_failure_exception When the file is not writable + * @throws filesystem_exception When the filesystem class fails + */ + public function create_new_file($path_to_file_to_create, $source, $create_from_content = false) + { + $path_to_file_to_create = $this->phpbb_root_path . $path_to_file_to_create; + + $dir = dirname($path_to_file_to_create); + if (!$this->filesystem->exists($dir)) + { + $this->make_dir($dir); + } + + $original_dir_perms = false; + + if (!$this->filesystem->is_writable($dir)) + { + // Extract last 9 bits we actually need + $original_dir_perms = @fileperms($dir) & 511; + $this->filesystem->phpbb_chmod($dir, filesystem::CHMOD_ALL); + } + + if (!$create_from_content) + { + try + { + $this->filesystem->copy($source, $path_to_file_to_create); + } + catch (filesystem_exception $e) + { + $this->write_file($path_to_file_to_create, $source, $create_from_content); + } + } + else + { + $this->write_file($path_to_file_to_create, $source, $create_from_content); + } + + if ($original_dir_perms !== false) + { + $this->filesystem->phpbb_chmod($dir, $original_dir_perms); + } + } + + /** + * {@inheritdoc} + * + * @throws file_updater_failure_exception When the file is not writable + * @throws filesystem_exception When the filesystem class fails + */ + public function update_file($path_to_file_to_update, $source, $create_from_content = false) + { + $path_to_file_to_update = $this->phpbb_root_path . $path_to_file_to_update; + $original_file_perms = false; + + if (!$this->filesystem->is_writable($path_to_file_to_update)) + { + // Extract last 9 bits we actually need + $original_file_perms = @fileperms($path_to_file_to_update) & 511; + $this->filesystem->phpbb_chmod($path_to_file_to_update, filesystem::CHMOD_WRITE); + } + + if (!$create_from_content) + { + try + { + $this->filesystem->copy($source, $path_to_file_to_update, true); + } + catch (filesystem_exception $e) + { + $this->write_file($path_to_file_to_update, $source, $create_from_content); + } + } + else + { + $this->write_file($path_to_file_to_update, $source, $create_from_content); + } + + if ($original_file_perms !== false) + { + $this->filesystem->phpbb_chmod($path_to_file_to_update, $original_file_perms); + } + } + + /** + * Creates directory structure + * + * @param string $path Path to the directory where the file should be placed (and non-existent) + */ + private function make_dir($path) + { + if (is_dir($path)) + { + return; + } + + $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); + $dirs = explode('/', $path); + $dirs_to_create = array(); + + do + { + $path .= '../'; + $dirs_to_create[] = array_pop($dirs); + } + while (!is_dir($path)); + + foreach ($dirs_to_create as $directory) + { + $path .= $directory; + $this->filesystem->mkdir($path, 493); // 493 === 0755 + $path .= '/'; + } + } + + /** + * Fallback function for file writing + * + * @param string $path_to_file Path to the file's location + * @param string $source Path to file to copy or string with the new file's content + * @param bool|false $create_from_content Whether or not to use $source as the content, false by default + * + * @throws file_updater_failure_exception When the file is not writable + */ + private function write_file($path_to_file, $source, $create_from_content = false) + { + if (!$create_from_content) + { + $source = @file_get_contents($source); + } + + $file_pointer = @fopen($path_to_file, 'w'); + + if (!is_resource($file_pointer)) + { + throw new file_updater_failure_exception(); + } + + @fwrite($file_pointer, $source); + @fclose($file_pointer); + } + + /** + * {@inheritdoc} + */ + public function get_method_name() + { + return 'direct_file'; + } +} diff --git a/phpBB/phpbb/install/helper/file_updater/file_updater_interface.php b/phpBB/phpbb/install/helper/file_updater/file_updater_interface.php new file mode 100644 index 0000000000..b13d7c9fe1 --- /dev/null +++ b/phpBB/phpbb/install/helper/file_updater/file_updater_interface.php @@ -0,0 +1,49 @@ + + * @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\helper\file_updater; + +interface file_updater_interface +{ + /** + * Deletes a file + * + * @param string $path_to_file Path to the file to delete + */ + public function delete_file($path_to_file); + + /** + * Creates a new file + * + * @param string $path_to_file_to_create Path to the new file's location + * @param string $source Path to file to copy or string with the new file's content + * @param bool $create_from_content Whether or not to use $source as the content, false by default + */ + public function create_new_file($path_to_file_to_create, $source, $create_from_content = false); + + /** + * Update file + * + * @param string $path_to_file_to_update Path to the file's location + * @param string $source Path to file to copy or string with the new file's content + * @param bool $create_from_content Whether or not to use $source as the content, false by default + */ + public function update_file($path_to_file_to_update, $source, $create_from_content = false); + + /** + * Returns the name of the file updater method + * + * @return string + */ + public function get_method_name(); +} diff --git a/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php b/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php new file mode 100644 index 0000000000..258a035768 --- /dev/null +++ b/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php @@ -0,0 +1,136 @@ + + * @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\helper\file_updater; + +use phpbb\install\helper\update_helper; + +/** + * File updater for FTP updates + */ +class ftp_file_updater implements file_updater_interface +{ + /** + * @var \transfer + */ + protected $transfer; + + /** + * @var update_helper + */ + protected $update_helper; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * Constructor + * + * @param update_helper $update_helper + * @param string $phpbb_root_path + * @param string $php_ext + */ + public function __constructor(update_helper $update_helper, $phpbb_root_path, $php_ext) + { + $this->transfer = null; + $this->update_helper = $update_helper; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * Initialize FTP connection + * + * @param string $method + * @param string $host + * @param string $user + * @param string $pass + * @param string $path + * @param int $port + * @param int $timeout + */ + public function init($method, $host, $user, $pass, $path, $port, $timeout) + { + $this->update_helper->include_file('includes/functions_transfer.' . $this->php_ext); + $this->transfer = new $method($host, $user, $pass, $path, $port, $timeout); + $this->transfer->open_session(); + } + + /** + * Close FTP session + */ + public function close() + { + $this->transfer->close_session(); + } + + /** + * {@inheritdoc} + */ + public function delete_file($path_to_file) + { + $this->transfer->delete_file($path_to_file); + } + + /** + * {@inheritdoc} + */ + public function create_new_file($path_to_file_to_create, $source, $create_from_content = false) + { + $dirname = dirname($path_to_file_to_create); + + if ($dirname && !file_exists($this->phpbb_root_path . $dirname)) + { + $this->transfer->make_dir($dirname); + } + + if ($create_from_content) + { + $this->transfer->write_file($path_to_file_to_create, $source); + } + else + { + $this->transfer->copy_file($path_to_file_to_create, $source); + } + } + + /** + * {@inheritdoc} + */ + public function update_file($path_to_file_to_update, $source, $create_from_content = false) + { + if ($create_from_content) + { + $this->transfer->write_file($path_to_file_to_update, $source); + } + else + { + $this->transfer->copy_file($path_to_file_to_update, $source); + } + } + + /** + * {@inheritdoc} + */ + public function get_method_name() + { + return 'ftp'; + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index fa628f3365..1342ffa30f 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -13,11 +13,19 @@ namespace phpbb\install\helper\iohandler; +use phpbb\path_helper; +use phpbb\routing\router; + /** * Input-Output handler for the AJAX frontend */ class ajax_iohandler extends iohandler_base { + /** + * @var path_helper + */ + protected $path_helper; + /** * @var \phpbb\request\request_interface */ @@ -28,6 +36,16 @@ class ajax_iohandler extends iohandler_base */ protected $template; + /** + * @var router + */ + protected $router; + + /** + * @var string + */ + protected $file_status; + /** * @var string */ @@ -48,19 +66,30 @@ class ajax_iohandler extends iohandler_base */ protected $cookies; + /** + * @var array + */ + protected $download; + /** * Constructor * + * @param path_helper $path_helper * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine + * @param router $router Router */ - public function __construct(\phpbb\request\request_interface $request, \phpbb\template\template $template) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router) { + $this->path_helper = $path_helper; $this->request = $request; + $this->router = $router; $this->template = $template; $this->form = ''; $this->nav_data = array(); $this->cookies = array(); + $this->download = array(); + $this->file_status = ''; parent::__construct(); } @@ -102,13 +131,13 @@ class ajax_iohandler extends iohandler_base */ public function add_user_form_group($title, $form) { - $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); - $this->template->assign_block_vars('options', array( 'LEGEND' => $this->language->lang($title), 'S_LEGEND' => true, )); + $not_button_form = false; + foreach ($form as $input_name => $input_options) { if (!isset($input_options['type'])) @@ -117,6 +146,7 @@ class ajax_iohandler extends iohandler_base } $tpl_ary = array(); + $not_button_form = ($input_options['type'] !== 'submit' || $not_button_form); $tpl_ary['TYPE'] = $input_options['type']; $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); @@ -136,7 +166,7 @@ class ajax_iohandler extends iohandler_base $tpl_ary['S_EXPLAIN'] = true; } - if (in_array($input_options['type'], array('select', 'radio'))) + if (in_array($input_options['type'], array('select', 'radio'), true)) { for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) { @@ -149,9 +179,12 @@ class ajax_iohandler extends iohandler_base $tpl_ary['OPTIONS'] = $input_options['options']; } - $this->template->assign_block_vars('options', $tpl_ary); + $block_name = ($input_options['type'] === 'submit') ? 'submit_buttons' : 'options'; + $this->template->assign_block_vars($block_name, $tpl_ary); } + $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form); + $this->template->set_filenames(array( 'form_install' => 'installer_form.html', )); @@ -185,14 +218,27 @@ class ajax_iohandler extends iohandler_base 'warnings' => $this->warnings, 'logs' => $this->logs, 'success' => $this->success, + 'download' => $this->download, ); + $this->errors = array(); + $this->warnings = array(); + $this->logs = array(); + $this->success = array(); + $this->download = array(); + if (!empty($this->form)) { $json_array['form'] = $this->form; $this->form = ''; } + if (!empty($this->file_status)) + { + $json_array['file_status'] = $this->file_status; + $this->file_status = ''; + } + // If current task name is set, we push progress message to the client side if (!empty($this->current_task_name)) { @@ -201,19 +247,20 @@ class ajax_iohandler extends iohandler_base 'task_num' => $this->current_task_progress, 'task_count' => $this->task_progress_count, ); + + if ($this->restart_progress_bar) + { + $json_array['progress']['restart'] = 1; + $this->restart_progress_bar = false; + } } if (!empty($this->nav_data)) { $json_array['nav'] = $this->nav_data; + $this->nav_data = array(); } - $this->errors = array(); - $this->warnings = array(); - $this->logs = array(); - $this->success = array(); - $this->nav_data = array(); - if ($this->request_client_refresh) { $json_array['refresh'] = true; @@ -275,6 +322,56 @@ class ajax_iohandler extends iohandler_base ); } + /** + * {@inheritdoc} + */ + public function add_download_link($route, $title, $msg = null) + { + $link_properties = array( + 'href' => $this->router->generate($route), + 'title' => $this->language->lang($title), + 'download' => $this->language->lang('DOWNLOAD'), + ); + + if ($msg !== null) + { + $link_properties['msg'] = htmlspecialchars_decode($this->language->lang($msg)); + } + + $this->download[] = $link_properties; + } + + /** + * {@inheritdoc} + */ + public function render_update_file_status($status_array) + { + $this->template->assign_vars(array( + 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . 'adm/images/', + )); + + foreach ($status_array as $block => $list) + { + foreach ($list as $filename) + { + $dirname = dirname($filename); + + $this->template->assign_block_vars($block, array( + 'STATUS' => $block, + 'FILENAME' => $filename, + 'DIR_PART' => (!empty($dirname) && $dirname !== '.') ? dirname($filename) . '/' : false, + 'FILE_PART' => basename($filename), + )); + } + } + + $this->template->set_filenames(array( + 'file_status' => 'installer_update_file_status.html', + )); + + $this->file_status = $this->template->assign_display('file_status'); + } + /** * Callback function for language replacing * diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index c5b2bb06bc..abdd730d2e 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -181,9 +181,12 @@ class cli_iohandler extends iohandler_base } } - public function set_task_count($task_count) + /** + * {@inheritdoc} + */ + public function set_task_count($task_count, $restart = false) { - parent::set_task_count($task_count); + parent::set_task_count($task_count, $restart); if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) { @@ -206,6 +209,9 @@ class cli_iohandler extends iohandler_base } } + /** + * {@inheritdoc} + */ public function set_progress($task_lang_key, $task_number) { parent::set_progress($task_lang_key, $task_number); @@ -262,4 +268,18 @@ class cli_iohandler extends iohandler_base public function set_cookie($cookie_name, $cookie_value) { } + + /** + * {@inheritdoc} + */ + public function add_download_link($route, $title, $msg = null) + { + } + + /** + * {@inheritdoc} + */ + public function render_update_file_status($status_array) + { + } } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index 006411f1e3..530cb4766b 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -80,6 +80,7 @@ abstract class iohandler_base implements iohandler_interface $this->logs = array(); $this->success = array(); + $this->restart_progress_bar = false; $this->task_progress_count = 0; $this->current_task_progress = 0; $this->current_task_name = ''; @@ -130,9 +131,10 @@ abstract class iohandler_base implements iohandler_interface /** * {@inheritdoc} */ - public function set_task_count($task_count) + public function set_task_count($task_count, $restart = false) { $this->task_progress_count = $task_count; + $this->restart_progress_bar = $restart; } /** diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index 5f5f8499d6..00aab3283e 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -127,8 +127,9 @@ interface iohandler_interface * Sets the number of tasks belonging to the installer in the current mode. * * @param int $task_count Number of tasks + * @param bool $restart Whether or not to restart the progress bar, false by default */ - public function set_task_count($task_count); + public function set_task_count($task_count, $restart = false); /** * Sets the progress information @@ -164,6 +165,22 @@ interface iohandler_interface */ public function finish_progress($message_lang_key); + /** + * Adds a download link + * + * @param string $route Route for the link + * @param string $title Language key for the title + * @param string|null|array $msg Language key for the message + */ + public function add_download_link($route, $title, $msg = null); + + /** + * Renders the status of update files + * + * @param array $status_array Array containing files in groups to render + */ + public function render_update_file_status($status_array); + /** * Sends and sets cookies * diff --git a/phpBB/phpbb/install/helper/navigation/update_navigation.php b/phpBB/phpbb/install/helper/navigation/update_navigation.php new file mode 100644 index 0000000000..3d239c3451 --- /dev/null +++ b/phpBB/phpbb/install/helper/navigation/update_navigation.php @@ -0,0 +1,80 @@ + + * @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\helper\navigation; + +use phpbb\install\helper\install_helper; + +class update_navigation implements navigation_interface +{ + /** + * @var install_helper + */ + private $install_helper; + + /** + * Constructor + * + * @param install_helper $install_helper + */ + public function __construct(install_helper $install_helper) + { + $this->install_helper = $install_helper; + } + + /** + * {@inheritdoc} + */ + public function get() + { + if (!$this->install_helper->is_phpbb_installed()) + { + return array(); + } + + return array( + 'update' => array( + 'label' => 'UPDATE', + 'route' => 'phpbb_installer_update', + 'order' => 1, + array( + 'introduction' => array( + 'label' => 'INTRODUCTION_TITLE', + 'stage' => true, + 'order' => 0, + ), + 'requirements' => array( + 'label' => 'STAGE_REQUIREMENTS', + 'stage' => true, + 'order' => 1, + ), + 'obtain_data' => array( + 'label' => 'STAGE_OBTAIN_DATA', + 'stage' => true, + 'order' => 2, + ), + 'update_files' => array( + 'label' => 'STAGE_UPDATE_FILES', + 'stage' => true, + 'order' => 3, + ), + 'update_database' => array( + 'label' => 'STAGE_UPDATE_DATABASE', + 'stage' => true, + 'order' => 4, + ), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/install/helper/update_helper.php b/phpBB/phpbb/install/helper/update_helper.php new file mode 100644 index 0000000000..2a3e6ceb0a --- /dev/null +++ b/phpBB/phpbb/install/helper/update_helper.php @@ -0,0 +1,118 @@ + + * @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\helper; + +/** + * General helper functionality for the updater + */ +class update_helper +{ + /** + * @var string + */ + protected $path_to_new_files; + + /** + * @var string + */ + protected $path_to_old_files; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param string $phpbb_root_path + */ + public function __construct($phpbb_root_path) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->path_to_new_files = $phpbb_root_path . 'install/update/new/'; + $this->path_to_old_files = $phpbb_root_path . 'install/update/old/'; + } + + /** + * Returns path to new update files + * + * @return string + */ + public function get_path_to_new_update_files() + { + return $this->path_to_new_files; + } + + /** + * Returns path to new update files + * + * @return string + */ + public function get_path_to_old_update_files() + { + return $this->path_to_old_files; + } + + /** + * Includes the updated file if available + * + * @param string $filename Path to the file relative to phpBB root path + */ + public function include_file($filename) + { + if (!is_file($this->phpbb_root_path . $filename)) + { + return; + } + + if (is_file($this->path_to_new_files . $filename)) + { + include_once($this->path_to_new_files . $filename); + } + else + { + include_once($this->phpbb_root_path . $filename); + } + } + + /** + * Customized version_compare() + * + * @param string $version_number1 + * @param string $version_number2 + * @param string|null $operator + * @return int|bool The returned value is identical to the PHP build-in function version_compare() + */ + public function phpbb_version_compare($version_number1, $version_number2, $operator = null) + { + if ($operator === null) + { + $result = version_compare( + str_replace('rc', 'RC', strtolower($version_number1)), + str_replace('rc', 'RC', strtolower($version_number2)) + ); + } + else + { + $result = version_compare( + str_replace('rc', 'RC', strtolower($version_number1)), + str_replace('rc', 'RC', strtolower($version_number2)), + $operator + ); + } + + return $result; + } +} diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 755edb5297..8a0374b1f0 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -15,6 +15,7 @@ namespace phpbb\install; use phpbb\di\ordered_service_collection; use phpbb\install\exception\installer_config_not_writable_exception; +use phpbb\install\exception\jump_to_restart_point_exception; use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; @@ -94,6 +95,7 @@ class installer // Variable used to check if the install process have been finished $install_finished = false; $fail_cleanup = false; + $send_refresh = false; // We are installing something, so the introduction stage can go now... $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction')); @@ -142,7 +144,7 @@ class installer $this->install_config->set_active_module($name); // Run until there are available resources - if ($this->install_config->get_time_remaining() <= 0 && $this->install_config->get_memory_remaining() <= 0) + if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { throw new resource_limit_reached_exception(); } @@ -208,7 +210,12 @@ class installer } catch (resource_limit_reached_exception $e) { - // Do nothing + $send_refresh = true; + } + catch (jump_to_restart_point_exception $e) + { + $this->install_config->jump_to_restart_point($e->get_restart_point_name()); + $send_refresh = true; } catch (\Exception $e) { @@ -222,9 +229,10 @@ class installer // Send install finished message $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count()); } - else if (!$fail_cleanup) + else if ($send_refresh) { $this->iohandler->request_refresh(); + $this->iohandler->send_response(); } // Save install progress diff --git a/phpBB/phpbb/install/module/obtain_data/install_module.php b/phpBB/phpbb/install/module/obtain_data/install_module.php new file mode 100644 index 0000000000..deb4be90d8 --- /dev/null +++ b/phpBB/phpbb/install/module/obtain_data/install_module.php @@ -0,0 +1,33 @@ + + * @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 install_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/module.php b/phpBB/phpbb/install/module/obtain_data/module.php deleted file mode 100644 index 0e008796c5..0000000000 --- a/phpBB/phpbb/install/module/obtain_data/module.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @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 index b2250e524b..41616e995a 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php @@ -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; 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 index 821c221123..0726cc449c 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php @@ -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(); } /** diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_file_updater_method.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_file_updater_method.php new file mode 100644 index 0000000000..9bcb73a6a9 --- /dev/null +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_file_updater_method.php @@ -0,0 +1,168 @@ + + * @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 ''; + } +} diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php new file mode 100644 index 0000000000..0cb809154e --- /dev/null +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php @@ -0,0 +1,113 @@ + + * @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 ''; + } +} diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php new file mode 100644 index 0000000000..a4d362a0f1 --- /dev/null +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php @@ -0,0 +1,164 @@ + + * @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 ''; + } +} diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php new file mode 100644 index 0000000000..6a98721e77 --- /dev/null +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php @@ -0,0 +1,103 @@ + + * @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 ''; + } +} diff --git a/phpBB/phpbb/install/module/obtain_data/update_module.php b/phpBB/phpbb/install/module/obtain_data/update_module.php new file mode 100644 index 0000000000..c2f9019d34 --- /dev/null +++ b/phpBB/phpbb/install/module/obtain_data/update_module.php @@ -0,0 +1,33 @@ + + * @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; + } +} diff --git a/phpBB/phpbb/install/module/requirements/abstract_requirements_module.php b/phpBB/phpbb/install/module/requirements/abstract_requirements_module.php new file mode 100644 index 0000000000..26593e6777 --- /dev/null +++ b/phpBB/phpbb/install/module/requirements/abstract_requirements_module.php @@ -0,0 +1,106 @@ + + * @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\requirements; + +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\exception\user_interaction_required_exception; +use phpbb\install\module_base; + +/** + * Base class for requirements installer module + */ +abstract class abstract_requirements_module extends module_base +{ + public function run() + { + $tests_passed = true; + + // Recover install progress + $task_name = $this->recover_progress(); + $task_found = false; + + /** + * @var string $name ID of the service + * @var \phpbb\install\task_interface $task Task object + */ + foreach ($this->task_collection as $name => $task) + { + // Run until there are available resources + if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) + { + throw new resource_limit_reached_exception(); + } + + // Skip forward until the next task is reached + if (!$task_found) + { + if ($name === $task_name || empty($task_name)) + { + $task_found = true; + + if ($name === $task_name) + { + continue; + } + } + else + { + continue; + } + } + + // Check if we can run the task + if (!$task->is_essential() && !$task->check_requirements()) + { + continue; + } + + if ($this->allow_progress_bar) + { + $this->install_config->increment_current_task_progress(); + } + + $test_result = $task->run(); + $tests_passed = ($tests_passed) ? $test_result : false; + } + + // Module finished, so clear task progress + $this->install_config->set_finished_task(''); + + // Check if tests have failed + if (!$tests_passed) + { + // If requirements are not met, exit form installer + // Set up UI for retesting + $this->iohandler->add_user_form_group('', array( + 'install' => array( + 'label' => 'RETEST_REQUIREMENTS', + 'type' => 'submit', + ), + )); + + // Send the response and quit + $this->iohandler->send_response(); + throw new user_interaction_required_exception(); + } + } + + /** + * {@inheritdoc} + */ + public function get_step_count() + { + return 0; + } +} diff --git a/phpBB/phpbb/install/module/requirements/install_module.php b/phpBB/phpbb/install/module/requirements/install_module.php new file mode 100644 index 0000000000..ed0c5fbd94 --- /dev/null +++ b/phpBB/phpbb/install/module/requirements/install_module.php @@ -0,0 +1,25 @@ + + * @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\requirements; + +class install_module extends abstract_requirements_module +{ + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('install', 0, 'requirements'); + } +} diff --git a/phpBB/phpbb/install/module/requirements/module.php b/phpBB/phpbb/install/module/requirements/module.php deleted file mode 100644 index 79a031bad9..0000000000 --- a/phpBB/phpbb/install/module/requirements/module.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @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\requirements; - -use phpbb\install\exception\resource_limit_reached_exception; -use phpbb\install\exception\user_interaction_required_exception; - -class module extends \phpbb\install\module_base -{ - public function run() - { - $tests_passed = true; - - // Recover install progress - $task_name = $this->recover_progress(); - $task_found = false; - - /** - * @var string $name ID of the service - * @var \phpbb\install\task_interface $task Task object - */ - foreach ($this->task_collection as $name => $task) - { - // Run until there are available resources - if ($this->install_config->get_time_remaining() <= 0 && $this->install_config->get_memory_remaining() <= 0) - { - throw new resource_limit_reached_exception(); - } - - // Skip forward until the next task is reached - if (!$task_found) - { - if ($name === $task_name || empty($task_name)) - { - $task_found = true; - - if ($name === $task_name) - { - continue; - } - } - else - { - continue; - } - } - - // Check if we can run the task - if (!$task->is_essential() && !$task->check_requirements()) - { - continue; - } - - if ($this->allow_progress_bar) - { - $this->install_config->increment_current_task_progress(); - } - - $test_result = $task->run(); - $tests_passed = ($tests_passed) ? $test_result : false; - } - - // Module finished, so clear task progress - $this->install_config->set_finished_task(''); - - // Check if tests have failed - if (!$tests_passed) - { - // If requirements are not met, exit form installer - // Set up UI for retesting - $this->iohandler->add_user_form_group('', array( - 'install' => array( - 'label' => 'RETEST_REQUIREMENTS', - 'type' => 'submit', - ), - )); - - // Send the response and quit - $this->iohandler->send_response(); - throw new user_interaction_required_exception(); - } - } - - /** - * {@inheritdoc} - */ - public function get_step_count() - { - return 0; - } - - /** - * {@inheritdoc} - */ - public function get_navigation_stage_path() - { - return array('install', 0, 'requirements'); - } -} diff --git a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php index ab6b1091e2..2aec3915e0 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php +++ b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php @@ -50,11 +50,9 @@ class check_filesystem extends \phpbb\install\task_base * @param \phpbb\install\helper\iohandler\iohandler_interface $response response helper * @param string $phpbb_root_path relative path to phpBB's root * @param string $php_ext extension of php files + * @param bool $check_config_php Whether or not to check if config.php is writable */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\iohandler\iohandler_interface $response, - $phpbb_root_path, - $php_ext) + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \phpbb\install\helper\iohandler\iohandler_interface $response, $phpbb_root_path, $php_ext, $check_config_php = true) { parent::__construct(true); @@ -87,12 +85,16 @@ class check_filesystem extends \phpbb\install\task_base 'failable' => true, 'is_file' => false, ), - array( + ); + + if ($check_config_php) + { + $this->files_to_check[] = array( 'path' => "config.$php_ext", 'failable' => false, 'is_file' => true, - ), - ); + ); + } } /** diff --git a/phpBB/phpbb/install/module/requirements/task/check_update.php b/phpBB/phpbb/install/module/requirements/task/check_update.php new file mode 100644 index 0000000000..c986c76810 --- /dev/null +++ b/phpBB/phpbb/install/module/requirements/task/check_update.php @@ -0,0 +1,185 @@ + + * @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\requirements\task; + +use phpbb\filesystem\filesystem; +use phpbb\install\helper\container_factory; +use phpbb\install\helper\iohandler\iohandler_interface; +use phpbb\install\helper\update_helper; +use phpbb\install\task_base; + +/** + * Check the availability of updater files and update version + */ +class check_update extends task_base +{ + /** + * @var \phpbb\config\db + */ + protected $config; + + /** + * @var filesystem + */ + protected $filesystem; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** + * @var update_helper + */ + protected $update_helper; + + /** + * @var \phpbb\version_helper + */ + protected $version_helper; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * @var bool + */ + protected $tests_passed; + + /** + * Constructor + * + * @param container_factory $container + * @param filesystem $filesystem + * @param iohandler_interface $iohandler + * @param update_helper $update_helper + * @param string $phpbb_root_path + * @param string $php_ext + */ + public function __construct(container_factory $container, filesystem $filesystem, iohandler_interface $iohandler, update_helper $update_helper, $phpbb_root_path, $php_ext) + { + $this->filesystem = $filesystem; + $this->iohandler = $iohandler; + $this->update_helper = $update_helper; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->tests_passed = true; + + $this->config = $container->get('config'); + $this->version_helper = $container->get('version_helper'); + + parent::__construct(true); + } + + /** + * Sets $this->tests_passed + * + * @param bool $is_passed + */ + protected function set_test_passed($is_passed) + { + // If one test failed, tests_passed should be false + $this->tests_passed = $this->tests_passed && $is_passed; + } + + /** + * {@inheritdoc} + */ + public function run() + { + // Array of update files + $update_files = array( + $this->phpbb_root_path . 'install/update', + $this->phpbb_root_path . 'install/update/index.' . $this->php_ext, + ); + + // Check for a valid update directory + if (!$this->filesystem->exists($update_files) || !$this->filesystem->is_readable($update_files)) + { + $this->iohandler->add_error_message('UPDATE_FILES_NOT_FOUND'); + $this->set_test_passed(false); + + // If there are no update files, we can't check the version + return false; + } + + // Recover version numbers + $update_info = array(); + @include($this->phpbb_root_path . 'install/update/index.' . $this->php_ext); + $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; + $update_version = false; + + if ($info !== false) + { + $update_version = (!empty($info['version']['to'])) ? trim($info['version']['to']) : false; + } + + // Get current and latest version + try + { + $latest_version = $this->version_helper->get_latest_on_current_branch(true); + } + catch (\RuntimeException $e) + { + $latest_version = $update_version; + } + + $current_version = (!empty($this->config['version_update_from'])) ? $this->config['version_update_from'] : $this->config['version']; + + // Check if the update package + if (!$this->update_helper->phpbb_version_compare($current_version, $update_version, '<')) + { + $this->iohandler->add_error_message('NO_UPDATE_FILES_UP_TO_DATE'); + $this->tests_passed = false; + } + + // Check if the update package works with the installed version + if (empty($info['version']['from']) || $info['version']['from'] !== $current_version) + { + $this->iohandler->add_error_message(array('INCOMPATIBLE_UPDATE_FILES', $current_version, $info['version']['from'], $update_version)); + $this->tests_passed = false; + } + + // check if this is the latest update package + if ($this->update_helper->phpbb_version_compare($update_version, $latest_version, '<')) + { + $this->iohandler->add_warning_message(array('OLD_UPDATE_FILES', $info['version']['from'], $update_version, $latest_version)); + } + + return $this->tests_passed; + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} diff --git a/phpBB/phpbb/install/module/requirements/update_module.php b/phpBB/phpbb/install/module/requirements/update_module.php new file mode 100644 index 0000000000..223d12faf3 --- /dev/null +++ b/phpBB/phpbb/install/module/requirements/update_module.php @@ -0,0 +1,25 @@ + + * @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\requirements; + +class update_module extends abstract_requirements_module +{ + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('update', 0, 'requirements'); + } +} diff --git a/phpBB/phpbb/install/module/update_database/module.php b/phpBB/phpbb/install/module/update_database/module.php new file mode 100644 index 0000000000..ee38afe17d --- /dev/null +++ b/phpBB/phpbb/install/module/update_database/module.php @@ -0,0 +1,33 @@ + + * @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\update_database; + +class module extends \phpbb\install\module_base +{ + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('update', 0, 'update_database'); + } + + /** + * {@inheritdoc} + */ + public function get_step_count() + { + return 0; + } +} diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php new file mode 100644 index 0000000000..2d640134a3 --- /dev/null +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -0,0 +1,212 @@ + + * @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\update_database\task; + +use phpbb\db\migration\exception; +use phpbb\db\output_handler\installer_migrator_output_handler; +use phpbb\db\output_handler\log_wrapper_migrator_output_handler; +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\exception\user_interaction_required_exception; +use phpbb\install\task_base; + +/** + * Database updater task + */ +class update extends task_base +{ + /** + * @var \phpbb\cache\driver\driver_interface + */ + protected $cache; + + /** + * @var \phpbb\config\config + */ + protected $config; + + /** + * @var \phpbb\extension\manager + */ + protected $extension_manager; + + /** + * @var \phpbb\filesystem\filesystem + */ + protected $filesystem; + + /** + * @var \phpbb\install\helper\config + */ + protected $installer_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var \phpbb\log\log + */ + protected $log; + + /** + * @var \phpbb\db\migrator + */ + protected $migrator; + + /** + * @var \phpbb\user + */ + protected $user; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param \phpbb\install\helper\container_factory $container + * @param \phpbb\filesystem\filesystem $filesystem + * @param \phpbb\install\helper\config $installer_config + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler + * @param \phpbb\language\language $language + * @param string $phpbb_root_path + */ + public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\filesystem\filesystem $filesystem, \phpbb\install\helper\config $installer_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, \phpbb\language\language $language, $phpbb_root_path) + { + $this->filesystem = $filesystem; + $this->installer_config = $installer_config; + $this->iohandler = $iohandler; + $this->language = $language; + $this->phpbb_root_path = $phpbb_root_path; + + $this->cache = $container->get('cache.driver'); + $this->config = $container->get('config'); + $this->extension_manager = $container->get('ext.manager'); + $this->log = $container->get('log'); + $this->migrator = $container->get('migrator'); + $this->user = $container->get('user'); + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->language->add_lang('migrator'); + + if (!isset($this->config['version_update_from'])) + { + $this->config->set('version_update_from', $this->config['version']); + } + + $original_version = $this->config['version_update_from']; + + $this->migrator->set_output_handler( + new log_wrapper_migrator_output_handler( + $this->language, + new installer_migrator_output_handler($this->iohandler), + $this->phpbb_root_path . 'store/migrations_' . time() . '.log', + $this->filesystem + ) + ); + + $this->migrator->create_migrations_table(); + + $migrations = $this->extension_manager + ->get_finder() + ->core_path('phpbb/db/migration/data/') + ->extension_directory('/migrations') + ->get_classes(); + + $this->migrator->set_migrations($migrations); + $migration_count = count($migrations); + $this->iohandler->set_task_count($migration_count, true); + $progress_count = $this->installer_config->get('database_update_count', 0); + + while (!$this->migrator->finished()) + { + try + { + $this->migrator->update(); + $progress_count++; + $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); + } + catch (exception $e) + { + $msg = $e->getParameters(); + array_unshift($msg, $e->getMessage()); + + $this->iohandler->add_error_message($msg); + throw new user_interaction_required_exception(); + } + + if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) + { + $this->installer_config->set('database_update_count', $progress_count); + throw new resource_limit_reached_exception(); + } + } + + if ($original_version !== $this->config['version']) + { + $this->log->add( + 'admin', + $this->user->data['user_id'], + $this->user->ip, + 'LOG_UPDATE_DATABASE', + false, + array( + $original_version, + $this->config['version'] + ) + ); + } + + $this->iohandler->finish_progress('INLINE_UPDATE_SUCCESSFUL'); + + $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); + + $this->config->delete('version_update_from'); + + $this->cache->purge(); + + $this->config->increment('assets_version', 1); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} diff --git a/phpBB/phpbb/install/module/update_filesystem/module.php b/phpBB/phpbb/install/module/update_filesystem/module.php new file mode 100644 index 0000000000..157c78a1ac --- /dev/null +++ b/phpBB/phpbb/install/module/update_filesystem/module.php @@ -0,0 +1,33 @@ + + * @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\update_filesystem; + +class module extends \phpbb\install\module_base +{ + /** + * {@inheritdoc} + */ + public function get_navigation_stage_path() + { + return array('update', 0, 'update_files'); + } + + /** + * {@inheritdoc} + */ + public function get_step_count() + { + return 0; + } +} diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php new file mode 100644 index 0000000000..e3e6db6263 --- /dev/null +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -0,0 +1,205 @@ + + * @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\update_filesystem\task; + +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\exception\user_interaction_required_exception; +use phpbb\install\helper\config; +use phpbb\install\helper\container_factory; +use phpbb\install\helper\iohandler\iohandler_interface; +use phpbb\install\helper\update_helper; +use phpbb\install\task_base; + +/** + * Merges user made changes into the files + */ +class diff_files extends task_base +{ + /** + * @var \phpbb\cache\driver\driver_interface + */ + protected $cache; + + /** + * @var config + */ + protected $installer_config; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * @var update_helper + */ + protected $update_helper; + + /** + * Constructor + * + * @param container_factory $container + * @param config $config + * @param iohandler_interface $iohandler + * @param update_helper $update_helper + * @param string $phpbb_root_path + * @param string $php_ext + */ + public function __construct(container_factory $container, config $config, iohandler_interface $iohandler, update_helper $update_helper, $phpbb_root_path, $php_ext) + { + $this->installer_config = $config; + $this->iohandler = $iohandler; + $this->update_helper = $update_helper; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->cache = $container->get('cache.driver'); + + parent::__construct(false); + } + + /** + * {@inheritdoc} + */ + public function check_requirements() + { + $files_to_diff = $this->installer_config->get('update_files', array()); + $files_to_diff = (isset($files_to_diff['update_with_diff'])) ? $files_to_diff['update_with_diff'] : array(); + + return $this->installer_config->get('do_update_files', false) && count($files_to_diff) > 0; + } + + /** + * {@inheritdoc} + */ + public function run() + { + // Include diff engine + $this->update_helper->include_file('includes/diff/diff.' . $this->php_ext); + $this->update_helper->include_file('includes/diff/engine.' . $this->php_ext); + + // Set up basic vars + $old_path = $this->update_helper->get_path_to_old_update_files(); + $new_path = $this->update_helper->get_path_to_new_update_files(); + + $files_to_diff = $this->installer_config->get('update_files', array()); + $files_to_diff = $files_to_diff['update_with_diff']; + + // Set progress bar + $this->iohandler->set_task_count(count($files_to_diff), true); + $this->iohandler->set_progress('UPDATE_FILE_DIFF', 0); + $progress_count = $this->installer_config->get('file_diff_update_count', 0); + + // Recover progress + $progress_key = $this->installer_config->get('differ_progress_key', -1); + $progress_recovered = ($progress_key === -1); + $merge_conflicts = $this->installer_config->get('merge_conflict_list', array()); + + foreach ($files_to_diff as $key => $filename) + { + if ($progress_recovered === false) + { + if ($progress_key === $key) + { + $progress_recovered = true; + } + + continue; + } + + // Read in files' content + $file_contents = array(); + + // Handle the special case when user created a file with the filename that is now new in the core + $file_contents[0] = (file_exists($old_path . $filename)) ? file_get_contents($old_path . $filename) : ''; + + $filenames = array( + $this->phpbb_root_path . $filename, + $new_path . $filename + ); + + foreach ($filenames as $file_to_diff) + { + $file_contents[] = file_get_contents($file_to_diff); + + if ($file_contents[sizeof($file_contents) - 1] === false) + { + $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff)); + unset($file_contents); + throw new user_interaction_required_exception(); + } + } + + $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]); + unset($file_contents); + + // Handle conflicts + if ($diff->get_num_conflicts() !== 0) + { + $merge_conflicts[] = $filename; + } + + // Save merged output + $this->cache->put( + '_file_' . md5($filename), + base64_encode(implode("\n", $diff->merged_output())) + ); + + unset($diff); + + $progress_count++; + $this->iohandler->set_progress('UPDATE_FILE_DIFF', $progress_count); + + if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) + { + // Save differ progress + $this->installer_config->set('differ_progress_key', $key); + $this->installer_config->set('merge_conflict_list', $merge_conflicts); + $this->installer_config->set('file_diff_update_count', $progress_count); + + // Request refresh + throw new resource_limit_reached_exception(); + } + } + + $this->iohandler->finish_progress('ALL_FILES_DIFFED'); + $this->installer_config->set('merge_conflict_list', $merge_conflicts); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php new file mode 100644 index 0000000000..9271e8fd50 --- /dev/null +++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php @@ -0,0 +1,124 @@ + + * @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\update_filesystem\task; + +use phpbb\filesystem\filesystem; +use phpbb\install\exception\jump_to_restart_point_exception; +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 download_updated_files extends task_base +{ + /** + * @var config + */ + protected $installer_config; + + /** + * @var filesystem + */ + protected $filesystem; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** + * Constructor + * + * @param config $config + * @param iohandler_interface $iohandler + * @param filesystem $filesystem + */ + public function __construct(config $config, iohandler_interface $iohandler, filesystem $filesystem) + { + $this->installer_config = $config; + $this->iohandler = $iohandler; + $this->filesystem = $filesystem; + + parent::__construct(false); + } + + /** + * {@inheritdoc} + */ + public function check_requirements() + { + return $this->installer_config->get('do_update_files', false) + && $this->installer_config->get('file_update_method', '') === 'compression'; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if ($this->iohandler->get_input('database_update_submit', false)) + { + // Remove archive + $this->filesystem->remove( + $this->installer_config->get('update_file_archive', null) + ); + + $this->installer_config->set('update_file_archive', null); + } + else if ($this->iohandler->get_input('update_recheck_files_submit', false)) + { + throw new jump_to_restart_point_exception('check_update_files'); + } + else + { + // Render download box + $this->iohandler->add_download_link( + 'phpbb_installer_update_file_download', + 'DOWNLOAD_UPDATE_METHOD', + 'DOWNLOAD_UPDATE_METHOD_EXPLAIN' + ); + + // Add form to continue update + $this->iohandler->add_user_form_group('UPDATE_CONTINUE_UPDATE_PROCESS', array( + 'update_recheck_files_submit' => array( + 'label' => 'UPDATE_RECHECK_UPDATE_FILES', + 'type' => 'submit', + ), + 'database_update_submit' => array( + 'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS', + '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 ''; + } +} diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php new file mode 100644 index 0000000000..9945e61714 --- /dev/null +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -0,0 +1,186 @@ + + * @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\update_filesystem\task; + +use phpbb\filesystem\filesystem; +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\helper\config; +use phpbb\install\helper\iohandler\iohandler_interface; +use phpbb\install\helper\update_helper; +use phpbb\install\task_base; + +/** + * Updater task performing file checking + */ +class file_check extends task_base +{ + /** + * @var filesystem + */ + protected $filesystem; + + /** + * @var config + */ + protected $installer_config; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** + * @var update_helper + */ + protected $update_helper; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Construct + * + * @param filesystem $filesystem + * @param config $config + * @param iohandler_interface $iohandler + * @param update_helper $update_helper + * @param string $phpbb_root_path + */ + public function __construct(filesystem $filesystem, config $config, iohandler_interface $iohandler, update_helper $update_helper, $phpbb_root_path) + { + $this->filesystem = $filesystem; + $this->installer_config = $config; + $this->iohandler = $iohandler; + $this->update_helper = $update_helper; + $this->phpbb_root_path = $phpbb_root_path; + + parent::__construct(false); + } + + /** + * {@inheritdoc} + */ + public function check_requirements() + { + return $this->installer_config->get('do_update_files', false); + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!$this->installer_config->has_restart_point('check_update_files')) + { + $this->installer_config->create_progress_restart_point('check_update_files'); + } + + $old_path = $this->update_helper->get_path_to_old_update_files(); + $new_path = $this->update_helper->get_path_to_new_update_files(); + + $update_info = $this->installer_config->get('update_info', array()); + $file_update_info = $this->installer_config->get('update_files', array()); + + if (empty($update_info)) + { + $root_path = $this->phpbb_root_path; + + $update_info = $this->installer_config->get('update_info_unprocessed', array()); + + $file_update_info = array(); + $file_update_info['update_without_diff'] = $update_info['binary']; + + // Filter out files that are already deleted + $file_update_info['delete'] = array_filter( + $update_info['deleted'], + function ($filename) use ($root_path) + { + return !file_exists($root_path . $filename); + } + ); + } + + $progress_count = $this->installer_config->get('file_check_progress_count', 0); + $task_count = count($update_info['files']); + $this->iohandler->set_task_count($task_count); + $this->iohandler->set_progress('UPDATE_CHECK_FILES', 0); + + foreach ($update_info['files'] as $key => $filename) + { + $old_file = $old_path . $filename; + $new_file = $new_path . $filename; + $file = $this->phpbb_root_path . $filename; + + if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) + { + // Save progress + $this->installer_config->set('update_info', $update_info); + $this->installer_config->set('file_check_progress_count', $progress_count); + $this->installer_config->set('update_files', $file_update_info); + + // Request refresh + throw new resource_limit_reached_exception(); + } + + $progress_count++; + $this->iohandler->set_progress('UPDATE_CHECK_FILES', $progress_count); + + if (!$this->filesystem->exists($file)) + { + $file_update_info['new'][] = $filename; + } + else + { + $file_checksum = md5_file($file); + + if ($file_checksum === md5_file($new_file)) + { + // File already up to date + continue; + } + else if ($this->filesystem->exists($old_file) && $file_checksum === md5_file($old_file)) + { + // No need to diff the file + $file_update_info['update_without_diff'][] = $filename; + } + else + { + $file_update_info['update_with_diff'][] = $filename; + } + } + + unset($update_info['files'][$key]); + } + + $this->installer_config->set('update_files', $file_update_info); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php new file mode 100644 index 0000000000..1c6b9aa058 --- /dev/null +++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php @@ -0,0 +1,168 @@ + + * @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\update_filesystem\task; + +use phpbb\filesystem\filesystem; +use phpbb\install\exception\user_interaction_required_exception; +use phpbb\install\helper\config; +use phpbb\install\helper\container_factory; +use phpbb\install\helper\file_updater\factory; +use phpbb\install\helper\iohandler\iohandler_interface; +use phpbb\install\task_base; + +class show_file_status extends task_base +{ + /** + * @var \phpbb\cache\driver\driver_interface + */ + protected $cache; + + /** + * @var filesystem + */ + protected $filesystem; + + /** + * @var config + */ + protected $installer_config; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\install\helper\file_updater\compression_file_updater + */ + protected $file_updater; + + /** + * Constructor + * + * @param container_factory $container + * @param config $config + * @param iohandler_interface $iohandler + * @param filesystem $filesystem + * @param factory $file_updater_factory + */ + public function __construct(container_factory $container, config $config, iohandler_interface $iohandler, filesystem $filesystem, factory $file_updater_factory) + { + $this->installer_config = $config; + $this->iohandler = $iohandler; + $this->filesystem = $filesystem; + + $this->cache = $container->get('cache.driver'); + + // Initialize compression file updater + $compression_method = $this->installer_config->get('compression_method', ''); + $this->file_updater = $file_updater_factory->get('compression'); + $conflict_archive = $this->file_updater->init($compression_method); + + $this->installer_config->set('update_file_conflict_archive', $conflict_archive); + + parent::__construct(false); + } + + /** + * {@inheritdoc} + */ + public function check_requirements() + { + return $this->installer_config->get('do_update_files', false); + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!$this->iohandler->get_input('submit_continue_file_update', false)) + { + // Handle merge conflicts + $merge_conflicts = $this->installer_config->get('merge_conflict_list', array()); + + // Create archive for merge conflicts + if (!empty($merge_conflicts)) + { + foreach ($merge_conflicts as $filename) + { + $this->file_updater->create_new_file( + $filename, + $this->cache->get('_file_' . md5($filename)), + true + ); + } + + // Render download box + $this->iohandler->add_download_link( + 'phpbb_installer_update_conflict_download', + 'DOWNLOAD_CONFLICTS', + 'DOWNLOAD_CONFLICTS_EXPLAIN' + ); + } + + $this->file_updater->close(); + + // Render update file statuses + $file_update_info = $this->installer_config->get('update_files', array()); + $file_status = array( + 'deleted' => (!isset($file_update_info['delete'])) ? array() : $file_update_info['delete'], + 'new' => (!isset($file_update_info['new'])) ? array() : $file_update_info['new'], + 'conflict' => $this->installer_config->get('merge_conflict_list', array()), + 'modified' => (!isset($file_update_info['update_with_diff'])) ? array() : $file_update_info['update_with_diff'], + 'not_modified' => (!isset($file_update_info['update_without_diff'])) ? array() : $file_update_info['update_without_diff'], + ); + + $this->iohandler->render_update_file_status($file_status); + + // Add form to continue update + $this->iohandler->add_user_form_group('UPDATE_CONTINUE_FILE_UPDATE', array( + 'submit_continue_file_update' => array( + 'label' => 'UPDATE_CONTINUE_FILE_UPDATE', + 'type' => 'submit', + ), + )); + + // Show results to the user + $this->iohandler->send_response(); + throw new user_interaction_required_exception(); + } + else + { + // Remove archive + $this->filesystem->remove( + $this->installer_config->get('update_file_conflict_archive', null) + ); + + $this->installer_config->set('update_file_conflict_archive', null); + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} diff --git a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php new file mode 100644 index 0000000000..747a86281b --- /dev/null +++ b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php @@ -0,0 +1,294 @@ + + * @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\update_filesystem\task; + +use phpbb\exception\runtime_exception; +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\helper\config; +use phpbb\install\helper\container_factory; +use phpbb\install\helper\file_updater\factory; +use phpbb\install\helper\file_updater\file_updater_interface; +use phpbb\install\helper\iohandler\iohandler_interface; +use phpbb\install\helper\update_helper; +use phpbb\install\task_base; + +/** + * File updater task + */ +class update_files extends task_base +{ + /** + * @var \phpbb\cache\driver\driver_interface + */ + protected $cache; + + /** + * @var config + */ + protected $installer_config; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** + * @var factory + */ + protected $factory; + + /** + * @var file_updater_interface + */ + protected $file_updater; + + /** + * @var update_helper + */ + protected $update_helper; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param container_factory $container + * @param config $config + * @param iohandler_interface $iohandler + * @param factory $file_updater_factory + * @param update_helper $update_helper + * @param string $phpbb_root_path + */ + public function __construct(container_factory $container, config $config, iohandler_interface $iohandler, factory $file_updater_factory, update_helper $update_helper, $phpbb_root_path) + { + $this->factory = $file_updater_factory; + $this->installer_config = $config; + $this->iohandler = $iohandler; + $this->update_helper = $update_helper; + $this->phpbb_root_path = $phpbb_root_path; + + $this->cache = $container->get('cache.driver'); + $this->file_updater = null; + + parent::__construct(false); + } + + /** + * {@inheritdoc} + */ + public function check_requirements() + { + return $this->installer_config->get('do_update_files', false); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $new_path = $this->update_helper->get_path_to_new_update_files(); + + $file_update_info = $this->installer_config->get('update_files', array()); + + $update_type_progress = $this->installer_config->get('file_updater_type_progress', ''); + $update_elem_progress = $this->installer_config->get('file_updater_elem_progress', ''); + $type_progress_found = false; + $elem_progress_found = false; + + // Progress bar + $task_count = 0; + foreach ($file_update_info as $sub_array) + { + $task_count += count($sub_array); + } + + // Everything is up to date, so just continue + if ($task_count === 0) + { + return; + } + + $progress_count = $this->installer_config->get('file_update_progress_count', 0); + $this->iohandler->set_task_count($task_count, true); + $this->iohandler->set_progress('UPDATE_UPDATING_FILES', 0); + + $this->file_updater = $this->get_file_updater(); + + // File updater fallback logic + try + { + // Update files + foreach ($file_update_info as $type => $file_update_vector) + { + if (!$type_progress_found) + { + if ($type === $update_type_progress || empty($update_elem_progress)) + { + $type_progress_found = true; + } + else + { + continue; + } + } + + foreach ($file_update_vector as $path) + { + if (!$elem_progress_found) + { + if ($path === $update_elem_progress || empty($update_elem_progress)) + { + $elem_progress_found = true; + } + else + { + continue; + } + } + + switch ($type) + { + case 'delete': + $this->file_updater->delete_file($path); + break; + case 'new': + $this->file_updater->create_new_file($path, $new_path . $path); + break; + case 'update_without_diff': + $this->file_updater->update_file($path, $new_path . $path); + break; + case 'update_with_diff': + $this->file_updater->update_file( + $path, + $this->cache->get('_file_' . md5($path)), + true + ); + break; + } + + // Save progress + $this->installer_config->set('file_updater_type_progress', $type); + $this->installer_config->set('file_updater_elem_progress', $path); + $progress_count++; + $this->iohandler->set_progress('UPDATE_UPDATING_FILES', $progress_count); + + if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) + { + // Request refresh + throw new resource_limit_reached_exception(); + } + } + } + + $this->iohandler->finish_progress('UPDATE_UPDATING_FILES'); + } + catch (runtime_exception $e) + { + if ($e instanceof resource_limit_reached_exception) + { + throw new resource_limit_reached_exception(); + } + + $current_method = $this->installer_config->get('file_update_method', ''); + + // File updater failed, try to fallback to download file update mode + if ($current_method !== 'compression') + { + $this->iohandler->add_warning_message(array( + 'UPDATE_FILE_UPDATER_HAS_FAILED', + $current_method, + 'compression' + )); + $this->installer_config->set('file_update_method', 'compression'); + + // We only want a simple refresh here + throw new resource_limit_reached_exception(); + } + else + { + // Nowhere to fallback to :( + // Due to the way the installer handles fatal errors, we need to throw a low level exception + throw new runtime_exception('UPDATE_FILE_UPDATERS_HAVE_FAILED'); + } + } + + $file_updater_method = $this->installer_config->get('file_update_method', ''); + if ($file_updater_method === 'compression' || $file_updater_method === 'ftp') + { + $this->file_updater->close(); + } + } + + /** + * Get file updater + * + * @param null|string $file_updater_method Name of the file updater to use + * + * @return file_updater_interface File updater + */ + protected function get_file_updater($file_updater_method = null) + { + $file_updater_method = ($file_updater_method === null) ? $this->installer_config->get('file_update_method', '') : $file_updater_method; + + if ($file_updater_method === 'compression') + { + $compression_method = $this->installer_config->get('file_update_compression', ''); + + /** @var \phpbb\install\helper\file_updater\compression_file_updater $file_updater */ + $file_updater = $this->factory->get('compression'); + $archive_path = $file_updater->init($compression_method); + $this->installer_config->set('update_file_archive', $archive_path); + } + else if ($file_updater_method === 'ftp') + { + /** @var \phpbb\install\helper\file_updater\ftp_file_updater $file_updater */ + $file_updater = $this->factory->get('ftp'); + $file_updater->init( + $this->installer_config->get('ftp_method', ''), + $this->installer_config->get('ftp_host', ''), + $this->installer_config->get('ftp_user', ''), + $this->installer_config->get('ftp_pass', ''), + $this->installer_config->get('ftp_path', ''), + $this->installer_config->get('ftp_port', 0), + $this->installer_config->get('ftp_timeout', 10) + ); + } + else + { + /** @var file_updater_interface $file_updater */ + $file_updater = $this->factory->get('direct_file'); + } + + return $file_updater; + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index a933d4987c..fb68c3aca2 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -115,7 +115,7 @@ abstract class module_base implements module_interface foreach ($this->task_collection as $name => $task) { // Run until there are available resources - if ($this->install_config->get_time_remaining() <= 0 && $this->install_config->get_memory_remaining() <= 0) + if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { throw new resource_limit_reached_exception(); } diff --git a/phpBB/phpbb/install/task_base.php b/phpBB/phpbb/install/task_base.php index 5946be8c52..b5199be4af 100644 --- a/phpBB/phpbb/install/task_base.php +++ b/phpBB/phpbb/install/task_base.php @@ -44,7 +44,7 @@ abstract class task_base implements task_interface /** * {@inheritdoc} * - * Overwrite this method if your task is non-essential! + * Note: Overwrite this method if your task is non-essential! */ public function check_requirements() { -- cgit v1.2.1 From 85eb6a0bc0575c687eb43efe61cf206b26b26af8 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:21:56 +0200 Subject: [ticket/14039] Fix language constants and comments PHPBB3-14039 --- phpBB/phpbb/install/controller/archive_download.php | 2 +- phpBB/phpbb/install/helper/config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index 711e1f2f0c..e1f7634963 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -38,7 +38,7 @@ class archive_download /** * Sends response with the merge conflict archive * - * Merge conflicts are always have to be resolved manually, + * Merge conflicts always have to be resolved manually, * so we use a different archive for that. * * @return BinaryFileResponse diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index e73e07208e..0f0840f470 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -262,7 +262,7 @@ class config * * @param string $name Name of the restart point * - * @return bool Returns false if the restart point name is not exist, true otherwise + * @return bool Returns false if the restart point name does not exist, otherwise true */ public function jump_to_restart_point($name) { -- cgit v1.2.1 From afe91fa7d3af0d30389c49428b30c9aeb0fe0916 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:22:19 +0200 Subject: [ticket/14039] Fix T_TEMPLATE_PATH constant PHPBB3-14039 --- phpBB/phpbb/install/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index ef6b8ba3c2..bfa9ec6238 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -271,7 +271,7 @@ class helper 'PAGE_TITLE' => $this->language->lang($page_title), 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images/', 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js', - 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style', + 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style/', 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets/', 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), -- cgit v1.2.1 From 100bb8f27c52b2faffddf2a6926c5d7b49faa421 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:26:41 +0200 Subject: [ticket/14039] Use http_exception instead of die() PHPBB3-14039 --- phpBB/phpbb/install/controller/archive_download.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index e1f7634963..a0f0ba181d 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -13,6 +13,7 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\config; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\ResponseHeaderBag; @@ -49,7 +50,7 @@ class archive_download if (!$filename) { - die ('The requested file is not exist.'); + throw new http_exception(404, 'URL_NOT_FOUND'); } return $this->send_response($filename); @@ -66,7 +67,7 @@ class archive_download if (!$filename) { - die ('The requested file is not exist.'); + throw new http_exception(404, 'URL_NOT_FOUND'); } return $this->send_response($filename); -- cgit v1.2.1 From 6b561b9eae320b06178725fdccbc3e67c0990837 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:30:09 +0200 Subject: [ticket/14039] Use compatibility globals from the update package PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index fd42d53c00..8c007de39f 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -168,6 +168,13 @@ class container_factory } // Get compatibilty globals - require ($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); + if (file_exists($this->phpbb_root_path . 'install/update/new/includes/compatibility_globals.' . $this->php_ext)) + { + require($this->phpbb_root_path . 'install/update/new/includes/compatibility_globals.' . $this->php_ext); + } + else + { + require($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); + } } } -- cgit v1.2.1 From dd8580632765c051ea68b877ce608ca69b5655fe Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 14:00:53 +0200 Subject: [ticket/14039] Fix filesystem file updater's mkdir usage PHPBB3-14039 --- .../phpbb/install/helper/file_updater/file_updater.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/file_updater/file_updater.php b/phpBB/phpbb/install/helper/file_updater/file_updater.php index 8ebbf64253..00cb0d17bd 100644 --- a/phpBB/phpbb/install/helper/file_updater/file_updater.php +++ b/phpBB/phpbb/install/helper/file_updater/file_updater.php @@ -155,22 +155,7 @@ class file_updater implements file_updater_interface } $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); - $dirs = explode('/', $path); - $dirs_to_create = array(); - - do - { - $path .= '../'; - $dirs_to_create[] = array_pop($dirs); - } - while (!is_dir($path)); - - foreach ($dirs_to_create as $directory) - { - $path .= $directory; - $this->filesystem->mkdir($path, 493); // 493 === 0755 - $path .= '/'; - } + $this->filesystem->mkdir($path, 493); // 493 === 0755 } /** -- cgit v1.2.1 From 29908e54bcdf734150371fded932d04042580505 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 17:31:12 +0200 Subject: [ticket/14039] Use shared language service in the container factory PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index 8c007de39f..efbe278628 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -15,9 +15,16 @@ namespace phpbb\install\helper; use phpbb\cache\driver\dummy; use phpbb\install\exception\cannot_build_container_exception; +use phpbb\language\language; +use phpbb\request\request; class container_factory { + /** + * @var language + */ + protected $language; + /** * @var string */ @@ -43,12 +50,14 @@ class container_factory /** * Constructor * - * @param \phpbb\request\request $request Request interface - * @param string $phpbb_root_path Path to phpBB's root - * @param string $php_ext Extension of PHP files + * @param language $language Language service + * @param request $request Request interface + * @param string $phpbb_root_path Path to phpBB's root + * @param string $php_ext Extension of PHP files */ - public function __construct(\phpbb\request\request $request, $phpbb_root_path, $php_ext) + public function __construct(language $language, request $request, $phpbb_root_path, $php_ext) { + $this->language = $language; $this->request = $request; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; @@ -150,6 +159,9 @@ class container_factory $this->container->register('request')->setSynthetic(true); $this->container->set('request', $this->request); + $this->container->register('language')->setSynthetic(true); + $this->container->set('language', $this->language); + // Replace cache service, as config gets cached, and we don't want that when we are installing if (!is_dir($other_config_path)) { -- cgit v1.2.1 From 3b593c5d522f8ac374ea443925ae8159782ff9dd Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 18:17:28 +0200 Subject: [ticket/14039] Fix misunderstandable comment in the archive file updater PHPBB3-14039 --- phpBB/phpbb/install/helper/file_updater/compression_file_updater.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php b/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php index a6eca36653..ede992fb6e 100644 --- a/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php +++ b/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php @@ -94,7 +94,9 @@ class compression_file_updater implements file_updater_interface */ public function delete_file($path_to_file) { - // We do absolutely nothing here + // We do absolutely nothing here, as this function is called when a file should be + // removed from the filesystem, but since this is an archive generator, it clearly + // cannot do that. } /** -- cgit v1.2.1 From 56093d1c82d6f4d5c0f2741769eb071eb7bec5d7 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 19:18:53 +0200 Subject: [ticket/14039] Fix constants for the updater PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index efbe278628..bf19efe22e 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -133,7 +133,7 @@ class container_factory $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); // For BC with functions that we need during install - global $phpbb_container; + global $phpbb_container, $table_prefix; $disable_super_globals = $this->request->super_globals_disabled(); @@ -172,6 +172,7 @@ class container_factory $this->container->compile(); $phpbb_container = $this->container; + $table_prefix = $phpbb_config_php_file->get('table_prefix'); // Restore super globals to previous state if ($disable_super_globals) @@ -188,5 +189,15 @@ class container_factory { require($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); } + + // Get compatibilty globals + if (file_exists($this->phpbb_root_path . 'install/update/new/includes/constants.' . $this->php_ext)) + { + require($this->phpbb_root_path . 'install/update/new/includes/constants.' . $this->php_ext); + } + else + { + require($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); + } } } -- cgit v1.2.1 From ed442198d1fff379b65b8d4a1c3bfb15890cfed1 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 19:27:50 +0200 Subject: [ticket/14039] Fix ACP link generation PHPBB3-14039 --- phpBB/phpbb/install/installer.php | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 8a0374b1f0..bdff62e0b1 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -21,6 +21,7 @@ use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; use phpbb\install\helper\iohandler\cli_iohandler; use phpbb\install\helper\iohandler\iohandler_interface; +use phpbb\path_helper; class installer { @@ -39,6 +40,11 @@ class installer */ protected $iohandler; + /** + * @var string + */ + protected $web_root; + /** * Stores the number of steps that a given module has * @@ -49,12 +55,14 @@ class installer /** * Constructor * - * @param config $config Installer config handler + * @param config $config Installer config handler + * @param path_helper $path_helper Path helper */ - public function __construct(config $config) + public function __construct(config $config, path_helper $path_helper) { $this->install_config = $config; $this->installer_modules = null; + $this->web_root = $path_helper->get_web_root_path(); } /** @@ -183,21 +191,7 @@ class installer else { global $SID; - - // Construct ACP url - $acp_url = $protocol = $this->install_config->get('server_protocol'); - $acp_url .= $this->install_config->get('server_name'); - $port = $this->install_config->get('server_port'); - - if (!((strpos($protocol, 'https:') === 0 && $port === 443) - || (strpos($protocol, 'http:') === 0 && $port === 80))) - { - $acp_url .= ':' . $port; - } - - $acp_url .= $this->install_config->get('script_path'); - $acp_url .= '/adm/index.php' . $SID; - + $acp_url = $this->web_root . '/adm/index.php' . $SID; $this->iohandler->add_success_message('INSTALLER_FINISHED', array( 'ACP_LINK', $acp_url, -- cgit v1.2.1 From 0ce72f94a21d7407b08c8d2cb233d445434743b4 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 22:33:31 +0200 Subject: [ticket/14039] Fix acp link PHPBB3-14039 --- phpBB/phpbb/install/installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index bdff62e0b1..77e0a896bc 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -191,7 +191,7 @@ class installer else { global $SID; - $acp_url = $this->web_root . '/adm/index.php' . $SID; + $acp_url = $this->web_root . 'adm/index.php' . $SID; $this->iohandler->add_success_message('INSTALLER_FINISHED', array( 'ACP_LINK', $acp_url, -- cgit v1.2.1 From 4b447c71de8af0530574958e4c788186b606346f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 23:04:53 +0200 Subject: [ticket/14039] Fix file check for deleted files PHPBB3-14039 --- phpBB/phpbb/install/module/update_filesystem/task/file_check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php index 9945e61714..4d9f736b0a 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -108,7 +108,7 @@ class file_check extends task_base $update_info['deleted'], function ($filename) use ($root_path) { - return !file_exists($root_path . $filename); + return file_exists($root_path . $filename); } ); } -- cgit v1.2.1 From 2f8ef80d92457e29f688155cd5433a92fa981139 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 23:11:20 +0200 Subject: [ticket/14039] Fix folder creation and deleted binary file issue PHPBB3-14039 --- phpBB/phpbb/install/helper/file_updater/file_updater.php | 7 +++++++ phpBB/phpbb/install/module/update_filesystem/task/file_check.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/file_updater/file_updater.php b/phpBB/phpbb/install/helper/file_updater/file_updater.php index 00cb0d17bd..cc0f5c6b5f 100644 --- a/phpBB/phpbb/install/helper/file_updater/file_updater.php +++ b/phpBB/phpbb/install/helper/file_updater/file_updater.php @@ -113,6 +113,13 @@ class file_updater implements file_updater_interface $path_to_file_to_update = $this->phpbb_root_path . $path_to_file_to_update; $original_file_perms = false; + // Maybe necessary for binary files + $dir = dirname($path_to_file_to_update); + if (!$this->filesystem->exists($dir)) + { + $this->make_dir($dir); + } + if (!$this->filesystem->is_writable($path_to_file_to_update)) { // Extract last 9 bits we actually need diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php index 4d9f736b0a..5dbee6c259 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -101,7 +101,7 @@ class file_check extends task_base $update_info = $this->installer_config->get('update_info_unprocessed', array()); $file_update_info = array(); - $file_update_info['update_without_diff'] = $update_info['binary']; + $file_update_info['update_without_diff'] = array_diff($update_info['binary'], $update_info['deleted']); // Filter out files that are already deleted $file_update_info['delete'] = array_filter( -- cgit v1.2.1 From de729110c8d723b64da333f515ba0acf2723c88c Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 19 Oct 2015 01:19:31 +0200 Subject: [ticket/14039] Fix inclusion logic in update helper PHPBB3-14039 --- phpBB/phpbb/install/helper/update_helper.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/update_helper.php b/phpBB/phpbb/install/helper/update_helper.php index 2a3e6ceb0a..a00731d317 100644 --- a/phpBB/phpbb/install/helper/update_helper.php +++ b/phpBB/phpbb/install/helper/update_helper.php @@ -72,16 +72,11 @@ class update_helper */ public function include_file($filename) { - if (!is_file($this->phpbb_root_path . $filename)) - { - return; - } - if (is_file($this->path_to_new_files . $filename)) { include_once($this->path_to_new_files . $filename); } - else + else if (is_file($this->phpbb_root_path . $filename)) { include_once($this->phpbb_root_path . $filename); } -- cgit v1.2.1 From d45f146814a1709a16fb8e4951374242d50b6aed Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 19 Oct 2015 09:12:26 +0200 Subject: [ticket/14039] Use update helper to include files in container factory PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 39 +++++++++--------------- 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index bf19efe22e..6c1ecd2d02 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -40,6 +40,11 @@ class container_factory */ protected $request; + /** + * @var update_helper + */ + protected $update_helper; + /** * The full phpBB container * @@ -50,15 +55,17 @@ class container_factory /** * Constructor * - * @param language $language Language service - * @param request $request Request interface - * @param string $phpbb_root_path Path to phpBB's root - * @param string $php_ext Extension of PHP files + * @param language $language Language service + * @param request $request Request interface + * @param update_helper $update_helper Update helper + * @param string $phpbb_root_path Path to phpBB's root + * @param string $php_ext Extension of PHP files */ - public function __construct(language $language, request $request, $phpbb_root_path, $php_ext) + public function __construct(language $language, request $request, update_helper $update_helper, $phpbb_root_path, $php_ext) { $this->language = $language; $this->request = $request; + $this->update_helper = $update_helper; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->container = null; @@ -180,24 +187,8 @@ class container_factory $this->request->disable_super_globals(); } - // Get compatibilty globals - if (file_exists($this->phpbb_root_path . 'install/update/new/includes/compatibility_globals.' . $this->php_ext)) - { - require($this->phpbb_root_path . 'install/update/new/includes/compatibility_globals.' . $this->php_ext); - } - else - { - require($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); - } - - // Get compatibilty globals - if (file_exists($this->phpbb_root_path . 'install/update/new/includes/constants.' . $this->php_ext)) - { - require($this->phpbb_root_path . 'install/update/new/includes/constants.' . $this->php_ext); - } - else - { - require($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); - } + // Get compatibilty globals and constants + $this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext); + $this->update_helper->include_file('includes/constants.' . $this->php_ext); } } -- cgit v1.2.1 From 597297b169e2ae14684ad1f40c8e083be22b241d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 22:47:04 +0200 Subject: [ticket/14044] Deduplicate the installers PHPBB3-14044 --- .../module/install_database/task/create_schema.php | 13 +++++++--- .../install_filesystem/task/create_config_file.php | 29 +++++++++++++++------- .../module/install_finish/task/notify_user.php | 2 ++ .../install_finish/task/populate_migrations.php | 2 ++ 4 files changed, 34 insertions(+), 12 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php index 7cc521eee8..cabb78787f 100644 --- a/phpBB/phpbb/install/module/install_database/task/create_schema.php +++ b/phpBB/phpbb/install/module/install_database/task/create_schema.php @@ -80,6 +80,16 @@ class create_schema extends \phpbb\install\task_base $factory = new \phpbb\db\tools\factory(); $this->db = new $dbms(); + $this->db->sql_connect( + $config->get('dbhost'), + $config->get('dbuser'), + $config->get('dbpasswd'), + $config->get('dbname'), + $config->get('dbport'), + false, + false + ); + $this->config = $config; $this->db_tools = $factory->get($this->db); $this->database_helper = $db_helper; @@ -89,9 +99,6 @@ class create_schema extends \phpbb\install\task_base $this->php_ext = $php_ext; parent::__construct(true); - - // Connect to DB - $this->db->sql_connect($config->get('dbhost'), $config->get('dbuser'), $config->get('dbpasswd'), $config->get('dbname'), $config->get('dbport'), false, false); } /** diff --git a/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php b/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php index 337d401216..e0890a929c 100644 --- a/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php +++ b/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php @@ -50,6 +50,11 @@ class create_config_file extends \phpbb\install\task_base */ protected $php_ext; + /** + * @var array + */ + protected $options; + /** * Constructor * @@ -59,13 +64,15 @@ class create_config_file extends \phpbb\install\task_base * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler * @param string $phpbb_root_path * @param string $php_ext + * @param array $options */ public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \phpbb\install\helper\config $install_config, \phpbb\install\helper\database $db_helper, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, $phpbb_root_path, - $php_ext) + $php_ext, + $options = array()) { $this->install_config = $install_config; $this->db_helper = $db_helper; @@ -73,6 +80,11 @@ class create_config_file extends \phpbb\install\task_base $this->iohandler = $iohandler; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + $this->options = array_merge(array( + 'debug' => false, + 'debug_container' => false, + 'environment' => null, + ), $options); parent::__construct(true); } @@ -93,7 +105,7 @@ class create_config_file extends \phpbb\install\task_base $config_written = false; } - $config_content = $this->get_config_data(); + $config_content = $this->get_config_data($this->options['debug'], $this->options['debug_container'], $this->options['environment']); if (!@fwrite($fp, $config_content)) { @@ -145,15 +157,14 @@ class create_config_file extends \phpbb\install\task_base /** * Returns the content which should be dumped to config.php * - * @param bool $debug If the debug constants should be enabled by default or not - * @param bool $debug_container If the container should be compiled on + * @param bool $debug If the debug constants should be enabled by default or not + * @param bool $debug_container If the container should be compiled on * every page load or not - * @param bool $debug_test If the DEBUG_TEST constant should be added - * NOTE: Only for use within the testing framework + * @param string $environment The environment to use * * @return string content to be written to the config file */ - protected function get_config_data($debug = false, $debug_container = false, $debug_test = false) + protected function get_config_data($debug = false, $debug_container = false, $environment = null) { $config_content = "get('cache.driver'), $container->get_parameter('tables.config') ); + + parent::__construct(true); } /** diff --git a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php index b2a4800f86..8629d9aea3 100644 --- a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php +++ b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php @@ -37,6 +37,8 @@ class populate_migrations extends \phpbb\install\task_base { $this->extension_manager = $container->get('ext.manager'); $this->migrator = $container->get('migrator'); + + parent::__construct(true); } /** -- cgit v1.2.1 From 369024b56fd96a9ca7174f36a706d9dce478ac3b Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 28 Oct 2015 00:58:34 +0100 Subject: [ticket/14044] Try to fix missing table prefix PHPBB3-14044 --- phpBB/phpbb/install/module/update_database/task/update.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 2d640134a3..015935e1de 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -98,6 +98,10 @@ class update extends task_base $this->language = $language; $this->phpbb_root_path = $phpbb_root_path; + // BC global for migrations + global $table_prefix; + $table_prefix = $container->get_parameter('table_prefix'); + $this->cache = $container->get('cache.driver'); $this->config = $container->get('config'); $this->extension_manager = $container->get('ext.manager'); -- cgit v1.2.1 From 33db26d0cf3161edb7c840c499c94f5b8f14a4e9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 28 Oct 2015 01:12:52 +0100 Subject: [ticket/14044] global $table_prefix in constants.php PHPBB3-14044 --- phpBB/phpbb/install/module/update_database/task/update.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 015935e1de..2d640134a3 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -98,10 +98,6 @@ class update extends task_base $this->language = $language; $this->phpbb_root_path = $phpbb_root_path; - // BC global for migrations - global $table_prefix; - $table_prefix = $container->get_parameter('table_prefix'); - $this->cache = $container->get('cache.driver'); $this->config = $container->get('config'); $this->extension_manager = $container->get('ext.manager'); -- cgit v1.2.1 From 3ac10ef5443a1bbc8aa2f13b7fb98f33ca2ff702 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 28 Oct 2015 14:14:49 +0100 Subject: [ticket/14044] Solve missing email template error PHPBB3-14044 --- phpBB/phpbb/install/module/install_finish/task/notify_user.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php index 83c03ce367..1cbc27ab6a 100644 --- a/phpBB/phpbb/install/module/install_finish/task/notify_user.php +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -40,6 +40,11 @@ class notify_user extends \phpbb\install\task_base */ protected $config; + /** + * @var \phpbb\language\language + */ + protected $language; + /** * @var \phpbb\log\log_interface */ @@ -75,6 +80,7 @@ class notify_user extends \phpbb\install\task_base $this->iohandler = $iohandler; $this->auth = $container->get('auth'); + $this->language = $container->get('language'); $this->log = $container->get('log'); $this->user = $container->get('user'); $this->phpbb_root_path = $phpbb_root_path; @@ -103,7 +109,7 @@ class notify_user extends \phpbb\install\task_base include ($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); $messenger = new \messenger(false); - $messenger->template('installed', $this->install_config->get('language')); + $messenger->template('installed', $this->language->get_used_language()); $messenger->to($this->config['board_email'], $this->install_config->get('admin_name')); $messenger->anti_abuse_headers($this->config, $this->user); $messenger->assign_vars(array( -- cgit v1.2.1 From 71ec5185e16c389d6d25b9999e73a4e6298cd721 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 28 Oct 2015 14:17:29 +0100 Subject: [ticket/14044] Fix wrong descriptions in install PHPBB3-14044 --- phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') 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 index ae7526a9e3..b04b8e353f 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php @@ -116,12 +116,12 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta ), 'smtp_host' => array( 'label' => 'SMTP_SERVER', - 'description' => 'SMTP_SERVER_EXPLAIN', 'type' => 'text', 'default' => $smtp_host, ), 'smtp_auth' => array( 'label' => 'SMTP_AUTH_METHOD', + 'description' => 'SMTP_AUTH_METHOD_EXPLAIN', 'type' => 'select', 'options' => $auth_options, ), -- cgit v1.2.1 From 719f42c54a45ab669a983964c1e8a6f75a4d4b02 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 30 Oct 2015 15:46:39 +0100 Subject: [ticket/14044] Fix language selection data loss PHPBB3-14044 --- phpBB/phpbb/install/controller/helper.php | 1 + .../install/module/install_database/task/add_config_settings.php | 2 +- phpBB/phpbb/install/module/install_finish/task/notify_user.php | 4 +++- phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index bfa9ec6238..fdb07d9c4a 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -204,6 +204,7 @@ class helper if ($lang !== null) { $this->language->set_user_language($lang, true); + $this->installer_config->set('user_language', $lang); } } diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php index 25da36e01d..6fb03ff73d 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -233,7 +233,7 @@ class add_config_settings extends \phpbb\install\task_base SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "', user_password='" . $this->password_manager->hash($this->install_config->get('admin_passwd')) . "', user_ip = '" . $this->db->sql_escape($user_ip) . "', - user_lang = '" . $this->db->sql_escape($this->install_config->get('language')) . "', + user_lang = '" . $this->db->sql_escape($this->install_config->get('user_language', 'en')) . "', user_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "', user_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "', user_email_hash = " . $this->db->sql_escape(phpbb_email_hash($this->install_config->get('board_email'))) . ", diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php index 1cbc27ab6a..2a8ee0f12e 100644 --- a/phpBB/phpbb/install/module/install_finish/task/notify_user.php +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -104,12 +104,14 @@ class notify_user extends \phpbb\install\task_base $this->user->session_begin(); $this->user->setup('common'); + $this->language->set_default_language($this->config['default_lang']); + if ($this->config['email_enable']) { include ($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); $messenger = new \messenger(false); - $messenger->template('installed', $this->language->get_used_language()); + $messenger->template('installed', $this->install_config->get('user_language', 'en')); $messenger->to($this->config['board_email'], $this->install_config->get('admin_name')); $messenger->anti_abuse_headers($this->config, $this->user); $messenger->assign_vars(array( 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 index 0726cc449c..4e977981ce 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php @@ -126,7 +126,7 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta } // Use language because we only check this to be valid - $default_lang = $this->install_config->get('language', ''); + $default_lang = $this->install_config->get('user_language', 'en'); $langs = $this->language_helper->get_available_languages(); $lang_options = array(); -- cgit v1.2.1 From f991e484da91e24f82fbcb05d0b2ae11ca51852b Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 3 Nov 2015 02:16:23 +0100 Subject: [ticket/14044] Add config as global in notify user PHPBB3-14044 --- phpBB/phpbb/install/module/install_finish/task/notify_user.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php index 2a8ee0f12e..5268b85a42 100644 --- a/phpBB/phpbb/install/module/install_finish/task/notify_user.php +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -104,12 +104,15 @@ class notify_user extends \phpbb\install\task_base $this->user->session_begin(); $this->user->setup('common'); - $this->language->set_default_language($this->config['default_lang']); - if ($this->config['email_enable']) { include ($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); + // functions_messenger.php uses config to determine language paths + // Remove when able + global $config; + $config = $this->config; + $messenger = new \messenger(false); $messenger->template('installed', $this->install_config->get('user_language', 'en')); $messenger->to($this->config['board_email'], $this->install_config->get('admin_name')); -- cgit v1.2.1 From 50d102c9751bd156be2a9207862dda3e6680de8e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 5 Nov 2015 16:32:19 -0800 Subject: [ticket/14274] Include user functions during installer PHPBB3-14274 --- phpBB/phpbb/install/module/install_data/task/add_bots.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php index b45d3808db..2ee641ff63 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_bots.php +++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php @@ -197,6 +197,11 @@ class add_bots extends \phpbb\install\task_base 'user_allow_pm' => 0, ); + if (!function_exists('user_add')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + $user_id = user_add($user_row); if (!$user_id) -- cgit v1.2.1 From 8d178f15f06e0f6b5e64447dc07157a796645572 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 4 Nov 2015 17:25:38 +0100 Subject: [ticket/14270] Purge cache when the installer is finished PHPBB3-14270 --- phpBB/phpbb/install/installer.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 77e0a896bc..a41b4cd6a6 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -13,6 +13,7 @@ namespace phpbb\install; +use phpbb\cache\driver\driver_interface; use phpbb\di\ordered_service_collection; use phpbb\install\exception\installer_config_not_writable_exception; use phpbb\install\exception\jump_to_restart_point_exception; @@ -25,6 +26,11 @@ use phpbb\path_helper; class installer { + /** + * @var driver_interface + */ + protected $cache; + /** * @var config */ @@ -55,11 +61,13 @@ class installer /** * Constructor * - * @param config $config Installer config handler - * @param path_helper $path_helper Path helper + * @param driver_interface $cache Cache service + * @param config $config Installer config handler + * @param path_helper $path_helper Path helper */ - public function __construct(config $config, path_helper $path_helper) + public function __construct(driver_interface $cache, config $config, path_helper $path_helper) { + $this->cache = $cache; $this->install_config = $config; $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); @@ -235,6 +243,7 @@ class installer if ($install_finished || $fail_cleanup) { $this->install_config->clean_up_config_file(); + $this->cache->purge(); } else { -- cgit v1.2.1 From d77455309b0edbcc65e4a347dc777542b1189328 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 9 Nov 2015 15:27:10 +0100 Subject: [ticket/14278] Check if user_id is set and fall back to ANONYMOUS PHPBB3-14278 --- phpBB/phpbb/install/module/update_database/task/update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 2d640134a3..84ec6f73f5 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -172,7 +172,7 @@ class update extends task_base { $this->log->add( 'admin', - $this->user->data['user_id'], + (isset($this->user->data['user_id'])) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, -- cgit v1.2.1 From 079b3d074d905c1982ec22840caae808c3b588f3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 10 Nov 2015 15:01:18 +0100 Subject: [ticket/14281] Fix installer CLI after recent changes PHPBB3-14281 --- phpBB/phpbb/install/console/command/install/config/show.php | 2 +- phpBB/phpbb/install/console/command/install/install.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php index 4155440fc3..587b5f4846 100644 --- a/phpBB/phpbb/install/console/command/install/config/show.php +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -96,7 +96,7 @@ class show extends \phpbb\console\command\command if (!is_file($config_file)) { - $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + $iohandler->add_error_message('MISSING_FILE', array($config_file)); return; } diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 81ad1039f6..d76182af92 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -116,7 +116,7 @@ class install extends \phpbb\console\command\command if (!is_file($config_file)) { - $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); return 1; } @@ -127,7 +127,7 @@ class install extends \phpbb\console\command\command } catch (ParseException $e) { - $iohandler->add_error_message('INVALID_YAML_FILE'); + $iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file)); return 1; } -- cgit v1.2.1 From a1abf8253f2328f0a5c7b8d7c5885c6cec93f547 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 10 Nov 2015 16:49:30 +0100 Subject: [ticket/14281] Correctly pass parameters to add_error_message PHPBB3-14281 --- phpBB/phpbb/install/console/command/install/config/show.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php index 587b5f4846..5d82d8d1ef 100644 --- a/phpBB/phpbb/install/console/command/install/config/show.php +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -96,7 +96,7 @@ class show extends \phpbb\console\command\command if (!is_file($config_file)) { - $iohandler->add_error_message('MISSING_FILE', array($config_file)); + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); return; } -- cgit v1.2.1 From c3b9b3ab5bbe475ce7b5368a959786fc64122ad4 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 24 Nov 2015 22:07:02 +0700 Subject: [ticket/14308] Fix multibyte input for installer PHPBB3-14308 --- phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php | 2 +- phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install') 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 index 41616e995a..ac305e8ab5 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php @@ -70,7 +70,7 @@ class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\insta $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', ''); + $board_email = $this->io_handler->get_input('board_email', '', true); $admin_data_valid = $this->check_admin_data($admin_name, $admin_pass1, $admin_pass2, $board_email); 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 index 4e977981ce..6c54561d14 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php @@ -76,8 +76,8 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta { // 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', ''); + $board_name = $this->io_handler->get_input('board_name', '', true); + $board_desc = $this->io_handler->get_input('board_description', '', true); // Check default lang $langs = $this->language_helper->get_available_languages(); @@ -116,8 +116,8 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta { if ($use_request_data) { - $board_name = $this->io_handler->get_input('board_name', ''); - $board_desc = $this->io_handler->get_input('board_description', ''); + $board_name = $this->io_handler->get_input('board_name', '', true); + $board_desc = $this->io_handler->get_input('board_description', '', true); } else { -- cgit v1.2.1 From 93b37b24c2d546a2bc80830508d64338a24f9afa Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 4 Nov 2015 14:00:59 +0100 Subject: [ticket/14269] Use http_exceptions in the installer instead of die() PHPBB3-14269 --- phpBB/phpbb/install/controller/install.php | 5 +- phpBB/phpbb/install/controller/update.php | 7 +- .../install/event/kernel_exception_subscriber.php | 125 +++++++++++++++++++++ 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 phpBB/phpbb/install/event/kernel_exception_subscriber.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 8d5ff95958..0fd4e8897c 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -13,6 +13,7 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\install_helper; use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; @@ -97,12 +98,14 @@ class install * Controller logic * * @return Response|StreamedResponse + * + * @throws http_exception When phpBB is already installed */ public function handle() { if ($this->install_helper->is_phpbb_installed()) { - die ('phpBB is already installed'); + throw new http_exception(404, 'INSTALL_PHPBB_IS_ALREADY_INSTALLED'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php index 5212ba7f26..6a4341710a 100644 --- a/phpBB/phpbb/install/controller/update.php +++ b/phpBB/phpbb/install/controller/update.php @@ -13,6 +13,7 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\install_helper; use phpbb\install\helper\iohandler\factory; use phpbb\install\helper\navigation\navigation_provider; @@ -93,12 +94,16 @@ class update /** * Controller entry point + * + * @return Response|StreamedResponse + * + * @throws http_exception When phpBB is not installed */ public function handle() { if (!$this->install_helper->is_phpbb_installed()) { - die ('phpBB is not installed'); + throw new http_exception(404, 'INSTALL_PHPBB_IS_NOT_INSTALLED'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/event/kernel_exception_subscriber.php b/phpBB/phpbb/install/event/kernel_exception_subscriber.php new file mode 100644 index 0000000000..2e6f9ca74d --- /dev/null +++ b/phpBB/phpbb/install/event/kernel_exception_subscriber.php @@ -0,0 +1,125 @@ + + * @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\event; + +use phpbb\exception\exception_interface; +use phpbb\install\controller\helper; +use phpbb\language\language; +use phpbb\template\template; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; +use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; + +/** + * Exception handler for the installer + */ +class kernel_exception_subscriber implements EventSubscriberInterface +{ + /** + * @var helper + */ + protected $controller_helper; + + /** + * @var language + */ + protected $language; + + /** + * @var template + */ + protected $template; + + /** + * Constructor + * + * @param helper $controller_helper + * @param language $language + * @param template $template + */ + public function __construct(helper $controller_helper, language $language, template $template) + { + $this->controller_helper = $controller_helper; + $this->language = $language; + $this->template = $template; + } + + /** + * This listener is run when the KernelEvents::EXCEPTION event is triggered + * + * @param GetResponseForExceptionEvent $event + */ + public function on_kernel_exception(GetResponseForExceptionEvent $event) + { + $exception = $event->getException(); + $message = $exception->getMessage(); + + if ($exception instanceof exception_interface) + { + $message = $this->language->lang_array($message, $exception->get_parameters()); + } + + if (!$event->getRequest()->isXmlHttpRequest()) + { + $this->template->assign_vars(array( + 'TITLE' => $this->language->lang('INFORMATION'), + 'BODY' => $message, + )); + + $response = $this->controller_helper->render( + 'installer_main.html', + $this->language->lang('INFORMATION'), + false, + 500 + ); + } + else + { + $data = array(); + + if (!empty($message)) + { + $data['message'] = $message; + } + + if (defined('DEBUG')) + { + $data['trace'] = $exception->getTrace(); + } + + $response = new JsonResponse($data, 500); + } + + if ($exception instanceof HttpExceptionInterface) + { + $response->setStatusCode($exception->getStatusCode()); + $response->headers->add($exception->getHeaders()); + } + + $event->setResponse($response); + } + + /** + * Returns an array of the events the object is subscribed to + * + * @return array Array of the events the object is subscribed to + */ + static public function getSubscribedEvents() + { + return array( + KernelEvents::EXCEPTION => 'on_kernel_exception', + ); + } +} -- cgit v1.2.1 From 4aac878ec792cfbae01b708dd3d0336a75704405 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 29 Nov 2015 15:49:18 +0100 Subject: [ticket/14320] Fix language selector in the installer PHPBB3-14320 --- phpBB/phpbb/install/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index fdb07d9c4a..ed817f7396 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -197,7 +197,7 @@ class helper $this->language_cookie = $lang; } - $lang = (!empty($lang) && strpos($lang, '/')) ? $lang : null; + $lang = (!empty($lang) && strpos($lang, '/') === false) ? $lang : null; $this->render_language_select($lang); -- cgit v1.2.1 From e95414ed541647d4a42b9349d1bb939725b57b0b Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 30 Nov 2015 23:17:00 +0100 Subject: [ticket/14326] Decode diffed file's content during update PHPBB3-14326 --- .../install/module/update_filesystem/task/show_file_status.php | 2 +- .../install/module/update_filesystem/task/update_files.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php index 1c6b9aa058..e712b8ad6a 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php @@ -100,7 +100,7 @@ class show_file_status extends task_base { $this->file_updater->create_new_file( $filename, - $this->cache->get('_file_' . md5($filename)), + base64_decode($this->cache->get('_file_' . md5($filename))), true ); } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php index 747a86281b..fbb465cc66 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php @@ -164,20 +164,20 @@ class update_files extends task_base { case 'delete': $this->file_updater->delete_file($path); - break; + break; case 'new': $this->file_updater->create_new_file($path, $new_path . $path); - break; + break; case 'update_without_diff': $this->file_updater->update_file($path, $new_path . $path); - break; + break; case 'update_with_diff': $this->file_updater->update_file( $path, - $this->cache->get('_file_' . md5($path)), + base64_decode($this->cache->get('_file_' . md5($path))), true ); - break; + break; } // Save progress -- cgit v1.2.1 From 02a9264780f3896cf88b9d793dbf8831aa54e029 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 3 Dec 2015 20:31:49 +0100 Subject: [ticket/14269] Fix comments and language var names PHPBB3-14269 --- phpBB/phpbb/install/controller/install.php | 2 +- phpBB/phpbb/install/controller/update.php | 2 +- phpBB/phpbb/install/event/kernel_exception_subscriber.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 0fd4e8897c..baa4e4807a 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -105,7 +105,7 @@ class install { if ($this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'INSTALL_PHPBB_IS_ALREADY_INSTALLED'); + throw new http_exception(404, 'INSTALL_PHPBB_INSTALLED'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php index 6a4341710a..8ecd8b3cb8 100644 --- a/phpBB/phpbb/install/controller/update.php +++ b/phpBB/phpbb/install/controller/update.php @@ -103,7 +103,7 @@ class update { if (!$this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'INSTALL_PHPBB_IS_NOT_INSTALLED'); + throw new http_exception(404, 'INSTALL_PHPBB_NOT_INSTALLED'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/event/kernel_exception_subscriber.php b/phpBB/phpbb/install/event/kernel_exception_subscriber.php index 2e6f9ca74d..c2960cb13c 100644 --- a/phpBB/phpbb/install/event/kernel_exception_subscriber.php +++ b/phpBB/phpbb/install/event/kernel_exception_subscriber.php @@ -112,9 +112,9 @@ class kernel_exception_subscriber implements EventSubscriberInterface } /** - * Returns an array of the events the object is subscribed to + * Returns an array of events the object is subscribed to * - * @return array Array of the events the object is subscribed to + * @return array Array of events the object is subscribed to */ static public function getSubscribedEvents() { -- cgit v1.2.1 From 44a90c9812c4eff73051e75647362859f9407a5f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 5 Dec 2015 15:42:22 +0100 Subject: [ticket/14269] Change HTTP status codes to 403 PHPBB3-14269 --- phpBB/phpbb/install/controller/install.php | 2 +- phpBB/phpbb/install/controller/update.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index baa4e4807a..8bf9062b08 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -105,7 +105,7 @@ class install { if ($this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'INSTALL_PHPBB_INSTALLED'); + throw new http_exception(403, 'INSTALL_PHPBB_INSTALLED'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php index 8ecd8b3cb8..9fff11cae8 100644 --- a/phpBB/phpbb/install/controller/update.php +++ b/phpBB/phpbb/install/controller/update.php @@ -103,7 +103,7 @@ class update { if (!$this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'INSTALL_PHPBB_NOT_INSTALLED'); + throw new http_exception(403, 'INSTALL_PHPBB_NOT_INSTALLED'); } $this->template->assign_vars(array( -- cgit v1.2.1 From 1b9ae803c5cf887c8acc2e7580ccb6fe76522d58 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Dec 2015 13:53:44 +0100 Subject: [ticket/14345] Check if description exists in message ary PHPBB3-14345 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index abdd730d2e..dae5d339a5 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -126,7 +126,8 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($error_title, $error_description); - $this->io->error($message['title'] . "\n" . $message['description']); + $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $this->io->error($message_string); if ($this->progress_bar !== null) { @@ -143,7 +144,8 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($warning_title, $warning_description); - $this->io->warning($message['title'] . "\n" . $message['description']); + $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $this->io->warning($message_string); if ($this->progress_bar !== null) { @@ -172,7 +174,8 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($error_title, $error_description); - $this->io->success($message['title'] . "\n" . $message['description']); + $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $this->io->success($message_string); if ($this->progress_bar !== null) { -- cgit v1.2.1 From 41b4fee6557c34d9ff534e7c1693d4e84e166ce1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Dec 2015 16:59:04 +0100 Subject: [ticket/14345] Move new line to ternary comparison PHPBB3-14345 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index dae5d339a5..4d0341ef12 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -126,7 +126,7 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($error_title, $error_description); - $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->error($message_string); if ($this->progress_bar !== null) @@ -144,7 +144,7 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($warning_title, $warning_description); - $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->warning($message_string); if ($this->progress_bar !== null) @@ -174,7 +174,7 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($error_title, $error_description); - $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->success($message_string); if ($this->progress_bar !== null) -- cgit v1.2.1 From 6188a8777950ffeaa80593d815600c84911ac932 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Dec 2015 23:36:49 +0100 Subject: [ticket/14344] Improve output of HTML errors trigged during install PHPBB3-14344 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 4 ++++ phpBB/phpbb/install/helper/iohandler/iohandler_base.php | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 4d0341ef12..89f3594378 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -125,6 +125,10 @@ class cli_iohandler extends iohandler_base { $this->io->newLine(); + if (strpos($error_title, '
') !== false) + { + $error_title = strip_tags(str_replace('
', "\n", $error_title)); + } $message = $this->translate_message($error_title, $error_description); $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->error($message_string); diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index 530cb4766b..8dee5390a9 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -101,6 +101,10 @@ abstract class iohandler_base implements iohandler_interface */ public function add_error_message($error_title, $error_description = false) { + if (strpos($error_title, '
') !== false) + { + $error_title = strip_tags(htmlspecialchars_decode($error_title)); + } $this->errors[] = $this->translate_message($error_title, $error_description); } -- cgit v1.2.1 From 2fe81c1ccb20035c9d66503726a7ff8df8b7fd78 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Dec 2015 22:20:56 +0100 Subject: [ticket/14373] Do not pass arrays to strpos() PHPBB3-14373 --- phpBB/phpbb/install/helper/iohandler/iohandler_base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index 8dee5390a9..7271fe9bc0 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -101,7 +101,7 @@ abstract class iohandler_base implements iohandler_interface */ public function add_error_message($error_title, $error_description = false) { - if (strpos($error_title, '
') !== false) + if (!is_array($error_title) && strpos($error_title, '
') !== false) { $error_title = strip_tags(htmlspecialchars_decode($error_title)); } -- cgit v1.2.1 From c02fc0f63fb8098cd4096481ad27b31f8069d5d1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 22 Dec 2015 20:01:22 +0100 Subject: [ticket/14378] Use consistent template variable paths PHPBB3-14378 --- phpBB/phpbb/install/controller/helper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index ed817f7396..2dad42b4b6 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -270,10 +270,10 @@ class helper 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'), 'L_SKIP' => $this->language->lang('SKIP'), 'PAGE_TITLE' => $this->language->lang($page_title), - 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images/', + 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images', 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js', - 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style/', - 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets/', + 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style', + 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets', 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right', -- cgit v1.2.1 From 73e6e5b77faadbb7676961bf38122d669de111db Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2015 17:50:29 +0100 Subject: [ticket/13454] Remove unused variables This is the first part of the changes. More to come. PHPBB3-13454 --- phpBB/phpbb/install/console/command/install/config/validate.php | 2 +- phpBB/phpbb/install/controller/install.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php index 19b6f99a8b..3bbbc23e34 100644 --- a/phpBB/phpbb/install/console/command/install/config/validate.php +++ b/phpBB/phpbb/install/console/command/install/config/validate.php @@ -117,7 +117,7 @@ class validate extends \phpbb\console\command\command try { - $config = $processor->processConfiguration($configuration, $config); + $processor->processConfiguration($configuration, $config); } catch (Exception $e) { diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 8bf9062b08..b987d91c6a 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -19,7 +19,6 @@ use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\Response; use phpbb\install\helper\iohandler\factory; -use phpbb\install\controller\helper; use phpbb\template\template; use phpbb\request\request_interface; use phpbb\install\installer; -- cgit v1.2.1 From ef09b562dbeab043ba410088edf2e1fe3f155e79 Mon Sep 17 00:00:00 2001 From: lavigor Date: Thu, 14 Jan 2016 15:38:14 +0300 Subject: [ticket/13442] UTF-8 symbols for database host PHPBB3-13442 --- phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') 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 index f0e7f1f686..3458aab63e 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php @@ -76,7 +76,7 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in { // Collect database data $dbms = $this->io_handler->get_input('dbms', ''); - $dbhost = $this->io_handler->get_input('dbhost', ''); + $dbhost = $this->io_handler->get_input('dbhost', '', true); $dbport = $this->io_handler->get_input('dbport', ''); $dbuser = $this->io_handler->get_input('dbuser', ''); $dbpasswd = $this->io_handler->get_input('dbpasswd', '', true); @@ -115,7 +115,7 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in if ($use_request_data) { $dbms = $this->io_handler->get_input('dbms', ''); - $dbhost = $this->io_handler->get_input('dbhost', ''); + $dbhost = $this->io_handler->get_input('dbhost', '', true); $dbport = $this->io_handler->get_input('dbport', ''); $dbuser = $this->io_handler->get_input('dbuser', ''); $dbname = $this->io_handler->get_input('dbname', ''); -- cgit v1.2.1 From fb1acb0ef463bc38421248497e7f0b7b271600f7 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 28 Jan 2016 07:04:55 -0800 Subject: [ticket/14434] Check migrations in the database updater task PHPBB3-14434 --- phpBB/phpbb/install/module/update_database/task/update.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 84ec6f73f5..eb9bdc8138 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -139,6 +139,15 @@ class update extends task_base ->extension_directory('/migrations') ->get_classes(); + // Unset classes that are not a valid migration + foreach ($migrations as $key => $migration_class) + { + if (\phpbb\db\migrator::is_migration($migration_class) === false) + { + unset($migrations[$key]); + } + } + $this->migrator->set_migrations($migrations); $migration_count = count($migrations); $this->iohandler->set_task_count($migration_count, true); -- cgit v1.2.1 From 27027deb9ce2076f64dbfdecba494efe1aa523dc Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 28 Jan 2016 11:22:30 -0800 Subject: [ticket/14434] Refactored to check migrations when setting them PHPBB3-14434 --- phpBB/phpbb/install/module/update_database/task/update.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index eb9bdc8138..4b2baf2c23 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -139,17 +139,8 @@ class update extends task_base ->extension_directory('/migrations') ->get_classes(); - // Unset classes that are not a valid migration - foreach ($migrations as $key => $migration_class) - { - if (\phpbb\db\migrator::is_migration($migration_class) === false) - { - unset($migrations[$key]); - } - } - $this->migrator->set_migrations($migrations); - $migration_count = count($migrations); + $migration_count = count($this->migrator->get_migrations()); $this->iohandler->set_task_count($migration_count, true); $progress_count = $this->installer_config->get('database_update_count', 0); -- cgit v1.2.1 From a649768e17d25bcf55ae539420abe4eb4b7a1ef1 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 28 Oct 2015 15:00:11 +0100 Subject: [ticket/14262] Move convertor to controller PHPBB3-14262 --- phpBB/phpbb/install/controller/helper.php | 5 +- .../install/helper/iohandler/ajax_iohandler.php | 31 ++++++++- .../install/helper/iohandler/cli_iohandler.php | 7 ++ .../install/helper/iohandler/iohandler_base.php | 8 +++ .../helper/iohandler/iohandler_interface.php | 18 +++++ .../helper/navigation/convertor_navigation.php | 78 ++++++++++++++++++++++ 6 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 phpBB/phpbb/install/helper/navigation/convertor_navigation.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 2dad42b4b6..6859414236 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -160,12 +160,13 @@ class helper * Returns path from route name * * @param string $route_name + * @param array $parameters * * @return string */ - public function route($route_name) + public function route($route_name, $parameters = array()) { - $url = $this->router->generate($route_name); + $url = $this->router->generate($route_name, $parameters); return $url; } diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 1342ffa30f..31474ae4e9 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -71,6 +71,11 @@ class ajax_iohandler extends iohandler_base */ protected $download; + /** + * @var array + */ + protected $redirect_url; + /** * Constructor * @@ -89,6 +94,7 @@ class ajax_iohandler extends iohandler_base $this->nav_data = array(); $this->cookies = array(); $this->download = array(); + $this->redirect_url = array(); $this->file_status = ''; parent::__construct(); @@ -130,6 +136,14 @@ class ajax_iohandler extends iohandler_base * {@inheritdoc} */ public function add_user_form_group($title, $form) + { + $this->form = $this->generate_form_render_data($title, $form); + } + + /** + * {@inheritdoc} + */ + public function generate_form_render_data($title, $form) { $this->template->assign_block_vars('options', array( 'LEGEND' => $this->language->lang($title), @@ -189,7 +203,7 @@ class ajax_iohandler extends iohandler_base 'form_install' => 'installer_form.html', )); - $this->form = $this->template->assign_display('form_install'); + return $this->template->assign_display('form_install'); } /** @@ -273,6 +287,12 @@ class ajax_iohandler extends iohandler_base $this->cookies = array(); } + if (!empty($this->redirect_url)) + { + $json_array['redirect'] = $this->redirect_url; + $this->redirect_url = array(); + } + return $json_array; } @@ -372,6 +392,15 @@ class ajax_iohandler extends iohandler_base $this->file_status = $this->template->assign_display('file_status'); } + /** + * {@inheritdoc} + */ + public function redirect($url, $use_ajax = false) + { + $this->redirect_url = array('url' => $url, 'use_ajax' => $use_ajax); + $this->send_response(); + } + /** * Callback function for language replacing * diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 89f3594378..7945904524 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -289,4 +289,11 @@ class cli_iohandler extends iohandler_base public function render_update_file_status($status_array) { } + + /** + * {@inheritdoc} + */ + public function redirect($url, $use_ajax = false) + { + } } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index 7271fe9bc0..fed4bc101f 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -169,6 +169,14 @@ abstract class iohandler_base implements iohandler_interface $this->current_task_progress = $this->task_progress_count; } + /** + * {@inheritdoc} + */ + public function generate_form_render_data($title, $form) + { + return ''; + } + /** * Localize message. * diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index 00aab3283e..6b3839506f 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -123,6 +123,16 @@ interface iohandler_interface */ public function add_user_form_group($title, $form); + /** + * Returns the rendering information for the form + * + * @param string $title Language variable with the title of the form + * @param array $form An array describing the required data (options etc) + * + * @return string Information to render the form + */ + public function generate_form_render_data($title, $form); + /** * Sets the number of tasks belonging to the installer in the current mode. * @@ -174,6 +184,14 @@ interface iohandler_interface */ public function add_download_link($route, $title, $msg = null); + /** + * Redirects the user to a new page + * + * @param string $url URL to redirect to + * @param bool $use_ajax Whether or not to use AJAX redirect + */ + public function redirect($url, $use_ajax = false); + /** * Renders the status of update files * diff --git a/phpBB/phpbb/install/helper/navigation/convertor_navigation.php b/phpBB/phpbb/install/helper/navigation/convertor_navigation.php new file mode 100644 index 0000000000..54cab83b1d --- /dev/null +++ b/phpBB/phpbb/install/helper/navigation/convertor_navigation.php @@ -0,0 +1,78 @@ + + * @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\helper\navigation; + +use phpbb\install\helper\install_helper; + +class convertor_navigation implements navigation_interface +{ + /** + * @var install_helper + */ + private $install_helper; + + /** + * Constructor + * + * @param install_helper $install_helper + */ + public function __construct(install_helper $install_helper) + { + $this->install_helper = $install_helper; + } + + /** + * {@inheritdoc} + */ + public function get() + { + if (!$this->install_helper->is_phpbb_installed()) + { + return array(); + } + + return array( + 'convert' => array( + 'label' => 'CONVERT', + 'route' => 'phpbb_convert_intro', + 'order' => 3, + array( + 'intro' => array( + 'label' => 'SUB_INTRO', + 'stage' => true, + 'order' => 0, + ), + 'settings' => array( + 'label' => 'STAGE_SETTINGS', + 'stage' => true, + 'route' => 'phpbb_convert_settings', + 'order' => 1, + ), + 'convert' => array( + 'label' => 'STAGE_IN_PROGRESS', + 'stage' => true, + 'route' => 'phpbb_convert_convert', + 'order' => 2, + ), + 'finish' => array( + 'label' => 'CONVERT_COMPLETE', + 'stage' => true, + 'route' => 'phpbb_convert_finish', + 'order' => 3, + ), + ), + ), + ); + } +} -- cgit v1.2.1 From debd1bb9d655106eb5454ac4687837c9323a99ae Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 2 Feb 2016 17:53:10 +0100 Subject: [ticket/14321] Clean up arcihve controller logic PHPBB3-14321 --- phpBB/phpbb/install/controller/archive_download.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index a0f0ba181d..eabc0a9976 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -46,9 +46,9 @@ class archive_download */ public function conflict_archive() { - $filename = $this->installer_config->get('update_file_conflict_archive', false); + $filename = $this->installer_config->get('update_file_conflict_archive', ''); - if (!$filename) + if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } @@ -65,7 +65,7 @@ class archive_download { $filename = $this->installer_config->get('update_file_archive', ''); - if (!$filename) + if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } -- cgit v1.2.1 From 8f4889da58e0aa4779ec6bf7c0e747c26a13aee3 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 2 Feb 2016 17:16:15 +0100 Subject: [ticket/14445] Force refresh before schema generation PHPBB3-14445 --- phpBB/phpbb/install/helper/config.php | 6 +++--- .../install/module/install_database/task/create_schema.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index 0f0840f470..ab5af86320 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -157,10 +157,10 @@ class config { if ($this->system_data['max_execution_time'] <= 0) { - return 1; + return PHP_INT_MAX; } - return ($this->system_data['start_time'] + $this->system_data['max_execution_time']) - time(); + return ($this->system_data['start_time'] + $this->system_data['max_execution_time']) - microtime(true); } /** @@ -430,7 +430,7 @@ class config $this->system_data['max_execution_time'] = $execution_time; // Set start time - $this->system_data['start_time'] = time(); + $this->system_data['start_time'] = microtime(true); // Get memory limit $this->system_data['memory_limit'] = $this->php_ini->getBytes('memory_limit'); diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php index cabb78787f..a5635d5dbe 100644 --- a/phpBB/phpbb/install/module/install_database/task/create_schema.php +++ b/phpBB/phpbb/install/module/install_database/task/create_schema.php @@ -13,6 +13,8 @@ namespace phpbb\install\module\install_database\task; +use phpbb\install\exception\resource_limit_reached_exception; + /** * Create database schema */ @@ -106,6 +108,17 @@ class create_schema extends \phpbb\install\task_base */ public function run() { + // As this task may take a large amount of time to complete refreshing the page might be necessary for some + // server configurations with limited resources + if (!$this->config->get('pre_schema_forced_refresh')) + { + if ($this->config->get_time_remaining() < 5) + { + $this->config->set('pre_schema_forced_refresh', true); + throw new resource_limit_reached_exception(); + } + } + $this->db->sql_return_on_error(true); $dbms = $this->config->get('dbms'); -- cgit v1.2.1 From 2f6f9a05eb1ae25a29fcb90bb301ce507298a474 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 4 Feb 2016 21:20:02 +0100 Subject: [ticket/14312] Push migration error messages to the user PHPBB3-14312 --- phpBB/phpbb/install/module/update_database/task/update.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 4b2baf2c23..aa44d403dd 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -158,6 +158,7 @@ class update extends task_base array_unshift($msg, $e->getMessage()); $this->iohandler->add_error_message($msg); + $this->iohandler->send_response(); throw new user_interaction_required_exception(); } -- cgit v1.2.1 From ad7b3ed17865b4ac91df24812fce4a9192f44fa1 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 4 Feb 2016 21:35:45 +0100 Subject: [ticket/14312] Allow updating without having the update directory PHPBB3-14312 --- .../obtain_data/task/obtain_update_settings.php | 37 +++++++++++++++------- .../module/requirements/task/check_update.php | 16 ++++++++-- 2 files changed, 38 insertions(+), 15 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php index 6a98721e77..be6404dcd8 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php @@ -57,22 +57,35 @@ class obtain_update_settings extends task_base } else { + if ($this->installer_config->get('disable_filesystem_update', false)) + { + $options[] = array( + 'value' => 'db_only', + 'label' => 'UPDATE_TYPE_DB_ONLY', + 'selected' => true, + ); + } + else + { + $options = array( + array( + 'value' => 'all', + 'label' => 'UPDATE_TYPE_ALL', + 'selected' => true, + ), + array( + 'value' => 'db_only', + 'label' => 'UPDATE_TYPE_DB_ONLY', + 'selected' => false, + ), + ); + } + $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, - ), - ), + 'options' => $options, ), 'submit_update' => array( 'label' => 'SUBMIT', diff --git a/phpBB/phpbb/install/module/requirements/task/check_update.php b/phpBB/phpbb/install/module/requirements/task/check_update.php index c986c76810..4e9124ff47 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_update.php +++ b/phpBB/phpbb/install/module/requirements/task/check_update.php @@ -14,6 +14,7 @@ namespace phpbb\install\module\requirements\task; use phpbb\filesystem\filesystem; +use phpbb\install\helper\config; use phpbb\install\helper\container_factory; use phpbb\install\helper\iohandler\iohandler_interface; use phpbb\install\helper\update_helper; @@ -34,6 +35,11 @@ class check_update extends task_base */ protected $filesystem; + /** + * @var config + */ + protected $installer_config; + /** * @var iohandler_interface */ @@ -69,14 +75,16 @@ class check_update extends task_base * * @param container_factory $container * @param filesystem $filesystem + * @param config $config * @param iohandler_interface $iohandler * @param update_helper $update_helper * @param string $phpbb_root_path * @param string $php_ext */ - public function __construct(container_factory $container, filesystem $filesystem, iohandler_interface $iohandler, update_helper $update_helper, $phpbb_root_path, $php_ext) + public function __construct(container_factory $container, filesystem $filesystem, config $config, iohandler_interface $iohandler, update_helper $update_helper, $phpbb_root_path, $php_ext) { $this->filesystem = $filesystem; + $this->installer_config = $config; $this->iohandler = $iohandler; $this->update_helper = $update_helper; $this->phpbb_root_path = $phpbb_root_path; @@ -117,8 +125,10 @@ class check_update extends task_base $this->iohandler->add_error_message('UPDATE_FILES_NOT_FOUND'); $this->set_test_passed(false); - // If there are no update files, we can't check the version - return false; + // If there are no update files, we can't check the version etc + // However, we can let the users run migrations if they really want to... + $this->installer_config->set('disable_filesystem_update', true); + return true; } // Recover version numbers -- cgit v1.2.1 From 37705353c53a391aa44da7a30f10ed824a442cfc Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 6 Feb 2016 14:10:48 +0100 Subject: [ticket/14460] Use the selected language with AJAX requests as well PHPBB3-14460 --- phpBB/phpbb/install/controller/helper.php | 7 +------ phpBB/phpbb/install/controller/install.php | 3 +-- phpBB/phpbb/install/controller/update.php | 3 +-- phpBB/phpbb/install/helper/config.php | 16 ++++++++++------ phpBB/phpbb/install/helper/iohandler/factory.php | 2 -- 5 files changed, 13 insertions(+), 18 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 6859414236..ff7e691224 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -183,11 +183,6 @@ class helper if (!empty($submit)) { $lang = $this->phpbb_request->variable('language', ''); - - if (!empty($lang)) - { - $this->language_cookie = $lang; - } } // Retrieve language from cookie @@ -195,10 +190,10 @@ class helper if (empty($lang) && !empty($lang_cookie)) { $lang = $lang_cookie; - $this->language_cookie = $lang; } $lang = (!empty($lang) && strpos($lang, '/') === false) ? $lang : null; + $this->language_cookie = $lang; $this->render_language_select($lang); diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index b987d91c6a..92506872a3 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -123,6 +123,7 @@ class install // Set the appropriate input-output handler $this->installer->set_iohandler($this->iohandler_factory->get()); + $this->controller_helper->handle_language_select(); if ($this->request->is_ajax()) { @@ -142,8 +143,6 @@ class install // Determine whether the installation was started or not if (true) { - $this->controller_helper->handle_language_select(); - // Set active stage $this->menu_provider->set_nav_property( array('install', 0, 'introduction'), diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php index 9fff11cae8..6b88827940 100644 --- a/phpBB/phpbb/install/controller/update.php +++ b/phpBB/phpbb/install/controller/update.php @@ -122,6 +122,7 @@ class update // Set the appropriate input-output handler $this->installer->set_iohandler($this->iohandler_factory->get()); + $this->controller_helper->handle_language_select(); // Render the intro page if ($this->request->is_ajax()) @@ -140,8 +141,6 @@ class update } else { - $this->controller_helper->handle_language_select(); - // Set active stage $this->menu_provider->set_nav_property( array('update', 0, 'introduction'), diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index ab5af86320..f58925899b 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -227,18 +227,22 @@ class config $file_content = @file_get_contents($this->install_config_file); $serialized_data = trim(substr($file_content, 8)); - $this->installer_config = array(); - $this->progress_data = array(); - $this->navigation_data = array(); + $installer_config = array(); + $progress_data = array(); + $navigation_data = array(); if (!empty($serialized_data)) { $unserialized_data = json_decode($serialized_data, true); - $this->installer_config = (is_array($unserialized_data['installer_config'])) ? $unserialized_data['installer_config'] : array(); - $this->progress_data = (is_array($unserialized_data['progress_data'])) ? $unserialized_data['progress_data'] : array(); - $this->navigation_data = (is_array($unserialized_data['navigation_data'])) ? $unserialized_data['navigation_data'] : array(); + $installer_config = (is_array($unserialized_data['installer_config'])) ? $unserialized_data['installer_config'] : array(); + $progress_data = (is_array($unserialized_data['progress_data'])) ? $unserialized_data['progress_data'] : array(); + $navigation_data = (is_array($unserialized_data['navigation_data'])) ? $unserialized_data['navigation_data'] : array(); } + + $this->installer_config = array_merge($this->installer_config, $installer_config); + $this->progress_data = array_merge($this->progress_data, $progress_data); + $this->navigation_data = array_merge($this->navigation_data, $navigation_data); } /** diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php index 52d24e49b2..1e8395760a 100644 --- a/phpBB/phpbb/install/helper/iohandler/factory.php +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -75,7 +75,5 @@ class factory throw new iohandler_not_implemented_exception(); break; } - - throw new iohandler_not_implemented_exception(); } } -- cgit v1.2.1 From 955b9ede33c5696173a760ea271ec32d79e843b9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 11 Feb 2016 13:18:30 +0100 Subject: [ticket/14462] Further speed improvements - Cache the secondary container - Only initialize tasks/modules that are being used - Add timeout error message in the AJAX UI PHPBB3-14462 --- phpBB/phpbb/install/helper/config.php | 20 ++-- phpBB/phpbb/install/helper/container_factory.php | 18 ++-- .../install/helper/iohandler/ajax_iohandler.php | 63 ++++++++--- .../install/helper/iohandler/cli_iohandler.php | 2 +- .../helper/iohandler/iohandler_interface.php | 4 +- phpBB/phpbb/install/installer.php | 116 ++++++++++++++------- .../install_filesystem/task/create_config_file.php | 2 - .../module/obtain_data/task/obtain_admin_data.php | 1 - .../module/obtain_data/task/obtain_board_data.php | 1 - .../obtain_data/task/obtain_database_data.php | 1 - .../module/obtain_data/task/obtain_email_data.php | 1 - .../task/obtain_file_updater_method.php | 1 - .../module/obtain_data/task/obtain_server_data.php | 1 - .../obtain_data/task/obtain_update_ftp_data.php | 1 - .../obtain_data/task/obtain_update_settings.php | 1 - .../requirements/abstract_requirements_module.php | 37 +------ .../install/module/update_database/task/update.php | 1 - .../task/download_updated_files.php | 1 - .../update_filesystem/task/show_file_status.php | 1 - phpBB/phpbb/install/module_base.php | 97 ++++++++--------- 20 files changed, 197 insertions(+), 173 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index f58925899b..94abf9ca0b 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -95,8 +95,9 @@ class config $this->installer_config = array(); $this->system_data = array(); $this->progress_data = array( - 'last_task_module_name' => '', // Stores the service name of the latest finished module - 'last_task_name' => '', // Stores the service name of the latest finished task + 'last_task_module_neme' => '', // Stores the service name of the latest finished module + 'last_task_module_index' => 0, // Stores the index of the latest finished module + 'last_task_index' => 0, // Stores the index of the latest finished task 'max_task_progress' => 0, 'current_task_progress' => 0, '_restart_points' => array(), @@ -187,21 +188,23 @@ class config /** * Saves the latest executed task * - * @param string $task_service_name Name of the installer task service + * @param int $task_service_index Index of the installer task service in the module */ - public function set_finished_task($task_service_name) + public function set_finished_task($task_service_index) { - $this->progress_data['last_task_name'] = $task_service_name; + $this->progress_data['last_task_index'] = $task_service_index; } /** * Set active module * * @param string $module_service_name Name of the installer module service + * @param int $module_service_index Index of the installer module service */ - public function set_active_module($module_service_name) + public function set_active_module($module_service_name, $module_service_index) { $this->progress_data['last_task_module_name'] = $module_service_name; + $this->progress_data['last_task_module_index'] = $module_service_index; } /** @@ -391,6 +394,11 @@ class config */ public function set_finished_navigation_stage($nav_path) { + if (isset($this->navigation_data['finished']) && in_array($nav_path, $this->navigation_data['finished'])) + { + return; + } + $this->navigation_data['finished'][] = $nav_path; } diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index 6c1ecd2d02..5cf4f8a283 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -13,7 +13,6 @@ namespace phpbb\install\helper; -use phpbb\cache\driver\dummy; use phpbb\install\exception\cannot_build_container_exception; use phpbb\language\language; use phpbb\request\request; @@ -157,25 +156,20 @@ class container_factory ->with_environment('production') ->with_config($phpbb_config_php_file) ->with_config_path($config_path) - ->without_cache() ->without_compiled_container() ->get_container(); // Setting request is required for the compatibility globals as those are generated from // this container - $this->container->register('request')->setSynthetic(true); - $this->container->set('request', $this->request); - - $this->container->register('language')->setSynthetic(true); - $this->container->set('language', $this->language); - - // Replace cache service, as config gets cached, and we don't want that when we are installing - if (!is_dir($other_config_path)) + if (!$this->container->isFrozen()) { - $this->container->register('cache.driver')->setSynthetic(true); - $this->container->set('cache.driver', new dummy()); + $this->container->register('request')->setSynthetic(true); + $this->container->register('language')->setSynthetic(true); } + $this->container->set('request', $this->request); + $this->container->set('language', $this->language); + $this->container->compile(); $phpbb_container = $this->container; diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 31474ae4e9..8c62ec7bd0 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -209,9 +209,15 @@ class ajax_iohandler extends iohandler_base /** * {@inheritdoc} */ - public function send_response() + public function send_response($no_more_output = false) { - $json_data_array = $this->prepare_json_array(); + $json_data_array = $this->prepare_json_array($no_more_output); + + if (empty($json_data_array)) + { + return; + } + $json_data = json_encode($json_data_array); // Try to push content to the browser @@ -223,23 +229,43 @@ class ajax_iohandler extends iohandler_base /** * Prepares iohandler's data to be sent out to the client. * + * @param bool $no_more_output Whether or not there will be more output in this response + * * @return array */ - protected function prepare_json_array() + protected function prepare_json_array($no_more_output = false) { - $json_array = array( - 'errors' => $this->errors, - 'warnings' => $this->warnings, - 'logs' => $this->logs, - 'success' => $this->success, - 'download' => $this->download, - ); + $json_array = array(); + + if (!empty($this->errors)) + { + $json_array['errors'] = $this->errors; + $this->errors = array(); + } + + if (!empty($this->warnings)) + { + $json_array['warnings'] = $this->warnings; + $this->warnings = array(); + } - $this->errors = array(); - $this->warnings = array(); - $this->logs = array(); - $this->success = array(); - $this->download = array(); + if (!empty($this->logs)) + { + $json_array['logs'] = $this->logs; + $this->logs = array(); + } + + if (!empty($this->success)) + { + $json_array['success'] = $this->success; + $this->success = array(); + } + + if (!empty($this->download)) + { + $json_array['download'] = $this->download; + $this->download = array(); + } if (!empty($this->form)) { @@ -293,6 +319,11 @@ class ajax_iohandler extends iohandler_base $this->redirect_url = array(); } + if ($no_more_output) + { + $json_array['over'] = true; + } + return $json_array; } @@ -398,7 +429,7 @@ class ajax_iohandler extends iohandler_base public function redirect($url, $use_ajax = false) { $this->redirect_url = array('url' => $url, 'use_ajax' => $use_ajax); - $this->send_response(); + $this->send_response(true); } /** diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 7945904524..94550d2db0 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -114,7 +114,7 @@ class cli_iohandler extends iohandler_base /** * {@inheritdoc} */ - public function send_response() + public function send_response($no_more_output = false) { } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index 6b3839506f..f22f33d9cb 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -20,8 +20,10 @@ interface iohandler_interface { /** * Renders or returns response message + * + * @param bool $no_more_output Whether or not there will be more output in this output unit */ - public function send_response(); + public function send_response($no_more_output = false); /** * Returns input variable diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index a41b4cd6a6..adf0ec8ac2 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -15,11 +15,13 @@ namespace phpbb\install; use phpbb\cache\driver\driver_interface; use phpbb\di\ordered_service_collection; +use phpbb\install\exception\cannot_build_container_exception; use phpbb\install\exception\installer_config_not_writable_exception; use phpbb\install\exception\jump_to_restart_point_exception; use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; +use phpbb\install\helper\container_factory; use phpbb\install\helper\iohandler\cli_iohandler; use phpbb\install\helper\iohandler\iohandler_interface; use phpbb\path_helper; @@ -31,13 +33,18 @@ class installer */ protected $cache; + /** + * @var container_factory + */ + protected $container_factory; + /** * @var config */ protected $install_config; /** - * @var array + * @var ordered_service_collection */ protected $installer_modules; @@ -58,19 +65,27 @@ class installer */ protected $module_step_count; + /** + * @var bool + */ + protected $purge_cache_before; + /** * Constructor * * @param driver_interface $cache Cache service * @param config $config Installer config handler * @param path_helper $path_helper Path helper + * @param container_factory $container Container */ - public function __construct(driver_interface $cache, config $config, path_helper $path_helper) + public function __construct(driver_interface $cache, config $config, path_helper $path_helper, container_factory $container) { $this->cache = $cache; $this->install_config = $config; + $this->container_factory = $container; $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); + $this->purge_cache_before = false; } /** @@ -96,6 +111,16 @@ class installer $this->iohandler = $iohandler; } + /** + * Sets whether to purge cache before the installation process + * + * @param bool $purge_cache_before + */ + public function set_purge_cache_before($purge_cache_before) + { + $this->purge_cache_before = $purge_cache_before; + } + /** * Run phpBB installer */ @@ -104,9 +129,16 @@ class installer // Load install progress $this->install_config->load_config(); + if (!$this->install_config->get('cache_purged_before', false) && $this->purge_cache_before) + { + /** @var \phpbb\cache\driver\driver_interface $cache */ + $cache = $this->container_factory->get('cache.driver'); + $cache->purge(); + $this->install_config->set('cache_purged_before', true); + } + // Recover install progress - $module_name = $this->recover_progress(); - $module_found = false; + $module_index = $this->recover_progress(); // Variable used to check if the install process have been finished $install_finished = false; @@ -141,29 +173,13 @@ class installer try { - foreach ($this->installer_modules as $name => $module) - { - // Skip forward until the current task is reached - if (!$module_found) - { - if ($module_name === $name || empty($module_name)) - { - $module_found = true; - } - else - { - continue; - } - } + $iterator = $this->installer_modules->getIterator(); + $iterator->seek($module_index); - // Log progress - $this->install_config->set_active_module($name); - - // Run until there are available resources - if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) - { - throw new resource_limit_reached_exception(); - } + while ($iterator->valid()) + { + $module = $iterator->current(); + $name = $iterator->key(); // Check if module should be executed if (!$module->is_essential() && !$module->check_requirements()) @@ -176,17 +192,31 @@ class installer $name, )); $this->install_config->increment_current_task_progress($this->module_step_count[$name]); - continue; + } + else + { + // Set the correct stage in the navigation bar + $this->install_config->set_active_navigation_stage($module->get_navigation_stage_path()); + $this->iohandler->set_active_stage_menu($module->get_navigation_stage_path()); + + $this->iohandler->send_response(); + + $module->run(); + + $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path()); + $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path()); } - // Set the correct stage in the navigation bar - $this->install_config->set_active_navigation_stage($module->get_navigation_stage_path()); - $this->iohandler->set_active_stage_menu($module->get_navigation_stage_path()); + $module_index++; + $iterator->next(); - $module->run(); + // Save progress + $this->install_config->set_active_module($name, $module_index); - $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path()); - $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path()); + if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)) + { + throw new resource_limit_reached_exception(); + } } // Installation finished @@ -208,7 +238,7 @@ class installer } catch (user_interaction_required_exception $e) { - // Do nothing + $this->iohandler->send_response(true); } catch (resource_limit_reached_exception $e) { @@ -222,7 +252,7 @@ class installer catch (\Exception $e) { $this->iohandler->add_error_message($e->getMessage()); - $this->iohandler->send_response(); + $this->iohandler->send_response(true); $fail_cleanup = true; } @@ -230,11 +260,12 @@ class installer { // Send install finished message $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count()); + $this->iohandler->send_response(true); } else if ($send_refresh) { $this->iohandler->request_refresh(); - $this->iohandler->send_response(); + $this->iohandler->send_response(true); } // Save install progress @@ -244,6 +275,17 @@ class installer { $this->install_config->clean_up_config_file(); $this->cache->purge(); + + try + { + /** @var \phpbb\cache\driver\driver_interface $cache */ + $cache = $this->container_factory->get('cache.driver'); + $cache->purge(); + } + catch (cannot_build_container_exception $e) + { + // Do not do anything, this is just means there is no config.php yet + } } else { @@ -270,6 +312,6 @@ class installer protected function recover_progress() { $progress_array = $this->install_config->get_progress_data(); - return $progress_array['last_task_module_name']; + return $progress_array['last_task_module_index']; } } diff --git a/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php b/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php index e0890a929c..5bc425b929 100644 --- a/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php +++ b/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php @@ -129,7 +129,6 @@ class create_config_file extends \phpbb\install\task_base else { $this->iohandler->add_error_message('UNABLE_TO_WRITE_CONFIG_FILE'); - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } @@ -139,7 +138,6 @@ class create_config_file extends \phpbb\install\task_base { // We were unable to create the lock file - abort $this->iohandler->add_error_message('UNABLE_TO_WRITE_LOCK'); - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } @fclose($fp); 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 index ac305e8ab5..d1f1af6b83 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php @@ -136,7 +136,6 @@ class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\insta $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(); } 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 index 6c54561d14..ff2a0a2f86 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php @@ -164,7 +164,6 @@ 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(); } 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 index 3458aab63e..ce720dbf76 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php @@ -188,7 +188,6 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in $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(); } 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 index b04b8e353f..606e4a2ddd 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php @@ -144,7 +144,6 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta $this->io_handler->add_user_form_group('EMAIL_CONFIG', $email_form); - $this->io_handler->send_response(); throw new user_interaction_required_exception(); } } diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_file_updater_method.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_file_updater_method.php index 9bcb73a6a9..d5a8855c37 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_file_updater_method.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_file_updater_method.php @@ -115,7 +115,6 @@ class obtain_file_updater_method extends task_base ), )); - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } } 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 index 654b5534a9..1ef70eae08 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php @@ -180,7 +180,6 @@ class obtain_server_data extends \phpbb\install\task_base implements \phpbb\inst $this->io_handler->add_user_form_group('SERVER_CONFIG', $server_form); - $this->io_handler->send_response(); throw new user_interaction_required_exception(); } } diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php index a4d362a0f1..f31472fc58 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php @@ -141,7 +141,6 @@ class obtain_update_ftp_data extends task_base ), )); - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } } diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php index be6404dcd8..c139b70fa4 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php @@ -93,7 +93,6 @@ class obtain_update_settings extends task_base ), )); - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } } diff --git a/phpBB/phpbb/install/module/requirements/abstract_requirements_module.php b/phpBB/phpbb/install/module/requirements/abstract_requirements_module.php index 26593e6777..121b4ff4e5 100644 --- a/phpBB/phpbb/install/module/requirements/abstract_requirements_module.php +++ b/phpBB/phpbb/install/module/requirements/abstract_requirements_module.php @@ -13,7 +13,6 @@ namespace phpbb\install\module\requirements; -use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\module_base; @@ -25,41 +24,8 @@ abstract class abstract_requirements_module extends module_base public function run() { $tests_passed = true; - - // Recover install progress - $task_name = $this->recover_progress(); - $task_found = false; - - /** - * @var string $name ID of the service - * @var \phpbb\install\task_interface $task Task object - */ foreach ($this->task_collection as $name => $task) { - // Run until there are available resources - if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) - { - throw new resource_limit_reached_exception(); - } - - // Skip forward until the next task is reached - if (!$task_found) - { - if ($name === $task_name || empty($task_name)) - { - $task_found = true; - - if ($name === $task_name) - { - continue; - } - } - else - { - continue; - } - } - // Check if we can run the task if (!$task->is_essential() && !$task->check_requirements()) { @@ -76,7 +42,7 @@ abstract class abstract_requirements_module extends module_base } // Module finished, so clear task progress - $this->install_config->set_finished_task(''); + $this->install_config->set_finished_task(0); // Check if tests have failed if (!$tests_passed) @@ -91,7 +57,6 @@ abstract class abstract_requirements_module extends module_base )); // Send the response and quit - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } } diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index aa44d403dd..4b2baf2c23 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -158,7 +158,6 @@ class update extends task_base array_unshift($msg, $e->getMessage()); $this->iohandler->add_error_message($msg); - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php index 9271e8fd50..f911b7ac62 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php @@ -101,7 +101,6 @@ class download_updated_files extends task_base ), )); - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php index e712b8ad6a..c46c05500a 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php @@ -136,7 +136,6 @@ class show_file_status extends task_base )); // Show results to the user - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } else diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index fb68c3aca2..f75e8cda02 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -105,47 +105,23 @@ abstract class module_base implements module_interface public function run() { // Recover install progress - $task_name = $this->recover_progress(); - $task_found = false; - - /** - * @var string $name ID of the service - * @var \phpbb\install\task_interface $task Task object - */ - foreach ($this->task_collection as $name => $task) - { - // Run until there are available resources - if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) - { - throw new resource_limit_reached_exception(); - } + $task_index = $this->recover_progress(); + $iterator = $this->task_collection->getIterator(); - // Skip forward until the next task is reached - if (!$task_found) - { - if ($name === $task_name || empty($task_name)) - { - $task_found = true; - - if ($name === $task_name) - { - continue; - } - } - else - { - continue; - } - } + if ($task_index < $iterator->count()) + { + $iterator->seek($task_index); + } + else + { + $this->install_config->set_finished_task(0); + return; + } - // Send progress information - if ($this->allow_progress_bar) - { - $this->iohandler->set_progress( - $task->get_task_lang_name(), - $this->install_config->get_current_task_progress() - ); - } + while ($iterator->valid()) + { + $task = $iterator->current(); + $name = $iterator->key(); // Check if we can run the task if (!$task->is_essential() && !$task->check_requirements()) @@ -156,20 +132,33 @@ abstract class module_base implements module_interface )); $this->install_config->increment_current_task_progress($this->task_step_count[$name]); - continue; } - - if ($this->allow_progress_bar) + else { - // Only increment progress by one, as if a task has more than one steps - // then that should be incremented in the task itself - $this->install_config->increment_current_task_progress(); - } + // Send progress information + if ($this->allow_progress_bar) + { + $this->iohandler->set_progress( + $task->get_task_lang_name(), + $this->install_config->get_current_task_progress() + ); - $task->run(); + $this->iohandler->send_response(); + } - // Log install progress - $this->install_config->set_finished_task($name); + $task->run(); + + if ($this->allow_progress_bar) + { + // Only increment progress by one, as if a task has more than one steps + // then that should be incremented in the task itself + $this->install_config->increment_current_task_progress(); + } + } + + $task_index++; + $this->install_config->set_finished_task($task_index); + $iterator->next(); // Send progress information if ($this->allow_progress_bar) @@ -181,10 +170,16 @@ abstract class module_base implements module_interface } $this->iohandler->send_response(); + + // Run until there are available resources + if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) + { + throw new resource_limit_reached_exception(); + } } // Module finished, so clear task progress - $this->install_config->set_finished_task(''); + $this->install_config->set_finished_task(0); } /** @@ -195,7 +190,7 @@ abstract class module_base implements module_interface protected function recover_progress() { $progress_array = $this->install_config->get_progress_data(); - return $progress_array['last_task_name']; + return $progress_array['last_task_index']; } /** -- cgit v1.2.1 From 68091561abef2c2f0674e3a461401f10f2ef5a25 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 14:20:04 +0100 Subject: [ticket/14462] Refactor tasks to be more modular PHPBB3-14462 --- .../install/module/install_data/task/add_bots.php | 22 +- .../module/install_data/task/add_modules.php | 428 +++++++++++++-------- .../install_database/task/add_config_settings.php | 20 + .../install_database/task/add_default_data.php | 21 + .../module/install_database/task/add_tables.php | 151 ++++++++ .../install_database/task/create_schema_file.php | 164 ++++++++ .../install_database/task/set_up_database.php | 164 ++++++++ .../module/install_finish/task/notify_user.php | 6 +- .../install_finish/task/populate_migrations.php | 24 +- 9 files changed, 835 insertions(+), 165 deletions(-) create mode 100644 phpBB/phpbb/install/module/install_database/task/add_tables.php create mode 100644 phpBB/phpbb/install/module/install_database/task/create_schema_file.php create mode 100644 phpBB/phpbb/install/module/install_database/task/set_up_database.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php index 2ee641ff63..b22c8257e4 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_bots.php +++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php @@ -13,6 +13,8 @@ namespace phpbb\install\module\install_data\task; +use phpbb\install\exception\resource_limit_reached_exception; + class add_bots extends \phpbb\install\task_base { /** @@ -179,7 +181,10 @@ class add_bots extends \phpbb\install\task_base $this->io_handler->add_error_message('NO_GROUP'); } - foreach ($this->bot_list as $bot_name => $bot_ary) + $i = $this->install_config->get('add_bot_index', 0); + $bot_list = array_slice($this->bot_list, $i); + + foreach ($bot_list as $bot_name => $bot_ary) { $user_row = array( 'user_type' => USER_IGNORE, @@ -221,6 +226,21 @@ class add_bots extends \phpbb\install\task_base )); $this->db->sql_query($sql); + + $i++; + + // Run until there are available resources + if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) + { + break; + } + } + + $this->install_config->set('add_bot_index', $i); + + if ($i < sizeof($this->bot_list)) + { + throw new resource_limit_reached_exception(); } } diff --git a/phpBB/phpbb/install/module/install_data/task/add_modules.php b/phpBB/phpbb/install/module/install_data/task/add_modules.php index bfbe6282bc..2f3a25a9c2 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_modules.php +++ b/phpBB/phpbb/install/module/install_data/task/add_modules.php @@ -13,8 +13,18 @@ namespace phpbb\install\module\install_data\task; +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\helper\config; +use phpbb\install\helper\container_factory; +use phpbb\install\helper\iohandler\iohandler_interface; + class add_modules extends \phpbb\install\task_base { + /** + * @var config + */ + protected $config; + /** * @var \phpbb\db\driver\driver_interface */ @@ -136,12 +146,13 @@ class add_modules extends \phpbb\install\task_base /** * Constructor * - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler - * @param \phpbb\install\helper\container_factory $container Installer's DI container + * @parma config $config Installer's config + * @param iohandler_interface $iohandler Installer's input-output handler + * @param container_factory $container Installer's DI container */ - public function __construct(\phpbb\install\helper\iohandler\iohandler_interface $iohandler, - \phpbb\install\helper\container_factory $container) + public function __construct(config $config, iohandler_interface $iohandler, container_factory $container) { + $this->config = $config; $this->db = $container->get('dbal.conn'); $this->extension_manager = $container->get('ext.manager'); $this->iohandler = $iohandler; @@ -158,11 +169,19 @@ class add_modules extends \phpbb\install\task_base $this->db->sql_return_on_error(true); $module_classes = array('acp', 'mcp', 'ucp'); + $total = sizeof($module_classes); + $i = $this->config->get('module_class_index', 0); + $module_classes = array_slice($module_classes, $i); + foreach ($module_classes as $module_class) { - $categories = array(); + $categories = $this->config->get('module_categories_array', array()); + + $k = $this->config->get('module_categories_index', 0); + $module_categories = array_slice($this->module_categories[$module_class], $k); + $timed_out = false; - foreach ($this->module_categories[$module_class] as $cat_name => $subs) + foreach ($module_categories as $cat_name => $subs) { // Check if this sub-category has a basename. If it has, use it. $basename = (isset($this->module_categories_basenames[$cat_name])) ? $this->module_categories_basenames[$cat_name] : ''; @@ -221,11 +240,31 @@ class add_modules extends \phpbb\install\task_base $categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id']; } } + + $k++; + + // Run until there are available resources + if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) + { + $timed_out = true; + break; + } + } + + $this->config->set('module_categories_array', $categories); + $this->config->set('module_categories_index', $k); + + if ($timed_out) + { + throw new resource_limit_reached_exception(); } // Get the modules we want to add... returned sorted by name $module_info = $this->module_manager->get_module_infos($module_class); + $k = $this->config->get('module_info_index', 0); + $module_info = array_slice($module_info, $k); + foreach ($module_info as $module_basename => $fileinfo) { foreach ($fileinfo['modes'] as $module_mode => $row) @@ -258,189 +297,256 @@ class add_modules extends \phpbb\install\task_base } } } - } - // Move some of the modules around since the code above will put them in the wrong place - if ($module_class === 'acp') - { - // Move main module 4 up... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_main' - AND module_class = 'acp' - AND module_mode = 'main'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + $k++; - $this->module_manager->move_module_by($row, 'acp', 'move_up', 4); - - // Move permissions intro screen module 4 up... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_permissions' - AND module_class = 'acp' - AND module_mode = 'intro'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + // Run until there are available resources + if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) + { + $timed_out = true; + break; + } + } - $this->module_manager->move_module_by($row, 'acp', 'move_up', 4); + $this->config->set('module_info_index', $k); - // Move manage users screen module 5 up... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_users' - AND module_class = 'acp' - AND module_mode = 'overview'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $this->module_manager->move_module_by($row, 'acp', 'move_up', 5); + // Run until there are available resources + if ($timed_out) + { + throw new resource_limit_reached_exception(); + } - // Move extension management module 1 up... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_EXTENSION_MANAGEMENT' - AND module_class = 'acp' - AND module_mode = '' - AND module_basename = ''"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + // Move some of the modules around since the code above will put them in the wrong place + if (!$this->config->get('modules_ordered', false)) + { + $this->order_modules($module_class); + $this->config->set('modules_ordered', true); - $this->module_manager->move_module_by($row, 'acp', 'move_up', 1); + // Run until there are available resources + if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) + { + throw new resource_limit_reached_exception(); + } } - if ($module_class == 'mcp') + // And now for the special ones + // (these are modules which appear in multiple categories and thus get added manually + // to some for more control) + if (isset($this->module_extras[$module_class])) { - // Move pm report details module 3 down... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'mcp_pm_reports' - AND module_class = 'mcp' - AND module_mode = 'pm_report_details'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + $this->add_module_extras($module_class); + } - $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + $this->module_manager->remove_cache_file($module_class); - // Move closed pm reports module 3 down... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'mcp_pm_reports' - AND module_class = 'mcp' - AND module_mode = 'pm_reports_closed'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + $i++; - $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + $this->config->set('module_class_index', $i); + $this->config->set('module_categories_index', 0); + $this->config->set('module_info_index', 0); + $this->config->set('added_extra_modules', false); + $this->config->set('modules_ordered', false); + $this->config->set('module_categories_array', array()); - // Move open pm reports module 3 down... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'mcp_pm_reports' - AND module_class = 'mcp' - AND module_mode = 'pm_reports'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + // Run until there are available resources + if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) + { + break; } + } - if ($module_class == 'ucp') - { - // Move attachment module 4 down... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'ucp_attachments' - AND module_class = 'ucp' - AND module_mode = 'attachments'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + if ($i < $total) + { + throw new resource_limit_reached_exception(); + } + } - $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4); + /** + * Move modules to their correct place + * + * @param string $module_class + */ + protected function order_modules($module_class) + { + if ($module_class == 'acp') + { + // Move main module 4 up... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_main' + AND module_class = 'acp' + AND module_mode = 'main'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'acp', 'move_up', 4); + + // Move permissions intro screen module 4 up... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_permissions' + AND module_class = 'acp' + AND module_mode = 'intro'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'acp', 'move_up', 4); + + // Move manage users screen module 5 up... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_users' + AND module_class = 'acp' + AND module_mode = 'overview'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'acp', 'move_up', 5); + + // Move extension management module 1 up... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_EXTENSION_MANAGEMENT' + AND module_class = 'acp' + AND module_mode = '' + AND module_basename = ''"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'acp', 'move_up', 1); + } - // Move notification options module 4 down... - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'ucp_notifications' - AND module_class = 'ucp' - AND module_mode = 'notification_options'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + if ($module_class == 'mcp') + { + // Move pm report details module 3 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'mcp_pm_reports' + AND module_class = 'mcp' + AND module_mode = 'pm_report_details'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + + // Move closed pm reports module 3 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'mcp_pm_reports' + AND module_class = 'mcp' + AND module_mode = 'pm_reports_closed'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + + // Move open pm reports module 3 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'mcp_pm_reports' + AND module_class = 'mcp' + AND module_mode = 'pm_reports'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3); + } - $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4); + if ($module_class == 'ucp') + { + // Move attachment module 4 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_attachments' + AND module_class = 'ucp' + AND module_mode = 'attachments'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4); + + // Move notification options module 4 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_notifications' + AND module_class = 'ucp' + AND module_mode = 'notification_options'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4); + + // Move OAuth module 5 down... + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_auth_link' + AND module_class = 'ucp' + AND module_mode = 'auth_link'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->module_manager->move_module_by($row, 'ucp', 'move_down', 5); + } + } - // Move OAuth module 5 down... + /** + * Add extra modules + * + * @param string $module_class + */ + protected function add_module_extras($module_class) + { + foreach ($this->module_extras[$module_class] as $cat_name => $mods) + { + $sql = 'SELECT module_id, left_id, right_id + FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($cat_name) . "' + AND module_class = '" . $this->db->sql_escape($module_class) . "'"; + $result = $this->db->sql_query_limit($sql, 1); + $row2 = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + foreach ($mods as $mod_name) + { $sql = 'SELECT * FROM ' . MODULES_TABLE . " - WHERE module_basename = 'ucp_auth_link' - AND module_class = 'ucp' - AND module_mode = 'auth_link'"; - $result = $this->db->sql_query($sql); + WHERE module_langname = '" . $this->db->sql_escape($mod_name) . "' + AND module_class = '" . $this->db->sql_escape($module_class) . "' + AND module_basename <> ''"; + $result = $this->db->sql_query_limit($sql, 1); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - $this->module_manager->move_module_by($row, 'ucp', 'move_down', 5); - } - - // And now for the special ones - // (these are modules which appear in multiple categories and thus get added manually - // to some for more control) - if (isset($this->module_extras[$module_class])) - { - foreach ($this->module_extras[$module_class] as $cat_name => $mods) - { - $sql = 'SELECT module_id, left_id, right_id - FROM ' . MODULES_TABLE . " - WHERE module_langname = '" . $this->db->sql_escape($cat_name) . "' - AND module_class = '" . $this->db->sql_escape($module_class) . "'"; - $result = $this->db->sql_query_limit($sql, 1); - $row2 = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - foreach ($mods as $mod_name) - { - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_langname = '" . $this->db->sql_escape($mod_name) . "' - AND module_class = '" . $this->db->sql_escape($module_class) . "' - AND module_basename <> ''"; - $result = $this->db->sql_query_limit($sql, 1); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $module_data = array( - 'module_basename' => $row['module_basename'], - 'module_enabled' => (int) $row['module_enabled'], - 'module_display' => (int) $row['module_display'], - 'parent_id' => (int) $row2['module_id'], - 'module_class' => $row['module_class'], - 'module_langname' => $row['module_langname'], - 'module_mode' => $row['module_mode'], - 'module_auth' => $row['module_auth'], - ); + $module_data = array( + 'module_basename' => $row['module_basename'], + 'module_enabled' => (int) $row['module_enabled'], + 'module_display' => (int) $row['module_display'], + 'parent_id' => (int) $row2['module_id'], + 'module_class' => $row['module_class'], + 'module_langname' => $row['module_langname'], + 'module_mode' => $row['module_mode'], + 'module_auth' => $row['module_auth'], + ); - $this->module_manager->update_module_data($module_data); + $this->module_manager->update_module_data($module_data); - // Check for last sql error happened - if ($this->db->get_sql_error_triggered()) - { - $error = $this->db->sql_error($this->db->get_sql_error_sql()); - $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); - } - } + // Check for last sql error happened + if ($this->db->get_sql_error_triggered()) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); } } - - $this->module_manager->remove_cache_file($module_class); } } diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php index 6fb03ff73d..5fd99638c2 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -13,6 +13,8 @@ namespace phpbb\install\module\install_database\task; +use phpbb\install\exception\resource_limit_reached_exception; + /** * Create database schema */ @@ -313,6 +315,10 @@ class add_config_settings extends \phpbb\install\task_base WHERE config_name = 'allow_avatar_upload'"; } + $i = $this->install_config->get('add_config_settings_index', 0); + $total = sizeof($sql_ary); + $sql_ary = array_slice($sql_ary, $i); + foreach ($sql_ary as $sql) { if (!$this->db->sql_query($sql)) @@ -320,6 +326,20 @@ class add_config_settings extends \phpbb\install\task_base $error = $this->db->sql_error($this->db->get_sql_error_sql()); $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); } + + $i++; + + // Run until there are available resources + if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) + { + break; + } + } + + if ($i < $total) + { + $this->install_config->set('add_config_settings_index', $i); + throw new resource_limit_reached_exception(); } } diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php index 3d73a74618..dd1829e6ed 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_default_data.php +++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php @@ -13,6 +13,8 @@ namespace phpbb\install\module\install_database\task; +use phpbb\install\exception\resource_limit_reached_exception; + /** * Create database schema */ @@ -96,6 +98,10 @@ class add_default_data extends \phpbb\install\task_base $sql_query = $this->database_helper->remove_comments($sql_query); $sql_query = $this->database_helper->split_sql_file($sql_query, $dbms_info[$dbms]['DELIM']); + $i = $this->config->get('add_default_data_index', 0); + $total = sizeof($sql_query); + $sql_query = array_slice($sql_query, $i); + foreach ($sql_query as $sql) { if (!$this->db->sql_query($sql)) @@ -103,6 +109,21 @@ class add_default_data extends \phpbb\install\task_base $error = $this->db->sql_error($this->db->get_sql_error_sql()); $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); } + + $i++; + + // Run until there are available resources + if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) + { + break; + } + } + + $this->config->set('add_default_data_index', $i); + + if ($i < $total) + { + throw new resource_limit_reached_exception(); } } diff --git a/phpBB/phpbb/install/module/install_database/task/add_tables.php b/phpBB/phpbb/install/module/install_database/task/add_tables.php new file mode 100644 index 0000000000..a0b19950be --- /dev/null +++ b/phpBB/phpbb/install/module/install_database/task/add_tables.php @@ -0,0 +1,151 @@ + + * @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\install_database\task; + +use phpbb\install\exception\resource_limit_reached_exception; + +/** + * Create tables + */ +class add_tables extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\config + */ + protected $config; + + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\db\tools\tools_interface + */ + protected $db_tools; + + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var string + */ + protected $schema_file_path; + + /** + * Constructor + * + * @param \phpbb\install\helper\config $config + * @param \phpbb\install\helper\database $db_helper + * @param \phpbb\filesystem\filesystem_interface $filesystem + * @param string $phpbb_root_path + */ + public function __construct(\phpbb\install\helper\config $config, + \phpbb\install\helper\database $db_helper, + \phpbb\filesystem\filesystem_interface $filesystem, + $phpbb_root_path) + { + $dbms = $db_helper->get_available_dbms($config->get('dbms')); + $dbms = $dbms[$config->get('dbms')]['DRIVER']; + $factory = new \phpbb\db\tools\factory(); + + $this->db = new $dbms(); + $this->db->sql_connect( + $config->get('dbhost'), + $config->get('dbuser'), + $config->get('dbpasswd'), + $config->get('dbname'), + $config->get('dbport'), + false, + false + ); + + $this->config = $config; + $this->db_tools = $factory->get($this->db); + $this->filesystem = $filesystem; + $this->schema_file_path = $phpbb_root_path . 'store/schema.json'; + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->db->sql_return_on_error(true); + + $table_prefix = $this->config->get('table_prefix'); + $change_prefix = $this->config->get('change_table_prefix', true); + + if (!defined('CONFIG_TABLE')) + { + // CONFIG_TABLE is required by sql_create_index() to check the + // length of index names. However table_prefix is not defined + // here yet, so we need to create the constant ourselves. + define('CONFIG_TABLE', $table_prefix . 'config'); + } + + $db_table_schema = @file_get_contents($this->schema_file_path); + $db_table_schema = json_decode($db_table_schema, true); + $total = sizeof($db_table_schema); + $i = $this->config->get('add_table_index', 0); + $db_table_schema = array_slice($db_table_schema, $i); + + foreach ($db_table_schema as $table_name => $table_data) + { + $i++; + + $this->db_tools->sql_create_table( + ( ($change_prefix) ? ($table_prefix . substr($table_name, 6)) : $table_name ), + $table_data + ); + + // Run until there are available resources + if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) + { + break; + } + } + + $this->config->set('add_table_index', $i); + + if ($i < $total) + { + throw new resource_limit_reached_exception(); + } + else + { + @unlink($this->schema_file_path); + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_CREATE_TABLES'; + } +} diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema_file.php b/phpBB/phpbb/install/module/install_database/task/create_schema_file.php new file mode 100644 index 0000000000..b6d6ece17f --- /dev/null +++ b/phpBB/phpbb/install/module/install_database/task/create_schema_file.php @@ -0,0 +1,164 @@ + + * @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\install_database\task; + +use phpbb\install\exception\resource_limit_reached_exception; + +/** + * Create database schema + */ +class create_schema_file extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\config + */ + protected $config; + + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * Constructor + * + * @param \phpbb\install\helper\config $config Installer's config provider + * @param \phpbb\install\helper\database $db_helper Installer's database helper + * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service + * @param string $phpbb_root_path Path phpBB's root + * @param string $php_ext Extension of PHP files + */ + public function __construct(\phpbb\install\helper\config $config, + \phpbb\install\helper\database $db_helper, + \phpbb\filesystem\filesystem_interface $filesystem, + $phpbb_root_path, + $php_ext) + { + $dbms = $db_helper->get_available_dbms($config->get('dbms')); + $dbms = $dbms[$config->get('dbms')]['DRIVER']; + + $this->db = new $dbms(); + $this->db->sql_connect( + $config->get('dbhost'), + $config->get('dbuser'), + $config->get('dbpasswd'), + $config->get('dbname'), + $config->get('dbport'), + false, + false + ); + + $this->config = $config; + $this->filesystem = $filesystem; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + // Generate database schema + if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) + { + $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); + $this->config->set('change_table_prefix', true); + } + else + { + global $table_prefix; + + // As this task may take a large amount of time to complete refreshing the page might be necessary for some + // server configurations with limited resources + if (!$this->config->get('pre_schema_forced_refresh', false)) + { + if ($this->config->get_time_remaining() < 5) + { + $this->config->set('pre_schema_forced_refresh', true); + throw new resource_limit_reached_exception(); + } + } + + $table_prefix = $this->config->get('table_prefix'); + + if (!defined('CONFIG_TABLE')) + { + // We need to include the constants file for the table constants + // when we generate the schema from the migration files. + include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); + } + + $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); + $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($this->db, true); + $schema_generator = new \phpbb\db\migration\schema_generator( + $migrator_classes, + new \phpbb\config\config(array()), + $this->db, + $db_tools, + $this->phpbb_root_path, + $this->php_ext, + $table_prefix + ); + $db_table_schema = $schema_generator->get_schema(); + $db_table_schema = json_encode($db_table_schema, JSON_PRETTY_PRINT); + + $this->config->set('change_table_prefix', false); + } + + $fp = @fopen($this->phpbb_root_path . 'store/schema.json', 'wb'); + if (!$fp) + { + throw new \Exception('INST_SCHEMA_FILE_NOT_WRITABLE'); + } + + fwrite($fp, $db_table_schema); + fclose($fp); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_CREATE_DATABASE_SCHEMA_FILE'; + } +} diff --git a/phpBB/phpbb/install/module/install_database/task/set_up_database.php b/phpBB/phpbb/install/module/install_database/task/set_up_database.php new file mode 100644 index 0000000000..49c8ea23ad --- /dev/null +++ b/phpBB/phpbb/install/module/install_database/task/set_up_database.php @@ -0,0 +1,164 @@ + + * @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\install_database\task; + +/** + * Set up database for table generation + */ +class set_up_database extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\config + */ + protected $config; + + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * @var \phpbb\install\helper\database + */ + protected $database_helper; + + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var string + */ + protected $schema_file_path; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param \phpbb\install\helper\config $config + * @param \phpbb\install\helper\database $db_helper + * @param \phpbb\filesystem\filesystem_interface $filesystem + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler + * @param string $phpbb_root_path + */ + public function __construct(\phpbb\install\helper\config $config, + \phpbb\install\helper\database $db_helper, + \phpbb\filesystem\filesystem_interface $filesystem, + \phpbb\install\helper\iohandler\iohandler_interface $iohandler, + $phpbb_root_path) + { + $dbms = $db_helper->get_available_dbms($config->get('dbms')); + $dbms = $dbms[$config->get('dbms')]['DRIVER']; + + $this->db = new $dbms(); + $this->db->sql_connect( + $config->get('dbhost'), + $config->get('dbuser'), + $config->get('dbpasswd'), + $config->get('dbname'), + $config->get('dbport'), + false, + false + ); + + $this->config = $config; + $this->database_helper = $db_helper; + $this->filesystem = $filesystem; + $this->iohandler = $iohandler; + $this->phpbb_root_path = $phpbb_root_path; + + parent::__construct(false); + } + + /** + * {@inheritdoc} + */ + public function check_requirements() + { + $dbms = $this->config->get('dbms'); + $dbms_info = $this->database_helper->get_available_dbms($dbms); + $schema_name = $dbms_info[$dbms]['SCHEMA']; + + if ($dbms === 'mysql') + { + if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) + { + $schema_name .= '_41'; + } + else + { + $schema_name .= '_40'; + } + } + + $this->schema_file_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; + + return $this->filesystem->exists($this->schema_file_path); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->db->sql_return_on_error(true); + + $dbms = $this->config->get('dbms'); + $dbms_info = $this->database_helper->get_available_dbms($dbms); + $delimiter = $dbms_info[$dbms]['DELIM']; + $table_prefix = $this->config->get('table_prefix'); + + $sql_query = @file_get_contents($this->schema_file_path); + $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); + $sql_query = $this->database_helper->remove_comments($sql_query); + $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); + + foreach ($sql_query as $sql) + { + if (!$this->db->sql_query($sql)) + { + $error = $this->db->sql_error($this->db->get_sql_error_sql()); + $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); + } + } + + unset($sql_query); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_SETUP_DATABASE'; + } +} diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php index 5268b85a42..292be57f5f 100644 --- a/phpBB/phpbb/install/module/install_finish/task/notify_user.php +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -87,9 +87,13 @@ class notify_user extends \phpbb\install\task_base $this->php_ext = $php_ext; // We need to reload config for cases when it doesn't have all values + /** @var \phpbb\cache\driver\driver_interface $cache */ + $cache = $container->get('cache.driver'); + $cache->destroy('config'); + $this->config = new db( $container->get('dbal.conn'), - $container->get('cache.driver'), + $cache, $container->get_parameter('tables.config') ); diff --git a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php index 8629d9aea3..34541c361e 100644 --- a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php +++ b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php @@ -13,11 +13,20 @@ namespace phpbb\install\module\install_finish\task; +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\helper\config; +use phpbb\install\helper\container_factory; + /** * Populates migrations */ class populate_migrations extends \phpbb\install\task_base { + /** + * @var config + */ + protected $config; + /** * @var \phpbb\extension\manager */ @@ -31,10 +40,12 @@ class populate_migrations extends \phpbb\install\task_base /** * Constructor * - * @param \phpbb\install\helper\container_factory $container phpBB's DI contianer + * @param config $config Installer's config + * @param container_factory $container phpBB's DI contianer */ - public function __construct(\phpbb\install\helper\container_factory $container) + public function __construct(config $config, container_factory $container) { + $this->config = $config; $this->extension_manager = $container->get('ext.manager'); $this->migrator = $container->get('migrator'); @@ -46,6 +57,15 @@ class populate_migrations extends \phpbb\install\task_base */ public function run() { + if (!$this->config->get('populate_migration_refresh_before', false)) + { + if ($this->config->get_time_remaining() < 1) + { + $this->config->set('populate_migration_refresh_before', true); + throw new resource_limit_reached_exception(); + } + } + $finder = $this->extension_manager->get_finder(); $migrations = $finder -- cgit v1.2.1 From 7c0fb563ec995d0d1fcb24d885a7d9d18838ed9c Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 15:38:34 +0100 Subject: [ticket/14462] Fix CS and typo PHPBB3-14462 --- phpBB/phpbb/install/helper/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index 94abf9ca0b..fad6749019 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -95,7 +95,7 @@ class config $this->installer_config = array(); $this->system_data = array(); $this->progress_data = array( - 'last_task_module_neme' => '', // Stores the service name of the latest finished module + 'last_task_module_name' => '', // Stores the service name of the latest finished module 'last_task_module_index' => 0, // Stores the index of the latest finished module 'last_task_index' => 0, // Stores the index of the latest finished task 'max_task_progress' => 0, -- cgit v1.2.1 From 2efceffaebd96fd6d092c4be8c854a7bcf032592 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 23:30:32 +0100 Subject: [ticket/14462] Fix comments PHPBB3-14462 --- phpBB/phpbb/install/installer.php | 2 +- phpBB/phpbb/install/module/install_data/task/add_bots.php | 2 +- phpBB/phpbb/install/module/install_data/task/add_modules.php | 10 +++++----- .../module/install_database/task/add_config_settings.php | 2 +- .../install/module/install_database/task/add_default_data.php | 2 +- .../phpbb/install/module/install_database/task/add_tables.php | 2 +- phpBB/phpbb/install/module_base.php | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index adf0ec8ac2..b5709e96c7 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -284,7 +284,7 @@ class installer } catch (cannot_build_container_exception $e) { - // Do not do anything, this is just means there is no config.php yet + // Do not do anything, this just means there is no config.php yet } } else diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php index b22c8257e4..d45a6839a0 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_bots.php +++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php @@ -229,7 +229,7 @@ class add_bots extends \phpbb\install\task_base $i++; - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { break; diff --git a/phpBB/phpbb/install/module/install_data/task/add_modules.php b/phpBB/phpbb/install/module/install_data/task/add_modules.php index 2f3a25a9c2..d21a5be823 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_modules.php +++ b/phpBB/phpbb/install/module/install_data/task/add_modules.php @@ -243,7 +243,7 @@ class add_modules extends \phpbb\install\task_base $k++; - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) { $timed_out = true; @@ -300,7 +300,7 @@ class add_modules extends \phpbb\install\task_base $k++; - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) { $timed_out = true; @@ -310,7 +310,7 @@ class add_modules extends \phpbb\install\task_base $this->config->set('module_info_index', $k); - // Run until there are available resources + // Stop execution if resource limit is reached if ($timed_out) { throw new resource_limit_reached_exception(); @@ -322,7 +322,7 @@ class add_modules extends \phpbb\install\task_base $this->order_modules($module_class); $this->config->set('modules_ordered', true); - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) { throw new resource_limit_reached_exception(); @@ -348,7 +348,7 @@ class add_modules extends \phpbb\install\task_base $this->config->set('modules_ordered', false); $this->config->set('module_categories_array', array()); - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) { break; diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php index 5fd99638c2..20b7679ec1 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -329,7 +329,7 @@ class add_config_settings extends \phpbb\install\task_base $i++; - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { break; diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php index dd1829e6ed..f5157637ee 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_default_data.php +++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php @@ -112,7 +112,7 @@ class add_default_data extends \phpbb\install\task_base $i++; - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) { break; diff --git a/phpBB/phpbb/install/module/install_database/task/add_tables.php b/phpBB/phpbb/install/module/install_database/task/add_tables.php index a0b19950be..f344f91582 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_tables.php +++ b/phpBB/phpbb/install/module/install_database/task/add_tables.php @@ -114,7 +114,7 @@ class add_tables extends \phpbb\install\task_base $table_data ); - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) { break; diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index f75e8cda02..527447b4a1 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -171,7 +171,7 @@ abstract class module_base implements module_interface $this->iohandler->send_response(); - // Run until there are available resources + // Stop execution if resource limit is reached if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { throw new resource_limit_reached_exception(); -- cgit v1.2.1 From 5bdfc6167ba13fc525470f89602889ff5bc3ed79 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 25 Feb 2016 22:39:42 +0100 Subject: [ticket/14499] Add command to update the board from CLI PHPBB3-14499 --- .../console/command/install/config/show.php | 12 +- .../console/command/install/config/validate.php | 10 +- .../install/console/command/install/install.php | 2 +- .../install/console/command/update/config/show.php | 123 ++++++++++++++ .../console/command/update/config/validate.php | 124 +++++++++++++++ .../install/console/command/update/update.php | 176 +++++++++++++++++++++ .../obtain_data/task/obtain_update_settings.php | 8 + .../module/requirements/task/check_update.php | 2 +- phpBB/phpbb/install/updater_configuration.php | 40 +++++ 9 files changed, 476 insertions(+), 21 deletions(-) create mode 100644 phpBB/phpbb/install/console/command/update/config/show.php create mode 100644 phpBB/phpbb/install/console/command/update/config/validate.php create mode 100644 phpBB/phpbb/install/console/command/update/update.php create mode 100644 phpBB/phpbb/install/updater_configuration.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php index 5d82d8d1ef..b6c11956fe 100644 --- a/phpBB/phpbb/install/console/command/install/config/show.php +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -14,7 +14,6 @@ namespace phpbb\install\console\command\install\config; use phpbb\install\helper\iohandler\factory; -use phpbb\install\installer; use phpbb\install\installer_configuration; use phpbb\language\language; use Symfony\Component\Config\Definition\Exception\Exception; @@ -33,11 +32,6 @@ class show extends \phpbb\console\command\command */ protected $iohandler_factory; - /** - * @var installer - */ - protected $installer; - /** * @var language */ @@ -48,12 +42,10 @@ class show extends \phpbb\console\command\command * * @param language $language * @param factory $factory - * @param installer $installer */ - public function __construct(language $language, factory $factory, installer $installer) + public function __construct(language $language, factory $factory) { $this->iohandler_factory = $factory; - $this->installer = $installer; $this->language = $language; parent::__construct(new \phpbb\user($language, 'datetime')); @@ -126,6 +118,6 @@ class show extends \phpbb\console\command\command return; } - $iohandler->add_log_message(Yaml::dump(array('installer' => $config), 10, 4, true, false)); + $style->block(Yaml::dump(array('installer' => $config), 10, 4, true, false)); } } diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php index 3bbbc23e34..b48a1acbd4 100644 --- a/phpBB/phpbb/install/console/command/install/config/validate.php +++ b/phpBB/phpbb/install/console/command/install/config/validate.php @@ -14,7 +14,6 @@ namespace phpbb\install\console\command\install\config; use phpbb\install\helper\iohandler\factory; -use phpbb\install\installer; use phpbb\install\installer_configuration; use phpbb\language\language; use Symfony\Component\Config\Definition\Exception\Exception; @@ -33,11 +32,6 @@ class validate extends \phpbb\console\command\command */ protected $iohandler_factory; - /** - * @var installer - */ - protected $installer; - /** * @var language */ @@ -48,12 +42,10 @@ class validate extends \phpbb\console\command\command * * @param language $language * @param factory $factory - * @param installer $installer */ - public function __construct(language $language, factory $factory, installer $installer) + public function __construct(language $language, factory $factory) { $this->iohandler_factory = $factory; - $this->installer = $installer; $this->language = $language; parent::__construct(new \phpbb\user($language, 'datetime')); diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index d76182af92..50c23f6877 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -109,7 +109,7 @@ class install extends \phpbb\console\command\command if ($this->install_helper->is_phpbb_installed()) { - $iohandler->add_error_message('PHPBB_ALREADY_INSTALLED'); + $iohandler->add_error_message('INSTALL_PHPBB_INSTALLED'); return 1; } diff --git a/phpBB/phpbb/install/console/command/update/config/show.php b/phpBB/phpbb/install/console/command/update/config/show.php new file mode 100644 index 0000000000..e462763b5d --- /dev/null +++ b/phpBB/phpbb/install/console/command/update/config/show.php @@ -0,0 +1,123 @@ + +* @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\console\command\update\config; + +use phpbb\install\helper\iohandler\factory; +use phpbb\install\updater_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class show extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + */ + public function __construct(language $language, factory $factory) + { + $this->iohandler_factory = $factory; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('update:config:show') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_SHOW_CONFIG')) + ; + } + + /** + * Show the validated configuration + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); + + return; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return; + } + + $processor = new Processor(); + $configuration = new updater_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return; + } + + $style->block(Yaml::dump(array('updater' => $config), 10, 4, true, false)); + } +} diff --git a/phpBB/phpbb/install/console/command/update/config/validate.php b/phpBB/phpbb/install/console/command/update/config/validate.php new file mode 100644 index 0000000000..18de5eab46 --- /dev/null +++ b/phpBB/phpbb/install/console/command/update/config/validate.php @@ -0,0 +1,124 @@ + +* @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\console\command\update\config; + +use phpbb\install\helper\iohandler\factory; +use phpbb\install\updater_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class validate extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + */ + public function __construct(language $language, factory $factory) + { + $this->iohandler_factory = $factory; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('update:config:validate') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_VALIDATE_CONFIG')) + ; + } + + /** + * Validate the configuration file + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + + return 1; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return 1; + } + + $processor = new Processor(); + $configuration = new updater_configuration(); + + try + { + $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return 1; + } + + $iohandler->add_success_message('CONFIGURATION_VALID'); + return 0; + } +} diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php new file mode 100644 index 0000000000..8e0d45172c --- /dev/null +++ b/phpBB/phpbb/install/console/command/update/update.php @@ -0,0 +1,176 @@ + +* @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\console\command\update; + +use phpbb\install\exception\installer_exception; +use phpbb\install\helper\install_helper; +use phpbb\install\helper\iohandler\cli_iohandler; +use phpbb\install\helper\iohandler\factory; +use phpbb\install\installer; +use phpbb\install\updater_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class update extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var installer + */ + protected $installer; + + /** + * @var install_helper + */ + protected $install_helper; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + * @param installer $installer + * @param install_helper $install_helper + */ + public function __construct(language $language, factory $factory, installer $installer, install_helper $install_helper) + { + $this->iohandler_factory = $factory; + $this->installer = $installer; + $this->language = $language; + $this->install_helper = $install_helper; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('update') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_UPDATE_BOARD')) + ; + } + + /** + * Executes the command update. + * + * Install the board + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $this->installer->set_iohandler($iohandler); + + $config_file = $input->getArgument('config-file'); + + if (!$this->install_helper->is_phpbb_installed()) + { + $iohandler->add_error_message('INSTALL_PHPBB_NOT_INSTALLED'); + + return 1; + } + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); + + return 1; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file)); + + return 1; + } + + $processor = new Processor(); + $configuration = new updater_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return 1; + } + + $this->register_configuration($iohandler, $config); + + try + { + $this->installer->run(); + } + catch (installer_exception $e) + { + $iohandler->add_error_message($e->getMessage()); + return 1; + } + } + + /** + * Register the configuration to simulate the forms. + * + * @param cli_iohandler $iohandler + * @param array $config + */ + private function register_configuration(cli_iohandler $iohandler, $config) + { + $iohandler->set_input('update_type', $config['type']); + $iohandler->set_input('submit_update', 'submit'); + + $iohandler->set_input('method', '.tar'); + $iohandler->set_input('submit_update_file', 'submit'); + } +} diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php index c139b70fa4..3b24e8ba40 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_settings.php @@ -53,6 +53,14 @@ class obtain_update_settings extends task_base if ($this->iohandler->get_input('submit_update', false)) { $update_files = $this->iohandler->get_input('update_type', 'all') === 'all'; + + if ($this->installer_config->get('disable_filesystem_update', false) && $update_files) + { + $this->iohandler->add_error_message('UPDATE_FILES_NOT_FOUND'); + + throw new user_interaction_required_exception(); + } + $this->installer_config->set('do_update_files', $update_files); } else diff --git a/phpBB/phpbb/install/module/requirements/task/check_update.php b/phpBB/phpbb/install/module/requirements/task/check_update.php index 4e9124ff47..cd66ffc8f9 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_update.php +++ b/phpBB/phpbb/install/module/requirements/task/check_update.php @@ -122,7 +122,7 @@ class check_update extends task_base // Check for a valid update directory if (!$this->filesystem->exists($update_files) || !$this->filesystem->is_readable($update_files)) { - $this->iohandler->add_error_message('UPDATE_FILES_NOT_FOUND'); + $this->iohandler->add_warning_message('UPDATE_FILES_NOT_FOUND'); $this->set_test_passed(false); // If there are no update files, we can't check the version etc diff --git a/phpBB/phpbb/install/updater_configuration.php b/phpBB/phpbb/install/updater_configuration.php new file mode 100644 index 0000000000..e992356290 --- /dev/null +++ b/phpBB/phpbb/install/updater_configuration.php @@ -0,0 +1,40 @@ + +* @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; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +class updater_configuration implements ConfigurationInterface +{ + + /** + * Generates the configuration tree builder. + * + * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('updater'); + $rootNode + ->addDefaultsIfNotSet() + ->children() + ->enumNode('type')->values(['all','db_only'])->defaultValue('all')->end() + ->end() + ; + + return $treeBuilder; + } +} -- cgit v1.2.1 From 062358f8b1d9a7fa3d9be97f6b58e06fea7ca844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sun, 28 Feb 2016 00:19:24 +0100 Subject: [ticket/14487] Try to handle connection timeouts PHPBB3-14487 --- phpBB/phpbb/install/controller/timeout_check.php | 80 ++++++++++++++++++++++ .../install/helper/iohandler/ajax_iohandler.php | 41 ++++++++++- phpBB/phpbb/install/installer.php | 22 +++++- 3 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 phpBB/phpbb/install/controller/timeout_check.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/controller/timeout_check.php b/phpBB/phpbb/install/controller/timeout_check.php new file mode 100644 index 0000000000..1c90e3caf3 --- /dev/null +++ b/phpBB/phpbb/install/controller/timeout_check.php @@ -0,0 +1,80 @@ + + * @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\controller; + +use Symfony\Component\HttpFoundation\JsonResponse; + +class timeout_check +{ + /** + * @var helper + */ + protected $helper; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param helper $helper + * @param string $phpbb_root_path + */ + public function __construct(helper $helper, $phpbb_root_path) + { + $this->helper = $helper; + $this->phpbb_root_path = $phpbb_root_path; + } + + /** + * Controller for querying installer status + */ + public function status() + { + $lock_file = $this->phpbb_root_path . 'store/io_lock.lock'; + $response = new JsonResponse(); + + if (!file_exists($lock_file)) + { + $response->setData(array( + 'status' => 'fail', + )); + } + else + { + $fp = @fopen($lock_file, 'r'); + + if ($fp && flock($fp, LOCK_EX | LOCK_NB)) + { + $status = (filesize($lock_file) >= 2 && fread($fp, 2) === 'ok') ? 'continue' : 'fail'; + + $response->setData(array( + 'status' => $status, + )); + flock($fp, LOCK_UN); + fclose($fp); + } + else + { + $response->setData(array( + 'status' => 'running', + )); + } + } + + return $response; + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 8c62ec7bd0..c168d26425 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -41,6 +41,11 @@ class ajax_iohandler extends iohandler_base */ protected $router; + /** + * @var string + */ + protected $phpbb_root_path; + /** * @var string */ @@ -76,6 +81,11 @@ class ajax_iohandler extends iohandler_base */ protected $redirect_url; + /** + * @var resource + */ + protected $file_lock_pointer; + /** * Constructor * @@ -83,8 +93,9 @@ class ajax_iohandler extends iohandler_base * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router + * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; @@ -96,6 +107,7 @@ class ajax_iohandler extends iohandler_base $this->download = array(); $this->redirect_url = array(); $this->file_status = ''; + $this->phpbb_root_path = $root_path; parent::__construct(); } @@ -432,6 +444,33 @@ class ajax_iohandler extends iohandler_base $this->send_response(true); } + /** + * Acquires a file lock + */ + public function acquire_lock() + { + $lock_file = $this->phpbb_root_path . 'store/io_lock.lock'; + $this->file_lock_pointer = @fopen($lock_file, 'w+'); + + if ($this->file_lock_pointer) + { + flock($this->file_lock_pointer, LOCK_EX); + } + } + + /** + * Release file lock + */ + public function release_lock() + { + if ($this->file_lock_pointer) + { + fwrite($this->file_lock_pointer, 'ok'); + flock($this->file_lock_pointer, LOCK_UN); + fclose($this->file_lock_pointer); + } + } + /** * Callback function for language replacing * diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index b5709e96c7..240423ae78 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -22,6 +22,7 @@ use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\exception\user_interaction_required_exception; use phpbb\install\helper\config; use phpbb\install\helper\container_factory; +use phpbb\install\helper\iohandler\ajax_iohandler; use phpbb\install\helper\iohandler\cli_iohandler; use phpbb\install\helper\iohandler\iohandler_interface; use phpbb\path_helper; @@ -126,6 +127,11 @@ class installer */ public function run() { + if ($this->iohandler instanceof ajax_iohandler) + { + $this->iohandler->acquire_lock(); + } + // Load install progress $this->install_config->load_config(); @@ -174,7 +180,16 @@ class installer try { $iterator = $this->installer_modules->getIterator(); - $iterator->seek($module_index); + + if ($module_index < $iterator->count()) + { + $iterator->seek($module_index); + } + else + { + $iterator->seek($module_index - 1); + $iterator->next(); + } while ($iterator->valid()) { @@ -256,6 +271,11 @@ class installer $fail_cleanup = true; } + if ($this->iohandler instanceof ajax_iohandler) + { + $this->iohandler->release_lock(); + } + if ($install_finished) { // Send install finished message -- cgit v1.2.1 From 8ec1a60156f66dd4fe0f0f6e2cfbee1c79132771 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 28 Feb 2016 20:49:18 +0100 Subject: [ticket/14499] Add missing config settings PHPBB3-14499 --- phpBB/phpbb/install/console/command/update/update.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php index 8e0d45172c..dfac13d5d7 100644 --- a/phpBB/phpbb/install/console/command/update/update.php +++ b/phpBB/phpbb/install/console/command/update/update.php @@ -170,7 +170,10 @@ class update extends \phpbb\console\command\command $iohandler->set_input('update_type', $config['type']); $iohandler->set_input('submit_update', 'submit'); - $iohandler->set_input('method', '.tar'); + $iohandler->set_input('compression_method', '.tar'); + $iohandler->set_input('method', 'direct_file'); $iohandler->set_input('submit_update_file', 'submit'); + + $iohandler->set_input('submit_continue_file_update', 'submit'); } } -- cgit v1.2.1 From 52dffef03cb97a54041b1fba638eafb3ed0a5ce0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 29 Feb 2016 20:27:12 +0100 Subject: [ticket/14499] Fix wording and comments PHPBB3-14499 --- phpBB/phpbb/install/console/command/update/update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php index dfac13d5d7..116f42f758 100644 --- a/phpBB/phpbb/install/console/command/update/update.php +++ b/phpBB/phpbb/install/console/command/update/update.php @@ -87,7 +87,7 @@ class update extends \phpbb\console\command\command /** * Executes the command update. * - * Install the board + * Update the board * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance -- cgit v1.2.1 From b1a136e7bd8cc06ee320655a4ee7cf72dcd7c611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Mon, 29 Feb 2016 23:23:31 +0100 Subject: [ticket/14487] Add missing use statement PHPBB3-14487 --- phpBB/phpbb/install/event/kernel_exception_subscriber.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/event/kernel_exception_subscriber.php b/phpBB/phpbb/install/event/kernel_exception_subscriber.php index c2960cb13c..60b7d9a400 100644 --- a/phpBB/phpbb/install/event/kernel_exception_subscriber.php +++ b/phpBB/phpbb/install/event/kernel_exception_subscriber.php @@ -21,6 +21,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; +use Symfony\Component\HttpFoundation\JsonResponse; /** * Exception handler for the installer -- cgit v1.2.1 From fa2ae3a14bebe34c84b0fa40323862c0f813c41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Wed, 2 Mar 2016 21:48:10 +0100 Subject: [ticket/14510] Prevent infinite loop in add_bots task PHPBB3-14510 --- phpBB/phpbb/install/module/install_data/task/add_bots.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php index d45a6839a0..1f1cecceb2 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_bots.php +++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php @@ -214,6 +214,7 @@ class add_bots extends \phpbb\install\task_base // If we can't insert this user then continue to the next one to avoid inconsistent data $this->io_handler->add_error_message('CONV_ERROR_INSERT_BOT'); + $i++; continue; } -- cgit v1.2.1 From 3278ff03e7809dd0bb31771b3928e8676a09c572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sun, 27 Mar 2016 18:25:06 +0200 Subject: [ticket/14393] Fix updater behaviour PHPBB3-14393 --- phpBB/phpbb/install/module/update_database/task/update.php | 2 +- .../phpbb/install/module/update_filesystem/task/file_check.php | 1 + .../install/module/update_filesystem/task/show_file_status.php | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 4b2baf2c23..d8807951d1 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -183,7 +183,7 @@ class update extends task_base ); } - $this->iohandler->finish_progress('INLINE_UPDATE_SUCCESSFUL'); + $this->iohandler->set_progress('INLINE_UPDATE_SUCCESSFUL', $migration_count); $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php index 5dbee6c259..f4b3870148 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -166,6 +166,7 @@ class file_check extends task_base } $this->installer_config->set('update_files', $file_update_info); + $this->installer_config->set('update_info', array()); } /** diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php index c46c05500a..329e6b9315 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php @@ -140,10 +140,14 @@ class show_file_status extends task_base } else { + $this->file_updater->close(); + $conflict_archive_path = $this->installer_config->get('update_file_conflict_archive', null); + // Remove archive - $this->filesystem->remove( - $this->installer_config->get('update_file_conflict_archive', null) - ); + if ($conflict_archive_path !== null && $this->filesystem->exists($conflict_archive_path)) + { + $this->filesystem->remove($conflict_archive_path); + } $this->installer_config->set('update_file_conflict_archive', null); } -- cgit v1.2.1 From 99196a42f201b716243fbc72554e4e0e31830472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sun, 27 Mar 2016 19:25:00 +0200 Subject: [ticket/14564] Fix cookie domain calculation PHPBB3-14564 --- .../install/module/install_database/task/add_config_settings.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php index 20b7679ec1..7a2df01de6 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -129,12 +129,19 @@ class add_config_settings extends \phpbb\install\task_base $this->db->sql_return_on_error(true); $server_name = $this->install_config->get('server_name'); - $cookie_domain = $this->install_config->get('cookie_domain'); $current_time = time(); $user_ip = phpbb_ip_normalise($this->iohandler->get_server_variable('REMOTE_ADDR')); $user_ip = ($user_ip === false) ? '' : $user_ip; $referer = $this->iohandler->get_server_variable('REFERER'); + // Calculate cookie domain + $cookie_domain = $server_name; + + if (strpos($cookie_domain, 'www.') === 0) + { + $cookie_domain = substr($cookie_domain, 3); + } + // Set default config and post data, this applies to all DB's $sql_ary = array( 'INSERT INTO ' . $this->config_table . " (config_name, config_value) -- cgit v1.2.1 From c44a01fd9deba39b43bcaf6979483a5b82bf364e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sun, 27 Mar 2016 20:10:45 +0200 Subject: [ticket/14393] Fix init for conflict archive PHPBB3-14393 --- .../module/update_filesystem/task/show_file_status.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php index 329e6b9315..7f18950cf6 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php @@ -66,11 +66,7 @@ class show_file_status extends task_base $this->cache = $container->get('cache.driver'); // Initialize compression file updater - $compression_method = $this->installer_config->get('compression_method', ''); $this->file_updater = $file_updater_factory->get('compression'); - $conflict_archive = $this->file_updater->init($compression_method); - - $this->installer_config->set('update_file_conflict_archive', $conflict_archive); parent::__construct(false); } @@ -96,6 +92,10 @@ class show_file_status extends task_base // Create archive for merge conflicts if (!empty($merge_conflicts)) { + $compression_method = $this->installer_config->get('compression_method', ''); + $conflict_archive = $this->file_updater->init($compression_method); + $this->installer_config->set('update_file_conflict_archive', $conflict_archive); + foreach ($merge_conflicts as $filename) { $this->file_updater->create_new_file( @@ -111,9 +111,9 @@ class show_file_status extends task_base 'DOWNLOAD_CONFLICTS', 'DOWNLOAD_CONFLICTS_EXPLAIN' ); - } - $this->file_updater->close(); + $this->file_updater->close(); + } // Render update file statuses $file_update_info = $this->installer_config->get('update_files', array()); @@ -140,7 +140,6 @@ class show_file_status extends task_base } else { - $this->file_updater->close(); $conflict_archive_path = $this->installer_config->get('update_file_conflict_archive', null); // Remove archive -- cgit v1.2.1 From 9fc01a42e678a934507dede60b9e1e806ccfd787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Wed, 30 Mar 2016 11:05:45 +0200 Subject: [ticket/14393] Fix db update progress bar PHPBB3-14393 --- phpBB/phpbb/install/module/update_database/task/update.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index d8807951d1..9fed2317e9 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -142,6 +142,7 @@ class update extends task_base $this->migrator->set_migrations($migrations); $migration_count = count($this->migrator->get_migrations()); $this->iohandler->set_task_count($migration_count, true); + $this->installer_config->set_task_progress_count($migration_count); $progress_count = $this->installer_config->get('database_update_count', 0); while (!$this->migrator->finished()) @@ -183,8 +184,6 @@ class update extends task_base ); } - $this->iohandler->set_progress('INLINE_UPDATE_SUCCESSFUL', $migration_count); - $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); $this->config->delete('version_update_from'); -- cgit v1.2.1 From 6d2acb5ba3fbd22b345b312e704021eab1375941 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 24 Mar 2016 13:01:52 +0100 Subject: [ticket/13616] Fix UI tests PHPBB3-13616 --- phpBB/phpbb/install/helper/container_factory.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index 5cf4f8a283..9e372fecde 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -183,6 +183,9 @@ class container_factory // Get compatibilty globals and constants $this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext); + + register_compatibility_globals(); + $this->update_helper->include_file('includes/constants.' . $this->php_ext); } } -- cgit v1.2.1 From 9163cc28647e9936fe9c9e390871f9130d2bf40b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sun, 10 Apr 2016 10:30:15 +0200 Subject: [ticket/14589] Add error messages for failable installer requirements PHPBB3-14589 --- phpBB/phpbb/install/module/requirements/task/check_filesystem.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php index 2aec3915e0..868af39433 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php +++ b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php @@ -177,7 +177,9 @@ class check_filesystem extends \phpbb\install\task_base if (!($exists && $writable)) { $title = ($exists) ? 'FILE_NOT_WRITABLE' : 'FILE_NOT_EXISTS'; - $description = array($title . '_EXPLAIN', $file); + $lang_suffix = '_EXPLAIN'; + $lang_suffix .= ($failable) ? '_OPTIONAL' : ''; + $description = array($title . $lang_suffix, $file); if ($failable) { @@ -244,7 +246,9 @@ class check_filesystem extends \phpbb\install\task_base if (!($exists && $writable)) { $title = ($exists) ? 'DIRECTORY_NOT_WRITABLE' : 'DIRECTORY_NOT_EXISTS'; - $description = array($title . '_EXPLAIN', $dir); + $lang_suffix = '_EXPLAIN'; + $lang_suffix .= ($failable) ? '_OPTIONAL' : ''; + $description = array($title . $lang_suffix, $dir); if ($failable) { -- cgit v1.2.1 From f41c7bd2b16906293498b4eb4073407e57a3567f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Mon, 11 Apr 2016 18:18:09 +0200 Subject: [ticket/14590] Prevent refresh requests after the last tasks in modules PHPBB3-14590 --- phpBB/phpbb/install/module_base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index 527447b4a1..93c10bd656 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -172,7 +172,7 @@ abstract class module_base implements module_interface $this->iohandler->send_response(); // Stop execution if resource limit is reached - if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) + if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)) { throw new resource_limit_reached_exception(); } -- cgit v1.2.1 From 1629e6aaf36092241eaf6c745af5c3b38f8182b3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 5 May 2016 17:05:17 +0200 Subject: [ticket/14628] Supports translatable error messages in the CLI installer PHPBB3-14628 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 94550d2db0..2a41cb10ba 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -124,13 +124,14 @@ class cli_iohandler extends iohandler_base public function add_error_message($error_title, $error_description = false) { $this->io->newLine(); + $message = $this->translate_message($error_title, $error_description); + $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); - if (strpos($error_title, '
') !== false) + if (strpos($message_string, '
') !== false) { - $error_title = strip_tags(str_replace('
', "\n", $error_title)); + $message_string = strip_tags(str_replace('
', "\n", $message_string)); } - $message = $this->translate_message($error_title, $error_description); - $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); + $this->io->error($message_string); if ($this->progress_bar !== null) -- cgit v1.2.1 From bf37cdf878aeb9d2c1d5195de9390db623a98ef4 Mon Sep 17 00:00:00 2001 From: Derek Held Date: Sat, 14 May 2016 07:56:30 -0700 Subject: [ticket/14595] Added SMTP port to getConfigTreeBuilder PHPBB3-14595 --- phpBB/phpbb/install/installer_configuration.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer_configuration.php b/phpBB/phpbb/install/installer_configuration.php index ab02da8686..c660c99d0f 100644 --- a/phpBB/phpbb/install/installer_configuration.php +++ b/phpBB/phpbb/install/installer_configuration.php @@ -93,6 +93,9 @@ class installer_configuration implements ConfigurationInterface ->scalarNode('smtp_host') ->defaultValue(null) ->end() + ->scalarNode('smtp_port') + ->defaultValue(null) + ->end() ->scalarNode('smtp_auth') ->defaultValue(null) ->end() -- cgit v1.2.1 From 9c34594bc374eeeca5d79afe2d3fdffae0cd1553 Mon Sep 17 00:00:00 2001 From: Derek Held Date: Sat, 14 May 2016 09:19:26 -0700 Subject: [ticket/14595] Added smtp_port where places where smtp_host exists. PHPBB3-14595 --- phpBB/phpbb/install/console/command/install/install.php | 1 + .../install/module/install_database/task/add_config_settings.php | 4 ++++ phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php | 7 +++++++ 3 files changed, 12 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 50c23f6877..de3a2e2d61 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -190,6 +190,7 @@ class install extends \phpbb\console\command\command $iohandler->set_input('email_enable', $config['email']['enabled']); $iohandler->set_input('smtp_delivery', $config['email']['smtp_delivery']); $iohandler->set_input('smtp_host', $config['email']['smtp_host']); + $iohandler->set_input('smtp_port', $config['email']['smtp_port']); $iohandler->set_input('smtp_auth', $config['email']['smtp_auth']); $iohandler->set_input('smtp_user', $config['email']['smtp_user']); $iohandler->set_input('smtp_pass', $config['email']['smtp_pass']); diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php index 7a2df01de6..8002e3ed97 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -190,6 +190,10 @@ class add_config_settings extends \phpbb\install\task_base SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_host')) . "' WHERE config_name = 'smtp_host'", + 'UPDATE ' . $this->config_table . " + SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_port')) . "' + WHERE config_name = 'smtp_port'", + 'UPDATE ' . $this->config_table . " SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_auth')) . "' WHERE config_name = 'smtp_auth_method'", 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 index 606e4a2ddd..1cb4f04297 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php @@ -51,6 +51,7 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta $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_port = $this->io_handler->get_input('smtp_port', ''); $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', ''); @@ -63,6 +64,7 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta $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_port', $smtp_port); $this->install_config->set('smtp_auth', $smtp_auth); $this->install_config->set('smtp_user', $smtp_user); $this->install_config->set('smtp_pass', $smtp_passwd); @@ -119,6 +121,11 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta 'type' => 'text', 'default' => $smtp_host, ), + 'smtp_port' => array( + 'label' => 'SMTP_PORT', + 'type' => 'text', + 'default' => $smtp_port, + ), 'smtp_auth' => array( 'label' => 'SMTP_AUTH_METHOD', 'description' => 'SMTP_AUTH_METHOD_EXPLAIN', -- cgit v1.2.1 From 3bafbc81ef11ee76c93eb4f21181d38b5e5c88ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= Date: Wed, 18 May 2016 14:53:52 -0400 Subject: [ticket/14591] Use the correct delimiter for MSSQL PHPBB3-14591 --- phpBB/phpbb/install/helper/database.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index c4c90a01a4..b8422fc1ed 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -58,7 +58,7 @@ class database 'LABEL' => 'MS SQL Server 2000+', 'SCHEMA' => 'mssql', 'MODULE' => 'mssql', - 'DELIM' => 'GO', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\mssql', 'AVAILABLE' => true, '2.0.x' => true, @@ -67,7 +67,7 @@ class database 'LABEL' => 'MS SQL Server [ ODBC ]', 'SCHEMA' => 'mssql', 'MODULE' => 'odbc', - 'DELIM' => 'GO', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\mssql_odbc', 'AVAILABLE' => true, '2.0.x' => true, @@ -76,7 +76,7 @@ class database 'LABEL' => 'MS SQL Server 2005+ [ Native ]', 'SCHEMA' => 'mssql', 'MODULE' => 'sqlsrv', - 'DELIM' => 'GO', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\mssqlnative', 'AVAILABLE' => true, '2.0.x' => false, -- cgit v1.2.1 From 61a147546def2aaee24e723d5a78cb7afbc31331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sat, 30 Jul 2016 13:04:39 +0200 Subject: [ticket/14633] Check for XML extension support on install PHPBB3-14633 --- .../requirements/task/check_server_environment.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/requirements/task/check_server_environment.php b/phpBB/phpbb/install/module/requirements/task/check_server_environment.php index 62485a2097..29f9777747 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_server_environment.php +++ b/phpBB/phpbb/install/module/requirements/task/check_server_environment.php @@ -71,6 +71,9 @@ class check_server_environment extends \phpbb\install\task_base // Check for JSON support $this->check_json(); + // XML extension support check + $this->check_xml(); + // Check for dbms support $this->check_available_dbms(); @@ -154,6 +157,22 @@ class check_server_environment extends \phpbb\install\task_base $this->set_test_passed(false); } + /** + * Checks whether or not the XML PHP extension is available (Required by the text formatter) + */ + protected function check_xml() + { + if (class_exists('DOMDocument')) + { + $this->set_test_passed(true); + return; + } + + $this->response_helper->add_error_message('PHP_XML_SUPPORT', 'PHP_XML_SUPPORT_EXPLAIN'); + + $this->set_test_passed(false); + } + /** * Check if any supported DBMS is available */ -- cgit v1.2.1 From c64b8102b7c5dc5bd0be9d8085d01a66e90dde73 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Tue, 29 Mar 2016 21:21:35 +0200 Subject: [ticket/10809] Remove MSSQL support PHPBB3-10809 --- phpBB/phpbb/install/helper/database.php | 9 --------- .../install/module/install_database/task/add_default_data.php | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index b8422fc1ed..be0c953d28 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -54,15 +54,6 @@ class database 'AVAILABLE' => true, '2.0.x' => true, ), - 'mssql' => array( - 'LABEL' => 'MS SQL Server 2000+', - 'SCHEMA' => 'mssql', - 'MODULE' => 'mssql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mssql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), 'mssql_odbc'=> array( 'LABEL' => 'MS SQL Server [ ODBC ]', 'SCHEMA' => 'mssql', diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php index f5157637ee..e32101a3f7 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_default_data.php +++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php @@ -134,7 +134,7 @@ class add_default_data extends \phpbb\install\task_base */ protected function replace_dbms_specific_sql($query) { - if ($this->db instanceof \phpbb\db\driver\mssql_base || $this->db instanceof \phpbb\db\driver\mssql) + if ($this->db instanceof \phpbb\db\driver\mssql_base) { $query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $query); } -- cgit v1.2.1 From 03be89ebd7bfd95e8586d0d13076a90afec243ee Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 11 Aug 2016 23:28:54 +0200 Subject: [ticket/14742] Fix progress bar in database updater Because of the new way, schema update steps are handled, the already misleading progress bar was even more misleading. This should fix it. PHPBB3-14742 --- .../install/module/update_database/task/update.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 9fed2317e9..d167181125 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -140,7 +140,14 @@ class update extends task_base ->get_classes(); $this->migrator->set_migrations($migrations); - $migration_count = count($this->migrator->get_migrations()); + + $migration_count = $this->installer_config->get('database_update_migrations', -1); + if ($migration_count < 0) + { + $migration_count = count($this->migrator->get_installable_migrations()); + $this->installer_config->set('database_update_migrations', $migration_count); + } + $this->iohandler->set_task_count($migration_count, true); $this->installer_config->set_task_progress_count($migration_count); $progress_count = $this->installer_config->get('database_update_count', 0); @@ -150,8 +157,14 @@ class update extends task_base try { $this->migrator->update(); - $progress_count++; - $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); + + $last_run_migration = $this->migrator->get_last_run_migration(); + + if ($last_run_migration['state']['migration_data_done']) + { + $progress_count++; + $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); + } } catch (exception $e) { -- cgit v1.2.1 From 758fe20f4be7178fd4b9fd6ce48c5342cfcbce27 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 12 Aug 2016 03:45:56 +0200 Subject: [ticket/14742] Further improve progress bar in db updater PHPBB3-14742 --- .../install/module/update_database/task/update.php | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index d167181125..c69dafaa10 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -141,16 +141,17 @@ class update extends task_base $this->migrator->set_migrations($migrations); - $migration_count = $this->installer_config->get('database_update_migrations', -1); - if ($migration_count < 0) + $migration_step_count = $this->installer_config->get('database_update_migration_steps', -1); + if ($migration_step_count < 0) { - $migration_count = count($this->migrator->get_installable_migrations()); - $this->installer_config->set('database_update_migrations', $migration_count); + $migration_step_count = count($this->migrator->get_installable_migrations()) * 2; + $this->installer_config->set('database_update_migration_steps', $migration_step_count); } - $this->iohandler->set_task_count($migration_count, true); - $this->installer_config->set_task_progress_count($migration_count); $progress_count = $this->installer_config->get('database_update_count', 0); + $restart_progress_bar = ($progress_count === 0); // Only "restart" when the update runs for the first time + $this->iohandler->set_task_count($migration_step_count, $restart_progress_bar); + $this->installer_config->set_task_progress_count($migration_step_count); while (!$this->migrator->finished()) { @@ -159,12 +160,17 @@ class update extends task_base $this->migrator->update(); $last_run_migration = $this->migrator->get_last_run_migration(); - - if ($last_run_migration['state']['migration_data_done']) + if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed']) + { + $progress_count += 2; + } + else if (($last_run_migration['task'] === 'process_schema_step' && $last_run_migration['state']['migration_schema_done']) || + ($last_run_migration['task'] === 'process_data_step' && $last_run_migration['state']['migration_data_done'])) { $progress_count++; - $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } + + $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } catch (exception $e) { -- cgit v1.2.1 From a37f10ae0951f16b115f4a175cc546a515cf7937 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 20 Aug 2016 22:40:37 +0200 Subject: [ticket/14742] Increase user feedback by improving progress bar We now count and display each step that was done by increasing the task count. PHPBB3-14742 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 11 ++++++++++- phpBB/phpbb/install/module/update_database/task/update.php | 14 ++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 2a41cb10ba..196cdcdaab 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -198,6 +198,16 @@ class cli_iohandler extends iohandler_base if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) { + if ($this->progress_bar !== null) + { + // Symfony's ProgressBar is immutable regarding task_count, so delete the old and create a new one. + $this->progress_bar->clear(); + } + else + { + $this->io->newLine(2); + } + $this->progress_bar = $this->io->createProgressBar($task_count); $this->progress_bar->setFormat( " %current:3s%/%max:-3s% %bar% %percent:3s%%\n" . @@ -212,7 +222,6 @@ class cli_iohandler extends iohandler_base } $this->progress_bar->setMessage(''); - $this->io->newLine(2); $this->progress_bar->start(); } } diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index c69dafaa10..9d7ba2f919 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -158,18 +158,23 @@ class update extends task_base try { $this->migrator->update(); + $progress_count++; $last_run_migration = $this->migrator->get_last_run_migration(); if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed']) { - $progress_count += 2; + // We skipped two step, so increment $progress_count by another one + $progress_count++; } - else if (($last_run_migration['task'] === 'process_schema_step' && $last_run_migration['state']['migration_schema_done']) || - ($last_run_migration['task'] === 'process_data_step' && $last_run_migration['state']['migration_data_done'])) + else if (($last_run_migration['task'] === 'process_schema_step' && !$last_run_migration['state']['migration_schema_done']) || + ($last_run_migration['task'] === 'process_data_step' && !$last_run_migration['state']['migration_data_done'])) { - $progress_count++; + // We just run a step that wasn't counted yet so make it count + $migration_step_count++; } + $this->iohandler->set_task_count($migration_step_count); + $this->installer_config->set_task_progress_count($migration_step_count); $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } catch (exception $e) @@ -184,6 +189,7 @@ class update extends task_base if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) { $this->installer_config->set('database_update_count', $progress_count); + $this->installer_config->set('database_update_migration_steps', $migration_step_count); throw new resource_limit_reached_exception(); } } -- cgit v1.2.1 From e974f338afb86c065e9b160363bc2e6156f8566d Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Sun, 13 Nov 2016 18:08:35 +0100 Subject: [ticket/14739] Remove SQLite 2.8.x database driver PHPBB3-14739 --- phpBB/phpbb/install/helper/database.php | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index be0c953d28..192f0a3654 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -90,15 +90,6 @@ class database 'AVAILABLE' => true, '2.0.x' => true, ), - 'sqlite' => array( - 'LABEL' => 'SQLite', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite', - 'AVAILABLE' => true, - '2.0.x' => false, - ), 'sqlite3' => array( 'LABEL' => 'SQLite3', 'SCHEMA' => 'sqlite', @@ -390,14 +381,6 @@ class database ); } break; - case 'sqlite': - if (version_compare($db->sql_server_info(true), '2.8.2', '<')) - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_SQLITE', - ); - } - break; case 'sqlite3': if (version_compare($db->sql_server_info(true), '3.6.15', '<')) { -- cgit v1.2.1 From 23f5b6debdd24cc1caefd3bb8cd6da96a88abe9a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Nov 2016 22:22:38 +0100 Subject: [ticket/14875] Add method for untrimmed input to ajax iohandler Due to the pre-encoded input and the escaping of the input, the string has to be decoded twice for the password. PHPBB3-14875 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 16 ++++++++++++++++ .../module/obtain_data/task/obtain_database_data.php | 11 ++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index c168d26425..591a19b7c1 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -120,6 +120,22 @@ class ajax_iohandler extends iohandler_base return $this->request->variable($name, $default, $multibyte); } + /** + * Returns untrimmed input variable + * + * @param string $name Name of the input variable to obtain + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * + * @return mixed Value of the untrimmed input variable + */ + public function get_untrimmed_input($name, $default, $multibyte = false) + { + return $this->request->untrimmed_variable($name, $default, $multibyte); + } + /** * {@inheritdoc} */ 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 index ce720dbf76..9019cf4332 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php @@ -79,10 +79,19 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in $dbhost = $this->io_handler->get_input('dbhost', '', true); $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', ''); + // Need to get untrimmed password when using ajax IO handler + if ($this->io_handler instanceof \phpbb\install\helper\iohandler\ajax_iohandler) + { + $dbpasswd = htmlspecialchars_decode(htmlspecialchars_decode($this->io_handler->get_untrimmed_input('dbpasswd', '', true))); + } + else + { + $dbpasswd = $this->io_handler->get_input('dbpasswd', '', true); + } + // Check database data $user_data_vaild = $this->check_database_data($dbms, $dbhost, $dbport, $dbuser, $dbpasswd, $dbname, $table_prefix); -- cgit v1.2.1 From 9aa017d0f7ce13a11114cbae24b694e935931342 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 25 Nov 2016 22:15:13 +0100 Subject: [ticket/14875] Add method for raw input to request and add to installer A method for retrieving raw input has been added to the request class. This will be used in the installer to retrieve the datatabase password while also allowing utf8 characters. Not escaping the input is ok in this case as it won't be put anywhere in this raw form and only be used to populate the entry for the password field in config.php. PHPBB3-14875 --- .../install/helper/iohandler/ajax_iohandler.php | 20 ++++++-------------- .../phpbb/install/helper/iohandler/cli_iohandler.php | 14 ++++++++++++++ .../install/helper/iohandler/iohandler_interface.php | 11 +++++++++++ .../module/obtain_data/task/obtain_database_data.php | 11 +---------- 4 files changed, 32 insertions(+), 24 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 591a19b7c1..2db6750f3f 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -27,7 +27,7 @@ class ajax_iohandler extends iohandler_base protected $path_helper; /** - * @var \phpbb\request\request_interface + * @var \phpbb\request\request */ protected $request; @@ -90,12 +90,12 @@ class ajax_iohandler extends iohandler_base * Constructor * * @param path_helper $path_helper - * @param \phpbb\request\request_interface $request HTTP request interface + * @param \phpbb\request\request $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) + public function __construct(path_helper $path_helper, \phpbb\request\request $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; @@ -121,19 +121,11 @@ class ajax_iohandler extends iohandler_base } /** - * Returns untrimmed input variable - * - * @param string $name Name of the input variable to obtain - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * - * @return mixed Value of the untrimmed input variable + * {@inheritdoc} */ - public function get_untrimmed_input($name, $default, $multibyte = false) + public function get_raw_input($name, $default) { - return $this->request->untrimmed_variable($name, $default, $multibyte); + return $this->request->raw_variable($name, $default); } /** diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 196cdcdaab..4117a3dfd3 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -74,6 +74,20 @@ class cli_iohandler extends iohandler_base return $result; } + /** + * {@inheritdoc} + */ + public function get_raw_input($name, $default) + { + return $this->get_input($name, $default, true); + } + + /** + * Set input variable + * + * @param string $name Name of input variable + * @param mixed $value Value of input variable + */ public function set_input($name, $value) { $this->input_values[$name] = $value; diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index f22f33d9cb..f0e0e99bbb 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -38,6 +38,17 @@ interface iohandler_interface */ public function get_input($name, $default, $multibyte = false); + /** + * Returns raw input variable + * + * @param string $name Name of the input variable to obtain + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * + * @return mixed Value of the raw input variable + */ + public function get_raw_input($name, $default); + /** * Returns server variable * 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 index 9019cf4332..dc7b060746 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php @@ -79,19 +79,10 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in $dbhost = $this->io_handler->get_input('dbhost', '', true); $dbport = $this->io_handler->get_input('dbport', ''); $dbuser = $this->io_handler->get_input('dbuser', ''); + $dbpasswd = $this->io_handler->get_raw_input('dbpasswd', ''); $dbname = $this->io_handler->get_input('dbname', ''); $table_prefix = $this->io_handler->get_input('table_prefix', ''); - // Need to get untrimmed password when using ajax IO handler - if ($this->io_handler instanceof \phpbb\install\helper\iohandler\ajax_iohandler) - { - $dbpasswd = htmlspecialchars_decode(htmlspecialchars_decode($this->io_handler->get_untrimmed_input('dbpasswd', '', true))); - } - else - { - $dbpasswd = $this->io_handler->get_input('dbpasswd', '', true); - } - // Check database data $user_data_vaild = $this->check_database_data($dbms, $dbhost, $dbport, $dbuser, $dbpasswd, $dbname, $table_prefix); -- cgit v1.2.1 From 9bdd002f584de78475362067b777749486504172 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 2 Dec 2016 11:36:07 +0100 Subject: [ticket/14875] Move raw_variable() method to request_interface PHPBB3-14875 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 6 +++--- phpBB/phpbb/install/helper/iohandler/iohandler_interface.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 2db6750f3f..a40d457466 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -27,7 +27,7 @@ class ajax_iohandler extends iohandler_base protected $path_helper; /** - * @var \phpbb\request\request + * @var \phpbb\request\request_interface */ protected $request; @@ -90,12 +90,12 @@ class ajax_iohandler extends iohandler_base * Constructor * * @param path_helper $path_helper - * @param \phpbb\request\request $request HTTP request interface + * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request $request, \phpbb\template\template $template, router $router, $root_path) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index f0e0e99bbb..440748901c 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -52,7 +52,7 @@ interface iohandler_interface /** * Returns server variable * - * This function should work the same as request_interterface::server(). + * This function should work the same as request_interface::server(). * * @param string $name Name of the server variable * @param mixed $default Default value to return when the requested variable does not exist @@ -62,7 +62,7 @@ interface iohandler_interface public function get_server_variable($name, $default = ''); /** - * Wrapper function for request_interterface::header() + * Wrapper function for request_interface::header() * * @param string $name Name of the request header variable * @param mixed $default Default value to return when the requested variable does not exist -- cgit v1.2.1 From c30394ff4a1034e5e6e7a0862e9101b5a80d8587 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Dec 2015 09:59:47 +0100 Subject: [ticket/14492] Add basic task for installing viglink extension PHPBB3-14492 --- .../module/install_finish/task/install_viglink.php | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 phpBB/phpbb/install/module/install_finish/task/install_viglink.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_viglink.php b/phpBB/phpbb/install/module/install_finish/task/install_viglink.php new file mode 100644 index 0000000000..1facb1eaf4 --- /dev/null +++ b/phpBB/phpbb/install/module/install_finish/task/install_viglink.php @@ -0,0 +1,119 @@ + + * @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\install_finish\task; + +/** + * Installs viglink extension with default config + */ +class install_viglink extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\config + */ + protected $install_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\config\db + */ + protected $config; + + /** + * @var \phpbb\log\log_interface + */ + protected $log; + + /** + * @var \phpbb\user + */ + protected $user; + + /** @var \phpbb\extension\manager */ + protected $extension_manager; + + /** + * Constructor + * + * @param \phpbb\install\helper\container_factory $container + * @param \phpbb\install\helper\config $install_config + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler + */ + public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler) + { + $this->install_config = $install_config; + $this->iohandler = $iohandler; + + $this->log = $container->get('log'); + $this->user = $container->get('user'); + $this->extension_manager = $container->get('ext.manager'); + $this->config = $container->get('config'); + + // Make sure asset version exists in config. Otherwise we might try to + // insert the assets_version setting into the database and cause a + // duplicate entry error. + if (!isset($this->config['assets_version'])) + { + $this->config['assets_version'] = 0; + } + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->user->session_begin(); + $this->user->setup(array('common', 'acp/common', 'cli')); + $name = 'phpbb/viglink'; + + // Should be available by default but make sure it is + if ($this->extension_manager->is_available($name)) + { + $this->extension_manager->enable($name); + $this->extension_manager->load_extensions(); + + if (!$this->extension_manager->is_enabled($name)) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); + } + } + else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array('phpbb/viglink')); + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_INSTALL_VIGLINK'; + } +} -- cgit v1.2.1 From 36460ebdf679f3cecb11afdc6e43e64195cc1d27 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 28 Jan 2016 20:24:51 +0100 Subject: [ticket/14492] Do not copy viglink on update if it was deleted PHPBB3-14492 --- phpBB/phpbb/install/module/update_filesystem/task/file_check.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php index f4b3870148..e4e0be0531 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -138,6 +138,15 @@ class file_check extends task_base $progress_count++; $this->iohandler->set_progress('UPDATE_CHECK_FILES', $progress_count); + // Do not copy viglink again if the previous version was packaged + // with it but it does not exist (e.g. deleted by admin) + if (strpos($file, $this->phpbb_root_path . 'ext/phpbb/viglink') !== false && + $this->update_helper->phpbb_version_compare($update_info['version']['from'], '3.2.0', '>=') && + !$this->filesystem->exists($this->phpbb_root_path . 'ext/phpbb/viglink')) + { + continue; + } + if (!$this->filesystem->exists($file)) { $file_update_info['new'][] = $filename; -- cgit v1.2.1 From 8fb2347cfa89ef9768311e92f11da4b090b94f7b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 28 Jan 2016 23:13:36 +0100 Subject: [ticket/14492] Install all packaged extensions by default PHPBB3-14492 --- .../install_finish/task/install_extensions.php | 135 +++++++++++++++++++++ .../module/install_finish/task/install_viglink.php | 119 ------------------ 2 files changed, 135 insertions(+), 119 deletions(-) create mode 100644 phpBB/phpbb/install/module/install_finish/task/install_extensions.php delete mode 100644 phpBB/phpbb/install/module/install_finish/task/install_viglink.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php new file mode 100644 index 0000000000..6b2881aa2f --- /dev/null +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -0,0 +1,135 @@ + + * @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\install_finish\task; + +/** + * Installs extensions that exist in ext folder upon install + */ +class install_extensions extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\config + */ + protected $install_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\config\db + */ + protected $config; + + /** + * @var \phpbb\log\log_interface + */ + protected $log; + + /** + * @var \phpbb\user + */ + protected $user; + + /** @var \phpbb\extension\manager */ + protected $extension_manager; + + /** @var \Symfony\Component\Finder\Finder */ + protected $finder; + + /** + * Constructor + * + * @param \phpbb\install\helper\container_factory $container + * @param \phpbb\install\helper\config $install_config + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler + * @param string $phpbb_root_path phpBB root path + */ + 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) + { + $this->install_config = $install_config; + $this->iohandler = $iohandler; + + $this->log = $container->get('log'); + $this->user = $container->get('user'); + $this->extension_manager = $container->get('ext.manager'); + $this->config = $container->get('config'); + $this->finder = new \Symfony\Component\Finder\Finder(); + $this->finder->in($phpbb_root_path . 'ext/') + ->ignoreUnreadableDirs() + ->depth('< 3') + ->files() + ->name('composer.json'); + + // Make sure asset version exists in config. Otherwise we might try to + // insert the assets_version setting into the database and cause a + // duplicate entry error. + if (!isset($this->config['assets_version'])) + { + $this->config['assets_version'] = 0; + } + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->user->session_begin(); + $this->user->setup(array('common', 'acp/common', 'cli')); + $name = 'phpbb/viglink'; + + // Find available extensions + foreach ($this->finder as $file) + { + /** @var \SplFileInfo $file */ + $ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath())); + + if ($this->extension_manager->is_available($ext_name)) + { + $this->extension_manager->enable($ext_name); + $this->extension_manager->load_extensions(); + + if (!$this->extension_manager->is_enabled($ext_name)) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); + } + } + else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + } + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_INSTALL_EXTENSIONS'; + } +} diff --git a/phpBB/phpbb/install/module/install_finish/task/install_viglink.php b/phpBB/phpbb/install/module/install_finish/task/install_viglink.php deleted file mode 100644 index 1facb1eaf4..0000000000 --- a/phpBB/phpbb/install/module/install_finish/task/install_viglink.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @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\install_finish\task; - -/** - * Installs viglink extension with default config - */ -class install_viglink extends \phpbb\install\task_base -{ - /** - * @var \phpbb\install\helper\config - */ - protected $install_config; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var \phpbb\config\db - */ - protected $config; - - /** - * @var \phpbb\log\log_interface - */ - protected $log; - - /** - * @var \phpbb\user - */ - protected $user; - - /** @var \phpbb\extension\manager */ - protected $extension_manager; - - /** - * Constructor - * - * @param \phpbb\install\helper\container_factory $container - * @param \phpbb\install\helper\config $install_config - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler - */ - public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler) - { - $this->install_config = $install_config; - $this->iohandler = $iohandler; - - $this->log = $container->get('log'); - $this->user = $container->get('user'); - $this->extension_manager = $container->get('ext.manager'); - $this->config = $container->get('config'); - - // Make sure asset version exists in config. Otherwise we might try to - // insert the assets_version setting into the database and cause a - // duplicate entry error. - if (!isset($this->config['assets_version'])) - { - $this->config['assets_version'] = 0; - } - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - $this->user->session_begin(); - $this->user->setup(array('common', 'acp/common', 'cli')); - $name = 'phpbb/viglink'; - - // Should be available by default but make sure it is - if ($this->extension_manager->is_available($name)) - { - $this->extension_manager->enable($name); - $this->extension_manager->load_extensions(); - - if (!$this->extension_manager->is_enabled($name)) - { - // Create log - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); - } - } - else - { - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array('phpbb/viglink')); - } - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_INSTALL_VIGLINK'; - } -} -- cgit v1.2.1 From 267d1b15c4884dd67a299b2428251e68cd55327b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 29 Jan 2016 10:13:06 +0100 Subject: [ticket/14492] Re-enable extensions if updated during update PHPBB3-14492 --- .../install_finish/task/install_extensions.php | 3 +- .../update_database/task/update_extensions.php | 162 +++++++++++++++++++++ 2 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 phpBB/phpbb/install/module/update_database/task/update_extensions.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index 6b2881aa2f..28911b36c5 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -91,7 +91,6 @@ class install_extensions extends \phpbb\install\task_base { $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); - $name = 'phpbb/viglink'; // Find available extensions foreach ($this->finder as $file) @@ -122,7 +121,7 @@ class install_extensions extends \phpbb\install\task_base */ static public function get_step_count() { - return 1; + return 0; } /** diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php new file mode 100644 index 0000000000..c7437d4746 --- /dev/null +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -0,0 +1,162 @@ + + * @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\update_database\task; + +use phpbb\install\helper\container_factory; +use phpbb\install\helper\config; +use phpbb\install\helper\iohandler\iohandler_interface; +use phpbb\install\helper\update_helper; +use phpbb\install\task_base; +use Symfony\Component\Finder\Finder; + +/** + * Installs extensions that exist in ext folder upon install + */ +class enable_extensions extends task_base +{ + /** + * @var config + */ + protected $install_config; + + /** + * @var iohandler_interface + */ + protected $iohandler; + + /** @var update_helper */ + protected $update_helper; + + /** + * @var \phpbb\config\db + */ + protected $config; + + /** + * @var \phpbb\log\log_interface + */ + protected $log; + + /** + * @var \phpbb\user + */ + protected $user; + + /** @var \phpbb\extension\manager */ + protected $extension_manager; + + /** @var Finder */ + protected $finder; + + /** + * Constructor + * + * @param container_factory $container + * @param config $install_config + * @param iohandler_interface $iohandler + * @param $update_helper $update_helper + * @param string $phpbb_root_path phpBB root path + */ + public function __construct(container_factory $container, config $install_config, iohandler_interface $iohandler, update_helper $update_helper, $phpbb_root_path) + { + $this->install_config = $install_config; + $this->iohandler = $iohandler; + + $this->log = $container->get('log'); + $this->user = $container->get('user'); + $this->extension_manager = $container->get('ext.manager'); + $this->config = $container->get('config'); + $this->finder = new Finder(); + $this->finder->in($phpbb_root_path . 'ext/') + ->ignoreUnreadableDirs() + ->depth('< 3') + ->files() + ->name('composer.json'); + + // Make sure asset version exists in config. Otherwise we might try to + // insert the assets_version setting into the database and cause a + // duplicate entry error. + if (!isset($this->config['assets_version'])) + { + $this->config['assets_version'] = 0; + } + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->user->session_begin(); + $this->user->setup(array('common', 'acp/common', 'cli')); + + $update_info = $this->install_config->get('update_info_unprocessed', array()); + + if (!empty($update_info)) + { + // Find available extensions + foreach ($this->finder as $file) + { + /** @var \SplFileInfo $file */ + $ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath())); + + // Skip extensions that were not added or updated during update + if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files']))) + { + continue; + } + + // Disable enabled extensions in order to run migrations if needed + if ($this->extension_manager->is_enabled($ext_name)) + { + $this->extension_manager->disable($ext_name); + } + + if ($this->extension_manager->is_available($ext_name)) + { + $this->extension_manager->enable($ext_name); + $this->extension_manager->load_extensions(); + + if (!$this->extension_manager->is_enabled($ext_name)) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); + } + } + else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + } + } + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_UPDATE_EXTENSIONS'; + } +} -- cgit v1.2.1 From 430ec6f61d5da5b278ee2cadda535fcf9dcaed22 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 30 Jan 2016 16:12:44 +0100 Subject: [ticket/14492] Do not install extensions in installer if in test env PHPBB3-14492 --- .../phpbb/install/module/install_finish/task/install_extensions.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index 28911b36c5..d5086e7b82 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -89,6 +89,11 @@ class install_extensions extends \phpbb\install\task_base */ public function run() { + if (defined('PHPBB_ENVIRONMENT') && PHPBB_ENVIRONMENT === 'test') + { + return; + } + $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); -- cgit v1.2.1 From 90a5e22eb51fa20c94d576ffc5cdb49fb31dab3a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Feb 2016 09:45:32 +0100 Subject: [ticket/14492] Correctly check if extension was enabled during install Also fixed some incorrectly generated log messages and improved the regex. PHPBB3-14492 --- .../install_finish/task/install_extensions.php | 42 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index d5086e7b82..c9a35a309a 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -49,6 +49,12 @@ class install_extensions extends \phpbb\install\task_base /** @var \Symfony\Component\Finder\Finder */ protected $finder; + /** @var string Extension table */ + protected $extension_table; + + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + /** * Constructor * @@ -61,11 +67,13 @@ class install_extensions extends \phpbb\install\task_base { $this->install_config = $install_config; $this->iohandler = $iohandler; + $this->extension_table = $container->get_parameter('tables.ext'); $this->log = $container->get('log'); $this->user = $container->get('user'); $this->extension_manager = $container->get('ext.manager'); $this->config = $container->get('config'); + $this->db = $container->get('dbal.conn'); $this->finder = new \Symfony\Component\Finder\Finder(); $this->finder->in($phpbb_root_path . 'ext/') ->ignoreUnreadableDirs() @@ -101,14 +109,14 @@ class install_extensions extends \phpbb\install\task_base foreach ($this->finder as $file) { /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath())); + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])([^\\/\\\]+)[\\/\\\]([^\\/\\\]+)#', '$2/$3', dirname($file->getRealPath())); if ($this->extension_manager->is_available($ext_name)) { $this->extension_manager->enable($ext_name); - $this->extension_manager->load_extensions(); + $extensions = $this->get_extensions(); - if (!$this->extension_manager->is_enabled($ext_name)) + if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); @@ -116,7 +124,7 @@ class install_extensions extends \phpbb\install\task_base } else { - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } } } @@ -136,4 +144,30 @@ class install_extensions extends \phpbb\install\task_base { return 'TASK_INSTALL_EXTENSIONS'; } + + /** + * Get extensions from database + * + * @return array List of extensions + */ + private function get_extensions() + { + $sql = 'SELECT * + FROM ' . $this->extension_table; + + $result = $this->db->sql_query($sql); + $extensions_row = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + $extensions = array(); + + foreach ($extensions_row as $extension) + { + $extensions[$extension['ext_name']] = $extension; + } + + ksort($extensions); + + return $extensions; + } } -- cgit v1.2.1 From 4451db9f225d7a0e8a12503f0ff2f1393ee42467 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Feb 2016 11:43:29 +0100 Subject: [ticket/14492] Apply fixes to update extensions task The regex was also simplified. PHPBB3-14492 --- .../install_finish/task/install_extensions.php | 2 +- .../update_database/task/update_extensions.php | 40 ++++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index c9a35a309a..d92f420202 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -109,7 +109,7 @@ class install_extensions extends \phpbb\install\task_base foreach ($this->finder as $file) { /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])([^\\/\\\]+)[\\/\\\]([^\\/\\\]+)#', '$2/$3', dirname($file->getRealPath())); + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); if ($this->extension_manager->is_available($ext_name)) { diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index c7437d4746..a6648084a6 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -59,6 +59,12 @@ class enable_extensions extends task_base /** @var Finder */ protected $finder; + /** @var string Extension table */ + protected $extension_table; + + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + /** * Constructor * @@ -72,11 +78,13 @@ class enable_extensions extends task_base { $this->install_config = $install_config; $this->iohandler = $iohandler; + $this->extension_table = $container->get_parameter('tables.ext'); $this->log = $container->get('log'); $this->user = $container->get('user'); $this->extension_manager = $container->get('ext.manager'); $this->config = $container->get('config'); + $this->db = $container->get('dbal.conn'); $this->finder = new Finder(); $this->finder->in($phpbb_root_path . 'ext/') ->ignoreUnreadableDirs() @@ -111,7 +119,7 @@ class enable_extensions extends task_base foreach ($this->finder as $file) { /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath())); + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); // Skip extensions that were not added or updated during update if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files']))) @@ -128,9 +136,9 @@ class enable_extensions extends task_base if ($this->extension_manager->is_available($ext_name)) { $this->extension_manager->enable($ext_name); - $this->extension_manager->load_extensions(); + $extensions = $this->get_extensions(); - if (!$this->extension_manager->is_enabled($ext_name)) + if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); @@ -159,4 +167,30 @@ class enable_extensions extends task_base { return 'TASK_UPDATE_EXTENSIONS'; } + + /** + * Get extensions from database + * + * @return array List of extensions + */ + private function get_extensions() + { + $sql = 'SELECT * + FROM ' . $this->extension_table; + + $result = $this->db->sql_query($sql); + $extensions_row = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + $extensions = array(); + + foreach ($extensions_row as $extension) + { + $extensions[$extension['ext_name']] = $extension; + } + + ksort($extensions); + + return $extensions; + } } -- cgit v1.2.1 From eb1ade67681ee7c88845978eade07ad3ac96357a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 24 Feb 2016 13:49:20 +0100 Subject: [ticket/14492] Set install extensions to synthetic and fix step count PHPBB3-14492 --- .../install/module/install_finish/task/install_extensions.php | 7 +------ .../install/module/update_database/task/update_extensions.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index d92f420202..bc13795188 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -97,11 +97,6 @@ class install_extensions extends \phpbb\install\task_base */ public function run() { - if (defined('PHPBB_ENVIRONMENT') && PHPBB_ENVIRONMENT === 'test') - { - return; - } - $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); @@ -134,7 +129,7 @@ class install_extensions extends \phpbb\install\task_base */ static public function get_step_count() { - return 0; + return 1; } /** diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index a6648084a6..a73fa9b854 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -157,7 +157,7 @@ class enable_extensions extends task_base */ static public function get_step_count() { - return 0; + return 1; } /** -- cgit v1.2.1 From 65d6e338a99baa2f100d6bd4dea5cd76ac146ac3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 24 Feb 2016 15:05:01 +0100 Subject: [ticket/14492] Allow specifying extensions to update & install PHPBB3-14492 --- .../phpbb/install/console/command/install/install.php | 18 ++++++++++++++++++ .../module/install_finish/task/install_extensions.php | 9 +++++++++ .../module/update_database/task/update_extensions.php | 7 ++++++- 3 files changed, 33 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index de3a2e2d61..3378f5fdac 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -80,6 +80,10 @@ class install extends \phpbb\console\command\command 'config-file', InputArgument::REQUIRED, $this->language->lang('CLI_CONFIG_FILE')) + ->addArgument( + 'install-extensions', + InputArgument::OPTIONAL, + $this->language->lang('CLI_INSTALL_EXTENSIONS')) ->setDescription($this->language->lang('CLI_INSTALL_BOARD')) ; } @@ -147,6 +151,7 @@ class install extends \phpbb\console\command\command } $this->register_configuration($iohandler, $config); + $this->register_install_extensions($iohandler, $input); try { @@ -204,4 +209,17 @@ class install extends \phpbb\console\command\command $iohandler->set_input('script_path', $config['server']['script_path']); $iohandler->set_input('submit_server', 'submit'); } + + /** + * Register extensions to install during installation + * + * @param cli_iohandler $iohandler + * @param InputInterface $input + */ + private function register_install_extensions(cli_iohandler $iohandler, InputInterface $input) + { + $install_extensions = $input->getArgument('install-extensions'); + $install_extensions = !empty($install_extensions) ? explode(',', $install_extensions) : array(); + $iohandler->set_input('install-extensions', $install_extensions); + } } diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index bc13795188..c42d17fc18 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -13,6 +13,8 @@ namespace phpbb\install\module\install_finish\task; +use Symfony\Component\Console\Input\ArgvInput; + /** * Installs extensions that exist in ext folder upon install */ @@ -100,12 +102,19 @@ class install_extensions extends \phpbb\install\task_base $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); + $install_extensions = $this->iohandler->get_input('install-extensions', array()); + // Find available extensions foreach ($this->finder as $file) { /** @var \SplFileInfo $file */ $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + if (!empty($install_extensions) && !in_array($ext_name, $install_extensions)) + { + continue; + } + if ($this->extension_manager->is_available($ext_name)) { $this->extension_manager->enable($ext_name); diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index a73fa9b854..7a65ff1803 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -18,6 +18,7 @@ use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; use phpbb\install\helper\update_helper; use phpbb\install\task_base; +use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Finder\Finder; /** @@ -111,6 +112,9 @@ class enable_extensions extends task_base $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); + $input = new ArgvInput(); + $update_extensions = explode(',', $input->getArgument('update-extensions')); + $update_info = $this->install_config->get('update_info_unprocessed', array()); if (!empty($update_info)) @@ -122,7 +126,8 @@ class enable_extensions extends task_base $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); // Skip extensions that were not added or updated during update - if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files']))) + if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files'])) && + !in_array($ext_name, $update_extensions) && $ext_name !== 'phpbb/viglink') { continue; } -- cgit v1.2.1 From e519b21b2e563f9d751aa8f9157ccc489b660ec8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 29 Feb 2016 11:31:33 +0100 Subject: [ticket/14492] Only show fail of extension install if it's available PHPBB3-14492 --- .../install/module/install_finish/task/install_extensions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index c42d17fc18..cef2abe0cb 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -125,10 +125,10 @@ class install_extensions extends \phpbb\install\task_base // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); } - } - else - { - $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); + else + { + $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); + } } } } -- cgit v1.2.1 From 69dece6197d6289199a713e7db57cc80574aae69 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 29 Feb 2016 15:04:55 +0100 Subject: [ticket/14492] Removed unused use statement PHPBB3-14492 --- phpBB/phpbb/install/module/install_finish/task/install_extensions.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index cef2abe0cb..9db922b7f4 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -13,8 +13,6 @@ namespace phpbb\install\module\install_finish\task; -use Symfony\Component\Console\Input\ArgvInput; - /** * Installs extensions that exist in ext folder upon install */ -- cgit v1.2.1 From ffe900c72d358ba0337c607f2ed76f893715f686 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 11:53:20 +0100 Subject: [ticket/14492] Define extensions to install in config not via cli argument PHPBB3-14492 --- .../phpbb/install/console/command/install/install.php | 19 ++----------------- phpBB/phpbb/install/console/command/update/update.php | 3 +++ phpBB/phpbb/install/installer_configuration.php | 4 ++++ phpBB/phpbb/install/updater_configuration.php | 4 ++++ 4 files changed, 13 insertions(+), 17 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 3378f5fdac..52a348fe44 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -80,10 +80,6 @@ class install extends \phpbb\console\command\command 'config-file', InputArgument::REQUIRED, $this->language->lang('CLI_CONFIG_FILE')) - ->addArgument( - 'install-extensions', - InputArgument::OPTIONAL, - $this->language->lang('CLI_INSTALL_EXTENSIONS')) ->setDescription($this->language->lang('CLI_INSTALL_BOARD')) ; } @@ -151,11 +147,11 @@ class install extends \phpbb\console\command\command } $this->register_configuration($iohandler, $config); - $this->register_install_extensions($iohandler, $input); try { $this->installer->run(); + return 0; } catch (installer_exception $e) { @@ -208,18 +204,7 @@ class install extends \phpbb\console\command\command $iohandler->set_input('server_port', $config['server']['server_port']); $iohandler->set_input('script_path', $config['server']['script_path']); $iohandler->set_input('submit_server', 'submit'); - } - /** - * Register extensions to install during installation - * - * @param cli_iohandler $iohandler - * @param InputInterface $input - */ - private function register_install_extensions(cli_iohandler $iohandler, InputInterface $input) - { - $install_extensions = $input->getArgument('install-extensions'); - $install_extensions = !empty($install_extensions) ? explode(',', $install_extensions) : array(); - $iohandler->set_input('install-extensions', $install_extensions); + $iohandler->set_input('install-extensions', $config['extensions']); } } diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php index 116f42f758..e827761d1c 100644 --- a/phpBB/phpbb/install/console/command/update/update.php +++ b/phpBB/phpbb/install/console/command/update/update.php @@ -151,6 +151,7 @@ class update extends \phpbb\console\command\command try { $this->installer->run(); + return 0; } catch (installer_exception $e) { @@ -175,5 +176,7 @@ class update extends \phpbb\console\command\command $iohandler->set_input('submit_update_file', 'submit'); $iohandler->set_input('submit_continue_file_update', 'submit'); + + $iohandler->set_input('update-extensions', $config['extensions']); } } diff --git a/phpBB/phpbb/install/installer_configuration.php b/phpBB/phpbb/install/installer_configuration.php index c660c99d0f..805140338c 100644 --- a/phpBB/phpbb/install/installer_configuration.php +++ b/phpBB/phpbb/install/installer_configuration.php @@ -136,6 +136,10 @@ class installer_configuration implements ConfigurationInterface ->end() ->end() ->end() + ->arrayNode('extensions') + ->prototype('scalar')->end() + ->defaultValue([]) + ->end() ->end() ; return $treeBuilder; diff --git a/phpBB/phpbb/install/updater_configuration.php b/phpBB/phpbb/install/updater_configuration.php index e992356290..5c1c29f1da 100644 --- a/phpBB/phpbb/install/updater_configuration.php +++ b/phpBB/phpbb/install/updater_configuration.php @@ -32,6 +32,10 @@ class updater_configuration implements ConfigurationInterface ->addDefaultsIfNotSet() ->children() ->enumNode('type')->values(['all','db_only'])->defaultValue('all')->end() + ->arrayNode('extensions') + ->prototype('scalar')->end() + ->defaultValue([]) + ->end() ->end() ; -- cgit v1.2.1 From 930b02342e4f27f1c72fe0590f7153298331c3a6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 13:02:44 +0100 Subject: [ticket/14492] Check if composer.json exists in viglink folder on file_check PHPBB3-14492 --- phpBB/phpbb/install/module/update_filesystem/task/file_check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php index e4e0be0531..8777b747de 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -142,7 +142,7 @@ class file_check extends task_base // with it but it does not exist (e.g. deleted by admin) if (strpos($file, $this->phpbb_root_path . 'ext/phpbb/viglink') !== false && $this->update_helper->phpbb_version_compare($update_info['version']['from'], '3.2.0', '>=') && - !$this->filesystem->exists($this->phpbb_root_path . 'ext/phpbb/viglink')) + !$this->filesystem->exists($this->phpbb_root_path . 'ext/phpbb/viglink/composer.json')) { continue; } -- cgit v1.2.1 From f604e1ab5d5d780ff4bed1e39fa83cc264a8af71 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 13:54:02 +0100 Subject: [ticket/14492] Rework logic for selecting which extensions to update PHPBB3-14492 --- .../update_database/task/update_extensions.php | 81 ++++++++++++++-------- 1 file changed, 54 insertions(+), 27 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 7a65ff1803..f3a977a013 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -24,7 +24,7 @@ use Symfony\Component\Finder\Finder; /** * Installs extensions that exist in ext folder upon install */ -class enable_extensions extends task_base +class update_extensions extends task_base { /** * @var config @@ -66,6 +66,14 @@ class enable_extensions extends task_base /** @var \phpbb\db\driver\driver_interface */ protected $db; + /** + * @var array List of default extensions to update, grouped by version + * they were added + */ + private $default_update = [ + '3.2.0-b2' => ['phpbb/viglink'] + ]; + /** * Constructor * @@ -112,47 +120,66 @@ class enable_extensions extends task_base $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); - $input = new ArgvInput(); - $update_extensions = explode(',', $input->getArgument('update-extensions')); + $update_info = $this->install_config->get('update_info_unprocessed', []); - $update_info = $this->install_config->get('update_info_unprocessed', array()); + if (empty($update_info)) + { + return; + } - if (!empty($update_info)) + $update_extensions = $this->iohandler->get_input('update-extensions', []); + + // Create list of default extensions that need to be enabled in update + $default_update_extensions = []; + foreach ($this->default_update as $version => $extensions) { - // Find available extensions - foreach ($this->finder as $file) + if ($this->update_helper->phpbb_version_compare($update_info['version']['from'], $version, '<')) { - /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); - - // Skip extensions that were not added or updated during update - if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files'])) && - !in_array($ext_name, $update_extensions) && $ext_name !== 'phpbb/viglink') - { - continue; - } + $default_update_extensions = array_merge($default_update_extensions, $extensions); + } + } - // Disable enabled extensions in order to run migrations if needed - if ($this->extension_manager->is_enabled($ext_name)) + // Find available extensions + foreach ($this->finder as $file) + { + /** @var \SplFileInfo $file */ + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + + // Update extensions if: + // 1) Extension is currently enabled + // 2) Extension was implicitly defined as needing an update + // 3) Extension was newly added as default phpBB extension in + // this update and should be enabled by default. + if ($this->extension_manager->is_available($ext_name) && + ( + $this->extension_manager->is_enabled($ext_name) || + in_array($ext_name, $update_extensions) || + in_array($ext_name, $default_update_extensions) + )) + { + $extension_enabled = $this->extension_manager->is_enabled($ext_name); + if ($extension_enabled) { $this->extension_manager->disable($ext_name); } + $this->extension_manager->enable($ext_name); + $extensions = $this->get_extensions(); - if ($this->extension_manager->is_available($ext_name)) + if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { - $this->extension_manager->enable($ext_name); - $extensions = $this->get_extensions(); - - if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) - { - // Create log - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); - } + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); } else { $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); } + + // Disable extensions if it was disabled by the admin before + if (!$extension_enabled && !in_array($ext_name, $default_update_extensions)) + { + $this->extension_manager->disable($ext_name); + } } } } -- cgit v1.2.1 From 64f0d74489515ad76d0caf6cfdf100ef92e16328 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 16:35:18 +0100 Subject: [ticket/14492] Properly retrieve version updating from PHPBB3-14492 --- .../install/module/update_database/task/update.php | 2 - .../update_database/task/update_extensions.php | 112 ++++++++++++--------- 2 files changed, 62 insertions(+), 52 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 9d7ba2f919..fb9eb44e6a 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -211,8 +211,6 @@ class update extends task_base $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); - $this->config->delete('version_update_from'); - $this->cache->purge(); $this->config->increment('assets_version', 1); diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index f3a977a013..cb5cd90952 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -26,6 +26,11 @@ use Symfony\Component\Finder\Finder; */ class update_extensions extends task_base { + /** + * @var \phpbb\cache\driver\driver_interface + */ + protected $cache; + /** * @var config */ @@ -92,8 +97,10 @@ class update_extensions extends task_base $this->log = $container->get('log'); $this->user = $container->get('user'); $this->extension_manager = $container->get('ext.manager'); + $this->cache = $container->get('cache.driver'); $this->config = $container->get('config'); $this->db = $container->get('dbal.conn'); + $this->update_helper = $update_helper; $this->finder = new Finder(); $this->finder->in($phpbb_root_path . 'ext/') ->ignoreUnreadableDirs() @@ -121,67 +128,72 @@ class update_extensions extends task_base $this->user->setup(array('common', 'acp/common', 'cli')); $update_info = $this->install_config->get('update_info_unprocessed', []); + $version_from = !empty($update_info) ? $update_info['version']['from'] : $this->config['version_update_from']; - if (empty($update_info)) + if (!empty($version_from)) { - return; - } - - $update_extensions = $this->iohandler->get_input('update-extensions', []); + $update_extensions = $this->iohandler->get_input('update-extensions', []); - // Create list of default extensions that need to be enabled in update - $default_update_extensions = []; - foreach ($this->default_update as $version => $extensions) - { - if ($this->update_helper->phpbb_version_compare($update_info['version']['from'], $version, '<')) - { - $default_update_extensions = array_merge($default_update_extensions, $extensions); - } - } - - // Find available extensions - foreach ($this->finder as $file) - { - /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); - - // Update extensions if: - // 1) Extension is currently enabled - // 2) Extension was implicitly defined as needing an update - // 3) Extension was newly added as default phpBB extension in - // this update and should be enabled by default. - if ($this->extension_manager->is_available($ext_name) && - ( - $this->extension_manager->is_enabled($ext_name) || - in_array($ext_name, $update_extensions) || - in_array($ext_name, $default_update_extensions) - )) + // Create list of default extensions that need to be enabled in update + $default_update_extensions = []; + foreach ($this->default_update as $version => $extensions) { - $extension_enabled = $this->extension_manager->is_enabled($ext_name); - if ($extension_enabled) + if ($this->update_helper->phpbb_version_compare($version_from, $version, '<')) { - $this->extension_manager->disable($ext_name); - } - $this->extension_manager->enable($ext_name); - $extensions = $this->get_extensions(); - - if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) - { - // Create log - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); - } - else - { - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + $default_update_extensions = array_merge($default_update_extensions, $extensions); } + } - // Disable extensions if it was disabled by the admin before - if (!$extension_enabled && !in_array($ext_name, $default_update_extensions)) + // Find available extensions + foreach ($this->finder as $file) + { + /** @var \SplFileInfo $file */ + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + + // Update extensions if: + // 1) Extension is currently enabled + // 2) Extension was implicitly defined as needing an update + // 3) Extension was newly added as default phpBB extension in + // this update and should be enabled by default. + if ($this->extension_manager->is_available($ext_name) && + ( + $this->extension_manager->is_enabled($ext_name) || + in_array($ext_name, $update_extensions) || + in_array($ext_name, $default_update_extensions) + ) + ) { - $this->extension_manager->disable($ext_name); + $extension_enabled = $this->extension_manager->is_enabled($ext_name); + if ($extension_enabled) + { + $this->extension_manager->disable($ext_name); + } + $this->extension_manager->enable($ext_name); + $extensions = $this->get_extensions(); + + if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); + } else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + } + + // Disable extensions if it was disabled by the admin before + if (!$extension_enabled && !in_array($ext_name, $default_update_extensions)) + { + $this->extension_manager->disable($ext_name); + } } } } + + $this->config->delete('version_update_from'); + + $this->cache->purge(); + + $this->config->increment('assets_version', 1); } /** -- cgit v1.2.1 From d62d35ad46baf9a7563a9f58038b16272cdf7c2d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 21:56:22 +0100 Subject: [ticket/14492] Redirect to help phpBB page after installation PHPBB3-14492 --- phpBB/phpbb/install/installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 240423ae78..b8eef34a1d 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -244,7 +244,7 @@ class installer else { global $SID; - $acp_url = $this->web_root . 'adm/index.php' . $SID; + $acp_url = $this->web_root . 'adm/index.php' . $SID . '&i=acp_help_phpbb&mode=help_phpbb'; $this->iohandler->add_success_message('INSTALLER_FINISHED', array( 'ACP_LINK', $acp_url, -- cgit v1.2.1 From fd37919ecb8e6e6618145aafae9de864fe16ded8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 22:00:08 +0100 Subject: [ticket/14492] Remove unused use statement PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index cb5cd90952..0a339f11e8 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -18,7 +18,6 @@ use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; use phpbb\install\helper\update_helper; use phpbb\install\task_base; -use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Finder\Finder; /** -- cgit v1.2.1 From e308093d7507258855c14dcfb7214e81beac187e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Mar 2016 22:26:29 +0100 Subject: [ticket/14492] Use extension manager instead of finder and add try/catch PHPBB3-14492 --- .../install_finish/task/install_extensions.php | 17 +++--- .../update_database/task/update_extensions.php | 61 ++++++++++++---------- 2 files changed, 44 insertions(+), 34 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index 9db922b7f4..eb44bb780b 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -102,18 +102,17 @@ class install_extensions extends \phpbb\install\task_base $install_extensions = $this->iohandler->get_input('install-extensions', array()); - // Find available extensions - foreach ($this->finder as $file) - { - /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + $available_extensions = $this->extension_manager->all_available(); + // Install extensions + foreach ($available_extensions as $ext_name => $ext_path) + { if (!empty($install_extensions) && !in_array($ext_name, $install_extensions)) { continue; } - if ($this->extension_manager->is_available($ext_name)) + try { $this->extension_manager->enable($ext_name); $extensions = $this->get_extensions(); @@ -122,12 +121,18 @@ class install_extensions extends \phpbb\install\task_base { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); + $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name)); } else { $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } } + catch (\Exception $e) + { + // Add fail log and continue + $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); + } } } diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 0a339f11e8..e8b73db25a 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -143,47 +143,52 @@ class update_extensions extends task_base } } - // Find available extensions - foreach ($this->finder as $file) - { - /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + $available_extensions = $this->extension_manager->all_available(); + // Update available extensions + foreach ($available_extensions as $ext_name => $ext_path) + { // Update extensions if: // 1) Extension is currently enabled // 2) Extension was implicitly defined as needing an update // 3) Extension was newly added as default phpBB extension in // this update and should be enabled by default. - if ($this->extension_manager->is_available($ext_name) && - ( - $this->extension_manager->is_enabled($ext_name) || - in_array($ext_name, $update_extensions) || - in_array($ext_name, $default_update_extensions) - ) + if ($this->extension_manager->is_enabled($ext_name) || + in_array($ext_name, $update_extensions) || + in_array($ext_name, $default_update_extensions) ) { - $extension_enabled = $this->extension_manager->is_enabled($ext_name); - if ($extension_enabled) + try { - $this->extension_manager->disable($ext_name); + $extension_enabled = $this->extension_manager->is_enabled($ext_name); + if ($extension_enabled) + { + $this->extension_manager->disable($ext_name); + } + $this->extension_manager->enable($ext_name); + $extensions = $this->get_extensions(); + + if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); + $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name)); + } else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + } + + // Disable extensions if it was disabled by the admin before + if (!$extension_enabled && !in_array($ext_name, $default_update_extensions)) + { + $this->extension_manager->disable($ext_name); + } } - $this->extension_manager->enable($ext_name); - $extensions = $this->get_extensions(); - - if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) - { - // Create log - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); - } else + catch (\Exception $e) { + // Add fail log and continue $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); } - - // Disable extensions if it was disabled by the admin before - if (!$extension_enabled && !in_array($ext_name, $default_update_extensions)) - { - $this->extension_manager->disable($ext_name); - } } } } -- cgit v1.2.1 From 2fa23c9b3f55e024f6a35c268cd7878e68ad08c2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Mar 2016 22:28:51 +0100 Subject: [ticket/14492] Unify version check for installing default extensions PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index e8b73db25a..6d0016ddb3 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -75,7 +75,7 @@ class update_extensions extends task_base * they were added */ private $default_update = [ - '3.2.0-b2' => ['phpbb/viglink'] + '3.2.0-b3' => ['phpbb/viglink'] ]; /** @@ -137,7 +137,7 @@ class update_extensions extends task_base $default_update_extensions = []; foreach ($this->default_update as $version => $extensions) { - if ($this->update_helper->phpbb_version_compare($version_from, $version, '<')) + if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) { $default_update_extensions = array_merge($default_update_extensions, $extensions); } -- cgit v1.2.1 From edfc4f3efc742342a37a5d510909aece6ae4c95d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 00:24:04 +0100 Subject: [ticket/14492] Use same list for checking if extension should be updated PHPBB3-14492 --- .../update_database/task/update_extensions.php | 4 +-- .../module/update_filesystem/task/file_check.php | 35 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 6d0016ddb3..64215e2f30 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -74,7 +74,7 @@ class update_extensions extends task_base * @var array List of default extensions to update, grouped by version * they were added */ - private $default_update = [ + static public $default_extensions_update = [ '3.2.0-b3' => ['phpbb/viglink'] ]; @@ -135,7 +135,7 @@ class update_extensions extends task_base // Create list of default extensions that need to be enabled in update $default_update_extensions = []; - foreach ($this->default_update as $version => $extensions) + foreach (self::$default_extensions_update as $version => $extensions) { if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) { diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php index 8777b747de..5b48350e73 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -118,6 +118,17 @@ class file_check extends task_base $this->iohandler->set_task_count($task_count); $this->iohandler->set_progress('UPDATE_CHECK_FILES', 0); + // Create list of default extensions that should have been added prior + // to this update + $default_update_extensions = []; + foreach (\phpbb\install\module\update_database\task\update_extensions::$default_extensions_update as $version => $extensions) + { + if ($this->update_helper->phpbb_version_compare($update_info['version']['from'], $version, '>')) + { + $default_update_extensions = array_merge($default_update_extensions, $extensions); + } + } + foreach ($update_info['files'] as $key => $filename) { $old_file = $old_path . $filename; @@ -138,13 +149,25 @@ class file_check extends task_base $progress_count++; $this->iohandler->set_progress('UPDATE_CHECK_FILES', $progress_count); - // Do not copy viglink again if the previous version was packaged - // with it but it does not exist (e.g. deleted by admin) - if (strpos($file, $this->phpbb_root_path . 'ext/phpbb/viglink') !== false && - $this->update_helper->phpbb_version_compare($update_info['version']['from'], '3.2.0', '>=') && - !$this->filesystem->exists($this->phpbb_root_path . 'ext/phpbb/viglink/composer.json')) + // Do not copy default extension again if the previous version was + // packaged with it but it does not exist (e.g. deleted by admin) + if (strpos($file, $this->phpbb_root_path . 'ext/') !== false) { - continue; + $skip_file = false; + foreach ($default_update_extensions as $ext_name) + { + if (strpos($file, $this->phpbb_root_path . 'ext/' . $ext_name) !== false && + !$this->filesystem->exists($this->phpbb_root_path . 'ext/' . $ext_name . '/composer.json')) + { + $skip_file = true; + break; + } + } + + if ($skip_file) + { + continue; + } } if (!$this->filesystem->exists($file)) -- cgit v1.2.1 From b1596fda7f88bc0e2817a1143be6ff94ef3aae2a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 17:27:27 +0100 Subject: [ticket/14492] Prevent timeouts in install & update extensions tasks PHPBB3-14492 --- .../install_finish/task/install_extensions.php | 21 ++++++++++++++++++++- .../update_database/task/update_extensions.php | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index eb44bb780b..b8a04685f6 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -13,6 +13,8 @@ namespace phpbb\install\module\install_finish\task; +use phpbb\install\exception\resource_limit_reached_exception; + /** * Installs extensions that exist in ext folder upon install */ @@ -102,7 +104,9 @@ class install_extensions extends \phpbb\install\task_base $install_extensions = $this->iohandler->get_input('install-extensions', array()); - $available_extensions = $this->extension_manager->all_available(); + $all_available_extensions = $this->extension_manager->all_available(); + $i = $this->install_config->get('install_extensions_index', 0); + $available_extensions = array_slice($all_available_extensions, $i); // Install extensions foreach ($available_extensions as $ext_name => $ext_path) @@ -133,6 +137,21 @@ class install_extensions extends \phpbb\install\task_base // Add fail log and continue $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } + + $i++; + + // Stop execution if resource limit is reached + if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) + { + break; + } + } + + $this->install_config->set('install_extensions_index', $i); + + if ($i < sizeof($all_available_extensions)) + { + throw new resource_limit_reached_exception(); } } diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 64215e2f30..24b72f7b42 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -13,6 +13,7 @@ namespace phpbb\install\module\update_database\task; +use phpbb\install\exception\resource_limit_reached_exception; use phpbb\install\helper\container_factory; use phpbb\install\helper\config; use phpbb\install\helper\iohandler\iohandler_interface; @@ -143,7 +144,9 @@ class update_extensions extends task_base } } - $available_extensions = $this->extension_manager->all_available(); + $all_available_extensions = $this->extension_manager->all_available(); + $i = $this->install_config->get('update_extensions_index', 0); + $available_extensions = array_slice($all_available_extensions, $i); // Update available extensions foreach ($available_extensions as $ext_name => $ext_path) @@ -190,6 +193,21 @@ class update_extensions extends task_base $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); } } + + $i++; + + // Stop execution if resource limit is reached + if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) + { + break; + } + } + + $this->install_config->set('update_extensions_index', $i); + + if ($i < sizeof($all_available_extensions)) + { + throw new resource_limit_reached_exception(); } } -- cgit v1.2.1 From dee5e6e07636db7e35a82919a723907e734fbcd1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 17:32:25 +0100 Subject: [ticket/14492] Add language variables for updating extensions PHPBB3-14492 --- .../install/module/update_database/task/update_extensions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 24b72f7b42..76904f80f1 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -174,11 +174,11 @@ class update_extensions extends task_base if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); - $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name)); + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_UPDATE', time(), array($ext_name)); + $this->iohandler->add_success_message(array('CLI_EXTENSION_UPDATE_SUCCESS', $ext_name)); } else { - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name)); } // Disable extensions if it was disabled by the admin before @@ -190,7 +190,7 @@ class update_extensions extends task_base catch (\Exception $e) { // Add fail log and continue - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name)); } } -- cgit v1.2.1 From 1f270972084cd228e135481b766ada9941582155 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 6 Mar 2016 14:59:34 +0100 Subject: [ticket/14492] Install all extensions if 'all' is specified for extensions PHPBB3-14492 --- phpBB/phpbb/install/module/install_finish/task/install_extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index b8a04685f6..553a30ea28 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -111,7 +111,7 @@ class install_extensions extends \phpbb\install\task_base // Install extensions foreach ($available_extensions as $ext_name => $ext_path) { - if (!empty($install_extensions) && !in_array($ext_name, $install_extensions)) + if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions)) { continue; } -- cgit v1.2.1 From b9c284d85be82e2a8f50c20e147d1ca2352453d4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 22 Aug 2016 20:59:57 +0200 Subject: [ticket/14492] Update phpBB version and fix miscellaneous code issues PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 76904f80f1..01b88344e8 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -176,7 +176,8 @@ class update_extensions extends task_base // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_UPDATE', time(), array($ext_name)); $this->iohandler->add_success_message(array('CLI_EXTENSION_UPDATE_SUCCESS', $ext_name)); - } else + } + else { $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name)); } -- cgit v1.2.1 From c54838b25f50dca71a2f516175621a7ccd39a071 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Sep 2016 22:59:58 +0200 Subject: [ticket/14492] Update versions in files PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 01b88344e8..13c1591dcd 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -76,7 +76,7 @@ class update_extensions extends task_base * they were added */ static public $default_extensions_update = [ - '3.2.0-b3' => ['phpbb/viglink'] + '3.2.0-RC2' => ['phpbb/viglink'] ]; /** -- cgit v1.2.1 From 8ded30bbbe1e12ed301c2deb43d52da5a22d5b05 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 22 Nov 2016 18:39:01 +0100 Subject: [ticket/14492] Fix redirection to help phpBB page PHPBB3-14492 --- phpBB/phpbb/install/installer.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index b8eef34a1d..abdb172cf3 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -59,6 +59,11 @@ class installer */ protected $web_root; + /** + * @var \phpbb\user + */ + protected $user; + /** * Stores the number of steps that a given module has * @@ -87,6 +92,7 @@ class installer $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); $this->purge_cache_before = false; + $this->user = $container->get('user'); } /** @@ -243,8 +249,14 @@ class installer } else { - global $SID; - $acp_url = $this->web_root . 'adm/index.php' . $SID . '&i=acp_help_phpbb&mode=help_phpbb'; + // Start session and try to apply session id + $auth = $this->container_factory->get('auth'); + $this->user->session_begin(); + $auth->acl($this->user->data); + $this->user->setup(); + $phpbb_root_path = $this->container_factory->get_parameter('core.root_path'); + + $acp_url = append_sid($phpbb_root_path . 'adm/index.php', 'i=acp_help_phpbb&mode=help_phpbb', true, $this->user->session_id); $this->iohandler->add_success_message('INSTALLER_FINISHED', array( 'ACP_LINK', $acp_url, -- cgit v1.2.1 From 5895f56de05b637765a6583b8c51c1db3daabe91 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Nov 2016 20:38:29 +0100 Subject: [ticket/14492] Add user service to installer & only instantiate if needed PHPBB3-14492 --- phpBB/phpbb/install/installer.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index abdb172cf3..a7d3b99dcb 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -59,11 +59,6 @@ class installer */ protected $web_root; - /** - * @var \phpbb\user - */ - protected $user; - /** * Stores the number of steps that a given module has * @@ -92,7 +87,6 @@ class installer $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); $this->purge_cache_before = false; - $this->user = $container->get('user'); } /** @@ -251,12 +245,13 @@ class installer { // Start session and try to apply session id $auth = $this->container_factory->get('auth'); - $this->user->session_begin(); - $auth->acl($this->user->data); - $this->user->setup(); + $user = $this->container_factory->get('user'); + $user->session_begin(); + $auth->acl($user->data); + $user->setup(); $phpbb_root_path = $this->container_factory->get_parameter('core.root_path'); - $acp_url = append_sid($phpbb_root_path . 'adm/index.php', 'i=acp_help_phpbb&mode=help_phpbb', true, $this->user->session_id); + $acp_url = append_sid($phpbb_root_path . 'adm/index.php', 'i=acp_help_phpbb&mode=help_phpbb', true, $user->session_id); $this->iohandler->add_success_message('INSTALLER_FINISHED', array( 'ACP_LINK', $acp_url, -- cgit v1.2.1 From 829e1475044f1a72f68958923a0900ed4e62f78e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 7 Dec 2016 17:55:57 +0100 Subject: [ticket/14896] Do not overwrite login when finishing install Otherwise the user will be "logged in" again as guest user which will prevent any redirectiong to the ACP after the installation. PHPBB3-14896 --- phpBB/phpbb/install/installer.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index a7d3b99dcb..e04e233a76 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -243,12 +243,18 @@ class installer } else { - // Start session and try to apply session id - $auth = $this->container_factory->get('auth'); + // Start session if not installing and get user object + // to allow redirecting to ACP $user = $this->container_factory->get('user'); - $user->session_begin(); - $auth->acl($user->data); - $user->setup(); + if (!isset($module) || !($module instanceof \phpbb\install\module\install_finish\module)) + { + $auth = $this->container_factory->get('auth'); + + $user->session_begin(); + $auth->acl($user->data); + $user->setup(); + } + $phpbb_root_path = $this->container_factory->get_parameter('core.root_path'); $acp_url = append_sid($phpbb_root_path . 'adm/index.php', 'i=acp_help_phpbb&mode=help_phpbb', true, $user->session_id); -- cgit v1.2.1 From f2fde5e7a32943017f7f22b070c974f161d14d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Wed, 7 Dec 2016 21:01:47 +0100 Subject: [ticket/14897] Add $restart_progress_bar to iohandler base PHPBB3-14897 --- phpBB/phpbb/install/helper/iohandler/iohandler_base.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index fed4bc101f..1797a6c9ad 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -70,6 +70,11 @@ abstract class iohandler_base implements iohandler_interface */ protected $current_task_name; + /** + * @var bool + */ + protected $restart_progress_bar; + /** * Constructor */ -- cgit v1.2.1 From 37a3bd131bf82becc436c72a4e01975f4381d4f6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Dec 2016 19:54:58 +0100 Subject: [ticket/14894] Use correct config name for conflicts archive extension PHPBB3-14894 --- phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php index 7f18950cf6..cf1e4cf4ac 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php @@ -92,7 +92,7 @@ class show_file_status extends task_base // Create archive for merge conflicts if (!empty($merge_conflicts)) { - $compression_method = $this->installer_config->get('compression_method', ''); + $compression_method = $this->installer_config->get('file_update_compression', ''); $conflict_archive = $this->file_updater->init($compression_method); $this->installer_config->set('update_file_conflict_archive', $conflict_archive); -- cgit v1.2.1 From 1846b90a33daa1f73586b17a871b28fa349983ee Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 17 Dec 2016 23:20:28 +0100 Subject: [ticket/14920] Force installer to only populate core migrations PHPBB3-14920 --- phpBB/phpbb/install/module/install_finish/task/populate_migrations.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php index 34541c361e..cebf0f425f 100644 --- a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php +++ b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php @@ -70,6 +70,7 @@ class populate_migrations extends \phpbb\install\task_base $migrations = $finder ->core_path('phpbb/db/migration/data/') + ->set_extensions(array()) ->get_classes(); $this->migrator->populate_migrations($migrations); } -- cgit v1.2.1 From 9bbd034a4e818fbfef657e04c2a87c889af640af Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 7 Jan 2017 14:44:04 +0100 Subject: [prep-release-3.2.0] Correctly compare extensions version --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 2 +- phpBB/phpbb/install/module/update_filesystem/task/file_check.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 13c1591dcd..b66847b243 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -138,7 +138,7 @@ class update_extensions extends task_base $default_update_extensions = []; foreach (self::$default_extensions_update as $version => $extensions) { - if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) + if ($this->update_helper->phpbb_version_compare($version_from, $version, '<')) { $default_update_extensions = array_merge($default_update_extensions, $extensions); } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php index 5b48350e73..47a71eb844 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -123,7 +123,7 @@ class file_check extends task_base $default_update_extensions = []; foreach (\phpbb\install\module\update_database\task\update_extensions::$default_extensions_update as $version => $extensions) { - if ($this->update_helper->phpbb_version_compare($update_info['version']['from'], $version, '>')) + if ($this->update_helper->phpbb_version_compare($update_info['version']['from'], $version, '>=')) { $default_update_extensions = array_merge($default_update_extensions, $extensions); } -- cgit v1.2.1 From abf7a4f6636d51f02ee9de0a359c5e784465a4ac Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 14 Jan 2017 22:48:24 +0100 Subject: [ticket/15012] Use valid constructor in ftp_file_updater PHPBB3-15012 --- phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php b/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php index 258a035768..5cdc331cbc 100644 --- a/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php +++ b/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php @@ -47,7 +47,7 @@ class ftp_file_updater implements file_updater_interface * @param string $phpbb_root_path * @param string $php_ext */ - public function __constructor(update_helper $update_helper, $phpbb_root_path, $php_ext) + public function __construct(update_helper $update_helper, $phpbb_root_path, $php_ext) { $this->transfer = null; $this->update_helper = $update_helper; -- cgit v1.2.1 From 0238d850ddf708e54992ae5b11bfc4e20748c171 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 22 Jan 2017 19:36:19 +0100 Subject: [ticket/15015] Use correct explain string for enable email settings PHPBB3-15015 --- phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') 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 index 1cb4f04297..e8a9c971b7 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php @@ -84,7 +84,7 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta $email_form = array( 'email_enable' => array( 'label' => 'ENABLE_EMAIL', - 'description' => 'COOKIE_SECURE_EXPLAIN', + 'description' => 'ENABLE_EMAIL_EXPLAIN', 'type' => 'radio', 'options' => array( array( -- cgit v1.2.1 From a03047da5b0f640d4428a74012453df3dfa4f070 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 24 Jan 2017 21:47:20 +0100 Subject: [ticket/15044] Add module task for creating search index during install PHPBB3-15044 --- .../install_data/task/create_search_index.php | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 phpBB/phpbb/install/module/install_data/task/create_search_index.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_data/task/create_search_index.php b/phpBB/phpbb/install/module/install_data/task/create_search_index.php new file mode 100644 index 0000000000..8a2f6aa1de --- /dev/null +++ b/phpBB/phpbb/install/module/install_data/task/create_search_index.php @@ -0,0 +1,134 @@ + + * @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\install_data\task; + +use phpbb\auth\auth; +use phpbb\db\driver\driver_interface; +use phpbb\event\dispatcher; +use phpbb\config\config; +use phpbb\install\helper\container_factory; +use phpbb\language\language; +use phpbb\search\fulltext_native; +use phpbb\user; + +class create_search_index extends \phpbb\install\task_base +{ + /** + * @var auth + */ + protected $auth; + + /** + * @var config + */ + protected $config; + + /** + * @var driver_interface + */ + protected $db; + + /** + * @var dispatcher + */ + protected $phpbb_dispatcher; + + /** + * @var language + */ + protected $language; + + /** + * @var user + */ + protected $user; + + /** + * @var string phpBB root path + */ + protected $phpbb_root_path; + + /** + * @var string PHP file extension + */ + protected $php_ext; + + /** + * Constructor + * + * @param config $config phpBB config + * @param container_factory $container Installer's DI container + * @param string $phpbb_root_path phpBB root path + * @param string $php_ext PHP file extension + */ + public function __construct(config $config, container_factory $container, + $phpbb_root_path, $php_ext) + { + $this->auth = $container->get('auth'); + $this->config = $config; + $this->db = $container->get('dbal.conn'); + $this->language = $container->get('language'); + $this->phpbb_dispatcher = $container->get('dispatcher'); + $this->user = $container->get('user'); + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + // Make sure fulltext native load update is set + $this->config->set('fulltext_native_load_upd', 1); + + $error = false; + $search = new fulltext_native( + $error, + $this->phpbb_root_path, + $this->php_ext, + $this->auth, + $this->config, + $this->db, + $this->user, + $this->phpbb_dispatcher + ); + + $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id + FROM ' . POSTS_TABLE; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']); + } + $this->db->sql_freeresult($result); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_CREATE_SEARCH_INDEX'; + } +} -- cgit v1.2.1 From f66594bf93ca2604be73ef094555af571a55ea9b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 25 Jan 2017 22:18:29 +0100 Subject: [ticket/15050] Use new file when new file already exists Instead of trying to diff the new file against a pre-existing file, we're just going to use the new file. It's impossible to know whether the pre-existing file is newer or older than the new file. As the system will rely on the files being in the "new" state it's better to simply use the file in "new" state. PHPBB3-15050 --- .../module/update_filesystem/task/diff_files.php | 71 ++++++++++++++-------- 1 file changed, 46 insertions(+), 25 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php index e3e6db6263..0c3658bd44 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -132,41 +132,62 @@ class diff_files extends task_base $file_contents = array(); // Handle the special case when user created a file with the filename that is now new in the core - $file_contents[0] = (file_exists($old_path . $filename)) ? file_get_contents($old_path . $filename) : ''; + if (file_exists($old_path . $filename)) + { + $file_contents[0] = file_get_contents($old_path . $filename); - $filenames = array( - $this->phpbb_root_path . $filename, - $new_path . $filename - ); + $filenames = array( + $this->phpbb_root_path . $filename, + $new_path . $filename + ); - foreach ($filenames as $file_to_diff) - { - $file_contents[] = file_get_contents($file_to_diff); + foreach ($filenames as $file_to_diff) + { + $file_contents[] = file_get_contents($file_to_diff); + + if ($file_contents[sizeof($file_contents) - 1] === false) + { + $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff)); + unset($file_contents); + throw new user_interaction_required_exception(); + } + } - if ($file_contents[sizeof($file_contents) - 1] === false) + $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]); + unset($file_contents); + + // Handle conflicts + if ($diff->get_num_conflicts() !== 0) { - $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff)); - unset($file_contents); - throw new user_interaction_required_exception(); + $merge_conflicts[] = $filename; } - } - $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]); - unset($file_contents); + // Save merged output + $this->cache->put( + '_file_' . md5($filename), + base64_encode(implode("\n", $diff->merged_output())) + ); - // Handle conflicts - if ($diff->get_num_conflicts() !== 0) - { - $merge_conflicts[] = $filename; + unset($diff); } + else + { + $new_file_content = file_get_contents($new_path . $filename); - // Save merged output - $this->cache->put( - '_file_' . md5($filename), - base64_encode(implode("\n", $diff->merged_output())) - ); + if ($new_file_content === false) + { + $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff)); + unset($new_file_content ); + throw new user_interaction_required_exception(); + } - unset($diff); + // Save new file content to cache + $this->cache->put( + '_file_' . md5($filename), + base64_encode($new_file_content) + ); + unset($new_file_content); + } $progress_count++; $this->iohandler->set_progress('UPDATE_FILE_DIFF', $progress_count); -- cgit v1.2.1 From b5ed02d03c2a28e01e68c9f52fc9044fae2de05c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 27 Jan 2017 08:40:35 +0100 Subject: [ticket/15050] Remove extra whitespace PHPBB3-15050 --- phpBB/phpbb/install/module/update_filesystem/task/diff_files.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php index 0c3658bd44..1792a3b723 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -172,9 +172,9 @@ class diff_files extends task_base } else { - $new_file_content = file_get_contents($new_path . $filename); + $new_file_content = file_get_contents($new_path . $filename); - if ($new_file_content === false) + if ($new_file_content === false) { $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff)); unset($new_file_content ); -- cgit v1.2.1 From e6bdba7da1069c71e9b3c148266d0cd90b6cf1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Thu, 15 Jun 2017 16:56:19 +0200 Subject: [ticket/15243] Check permissions before installing with SQLite PHPBB3-15243 --- phpBB/phpbb/install/helper/database.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 192f0a3654..59b86a8ca7 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -336,6 +336,15 @@ class database ); } + // Check if SQLite database is writable + if ($dbms_info['SCHEMA'] === 'sqlite' + && (!$this->filesystem->is_writable($dbhost) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) + { + $errors[] = array( + 'title' =>'INST_ERR_DB_NO_WRITABLE', + ); + } + // Try to connect to db if (is_array($db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, false, true))) { -- cgit v1.2.1 From d84834db88ea54bc33a323457236943a56399747 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 23 Jul 2017 21:09:30 +0200 Subject: [ticket/15293] Prevent continuing to database update on incomplete file update PHPBB3-15293 --- .../install/helper/iohandler/ajax_iohandler.php | 6 +++++ .../task/download_updated_files.php | 24 ++++++++++++------ .../module/update_filesystem/task/file_check.php | 29 ++++++++++++++++++++++ .../update_filesystem/task/show_file_status.php | 6 ++--- 4 files changed, 54 insertions(+), 11 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index a40d457466..bce0149890 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -186,6 +186,7 @@ class ajax_iohandler extends iohandler_base $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); $tpl_ary['KEY'] = $input_name; $tpl_ary['S_EXPLAIN'] = false; + $tpl_ary['DISABLED'] = isset($input_options['disabled']) ? $input_options['disabled'] : false; if (isset($input_options['default'])) { @@ -219,6 +220,11 @@ class ajax_iohandler extends iohandler_base $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form); + if (!$not_button_form) + { + $this->template->destroy_block_vars('options'); + } + $this->template->set_filenames(array( 'form_install' => 'installer_form.html', )); diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php index f911b7ac62..21aa93b7ea 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php @@ -78,16 +78,23 @@ class download_updated_files extends task_base } else if ($this->iohandler->get_input('update_recheck_files_submit', false)) { + $this->installer_config->set('file_updater_elem_progress', ''); + $this->installer_config->set('update_files', array()); throw new jump_to_restart_point_exception('check_update_files'); } else { - // Render download box - $this->iohandler->add_download_link( - 'phpbb_installer_update_file_download', - 'DOWNLOAD_UPDATE_METHOD', - 'DOWNLOAD_UPDATE_METHOD_EXPLAIN' - ); + $file_update_info = $this->installer_config->get('update_files', array()); + + if (count($file_update_info) > 0) + { + // Render download box + $this->iohandler->add_download_link( + 'phpbb_installer_update_file_download', + 'DOWNLOAD_UPDATE_METHOD', + 'DOWNLOAD_UPDATE_METHOD_EXPLAIN' + ); + } // Add form to continue update $this->iohandler->add_user_form_group('UPDATE_CONTINUE_UPDATE_PROCESS', array( @@ -96,8 +103,9 @@ class download_updated_files extends task_base 'type' => 'submit', ), 'database_update_submit' => array( - 'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS', - 'type' => 'submit', + 'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS', + 'type' => 'submit', + 'disabled' => count($file_update_info) > 0, ), )); diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php index 47a71eb844..9daa8530c6 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -103,6 +103,29 @@ class file_check extends task_base $file_update_info = array(); $file_update_info['update_without_diff'] = array_diff($update_info['binary'], $update_info['deleted']); + foreach ($file_update_info['update_without_diff'] as $key => $binary_file) + { + $new_file = $new_path . $binary_file; + $file = $this->phpbb_root_path . $binary_file; + + if (!$this->filesystem->exists($file)) + { + continue; + } + + if (md5_file($file) === md5_file($new_file)) + { + // File already up to date + unset($file_update_info['update_without_diff'][$key]); + } + } + + // Remove update without diff info if empty + if (count($file_update_info['update_without_diff']) < 1) + { + unset($file_update_info['update_without_diff']); + } + // Filter out files that are already deleted $file_update_info['delete'] = array_filter( $update_info['deleted'], @@ -111,6 +134,12 @@ class file_check extends task_base return file_exists($root_path . $filename); } ); + + // Remove files to delete list if empty + if (count($file_update_info['delete']) < 1) + { + unset($file_update_info['delete']); + } } $progress_count = $this->installer_config->get('file_check_progress_count', 0); diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php index cf1e4cf4ac..0e82f91553 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php @@ -129,9 +129,9 @@ class show_file_status extends task_base // Add form to continue update $this->iohandler->add_user_form_group('UPDATE_CONTINUE_FILE_UPDATE', array( - 'submit_continue_file_update' => array( - 'label' => 'UPDATE_CONTINUE_FILE_UPDATE', - 'type' => 'submit', + 'submit_continue_file_update' => array( + 'label' => 'UPDATE_CONTINUE_FILE_UPDATE', + 'type' => 'submit', ), )); -- cgit v1.2.1 From e854e5b71f90910075fbac2b4f0dadac4fd39588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 3 Sep 2017 17:50:40 +0200 Subject: [ticket/15346] Check if extension is enableable during install PHPBB3-15346 --- .../install/module/install_finish/task/install_extensions.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index 553a30ea28..db28ad8fe3 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -118,6 +118,13 @@ class install_extensions extends \phpbb\install\task_base try { + $extension = $this->extension_manager->get_extension($ext_name); + + if (!$extension->is_enableable()) + { + continue; + } + $this->extension_manager->enable($ext_name); $extensions = $this->get_extensions(); -- cgit v1.2.1 From d99dbf1f0ea08e69be4fd61df2a45bbf1f0b1340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Tue, 5 Sep 2017 17:50:44 +0200 Subject: [ticket/15346] Add log message if extension is not enableable PHPBB3-15346 --- phpBB/phpbb/install/module/install_finish/task/install_extensions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index db28ad8fe3..eee13a6581 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -122,6 +122,7 @@ class install_extensions extends \phpbb\install\task_base if (!$extension->is_enableable()) { + $this->iohandler->add_log_message(array('CLI_EXTENSION_NOT_ENABLEABLE', $ext_name)); continue; } -- cgit v1.2.1 From f8f985c099225700a888a91c34f0481910e08378 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 10 Sep 2017 12:50:06 +0200 Subject: [ticket/15353] Make sure users can continue update after merging file diff PHPBB3-15353 --- .../install/helper/iohandler/ajax_iohandler.php | 6 +++ .../module/update_filesystem/task/diff_files.php | 43 ++++++++++++++++++---- .../task/download_updated_files.php | 5 ++- 3 files changed, 44 insertions(+), 10 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index bce0149890..dd584eff30 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -187,6 +187,7 @@ class ajax_iohandler extends iohandler_base $tpl_ary['KEY'] = $input_name; $tpl_ary['S_EXPLAIN'] = false; $tpl_ary['DISABLED'] = isset($input_options['disabled']) ? $input_options['disabled'] : false; + $tpl_ary['IS_SECONDARY'] = isset($input_options['is_secondary']) ? $input_options['is_secondary'] : false; if (isset($input_options['default'])) { @@ -218,6 +219,11 @@ class ajax_iohandler extends iohandler_base $this->template->assign_block_vars($block_name, $tpl_ary); } + if (isset($form['database_update_submit']) && !$form['database_update_submit']['disabled']) + { + $this->template->assign_var('FORM_TITLE', $this->language->lang('UPDATE_CONTINUE_UPDATE_PROCESS')); + } + $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form); if (!$not_button_form) diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php index 1792a3b723..b15e32cc82 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -103,8 +103,8 @@ class diff_files extends task_base $old_path = $this->update_helper->get_path_to_old_update_files(); $new_path = $this->update_helper->get_path_to_new_update_files(); - $files_to_diff = $this->installer_config->get('update_files', array()); - $files_to_diff = $files_to_diff['update_with_diff']; + $update_files = $this->installer_config->get('update_files', array()); + $files_to_diff = $update_files['update_with_diff']; // Set progress bar $this->iohandler->set_task_count(count($files_to_diff), true); @@ -154,7 +154,6 @@ class diff_files extends task_base } $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]); - unset($file_contents); // Handle conflicts if ($diff->get_num_conflicts() !== 0) @@ -162,12 +161,20 @@ class diff_files extends task_base $merge_conflicts[] = $filename; } - // Save merged output - $this->cache->put( - '_file_' . md5($filename), - base64_encode(implode("\n", $diff->merged_output())) - ); + if ($diff->merged_output() !== $file_contents[1]) + { + // Save merged output + $this->cache->put( + '_file_' . md5($filename), + base64_encode(implode("\n", $diff->merged_output())) + ); + } + else + { + unset($update_files['update_with_diff'][$key]); + } + unset($file_contents); unset($diff); } else @@ -199,6 +206,16 @@ class diff_files extends task_base $this->installer_config->set('merge_conflict_list', $merge_conflicts); $this->installer_config->set('file_diff_update_count', $progress_count); + foreach ($update_files as $type => $files) + { + if (count($files) < 1) + { + unset($update_files[$type]); + } + } + + $this->installer_config->set('update_files', $update_files); + // Request refresh throw new resource_limit_reached_exception(); } @@ -206,6 +223,16 @@ class diff_files extends task_base $this->iohandler->finish_progress('ALL_FILES_DIFFED'); $this->installer_config->set('merge_conflict_list', $merge_conflicts); + + foreach ($update_files as $type => $files) + { + if (count($files) < 1) + { + unset($update_files[$type]); + } + } + + $this->installer_config->set('update_files', $update_files); } /** diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php index 21aa93b7ea..2fc756c20a 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php @@ -99,8 +99,9 @@ class download_updated_files extends task_base // Add form to continue update $this->iohandler->add_user_form_group('UPDATE_CONTINUE_UPDATE_PROCESS', array( 'update_recheck_files_submit' => array( - 'label' => 'UPDATE_RECHECK_UPDATE_FILES', - 'type' => 'submit', + 'label' => 'UPDATE_RECHECK_UPDATE_FILES', + 'type' => 'submit', + 'is_secondary' => count($file_update_info) < 1, ), 'database_update_submit' => array( 'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS', -- cgit v1.2.1 From f57e3778470ad7df2e69b839fd329e53eb524481 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 12 Oct 2017 21:56:59 +0200 Subject: [ticket/15353] Use empty where applicable PHPBB3-15353 --- phpBB/phpbb/install/module/update_filesystem/task/diff_files.php | 4 ++-- .../install/module/update_filesystem/task/download_updated_files.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php index b15e32cc82..8151a24f2d 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -208,7 +208,7 @@ class diff_files extends task_base foreach ($update_files as $type => $files) { - if (count($files) < 1) + if (empty($files)) { unset($update_files[$type]); } @@ -226,7 +226,7 @@ class diff_files extends task_base foreach ($update_files as $type => $files) { - if (count($files) < 1) + if (empty($files)) { unset($update_files[$type]); } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php index 2fc756c20a..0b83e9a79d 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php @@ -101,12 +101,12 @@ class download_updated_files extends task_base 'update_recheck_files_submit' => array( 'label' => 'UPDATE_RECHECK_UPDATE_FILES', 'type' => 'submit', - 'is_secondary' => count($file_update_info) < 1, + 'is_secondary' => empty($file_update_info), ), 'database_update_submit' => array( 'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS', 'type' => 'submit', - 'disabled' => count($file_update_info) > 0, + 'disabled' => !empty($file_update_info), ), )); -- cgit v1.2.1 From f8fbe3793680af1dae2db2829cfc84068831c52f Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 28 Jun 2017 00:58:03 +0700 Subject: [ticket/14972] replace all occurrences of sizeof() with the count() PHPBB3-14972 --- phpBB/phpbb/install/helper/database.php | 2 +- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 6 +++--- phpBB/phpbb/install/module/install_data/task/add_bots.php | 2 +- phpBB/phpbb/install/module/install_data/task/add_modules.php | 2 +- .../install/module/install_database/task/add_config_settings.php | 2 +- .../phpbb/install/module/install_database/task/add_default_data.php | 2 +- phpBB/phpbb/install/module/install_database/task/add_tables.php | 2 +- .../phpbb/install/module/install_finish/task/install_extensions.php | 2 +- .../phpbb/install/module/update_database/task/update_extensions.php | 2 +- phpBB/phpbb/install/module/update_filesystem/task/diff_files.php | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 59b86a8ca7..ad0f3dd3cd 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -372,7 +372,7 @@ class database $tables = array_map('strtolower', $tables); $table_intersect = array_intersect($tables, $table_ary); - if (sizeof($table_intersect)) + if (count($table_intersect)) { $errors[] = array( 'title' => 'INST_ERR_PREFIX', diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index dd584eff30..2a608f504e 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -204,7 +204,7 @@ class ajax_iohandler extends iohandler_base if (in_array($input_options['type'], array('select', 'radio'), true)) { - for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) + for ($i = 0, $total = count($input_options['options']); $i < $total; $i++) { if (isset($input_options['options'][$i]['label'])) { @@ -381,7 +381,7 @@ class ajax_iohandler extends iohandler_base */ public function set_active_stage_menu($menu_path) { - $this->nav_data['active'] = $menu_path[sizeof($menu_path) - 1]; + $this->nav_data['active'] = $menu_path[count($menu_path) - 1]; $this->send_response(); } @@ -390,7 +390,7 @@ class ajax_iohandler extends iohandler_base */ public function set_finished_stage_menu($menu_path) { - $this->nav_data['finished'][] = $menu_path[sizeof($menu_path) - 1]; + $this->nav_data['finished'][] = $menu_path[count($menu_path) - 1]; $this->send_response(); } diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php index 1f1cecceb2..07f8e025cf 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_bots.php +++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php @@ -239,7 +239,7 @@ class add_bots extends \phpbb\install\task_base $this->install_config->set('add_bot_index', $i); - if ($i < sizeof($this->bot_list)) + if ($i < count($this->bot_list)) { throw new resource_limit_reached_exception(); } diff --git a/phpBB/phpbb/install/module/install_data/task/add_modules.php b/phpBB/phpbb/install/module/install_data/task/add_modules.php index d21a5be823..b64f4c31db 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_modules.php +++ b/phpBB/phpbb/install/module/install_data/task/add_modules.php @@ -169,7 +169,7 @@ class add_modules extends \phpbb\install\task_base $this->db->sql_return_on_error(true); $module_classes = array('acp', 'mcp', 'ucp'); - $total = sizeof($module_classes); + $total = count($module_classes); $i = $this->config->get('module_class_index', 0); $module_classes = array_slice($module_classes, $i); diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php index 8002e3ed97..54114e3f9c 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -327,7 +327,7 @@ class add_config_settings extends \phpbb\install\task_base } $i = $this->install_config->get('add_config_settings_index', 0); - $total = sizeof($sql_ary); + $total = count($sql_ary); $sql_ary = array_slice($sql_ary, $i); foreach ($sql_ary as $sql) diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php index e32101a3f7..c05e5321fb 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_default_data.php +++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php @@ -99,7 +99,7 @@ class add_default_data extends \phpbb\install\task_base $sql_query = $this->database_helper->split_sql_file($sql_query, $dbms_info[$dbms]['DELIM']); $i = $this->config->get('add_default_data_index', 0); - $total = sizeof($sql_query); + $total = count($sql_query); $sql_query = array_slice($sql_query, $i); foreach ($sql_query as $sql) diff --git a/phpBB/phpbb/install/module/install_database/task/add_tables.php b/phpBB/phpbb/install/module/install_database/task/add_tables.php index f344f91582..dc814f36ef 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_tables.php +++ b/phpBB/phpbb/install/module/install_database/task/add_tables.php @@ -101,7 +101,7 @@ class add_tables extends \phpbb\install\task_base $db_table_schema = @file_get_contents($this->schema_file_path); $db_table_schema = json_decode($db_table_schema, true); - $total = sizeof($db_table_schema); + $total = count($db_table_schema); $i = $this->config->get('add_table_index', 0); $db_table_schema = array_slice($db_table_schema, $i); diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index eee13a6581..47ea156c66 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -157,7 +157,7 @@ class install_extensions extends \phpbb\install\task_base $this->install_config->set('install_extensions_index', $i); - if ($i < sizeof($all_available_extensions)) + if ($i < count($all_available_extensions)) { throw new resource_limit_reached_exception(); } diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index b66847b243..0195b9c661 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -206,7 +206,7 @@ class update_extensions extends task_base $this->install_config->set('update_extensions_index', $i); - if ($i < sizeof($all_available_extensions)) + if ($i < count($all_available_extensions)) { throw new resource_limit_reached_exception(); } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php index 8151a24f2d..2f6048b4fd 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -145,7 +145,7 @@ class diff_files extends task_base { $file_contents[] = file_get_contents($file_to_diff); - if ($file_contents[sizeof($file_contents) - 1] === false) + if ($file_contents[count($file_contents) - 1] === false) { $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff)); unset($file_contents); -- cgit v1.2.1 From 57179fbb7944e75a92e15cdbd5a9955bcc1677c7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 6 Jan 2018 19:23:20 +0100 Subject: [ticket/15353] Do not use empty to not offer empty archive for download PHPBB3-15353 --- phpBB/phpbb/install/module/update_filesystem/task/diff_files.php | 4 ++-- .../install/module/update_filesystem/task/download_updated_files.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php index 8151a24f2d..b15e32cc82 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -208,7 +208,7 @@ class diff_files extends task_base foreach ($update_files as $type => $files) { - if (empty($files)) + if (count($files) < 1) { unset($update_files[$type]); } @@ -226,7 +226,7 @@ class diff_files extends task_base foreach ($update_files as $type => $files) { - if (empty($files)) + if (count($files) < 1) { unset($update_files[$type]); } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php index 0b83e9a79d..2fc756c20a 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php @@ -101,12 +101,12 @@ class download_updated_files extends task_base 'update_recheck_files_submit' => array( 'label' => 'UPDATE_RECHECK_UPDATE_FILES', 'type' => 'submit', - 'is_secondary' => empty($file_update_info), + 'is_secondary' => count($file_update_info) < 1, ), 'database_update_submit' => array( 'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS', 'type' => 'submit', - 'disabled' => !empty($file_update_info), + 'disabled' => count($file_update_info) > 0, ), )); -- cgit v1.2.1 From 77b275181aeddf43e1077d06abce11a9722bb85a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 7 Jan 2018 16:59:14 +0100 Subject: [prep-release-3.2.2] Add 3.1.12 to build and fix display of download box --- phpBB/phpbb/install/module/update_filesystem/task/diff_files.php | 4 ++-- .../module/update_filesystem/task/download_updated_files.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php index 7114e60ba1..2f6048b4fd 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -208,7 +208,7 @@ class diff_files extends task_base foreach ($update_files as $type => $files) { - if (count($files) < 1) + if (empty($files)) { unset($update_files[$type]); } @@ -226,7 +226,7 @@ class diff_files extends task_base foreach ($update_files as $type => $files) { - if (count($files) < 1) + if (empty($files)) { unset($update_files[$type]); } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php index 2fc756c20a..4d7f0e0cdf 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php @@ -86,7 +86,8 @@ class download_updated_files extends task_base { $file_update_info = $this->installer_config->get('update_files', array()); - if (count($file_update_info) > 0) + // Display download box only if the archive won't be empty + if (!empty($file_update_info) && !(isset($file_update_info['delete']) && count($file_update_info) == 1)) { // Render download box $this->iohandler->add_download_link( @@ -101,12 +102,12 @@ class download_updated_files extends task_base 'update_recheck_files_submit' => array( 'label' => 'UPDATE_RECHECK_UPDATE_FILES', 'type' => 'submit', - 'is_secondary' => count($file_update_info) < 1, + 'is_secondary' => empty($file_update_info), ), 'database_update_submit' => array( 'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS', 'type' => 'submit', - 'disabled' => count($file_update_info) > 0, + 'disabled' => !empty($file_update_info), ), )); -- cgit v1.2.1 From c160882cdbf892e2d19d2990502f0e918dda75e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 17 Feb 2018 18:50:04 +0100 Subject: [ticket/15563] Check if database file is writable only if exists PHPBB3-15563 --- phpBB/phpbb/install/helper/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index ad0f3dd3cd..21af652f9d 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -338,7 +338,7 @@ class database // Check if SQLite database is writable if ($dbms_info['SCHEMA'] === 'sqlite' - && (!$this->filesystem->is_writable($dbhost) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) + && (($this->filesystem->exists($dbhost) && !$this->filesystem->is_writable($dbhost)) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) { $errors[] = array( 'title' =>'INST_ERR_DB_NO_WRITABLE', -- cgit v1.2.1 From c912e6feaabfb0b39956cde70354106334da0172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Thu, 9 Aug 2018 21:25:59 +0200 Subject: [ticket/15751] Fix warning when update with CLI PHPBB3-15751 --- phpBB/phpbb/install/module/requirements/task/check_update.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/requirements/task/check_update.php b/phpBB/phpbb/install/module/requirements/task/check_update.php index cd66ffc8f9..4eb2c6d75e 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_update.php +++ b/phpBB/phpbb/install/module/requirements/task/check_update.php @@ -122,8 +122,11 @@ class check_update extends task_base // Check for a valid update directory if (!$this->filesystem->exists($update_files) || !$this->filesystem->is_readable($update_files)) { - $this->iohandler->add_warning_message('UPDATE_FILES_NOT_FOUND'); - $this->set_test_passed(false); + if ($this->iohandler->get_input('update_type', 'all') === 'all') + { + $this->iohandler->add_warning_message('UPDATE_FILES_NOT_FOUND'); + $this->set_test_passed(false); + } // If there are no update files, we can't check the version etc // However, we can let the users run migrations if they really want to... -- cgit v1.2.1 From 3a2374e37c92bece4a7c87484ff4e8e22697142f Mon Sep 17 00:00:00 2001 From: hubaishan Date: Mon, 1 Oct 2018 20:25:55 +0300 Subject: [ticket/15817] Fix installtion failed with Oracle Fix installtion failed with Oracle PHPBB3-15817 --- phpBB/phpbb/install/helper/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 21af652f9d..fa5a10c6fc 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -76,7 +76,7 @@ class database 'LABEL' => 'Oracle', 'SCHEMA' => 'oracle', 'MODULE' => 'oci8', - 'DELIM' => '/', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\oracle', 'AVAILABLE' => true, '2.0.x' => false, -- cgit v1.2.1 From d753351edc04a45c61411ee09607fb932d314617 Mon Sep 17 00:00:00 2001 From: Derky Date: Tue, 23 Oct 2018 23:51:55 +0200 Subject: [ticket/security/227] Replace ImageMagick support with thumbnail event SECURITY-227 --- .../install_database/task/add_config_settings.php | 4 - .../obtain_data/task/obtain_imagick_path.php | 89 ---------------------- 2 files changed, 93 deletions(-) delete mode 100644 phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php index 54114e3f9c..ba439609ff 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -150,10 +150,6 @@ class add_config_settings extends \phpbb\install\task_base 'INSERT INTO ' . $this->config_table . " (config_name, config_value) VALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')", - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('img_imagick')) . "' - WHERE config_name = 'img_imagick'", - 'UPDATE ' . $this->config_table . " SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "' WHERE config_name = 'server_name'", 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 deleted file mode 100644 index 377d96ed1a..0000000000 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @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 ''; - } -} -- cgit v1.2.1 From 47acbdd1388096586294cad6f93f62fdccd90b9c Mon Sep 17 00:00:00 2001 From: rubencm Date: Sat, 1 Dec 2018 20:51:59 +0000 Subject: [ticket/15869] Allow multibyte characters in hostname during installation PHPBB3-15869 --- phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php | 6 +++--- phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install') 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 index e8a9c971b7..7cd0d7bf23 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php @@ -50,11 +50,11 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta // 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_host = $this->io_handler->get_input('smtp_host', '', true); $smtp_port = $this->io_handler->get_input('smtp_port', ''); $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', ''); + $smtp_user = $this->io_handler->get_input('smtp_user', '', true); + $smtp_passwd = $this->io_handler->get_input('smtp_pass', '', true); $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP'); 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 index 1ef70eae08..135a75ff8c 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php @@ -79,7 +79,7 @@ class obtain_server_data extends \phpbb\install\task_base implements \phpbb\inst $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_name = $this->io_handler->get_input('server_name', $server_name, true); $server_port = $this->io_handler->get_input('server_port', $server_port); $script_path = $this->io_handler->get_input('script_path', $script_path); -- cgit v1.2.1 From 91847ed1fd3953da70e8df7f55a0274bbd9ebccf Mon Sep 17 00:00:00 2001 From: rubencm Date: Sun, 2 Dec 2018 10:26:19 +0000 Subject: [ticket/15869] Allow multibyte characters in more variables PHPBB3-15869 --- .../install/module/obtain_data/task/obtain_database_data.php | 8 ++++---- .../phpbb/install/module/obtain_data/task/obtain_server_data.php | 2 +- .../install/module/obtain_data/task/obtain_update_ftp_data.php | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/install') 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 index dc7b060746..6ec1e612b9 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php @@ -78,10 +78,10 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in $dbms = $this->io_handler->get_input('dbms', ''); $dbhost = $this->io_handler->get_input('dbhost', '', true); $dbport = $this->io_handler->get_input('dbport', ''); - $dbuser = $this->io_handler->get_input('dbuser', ''); - $dbpasswd = $this->io_handler->get_raw_input('dbpasswd', ''); - $dbname = $this->io_handler->get_input('dbname', ''); - $table_prefix = $this->io_handler->get_input('table_prefix', ''); + $dbuser = $this->io_handler->get_input('dbuser', '', true); + $dbpasswd = $this->io_handler->get_raw_input('dbpasswd', '', true); + $dbname = $this->io_handler->get_input('dbname', '', true); + $table_prefix = $this->io_handler->get_input('table_prefix', '', true); // Check database data $user_data_vaild = $this->check_database_data($dbms, $dbhost, $dbport, $dbuser, $dbpasswd, $dbname, $table_prefix); 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 index 135a75ff8c..5096ce284e 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php @@ -81,7 +81,7 @@ class obtain_server_data extends \phpbb\install\task_base implements \phpbb\inst $force_server_vars = $this->io_handler->get_input('force_server_vars', 0); $server_name = $this->io_handler->get_input('server_name', $server_name, true); $server_port = $this->io_handler->get_input('server_port', $server_port); - $script_path = $this->io_handler->get_input('script_path', $script_path); + $script_path = $this->io_handler->get_input('script_path', $script_path, true); // Clean up script path if ($script_path !== '/') diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php index f31472fc58..3c17576c13 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php @@ -85,10 +85,10 @@ class obtain_update_ftp_data extends task_base $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_host = $this->iohandler->get_input('ftp_host', '', true); + $ftp_user = $this->iohandler->get_input('ftp_user', '', true); + $ftp_pass = htmlspecialchars_decode($this->iohandler->get_input('ftp_pass', '', true)); + $ftp_path = $this->iohandler->get_input('ftp_path', '', true); $ftp_port = $this->iohandler->get_input('ftp_port', 21); $ftp_time = $this->iohandler->get_input('ftp_timeout', 10); -- cgit v1.2.1 From 8e5a0c81ef118c7d88e10fb7d793a36e9204aea8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 21 Apr 2019 22:22:35 +0200 Subject: [ticket/security/233] Make smtp_password and smtp_username dynamic SECURITY-233 --- phpBB/phpbb/install/helper/config.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/install') diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index fad6749019..7eb0ae3b05 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -330,6 +330,8 @@ class config fwrite($fp, $file_content); fclose($fp); + // Enforce 0600 permission for install config + $this->filesystem->chmod([$this->install_config_file], 0600); } /** -- cgit v1.2.1