root/tags/1.5-rc1/index-install.php

Revision 1226, 21.3 kB (checked in by donncha, 8 months ago)

weblog_title gets passed to update_option() eventually which expects unescaped values

  • Property svn:eol-style set to native
Line 
1 <?php
2 // don't ever call this file directly!
3 if( strpos( $_SERVER["REQUEST_URI"], 'index-install.php' ) ) {
4     header( "Location: index.php" );
5     die();
6 }
7 if( $_SERVER[ 'HTTP_HOST' ] == 'localhost' ) {
8     die( "<h2>Warning!</h2> Installing to http://localhost/ is not supported. Please use <a href='http://localhost.localdomain/'>http://localhost.localdomain/</a> instead." );
9 }
10 define('WP_INSTALLING', true);
11
12 $dirs = array( dirname(__FILE__), dirname(__FILE__) . "/wp-content/" );
13
14 function printheader() {
15 ?>
16 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
17 <html xmlns="http://www.w3.org/1999/xhtml">
18 <head>
19         <title>WordPress &rsaquo; Installation</title>
20         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
21         <style media="screen" type="text/css">
22         html {
23                 background: #eee;
24         }
25         body {
26                 background: #fff;
27                 color: #000;
28                 font-family: Georgia, "Times New Roman", Times, serif;
29                 margin-left: 20%;
30                 margin-right: 20%;
31                 padding: .2em 2em;
32         }
33        
34         h1, h2 {
35                 color: #006;
36                 font-size: 18px;
37                 font-weight: lighter;
38         }
39        
40         p, li, dt {
41                 line-height: 140%;
42                 padding-bottom: 2px;
43         }
44
45         ul, ol {
46                 padding: 5px 5px 5px 20px;
47         }
48         #logo {
49                 margin-bottom: 2em;
50         }
51 .step a, .step input {
52         font-size: 2em;
53 }
54 .step, th {
55         text-align: right;
56 }
57 #footer {
58 text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: italic;
59 }
60 .fakelink {
61     color: #00a;
62     text-decoration: underline;
63 }
64         </style>
65 </head>
66 <body>
67
68 <h1><img src="wp-includes/images/wordpress-mu.png" alt="WordPress &micro;" /></h1>
69 <?php
70 }
71
72 function filestats( $err ) {
73     print "<h1>Server Summary</h1>";
74     print "<p>If you post a message to the &micro; support forum at <a target='_blank' href='http://mu.wordpress.org/forums/'>http://mu.wordpress.org/forums/</a> then copy and paste the following information into your message:</p>";
75
76     print "<blockquote style='background: #eee; border: 1px solid #333; padding: 5px;'>";
77     print "<br /><strong>ERROR: $err</strong></br >";
78     clearstatcache();
79     $files = array( "htaccess.dist", ".htaccess" );
80     while( list( $key, $val ) = each( $files ) ) {
81         $stats = @stat( $val );
82         if( $stats ) {
83             print "<h2>$val</h2>";
84             print "&nbsp;&nbsp;&nbsp;&nbsp;uid/gid: " . $stats[ 'uid' ] . "/" . $stats[ 'gid' ] . "<br />\n";
85             print "&nbsp;&nbsp;&nbsp;&nbsp;size: " . $stats[ 'size' ] . "<br />";
86             print "&nbsp;&nbsp;&nbsp;&nbsp;perms: " . substr( sprintf('%o', fileperms( $val ) ), -4 ) . "<br />";
87             print "&nbsp;&nbsp;&nbsp;&nbsp;readable: ";
88             print is_readable( $val ) == true ? "yes" : "no";
89             print "<br />";
90             print "&nbsp;&nbsp;&nbsp;&nbsp;writeable: ";
91             print is_writeable( $val ) == true ? "yes" : "no";
92             print "<br />";
93         } elseif( file_exists( $val ) == false ) {
94             print "<h2>$val</h2>";
95             print "&nbsp;&nbsp;&nbsp;&nbsp;FILE NOT FOUND: $val<br>";
96         }
97     }
98     print "</blockquote>";
99 }
100
101 function do_htaccess( $oldfilename, $newfilename, $base, $url ) {
102     // remove ending slash from $base and $url
103     $htaccess = '';
104     if( substr($base, -1 ) == '/') {
105         $base = substr($base, 0, -1);
106     }
107
108     if( substr($url, -1 ) == '/') {
109         $url = substr($url, 0, -1);
110     }
111     $err = '';
112     if( is_file( $oldfilename ) ) {
113         $fp = @fopen( $oldfilename, "r" );
114         if( $fp ) {
115             while( !feof( $fp ) )
116             {
117                 $htaccess .= fgets( $fp, 4096 );
118             }
119             fclose( $fp );
120             $htaccess = str_replace( "BASE", $base, $htaccess );
121             if( touch( $newfilename ) ) {
122                 $fp = fopen( $newfilename, "w" );
123                 if( $fp ) {
124                     fwrite( $fp, $htaccess );
125                     fclose( $fp );
126                 } else {
127                     $err = "could not open $newfilename for writing";
128                 }
129             } else {
130                 $err = "could not open $newfilename for writing";
131             }
132         } else {
133             $err = "could not open $oldfilename for reading";
134         }
135     } else {
136         $err = "$oldfilename not found";
137     }
138
139     if( $err != '' ) {
140         print "<h1>Warning!</h1>";
141         print "<p><strong>There was a problem creating the .htaccess file.</strong> </p>";
142         print "<p style='color: #900'>Error: ";
143         if( $err == "could not open $newfilename for writing" ) {
144             print "Could Not Write To $newfilename.";
145         } elseif( $err == "could not open $oldfilename for reading" ) {
146             print "I could not read from $oldfilename. ";
147         } elseif( $err == "$oldfilename not found" ) {
148             print "The file, $oldfilename, is missing.";
149         }
150         print "</p>";
151         filestats( $err );
152
153         print "<p>Please ensure that the webserver can write to this directory.</p>";
154         print "<p>If you use Cpanel then read <a href='http://mu.wordpress.org/forums/topic.php?id=99'>this post</a>. Cpanel creates files that I need to overwrite and you have to fix that.</p>";
155         print "<p>If all else fails then you'll have to create it by hand:";
156         print "<ul><li> Download htaccess.dist to your computer and open it in your favourite text editor.</li>
157         <li> Replace the following text:<ul><li>BASE by '$base'</li><li>HOST by '$url'</li></li>
158         <li> Rename htaccess.dist to .htaccess and upload it back to the same directory.</li></ul>";
159         die( "Installation Aborted!" );
160     }
161 }
162
163 function checkdirs() {
164     global $dirs;
165
166     $ret = true;
167     foreach( $dirs as $dir ) {
168         if( false == is_writeable( $dir ) ) {
169             $err[] = $dir;
170         }
171     }
172
173     if( is_array( $err ) ) {
174         ?><h2>Warning!</h2>
175         <div style='border: 1px solid #ccc'>
176         <p style='font-weight: bold; padding-left: 10px'>One or more of the directories must be made writeable by the webserver. You will be reminded to reset the permissions at the end of the install.<br>
177         Please <code>chmod 777 <q>directory-name</q></code> or <code>chown</code> that directory to the user the web server runs as (usually nobody, apache, or www-data)<br>
178         Refresh this page when you're done!<br></p>
179         </div>
180         <p>Quick fix:<br /> <code>chmod&nbsp;777&nbsp;<?php
181         foreach( $err as $dir ) {
182             echo "$dir&nbsp;";
183         }
184         ?></code></p><?php
185         $ret = false;
186     }
187     if( file_exists( "./.htaccess" ) && is_writeable( "./.htaccess" ) == false ) {
188         $ret = false;
189         print "<h2>Warning! .htaccess already exists.</h2>";
190         print "<div style='border: 1px solid #ccc'>";
191         print "<p style='font-weight: bold; padding-left: 10px'>A file with the name '.htaccess' already exists in this directory and I cannot write to it. Please ftp to the server and delete this file from this directory!<br />";
192         print "Offending file: " . realpath( '.htaccess' ) . "</p>";
193         print "</div>";
194     }
195     return $ret;
196 }
197
198 function step1() {
199     ?><h2>Installing WordPress &micro;</h2>
200     <p><strong>Welcome to WordPress &micro;.</strong> I will help you install this software by asking you a few questions and asking that you change the permissions on a few directories so I can create configuration files and make a directory to store all your uploaded files.</p>
201     <p>If you have installed the single-blog version of WordPress before, please note that the WordPress &micro; installer is different and trying to create the configuration file wp-config.php youself may result in a broken site. It's much easier to use this installer to get the job done.</p>
202     <h3>What do I need?</h3>
203     <p><ul><li>Access to your server to change directory permissions. This can be done through ssh or ftp for example.</li><li>A valid email where your password and administrative emails will be sent.</li><li>An empty MySQL database.Tables are prefixed with <code>wp_</code> which may conflict with an existing WordPress install.</li><li> Wildcard dns records if you're going to use the virtual host functionality. Check the <a href='http://trac.mu.wordpress.org/browser/trunk/README.txt'>README</a> for further details.</li></ul><p>
204     <?php
205     $mod_rewrite_msg = "<p>If the <code>mod_rewrite</code> module is disabled ask your administrator to enable that module, or look at the <a href='http://httpd.apache.org/docs/mod/mod_rewrite.html'>Apache documentation</a> or <a href='http://www.google.com/search?q=apache+mod_rewrite'>elsewhere</a> for help setting it up.</p>";
206     if( function_exists( "apache_get_modules" ) ) {
207         $modules = apache_get_modules();
208         if( in_array( "mod_rewrite", $modules ) == false ) {
209             echo "<p><strong>Warning!</strong> It looks like mod_rewrite is not installed.</p>" . $mod_rewrite_msg;
210         }
211     } else {
212         ?><p>Please make sure <code>mod_rewrite</code> is installed as it will be activated at the end of this install.</p><?php
213         echo $mod_rewrite_msg;
214     }
215     if( checkdirs() == false ) {
216         return false;
217     }
218
219     // Create Blogs living area.
220     @mkdir( dirname(__FILE__) . "/wp-content/blogs.dir", 0777 );
221
222     $url = stripslashes( "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] ) );
223     if( substr( $url, -1 ) == '/' )
224     $url = substr( $url, 0, -1 );
225     $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) );
226     if( $base != "/") {
227         $base .= "/";
228     }
229     $realpath = dirname(__FILE__);
230
231     return true;
232 }
233
234 function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'password', $dbhost = 'localhost', $vhost = 'yes', $prefix = 'wp_' ) {
235     $weblog_title = 'My new WordPress MU Site';
236     $email = '';
237     $hostname = $_SERVER[ 'HTTP_HOST' ];
238     if( substr( $_SERVER[ 'HTTP_HOST' ], 0, 4 ) == 'www.' )
239         $hostname = str_replace( "www.", "", $_SERVER[ 'HTTP_HOST' ] );
240     ?>
241     <form method='post' action='index.php'>
242     <input type='hidden' name='action' value='step2'>
243     <h2>Blog Addresses</h2>
244     <p>Please choose whether you would like blogs for the WordPress &micro; install to use sub-domains or sub-directories. You can not change this later. We recommend sub-domains.</p>
245     <p><label><input type='radio' name='vhost' value='yes' <?php if( $vhost == 'yes' ) echo 'checked '; ?> /> Sub-domains (like <code>blog1.example.com</code>)</label><br />
246     <label><input type='radio' name='vhost' value='no' <?php if( $vhost == 'no' ) echo 'checked '; ?> /> Sub-directories (like <code>example.com/blog1</code></label></p>
247    
248     <h2>Database</h2>
249
250   <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
251   <table cellpadding='5'>
252     <tr>
253       <th scope='row' width='33%'>Database Name</th>
254       <td><input name='dbname' type='text' size='45' value='<?php echo $dbname ?>' /></td> 
255     </tr>
256     <tr>
257       <th scope='row'>User Name</th>
258       <td><input name='uname' type='text' size='45' value='<?php echo $uname ?>' /></td>
259     </tr>
260     <tr>
261       <th scope='row'>Password</th>
262       <td><input name='pwd' type='text' size='45' value='<?php echo $pwd ?>' /></td>
263     </tr>
264     <tr>
265       <th scope='row'>Database Host</th>
266       <td><input name='dbhost' type='text' size='45' value='<?php echo $dbhost ?>' /></td>
267     </tr>
268   </table>
269   <h2>Server Address</h2>
270   <p><label>What is the Internet address of your site? You should enter the shortest address possible. For example, use <em>example.com</em> instead of <em>www.example.com</em> but if you are going to use an address like <em>blogs.example.com</em> then enter that unaltered in the box below.<br /><b>Server Address:</b> <input type='text' name='basedomain' value='<?php echo $hostname ?>'></label></p>
271   <h2>Site Details</h2>
272   <table width='100%'>
273   <tr>
274   <th scope='row'>Site&nbsp;Title</th>
275   <td><input name='weblog_title' type='text' size='45' value='<?php echo $weblog_title ?>' /></td>
276   <td>What would you like to call your site? </td>
277   </tr>
278   <tr>
279   <th scope='row'>Email</th>
280   <td><input name='email' type='text' size='45' value='<?php echo $email ?>' /></td>
281   <td>Your email address.</td>
282   </tr>
283   </table>
284   <p class='submit'><input name='submit' type='submit' value='Submit' /> </p>
285 </form>
286 <?php
287 }
288
289 function step2() {
290     global $wpdb, $table_prefix, $base, $blog_id;
291     $dbname  = $_POST['dbname'];
292     $uname   = $_POST['uname'];
293     $passwrd = $_POST['pwd'];
294     $dbhost  = $_POST['dbhost'];
295     $vhost   = $_POST['vhost' ];
296     $prefix  = 'wp_';
297     $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) );
298     if( $base != "/")
299         $base .= "/";
300
301     // Test the db connection.
302     define('DB_NAME', $dbname);
303     define('DB_USER', $uname);
304     define('DB_PASSWORD', $passwrd);
305     define('DB_HOST', $dbhost);
306
307     if (!file_exists('wp-config-sample.php'))
308         die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
309
310     $configFile = file('wp-config-sample.php');
311     // We'll fail here if the values are no good.
312     require_once('wp-includes/wp-db.php');
313     printheader();
314
315     $handle = fopen('wp-config.php', 'w');
316
317     foreach ($configFile as $line_num => $line) {
318         switch (trim( substr($line,0,16) )) {
319             case "define('DB_NAME'":
320                 fwrite($handle, str_replace("wordpress", $dbname, $line));
321                 break;
322             case "define('DB_USER'":
323                 fwrite($handle, str_replace("'username'", "'$uname'", $line));
324                 break;
325             case "define('DB_PASSW":
326                 fwrite($handle, str_replace("'password'", "'$passwrd'", $line));
327                 break;
328             case "define('DB_HOST'":
329                 fwrite($handle, str_replace("localhost", $dbhost, $line));
330                 break;
331             case "define('VHOST',":
332                 fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line));
333                 break;
334             case '$table_prefix  =':
335                 fwrite($handle, str_replace('wp_', $prefix, $line));
336                 break;
337             case '$base = \'BASE\';':
338                 fwrite($handle, str_replace('BASE', $base, $line));
339                 break;
340             case "define('SECRET_K":
341             case "define('SECRET_S":
342                 fwrite($handle, str_replace('put your unique phrase here', md5( mt_rand() ) . md5( mt_rand() ), $line));
343                 break;
344             default:
345                 fwrite($handle, $line);
346                 break;
347         }
348     }
349     fclose($handle);
350     chmod('wp-config.php', 0644);
351     define( 'VHOST', $vhost );
352 }
353
354 function step3() {
355     global $wpdb, $current_site, $dirs, $wp_version;
356     $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) );
357     if( $base != "/") {
358         $base .= "/";
359     }
360     $domain =   $wpdb->escape( $_POST[ 'basedomain' ] );
361     $domain = str_replace( 'http://', '', $domain );
362     if( substr( $domain, 0, 4 ) == 'www.' )
363         $domain = substr( $domain, 4 );
364     if( strpos( $domain, '/' ) )
365         $domain = substr( $domain, 0, strpos( $domain, '/' ) );
366     $email = $wpdb->escape( $_POST[ 'email' ] );
367     if( $email == '' )
368         die( 'You must enter an email address!' );
369     $weblog_title = stripslashes( $_POST[ 'weblog_title' ] );
370
371     // set up site tables
372     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_email', '".$email."')" );
373     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_user_id', '1')" );
374     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'registration', 'none')" );
375     $wpdb->query( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( NULL, '$domain', '$base' )" );
376     $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (1, 'Uncategorized', 'uncategorized', NOW())" );
377     $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (2, 'Blogroll', 'blogroll', NOW())" );
378     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'upload_filetypes', 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf' )" );
379     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'blog_upload_space', '10' )" );
380     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'fileupload_maxk', '1500' )" );
381     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_admins', '" . serialize( array( 'admin' ) ) . "' )" );
382     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'allowedthemes', '" . serialize( array( 'classic' => 1, 'default' => 1 ) ) . "' )" );
383     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'illegal_names', '" . serialize( array(  "www", "web", "root", "admin", "main", "invite", "administrator" ) ) . "' )" );
384     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'welcome_email', 'Dear User,
385
386 Your new SITE_NAME blog has been successfully set up at:
387 BLOG_URL
388
389 You can log in to the administrator account with the following information:
390  Username: USERNAME
391  Password: PASSWORD
392 Login Here: BLOG_URLwp-login.php
393
394 We hope you enjoy your new blog.
395 Thanks!
396
397 --The Team @ SITE_NAME')" );
398     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' )" );
399
400     $pass = substr( md5( rand() ), 5, 12 );
401     $user_id = wpmu_create_user( 'admin', $pass, $email);
402
403     $current_site->domain = $domain;
404     $current_site->path = $base;
405     $current_site->site_name = ucfirst( $domain );
406
407     wpmu_create_blog( $domain, $base, $weblog_title, $user_id, array( 'blog_public' => 1, 'public' => 1 ) );
408     update_blog_option( 1, 'template', 'home');
409     update_blog_option( 1, 'stylesheet', 'home');
410     if( constant( 'VHOST' ) == 'yes' ) {
411         update_blog_option( 1, 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
412     } else {
413         update_blog_option( 1, 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');
414     }
415     update_blog_option( 1, 'rewrite_rules', '');
416     $msg = "Your new WordPress MU site has been created at\nhttp://{$domain}{$base}\n\nLogin details:\nUsername: admin\nPassword: $pass\nLogin: http://{$domain}{$base}wp-login.php\n";
417     wp_mail( $email, "Your new WordPress MU site is ready!", $msg, "From: wordpress@" . $_SERVER[ 'HTTP_HOST' ]  );
418     ?><h2>Installation Finished!</h2>
419     <p>Congratulations! Your <a href='http://<?php echo $domain . $base; ?>'>WordPress &micro; site</a> has been configured.</p>
420     <p>You can <a href='wp-login.php'>log in</a> using the username "admin" and password <?php echo $pass; ?></p>
421     <h3>Directory Permissions</h3>
422     <p>Please remember to reset the permissions on the following directories:<ul>
423     <?php
424     reset( $dirs );
425     foreach( $dirs as $dir ) {
426         echo "<li> $dir</li>";
427     }
428     ?></ul></p>
429     <p>You can probably use the following command to fix the permissions but check with your host if it doubt:<br /><code>chmod&nbsp;755&nbsp;<?php
430     reset( $dirs );
431     foreach( $dirs as $dir ) {
432         echo "$dir&nbsp;";
433     }
434     ?></code></p>
435     <h3>Further reading</h3>
436     <p><ul><li>If you run into problems, please search the <a href='http://mu.wordpress.org/forums/'>WordPress &micro; Forums</a> where you will most likely find a solution. Please don't post there before searching. It's not polite.</li>
437     <li>There is also the <a href='http://trac.mu.wordpress.org/'>WordPress &micro; Trac</a>. That's our bug tracker.</li></ul></p>
438     <p>Thanks for installing WordPress &micro;!<br /><br />
439    
440     Donncha<br />
441     <code>wpmu version: <?php echo $wp_version ?></code></p>
442     <?php
443 }
444
445 function nowww() {
446     $nowww = str_replace( 'www.', '', $_POST[ 'basedomain' ] );
447     ?>
448     <h1>No-www</h1>
449     <p>WordPress &micro; strips the string "www" from the URLs of sites using this software. It is still possible to visit your site using the "www" prefix with an address like <em><?php echo $_POST[ 'basedomain' ] ?></em> but any links will not have the "www" prefix. They will instead point at <?php echo $nowww ?>.</p>
450     <p>The preferred method of hosting blogs is without the "www" prefix as it's more compact and simple.</p><p>You can still use "<?php echo $_POST[ 'basedomain' ] ?>" and URLs like "www.blog1.<?php echo $nowww; ?>" to address your site and blogs after installation but internal links will use the <?php echo $nowww ?> format.</p>
451     <p><a target='_blank' href="http://no-www.org/">www. is depreciated</a> has a lot more information on why 'www.' isn't needed any more.</p>
452     <p><form method='POST'>
453     <input type='hidden' name='dbname' value='<?php echo $_POST[ 'dbname' ]; ?>'>
454     <input type='hidden' name='uname' value='<?php echo $_POST[ 'uname' ]; ?>'>
455     <input type='hidden' name='pwd' value='<?php echo $_POST[ 'pwd' ]; ?>'>
456     <input type='hidden' name='dbhost' value='<?php echo $_POST[ 'dbhost' ]; ?>'>
457     <input type='hidden' name='vhost' value='<?php echo $_POST[ 'vhost' ]; ?>'>
458     <input type='hidden' name='weblog_title' value='<?php echo $_POST[ 'weblog_title' ]; ?>'>
459     <input type='hidden' name='email' value='<?php echo $_POST[ 'email' ]; ?>'>
460     <input type='hidden' name='action' value='step2'>
461     <input type='hidden' name='basedomain' value='<?echo $nowww ?>'>
462     <input type='submit' value='Continue'>
463     </form></p>
464     <?php
465 }
466
467 $action = isset($_POST[ 'action' ]) ? $_POST[ 'action' ] : null;
468 switch($action) {
469     case "step2":
470         if( substr( $_POST[ 'basedomain' ], 0, 4 ) == 'www.' ) {
471             printheader();
472             nowww();
473             continue;
474         }
475         // get blog username
476         // create wp-config.php
477         step2();
478         // Install Blog!
479         include_once('./wp-config.php');
480         include_once('./wp-admin/includes/upgrade.php');
481         // normalise hostname - no www.
482         $_SERVER[ 'HTTP_HOST' ] = str_replace( 'www.', '', $_SERVER[ 'HTTP_HOST' ] );
483         make_db_current_silent();
484         populate_options();
485         do_htaccess( 'htaccess.dist', '.htaccess', $base, '');
486         step3();
487     break;
488     default:
489         // check that directories are writeable.
490         // create wpmu-settings.php
491         // get db auth info.
492         printheader();
493         if( step1() ) {
494             printstep1form();
495         }
496     break;
497 }
498