mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-12 11:44:08 +02:00
Updated for improved use with ODBC setups + introduced a re-install feature ... the schema updates _only_ remove foreign key and drop table clauses
git-svn-id: file:///svn/phpbb/trunk@1491 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -22,6 +22,10 @@
|
||||
$phpbb_root_path='./';
|
||||
include($phpbb_root_path.'extension.inc');
|
||||
|
||||
$userdata = array();
|
||||
$lang = array();
|
||||
$reinstall = false;
|
||||
|
||||
if( !get_magic_quotes_gpc() )
|
||||
{
|
||||
if( is_array($HTTP_GET_VARS) )
|
||||
@@ -96,30 +100,89 @@ if( !get_magic_quotes_gpc() )
|
||||
|
||||
$default_language = 'english';
|
||||
$default_template = 'subSilver';
|
||||
|
||||
|
||||
$available_dbms = array(
|
||||
array(
|
||||
"LABEL" => "MySQL",
|
||||
"VALUE" => "mysql"
|
||||
"mysql" => array(
|
||||
"LABEL" => "MySQL 3.x",
|
||||
"SCHEMA" => "mysql",
|
||||
"DELIM" => ";",
|
||||
"DELIM_BASIC" => ";",
|
||||
"COMMENTS" => "remove_remarks"
|
||||
),
|
||||
array(
|
||||
"mysql4" => array(
|
||||
"LABEL" => "MySQL 4.x",
|
||||
"SCHEMA" => "mysql",
|
||||
"DELIM" => ";",
|
||||
"DELIM_BASIC" => ";",
|
||||
"COMMENTS" => "remove_remarks"
|
||||
),
|
||||
"postgres" => array(
|
||||
"LABEL" => "PostgreSQL 7.x",
|
||||
"VALUE" => "postgres"
|
||||
"SCHEMA" => "postgres",
|
||||
"DELIM" => ";",
|
||||
"DELIM_BASIC" => ";",
|
||||
"COMMENTS" => "remove_comments"
|
||||
),
|
||||
array(
|
||||
"mssql" => array(
|
||||
"LABEL" => "MS SQL Server 7/2000",
|
||||
"VALUE" => "mssql"
|
||||
"SCHEMA" => "mssql",
|
||||
"DELIM" => "GO",
|
||||
"DELIM_BASIC" => ";",
|
||||
"COMMENTS" => "remove_comments"
|
||||
),
|
||||
array(
|
||||
"msaccess" => array(
|
||||
"LABEL" => "MS Access [ ODBC ]",
|
||||
"VALUE" => "msaccess"
|
||||
"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);
|
||||
|
||||
/***************************************************************************
|
||||
@@ -128,12 +191,12 @@ $available_dbms = array(
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
$userdata = array();
|
||||
$lang = array();
|
||||
|
||||
//
|
||||
// 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'];
|
||||
@@ -143,6 +206,7 @@ else
|
||||
$install_step = "";
|
||||
}
|
||||
|
||||
$upgrade = ( !empty($HTTP_POST_VARS['upgrade']) ) ? $HTTP_POST_VARS['upgrade']: '';
|
||||
$dbms = isset($HTTP_POST_VARS['dbms']) ? $HTTP_POST_VARS['dbms'] : "";
|
||||
$language = ( !empty($HTTP_POST_VARS['language']) ) ? $HTTP_POST_VARS['language'] : $default_language;
|
||||
|
||||
@@ -151,71 +215,125 @@ $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_username = ( !empty($HTTP_POST_VARS['admin_user']) ) ? $HTTP_POST_VARS['admin_user'] : "";
|
||||
$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'] : "";
|
||||
|
||||
$table_prefix = ( !empty($HTTP_POST_VARS['prefix']) ) ? $HTTP_POST_VARS['prefix'] : "";
|
||||
$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'] : "";
|
||||
$upgrade = ( !empty($HTTP_POST_VARS['upgrade']) ) ? $HTTP_POST_VARS['upgrade']: '';
|
||||
|
||||
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);
|
||||
|
||||
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'])
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Start main program ...
|
||||
//
|
||||
if( @file_exists('config.'.$phpEx) )
|
||||
{
|
||||
include('config.'.$phpEx);
|
||||
}
|
||||
|
||||
if( defined("PHPBB_INSTALLED") )
|
||||
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);
|
||||
|
||||
//
|
||||
// Sorry this has already been installed can't do anything more with it
|
||||
// Import language file, setup template ...
|
||||
//
|
||||
$template->assign_block_vars("switch_error_install", array());
|
||||
$template->assign_vars(array(
|
||||
"L_ERROR_TITLE" => $lang['Installer_Error'],
|
||||
"L_ERROR" => $lang['Previous_Install'])
|
||||
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);
|
||||
|
||||
if( $upgrade == 1 )
|
||||
{
|
||||
require('upgrade.'.$phpEx);
|
||||
$install_step = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Load default template for install
|
||||
//
|
||||
$template->set_filenames(array(
|
||||
"body" => "install.tpl")
|
||||
);
|
||||
|
||||
$template->pparse('body');
|
||||
exit;
|
||||
$template->assign_vars(array(
|
||||
"L_INSTALLATION" => $lang['Welcome_install'])
|
||||
);
|
||||
}
|
||||
else if( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 1 )
|
||||
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'])
|
||||
);
|
||||
|
||||
$reinstall = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
header("HTTP/1.0 302 Redirect");
|
||||
header("Location: " . append_sid("index.$phpEx", true));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
if( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 1 && !defined("PHPBB_INSTALLED") )
|
||||
{
|
||||
header("Content-Type: text/x-delimtext; name=\"config.php\"");
|
||||
header("Content-disposition: attachment; filename=config.php");
|
||||
@@ -231,7 +349,7 @@ else if( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] ==
|
||||
|
||||
exit;
|
||||
}
|
||||
else if( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 2 )
|
||||
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.
|
||||
@@ -239,93 +357,101 @@ else if( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] ==
|
||||
|
||||
$HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']);
|
||||
|
||||
$s_hidden_fields = '<input type="hidden" name="config_data" value="'.htmlspecialchars($HTTP_POST_VARS['config_data']).'" />';
|
||||
$s_hidden_fields = '<input type="hidden" name="config_data" value="' . htmlspecialchars($HTTP_POST_VARS['config_data']) . '" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="ftp_file" value="1" />';
|
||||
|
||||
$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")
|
||||
"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']) )
|
||||
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) )
|
||||
$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 = '<input type="hidden" name="config_data" value="' . htmlspecialchars($config_data) . '" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="send_file" value="1" />';
|
||||
|
||||
$template->assign_block_vars("switch_common_install", array());
|
||||
if ( $dbms == 'odbc' )
|
||||
{
|
||||
//
|
||||
// Output the instruction_textions for the odbc...
|
||||
//
|
||||
$s_hidden_fields .= '<input type="hidden" name="install_step" value="3" />';
|
||||
$lang['NoFTP_config'] = $lang['ODBC_Instructs'] . '<br />' . $lang['NoFTP_config'];
|
||||
}
|
||||
|
||||
$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();
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Write out a temp file...
|
||||
//
|
||||
$tmpfname = tempnam('/tmp', 'cfg');
|
||||
$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.php', $tmpfname, FTP_ASCII);
|
||||
|
||||
@ftp_quit($conn_id);
|
||||
|
||||
unlink($tmpfname);
|
||||
|
||||
//
|
||||
// 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 = '<input type="hidden" name="username" value="' . $admin_name . '" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="password" value="' . $admin_pass1 . '" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="redirect" value="admin/" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="submit" value="Login" />';
|
||||
if ( $dbms == 'odbc' )
|
||||
{
|
||||
//
|
||||
// Output the instruction_textions for the odbc...
|
||||
//
|
||||
$lang['Inst_Step_2'] = $lang['ODBC_Instructs'] . '<br />' . $lang['Inst_Step_2'];
|
||||
}
|
||||
$s_hidden_fields .= '<input type="hidden" name="submit" value="' . $lang['Login'] . '" />';
|
||||
|
||||
$template->assign_block_vars("switch_common_install", array());
|
||||
|
||||
$template->assign_vars(array(
|
||||
"L_INSTRUCTION_TEXT" => $lang['Inst_Step_2'],
|
||||
"L_SUBMIT" => $lang['Finish_Install'],
|
||||
@@ -335,10 +461,11 @@ else if( !empty($HTTP_POST_VARS['ftp_file']) )
|
||||
);
|
||||
|
||||
$template->pparse('body');
|
||||
|
||||
exit();
|
||||
}
|
||||
}
|
||||
else if( empty($install_step) || $admin_pass1 != $admin_pass2 || $dbhost == "" )
|
||||
else if( ( empty($install_step) || $admin_pass1 != $admin_pass2 || $dbhost == "" ) && !defined("PHPBB_INSTALLED") )
|
||||
{
|
||||
//
|
||||
// Ok we haven't installed before so lets work our way through the various
|
||||
@@ -360,25 +487,17 @@ else if( empty($install_step) || $admin_pass1 != $admin_pass2 || $dbhost == "" )
|
||||
$lang_options = language_select($language, 'language');
|
||||
|
||||
$dbms_options = '<select name="dbms">';
|
||||
for($i = 0; $i < count($available_dbms); $i++)
|
||||
while( list($dbms_name, $details) = @each($available_dbms) )
|
||||
{
|
||||
$selected = ( $available_dbms[$i]['VALUE'] == $dbms ) ? "selected=\"selected\"" : "";
|
||||
$dbms_options .= '<option value="' . $available_dbms[$i]['VALUE'] . '">' . $available_dbms[$i]['LABEL'] . '</option>';
|
||||
$selected = ( $dbms_name == $dbms ) ? "selected=\"selected\"" : "";
|
||||
$dbms_options .= '<option value="' . $dbms_name . '">' . $details['LABEL'] . '</option>';
|
||||
}
|
||||
$dbms_options .= '</select>';
|
||||
|
||||
$upgrade_option = '<select name="upgrade"';
|
||||
$upgrade_option .= 'onchange="if(this.options[this.selectedIndex].value==1)
|
||||
{
|
||||
document.install_form.dbms.selectedIndex=0;
|
||||
document.install_form.dbms.disabled=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.install_form.dbms.disabled=0;
|
||||
}">';
|
||||
$upgrade_option .= '<option value="0">'.$lang['Install'].'</option>';
|
||||
$upgrade_option .= '<option value="1">'.$lang['Upgrade'].'</option></select>';
|
||||
$upgrade_option .= 'onchange="if( this.options[this.selectedIndex].value == 1 ) { document.install_form.dbms.selectedIndex=0; document.install_form.dbms.disabled=1; } else { document.install_form.dbms.disabled=0; }">';
|
||||
$upgrade_option .= '<option value="0">' . $lang['Install'] . '</option>';
|
||||
$upgrade_option .= '<option value="1">' . $lang['Upgrade'] . '</option></select>';
|
||||
|
||||
$s_hidden_fields = '<input type="hidden" name="install_step" value="1" />';
|
||||
|
||||
@@ -401,10 +520,9 @@ else if( empty($install_step) || $admin_pass1 != $admin_pass2 || $dbhost == "" )
|
||||
"L_ADMIN_USERNAME" => $lang['Administrator'] . ' ' . $lang['Username'],
|
||||
"L_ADMIN_PASSWORD" => $lang['Administrator'] . ' ' . $lang['Password'],
|
||||
"L_ADMIN_CONFIRM_PASSWORD" => $lang['Confirm'] . ' ' . $lang['Password'],
|
||||
|
||||
"L_SUBMIT" => $lang['Start_Install'],
|
||||
|
||||
"DB_PREFIX" => ( $table_prefix != "" ) ? $table_prefix : "phpbb_",
|
||||
"DB_PREFIX" => ( !empty($table_prefix) ) ? $table_prefix : "phpbb_",
|
||||
"DB_HOST" => ( $dbhost != "" ) ? $dbhost : "",
|
||||
"DB_USER" => ( $dbuser != "" ) ? $dbuser : "",
|
||||
"DB_PASSWD" => ( $dbpasswd != "" ) ? $dbpasswd : "",
|
||||
@@ -417,92 +535,132 @@ else if( empty($install_step) || $admin_pass1 != $admin_pass2 || $dbhost == "" )
|
||||
"S_FORM_ACTION" => "install.$phpEx")
|
||||
);
|
||||
|
||||
// "L_DOMAIN_NAME" => $lang['Domain_name'],
|
||||
// "L_DOMAIN_NAME_EXPLAIN" => $lang['Domain_name_explain'],
|
||||
|
||||
$template->pparse("body");
|
||||
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// If the dbms is set to be odbc then we need to skip most of the
|
||||
// steps and go straight to writing the config file. We'll spit
|
||||
// out some additional instruction_textions later on what to do after installation
|
||||
// for the odbc DBMS.
|
||||
// Go ahead and create the DB, then populate it
|
||||
//
|
||||
print "dbms = - $dbms -<br>";
|
||||
if( isset($dbms) )
|
||||
// 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'] . '<br /><br />' . $error)
|
||||
);
|
||||
|
||||
$template->pparse('body');
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$admin_name = $userdata['username'];
|
||||
$admin_pass1 = $userdata['user_password'];
|
||||
$language = $userdata['user_lang'];
|
||||
}
|
||||
else if( isset($dbms) )
|
||||
{
|
||||
include($phpbb_root_path.'includes/db.'.$phpEx);
|
||||
}
|
||||
|
||||
$dbms_schema = 'db/schemas/' . $dbms.'_schema.sql';
|
||||
$dbms_basic = 'db/schemas/' . $dbms . '_basic.sql';
|
||||
$dbms_schema = 'db/schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql';
|
||||
$dbms_basic = 'db/schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_basic.sql';
|
||||
|
||||
$remove_remarks = ( $dbms == 'mysql' ) ? 'remove_remarks' : 'remove_comments';
|
||||
$delimiter = ( $dbms == 'mssql' ) ? 'GO' : ';';
|
||||
$remove_remarks = $available_dbms[$dbms]['COMMENTS'];;
|
||||
$delimiter = $available_dbms[$dbms]['DELIM'];
|
||||
$delimiter_basic = $available_dbms[$dbms]['DELIM_BASIC'];
|
||||
|
||||
if( $install_step == 1 )
|
||||
if( $install_step == 1 || $reinstall )
|
||||
{
|
||||
if( $dbms != 'msaccess' && $upgrade != 1 )
|
||||
if( $upgrade != 1 )
|
||||
{
|
||||
//
|
||||
// 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 = $remove_remarks($sql_query);
|
||||
$sql_query = split_sql_file($sql_query, $delimiter);
|
||||
$sql_count = count($sql_query);
|
||||
$sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query);
|
||||
|
||||
for($i = 0; $i < $sql_count; $i++)
|
||||
if( $dbms != 'msaccess' )
|
||||
{
|
||||
$result = $db->sql_query($sql_query[$i]);
|
||||
if( !$result )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
|
||||
$template->assign_block_vars("switch_error_install", array());
|
||||
//
|
||||
// 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);
|
||||
|
||||
$template->assign_vars(array(
|
||||
"L_ERROR_TITLE" => $lang['Installer_Error'],
|
||||
"L_ERROR" => $lang['Install_db_error'] . '<br>' . $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 = $remove_remarks($sql_query);
|
||||
$sql_query = split_sql_file($sql_query, $delimiter);
|
||||
$sql_count = count($sql_query);
|
||||
$sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query);
|
||||
|
||||
for($i = 0; $i < $sql_count; $i++)
|
||||
{
|
||||
$result = $db->sql_query($sql_query[$i]);
|
||||
if( !$result )
|
||||
|
||||
for($i = 0; $i < $sql_count; $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'] . "<br />" . $error["message"])
|
||||
);
|
||||
$template->pparse('body');
|
||||
exit;
|
||||
$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'] . '<br />' . $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);
|
||||
|
||||
$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'] . "<br />" . $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
|
||||
@@ -511,6 +669,7 @@ else
|
||||
// to set up their forum defaults.
|
||||
//
|
||||
$error = "";
|
||||
|
||||
//
|
||||
// Update the default admin user with their information.
|
||||
//
|
||||
@@ -519,7 +678,7 @@ else
|
||||
$result = $db->sql_query($sql);
|
||||
if( !$result )
|
||||
{
|
||||
$error .= "Could not insert board_startdate :: " . $sql . "<br /><br />";
|
||||
$error .= "Could not insert board_startdate :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value)
|
||||
@@ -527,16 +686,18 @@ else
|
||||
$result = $db->sql_query($sql);
|
||||
if( !$result )
|
||||
{
|
||||
$error .= "Could not insert default_lang :: " . $sql . "<br /><br />";
|
||||
$error .= "Could not insert default_lang :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
|
||||
}
|
||||
|
||||
$admin_pass_md5 = ( $confirm && $userdata['user_level'] == ADMIN ) ? $admin_pass1 : md5($admin_pass1);
|
||||
|
||||
$sql = "UPDATE " . $table_prefix . "users
|
||||
SET username = '$admin_name', user_password='" . md5($admin_pass1) . "', user_lang = '" . $language . "'
|
||||
SET username = '$admin_name', user_password='$admin_pass_md5', user_lang = '" . $language . "'
|
||||
WHERE username = 'Admin'";
|
||||
$result = $db->sql_query($sql);
|
||||
if( !$result )
|
||||
{
|
||||
$error .= "Could not update admin info :: " . $sql . "<br /><br />";
|
||||
$error .= "Could not update admin info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
|
||||
}
|
||||
|
||||
$sql = "UPDATE " . $table_prefix . "users
|
||||
@@ -544,104 +705,133 @@ else
|
||||
$result = $db->sql_query($sql);
|
||||
if( !$result )
|
||||
{
|
||||
$error .= "Could not update user_regdate :: " . $sql . "<br /><br />";
|
||||
$error .= "Could not update user_regdate :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
|
||||
}
|
||||
|
||||
//
|
||||
// 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";
|
||||
if( !$result = $db->sql_query($sql))
|
||||
{
|
||||
$error .= "Could not alter session table to HEAP type :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $error != "" )
|
||||
{
|
||||
$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'] . '<br /><br />' . $error)
|
||||
);
|
||||
|
||||
$template->pparse('body');
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$template->assign_block_vars("switch_common_install", array());
|
||||
//
|
||||
// Write out the config file.
|
||||
//
|
||||
$config_data = '<?php'."\n\n";
|
||||
$config_data .= "//\n// phpBB 2.x auto-generated config file\n// Do not change anything in this file!\n//\n\n";
|
||||
$config_data .= '$dbms = "' . $dbms . '";' . "\n\n";
|
||||
$config_data .= '$dbhost = "' . $dbhost . '";' . "\n";
|
||||
$config_data .= '$dbname = "' . $dbname . '";' . "\n";
|
||||
$config_data .= '$dbuser = "' . $dbuser . '";' . "\n";
|
||||
$config_data .= '$dbpasswd = "' . $dbpasswd . '";' . "\n\n";
|
||||
$config_data .= '$table_prefix = "' . $table_prefix . '";' . "\n\n";
|
||||
$config_data .= 'define(\'PHPBB_INSTALLED\', true);'."\n\n";
|
||||
$config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused!
|
||||
|
||||
@umask(0111);
|
||||
$no_open = FALSE;
|
||||
$fp = @fopen('config.php', 'w');
|
||||
if( !$fp )
|
||||
if( !$reinstall )
|
||||
{
|
||||
$template->assign_block_vars("switch_common_install", array());
|
||||
|
||||
//
|
||||
// Unable to open the file writeable do something here as an attempt
|
||||
// to get around that...
|
||||
// Write out the config file.
|
||||
//
|
||||
$s_hidden_fields = '<input type="hidden" name="config_data" value="' . htmlspecialchars($config_data) . '" />';
|
||||
if( extension_loaded('ftp') && !defined('NO_FTP') )
|
||||
$config_data = '<?php'."\n\n";
|
||||
$config_data .= "//\n// phpBB 2.x auto-generated config file\n// Do not change anything in this file!\n//\n\n";
|
||||
$config_data .= '$dbms = "' . $dbms . '";' . "\n\n";
|
||||
$config_data .= '$dbhost = "' . $dbhost . '";' . "\n";
|
||||
$config_data .= '$dbname = "' . $dbname . '";' . "\n";
|
||||
$config_data .= '$dbuser = "' . $dbuser . '";' . "\n";
|
||||
$config_data .= '$dbpasswd = "' . $dbpasswd . '";' . "\n\n";
|
||||
$config_data .= '$table_prefix = "' . $table_prefix . '";' . "\n\n";
|
||||
$config_data .= 'define(\'PHPBB_INSTALLED\', true);'."\n\n";
|
||||
$config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused!
|
||||
|
||||
@umask(0111);
|
||||
$no_open = FALSE;
|
||||
|
||||
$fp = @fopen('config.php', 'w');
|
||||
if( !$fp )
|
||||
{
|
||||
$template->assign_block_vars('switch_ftp_option', array());
|
||||
$lang['Unwriteable_config'] .= '<p>'.$lang['ftp_option'].'</p>';
|
||||
//
|
||||
// Unable to open the file writeable do something here as an attempt
|
||||
// to get around that...
|
||||
//
|
||||
$s_hidden_fields = '<input type="hidden" name="config_data" value="' . htmlspecialchars($config_data) . '" />';
|
||||
|
||||
if( extension_loaded('ftp') && !defined('NO_FTP') )
|
||||
{
|
||||
$template->assign_block_vars('switch_ftp_option', array());
|
||||
|
||||
$lang['Unwriteable_config'] .= '<p>' . $lang['ftp_option'] . '</p>';
|
||||
|
||||
$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 .= '<input type="hidden" name="send_file" value="1" />';
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
"L_CHOOSE_FTP" => $lang['ftp_choose'],
|
||||
"L_ATTEMPT_FTP" => $lang['Attempt_ftp'],
|
||||
"L_SEND_FILE" => $lang['Send_file'])
|
||||
"L_INSTRUCTION_TEXT" => $lang['Unwriteable_config'],
|
||||
"L_SUBMIT" => $lang['Download_config'],
|
||||
|
||||
"S_HIDDEN_FIELDS" => $s_hidden_fields,
|
||||
"S_FORM_ACTION" => "install.$phpEx")
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$s_hidden_fields .= '<input type="hidden" name="send_file" value="1" />';
|
||||
}
|
||||
if ( $dbms == 'odbc' )
|
||||
{
|
||||
//
|
||||
// Output the instruction_textions for the odbc...
|
||||
//
|
||||
// $template->assign_block_vars("common_install", array());
|
||||
|
||||
$s_hidden_fields .= '<input type="hidden" name="install_step" value="3" />';
|
||||
$lang['Unwriteable_config'] = $lang['ODBC_Instructs'] . '<p>' . $lang['Unwriteable_config'] . '</p>';
|
||||
|
||||
$template->pparse('body');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
"L_INSTRUCTION_TEXT" => $lang['Unwriteable_config'],
|
||||
"L_SUBMIT" => $lang['Download_config'],
|
||||
$result = @fputs($fp, $config_data, strlen($config_data));
|
||||
|
||||
"S_HIDDEN_FIELDS" => $s_hidden_fields,
|
||||
"S_FORM_ACTION" => "install.$phpEx")
|
||||
);
|
||||
|
||||
$template->pparse('body');
|
||||
exit();
|
||||
@fclose($fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_block_vars("switch_common_install", array());
|
||||
}
|
||||
|
||||
$result = @fputs($fp, $config_data, strlen($config_data));
|
||||
fclose($fp);
|
||||
|
||||
//
|
||||
// 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 = '<input type="hidden" name="username" value="' . $admin_name . '" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="password" value="' . $admin_pass1 . '" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="redirect" value="admin/" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="submit" value="Login" />';
|
||||
if ( $dbms == 'odbc' )
|
||||
if( !$reinstall )
|
||||
{
|
||||
//
|
||||
// Output the instruction_textions for the odbc...
|
||||
//
|
||||
$lang['Inst_Step_2'] = $lang['ODBC_Instructs'] . '<br />' . $lang['Inst_Step_2'];
|
||||
$s_hidden_fields = '<input type="hidden" name="username" value="' . $admin_name . '" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="password" value="' . $admin_pass1 . '" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="redirect" value="admin/" />';
|
||||
$s_hidden_fields .= '<input type="hidden" name="login" value="true" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$s_hidden_fields = "";
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
@@ -649,11 +839,13 @@ else
|
||||
"L_SUBMIT" => $lang['Finish_Install'],
|
||||
|
||||
"S_HIDDEN_FIELDS" => $s_hidden_fields,
|
||||
"S_FORM_ACTION" => "login.$phpEx")
|
||||
"S_FORM_ACTION" => ( $reinstall ) ? append_sid("login.$phpEx") : "login.$phpEx")
|
||||
);
|
||||
|
||||
$template->pparse('body');
|
||||
exit();
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
?>
|
Reference in New Issue
Block a user