From 0fe8239f493a5a2e1978dc787b8d5983908c696b Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Tue, 17 Dec 2002 23:59:07 +0000 Subject: [PATCH] Centralise install ... as per 2.2 ... de-template install, moved schemas, introduce better language support in install ... add check for deletion of this and contrib/ in common.php git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3197 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/index.htm | 10 + phpBB/install/install.php | 1264 +++++++++++++++++-------------- phpBB/install/update_to_202.php | 665 ++++++++++++++++ phpBB/install/update_to_203.php | 668 ++++++++++++++++ phpBB/install/update_to_204.php | 910 ++++++++++++++++++++++ phpBB/install/upgrade.php | 176 +++-- 6 files changed, 3038 insertions(+), 655 deletions(-) create mode 100644 phpBB/install/index.htm create mode 100644 phpBB/install/update_to_202.php create mode 100644 phpBB/install/update_to_203.php create mode 100644 phpBB/install/update_to_204.php diff --git a/phpBB/install/index.htm b/phpBB/install/index.htm new file mode 100644 index 0000000000..ee1f723a7d --- /dev/null +++ b/phpBB/install/index.htm @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/phpBB/install/install.php b/phpBB/install/install.php index cb33ca7c73..639e6fac67 100644 --- a/phpBB/install/install.php +++ b/phpBB/install/install.php @@ -19,262 +19,517 @@ * ***************************************************************************/ -error_reporting (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables -set_magic_quotes_runtime(0); // Disable magic_quotes_runtime - -if ( !get_magic_quotes_gpc() ) +// --------- +// FUNCTIONS +// +function page_header($text) { - $_GET = slash_input_data($_GET); - $_POST = slash_input_data($_POST); + global $phpEx, $lang; + +?> + + + + + +<?php echo $lang['Welcome_install'];?> + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + +
Forum Home


+ + + +


+ +
+ + + + + + + + + + + + + + + + + + + + + + 'ar([_-][a-z]+)?', + 'bulgarian' => 'bg', + 'catalan' => 'ca', + 'czech' => 'cs', + 'danish' => 'da', + 'german' => 'de([_-][a-z]+)?', + 'english' => 'en([_-][a-z]+)?', + 'estonian' => 'et', + 'finnish' => 'fi', + 'french' => 'fr([_-][a-z]+)?', + 'greek' => 'el', + 'spanish_argentina' => 'es[_-]ar', + 'spanish' => 'es([_-][a-z]+)?', + 'gaelic' => 'gd', + 'galego' => 'gl', + 'gujarati' => 'gu', + 'hebrew' => 'he', + 'hindi' => 'hi', + 'croatian' => 'hr', + 'hungarian' => 'hu', + 'icelandic' => 'is', + 'indonesian' => 'id([_-][a-z]+)?', + 'italian' => 'it([_-][a-z]+)?', + 'japanese' => 'ja([_-][a-z]+)?', + 'korean' => 'ko([_-][a-z]+)?', + 'latvian' => 'lv', + 'lithuanian' => 'lt', + 'macedonian' => 'mk', + 'dutch' => 'nl([_-][a-z]+)?', + 'norwegian' => 'no', + 'polish' => 'pl', + 'portuguese_brazil' => 'pt[_-]br', + 'portuguese' => 'pt([_-][a-z]+)?', + 'punjabi' => 'pa', + 'romanian' => 'ro([_-][a-z]+)?', + 'russian' => 'ru([_-][a-z]+)?', + 'slovenian' => 'sl([_-][a-z]+)?', + 'albanian' => 'sq', + 'serbian' => 'sr([_-][a-z]+)?', + 'slovak' => 'sv([_-][a-z]+)?', + 'swedish' => 'sv([_-][a-z]+)?', + 'thai' => 'th([_-][a-z]+)?', + 'turkish' => 'tr([_-][a-z]+)?', + 'ukranian' => 'uk([_-][a-z]+)?', + 'urdu' => 'ur', + 'viatnamese' => 'vi', + 'chinese_traditional_taiwan'=> 'zh[_-]tw', + 'chinese_simplified' => 'zh', + ); + + if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'])) { - // Set correct format ... guess full xx_YY form - $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2)); - if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) ) + $accept_lang_ary = explode(',', $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE']); + for ($i = 0; $i < sizeof($accept_lang_ary); $i++) { - $default_language = $accept_lang; - break; - } - else - { - // No match on xx_YY so try xx - $accept_lang = substr($accept_lang, 0, 2); - if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) ) + @reset($match_lang); + while (list($lang, $match) = each($match_lang)) { - $default_language = $accept_lang; - break; + if (preg_match('#' . $match . '#i', trim($accept_lang_ary[$i]))) + { + if (file_exists($phpbb_root_path . 'language/lang_' . $lang)) + { + return $lang; + } + } } } } + + return 'english'; + +} +// +// FUNCTIONS +// --------- + +// Begin +error_reporting (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables +set_magic_quotes_runtime(0); // Disable magic_quotes_runtime + +// Slash data if it isn't slashed +if (!get_magic_quotes_gpc()) +{ + if (is_array($HTTP_GET_VARS)) + { + while (list($k, $v) = each($HTTP_GET_VARS)) + { + if (is_array($HTTP_GET_VARS[$k])) + { + while (list($k2, $v2) = each($HTTP_GET_VARS[$k])) + { + $HTTP_GET_VARS[$k][$k2] = addslashes($v2); + } + @reset($HTTP_GET_VARS[$k]); + } + else + { + $HTTP_GET_VARS[$k] = addslashes($v); + } + } + @reset($HTTP_GET_VARS); + } + + if (is_array($HTTP_POST_VARS)) + { + while (list($k, $v) = each($HTTP_POST_VARS)) + { + if (is_array($HTTP_POST_VARS[$k])) + { + while (list($k2, $v2) = each($HTTP_POST_VARS[$k])) + { + $HTTP_POST_VARS[$k][$k2] = addslashes($v2); + } + @reset($HTTP_POST_VARS[$k]); + } + else + { + $HTTP_POST_VARS[$k] = addslashes($v); + } + } + @reset($HTTP_POST_VARS); + } + + if (is_array($HTTP_COOKIE_VARS)) + { + while (list($k, $v) = each($HTTP_COOKIE_VARS)) + { + if (is_array($HTTP_COOKIE_VARS[$k])) + { + while (list($k2, $v2) = each($HTTP_COOKIE_VARS[$k])) + { + $HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2); + } + @reset($HTTP_COOKIE_VARS[$k]); + } + else + { + $HTTP_COOKIE_VARS[$k] = addslashes($v); + } + } + @reset($HTTP_COOKIE_VARS); + } } -$default_template = 'subSilver'; +// Begin main prog +define('IN_PHPBB', true); +// Uncomment the following line to completely disable the ftp option... +// define('NO_FTP', true); +$phpbb_root_path = './../'; +include($phpbb_root_path.'extension.inc'); +// Initialise some basic arrays +$userdata = array(); +$lang = array(); + +// Include some required functions +include($phpbb_root_path.'includes/constants.'.$phpEx); +include($phpbb_root_path.'includes/functions.'.$phpEx); +include($phpbb_root_path.'includes/sessions.'.$phpEx); + +// Define schema info $available_dbms = array( - 'mysql' => array( - 'LABEL' => 'MySQL 3.x', - 'SCHEMA' => 'mysql', - 'DELIM' => ';', - 'DELIM_BASIC' => ';', - 'COMMENTS' => 'remove_remarks' - ), + 'mysql'=> array( + 'LABEL' => 'MySQL 3.x', + 'SCHEMA' => 'mysql', + 'DELIM' => ';', + 'DELIM_BASIC' => ';', + 'COMMENTS' => 'remove_remarks' + ), 'mysql4' => array( - 'LABEL' => 'MySQL 4.x', - 'SCHEMA' => 'mysql', - 'DELIM' => ';', - 'DELIM_BASIC' => ';', - 'COMMENTS' => 'remove_remarks' - ), + 'LABEL' => 'MySQL 4.x', + 'SCHEMA' => 'mysql', + 'DELIM' => ';', + 'DELIM_BASIC' => ';', + 'COMMENTS' => 'remove_remarks' + ), 'postgres' => array( - 'LABEL' => 'PostgreSQL 7.x', - 'SCHEMA' => 'postgres', - 'DELIM' => ';', - 'DELIM_BASIC' => ';', - 'COMMENTS' => 'remove_comments' - ), + 'LABEL' => 'PostgreSQL 7.x', + 'SCHEMA' => 'postgres', + 'DELIM' => ';', + 'DELIM_BASIC' => ';', + 'COMMENTS' => 'remove_comments' + ), 'mssql' => array( - 'LABEL' => 'MS SQL Server 7/2000', - 'SCHEMA' => 'mssql', - 'DELIM' => 'GO', - 'DELIM_BASIC' => ';', - 'COMMENTS' => 'remove_comments' + 'LABEL' => 'MS SQL Server 7/2000', + 'SCHEMA' => 'mssql', + 'DELIM' => 'GO', + 'DELIM_BASIC' => ';', + 'COMMENTS' => 'remove_comments' ), 'msaccess' => array( - 'LABEL' => 'MS Access [ ODBC ]', - 'SCHEMA' => '', - 'DELIM' => '', - 'DELIM_BASIC' => ';', - 'COMMENTS' => '' + 'LABEL' => 'MS Access [ ODBC ]', + 'SCHEMA' => '', + 'DELIM' => '', + 'DELIM_BASIC' => ';', + 'COMMENTS' => '' ), 'mssql-odbc' => array( - 'LABEL' => 'MS SQL Server [ ODBC ]', - 'SCHEMA' => 'mssql', - 'DELIM' => 'GO', - 'DELIM_BASIC' => ';', - 'COMMENTS' => 'remove_comments' + 'LABEL' => 'MS SQL Server [ ODBC ]', + 'SCHEMA' => 'mssql', + 'DELIM' => 'GO', + 'DELIM_BASIC' => ';', + 'COMMENTS' => 'remove_comments' ) ); -// -// Uncomment the following line to completely disable the ftp option... -// -// define('NO_FTP', true); - -/*************************************************************************** -* -* End Install Customization Section -* -***************************************************************************/ - -// -// Try opening config file -// -if ( @file_exists('../config.'.$phpEx) ) -{ - include('../config.'.$phpEx); -} - -// // Obtain various vars -// -$confirm = ( isset($_POST['confirm']) ) ? true : false; -$cancel = ( isset($_POST['cancel']) ) ? true : false; +$confirm = (isset($HTTP_POST_VARS['confirm'])) ? true : false; +$cancel = (isset($HTTP_POST_VARS['cancel'])) ? true : false; -if ( isset($_POST['install_step']) || isset($_GET['install_step']) ) +if (isset($HTTP_POST_VARS['install_step']) || isset($HTTP_GET_VARS['install_step'])) { - $install_step = ( isset($_POST['install_step']) ) ? $_POST['install_step'] : $_GET['install_step']; + $install_step = (isset($HTTP_POST_VARS['install_step'])) ? $HTTP_POST_VARS['install_step'] : $HTTP_GET_VARS['install_step']; } else { $install_step = ''; } -$upgrade = ( !empty($_POST['upgrade']) ) ? $_POST['upgrade']: ''; -$upgrade_now = ( !empty($_POST['upgrade_now']) ) ? $_POST['upgrade_now']:''; +$upgrade = (!empty($HTTP_POST_VARS['upgrade'])) ? $HTTP_POST_VARS['upgrade']: ''; +$upgrade_now = (!empty($HTTP_POST_VARS['upgrade_now'])) ? $HTTP_POST_VARS['upgrade_now']:''; -$dbms = isset($_POST['dbms']) ? $_POST['dbms'] : ''; -$language = ( !empty($_POST['language']) ) ? $_POST['language'] : $default_language; +$dbms = isset($HTTP_POST_VARS['dbms']) ? $HTTP_POST_VARS['dbms'] : ''; -$dbhost = ( !empty($_POST['dbhost']) ) ? $_POST['dbhost'] : ''; -$dbuser = ( !empty($_POST['dbuser']) ) ? $_POST['dbuser'] : ''; -$dbpasswd = ( !empty($_POST['dbpasswd']) ) ? $_POST['dbpasswd'] : ''; -$dbname = ( !empty($_POST['dbname']) ) ? $_POST['dbname'] : ''; +$dbhost = (!empty($HTTP_POST_VARS['dbhost'])) ? $HTTP_POST_VARS['dbhost'] : ''; +$dbuser = (!empty($HTTP_POST_VARS['dbuser'])) ? $HTTP_POST_VARS['dbuser'] : ''; +$dbpasswd = (!empty($HTTP_POST_VARS['dbpasswd'])) ? $HTTP_POST_VARS['dbpasswd'] : ''; +$dbname = (!empty($HTTP_POST_VARS['dbname'])) ? $HTTP_POST_VARS['dbname'] : ''; -$table_prefix = ( !empty($_POST['prefix']) ) ? $_POST['prefix'] : ''; +$table_prefix = (!empty($HTTP_POST_VARS['prefix'])) ? $HTTP_POST_VARS['prefix'] : ''; -$admin_name = ( !empty($_POST['admin_name']) ) ? $_POST['admin_name'] : ''; -$admin_pass1 = ( !empty($_POST['admin_pass1']) ) ? $_POST['admin_pass1'] : ''; -$admin_pass2 = ( !empty($_POST['admin_pass2']) ) ? $_POST['admin_pass2'] : ''; +$admin_name = (!empty($HTTP_POST_VARS['admin_name'])) ? $HTTP_POST_VARS['admin_name'] : ''; +$admin_pass1 = (!empty($HTTP_POST_VARS['admin_pass1'])) ? $HTTP_POST_VARS['admin_pass1'] : ''; +$admin_pass2 = (!empty($HTTP_POST_VARS['admin_pass2'])) ? $HTTP_POST_VARS['admin_pass2'] : ''; -$ftp_path = ( !empty($_POST['ftp_path']) ) ? $_POST['ftp_path'] : ''; -$ftp_user = ( !empty($_POST['ftp_user']) ) ? $_POST['ftp_user'] : ''; -$ftp_pass = ( !empty($_POST['ftp_pass']) ) ? $_POST['ftp_pass'] : ''; +$ftp_path = (!empty($HTTP_POST_VARS['ftp_path'])) ? $HTTP_POST_VARS['ftp_path'] : ''; +$ftp_user = (!empty($HTTP_POST_VARS['ftp_user'])) ? $HTTP_POST_VARS['ftp_user'] : ''; +$ftp_pass = (!empty($HTTP_POST_VARS['ftp_pass'])) ? $HTTP_POST_VARS['ftp_pass'] : ''; -$server_name = ( !empty($_POST['server_name']) ) ? $_POST['server_name'] : ''; -$server_port = ( !empty($_POST['server_port']) ) ? $_POST['server_port'] : ''; -$board_email = ( !empty($_POST['board_email']) ) ? $_POST['board_email'] : ''; -$script_path = ( !empty($_POST['script_path']) ) ? $_POST['script_path'] : ''; - -// -// Do we install/upgrade/update or quit back to index? -// -if ( !defined('PHPBB_INSTALLED') ) +if (isset($HTTP_POST_VARS['lang']) && preg_match('#^[a-z_]+$#', $HTTP_POST_VARS['lang'])) { - include($phpbb_root_path . 'includes/session.'.$phpEx); - include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); + $language = strip_tags($HTTP_POST_VARS['lang']); +} +else +{ + $language = guess_lang(); +} + +$board_email = (!empty($HTTP_POST_VARS['board_email'])) ? $HTTP_POST_VARS['board_email'] : ''; +$script_path = (!empty($HTTP_POST_VARS['script_path'])) ? $HTTP_POST_VARS['script_path'] : preg_replace('#install/install\.'.$phpEx.'#i', '', $HTTP_SERVER_VARS['PHP_SELF']); + +if (!empty($HTTP_POST_VARS['server_name'])) +{ + $server_name = $HTTP_POST_VARS['server_name']; +} +else +{ + // Guess at some basic info used for install.. + if (!empty($HTTP_SERVER_VARS['SERVER_NAME']) || !empty($HTTP_ENV_VARS['SERVER_NAME'])) + { + $server_name = (!empty($HTTP_SERVER_VARS['SERVER_NAME'])) ? $HTTP_SERVER_VARS['SERVER_NAME'] : $HTTP_ENV_VARS['SERVER_NAME']; + } + else if (!empty($HTTP_SERVER_VARS['HTTP_HOST']) || !empty($HTTP_ENV_VARS['HTTP_HOST'])) + { + $server_name = (!empty($HTTP_SERVER_VARS['HTTP_HOST'])) ? $HTTP_SERVER_VARS['HTTP_HOST'] : $HTTP_ENV_VARS['HTTP_HOST']; + } + else + { + $server_name = ''; + } +} + +if (!empty($HTTP_POST_VARS['server_port'])) +{ + $server_port = $HTTP_POST_VARS['server_port']; +} +else +{ + if (!empty($HTTP_SERVER_VARS['SERVER_PORT']) || !empty($HTTP_ENV_VARS['SERVER_PORT'])) + { + $server_port = (!empty($HTTP_SERVER_VARS['SERVER_PORT'])) ? $HTTP_SERVER_VARS['SERVER_PORT'] : $HTTP_ENV_VARS['SERVER_PORT']; + } + else + { + $server_port = '80'; + } +} + +// Open config.php ... if it exists +if (@file_exists(@realpath('config.'.$phpEx))) +{ + include($phpbb_root_path.'config.'.$phpEx); +} + +// Is phpBB already installed? No, include necessary +// files and continue, else redirect to the index +if (!defined("PHPBB_INSTALLED")) +{ + include($phpbb_root_path.'includes/sql_parse.'.$phpEx); // Import language file, setup template ... - include($phpbb_root_path . 'language/' . $language . '/lang_main.'.$phpEx); - include($phpbb_root_path . 'language/' . $language . '/lang_admin.'.$phpEx); + include($phpbb_root_path.'language/lang_' . $language . '/lang_main.'.$phpEx); + include($phpbb_root_path.'language/lang_' . $language . '/lang_admin.'.$phpEx); - if ( $upgrade == 1 ) + // Ok for the time being I'm commenting this out whilst I'm working on + // better integration of the install with upgrade as per Bart's request + // JLH + if ($upgrade == 1) { - require('upgrade.'.$phpEx); + // require('upgrade.'.$phpEx); $install_step = 1; } } else { - header("Location: ../index.$phpEx"); - exit; + redirect('index.'.$phpEx); } // -// What shall we do? // -if ( !empty($_POST['send_file']) && $_POST['send_file'] == 1 && !defined("PHPBB_INSTALLED") && empty($_POST['upgrade_now']) ) +// +if (!empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 1 && !defined("PHPBB_INSTALLED") && empty($HTTP_POST_VARS['upgrade_now'])) { - // + header('Content-Type: text/x-delimtext; name="config.' . $phpEx . '"'); + header('Content-disposition: attachment; filename=config.' . $phpEx . '"'); + // We need to stripslashes no matter what the setting of magic_quotes_gpc is - // because we add slahes at the top if its off, and they are added automaticlly + // because we add slashes at the top if its off, and they are added automaticlly // if it is on. - // - $_POST['config_data'] = stripslashes($_POST['config_data']); + echo stripslashes($HTTP_POST_VARS['config_data']); - header("Content-Type: text/x-delimtext; name=\"config.$phpEx\""); - header("Content-disposition: attachment; filename=config.$phpEx"); - echo $_POST['config_data']; exit; - } -else if ( !empty($_POST['send_file']) && $_POST['send_file'] == 2 && !defined("PHPBB_INSTALLED") ) +else if (!empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 2 && !defined("PHPBB_INSTALLED") ) { - // - // Ok we couldn't write the config file so let's try ftping it. - // - - $_POST['config_data'] = stripslashes($_POST['config_data']); - - $s_hidden_fields = ''; + $s_hidden_fields = ''; $s_hidden_fields .= ''; - if ( $upgrade == 1 ) + if ($upgrade == 1) { $s_hidden_fields .= ''; } - $template->assign_block_vars("switch_ftp_file", array()); - $template->assign_block_vars("switch_common_install", array()); + page_header($lang['ftp_instructs']); - $template->assign_vars(array( - "L_INSTRUCTION_TEXT" => $lang['ftp_instructs'], - "L_FTP_INFO" => $lang['ftp_info'], - "L_FTP_PATH" => $lang['ftp_path'], - "L_FTP_PASS" => $lang['ftp_password'], - "L_FTP_USER" => $lang['ftp_username'], - "L_SUBMIT" => $lang['Transfer_config'], - - "S_HIDDEN_FIELDS" => $s_hidden_fields, - "S_FORM_ACTION" => "install.$phpEx") - ); - - $template->pparse("body"); +?> + + + + + + + + + + + + + + + +'; + $s_hidden_fields = ''; $s_hidden_fields .= ''; - page_header($lang['NoFTP_config'], "install.$phpEx"); - - if ( $upgrade == 1 ) + // If we're upgrading ... + if ($upgrade == 1) { $s_hidden_fields .= ''; $s_hidden_fields .= ''; @@ -291,438 +546,417 @@ else if( !empty($_POST['ftp_file']) && !defined("PHPBB_INSTALLED") ) $s_hidden_fields .= ''; $s_hidden_fields .= ''; - $template->assign_block_vars("switch_upgrade_install", array()); - $template->assign_vars(array( - "L_UPGRADE_INST" => $lang['continue_upgrade'], - "L_UPGRADE_SUBMIT" => $lang['upgrade_submit']) - ); + page_upgrade_form(); + } + else + { + page_common_form($s_hidden_fields, $lang['Download_config']); + } - page_footer($lang['Download_config'], $s_hidden_fields); - + page_footer(); exit; } else { - // // Write out a temp file... - // $tmpfname = @tempnam('/tmp', 'cfg'); @unlink($tmpfname); // unlink for safety on php4.0.3+ $fp = @fopen($tmpfname, 'w'); - @fwrite($fp, $_POST['config_data']); + @fwrite($fp, stripslashes($HTTP_POST_VARS['config_data'])); @fclose($fp); - // // Now ftp it across. - // @ftp_chdir($conn_id, $ftp_dir); - $res = ftp_put($conn_id, '../config.'.$phpEx, $tmpfname, FTP_ASCII); + $res = ftp_put($conn_id, 'config.'.$phpEx, $tmpfname, FTP_ASCII); @ftp_quit($conn_id); unlink($tmpfname); - if( $upgrade == 1 ) + if ($upgrade == 1) { require('upgrade.'.$phpEx); exit; } - // - // Ok we are basically done with the install process let's go on and let the user - // configure their board now. We are going to do this by calling the admin_board.php - // from the normal board admin section. - // + // Ok we are basically done with the install process let's go on + // and let the user configure their board now. We are going to do + // this by calling the admin_board.php from the normal board admin + // section. $s_hidden_fields = ''; $s_hidden_fields .= ''; $s_hidden_fields .= ''; $s_hidden_fields .= ''; - page_header($lang['Inst_Step_2'], "../login.$phpEx"); - page_footer($lang['Finish_Install'], $s_hidden_fields); - + page_header($lang['Inst_Step_2']); + page_common_form($s_hidden_fields, $lang['Finish_Install']); + page_footer(); exit(); } - } -else if ( ( empty($install_step) || $admin_pass1 != $admin_pass2 || empty($admin_pass1) || $dbhost == '' ) && !defined("PHPBB_INSTALLED") ) +else if ((empty($install_step) || $admin_pass1 != $admin_pass2 || empty($admin_pass1) || $dbhost == '') && !defined("PHPBB_INSTALLED")) { - // // Ok we haven't installed before so lets work our way through the various - // steps of the install process. This could turn out to be quite a lengty + // steps of the install process. This could turn out to be quite a lengty // process. - // + // Step 0 gather the pertinant info for database setup... // Namely dbms, dbhost, dbname, dbuser, and dbpasswd. - // - - // - // Guess at some basic info used for install.. - // - if ( !empty($_SERVER['SERVER_NAME']) || !empty($_ENV['SERVER_NAME']) ) - { - $server_name = ( !empty($_SERVER['SERVER_NAME']) ) ? $_SERVER['SERVER_NAME'] : $_ENV['SERVER_NAME']; - } - else if ( !empty($_SERVER['HTTP_HOST']) || !empty($_ENV['HTTP_HOST']) ) - { - $server_name = ( !empty($_SERVER['HTTP_HOST']) ) ? $_SERVER['HTTP_HOST'] : $_ENV['HTTP_HOST']; - } - else - { - $server_name = ''; - } - - if ( !empty($_SERVER['SERVER_PORT']) || !empty($_ENV['SERVER_PORT']) ) - { - $server_port = ( !empty($_SERVER['SERVER_PORT']) ) ? $_SERVER['SERVER_PORT'] : $_ENV['SERVER_PORT']; - } - else - { - $server_port = '80'; - } - - $script_path = preg_replace('/install\/install\.'.$phpEx.'/i', '', $_SERVER['PHP_SELF']); - - // - // - // $instruction_text = $lang['Inst_Step_0']; -/* - if ( (($_POST['admin_pass1'] != $_POST['admin_pass2']) && $install_step != '0') || ( empty($_POST['admin_pass1']) && !empty($dbhost)) ) + + if ((($HTTP_POST_VARS['admin_pass1'] != $HTTP_POST_VARS['admin_pass2']) && $install_step != '0') || (empty($HTTP_POST_VARS['admin_pass1']) && !empty($dbhost))) { $instruction_text = $lang['Password_mismatch'] . '
' . $instruction_text; } -*/ - $lang_options = language_select($language, 'language', '../language'); - foreach( $available_dbms as $dbms_name => $details ) + $dir = opendir($phpbb_root_path . 'language'); + + $lang_options = array(); + while ($file = readdir($dir)) { - $selected = ( $dbms_name == $dbms ) ? ' selected="selected' : ''; - $dbms_options .= ''; + if (preg_match('#^lang_#i', $file) && !is_file($dirname . '/' . $file) && !is_link($dirname . '/' . $file)) + { + $filename = trim(str_replace('lang_', '', $file)); + $displayname = preg_replace('/^(.*?)_(.*)$/', '\1 [ \2 ]', $filename); + $displayname = preg_replace('/\[(.*?)_(.*)\]/', '[ \1 - \2 ]', $displayname); + $lang_options[$displayname] = $filename; + } } - $upgrade_option = ''; - $upgrade_option .= ''; - $upgrade_option .= ''; + closedir($dir); - $s_hidden_fields = ''; + @asort($lang_options); + @reset($lang_options); - page_header($instruction_text, "install.$phpEx"); + $lang_select = ''; + + $dbms_select = ''; + + $upgrade_option = ''; + + $s_hidden_fields = ''; + + page_header($instruction_text); ?> - - - - - : - - - - : - - - - : - - - - - - - : - - - - : - - - - : - - - - : - - - - : - - - - - - - : - - - - : - - - - : - - - - : - - - - : - - - - : - - - - : - - + + + + + : + + + + : + + + + : + + + + + + + : + + + + : + + + + : + + + + : + + + + : + " /> + + + + + + : + + + + : + + + + : + + + + : + + + + : + + + + : + + + + : + + assign_block_vars("switch_error_install", array()); - - $template->assign_vars(array( - "L_ERROR_TITLE" => $lang['Installer_Error'], - "L_ERROR" => $lang['Install_No_Ext']) - ); - $template->pparse('body'); */ - - die("Error during installation: no $check_exts extension"); + if (!extension_loaded($check_exts) && !extension_loaded($check_other)) + { + page_header($lang['Install'], ''); + page_error($lang['Installer_Error'], $lang['Install_No_Ext']); + page_footer(); + exit; } - include($phpbb_root_path . 'db/' . $dbms . '.' . $phpEx); - - $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); + include($phpbb_root_path.'includes/db.'.$phpEx); } $dbms_schema = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql'; $dbms_basic = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_basic.sql'; $remove_remarks = $available_dbms[$dbms]['COMMENTS'];; - $delimiter = $available_dbms[$dbms]['DELIM']; - $delimiter_basic = $available_dbms[$dbms]['DELIM_BASIC']; + $delimiter = $available_dbms[$dbms]['DELIM']; + $delimiter_basic = $available_dbms[$dbms]['DELIM_BASIC']; - if ( $install_step == 1 || $reinstall ) + if ($install_step == 1) { - if ( $upgrade != 1 ) + if ($upgrade != 1) { - if ( $dbms != 'msaccess' ) + if ($dbms != 'msaccess') { - // // Ok we have the db info go ahead and read in the relevant schema // and work on building the table.. probably ought to provide some // kind of feedback to the user as we are working here in order // to let them know we are actually doing something. - // $sql_query = @fread(@fopen($dbms_schema, 'r'), @filesize($dbms_schema)); - $sql_query = preg_replace('/phpbb_/is', $table_prefix, $sql_query); + $sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query); $sql_query = $remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, $delimiter); - $sql_count = count($sql_query); - - for($i = 0; $i < $sql_count; $i++) + for ($i = 0; $i < sizeof($sql_query); $i++) { - $db->sql_query($sql_query[$i]); + if (trim($sql_query[$i]) != '') + { + if (!($result = $db->sql_query($sql_query[$i]))) + { + $error = $db->sql_error(); + + page_header($lang['Install'], ''); + page_error($lang['Installer_Error'], $lang['Install_db_error'] . '
' . $error['message']); + page_footer(); + exit; + } + } } - - // + // Ok tables have been built, let's fill in the basic information - // $sql_query = @fread(@fopen($dbms_basic, 'r'), @filesize($dbms_basic)); $sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query); $sql_query = $remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, $delimiter_basic); - $sql_count = count($sql_query); - - for($i = 0; $i < $sql_count; $i++) + for($i = 0; $i < sizeof($sql_query); $i++) { - $db->sql_query($sql_query[$i]); + if (trim($sql_query[$i]) != '') + { + if (!($result = $db->sql_query($sql_query[$i]))) + { + $error = $db->sql_error(); + + page_header($lang['Install'], ''); + page_error($lang['Installer_Error'], $lang['Install_db_error'] . '
' . $error['message']); + page_footer(); + exit; + } + } } } - // - // Ok at this point they have entered their admin password, let's go + // Ok at this point they have entered their admin password, let's go // ahead and create the admin account with some basic default information // that they can customize later, and write out the config file. After // this we are going to pass them over to the admin_forum.php script // to set up their forum defaults. - // - $admin_pass_md5 = ( $confirm && $userdata['user_level'] == ADMIN ) ? $admin_pass1 : md5($admin_pass1); $error = ''; - // // Update the default admin user with their information. - // - $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value) + $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value) VALUES ('board_startdate', " . time() . ")"; - $db->sql_query($sql); + if (!$db->sql_query($sql)) + { + $error .= "Could not insert board_startdate :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; + } - $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value) + $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value) VALUES ('default_lang', '" . str_replace("\'", "''", $language) . "')"; - $db->sql_query($sql); + if (!$db->sql_query($sql)) + { + $error .= "Could not insert default_lang :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; + } - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_name . "' - WHERE config_name = 'server_name'"; - $db->sql_query($sql); + $update_config = array( + 'board_email' => $board_email, + 'script_path' => $script_path, + 'server_port' => $server_port, + 'server_name' => $server_name, + ); - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_port . "' - WHERE config_name = 'server_port'"; - $db->sql_query($sql); + while (list($config_name, $config_value) = each($update_config)) + { + $sql = "UPDATE " . $table_prefix . "config + SET config_value = '$config_value' + WHERE config_name = '$config_name'"; + if (!$db->sql_query($sql)) + { + $error .= "Could not insert default_lang :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; + } + } - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $script_path . "' - WHERE config_name = 'script_path'"; - $db->sql_query($sql); + $admin_pass_md5 = ($confirm && $userdata['user_level'] == ADMIN) ? $admin_pass1 : md5($admin_pass1); - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $board_email . "' - WHERE config_name = 'board_email'"; - $db->sql_query($sql); - - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_name . "' - WHERE config_name = 'cookie_domain'"; - $db->sql_query($sql); - - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $admin_name . "' - WHERE config_name = 'newest_username'"; - $db->sql_query($sql); - - $sql = "UPDATE " . $table_prefix . "users + $sql = "UPDATE " . $table_prefix . "users SET username = '" . str_replace("\'", "''", $admin_name) . "', user_password='" . str_replace("\'", "''", $admin_pass_md5) . "', user_lang = '" . str_replace("\'", "''", $language) . "', user_email='" . str_replace("\'", "''", $board_email) . "' WHERE username = 'Admin'"; - $db->sql_query($sql); - - $sql = "UPDATE " . $table_prefix . "moderator_cache - SET username = '" . $admin_name . "' - WHERE username = 'Admin'"; - $db->sql_query($sql); - - $sql = "UPDATE " . $table_prefix . "forums - SET forum_last_poster_name = '" . $admin_name . "' - WHERE forum_last_poster_name = 'Admin'"; - $db->sql_query($sql); - - $sql = "UPDATE " . $table_prefix . "users - SET user_regdate = " . time(); - $db->sql_query($sql); - -/* if ( $error != '' ) + if (!$db->sql_query($sql)) { - $template->assign_block_vars("switch_error_install", array()); + $error .= "Could not update admin info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; + } - $template->assign_vars(array( - "L_ERROR_TITLE" => $lang['Installer_Error'], - "L_ERROR" => $lang['Install_db_error'] . '

' . $error) - ); - - $template->pparse('body'); + $sql = "UPDATE " . $table_prefix . "users + SET user_regdate = " . time(); + if (!$db->sql_query($sql)) + { + $error .= "Could not update user_regdate :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; + } + if ($error != '') + { + page_header($lang['Install'], ''); + page_error($lang['Installer_Error'], $lang['Install_db_error'] . '

' . $error); + page_footer(); exit; - }*/ + } } - if ( !$reinstall && !$upgrade_now ) + if (!$upgrade_now) { -// $template->assign_block_vars("switch_common_install", array()); - - // // Write out the config file. - // $config_data = ''; // Done this to prevent highlighting editors getting confused! @umask(0111); $no_open = FALSE; - if ( !($fp = @fopen('../config.'.$phpEx, 'w')) ) + // Unable to open the file writeable do something here as an attempt + // to get around that... + if (!($fp = @fopen('config.'.$phpEx, 'w'))) { - // - // Unable to open the file writeable do something here as an attempt - // to get around that... - // $s_hidden_fields = ''; - if ( extension_loaded('ftp') && !defined('NO_FTP') ) + if (@extension_loaded('ftp') && !defined('NO_FTP')) { - $template->assign_block_vars('switch_ftp_option', array()); + page_header($lang['Unwriteable_config'] . '

' . $lang['ftp_option'] . '

'); - $lang['Unwriteable_config'] .= '

' . $lang['ftp_option'] . '

'; - - $template->assign_vars(array( - "L_CHOOSE_FTP" => $lang['ftp_choose'], - "L_ATTEMPT_FTP" => $lang['Attempt_ftp'], - "L_SEND_FILE" => $lang['Send_file']) - ); +?> + + + + + + + + + + + +'; } - if ( $upgrade == 1 ) + if ($upgrade == 1) { $s_hidden_fields .= ''; $s_hidden_fields .= ''; @@ -739,23 +973,15 @@ else $s_hidden_fields .= ''; $s_hidden_fields .= ''; - $template->assign_block_vars("switch_upgrade_install", array()); - $template->assign_vars(array( - "L_UPGRADE_INST" => $lang['continue_upgrade'], - "L_UPGRADE_SUBMIT" => $lang['upgrade_submit']) - ); + page_upgrade_form(); + + } + else + { + page_common_form($s_hidden_fields, $lang['Download_config']); } - $template->assign_vars(array( - "L_INSTRUCTION_TEXT" => $lang['Unwriteable_config'], - "L_SUBMIT" => $lang['Download_config'], - - "S_HIDDEN_FIELDS" => $s_hidden_fields, - "S_FORM_ACTION" => "install.$phpEx") - ); - - $template->pparse('body'); - + page_footer(); exit; } @@ -764,119 +990,29 @@ else @fclose($fp); $upgrade_now = $lang['upgrade_submit']; } - else - { -// $template->assign_block_vars("switch_common_install", array()); - } - // // First off let's check and see if we are supposed to be doing an upgrade. - // - if ( $upgrade == 1 && $upgrade_now == $lang['upgrade_submit'] ) + if ($upgrade == 1 && $upgrade_now == $lang['upgrade_submit']) { define('INSTALLING', true); require('upgrade.'.$phpEx); exit; } - // - // Ok we are basically done with the install process let's go on - // and let the user configure their board now. - // - // We are going to do this by calling the admin_board.php from the - // normal board admin section. - // - if ( !$reinstall ) - { - $s_hidden_fields = ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - } - else - { - $s_hidden_fields = ''; - } - page_header($lang['Inst_Step_2'], "../login.$phpEx"); - page_footer($lang['Finish_Install'], $s_hidden_fields); + // Ok we are basically done with the install process let's go on + // and let the user configure their board now. We are going to do + // this by calling the admin_board.php from the normal board admin + // section. + $s_hidden_fields = ''; + $s_hidden_fields .= ''; + $s_hidden_fields .= ''; + $s_hidden_fields .= ''; + page_header($lang['Inst_Step_2']); + page_common_form($s_hidden_fields, $lang['Finish_Install']); + page_footer(); exit; } } -// addslashes to vars if magic_quotes_gpc is off this is a security precaution -// to prevent someone trying to break out of a SQL statement. -function slash_input_data(&$data) -{ - if ( is_array($data) ) - { - foreach ( $data as $k => $v ) - { - $data[$k] = ( is_array($v) ) ? slash_input_data($v) : addslashes($v); - } - } - return $data; -} - -// Output page -> header -function page_header($l_instructions, $s_action) -{ - global $phpEx, $lang; - -?> - - - - - -<?php echo $lang['Welcome_install']; ?> - - - - - - - - -
phpBB Logo      
- - - -


- -

- -
- -
- footer -function page_footer($l_submit, $s_hidden_fields) -{ - global $lang; - -?> - - - -
- -
Powered by phpBB © 2002 phpBB Group
- -
- - - - \ No newline at end of file diff --git a/phpBB/install/update_to_202.php b/phpBB/install/update_to_202.php new file mode 100644 index 0000000000..e3691d1d68 --- /dev/null +++ b/phpBB/install/update_to_202.php @@ -0,0 +1,665 @@ +sql_query($sql)) ) + { + $errored = true; + $error_ary['sql'][] = ( is_array($sql) ) ? $sql[$i] : $sql; + $error_ary['error_code'][] = $db->sql_error(); + } + + if ( $echo_dot ) + { + echo "."; + flush(); + } + + return $result; +} + +define('IN_PHPBB', 1); +$phpbb_root_path = './../'; +include($phpbb_root_path . 'extension.inc'); +include($phpbb_root_path . 'config.'.$phpEx); +include($phpbb_root_path . 'includes/constants.'.$phpEx); +include($phpbb_root_path . 'includes/functions.'.$phpEx); +include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); +include($phpbb_root_path . 'includes/db.'.$phpEx); + +// +// +// +$updates_to_version = ".0.2"; +// +// +// + +?> + + + + + + + + + + + + + +
+ + + + +
Forum HomeUpdating to latest stable release
+ +
+ +

