/** * {@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('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(); } } }
/** * Delete attachment from filesystem * * @param string $filename Filename of attachment * @param string $mode Delete mode * @param bool $entry_removed Whether entry was removed. Defaults to false * @return bool True if file was removed, false if not */ public function unlink_attachment($filename, $mode = 'file', $entry_removed = false) { // Because of copying topics or modifications a physical filename could be assigned more than once. If so, do not remove the file itself. $sql = 'SELECT COUNT(attach_id) AS num_entries FROM ' . ATTACHMENTS_TABLE . "\n\t\tWHERE physical_filename = '" . $this->db->sql_escape(utf8_basename($filename)) . "'"; $result = $this->db->sql_query($sql); $num_entries = (int) $this->db->sql_fetchfield('num_entries'); $this->db->sql_freeresult($result); // Do not remove file if at least one additional entry with the same name exist. if ($entry_removed && $num_entries > 0 || !$entry_removed && $num_entries > 1) { return false; } $filename = $mode == 'thumbnail' ? 'thumb_' . utf8_basename($filename) : utf8_basename($filename); $filepath = $this->phpbb_root_path . $this->config['upload_path'] . '/' . $filename; try { if ($this->filesystem->exists($filepath)) { $this->filesystem->remove($this->phpbb_root_path . $this->config['upload_path'] . '/' . $filename); return true; } } catch (\phpbb\filesystem\exception\filesystem_exception $exception) { // Fail is covered by return statement below } return false; }
/** * {@inheritdoc} * * @throws file_updater_failure_exception When the file is not writable * @throws filesystem_exception When the filesystem class fails */ public function delete_file($path_to_file) { $this->filesystem->remove($this->phpbb_root_path . $path_to_file); }