"MySQL", "VALUE" => "mysql" ), array( "LABEL" => "PostgreSQL 7.x", "VALUE" => "postgres" ), array( "LABEL" => "MS SQL Server 7/2000", "VALUE" => "mssql" ), array( "LABEL" => "MS Access [ ODBC ]", "VALUE" => "msaccess" ) ); // // Uncomment the following line to completely disable the ftp option... // // define('NO_FTP', true); /*************************************************************************** * * End Install Customization Section * ***************************************************************************/ $userdata = array(); $lang = array(); // // Obtain various vars // 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 = ""; } $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'] : ""; $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") ) { // // Sorry this has already been installed can't do anything more with it // $template->assign_block_vars("switch_error_install", array()); $template->assign_vars(array( "L_ERROR_TITLE" => $lang['Installer_Error'], "L_ERROR" => $lang['Previous_Install']) ); $template->pparse('body'); exit; } else if( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 1 ) { header("Content-Type: text/x-delimtext; name=\"config.php\""); header("Content-disposition: attachment; filename=config.php"); // // 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 ) { // // 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 .= ''; $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']) ) { // // 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 .= ''; $template->assign_block_vars("switch_common_install", array()); if ( $dbms == 'odbc' ) { // // Output the instruction_textions for the odbc... // $s_hidden_fields .= ''; $lang['NoFTP_config'] = $lang['ODBC_Instructs'] . '
' . $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(); } 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.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 = ''; $s_hidden_fields .= ''; $s_hidden_fields .= ''; $s_hidden_fields .= ''; if ( $dbms == 'odbc' ) { // // Output the instruction_textions for the odbc... // $lang['Inst_Step_2'] = $lang['ODBC_Instructs'] . '
' . $lang['Inst_Step_2']; } $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 || $dbhost == "" ) { // // 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. // $instruction_text = $lang['Inst_Step_0']; if( $HTTP_POST_VARS['admin_pass1'] != $HTTP_POST_VARS['admin_pass2'] ) { $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['Database'] . ' ' . $lang['Username'], "L_DB_PASSWORD" => $lang['Database'] . ' ' . $lang['Password'], "L_DB_PREFIX" => $lang['Table_Prefix'], "L_UPGRADE" => $lang['Install_Method'], "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_HOST" => ( $dbhost != "" ) ? $dbhost : "", "DB_USER" => ( $dbuser != "" ) ? $dbuser : "", "DB_PASSWD" => ( $dbpasswd != "" ) ? $dbpasswd : "", "ADMIN_USERNAME" => ( $admin_username != "" ) ? $admin_username : "", "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") ); // "L_DOMAIN_NAME" => $lang['Domain_name'], // "L_DOMAIN_NAME_EXPLAIN" => $lang['Domain_name_explain'], $template->pparse("body"); 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. // if( isset($dbms) ) { include($phpbb_root_path.'includes/db.'.$phpEx); } $dbms_schema = 'db/schemas/' . $dbms.'_schema.sql'; $dbms_basic = 'db/schemas/' . $dbms . '_basic.sql'; $remove_remarks = ( $dbms == 'mysql' ) ? 'remove_remarks' : 'remove_comments'; $delimiter = ( $dbms == 'mssql' ) ? 'GO' : ';'; if( $install_step == 1 ) { if( $dbms != 'msaccess' && $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++) { $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; } } // // 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 ) { $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 . "

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

"; } $sql = "UPDATE " . $table_prefix . "users SET username = '$admin_name', user_password='" . md5($admin_pass1) . "', user_lang = '" . $language . "' WHERE username = 'Admin'"; $result = $db->sql_query($sql); if( !$result ) { $error .= "Could not update admin info :: " . $sql . "

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

"; } 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'] . '

' . $error) ); $template->pparse('body'); exit; } } $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.php', '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 ( $dbms == 'odbc' ) { // // Output the instruction_textions for the odbc... // // $template->assign_block_vars("common_install", array()); $s_hidden_fields .= ''; $lang['Unwriteable_config'] = $lang['ODBC_Instructs'] . '

' . $lang['Unwriteable_config'] . '

'; } $template->assign_vars(array( "L_INSTRUCTION_TEXT" => $lang['Unwriteable_config'], "L_SUBMIT" => $lang['Download_config'], "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_FORM_ACTION" => "install.$phpEx") ); $template->pparse('body'); exit(); } $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 = ''; $s_hidden_fields .= ''; $s_hidden_fields .= ''; $s_hidden_fields .= ''; if ( $dbms == 'odbc' ) { // // Output the instruction_textions for the odbc... // $lang['Inst_Step_2'] = $lang['ODBC_Instructs'] . '
' . $lang['Inst_Step_2']; } $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(); } } ?>