Information

+ +Database type    :: ' . SQL_LAYER . '
'; + +$sql = "SELECT config_value + FROM " . CONFIG_TABLE . " + WHERE config_name = 'version'"; +if ( !($result = $db->sql_query($sql)) ) +{ + die("Couldn't obtain version info"); +} + +$row = $db->sql_fetchrow($result); + +$sql = array(); + +switch ( $row['config_value'] ) +{ + case '': + echo 'Previous version :: < RC-3


'; + break; + case 'RC-3': + echo 'Previous version :: RC-3


'; + break; + case 'RC-4': + echo 'Previous version :: RC-4


'; + break; + default: + echo 'Previous version :: 2' . $row['config_value'] . '
'; + break; +} + +echo 'Updated version  :: 2' . $updates_to_version . '

' ."\n"; + +switch ( $row['config_value'] ) +{ + case '': + switch ( SQL_LAYER ) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP + COLUMN rank_max"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_time int(11) DEFAULT '0' NOT NULL, + ADD COLUMN user_session_page smallint(5) DEFAULT '0' NOT NULL, + ADD INDEX (user_session_time)"; + $sql[] = "ALTER TABLE " . SEARCH_TABLE . " + MODIFY search_id int(11) NOT NULL"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " + MODIFY topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + ADD COLUMN topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + ADD INDEX (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class1_name varchar(50) NULL, + ADD COLUMN tr_class2_name varchar(50) NULL, + ADD COLUMN tr_class3_name varchar(50) NULL, + ADD COLUMN th_class1_name varchar(50) NULL, + ADD COLUMN th_class2_name varchar(50) NULL, + ADD COLUMN th_class3_name varchar(50) NULL, + ADD COLUMN td_class1_name varchar(50) NULL, + ADD COLUMN td_class2_name varchar(50) NULL, + ADD COLUMN td_class3_name varchar(50) NULL, + ADD COLUMN span_class1_name varchar(50) NULL, + ADD COLUMN span_class2_name varchar(50) NULL, + ADD COLUMN span_class3_name varchar(50) NULL"; + break; + case 'postgresql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_time int4"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_page int2"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN user_session_time SET DEFAULT '0'"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN user_session_page SET DEFAULT '0'"; + $sql[] = "CREATE INDEX user_session_time_" . $table_prefix . "users_index + ON " . USERS_TABLE . " (user_session_time)"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " + ADD COLUMN topic_first_post_id int4"; + $sql[] = "CREATE INDEX topic_first_post_id_" . $table_prefix . "topics_index + ON " . TOPICS_TABLE . " (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class3_name varchar(50) NULL"; + break; + + case 'mssql-odbc': + case 'mssql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD + user_session_time int NOT NULL, + user_session_page smallint NOT NULL, + CONSTRAINT [DF_" . $table_prefix . "users_user_session_time] DEFAULT (0) FOR [user_session_time], + CONSTRAINT [DF_" . $table_prefix . "users_user_session_page] DEFAULT (0) FOR [user_session_page]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "users] + ON [" . USERS_TABLE . "]([user_session_time]) ON [PRIMARY]"; + + /* --------------------------------------------------------------------- + DROP FORUM TABLE -- if this may cause you problems you can safely + comment it out, remember to manually remove the IDENTITY setting on + the forum_id column + --------------------------------------------------------------------- */ + $sql [] = "ALTER TABLE " . FORUMS_TABLE . " DROP + CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id], + CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_view], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_read], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_post], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments]"; + $sql[] = "CREATE TABLE Tmp_" . FORUMS_TABLE . " + (forum_id int NOT NULL, cat_id int NOT NULL, forum_name varchar(100) NOT NULL, forum_desc varchar(255) NULL, forum_status smallint NOT NULL, forum_order int NOT NULL, forum_posts int NOT NULL, forum_topics smallint NOT NULL, forum_last_post_id int NOT NULL, prune_next int NULL, prune_enable smallint NOT NULL, auth_view smallint NOT NULL, auth_read smallint NOT NULL, auth_post smallint NOT NULL, auth_reply smallint NOT NULL, auth_edit smallint NOT NULL, auth_delete smallint NOT NULL, auth_sticky smallint NOT NULL, auth_announce smallint NOT NULL, auth_vote smallint NOT NULL, auth_pollcreate smallint NOT NULL, auth_attachments smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "ALTER TABLE [Tmp_" . FORUMS_TABLE . "] WITH NOCHECK ADD + CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts] DEFAULT (0) FOR [forum_posts], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics] DEFAULT (0) FOR [forum_topics], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id] DEFAULT (0) FOR [forum_last_post_id], + CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable] DEFAULT (0) FOR [prune_enable], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_view] DEFAULT (0) FOR [auth_view], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_read] DEFAULT (0) FOR [auth_read], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_post] DEFAULT (0) FOR [auth_post], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply] DEFAULT (0) FOR [auth_reply], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit] DEFAULT (0) FOR [auth_edit], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete] DEFAULT (0) FOR [auth_delete], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky] DEFAULT (0) FOR [auth_sticky], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce] DEFAULT (0) FOR [auth_announce], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote] DEFAULT (0) FOR [auth_vote], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate] DEFAULT (0) FOR [auth_pollcreate], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments] DEFAULT (0) FOR [auth_attachments]"; + $sql[] = "INSERT INTO Tmp_" . FORUMS_TABLE . " (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments) + SELECT forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments FROM " . FORUMS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . FORUMS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . FORUMS_TABLE . "', N'" . FORUMS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . FORUMS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "forums] PRIMARY KEY CLUSTERED (forum_id) ON [PRIMARY]"; + $sql[] = "CREATE NONCLUSTERED INDEX [IX_" . $table_prefix . "forums] + ON " . FORUMS_TABLE . " (cat_id, forum_order, forum_last_post_id) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP FORUM -- don't remove anything after this point! + -------------------------------------------------------------- */ + + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "INSERT INTO Tmp_" . GROPUS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_id, group_type, group_name, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + + $sql[] = "DROP INDEX " . RANKS_TABLE . ".IX_" . $table_prefix . "ranks"; + $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP + COLUMN rank_max"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "ranks] + ON [" . RANKS_TABLE . "]([rank_min], [rank_special]) ON [PRIMARY]"; + + $sql[] = "DROP INDEX " . TOPICS_TABLE . ".IX_" . $table_prefix . "topics"; + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD + topic_first_post_id int NULL, + CONSTRAINT [DF_" . $table_prefix . "topics_topic_first_post_id] FOR [topic_first_post_id]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "topics] + ON [" . TOPICS_TABLE . "]([forum_id], [topic_type], [topic_first_post_id], [topic_last_post_id]) ON [PRIMARY]"; + + $sql[] = "ALTER TABLE " . SEARCH_WORD_TABLE . " DROP + CONSTRAINT [PK_" . $table_prefix . "search_wordlist]"; + $sql[] = "CREATE UNIQUE INDEX [IX_" . $table_prefix . "search_wordlist] + ON [" . SEARCH_WORD_TABLE . "]([word_text]) WITH IGNORE_DUP_KEY ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordlist_1] + ON [" . SEARCH_WORD_TABLE . "]([word_common]) ON [PRIMARY]"; + + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordmatch_1] + ON [" . SEARCH_MATCH_TABLE . "]([word_id]) ON [PRIMARY]"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD + tr_class1_name varchar(50) NULL, + tr_class2_name varchar(50) NULL, + tr_class3_name varchar(50) NULL, + th_class1_name varchar(50) NULL, + th_class2_name varchar(50) NULL, + th_class3_name varchar(50) NULL, + td_class1_name varchar(50) NULL, + td_class2_name varchar(50) NULL, + td_class3_name varchar(50) NULL, + span_class1_name varchar(50) NULL, + span_class2_name varchar(50) NULL, + span_class3_name varchar(50) NULL"; + break; + + case 'msaccess': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD + user_session_time int NOT NULL, + user_session_page smallint NOT NULL"; + $sql[] = "CREATE INDEX user_session_time + ON " . USERS_TABLE . " (user_session_time)"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD + topic_first_post_id int NULL"; + $sql[] = "CREATE INDEX topic_first_post_id + ON " . TOPICS_TABLE . " (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD + tr_class1_name varchar(50) NULL, + tr_class2_name varchar(50) NULL, + tr_class3_name varchar(50) NULL, + th_class1_name varchar(50) NULL, + th_class2_name varchar(50) NULL, + th_class3_name varchar(50) NULL, + td_class1_name varchar(50) NULL, + td_class2_name varchar(50) NULL, + td_class3_name varchar(50) NULL, + span_class1_name varchar(50) NULL, + span_class2_name varchar(50) NULL, + span_class3_name varchar(50) NULL"; + break; + + default: + die("No DB LAYER found!"); + break; + } + + case 'RC-3': + case 'RC-4': + case '.0.0': + switch ( SQL_LAYER ) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + MODIFY COLUMN user_id mediumint(8) NOT NULL, + MODIFY COLUMN user_timezone decimal(4,2) DEFAULT '0' NOT NULL"; + break; + case 'postgresql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + RENAME COLUMN user_timezone TO user_timezone_old"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_timezone decimal(4)"; + break; + case 'mssql': + case 'mssql-odbc': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN [user_timezone] [decimal] (4,2) NOT NULL"; + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "INSERT INTO Tmp_" . GROPUS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_id, group_type, group_name, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + break; + } + + case '.0.1': + switch ( SQL_LAYER ) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " + MODIFY COLUMN group_id mediumint(8) NOT NULL auto_increment"; + break; + case 'mssql': + case 'mssql-odbc': + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "INSERT INTO Tmp_" . GROPUS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_id, group_type, group_name, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + break; + } +} + +echo "

Updating database schema

\n"; +echo "

Progress :: "; +flush(); + +$error_ary = array(); +$errored = false; +if ( count($sql) ) +{ + for($i = 0; $i < count($sql); $i++) + { + _sql($sql[$i], $errored, $error_ary); + } + + echo " Done
Result   :: \n"; + + if ( $errored ) + { + echo " Some queries failed, the statements and errors are listing below\n

    "; + + for($i = 0; $i < count($error_ary['sql']); $i++) + { + echo "
  • Error :: " . $error_ary['error_code'][$i]['message'] . "
    "; + echo "SQL   :: " . $error_ary['sql'][$i] . "

  • "; + } + + echo "
\n

This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See README for details on how to obtain advice.

\n"; + } + else + { + echo "No errors\n"; + } +} +else +{ + echo " No updates required

\n"; +} + +// +// +// +unset($sql); +$error_ary = array(); +$errored = false; + +echo "

Updating data

\n"; +echo "

Progress :: "; +flush(); + +switch ( $row['config_value'] ) +{ + case '': + $sql = "SELECT themes_id + FROM " . THEMES_TABLE . " + WHERE template_name = 'subSilver'"; + $result = _sql($sql, $errored, $error_ary); + + if( $row = $db->sql_fetchrow($result) ) + { + $theme_id = $row['themes_id']; + + $sql = "UPDATE " . THEMES_TABLE . " + SET head_stylesheet = 'subSilver.css', body_background = '', body_bgcolor = 'E5E5E5', body_text = '000000', body_link = '006699', body_vlink = '5493B4', body_alink = '', body_hlink = 'DD6900', tr_color1 = 'EFEFEF', tr_color2 = 'DEE3E7', tr_color3 = 'D1D7DC', tr_class1 = '', tr_class2 = '', tr_class3 = '', th_color1 = '98AAB1', th_color2 = '006699', th_color3 = 'FFFFFF', th_class1 = 'cellpic1.gif', th_class2 = 'cellpic3.gif', th_class3 = 'cellpic2.jpg', td_color1 = 'FAFAFA', td_color2 = 'FFFFFF', td_color3 = '', td_class1 = 'row1', td_class2 = 'row2', td_class3 = '', fontface1 = 'Verdana, Arial, Helvetica, sans-serif', fontface2 = 'Trebuchet MS', fontface3 = 'Courier, ''Courier New'', sans-serif', fontsize1 = 10, fontsize2 = 11, fontsize3 = 12, fontcolor1 = '444444', fontcolor2 = '006600', fontcolor3 = 'FFA34F', span_class1 = '', span_class2 = '', span_class3 = '' + WHERE themes_id = $theme_id"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . THEMES_NAME_TABLE . " + WHERE themes_id = $theme_id"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, tr_color1_name, tr_color2_name, tr_color3_name, tr_class1_name, tr_class2_name, tr_class3_name, th_color1_name, th_color2_name, th_color3_name, th_class1_name, th_class2_name, th_class3_name, td_color1_name, td_color2_name, td_color3_name, td_class1_name, td_class2_name, td_class3_name, fontface1_name, fontface2_name, fontface3_name, fontsize1_name, fontsize2_name, fontsize3_name, fontcolor1_name, fontcolor2_name, fontcolor3_name, span_class1_name, span_class2_name, span_class3_name) + VALUES ($theme_id, 'The lightest row colour', 'The medium row color', 'The darkest row colour', '', '', '', 'Border round the whole page', 'Outer table border', 'Inner table border', 'Silver gradient picture', 'Blue gradient picture', 'Fade-out gradient on index', 'Background for quote boxes', 'All white areas', '', 'Background for topic posts', '2nd background for topic posts', '', 'Main fonts', 'Additional topic title font', 'Form fonts', 'Smallest font size', 'Medium font size', 'Normal font size (post body etc)', 'Quote & copyright text', 'Code text colour', 'Main table header text colour', '', '', '')"; + _sql($sql, $errored, $error_ary); + } + + $sql = "SELECT MIN(post_id) AS first_post_id, topic_id + FROM " . POSTS_TABLE . " + GROUP BY topic_id + ORDER BY topic_id ASC"; + $result = _sql($sql, $errored, $error_ary); + + if ( $row = $db->sql_fetchrow($result) ) + { + do + { + $sql = "UPDATE " . TOPICS_TABLE . " + SET topic_first_post_id = " . $row['first_post_id'] . " + WHERE topic_id = " . $row['topic_id']; + _sql($sql, $errored, $error_ary); + } + while ( $row = $db->sql_fetchrow($result) ); + } + + $sql = "SELECT DISTINCT u.user_id + FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa + WHERE aa.auth_mod = 1 + AND ug.group_id = aa.group_id + AND u.user_id = ug.user_id + AND u.user_level <> " . ADMIN; + $result = _sql($sql, $errored, $error_ary); + + $mod_user = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $mod_user[] = $row['user_id']; + } + + if ( count($mod_user) ) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_level = " . MOD . " + WHERE user_id IN (" . implode(', ', $mod_user) . ")"; + _sql($sql, $errored, $error_ary); + } + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('server_name', 'www.myserver.tld')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('script_path', '/phpBB2/')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('server_port', '80')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('record_online_users', '1')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('record_online_date', '" . time() . "')"; + _sql($sql, $errored, $error_ary); + + case 'RC-3': + case 'RC-4': + case '.0.0': + case '.0.1': + if ( SQL_LAYER == 'postgresql' ) + { + $sql = "SELECT user_id, user_timezone_old + FROM " . USERS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ( $row = $db->sql_fetchrow($result) ) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_timezone = " . $row['user_timezone_old'] . " + WHERE user_id = " . $row['user_id']; + _sql($sql, $errored, $error_ary); + } + } + + $sql = "SELECT topic_id, topic_moved_id + FROM " . TOPICS_TABLE . " + WHERE topic_moved_id <> 0"; + $result = _sql($sql, $errored, $error_ary); + + $topic_ary = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $topic_ary[$row['topic_id']] = $row['topic_moved_id']; + } + + while ( list($topic_id, $topic_moved_id) = each($topic_ary) ) + { + $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts + FROM " . POSTS_TABLE . " + WHERE topic_id = $topic_moved_id"; + $result = _sql($sql, $errored, $error_ary); + + $sql = ( $row = $db->sql_fetchrow($result) ) ? "UPDATE " . TOPICS_TABLE . " SET topic_replies = " . ( $row['total_posts'] - 1 ) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . " WHERE topic_id = $topic_id" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = " . $row['topic_id']; + _sql($sql, $errored, $error_ary); + } + + unset($sql); + + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '$updates_to_version' + WHERE config_name = 'version'"; + _sql($sql, $errored, $error_ary); + + sync('all forums'); + + echo " Done
Result   :: \n"; + + if ( $errored ) + { + echo " Some queries failed, the statements and errors are listing below\n

    "; + + for($i = 0; $i < count($error_ary['sql']); $i++) + { + echo "
  • Error :: " . $error_ary['error_code'][$i]['message'] . "
    "; + echo "SQL   :: " . $error_ary['sql'][$i] . "

  • "; + } + + echo "
\n

This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See README for details on how to obtain advice.

\n"; + } + else + { + echo "No errors\n"; + } + + break; + + default: + echo " No updates where required

\n"; + break; +} + +echo "

Update completed

\n"; +echo "\n

You should now visit the General Configuration settings page in the Administration Panel and check the General Configuration of the board. If you updated from versions prior to RC-3 you must update some entries. If you do not do this emails sent from the board will contain incorrect information. Don't forget to delete this file!

\n"; + +?> + +
+ + + diff --git a/phpBB/install/update_to_203.php b/phpBB/install/update_to_203.php new file mode 100644 index 0000000000..3e0c0176cd --- /dev/null +++ b/phpBB/install/update_to_203.php @@ -0,0 +1,668 @@ +sql_query($sql)) ) + { + $errored = true; + $error_ary['sql'][] = ( is_array($sql) ) ? $sql[$i] : $sql; + $error_ary['error_code'][] = $db->sql_error(); + } + + if ( $echo_dot ) + { + echo "."; + flush(); + } + + return $result; +} + +define('IN_PHPBB', 1); +$phpbb_root_path = './../'; +include($phpbb_root_path . 'extension.inc'); +include($phpbb_root_path . 'config.'.$phpEx); +include($phpbb_root_path . 'includes/constants.'.$phpEx); +include($phpbb_root_path . 'includes/functions.'.$phpEx); +include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); +include($phpbb_root_path . 'includes/db.'.$phpEx); + +// +// +// +$updates_to_version = ".0.3"; +// +// +// + +?> + + + + + + + + + + + + + +
+ + + + +
Forum HomeUpdating to latest stable release
+ +
+ +

