-
+ 18C303BAA0E677B7A3663A4310092C33960049486846CAE28B70517166D985AC0BF80DF8C4E51254265D9CAF93AFB7B3CDCFA4E6D678BF3BA98BDCD05EFE20F1
mp-wp/wp-admin/setup-config.php
(0 . 0)(1 . 194)
57086 <?php
57087 /**
57088 * Retrieves and creates the wp-config.php file.
57089 *
57090 * The permissions for the base directory must allow for writing files in order
57091 * for the wp-config.php to be created using this page.
57092 *
57093 * @package WordPress
57094 * @subpackage Administration
57095 */
57096
57097 /**
57098 * We are installing.
57099 *
57100 * @package WordPress
57101 */
57102 define('WP_INSTALLING', true);
57103
57104 /**#@+
57105 * These three defines are required to allow us to use require_wp_db() to load
57106 * the database class while being wp-content/db.php aware.
57107 * @ignore
57108 */
57109 define('ABSPATH', dirname(dirname(__FILE__)).'/');
57110 define('WPINC', 'wp-includes');
57111 define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
57112 /**#@-*/
57113
57114 require_once('../wp-includes/compat.php');
57115 require_once('../wp-includes/functions.php');
57116 require_once('../wp-includes/classes.php');
57117
57118 if (!file_exists('../wp-config-sample.php'))
57119 wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
57120
57121 $configFile = file('../wp-config-sample.php');
57122
57123 if ( !is_writable('../'))
57124 wp_die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually.");
57125
57126 // Check if wp-config.php has been created
57127 if (file_exists('../wp-config.php'))
57128 wp_die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
57129
57130 // Check if wp-config.php exists above the root directory
57131 if (file_exists('../../wp-config.php') && ! file_exists('../../wp-load.php'))
57132 wp_die("<p>The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
57133
57134 if (isset($_GET['step']))
57135 $step = $_GET['step'];
57136 else
57137 $step = 0;
57138
57139 /**
57140 * Display setup wp-config.php file header.
57141 *
57142 * @ignore
57143 * @since 2.3.0
57144 * @package WordPress
57145 * @subpackage Installer_WP_Config
57146 */
57147 function display_header() {
57148 header( 'Content-Type: text/html; charset=utf-8' );
57149 ?>
57150 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
57151 <html xmlns="http://www.w3.org/1999/xhtml">
57152 <head>
57153 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
57154 <title>WordPress › Setup Configuration File</title>
57155 <link rel="stylesheet" href="css/install.css" type="text/css" />
57156
57157 </head>
57158 <body>
57159 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
57160 <?php
57161 }//end function display_header();
57162
57163 switch($step) {
57164 case 0:
57165 display_header();
57166 ?>
57167
57168 <p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
57169 <ol>
57170 <li>Database name</li>
57171 <li>Database username</li>
57172 <li>Database password</li>
57173 <li>Database host</li>
57174 <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
57175 </ol>
57176 <p><strong>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>
57177 <p>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’re all ready…</p>
57178
57179 <p class="step"><a href="setup-config.php?step=1" class="button">Let’s go!</a></p>
57180 <?php
57181 break;
57182
57183 case 1:
57184 display_header();
57185 ?>
57186 <form method="post" action="setup-config.php?step=2">
57187 <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
57188 <table class="form-table">
57189 <tr>
57190 <th scope="row"><label for="dbname">Database Name</label></th>
57191 <td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td>
57192 <td>The name of the database you want to run WP in. </td>
57193 </tr>
57194 <tr>
57195 <th scope="row"><label for="uname">User Name</label></th>
57196 <td><input name="uname" id="uname" type="text" size="25" value="username" /></td>
57197 <td>Your MySQL username</td>
57198 </tr>
57199 <tr>
57200 <th scope="row"><label for="pwd">Password</label></th>
57201 <td><input name="pwd" id="pwd" type="text" size="25" value="password" /></td>
57202 <td>...and MySQL password.</td>
57203 </tr>
57204 <tr>
57205 <th scope="row"><label for="dbhost">Database Host</label></th>
57206 <td><input name="dbhost" id="dbhost" type="text" size="25" value="localhost" /></td>
57207 <td>99% chance you won't need to change this value.</td>
57208 </tr>
57209 <tr>
57210 <th scope="row"><label for="prefix">Table Prefix</label></th>
57211 <td><input name="prefix" id="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
57212 <td>If you want to run multiple WordPress installations in a single database, change this.</td>
57213 </tr>
57214 </table>
57215 <p class="step"><input name="submit" type="submit" value="Submit" class="button" /></p>
57216 </form>
57217 <?php
57218 break;
57219
57220 case 2:
57221 $dbname = trim($_POST['dbname']);
57222 $uname = trim($_POST['uname']);
57223 $passwrd = trim($_POST['pwd']);
57224 $dbhost = trim($_POST['dbhost']);
57225 $prefix = trim($_POST['prefix']);
57226 if (empty($prefix)) $prefix = 'wp_';
57227
57228 // Test the db connection.
57229 /**#@+
57230 * @ignore
57231 */
57232 define('DB_NAME', $dbname);
57233 define('DB_USER', $uname);
57234 define('DB_PASSWORD', $passwrd);
57235 define('DB_HOST', $dbhost);
57236 /**#@-*/
57237
57238 // We'll fail here if the values are no good.
57239 require_wp_db();
57240 if ( !empty($wpdb->error) )
57241 wp_die($wpdb->error->get_error_message());
57242
57243 $handle = fopen('../wp-config.php', 'w');
57244
57245 foreach ($configFile as $line_num => $line) {
57246 switch (substr($line,0,16)) {
57247 case "define('DB_NAME'":
57248 fwrite($handle, str_replace("putyourdbnamehere", $dbname, $line));
57249 break;
57250 case "define('DB_USER'":
57251 fwrite($handle, str_replace("'usernamehere'", "'$uname'", $line));
57252 break;
57253 case "define('DB_PASSW":
57254 fwrite($handle, str_replace("'yourpasswordhere'", "'$passwrd'", $line));
57255 break;
57256 case "define('DB_HOST'":
57257 fwrite($handle, str_replace("localhost", $dbhost, $line));
57258 break;
57259 case '$table_prefix =':
57260 fwrite($handle, str_replace('wp_', $prefix, $line));
57261 break;
57262 default:
57263 fwrite($handle, $line);
57264 }
57265 }
57266 fclose($handle);
57267 chmod('../wp-config.php', 0666);
57268
57269 display_header();
57270 ?>
57271 <p>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…</p>
57272
57273 <p class="step"><a href="install.php" class="button">Run the install</a></p>
57274 <?php
57275 break;
57276 }
57277 ?>
57278 </body>
57279 </html>