2 define('WP_INSTALLING', true);
3 //These two defines are required to allow us to use require_wp_db() to load the database class while being wp-content/wp-db.php aware
4 define('ABSPATH', dirname(dirname(__FILE__)).'/');
5 define('WPINC', 'wp-includes');
7 require_once('../wp-includes/compat.php');
8 require_once('../wp-includes/functions.php');
9 require_once('../wp-includes/classes.php');
11 if (!file_exists('../wp-config-sample.php'))
12 wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
14 $configFile = file('../wp-config-sample.php');
16 if ( !is_writable('../'))
17 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.");
19 // Check if wp-config.php has been created
20 if (file_exists('../wp-config.php'))
21 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>");
23 if (isset($_GET['step']))
24 $step = $_GET['step'];
28 function display_header(){
29 header( 'Content-Type: text/html; charset=utf-8' );
31 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32 <html xmlns="http://www.w3.org/1999/xhtml">
34 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
35 <title>WordPress › Setup Configuration File</title>
36 <link rel="stylesheet" href="<?php echo $admin_dir; ?>css/install.css" type="text/css" />
40 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
42 }//end function display_header();
49 <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>
51 <li>Database name</li>
52 <li>Database username</li>
53 <li>Database password</li>
54 <li>Database host</li>
55 <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
57 <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>
58 <p>In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…</p>
60 <p><a href="setup-config.php?step=1" class="button">Let’s go!</a></p>
67 <form method="post" action="setup-config.php?step=2">
68 <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
69 <table class="form-table">
71 <th scope="row">Database Name</th>
72 <td><input name="dbname" type="text" size="25" value="wordpress" /></td>
73 <td>The name of the database you want to run WP in. </td>
76 <th scope="row">User Name</th>
77 <td><input name="uname" type="text" size="25" value="username" /></td>
78 <td>Your MySQL username</td>
81 <th scope="row">Password</th>
82 <td><input name="pwd" type="text" size="25" value="password" /></td>
83 <td>...and MySQL password.</td>
86 <th scope="row">Database Host</th>
87 <td><input name="dbhost" type="text" size="25" value="localhost" /></td>
88 <td>99% chance you won't need to change this value.</td>
91 <th scope="row">Table Prefix</th>
92 <td><input name="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
93 <td>If you want to run multiple WordPress installations in a single database, change this.</td>
97 <input name="submit" type="submit" value="Submit" class="button" />
104 $dbname = trim($_POST['dbname']);
105 $uname = trim($_POST['uname']);
106 $passwrd = trim($_POST['pwd']);
107 $dbhost = trim($_POST['dbhost']);
108 $prefix = trim($_POST['prefix']);
109 if (empty($prefix)) $prefix = 'wp_';
111 // Test the db connection.
112 define('DB_NAME', $dbname);
113 define('DB_USER', $uname);
114 define('DB_PASSWORD', $passwrd);
115 define('DB_HOST', $dbhost);
117 // We'll fail here if the values are no good.
119 if ( !empty($wpdb->error) )
120 wp_die($wpdb->error->get_error_message());
122 $handle = fopen('../wp-config.php', 'w');
124 foreach ($configFile as $line_num => $line) {
125 switch (substr($line,0,16)) {
126 case "define('DB_NAME'":
127 fwrite($handle, str_replace("putyourdbnamehere", $dbname, $line));
129 case "define('DB_USER'":
130 fwrite($handle, str_replace("'usernamehere'", "'$uname'", $line));
132 case "define('DB_PASSW":
133 fwrite($handle, str_replace("'yourpasswordhere'", "'$passwrd'", $line));
135 case "define('DB_HOST'":
136 fwrite($handle, str_replace("localhost", $dbhost, $line));
138 case '$table_prefix =':
139 fwrite($handle, str_replace('wp_', $prefix, $line));
142 fwrite($handle, $line);
146 chmod('../wp-config.php', 0666);
150 <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>
152 <p><a href="install.php" class="button">Run the install</a></p>