Adds a requested data group to the rendering queue
public add_user_form_group ( string $title, array $form ) | ||
$title | string | Language variable with the title of the form |
$form | array | An array describing the required data (options etc) |
/** * {@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(); } }
/** * {@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() { 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(); } }
/** * 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', '', true); $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 throw new user_interaction_required_exception(); }
/** * {@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() { // 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(); } }
/** * {@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() { $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(); } }
/** * 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 throw new user_interaction_required_exception(); }
/** * Renders settings form * * @param array $error Array of errors */ public function render_settings_form($error = array()) { foreach ($error as $msg) { $this->iohandler->add_error_message($msg); } $dbms_options = array(); foreach ($this->db_helper->get_available_dbms() as $dbms_key => $dbms_array) { $dbms_options[] = array('value' => $dbms_key, 'label' => 'DB_OPTION_' . strtoupper($dbms_key)); } $form_title = 'SPECIFY_OPTIONS'; $form_data = array('src_dbms' => array('label' => 'DBMS', 'type' => 'select', 'options' => $dbms_options), 'src_dbhost' => array('label' => 'DB_HOST', 'description' => 'DB_HOST_EXPLAIN', 'type' => 'text'), 'src_dbport' => array('label' => 'DB_PORT', 'description' => 'DB_PORT_EXPLAIN', 'type' => 'text'), 'src_dbname' => array('label' => 'DB_NAME', 'type' => 'text'), 'src_dbuser' => array('label' => 'DB_USERNAME', 'type' => 'text'), 'src_dbpasswd' => array('label' => 'DB_PASSWORD', 'type' => 'password'), 'src_table_prefix' => array('label' => 'TABLE_PREFIX', 'description' => 'TABLE_PREFIX_EXPLAIN', 'type' => 'text'), 'forum_path' => array('label' => 'FORUM_PATH', 'description' => 'FORUM_PATH_EXPLAIN', 'type' => 'text'), 'refresh' => array('label' => 'REFRESH_PAGE', 'description' => 'REFRESH_PAGE_EXPLAIN', 'type' => 'radio', 'options' => array(array('value' => 0, 'label' => 'NO', 'selected' => true), array('value' => 1, 'label' => 'YES', 'selected' => false))), 'submit' => array('label' => 'SUBMIT', 'type' => 'submit')); if ($this->request->is_ajax()) { $this->iohandler->add_user_form_group($form_title, $form_data); $this->iohandler->send_response(true); } else { $rendered_form = $this->iohandler->generate_form_render_data($form_title, $form_data); $this->template->assign_vars(array('TITLE' => $this->language->lang('STAGE_SETTINGS'), 'CONTENT' => $rendered_form)); } }
/** * 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(); }