Information

+ +Database type    :: ' . SQL_LAYER . '
'; + +$sql = "SELECT config_value + FROM " . CONFIG_TABLE . " + WHERE config_name = 'version'"; +if ( !($result = $db->sql_query($sql)) ) +{ + die("Couldn't obtain version info"); +} + +$row = $db->sql_fetchrow($result); + +$sql = array(); + +switch ( $row['config_value'] ) +{ + case '': + echo 'Previous version :: < RC-3


'; + break; + case 'RC-3': + echo 'Previous version :: RC-3


'; + break; + case 'RC-4': + echo 'Previous version :: RC-4


'; + break; + default: + echo 'Previous version :: 2' . $row['config_value'] . '
'; + break; +} + +echo 'Updated version  :: 2' . $updates_to_version . '

' ."\n"; + +switch ( $row['config_value'] ) +{ + case '': + switch ( SQL_LAYER ) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP + COLUMN rank_max"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_time int(11) DEFAULT '0' NOT NULL, + ADD COLUMN user_session_page smallint(5) DEFAULT '0' NOT NULL, + ADD INDEX (user_session_time)"; + $sql[] = "ALTER TABLE " . SEARCH_TABLE . " + MODIFY search_id int(11) NOT NULL"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " + MODIFY topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + ADD COLUMN topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + ADD INDEX (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class1_name varchar(50) NULL, + ADD COLUMN tr_class2_name varchar(50) NULL, + ADD COLUMN tr_class3_name varchar(50) NULL, + ADD COLUMN th_class1_name varchar(50) NULL, + ADD COLUMN th_class2_name varchar(50) NULL, + ADD COLUMN th_class3_name varchar(50) NULL, + ADD COLUMN td_class1_name varchar(50) NULL, + ADD COLUMN td_class2_name varchar(50) NULL, + ADD COLUMN td_class3_name varchar(50) NULL, + ADD COLUMN span_class1_name varchar(50) NULL, + ADD COLUMN span_class2_name varchar(50) NULL, + ADD COLUMN span_class3_name varchar(50) NULL"; + break; + case 'postgresql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_time int4"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_page int2"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN user_session_time SET DEFAULT '0'"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN user_session_page SET DEFAULT '0'"; + $sql[] = "CREATE INDEX user_session_time_" . $table_prefix . "users_index + ON " . USERS_TABLE . " (user_session_time)"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " + ADD COLUMN topic_first_post_id int4"; + $sql[] = "CREATE INDEX topic_first_post_id_" . $table_prefix . "topics_index + ON " . TOPICS_TABLE . " (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class3_name varchar(50) NULL"; + break; + + case 'mssql-odbc': + case 'mssql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD + user_session_time int NOT NULL, + user_session_page smallint NOT NULL, + CONSTRAINT [DF_" . $table_prefix . "users_user_session_time] DEFAULT (0) FOR [user_session_time], + CONSTRAINT [DF_" . $table_prefix . "users_user_session_page] DEFAULT (0) FOR [user_session_page]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "users] + ON [" . USERS_TABLE . "]([user_session_time]) ON [PRIMARY]"; + + /* --------------------------------------------------------------------- + DROP FORUM TABLE -- if this may cause you problems you can safely + comment it out, remember to manually remove the IDENTITY setting on + the forum_id column + --------------------------------------------------------------------- */ + $sql [] = "ALTER TABLE " . FORUMS_TABLE . " DROP + CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id], + CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_view], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_read], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_post], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments]"; + $sql[] = "CREATE TABLE Tmp_" . FORUMS_TABLE . " + (forum_id int NOT NULL, cat_id int NOT NULL, forum_name varchar(100) NOT NULL, forum_desc varchar(255) NULL, forum_status smallint NOT NULL, forum_order int NOT NULL, forum_posts int NOT NULL, forum_topics smallint NOT NULL, forum_last_post_id int NOT NULL, prune_next int NULL, prune_enable smallint NOT NULL, auth_view smallint NOT NULL, auth_read smallint NOT NULL, auth_post smallint NOT NULL, auth_reply smallint NOT NULL, auth_edit smallint NOT NULL, auth_delete smallint NOT NULL, auth_sticky smallint NOT NULL, auth_announce smallint NOT NULL, auth_vote smallint NOT NULL, auth_pollcreate smallint NOT NULL, auth_attachments smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "ALTER TABLE [Tmp_" . FORUMS_TABLE . "] WITH NOCHECK ADD + CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts] DEFAULT (0) FOR [forum_posts], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics] DEFAULT (0) FOR [forum_topics], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id] DEFAULT (0) FOR [forum_last_post_id], + CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable] DEFAULT (0) FOR [prune_enable], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_view] DEFAULT (0) FOR [auth_view], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_read] DEFAULT (0) FOR [auth_read], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_post] DEFAULT (0) FOR [auth_post], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply] DEFAULT (0) FOR [auth_reply], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit] DEFAULT (0) FOR [auth_edit], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete] DEFAULT (0) FOR [auth_delete], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky] DEFAULT (0) FOR [auth_sticky], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce] DEFAULT (0) FOR [auth_announce], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote] DEFAULT (0) FOR [auth_vote], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate] DEFAULT (0) FOR [auth_pollcreate], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments] DEFAULT (0) FOR [auth_attachments]"; + $sql[] = "INSERT INTO Tmp_" . FORUMS_TABLE . " (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments) + SELECT forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments FROM " . FORUMS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . FORUMS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . FORUMS_TABLE . "', N'" . FORUMS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . FORUMS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "forums] PRIMARY KEY CLUSTERED (forum_id) ON [PRIMARY]"; + $sql[] = "CREATE NONCLUSTERED INDEX [IX_" . $table_prefix . "forums] + ON " . FORUMS_TABLE . " (cat_id, forum_order, forum_last_post_id) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP FORUM -- don't remove anything after this point! + -------------------------------------------------------------- */ + + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "INSERT INTO Tmp_" . GROPUS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_id, group_type, group_name, group_description, group_moderator, group_signle_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + + $sql[] = "DROP INDEX " . RANKS_TABLE . ".IX_" . $table_prefix . "ranks"; + $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP + COLUMN rank_max"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "ranks] + ON [" . RANKS_TABLE . "]([rank_min], [rank_special]) ON [PRIMARY]"; + + $sql[] = "DROP INDEX " . TOPICS_TABLE . ".IX_" . $table_prefix . "topics"; + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD + topic_first_post_id int NULL, + CONSTRAINT [DF_" . $table_prefix . "topics_topic_first_post_id] FOR [topic_first_post_id]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "topics] + ON [" . TOPICS_TABLE . "]([forum_id], [topic_type], [topic_first_post_id], [topic_last_post_id]) ON [PRIMARY]"; + + $sql[] = "ALTER TABLE " . SEARCH_WORD_TABLE . " DROP + CONSTRAINT [PK_" . $table_prefix . "search_wordlist]"; + $sql[] = "CREATE UNIQUE INDEX [IX_" . $table_prefix . "search_wordlist] + ON [" . SEARCH_WORD_TABLE . "]([word_text]) WITH IGNORE_DUP_KEY ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordlist_1] + ON [" . SEARCH_WORD_TABLE . "]([word_common]) ON [PRIMARY]"; + + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordmatch_1] + ON [" . SEARCH_MATCH_TABLE . "]([word_id]) ON [PRIMARY]"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD + tr_class1_name varchar(50) NULL, + tr_class2_name varchar(50) NULL, + tr_class3_name varchar(50) NULL, + th_class1_name varchar(50) NULL, + th_class2_name varchar(50) NULL, + th_class3_name varchar(50) NULL, + td_class1_name varchar(50) NULL, + td_class2_name varchar(50) NULL, + td_class3_name varchar(50) NULL, + span_class1_name varchar(50) NULL, + span_class2_name varchar(50) NULL, + span_class3_name varchar(50) NULL"; + break; + + case 'msaccess': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD + user_session_time int NOT NULL, + user_session_page smallint NOT NULL"; + $sql[] = "CREATE INDEX user_session_time + ON " . USERS_TABLE . " (user_session_time)"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD + topic_first_post_id int NULL"; + $sql[] = "CREATE INDEX topic_first_post_id + ON " . TOPICS_TABLE . " (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD + tr_class1_name varchar(50) NULL, + tr_class2_name varchar(50) NULL, + tr_class3_name varchar(50) NULL, + th_class1_name varchar(50) NULL, + th_class2_name varchar(50) NULL, + th_class3_name varchar(50) NULL, + td_class1_name varchar(50) NULL, + td_class2_name varchar(50) NULL, + td_class3_name varchar(50) NULL, + span_class1_name varchar(50) NULL, + span_class2_name varchar(50) NULL, + span_class3_name varchar(50) NULL"; + break; + + default: + die("No DB LAYER found!"); + break; + } + + case 'RC-3': + case 'RC-4': + case '.0.0': + switch ( SQL_LAYER ) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + MODIFY COLUMN user_id mediumint(8) NOT NULL, + MODIFY COLUMN user_timezone decimal(4,2) DEFAULT '0' NOT NULL"; + break; + case 'postgresql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + RENAME COLUMN user_timezone TO user_timezone_old"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_timezone decimal(4)"; + break; + case 'mssql': + case 'mssql-odbc': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN [user_timezone] [decimal] (4,2) NOT NULL"; + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "INSERT INTO Tmp_" . GROPUS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_id, group_type, group_name, group_description, group_moderator, group_signle_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + break; + } + + case '.0.1': + switch ( SQL_LAYER ) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " + MODIFY COLUMN group_id mediumint(8) NOT NULL auto_increment"; + break; + case 'mssql': + case 'mssql-odbc': + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "INSERT INTO Tmp_" . GROPUS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_id, group_type, group_name, group_description, group_moderator, group_signle_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + break; + + } +} + +echo "

Updating database schema

\n"; +echo "

Progress :: "; +flush(); + +$error_ary = array(); +$errored = false; +if ( count($sql) ) +{ + for($i = 0; $i < count($sql); $i++) + { + _sql($sql[$i], $errored, $error_ary); + } + + echo " Done
Result   :: \n"; + + if ( $errored ) + { + echo " Some queries failed, the statements and errors are listing below\n

    "; + + for($i = 0; $i < count($error_ary['sql']); $i++) + { + echo "
  • Error :: " . $error_ary['error_code'][$i]['message'] . "
    "; + echo "SQL   :: " . $error_ary['sql'][$i] . "

  • "; + } + + echo "
\n

This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See README for details on how to obtain advice.

\n"; + } + else + { + echo "No errors\n"; + } +} +else +{ + echo " No updates required

\n"; +} + +// +// +// +unset($sql); +$error_ary = array(); +$errored = false; + +echo "

Updating data

\n"; +echo "

Progress :: "; +flush(); + +switch ( $row['config_value'] ) +{ + case '': + $sql = "SELECT themes_id + FROM " . THEMES_TABLE . " + WHERE template_name = 'subSilver'"; + $result = _sql($sql, $errored, $error_ary); + + if( $row = $db->sql_fetchrow($result) ) + { + $theme_id = $row['themes_id']; + + $sql = "UPDATE " . THEMES_TABLE . " + SET head_stylesheet = 'subSilver.css', body_background = '', body_bgcolor = 'E5E5E5', body_text = '000000', body_link = '006699', body_vlink = '5493B4', body_alink = '', body_hlink = 'DD6900', tr_color1 = 'EFEFEF', tr_color2 = 'DEE3E7', tr_color3 = 'D1D7DC', tr_class1 = '', tr_class2 = '', tr_class3 = '', th_color1 = '98AAB1', th_color2 = '006699', th_color3 = 'FFFFFF', th_class1 = 'cellpic1.gif', th_class2 = 'cellpic3.gif', th_class3 = 'cellpic2.jpg', td_color1 = 'FAFAFA', td_color2 = 'FFFFFF', td_color3 = '', td_class1 = 'row1', td_class2 = 'row2', td_class3 = '', fontface1 = 'Verdana, Arial, Helvetica, sans-serif', fontface2 = 'Trebuchet MS', fontface3 = 'Courier, ''Courier New'', sans-serif', fontsize1 = 10, fontsize2 = 11, fontsize3 = 12, fontcolor1 = '444444', fontcolor2 = '006600', fontcolor3 = 'FFA34F', span_class1 = '', span_class2 = '', span_class3 = '' + WHERE themes_id = $theme_id"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . THEMES_NAME_TABLE . " + WHERE themes_id = $theme_id"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, tr_color1_name, tr_color2_name, tr_color3_name, tr_class1_name, tr_class2_name, tr_class3_name, th_color1_name, th_color2_name, th_color3_name, th_class1_name, th_class2_name, th_class3_name, td_color1_name, td_color2_name, td_color3_name, td_class1_name, td_class2_name, td_class3_name, fontface1_name, fontface2_name, fontface3_name, fontsize1_name, fontsize2_name, fontsize3_name, fontcolor1_name, fontcolor2_name, fontcolor3_name, span_class1_name, span_class2_name, span_class3_name) + VALUES ($theme_id, 'The lightest row colour', 'The medium row color', 'The darkest row colour', '', '', '', 'Border round the whole page', 'Outer table border', 'Inner table border', 'Silver gradient picture', 'Blue gradient picture', 'Fade-out gradient on index', 'Background for quote boxes', 'All white areas', '', 'Background for topic posts', '2nd background for topic posts', '', 'Main fonts', 'Additional topic title font', 'Form fonts', 'Smallest font size', 'Medium font size', 'Normal font size (post body etc)', 'Quote & copyright text', 'Code text colour', 'Main table header text colour', '', '', '')"; + _sql($sql, $errored, $error_ary); + } + + $sql = "SELECT MIN(post_id) AS first_post_id, topic_id + FROM " . POSTS_TABLE . " + GROUP BY topic_id + ORDER BY topic_id ASC"; + $result = _sql($sql, $errored, $error_ary); + + if ( $row = $db->sql_fetchrow($result) ) + { + do + { + $sql = "UPDATE " . TOPICS_TABLE . " + SET topic_first_post_id = " . $row['first_post_id'] . " + WHERE topic_id = " . $row['topic_id']; + _sql($sql, $errored, $error_ary); + } + while ( $row = $db->sql_fetchrow($result) ); + } + + $sql = "SELECT DISTINCT u.user_id + FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa + WHERE aa.auth_mod = 1 + AND ug.group_id = aa.group_id + AND u.user_id = ug.user_id + AND u.user_level <> " . ADMIN; + $result = _sql($sql, $errored, $error_ary); + + $mod_user = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $mod_user[] = $row['user_id']; + } + + if ( count($mod_user) ) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_level = " . MOD . " + WHERE user_id IN (" . implode(', ', $mod_user) . ")"; + _sql($sql, $errored, $error_ary); + } + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('server_name', 'www.myserver.tld')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('script_path', '/phpBB2/')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('server_port', '80')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('record_online_users', '1')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('record_online_date', '" . time() . "')"; + _sql($sql, $errored, $error_ary); + + case 'RC-3': + case 'RC-4': + case '.0.0': + case '.0.1': + if ( SQL_LAYER == 'postgresql' ) + { + $sql = "SELECT user_id, user_timezone_old + FROM " . USERS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ( $row = $db->sql_fetchrow($result) ) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_timezone = " . $row['user_timezone_old'] . " + WHERE user_id = " . $row['user_id']; + _sql($sql, $errored, $error_ary); + } + } + + $sql = "SELECT topic_id, topic_moved_id + FROM " . TOPICS_TABLE . " + WHERE topic_moved_id <> 0"; + $result = _sql($sql, $errored, $error_ary); + + $topic_ary = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $topic_ary[$row['topic_id']] = $row['topic_moved_id']; + } + + while ( list($topic_id, $topic_moved_id) = each($topic_ary) ) + { + $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts + FROM " . POSTS_TABLE . " + WHERE topic_id = $topic_moved_id"; + $result = _sql($sql, $errored, $error_ary); + + $sql = ( $row = $db->sql_fetchrow($result) ) ? "UPDATE " . TOPICS_TABLE . " SET topic_replies = " . ( $row['total_posts'] - 1 ) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . " WHERE topic_id = $topic_id" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = " . $row['topic_id']; + _sql($sql, $errored, $error_ary); + } + + unset($sql); + + sync('all forums'); + + case '.0.2': + + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '$updates_to_version' + WHERE config_name = 'version'"; + _sql($sql, $errored, $error_ary); + + echo " Done
Result   :: \n"; + + if ( $errored ) + { + echo " Some queries failed, the statements and errors are listing below\n

    "; + + for($i = 0; $i < count($error_ary['sql']); $i++) + { + echo "
  • Error :: " . $error_ary['error_code'][$i]['message'] . "
    "; + echo "SQL   :: " . $error_ary['sql'][$i] . "

  • "; + } + + echo "
\n

This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See README for details on how to obtain advice.

\n"; + } + else + { + echo "No errors\n"; + } + + break; + + default: + echo " No updates where required

\n"; + break; +} + +echo "

Update completed

\n"; +echo "\n

You should now visit the General Configuration settings page in the Administration Panel and check the General Configuration of the board. If you updated from versions prior to RC-3 you must update some entries. If you do not do this emails sent from the board will contain incorrect information. Don't forget to delete this file!

\n"; + +?> + +
+ + + diff --git a/phpBB/install/update_to_204.php b/phpBB/install/update_to_204.php new file mode 100644 index 0000000000..4629d05cde --- /dev/null +++ b/phpBB/install/update_to_204.php @@ -0,0 +1,910 @@ +sql_query($sql))) + { + $errored = true; + $error_ary['sql'][] = (is_array($sql)) ? $sql[$i] : $sql; + $error_ary['error_code'][] = $db->sql_error(); + } + + if ($echo_dot) + { + echo ". \n"; + flush(); + } + + return $result; +} + +@set_time_limit(120); + +define('IN_PHPBB', 1); +$phpbb_root_path = './../'; +include($phpbb_root_path . 'extension.inc'); +include($phpbb_root_path . 'config.'.$phpEx); +include($phpbb_root_path . 'includes/constants.'.$phpEx); +include($phpbb_root_path . 'includes/functions.'.$phpEx); +include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); +include($phpbb_root_path . 'includes/functions_search.'.$phpEx); +include($phpbb_root_path . 'includes/db.'.$phpEx); + +$batch = (isset($HTTP_GET_VARS['batch'])) ? $HTTP_GET_VARS['batch'] : false; + +// +// +// +$updates_to_version = ".0.4"; +// +// +// + +?> + + + + + + + + + + + + + +
+ + + + +
Forum HomeUpdating to latest stable release
+ +
+ +

