web/wp-admin/setup-config.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    83  * @ignore
    83  * @ignore
    84  * @since 2.3.0
    84  * @since 2.3.0
    85  * @package WordPress
    85  * @package WordPress
    86  * @subpackage Installer_WP_Config
    86  * @subpackage Installer_WP_Config
    87  */
    87  */
    88 function display_header() {
    88 function setup_config_display_header() {
    89 	global $wp_version;
    89 	global $wp_version;
    90 
    90 
    91 	header( 'Content-Type: text/html; charset=utf-8' );
    91 	header( 'Content-Type: text/html; charset=utf-8' );
    92 ?>
    92 ?>
    93 <!DOCTYPE html>
    93 <!DOCTYPE html>
    94 <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
    94 <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
    95 <head>
    95 <head>
    96 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    96 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    97 <title><?php _e( 'WordPress &rsaquo; Setup Configuration File' ); ?></title>
    97 <title><?php _e( 'WordPress &rsaquo; Setup Configuration File' ); ?></title>
    98 <link rel="stylesheet" href="css/install.css?ver=<?php echo preg_replace( '/[^0-9a-z\.-]/i', '', $wp_version ); ?>" type="text/css" />
    98 <link rel="stylesheet" href="css/install.css?ver=<?php echo preg_replace( '/[^0-9a-z\.-]/i', '', $wp_version ); ?>" type="text/css" />
       
    99 <link rel="stylesheet" href="../wp-includes/css/buttons.css?ver=<?php echo preg_replace( '/[^0-9a-z\.-]/i', '', $wp_version ); ?>" type="text/css" />
    99 
   100 
   100 </head>
   101 </head>
   101 <body<?php if ( is_rtl() ) echo ' class="rtl"'; ?>>
   102 <body class="wp-core-ui<?php if ( is_rtl() ) echo ' rtl'; ?>">
   102 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png?ver=20120216" /></h1>
   103 <h1 id="logo"><a href="<?php esc_attr_e( 'http://wordpress.org/' ); ?>"><?php _e( 'WordPress' ); ?></a></h1>
   103 <?php
   104 <?php
   104 }//end function display_header();
   105 } // end function setup_config_display_header();
   105 
   106 
   106 switch($step) {
   107 switch($step) {
   107 	case 0:
   108 	case 0:
   108 		display_header();
   109 		setup_config_display_header();
   109 ?>
   110 ?>
   110 
   111 
   111 <p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
   112 <p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
   112 <ol>
   113 <ol>
   113 	<li><?php _e( 'Database name' ); ?></li>
   114 	<li><?php _e( 'Database name' ); ?></li>
   114 	<li><?php _e( 'Database username' ); ?></li>
   115 	<li><?php _e( 'Database username' ); ?></li>
   115 	<li><?php _e( 'Database password' ); ?></li>
   116 	<li><?php _e( 'Database password' ); ?></li>
   116 	<li><?php _e( 'Database host' ); ?></li>
   117 	<li><?php _e( 'Database host' ); ?></li>
   117 	<li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
   118 	<li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
   118 </ol>
   119 </ol>
   119 <p><strong><?php _e( "If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
   120 <p><strong><?php _e( "If for any reason this automatic file creation doesn&#8217;t work, don&#8217;t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
   120 <p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;" ); ?></p>
   121 <p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;" ); ?></p>
   121 
   122 
   122 <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
   123 <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button button-large"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
   123 <?php
   124 <?php
   124 	break;
   125 	break;
   125 
   126 
   126 	case 1:
   127 	case 1:
   127 		display_header();
   128 		setup_config_display_header();
   128 	?>
   129 	?>
   129 <form method="post" action="setup-config.php?step=2">
   130 <form method="post" action="setup-config.php?step=2">
   130 	<p><?php _e( "Below you should enter your database connection details. If you're not sure about these, contact your host." ); ?></p>
   131 	<p><?php _e( "Below you should enter your database connection details. If you&#8217;re not sure about these, contact your host." ); ?></p>
   131 	<table class="form-table">
   132 	<table class="form-table">
   132 		<tr>
   133 		<tr>
   133 			<th scope="row"><label for="dbname"><?php _e( 'Database Name' ); ?></label></th>
   134 			<th scope="row"><label for="dbname"><?php _e( 'Database Name' ); ?></label></th>
   134 			<td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td>
   135 			<td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td>
   135 			<td><?php _e( 'The name of the database you want to run WP in.' ); ?></td>
   136 			<td><?php _e( 'The name of the database you want to run WP in.' ); ?></td>
   154 			<td><input name="prefix" id="prefix" type="text" value="wp_" size="25" /></td>
   155 			<td><input name="prefix" id="prefix" type="text" value="wp_" size="25" /></td>
   155 			<td><?php _e( 'If you want to run multiple WordPress installations in a single database, change this.' ); ?></td>
   156 			<td><?php _e( 'If you want to run multiple WordPress installations in a single database, change this.' ); ?></td>
   156 		</tr>
   157 		</tr>
   157 	</table>
   158 	</table>
   158 	<?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?>
   159 	<?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?>
   159 	<p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button" /></p>
   160 	<p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p>
   160 </form>
   161 </form>
   161 <?php
   162 <?php
   162 	break;
   163 	break;
   163 
   164 
   164 	case 2:
   165 	case 2:
   165 	foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
   166 	foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
   166 		$$key = trim( stripslashes( $_POST[ $key ] ) );
   167 		$$key = trim( stripslashes( $_POST[ $key ] ) );
   167 
   168 
   168 	$tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">' . __( 'Try Again' ) . '</a>';
   169 	$tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
   169 
   170 
   170 	if ( empty( $prefix ) )
   171 	if ( empty( $prefix ) )
   171 		wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
   172 		wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
   172 
   173 
   173 	// Validate $prefix: it can only contain letters, numbers and underscores.
   174 	// Validate $prefix: it can only contain letters, numbers and underscores.
   252 		}
   253 		}
   253 	}
   254 	}
   254 	unset( $line );
   255 	unset( $line );
   255 
   256 
   256 	if ( ! is_writable(ABSPATH) ) :
   257 	if ( ! is_writable(ABSPATH) ) :
   257 		display_header();
   258 		setup_config_display_header();
   258 ?>
   259 ?>
   259 <p><?php _e( "Sorry, but I can't write the <code>wp-config.php</code> file." ); ?></p>
   260 <p><?php _e( "Sorry, but I can&#8217;t write the <code>wp-config.php</code> file." ); ?></p>
   260 <p><?php _e( 'You can create the <code>wp-config.php</code> manually and paste the following text into it.' ); ?></p>
   261 <p><?php _e( 'You can create the <code>wp-config.php</code> manually and paste the following text into it.' ); ?></p>
   261 <textarea cols="98" rows="15" class="code"><?php
   262 <textarea id="wp-config" cols="98" rows="15" class="code" readonly="readonly"><?php
   262 		foreach( $config_file as $line ) {
   263 		foreach( $config_file as $line ) {
   263 			echo htmlentities($line, ENT_COMPAT, 'UTF-8');
   264 			echo htmlentities($line, ENT_COMPAT, 'UTF-8');
   264 		}
   265 		}
   265 ?></textarea>
   266 ?></textarea>
   266 <p><?php _e( 'After you\'ve done that, click "Run the install."' ); ?></p>
   267 <p><?php _e( 'After you&#8217;ve done that, click &#8220;Run the install.&#8221;' ); ?></p>
   267 <p class="step"><a href="install.php" class="button"><?php _e( 'Run the install' ); ?></a></p>
   268 <p class="step"><a href="install.php" class="button button-large"><?php _e( 'Run the install' ); ?></a></p>
       
   269 <script>
       
   270 (function(){
       
   271 var el=document.getElementById('wp-config');
       
   272 el.focus();
       
   273 el.select();
       
   274 })();
       
   275 </script>
   268 <?php
   276 <?php
   269 	else :
   277 	else :
   270 		$handle = fopen(ABSPATH . 'wp-config.php', 'w');
   278 		$handle = fopen(ABSPATH . 'wp-config.php', 'w');
   271 		foreach( $config_file as $line ) {
   279 		foreach( $config_file as $line ) {
   272 			fwrite($handle, $line);
   280 			fwrite($handle, $line);
   273 		}
   281 		}
   274 		fclose($handle);
   282 		fclose($handle);
   275 		chmod(ABSPATH . 'wp-config.php', 0666);
   283 		chmod(ABSPATH . 'wp-config.php', 0666);
   276 		display_header();
   284 		setup_config_display_header();
   277 ?>
   285 ?>
   278 <p><?php _e( "All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;" ); ?></p>
   286 <p><?php _e( "All right sparky! You&#8217;ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;" ); ?></p>
   279 
   287 
   280 <p class="step"><a href="install.php" class="button"><?php _e( 'Run the install' ); ?></a></p>
   288 <p class="step"><a href="install.php" class="button button-large"><?php _e( 'Run the install' ); ?></a></p>
   281 <?php
   289 <?php
   282 	endif;
   290 	endif;
   283 	break;
   291 	break;
   284 }
   292 }
   285 ?>
   293 ?>