diff --git a/phpBB/install.php b/phpBB/install.php deleted file mode 100644 index 86276878c1..0000000000 --- a/phpBB/install.php +++ /dev/null @@ -1,1040 +0,0 @@ - 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" - ), - "postgres" => array( - "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" - ), - "msaccess" => array( - "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" - ) -); - -// -// drop table schema -// -$sql_array = array(); - -$sql_array['drop_schema'][] = "DROP TABLE phpbb_auth_access"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_banlist"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_categories"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_config"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_disallow"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_forum_prune"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_forums"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_groups"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_posts"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_posts_text"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_privmsgs"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_privmsgs_text"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_ranks"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_search_results"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_search_wordlist"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_search_wordmatch"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_sessions"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_smilies"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_themes"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_themes_name"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_topics"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_topics_watch"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_user_group"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_users"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_vote_desc"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_vote_results"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_vote_voters"; -$sql_array['drop_schema'][] = "DROP TABLE phpbb_words"; - -// -// Uncomment the following line to completely disable the ftp option... -// -// define('NO_FTP', true); - -/*************************************************************************** -* -* End Install Customization Section -* -***************************************************************************/ - -// -// Obtain various vars -// -$confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? true : false; -$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false; - -if( isset($HTTP_POST_VARS['install_step']) || isset($HTTP_GET_VARS['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($HTTP_POST_VARS['upgrade']) ) ? $HTTP_POST_VARS['upgrade']: ''; -$upgrade_now = ( !empty($HTTP_POST_VARS['upgrade_now']) ) ? $HTTP_POST_VARS['upgrade_now']:''; - -$dbms = isset($HTTP_POST_VARS['dbms']) ? $HTTP_POST_VARS['dbms'] : ""; -$language = ( !empty($HTTP_POST_VARS['language']) ) ? $HTTP_POST_VARS['language'] : $default_language; - -$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($HTTP_POST_VARS['prefix']) ) ? $HTTP_POST_VARS['prefix'] : ""; - -$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($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($HTTP_POST_VARS['server_name']) ) ? $HTTP_POST_VARS['server_name'] : ""; -$server_port = ( !empty($HTTP_POST_VARS['server_port']) ) ? $HTTP_POST_VARS['server_port'] : ""; -$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'] : ""; - -if( @file_exists(@realpath('config.'.$phpEx)) ) -{ - include('config.'.$phpEx); -} - -if( !defined("PHPBB_INSTALLED") ) -{ - include($phpbb_root_path.'includes/sql_parse.'.$phpEx); - include($phpbb_root_path.'includes/constants.'.$phpEx); - include($phpbb_root_path.'includes/template.'.$phpEx); - include($phpbb_root_path.'includes/functions.'.$phpEx); - include($phpbb_root_path.'includes/sessions.'.$phpEx); - - // - // Import language file, setup template ... - // - include($phpbb_root_path.'language/lang_' . $language . '/lang_main.'.$phpEx); - include($phpbb_root_path.'language/lang_' . $language . '/lang_admin.'.$phpEx); - - $template = new Template($phpbb_root_path . "templates/" . $default_template); - - // - // 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); - $install_step = 1; - } - - // - // Load default template for install - // - $template->set_filenames(array( - "body" => "install.tpl") - ); - - $template->assign_vars(array( - "L_INSTALLATION" => $lang['Welcome_install'], - "L_ENCODING" => $lang['ENCODING']) - ); -} -else -{ - define("IN_ADMIN", 1); - - include($phpbb_root_path.'common.'.$phpEx); - include($phpbb_root_path.'includes/sql_parse.'.$phpEx); - - // - // Set page ID for session management - // - $userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length); - init_userprefs($userdata); - // - // End session management - // - - if( $userdata['user_level'] == ADMIN && !$cancel && $dbms != 'msaccess' ) - { - if( !$confirm ) - { - // - // Sorry this has already been installed can't do anything more with it - // - include($phpbb_root_path . 'includes/page_header.'.$phpEx); - - $template->set_filenames(array( - "confirm" => "confirm_body.tpl") - ); - - $template->assign_vars(array( - "MESSAGE_TITLE" => $lang['Admin_config'], - "MESSAGE_TEXT" => $lang['Re_install'], - - "L_YES" => $lang['Yes'], - "L_NO" => $lang['No'], - - "S_CONFIRM_ACTION" => append_sid("install.$phpEx"), - "S_HIDDEN_FIELDS" => $hidden_fields) - ); - - $template->pparse("confirm"); - - include($phpbb_root_path . 'includes/page_tail.'.$phpEx); - } - - include($phpbb_root_path.'language/lang_' . $language . '/lang_main.'.$phpEx); - include($phpbb_root_path.'language/lang_' . $language . '/lang_admin.'.$phpEx); - - $template = new Template($phpbb_root_path . "templates/" . $default_template); - - $template->set_filenames(array( - "body" => "install.tpl") - ); - - $template->assign_vars(array( - "L_INSTALLATION" => $lang['Welcome_install'], - "L_ENCODING" => $lang['ENCODING']) - ); - - $reinstall = true; - } - else - { - header("Location: " . append_sid("index.$phpEx", true)); - exit; - } -} - -// -// -// -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 - // if it is on. - // - $HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']); - - echo $HTTP_POST_VARS['config_data']; - - exit; -} -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. - // - - $HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']); - - $s_hidden_fields = ''; - $s_hidden_fields .= ''; - - if( $upgrade == 1 ) - { - $s_hidden_fields .= ''; - } - - $template->assign_block_vars("switch_ftp_file", array()); - $template->assign_block_vars("switch_common_install", array()); - - $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"); - - exit; - -} -else if( !empty($HTTP_POST_VARS['ftp_file']) && !defined("PHPBB_INSTALLED") ) -{ - // - // Here we'll actually send the file... - // - $HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']); - - $conn_id = @ftp_connect('localhost'); - $login_result = @ftp_login($conn_id, "$ftp_user", "$ftp_pass"); - - if( !$conn_id || !$login_result ) - { - // - // Error couldn't get connected... Go back to option to send file... - // - $s_hidden_fields = ''; - $s_hidden_fields .= ''; - if( $upgrade == 1 ) - { - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $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']) - ); - } - $template->assign_block_vars("switch_common_install", array()); - - $template->assign_vars(array( - "L_INSTRUCTION_TEXT" => $lang['NoFTP_config'], - "L_SUBMIT" => $lang['Download_config'], - - "S_HIDDEN_FIELDS" => $s_hidden_fields, - "S_FORM_ACTION" => "install.$phpEx") - ); - - $template->pparse('body'); - - 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, $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); - - @ftp_quit($conn_id); - - unlink($tmpfname); - 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. - // - $s_hidden_fields = ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - - $template->assign_block_vars("switch_common_install", array()); - - $template->assign_vars(array( - "L_INSTRUCTION_TEXT" => $lang['Inst_Step_2'], - "L_SUBMIT" => $lang['Finish_Install'], - - "S_HIDDEN_FIELDS" => $s_hidden_fields, - "S_FORM_ACTION" => "login.$phpEx") - ); - - $template->pparse('body'); - - exit(); - } -} -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 - // 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($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_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'; - } - $script_path = preg_replace('/install\.'.$phpEx.'/i', '', $HTTP_SERVER_VARS['PHP_SELF']); - - $instruction_text = $lang['Inst_Step_0']; - - 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'); - - $dbms_options = ''; - - $upgrade_option = ''; - - $s_hidden_fields = ''; - - $template->assign_block_vars("switch_stage_one_install", array()); - $template->assign_block_vars("switch_common_install", array()); - - $template->assign_vars(array( - "L_INSTRUCTION_TEXT" => $instruction_text, - "L_INITIAL_CONFIGURATION" => $lang['Initial_config'], - "L_DATABASE_CONFIGURATION" => $lang['DB_config'], - "L_ADMIN_CONFIGURATION" => $lang['Admin_config'], - "L_LANGUAGE" => $lang['Default_lang'], - "L_DBMS" => $lang['dbms'], - "L_DB_HOST" => $lang['DB_Host'], - "L_DB_NAME" => $lang['DB_Name'], - "L_DB_USER" => $lang['DB_Username'], - "L_DB_PASSWORD" => $lang['DB_Password'], - "L_DB_PREFIX" => $lang['Table_Prefix'], - "L_UPGRADE" => $lang['Install_Method'], - "L_ADMIN_USERNAME" => $lang['Admin_Username'], - "L_ADMIN_PASSWORD" => $lang['Admin_Password'], - "L_ADMIN_CONFIRM_PASSWORD" => $lang['Admin_Password_confirm'], - "L_SUBMIT" => $lang['Start_Install'], - "L_ADMIN_EMAIL" => $lang['Admin_email'], - "L_SERVER_NAME" => $lang['Server_name'], - "L_SERVER_PORT" => $lang['Server_port'], - "L_SCRIPT_PATH" => $lang['Script_path'], - - "SCRIPT_PATH" => $script_path, - "SERVER_PORT" => $server_port, - "SERVER_NAME" => $server_name, - "DB_PREFIX" => ( !empty($table_prefix) ) ? $table_prefix : "phpbb_", - "DB_HOST" => ( $dbhost != "" ) ? $dbhost : "", - "DB_USER" => ( $dbuser != "" ) ? $dbuser : "", - "DB_PASSWD" => ( $dbpasswd != "" ) ? $dbpasswd : "", - "ADMIN_USERNAME" => ( $admin_name != "" ) ? $admin_name : "", - - "S_LANG_SELECT" => $lang_options, - "S_DBMS_SELECT" => $dbms_options, - "S_HIDDEN_FIELDS" => $s_hidden_fields, - "S_UPGRADE_SELECT" => $upgrade_option, - "S_FORM_ACTION" => "install.$phpEx") - ); - - $template->pparse("body"); - - exit; -} -else -{ - // - // Go ahead and create the DB, then populate it - // - // MS Access is slightly different in that a pre-built, pre- - // populated DB is supplied, all we need do here is update - // the relevant entries - // - if( $reinstall ) - { - $sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_array['drop_schema']); - $sql_count = count($sql_query); - - for($i = 0; $i < $sql_count; $i++) - { - $result = $db->sql_query($sql_query[$i]); - if( !$result ) - { - $error = $db->sql_error(); - - $template->assign_block_vars("switch_error_install", array()); - - $template->assign_vars(array( - "L_ERROR_TITLE" => $lang['Installer_Error'], - "L_ERROR" => $lang['Install_db_error'] . '

' . $error) - ); - - $template->pparse('body'); - - exit; - } - } - - $admin_name = $userdata['username']; - $admin_pass1 = $userdata['user_password']; - $language = $userdata['user_lang']; - } - else if( isset($dbms) ) - { - switch( $dbms ) - { - case 'msaccess': - case 'mssql-odbc': - $check_exts = 'odbc'; - $check_other = 'odbc'; - break; - case 'mssql': - $check_exts = 'mssql'; - $check_other = 'sybase'; - break; - case 'mysql': - case 'mysql4': - $check_exts = 'mysql'; - $check_other = 'mysql'; - break; - case 'postgres': - $check_exts = 'pgsql'; - $check_other = 'pgsql'; - break; - } - if( !extension_loaded( $check_exts ) && !extension_loaded( $check_other ) ) - { - $template->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'); - exit; - } - include($phpbb_root_path.'includes/db.'.$phpEx); - } - - $dbms_schema = 'db/schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql'; - $dbms_basic = 'db/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']; - - if( $install_step == 1 || $reinstall ) - { - if( $upgrade != 1 ) - { - 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_/', $table_prefix, $sql_query); - - $sql_query = $remove_remarks($sql_query); - $sql_query = split_sql_file($sql_query, $delimiter); - - for ($i = 0; $i < sizeof($sql_query); $i++) - { - if (trim($sql_query[$i]) != '') - { - if (!($result = $db->sql_query($sql_query[$i]))) - { - $error = $db->sql_error(); - - $template->assign_block_vars("switch_error_install", array()); - - $template->assign_vars(array( - "L_ERROR_TITLE" => $lang['Installer_Error'], - "L_ERROR" => $lang['Install_db_error'] . '
' . $error['message']) - ); - - $template->pparse('body'); - - 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); - - for($i = 0; $i < sizeof($sql_query); $i++) - { - if (trim($sql_query[$i]) != '') - { - if (!($result = $db->sql_query($sql_query[$i]))) - { - $error = $db->sql_error(); - - $template->assign_block_vars("switch_error_install", array()); - - $template->assign_vars(array( - "L_ERROR_TITLE" => $lang['Installer_Error'], - "L_ERROR" => $lang['Install_db_error'] . "
" . $error["message"]) - ); - - $template->pparse('body'); - - exit; - } - } - } - } - - // - // 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. - // - $error = ''; - - // - // Update the default admin user with their information. - // - $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value) - VALUES ('board_startdate', " . time() . ")"; - $result = $db->sql_query($sql); - if( !$result ) - { - $error .= "Could not insert board_startdate :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

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

"; - } - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_name . "' - WHERE config_name = 'server_name'"; - $result = $db->sql_query($sql); - if( !$result ) - { - $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; - } - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_port . "' - WHERE config_name = 'server_port'"; - $result = $db->sql_query($sql); - if( !$result ) - { - $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; - } - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $script_path . "' - WHERE config_name = 'script_path'"; - $result = $db->sql_query($sql); - if( !$result ) - { - $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; - } - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $board_email . "' - WHERE config_name = 'board_email'"; - $result = $db->sql_query($sql); - if( !$result ) - { - $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; - } - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_name . "' - WHERE config_name = 'cookie_domain'"; - $result = $db->sql_query($sql); - if( !$result ) - { - $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

"; - } - - - $admin_pass_md5 = ( $confirm && $userdata['user_level'] == ADMIN ) ? $admin_pass1 : md5($admin_pass1); - - $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'"; - $result = $db->sql_query($sql); - if( !$result ) - { - $error .= "Could not update admin info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "

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

"; - } - - /* - // Disabled in 2.0.4 ... too many issues with MAX ROWS - // - // Change session table to HEAP if MySQL version matches - // - if( preg_match("/^mysql/", $dbms) ) - { - $sql = "SELECT VERSION() AS mysql_version"; - if($result = $db->sql_query($sql)) - { - $row = $db->sql_fetchrow($result); - $version = $row['mysql_version']; - - if( preg_match("/^(3\.23)|(4\.)/", $version) ) - { - $sql = "ALTER TABLE " . $table_prefix . "sessions - TYPE=HEAP MAX_ROWS=500"; - $db->sql_query($sql); - } - } - } - */ - - if( $error != "" ) - { - $template->assign_block_vars("switch_error_install", array()); - - $template->assign_vars(array( - "L_ERROR_TITLE" => $lang['Installer_Error'], - "L_ERROR" => $lang['Install_db_error'] . '

' . $error) - ); - - $template->pparse('body'); - - exit; - } - } - - if( !$reinstall && !$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; - - $fp = @fopen('config.'.$phpEx, 'w'); - if( !$fp ) - { - // - // 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') ) - { - $template->assign_block_vars('switch_ftp_option', array()); - - $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']) - ); - } - else - { - $s_hidden_fields .= ''; - } - if( $upgrade == 1 ) - { - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $s_hidden_fields .= ''; - $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']) - ); - } - - $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'); - - exit; - } - - $result = @fputs($fp, $config_data, strlen($config_data)); - - @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'] ) - { - 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 = ""; - } - - $template->assign_vars(array( - "L_INSTRUCTION_TEXT" => $lang['Inst_Step_2'], - "L_SUBMIT" => $lang['Finish_Install'], - - "S_HIDDEN_FIELDS" => $s_hidden_fields, - "S_FORM_ACTION" => ( $reinstall ) ? append_sid("login.$phpEx") : "login.$phpEx") - ); - - $template->pparse('body'); - - exit; - } -} - -?> diff --git a/phpBB/update_to_202.php b/phpBB/update_to_202.php deleted file mode 100644 index 21c3eb8450..0000000000 --- a/phpBB/update_to_202.php +++ /dev/null @@ -1,665 +0,0 @@ -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

