diff --git a/phpBB/install.php b/phpBB/install.php index 4a20fa6935..da25f31f89 100644 --- a/phpBB/install.php +++ b/phpBB/install.php @@ -116,6 +116,12 @@ $available_dbms = array( ) ); +// +// Uncomment the following line to completely disable the ftp option... +// + +// define('NO_FTP', true); + /*************************************************************************** * * End Install Customization Section @@ -150,6 +156,9 @@ $admin_pass1 = ( !empty($HTTP_POST_VARS['admin_pass1']) ) ? $HTTP_POST_VARS['adm $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'] : ""; include($phpbb_root_path.'includes/sql_parse.'.$phpEx); include($phpbb_root_path.'includes/constants.'.$phpEx); @@ -198,7 +207,7 @@ if( defined("PHPBB_INSTALLED") ) $template->pparse('body'); exit; } -else if( !empty($HTTP_POST_VARS['send_file']) ) +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"); @@ -212,6 +221,116 @@ else if( !empty($HTTP_POST_VARS['send_file']) ) 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. + // + if ( get_magic_quotes_gpc() ) + { + $HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']); + } + $s_hidden_fields = ''; + $s_hidden_fields .= ''; + $template->assign_block_vars("ftp_file", array()); + $template->assign_block_vars("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... + // + if ( get_magic_quotes_gpc() ) + { + $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("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("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 == "" ) { // @@ -450,16 +569,29 @@ else // to get around that... // $s_hidden_fields = ''; - $s_hidden_fields .= ''; + if( extension_loaded('ftp') && !defined('NO_FTP') ) + { + $template->assign_block_vars('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()); + // $template->assign_block_vars("common_install", array()); $s_hidden_fields .= ''; - $lang['Unwritable_config'] = $lang['ODBC_Instructs'] . '
' . $lang['Unwritable_config']; + $lang['Unwriteable_config'] = $lang['ODBC_Instructs'] . '

' . $lang['Unwriteable_config'] . '

'; } $template->assign_vars(array( @@ -508,4 +640,4 @@ else } } -?> \ No newline at end of file +?> diff --git a/phpBB/language/lang_english/lang_main.php b/phpBB/language/lang_english/lang_main.php index 667b2439be..e37de79e4a 100644 --- a/phpBB/language/lang_english/lang_main.php +++ b/phpBB/language/lang_english/lang_main.php @@ -1079,7 +1079,16 @@ $lang['ODBC_Instructs'] = "Someone please write some odbc instructions in the \$ $lang['Table_Prefix'] = "Prefix for tables in database"; $lang['Unwriteable_config'] = "Your config file is unwriteable at present. A copy of the config file will be downloaded to your when you click the button below. You should upload this file to the same directory as phpBB 2. Once this is done you should log in using the administrator name and password you provided on the previous form and visit the admin control centre (a link will appear at the bottom of each screen once logged in) to check the general configuration. Thank you for choosing phpBB 2."; $lang['Download_config'] = "Download Config"; - +$lang['ftp_choose'] = "Choose Download Method"; +$lang['Attempt_ftp'] = "Attempt to ftp config file into place:"; +$lang['Send_file'] = "Just send the file to me and I'll ftp it manually:"; +$lang['ftp_option'] = "
Since the ftp extensions are loaded in php you may will also be given the option of first trying to automatically ftp the config file into place."; +$lang['ftp_instructs'] = "You have chosen to attempt to ftp the file to your phpBB installation automagically. Please enter the information below to facilitate this process. Note that the FTP Path should be the exact path via ftp to your phpBB2 installation as if you were ftping to it."; +$lang['ftp_path'] = "FTP Path to phpBB2:"; +$lang['ftp_username'] = "Your FTP Username:"; +$lang['ftp_password'] = "Your FTP Password:"; +$lang['Transfer_config'] = "Start Transfer"; +$lang['ftp_info'] = "Enter Your FTP Information"; // // Ranks admin @@ -1118,4 +1127,4 @@ $lang['no_disallowed'] = "No Disallowed Usernames"; // That's all Folks! // ------------------------------------------------- -?> \ No newline at end of file +?> diff --git a/phpBB/templates/subSilver/install.tpl b/phpBB/templates/subSilver/install.tpl index 372837f8fd..e12a90c6b2 100644 --- a/phpBB/templates/subSilver/install.tpl +++ b/phpBB/templates/subSilver/install.tpl @@ -177,9 +177,39 @@ a.copyright:hover { color: #000000; text-decoration: underline;} {L_ERROR_TITLE} - {L_ERROR} + {L_ERROR} + + + {L_FTP_INFO} + + + {L_FTP_PATH} + + + + {L_FTP_USER} + + + + {L_FTP_PASS} + + + + + + {L_CHOOSE_FTP} + + + {L_ATTEMPT_FTP} + + + + {L_SEND_FILE} + + + {S_HIDDEN_FIELDS}