Index: wp-admin/setup-config.php
===================================================================
--- wp-admin/setup-config.php	(revision 6499)
+++ wp-admin/setup-config.php	(working copy)
@@ -111,6 +111,7 @@
 
 	case 1:
 		display_header();
+		require_once('../wp-includes/pluggable.php'); // to generate secret key
 	?>
 </p>
 <form method="post" action="setup-config.php?step=2">
@@ -142,6 +143,40 @@
 			<td>If you want to run multiple WordPress installations in a single database, change this.</td>
 		</tr>
 	</table>
+<h2>Advanced</h2>
+<p>You will not likely need to edit these settings; the defaults should be fine. But you may modify them if you wish.</p>
+	<table>
+		<tr>
+			<th scope="row">Secret Key</th>
+			<td><input name="secret" type="text" size="25" value="<?php echo md5(wp_generate_password()); ?>" autocomplete="off" /></td>
+			<td>The secret key used to encrypt login cookies. It should be long and random, and you don't need to remember it.</td>
+		</tr>
+		<tr>
+			<th scope="row">Home URL</th>
+			<td><input name="wphome" type="text" size="25" value="" /></td>
+			<td>WP_HOME value</td>
+		</tr>
+		<tr>
+			<th scope="row">Site URL</th>
+			<td><input name="wpsiteurl" type="text" size="25" value="" /></td>
+			<td>WP_SITEURL value</td>
+		</tr>
+		<tr>
+			<th scope="row">Database Character Set</th>
+			<td><input name="dbcharset" type="text" size="25" value="utf8" /></td>
+			<td>Character set used in database.</td>
+		</tr>
+		<tr>
+			<th scope="row">Database Collation</th>
+			<td><input name="dbcollate" type="text" value="" size="25" /></td>
+			<td>Collation used in database.</td>
+		</tr>
+		<tr>
+			<th scope="row">Language</th>
+			<td><input name="lang" type="text" value="" size="2" /></td>
+			<td>Two-letter language code to localize install. A corresponding MO file for the chosen language must be installed to wp-content/languages.</td>
+		</tr>
+	</table>
 	<h2 class="step">
 	<input name="submit" type="submit" value="Submit" />
 	</h2>
@@ -156,6 +191,13 @@
 	$dbhost  = trim($_POST['dbhost']);
 	$prefix  = trim($_POST['prefix']);
 	if (empty($prefix)) $prefix = 'wp_';
+	
+	$secret     = trim($_POST['secret']);
+	$wphome     = trim($_POST['wphome']);
+	$wpsiteurl  = trim($_POST['wpsiteurl']);
+	$dbcharset  = trim($_POST['dbcharset']);
+	$dbcollate  = trim($_POST['dbcollate']);
+	$lang  = trim($_POST['lang']);
 
 	// Test the db connection.
 	define('DB_NAME', $dbname);
@@ -168,6 +210,10 @@
 	if ( !empty($wpdb->error) )
 		wp_die($wpdb->error->get_error_message());
 
+	// Fail here if language specified but language file does not exist
+	if ( strlen($lang) > 0 && !file_exists('../wp-content/languages/$lang.mo'))
+	wp_die("Sorry, you specified language <strong><code>$lang</code></strong> but this file doesn't exist. Please re-upload language file <strong><code>wp-content/languages/$lang.mo</code></strong> and try again.");
+
 	$handle = fopen('../wp-config.php', 'w');
 
 	foreach ($configFile as $line_num => $line) {
@@ -187,6 +233,24 @@
 			case '$table_prefix  =':
 				fwrite($handle, str_replace('wp_', $prefix, $line));
 				break;
+			case "define('SECRET_K":
+				fwrite($handle, str_replace("'put your unique phrase here'", "'$secret'", $line));
+				break;
+			case "define('DB_CHARS":
+				fwrite($handle, str_replace("utf8", $dbcharset, $line));
+				break;
+			case "define('DB_COLLA":
+				fwrite($handle, str_replace("''", "'$dbcollate'", $line));
+				break;
+			case "define('WPLANG',":
+				fwrite($handle, str_replace("''", "'$lang'", $line));
+				break;
+			case "/* That's all, s":
+				if ( strlen($wphome) > 0 ) { fwrite($handle, "// The Home URL\ndefine('WP_HOME', '$wphome');\n"); }
+				if ( strlen($wpsiteurl) > 0 ) { fwrite($handle, "// The WordPress Site URL\ndefine('WP_SITEURL', '$wpsiteurl');\n"); }
+				if ( strlen($wphome) > 0 || strlen($wpsiteurl) > 0 ) { fwrite($handle, "\n"); }
+				fwrite($handle, $line);
+				break;
 			default:
 				fwrite($handle, $line);
 		}
