Returns input variable
public get_input ( string $name, mixed $default, boolean $multibyte = false ) : mixed | ||
$name | string | Name of the input variable to obtain |
$default | mixed | A default value that is returned if the variable was not set. This function will always return a value of the same type as the default. |
$multibyte | boolean | If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks |
return | mixed | Value of the input variable |
/** * {@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() { // 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(); } }
/** * 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(); }
/** * {@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(); } }
/** * {@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(); } }
/** * 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_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(); } }
/** * {@inheritdoc} */ public function run() { $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); $install_extensions = $this->iohandler->get_input('install-extensions', array()); $all_available_extensions = $this->extension_manager->all_available(); $i = $this->install_config->get('install_extensions_index', 0); $available_extensions = array_slice($all_available_extensions, $i); // Install extensions foreach ($available_extensions as $ext_name => $ext_path) { if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions)) { continue; } try { $this->extension_manager->enable($ext_name); $extensions = $this->get_extensions(); if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name)); } else { $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } } catch (\Exception $e) { // Add fail log and continue $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } $i++; // Stop execution if resource limit is reached if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { break; } } $this->install_config->set('install_extensions_index', $i); if ($i < sizeof($all_available_extensions)) { throw new resource_limit_reached_exception(); } }
/** * 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(); }
/** * {@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); }