/** * Validates settings form * * @param string $convertor */ public function proccess_settings_form($convertor) { global $phpbb_root_path, $phpEx, $get_info; $phpbb_root_path = $this->phpbb_root_path; $phpEx = $this->php_ext; $get_info = true; require_once $this->phpbb_root_path . 'includes/constants.' . $this->php_ext; require_once $this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext; // Include convertor if available $convertor_file_path = $this->phpbb_root_path . 'install/convertors/convert_' . $convertor . '.' . $this->php_ext; include $convertor_file_path; // We expect to have an AJAX request here $src_dbms = $this->request->variable('src_dbms', $convertor_data['dbms']); $src_dbhost = $this->request->variable('src_dbhost', $convertor_data['dbhost']); $src_dbport = $this->request->variable('src_dbport', $convertor_data['dbport']); $src_dbuser = $this->request->variable('src_dbuser', $convertor_data['dbuser']); $src_dbpasswd = $this->request->variable('src_dbpasswd', $convertor_data['dbpasswd']); $src_dbname = $this->request->variable('src_dbname', $convertor_data['dbname']); $src_table_prefix = $this->request->variable('src_table_prefix', $convertor_data['table_prefix']); $forum_path = $this->request->variable('forum_path', $convertor_data['forum_path']); $refresh = $this->request->variable('refresh', 1); // Default URL of the old board // @todo Are we going to use this for attempting to convert URL references in posts, or should we remove it? // -> We should convert old urls to the new relative urls format // $src_url = $request->variable('src_url', 'Not in use at the moment'); // strip trailing slash from old forum path $forum_path = strlen($forum_path) && $forum_path[strlen($forum_path) - 1] == '/' ? substr($forum_path, 0, -1) : $forum_path; $error = array(); if (!file_exists($this->phpbb_root_path . $forum_path . '/' . $test_file)) { $error[] = $this->language->lang('COULD_NOT_FIND_PATH', $forum_path); } $connect_test = false; $available_dbms = $this->db_helper->get_available_dbms(false, true, true); if (!isset($available_dbms[$src_dbms]) || !$available_dbms[$src_dbms]['AVAILABLE']) { $error[] = $this->language->lang('INST_ERR_NO_DB'); } else { $connect_test = $this->db_helper->check_database_connection($src_dbms, $src_dbhost, $src_dbport, $src_dbuser, $src_dbpasswd, $src_dbname, $src_table_prefix); } extract($this->config_php_file->get_all()); // The forum prefix of the old and the new forum can only be the same if two different databases are used. if ($src_table_prefix === $table_prefix && $src_dbms === $dbms && $src_dbhost === $dbhost && $src_dbport === $dbport && $src_dbname === $dbname) { $error[] = $this->language->lang('TABLE_PREFIX_SAME', $src_table_prefix); } if (!$connect_test) { $error[] = $this->language->lang('INST_ERR_DB_CONNECT'); } $src_dbms = $this->config_php_file->convert_30_dbms_to_31($src_dbms); // Check table prefix if (empty($error)) { // initiate database connection to old db if old and new db differ global $src_db, $same_db; $src_db = $same_db = false; if ($src_dbms != $dbms || $src_dbhost != $dbhost || $src_dbport != $dbport || $src_dbname != $dbname || $src_dbuser != $dbuser) { /** @var \phpbb\db\driver\driver_interface $src_db */ $src_db = new $src_dbms(); $src_db->sql_connect($src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd), $src_dbname, $src_dbport, false, true); $same_db = false; } else { $src_db = $this->db; $same_db = true; } $src_db->sql_return_on_error(true); $this->db->sql_return_on_error(true); // Try to select one row from the first table to see if the prefix is OK $result = $src_db->sql_query_limit('SELECT * FROM ' . $src_table_prefix . $tables[0], 1); if (!$result) { $prefixes = array(); $db_tools_factory = new \phpbb\db\tools\factory(); $db_tools = $db_tools_factory->get($src_db); $tables_existing = $db_tools->sql_list_tables(); $tables_existing = array_map('strtolower', $tables_existing); foreach ($tables_existing as $table_name) { compare_table($tables, $table_name, $prefixes); } unset($tables_existing); foreach ($prefixes as $prefix => $count) { if ($count >= sizeof($tables)) { $possible_prefix = $prefix; break; } } $msg = ''; if (!empty($convertor_data['table_prefix'])) { $msg .= $this->language->lang_array('DEFAULT_PREFIX_IS', array($convertor_data['forum_name'], $convertor_data['table_prefix'])); } if (!empty($possible_prefix)) { $msg .= '<br />'; $msg .= $possible_prefix == '*' ? $this->language->lang('BLANK_PREFIX_FOUND') : $this->language->lang_array('PREFIX_FOUND', array($possible_prefix)); $src_table_prefix = $possible_prefix == '*' ? '' : $possible_prefix; } $error[] = $msg; } $src_db->sql_freeresult($result); $src_db->sql_return_on_error(false); } if (empty($error)) { // Save convertor Status $this->config->set('convert_progress', serialize(array('step' => '', 'table_prefix' => $src_table_prefix, 'tag' => $convertor)), false); $this->config->set('convert_db_server', serialize(array('dbms' => $src_dbms, 'dbhost' => $src_dbhost, 'dbport' => $src_dbport, 'dbname' => $src_dbname)), false); $this->config->set('convert_db_user', serialize(array('dbuser' => $src_dbuser, 'dbpasswd' => $src_dbpasswd)), false); // Save options $this->config->set('convert_options', serialize(array('forum_path' => $this->phpbb_root_path . $forum_path, 'refresh' => $refresh)), false); $url = $this->controller_helper->route('phpbb_convert_convert', array('converter' => $convertor)); $this->iohandler->redirect($url); $this->iohandler->send_response(true); } else { $this->render_settings_form($error); } }
/** * {@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', []); $version_from = !empty($update_info) ? $update_info['version']['from'] : $this->config['version_update_from']; if (!empty($version_from)) { $update_extensions = $this->iohandler->get_input('update-extensions', []); // Create list of default extensions that need to be enabled in update $default_update_extensions = []; foreach (self::$default_extensions_update as $version => $extensions) { if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) { $default_update_extensions = array_merge($default_update_extensions, $extensions); } } $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) { // 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_enabled($ext_name) || in_array($ext_name, $update_extensions) || in_array($ext_name, $default_update_extensions)) { try { $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_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_UPDATE_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); } } catch (\Exception $e) { // Add fail log and continue $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_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(); } } $this->config->delete('version_update_from'); $this->cache->purge(); $this->config->increment('assets_version', 1); }