send_response() public method

Renders or returns response message
public send_response ( boolean $no_more_output = false )
$no_more_output boolean Whether or not there will be more output in this output unit
 /**
  * {@inheritdoc}
  */
 public function write($message, $verbosity)
 {
     if ($verbosity <= migrator_output_handler_interface::VERBOSITY_VERBOSE) {
         $this->iohandler->add_log_message($message);
         $this->iohandler->send_response();
     }
 }
Exemplo n.º 2
0
 /**
  * {@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_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_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', 'description' => 'SMTP_SERVER_EXPLAIN', 'type' => 'text', 'default' => $smtp_host), 'smtp_auth' => array('label' => 'SMTP_AUTH_METHOD', '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);
         $this->io_handler->send_response();
         throw new user_interaction_required_exception();
     }
 }
Exemplo n.º 3
0
 /**
  * {@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')));
         $this->iohandler->send_response();
         throw new user_interaction_required_exception();
     }
 }
Exemplo n.º 4
0
 /**
  * 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', '');
         $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
     $this->io_handler->send_response();
     throw new user_interaction_required_exception();
 }
Exemplo n.º 5
0
 /**
  * {@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);
     }
 }
Exemplo n.º 6
0
 /**
  * {@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')));
         $this->iohandler->send_response();
         throw new user_interaction_required_exception();
     }
 }
Exemplo n.º 7
0
 /**
  * {@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')));
             $this->iohandler->send_response();
             throw new user_interaction_required_exception();
         }
     }
 }
Exemplo n.º 8
0
 /**
  * {@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')));
         $this->iohandler->send_response();
         throw new user_interaction_required_exception();
     }
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Recover install progress
     $task_name = $this->recover_progress();
     $task_found = false;
     /**
      * @var string							$name	ID of the service
      * @var \phpbb\install\task_interface	$task	Task object
      */
     foreach ($this->task_collection as $name => $task) {
         // Run until there are available resources
         if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
             throw new resource_limit_reached_exception();
         }
         // Skip forward until the next task is reached
         if (!$task_found) {
             if ($name === $task_name || empty($task_name)) {
                 $task_found = true;
                 if ($name === $task_name) {
                     continue;
                 }
             } else {
                 continue;
             }
         }
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         // Check if we can run the task
         if (!$task->is_essential() && !$task->check_requirements()) {
             $this->iohandler->add_log_message(array('SKIP_TASK', $name));
             $this->install_config->increment_current_task_progress($this->task_step_count[$name]);
             continue;
         }
         if ($this->allow_progress_bar) {
             // Only increment progress by one, as if a task has more than one steps
             // then that should be incremented in the task itself
             $this->install_config->increment_current_task_progress();
         }
         $task->run();
         // Log install progress
         $this->install_config->set_finished_task($name);
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         $this->iohandler->send_response();
     }
     // Module finished, so clear task progress
     $this->install_config->set_finished_task('');
 }