Information

+ +Database type    :: ' . SQL_LAYER . '
'; + +$sql = "SELECT config_value + FROM " . CONFIG_TABLE . " + WHERE config_name = 'version'"; +if (!($result = $db->sql_query($sql))) +{ + die("Couldn't obtain version info"); +} + +$row = $db->sql_fetchrow($result); + +$sql = array(); + +switch ($row['config_value']) +{ + case '': + echo 'Previous version :: < RC-3


'; + break; + case 'RC-3': + echo 'Previous version :: RC-3


'; + break; + case 'RC-4': + echo 'Previous version :: RC-4


'; + break; + default: + echo 'Previous version :: 2' . $row['config_value'] . '
'; + break; +} + +echo 'Updated version  :: 2' . $updates_to_version . '

' ."\n"; + +// +// Schema updates +// +switch ($row['config_value']) +{ + case '': + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP + COLUMN rank_max"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_time int(11) DEFAULT '0' NOT NULL, + ADD COLUMN user_session_page smallint(5) DEFAULT '0' NOT NULL, + ADD INDEX (user_session_time)"; + $sql[] = "ALTER TABLE " . SEARCH_TABLE . " + MODIFY search_id int(11) NOT NULL"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " + MODIFY topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + ADD COLUMN topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + ADD INDEX (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class1_name varchar(50) NULL, + ADD COLUMN tr_class2_name varchar(50) NULL, + ADD COLUMN tr_class3_name varchar(50) NULL, + ADD COLUMN th_class1_name varchar(50) NULL, + ADD COLUMN th_class2_name varchar(50) NULL, + ADD COLUMN th_class3_name varchar(50) NULL, + ADD COLUMN td_class1_name varchar(50) NULL, + ADD COLUMN td_class2_name varchar(50) NULL, + ADD COLUMN td_class3_name varchar(50) NULL, + ADD COLUMN span_class1_name varchar(50) NULL, + ADD COLUMN span_class2_name varchar(50) NULL, + ADD COLUMN span_class3_name varchar(50) NULL"; + break; + case 'postgresql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_time int4"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_session_page int2"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN user_session_time SET DEFAULT '0'"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN user_session_page SET DEFAULT '0'"; + $sql[] = "CREATE INDEX user_session_time_" . $table_prefix . "users_index + ON " . USERS_TABLE . " (user_session_time)"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " + ADD COLUMN topic_first_post_id int4"; + $sql[] = "CREATE INDEX topic_first_post_id_" . $table_prefix . "topics_index + ON " . TOPICS_TABLE . " (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN tr_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN th_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN td_class3_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class1_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class2_name varchar(50) NULL"; + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " + ADD COLUMN span_class3_name varchar(50) NULL"; + break; + + case 'mssql-odbc': + case 'mssql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD + user_session_time int NOT NULL, + user_session_page smallint NOT NULL, + CONSTRAINT [DF_" . $table_prefix . "users_user_session_time] DEFAULT (0) FOR [user_session_time], + CONSTRAINT [DF_" . $table_prefix . "users_user_session_page] DEFAULT (0) FOR [user_session_page]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "users] + ON [" . USERS_TABLE . "]([user_session_time]) ON [PRIMARY]"; + + /* --------------------------------------------------------------------- + DROP FORUM TABLE -- if this may cause you problems you can safely + comment it out, remember to manually remove the IDENTITY setting on + the forum_id column + --------------------------------------------------------------------- */ + $sql [] = "ALTER TABLE " . FORUMS_TABLE . " DROP + CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id], + CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_view], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_read], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_post], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments]"; + $sql[] = "CREATE TABLE Tmp_" . FORUMS_TABLE . " + (forum_id int NOT NULL, cat_id int NOT NULL, forum_name varchar(100) NOT NULL, forum_desc varchar(255) NULL, forum_status smallint NOT NULL, forum_order int NOT NULL, forum_posts int NOT NULL, forum_topics smallint NOT NULL, forum_last_post_id int NOT NULL, prune_next int NULL, prune_enable smallint NOT NULL, auth_view smallint NOT NULL, auth_read smallint NOT NULL, auth_post smallint NOT NULL, auth_reply smallint NOT NULL, auth_edit smallint NOT NULL, auth_delete smallint NOT NULL, auth_sticky smallint NOT NULL, auth_announce smallint NOT NULL, auth_vote smallint NOT NULL, auth_pollcreate smallint NOT NULL, auth_attachments smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "ALTER TABLE [Tmp_" . FORUMS_TABLE . "] WITH NOCHECK ADD + CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts] DEFAULT (0) FOR [forum_posts], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics] DEFAULT (0) FOR [forum_topics], + CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id] DEFAULT (0) FOR [forum_last_post_id], + CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable] DEFAULT (0) FOR [prune_enable], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_view] DEFAULT (0) FOR [auth_view], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_read] DEFAULT (0) FOR [auth_read], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_post] DEFAULT (0) FOR [auth_post], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply] DEFAULT (0) FOR [auth_reply], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit] DEFAULT (0) FOR [auth_edit], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete] DEFAULT (0) FOR [auth_delete], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky] DEFAULT (0) FOR [auth_sticky], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce] DEFAULT (0) FOR [auth_announce], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote] DEFAULT (0) FOR [auth_vote], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate] DEFAULT (0) FOR [auth_pollcreate], + CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments] DEFAULT (0) FOR [auth_attachments]"; + $sql[] = "INSERT INTO Tmp_" . FORUMS_TABLE . " (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments) + SELECT forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments FROM " . FORUMS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . FORUMS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . FORUMS_TABLE . "', N'" . FORUMS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . FORUMS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "forums] PRIMARY KEY CLUSTERED (forum_id) ON [PRIMARY]"; + $sql[] = "CREATE NONCLUSTERED INDEX [IX_" . $table_prefix . "forums] + ON " . FORUMS_TABLE . " (cat_id, forum_order, forum_last_post_id) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP FORUM -- don't remove anything after this point! + -------------------------------------------------------------- */ + + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "INSERT INTO Tmp_" . GROUPS_TABLE . " (group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_type, group_name, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + + $sql[] = "DROP INDEX " . RANKS_TABLE . ".IX_" . $table_prefix . "ranks"; + $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP + COLUMN rank_max"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "ranks] + ON [" . RANKS_TABLE . "]([rank_min], [rank_special]) ON [PRIMARY]"; + + $sql[] = "DROP INDEX " . TOPICS_TABLE . ".IX_" . $table_prefix . "topics"; + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD + topic_first_post_id int NULL, + CONSTRAINT [DF_" . $table_prefix . "topics_topic_first_post_id] FOR [topic_first_post_id]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "topics] + ON [" . TOPICS_TABLE . "]([forum_id], [topic_type], [topic_first_post_id], [topic_last_post_id]) ON [PRIMARY]"; + + $sql[] = "ALTER TABLE " . SEARCH_WORD_TABLE . " DROP + CONSTRAINT [PK_" . $table_prefix . "search_wordlist]"; + $sql[] = "CREATE UNIQUE INDEX [IX_" . $table_prefix . "search_wordlist] + ON [" . SEARCH_WORD_TABLE . "]([word_text]) WITH IGNORE_DUP_KEY ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordlist_1] + ON [" . SEARCH_WORD_TABLE . "]([word_common]) ON [PRIMARY]"; + + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordmatch_1] + ON [" . SEARCH_MATCH_TABLE . "]([word_id]) ON [PRIMARY]"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD + tr_class1_name varchar(50) NULL, + tr_class2_name varchar(50) NULL, + tr_class3_name varchar(50) NULL, + th_class1_name varchar(50) NULL, + th_class2_name varchar(50) NULL, + th_class3_name varchar(50) NULL, + td_class1_name varchar(50) NULL, + td_class2_name varchar(50) NULL, + td_class3_name varchar(50) NULL, + span_class1_name varchar(50) NULL, + span_class2_name varchar(50) NULL, + span_class3_name varchar(50) NULL"; + break; + + case 'msaccess': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + + $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD + user_session_time int NOT NULL, + user_session_page smallint NOT NULL"; + $sql[] = "CREATE INDEX user_session_time + ON " . USERS_TABLE . " (user_session_time)"; + + $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD + topic_first_post_id int NULL"; + $sql[] = "CREATE INDEX topic_first_post_id + ON " . TOPICS_TABLE . " (topic_first_post_id)"; + + $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD + tr_class1_name varchar(50) NULL, + tr_class2_name varchar(50) NULL, + tr_class3_name varchar(50) NULL, + th_class1_name varchar(50) NULL, + th_class2_name varchar(50) NULL, + th_class3_name varchar(50) NULL, + td_class1_name varchar(50) NULL, + td_class2_name varchar(50) NULL, + td_class3_name varchar(50) NULL, + span_class1_name varchar(50) NULL, + span_class2_name varchar(50) NULL, + span_class3_name varchar(50) NULL"; + break; + + default: + die("No DB LAYER found!"); + break; + } + + case 'RC-3': + case 'RC-4': + case '.0.0': + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + MODIFY COLUMN user_id mediumint(8) NOT NULL, + MODIFY COLUMN user_timezone decimal(4,2) DEFAULT '0' NOT NULL"; + break; + case 'postgresql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + RENAME COLUMN user_timezone TO user_timezone_old"; + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ADD COLUMN user_timezone decimal(4)"; + break; + case 'mssql': + case 'mssql-odbc': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + ALTER COLUMN [user_timezone] [decimal] (4,2) NOT NULL"; + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "SET IDENTITY_INSERT " . GROUPS_TABLE . " ON"; + $sql[] = "INSERT INTO Tmp_" . GROUPS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_id, group_type, group_name, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "SET IDENTITY_INSERT " . GROUPS_TABLE . " OFF"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + break; + } + + case '.0.1': + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " + MODIFY COLUMN group_id mediumint(8) NOT NULL auto_increment"; + break; + case 'mssql': + case 'mssql-odbc': + /* --------------------------------------------------------------------- + DROP GROUP TABLE -- if this may cause you problems you can safely + comment it out, remember to manually add the IDENTITY setting on + the group_id column + --------------------------------------------------------------------- */ + $sql[] = "CREATE TABLE Tmp_" . GROUPS_TABLE . " + (group_id int IDENTITY (1, 1) NOT NULL, group_type smallint NULL, group_name varchar(50) NOT NULL, group_description varchar(255) NOT NULL, group_moderator int NULL, group_single_user smallint NOT NULL) ON [PRIMARY]"; + $sql[] = "SET IDENTITY_INSERT " . GROUPS_TABLE . " ON"; + $sql[] = "INSERT INTO Tmp_" . GROUPS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user) + SELECT group_id, group_type, group_name, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE . " TABLOCKX"; + $sql[] = "SET IDENTITY_INSERT " . GROUPS_TABLE . " OFF"; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "EXECUTE sp_rename N'Tmp_" . GROUPS_TABLE . "', N'" . GROUPS_TABLE . "', 'OBJECT'"; + $sql[] = "ALTER TABLE " . GROUPS_TABLE . " ADD + CONSTRAINT [PK_" . $table_prefix . "groups] PRIMARY KEY CLUSTERED (group_id) ON [PRIMARY]"; + $sql[] = "CREATE INDEX [IX_" . $table_prefix . "groups] + ON " . GROUPS_TABLE . " (group_single_user) ON [PRIMARY]"; + /* -------------------------------------------------------------- + END OF DROP GROUP -- don't remove anything after this point! + -------------------------------------------------------------- */ + break; + + } + + case '.0.3': + + // Add indexes to post_id in search match table (+ word_id for MS Access) + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . SEARCH_MATCH_TABLE . " ADD INDEX post_id (post_id)"; + break; + + case 'postgresql': + $sql[] = "CREATE INDEX post_id_" . SEARCH_MATCH_TABLE . " ON " . SEARCH_MATCH_TABLE . " (post_id)"; + break; + + case 'msaccess': + $sql[] = "CREATE INDEX " . SEARCH_MATCH_TABLE . " ON " . SEARCH_MATCH_TABLE . " ([post_id])"; + $sql[] = "CREATE INDEX " . SEARCH_MATCH_TABLE . "_1 ON " . SEARCH_MATCH_TABLE . " ([word_id])"; + break; + } + + // Regenerate groups table with incremented group_id for pgsql + // ... missing in 2.0.3 ... + switch (SQL_LAYER) + { + case 'postgresql': + $sql[] = "CREATE SEQUENCE " . GROUPS_TABLE . "_id_seq start 3 increment 1 maxvalue 2147483647 minvalue 1 cache 1"; + $sql[] = "CREATE TABLE tmp_" . GROUPS_TABLE . " AS SELECT group_id, group_name, group_type, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "CREATE TABLE phpbb_groups (group_id int DEFAULT nextval('" . GROUPS_TABLE . "_id_seq'::text) NOT NULL, group_name varchar(40) NOT NULL, group_type int2 DEFAULT '1' NOT NULL, group_description varchar(255) NOT NULL, group_moderator int4 DEFAULT '0' NOT NULL, group_single_user int2 DEFAULT '0' NOT NULL, CONSTRAINT phpbb_groups_pkey PRIMARY KEY (group_id))"; + $sql[] = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_type, group_description, group_moderator, group_single_user) SELECT group_id, group_name, group_type, group_description, group_moderator, group_single_user FROM tmp_" . GROUPS_TABLE; + $sql[] = "DROP TABLE tmp_" . GROUPS_TABLE; + break; + } + + // Modify user_timezone to decimal(5,2) for mysql ... mysql4/mssql/pgsql/msaccess + // should be completely unaffected + // Change default user_notify to 0 + switch (SQL_LAYER) + { + case 'mysql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + MODIFY COLUMN user_timezone decimal(5,2) DEFAULT '0' NOT NULL, + MODIFY COLUMN user_notify tinyint(1) DEFAULT '0' NOT NULL"; + break; + + case 'mssql': + case 'mssql-odbc': + break; + + case 'msaccess': + break; + + case 'postgresql': + break; + } +} + +echo "