\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

\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/update_to_203.php b/phpBB/update_to_203.php deleted file mode 100644 index 39d6f6d195..0000000000 --- a/phpBB/update_to_203.php +++ /dev/null @@ -1,668 +0,0 @@ -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

\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

\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/update_to_204.php b/phpBB/update_to_204.php deleted file mode 100644 index 095978ca9c..0000000000 --- a/phpBB/update_to_204.php +++ /dev/null @@ -1,910 +0,0 @@ -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

\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

\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/upgrade.php b/phpBB/upgrade.php deleted file mode 100644 index 8674641b8f..0000000000 --- a/phpBB/upgrade.php +++ /dev/null @@ -1,1933 +0,0 @@ - 1, - 'Feb' => 2, - 'Mar' => 3, - 'Apr' => 4, - 'May' => 5, - 'Jun' => 6, - 'Jul' => 7, - 'Aug' => 8, - 'Sep' => 9, - 'Sept' => 9, - 'Oct' => 10, - 'Nov' => 11, - 'Dec' => 12 -); - -// --------------- -// Begin functions -// -function common_header() -{ -?> - - - - - - - - - - - - - -
- - - - -
Forum HomeUpgrading to phpBB 2.0
- -
- - - -
- - - -sql_query($sql)) ) - { - print "
\n"; - print "$errormsg
"; - - $sql_error = $db->sql_error(); - print $sql_error['code'] .": ". $sql_error['message']. "
\n"; - - print "
$sql
"; - print "
\n"; - - return FALSE; - } - else - { - return $result; - } -} - -function smiley_replace($text = '') -{ - global $db; - - static $search, $replace; - - // Did we get the smiley info in a previous call? - if ( !is_array($search) ) - { - $sql = "SELECT code, smile_url - FROM smiles"; - $result = query($sql, "Unable to get list of smilies from the DB"); - - $smilies = $db->sql_fetchrowset($result); - @usort($smilies, 'smiley_sort'); - - $search = array(); - $replace = array(); - for($i = 0; $i < count($smilies); $i++) - { - $search[] = '//i'; - $replace[] = $smilies[$i]['code']; - } - } - - return ( $text != '' ) ? preg_replace($search, $replace, $text) : ''; - -} - -function get_schema() -{ - global $table_prefix; - - $schemafile = file('db/schemas/mysql_schema.sql'); - $tabledata = 0; - - for($i=0; $i < count($schemafile); $i++) - { - $line = $schemafile[$i]; - - if ( preg_match('/^CREATE TABLE (\w+)/i', $line, $matches) ) - { - // Start of a new table definition, set some variables and go to the next line. - $tabledata = 1; - // Replace the 'phpbb_' prefix by the user defined prefix. - $table = str_replace('phpbb_', $table_prefix, $matches[1]); - $table_def[$table] = "CREATE TABLE $table (\n"; - continue; - } - - if ( preg_match('/^\);/', $line) ) - { - // End of the table definition - // After this we will skip everything until the next 'CREATE' line - $tabledata = 0; - $table_def[$table] .= ')'; // We don't need the closing semicolon - } - - if ( $tabledata == 1 ) - { - // We are inside a table definition, parse this line. - // Add the current line to the complete table definition: - $table_def[$table] .= $line; - if ( preg_match('/^\s*(\w+)\s+(\w+)\(([\d,]+)\)(.*)$/', $line, $matches) ) - { - // This is a column definition - $field = $matches[1]; - $type = $matches[2]; - $size = $matches[3]; - - preg_match('/DEFAULT (NULL|\'.*?\')[,\s](.*)$/i', $matches[4], $match); - $default = $match[1]; - - $notnull = ( preg_match('/NOT NULL/i', $matches[4]) ) ? 1 : 0; - $auto_increment = ( preg_match('/auto_increment/i', $matches[4]) ) ? 1 : 0; - - $field_def[$table][$field] = array( - 'type' => $type, - 'size' => $size, - 'default' => $default, - 'notnull' => $notnull, - 'auto_increment' => $auto_increment - ); - } - - if ( preg_match('/\s*PRIMARY\s+KEY\s*\((.*)\).*/', $line, $matches) ) - { - // Primary key - $key_def[$table]['PRIMARY'] = $matches[1]; - } - else if ( preg_match('/\s*KEY\s+(\w+)\s*\((.*)\)/', $line, $matches) ) - { - // Normal key - $key_def[$table][$matches[1]] = $matches[2]; - } - else if ( preg_match('/^\s*(\w+)\s*(.*?),?\s*$/', $line, $matches) ) - { - // Column definition - $create_def[$table][$matches[1]] = $matches[2]; - } - else - { - // It's a bird! It's a plane! It's something we didn't expect ;( - } - } - } - - $schema['field_def'] = $field_def; - $schema['table_def'] = $table_def; - $schema['create_def'] = $create_def; - $schema['key_def'] = $key_def; - - return $schema; -} - -function get_inserts() -{ - global $table_prefix; - - $insertfile = file('db/schemas/mysql_basic.sql'); - - for($i = 0; $i < count($insertfile); $i++) - { - if ( preg_match('/(INSERT INTO (\w+)\s.*);/i', str_replace('phpbb_', $table_prefix, $insertfile[$i]), $matches) ) - { - $returnvalue[$matches[2]][] = $matches[1]; - } - } - - return $returnvalue; -} - -function lock_tables($state, $tables= '') -{ - if ( $state == 1 ) - { - if ( is_array($tables) ) - { - $tables = join(' WRITE, ', $tables); - } - - query("LOCK TABLES $tables WRITE", "Couldn't do: $sql"); - } - else - { - query("UNLOCK TABLES", "Couldn't unlock all tables"); - } -} - -function output_table_content($content) -{ - echo $content . "\n"; - - return; -} - -// -// Nathan's bbcode2 conversion routines -// -function bbdecode($message) -{ - // Undo [code] - $code_start_html = '
Code:
';
-	$code_end_html = '

'; - $message = str_replace($code_start_html, '[code]', $message); - $message = str_replace($code_end_html, '[/code]', $message); - - // Undo [quote] - $quote_start_html = '
Quote:
'; - $quote_end_html = '

'; - $message = str_replace($quote_start_html, '[quote]', $message); - $message = str_replace($quote_end_html, '[/quote]', $message); - - // Undo [b] and [i] - $message = preg_replace("#(.*?)#s", "[b]\\1[/b]", $message); - $message = preg_replace("#(.*?)#s", "[i]\\1[/i]", $message); - - // Undo [url] (long form) - $message = preg_replace("#(.*?)#s", "[url=\\1\\2]\\3[/url]", $message); - - // Undo [url] (short form) - $message = preg_replace("#(.*?)#s", "[url]\\3[/url]", $message); - - // Undo [email] - $message = preg_replace("#(.*?)#s", "[email]\\1[/email]", $message); - - // Undo [img] - $message = preg_replace("##s", "[img]\\1[/img]", $message); - - // Undo lists (unordered/ordered) - - //
  • tags: - $message = str_replace('
  • ', '[*]', $message); - - // [list] tags: - $message = str_replace('', '[/list]', $message); - $message = str_replace('', '[/list]', $message); - - return $message; -} - -// -// Alternative for in_array() which is only available in PHP4 -// -function inarray($needle, $haystack) -{ - for( $i = 0 ; $i < sizeof($haystack) ; $i++ ) - { - if ( $haystack[$i] == $needle ) - { - return true; - } - } - - return false; -} - -function end_step($next) -{ - global $debug; - - print "
    Next step: $next

    \n"; -} -// -// End functions -// ------------- - - -// -// Start at the beginning if the user hasn't specified a specific starting point. -// -$next = ( isset($HTTP_GET_VARS['next']) ) ? $HTTP_GET_VARS['next'] : 'start'; - -// If debug is set we'll do all steps in one go. -$debug = 1; - -// Parse the MySQL schema file into some arrays. -$schema = get_schema(); - -$table_def = $schema['table_def']; -$field_def = $schema['field_def']; -$key_def = $schema['key_def']; -$create_def = $schema['create_def']; - -// -// Get mysql_basic data -// -$inserts = get_inserts(); - -// -// Get smiley data -// -smiley_replace(); - -common_header(); - -if ( !empty($next) ) -{ - switch($next) - { - case 'start': - end_step('initial_drops'); - - case 'initial_drops': - print " * Dropping sessions and themes tables :: "; - flush(); - - query("DROP TABLE sessions", "Couldn't drop table 'sessions'"); - query("DROP TABLE themes", "Couldn't drop table 'themes'"); - - print "OK
    \n"; - - end_step('mod_old_tables'); - - case 'mod_old_tables': - $modtables = array( - "banlist" => "banlist", - "catagories" => "categories", - "config" => "old_config", - "forums" => "forums", - "disallow" => "disallow", - "posts" => "posts", - "posts_text" => "posts_text", - "priv_msgs" => "privmsgs", - "ranks" => "ranks", - "smiles" => "smilies", - "topics" => "topics", - "users" => "users", - "words" => "words" - ); - - while( list($old, $new) = each($modtables) ) - { - $result = query("SHOW INDEX FROM $old", "Couldn't get list of indices for table $old"); - - while( $row = $db->sql_fetchrow($result) ) - { - $index = $row['Key_name']; - if ( $index != 'PRIMARY' ) - { - query("ALTER TABLE $old DROP INDEX $index", "Couldn't DROP INDEX $old.$index"); - } - } - - // Rename table - $new = $table_prefix . $new; - - print " * Renaming '$old' to '$new' :: "; - flush(); - query("ALTER TABLE $old RENAME $new", "Failed to rename $old to $new"); - print "OK
    \n"; - - } - end_step('create_tables'); - - case 'create_tables': - // Create array with tables in 'old' database - $result = query('SHOW TABLES', "Couldn't get list of current tables"); - - while( $table = $db->sql_fetchrow($result) ) - { - $currenttables[] = $table[0]; - } - - // Check what tables we need to CREATE - while( list($table, $definition) = each($table_def) ) - { - if ( !inarray($table, $currenttables) ) - { - print " * Creating $table :: "; - - query($definition, "Couldn't create table $table"); - - print "OK
    \n"; - } - } - - end_step('create_config'); - - case 'create_config': - print " * Inserting new values into new layout config table :: "; - - @reset($inserts); - while( list($table, $inserts_table) = each($inserts) ) - { - if ( $table == CONFIG_TABLE ) - { - $per_pct = ceil( count($inserts_table) / 40 ); - $inc = 0; - - while( list($nr, $insert) = each($inserts_table) ) - { - query($insert, "Couldn't insert value into config table"); - - $inc++; - if ( $inc == $per_pct ) - { - print "."; - flush(); - $inc = 0; - } - } - } - } - - print " OK
    \n"; - - end_step('convert_config'); - - case 'convert_config': - print " * Converting configuration table :: "; - - $sql = "SELECT * - FROM $table_prefix" . "old_config"; - $result = query($sql, "Couldn't get info from old config table"); - - $oldconfig = $db->sql_fetchrow($result); - - // - // We don't need several original config types and two others - // have changed name ... so take account of this. - // - $ignore_configs = array("selected", "admin_passwd", "override_themes", "allow_sig"); - $rename_configs = array( - "email_from" => "board_email", - "email_sig" => "board_email_sig" - ); - - while( list($name, $value) = each($oldconfig) ) - { - if ( is_int($name) ) - { - continue; - } - - if ( !inarray($name, $ignore_configs) ) - { - $name = ( !empty($rename_configs[$name]) ) ? $rename_configs[$name] : $name; - - $sql = "REPLACE INTO " . CONFIG_TABLE . " (config_name, config_value) - VALUES ('$name', '" . stripslashes($value) . "')"; - query($sql, "Couldn't update config table with values from old config table"); - } - } - - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = 'dutch' - WHERE config_name = 'default_lang' && config_value = 'nederlands'"; - query($sql, "Couldn't rename 'nederlands' to 'dutch' in config table"); - - print "OK
    \n"; - end_step('convert_ips'); - - case 'convert_ips': - $names = array( - POSTS_TABLE => array( - 'id' => 'post_id', - 'field' => 'poster_ip' - ), - PRIVMSGS_TABLE => array( - 'id' => 'msg_id', - 'field' => 'poster_ip' - ), - BANLIST_TABLE => array( - 'id' => 'ban_id', - 'field' => 'ban_ip' - ) - ); - - lock_tables(1, array(POSTS_TABLE, PRIVMSGS_TABLE, BANLIST_TABLE)); - - $batchsize = 2000; - while( list($table, $data_array) = each($names) ) - { - $sql = "SELECT MAX(" . $data_array['id'] . ") AS max_id - FROM $table"; - $result = query($sql, "Couldn't obtain ip data from $table (" . $fields . ")"); - - $row = $db->sql_fetchrow($result); - - $maxid = $row['max_id']; - - for($i = 0; $i <= $maxid; $i += $batchsize) - { - $batchstart = $i; - $batchend = $i + $batchsize; - - $field_id = $data_array['id']; - $field = $data_array['field']; - - print " * Converting IP format '" . $field . "' / '$table' ( $batchstart to $batchend ) :: "; - flush(); - - $sql = "SELECT $field_id, $field - FROM $table - WHERE $field_id - BETWEEN $batchstart - AND $batchend"; - $result = query($sql, "Couldn't obtain ip data from $table (" . $fields . ")"); - - $per_pct = ceil( $db->sql_numrows($result) / 40 ); - $inc = 0; - - while( $row = $db->sql_fetchrow($result) ) - { - $sql = "UPDATE $table - SET $field = '" . encode_ip($row[$field]) . "' - WHERE $field_id = " . $row[$field_id]; - query($sql, "Couldn't convert IP format of $field in $table with $field_id of " . $rowset[$field_id]); - - $inc++; - if ( $inc == $per_pct ) - { - print "."; - flush(); - $inc = 0; - } - } - - print " OK
    \n"; - } - } - - lock_tables(0); - end_step('convert_dates'); - - case 'convert_dates': - $names = array( - POSTS_TABLE => array('post_time'), - TOPICS_TABLE => array('topic_time'), - PRIVMSGS_TABLE => array('msg_time') - ); - - lock_tables(1, array(POSTS_TABLE, TOPICS_TABLE, PRIVMSGS_TABLE)); - - while( list($table, $fields) = each($names) ) - { - print " * Converting date format of $fields[$i] in $table :: "; - flush(); - - for($i = 0; $i < count($fields); $i++) - { - $sql = "UPDATE $table - SET " . $fields[$i] . " = UNIX_TIMESTAMP(" . $fields[$i] . ")"; - query($sql, "Couldn't convert date format of $table(" . $fields[$i] . ")"); - } - - print "OK
    \n"; - } - - lock_tables(0); - end_step('fix_addslashes'); - - case 'fix_addslashes': - $slashfields[TOPICS_TABLE] = array('topic_title'); - $slashfields[FORUMS_TABLE] = array('forum_desc', 'forum_name'); - $slashfields[CATEGORIES_TABLE] = array('cat_title'); - $slashfields[WORDS_TABLE] = array('word', 'replacement'); - $slashfields[RANKS_TABLE] = array('rank_title'); - $slashfields[DISALLOW_TABLE] = array('disallow_username'); - - //convert smilies? - $slashes = array( - "\\'" => "'", - "\\\"" => "\"", - "\\\\" => "\\"); - $slashes = array( - "\\'" => "'", - "\\\"" => "\"", - "\\\\" => "\\"); - - lock_tables(1, array(TOPICS_TABLE, FORUMS_TABLE, CATEGORIES_TABLE, WORDS_TABLE, RANKS_TABLE, DISALLOW_TABLE, SMILIES_TABLE)); - - while( list($table, $fields) = each($slashfields) ) - { - print " * Removing slashes from $table table :: "; - flush(); - - while( list($nr, $field) = each($fields) ) - { - @reset($slashes); - while( list($search, $replace) = each($slashes) ) - { - $sql = "UPDATE $table - SET $field = REPLACE($field, '" . addslashes($search) . "', '" . addslashes($replace) . "')"; - query($sql, "Couldn't remove extraneous slashes from the old data."); - } - } - - print "OK
    \n"; - } - - lock_tables(0); - end_step('remove_topics'); - - case 'remove_topics': - print " * Removing posts with no corresponding topics :: "; - flush(); - - $sql = "SELECT p.post_id - FROM " . POSTS_TABLE . " p - LEFT JOIN " . TOPICS_TABLE . " t ON p.topic_id = t.topic_id - WHERE t.topic_id IS NULL"; - $result = query($sql, "Couldn't obtain list of deleted topics"); - - $post_total = $db->sql_numrows($result); - - if ( $post_total ) - { - $post_id_ary = array(); - while( $row = $db->sql_fetchrow($result) ) - { - $post_id_ary[] = $row['post_id']; - } - - $sql = "DELETE FROM " . POSTS_TABLE . " - WHERE post_id IN (" . implode(", ", $post_id_ary) . ")"; - query($sql, "Couldn't update posts to remove deleted user poster_id values"); - - $sql = "DELETE FROM " . POSTS_TEXT_TABLE . " - WHERE post_id IN (" . implode(", ", $post_id_ary) . ")"; - query($sql, "Couldn't update posts to remove deleted user poster_id values"); - } - - echo "OK ( Removed $post_total posts )
    \n"; - end_step('convert_users'); - - case 'convert_users': - // - // Completely remove old soft-deleted users - // - $sql = "DELETE FROM " . USERS_TABLE . " - WHERE user_level = -1"; - query($sql, "Couldn't delete old soft-deleted users"); - - $sql = "SELECT COUNT(*) AS total, MAX(user_id) AS maxid - FROM " . USERS_TABLE; - $result = query($sql, "Couldn't get max post_id."); - - $maxid = $db->sql_fetchrow($result); - - $totalposts = $maxid['total']; - $maxid = $maxid['maxid']; - - $sql = "ALTER TABLE " . USERS_TABLE . " - ADD user_sig_bbcode_uid CHAR(10), - MODIFY user_sig text"; - query($sql, "Couldn't add user_sig_bbcode_uid field to users table"); - - $super_mods = array(); - $first_admin = -2; - - $batchsize = 1000; - for($i = -1; $i <= $maxid; $i += $batchsize) - { - $batchstart = $i; - $batchend = $i + $batchsize; - - print " * Converting Users ( $batchstart to $batchend ) :: "; - flush(); - - $sql = "SELECT * - FROM " . USERS_TABLE . " - WHERE user_id - BETWEEN $batchstart - AND $batchend"; - $result = query($sql, "Couldn't get ". USERS_TABLE .".user_id $batchstart to $batchend"); - - // Array with user fields that we want to check for invalid data (to few characters) - $checklength = array( - 'user_occ', - 'user_website', - 'user_email', - 'user_from', - 'user_intrest', - 'user_aim', - 'user_yim', - 'user_msnm'); - - lock_tables(1, array(USERS_TABLE, GROUPS_TABLE, USER_GROUP_TABLE, POSTS_TABLE)); - - $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_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); - - $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']) ) - { - // We already converted this post to the new style BBcode, skip this post. - continue; - } - - $group_id++; - - // - // Nathan's bbcode2 conversion - // - - // undo 1.2.x encoding.. - $row['user_sig'] = bbdecode(stripslashes($row['user_sig'])); - $row['user_sig'] = undo_make_clickable($row['user_sig']); - $row['user_sig'] = str_replace("
    ", "\n", $row['user_sig']); - - // make a uid - $uid = make_bbcode_uid(); - - // do 2.x first-pass encoding.. - $row['user_sig'] = bbencode_first_pass($row['user_sig'], $uid); - $row['user_sig'] = addslashes($row['user_sig']); - - // Check for invalid info like '-' and '?' for a lot of fields - @reset($checklength); - while($field = each($checklength)) - { - $row[$field[1]] = strlen($row[$field[1]]) < 3 ? '' : $row[$field[1]]; - } - - preg_match('/(.*?) (\d{1,2}), (\d{4})/', $row['user_regdate'], $parts); - $row['user_regdate'] = gmmktime(0, 0, 0, $months[$parts[1]], $parts[2], $parts[3]); - - $website = $row['user_website']; - if ( substr(strtolower($website), 0, 7) != "http://" ) - { - $website = "http://" . $website; - } - if( strtolower($website) == 'http://' ) - { - $website = ''; - } - $row['user_website'] = addslashes($website); - - $row['user_icq'] = (ereg("^[0-9]+$", $row['user_icq'])) ? $row['user_icq'] : ''; - reset($checklength); - - while($field = each($checklength)) - { - if ( strlen($row[$field[1]]) < 3 ) - { - $row[$field[1]] = ''; - } - $row[$field[1]] = addslashes($row[$field[1]]); - } - - // - // Is user a super moderator? - // - if( $row['user_level'] == 3 ) - { - $super_mods[] = $row['user_id']; - } - - $row['user_level'] = ( $row['user_level'] == 4 ) ? ADMIN : USER; - - // - // Used to define a 'practical' group moderator user_id - // for super mods a little latter. - // - if( $first_admin == -2 && $row['user_level'] == ADMIN ) - { - $first_admin = $row['user_id']; - } - - // - // Dutch language files have been renamed from 'nederlands' to 'dutch' - // - if( $row['user_lang'] == 'nederlands' ) - { - $row['user_lang'] = 'dutch'; - } - - $sql = "UPDATE " . USERS_TABLE . " - SET - user_sig = '" . $row['user_sig'] . "', - user_sig_bbcode_uid = '$uid', - user_regdate = '" . $row['user_regdate'] . "', - user_website = '" . $row['user_website'] . "', - user_occ = '" . $row['user_occ'] . "', - user_email = '" . $row['user_email'] . "', - user_from = '" . $row['user_from'] . "', - user_intrest = '" . $row['user_intrest'] . "', - user_aim = '" . $row['user_aim'] . "', - user_yim = '" . $row['user_yim'] . "', - user_msnm = '" . $row['user_msnm'] . "', - user_level = '" . $row['user_level'] . "', - user_desmile = NOT(user_desmile), - user_bbcode = 1, - user_theme = 1 - WHERE user_id = " . $row['user_id']; - query($sql, "Couldn't update ".USERS_TABLE." table with new BBcode and regdate for user_id ".$row['user_id']); - - $inc++; - if ( $inc == $per_pct ) - { - print "."; - flush(); - $inc = 0; - } - } - - print " OK
    \n"; - - lock_tables(0); - } - - // - // Handle super-mods, create hidden group for them - // - // Iterate trough access table - if( count($super_mods) && $first_admin != -2 ) - { - print "\n
    \n * Creating new group for super moderators :: "; - flush(); - - $sql = "INSERT INTO " . GROUPS_TABLE . " (group_type, group_name, group_description, group_moderator, group_single_user) - VALUES (" . GROUP_HIDDEN . ", 'Super Moderators', 'Converted super moderators', $first_admin, 0)"; - $result = query($sql, "Couldn't create group for ".$row['forum_name']); - - $group_id = $db->sql_nextid(); - - if ( $group_id <= 0 ) - { - print "Group creation failed. Aborting creation of groups...
    \n"; - continue 2; - } - - print "OK
    \n"; - - print " * Updating auth_access for super moderator group :: "; - flush(); - - $sql = "SELECT forum_id - FROM " . FORUMS_TABLE; - $result = query($sql, "Couldn't obtain forum_id list"); - - while( $row = $db->sql_fetchrow($result) ) - { - $sql = "INSERT INTO " . AUTH_ACCESS_TABLE . " (group_id, forum_id, auth_mod) - VALUES ($group_id, " . $row['forum_id'] . ", 1)"; - $result_insert = query($sql, "Unable to set group auth access for super mods."); - } - - for($i = 0; $i < count($super_mods); $i++) - { - $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) - VALUES ($group_id, " . $super_mods[$i] . ", 0)"; - query($sql, "Unable to add user_id $user_id to group_id $group_id (super mods)
    \n"); - } - - print "OK
    \n"; - } - - end_step('convert_posts'); - - case 'convert_posts': - print " * Adding enable_sig field to " . POSTS_TABLE . " :: "; - flush(); - $sql = "ALTER TABLE " . POSTS_TABLE . " - ADD enable_sig tinyint(1) DEFAULT '1' NOT NULL"; - $result = query($sql, "Couldn't add enable_sig field to " . POSTS_TABLE . "."); - print "OK
    \n"; - - print " * Adding enable_bbcode field to " . POSTS_TEXT_TABLE . " :: "; - flush(); - $sql = "ALTER TABLE " . POSTS_TEXT_TABLE . " - ADD enable_bbcode tinyint(1) DEFAULT '1' NOT NULL"; - $result = query($sql, "Couldn't add enable_bbcode field to " . POSTS_TABLE . "."); - print "OK
    \n"; - - print " * Adding bbcode_uid field to " . POSTS_TEXT_TABLE . " :: "; - flush(); - $sql = "ALTER TABLE " . POSTS_TEXT_TABLE . " - ADD bbcode_uid char(10) NOT NULL"; - $result = query($sql, "Couldn't add bbcode_uid field to " . POSTS_TABLE . "."); - print "OK
    \n"; - - print " * Adding post_edit_time field to " . POSTS_TABLE . " :: "; - flush(); - $sql = "ALTER TABLE " . POSTS_TABLE . " - ADD post_edit_time int(11)"; - $result = query($sql, "Couldn't add post_edit_time field to " . POSTS_TABLE . "."); - print "OK
    \n"; - - print " * Adding post_edit_count field to " . POSTS_TABLE . " :: "; - flush(); - $sql = "ALTER TABLE " . POSTS_TABLE . " - ADD post_edit_count smallint(5) UNSIGNED DEFAULT '0' NOT NULL"; - $result = query($sql, "Couldn't add post_edit_count field to " . POSTS_TABLE . "."); - print "OK
    \n
    \n"; - - $sql = "SELECT COUNT(*) as total, MAX(post_id) as maxid - FROM " . POSTS_TEXT_TABLE; - $result = query($sql, "Couldn't get max post_id."); - - $maxid = $db->sql_fetchrow($result); - - $totalposts = $maxid['total']; - $maxid = $maxid['maxid']; - - $batchsize = 2000; - for($i = 0; $i <= $maxid; $i += $batchsize) - { - $batchstart = $i + 1; - $batchend = $i + $batchsize; - - print " * Converting BBcode ( $batchstart to $batchend ) :: "; - flush(); - - $sql = "SELECT * - FROM " . POSTS_TEXT_TABLE . " - WHERE post_id - BETWEEN $batchstart - AND $batchend"; - $result = query($sql, "Couldn't get ". POSTS_TEXT_TABLE .".post_id $batchstart to $batchend"); - - lock_tables(1, array(POSTS_TEXT_TABLE, POSTS_TABLE)); - - $per_pct = ceil( $db->sql_numrows($result) / 40 ); - $inc = 0; - - while( $row = $db->sql_fetchrow($result) ) - { - if ( $row['bbcode_uid'] != '' ) - { - // We already converted this post to the new style BBcode, skip this post. - continue; - } - - // - // Nathan's bbcode2 conversion - // - // undo 1.2.x encoding.. - $row['post_text'] = bbdecode(stripslashes($row['post_text'])); - $row['post_text'] = undo_make_clickable($row['post_text']); - $row['post_text'] = str_replace('
    ', "\n", $row['post_text']); - - // make a uid - $uid = make_bbcode_uid(); - - // do 2.x first-pass encoding.. - $row['post_text'] = smiley_replace($row['post_text']); - $row['post_text'] = bbencode_first_pass($row['post_text'], $uid); - $row['post_text'] = addslashes($row['post_text']); - - $edited_sql = ""; - if ( preg_match('/^(.*?)([\n]+\[ This message was .*?)$/s', $row['post_text'], $matches) ) - { - $row['post_text'] = $matches[1]; - $edit_info = $matches[2]; - - $edit_times = count(explode(' message ', $edit_info)) - 1; // Taken from example for substr_count in annotated PHP manual - - if ( preg_match('/^.* by: (.*?) on (....)-(..)-(..) (..):(..) \]<\/font>/s', $edit_info, $matches) ) - { - $edited_user = $matches[1]; - $edited_time = gmmktime($matches[5], $matches[6], 0, $matches[3], $matches[4], $matches[2]); - - // - // This isn't strictly correct since 2.0 won't include and edit - // statement if the edit wasn't by the user who posted ... - // - $edited_sql = ", post_edit_time = $edited_time, post_edit_count = $edit_times"; - } - } - - if ( preg_match("/^(.*?)\n-----------------\n.*$/is", $row['post_text'], $matches) ) - { - $row['post_text'] = $matches[1]; - $enable_sig = 1; - } - else - { - $checksig = preg_replace('/\[addsig\]$/', '', $row['post_text']); - $enable_sig = ( strlen($checksig) == strlen($row['post_text']) ) ? 0 : 1; - } - - $sql = "UPDATE " . POSTS_TEXT_TABLE . " - SET post_text = '$checksig', bbcode_uid = '$uid' - WHERE post_id = " . $row['post_id']; - query($sql, "Couldn't update " . POSTS_TEXT_TABLE . " table with new BBcode for post_id :: " . $row['post_id']); - - $sql = "UPDATE " . POSTS_TABLE . " - SET enable_sig = $enable_sig" . $edited_sql . " - WHERE post_id = " . $row['post_id']; - query($sql, "Couldn't update " . POSTS_TABLE . " table with signature status for post with post_id :: " . $row['post_id']); - - $inc++; - if ( $inc == $per_pct ) - { - print '.'; - flush(); - $inc = 0; - } - } - - print " OK
    \n"; - - lock_tables(0); - } - - print "
    \n * Updating poster_id for deleted users :: "; - flush(); - - $sql = "SELECT DISTINCT p.post_id - FROM " . POSTS_TABLE . " p - LEFT JOIN " . USERS_TABLE . " u ON p.poster_id = u.user_id - WHERE u.user_id IS NULL"; - $result = query($sql, "Couldn't obtain list of deleted users"); - - $users_removed = $db->sql_numrows($result); - - if ( $users_removed ) - { - $post_id_ary = array(); - while( $row = $db->sql_fetchrow($result) ) - { - $post_id_ary[] = $row['post_id']; - } - - $sql = "UPDATE " . POSTS_TABLE . " - SET poster_id = " . ANONYMOUS . ", enable_sig = 0 - WHERE post_id IN (" . implode(", ", $post_id_ary) . ")"; - query($sql, "Couldn't update posts to remove deleted user poster_id values"); - } - - print "OK ( Removed $users_removed non-existent user references )
    \n"; - - end_step('convert_privmsgs'); - - case 'convert_privmsgs': - $sql = "SELECT COUNT(*) as total, max(msg_id) as maxid - FROM " . PRIVMSGS_TABLE; - $result = query($sql, "Couldn't get max privmsgs_id."); - - $maxid = $db->sql_fetchrow($result); - - $totalposts = $maxid['total']; - $maxid = $maxid['maxid']; - - $sql = "ALTER TABLE " . PRIVMSGS_TABLE . " - ADD privmsgs_subject VARCHAR(255), - ADD privmsgs_attach_sig TINYINT(1) DEFAULT 1"; - query($sql, "Couldn't add privmsgs_subject field to " . PRIVMSGS_TABLE . " table"); - - $batchsize = 2000; - for($i = 0; $i <= $maxid; $i += $batchsize) - { - $batchstart = $i + 1; - $batchend = $i + $batchsize; - - print " * Converting Private Message ( $batchstart to $batchend ) :: "; - flush(); - - $sql = "SELECT * - FROM " . PRIVMSGS_TABLE . " - WHERE msg_id - BETWEEN $batchstart - AND $batchend"; - $result = query($sql, "Couldn't get " . POSTS_TEXT_TABLE . " post_id $batchstart to $batchend"); - - lock_tables(1, array(PRIVMSGS_TABLE, PRIVMSGS_TEXT_TABLE)); - - $per_pct = ceil( $db->sql_numrows($result) / 40 ); - $inc = 0; - - while( $row = $db->sql_fetchrow($result) ) - { - if ( $row['msg_text'] == NULL ) - { - // We already converted this post to the new style BBcode, skip this post. - continue; - } - // - // Nathan's bbcode2 conversion - // - // undo 1.2.x encoding.. - $row['msg_text'] = bbdecode(stripslashes($row['msg_text'])); - $row['msg_text'] = undo_make_clickable($row['msg_text']); - $row['msg_text'] = str_replace("
    ", "\n", $row['msg_text']); - - // make a uid - $uid = make_bbcode_uid(); - - // do 2.x first-pass encoding.. - $row['msg_text'] = smiley_replace($row['msg_text']); - $row['msg_text'] = bbencode_first_pass($row['msg_text'], $uid); - - $checksig = preg_replace('/\[addsig\]$/', '', $row['msg_text']); - $enable_sig = (strlen($checksig) == strlen($row['msg_text'])) ? 0 : 1; - - if ( preg_match("/^(.*?)\n-----------------\n.*$/is", $checksig, $matches) ) - { - $checksig = $matches[1]; - $enable_sig = 1; - } - - $row['msg_text'] = $checksig; - - $row['msg_status'] = ($row['msg_status'] == 1) ? PRIVMSGS_READ_MAIL : PRIVMSGS_NEW_MAIL; - - // Subject contains first 60 characters of msg, remove any BBCode tags - $subject = addslashes(strip_tags(substr($row['msg_text'], 0, 60))); - $subject = preg_replace("/\[.*?\:(([a-z0-9]:)?)$uid.*?\]/si", "", $subject); - - $row['msg_text'] = addslashes($row['msg_text']); - - $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) - VALUES ('" . $row['msg_id'] . "', '$uid', '" . $row['msg_text'] . "')"; - query($sql, "Couldn't insert PrivMsg text into " . PRIVMSGS_TEXT_TABLE . " table msg_id " . $row['msg_id']); - - $sql = "UPDATE " . PRIVMSGS_TABLE . " - SET msg_text = NULL, msg_status = " . $row['msg_status'] . ", privmsgs_subject = '$subject', privmsgs_attach_sig = $enable_sig - WHERE msg_id = " . $row['msg_id']; - query($sql, "Couldn't update " . PRIVMSGS_TABLE . " table for msg_id " . $row['post_id']); - - $inc++; - if ( $inc == $per_pct ) - { - print '.'; - flush(); - $inc = 0; - } - } - - print " OK
    \n"; - } - - lock_tables(0); - end_step('convert_moderators'); - - case 'convert_moderators'; - $sql = "SELECT * - FROM forum_mods"; - $result = query($sql, "Couldn't get list with all forum moderators"); - - while( $row = $db->sql_fetchrow($result) ) - { - // Check if this moderator and this forum still exist - $sql = "SELECT user_id - FROM " . USERS_TABLE . ", " . FORUMS_TABLE . " - WHERE user_id = " . $row['user_id'] . " - AND forum_id = " . $row['forum_id']; - $check_data = query($sql, "Couldn't check if user " . $row['user_id'] . " and forum " . $row['forum_id'] . " exist"); - - if ( !($rowtest = $db->sql_fetchrow($check_data)) ) - { - // Either the moderator or the forum have been deleted, this line in forum_mods was redundant, skip it. - continue; - } - - $sql = "SELECT g.group_id - FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug - WHERE g.group_id = ug.group_id - AND ug.user_id = " . $row['user_id'] . " - AND g.group_single_user = 1"; - $insert_group = query($sql, "Couldn't get group number for user " . $row['user_id'] . "."); - - $group_id = $db->sql_fetchrow($insert_group); - $group_id = $group_id['group_id']; - - print " * Adding moderator for forum " . $row['forum_id'] . " :: "; - flush(); - - $sql = "INSERT INTO " . AUTH_ACCESS_TABLE . " (group_id, forum_id, auth_mod) VALUES ($group_id, ".$row['forum_id'].", 1)"; - query($sql, "Couldn't set moderator (user_id = " . $row['user_id'] . ") for forum " . $row['forum_id'] . "."); - - print "OK
    \n"; - } - - print " * Setting correct user_level for moderators ::"; - flush(); - - $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 = query($sql, "Couldn't obtain list of moderators"); - - if ( $row = $db->sql_fetchrow($result) ) - { - $ug_sql = ''; - - do - { - $ug_sql .= ( ( $ug_sql != '' ) ? ', ' : '' ) . $row['user_id']; - } - while ( $row = $db->sql_fetchrow($result) ); - - $sql = "UPDATE " . USERS_TABLE . " - SET user_level = " . MOD . " - WHERE user_id IN ($ug_sql)"; - query($sql, "Couldn't set moderator status for users"); - } - - print "OK
    \n"; - - end_step('convert_privforums'); - - case 'convert_privforums': - $sql = "SELECT fa.*, f.forum_name - FROM forum_access fa - LEFT JOIN " . FORUMS_TABLE . " f ON fa.forum_id = f.forum_id - ORDER BY fa.forum_id, fa.user_id"; - $forum_access = query($sql, "Couldn't get list with special forum access (forum_access)"); - - $forum_id = -1; - while( $row = $db->sql_fetchrow($forum_access) ) - { - // Iterate trough access table - if ( $row['forum_id'] != $forum_id ) - { - // This is a new forum, create new group. - $forum_id = $row['forum_id']; - - print " * Creating new group for forum $forum_id :: "; - flush(); - - $sql = "INSERT INTO " . GROUPS_TABLE . " (group_type, group_name, group_description, group_moderator, group_single_user) - VALUES (" . GROUP_HIDDEN . ", '" . addslashes($row['forum_name']) . " Group', 'Converted Private Forum Group', " . $row['user_id'] . ", 0)"; - $result = query($sql, "Couldn't create group for ".$row['forum_name']); - - $group_id = $db->sql_nextid(); - - if ( $group_id <= 0 ) - { - print "Group creation failed. Aborting creation of groups...
    \n"; - continue 2; - } - - print "OK
    \n"; - - print " * Creating auth_access group for forum $forum_id :: "; - flush(); - - $sql = "INSERT INTO " . AUTH_ACCESS_TABLE . " (group_id, forum_id, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate) - VALUES ($group_id, $forum_id, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1)"; - $result = query($sql, "Unable to set group auth access."); - - if ( $db->sql_affectedrows($result) <= 0 ) - { - print "Group creation failed. Aborting creation of groups...
    \n"; - continue 2; - } - - print "OK
    \n"; - } - - // Add user to the group - $user_id = $row['user_id']; - - $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) - VALUES ($group_id, $user_id, 0)"; - query($sql, "Unable to add user_id $user_id to group_id $group_id
    \n"); - } - - end_step('update_schema'); - - case 'update_schema': - $rename = array( - $table_prefix . "users" => array( - "user_interests" => "user_intrest", - "user_allowsmile" => "user_desmile", - "user_allowhtml" => "user_html", - "user_allowbbcode" => "user_bbcode", - "user_style" => "user_theme" - ), - $table_prefix . "privmsgs" => array( - "privmsgs_id" => "msg_id", - "privmsgs_from_userid" => "from_userid", - "privmsgs_to_userid" => "to_userid", - "privmsgs_date" => "msg_time", - "privmsgs_ip" => "poster_ip", - "privmsgs_type" => "msg_status" - ), - $table_prefix . "smilies" => array( - "smilies_id" => "id" - ) - ); - - $schema = get_schema(); - - $table_def = $schema['table_def']; - $field_def = $schema['field_def']; - - // Loop tables in schema - while (list($table, $table_def) = @each($field_def)) - { - // Loop fields in table - print " * Updating table '$table' :: "; - flush(); - - $sql = "SHOW FIELDS - FROM $table"; - $result = query($sql, "Can't get definition of current $table table"); - - while( $row = $db->sql_fetchrow($result) ) - { - $current_fields[] = $row['Field']; - } - - $alter_sql = "ALTER TABLE $table "; - while (list($field, $definition) = each($table_def)) - { - if ( $field == '' ) - { - // Skip empty fields if any (shouldn't be needed) - continue; - } - - $type = $definition['type']; - $size = $definition['size']; - - $default = isset($definition['default']) ? "DEFAULT " . $definition['default'] : ''; - - $notnull = $definition['notnull'] == 1 ? 'NOT NULL' : ''; - - $auto_increment = $definition['auto_increment'] == 1 ? 'auto_increment' : ''; - - $oldfield = isset($rename[$table][$field]) ? $rename[$table][$field] : $field; - - if ( !inarray($field, $current_fields) && $oldfield == $field ) - { - // If the current is not a key of $current_def and it is not a field that is - // to be renamed then the field doesn't currently exist. - $changes[] = " ADD $field " . $create_def[$table][$field]; - } - else - { - $changes[] = " CHANGE $oldfield $field " . $create_def[$table][$field]; - } - } - - $alter_sql .= join(',', $changes); - unset($changes); - unset($current_fields); - - $sql = "SHOW INDEX - FROM $table"; - $result = query($sql, "Couldn't get list of indices for table $table"); - - unset($indices); - - while( $row = $db->sql_fetchrow($result) ) - { - $indices[] = $row['Key_name']; - } - - while ( list($key_name, $key_field) = each($key_def[$table]) ) - { - if ( !inarray($key_name, $indices) ) - { - $alter_sql .= ($key_name == 'PRIMARY') ? ", ADD PRIMARY KEY ($key_field)" : ", ADD INDEX $key_name ($key_field)"; - } - } - query($alter_sql, "Couldn't alter table $table"); - - print "OK
    \n"; - flush(); - } - - end_step('convert_forums'); - - case 'convert_forums': - $sql = "SELECT * - FROM " . FORUMS_TABLE; - $result = query($sql, "Couldn't get list with all forums"); - - while( $row = $db->sql_fetchrow($result) ) - { - print " * Converting forum '" . $row['forum_name'] . "' :: "; - flush(); - - // forum_access: (only concerns posting) - // 1 = Registered users only - // 2 = Anonymous Posting - // 3 = Moderators/Administrators only - switch( $row['forum_access'] ) - { - case 1: - // Public forum, no anonymous posting - $auth_view = AUTH_ALL; - $auth_read = AUTH_ALL; - $auth_post = AUTH_REG; - $auth_reply = AUTH_REG; - $auth_edit = AUTH_REG; - $auth_delete = AUTH_REG; - $auth_vote = AUTH_REG; - $auth_pollcreate = AUTH_REG; - $auth_sticky = AUTH_MOD; - $auth_announce = AUTH_MOD; - break; - case 2: - $auth_post = AUTH_ALL; - $auth_reply = AUTH_ALL; - $auth_edit = AUTH_REG; - $auth_delete = AUTH_REG; - $auth_vote = AUTH_ALL; - $auth_pollcreate = AUTH_ALL; - $auth_sticky = AUTH_MOD; - $auth_announce = AUTH_MOD; - break; - default: - $auth_post = AUTH_MOD; - $auth_reply = AUTH_MOD; - $auth_edit = AUTH_MOD; - $auth_delete = AUTH_MOD; - $auth_vote = AUTH_MOD; - $auth_pollcreate = AUTH_MOD; - $auth_sticky = AUTH_MOD; - $auth_announce = AUTH_MOD; - break; - } - - // Old auth structure: - // forum_type: (only concerns viewing) - // 0 = Public - // 1 = Private - switch( $row['forum_type'] ) - { - case 0: - $auth_view = AUTH_ALL; - $auth_read = AUTH_ALL; - break; - default: - // - // Make it really private ... - // - $auth_view = AUTH_ACL; - $auth_read = AUTH_ACL; - $auth_post = AUTH_ACL; - $auth_reply = AUTH_ACL; - $auth_edit = AUTH_ACL; - $auth_delete = AUTH_ACL; - $auth_vote = AUTH_ACL; - $auth_pollcreate = AUTH_ACL; - $auth_sticky = AUTH_ACL; - $auth_announce = AUTH_MOD; - break; - } - - $sql = "UPDATE " . FORUMS_TABLE . " SET - auth_view = $auth_view, - auth_read = $auth_read, - auth_post = $auth_post, - auth_reply = $auth_reply, - auth_edit = $auth_edit, - auth_delete = $auth_delete, - auth_vote = $auth_vote, - auth_pollcreate = $auth_pollcreate, - auth_sticky = $auth_sticky, - auth_announce = $auth_announce - WHERE forum_id = ". $row['forum_id']; - query($sql, "Was unable to update forum permissions!"); - - print "OK
    \n"; - } - - end_step('insert_themes'); - - case 'insert_themes': - print " * Inserting new values into themes table :: "; - - @reset($inserts); - while( list($table, $inserts_table) = each($inserts) ) - { - if ( $table == THEMES_TABLE ) - { - $per_pct = ceil( count($inserts_table) / 40 ); - $inc = 0; - - while( list($nr, $insert) = each($inserts_table) ) - { - query($insert, "Couldn't insert value into " . THEMES_TABLE); - - $inc++; - if ( $inc == $per_pct ) - { - print "."; - flush(); - $inc = 0; - } - } - } - } - - print " OK
    \n"; - end_step('update_topics'); - - case 'update_topics': - $sql = "SELECT MAX(topic_id) AS max_topic - FROM " . TOPICS_TABLE; - $result = query($sql, "Couldn't get max topic id"); - - $row = $db->sql_fetchrow($result); - - $maxid = $row['max_topic']; - - lock_tables(1, array(TOPICS_TABLE, POSTS_TABLE)); - - $batchsize = 1000; - for($i = 0; $i <= $maxid; $i += $batchsize) - { - $batchstart = $i + 1; - $batchend = $i + $batchsize; - - print " * Setting topic first post_id ( $batchstart to $batchend ) :: "; - flush(); - - $sql = "SELECT MIN(post_id) AS first_post_id, topic_id - FROM " . POSTS_TABLE . " - WHERE topic_id - BETWEEN $batchstart - AND $batchend - GROUP BY topic_id - ORDER BY topic_id ASC"; - $result = query($sql, "Couldn't get post id data"); - - $per_pct = ceil( $db->sql_numrows($result) / 40 ); - $inc = 0; - - 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']; - query($sql, "Couldn't update topic first post id in topic :: $topic_id"); - - $inc++; - if ( $inc == $per_pct ) - { - print "."; - flush(); - $inc = 0; - } - } - while ( $row = $db->sql_fetchrow($result) ); - } - - print " OK
    \n"; - } - - lock_tables(0); - end_step('final_configuration'); - - case 'final_configuration': - // - // Update forum last post information - // - $sql = "SELECT forum_id, forum_name - FROM " . FORUMS_TABLE; - $f_result = query($sql, "Couldn't obtain forum_ids"); - - while( $forum_row = $db->sql_fetchrow($f_result) ) - { - print " * Updating '" . $forum_row['forum_name'] . "' post info :: "; - flush(); - - $id = $forum_row['forum_id']; - - $sql = "SELECT MIN(p.post_id) AS first_post, MAX(p.post_id) AS last_post - FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t - WHERE p.forum_id = $id - AND p.topic_id = t.topic_id"; - $result = query($sql, "Could not get post ID forum post information :: $id"); - - if ( $row = $db->sql_fetchrow($result) ) - { - $first_post = ( $row['first_post'] ) ? $row['first_post'] : 0; - $last_post = ($row['last_post']) ? $row['last_post'] : 0; - } - else - { - $first_post = 0; - $last_post = 0; - } - - $sql = "SELECT COUNT(post_id) AS total - FROM " . POSTS_TABLE . " - WHERE forum_id = $id"; - $result = query($sql, "Could not get post count forum post information :: $id"); - - if ( $row = $db->sql_fetchrow($result) ) - { - $total_posts = ($row['total']) ? $row['total'] : 0; - } - else - { - $total_posts = 0; - } - - $sql = "SELECT COUNT(topic_id) AS total - FROM " . TOPICS_TABLE . " - WHERE forum_id = $id - AND topic_status <> " . TOPIC_MOVED; - $result = query($sql, "Could not get topic count forum post information :: $id"); - - if ( $row = $db->sql_fetchrow($result) ) - { - $total_topics = ($row['total']) ? $row['total'] : 0; - } - else - { - $total_topics = 0; - } - - $sql = "UPDATE " . FORUMS_TABLE . " - SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics - WHERE forum_id = $id"; - query($sql, "Could not update forum post information :: $id"); - - print "OK
    \n"; - } - - print "
    \n * Update default user and finalise configuration :: "; - flush(); - - // - // Update the default admin user with their information. - // - $sql = "SELECT MIN(user_regdate) AS oldest_time - FROM " . USERS_TABLE . " - WHERE user_regdate > 0 AND user_id > 0"; - $result = query($sql, "Couldn't obtain oldest post time"); - - $row = $db->sql_fetchrow($result); - - $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value) - VALUES ('board_startdate', " . $row['oldest_time'] . ")"; - query($sql, "Couldn't insert board_startdate"); - - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_name . "' - WHERE config_name = 'server_name' - OR config_name = 'cookie_domain'"; - query($sql, "Couldn't insert Board Server domain"); - - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_port . "' - WHERE config_name = 'server_port'"; - query($sql, "Couldn't insert Board server port"); - - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $board_email . "' - WHERE config_name = 'board_email'"; - query($sql, "Couldn't insert Board admin email"); - - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $script_path . "' - WHERE config_name = 'script_path'"; - query($sql, "Couldn't insert Board script path"); - - // - // Change session table to HEAP if MySQL version matches - // - $sql = "SELECT VERSION() AS mysql_version"; - $result = query($sql, "Couldn't obtain MySQL Version"); - - $row = $db->sql_fetchrow($result); - - $version = $row['mysql_version']; - - if ( preg_match("/^(3\.23)|(4\.)/", $version) ) - { - $sql = "ALTER TABLE " . $table_prefix . "sessions - TYPE=HEAP MAX_ROWS=500"; - $db->sql_query($sql); - } - - echo "OK
    \n"; - end_step('drop_fields'); - - case 'drop_fields': - $fields = array( - BANLIST_TABLE => array("ban_start", "ban_end", "ban_time_type"), - FORUMS_TABLE => array("forum_access", "forum_moderator", "forum_type"), - PRIVMSGS_TABLE => array("msg_text"), - RANKS_TABLE => array("rank_max"), - SMILIES_TABLE => array("emotion"), - TOPICS_TABLE => array("topic_notify") - ); - - while( list($table, $field_data) = each($fields) ) - { - for($i = 0; $i < count($field_data); $i++) - { - print " * Drop field '" . $field_data[$i] . "' in '$table' :: "; - flush(); - - $sql = "ALTER TABLE $table - DROP COLUMN " . $field_data[$i]; - query($sql, "Couldn't drop field :: " . $field_data[$i] . " from table :: $table"); - - print "OK
    \n"; - - } - } - - end_step('drop_tables'); - - case 'drop_tables': - $drop_tables = array('access', 'forum_access', 'forum_mods', 'headermetafooter', 'whosonline', $table_prefix . 'old_config'); - - for($i = 0; $i < count($drop_tables); $i++) - { - print " * Dropping table '" . $drop_tables[$i] . "' :: "; - flush(); - - $sql = "DROP TABLE " . $drop_tables[$i]; - query($sql, "Couldn't drop table :: " . $drop_tables[$i]); - - 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"; - } -} - -print "
    If the upgrade completed without error you may click Here to proceed to the index
    "; - -common_footer(); - -?>