Exemplo n.º 10
0
 /**
  * {@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();
     }
 }
Exemplo n.º 11
0
 /**
  * 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
     $this->io_handler->send_response();
     throw new user_interaction_required_exception();
 }
Exemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Recover install progress
     $task_index = $this->recover_progress();
     $iterator = $this->task_collection->getIterator();
     if ($task_index < $iterator->count()) {
         $iterator->seek($task_index);
     } else {
         $this->install_config->set_finished_task(0);
         return;
     }
     while ($iterator->valid()) {
         $task = $iterator->current();
         $name = $iterator->key();
         // Check if we can run the task
         if (!$task->is_essential() && !$task->check_requirements()) {
             $this->iohandler->add_log_message(array('SKIP_TASK', $name));
             $this->install_config->increment_current_task_progress($this->task_step_count[$name]);
         } else {
             // Send progress information
             if ($this->allow_progress_bar) {
                 $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
                 $this->iohandler->send_response();
             }
             $task->run();
             if ($this->allow_progress_bar) {
                 // Only increment progress by one, as if a task has more than one steps
                 // then that should be incremented in the task itself
                 $this->install_config->increment_current_task_progress();
             }
         }
         $task_index++;
         $this->install_config->set_finished_task($task_index);
         $iterator->next();
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         $this->iohandler->send_response();
         // Stop execution if resource limit is reached
         if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
             throw new resource_limit_reached_exception();
         }
     }
     // Module finished, so clear task progress
     $this->install_config->set_finished_task(0);
 }
Exemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $config_written = true;
     // Create config.php
     $path_to_config = $this->phpbb_root_path . 'config.' . $this->php_ext;
     $fp = @fopen($path_to_config, 'w');
     if (!$fp) {
         $config_written = false;
     }
     $config_content = $this->get_config_data();
     if (!@fwrite($fp, $config_content)) {
         $config_written = false;
     }
     @fclose($fp);
     // chmod config.php to be only readable
     if ($config_written) {
         try {
             $this->filesystem->phpbb_chmod($path_to_config, \phpbb\filesystem\filesystem_interface::CHMOD_READ);
         } catch (\phpbb\filesystem\exception\filesystem_exception $e) {
             // Do nothing, the user will get a notice later
         }
     } else {
         $this->iohandler->add_error_message('UNABLE_TO_WRITE_CONFIG_FILE');
         $this->iohandler->send_response();
         throw new user_interaction_required_exception();
     }
     // Create a lock file to indicate that there is an install in progress
     $fp = @fopen($this->phpbb_root_path . 'cache/install_lock', 'wb');
     if ($fp === false) {
         // We were unable to create the lock file - abort
         $this->iohandler->add_error_message('UNABLE_TO_WRITE_LOCK');
         $this->iohandler->send_response();
         throw new user_interaction_required_exception();
     }
     @fclose($fp);
     try {
         $this->filesystem->phpbb_chmod($this->phpbb_root_path . 'cache/install_lock', 0777);
     } catch (\phpbb\filesystem\exception\filesystem_exception $e) {
         // Do nothing, the user will get a notice later
     }
 }
Exemplo n.º 14
0
 /**
  * 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);
     $this->io_handler->send_response();
     throw new user_interaction_required_exception();
 }
Exemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->language->add_lang('migrator');
     if (!isset($this->config['version_update_from'])) {
         $this->config->set('version_update_from', $this->config['version']);
     }
     $original_version = $this->config['version_update_from'];
     $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new installer_migrator_output_handler($this->iohandler), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
     $this->migrator->create_migrations_table();
     $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes();
     $this->migrator->set_migrations($migrations);
     $migration_count = count($this->migrator->get_migrations());
     $this->iohandler->set_task_count($migration_count, true);
     $progress_count = $this->installer_config->get('database_update_count', 0);
     while (!$this->migrator->finished()) {
         try {
             $this->migrator->update();
             $progress_count++;
             $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
         } catch (exception $e) {
             $msg = $e->getParameters();
             array_unshift($msg, $e->getMessage());
             $this->iohandler->add_error_message($msg);
             $this->iohandler->send_response();
             throw new user_interaction_required_exception();
         }
         if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) {
             $this->installer_config->set('database_update_count', $progress_count);
             throw new resource_limit_reached_exception();
         }
     }
     if ($original_version !== $this->config['version']) {
         $this->log->add('admin', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, array($original_version, $this->config['version']));
     }
     $this->iohandler->finish_progress('INLINE_UPDATE_SUCCESSFUL');
     $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL');
     $this->config->delete('version_update_from');
     $this->cache->purge();
     $this->config->increment('assets_version', 1);
 }
Exemplo n.º 16
0
 /**
  * Redirects an AJAX request to a non-JS version
  *
  * @param string	$url	URL to redirect to
  */
 public function redirect_to_html($url)
 {
     $this->iohandler->redirect($url);
     $this->iohandler->send_response(true);
 }
