From 183718f25f049b34a1c339dc63f01c7629c2d313 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Tue, 16 Jul 2002 17:30:36 +0000 Subject: [PATCH] This will do a clean install ... it will fail if config isn't writeable or any other error occurs ... git-svn-id: file:///svn/phpbb/trunk@2698 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/install.php | 401 +++++++++---------------- phpBB/install/schemas/mysql_basic.sql | 53 ++-- phpBB/install/schemas/mysql_schema.sql | 8 +- 3 files changed, 184 insertions(+), 278 deletions(-) diff --git a/phpBB/install/install.php b/phpBB/install/install.php index 7179f38c84..77ff02f128 100644 --- a/phpBB/install/install.php +++ b/phpBB/install/install.php @@ -4,7 +4,7 @@ * ------------------- * begin : Tuesday, Sept 11, 2001 * copyright : (C) 2001 The phpBB Group - * email : supportphpbb.com + * email : support@phpbb.com * * $Id$ * @@ -94,40 +94,6 @@ $available_dbms = array( ) ); -// -// 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... // @@ -139,13 +105,21 @@ $sql_array['drop_schema'][] = "DROP TABLE phpbb_words"; * ***************************************************************************/ +// +// Try opening config file +// +if ( @file_exists('../config.'.$phpEx) ) +{ + include('../config.'.$phpEx); +} + // // 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']) ) +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']; } @@ -181,15 +155,7 @@ $board_email = ( !empty($HTTP_POST_VARS['board_email']) ) ? $HTTP_POST_VARS['boa $script_path = ( !empty($HTTP_POST_VARS['script_path']) ) ? $HTTP_POST_VARS['script_path'] : ''; // -// -// -if ( @file_exists('../config.'.$phpEx) ) -{ - include('../config.'.$phpEx); -} - -// -// +// Do we install/upgrade/update or quit back to index? // if ( !defined('PHPBB_INSTALLED') ) { @@ -202,14 +168,9 @@ if ( !defined('PHPBB_INSTALLED') ) include($phpbb_root_path . 'language/lang_' . $language . '/lang_main.'.$phpEx); include($phpbb_root_path . 'language/lang_' . $language . '/lang_admin.'.$phpEx); - // - // Ok for the time being I'm commenting this out whilst I'm working on - // better integration of the install with upgrade as per Bart's request - // JLH - // if ( $upgrade == 1 ) { - // require('upgrade.'.$phpEx); + require('upgrade.'.$phpEx); $install_step = 1; } } @@ -220,13 +181,10 @@ else } // -// +// What shall we do? // 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 @@ -234,9 +192,11 @@ if ( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 1 // $HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']); + header("Content-Type: text/x-delimtext; name=\"config.$phpEx\""); + header("Content-disposition: attachment; filename=config.$phpEx"); echo $HTTP_POST_VARS['config_data']; - exit; + } else if ( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 2 && !defined("PHPBB_INSTALLED") ) { @@ -249,7 +209,7 @@ else if ( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] = $s_hidden_fields = ''; $s_hidden_fields .= ''; - if( $upgrade == 1 ) + if ( $upgrade == 1 ) { $s_hidden_fields .= ''; } @@ -291,7 +251,10 @@ else if( !empty($HTTP_POST_VARS['ftp_file']) && !defined("PHPBB_INSTALLED") ) // $s_hidden_fields = ''; $s_hidden_fields .= ''; - if( $upgrade == 1 ) + + page_header($lang['NoFTP_config'], "install.$phpEx"); + + if ( $upgrade == 1 ) { $s_hidden_fields .= ''; $s_hidden_fields .= ''; @@ -307,23 +270,15 @@ else if( !empty($HTTP_POST_VARS['ftp_file']) && !defined("PHPBB_INSTALLED") ) $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'); + page_footer($lang['Download_config'], $s_hidden_fields); exit; } @@ -347,42 +302,34 @@ else if( !empty($HTTP_POST_VARS['ftp_file']) && !defined("PHPBB_INSTALLED") ) // @ftp_chdir($conn_id, $ftp_dir); - $res = ftp_put($conn_id, 'config.'.$phpEx, $tmpfname, FTP_ASCII); + $res = ftp_put($conn_id, '../config.'.$phpEx, $tmpfname, FTP_ASCII); @ftp_quit($conn_id); unlink($tmpfname); + if( $upgrade == 1 ) { require('upgrade.'.$phpEx); exit; } + // - // Ok we are basically done with the install process let's go on - // and let the user configure their board now. - // - // We are going to do this by calling the admin_board.php from the - // normal board admin section. + // Ok we are basically done with the install process let's go on and let the user + // configure their board now. We are going to do this by calling the admin_board.php + // from the normal board admin section. // $s_hidden_fields = ''; $s_hidden_fields .= ''; $s_hidden_fields .= ''; $s_hidden_fields .= ''; - $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'); + page_header($lang['Inst_Step_2'], "../login.$phpEx"); + page_footer($lang['Finish_Install'], $s_hidden_fields); exit(); } + } else if ( ( empty($install_step) || $admin_pass1 != $admin_pass2 || empty($admin_pass1) || $dbhost == '' ) && !defined("PHPBB_INSTALLED") ) { @@ -446,81 +393,81 @@ else if ( ( empty($install_step) || $admin_pass1 != $admin_pass2 || empty($admin $s_hidden_fields = ''; - page_header($instruction_text); + page_header($instruction_text, "install.$phpEx"); ?> - - - - - : - - - - : - - - - : - - - - - - - : - - - - : - - - - : - - - - : - - - - : - - - - - - - : - - - - : - - - - : - - - - : - - - - : - - - - : - - - - : - - + + + + + : + + + + : + + + + : + + + + + + + : + + + + : + + + + : + + + + : + + + + : + + + + + + + : + + + + : + + + + : + + + + : + + + + : + + + + : + + + + : + + 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 ) + switch ( $dbms ) { case 'msaccess': case 'mssql-odbc': @@ -585,32 +503,37 @@ else $check_other = 'pgsql'; break; } + if ( !extension_loaded( $check_exts ) && !extension_loaded( $check_other ) ) { - $template->assign_block_vars("switch_error_install", array()); +/* $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'); + $template->pparse('body'); */ + exit; } - include($phpbb_root_path.'includes/db.'.$phpEx); + + include($phpbb_root_path . 'db/' . $dbms . '.' . $phpEx); + + $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); } - $dbms_schema = 'db/schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql'; - $dbms_basic = 'db/schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_basic.sql'; + $dbms_schema = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql'; + $dbms_basic = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_basic.sql'; $remove_remarks = $available_dbms[$dbms]['COMMENTS'];; $delimiter = $available_dbms[$dbms]['DELIM']; $delimiter_basic = $available_dbms[$dbms]['DELIM_BASIC']; - if( $install_step == 1 || $reinstall ) + if ( $install_step == 1 || $reinstall ) { - if( $upgrade != 1 ) + if ( $upgrade != 1 ) { - if( $dbms != 'msaccess' ) + if ( $dbms != 'msaccess' ) { // // Ok we have the db info go ahead and read in the relevant schema @@ -619,7 +542,7 @@ else // 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 = preg_replace('/phpbb_/is', $table_prefix, $sql_query); $sql_query = $remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, $delimiter); @@ -628,22 +551,7 @@ else 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['message']) - ); - - $template->pparse('body'); - - exit; - } + $db->sql_query($sql_query[$i]); } // @@ -659,22 +567,7 @@ else 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["message"]) - ); - - $template->pparse('body'); - - exit; - } + $db->sql_query($sql_query[$i]); } } @@ -685,7 +578,8 @@ else // this we are going to pass them over to the admin_forum.php script // to set up their forum defaults. // - $error = ""; + $admin_pass_md5 = ( $confirm && $userdata['user_level'] == ADMIN ) ? $admin_pass1 : md5($admin_pass1); + $error = ''; // // Update the default admin user with their information. @@ -728,8 +622,6 @@ else WHERE config_name = 'newest_username'"; $db->sql_query($sql); - $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'"; @@ -739,11 +631,10 @@ else SET user_regdate = " . time(); $db->sql_query($sql); - // // Change session table to HEAP if MySQL version matches // - if( preg_match("/^mysql/", $dbms) ) + if ( preg_match("/^mysql/", $dbms) ) { $sql = "SELECT VERSION() AS mysql_version"; if($result = $db->sql_query($sql)) @@ -760,7 +651,7 @@ else } } - if( $error != "" ) +/* if ( $error != '' ) { $template->assign_block_vars("switch_error_install", array()); @@ -772,12 +663,12 @@ else $template->pparse('body'); exit; - } + }*/ } - if( !$reinstall && !$upgrade_now ) + if ( !$reinstall && !$upgrade_now ) { - $template->assign_block_vars("switch_common_install", array()); +// $template->assign_block_vars("switch_common_install", array()); // // Write out the config file. @@ -796,8 +687,7 @@ else @umask(0111); $no_open = FALSE; - $fp = @fopen('config.'.$phpEx, 'w'); - if( !$fp ) + if ( !($fp = @fopen('../config.'.$phpEx, 'w')) ) { // // Unable to open the file writeable do something here as an attempt @@ -805,7 +695,7 @@ else // $s_hidden_fields = ''; - if( extension_loaded('ftp') && !defined('NO_FTP') ) + if ( extension_loaded('ftp') && !defined('NO_FTP') ) { $template->assign_block_vars('switch_ftp_option', array()); @@ -821,7 +711,8 @@ else { $s_hidden_fields .= ''; } - if( $upgrade == 1 ) + + if ( $upgrade == 1 ) { $s_hidden_fields .= ''; $s_hidden_fields .= ''; @@ -865,7 +756,7 @@ else } else { - $template->assign_block_vars("switch_common_install", array()); +// $template->assign_block_vars("switch_common_install", array()); } // @@ -884,7 +775,7 @@ else // We are going to do this by calling the admin_board.php from the // normal board admin section. // - if( !$reinstall ) + if ( !$reinstall ) { $s_hidden_fields = ''; $s_hidden_fields .= ''; @@ -893,18 +784,11 @@ else } else { - $s_hidden_fields = ""; + $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'); + page_header($lang['Inst_Step_2'], "../login.$phpEx"); + page_footer($lang['Finish_Install'], $s_hidden_fields); exit; } @@ -931,7 +815,7 @@ function slash_input_data(&$data) // // // -function page_header($l_instructions) +function page_header($l_instructions, $s_action) { global $phpEx, $lang; @@ -959,15 +843,20 @@ td.cat { background-image: url('../admin/images/cellpic1.gif') } -

