/** * {@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, base64_decode($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} */ 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} */ 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($this->phpbb_root_path . 'install/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']); $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)) { $error = $this->db->sql_error($this->db->get_sql_error_sql()); $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); } $i++; // Stop execution if resource limit is reached 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(); } }
/** * Sends response with the updated files' archive * * @return BinaryFileResponse */ public function update_archive() { $filename = $this->installer_config->get('update_file_archive', ''); if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } return $this->send_response($filename); }
/** * {@inheritdoc} */ 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->core_path('phpbb/db/migration/data/')->get_classes(); $this->migrator->populate_migrations($migrations); }
/** * {@inheritdoc} */ public function run() { $cookie_secure = $this->io_handler->is_secure(); $server_protocol = $this->io_handler->is_secure() ? 'https://' : 'http://'; $server_port = $this->io_handler->get_server_variable('SERVER_PORT', 0); // HTTP_HOST is having the correct browser url in most cases... $server_name = strtolower(htmlspecialchars_decode($this->io_handler->get_header_variable('Host', $this->io_handler->get_server_variable('SERVER_NAME')))); // HTTP HOST can carry a port number... if (strpos($server_name, ':') !== false) { $server_name = substr($server_name, 0, strpos($server_name, ':')); } $script_path = htmlspecialchars_decode($this->io_handler->get_server_variable('PHP_SELF')); if (!$script_path) { $script_path = htmlspecialchars_decode($this->io_handler->get_server_variable('REQUEST_URI')); } $script_path = str_replace(array('\\', '//'), '/', $script_path); $script_path = trim(dirname(dirname(dirname($script_path)))); // Because we are in install/app.php/route_name // Server data $cookie_secure = $this->io_handler->get_input('cookie_secure', $cookie_secure); $server_protocol = $this->io_handler->get_input('server_protocol', $server_protocol); $force_server_vars = $this->io_handler->get_input('force_server_vars', 0); $server_name = $this->io_handler->get_input('server_name', $server_name); $server_port = $this->io_handler->get_input('server_port', $server_port); $script_path = $this->io_handler->get_input('script_path', $script_path); // Clean up script path if ($script_path !== '/') { // Adjust destination path (no trailing slash) if (substr($script_path, -1) === '/') { $script_path = substr($script_path, 0, -1); } $script_path = str_replace(array('../', './'), '', $script_path); if ($script_path[0] !== '/') { $script_path = '/' . $script_path; } } // Check if data is sent if ($this->io_handler->get_input('submit_server', false)) { $this->install_config->set('cookie_secure', $cookie_secure); $this->install_config->set('server_protocol', $server_protocol); $this->install_config->set('force_server_vars', $force_server_vars); $this->install_config->set('server_name', $server_name); $this->install_config->set('server_port', $server_port); $this->install_config->set('script_path', $script_path); } else { // Render form $server_form = array('cookie_secure' => array('label' => 'COOKIE_SECURE', 'description' => 'COOKIE_SECURE_EXPLAIN', 'type' => 'radio', 'options' => array(array('value' => 0, 'label' => 'NO', 'selected' => !$cookie_secure), array('value' => 1, 'label' => 'YES', 'selected' => $cookie_secure))), 'force_server_vars' => array('label' => 'FORCE_SERVER_VARS', 'description' => 'FORCE_SERVER_VARS_EXPLAIN', 'type' => 'radio', 'options' => array(array('value' => 0, 'label' => 'NO', 'selected' => true), array('value' => 1, 'label' => 'YES', 'selected' => false))), 'server_protocol' => array('label' => 'SERVER_PROTOCOL', 'description' => 'SERVER_PROTOCOL_EXPLAIN', 'type' => 'text', 'default' => $server_protocol), 'server_name' => array('label' => 'SERVER_NAME', 'description' => 'SERVER_NAME_EXPLAIN', 'type' => 'text', 'default' => $server_name), 'server_port' => array('label' => 'SERVER_PORT', 'description' => 'SERVER_PORT_EXPLAIN', 'type' => 'text', 'default' => $server_port), 'script_path' => array('label' => 'SCRIPT_PATH', 'description' => 'SCRIPT_PATH_EXPLAIN', 'type' => 'text', 'default' => $script_path), 'submit_server' => array('label' => 'SUBMIT', 'type' => 'submit')); $this->io_handler->add_user_form_group('SERVER_CONFIG', $server_form); $this->io_handler->send_response(); throw new user_interaction_required_exception(); } }
/** * {@inheritdoc} */ 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_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', ''); $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_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); } 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', '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', '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); throw new user_interaction_required_exception(); } }
/** * Process form data */ protected function process_form() { // Collect database data $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_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); } }
/** * {@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'))); throw new user_interaction_required_exception(); } }
/** * 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', '', true); $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); } }
/** * {@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 { 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' => $options), 'submit_update' => array('label' => 'SUBMIT', 'type' => 'submit'))); throw new user_interaction_required_exception(); } }
/** * {@inheritdoc} */ public function run() { $this->db->sql_return_on_error(true); $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE 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); 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) { // 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} */ public function run() { $this->user->session_begin(); $this->user->setup('common'); 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')); $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); } // 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'); }
/** * 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 = "<?php\n"; $config_content .= "// phpBB 3.2.x auto-generated configuration file\n// Do not change anything in this file!\n"; $dbms = $this->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} */ 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() { 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'))); throw new user_interaction_required_exception(); } } }
/** * {@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'))); throw new user_interaction_required_exception(); } }
public function test_progress_tracking() { $this->config->set_finished_task('foo'); $this->config->set_active_module('bar'); $this->config->set_task_progress_count(10); $this->config->increment_current_task_progress(); $progress_data = $this->config->get_progress_data(); $this->assertEquals(1, $progress_data['current_task_progress']); $this->config->increment_current_task_progress(2); $this->assertEquals(array('last_task_module_name' => 'bar', 'last_task_name' => 'foo', 'max_task_progress' => 10, 'current_task_progress' => 3), $this->config->get_progress_data()); }
/** * {@inheritdoc} */ public function run() { $this->db->sql_return_on_error(true); $server_name = $this->install_config->get('server_name'); $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)\n\t\t\t\tVALUES ('board_startdate', '{$current_time}')", 'INSERT INTO ' . $this->config_table . " (config_name, config_value)\n\t\t\t\tVALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('img_imagick')) . "'\n\t\t\t\tWHERE config_name = 'img_imagick'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "'\n\t\t\t\tWHERE config_name = 'server_name'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('server_port')) . "'\n\t\t\t\tWHERE config_name = 'server_port'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "'\n\t\t\t\tWHERE config_name = 'board_email'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "'\n\t\t\t\tWHERE config_name = 'board_contact'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($cookie_domain) . "'\n\t\t\t\tWHERE config_name = 'cookie_domain'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "'\n\t\t\t\tWHERE config_name = 'default_dateformat'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('email_enable')) . "'\n\t\t\t\tWHERE config_name = 'email_enable'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_delivery')) . "'\n\t\t\t\tWHERE config_name = 'smtp_delivery'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_host')) . "'\n\t\t\t\tWHERE config_name = 'smtp_host'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_port')) . "'\n\t\t\t\tWHERE config_name = 'smtp_port'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_auth')) . "'\n\t\t\t\tWHERE config_name = 'smtp_auth_method'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_user')) . "'\n\t\t\t\tWHERE config_name = 'smtp_username'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_pass')) . "'\n\t\t\t\tWHERE config_name = 'smtp_password'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('cookie_secure')) . "'\n\t\t\t\tWHERE config_name = 'cookie_secure'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('force_server_vars')) . "'\n\t\t\t\tWHERE config_name = 'force_server_vars'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('script_path')) . "'\n\t\t\t\tWHERE config_name = 'script_path'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('server_protocol')) . "'\n\t\t\t\tWHERE config_name = 'server_protocol'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'\n\t\t\t\tWHERE config_name = 'newest_username'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . md5(mt_rand()) . "'\n\t\t\t\tWHERE config_name = 'avatar_salt'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . md5(mt_rand()) . "'\n\t\t\t\tWHERE config_name = 'plupload_salt'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('board_name')) . "'\n\t\t\t\tWHERE config_name = 'sitename'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('board_description')) . "'\n\t\t\t\tWHERE config_name = 'site_desc'", 'UPDATE ' . $this->user_table . "\n\t\t\t\tSET username = '******'admin_name')) . "',\n\t\t\t\t\tuser_password='******'admin_passwd')) . "',\n\t\t\t\t\tuser_ip = '" . $this->db->sql_escape($user_ip) . "',\n\t\t\t\t\tuser_lang = '" . $this->db->sql_escape($this->install_config->get('user_language', 'en')) . "',\n\t\t\t\t\tuser_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "',\n\t\t\t\t\tuser_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "',\n\t\t\t\t\tuser_email_hash = " . $this->db->sql_escape(phpbb_email_hash($this->install_config->get('board_email'))) . ",\n\t\t\t\t\tusername_clean = '" . $this->db->sql_escape(utf8_clean_string($this->install_config->get('admin_name'))) . "'\n\t\t\t\tWHERE username = '******'", 'UPDATE ' . $this->moderator_cache_table . "\n\t\t\t\tSET username = '******'admin_name')) . "'\n\t\t\t\tWHERE username = '******'", 'UPDATE ' . $this->forums_table . "\n\t\t\t\tSET forum_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'\n\t\t\t\tWHERE forum_last_poster_name = 'Admin'", 'UPDATE ' . $this->topics_table . "\n\t\t\t\tSET topic_first_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "',\n\t\t\t\ttopic_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'\n\t\t\t\tWHERE topic_first_poster_name = 'Admin'\n\t\t\t\t\tOR topic_last_poster_name = 'Admin'", 'UPDATE ' . $this->user_table . "\n\t\t\t\tSET user_regdate = {$current_time}", 'UPDATE ' . $this->posts_table . "\n\t\t\t\tSET post_time = {$current_time}, poster_ip = '" . $this->db->sql_escape($user_ip) . "'", 'UPDATE ' . $this->topics_table . "\n\t\t\t\tSET topic_time = {$current_time}, topic_last_post_time = {$current_time}", 'UPDATE ' . $this->forums_table . "\n\t\t\t\tSET forum_last_post_time = {$current_time}", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->db->sql_server_info(true)) . "'\n\t\t\t\tWHERE config_name = 'dbms_version'"); if (@extension_loaded('gd')) { $sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = 'core.captcha.plugins.gd'\n\t\t\t\tWHERE config_name = 'captcha_plugin'"; $sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '1'\n\t\t\t\tWHERE config_name = 'captcha_gd'"; } $ref = substr($referer, strpos($referer, '://') + 3); if (!(stripos($ref, $server_name) === 0)) { $sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '0'\n\t\t\t\tWHERE 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 . "\n\t\t\tSET config_value = '" . $this->db->sql_escape($cookie_name) . "'\n\t\t\tWHERE 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 . "\n\t\t\t\tSET config_value = '0'\n\t\t\t\tWHERE config_name = 'allow_avatar'"; $sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '0'\n\t\t\t\tWHERE 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)) { $error = $this->db->sql_error($this->db->get_sql_error_sql()); $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); } $i++; // Stop execution if resource limit is reached 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(); } }
/** * {@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} */ 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($this->phpbb_root_path . 'install/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']); } } }
/** * {@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); // Stop execution if resource limit is reached 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); } }
/** * Controller logic * * @return Response|StreamedResponse */ public function handle() { if ($this->install_helper->is_phpbb_installed()) { die('phpBB is 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(); }); // Try to bypass any server output buffers $response->headers->set('X-Accel-Buffering', 'no'); return $response; } else { // 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'), 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', true); } // @todo: implement no js controller logic } }
/** * {@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'] = array_diff($update_info['binary'], $update_info['deleted']); // 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); $this->installer_config->set('update_info', array()); }
public function test_progress_tracking() { $this->config->set_finished_task('foo'); $this->config->set_active_module('bar'); $this->config->set_task_progress_count(10); $this->config->increment_current_task_progress(); $progress_data = $this->config->get_progress_data(); $this->assertEquals(1, $progress_data['current_task_progress']); $this->config->increment_current_task_progress(2); // We only want to check these values $result = $this->config->get_progress_data(); $expected_result = array('last_task_module_name' => 'bar', 'last_task_name' => 'foo', 'max_task_progress' => 10, 'current_task_progress' => 3); foreach ($expected_result as $key => $value) { $this->assertEquals($value, $result[$key]); } }
/** * {@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_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... $this->installer_config->set('disable_filesystem_update', true); return true; } // 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} */ 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); }
/** * 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', '', true); $board_desc = $this->io_handler->get_input('board_description', '', true); } 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('user_language', 'en'); $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); throw new user_interaction_required_exception(); }
/** * 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)); } } }
/** * 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; }