Exemplo n.º 17
0
 /**
  * Run phpBB installer
  */
 public function run()
 {
     // Load install progress
     $this->install_config->load_config();
     // Recover install progress
     $module_name = $this->recover_progress();
     $module_found = false;
     // Variable used to check if the install process have been finished
     $install_finished = false;
     $fail_cleanup = false;
     $send_refresh = false;
     // We are installing something, so the introduction stage can go now...
     $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction'));
     $this->iohandler->set_finished_stage_menu(array('install', 0, 'introduction'));
     if ($this->install_config->get_task_progress_count() === 0) {
         // Count all tasks in the current installer modules
         $step_count = 0;
         /** @var \phpbb\install\module_interface $module */
         foreach ($this->installer_modules as $name => $module) {
             $module_step_count = $module->get_step_count();
             $step_count += $module_step_count;
             $this->module_step_count[$name] = $module_step_count;
         }
         // Set task count
         $this->install_config->set_task_progress_count($step_count);
     }
     // Set up progress information
     $this->iohandler->set_task_count($this->install_config->get_task_progress_count());
     try {
         foreach ($this->installer_modules as $name => $module) {
             // Skip forward until the current task is reached
             if (!$module_found) {
                 if ($module_name === $name || empty($module_name)) {
                     $module_found = true;
                 } else {
                     continue;
                 }
             }
             // Log progress
             $this->install_config->set_active_module($name);
             // Run until there are available resources
             if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
                 throw new resource_limit_reached_exception();
             }
             // Check if module should be executed
             if (!$module->is_essential() && !$module->check_requirements()) {
                 $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
                 $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
                 $this->iohandler->add_log_message(array('SKIP_MODULE', $name));
                 $this->install_config->increment_current_task_progress($this->module_step_count[$name]);
                 continue;
             }
             // Set the correct stage in the navigation bar
             $this->install_config->set_active_navigation_stage($module->get_navigation_stage_path());
             $this->iohandler->set_active_stage_menu($module->get_navigation_stage_path());
             $module->run();
             $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
             $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
         }
         // Installation finished
         $install_finished = true;
         if ($this->iohandler instanceof cli_iohandler) {
             $this->iohandler->add_success_message('INSTALLER_FINISHED');
         } else {
             global $SID;
             $acp_url = $this->web_root . 'adm/index.php' . $SID;
             $this->iohandler->add_success_message('INSTALLER_FINISHED', array('ACP_LINK', $acp_url));
         }
     } catch (user_interaction_required_exception $e) {
         // Do nothing
     } catch (resource_limit_reached_exception $e) {
         $send_refresh = true;
     } catch (jump_to_restart_point_exception $e) {
         $this->install_config->jump_to_restart_point($e->get_restart_point_name());
         $send_refresh = true;
     } catch (\Exception $e) {
         $this->iohandler->add_error_message($e->getMessage());
         $this->iohandler->send_response();
         $fail_cleanup = true;
     }
     if ($install_finished) {
         // Send install finished message
         $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count());
     } else {
         if ($send_refresh) {
             $this->iohandler->request_refresh();
             $this->iohandler->send_response();
         }
     }
     // Save install progress
     try {
         if ($install_finished || $fail_cleanup) {
             $this->install_config->clean_up_config_file();
         } else {
             $this->install_config->save_config();
         }
     } catch (installer_config_not_writable_exception $e) {
         // It is allowed to fail this test during requirements testing
         $progress_data = $this->install_config->get_progress_data();
         if ($progress_data['last_task_module_name'] !== 'installer.module.requirements_install') {
             $this->iohandler->add_error_message('INSTALLER_CONFIG_NOT_WRITABLE');
         }
     }
 }
