Changeset 912
- Timestamp:
- 03/12/07 14:40:14 (2 years ago)
- Files:
-
- trunk/htaccess.dist (modified) (1 diff)
- trunk/index-install.php (modified) (9 diffs)
- trunk/wpmu-settings.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/htaccess.dist
r892 r912 2 2 RewriteBase BASE/ 3 3 4 # Rewrite www.domain.com to domain.com5 RewriteCond %{HTTP_HOST} ^www\.(.*)6 RewriteRule ^(.*) http://%1/$1 [R,L]7 4 8 5 #uploaded files trunk/index-install.php
r908 r912 11 11 12 12 function printheader() { 13 if( substr( $_SERVER[ 'SERVER_NAME' ], 0, 4 ) == 'www.' ) { 14 $url = 'http://' . str_replace( 'www.', '', $_SERVER[ 'SERVER_NAME' ] ) . $_SERVER[ 'REQUEST_URI' ]; 15 print "<html><head><title>WordPress MU Installer</title><body>"; 16 print "<p style='margin-left: 20%; margin-right: 20%; margin-top: 5%; text-align: center'><strong>Warning!</strong> WordPress MU must be installed without the 'www.' in the URL.<br />Please click here to continue the install: <a href='$url'>$url</a></p></body></html>"; 17 die(); 18 } 19 print ' 13 ?> 20 14 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 21 15 <html xmlns="http://www.w3.org/1999/xhtml"> … … 24 18 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 25 19 <style media="screen" type="text/css"> 26 <!--27 20 html { 28 21 background: #eee; … … 67 60 text-decoration: underline; 68 61 } 69 -->70 62 </style> 71 63 </head> … … 73 65 74 66 <h1><img src="wp-includes/images/wordpress-mu.png" alt="WordPress MU" /></h1> 75 '; 67 <?php 76 68 } 77 69 … … 235 227 } 236 228 237 function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'password', $dbhost = 'localhost', $ prefix = 'wp_' ) {229 function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'password', $dbhost = 'localhost', $vhost = 'yes', $prefix = 'wp_' ) { 238 230 $weblog_title = 'My new WPMU Blog'; 239 231 $email = ''; 240 $hostname = str_replace( "www.", "", $_SERVER[ 'HTTP_HOST' ] ); 241 print " 232 if( substr( $_SERVER[ 'HTTP_HOST' ], 0, 4 ) == 'www.' ) 233 $hostname = str_replace( "www.", "", $_SERVER[ 'HTTP_HOST' ] ); 234 ?> 242 235 <form method='post' action='index.php'> 243 236 <input type='hidden' name='action' value='step2'> 244 237 <h2>Blog Addresses</h2> 245 238 <p>Please choose whether you would like blogs for the MU install to use sub-domains or sub-directories. You can not change this later. We recommend sub-domains.</p> 246 <p><label><input type='radio' name='vhost' value='yes' checked/> Sub-domains (like <code>blog1.example.com</code>)</label><br />247 <label><input type='radio' name='vhost' value='no' /> Sub-directories (like <code>example.com/blog1</code></label></p>239 <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 /> 240 <label><input type='radio' name='vhost' value='no' <?php if( $vhost == 'no' ) echo 'checked '; ?> /> Sub-directories (like <code>example.com/blog1</code></label></p> 248 241 249 242 <h2>Database</h2> … … 253 246 <tr> 254 247 <th scope='row' width='33%'>Database Name</th> 255 <td><input name='dbname' type='text' size='45' value=' $dbname' /></td>248 <td><input name='dbname' type='text' size='45' value='<?php echo $dbname ?>' /></td> 256 249 </tr> 257 250 <tr> 258 251 <th scope='row'>User Name</th> 259 <td><input name='uname' type='text' size='45' value=' $uname' /></td>252 <td><input name='uname' type='text' size='45' value='<?php echo $uname ?>' /></td> 260 253 </tr> 261 254 <tr> 262 255 <th scope='row'>Password</th> 263 <td><input name='pwd' type='text' size='45' value=' $pwd' /></td>256 <td><input name='pwd' type='text' size='45' value='<?php echo $pwd ?>' /></td> 264 257 </tr> 265 258 <tr> 266 259 <th scope='row'>Database Host</th> 267 <td><input name='dbhost' type='text' size='45' value=' $dbhost' /></td>260 <td><input name='dbhost' type='text' size='45' value='<?php echo $dbhost ?>' /></td> 268 261 </tr> 269 262 </table> 270 263 <h2>Server Address</h2> 271 <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=' {$hostname}'></label></p>264 <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> 272 265 <h2>Blog Details</h2> 273 266 <table width='100%'> 274 267 <tr> 275 268 <th scope='row'>Weblog Title</th> 276 <td><input name='weblog_title' type='text' size='45' value=' ".$weblog_title."' /></td>269 <td><input name='weblog_title' type='text' size='45' value='<?php echo $weblog_title ?>' /></td> 277 270 <td>What would you like to call your weblog? </td> 278 271 </tr> 279 272 <tr> 280 273 <th scope='row'>Email</th> 281 <td><input name='email' type='text' size='45' value=' ".$email."' /></td>274 <td><input name='email' type='text' size='45' value='<?php echo $email ?>' /></td> 282 275 <td>Your email address.</td> 283 276 </tr> 284 277 </table> 285 278 <p class='submit'><input name='submit' type='submit' value='Submit' /> </p> 286 </form> "; 279 </form> 280 <?php 287 281 } 288 282 … … 349 343 print "<b style='color: #00aa00; font-weight: bold'>DONE</b><br />"; 350 344 define( 'VHOST', $vhost ); 351 }352 353 function printuserdetailsform( $weblog_title = 'My new Blog', $username = '', $email = '' ) {354 $hostname = str_replace( "www.", "", $_SERVER[ 'HTTP_HOST' ] );355 print "356 <form method='post' action='index.php'>357 <input type='hidden' name='action' value='step3'>358 <p>To finish setting up your blog, please fill in the following form and click <q>Submit</q>.</p>359 <input name='submit' type='submit' value='Submit' />360 </form>361 <br />362 You will be sent an email with your password and login links and details.";363 345 } 364 346 … … 421 403 } 422 404 405 function nowww() { 406 $nowww = str_replace( 'www.', '', $_POST[ 'basedomain' ] ); 407 ?> 408 <h1>No-www</h1> 409 <p>WordPress MU 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> 410 <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> 411 <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> 412 <p><form method='POST'> 413 <input type='hidden' name='dbname' value='<?php echo $_POST[ 'dbname' ]; ?>'> 414 <input type='hidden' name='uname' value='<?php echo $_POST[ 'uname' ]; ?>'> 415 <input type='hidden' name='pwd' value='<?php echo $_POST[ 'pwd' ]; ?>'> 416 <input type='hidden' name='dbhost' value='<?php echo $_POST[ 'dbhost' ]; ?>'> 417 <input type='hidden' name='vhost' value='<?php echo $_POST[ 'vhost' ]; ?>'> 418 <input type='hidden' name='weblog_title' value='<?php echo $_POST[ 'weblog_title' ]; ?>'> 419 <input type='hidden' name='email' value='<?php echo $_POST[ 'email' ]; ?>'> 420 <input type='hidden' name='action' value='step2'> 421 <input type='hidden' name='basedomain' value='<?echo $nowww ?>'> 422 <input type='submit' value='Continue'> 423 </form></p> 424 <?php 425 } 426 423 427 switch( $_POST[ 'action' ] ) { 424 428 case "step2": 429 if( substr( $_POST[ 'basedomain' ], 0, 4 ) == 'www.' ) { 430 printheader(); 431 nowww(); 432 continue; 433 } 425 434 // get blog username 426 435 // create wp-config.php … … 429 438 include_once('./wp-config.php'); 430 439 include_once('./wp-admin/upgrade-functions.php'); 440 // normalise hostname - no www. 441 $_SERVER[ 'HTTP_HOST' ] = str_replace( 'www.', '', $_SERVER[ 'HTTP_HOST' ] ); 431 442 make_db_current_silent(); 432 443 populate_options(); trunk/wpmu-settings.php
r886 r912 24 24 $path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path ); 25 25 26 function wpmu_current_site() { 27 global $wpdb, $current_site, $domain, $path, $sites; 28 $path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) ); 29 if( constant( 'VHOST' ) == 'yes' ) { 30 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" ); 31 if( $current_site != null ) 32 return $current_site; 33 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" ); 34 if( $current_site != null ) { 35 $path = '/'; 36 return $current_site; 37 } 38 $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) ); 39 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" ); 40 if( $current_site != null ) 41 return $current_site; 42 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='/'" ); 43 if( $current_site == null && defined( "WP_INSTALLING" ) == false ) { 44 if( count( $sites ) == 1 ) { 45 $current_site = $sites[0]; 46 die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" ); 47 } else { 48 die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://trac.mu.wordpress.org/wiki/DebuggingWpmu'>Debugging WPMU</a> for further assistance." ); 49 } 50 } else { 51 $path = '/'; 52 } 53 } else { 54 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" ); 55 if( $current_site != null ) 56 return $current_site; 57 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" ); 58 if( $current_site == null && defined( "WP_INSTALLING" ) == false ) { 59 if( count( $sites ) == 1 ) { 60 $current_site = $sites[0]; 61 die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" ); 62 } else { 63 die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://trac.mu.wordpress.org/wiki/DebuggingWpmu'>Debugging WPMU</a> for further assistance." ); 64 } 65 } else { 66 $path = '/'; 67 } 68 } 69 return $current_site; 70 } 71 26 72 $wpdb->hide_errors(); 27 73 $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site … … 29 75 $current_site = $sites[0]; 30 76 $path = $current_site->path; 31 } 32 33 if( isset( $current_site ) == false ) { 34 $path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) ); 35 if( constant( 'VHOST' ) == 'yes' ) { 36 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" ); 37 if( $current_site == null ) { 38 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" ); 39 if( $current_site == null ) { 40 $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) ); 41 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" ); 42 if( $current_site == null ) { 43 $path = '/'; 44 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" ); 45 if( $current_site == null && defined( "WP_INSTALLING" ) == false ) { 46 if( count( $sites ) == 1 ) { 47 $current_site = $sites[0]; 48 die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" ); 49 } else { 50 die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://trac.mu.wordpress.org/wiki/DebuggingWpmu'>Debugging WPMU</a> for further assistance." ); 51 } 52 } 53 } 54 } else { 55 $path = '/'; 56 } 57 } 58 } else { 59 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" ); 60 if( $current_site == null ) { 61 $path = '/'; 62 $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" ); 63 if( $current_site == null && defined( "WP_INSTALLING" ) == false ) { 64 $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); 65 if( count( $sites ) == 1 ) { 66 $current_site = $sites[0]; 67 die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" ); 68 } else { 69 die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://trac.mu.wordpress.org/wiki/DebuggingWpmu'>Debugging WPMU</a> for further assistance." ); 70 } 71 } 72 } 73 } 77 } else { 78 $current_site = wpmu_current_site(); 74 79 } 75 80
