From 4b5fab372ff69a809144dee3a0a7f90c219fe400 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 30 Jan 2008 16:14:39 +0000 Subject: merge with revision #r8350 git-svn-id: file:///svn/phpbb/trunk@8351 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index adbe03283b..d494007f3d 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -53,7 +53,7 @@ class install_update extends module { var $p_master; var $update_info; - + var $old_location; var $new_location; var $latest_version; @@ -764,7 +764,7 @@ class install_update extends module { continue; } - + $methods[] = $type; } @@ -1490,7 +1490,7 @@ class install_update extends module return; } - if (in_array($file, array_keys($this->update_info['custom']))) + if (isset($this->update_info['custom'][$file])) { foreach ($this->update_info['custom'][$file] as $_file) { -- cgit v1.2.1 From 2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 29 May 2008 12:25:56 +0000 Subject: ok... i hope i haven't messed too much with the code and everything is still working. Changes: - Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed. - A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added. git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 119 +++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 62 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index d494007f3d..8bad2f7560 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -20,9 +20,9 @@ if (!defined('IN_INSTALL')) if (!empty($setmodules)) { // If phpBB is not installed we do not include this module - if (@file_exists($phpbb_root_path . 'config.' . $phpEx) && !@file_exists($phpbb_root_path . 'cache/install_lock')) + if (@file_exists(PHPBB_ROOT_PATH . 'config.' . PHP_EXT) && !@file_exists(PHPBB_ROOT_PATH . 'cache/install_lock')) { - include_once($phpbb_root_path . 'config.' . $phpEx); + include_once(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); if (!defined('PHPBB_INSTALLED')) { @@ -37,7 +37,7 @@ if (!empty($setmodules)) $module[] = array( 'module_type' => 'update', 'module_title' => 'UPDATE', - 'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), + 'module_filename' => substr(basename(__FILE__), 0, -strlen(PHP_EXT)-1), 'module_order' => 30, 'module_subs' => '', 'module_stages' => array('INTRO', 'VERSION_CHECK', 'UPDATE_DB', 'FILE_CHECK', 'UPDATE_FILES'), @@ -70,19 +70,19 @@ class install_update extends module function main($mode, $sub) { - global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth; + global $template, $user, $db, $config, $cache, $auth; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; $this->unequal_version = false; - $this->old_location = $phpbb_root_path . 'install/update/old/'; - $this->new_location = $phpbb_root_path . 'install/update/new/'; + $this->old_location = PHPBB_ROOT_PATH . 'install/update/old/'; + $this->new_location = PHPBB_ROOT_PATH . 'install/update/new/'; // Init DB - require($phpbb_root_path . 'config.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - require($phpbb_root_path . 'includes/constants.' . $phpEx); + require(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); + require(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT); + require(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT); // Special options for conflicts/modified files define('MERGE_NO_MERGE_NEW', 1); @@ -148,7 +148,7 @@ class install_update extends module $up_to_date = (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->latest_version)), '<')) ? false : true; // Check for a valid update directory, else point the user to the phpbb.com website - if (!file_exists($phpbb_root_path . 'install/update') || !file_exists($phpbb_root_path . 'install/update/index.' . $phpEx) || !file_exists($this->old_location) || !file_exists($this->new_location)) + if (!file_exists(PHPBB_ROOT_PATH . 'install/update') || !file_exists(PHPBB_ROOT_PATH . 'install/update/index.php') || !file_exists($this->old_location) || !file_exists($this->new_location)) { $template->assign_vars(array( 'S_ERROR' => true, @@ -206,9 +206,9 @@ class install_update extends module } // Include renderer and engine - $this->include_file('includes/diff/diff.' . $phpEx); - $this->include_file('includes/diff/engine.' . $phpEx); - $this->include_file('includes/diff/renderer.' . $phpEx); + $this->include_file('includes/diff/diff.' . PHP_EXT); + $this->include_file('includes/diff/engine.' . PHP_EXT); + $this->include_file('includes/diff/renderer.' . PHP_EXT); // Make sure we stay at the file check if checking the files again if (!empty($_POST['check_again'])) @@ -259,9 +259,9 @@ class install_update extends module $valid = false; $updates_to_version = ''; - if (file_exists($phpbb_root_path . 'install/database_update.' . $phpEx)) + if (file_exists(PHPBB_ROOT_PATH . 'install/database_update.' . PHP_EXT)) { - include_once($phpbb_root_path . 'install/database_update.' . $phpEx); + include_once(PHPBB_ROOT_PATH . 'install/database_update.' . PHP_EXT); if ($updates_to_version === $this->update_info['version']['to']) { @@ -282,7 +282,7 @@ class install_update extends module $template->assign_vars(array( 'S_DB_UPDATE' => true, 'S_DB_UPDATE_FINISHED' => ($config['version'] == $this->update_info['version']['to']) ? true : false, - 'U_DB_UPDATE' => append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=1&language=' . $user->data['user_lang']), + 'U_DB_UPDATE' => append_sid('install/database_update', 'type=1&language=' . $user->data['user_lang']), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), )); @@ -301,7 +301,7 @@ class install_update extends module // We are directly within an update. To make sure our update list is correct we check its status. $update_list = (!empty($_POST['check_again'])) ? false : $cache->get('_update_list'); - $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . $phpEx) : 0; + $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . PHP_EXT) : 0; // Make sure the list is up-to-date if ($update_list !== false) @@ -309,7 +309,7 @@ class install_update extends module $get_new_list = false; foreach ($this->update_info['files'] as $file) { - if (file_exists($phpbb_root_path . $file) && filemtime($phpbb_root_path . $file) > $modified) + if (file_exists(PHPBB_ROOT_PATH . $file) && filemtime(PHPBB_ROOT_PATH . $file) > $modified) { $get_new_list = true; break; @@ -459,21 +459,21 @@ class install_update extends module $update_time = time(); // We test for stylesheet.css because it is faster and most likely the only file changed on common themes - if (!$recache && $theme['theme_mtime'] < @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css')) + if (!$recache && $theme['theme_mtime'] < @filemtime(PHPBB_ROOT_PATH . 'styles/' . $theme['theme_path'] . '/theme/stylesheet.css')) { $recache = true; - $update_time = @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css'); + $update_time = @filemtime(PHPBB_ROOT_PATH . 'styles/' . $theme['theme_path'] . '/theme/stylesheet.css'); } else if (!$recache) { $last_change = $theme['theme_mtime']; - $dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme"); + $dir = @opendir(PHPBB_ROOT_PATH . "styles/{$theme['theme_path']}/theme"); if ($dir) { while (($entry = readdir($dir)) !== false) { - if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}")) + if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime(PHPBB_ROOT_PATH . "styles/{$theme['theme_path']}/theme/{$entry}")) { $recache = true; break; @@ -485,7 +485,7 @@ class install_update extends module if ($recache) { - include_once($phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx); + include_once(PHPBB_ROOT_PATH . 'includes/acp/acp_styles.' . PHP_EXT); $theme['theme_data'] = acp_styles::db_theme_data($theme); $theme['theme_mtime'] = $update_time; @@ -679,11 +679,11 @@ class install_update extends module break; case MERGE_NO_MERGE_MOD: - $contents = file_get_contents($phpbb_root_path . $file_struct['filename']); + $contents = file_get_contents(PHPBB_ROOT_PATH . $file_struct['filename']); break; default: - $diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename); + $diff = $this->return_diff($this->old_location . $original_filename, PHPBB_ROOT_PATH . $file_struct['filename'], $this->new_location . $original_filename); $contents = implode("\n", $diff->merged_output()); unset($diff); @@ -710,12 +710,12 @@ class install_update extends module break; case MERGE_NO_MERGE_MOD: - $contents = file_get_contents($phpbb_root_path . $file_struct['filename']); + $contents = file_get_contents(PHPBB_ROOT_PATH . $file_struct['filename']); break; default: - $diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename); + $diff = $this->return_diff($this->old_location . $original_filename, PHPBB_ROOT_PATH . $file_struct['filename'], $this->new_location . $original_filename); if ($option == MERGE_NEW_FILE) { @@ -752,7 +752,7 @@ class install_update extends module if (!empty($_REQUEST['download'])) { - $this->include_file('includes/functions_compress.' . $phpEx); + $this->include_file('includes/functions_compress.' . PHP_EXT); $use_method = request_var('use_method', ''); $methods = array('.tar'); @@ -822,7 +822,7 @@ class install_update extends module } else { - $this->include_file('includes/functions_transfer.' . $phpEx); + $this->include_file('includes/functions_transfer.' . PHP_EXT); // Choose FTP, if not available use fsock... $method = basename(request_var('method', '')); @@ -850,7 +850,7 @@ class install_update extends module if ($test_connection === true) { // Check for common.php file - if (!$transfer->file_exists($phpbb_root_path, 'common.' . $phpEx)) + if (!$transfer->file_exists(PHPBB_ROOT_PATH, 'common.' . PHP_EXT)) { $test_connection = 'ERR_WRONG_PATH_TO_PHPBB'; } @@ -914,11 +914,11 @@ class install_update extends module { if ($use_method == '.zip') { - $compress = new compress_zip('w', $phpbb_root_path . 'store/' . $archive_filename . $use_method); + $compress = new compress_zip('w', PHPBB_ROOT_PATH . 'store/' . $archive_filename . $use_method); } else { - $compress = new compress_tar('w', $phpbb_root_path . 'store/' . $archive_filename . $use_method, $use_method); + $compress = new compress_tar('w', PHPBB_ROOT_PATH . 'store/' . $archive_filename . $use_method, $use_method); } } else @@ -965,7 +965,7 @@ class install_update extends module // New directory too? $dirname = dirname($file_struct['filename']); - if ($dirname && !file_exists($phpbb_root_path . $dirname)) + if ($dirname && !file_exists(PHPBB_ROOT_PATH . $dirname)) { $transfer->make_dir($dirname); } @@ -1013,7 +1013,7 @@ class install_update extends module $compress->close(); $compress->download($archive_filename, $download_filename); - @unlink($phpbb_root_path . 'store/' . $archive_filename . $use_method); + @unlink(PHPBB_ROOT_PATH . 'store/' . $archive_filename . $use_method); exit; } @@ -1038,7 +1038,7 @@ class install_update extends module */ function show_diff(&$update_list) { - global $phpbb_root_path, $template, $user; + global $template, $user; $this->tpl_name = 'install_update_diff'; @@ -1088,7 +1088,7 @@ class install_update extends module case MERGE_NO_MERGE_NEW: case MERGE_NO_MERGE_MOD: - $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : $phpbb_root_path . $file); + $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : PHPBB_ROOT_PATH . $file); $template->assign_var('S_DIFF_NEW_FILE', true); $diff_mode = 'inline'; @@ -1099,7 +1099,7 @@ class install_update extends module case MERGE_NEW_FILE: case MERGE_MOD_FILE: - $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $file, $this->new_location . $original_file); + $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); $tmp = array( 'file1' => array(), @@ -1118,14 +1118,14 @@ class install_update extends module default: - $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $file, $this->new_location . $original_file); + $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); $template->assign_vars(array( 'S_DIFF_CONFLICT_FILE' => true, 'NUM_CONFLICTS' => $diff->merged_output(false, false, false, true)) ); - $diff = $this->return_diff($phpbb_root_path . $file, $diff->merged_output()); + $diff = $this->return_diff(PHPBB_ROOT_PATH . $file, $diff->merged_output()); break; } @@ -1139,7 +1139,7 @@ class install_update extends module case MERGE_NO_MERGE_NEW: case MERGE_NO_MERGE_MOD: - $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : $phpbb_root_path . $file); + $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : PHPBB_ROOT_PATH . $file); $template->assign_var('S_DIFF_NEW_FILE', true); $diff_mode = 'inline'; @@ -1148,14 +1148,14 @@ class install_update extends module break; default: - $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $original_file, $this->new_location . $file); + $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $original_file, $this->new_location . $file); break; } break; case 'not_modified': case 'new_conflict': - $diff = $this->return_diff($phpbb_root_path . $file, $this->new_location . $original_file); + $diff = $this->return_diff(PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); break; case 'new': @@ -1200,7 +1200,7 @@ class install_update extends module */ function get_update_structure(&$update_list) { - global $phpbb_root_path, $phpEx, $user; + global $user; if ($update_list === false) { @@ -1242,7 +1242,7 @@ class install_update extends module return; } - if (!file_exists($phpbb_root_path . $file)) + if (!file_exists(PHPBB_ROOT_PATH . $file)) { // Make sure the update files are consistent by checking if the file is in new_files... if (!file_exists($this->new_location . $file)) @@ -1259,7 +1259,7 @@ class install_update extends module /* Only include a new file as new if the underlying path exist // The path normally do not exist if the original style or language has been removed - if (file_exists($phpbb_root_path . dirname($file))) + if (file_exists(PHPBB_ROOT_PATH . dirname($file))) { $this->get_custom_info($update_list['new'], $file); $update_list['new'][] = array('filename' => $file, 'custom' => false); @@ -1273,7 +1273,7 @@ class install_update extends module } }*/ - if (file_exists($phpbb_root_path . dirname($file)) || (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0)) + if (file_exists(PHPBB_ROOT_PATH . dirname($file)) || (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0)) { $this->get_custom_info($update_list['new'], $file); $update_list['new'][] = array('filename' => $file, 'custom' => false); @@ -1327,7 +1327,7 @@ class install_update extends module */ function make_update_diff(&$update_list, $original_file, $file, $custom = false) { - global $phpbb_root_path, $user; + global $user; $update_ary = array('filename' => $file, 'custom' => $custom); @@ -1338,11 +1338,11 @@ class install_update extends module // On a successfull update the new location file exists but the old one does not exist. // Check for this circumstance, the new file need to be up-to-date with the current file then... - if (!file_exists($this->old_location . $original_file) && file_exists($this->new_location . $original_file) && file_exists($phpbb_root_path . $file)) + if (!file_exists($this->old_location . $original_file) && file_exists($this->new_location . $original_file) && file_exists(PHPBB_ROOT_PATH . $file)) { $tmp = array( 'file1' => file_get_contents($this->new_location . $original_file), - 'file2' => file_get_contents($phpbb_root_path . $file), + 'file2' => file_get_contents(PHPBB_ROOT_PATH . $file), ); // We need to diff the contents here to make sure the file is really the one we expect @@ -1377,7 +1377,7 @@ class install_update extends module $tmp = array( 'file1' => file_get_contents($this->old_location . $original_file), - 'file2' => file_get_contents($phpbb_root_path . $file), + 'file2' => file_get_contents(PHPBB_ROOT_PATH . $file), ); // We need to diff the contents here to make sure the file is really the one we expect @@ -1388,7 +1388,7 @@ class install_update extends module $tmp = array( 'file1' => file_get_contents($this->new_location . $original_file), - 'file2' => file_get_contents($phpbb_root_path . $file), + 'file2' => file_get_contents(PHPBB_ROOT_PATH . $file), ); // We need to diff the contents here to make sure the file is really the one we expect @@ -1424,7 +1424,7 @@ class install_update extends module // if the file is modified we try to make sure a merge succeed $tmp = array( 'file1' => file_get_contents($this->old_location . $original_file), - 'file2' => file_get_contents($phpbb_root_path . $file), + 'file2' => file_get_contents(PHPBB_ROOT_PATH . $file), 'file3' => file_get_contents($this->new_location . $original_file), ); @@ -1438,7 +1438,7 @@ class install_update extends module // There is one special case... users having merged with a conflicting file... we need to check this $tmp = array( - 'file1' => file_get_contents($phpbb_root_path . $file), + 'file1' => file_get_contents(PHPBB_ROOT_PATH . $file), 'file2' => implode("\n", $diff->merged_orig_output()), ); @@ -1460,7 +1460,7 @@ class install_update extends module } $tmp = array( - 'file1' => file_get_contents($phpbb_root_path . $file), + 'file1' => file_get_contents(PHPBB_ROOT_PATH . $file), 'file2' => implode("\n", $diff->merged_output()), ); @@ -1512,7 +1512,6 @@ class install_update extends module switch ($mode) { case 'version_info': - global $phpbb_root_path, $phpEx; $info = get_remote_file('www.phpbb.com', '/updatecheck', ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); if ($info !== false) @@ -1530,7 +1529,7 @@ class install_update extends module if ($info === false) { $update_info = array(); - include($phpbb_root_path . 'install/update/index.php'); + include(PHPBB_ROOT_PATH . 'install/update/index.php'); $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; if ($info !== false) @@ -1541,10 +1540,8 @@ class install_update extends module break; case 'update_info': - global $phpbb_root_path, $phpEx; - $update_info = array(); - include($phpbb_root_path . 'install/update/index.php'); + include(PHPBB_ROOT_PATH . 'install/update/index.php'); $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; $errstr = ($info === false) ? $user->lang['WRONG_INFO_FILE_FORMAT'] : ''; @@ -1603,15 +1600,13 @@ class install_update extends module */ function include_file($filename) { - global $phpbb_root_path, $phpEx; - if (!empty($this->update_info['files']) && in_array($filename, $this->update_info['files'])) { include_once($this->new_location . $filename); } else { - include_once($phpbb_root_path . $filename); + include_once(PHPBB_ROOT_PATH . $filename); } } -- cgit v1.2.1 From 4235be4bcb07a121afd0b6a202fb7b3823dcce67 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Fri, 15 Aug 2008 13:00:20 +0000 Subject: PHP5.3 compatibility. git-svn-id: file:///svn/phpbb/trunk@8759 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 8bad2f7560..5a4f612a45 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1106,7 +1106,7 @@ class install_update extends module 'file2' => ($option == MERGE_NEW_FILE) ? implode("\n", $diff->merged_new_output()) : implode("\n", $diff->merged_orig_output()), ); - $diff = &new diff($tmp['file1'], $tmp['file2']); + $diff = new diff($tmp['file1'], $tmp['file2']); unset($tmp); @@ -1183,7 +1183,7 @@ class install_update extends module trigger_error('Chosen diff mode is not supported', E_USER_ERROR); } - $renderer = &new $render_class(); + $renderer = new $render_class(); $template->assign_vars(array( 'DIFF_CONTENT' => $renderer->get_diff_content($diff), @@ -1346,7 +1346,7 @@ class install_update extends module ); // We need to diff the contents here to make sure the file is really the one we expect - $diff = &new diff($tmp['file1'], $tmp['file2'], false); + $diff = new diff($tmp['file1'], $tmp['file2'], false); $empty = $diff->is_empty(); unset($tmp, $diff); @@ -1381,7 +1381,7 @@ class install_update extends module ); // We need to diff the contents here to make sure the file is really the one we expect - $diff = &new diff($tmp['file1'], $tmp['file2'], false); + $diff = new diff($tmp['file1'], $tmp['file2'], false); $empty_1 = $diff->is_empty(); unset($tmp, $diff); @@ -1392,7 +1392,7 @@ class install_update extends module ); // We need to diff the contents here to make sure the file is really the one we expect - $diff = &new diff($tmp['file1'], $tmp['file2'], false); + $diff = new diff($tmp['file1'], $tmp['file2'], false); $empty_2 = $diff->is_empty(); unset($tmp, $diff); @@ -1428,7 +1428,7 @@ class install_update extends module 'file3' => file_get_contents($this->new_location . $original_file), ); - $diff = &new diff3($tmp['file1'], $tmp['file2'], $tmp['file3'], false); + $diff = new diff3($tmp['file1'], $tmp['file2'], $tmp['file3'], false); unset($tmp); @@ -1442,7 +1442,7 @@ class install_update extends module 'file2' => implode("\n", $diff->merged_orig_output()), ); - $diff = &new diff($tmp['file1'], $tmp['file2'], false); + $diff = new diff($tmp['file1'], $tmp['file2'], false); $empty = $diff->is_empty(); if ($empty) @@ -1465,7 +1465,7 @@ class install_update extends module ); // now compare the merged output with the original file to see if the modified file is up to date - $diff = &new diff($tmp['file1'], $tmp['file2'], false); + $diff = new diff($tmp['file1'], $tmp['file2'], false); $empty = $diff->is_empty(); if ($empty) @@ -1629,11 +1629,11 @@ class install_update extends module $file3 = array_shift($args); $tmp['file3'] = (!empty($file3) && is_string($file3)) ? file_get_contents($file3) : $file3; - $diff = &new diff3($tmp['file1'], $tmp['file2'], $tmp['file3']); + $diff = new diff3($tmp['file1'], $tmp['file2'], $tmp['file3']); } else { - $diff = &new diff($tmp['file1'], $tmp['file2']); + $diff = new diff($tmp['file1'], $tmp['file2']); } unset($tmp); -- cgit v1.2.1 From 0dbe7e3b6cd450342d3c566eb2caf36ca1b5db8e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Sep 2008 11:39:25 +0000 Subject: Remove caching of templates from the database completely, themes is cut down ready for a complete chop, and fix the installer :) git-svn-id: file:///svn/phpbb/trunk@8812 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 5a4f612a45..33a706edf1 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -128,9 +128,6 @@ class install_update extends module // Set custom template again. ;) $template->set_custom_template('../adm/style', 'admin'); - // still, the acp template is never stored in the database - $user->theme['template_storedb'] = false; - // Get current and latest version if (($latest_version = $cache->get('_version_info')) === false) { -- cgit v1.2.1 From c903b453fa00871a11ea988b5e348c3a2741b251 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 2 Nov 2008 11:22:30 +0000 Subject: i had these changes sitting... must've been a merge not committed (and because we do not use svn 1.5 as the client version i am not able to say which they were) git-svn-id: file:///svn/phpbb/trunk@9042 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 33a706edf1..8312b3fc55 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -893,8 +893,9 @@ class install_update extends module 'S_FTP_UPLOAD' => true, 'UPLOAD_METHOD' => $method, 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), - 'S_HIDDEN_FIELDS' => $s_hidden_fields) - ); + 'U_DOWNLOAD_METHOD' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files&download=1"), + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + )); return; } -- cgit v1.2.1 From 07e9b83a3de0264916a058b9cf180b91b297604f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 24 Nov 2008 00:20:33 +0000 Subject: - updated all code to use the request class instead of any direct access to super globals - disabled super globals in common.php. See commit r9101 for more information - cleaned up/simplified a few lines along the way. git-svn-id: file:///svn/phpbb/trunk@9102 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 8312b3fc55..f10caf9d54 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -208,7 +208,7 @@ class install_update extends module $this->include_file('includes/diff/renderer.' . PHP_EXT); // Make sure we stay at the file check if checking the files again - if (!empty($_POST['check_again'])) + if (request::variable('check_again', false, false, request::POST)) { $sub = $this->p_master->sub = 'file_check'; } @@ -297,7 +297,7 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = (!empty($_POST['check_again'])) ? false : $cache->get('_update_list'); + $update_list = (request::variable('check_again', false, false, request::POST)) ? false : $cache->get('_update_list'); $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . PHP_EXT) : 0; // Make sure the list is up-to-date @@ -644,7 +644,7 @@ class install_update extends module { $cache->put('_diff_files', $file_list); - if (!empty($_REQUEST['download'])) + if (request_var('download', false)) { $params[] = 'download=1'; } @@ -747,7 +747,7 @@ class install_update extends module $file_list['status'] = -1; $cache->put('_diff_files', $file_list); - if (!empty($_REQUEST['download'])) + if (request_var('download', false)) { $this->include_file('includes/functions_compress.' . PHP_EXT); @@ -823,7 +823,7 @@ class install_update extends module // Choose FTP, if not available use fsock... $method = basename(request_var('method', '')); - $submit = (isset($_POST['submit'])) ? true : false; + $submit = request::is_set_post('submit'); $test_ftp_connection = request_var('test_connection', ''); if (!$method || !class_exists($method)) @@ -881,7 +881,7 @@ class install_update extends module 'DATA' => $data, 'NAME' => $user->lang[strtoupper($method . '_' . $data)], 'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], - 'DEFAULT' => (!empty($_REQUEST[$data])) ? request_var($data, '') : $default + 'DEFAULT' => (request_var($data, false)) ? request_var($data, '') : $default )); } -- cgit v1.2.1 From 5b9a3c9a7d8f8e4590dddf4440ac82c30ef3f730 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 25 Dec 2008 14:47:57 +0000 Subject: add nils' request and super globals class rename request:: to phpbb_request:: git-svn-id: file:///svn/phpbb/trunk@9230 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index f10caf9d54..28ee7a95ff 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -208,7 +208,7 @@ class install_update extends module $this->include_file('includes/diff/renderer.' . PHP_EXT); // Make sure we stay at the file check if checking the files again - if (request::variable('check_again', false, false, request::POST)) + if (phpbb_request::variable('check_again', false, false, phpbb_request::POST)) { $sub = $this->p_master->sub = 'file_check'; } @@ -297,7 +297,7 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = (request::variable('check_again', false, false, request::POST)) ? false : $cache->get('_update_list'); + $update_list = (phpbb_request::variable('check_again', false, false, phpbb_request::POST)) ? false : $cache->get('_update_list'); $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . PHP_EXT) : 0; // Make sure the list is up-to-date @@ -823,7 +823,7 @@ class install_update extends module // Choose FTP, if not available use fsock... $method = basename(request_var('method', '')); - $submit = request::is_set_post('submit'); + $submit = phpbb_request::is_set_post('submit'); $test_ftp_connection = request_var('test_connection', ''); if (!$method || !class_exists($method)) -- cgit v1.2.1 From 889fa871402814874d5d4f01b2f1c829d8206eb9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 28 Dec 2008 13:27:58 +0000 Subject: implement new phpbb::$acm object, replacing $cache global git-svn-id: file:///svn/phpbb/trunk@9240 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 28ee7a95ff..a396c04dc5 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -70,7 +70,7 @@ class install_update extends module function main($mode, $sub) { - global $template, $user, $db, $config, $cache, $auth; + global $template, $user, $db, $config, $auth; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; @@ -122,17 +122,17 @@ class install_update extends module // If we are within the intro page we need to make sure we get up-to-date version info if ($sub == 'intro') { - $cache->destroy('_version_info'); + phpbb::$acm->destroy('version_info'); } // Set custom template again. ;) $template->set_custom_template('../adm/style', 'admin'); // Get current and latest version - if (($latest_version = $cache->get('_version_info')) === false) + if (($latest_version = phpbb::$acm->get('version_info')) === false) { $this->latest_version = $this->get_file('version_info'); - $cache->put('_version_info', $this->latest_version); + phpbb::$acm->put('version_info', $this->latest_version); } else { @@ -224,8 +224,8 @@ class install_update extends module )); // Make sure the update list is destroyed. - $cache->destroy('_update_list'); - $cache->destroy('_diff_files'); + phpbb::$acm->destroy('update_list'); + phpbb::$acm->destroy('diff_files'); break; case 'version_check': @@ -273,7 +273,7 @@ class install_update extends module } // Just a precaution - $cache->purge(); + phpbb::$acm->purge(); // Redirect the user to the database update script with some explanations... $template->assign_vars(array( @@ -289,7 +289,7 @@ class install_update extends module case 'file_check': // Make sure the previous file collection is no longer valid... - $cache->destroy('_diff_files'); + phpbb::$acm->destroy('diff_files'); $this->page_title = 'STAGE_FILE_CHECK'; @@ -297,8 +297,8 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = (phpbb_request::variable('check_again', false, false, phpbb_request::POST)) ? false : $cache->get('_update_list'); - $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . PHP_EXT) : 0; + $update_list = (phpbb_request::variable('check_again', false, false, phpbb_request::POST)) ? false : phpbb::$acm->get('update_list'); + $modified = ($update_list !== false) ? phpbb::$acm->get_modified_date('data', 'update_list') : 0; // Make sure the list is up-to-date if ($update_list !== false) @@ -326,7 +326,7 @@ class install_update extends module if ($get_new_list) { $this->get_update_structure($update_list); - $cache->put('_update_list', $update_list); + phpbb::$acm->put('update_list', $update_list); // Refresh the page if we are still not finished... if ($update_list['status'] != -1) @@ -497,7 +497,7 @@ class install_update extends module WHERE theme_id = ' . $theme['theme_id']; $db->sql_query($sql); - $cache->destroy('sql', STYLES_THEME_TABLE); + phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); } } @@ -505,7 +505,7 @@ class install_update extends module $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); $db->sql_return_on_error(false); - $cache->purge(); + phpbb::$acm->purge(); } break; @@ -544,7 +544,7 @@ class install_update extends module } // Before the user is choosing his preferred method, let's create the content list... - $update_list = $cache->get('_update_list'); + $update_list = phpbb::$acm->get('update_list'); if ($update_list === false) { @@ -601,7 +601,7 @@ class install_update extends module // Before we do anything, let us diff the files and store the raw file information "somewhere" $get_files = false; - $file_list = $cache->get('_diff_files'); + $file_list = phpbb::$acm->get('diff_files'); if ($file_list === false || $file_list['status'] != -1) { @@ -642,7 +642,7 @@ class install_update extends module // Refresh if we reach 5 diffs... if ($processed >= 5) { - $cache->put('_diff_files', $file_list); + phpbb::$acm->put('diff_files', $file_list); if (request_var('download', false)) { @@ -687,8 +687,8 @@ class install_update extends module break; } - $file_list[$file_struct['filename']] = '_file_' . md5($file_struct['filename']); - $cache->put($file_list[$file_struct['filename']], base64_encode($contents)); + $file_list[$file_struct['filename']] = 'file_' . md5($file_struct['filename']); + phpbb::$acm->put($file_list[$file_struct['filename']], base64_encode($contents)); $file_list['status']++; $processed++; @@ -732,8 +732,8 @@ class install_update extends module break; } - $file_list[$file_struct['filename']] = '_file_' . md5($file_struct['filename']); - $cache->put($file_list[$file_struct['filename']], base64_encode($contents)); + $file_list[$file_struct['filename']] = 'file_' . md5($file_struct['filename']); + phpbb::$acm->put($file_list[$file_struct['filename']], base64_encode($contents)); $file_list['status']++; $processed++; @@ -745,7 +745,7 @@ class install_update extends module } $file_list['status'] = -1; - $cache->put('_diff_files', $file_list); + phpbb::$acm->put('diff_files', $file_list); if (request_var('download', false)) { @@ -784,7 +784,7 @@ class install_update extends module ); // To ease the update process create a file location map - $update_list = $cache->get('_update_list'); + $update_list = phpbb::$acm->get('update_list'); $script_path = ($config['force_server_vars']) ? (($config['script_path'] == '/') ? '/' : $config['script_path'] . '/') : $user->page['root_script_path']; foreach ($update_list as $status => $files) @@ -974,7 +974,7 @@ class install_update extends module case 'modified': - $contents = base64_decode($cache->get($file_list[$file_struct['filename']])); + $contents = base64_decode(phpbb::$acm->get($file_list[$file_struct['filename']])); if ($update_mode == 'download') { @@ -990,7 +990,7 @@ class install_update extends module case 'conflict': - $contents = base64_decode($cache->get($file_list[$file_struct['filename']])); + $contents = base64_decode(phpbb::$acm->get($file_list[$file_struct['filename']])); if ($update_mode == 'download') { -- cgit v1.2.1 From 19aed179e53f9660a7202e2e50816e1cef0f7be9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 28 Dec 2008 23:30:09 +0000 Subject: $config to phpbb::$config git-svn-id: file:///svn/phpbb/trunk@9242 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index a396c04dc5..4da795bb4b 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -70,7 +70,7 @@ class install_update extends module function main($mode, $sub) { - global $template, $user, $db, $config, $auth; + global $template, $user, $db, $auth; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; @@ -98,20 +98,8 @@ class install_update extends module // We do not need this any longer, unset for safety purposes unset($dbpasswd); - $config = array(); - - $sql = 'SELECT config_name, config_value - FROM ' . CONFIG_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $config[$row['config_name']] = $row['config_value']; - } - $db->sql_freeresult($result); - // Force template recompile - $config['load_tplcompile'] = 1; + phpbb::$config['load_tplcompile'] = 1; // First of all, init the user session $user->session_begin(); @@ -140,7 +128,7 @@ class install_update extends module } // For the current version we trick a bit. ;) - $this->current_version = (!empty($config['version_update_from'])) ? $config['version_update_from'] : $config['version']; + $this->current_version = (!empty(phpbb::$config['version_update_from'])) ? phpbb::$config['version_update_from'] : phpbb::$config['version']; $up_to_date = (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->latest_version)), '<')) ? false : true; @@ -149,7 +137,7 @@ class install_update extends module { $template->assign_vars(array( 'S_ERROR' => true, - 'ERROR_MSG' => ($up_to_date) ? $user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf($user->lang['NO_UPDATE_FILES_OUTDATED'], $config['version'], $this->current_version, $this->latest_version)) + 'ERROR_MSG' => ($up_to_date) ? $user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf($user->lang['NO_UPDATE_FILES_OUTDATED'], phpbb::$config['version'], $this->current_version, $this->latest_version)) ); return; @@ -163,7 +151,7 @@ class install_update extends module { $template->assign_vars(array( 'S_ERROR' => true, - 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], $config['version'], $this->update_info['version']['from'], $this->update_info['version']['to'])) + 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], phpbb::$config['version'], $this->update_info['version']['from'], $this->update_info['version']['to'])) ); return; @@ -278,7 +266,7 @@ class install_update extends module // Redirect the user to the database update script with some explanations... $template->assign_vars(array( 'S_DB_UPDATE' => true, - 'S_DB_UPDATE_FINISHED' => ($config['version'] == $this->update_info['version']['to']) ? true : false, + 'S_DB_UPDATE_FINISHED' => (phpbb::$config['version'] == $this->update_info['version']['to']) ? true : false, 'U_DB_UPDATE' => append_sid('install/database_update', 'type=1&language=' . $user->data['user_lang']), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), @@ -785,7 +773,7 @@ class install_update extends module // To ease the update process create a file location map $update_list = phpbb::$acm->get('update_list'); - $script_path = ($config['force_server_vars']) ? (($config['script_path'] == '/') ? '/' : $config['script_path'] . '/') : $user->page['root_script_path']; + $script_path = (phpbb::$config['force_server_vars']) ? ((phpbb::$config['script_path'] == '/') ? '/' : phpbb::$config['script_path'] . '/') : $user->page['root_script_path']; foreach ($update_list as $status => $files) { -- cgit v1.2.1 From 5a263f76a936dc6f1dba446b5ec1a1c3f5075a84 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 16 Jan 2009 17:57:28 +0000 Subject: "are you serious?" - "yes, sure" - "wow, install works, you are right" - "i told you" git-svn-id: file:///svn/phpbb/trunk@9277 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 4da795bb4b..d347c0af59 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -70,7 +70,7 @@ class install_update extends module function main($mode, $sub) { - global $template, $user, $db, $auth; + require PHPBB_ROOT_PATH . 'common.' . PHP_EXT; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; @@ -79,33 +79,13 @@ class install_update extends module $this->old_location = PHPBB_ROOT_PATH . 'install/update/old/'; $this->new_location = PHPBB_ROOT_PATH . 'install/update/new/'; - // Init DB - require(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); - require(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT); - require(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT); - - // Special options for conflicts/modified files - define('MERGE_NO_MERGE_NEW', 1); - define('MERGE_NO_MERGE_MOD', 2); - define('MERGE_NEW_FILE', 3); - define('MERGE_MOD_FILE', 4); - - $db = new $sql_db(); - - // Connect to DB - $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); - - // We do not need this any longer, unset for safety purposes - unset($dbpasswd); - // Force template recompile phpbb::$config['load_tplcompile'] = 1; - // First of all, init the user session - $user->session_begin(); - $auth->acl($user->data); - - $user->setup('install'); + // Start session management + phpbb::$user->session_begin(); + phpbb::$acl->init(phpbb::$user->data); + phpbb::$user->setup('viewforum'); // If we are within the intro page we need to make sure we get up-to-date version info if ($sub == 'intro') -- cgit v1.2.1 From cd4091af43fa2d7d3dbe5ad0d583c63f1d96c903 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 20 Jan 2009 16:54:15 +0000 Subject: i am not sure if people will like the config layout i test here... it requires the framework at least being present git-svn-id: file:///svn/phpbb/trunk@9281 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index d347c0af59..137b9d4957 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -24,7 +24,7 @@ if (!empty($setmodules)) { include_once(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); - if (!defined('PHPBB_INSTALLED')) + if (!phpbb::$base_config['installed']) { return; } -- cgit v1.2.1 From 794c5749696c9fa2595ed3a1d7c836a0d984e11c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 15:29:18 +0000 Subject: remove global and change $user-> to phpbb::$user-> git-svn-id: file:///svn/phpbb/trunk@9334 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 62 +++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 35 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 137b9d4957..19cf3051c9 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -117,7 +117,7 @@ class install_update extends module { $template->assign_vars(array( 'S_ERROR' => true, - 'ERROR_MSG' => ($up_to_date) ? $user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf($user->lang['NO_UPDATE_FILES_OUTDATED'], phpbb::$config['version'], $this->current_version, $this->latest_version)) + 'ERROR_MSG' => ($up_to_date) ? phpbb::$user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf(phpbb::$user->lang['NO_UPDATE_FILES_OUTDATED'], phpbb::$config['version'], $this->current_version, $this->latest_version)) ); return; @@ -131,7 +131,7 @@ class install_update extends module { $template->assign_vars(array( 'S_ERROR' => true, - 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], phpbb::$config['version'], $this->update_info['version']['from'], $this->update_info['version']['to'])) + 'ERROR_MSG' => sprintf(phpbb::$user->lang['INCOMPATIBLE_UPDATE_FILES'], phpbb::$config['version'], $this->update_info['version']['from'], $this->update_info['version']['to'])) ); return; @@ -144,7 +144,7 @@ class install_update extends module $template->assign_vars(array( 'S_WARNING' => true, - 'WARNING_MSG' => sprintf($user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version)) + 'WARNING_MSG' => sprintf(phpbb::$user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version)) ); } @@ -162,10 +162,10 @@ class install_update extends module $lang = array(); include($this->new_location . 'language/en/install.php'); // only add new keys to user's language in english - $new_keys = array_diff(array_keys($lang), array_keys($user->lang)); + $new_keys = array_diff(array_keys($lang), array_keys(phpbb::$user->lang)); foreach ($new_keys as $i => $new_key) { - $user->lang[$new_key] = $lang[$new_key]; + phpbb::$user->lang[$new_key] = $lang[$new_key]; } } } @@ -237,7 +237,7 @@ class install_update extends module // Should not happen at all if (!$valid) { - trigger_error($user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); + trigger_error(phpbb::$user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); } // Just a precaution @@ -247,7 +247,7 @@ class install_update extends module $template->assign_vars(array( 'S_DB_UPDATE' => true, 'S_DB_UPDATE_FINISHED' => (phpbb::$config['version'] == $this->update_info['version']['to']) ? true : false, - 'U_DB_UPDATE' => append_sid('install/database_update', 'type=1&language=' . $user->data['user_lang']), + 'U_DB_UPDATE' => append_sid('install/database_update', 'type=1&language=' . phpbb::$user->data['user_lang']), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), )); @@ -306,8 +306,8 @@ class install_update extends module 'S_IN_PROGRESS' => true, 'S_COLLECTED' => (int) $update_list['status'], 'S_TO_COLLECT' => sizeof($this->update_info['files']), - 'L_IN_PROGRESS' => $user->lang['COLLECTING_FILE_DIFFS'], - 'L_IN_PROGRESS_EXPLAIN' => sprintf($user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files'])), + 'L_IN_PROGRESS' => phpbb::$user->lang['COLLECTING_FILE_DIFFS'], + 'L_IN_PROGRESS_EXPLAIN' => sprintf(phpbb::$user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files'])), )); return; @@ -339,9 +339,9 @@ class install_update extends module $template->assign_block_vars('files', array( 'S_STATUS' => true, 'STATUS' => $status, - 'L_STATUS' => $user->lang['STATUS_' . strtoupper($status)], - 'TITLE' => $user->lang['FILES_' . strtoupper($status)], - 'EXPLAIN' => $user->lang['FILES_' . strtoupper($status) . '_EXPLAIN'], + 'L_STATUS' => phpbb::$user->lang['STATUS_' . strtoupper($status)], + 'TITLE' => phpbb::$user->lang['FILES_' . strtoupper($status)], + 'EXPLAIN' => phpbb::$user->lang['FILES_' . strtoupper($status) . '_EXPLAIN'], ) ); @@ -376,7 +376,7 @@ class install_update extends module 'CUSTOM_ORIGINAL' => ($file_struct['custom']) ? $file_struct['original'] : '', 'U_SHOW_DIFF' => $diff_url, - 'L_SHOW_DIFF' => ($status != 'up_to_date') ? $user->lang['SHOW_DIFF_' . strtoupper($status)] : '', + 'L_SHOW_DIFF' => ($status != 'up_to_date') ? phpbb::$user->lang['SHOW_DIFF_' . strtoupper($status)] : '', 'U_VIEW_MOD_FILE' => $diff_url . '&op=' . MERGE_MOD_FILE, 'U_VIEW_NEW_FILE' => $diff_url . '&op=' . MERGE_NEW_FILE, @@ -516,7 +516,7 @@ class install_update extends module if ($update_list === false) { - trigger_error($user->lang['NO_UPDATE_INFO'], E_USER_ERROR); + trigger_error(phpbb::$user->lang['NO_UPDATE_INFO'], E_USER_ERROR); } // Check if the conflicts data is valid @@ -564,7 +564,7 @@ class install_update extends module // Check number of conflicting files, they need to be equal. For modified files the number can differ if (sizeof($update_list['conflict']) != sizeof($conflicts)) { - trigger_error($user->lang['MERGE_SELECT_ERROR'], E_USER_ERROR); + trigger_error(phpbb::$user->lang['MERGE_SELECT_ERROR'], E_USER_ERROR); } // Before we do anything, let us diff the files and store the raw file information "somewhere" @@ -622,8 +622,8 @@ class install_update extends module $template->assign_vars(array( 'S_IN_PROGRESS' => true, - 'L_IN_PROGRESS' => $user->lang['MERGING_FILES'], - 'L_IN_PROGRESS_EXPLAIN' => $user->lang['MERGING_FILES_EXPLAIN'], + 'L_IN_PROGRESS' => phpbb::$user->lang['MERGING_FILES'], + 'L_IN_PROGRESS_EXPLAIN' => phpbb::$user->lang['MERGING_FILES_EXPLAIN'], )); return; @@ -753,7 +753,7 @@ class install_update extends module // To ease the update process create a file location map $update_list = phpbb::$acm->get('update_list'); - $script_path = (phpbb::$config['force_server_vars']) ? ((phpbb::$config['script_path'] == '/') ? '/' : phpbb::$config['script_path'] . '/') : $user->page['root_script_path']; + $script_path = (phpbb::$config['force_server_vars']) ? ((phpbb::$config['script_path'] == '/') ? '/' : phpbb::$config['script_path'] . '/') : phpbb::$user->page['root_script_path']; foreach ($update_list as $status => $files) { @@ -847,8 +847,8 @@ class install_update extends module { $template->assign_block_vars('data', array( 'DATA' => $data, - 'NAME' => $user->lang[strtoupper($method . '_' . $data)], - 'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], + 'NAME' => phpbb::$user->lang[strtoupper($method . '_' . $data)], + 'EXPLAIN' => phpbb::$user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], 'DEFAULT' => (request_var($data, false)) ? request_var($data, '') : $default )); } @@ -856,7 +856,7 @@ class install_update extends module $template->assign_vars(array( 'S_CONNECTION_SUCCESS' => ($test_ftp_connection && $test_connection === true) ? true : false, 'S_CONNECTION_FAILED' => ($test_ftp_connection && $test_connection !== true) ? true : false, - 'ERROR_MSG' => ($test_ftp_connection && $test_connection !== true) ? $user->lang[$test_connection] : '', + 'ERROR_MSG' => ($test_ftp_connection && $test_connection !== true) ? phpbb::$user->lang[$test_connection] : '', 'S_FTP_UPLOAD' => true, 'UPLOAD_METHOD' => $method, @@ -1004,8 +1004,6 @@ class install_update extends module */ function show_diff(&$update_list) { - global $template, $user; - $this->tpl_name = 'install_update_diff'; // Got the diff template itself updated? If so, we are able to directly use it @@ -1032,13 +1030,13 @@ class install_update extends module if (empty($found_entry)) { - trigger_error($user->lang['FILE_DIFF_NOT_ALLOWED'], E_USER_ERROR); + trigger_error(phpbb::$user->lang['FILE_DIFF_NOT_ALLOWED'], E_USER_ERROR); } // If the status is 'up_to_date' then we do not need to show a diff if ($status == 'up_to_date') { - trigger_error($user->lang['FILE_ALREADY_UP_TO_DATE'], E_USER_ERROR); + trigger_error(phpbb::$user->lang['FILE_ALREADY_UP_TO_DATE'], E_USER_ERROR); } $original_file = ($found_entry['custom']) ? $found_entry['original'] : $file; @@ -1138,7 +1136,7 @@ class install_update extends module $diff_mode_options = ''; foreach (array('side_by_side', 'inline', 'unified', 'raw') as $option) { - $diff_mode_options .= ''; + $diff_mode_options .= ''; } // Now the correct renderer @@ -1166,8 +1164,6 @@ class install_update extends module */ function get_update_structure(&$update_list) { - global $user; - if ($update_list === false) { $update_list = array( @@ -1213,7 +1209,7 @@ class install_update extends module // Make sure the update files are consistent by checking if the file is in new_files... if (!file_exists($this->new_location . $file)) { - trigger_error($user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); + trigger_error(phpbb::$user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); } // If the file exists within the old directory the file got removed and we will write it back @@ -1293,8 +1289,6 @@ class install_update extends module */ function make_update_diff(&$update_list, $original_file, $file, $custom = false) { - global $user; - $update_ary = array('filename' => $file, 'custom' => $custom); if ($custom) @@ -1338,7 +1332,7 @@ class install_update extends module // Check for existance, else abort immediately if (!file_exists($this->old_location . $original_file) || !file_exists($this->new_location . $original_file)) { - trigger_error($user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); + trigger_error(phpbb::$user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); } $tmp = array( @@ -1470,8 +1464,6 @@ class install_update extends module */ function get_file($mode) { - global $user, $db; - $errstr = ''; $errno = 0; @@ -1510,7 +1502,7 @@ class install_update extends module include(PHPBB_ROOT_PATH . 'install/update/index.php'); $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; - $errstr = ($info === false) ? $user->lang['WRONG_INFO_FILE_FORMAT'] : ''; + $errstr = ($info === false) ? phpbb::$user->lang['WRONG_INFO_FILE_FORMAT'] : ''; if ($info !== false) { -- cgit v1.2.1 From 84f795e9fbd172924280593d575bf4587c9b40e5 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 18:06:05 +0000 Subject: $db-> to phpbb::$db-> git-svn-id: file:///svn/phpbb/trunk@9336 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 19cf3051c9..2040bf8dd2 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -414,9 +414,9 @@ class install_update extends module $sql = 'SELECT * FROM ' . STYLES_THEME_TABLE . " WHERE theme_name = 'prosilver'"; - $result = $db->sql_query($sql); - $theme = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $theme = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); if ($theme) { @@ -461,17 +461,17 @@ class install_update extends module 'theme_data' => $theme['theme_data'] ); - $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . ' WHERE theme_id = ' . $theme['theme_id']; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); } } - $db->sql_return_on_error(true); - $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); - $db->sql_return_on_error(false); + phpbb::$db->sql_return_on_error(true); + phpbb::$db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); + phpbb::$db->sql_return_on_error(false); phpbb::$acm->purge(); } @@ -1513,14 +1513,14 @@ class install_update extends module $sql = 'SELECT template_name, template_path FROM ' . STYLES_TEMPLATE_TABLE . " WHERE LOWER(template_name) NOT IN ('subsilver2', 'prosilver')"; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); $templates = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $templates[] = $row; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); if (sizeof($templates)) { -- cgit v1.2.1 From b27add94f8eb36d5e740afadf5306c48873736f9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 18:56:09 +0000 Subject: $template to phpbb::$template git-svn-id: file:///svn/phpbb/trunk@9337 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 85 ++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 43 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 2040bf8dd2..b815e36e29 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -94,7 +94,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_template('../adm/style', 'admin'); + phpbb::$template->set_custom_template('../adm/style', 'admin'); // Get current and latest version if (($latest_version = phpbb::$acm->get('version_info')) === false) @@ -115,10 +115,10 @@ class install_update extends module // Check for a valid update directory, else point the user to the phpbb.com website if (!file_exists(PHPBB_ROOT_PATH . 'install/update') || !file_exists(PHPBB_ROOT_PATH . 'install/update/index.php') || !file_exists($this->old_location) || !file_exists($this->new_location)) { - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_ERROR' => true, - 'ERROR_MSG' => ($up_to_date) ? phpbb::$user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf(phpbb::$user->lang['NO_UPDATE_FILES_OUTDATED'], phpbb::$config['version'], $this->current_version, $this->latest_version)) - ); + 'ERROR_MSG' => ($up_to_date) ? phpbb::$user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf(phpbb::$user->lang['NO_UPDATE_FILES_OUTDATED'], phpbb::$config['version'], $this->current_version, $this->latest_version), + )); return; } @@ -129,10 +129,10 @@ class install_update extends module // Since admins are able to run the update/checks more than once we only check if the current version is lower or equal than the version to which we update to. if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '>')) { - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_ERROR' => true, - 'ERROR_MSG' => sprintf(phpbb::$user->lang['INCOMPATIBLE_UPDATE_FILES'], phpbb::$config['version'], $this->update_info['version']['from'], $this->update_info['version']['to'])) - ); + 'ERROR_MSG' => sprintf(phpbb::$user->lang['INCOMPATIBLE_UPDATE_FILES'], phpbb::$config['version'], $this->update_info['version']['from'], $this->update_info['version']['to']), + )); return; } @@ -142,10 +142,10 @@ class install_update extends module { $this->unequal_version = true; - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_WARNING' => true, - 'WARNING_MSG' => sprintf(phpbb::$user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version)) - ); + 'WARNING_MSG' => sprintf(phpbb::$user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version), + )); } if ($this->test_update === false) @@ -186,7 +186,7 @@ class install_update extends module case 'intro': $this->page_title = 'UPDATE_INSTALLATION'; - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_INTRO' => true, 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=version_check"), )); @@ -199,7 +199,7 @@ class install_update extends module case 'version_check': $this->page_title = 'STAGE_VERSION_CHECK'; - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_UP_TO_DATE' => $up_to_date, 'S_VERSION_CHECK' => true, @@ -207,13 +207,13 @@ class install_update extends module 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), 'LATEST_VERSION' => $this->latest_version, - 'CURRENT_VERSION' => $this->current_version) - ); + 'CURRENT_VERSION' => $this->current_version, + )); // Print out version the update package updates to if ($this->unequal_version) { - $template->assign_var('PACKAGE_VERSION', $this->update_info['version']['to']); + phpbb::$template->assign_var('PACKAGE_VERSION', $this->update_info['version']['to']); } break; @@ -244,7 +244,7 @@ class install_update extends module phpbb::$acm->purge(); // Redirect the user to the database update script with some explanations... - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_DB_UPDATE' => true, 'S_DB_UPDATE_FINISHED' => (phpbb::$config['version'] == $this->update_info['version']['to']) ? true : false, 'U_DB_UPDATE' => append_sid('install/database_update', 'type=1&language=' . phpbb::$user->data['user_lang']), @@ -302,7 +302,7 @@ class install_update extends module $refresh_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"); meta_refresh(2, $refresh_url); - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_IN_PROGRESS' => true, 'S_COLLECTED' => (int) $update_list['status'], 'S_TO_COLLECT' => sizeof($this->update_info['files']), @@ -322,10 +322,10 @@ class install_update extends module if (sizeof($update_list['no_update'])) { - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_NO_UPDATE_FILES' => true, - 'NO_UPDATE_FILES' => implode(', ', array_map('htmlspecialchars', $update_list['no_update']))) - ); + 'NO_UPDATE_FILES' => implode(', ', array_map('htmlspecialchars', $update_list['no_update'])), + )); } // Now assign the list to the template @@ -336,14 +336,13 @@ class install_update extends module continue; } - $template->assign_block_vars('files', array( + phpbb::$template->assign_block_vars('files', array( 'S_STATUS' => true, 'STATUS' => $status, 'L_STATUS' => phpbb::$user->lang['STATUS_' . strtoupper($status)], 'TITLE' => phpbb::$user->lang['FILES_' . strtoupper($status)], 'EXPLAIN' => phpbb::$user->lang['FILES_' . strtoupper($status) . '_EXPLAIN'], - ) - ); + )); foreach ($filelist as $file_struct) { @@ -363,7 +362,7 @@ class install_update extends module $diff_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check&action=diff&status=$status&file=" . urlencode($file_struct['filename'])); - $template->assign_block_vars('files', array( + phpbb::$template->assign_block_vars('files', array( 'STATUS' => $status, 'FILENAME' => $filename, @@ -396,7 +395,7 @@ class install_update extends module } } - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_FILE_CHECK' => true, 'S_ALL_UP_TO_DATE' => $all_up_to_date, 'S_VERSION_UP_TO_DATE' => $up_to_date, @@ -620,7 +619,7 @@ class install_update extends module $redirect_url = append_sid($this->p_master->module_url, "mode=$mode&sub=update_files&" . implode('&', $params)); meta_refresh(3, $redirect_url); - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_IN_PROGRESS' => true, 'L_IN_PROGRESS' => phpbb::$user->lang['MERGING_FILES'], 'L_IN_PROGRESS_EXPLAIN' => phpbb::$user->lang['MERGING_FILES_EXPLAIN'], @@ -744,12 +743,12 @@ class install_update extends module $radio_buttons .= ''; } - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_DOWNLOAD_FILES' => true, 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), 'RADIO_BUTTONS' => $radio_buttons, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) - ); + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + )); // To ease the update process create a file location map $update_list = phpbb::$acm->get('update_list'); @@ -769,7 +768,7 @@ class install_update extends module continue; } - $template->assign_block_vars('location', array( + phpbb::$template->assign_block_vars('location', array( 'SOURCE' => htmlspecialchars($file_struct['filename']), 'DESTINATION' => $script_path . htmlspecialchars($file_struct['filename']), )); @@ -845,7 +844,7 @@ class install_update extends module $requested_data = call_user_func(array($method, 'data')); foreach ($requested_data as $data => $default) { - $template->assign_block_vars('data', array( + phpbb::$template->assign_block_vars('data', array( 'DATA' => $data, 'NAME' => phpbb::$user->lang[strtoupper($method . '_' . $data)], 'EXPLAIN' => phpbb::$user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], @@ -853,7 +852,7 @@ class install_update extends module )); } - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_CONNECTION_SUCCESS' => ($test_ftp_connection && $test_connection === true) ? true : false, 'S_CONNECTION_FAILED' => ($test_ftp_connection && $test_connection !== true) ? true : false, 'ERROR_MSG' => ($test_ftp_connection && $test_connection !== true) ? phpbb::$user->lang[$test_connection] : '', @@ -987,10 +986,10 @@ class install_update extends module { $transfer->close_session(); - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_UPLOAD_SUCCESS' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check")) - ); + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), + )); return; } @@ -1054,7 +1053,7 @@ class install_update extends module $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : PHPBB_ROOT_PATH . $file); - $template->assign_var('S_DIFF_NEW_FILE', true); + phpbb::$template->assign_var('S_DIFF_NEW_FILE', true); $diff_mode = 'inline'; $this->page_title = 'VIEWING_FILE_CONTENTS'; @@ -1074,7 +1073,7 @@ class install_update extends module unset($tmp); - $template->assign_var('S_DIFF_NEW_FILE', true); + phpbb::$template->assign_var('S_DIFF_NEW_FILE', true); $diff_mode = 'inline'; $this->page_title = 'VIEWING_FILE_CONTENTS'; @@ -1084,10 +1083,10 @@ class install_update extends module $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_DIFF_CONFLICT_FILE' => true, - 'NUM_CONFLICTS' => $diff->merged_output(false, false, false, true)) - ); + 'NUM_CONFLICTS' => $diff->merged_output(false, false, false, true), + )); $diff = $this->return_diff(PHPBB_ROOT_PATH . $file, $diff->merged_output()); break; @@ -1105,7 +1104,7 @@ class install_update extends module $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : PHPBB_ROOT_PATH . $file); - $template->assign_var('S_DIFF_NEW_FILE', true); + phpbb::$template->assign_var('S_DIFF_NEW_FILE', true); $diff_mode = 'inline'; $this->page_title = 'VIEWING_FILE_CONTENTS'; @@ -1126,7 +1125,7 @@ class install_update extends module $diff = $this->return_diff(array(), $this->new_location . $original_file); - $template->assign_var('S_DIFF_NEW_FILE', true); + phpbb::$template->assign_var('S_DIFF_NEW_FILE', true); $diff_mode = 'inline'; $this->page_title = 'VIEWING_FILE_CONTENTS'; @@ -1149,7 +1148,7 @@ class install_update extends module $renderer = new $render_class(); - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'DIFF_CONTENT' => $renderer->get_diff_content($diff), 'DIFF_MODE' => $diff_mode, 'S_DIFF_MODE_OPTIONS' => $diff_mode_options, -- cgit v1.2.1 From 4cbf6bc703bdadf716197b68a89b3438247ff022 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Mar 2009 16:34:26 +0000 Subject: Merge most changes from 3.0.x branch since the 25th december. (Captcha changes for refreshing captcha image not included) git-svn-id: file:///svn/phpbb/trunk@9404 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 55 +++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 15 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index b815e36e29..383a4d8cca 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -148,6 +148,12 @@ class install_update extends module )); } + // Fill DB version + if (empty(phpbb::$config['dbms_version'])) + { + set_config('dbms_version', phpbb::$db->sql_server_info(true)); + } + if ($this->test_update === false) { // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present @@ -336,13 +342,14 @@ class install_update extends module continue; } - phpbb::$template->assign_block_vars('files', array( +/* phpbb::$template->assign_block_vars('files', array( 'S_STATUS' => true, 'STATUS' => $status, 'L_STATUS' => phpbb::$user->lang['STATUS_' . strtoupper($status)], 'TITLE' => phpbb::$user->lang['FILES_' . strtoupper($status)], 'EXPLAIN' => phpbb::$user->lang['FILES_' . strtoupper($status) . '_EXPLAIN'], - )); + ) + );*/ foreach ($filelist as $file_struct) { @@ -362,7 +369,7 @@ class install_update extends module $diff_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check&action=diff&status=$status&file=" . urlencode($file_struct['filename'])); - phpbb::$template->assign_block_vars('files', array( + phpbb::$template->assign_block_vars($status, array( 'STATUS' => $status, 'FILENAME' => $filename, @@ -649,7 +656,7 @@ class install_update extends module default: $diff = $this->return_diff($this->old_location . $original_filename, PHPBB_ROOT_PATH . $file_struct['filename'], $this->new_location . $original_filename); - $contents = implode("\n", $diff->merged_output()); + $contents = implode("\n", $diff->merged_new_output()); unset($diff); break; } @@ -1015,7 +1022,7 @@ class install_update extends module $status = request_var('status', ''); $file = request_var('file', ''); - $diff_mode = request_var('diff_mode', 'side_by_side'); + $diff_mode = request_var('diff_mode', 'inline'); // First of all make sure the file is within our file update list with the correct status $found_entry = array(); @@ -1059,9 +1066,7 @@ class install_update extends module break; - case MERGE_NEW_FILE: - case MERGE_MOD_FILE: - +/* $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); $tmp = array( @@ -1078,17 +1083,37 @@ class install_update extends module $this->page_title = 'VIEWING_FILE_CONTENTS'; break; - - default: +*/ + // Merge differences and use new phpBB code for conflicted blocks + case MERGE_NEW_FILE: + case MERGE_MOD_FILE: $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); phpbb::$template->assign_vars(array( 'S_DIFF_CONFLICT_FILE' => true, - 'NUM_CONFLICTS' => $diff->merged_output(false, false, false, true), + 'NUM_CONFLICTS' => $diff->get_num_conflicts(), )); - $diff = $this->return_diff(PHPBB_ROOT_PATH . $file, $diff->merged_output()); + $diff = $this->return_diff(PHPBB_ROOT_PATH . $file, ($option == MERGE_NEW_FILE) ? $diff->merged_new_output() : $diff->merged_orig_output()); + break; + + // Download conflict file + default: + + $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $file, $this->new_location . $original_file); + + header('Pragma: no-cache'); + header("Content-Type: application/octetstream; name=\"$file\""); + header("Content-disposition: attachment; filename=$file"); + + @set_time_limit(0); + + echo implode("\n", $diff->get_conflicts_content()); + + flush(); + exit; + break; } @@ -1391,9 +1416,9 @@ class install_update extends module unset($tmp); - if ($diff->merged_output(false, false, false, true)) + if ($diff->get_num_conflicts()) { - $update_ary['conflicts'] = $diff->_conflicting_blocks; + $update_ary['conflicts'] = $diff->get_num_conflicts(); // There is one special case... users having merged with a conflicting file... we need to check this $tmp = array( @@ -1420,7 +1445,7 @@ class install_update extends module $tmp = array( 'file1' => file_get_contents(PHPBB_ROOT_PATH . $file), - 'file2' => implode("\n", $diff->merged_output()), + 'file2' => implode("\n", $diff->merged_new_output()), ); // now compare the merged output with the original file to see if the modified file is up to date -- cgit v1.2.1 From 7909b729bbb1facce975b10da28754eb157723aa Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sun, 12 Jul 2009 15:44:43 +0000 Subject: unified the transfer routines from the updater and from acp_language.php. still needs work.. git-svn-id: file:///svn/phpbb/trunk@9751 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 287 ++++----------------------------------- 1 file changed, 23 insertions(+), 264 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 383a4d8cca..1cc38c5a94 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -182,7 +182,7 @@ class install_update extends module $this->include_file('includes/diff/renderer.' . PHP_EXT); // Make sure we stay at the file check if checking the files again - if (phpbb_request::variable('check_again', false, false, phpbb_request::POST)) + if (phpbb_request::variable('clean_up', false, false, phpbb_request::POST)) { $sub = $this->p_master->sub = 'file_check'; } @@ -271,7 +271,7 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = (phpbb_request::variable('check_again', false, false, phpbb_request::POST)) ? false : phpbb::$acm->get('update_list'); + $update_list = (phpbb_request::variable('clean_up', false, false, phpbb_request::POST)) ? false : phpbb::$acm->get('update_list'); $modified = ($update_list !== false) ? phpbb::$acm->get_modified_date('data', 'update_list') : 0; // Make sure the list is up-to-date @@ -721,284 +721,43 @@ class install_update extends module $file_list['status'] = -1; phpbb::$acm->put('diff_files', $file_list); - if (request_var('download', false)) - { - $this->include_file('includes/functions_compress.' . PHP_EXT); - - $use_method = request_var('use_method', ''); - $methods = array('.tar'); - - $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib'); - foreach ($available_methods as $type => $module) - { - if (!@extension_loaded($module)) - { - continue; - } - - $methods[] = $type; - } - - // Let the user decide in which format he wants to have the pack - if (!$use_method) - { - $this->page_title = 'SELECT_DOWNLOAD_FORMAT'; - - $radio_buttons = ''; - foreach ($methods as $method) - { - $radio_buttons .= ''; - } - - phpbb::$template->assign_vars(array( - 'S_DOWNLOAD_FILES' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), - 'RADIO_BUTTONS' => $radio_buttons, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - )); + $this->include_file('includes/functions_compress.' . $phpEx); + $this->include_file('includes/functions_transfer.' . $phpEx); - // To ease the update process create a file location map - $update_list = phpbb::$acm->get('update_list'); - $script_path = (phpbb::$config['force_server_vars']) ? ((phpbb::$config['script_path'] == '/') ? '/' : phpbb::$config['script_path'] . '/') : phpbb::$user->page['root_script_path']; - - foreach ($update_list as $status => $files) - { - if ($status == 'up_to_date' || $status == 'no_update' || $status == 'status') - { - continue; - } - - foreach ($files as $file_struct) - { - if (in_array($file_struct['filename'], $no_update)) - { - continue; - } - - phpbb::$template->assign_block_vars('location', array( - 'SOURCE' => htmlspecialchars($file_struct['filename']), - 'DESTINATION' => $script_path . htmlspecialchars($file_struct['filename']), - )); - } - } - return; - } - - if (!in_array($use_method, $methods)) - { - $use_method = '.tar'; - } - - $update_mode = 'download'; - } - else - { - $this->include_file('includes/functions_transfer.' . PHP_EXT); - - // Choose FTP, if not available use fsock... - $method = basename(request_var('method', '')); - $submit = phpbb_request::is_set_post('submit'); - $test_ftp_connection = request_var('test_connection', ''); - - if (!$method || !class_exists($method)) - { - $method = 'ftp'; - $methods = transfer::methods(); - - if (!in_array('ftp', $methods)) - { - $method = $methods[0]; - } - } - - $test_connection = false; - if ($test_ftp_connection || $submit) - { - $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); - $test_connection = $transfer->open_session(); - - // Make sure that the directory is correct by checking for the existence of common.php - if ($test_connection === true) - { - // Check for common.php file - if (!$transfer->file_exists(PHPBB_ROOT_PATH, 'common.' . PHP_EXT)) - { - $test_connection = 'ERR_WRONG_PATH_TO_PHPBB'; - } - } - - $transfer->close_session(); - - // Make sure the login details are correct before continuing - if ($submit && $test_connection !== true) - { - $submit = false; - $test_ftp_connection = true; - } - } - - $s_hidden_fields .= build_hidden_fields(array('method' => $method)); - - if (!$submit) - { - $this->page_title = 'SELECT_FTP_SETTINGS'; - - if (!class_exists($method)) - { - trigger_error('Method does not exist.', E_USER_ERROR); - } - - $requested_data = call_user_func(array($method, 'data')); - foreach ($requested_data as $data => $default) - { - phpbb::$template->assign_block_vars('data', array( - 'DATA' => $data, - 'NAME' => phpbb::$user->lang[strtoupper($method . '_' . $data)], - 'EXPLAIN' => phpbb::$user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], - 'DEFAULT' => (request_var($data, false)) ? request_var($data, '') : $default - )); - } - - phpbb::$template->assign_vars(array( - 'S_CONNECTION_SUCCESS' => ($test_ftp_connection && $test_connection === true) ? true : false, - 'S_CONNECTION_FAILED' => ($test_ftp_connection && $test_connection !== true) ? true : false, - 'ERROR_MSG' => ($test_ftp_connection && $test_connection !== true) ? phpbb::$user->lang[$test_connection] : '', - - 'S_FTP_UPLOAD' => true, - 'UPLOAD_METHOD' => $method, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), - 'U_DOWNLOAD_METHOD' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files&download=1"), - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - )); - - return; - } - - $update_mode = 'upload'; - } - - // Now update the installation or download the archive... - $download_filename = 'update_' . $this->update_info['version']['from'] . '_to_' . $this->update_info['version']['to']; - $archive_filename = $download_filename . '_' . time() . '_' . unique_id(); - - // Now init the connection - if ($update_mode == 'download') - { - if ($use_method == '.zip') - { - $compress = new compress_zip('w', PHPBB_ROOT_PATH . 'store/' . $archive_filename . $use_method); - } - else - { - $compress = new compress_tar('w', PHPBB_ROOT_PATH . 'store/' . $archive_filename . $use_method, $use_method); - } - } - else - { - $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); - $transfer->open_session(); - } - - // Ok, go through the update list and do the operations based on their status - foreach ($update_list as $status => $files) + $module_url = append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"); + foreach ($update_list as &$files) { if (!is_array($files)) { continue; } - - foreach ($files as $file_struct) + for ($i = 0, $size = sizeof($files); $i < $size; $i++) { // Skip this file if the user selected to not update it - if (in_array($file_struct['filename'], $no_update)) - { - continue; - } - - $original_filename = ($file_struct['custom']) ? $file_struct['original'] : $file_struct['filename']; - - switch ($status) + if (in_array($files[$i]['filename'], $no_update)) { - case 'new': - case 'new_conflict': - case 'not_modified': - - if ($update_mode == 'download') - { - $compress->add_custom_file($this->new_location . $original_filename, $file_struct['filename']); - } - else - { - if ($status != 'new') - { - $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); - } - - // New directory too? - $dirname = dirname($file_struct['filename']); - - if ($dirname && !file_exists(PHPBB_ROOT_PATH . $dirname)) - { - $transfer->make_dir($dirname); - } - - $transfer->copy_file($this->new_location . $original_filename, $file_struct['filename']); - } - break; - - case 'modified': - - $contents = base64_decode(phpbb::$acm->get($file_list[$file_struct['filename']])); - - if ($update_mode == 'download') - { - $compress->add_data($contents, $file_struct['filename']); - } - else - { - // @todo add option to specify if a backup file should be created? - $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); - $transfer->write_file($file_struct['filename'], $contents); - } - break; - - case 'conflict': - - $contents = base64_decode(phpbb::$acm->get($file_list[$file_struct['filename']])); - - if ($update_mode == 'download') - { - $compress->add_data($contents, $file_struct['filename']); - } - else - { - $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); - $transfer->write_file($file_struct['filename'], $contents); - } - break; + unset($files[$i]['filename']); } } + $files = array_values($files); } + unset($files); + $new_location = $this->new_location; + $download_filename = 'update_' . $this->update_info['version']['from'] . '_to_' . $this->update_info['version']['to']; + $check_params = "mode=$mode&sub=file_check"; - if ($update_mode == 'download') + $temp = process_transfer($module_url, $update_list, $new_location, $download_filename); + if (is_string($temp)) { - $compress->close(); - - $compress->download($archive_filename, $download_filename); - @unlink(PHPBB_ROOT_PATH . 'store/' . $archive_filename . $use_method); - - exit; + $this->page_title = $temp; } - else - { - $transfer->close_session(); - phpbb::$template->assign_vars(array( - 'S_UPLOAD_SUCCESS' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), - )); - return; - } + phpbb::$template->assign_vars(array( + 'S_UPDATE_OPTIONS' => true, + 'S_CHECK_AGAIN' => true, + // 'U_INITIAL_ACTION' isn't set because it's taken care of in the S_FILE_CHECK block of install_update.html + 'U_FINAL_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files")) + ); break; -- cgit v1.2.1 From bf8ac19eaa8d74f9dfd6d597190f5664e7339382 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Oct 2009 18:13:59 +0000 Subject: Move trunk/phpBB to old_trunk/phpBB git-svn-id: file:///svn/phpbb/trunk@10210 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 1386 -------------------------------------- 1 file changed, 1386 deletions(-) delete mode 100644 phpBB/install/install_update.php (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php deleted file mode 100644 index 1cc38c5a94..0000000000 --- a/phpBB/install/install_update.php +++ /dev/null @@ -1,1386 +0,0 @@ - 'update', - 'module_title' => 'UPDATE', - 'module_filename' => substr(basename(__FILE__), 0, -strlen(PHP_EXT)-1), - 'module_order' => 30, - 'module_subs' => '', - 'module_stages' => array('INTRO', 'VERSION_CHECK', 'UPDATE_DB', 'FILE_CHECK', 'UPDATE_FILES'), - 'module_reqs' => '' - ); -} - -/** -* Update Installation -* @package install -*/ -class install_update extends module -{ - var $p_master; - var $update_info; - - var $old_location; - var $new_location; - var $latest_version; - var $current_version; - var $unequal_version; - - // Set to false - var $test_update = false; - - function install_update(&$p_master) - { - $this->p_master = &$p_master; - } - - function main($mode, $sub) - { - require PHPBB_ROOT_PATH . 'common.' . PHP_EXT; - - $this->tpl_name = 'install_update'; - $this->page_title = 'UPDATE_INSTALLATION'; - $this->unequal_version = false; - - $this->old_location = PHPBB_ROOT_PATH . 'install/update/old/'; - $this->new_location = PHPBB_ROOT_PATH . 'install/update/new/'; - - // Force template recompile - phpbb::$config['load_tplcompile'] = 1; - - // Start session management - phpbb::$user->session_begin(); - phpbb::$acl->init(phpbb::$user->data); - phpbb::$user->setup('viewforum'); - - // If we are within the intro page we need to make sure we get up-to-date version info - if ($sub == 'intro') - { - phpbb::$acm->destroy('version_info'); - } - - // Set custom template again. ;) - phpbb::$template->set_custom_template('../adm/style', 'admin'); - - // Get current and latest version - if (($latest_version = phpbb::$acm->get('version_info')) === false) - { - $this->latest_version = $this->get_file('version_info'); - phpbb::$acm->put('version_info', $this->latest_version); - } - else - { - $this->latest_version = $latest_version; - } - - // For the current version we trick a bit. ;) - $this->current_version = (!empty(phpbb::$config['version_update_from'])) ? phpbb::$config['version_update_from'] : phpbb::$config['version']; - - $up_to_date = (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->latest_version)), '<')) ? false : true; - - // Check for a valid update directory, else point the user to the phpbb.com website - if (!file_exists(PHPBB_ROOT_PATH . 'install/update') || !file_exists(PHPBB_ROOT_PATH . 'install/update/index.php') || !file_exists($this->old_location) || !file_exists($this->new_location)) - { - phpbb::$template->assign_vars(array( - 'S_ERROR' => true, - 'ERROR_MSG' => ($up_to_date) ? phpbb::$user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf(phpbb::$user->lang['NO_UPDATE_FILES_OUTDATED'], phpbb::$config['version'], $this->current_version, $this->latest_version), - )); - - return; - } - - $this->update_info = $this->get_file('update_info'); - - // Make sure the update directory holds the correct information - // Since admins are able to run the update/checks more than once we only check if the current version is lower or equal than the version to which we update to. - if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '>')) - { - phpbb::$template->assign_vars(array( - 'S_ERROR' => true, - 'ERROR_MSG' => sprintf(phpbb::$user->lang['INCOMPATIBLE_UPDATE_FILES'], phpbb::$config['version'], $this->update_info['version']['from'], $this->update_info['version']['to']), - )); - - return; - } - - // Check if the update files stored are for the latest version... - if ($this->latest_version != $this->update_info['version']['to']) - { - $this->unequal_version = true; - - phpbb::$template->assign_vars(array( - 'S_WARNING' => true, - 'WARNING_MSG' => sprintf(phpbb::$user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version), - )); - } - - // Fill DB version - if (empty(phpbb::$config['dbms_version'])) - { - set_config('dbms_version', phpbb::$db->sql_server_info(true)); - } - - if ($this->test_update === false) - { - // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present - if (in_array('adm/style/install_update.html', $this->update_info['files'])) - { - $this->tpl_name = '../../install/update/new/adm/style/install_update'; - } - - // What about the language file? Got it updated? - if (in_array('language/en/install.php', $this->update_info['files'])) - { - $lang = array(); - include($this->new_location . 'language/en/install.php'); - // only add new keys to user's language in english - $new_keys = array_diff(array_keys($lang), array_keys(phpbb::$user->lang)); - foreach ($new_keys as $i => $new_key) - { - phpbb::$user->lang[$new_key] = $lang[$new_key]; - } - } - } - - // Include renderer and engine - $this->include_file('includes/diff/diff.' . PHP_EXT); - $this->include_file('includes/diff/engine.' . PHP_EXT); - $this->include_file('includes/diff/renderer.' . PHP_EXT); - - // Make sure we stay at the file check if checking the files again - if (phpbb_request::variable('clean_up', false, false, phpbb_request::POST)) - { - $sub = $this->p_master->sub = 'file_check'; - } - - switch ($sub) - { - case 'intro': - $this->page_title = 'UPDATE_INSTALLATION'; - - phpbb::$template->assign_vars(array( - 'S_INTRO' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=version_check"), - )); - - // Make sure the update list is destroyed. - phpbb::$acm->destroy('update_list'); - phpbb::$acm->destroy('diff_files'); - break; - - case 'version_check': - $this->page_title = 'STAGE_VERSION_CHECK'; - - phpbb::$template->assign_vars(array( - 'S_UP_TO_DATE' => $up_to_date, - 'S_VERSION_CHECK' => true, - - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), - - 'LATEST_VERSION' => $this->latest_version, - 'CURRENT_VERSION' => $this->current_version, - )); - - // Print out version the update package updates to - if ($this->unequal_version) - { - phpbb::$template->assign_var('PACKAGE_VERSION', $this->update_info['version']['to']); - } - - break; - - case 'update_db': - - // Make sure the database update is valid for the latest version - $valid = false; - $updates_to_version = ''; - - if (file_exists(PHPBB_ROOT_PATH . 'install/database_update.' . PHP_EXT)) - { - include_once(PHPBB_ROOT_PATH . 'install/database_update.' . PHP_EXT); - - if ($updates_to_version === $this->update_info['version']['to']) - { - $valid = true; - } - } - - // Should not happen at all - if (!$valid) - { - trigger_error(phpbb::$user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); - } - - // Just a precaution - phpbb::$acm->purge(); - - // Redirect the user to the database update script with some explanations... - phpbb::$template->assign_vars(array( - 'S_DB_UPDATE' => true, - 'S_DB_UPDATE_FINISHED' => (phpbb::$config['version'] == $this->update_info['version']['to']) ? true : false, - 'U_DB_UPDATE' => append_sid('install/database_update', 'type=1&language=' . phpbb::$user->data['user_lang']), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), - )); - - break; - - case 'file_check': - - // Make sure the previous file collection is no longer valid... - phpbb::$acm->destroy('diff_files'); - - $this->page_title = 'STAGE_FILE_CHECK'; - - // Now make sure our update list is correct if the admin refreshes - $action = request_var('action', ''); - - // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = (phpbb_request::variable('clean_up', false, false, phpbb_request::POST)) ? false : phpbb::$acm->get('update_list'); - $modified = ($update_list !== false) ? phpbb::$acm->get_modified_date('data', 'update_list') : 0; - - // Make sure the list is up-to-date - if ($update_list !== false) - { - $get_new_list = false; - foreach ($this->update_info['files'] as $file) - { - if (file_exists(PHPBB_ROOT_PATH . $file) && filemtime(PHPBB_ROOT_PATH . $file) > $modified) - { - $get_new_list = true; - break; - } - } - } - else - { - $get_new_list = true; - } - - if (!$get_new_list && $update_list['status'] != -1) - { - $get_new_list = true; - } - - if ($get_new_list) - { - $this->get_update_structure($update_list); - phpbb::$acm->put('update_list', $update_list); - - // Refresh the page if we are still not finished... - if ($update_list['status'] != -1) - { - $refresh_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"); - meta_refresh(2, $refresh_url); - - phpbb::$template->assign_vars(array( - 'S_IN_PROGRESS' => true, - 'S_COLLECTED' => (int) $update_list['status'], - 'S_TO_COLLECT' => sizeof($this->update_info['files']), - 'L_IN_PROGRESS' => phpbb::$user->lang['COLLECTING_FILE_DIFFS'], - 'L_IN_PROGRESS_EXPLAIN' => sprintf(phpbb::$user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files'])), - )); - - return; - } - } - - if ($action == 'diff') - { - $this->show_diff($update_list); - return; - } - - if (sizeof($update_list['no_update'])) - { - phpbb::$template->assign_vars(array( - 'S_NO_UPDATE_FILES' => true, - 'NO_UPDATE_FILES' => implode(', ', array_map('htmlspecialchars', $update_list['no_update'])), - )); - } - - // Now assign the list to the template - foreach ($update_list as $status => $filelist) - { - if ($status == 'no_update' || !sizeof($filelist) || $status == 'status') - { - continue; - } - -/* phpbb::$template->assign_block_vars('files', array( - 'S_STATUS' => true, - 'STATUS' => $status, - 'L_STATUS' => phpbb::$user->lang['STATUS_' . strtoupper($status)], - 'TITLE' => phpbb::$user->lang['FILES_' . strtoupper($status)], - 'EXPLAIN' => phpbb::$user->lang['FILES_' . strtoupper($status) . '_EXPLAIN'], - ) - );*/ - - foreach ($filelist as $file_struct) - { - $s_binary = (!empty($this->update_info['binary']) && in_array($file_struct['filename'], $this->update_info['binary'])) ? true : false; - - $filename = htmlspecialchars($file_struct['filename']); - if (strrpos($filename, '/') !== false) - { - $dir_part = substr($filename, 0, strrpos($filename, '/') + 1); - $file_part = substr($filename, strrpos($filename, '/') + 1); - } - else - { - $dir_part = ''; - $file_part = $filename; - } - - $diff_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check&action=diff&status=$status&file=" . urlencode($file_struct['filename'])); - - phpbb::$template->assign_block_vars($status, array( - 'STATUS' => $status, - - 'FILENAME' => $filename, - 'DIR_PART' => $dir_part, - 'FILE_PART' => $file_part, - 'NUM_CONFLICTS' => (isset($file_struct['conflicts'])) ? $file_struct['conflicts'] : 0, - - 'S_CUSTOM' => ($file_struct['custom']) ? true : false, - 'S_BINARY' => $s_binary, - 'CUSTOM_ORIGINAL' => ($file_struct['custom']) ? $file_struct['original'] : '', - - 'U_SHOW_DIFF' => $diff_url, - 'L_SHOW_DIFF' => ($status != 'up_to_date') ? phpbb::$user->lang['SHOW_DIFF_' . strtoupper($status)] : '', - - 'U_VIEW_MOD_FILE' => $diff_url . '&op=' . MERGE_MOD_FILE, - 'U_VIEW_NEW_FILE' => $diff_url . '&op=' . MERGE_NEW_FILE, - 'U_VIEW_NO_MERGE_MOD' => $diff_url . '&op=' . MERGE_NO_MERGE_MOD, - 'U_VIEW_NO_MERGE_NEW' => $diff_url . '&op=' . MERGE_NO_MERGE_NEW, - )); - } - } - - $all_up_to_date = true; - foreach ($update_list as $status => $filelist) - { - if ($status != 'up_to_date' && $status != 'custom' && $status != 'status' && sizeof($filelist)) - { - $all_up_to_date = false; - break; - } - } - - phpbb::$template->assign_vars(array( - 'S_FILE_CHECK' => true, - 'S_ALL_UP_TO_DATE' => $all_up_to_date, - 'S_VERSION_UP_TO_DATE' => $up_to_date, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), - 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), - )); - - if ($all_up_to_date) - { - // Add database update to log - add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->latest_version); - - // Refresh prosilver css data - this may cause some unhappy users, but - $sql = 'SELECT * - FROM ' . STYLES_THEME_TABLE . " - WHERE theme_name = 'prosilver'"; - $result = phpbb::$db->sql_query($sql); - $theme = phpbb::$db->sql_fetchrow($result); - phpbb::$db->sql_freeresult($result); - - if ($theme) - { - $recache = (empty($theme['theme_data'])) ? true : false; - $update_time = time(); - - // We test for stylesheet.css because it is faster and most likely the only file changed on common themes - if (!$recache && $theme['theme_mtime'] < @filemtime(PHPBB_ROOT_PATH . 'styles/' . $theme['theme_path'] . '/theme/stylesheet.css')) - { - $recache = true; - $update_time = @filemtime(PHPBB_ROOT_PATH . 'styles/' . $theme['theme_path'] . '/theme/stylesheet.css'); - } - else if (!$recache) - { - $last_change = $theme['theme_mtime']; - $dir = @opendir(PHPBB_ROOT_PATH . "styles/{$theme['theme_path']}/theme"); - - if ($dir) - { - while (($entry = readdir($dir)) !== false) - { - if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime(PHPBB_ROOT_PATH . "styles/{$theme['theme_path']}/theme/{$entry}")) - { - $recache = true; - break; - } - } - closedir($dir); - } - } - - if ($recache) - { - include_once(PHPBB_ROOT_PATH . 'includes/acp/acp_styles.' . PHP_EXT); - - $theme['theme_data'] = acp_styles::db_theme_data($theme); - $theme['theme_mtime'] = $update_time; - - // Save CSS contents - $sql_ary = array( - 'theme_mtime' => $theme['theme_mtime'], - 'theme_data' => $theme['theme_data'] - ); - - $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE theme_id = ' . $theme['theme_id']; - phpbb::$db->sql_query($sql); - - phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); - } - } - - phpbb::$db->sql_return_on_error(true); - phpbb::$db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); - phpbb::$db->sql_return_on_error(false); - - phpbb::$acm->purge(); - } - - break; - - case 'update_files': - - $this->page_title = 'STAGE_UPDATE_FILES'; - - $s_hidden_fields = ''; - $params = array(); - $conflicts = request_var('conflict', array('' => 0)); - $modified = request_var('modified', array('' => 0)); - - foreach ($conflicts as $filename => $merge_option) - { - $s_hidden_fields .= ''; - $params[] = 'conflict[' . urlencode($filename) . ']=' . urlencode($merge_option); - } - - foreach ($modified as $filename => $merge_option) - { - if (!$merge_option) - { - continue; - } - $s_hidden_fields .= ''; - $params[] = 'modified[' . urlencode($filename) . ']=' . urlencode($merge_option); - } - - $no_update = request_var('no_update', array(0 => '')); - - foreach ($no_update as $index => $filename) - { - $s_hidden_fields .= ''; - $params[] = 'no_update[]=' . urlencode($filename); - } - - // Before the user is choosing his preferred method, let's create the content list... - $update_list = phpbb::$acm->get('update_list'); - - if ($update_list === false) - { - trigger_error(phpbb::$user->lang['NO_UPDATE_INFO'], E_USER_ERROR); - } - - // Check if the conflicts data is valid - if (sizeof($conflicts)) - { - $conflict_filenames = array(); - foreach ($update_list['conflict'] as $files) - { - $conflict_filenames[] = $files['filename']; - } - - $new_conflicts = array(); - foreach ($conflicts as $filename => $diff_method) - { - if (in_array($filename, $conflict_filenames)) - { - $new_conflicts[$filename] = $diff_method; - } - } - - $conflicts = $new_conflicts; - } - - // Build list for modifications - if (sizeof($modified)) - { - $modified_filenames = array(); - foreach ($update_list['modified'] as $files) - { - $modified_filenames[] = $files['filename']; - } - - $new_modified = array(); - foreach ($modified as $filename => $diff_method) - { - if (in_array($filename, $modified_filenames)) - { - $new_modified[$filename] = $diff_method; - } - } - - $modified = $new_modified; - } - - // Check number of conflicting files, they need to be equal. For modified files the number can differ - if (sizeof($update_list['conflict']) != sizeof($conflicts)) - { - trigger_error(phpbb::$user->lang['MERGE_SELECT_ERROR'], E_USER_ERROR); - } - - // Before we do anything, let us diff the files and store the raw file information "somewhere" - $get_files = false; - $file_list = phpbb::$acm->get('diff_files'); - - if ($file_list === false || $file_list['status'] != -1) - { - $get_files = true; - } - - if ($get_files) - { - if ($file_list === false) - { - $file_list = array( - 'status' => 0, - ); - } - - $processed = 0; - foreach ($update_list as $status => $files) - { - if (!is_array($files)) - { - continue; - } - - foreach ($files as $file_struct) - { - // Skip this file if the user selected to not update it - if (in_array($file_struct['filename'], $no_update)) - { - continue; - } - - // Already handled... then skip of course... - if (isset($file_list[$file_struct['filename']])) - { - continue; - } - - // Refresh if we reach 5 diffs... - if ($processed >= 5) - { - phpbb::$acm->put('diff_files', $file_list); - - if (request_var('download', false)) - { - $params[] = 'download=1'; - } - - $redirect_url = append_sid($this->p_master->module_url, "mode=$mode&sub=update_files&" . implode('&', $params)); - meta_refresh(3, $redirect_url); - - phpbb::$template->assign_vars(array( - 'S_IN_PROGRESS' => true, - 'L_IN_PROGRESS' => phpbb::$user->lang['MERGING_FILES'], - 'L_IN_PROGRESS_EXPLAIN' => phpbb::$user->lang['MERGING_FILES_EXPLAIN'], - )); - - return; - } - - $original_filename = ($file_struct['custom']) ? $file_struct['original'] : $file_struct['filename']; - - switch ($status) - { - case 'modified': - - $option = (isset($modified[$file_struct['filename']])) ? $modified[$file_struct['filename']] : 0; - - switch ($option) - { - case MERGE_NO_MERGE_NEW: - $contents = file_get_contents($this->new_location . $original_filename); - break; - - case MERGE_NO_MERGE_MOD: - $contents = file_get_contents(PHPBB_ROOT_PATH . $file_struct['filename']); - break; - - default: - $diff = $this->return_diff($this->old_location . $original_filename, PHPBB_ROOT_PATH . $file_struct['filename'], $this->new_location . $original_filename); - - $contents = implode("\n", $diff->merged_new_output()); - unset($diff); - break; - } - - $file_list[$file_struct['filename']] = 'file_' . md5($file_struct['filename']); - phpbb::$acm->put($file_list[$file_struct['filename']], base64_encode($contents)); - - $file_list['status']++; - $processed++; - - break; - - case 'conflict': - - $option = $conflicts[$file_struct['filename']]; - $contents = ''; - - switch ($option) - { - case MERGE_NO_MERGE_NEW: - $contents = file_get_contents($this->new_location . $original_filename); - break; - - case MERGE_NO_MERGE_MOD: - $contents = file_get_contents(PHPBB_ROOT_PATH . $file_struct['filename']); - break; - - default: - - $diff = $this->return_diff($this->old_location . $original_filename, PHPBB_ROOT_PATH . $file_struct['filename'], $this->new_location . $original_filename); - - if ($option == MERGE_NEW_FILE) - { - $contents = implode("\n", $diff->merged_new_output()); - } - else if ($option == MERGE_MOD_FILE) - { - $contents = implode("\n", $diff->merged_orig_output()); - } - else - { - unset($diff); - break 2; - } - - unset($diff); - break; - } - - $file_list[$file_struct['filename']] = 'file_' . md5($file_struct['filename']); - phpbb::$acm->put($file_list[$file_struct['filename']], base64_encode($contents)); - - $file_list['status']++; - $processed++; - - break; - } - } - } - } - - $file_list['status'] = -1; - phpbb::$acm->put('diff_files', $file_list); - - $this->include_file('includes/functions_compress.' . $phpEx); - $this->include_file('includes/functions_transfer.' . $phpEx); - - $module_url = append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"); - foreach ($update_list as &$files) - { - if (!is_array($files)) - { - continue; - } - for ($i = 0, $size = sizeof($files); $i < $size; $i++) - { - // Skip this file if the user selected to not update it - if (in_array($files[$i]['filename'], $no_update)) - { - unset($files[$i]['filename']); - } - } - $files = array_values($files); - } - unset($files); - $new_location = $this->new_location; - $download_filename = 'update_' . $this->update_info['version']['from'] . '_to_' . $this->update_info['version']['to']; - $check_params = "mode=$mode&sub=file_check"; - - $temp = process_transfer($module_url, $update_list, $new_location, $download_filename); - if (is_string($temp)) - { - $this->page_title = $temp; - } - - phpbb::$template->assign_vars(array( - 'S_UPDATE_OPTIONS' => true, - 'S_CHECK_AGAIN' => true, - // 'U_INITIAL_ACTION' isn't set because it's taken care of in the S_FILE_CHECK block of install_update.html - 'U_FINAL_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files")) - ); - - break; - - } - } - - /** - * Show file diff - */ - function show_diff(&$update_list) - { - $this->tpl_name = 'install_update_diff'; - - // Got the diff template itself updated? If so, we are able to directly use it - if (in_array('adm/style/install_update_diff.html', $this->update_info['files'])) - { - $this->tpl_name = '../../install/update/new/adm/style/install_update_diff'; - } - - $this->page_title = 'VIEWING_FILE_DIFF'; - - $status = request_var('status', ''); - $file = request_var('file', ''); - $diff_mode = request_var('diff_mode', 'inline'); - - // First of all make sure the file is within our file update list with the correct status - $found_entry = array(); - foreach ($update_list[$status] as $index => $file_struct) - { - if ($file_struct['filename'] === $file) - { - $found_entry = $update_list[$status][$index]; - } - } - - if (empty($found_entry)) - { - trigger_error(phpbb::$user->lang['FILE_DIFF_NOT_ALLOWED'], E_USER_ERROR); - } - - // If the status is 'up_to_date' then we do not need to show a diff - if ($status == 'up_to_date') - { - trigger_error(phpbb::$user->lang['FILE_ALREADY_UP_TO_DATE'], E_USER_ERROR); - } - - $original_file = ($found_entry['custom']) ? $found_entry['original'] : $file; - - // Get the correct diff - switch ($status) - { - case 'conflict': - $option = request_var('op', 0); - - switch ($option) - { - case MERGE_NO_MERGE_NEW: - case MERGE_NO_MERGE_MOD: - - $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : PHPBB_ROOT_PATH . $file); - - phpbb::$template->assign_var('S_DIFF_NEW_FILE', true); - $diff_mode = 'inline'; - $this->page_title = 'VIEWING_FILE_CONTENTS'; - - break; - -/* - $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); - - $tmp = array( - 'file1' => array(), - 'file2' => ($option == MERGE_NEW_FILE) ? implode("\n", $diff->merged_new_output()) : implode("\n", $diff->merged_orig_output()), - ); - - $diff = new diff($tmp['file1'], $tmp['file2']); - - unset($tmp); - - phpbb::$template->assign_var('S_DIFF_NEW_FILE', true); - $diff_mode = 'inline'; - $this->page_title = 'VIEWING_FILE_CONTENTS'; - - break; -*/ - // Merge differences and use new phpBB code for conflicted blocks - case MERGE_NEW_FILE: - case MERGE_MOD_FILE: - - $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); - - phpbb::$template->assign_vars(array( - 'S_DIFF_CONFLICT_FILE' => true, - 'NUM_CONFLICTS' => $diff->get_num_conflicts(), - )); - - $diff = $this->return_diff(PHPBB_ROOT_PATH . $file, ($option == MERGE_NEW_FILE) ? $diff->merged_new_output() : $diff->merged_orig_output()); - break; - - // Download conflict file - default: - - $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $file, $this->new_location . $original_file); - - header('Pragma: no-cache'); - header("Content-Type: application/octetstream; name=\"$file\""); - header("Content-disposition: attachment; filename=$file"); - - @set_time_limit(0); - - echo implode("\n", $diff->get_conflicts_content()); - - flush(); - exit; - - break; - } - - break; - - case 'modified': - $option = request_var('op', 0); - - switch ($option) - { - case MERGE_NO_MERGE_NEW: - case MERGE_NO_MERGE_MOD: - - $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : PHPBB_ROOT_PATH . $file); - - phpbb::$template->assign_var('S_DIFF_NEW_FILE', true); - $diff_mode = 'inline'; - $this->page_title = 'VIEWING_FILE_CONTENTS'; - - break; - - default: - $diff = $this->return_diff($this->old_location . $original_file, PHPBB_ROOT_PATH . $original_file, $this->new_location . $file); - break; - } - break; - - case 'not_modified': - case 'new_conflict': - $diff = $this->return_diff(PHPBB_ROOT_PATH . $file, $this->new_location . $original_file); - break; - - case 'new': - - $diff = $this->return_diff(array(), $this->new_location . $original_file); - - phpbb::$template->assign_var('S_DIFF_NEW_FILE', true); - $diff_mode = 'inline'; - $this->page_title = 'VIEWING_FILE_CONTENTS'; - - break; - } - - $diff_mode_options = ''; - foreach (array('side_by_side', 'inline', 'unified', 'raw') as $option) - { - $diff_mode_options .= ''; - } - - // Now the correct renderer - $render_class = 'diff_renderer_' . $diff_mode; - - if (!class_exists($render_class)) - { - trigger_error('Chosen diff mode is not supported', E_USER_ERROR); - } - - $renderer = new $render_class(); - - phpbb::$template->assign_vars(array( - 'DIFF_CONTENT' => $renderer->get_diff_content($diff), - 'DIFF_MODE' => $diff_mode, - 'S_DIFF_MODE_OPTIONS' => $diff_mode_options, - 'S_SHOW_DIFF' => true, - )); - - unset($diff, $renderer); - } - - /** - * Collect all file status infos we need for the update by diffing all files - */ - function get_update_structure(&$update_list) - { - if ($update_list === false) - { - $update_list = array( - 'up_to_date' => array(), - 'new' => array(), - 'not_modified' => array(), - 'modified' => array(), - 'new_conflict' => array(), - 'conflict' => array(), - 'no_update' => array(), - 'status' => 0, - ); - } - - /* if (!empty($this->update_info['custom'])) - { - foreach ($this->update_info['custom'] as $original_file => $file_ary) - { - foreach ($file_ary as $index => $file) - { - $this->make_update_diff($update_list, $original_file, $file, true); - } - } - } */ - - // Get a list of those files which are completely new by checking with file_exists... - $num_bytes_processed = 0; - - foreach ($this->update_info['files'] as $index => $file) - { - if (is_int($update_list['status']) && $index < $update_list['status']) - { - continue; - } - - if ($num_bytes_processed >= 500 * 1024) - { - return; - } - - if (!file_exists(PHPBB_ROOT_PATH . $file)) - { - // Make sure the update files are consistent by checking if the file is in new_files... - if (!file_exists($this->new_location . $file)) - { - trigger_error(phpbb::$user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); - } - - // If the file exists within the old directory the file got removed and we will write it back - // not a biggie, but we might want to state this circumstance separately later. - // if (file_exists($this->old_location . $file)) - // { - // $update_list['removed'][] = $file; - // } - - /* Only include a new file as new if the underlying path exist - // The path normally do not exist if the original style or language has been removed - if (file_exists(PHPBB_ROOT_PATH . dirname($file))) - { - $this->get_custom_info($update_list['new'], $file); - $update_list['new'][] = array('filename' => $file, 'custom' => false); - } - else - { - // Do not include style-related or language-related content - if (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0) - { - $update_list['no_update'][] = $file; - } - }*/ - - if (file_exists(PHPBB_ROOT_PATH . dirname($file)) || (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0)) - { - $this->get_custom_info($update_list['new'], $file); - $update_list['new'][] = array('filename' => $file, 'custom' => false); - } - - // unset($this->update_info['files'][$index]); - } - else - { - // not modified? - $this->make_update_diff($update_list, $file, $file); - } - - $num_bytes_processed += (file_exists($this->new_location . $file)) ? filesize($this->new_location . $file) : 100 * 1024; - $update_list['status']++; - } - - $update_list['status'] = -1; -/* if (!sizeof($this->update_info['files'])) - { - return $update_list; - } - - // Now diff the remaining files to get information about their status (not modified/modified/up-to-date) - - // not modified? - foreach ($this->update_info['files'] as $index => $file) - { - $this->make_update_diff($update_list, $file, $file); - } - - // Now to the styles... - if (empty($this->update_info['custom'])) - { - return $update_list; - } - - foreach ($this->update_info['custom'] as $original_file => $file_ary) - { - foreach ($file_ary as $index => $file) - { - $this->make_update_diff($update_list, $original_file, $file, true); - } - } - - return $update_list;*/ - } - - /** - * Compare files for storage in update_list - */ - function make_update_diff(&$update_list, $original_file, $file, $custom = false) - { - $update_ary = array('filename' => $file, 'custom' => $custom); - - if ($custom) - { - $update_ary['original'] = $original_file; - } - - // On a successfull update the new location file exists but the old one does not exist. - // Check for this circumstance, the new file need to be up-to-date with the current file then... - if (!file_exists($this->old_location . $original_file) && file_exists($this->new_location . $original_file) && file_exists(PHPBB_ROOT_PATH . $file)) - { - $tmp = array( - 'file1' => file_get_contents($this->new_location . $original_file), - 'file2' => file_get_contents(PHPBB_ROOT_PATH . $file), - ); - - // We need to diff the contents here to make sure the file is really the one we expect - $diff = new diff($tmp['file1'], $tmp['file2'], false); - $empty = $diff->is_empty(); - - unset($tmp, $diff); - - // if there are no differences we have an up-to-date file... - if ($empty) - { - $update_list['up_to_date'][] = $update_ary; - return; - } - - // If no other status matches we have another file in the way... - $update_list['new_conflict'][] = $update_ary; - return; - } - - // Old file removed? - if (file_exists($this->old_location . $original_file) && !file_exists($this->new_location . $original_file)) - { - return; - } - - // Check for existance, else abort immediately - if (!file_exists($this->old_location . $original_file) || !file_exists($this->new_location . $original_file)) - { - trigger_error(phpbb::$user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); - } - - $tmp = array( - 'file1' => file_get_contents($this->old_location . $original_file), - 'file2' => file_get_contents(PHPBB_ROOT_PATH . $file), - ); - - // We need to diff the contents here to make sure the file is really the one we expect - $diff = new diff($tmp['file1'], $tmp['file2'], false); - $empty_1 = $diff->is_empty(); - - unset($tmp, $diff); - - $tmp = array( - 'file1' => file_get_contents($this->new_location . $original_file), - 'file2' => file_get_contents(PHPBB_ROOT_PATH . $file), - ); - - // We need to diff the contents here to make sure the file is really the one we expect - $diff = new diff($tmp['file1'], $tmp['file2'], false); - $empty_2 = $diff->is_empty(); - - unset($tmp, $diff); - - // If the file is not modified we are finished here... - if ($empty_1) - { - // Further check if it is already up to date - it could happen that non-modified files - // slip through - if ($empty_2) - { - $update_list['up_to_date'][] = $update_ary; - return; - } - - $update_list['not_modified'][] = $update_ary; - return; - } - - // If the file had been modified then we need to check if it is already up to date - - // if there are no differences we have an up-to-date file... - if ($empty_2) - { - $update_list['up_to_date'][] = $update_ary; - return; - } - - // if the file is modified we try to make sure a merge succeed - $tmp = array( - 'file1' => file_get_contents($this->old_location . $original_file), - 'file2' => file_get_contents(PHPBB_ROOT_PATH . $file), - 'file3' => file_get_contents($this->new_location . $original_file), - ); - - $diff = new diff3($tmp['file1'], $tmp['file2'], $tmp['file3'], false); - - unset($tmp); - - if ($diff->get_num_conflicts()) - { - $update_ary['conflicts'] = $diff->get_num_conflicts(); - - // There is one special case... users having merged with a conflicting file... we need to check this - $tmp = array( - 'file1' => file_get_contents(PHPBB_ROOT_PATH . $file), - 'file2' => implode("\n", $diff->merged_orig_output()), - ); - - $diff = new diff($tmp['file1'], $tmp['file2'], false); - $empty = $diff->is_empty(); - - if ($empty) - { - unset($update_ary['conflicts']); - unset($diff); - $update_list['up_to_date'][] = $update_ary; - return; - } - - $update_list['conflict'][] = $update_ary; - unset($diff); - - return; - } - - $tmp = array( - 'file1' => file_get_contents(PHPBB_ROOT_PATH . $file), - 'file2' => implode("\n", $diff->merged_new_output()), - ); - - // now compare the merged output with the original file to see if the modified file is up to date - $diff = new diff($tmp['file1'], $tmp['file2'], false); - $empty = $diff->is_empty(); - - if ($empty) - { - unset($diff); - - $update_list['up_to_date'][] = $update_ary; - return; - } - - // If no other status matches we have a modified file... - $update_list['modified'][] = $update_ary; - } - - /** - * Update update_list with custom new files - */ - function get_custom_info(&$update_list, $file) - { - if (empty($this->update_info['custom'])) - { - return; - } - - if (isset($this->update_info['custom'][$file])) - { - foreach ($this->update_info['custom'][$file] as $_file) - { - $update_list[] = array('filename' => $_file, 'custom' => true, 'original' => $file); - } - } - } - - /** - * Get remote file - */ - function get_file($mode) - { - $errstr = ''; - $errno = 0; - - switch ($mode) - { - case 'version_info': - $info = get_remote_file('www.phpbb.com', '/updatecheck', ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); - - if ($info !== false) - { - $info = explode("\n", $info); - $info = trim($info[0]); - } - - if ($this->test_update !== false) - { - $info = $this->test_update; - } - - // If info is false the fsockopen function may not be working. Instead get the latest version from our update file (and pray it is up-to-date) - if ($info === false) - { - $update_info = array(); - include(PHPBB_ROOT_PATH . 'install/update/index.php'); - $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; - - if ($info !== false) - { - $info = (!empty($info['version']['to'])) ? trim($info['version']['to']) : false; - } - } - break; - - case 'update_info': - $update_info = array(); - include(PHPBB_ROOT_PATH . 'install/update/index.php'); - - $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; - $errstr = ($info === false) ? phpbb::$user->lang['WRONG_INFO_FILE_FORMAT'] : ''; - - if ($info !== false) - { - // Adjust the update info file to hold some specific style-related information - $info['custom'] = array(); -/* - // Get custom installed styles... - $sql = 'SELECT template_name, template_path - FROM ' . STYLES_TEMPLATE_TABLE . " - WHERE LOWER(template_name) NOT IN ('subsilver2', 'prosilver')"; - $result = phpbb::$db->sql_query($sql); - - $templates = array(); - while ($row = phpbb::$db->sql_fetchrow($result)) - { - $templates[] = $row; - } - phpbb::$db->sql_freeresult($result); - - if (sizeof($templates)) - { - foreach ($info['files'] as $filename) - { - // Template update? - if (strpos(strtolower($filename), 'styles/prosilver/template/') === 0) - { - foreach ($templates as $row) - { - $info['custom'][$filename][] = str_replace('/prosilver/', '/' . $row['template_path'] . '/', $filename); - } - } - } - } -*/ - } - break; - - default: - trigger_error('Mode for getting remote file not specified', E_USER_ERROR); - break; - } - - if ($info === false) - { - trigger_error($errstr, E_USER_ERROR); - } - - return $info; - } - - /** - * Function for including files... - */ - function include_file($filename) - { - if (!empty($this->update_info['files']) && in_array($filename, $this->update_info['files'])) - { - include_once($this->new_location . $filename); - } - else - { - include_once(PHPBB_ROOT_PATH . $filename); - } - } - - /** - * Wrapper for returning a diff object - */ - function &return_diff() - { - $args = func_get_args(); - $three_way_diff = (func_num_args() > 2) ? true : false; - - $file1 = array_shift($args); - $file2 = array_shift($args); - - $tmp['file1'] = (!empty($file1) && is_string($file1)) ? file_get_contents($file1) : $file1; - $tmp['file2'] = (!empty($file2) && is_string($file2)) ? file_get_contents($file2) : $file2; - - if ($three_way_diff) - { - $file3 = array_shift($args); - $tmp['file3'] = (!empty($file3) && is_string($file3)) ? file_get_contents($file3) : $file3; - - $diff = new diff3($tmp['file1'], $tmp['file2'], $tmp['file3']); - } - else - { - $diff = new diff($tmp['file1'], $tmp['file2']); - } - - unset($tmp); - - return $diff; - } -} - -?> \ No newline at end of file -- cgit v1.2.1 From 2e17e448deed073f8614bb555a8ef20c57291c2a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Oct 2009 18:14:59 +0000 Subject: Copy 3.0.x branch to trunk git-svn-id: file:///svn/phpbb/trunk@10211 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 1705 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 1705 insertions(+) create mode 100644 phpBB/install/install_update.php (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php new file mode 100644 index 0000000000..ab7ec35705 --- /dev/null +++ b/phpBB/install/install_update.php @@ -0,0 +1,1705 @@ + 'update', + 'module_title' => 'UPDATE', + 'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), + 'module_order' => 30, + 'module_subs' => '', + 'module_stages' => array('INTRO', 'VERSION_CHECK', 'UPDATE_DB', 'FILE_CHECK', 'UPDATE_FILES'), + 'module_reqs' => '' + ); +} + +/** +* Update Installation +* @package install +*/ +class install_update extends module +{ + var $p_master; + var $update_info; + + var $old_location; + var $new_location; + var $latest_version; + var $current_version; + var $unequal_version; + + var $update_to_version; + + // Set to false + var $test_update = false; + + function install_update(&$p_master) + { + $this->p_master = &$p_master; + } + + function main($mode, $sub) + { + global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth; + + $this->tpl_name = 'install_update'; + $this->page_title = 'UPDATE_INSTALLATION'; + $this->unequal_version = false; + + $this->old_location = $phpbb_root_path . 'install/update/old/'; + $this->new_location = $phpbb_root_path . 'install/update/new/'; + + // Init DB + require($phpbb_root_path . 'config.' . $phpEx); + require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); + require($phpbb_root_path . 'includes/constants.' . $phpEx); + + // Special options for conflicts/modified files + define('MERGE_NO_MERGE_NEW', 1); + define('MERGE_NO_MERGE_MOD', 2); + define('MERGE_NEW_FILE', 3); + define('MERGE_MOD_FILE', 4); + + $db = new $sql_db(); + + // Connect to DB + $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); + + // We do not need this any longer, unset for safety purposes + unset($dbpasswd); + + $config = array(); + + $sql = 'SELECT config_name, config_value + FROM ' . CONFIG_TABLE; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $config[$row['config_name']] = $row['config_value']; + } + $db->sql_freeresult($result); + + // Force template recompile + $config['load_tplcompile'] = 1; + + // First of all, init the user session + $user->session_begin(); + $auth->acl($user->data); + + $user->setup('install'); + + // If we are within the intro page we need to make sure we get up-to-date version info + if ($sub == 'intro') + { + $cache->destroy('_version_info'); + } + + // Set custom template again. ;) + $template->set_custom_template('../adm/style', 'admin'); + + // still, the acp template is never stored in the database + $user->theme['template_storedb'] = false; + + // Get current and latest version + if (($latest_version = $cache->get('_version_info')) === false) + { + $this->latest_version = $this->get_file('version_info'); + $cache->put('_version_info', $this->latest_version); + } + else + { + $this->latest_version = $latest_version; + } + + // For the current version we trick a bit. ;) + $this->current_version = (!empty($config['version_update_from'])) ? $config['version_update_from'] : $config['version']; + + $up_to_date = (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->latest_version)), '<')) ? false : true; + + // Check for a valid update directory, else point the user to the phpbb.com website + if (!file_exists($phpbb_root_path . 'install/update') || !file_exists($phpbb_root_path . 'install/update/index.' . $phpEx) || !file_exists($this->old_location) || !file_exists($this->new_location)) + { + $template->assign_vars(array( + 'S_ERROR' => true, + 'ERROR_MSG' => ($up_to_date) ? $user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf($user->lang['NO_UPDATE_FILES_OUTDATED'], $config['version'], $this->current_version, $this->latest_version)) + ); + + return; + } + + $this->update_info = $this->get_file('update_info'); + + // Make sure the update directory holds the correct information + // Since admins are able to run the update/checks more than once we only check if the current version is lower or equal than the version to which we update to. + if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '>')) + { + $template->assign_vars(array( + 'S_ERROR' => true, + 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], $config['version'], $this->update_info['version']['from'], $this->update_info['version']['to'])) + ); + + return; + } + + // Check if the update files stored are for the latest version... + if ($this->latest_version != $this->update_info['version']['to']) + { + $this->unequal_version = true; + + $template->assign_vars(array( + 'S_WARNING' => true, + 'WARNING_MSG' => sprintf($user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version)) + ); + } + + // We store the "update to" version, because it is not always the latest. ;) + $this->update_to_version = $this->update_info['version']['to']; + + // Fill DB version + if (empty($config['dbms_version'])) + { + set_config('dbms_version', $db->sql_server_info(true)); + } + + if ($this->test_update === false) + { + // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present + if (in_array('adm/style/install_update.html', $this->update_info['files'])) + { + $this->tpl_name = '../../install/update/new/adm/style/install_update'; + } + + // What about the language file? Got it updated? + if (in_array('language/en/install.' . $phpEx, $this->update_info['files'])) + { + $lang = array(); + include($this->new_location . 'language/en/install.' . $phpEx); + // only add new keys to user's language in english + $new_keys = array_diff(array_keys($lang), array_keys($user->lang)); + foreach ($new_keys as $i => $new_key) + { + $user->lang[$new_key] = $lang[$new_key]; + } + } + } + + // Include renderer and engine + $this->include_file('includes/diff/diff.' . $phpEx); + $this->include_file('includes/diff/engine.' . $phpEx); + $this->include_file('includes/diff/renderer.' . $phpEx); + + // Make sure we stay at the file check if checking the files again + if (!empty($_POST['check_again'])) + { + $sub = $this->p_master->sub = 'file_check'; + } + + switch ($sub) + { + case 'intro': + $this->page_title = 'UPDATE_INSTALLATION'; + + $template->assign_vars(array( + 'S_INTRO' => true, + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=version_check"), + )); + + // Make sure the update list is destroyed. + $cache->destroy('_update_list'); + $cache->destroy('_diff_files'); + break; + + case 'version_check': + $this->page_title = 'STAGE_VERSION_CHECK'; + + $template->assign_vars(array( + 'S_UP_TO_DATE' => $up_to_date, + 'S_VERSION_CHECK' => true, + + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), + 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), + + 'LATEST_VERSION' => $this->latest_version, + 'CURRENT_VERSION' => $this->current_version) + ); + + // Print out version the update package updates to + if ($this->unequal_version) + { + $template->assign_var('PACKAGE_VERSION', $this->update_info['version']['to']); + } + + break; + + case 'update_db': + + // Make sure the database update is valid for the latest version + $valid = false; + $updates_to_version = ''; + + if (file_exists($phpbb_root_path . 'install/database_update.' . $phpEx)) + { + include_once($phpbb_root_path . 'install/database_update.' . $phpEx); + + if ($updates_to_version === $this->update_info['version']['to']) + { + $valid = true; + } + } + + // Should not happen at all + if (!$valid) + { + trigger_error($user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); + } + + // Just a precaution + $cache->purge(); + + // Redirect the user to the database update script with some explanations... + $template->assign_vars(array( + 'S_DB_UPDATE' => true, + 'S_DB_UPDATE_FINISHED' => ($config['version'] == $this->update_info['version']['to']) ? true : false, + 'U_DB_UPDATE' => append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=1&language=' . $user->data['user_lang']), + 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), + )); + + break; + + case 'file_check': + + // Make sure the previous file collection is no longer valid... + $cache->destroy('_diff_files'); + + $this->page_title = 'STAGE_FILE_CHECK'; + + // Now make sure our update list is correct if the admin refreshes + $action = request_var('action', ''); + + // We are directly within an update. To make sure our update list is correct we check its status. + $update_list = (!empty($_POST['check_again'])) ? false : $cache->get('_update_list'); + $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . $phpEx) : 0; + + // Make sure the list is up-to-date + if ($update_list !== false) + { + $get_new_list = false; + foreach ($this->update_info['files'] as $file) + { + if (file_exists($phpbb_root_path . $file) && filemtime($phpbb_root_path . $file) > $modified) + { + $get_new_list = true; + break; + } + } + } + else + { + $get_new_list = true; + } + + if (!$get_new_list && $update_list['status'] != -1) + { + $get_new_list = true; + } + + if ($get_new_list) + { + $this->get_update_structure($update_list); + $cache->put('_update_list', $update_list); + + // Refresh the page if we are still not finished... + if ($update_list['status'] != -1) + { + $refresh_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"); + meta_refresh(2, $refresh_url); + + $template->assign_vars(array( + 'S_IN_PROGRESS' => true, + 'S_COLLECTED' => (int) $update_list['status'], + 'S_TO_COLLECT' => sizeof($this->update_info['files']), + 'L_IN_PROGRESS' => $user->lang['COLLECTING_FILE_DIFFS'], + 'L_IN_PROGRESS_EXPLAIN' => sprintf($user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files'])), + )); + + return; + } + } + + if ($action == 'diff') + { + $this->show_diff($update_list); + return; + } + + if (sizeof($update_list['no_update'])) + { + $template->assign_vars(array( + 'S_NO_UPDATE_FILES' => true, + 'NO_UPDATE_FILES' => implode(', ', array_map('htmlspecialchars', $update_list['no_update']))) + ); + } + + // Now assign the list to the template + foreach ($update_list as $status => $filelist) + { + if ($status == 'no_update' || !sizeof($filelist) || $status == 'status') + { + continue; + } + +/* $template->assign_block_vars('files', array( + 'S_STATUS' => true, + 'STATUS' => $status, + 'L_STATUS' => $user->lang['STATUS_' . strtoupper($status)], + 'TITLE' => $user->lang['FILES_' . strtoupper($status)], + 'EXPLAIN' => $user->lang['FILES_' . strtoupper($status) . '_EXPLAIN'], + ) + );*/ + + foreach ($filelist as $file_struct) + { + $s_binary = (!empty($this->update_info['binary']) && in_array($file_struct['filename'], $this->update_info['binary'])) ? true : false; + + $filename = htmlspecialchars($file_struct['filename']); + if (strrpos($filename, '/') !== false) + { + $dir_part = substr($filename, 0, strrpos($filename, '/') + 1); + $file_part = substr($filename, strrpos($filename, '/') + 1); + } + else + { + $dir_part = ''; + $file_part = $filename; + } + + $diff_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check&action=diff&status=$status&file=" . urlencode($file_struct['filename'])); + + $template->assign_block_vars($status, array( + 'STATUS' => $status, + + 'FILENAME' => $filename, + 'DIR_PART' => $dir_part, + 'FILE_PART' => $file_part, + 'NUM_CONFLICTS' => (isset($file_struct['conflicts'])) ? $file_struct['conflicts'] : 0, + + 'S_CUSTOM' => ($file_struct['custom']) ? true : false, + 'S_BINARY' => $s_binary, + 'CUSTOM_ORIGINAL' => ($file_struct['custom']) ? $file_struct['original'] : '', + + 'U_SHOW_DIFF' => $diff_url, + 'L_SHOW_DIFF' => ($status != 'up_to_date') ? $user->lang['SHOW_DIFF_' . strtoupper($status)] : '', + + 'U_VIEW_MOD_FILE' => $diff_url . '&op=' . MERGE_MOD_FILE, + 'U_VIEW_NEW_FILE' => $diff_url . '&op=' . MERGE_NEW_FILE, + 'U_VIEW_NO_MERGE_MOD' => $diff_url . '&op=' . MERGE_NO_MERGE_MOD, + 'U_VIEW_NO_MERGE_NEW' => $diff_url . '&op=' . MERGE_NO_MERGE_NEW, + )); + } + } + + $all_up_to_date = true; + foreach ($update_list as $status => $filelist) + { + if ($status != 'up_to_date' && $status != 'custom' && $status != 'status' && sizeof($filelist)) + { + $all_up_to_date = false; + break; + } + } + + $template->assign_vars(array( + 'S_FILE_CHECK' => true, + 'S_ALL_UP_TO_DATE' => $all_up_to_date, + 'S_VERSION_UP_TO_DATE' => $up_to_date, + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), + 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), + 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), + )); + + if ($all_up_to_date) + { + // Add database update to log + add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->update_to_version); + + // Refresh prosilver css data - this may cause some unhappy users, but + $sql = 'SELECT * + FROM ' . STYLES_THEME_TABLE . " + WHERE LOWER(theme_name) = 'prosilver'"; + $result = $db->sql_query($sql); + $theme = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($theme) + { + $recache = (empty($theme['theme_data'])) ? true : false; + $update_time = time(); + + // We test for stylesheet.css because it is faster and most likely the only file changed on common themes + if (!$recache && $theme['theme_mtime'] < @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css')) + { + $recache = true; + $update_time = @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css'); + } + else if (!$recache) + { + $last_change = $theme['theme_mtime']; + $dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme"); + + if ($dir) + { + while (($entry = readdir($dir)) !== false) + { + if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}")) + { + $recache = true; + break; + } + } + closedir($dir); + } + } + + if ($recache) + { + // Instead of re-caching here, we simply remove theme_data... HAR HAR HAR (think about a carribean pirate) + $sql = 'UPDATE ' . STYLES_THEME_TABLE . " SET theme_data = '' + WHERE theme_id = " . $theme['theme_id']; + $db->sql_query($sql); + + $cache->destroy('sql', STYLES_THEME_TABLE); + $cache->destroy('sql', STYLES_TABLE); + } + } + + $db->sql_return_on_error(true); + $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); + $db->sql_return_on_error(false); + + $cache->purge(); + } + + break; + + case 'update_files': + + $this->page_title = 'STAGE_UPDATE_FILES'; + + $s_hidden_fields = ''; + $params = array(); + $conflicts = request_var('conflict', array('' => 0)); + $modified = request_var('modified', array('' => 0)); + + foreach ($conflicts as $filename => $merge_option) + { + $s_hidden_fields .= ''; + $params[] = 'conflict[' . urlencode($filename) . ']=' . urlencode($merge_option); + } + + foreach ($modified as $filename => $merge_option) + { + if (!$merge_option) + { + continue; + } + $s_hidden_fields .= ''; + $params[] = 'modified[' . urlencode($filename) . ']=' . urlencode($merge_option); + } + + $no_update = request_var('no_update', array(0 => '')); + + foreach ($no_update as $index => $filename) + { + $s_hidden_fields .= ''; + $params[] = 'no_update[]=' . urlencode($filename); + } + + // Before the user is choosing his preferred method, let's create the content list... + $update_list = $cache->get('_update_list'); + + if ($update_list === false) + { + trigger_error($user->lang['NO_UPDATE_INFO'], E_USER_ERROR); + } + + // Check if the conflicts data is valid + if (sizeof($conflicts)) + { + $conflict_filenames = array(); + foreach ($update_list['conflict'] as $files) + { + $conflict_filenames[] = $files['filename']; + } + + $new_conflicts = array(); + foreach ($conflicts as $filename => $diff_method) + { + if (in_array($filename, $conflict_filenames)) + { + $new_conflicts[$filename] = $diff_method; + } + } + + $conflicts = $new_conflicts; + } + + // Build list for modifications + if (sizeof($modified)) + { + $modified_filenames = array(); + foreach ($update_list['modified'] as $files) + { + $modified_filenames[] = $files['filename']; + } + + $new_modified = array(); + foreach ($modified as $filename => $diff_method) + { + if (in_array($filename, $modified_filenames)) + { + $new_modified[$filename] = $diff_method; + } + } + + $modified = $new_modified; + } + + // Check number of conflicting files, they need to be equal. For modified files the number can differ + if (sizeof($update_list['conflict']) != sizeof($conflicts)) + { + trigger_error($user->lang['MERGE_SELECT_ERROR'], E_USER_ERROR); + } + + // Before we do anything, let us diff the files and store the raw file information "somewhere" + $get_files = false; + $file_list = $cache->get('_diff_files'); + + if ($file_list === false || $file_list['status'] != -1) + { + $get_files = true; + } + + if ($get_files) + { + if ($file_list === false) + { + $file_list = array( + 'status' => 0, + ); + } + + $processed = 0; + foreach ($update_list as $status => $files) + { + if (!is_array($files)) + { + continue; + } + + foreach ($files as $file_struct) + { + // Skip this file if the user selected to not update it + if (in_array($file_struct['filename'], $no_update)) + { + continue; + } + + // Already handled... then skip of course... + if (isset($file_list[$file_struct['filename']])) + { + continue; + } + + // Refresh if we reach 5 diffs... + if ($processed >= 5) + { + $cache->put('_diff_files', $file_list); + + if (!empty($_REQUEST['download'])) + { + $params[] = 'download=1'; + } + + $redirect_url = append_sid($this->p_master->module_url, "mode=$mode&sub=update_files&" . implode('&', $params)); + meta_refresh(3, $redirect_url); + + $template->assign_vars(array( + 'S_IN_PROGRESS' => true, + 'L_IN_PROGRESS' => $user->lang['MERGING_FILES'], + 'L_IN_PROGRESS_EXPLAIN' => $user->lang['MERGING_FILES_EXPLAIN'], + )); + + return; + } + + $original_filename = ($file_struct['custom']) ? $file_struct['original'] : $file_struct['filename']; + + switch ($status) + { + case 'modified': + + $option = (isset($modified[$file_struct['filename']])) ? $modified[$file_struct['filename']] : 0; + + switch ($option) + { + case MERGE_NO_MERGE_NEW: + $contents = file_get_contents($this->new_location . $original_filename); + break; + + case MERGE_NO_MERGE_MOD: + $contents = file_get_contents($phpbb_root_path . $file_struct['filename']); + break; + + default: + $diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename); + + $contents = implode("\n", $diff->merged_output()); + unset($diff); + break; + } + + $file_list[$file_struct['filename']] = '_file_' . md5($file_struct['filename']); + $cache->put($file_list[$file_struct['filename']], base64_encode($contents)); + + $file_list['status']++; + $processed++; + + break; + + case 'conflict': + + $option = $conflicts[$file_struct['filename']]; + $contents = ''; + + switch ($option) + { + case MERGE_NO_MERGE_NEW: + $contents = file_get_contents($this->new_location . $original_filename); + break; + + case MERGE_NO_MERGE_MOD: + $contents = file_get_contents($phpbb_root_path . $file_struct['filename']); + break; + + default: + + $diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename); + + if ($option == MERGE_NEW_FILE) + { + $contents = implode("\n", $diff->merged_new_output()); + } + else if ($option == MERGE_MOD_FILE) + { + $contents = implode("\n", $diff->merged_orig_output()); + } + else + { + unset($diff); + break 2; + } + + unset($diff); + break; + } + + $file_list[$file_struct['filename']] = '_file_' . md5($file_struct['filename']); + $cache->put($file_list[$file_struct['filename']], base64_encode($contents)); + + $file_list['status']++; + $processed++; + + break; + } + } + } + } + + $file_list['status'] = -1; + $cache->put('_diff_files', $file_list); + + if (!empty($_REQUEST['download'])) + { + $this->include_file('includes/functions_compress.' . $phpEx); + + $use_method = request_var('use_method', ''); + $methods = array('.tar'); + + $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib'); + foreach ($available_methods as $type => $module) + { + if (!@extension_loaded($module)) + { + continue; + } + + $methods[] = $type; + } + + // Let the user decide in which format he wants to have the pack + if (!$use_method) + { + $this->page_title = 'SELECT_DOWNLOAD_FORMAT'; + + $radio_buttons = ''; + foreach ($methods as $method) + { + $radio_buttons .= ''; + } + + $template->assign_vars(array( + 'S_DOWNLOAD_FILES' => true, + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), + 'RADIO_BUTTONS' => $radio_buttons, + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + // To ease the update process create a file location map + $update_list = $cache->get('_update_list'); + $script_path = ($config['force_server_vars']) ? (($config['script_path'] == '/') ? '/' : $config['script_path'] . '/') : $user->page['root_script_path']; + + foreach ($update_list as $status => $files) + { + if ($status == 'up_to_date' || $status == 'no_update' || $status == 'status') + { + continue; + } + + foreach ($files as $file_struct) + { + if (in_array($file_struct['filename'], $no_update)) + { + continue; + } + + $template->assign_block_vars('location', array( + 'SOURCE' => htmlspecialchars($file_struct['filename']), + 'DESTINATION' => $script_path . htmlspecialchars($file_struct['filename']), + )); + } + } + return; + } + + if (!in_array($use_method, $methods)) + { + $use_method = '.tar'; + } + + $update_mode = 'download'; + } + else + { + $this->include_file('includes/functions_transfer.' . $phpEx); + + // Choose FTP, if not available use fsock... + $method = basename(request_var('method', '')); + $submit = (isset($_POST['submit'])) ? true : false; + $test_ftp_connection = request_var('test_connection', ''); + + if (!$method || !class_exists($method)) + { + $method = 'ftp'; + $methods = transfer::methods(); + + if (!in_array('ftp', $methods)) + { + $method = $methods[0]; + } + } + + $test_connection = false; + if ($test_ftp_connection || $submit) + { + $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $test_connection = $transfer->open_session(); + + // Make sure that the directory is correct by checking for the existence of common.php + if ($test_connection === true) + { + // Check for common.php file + if (!$transfer->file_exists($phpbb_root_path, 'common.' . $phpEx)) + { + $test_connection = 'ERR_WRONG_PATH_TO_PHPBB'; + } + } + + $transfer->close_session(); + + // Make sure the login details are correct before continuing + if ($submit && $test_connection !== true) + { + $submit = false; + $test_ftp_connection = true; + } + } + + $s_hidden_fields .= build_hidden_fields(array('method' => $method)); + + if (!$submit) + { + $this->page_title = 'SELECT_FTP_SETTINGS'; + + if (!class_exists($method)) + { + trigger_error('Method does not exist.', E_USER_ERROR); + } + + $requested_data = call_user_func(array($method, 'data')); + foreach ($requested_data as $data => $default) + { + $template->assign_block_vars('data', array( + 'DATA' => $data, + 'NAME' => $user->lang[strtoupper($method . '_' . $data)], + 'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], + 'DEFAULT' => (!empty($_REQUEST[$data])) ? request_var($data, '') : $default + )); + } + + $template->assign_vars(array( + 'S_CONNECTION_SUCCESS' => ($test_ftp_connection && $test_connection === true) ? true : false, + 'S_CONNECTION_FAILED' => ($test_ftp_connection && $test_connection !== true) ? true : false, + 'ERROR_MSG' => ($test_ftp_connection && $test_connection !== true) ? $user->lang[$test_connection] : '', + + 'S_FTP_UPLOAD' => true, + 'UPLOAD_METHOD' => $method, + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), + 'U_DOWNLOAD_METHOD' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files&download=1"), + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + )); + + return; + } + + $update_mode = 'upload'; + } + + // Now update the installation or download the archive... + $download_filename = 'update_' . $this->update_info['version']['from'] . '_to_' . $this->update_info['version']['to']; + $archive_filename = $download_filename . '_' . time() . '_' . unique_id(); + + // Now init the connection + if ($update_mode == 'download') + { + if (function_exists('phpbb_is_writable') && !phpbb_is_writable($phpbb_root_path . 'store/')) + { + trigger_error(sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $phpbb_root_path . 'store/'), E_USER_ERROR); + } + + if ($use_method == '.zip') + { + $compress = new compress_zip('w', $phpbb_root_path . 'store/' . $archive_filename . $use_method); + } + else + { + $compress = new compress_tar('w', $phpbb_root_path . 'store/' . $archive_filename . $use_method, $use_method); + } + } + else + { + $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer->open_session(); + } + + // Ok, go through the update list and do the operations based on their status + foreach ($update_list as $status => $files) + { + if (!is_array($files)) + { + continue; + } + + foreach ($files as $file_struct) + { + // Skip this file if the user selected to not update it + if (in_array($file_struct['filename'], $no_update)) + { + continue; + } + + $original_filename = ($file_struct['custom']) ? $file_struct['original'] : $file_struct['filename']; + + switch ($status) + { + case 'new': + case 'new_conflict': + case 'not_modified': + + if ($update_mode == 'download') + { + $compress->add_custom_file($this->new_location . $original_filename, $file_struct['filename']); + } + else + { + if ($status != 'new') + { + $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); + } + + // New directory too? + $dirname = dirname($file_struct['filename']); + + if ($dirname && !file_exists($phpbb_root_path . $dirname)) + { + $transfer->make_dir($dirname); + } + + $transfer->copy_file($this->new_location . $original_filename, $file_struct['filename']); + } + break; + + case 'modified': + + $contents = base64_decode($cache->get($file_list[$file_struct['filename']])); + + if ($update_mode == 'download') + { + $compress->add_data($contents, $file_struct['filename']); + } + else + { + // @todo add option to specify if a backup file should be created? + $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); + $transfer->write_file($file_struct['filename'], $contents); + } + break; + + case 'conflict': + + $contents = base64_decode($cache->get($file_list[$file_struct['filename']])); + + if ($update_mode == 'download') + { + $compress->add_data($contents, $file_struct['filename']); + } + else + { + $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); + $transfer->write_file($file_struct['filename'], $contents); + } + break; + } + } + } + + if ($update_mode == 'download') + { + $compress->close(); + + $compress->download($archive_filename, $download_filename); + @unlink($phpbb_root_path . 'store/' . $archive_filename . $use_method); + + exit; + } + else + { + $transfer->close_session(); + + $template->assign_vars(array( + 'S_UPLOAD_SUCCESS' => true, + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check")) + ); + return; + } + + break; + + } + } + + /** + * Show file diff + */ + function show_diff(&$update_list) + { + global $phpbb_root_path, $template, $user; + + $this->tpl_name = 'install_update_diff'; + + // Got the diff template itself updated? If so, we are able to directly use it + if (in_array('adm/style/install_update_diff.html', $this->update_info['files'])) + { + $this->tpl_name = '../../install/update/new/adm/style/install_update_diff'; + } + + $this->page_title = 'VIEWING_FILE_DIFF'; + + $status = request_var('status', ''); + $file = request_var('file', ''); + $diff_mode = request_var('diff_mode', 'inline'); + + // First of all make sure the file is within our file update list with the correct status + $found_entry = array(); + foreach ($update_list[$status] as $index => $file_struct) + { + if ($file_struct['filename'] === $file) + { + $found_entry = $update_list[$status][$index]; + } + } + + if (empty($found_entry)) + { + trigger_error($user->lang['FILE_DIFF_NOT_ALLOWED'], E_USER_ERROR); + } + + // If the status is 'up_to_date' then we do not need to show a diff + if ($status == 'up_to_date') + { + trigger_error($user->lang['FILE_ALREADY_UP_TO_DATE'], E_USER_ERROR); + } + + $original_file = ($found_entry['custom']) ? $found_entry['original'] : $file; + + // Get the correct diff + switch ($status) + { + case 'conflict': + $option = request_var('op', 0); + + switch ($option) + { + case MERGE_NO_MERGE_NEW: + case MERGE_NO_MERGE_MOD: + + $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : $phpbb_root_path . $file); + + $template->assign_var('S_DIFF_NEW_FILE', true); + $diff_mode = 'inline'; + $this->page_title = 'VIEWING_FILE_CONTENTS'; + + break; + + // Merge differences and use new phpBB code for conflicted blocks + case MERGE_NEW_FILE: + case MERGE_MOD_FILE: + + $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $file, $this->new_location . $original_file); + + $template->assign_vars(array( + 'S_DIFF_CONFLICT_FILE' => true, + 'NUM_CONFLICTS' => $diff->get_num_conflicts()) + ); + + $diff = $this->return_diff($phpbb_root_path . $file, ($option == MERGE_NEW_FILE) ? $diff->merged_new_output() : $diff->merged_orig_output()); + break; + + // Download conflict file + default: + + $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $file, $this->new_location . $original_file); + + header('Pragma: no-cache'); + header("Content-Type: application/octetstream; name=\"$file\""); + header("Content-disposition: attachment; filename=$file"); + + @set_time_limit(0); + + echo implode("\n", $diff->get_conflicts_content()); + + flush(); + exit; + + break; + } + + break; + + case 'modified': + $option = request_var('op', 0); + + switch ($option) + { + case MERGE_NO_MERGE_NEW: + case MERGE_NO_MERGE_MOD: + + $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : $phpbb_root_path . $file); + + $template->assign_var('S_DIFF_NEW_FILE', true); + $diff_mode = 'inline'; + $this->page_title = 'VIEWING_FILE_CONTENTS'; + + break; + + default: + $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $original_file, $this->new_location . $file); + $diff = $this->return_diff($phpbb_root_path . $file, $diff->merged_output()); + break; + } + break; + + case 'not_modified': + case 'new_conflict': + $diff = $this->return_diff($phpbb_root_path . $file, $this->new_location . $original_file); + break; + + case 'new': + + $diff = $this->return_diff(array(), $this->new_location . $original_file); + + $template->assign_var('S_DIFF_NEW_FILE', true); + $diff_mode = 'inline'; + $this->page_title = 'VIEWING_FILE_CONTENTS'; + + break; + } + + $diff_mode_options = ''; + foreach (array('side_by_side', 'inline', 'unified', 'raw') as $option) + { + $diff_mode_options .= ''; + } + + // Now the correct renderer + $render_class = 'diff_renderer_' . $diff_mode; + + if (!class_exists($render_class)) + { + trigger_error('Chosen diff mode is not supported', E_USER_ERROR); + } + + $renderer = new $render_class(); + + $template->assign_vars(array( + 'DIFF_CONTENT' => $renderer->get_diff_content($diff), + 'DIFF_MODE' => $diff_mode, + 'S_DIFF_MODE_OPTIONS' => $diff_mode_options, + 'S_SHOW_DIFF' => true, + )); + + unset($diff, $renderer); + } + + /** + * Collect all file status infos we need for the update by diffing all files + */ + function get_update_structure(&$update_list) + { + global $phpbb_root_path, $phpEx, $user; + + if ($update_list === false) + { + $update_list = array( + 'up_to_date' => array(), + 'new' => array(), + 'not_modified' => array(), + 'modified' => array(), + 'new_conflict' => array(), + 'conflict' => array(), + 'no_update' => array(), + 'status' => 0, + ); + } + + /* if (!empty($this->update_info['custom'])) + { + foreach ($this->update_info['custom'] as $original_file => $file_ary) + { + foreach ($file_ary as $index => $file) + { + $this->make_update_diff($update_list, $original_file, $file, true); + } + } + } */ + + // Get a list of those files which are completely new by checking with file_exists... + $num_bytes_processed = 0; + + foreach ($this->update_info['files'] as $index => $file) + { + if (is_int($update_list['status']) && $index < $update_list['status']) + { + continue; + } + + if ($num_bytes_processed >= 500 * 1024) + { + return; + } + + if (!file_exists($phpbb_root_path . $file)) + { + // Make sure the update files are consistent by checking if the file is in new_files... + if (!file_exists($this->new_location . $file)) + { + trigger_error($user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); + } + + // If the file exists within the old directory the file got removed and we will write it back + // not a biggie, but we might want to state this circumstance separately later. + // if (file_exists($this->old_location . $file)) + // { + // $update_list['removed'][] = $file; + // } + + /* Only include a new file as new if the underlying path exist + // The path normally do not exist if the original style or language has been removed + if (file_exists($phpbb_root_path . dirname($file))) + { + $this->get_custom_info($update_list['new'], $file); + $update_list['new'][] = array('filename' => $file, 'custom' => false); + } + else + { + // Do not include style-related or language-related content + if (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0) + { + $update_list['no_update'][] = $file; + } + }*/ + + if (file_exists($phpbb_root_path . dirname($file)) || (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0)) + { + $this->get_custom_info($update_list['new'], $file); + $update_list['new'][] = array('filename' => $file, 'custom' => false); + } + + // unset($this->update_info['files'][$index]); + } + else + { + // not modified? + $this->make_update_diff($update_list, $file, $file); + } + + $num_bytes_processed += (file_exists($this->new_location . $file)) ? filesize($this->new_location . $file) : 100 * 1024; + $update_list['status']++; + } + + $update_list['status'] = -1; +/* if (!sizeof($this->update_info['files'])) + { + return $update_list; + } + + // Now diff the remaining files to get information about their status (not modified/modified/up-to-date) + + // not modified? + foreach ($this->update_info['files'] as $index => $file) + { + $this->make_update_diff($update_list, $file, $file); + } + + // Now to the styles... + if (empty($this->update_info['custom'])) + { + return $update_list; + } + + foreach ($this->update_info['custom'] as $original_file => $file_ary) + { + foreach ($file_ary as $index => $file) + { + $this->make_update_diff($update_list, $original_file, $file, true); + } + } + + return $update_list;*/ + } + + /** + * Compare files for storage in update_list + */ + function make_update_diff(&$update_list, $original_file, $file, $custom = false) + { + global $phpbb_root_path, $user; + + $update_ary = array('filename' => $file, 'custom' => $custom); + + if ($custom) + { + $update_ary['original'] = $original_file; + } + + // we only want to know if the files are successfully merged and newlines could result in errors (duplicate addition of lines and such things) + // Therefore we check for empty diffs with two methods, preserving newlines and not preserving them (which mostly works best, therefore the first option) + + // On a successfull update the new location file exists but the old one does not exist. + // Check for this circumstance, the new file need to be up-to-date with the current file then... + if (!file_exists($this->old_location . $original_file) && file_exists($this->new_location . $original_file) && file_exists($phpbb_root_path . $file)) + { + $tmp = array( + 'file1' => file_get_contents($this->new_location . $original_file), + 'file2' => file_get_contents($phpbb_root_path . $file), + ); + + // We need to diff the contents here to make sure the file is really the one we expect + $diff = new diff($tmp['file1'], $tmp['file2'], false); + $empty = $diff->is_empty(); + + unset($tmp, $diff); + + // if there are no differences we have an up-to-date file... + if ($empty) + { + $update_list['up_to_date'][] = $update_ary; + return; + } + + // If no other status matches we have another file in the way... + $update_list['new_conflict'][] = $update_ary; + return; + } + + // Old file removed? + if (file_exists($this->old_location . $original_file) && !file_exists($this->new_location . $original_file)) + { + return; + } + + // Check for existance, else abort immediately + if (!file_exists($this->old_location . $original_file) || !file_exists($this->new_location . $original_file)) + { + trigger_error($user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); + } + + $preserve_cr_ary = array(false, true); + + foreach ($preserve_cr_ary as $preserve_cr) + { + $tmp = array( + 'file1' => file_get_contents($this->old_location . $original_file), + 'file2' => file_get_contents($phpbb_root_path . $file), + ); + + // We need to diff the contents here to make sure the file is really the one we expect + $diff = new diff($tmp['file1'], $tmp['file2'], $preserve_cr); + $empty_1 = $diff->is_empty(); + + unset($tmp, $diff); + + $tmp = array( + 'file1' => file_get_contents($this->new_location . $original_file), + 'file2' => file_get_contents($phpbb_root_path . $file), + ); + + $diff = new diff($tmp['file1'], $tmp['file2'], $preserve_cr); + $empty_2 = $diff->is_empty(); + + unset($tmp, $diff); + + // If the file is not modified we are finished here... + if ($empty_1) + { + // Further check if it is already up to date - it could happen that non-modified files + // slip through + if ($empty_2) + { + $update_list['up_to_date'][] = $update_ary; + return; + } + + $update_list['not_modified'][] = $update_ary; + return; + } + + // If the file had been modified then we need to check if it is already up to date + + // if there are no differences we have an up-to-date file... + if ($empty_2) + { + $update_list['up_to_date'][] = $update_ary; + return; + } + } + + $conflicts = false; + + foreach ($preserve_cr_ary as $preserve_cr) + { + // if the file is modified we try to make sure a merge succeed + $tmp = array( + 'orig' => file_get_contents($this->old_location . $original_file), + 'final1' => file_get_contents($phpbb_root_path . $file), + 'final2' => file_get_contents($this->new_location . $original_file), + ); + + $diff = new diff3($tmp['orig'], $tmp['final1'], $tmp['final2'], $preserve_cr); + unset($tmp); + + if (!$diff->get_num_conflicts()) + { + $tmp = array( + 'file1' => file_get_contents($phpbb_root_path . $file), + 'file2' => implode("\n", $diff->merged_output()), + ); + + // now compare the merged output with the original file to see if the modified file is up to date + $diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr); + $empty = $diff2->is_empty(); + + unset($diff, $diff2); + + if ($empty) + { + $update_list['up_to_date'][] = $update_ary; + return; + } + + // If we preserve cr tag it as modified because the conflict would not show in this mode anyway + if ($preserve_cr) + { + $update_list['modified'][] = $update_ary; + return; + } + } + else + { + // There is one special case... users having merged with a conflicting file... we need to check this + $tmp = array( + 'file1' => file_get_contents($phpbb_root_path . $file), + 'file2' => implode("\n", $diff->merged_new_output()), + ); + + $diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr); + $empty = $diff2->is_empty(); + + if (!$empty) + { + unset($tmp, $diff2); + + // We check if the user merged with his output + $tmp = array( + 'file1' => file_get_contents($phpbb_root_path . $file), + 'file2' => implode("\n", $diff->merged_orig_output()), + ); + + $diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr); + $empty = $diff2->is_empty(); + } + + if (!$empty) + { + $conflicts = $diff->get_num_conflicts(); + } + + unset($diff, $diff2); + + if ($empty) + { + // A conflict got resolved... + $update_list['up_to_date'][] = $update_ary; + return; + } + } + } + + if ($conflicts !== false) + { + $update_ary['conflicts'] = $conflicts; + $update_list['conflict'][] = $update_ary; + return; + } + + // If no other status matches we have a modified file... + $update_list['modified'][] = $update_ary; + } + + /** + * Update update_list with custom new files + */ + function get_custom_info(&$update_list, $file) + { + if (empty($this->update_info['custom'])) + { + return; + } + + if (isset($this->update_info['custom'][$file])) + { + foreach ($this->update_info['custom'][$file] as $_file) + { + $update_list[] = array('filename' => $_file, 'custom' => true, 'original' => $file); + } + } + } + + /** + * Get remote file + */ + function get_file($mode) + { + global $user, $db; + + $errstr = ''; + $errno = 0; + + switch ($mode) + { + case 'version_info': + global $phpbb_root_path, $phpEx; + $info = get_remote_file('www.phpbb.com', '/updatecheck', ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); + + if ($info !== false) + { + $info = explode("\n", $info); + $info = trim($info[0]); + } + + if ($this->test_update !== false) + { + $info = $this->test_update; + } + + // If info is false the fsockopen function may not be working. Instead get the latest version from our update file (and pray it is up-to-date) + if ($info === false) + { + $update_info = array(); + include($phpbb_root_path . 'install/update/index.' . $phpEx); + $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; + + if ($info !== false) + { + $info = (!empty($info['version']['to'])) ? trim($info['version']['to']) : false; + } + } + break; + + case 'update_info': + global $phpbb_root_path, $phpEx; + + $update_info = array(); + include($phpbb_root_path . 'install/update/index.' . $phpEx); + + $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; + $errstr = ($info === false) ? $user->lang['WRONG_INFO_FILE_FORMAT'] : ''; + + if ($info !== false) + { + // We assume that all file extensions have been renamed to .$phpEx, + // if someone is using a non .php file extension for php files. + // However, in $update_info['files'] we use hardcoded .php. + // We therefore replace .php with .$phpEx. + $info['files'] = preg_replace('/\.php$/i', ".$phpEx", $info['files']); + + // Adjust the update info file to hold some specific style-related information + $info['custom'] = array(); +/* + // Get custom installed styles... + $sql = 'SELECT template_name, template_path + FROM ' . STYLES_TEMPLATE_TABLE . " + WHERE LOWER(template_name) NOT IN ('subsilver2', 'prosilver')"; + $result = $db->sql_query($sql); + + $templates = array(); + while ($row = $db->sql_fetchrow($result)) + { + $templates[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($templates)) + { + foreach ($info['files'] as $filename) + { + // Template update? + if (strpos(strtolower($filename), 'styles/prosilver/template/') === 0) + { + foreach ($templates as $row) + { + $info['custom'][$filename][] = str_replace('/prosilver/', '/' . $row['template_path'] . '/', $filename); + } + } + } + } +*/ + } + break; + + default: + trigger_error('Mode for getting remote file not specified', E_USER_ERROR); + break; + } + + if ($info === false) + { + trigger_error($errstr, E_USER_ERROR); + } + + return $info; + } + + /** + * Function for including files... + */ + function include_file($filename) + { + global $phpbb_root_path, $phpEx; + + if (!empty($this->update_info['files']) && in_array($filename, $this->update_info['files'])) + { + include_once($this->new_location . $filename); + } + else + { + include_once($phpbb_root_path . $filename); + } + } + + /** + * Wrapper for returning a diff object + */ + function return_diff() + { + $args = func_get_args(); + $three_way_diff = (func_num_args() > 2) ? true : false; + + $file1 = array_shift($args); + $file2 = array_shift($args); + + $tmp['file1'] = (!empty($file1) && is_string($file1)) ? file_get_contents($file1) : $file1; + $tmp['file2'] = (!empty($file2) && is_string($file2)) ? file_get_contents($file2) : $file2; + + if ($three_way_diff) + { + $file3 = array_shift($args); + $tmp['file3'] = (!empty($file3) && is_string($file3)) ? file_get_contents($file3) : $file3; + + $diff = new diff3($tmp['file1'], $tmp['file2'], $tmp['file3']); + } + else + { + $diff = new diff($tmp['file1'], $tmp['file2']); + } + + unset($tmp); + + return $diff; + } +} + +?> \ No newline at end of file -- cgit v1.2.1 From b68de2323d6444b4b3685a98bbcb9500a38e45cb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 16 Dec 2009 15:48:23 +0000 Subject: merge changes from 3.0.x branch git-svn-id: file:///svn/phpbb/trunk@10342 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install_update.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index ab7ec35705..9f5a428029 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -262,6 +262,16 @@ class install_update extends module $template->assign_var('PACKAGE_VERSION', $this->update_info['version']['to']); } + // Since some people try to update to RC releases, but phpBB.com tells them the last version is the version they currently run + // we are faced with the updater thinking the database schema is up-to-date; which it is, but should be updated none-the-less + // We now try to cope with this by triggering the update process + if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '<')) + { + $template->assign_vars(array( + 'S_UP_TO_DATE' => false, + )); + } + break; case 'update_db': @@ -917,7 +927,7 @@ class install_update extends module { if (function_exists('phpbb_is_writable') && !phpbb_is_writable($phpbb_root_path . 'store/')) { - trigger_error(sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $phpbb_root_path . 'store/'), E_USER_ERROR); + trigger_error(sprintf('The directory “%s” is not writable.', $phpbb_root_path . 'store/'), E_USER_ERROR); } if ($use_method == '.zip') -- cgit v1.2.1 From fccd7f0ab5ab559dc89be6af9e582a986af8bb13 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 22 Sep 2010 21:58:20 +0200 Subject: [feature/request-class] Convert any direct access to $_* to use $request PHPBB3-9716 --- phpBB/install/install_update.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 6184cbbc33..1399a99a31 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -73,6 +73,7 @@ class install_update extends module function main($mode, $sub) { global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; + global $request; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; @@ -251,7 +252,7 @@ class install_update extends module $this->include_file('includes/diff/renderer.' . $phpEx); // Make sure we stay at the file check if checking the files again - if (!empty($_POST['check_again'])) + if ($request->variable('check_again', false, false, phpbb_request_interface::POST)) { $sub = $this->p_master->sub = 'file_check'; } @@ -358,7 +359,7 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = (!empty($_POST['check_again'])) ? false : $cache->get('_update_list'); + $update_list = ($request->variable('check_again', false, false, phpbb_request_interface::POST)) ? false : $cache->get('_update_list'); $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . $phpEx) : 0; // Make sure the list is up-to-date @@ -714,7 +715,7 @@ class install_update extends module { $cache->put('_diff_files', $file_list); - if (!empty($_REQUEST['download'])) + if ($request->variable('download', false)) { $params[] = 'download=1'; } @@ -829,7 +830,7 @@ class install_update extends module $file_list['status'] = -1; $cache->put('_diff_files', $file_list); - if (!empty($_REQUEST['download'])) + if ($request->variable('download', false)) { $this->include_file('includes/functions_compress.' . $phpEx); @@ -963,7 +964,7 @@ class install_update extends module 'DATA' => $data, 'NAME' => $user->lang[strtoupper($method . '_' . $data)], 'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], - 'DEFAULT' => (!empty($_REQUEST[$data])) ? request_var($data, '') : $default + 'DEFAULT' => $request->variable($data, (string) $default), )); } -- cgit v1.2.1 From af5b9a96409d788733fcb1ff367e0c7fb0583702 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 9 Nov 2010 08:59:25 +0100 Subject: [ticket/9556] Drop php closing tags, add trailing newline Closing tags converted using Oleg's script. remove-php-end-tags.py -a . Trailing newlines added using the following where $ext is file extension. find . -type f -name "*.$ext" -print | xargs printf "e %s\nw\n" | ed -s; Extensions: php, css, html, js, xml. PHPBB3-9556 --- phpBB/install/install_update.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 39c74d272b..2e78803b74 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1796,5 +1796,3 @@ class install_update extends module return $diff; } } - -?> \ No newline at end of file -- cgit v1.2.1 From fb2642bbc6360dacfd4a3cc9f7e9447b02cb46a1 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 10 Jan 2011 02:27:18 +0100 Subject: [task/config-class] Implemented a config class to replace the global array. There is a phpbb_config class which simply holds an array and does not persist any data. It implements ArrayAccess, Countable and IteratorAggregate to allow regular use of configuration as if it was still an array. The phpbb_config_db class depends on an instance of the dbal and a cache driver. It obtains the configuration data from cache and database as necessary and persists data to the database. The functions set_config and set_config_count remain for backward compatability but they only call methods on the new config class now instead of directly manipulating the database and cache. PHPBB3-9988 --- phpBB/install/install_update.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 2e78803b74..7c91b112a2 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -101,17 +101,8 @@ class install_update extends module // We do not need this any longer, unset for safety purposes unset($dbpasswd); - $config = array(); - - $sql = 'SELECT config_name, config_value - FROM ' . CONFIG_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $config[$row['config_name']] = $row['config_value']; - } - $db->sql_freeresult($result); + // We need to fill the config to let internal functions correctly work + $config = new phpbb_config_db($db, new phpbb_cache_driver_null); // Force template recompile $config['load_tplcompile'] = 1; -- cgit v1.2.1 From 6b1e343d8dae618afd0cb04173749f005c10e376 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 11 Jan 2011 23:25:51 +0100 Subject: [task/config-class] Always specify the config table to use. PHPBB3-9988 --- phpBB/install/install_update.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 7c91b112a2..5c3a38d237 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -102,7 +102,9 @@ class install_update extends module unset($dbpasswd); // We need to fill the config to let internal functions correctly work - $config = new phpbb_config_db($db, new phpbb_cache_driver_null); + $config = new phpbb_config_db($db, new phpbb_cache_driver_null, CONFIG_TABLE); + set_config(null, null, null, $config); + set_config_count(null, null, null, $config); // Force template recompile $config['load_tplcompile'] = 1; -- cgit v1.2.1 From 9e4349e7faac65403de02fd090a837fee92b764a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Sep 2008 11:39:25 +0000 Subject: [feature/remove-db-styles] Removed database storage of style components. The bulk of database storage of templates is removed, rendering template stored in the database as useless. Theme database storage is reduced to a skeleton for full removal soon. This commit was cherry picked from the old feature/ascraeus-experiment branch the old commit hash is 0dbe7e3b6cd450342d3c566eb2caf36ca1b5db8e. PHPBB3-9741 --- phpBB/install/install_update.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 5c3a38d237..926b7cad46 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -134,9 +134,6 @@ class install_update extends module // Set custom template again. ;) $template->set_custom_template('../adm/style', 'admin'); - // still, the acp template is never stored in the database - $user->theme['template_storedb'] = false; - $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], -- cgit v1.2.1 From 7a04c9048c110f0bd21ea3e9e869e17b408d640e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 31 Dec 2011 13:32:52 +0000 Subject: [ticket/9916] Updating header license and removing Version $Id$ PHPBB3-9916 --- phpBB/install/install_update.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 926b7cad46..9f50a56595 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -2,9 +2,8 @@ /** * * @package install -* @version $Id$ * @copyright (c) 2006 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * * @todo check for writable cache/store/files directory */ -- cgit v1.2.1 From ae3b0f736d45690d37a10a453a98e598166e8506 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 14 Mar 2012 23:18:18 +0200 Subject: [feature/merging-style-components] Updating database and acp modules Removing theme and template tables, adding new columns to styles table, deleting acp modules, deleting code that updates theme in updater PHPBB3-10632 --- phpBB/install/install_update.php | 58 +++------------------------------------- 1 file changed, 4 insertions(+), 54 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 9f50a56595..aba692aa62 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -504,56 +504,6 @@ class install_update extends module // Add database update to log add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->update_to_version); - // Refresh prosilver css data - this may cause some unhappy users, but - $sql = 'SELECT * - FROM ' . STYLES_THEME_TABLE . " - WHERE LOWER(theme_name) = 'prosilver'"; - $result = $db->sql_query($sql); - $theme = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($theme) - { - $recache = (empty($theme['theme_data'])) ? true : false; - $update_time = time(); - - // We test for stylesheet.css because it is faster and most likely the only file changed on common themes - if (!$recache && $theme['theme_mtime'] < @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css')) - { - $recache = true; - $update_time = @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css'); - } - else if (!$recache) - { - $last_change = $theme['theme_mtime']; - $dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme"); - - if ($dir) - { - while (($entry = readdir($dir)) !== false) - { - if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}")) - { - $recache = true; - break; - } - } - closedir($dir); - } - } - - if ($recache) - { - // Instead of re-caching here, we simply remove theme_data... HAR HAR HAR (think about a carribean pirate) - $sql = 'UPDATE ' . STYLES_THEME_TABLE . " SET theme_data = '' - WHERE theme_id = " . $theme['theme_id']; - $db->sql_query($sql); - - $cache->destroy('sql', STYLES_THEME_TABLE); - $cache->destroy('sql', STYLES_TABLE); - } - } - $db->sql_return_on_error(true); $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); $db->sql_return_on_error(false); @@ -1694,9 +1644,9 @@ class install_update extends module $info['custom'] = array(); /* // Get custom installed styles... - $sql = 'SELECT template_name, template_path - FROM ' . STYLES_TEMPLATE_TABLE . " - WHERE LOWER(template_name) NOT IN ('subsilver2', 'prosilver')"; + $sql = 'SELECT style_name, style_path + FROM ' . STYLES_TABLE . " + WHERE LOWER(style_name) NOT IN ('subsilver2', 'prosilver')"; $result = $db->sql_query($sql); $templates = array(); @@ -1715,7 +1665,7 @@ class install_update extends module { foreach ($templates as $row) { - $info['custom'][$filename][] = str_replace('/prosilver/', '/' . $row['template_path'] . '/', $filename); + $info['custom'][$filename][] = str_replace('/prosilver/', '/' . $row['style_path'] . '/', $filename); } } } -- cgit v1.2.1 From fd96f97dc3c659e1d2e9b58420d652ad79387fbf Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 21:11:34 +0200 Subject: [feature/merging-style-components] Updating style initialization Changing template initialization to style initialization. PHPBB3-10632 --- phpBB/install/install_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index aba692aa62..dcf01e5cc8 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -71,7 +71,7 @@ class install_update extends module function main($mode, $sub) { - global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; + global $style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request; $this->tpl_name = 'install_update'; @@ -131,7 +131,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_template('../adm/style', 'admin'); + $style->set_custom_style('admin', '../adm/style', ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From 57065095d570f0ff5976470ce81a4b216fe5f98e Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 3 Apr 2012 00:41:56 +0300 Subject: [ticket/10754] Changing $style to $phpbb_style Renaming global variable $style to $phpbb_style PHPBB3-10754 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index dcf01e5cc8..c2feaa086a 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -131,7 +131,7 @@ class install_update extends module } // Set custom template again. ;) - $style->set_custom_style('admin', '../adm/style', ''); + $phpbb_style->set_custom_style('admin', '../adm/style', ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From 90a957ad26f52e26c3979464c5ac15b1fd0fcc28 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 17:43:43 +0200 Subject: [ticket/11015] Make DBAL classes autoloadable PHPBB3-11015 This allows us to just create the object without having to include the driver first. However, it also means that users must specify the full class name in config.php --- phpBB/install/install_update.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index c2feaa086a..fb76420033 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -83,7 +83,6 @@ class install_update extends module // Init DB require($phpbb_root_path . 'config.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); // Special options for conflicts/modified files @@ -92,7 +91,7 @@ class install_update extends module define('MERGE_NEW_FILE', 3); define('MERGE_MOD_FILE', 4); - $db = new $sql_db(); + $db = new $dbms(); // Connect to DB $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); -- cgit v1.2.1 From 01bc818d465ab168288e260745a045ff2794648d Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 30 Jul 2012 18:44:40 -0500 Subject: [ticket/10875] Fix SQL Caching The sql_save function cannot take arguments by reference since it is called by call_user_func_array() Replace use of isset($cache->sql_rowset[$query_id]) with $cache->sql_exists Replace $cache->cache_dir with $cache->get_driver()->cache_dir PHPBB3-10875 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index c2feaa086a..88b00f1cf1 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -349,7 +349,7 @@ class install_update extends module // We are directly within an update. To make sure our update list is correct we check its status. $update_list = ($request->variable('check_again', false, false, phpbb_request_interface::POST)) ? false : $cache->get('_update_list'); - $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . $phpEx) : 0; + $modified = ($update_list !== false) ? @filemtime($cache->get_driver()->cache_dir . 'data_update_list.' . $phpEx) : 0; // Make sure the list is up-to-date if ($update_list !== false) -- cgit v1.2.1 From b3cd5a649be62f175de651a16ae02c5f709ca2f4 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 3 Sep 2012 13:32:33 -0500 Subject: [ticket/8713] Do not trim login inputs Create a function to request variables which are not trimmed. All requests for passwords (except forum passwords) now use the untrimmed request function. PHPBB3-8713 --- phpBB/install/install_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 88b00f1cf1..4b5a23e497 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -862,7 +862,7 @@ class install_update extends module $test_connection = false; if ($test_ftp_connection || $submit) { - $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $test_connection = $transfer->open_session(); // Make sure that the directory is correct by checking for the existence of common.php @@ -948,7 +948,7 @@ class install_update extends module } else { - $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $transfer->open_session(); } -- cgit v1.2.1 From f2607fc9e80c6f9ad7543b7be5ea6f294aa6c40a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 14:15:56 +0200 Subject: [ticket/8713] Rename untrimed_variable() to untrimmed_variable(). PHPBB3-8713 --- phpBB/install/install_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 4b5a23e497..1ecedecce6 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -862,7 +862,7 @@ class install_update extends module $test_connection = false; if ($test_ftp_connection || $submit) { - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $test_connection = $transfer->open_session(); // Make sure that the directory is correct by checking for the existence of common.php @@ -948,7 +948,7 @@ class install_update extends module } else { - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $transfer->open_session(); } -- cgit v1.2.1 From cc0c378caf9bfc480391a9d11d5a4d78c0df097c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 14:40:35 +0200 Subject: [ticket/8713] Call htmlspecialchars_decode() on transfer (e.g. ftp) passwords. PHPBB3-8713 --- phpBB/install/install_update.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 1ecedecce6..8c044550f3 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -862,7 +862,14 @@ class install_update extends module $test_connection = false; if ($test_ftp_connection || $submit) { - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method( + request_var('host', ''), + request_var('username', ''), + htmlspecialchars_decode($request->untrimmed_variable('password', '')), + request_var('root_path', ''), + request_var('port', ''), + request_var('timeout', '') + ); $test_connection = $transfer->open_session(); // Make sure that the directory is correct by checking for the existence of common.php @@ -948,7 +955,14 @@ class install_update extends module } else { - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method( + request_var('host', ''), + request_var('username', ''), + htmlspecialchars_decode($request->untrimmed_variable('password', '')), + request_var('root_path', ''), + request_var('port', ''), + request_var('timeout', '') + ); $transfer->open_session(); } -- cgit v1.2.1 From 5bc0f4b3d49ed1bea45464beece42906646eb026 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 17 Nov 2012 00:24:32 +0100 Subject: [ticket/11015] Move db driver class name fixing to function PHPBB3-11015 --- phpBB/install/install_update.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 7d0d627e9d..a556056382 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -91,6 +91,8 @@ class install_update extends module define('MERGE_NEW_FILE', 3); define('MERGE_MOD_FILE', 4); + $dbms = phpbb_convert_30_dbms_to_31($dbms); + $db = new $dbms(); // Connect to DB -- cgit v1.2.1 From 98921e0b87b25fcd5985edb747d5768cd8ccf18e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 17 Nov 2012 01:17:45 +0100 Subject: [ticket/11213] Add missing global in install_update.php PHPBB3-11213 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 8c044550f3..7f40015002 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -71,7 +71,7 @@ class install_update extends module function main($mode, $sub) { - global $style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; + global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request; $this->tpl_name = 'install_update'; -- cgit v1.2.1 From 44d6dc4c4ccf969fd3d84f3b39bfd24ecd3a3f9d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 8 Nov 2012 12:21:06 -0500 Subject: [feature/template-events] Convert a single style name to array of them. This allows template code to know the entire style hierarchy for templates being rendered. PHPBB3-9550 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 8c044550f3..3964dbfe2b 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -131,7 +131,7 @@ class install_update extends module } // Set custom template again. ;) - $phpbb_style->set_custom_style('admin', '../adm/style', ''); + $phpbb_style->set_custom_style('admin', '../adm/style', array(), ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From 6dee2539419ba2c050830b7677294603a63b559a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Dec 2012 17:01:08 -0600 Subject: [ticket/11259] Make phpbb_admin_path available everywhere PHPBB3-11259 --- phpBB/install/install_update.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 7f40015002..679850db31 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -72,7 +72,7 @@ class install_update extends module function main($mode, $sub) { global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; - global $request; + global $request, $phpbb_admin_path, $adm_relative_path; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; @@ -131,7 +131,7 @@ class install_update extends module } // Set custom template again. ;) - $phpbb_style->set_custom_style('admin', '../adm/style', ''); + $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], @@ -216,7 +216,7 @@ class install_update extends module if ($this->test_update === false) { // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present - if (in_array('adm/style/install_update.html', $this->update_info['files'])) + if (in_array($adm_relative_path . 'style/install_update.html', $this->update_info['files'])) { $this->tpl_name = '../../install/update/new/adm/style/install_update'; } @@ -493,6 +493,7 @@ class install_update extends module $template->assign_vars(array( 'S_FILE_CHECK' => true, 'S_ALL_UP_TO_DATE' => $all_up_to_date, + 'L_ALL_FILES_UP_TO_DATE' => $user->lang('ALL_FILES_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), 'S_VERSION_UP_TO_DATE' => $up_to_date, 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files"), @@ -1077,12 +1078,12 @@ class install_update extends module */ function show_diff(&$update_list) { - global $phpbb_root_path, $template, $user; + global $phpbb_root_path, $template, $user, $adm_relative_path; $this->tpl_name = 'install_update_diff'; // Got the diff template itself updated? If so, we are able to directly use it - if (in_array('adm/style/install_update_diff.html', $this->update_info['files'])) + if (in_array($adm_relative_path . 'style/install_update_diff.html', $this->update_info['files'])) { $this->tpl_name = '../../install/update/new/adm/style/install_update_diff'; } -- cgit v1.2.1 From 30de17f69f70a0c23fa314de479bac57e3dbae2b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Dec 2012 19:29:51 -0600 Subject: [ticket/11259] adm_relative_path -> phpbb_adm_relative_path We can assume they properly format their config settings, right? PHPBB3-11259 --- phpBB/install/install_update.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 679850db31..55dba9a935 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -72,7 +72,7 @@ class install_update extends module function main($mode, $sub) { global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; - global $request, $phpbb_admin_path, $adm_relative_path; + global $request, $phpbb_admin_path, $phpbb_adm_relative_path; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; @@ -216,7 +216,7 @@ class install_update extends module if ($this->test_update === false) { // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present - if (in_array($adm_relative_path . 'style/install_update.html', $this->update_info['files'])) + if (in_array($phpbb_adm_relative_path . 'style/install_update.html', $this->update_info['files'])) { $this->tpl_name = '../../install/update/new/adm/style/install_update'; } @@ -493,7 +493,7 @@ class install_update extends module $template->assign_vars(array( 'S_FILE_CHECK' => true, 'S_ALL_UP_TO_DATE' => $all_up_to_date, - 'L_ALL_FILES_UP_TO_DATE' => $user->lang('ALL_FILES_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), + 'L_ALL_FILES_UP_TO_DATE' => $user->lang('ALL_FILES_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), 'S_VERSION_UP_TO_DATE' => $up_to_date, 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files"), @@ -1078,12 +1078,12 @@ class install_update extends module */ function show_diff(&$update_list) { - global $phpbb_root_path, $template, $user, $adm_relative_path; + global $phpbb_root_path, $template, $user, $phpbb_adm_relative_path; $this->tpl_name = 'install_update_diff'; // Got the diff template itself updated? If so, we are able to directly use it - if (in_array($adm_relative_path . 'style/install_update_diff.html', $this->update_info['files'])) + if (in_array($phpbb_adm_relative_path . 'style/install_update_diff.html', $this->update_info['files'])) { $this->tpl_name = '../../install/update/new/adm/style/install_update_diff'; } -- cgit v1.2.1 From cc902ddee09c3d516a27c26fbf19af8f772814e6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Apr 2013 11:26:13 -0500 Subject: [ticket/11479] Fix install/update (rebuild container) Code copied from fix in 11305 PHPBB3-11479 --- phpBB/install/install_update.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index bfceed6b17..cf800aefd4 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -72,7 +72,24 @@ class install_update extends module function main($mode, $sub) { global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; - global $request, $phpbb_admin_path, $phpbb_adm_relative_path; + global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; + + // Create a normal container now + $phpbb_container = phpbb_create_dumped_container_unless_debug( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), + ), + array( + new phpbb_di_pass_collection_pass(), + new phpbb_di_pass_kernel_pass(), + ), + $phpbb_root_path, + $phpEx + ); + + // Writes into global $cache + $cache = $phpbb_container->get('cache'); $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; -- cgit v1.2.1 From 4becf85f5274bbe861da05917ab466eb072ea600 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 24 Apr 2013 14:58:27 -0500 Subject: [ticket/11479] Use phpbb_create_default_container PHPBB3-11479 --- phpBB/install/install_update.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index cf800aefd4..aa1bd0fa35 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -75,18 +75,7 @@ class install_update extends module global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; // Create a normal container now - $phpbb_container = phpbb_create_dumped_container_unless_debug( - array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), - ), - array( - new phpbb_di_pass_collection_pass(), - new phpbb_di_pass_kernel_pass(), - ), - $phpbb_root_path, - $phpEx - ); + $phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); // Writes into global $cache $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From 14ff1ef540f71e765ceeaa53b87ad62e4c8d8a40 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 14:44:49 +0200 Subject: [ticket/11574] Create phpbb_log object before using it. PHPBB3-11574 --- phpBB/install/install_update.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index df9b6c1c7e..90c56bcdcc 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -509,6 +509,9 @@ class install_update extends module if ($all_up_to_date) { + global $phpbb_log, $phpbb_container; + $phpbb_log = $phpbb_container->get('log'); + // Add database update to log add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->update_to_version); -- cgit v1.2.1 From fe7823b6685975012d3c033b335d7ed5fa9756d7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 19:26:37 +0200 Subject: [ticket/11574] Use log object instead of old function PHPBB3-11574 --- phpBB/install/install_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 90c56bcdcc..38d9f66629 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -509,11 +509,11 @@ class install_update extends module if ($all_up_to_date) { - global $phpbb_log, $phpbb_container; + global $phpbb_container; $phpbb_log = $phpbb_container->get('log'); // Add database update to log - add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->update_to_version); + $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_UPDATE_PHPBB', time(), array($this->current_version, $this->update_to_version)); $db->sql_return_on_error(true); $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); -- cgit v1.2.1 From d6de892ee40579c45259f8c68ba7eef26accc08b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 13 Jul 2013 16:47:15 -0400 Subject: [ticket/11574] Fix various path issues in the updater PHPBB3-11574 --- phpBB/install/install_update.php | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 38d9f66629..f9dfaaef50 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -75,7 +75,7 @@ class install_update extends module global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; // Create a normal container now - $phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); + $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config'); // Writes into global $cache $cache = $phpbb_container->get('cache'); @@ -125,7 +125,7 @@ class install_update extends module $config['default_lang'] = $language; $user->data['user_lang'] = $language; - $user->setup(array('common', 'acp/common', 'acp/board', 'install', 'posting')); + $user->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); // Reset the default_lang $config['default_lang'] = $config_default_lang; @@ -302,30 +302,6 @@ class install_update extends module break; case 'update_db': - - // Make sure the database update is valid for the latest version - $valid = false; - $updates_to_version = ''; - - if (file_exists($phpbb_root_path . 'install/database_update.' . $phpEx)) - { - include_once($phpbb_root_path . 'install/database_update.' . $phpEx); - - if ($updates_to_version === $this->update_info['version']['to']) - { - $valid = true; - } - } - - // Should not happen at all - if (!$valid) - { - trigger_error($user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); - } - - // Just a precaution - $cache->purge(); - // Redirect the user to the database update script with some explanations... $template->assign_vars(array( 'S_DB_UPDATE' => true, -- cgit v1.2.1 From da2752e4004b296ae5acdd08b7c0a758d8f61e9d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 13:30:52 -0400 Subject: [ticket/11700] Modify all code to use the new interface names PHPBB3-11700 --- phpBB/install/install_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index df9b6c1c7e..2d165b551a 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -248,7 +248,7 @@ class install_update extends module $this->include_file('includes/diff/renderer.' . $phpEx); // Make sure we stay at the file check if checking the files again - if ($request->variable('check_again', false, false, phpbb_request_interface::POST)) + if ($request->variable('check_again', false, false, phpbb_request_request_interface::POST)) { $sub = $this->p_master->sub = 'file_check'; } @@ -355,7 +355,7 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = ($request->variable('check_again', false, false, phpbb_request_interface::POST)) ? false : $cache->get('_update_list'); + $update_list = ($request->variable('check_again', false, false, phpbb_request_request_interface::POST)) ? false : $cache->get('_update_list'); $modified = ($update_list !== false) ? @filemtime($cache->get_driver()->cache_dir . 'data_update_list.' . $phpEx) : 0; // Make sure the list is up-to-date -- cgit v1.2.1 From 8928240dc3fefd42d8e98132451e2de92ff7cbec Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 14 Jul 2013 15:40:09 -0400 Subject: [ticket/11574] Fix more issues in the updater * Stupid mistake in phpbb_create_update_container * Do not bootstrap extensions in installer/updater * Fix template lookup in installer/updater * Do not attempt to delete posts from bots The latter is a really fun problem. Since deleting posts now depends on a new db column that does not exist yet, we cannot call delete_post from a migration, ever. By using retain, we can hack around the issue for now. PHPBB3-11574 --- phpBB/install/install_update.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index f9dfaaef50..478cc9f76f 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -222,12 +222,6 @@ class install_update extends module if ($this->test_update === false) { - // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present - if (in_array($phpbb_adm_relative_path . 'style/install_update.html', $this->update_info['files'])) - { - $this->tpl_name = '../../install/update/new/adm/style/install_update'; - } - // What about the language file? Got it updated? if (in_array('language/en/install.' . $phpEx, $this->update_info['files'])) { @@ -1068,12 +1062,6 @@ class install_update extends module $this->tpl_name = 'install_update_diff'; - // Got the diff template itself updated? If so, we are able to directly use it - if (in_array($phpbb_adm_relative_path . 'style/install_update_diff.html', $this->update_info['files'])) - { - $this->tpl_name = '../../install/update/new/adm/style/install_update_diff'; - } - $this->page_title = 'VIEWING_FILE_DIFF'; $status = request_var('status', ''); -- cgit v1.2.1 From 5d1afb453211d42a8deacb66684c136385918192 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:24:35 -0500 Subject: [ticket/11628] Remove phpbb_style (move methods to phpbb_template) PHPBB3-11628 --- phpBB/install/install_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index df9b6c1c7e..51fbd1975c 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -71,7 +71,7 @@ class install_update extends module function main($mode, $sub) { - global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; + global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; // Create a normal container now @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From 4b761f65758c40db4851983fa3a08d354da3323d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:55:41 -0500 Subject: [ticket/11628] Remove third parameter ($names) from set_custom_style This was basically duplicating functionality. $names would be used if not empty, else array($name) would be used. Merged functionality into the first argument PHPBB3-11628 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 51fbd1975c..63f10c96d7 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From 12c22585069066957cc3211136ebd480295d4758 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:25:20 -0500 Subject: [ticket/11628] Remove template_path option on set_custom_style This was set to default 'template/' to append template/ to all the paths, but every location was actually just setting it to '' to not append anything. So removed the option entirely (additional paths can be appended to the paths being sent to the function already) PHPBB3-11628 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 63f10c96d7..a105944fb3 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From 5bb08a1ab973ee13237876d11b001c4ed6658892 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 29 Jul 2013 21:30:01 +0200 Subject: [ticket/11574] Change order of files and database update PHPBB3-11574 --- phpBB/install/install_update.php | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 478cc9f76f..a8abfc7cfc 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -39,7 +39,7 @@ if (!empty($setmodules)) 'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), 'module_order' => 30, 'module_subs' => '', - 'module_stages' => array('INTRO', 'VERSION_CHECK', 'UPDATE_DB', 'FILE_CHECK', 'UPDATE_FILES'), + 'module_stages' => array('INTRO', 'VERSION_CHECK', 'FILE_CHECK', 'UPDATE_FILES', 'UPDATE_DB'), 'module_reqs' => '' ); } @@ -74,6 +74,11 @@ class install_update extends module global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; + // We must enable super globals, otherwise creating a new instance of the request class, + // using the new container with a dbal connection will fail with the following PHP Notice: + // Object of class phpbb_request_deactivated_super_global could not be converted to int + $request->enable_super_globals(); + // Create a normal container now $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config'); @@ -138,7 +143,9 @@ class install_update extends module } // Set custom template again. ;) - $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); + $paths = array_filter($paths, 'is_dir'); + $phpbb_style->set_custom_style('admin', $paths, array(), ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], @@ -267,15 +274,14 @@ class install_update extends module $this->page_title = 'STAGE_VERSION_CHECK'; $template->assign_vars(array( - 'S_UP_TO_DATE' => $up_to_date, 'S_VERSION_CHECK' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), + 'S_UP_TO_DATE' => $up_to_date, 'LATEST_VERSION' => $this->latest_version, - 'CURRENT_VERSION' => $this->current_version) - ); + 'CURRENT_VERSION' => $this->current_version, + )); // Print out version the update package updates to if ($this->unequal_version) @@ -303,6 +309,7 @@ class install_update extends module 'U_DB_UPDATE' => append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=1&language=' . $user->data['user_lang']), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), + 'L_EVERYTHING_UP_TO_DATE' => $user->lang('EVERYTHING_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), )); break; @@ -470,13 +477,23 @@ class install_update extends module $template->assign_vars(array( 'S_FILE_CHECK' => true, 'S_ALL_UP_TO_DATE' => $all_up_to_date, - 'L_ALL_FILES_UP_TO_DATE' => $user->lang('ALL_FILES_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), 'S_VERSION_UP_TO_DATE' => $up_to_date, + 'S_UP_TO_DATE' => $up_to_date, 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files"), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), )); + // Since some people try to update to RC releases, but phpBB.com tells them the last version is the version they currently run + // we are faced with the updater thinking the database schema is up-to-date; which it is, but should be updated none-the-less + // We now try to cope with this by triggering the update process + if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '<')) + { + $template->assign_vars(array( + 'S_UP_TO_DATE' => false, + )); + } + if ($all_up_to_date) { global $phpbb_container; -- cgit v1.2.1 From 0ff2e93c1937f96f8fcd733a152a0c2f263706b1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2013 01:18:32 +0200 Subject: [ticket/11574] Do not display incompatible package note after successful update PHPBB3-11574 --- phpBB/install/install_update.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index dce0134730..4ae39f202f 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -313,6 +313,11 @@ class install_update extends module 'L_EVERYTHING_UP_TO_DATE' => $user->lang('EVERYTHING_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), )); + // Do not display incompatible package note after successful update + if ($config['version'] == $this->update_info['version']['to']) + { + $template->assign_var('S_ERROR', false); + } break; case 'file_check': -- cgit v1.2.1 From 8ee86b75908141c28aa4d92ba93921337cde30c3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 28 Aug 2013 13:40:35 -0500 Subject: [ticket/11791] Load adm/ events from styles/adm/event/ PHPBB3-11791 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index a569e0ad9a..8ab0ad49d3 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -143,7 +143,7 @@ class install_update extends module // Set custom template again. ;) $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); $paths = array_filter($paths, 'is_dir'); - $template->set_custom_style('admin', $paths); + $template->set_custom_style('adm', $paths); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- phpBB/install/install_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 2d165b551a..b61ee277b4 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -108,7 +108,7 @@ class install_update extends module unset($dbpasswd); // We need to fill the config to let internal functions correctly work - $config = new phpbb_config_db($db, new phpbb_cache_driver_null, CONFIG_TABLE); + $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); set_config(null, null, null, $config); set_config_count(null, null, null, $config); @@ -248,7 +248,7 @@ class install_update extends module $this->include_file('includes/diff/renderer.' . $phpEx); // Make sure we stay at the file check if checking the files again - if ($request->variable('check_again', false, false, phpbb_request_request_interface::POST)) + if ($request->variable('check_again', false, false, \phpbb\request\request_interface::POST)) { $sub = $this->p_master->sub = 'file_check'; } @@ -355,7 +355,7 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = ($request->variable('check_again', false, false, phpbb_request_request_interface::POST)) ? false : $cache->get('_update_list'); + $update_list = ($request->variable('check_again', false, false, \phpbb\request\request_interface::POST)) ? false : $cache->get('_update_list'); $modified = ($update_list !== false) ? @filemtime($cache->get_driver()->cache_dir . 'data_update_list.' . $phpEx) : 0; // Make sure the list is up-to-date -- cgit v1.2.1 From 7aa4d8fce2e61776d5f2dbf67386a589bcd7d634 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Nov 2013 12:56:10 +0100 Subject: [ticket/11927] Correctly add new files on update Currently we ignore language and style files when the directory where they go to do not exist. However in 3.1 we introduce some new sub directories: * language/en/email/short/ * styles/prosilver/theme/en/ So we need to change our check to look whether the language or style exist, rather then the parent directory. PHPBB3-11927 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index b7b358ab2f..67420803c9 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1311,7 +1311,7 @@ class install_update extends module } }*/ - if (file_exists($phpbb_root_path . dirname($file)) || (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0)) + if (!ignore_new_file_on_update($phpbb_root_path, $file)) { $this->get_custom_info($update_list['new'], $file); $update_list['new'][] = array('filename' => $file, 'custom' => false); -- cgit v1.2.1 From 95348c8f6d64302d2d525f2ba1a9408f1510144b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Nov 2013 13:49:55 +0100 Subject: [ticket/11927] Prefix function with phpbb_ PHPBB3-11927 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 67420803c9..dc6e57c851 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1311,7 +1311,7 @@ class install_update extends module } }*/ - if (!ignore_new_file_on_update($phpbb_root_path, $file)) + if (!phpbb_ignore_new_file_on_update($phpbb_root_path, $file)) { $this->get_custom_info($update_list['new'], $file); $update_list['new'][] = array('filename' => $file, 'custom' => false); -- cgit v1.2.1 From 6c8589775b8df2b6fbeffbe594d9279ae90e85ba Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 19 Feb 2014 16:11:40 -0600 Subject: [ticket/9871] Update version check file to use json format PHPBB3-9871 --- phpBB/install/install_update.php | 50 +++++++++++----------------------------- 1 file changed, 14 insertions(+), 36 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index dc6e57c851..5891efb375 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -154,14 +154,23 @@ class install_update extends module )); // Get current and latest version - if (($latest_version = $cache->get('_version_info')) === false) + $version_helper = $phpbb_container->get('version_helper'); + try { - $this->latest_version = $this->get_file('version_info'); - $cache->put('_version_info', $this->latest_version); + $this->latest_version = $version_helper->get_latest_on_current_branch(true); } - else + catch (\RuntimeException $e) { - $this->latest_version = $latest_version; + $this->latest_version = false; + + $update_info = array(); + include($phpbb_root_path . 'install/update/index.' . $phpEx); + $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; + + if ($info !== false) + { + $this->latest_version = (!empty($info['version']['to'])) ? trim($info['version']['to']) : false; + } } // For the current version we trick a bit. ;) @@ -1606,37 +1615,6 @@ class install_update extends module switch ($mode) { - case 'version_info': - global $phpbb_root_path, $phpEx; - - $info = get_remote_file('version.phpbb.com', '/phpbb', - ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); - - if ($info !== false) - { - $info = explode("\n", $info); - $info = trim($info[0]); - } - - if ($this->test_update !== false) - { - $info = $this->test_update; - } - - // If info is false the fsockopen function may not be working. Instead get the latest version from our update file (and pray it is up-to-date) - if ($info === false) - { - $update_info = array(); - include($phpbb_root_path . 'install/update/index.' . $phpEx); - $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; - - if ($info !== false) - { - $info = (!empty($info['version']['to'])) ? trim($info['version']['to']) : false; - } - } - break; - case 'update_info': global $phpbb_root_path, $phpEx; -- cgit v1.2.1 From 249b9dcdb5a19e3d380a28f3df403106a41fadff Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 22 Feb 2014 20:23:30 -0800 Subject: [ticket/12160] Use phpbb_check_installation_exists() in the other modules. PHPBB3-12160 --- phpBB/install/install_update.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index dc6e57c851..87fe56737a 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -19,16 +19,7 @@ if (!defined('IN_INSTALL')) if (!empty($setmodules)) { // If phpBB is not installed we do not include this module - if (@file_exists($phpbb_root_path . 'config.' . $phpEx) && !@file_exists($phpbb_root_path . 'cache/install_lock')) - { - include_once($phpbb_root_path . 'config.' . $phpEx); - - if (!defined('PHPBB_INSTALLED')) - { - return; - } - } - else + if (!phpbb_check_installation_exists($phpbb_root_path, $phpEx) || file_exists($phpbb_root_path . 'cache/install_lock')) { return; } -- cgit v1.2.1 From df5761b370e03abde999be8b0dd895b1e61660d9 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 29 Mar 2014 23:02:00 +0100 Subject: [ticket/12324] Correctly create di container if config/ is missing from update/ PHPBB3-12324 --- phpBB/install/install_update.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index cdfb7ecb06..87b7d8d703 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -70,7 +70,14 @@ class install_update extends module $request->enable_super_globals(); // Create a normal container now - $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config'); + if (file_exists($phpbb_root_path . 'install/update/new/config')) + { + $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config'); + } + else + { + $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'config'); + } // Writes into global $cache $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From 9d7c36041e0dac509476069ee5bbce92e841f33e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 14 May 2014 02:16:32 +0200 Subject: [ticket/12509] Update calls to set_custom_style in forgotten places PHPBB3-12509 --- phpBB/install/install_update.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 87b7d8d703..ab276624ee 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -141,7 +141,12 @@ class install_update extends module // Set custom template again. ;) $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); $paths = array_filter($paths, 'is_dir'); - $template->set_custom_style('adm', $paths); + $template->set_custom_style(array( + array( + 'name' => 'adm', + 'ext_path' => 'adm/style/', + ) + ), $paths); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From 6e6891f841dfc4131a41a83a4c41f04feaa7397d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 23 May 2014 22:59:46 +0200 Subject: [ticket/12325] Automatic update should notify about outdated files PHPBB3-12325 --- phpBB/install/install_update.php | 50 ++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 87b7d8d703..e7a7a906d2 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -366,7 +366,7 @@ class install_update extends module $get_new_list = true; } - if (!$get_new_list && $update_list['status'] != -1) + if (!$get_new_list && ($update_list['status'] != -1 || $update_list['status_deleted'] != -1)) { $get_new_list = true; } @@ -377,17 +377,17 @@ class install_update extends module $cache->put('_update_list', $update_list); // Refresh the page if we are still not finished... - if ($update_list['status'] != -1) + if ($update_list['status'] != -1 || $update_list['status_deleted'] != -1) { $refresh_url = append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"); meta_refresh(2, $refresh_url); $template->assign_vars(array( 'S_IN_PROGRESS' => true, - 'S_COLLECTED' => (int) $update_list['status'], + 'S_COLLECTED' => (int) $update_list['status'] + (int) $update_list['status_deleted'], 'S_TO_COLLECT' => sizeof($this->update_info['files']), 'L_IN_PROGRESS' => $user->lang['COLLECTING_FILE_DIFFS'], - 'L_IN_PROGRESS_EXPLAIN' => sprintf($user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files'])), + 'L_IN_PROGRESS_EXPLAIN' => sprintf($user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files']) + sizeof($this->update_info['deleted'])), )); return; @@ -413,7 +413,7 @@ class install_update extends module // Now assign the list to the template foreach ($update_list as $status => $filelist) { - if ($status == 'no_update' || !sizeof($filelist) || $status == 'status') + if ($status == 'no_update' || !sizeof($filelist) || $status == 'status' || $status == 'status_deleted') { continue; } @@ -480,7 +480,7 @@ class install_update extends module $all_up_to_date = true; foreach ($update_list as $status => $filelist) { - if ($status != 'up_to_date' && $status != 'custom' && $status != 'status' && sizeof($filelist)) + if ($status != 'up_to_date' && $status != 'custom' && $status != 'status' && $status != 'status_deleted' && sizeof($filelist)) { $all_up_to_date = false; break; @@ -822,7 +822,7 @@ class install_update extends module foreach ($update_list as $status => $files) { - if ($status == 'up_to_date' || $status == 'no_update' || $status == 'status') + if ($status == 'up_to_date' || $status == 'no_update' || $status == 'status' || $status == 'status_deleted') { continue; } @@ -1212,6 +1212,16 @@ class install_update extends module $this->page_title = 'VIEWING_FILE_CONTENTS'; break; + + case 'deleted': + + $diff = $this->return_diff(array(), $phpbb_root_path . $original_file); + + $template->assign_var('S_DIFF_NEW_FILE', true); + $diff_mode = 'inline'; + $this->page_title = 'VIEWING_FILE_CONTENTS'; + + break; } $diff_mode_options = ''; @@ -1257,7 +1267,9 @@ class install_update extends module 'new_conflict' => array(), 'conflict' => array(), 'no_update' => array(), + 'deleted' => array(), 'status' => 0, + 'status_deleted'=> 0, ); } @@ -1337,6 +1349,30 @@ class install_update extends module } $update_list['status'] = -1; + + foreach ($this->update_info['deleted'] as $index => $file) + { + if (is_int($update_list['status_deleted']) && $index < $update_list['status_deleted']) + { + continue; + } + + if ($num_bytes_processed >= 500 * 1024) + { + return; + } + + if (file_exists($phpbb_root_path . $file)) + { + $update_list['deleted'][] = array('filename' => $file, 'custom' => false, 'as_expected' => false); + $num_bytes_processed += filesize($phpbb_root_path . $file); + } + + $update_list['status_deleted']++; + } + + $update_list['status_deleted'] = -1; + /* if (!sizeof($this->update_info['files'])) { return $update_list; -- cgit v1.2.1 From 088f5b47c3eff946bdb00a0d38a4247fef0123b4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 24 May 2014 14:06:14 +0200 Subject: [ticket/12325] Fix: it's not stuck in an inifinite loop anymore PHPBB3-12325 --- phpBB/install/install_update.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index e7a7a906d2..c166c33be9 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -366,7 +366,7 @@ class install_update extends module $get_new_list = true; } - if (!$get_new_list && ($update_list['status'] != -1 || $update_list['status_deleted'] != -1)) + if (!$get_new_list && $update_list['status'] != -1) { $get_new_list = true; } @@ -377,14 +377,14 @@ class install_update extends module $cache->put('_update_list', $update_list); // Refresh the page if we are still not finished... - if ($update_list['status'] != -1 || $update_list['status_deleted'] != -1) + if ($update_list['status'] != -1) { $refresh_url = append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"); meta_refresh(2, $refresh_url); $template->assign_vars(array( 'S_IN_PROGRESS' => true, - 'S_COLLECTED' => (int) $update_list['status'] + (int) $update_list['status_deleted'], + 'S_COLLECTED' => (int) $update_list['status'], 'S_TO_COLLECT' => sizeof($this->update_info['files']), 'L_IN_PROGRESS' => $user->lang['COLLECTING_FILE_DIFFS'], 'L_IN_PROGRESS_EXPLAIN' => sprintf($user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files']) + sizeof($this->update_info['deleted'])), @@ -1348,8 +1348,6 @@ class install_update extends module $update_list['status']++; } - $update_list['status'] = -1; - foreach ($this->update_info['deleted'] as $index => $file) { if (is_int($update_list['status_deleted']) && $index < $update_list['status_deleted']) @@ -1369,9 +1367,11 @@ class install_update extends module } $update_list['status_deleted']++; + $update_list['status']++; } $update_list['status_deleted'] = -1; + $update_list['status'] = -1; /* if (!sizeof($this->update_info['files'])) { -- cgit v1.2.1 From 9a846e447ba98b175c510d9fbe7741648296a1ba Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 26 May 2014 23:44:30 +0200 Subject: [ticket/12509] Add missing ',' in arrays PHPBB3-12509 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index ab276624ee..c2f7b191a7 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -145,7 +145,7 @@ class install_update extends module array( 'name' => 'adm', 'ext_path' => 'adm/style/', - ) + ), ), $paths); $template->assign_vars(array( -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/install/install_update.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 87b7d8d703..1a90efc2b4 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1,15 +1,20 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * -* @todo check for writable cache/store/files directory */ /** +* @todo check for writable cache/store/files directory */ + if (!defined('IN_INSTALL')) { // Someone has tried to access the file directly. This is not a good idea, so exit @@ -37,7 +42,6 @@ if (!empty($setmodules)) /** * Update Installation -* @package install */ class install_update extends module { -- cgit v1.2.1 From 91ca12f20ec0901a02222a83abd18df7efa84d81 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 27 Jun 2014 21:48:27 +0200 Subject: [ticket/12775] Update container and config in install/ PHPBB3-12775 --- phpBB/install/install_update.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index c6f771a7d5..943b89f2d7 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -66,7 +66,9 @@ class install_update extends module function main($mode, $sub) { global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; - global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; + global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container, $phpbb_config_php_handler; + + extract($phpbb_config_php_handler->get_all()); // We must enable super globals, otherwise creating a new instance of the request class, // using the new container with a dbal connection will fail with the following PHP Notice: @@ -74,14 +76,14 @@ class install_update extends module $request->enable_super_globals(); // Create a normal container now + $phpbb_container_factory = new \phpbb\di\container_factory($phpbb_config_php_handler, $phpbb_root_path, $phpEx); + $phpbb_container_factory->set_dump_container(false); + $phpbb_container_factory->set_use_extensions(false); if (file_exists($phpbb_root_path . 'install/update/new/config')) { - $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config'); - } - else - { - $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'config'); + $phpbb_container_factory->set_config_path($phpbb_root_path . 'install/update/new/config'); } + $phpbb_container = $phpbb_container_factory->get_container(); // Writes into global $cache $cache = $phpbb_container->get('cache'); @@ -93,7 +95,6 @@ class install_update extends module $this->new_location = $phpbb_root_path . 'install/update/new/'; // Init DB - require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); // Special options for conflicts/modified files -- cgit v1.2.1 From 40937e21c58399a847d04f23423622b0e1894446 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:29:08 +0200 Subject: [ticket/12775] Renamed to \phpbb\di\container_builder PHPBB3-12775 --- phpBB/install/install_update.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 943b89f2d7..5474ae71bc 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -76,14 +76,14 @@ class install_update extends module $request->enable_super_globals(); // Create a normal container now - $phpbb_container_factory = new \phpbb\di\container_factory($phpbb_config_php_handler, $phpbb_root_path, $phpEx); - $phpbb_container_factory->set_dump_container(false); - $phpbb_container_factory->set_use_extensions(false); + $phpbb_container_builder = new \phpbb\di\container_factory($phpbb_config_php_handler, $phpbb_root_path, $phpEx); + $phpbb_container_builder->set_dump_container(false); + $phpbb_container_builder->set_use_extensions(false); if (file_exists($phpbb_root_path . 'install/update/new/config')) { - $phpbb_container_factory->set_config_path($phpbb_root_path . 'install/update/new/config'); + $phpbb_container_builder->set_config_path($phpbb_root_path . 'install/update/new/config'); } - $phpbb_container = $phpbb_container_factory->get_container(); + $phpbb_container = $phpbb_container_builder->get_container(); // Writes into global $cache $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From 2db160ff87fa42ca6c47e580de9bc9d7e5cced49 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:33:31 +0200 Subject: [ticket/12775] Rename config_php to config_php_file PHPBB3-12775 --- phpBB/install/install_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 5474ae71bc..bffb2f3365 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -66,9 +66,9 @@ class install_update extends module function main($mode, $sub) { global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; - global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container, $phpbb_config_php_handler; + global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container, $phpbb_config_php_file; - extract($phpbb_config_php_handler->get_all()); + extract($phpbb_config_php_file->get_all()); // We must enable super globals, otherwise creating a new instance of the request class, // using the new container with a dbal connection will fail with the following PHP Notice: @@ -76,7 +76,7 @@ class install_update extends module $request->enable_super_globals(); // Create a normal container now - $phpbb_container_builder = new \phpbb\di\container_factory($phpbb_config_php_handler, $phpbb_root_path, $phpEx); + $phpbb_container_builder = new \phpbb\di\container_factory($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_dump_container(false); $phpbb_container_builder->set_use_extensions(false); if (file_exists($phpbb_root_path . 'install/update/new/config')) -- cgit v1.2.1 From f2e8e928c08809202b1abf5668a46e3d9e735c38 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:35:46 +0200 Subject: [ticket/12775] Fix container_builder PHPBB3-12775 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index bffb2f3365..f8e8c53b2a 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -76,7 +76,7 @@ class install_update extends module $request->enable_super_globals(); // Create a normal container now - $phpbb_container_builder = new \phpbb\di\container_factory($phpbb_config_php_file, $phpbb_root_path, $phpEx); + $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_dump_container(false); $phpbb_container_builder->set_use_extensions(false); if (file_exists($phpbb_root_path . 'install/update/new/config')) -- cgit v1.2.1 From ed812a9dfb59b1eb83263adbaa52723ff826a791 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 21:58:17 +0200 Subject: [ticket/12775] Move phpbb_convert_30_dbms_to_31 into the config file class PHPBB3-12775 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index f8e8c53b2a..ac89214590 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -103,7 +103,7 @@ class install_update extends module define('MERGE_NEW_FILE', 3); define('MERGE_MOD_FILE', 4); - $dbms = phpbb_convert_30_dbms_to_31($dbms); + $dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms); $db = new $dbms(); -- cgit v1.2.1 From 285656a6d4b708c2ff40b85c591ef361114ca717 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 30 Jun 2014 21:46:33 +0200 Subject: [ticket/12775] Extract the vars later in install/install_update.php PHPBB3-12775 --- phpBB/install/install_update.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index ac89214590..28777a8d24 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -68,8 +68,6 @@ class install_update extends module global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container, $phpbb_config_php_file; - extract($phpbb_config_php_file->get_all()); - // We must enable super globals, otherwise creating a new instance of the request class, // using the new container with a dbal connection will fail with the following PHP Notice: // Object of class phpbb_request_deactivated_super_global could not be converted to int @@ -95,6 +93,7 @@ class install_update extends module $this->new_location = $phpbb_root_path . 'install/update/new/'; // Init DB + extract($phpbb_config_php_file->get_all()); require($phpbb_root_path . 'includes/constants.' . $phpEx); // Special options for conflicts/modified files -- cgit v1.2.1 From 07a92d29df03a1a2c432382e35c0741e133787ea Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 7 Aug 2014 15:49:41 +0200 Subject: [ticket/12778] Automatically delete files on update PHPBB3-12778 --- phpBB/install/install_update.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 28777a8d24..7a423b622f 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1063,6 +1063,14 @@ class install_update extends module $transfer->write_file($file_struct['filename'], $contents); } break; + + case 'deleted': + + if ($update_mode != 'download') + { + $transfer->delete_file($file_struct['filename']); + } + break; } } } -- cgit v1.2.1 From 54885416404db57ad0062799f0c22db3e472169d Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 7 Aug 2014 16:52:49 +0200 Subject: [ticket/12778] Rename the file to *.bak instead of deleting PHPBB3-12778 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 7a423b622f..82ca0fc18d 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1068,7 +1068,7 @@ class install_update extends module if ($update_mode != 'download') { - $transfer->delete_file($file_struct['filename']); + $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); } break; } -- cgit v1.2.1 From b6cf2d7284b62c263d563995c3edecf9e8d88ca7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 25 Feb 2016 12:25:08 +0100 Subject: [ticket/14496] Cache last update of update list instead of using filemtime PHPBB3-14496 --- phpBB/install/install_update.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 82ca0fc18d..ba054d1747 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -355,7 +355,7 @@ class install_update extends module // We are directly within an update. To make sure our update list is correct we check its status. $update_list = ($request->variable('check_again', false, false, \phpbb\request\request_interface::POST)) ? false : $cache->get('_update_list'); - $modified = ($update_list !== false) ? @filemtime($cache->get_driver()->cache_dir . 'data_update_list.' . $phpEx) : 0; + $modified = ($update_list !== false) ? $cache->get('_update_list_time') : 0; // Make sure the list is up-to-date if ($update_list !== false) @@ -384,6 +384,7 @@ class install_update extends module { $this->get_update_structure($update_list, $expected_files); $cache->put('_update_list', $update_list); + $cache->put('_update_list_time', time()); // Refresh the page if we are still not finished... if ($update_list['status'] != -1) -- cgit v1.2.1 From db1b73a3f4c8a7c11b493c930a080c3dfafb086b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 26 Feb 2016 16:57:48 +0100 Subject: [ticket/14496] Destroy update_list_time cache variable on intro PHPBB3-14496 --- phpBB/install/install_update.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/install/install_update.php') diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index ba054d1747..a00280a925 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -283,6 +283,7 @@ class install_update extends module // Make sure the update list is destroyed. $cache->destroy('_update_list'); + $cache->destroy('_update_list_time'); $cache->destroy('_diff_files'); $cache->destroy('_expected_files'); break; -- cgit v1.2.1