Exemplo n.º 18
0
 /**
  * Run phpBB installer
  */
 public function run()
 {
     if ($this->iohandler instanceof ajax_iohandler) {
         $this->iohandler->acquire_lock();
     }
     // Load install progress
     $this->install_config->load_config();
     if (!$this->install_config->get('cache_purged_before', false) && $this->purge_cache_before) {
         /** @var \phpbb\cache\driver\driver_interface $cache */
         $cache = $this->container_factory->get('cache.driver');
         $cache->purge();
         $this->install_config->set('cache_purged_before', true);
     }
     // Recover install progress
     $module_index = $this->recover_progress();
     // Variable used to check if the install process have been finished
     $install_finished = false;
     $fail_cleanup = false;
     $send_refresh = false;
     // We are installing something, so the introduction stage can go now...
     $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction'));
     $this->iohandler->set_finished_stage_menu(array('install', 0, 'introduction'));
     if ($this->install_config->get_task_progress_count() === 0) {
         // Count all tasks in the current installer modules
         $step_count = 0;
         /** @var \phpbb\install\module_interface $module */
         foreach ($this->installer_modules as $name => $module) {
             $module_step_count = $module->get_step_count();
             $step_count += $module_step_count;
             $this->module_step_count[$name] = $module_step_count;
         }
         // Set task count
         $this->install_config->set_task_progress_count($step_count);
     }
     // Set up progress information
     $this->iohandler->set_task_count($this->install_config->get_task_progress_count());
     try {
         $iterator = $this->installer_modules->getIterator();
         if ($module_index < $iterator->count()) {
             $iterator->seek($module_index);
         } else {
             $iterator->seek($module_index - 1);
             $iterator->next();
         }
         while ($iterator->valid()) {
             $module = $iterator->current();
             $name = $iterator->key();
             // Check if module should be executed
             if (!$module->is_essential() && !$module->check_requirements()) {
                 $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
                 $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
                 $this->iohandler->add_log_message(array('SKIP_MODULE', $name));
                 $this->install_config->increment_current_task_progress($this->module_step_count[$name]);
             } else {
                 // Set the correct stage in the navigation bar
                 $this->install_config->set_active_navigation_stage($module->get_navigation_stage_path());
                 $this->iohandler->set_active_stage_menu($module->get_navigation_stage_path());
                 $this->iohandler->send_response();
                 $module->run();
                 $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
                 $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
             }
             $module_index++;
             $iterator->next();
             // Save progress
             $this->install_config->set_active_module($name, $module_index);
             if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)) {
                 throw new resource_limit_reached_exception();
             }
         }
         // Installation finished
         $install_finished = true;
         if ($this->iohandler instanceof cli_iohandler) {
             $this->iohandler->add_success_message('INSTALLER_FINISHED');
         } else {
             global $SID;
             $acp_url = $this->web_root . 'adm/index.php' . $SID;
             $this->iohandler->add_success_message('INSTALLER_FINISHED', array('ACP_LINK', $acp_url));
         }
     } catch (user_interaction_required_exception $e) {
         $this->iohandler->send_response(true);
     } catch (resource_limit_reached_exception $e) {
         $send_refresh = true;
     } catch (jump_to_restart_point_exception $e) {
         $this->install_config->jump_to_restart_point($e->get_restart_point_name());
         $send_refresh = true;
     } catch (\Exception $e) {
         $this->iohandler->add_error_message($e->getMessage());
         $this->iohandler->send_response(true);
         $fail_cleanup = true;
     }
     if ($this->iohandler instanceof ajax_iohandler) {
         $this->iohandler->release_lock();
     }
     if ($install_finished) {
         // Send install finished message
         $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count());
         $this->iohandler->send_response(true);
     } else {
         if ($send_refresh) {
             $this->iohandler->request_refresh();
             $this->iohandler->send_response(true);
         }
     }
     // Save install progress
     try {
         if ($install_finished || $fail_cleanup) {
             $this->install_config->clean_up_config_file();
             $this->cache->purge();
             try {
                 /** @var \phpbb\cache\driver\driver_interface $cache */
                 $cache = $this->container_factory->get('cache.driver');
                 $cache->purge();
             } catch (cannot_build_container_exception $e) {
                 // Do not do anything, this just means there is no config.php yet
             }
         } else {
             $this->install_config->save_config();
         }
     } catch (installer_config_not_writable_exception $e) {
         // It is allowed to fail this test during requirements testing
         $progress_data = $this->install_config->get_progress_data();
         if ($progress_data['last_task_module_name'] !== 'installer.module.requirements_install') {
             $this->iohandler->add_error_message('INSTALLER_CONFIG_NOT_WRITABLE');
         }
     }
 }