/** * Executes the command cache:purge. * * Purge the cache (including permissions) and increment the asset_version number * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null */ protected function execute(InputInterface $input, OutputInterface $output) { $this->config->increment('assets_version', 1); $this->cache->purge(); // Clear permissions $this->auth->acl_clear_prefetch(); phpbb_cache_moderators($this->db, $this->cache, $this->auth); $this->log->add('admin', ANONYMOUS, '', 'LOG_PURGE_CACHE', time(), array()); $output->writeln($this->user->lang('PURGE_CACHE_SUCCESS')); }
/** * Render the final page of the convertor */ public function finish() { $this->setup_navigation('finish'); $this->template->assign_vars(array('TITLE' => $this->language->lang('CONVERT_COMPLETE'), 'BODY' => $this->language->lang('CONVERT_COMPLETE_EXPLAIN'))); // If we reached this step (conversion completed) we want to purge the cache and log the user out. // This is for making sure the session get not screwed due to the 3.0.x users table being completely new. $this->cache->purge(); $this->installer_cache->purge(); require_once $this->phpbb_root_path . 'includes/constants.' . $this->php_ext; require_once $this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext; $sql = 'SELECT config_value FROM ' . $this->config_table . ' WHERE config_name = \'search_type\''; $result = $this->db->sql_query($sql); if ($this->db->sql_fetchfield('config_value') != 'fulltext_mysql') { $this->template->assign_vars(array('S_ERROR_BOX' => true, 'ERROR_TITLE' => $this->language->lang('SEARCH_INDEX_UNCONVERTED'), 'ERROR_MSG' => $this->language->lang('SEARCH_INDEX_UNCONVERTED_EXPLAIN'))); } $this->db->sql_freeresult($result); switch ($this->db->get_sql_layer()) { case 'sqlite': case 'sqlite3': $this->db->sql_query('DELETE FROM ' . $this->session_keys_table); $this->db->sql_query('DELETE FROM ' . $this->session_table); break; default: $this->db->sql_query('TRUNCATE TABLE ' . $this->session_keys_table); $this->db->sql_query('TRUNCATE TABLE ' . $this->session_table); break; } return $this->controller_helper->render('installer_convert.html', 'CONVERT_COMPLETE'); }
/** * Perform table SQL query and return any messages * * @param string $query should either be OPTIMIZE TABLE, REPAIR TABLE, or CHECK TABLE * @param string $tables comma delineated string of all tables to be processed * @param int $disable_board the users option to disable the board during run time * @return string $message any errors or status information * @access protected */ protected function table_maintenance($query, $tables, $disable_board = 0) { // Disable the board if admin selected this option if ($disable_board) { $this->config->set('board_disable', 1); } $message = ''; $result = $this->db->sql_query($query . ' ' . $this->db->sql_escape($tables)); while ($row = $this->db->sql_fetchrow($result)) { // Build a message only for optimize/repair errors, or if check table is run if (in_array(strtolower($row['Msg_type']), array('error', 'info', 'note', 'warning')) || $query == 'CHECK TABLE') { $message .= '<br />' . substr($row['Table'], strpos($row['Table'], '.') + 1) . ' ... ' . $row['Msg_type'] . ': ' . $row['Msg_text']; } } $this->db->sql_freeresult($result); // Enable the board again if admin selected this option if ($disable_board) { $this->config->set('board_disable', 0); } // Clear cache to ensure board is re-enabled for all users $this->cache->purge(); // Let's add an extra line break if there are messages, it looks better $message = !empty($message) ? '<br />' . $message : ''; return $message; }
/** * {@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_step_count = $this->installer_config->get('database_update_migration_steps', -1); if ($migration_step_count < 0) { $migration_step_count = count($this->migrator->get_installable_migrations()) * 2; $this->installer_config->set('database_update_migration_steps', $migration_step_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()) { 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']) { // 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']) { // 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) { $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); $this->installer_config->set('database_update_migration_steps', $migration_step_count); throw new resource_limit_reached_exception(); } } if ($original_version !== $this->config['version']) { $this->log->add('admin', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, array($original_version, $this->config['version'])); } $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); $this->config->delete('version_update_from'); $this->cache->purge(); $this->config->increment('assets_version', 1); }
/** * {@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($this->migrator->get_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); $this->iohandler->send_response(); 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', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $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); }
/** * Run phpBB installer */ public function run() { if ($this->iohandler instanceof ajax_iohandler) { $this->iohandler->acquire_lock(); } // 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_index = $this->recover_progress(); // 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')); $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 { $iterator = $this->installer_modules->getIterator(); if ($module_index < $iterator->count()) { $iterator->seek($module_index); } else { $iterator->seek($module_index - 1); $iterator->next(); } while ($iterator->valid()) { $module = $iterator->current(); $name = $iterator->key(); // 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', $name)); $this->install_config->increment_current_task_progress($this->module_step_count[$name]); } 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()); } $module_index++; $iterator->next(); // Save progress $this->install_config->set_active_module($name, $module_index); 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 $install_finished = true; if ($this->iohandler instanceof cli_iohandler) { $this->iohandler->add_success_message('INSTALLER_FINISHED'); } else { global $SID; $acp_url = $this->web_root . 'adm/index.php' . $SID; $this->iohandler->add_success_message('INSTALLER_FINISHED', array('ACP_LINK', $acp_url)); } } catch (user_interaction_required_exception $e) { $this->iohandler->send_response(true); } catch (resource_limit_reached_exception $e) { $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) { $this->iohandler->add_error_message($e->getMessage()); $this->iohandler->send_response(true); $fail_cleanup = true; } if ($this->iohandler instanceof ajax_iohandler) { $this->iohandler->release_lock(); } if ($install_finished) { // 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(true); } } // Save install progress try { if ($install_finished || $fail_cleanup) { $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 just means there is no config.php yet } } else { $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'); } } }
/** * Show style details */ protected function action_details() { global $user, $phpbb_log; $id = $this->request->variable('id', 0); if (!$id) { trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } // Get all styles $styles = $this->get_styles(); usort($styles, array($this, 'sort_styles')); // Find current style $style = false; foreach ($styles as $row) { if ($row['style_id'] == $id) { $style = $row; break; } } if ($style === false) { trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } // Find all available parent styles $list = $this->find_possible_parents($styles, $id); // Add form key $form_key = 'acp_styles'; add_form_key($form_key); // Change data if ($this->request->variable('update', false)) { if (!check_form_key($form_key)) { trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } $update = array('style_name' => trim($this->request->variable('style_name', $style['style_name'])), 'style_parent_id' => $this->request->variable('style_parent', (int) $style['style_parent_id']), 'style_active' => $this->request->variable('style_active', (int) $style['style_active'])); $update_action = $this->u_action . '&action=details&id=' . $id; // Check style name if ($update['style_name'] != $style['style_name']) { if (!strlen($update['style_name'])) { trigger_error($this->user->lang['STYLE_ERR_STYLE_NAME'] . adm_back_link($update_action), E_USER_WARNING); } foreach ($styles as $row) { if ($row['style_name'] == $update['style_name']) { trigger_error($this->user->lang['STYLE_ERR_NAME_EXIST'] . adm_back_link($update_action), E_USER_WARNING); } } } else { unset($update['style_name']); } // Check parent style id if ($update['style_parent_id'] != $style['style_parent_id']) { if ($update['style_parent_id'] != 0) { $found = false; foreach ($list as $row) { if ($row['style_id'] == $update['style_parent_id']) { $found = true; $update['style_parent_tree'] = ($row['style_parent_tree'] != '' ? $row['style_parent_tree'] . '/' : '') . $row['style_path']; break; } } if (!$found) { trigger_error($this->user->lang['STYLE_ERR_INVALID_PARENT'] . adm_back_link($update_action), E_USER_WARNING); } } else { $update['style_parent_tree'] = ''; } } else { unset($update['style_parent_id']); } // Check style_active if ($update['style_active'] != $style['style_active']) { if (!$update['style_active'] && $this->default_style == $style['style_id']) { trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($update_action), E_USER_WARNING); } } else { unset($update['style_active']); } // Update data if (count($update)) { $sql = 'UPDATE ' . STYLES_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $update) . "\n\t\t\t\t\tWHERE style_id = {$id}"; $this->db->sql_query($sql); $style = array_merge($style, $update); if (isset($update['style_parent_id'])) { // Update styles tree $styles = $this->get_styles(); if ($this->update_styles_tree($styles, $style)) { // Something was changed in styles tree, purge all cache $this->cache->purge(); } } $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_STYLE_EDIT_DETAILS', false, array($style['style_name'])); } // Update default style $default = $this->request->variable('style_default', 0); if ($default) { if (!$style['style_active']) { trigger_error($this->user->lang['STYLE_DEFAULT_CHANGE_INACTIVE'] . adm_back_link($update_action), E_USER_WARNING); } $this->config->set('default_style', $id); $this->cache->purge(); } // Show styles list $this->frontend(); return; } // Show page title $this->welcome_message('ACP_STYLES', null); // Show parent styles foreach ($list as $row) { $this->template->assign_block_vars('parent_styles', array('STYLE_ID' => $row['style_id'], 'STYLE_NAME' => htmlspecialchars($row['style_name']), 'LEVEL' => $row['level'], 'SPACER' => str_repeat(' ', $row['level']))); } // Show style details $this->template->assign_vars(array('S_STYLE_DETAILS' => true, 'STYLE_ID' => $style['style_id'], 'STYLE_NAME' => htmlspecialchars($style['style_name']), 'STYLE_PATH' => htmlspecialchars($style['style_path']), 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), 'STYLE_PARENT' => $style['style_parent_id'], 'S_STYLE_ACTIVE' => $style['style_active'], 'S_STYLE_DEFAULT' => $style['style_id'] == $this->default_style)); }
/** * Run phpBB installer */ public function run() { // Load install progress $this->install_config->load_config(); // Recover install progress $module_name = $this->recover_progress(); $module_found = false; // 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')); $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 { 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; } } // 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(); } // 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', $name)); $this->install_config->increment_current_task_progress($this->module_step_count[$name]); 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()); } // Installation finished $install_finished = true; if ($this->iohandler instanceof cli_iohandler) { $this->iohandler->add_success_message('INSTALLER_FINISHED'); } else { global $SID; $acp_url = $this->web_root . 'adm/index.php' . $SID; $this->iohandler->add_success_message('INSTALLER_FINISHED', array('ACP_LINK', $acp_url)); } } catch (user_interaction_required_exception $e) { // Do nothing } catch (resource_limit_reached_exception $e) { $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) { $this->iohandler->add_error_message($e->getMessage()); $this->iohandler->send_response(); $fail_cleanup = true; } if ($install_finished) { // Send install finished message $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count()); } else { if ($send_refresh) { $this->iohandler->request_refresh(); $this->iohandler->send_response(); } } // Save install progress try { if ($install_finished || $fail_cleanup) { $this->install_config->clean_up_config_file(); $this->cache->purge(); } else { $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'); } } }
/** * {@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); }