+


-
+
+ +
Group -INSERT INTO phpbb_user_group (group_id, user_id, user_pending) VALUES (1, 1, 0); -INSERT INTO phpbb_user_group (group_id, user_id, user_pending) VALUES (2, 1, 0); +INSERT INTO phpbb_user_group (group_id, user_id, user_pending) VALUES (1, 2, 0); +INSERT INTO phpbb_user_group (group_id, user_id, user_pending) VALUES (2, 2, 0); + + +# -- User auth +INSERT INTO phpbb_auth_users (user_id, forum_id, auth_option_id, auth_allow_deny) SELECT -1, 1, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_type LIKE 'forum' AND auth_option IN ('list', 'read', 'post', 'reply'); + +# -- Group auth +INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_allow_deny) SELECT 2, 0, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_type IN ('admin'); +INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_allow_deny) SELECT 1, 1, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_type IN ('forum', 'mod'); + +# -- Prefetch auth +INSERT INTO phpbb_auth_prefetch (user_id, forum_id, auth_option_id, auth_allow_deny) SELECT -1, 1, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_type LIKE 'forum' AND auth_option IN ('list', 'read', 'post', 'reply'); +INSERT INTO phpbb_auth_prefetch (user_id, forum_id, auth_option_id, auth_allow_deny) SELECT 2, 0, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_type IN ('admin'); +INSERT INTO phpbb_auth_prefetch (user_id, forum_id, auth_option_id, auth_allow_deny) SELECT 2, 1, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_type IN ('forum', 'mod'); # -- Demo Topic -INSERT INTO phpbb_topics (topic_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, forum_id, topic_status, topic_type, topic_vote, topic_first_post_id, topic_last_post_id) VALUES (1, 'Welcome to phpBB 2', 2, '972086460', 0, 0, 1, 0, 0, 0, 1, 1); +INSERT INTO phpbb_topics (topic_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, forum_id, topic_status, topic_type, topic_first_post_id, topic_last_post_id) VALUES (1, 'Welcome to phpBB 2', 2, '972086460', 0, 0, 1, 0, 0, 1, 1); # -- Demo Post diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index 04c28e0da4..5276a06e67 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -48,10 +48,10 @@ CREATE TABLE phpbb_auth_options ( # Table structure for table `phpbb_auth_prefetch` # CREATE TABLE phpbb_auth_prefetch ( - user_id mediumint(8) unsigned NOT NULL default '0', + user_id mediumint(8) NOT NULL default '0', forum_id mediumint(8) unsigned NOT NULL default '0', auth_option_id smallint(5) unsigned NOT NULL default '0', - auth_allow_deny tinyint(4) NOT NULL default '1') + auth_allow_deny tinyint(4) NOT NULL default '1' ); @@ -60,7 +60,7 @@ CREATE TABLE phpbb_auth_prefetch ( # Table structure for table `phpbb_auth_users` # CREATE TABLE phpbb_auth_users ( - user_id mediumint(8) unsigned NOT NULL default '0', + user_id mediumint(8) NOT NULL default '0', forum_id mediumint(8) unsigned NOT NULL default '0', auth_option_id smallint(5) unsigned NOT NULL default '0', auth_allow_deny tinyint(4) NOT NULL default '1' @@ -134,6 +134,8 @@ CREATE TABLE phpbb_disallow ( # CREATE TABLE phpbb_forums ( forum_id smallint(5) UNSIGNED NOT NULL, + cat_id smallint(5) UNSIGNED NOT NULL, + parent_id smallint(5) UNSIGNED NOT NULL, forum_order smallint(5) UNSIGNED DEFAULT '1' NOT NULL,