Updating database schema

\n"; +echo "

Progress :: "; +flush(); + +$error_ary = array(); +$errored = false; +if (count($sql)) +{ + for ($i = 0; $i < count($sql); $i++) + { + _sql($sql[$i], $errored, $error_ary); + } + + echo " Done
Result   :: \n"; + + if ($errored) + { + echo " Some queries failed, the statements and errors are listing below\n

    "; + + for ($i = 0; $i < count($error_ary['sql']); $i++) + { + echo "
  • Error :: " . $error_ary['error_code'][$i]['message'] . "
    "; + echo "SQL   :: " . $error_ary['sql'][$i] . "

  • "; + } + + echo "
\n

This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See README for details on how to obtain advice.

\n"; + } + else + { + echo "No errors\n"; + } +} +else +{ + echo " No updates required

\n"; +} + +// +// Data updates +// +unset($sql); +$error_ary = array(); +$errored = false; + +echo "

Updating data

\n"; +echo "

Progress :: "; +flush(); + +switch ($row['config_value']) +{ + case '': + $sql = "SELECT themes_id + FROM " . THEMES_TABLE . " + WHERE template_name = 'subSilver'"; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + $theme_id = $row['themes_id']; + + $sql = "UPDATE " . THEMES_TABLE . " + SET head_stylesheet = 'subSilver.css', body_background = '', body_bgcolor = 'E5E5E5', body_text = '000000', body_link = '006699', body_vlink = '5493B4', body_alink = '', body_hlink = 'DD6900', tr_color1 = 'EFEFEF', tr_color2 = 'DEE3E7', tr_color3 = 'D1D7DC', tr_class1 = '', tr_class2 = '', tr_class3 = '', th_color1 = '98AAB1', th_color2 = '006699', th_color3 = 'FFFFFF', th_class1 = 'cellpic1.gif', th_class2 = 'cellpic3.gif', th_class3 = 'cellpic2.jpg', td_color1 = 'FAFAFA', td_color2 = 'FFFFFF', td_color3 = '', td_class1 = 'row1', td_class2 = 'row2', td_class3 = '', fontface1 = 'Verdana, Arial, Helvetica, sans-serif', fontface2 = 'Trebuchet MS', fontface3 = 'Courier, ''Courier New'', sans-serif', fontsize1 = 10, fontsize2 = 11, fontsize3 = 12, fontcolor1 = '444444', fontcolor2 = '006600', fontcolor3 = 'FFA34F', span_class1 = '', span_class2 = '', span_class3 = '' + WHERE themes_id = $theme_id"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . THEMES_NAME_TABLE . " + WHERE themes_id = $theme_id"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, tr_color1_name, tr_color2_name, tr_color3_name, tr_class1_name, tr_class2_name, tr_class3_name, th_color1_name, th_color2_name, th_color3_name, th_class1_name, th_class2_name, th_class3_name, td_color1_name, td_color2_name, td_color3_name, td_class1_name, td_class2_name, td_class3_name, fontface1_name, fontface2_name, fontface3_name, fontsize1_name, fontsize2_name, fontsize3_name, fontcolor1_name, fontcolor2_name, fontcolor3_name, span_class1_name, span_class2_name, span_class3_name) + VALUES ($theme_id, 'The lightest row colour', 'The medium row color', 'The darkest row colour', '', '', '', 'Border round the whole page', 'Outer table border', 'Inner table border', 'Silver gradient picture', 'Blue gradient picture', 'Fade-out gradient on index', 'Background for quote boxes', 'All white areas', '', 'Background for topic posts', '2nd background for topic posts', '', 'Main fonts', 'Additional topic title font', 'Form fonts', 'Smallest font size', 'Medium font size', 'Normal font size (post body etc)', 'Quote & copyright text', 'Code text colour', 'Main table header text colour', '', '', '')"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + $sql = "SELECT MIN(post_id) AS first_post_id, topic_id + FROM " . POSTS_TABLE . " + GROUP BY topic_id + ORDER BY topic_id ASC"; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + $sql = "UPDATE " . TOPICS_TABLE . " + SET topic_first_post_id = " . $row['first_post_id'] . " + WHERE topic_id = " . $row['topic_id']; + _sql($sql, $errored, $error_ary); + } + while ($row = $db->sql_fetchrow($result)); + } + $db->sql_freeresult($result); + + $sql = "SELECT DISTINCT u.user_id + FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa + WHERE aa.auth_mod = 1 + AND ug.group_id = aa.group_id + AND u.user_id = ug.user_id + AND u.user_level <> " . ADMIN; + $result = _sql($sql, $errored, $error_ary); + + $mod_user = array(); + while ($row = $db->sql_fetchrow($result)) + { + $mod_user[] = $row['user_id']; + } + $db->sql_freeresult($result); + + if (count($mod_user)) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_level = " . MOD . " + WHERE user_id IN (" . implode(', ', $mod_user) . ")"; + _sql($sql, $errored, $error_ary); + } + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('server_name', 'www.myserver.tld')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('script_path', '/phpBB2/')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('server_port', '80')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('record_online_users', '1')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('record_online_date', '" . time() . "')"; + _sql($sql, $errored, $error_ary); + + case 'RC-3': + case 'RC-4': + case '.0.0': + case '.0.1': + if (SQL_LAYER == 'postgresql') + { + $sql = "SELECT user_id, user_timezone_old + FROM " . USERS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_timezone = " . $row['user_timezone_old'] . " + WHERE user_id = " . $row['user_id']; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + } + + $sql = "SELECT topic_id, topic_moved_id + FROM " . TOPICS_TABLE . " + WHERE topic_moved_id <> 0 + AND topic_status = " . TOPIC_MOVED; + $result = _sql($sql, $errored, $error_ary); + + $topic_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ary[$row['topic_id']] = $row['topic_moved_id']; + } + $db->sql_freeresult($result); + + while (list($topic_id, $topic_moved_id) = each($topic_ary)) + { + $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts + FROM " . POSTS_TABLE . " + WHERE topic_id = $topic_moved_id"; + $result = _sql($sql, $errored, $error_ary); + + $sql = ($row = $db->sql_fetchrow($result)) ? "UPDATE " . TOPICS_TABLE . " SET topic_replies = " . ($row['total_posts'] - 1) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . " WHERE topic_id = $topic_id" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = " . $row['topic_id']; + _sql($sql, $errored, $error_ary); + } + + unset($sql); + + sync('all forums'); + + case '.0.2': + + case '.0.3': + + // Topics will resync automatically + + // Remove stop words from search match and search words + $dirname = 'language'; + $dir = opendir($phpbb_root_path . $dirname); + + while ($file = readdir($dir)) + { + if (preg_match("#^lang_#i", $file) && !is_file($phpbb_root_path . $dirname . "/" . $file) && !is_link($phpbb_root_path . $dirname . "/" . $file) && file_exists($phpbb_root_path . $dirname . "/" . $file . '/search_stopwords.txt')) + { + + $stopword_list = trim(preg_replace('#([\w\.\-_\+\'±µ-ÿ\\\]+?)[ \n\r]*?(,|$)#', '\'\1\'\2', str_replace("'", "\'", implode(', ', file($phpbb_root_path . $dirname . "/" . $file . '/search_stopwords.txt'))))); + + $sql = "SELECT word_id + FROM " . SEARCH_WORD_TABLE . " + WHERE word_text IN ($stopword_list)"; + $result = _sql($sql, $errored, $error_ary); + + $word_id_sql = ''; + if ($row = $db->sql_fetchrow($result)) + { + do + { + $word_id_sql .= (($word_id_sql != '') ? ', ' : '') . $row['word_id']; + } + while ($row = $db->sql_fetchrow($result)); + + $sql = "DELETE FROM " . SEARCH_WORD_TABLE . " + WHERE word_id IN ($word_id_sql)"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " + WHERE word_id IN ($word_id_sql)"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + } + } + closedir($dir); + + // Mark common words ... + remove_common('global', 0.4); + + // remove superfluous polls ... grab polls with topics then delete polls + // not in that list + $sql = "SELECT v.vote_id + FROM " . TOPICS_TABLE . " t, " . VOTE_DESC_TABLE . " v + WHERE v.topic_id = t.topic_id"; + $result = _sql($sql, $errored, $error_ary); + + $vote_id_sql = ''; + if ($row = $db->sql_fetchrow($result)) + { + do + { + $vote_id_sql .= (($vote_id_sql != '') ? ', ' : '') . $row['vote_id']; + } + while ($row = $db->sql_fetchrow($result)); + + $sql = "DELETE FROM " . VOTE_DESC_TABLE . " + WHERE vote_id NOT IN ($vote_id_sql)"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . " + WHERE vote_id NOT IN ($vote_id_sql)"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . VOTE_USERS_TABLE . " + WHERE vote_id NOT IN ($vote_id_sql)"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + // update pm counters + $sql = "SELECT privmsgs_to_userid, COUNT(privmsgs_id) AS unread_count + FROM " . PRIVMSGS_TABLE . " + WHERE privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " + GROUP BY privmsgs_to_userid"; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + $update_users = array(); + do + { + $update_users[$row['unread_count']][] = $row['privmsgs_to_userid']; + } + while ($row = $db->sql_fetchrow($result)); + + while (list($num, $user_ary) = each($update_users)) + { + $user_ids = implode(', ', $user_ary); + + $sql = "UPDATE " . USERS_TABLE . " + SET user_unread_privmsg = $num + WHERE user_id IN ($user_ids)"; + _sql($sql, $errored, $error_ary); + } + unset($update_list); + } + $db->sql_freeresult($result); + + $sql = "SELECT privmsgs_to_userid, COUNT(privmsgs_id) AS new_count + FROM " . PRIVMSGS_TABLE . " + WHERE privmsgs_type = " . PRIVMSGS_NEW_MAIL . " + GROUP BY privmsgs_to_userid"; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + $update_users = array(); + do + { + $update_users[$row['new_count']][] = $row['privmsgs_to_userid']; + } + while ($row = $db->sql_fetchrow($result)); + + while (list($num, $user_ary) = each($update_users)) + { + $user_ids = implode(', ', $user_ary); + + $sql = "UPDATE " . USERS_TABLE . " + SET user_new_privmsg = $num + WHERE user_id IN ($user_ids)"; + _sql($sql, $errored, $error_ary); + } + unset($update_list); + } + $db->sql_freeresult($result); + + // Remove superfluous watched topics + $sql = "SELECT t.topic_id + FROM " . TOPICS_TABLE . " t, " . TOPICS_WATCH_TABLE . " w + WHERE w.topic_id = t.topic_id"; + $result = _sql($sql, $errored, $error_ary); + + $topic_id_sql = ''; + if ($row = $db->sql_fetchrow($result)) + { + do + { + $topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . $row['topic_id']; + } + while ($row = $db->sql_fetchrow($result)); + + $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " + WHERE topic_id NOT IN ($topic_id_sql)"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + // Optimize/vacuum analyze the tables where appropriate + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; + _sql($sql, $errored, $error_ary); + break; + + case 'postgresql': + _sql("VACUUM ANALYZE", $errored, $error_ary); + break; + } + + // Very last thing, update the version + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '$updates_to_version' + WHERE config_name = 'version'"; + _sql($sql, $errored, $error_ary); + + echo " Done
Result   :: \n"; + + if ($errored) + { + echo " Some queries failed, the statements and errors are listing below\n

    "; + + for ($i = 0; $i < count($error_ary['sql']); $i++) + { + echo "
  • Error :: " . $error_ary['error_code'][$i]['message'] . "
    "; + echo "SQL   :: " . $error_ary['sql'][$i] . "

  • "; + } + + echo "
\n

This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See README for details on how to obtain advice.

\n"; + } + else + { + echo "No errors\n"; + } + + break; + + default: + echo " No updates where required

\n"; + break; +} + +echo "

Update completed

\n"; +echo "\n

You should now visit the General Configuration settings page in the Administration Panel and check the General Configuration of the board. If you updated from versions prior to RC-3 you must update some entries. If you do not do this emails sent from the board will contain incorrect information. Don't forget to delete this file!

\n"; + +?> + +
+ + + \ No newline at end of file diff --git a/phpBB/install/upgrade.php b/phpBB/install/upgrade.php index 7cad1a220a..5500627ef2 100644 --- a/phpBB/install/upgrade.php +++ b/phpBB/install/upgrade.php @@ -20,7 +20,8 @@ ***************************************************************************/ define('IN_PHPBB', true); -$phpbb_root_path='./../'; + +$phpbb_root_path = './../'; if ( !defined('INSTALLING') ) { @@ -36,10 +37,9 @@ if ( !defined('INSTALLING') ) include($phpbb_root_path . 'includes/constants.'.$phpEx); include($phpbb_root_path . 'includes/functions.'.$phpEx); - if ( defined('PHPBB_INSTALLED') ) + if( defined("PHPBB_INSTALLED") ) { - header("Location: index.$phpEx"); - exit; + redirect("index.$phpEx); } } @@ -812,24 +812,16 @@ if ( !empty($next) ) $per_pct = ceil( $db->sql_numrows($result) / 40 ); $inc = 0; + $group_id = 1; while( $row = $db->sql_fetchrow($result) ) { - $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user) - VALUES ('" . addslashes($row['username']) . "', 'Personal User', 1)"; + $sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_description, group_single_user) + VALUES ($group_id, '" . addslashes($row['username']) . "', 'Personal User', 1)"; query($sql, "Wasn't able to insert user ".$row['user_id']." into table ".GROUPS_TABLE); - $group_id = $db->sql_nextid(); - - if ( $group_id != 0 ) - { - $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) - VALUES ($group_id, " . $row['user_id'] . ", 0)"; - query($sql, "Wasn't able to insert user ".$row['user_id']." into table ".USER_GROUP_TABLE); - } - else - { - print "Couldn't get insert ID for " . GROUPS_TABLE . " table
\n"; - } + $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) + VALUES ($group_id, " . $row['user_id'] . ", 0)"; + query($sql, "Wasn't able to insert user ".$row['user_id']." into table ".USER_GROUP_TABLE); if ( is_int($row['user_regdate']) ) { @@ -837,6 +829,8 @@ if ( !empty($next) ) continue; } + $group_id++; + // // Nathan's bbcode2 conversion // @@ -1630,77 +1624,6 @@ if ( !empty($next) ) } print " OK
\n"; - end_step('fulltext_search_indexing'); - - case 'fulltext_search_indexing': - // - // Generate search word list - // - // Fetch a batch of posts_text entries - // - $sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id - FROM " . POSTS_TEXT_TABLE; - $result = query($sql, "Couldn't get post count totals"); - - $max_post_id = $db->sql_fetchrow($result); - - $totalposts = $max_post_id['total']; - $max_post_id = $max_post_id['max_post_id']; - $per_percent = round(( $totalposts / 500 ) * 10); - - $postcounter = ( !isset($HTTP_GET_VARS['batchstart']) ) ? 0 : $HTTP_GET_VARS['batchstart']; - - $batchsize = 150; // Process this many posts per loop - $batchcount = 0; - $total_percent = 0; - - for(;$postcounter <= $max_post_id; $postcounter += $batchsize) - { - $batchstart = $postcounter + 1; - $batchend = $postcounter + $batchsize; - $batchcount++; - - print " * Fulltext Indexing ( $batchstart to $batchend ) :: "; - flush(); - - $sql = "SELECT * - FROM " . POSTS_TEXT_TABLE ." - WHERE post_id - BETWEEN $batchstart - AND $batchend"; - $posts_result = query($sql, "Couldn't obtain post_text"); - - $per_pct = ceil( $db->sql_numrows($posts_result) / 40 ); - $inc = 0; - - if ( $row = $db->sql_fetchrow($posts_result) ) - { - do - { - add_search_words($row['post_id'], $row['post_text'], $row['post_subject']); - - $inc++; - if ( $inc == $per_pct ) - { - print "."; - flush(); - $inc = 0; - } - } - while( $row = $db->sql_fetchrow($posts_result) ); - } - - $db->sql_freeresult($posts_result); - - // Remove common words after the first 2 batches and after every 4th batch after that. - if ( $batchcount % 4 == 3 ) - { - remove_common('global', 0.4); - } - - print " OK
\n"; - } - end_step('update_topics'); case 'update_topics': @@ -1866,7 +1789,7 @@ if ( !empty($next) ) $sql = "UPDATE " . $table_prefix . "config SET config_value = '" . $script_path . "' WHERE config_name = 'script_path'"; - query($sql, "Couldn't insert Board admin email"); + query($sql, "Couldn't insert Board script path"); // // Change session table to HEAP if MySQL version matches @@ -1881,7 +1804,7 @@ if ( !empty($next) ) if ( preg_match("/^(3\.23)|(4\.)/", $version) ) { $sql = "ALTER TABLE " . $table_prefix . "sessions - TYPE=HEAP"; + TYPE=HEAP MAX_ROWS=500"; $db->sql_query($sql); } @@ -1930,6 +1853,77 @@ if ( !empty($next) ) print "OK
\n"; } + end_step('fulltext_search_indexing'); + + case 'fulltext_search_indexing': + // + // Generate search word list + // + // Fetch a batch of posts_text entries + // + $sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id + FROM " . POSTS_TEXT_TABLE; + $result = query($sql, "Couldn't get post count totals"); + + $max_post_id = $db->sql_fetchrow($result); + + $totalposts = $max_post_id['total']; + $max_post_id = $max_post_id['max_post_id']; + $per_percent = round(( $totalposts / 500 ) * 10); + + $postcounter = ( !isset($HTTP_GET_VARS['batchstart']) ) ? 0 : $HTTP_GET_VARS['batchstart']; + + $batchsize = 150; // Process this many posts per loop + $batchcount = 0; + $total_percent = 0; + + for(;$postcounter <= $max_post_id; $postcounter += $batchsize) + { + $batchstart = $postcounter + 1; + $batchend = $postcounter + $batchsize; + $batchcount++; + + print " * Fulltext Indexing ( $batchstart to $batchend ) :: "; + flush(); + + $sql = "SELECT * + FROM " . POSTS_TEXT_TABLE ." + WHERE post_id + BETWEEN $batchstart + AND $batchend"; + $posts_result = query($sql, "Couldn't obtain post_text"); + + $per_pct = ceil( $db->sql_numrows($posts_result) / 40 ); + $inc = 0; + + if ( $row = $db->sql_fetchrow($posts_result) ) + { + do + { + add_search_words('global', $row['post_id'], $row['post_text'], $row['post_subject']); + + $inc++; + if ( $inc == $per_pct ) + { + print "."; + flush(); + $inc = 0; + } + } + while( $row = $db->sql_fetchrow($posts_result) ); + } + + $db->sql_freeresult($posts_result); + + // Remove common words after the first 2 batches and after every 4th batch after that. + if ( $batchcount % 4 == 3 ) + { + remove_common('global', 0.4); + } + + print " OK
\n"; + } + echo "\n

\n\nUPGRADE COMPLETED
\n"; } }