[ Root ] [ Search ] [ Index ]

PHP Cross Reference of WordPress MU 2.9.2

Provided by Yoast

title

Body

[close]

/ -> index-install.php (source)

   1  <?php
   2  // don't ever call this file directly!
   3  if ( strpos( $_SERVER[ "REQUEST_URI" ], 'index-install.php' ) || strpos( $_SERVER[ "SCRIPT_NAME" ], 'index-install.php' ) ) {
   4      header( "Location: index.php" );
   5      exit();
   6  }
   7  
   8  if( $_SERVER[ 'HTTP_HOST' ] == 'localhost' ) {
   9      die( "<h2>Warning!</h2><p>Installing to http://localhost/ is not supported. Please use <a href='http://localhost.localdomain/'>http://localhost.localdomain/</a> instead.</p>" );
  10  }
  11  
  12  define('WP_INSTALLING', true);
  13  define('WP_FIRST_INSTALL', true);
  14  
  15  $dirs = array( dirname(__FILE__), dirname(__FILE__) . "/wp-content/" );
  16  
  17  function printheader() {
  18      ?>
  19      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  20      <html xmlns="http://www.w3.org/1999/xhtml">
  21      <head>
  22          <title>WordPress &rsaquo; Installation</title>
  23          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  24  
  25          <style media="screen" type="text/css">
  26          html { background: #f1f1f1; }
  27  
  28          body {
  29              background: #fff;
  30              color: #333;
  31              font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
  32              margin: 2em auto 0 auto;
  33              width: 700px;
  34              padding: 1em 2em;
  35              -moz-border-radius: 12px;
  36              -khtml-border-radius: 12px;
  37              -webkit-border-radius: 12px;
  38              border-radius: 12px;
  39          }
  40  
  41          a { color: #2583ad; text-decoration: none; }
  42  
  43          a:hover { color: #d54e21; }
  44  
  45  
  46          h1 {
  47              font-size: 18px;
  48              margin-bottom: 0;
  49          }
  50  
  51          h2 { font-size: 16px; }
  52  
  53          p, li {
  54              padding-bottom: 2px;
  55              font-size: 13px;
  56              line-height: 18px;
  57          }
  58  
  59          code {
  60              font-size: 13px;
  61          }
  62  
  63          ul, ol { padding: 5px 5px 5px 22px; }
  64  
  65          #logo { margin: 6px 0 14px 0px; border-bottom: none;}
  66  
  67          .step {
  68              margin: 20px 0 15px;
  69          }
  70  
  71          .step input {
  72              font-size: 18px;
  73          }
  74  
  75          a.button {
  76              font-size: 18px;
  77          }
  78  
  79          .step, th { text-align: left; padding: 0; }
  80  
  81          .submit input, .button, .button-secondary {
  82              font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
  83              padding: 5px 7px 7px;
  84              border: 1px solid #a3a3a3;
  85              margin-left: 0;
  86              -moz-border-radius: 3px;
  87              -khtml-border-radius: 3px;
  88              -webkit-border-radius: 3px;
  89              border-radius: 3px;
  90              color: #246;
  91              background: #e5e5e5;
  92          }
  93  
  94          .button-secondary {
  95              background: #cee1ef;
  96          }
  97  
  98          .submit input:hover, .button:hover, .button-secondary:hover {
  99              color: #d54e21;
 100              border-color: #535353;
 101          }
 102  
 103          .form-table {
 104              border-collapse: collapse;
 105              margin-top: 1em;
 106              width: 100%;
 107          }
 108  
 109          .form-table td {
 110              margin-bottom: 9px;
 111              padding: 10px;
 112              border-bottom: 8px solid #fff;
 113              font-size: 12px;
 114          }
 115  
 116          .form-table th {
 117              font-size: 13px;
 118              text-align: left;
 119              padding: 16px 10px 10px 10px;
 120              border-bottom: 8px solid #fff;
 121              width: 110px;
 122              vertical-align: top;
 123          }
 124  
 125          .form-table tr, .blog-address {
 126              background: #eaf3fa;
 127          }
 128  
 129          .form-table code {
 130              line-height: 18px;
 131              font-size: 18px;
 132          }
 133  
 134          .form-table p {
 135              margin: 4px 0 0 0;
 136              font-size: 11px;
 137          }
 138  
 139          .form-table input {
 140              line-height: 20px;
 141              font-size: 15px;
 142              padding: 2px;
 143              margin-bottom:3px;
 144          }
 145  
 146          h1 {
 147              border-bottom: 1px solid #dadada;
 148              clear: both;
 149              color: #666666;
 150              font: 24px Georgia, "Times New Roman", Times, serif;
 151              margin: 5px 0 0 -4px;
 152              padding: 0;
 153              padding-bottom: 7px;
 154          }
 155  
 156          #error-page {
 157              margin-top: 50px;
 158          }
 159  
 160          #error-page p {
 161              font-size: 14px;
 162              line-height: 16px;
 163              margin: 25px 0 20px;
 164          }
 165  
 166          #error-page code {
 167              font-size: 15px;
 168          }
 169          </style>
 170      </head>
 171      <body>
 172          <h1 id="logo"><img src="wp-includes/images/wordpress-mu.png" alt="WordPress &micro;" /></h1>
 173          <?php
 174  }
 175  
 176  function filestats( $err ) {
 177      print "<h2>Server Summary</h2>";
 178      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>";
 179  
 180      print "<blockquote style='background: #eee; border: 1px solid #333; padding: 5px;'>";
 181      print "<br /><strong>ERROR: $err</strong><br />";
 182      clearstatcache();
 183      $files = array( "htaccess.dist", ".htaccess" );
 184      
 185      foreach ( (array) $files as $val ) {
 186          $stats = @stat( $val );
 187          if( $stats ) {
 188              print "<h2>$val</h2>";
 189              print "&nbsp;&nbsp;&nbsp;&nbsp;uid/gid: " . $stats[ 'uid' ] . "/" . $stats[ 'gid' ] . "<br />\n";
 190              print "&nbsp;&nbsp;&nbsp;&nbsp;size: " . $stats[ 'size' ] . "<br />";
 191              print "&nbsp;&nbsp;&nbsp;&nbsp;perms: " . substr( sprintf('%o', fileperms( $val ) ), -4 ) . "<br />";
 192              print "&nbsp;&nbsp;&nbsp;&nbsp;readable: ";
 193              print is_readable( $val ) == true ? "yes" : "no";
 194              print "<br />";
 195              print "&nbsp;&nbsp;&nbsp;&nbsp;writeable: ";
 196              print is_writeable( $val ) == true ? "yes" : "no";
 197              print "<br />";
 198          } elseif( file_exists( $val ) == false ) {
 199              print "<h2>$val</h2>";
 200              print "&nbsp;&nbsp;&nbsp;&nbsp;FILE NOT FOUND: $val<br />";
 201          }
 202      }
 203      print "</blockquote>";
 204  }
 205  
 206  function do_htaccess( $oldfilename, $newfilename, $base, $url ) {
 207      // remove ending slash from $base and $url
 208      $htaccess = '';
 209      if( substr($base, -1 ) == '/') {
 210          $base = substr($base, 0, -1);
 211      }
 212  
 213      if( substr($url, -1 ) == '/') {
 214          $url = substr($url, 0, -1);
 215      }
 216      $err = '';
 217      if( is_file( $oldfilename ) ) {
 218          $fp = @fopen( $oldfilename, "r" );
 219          if( $fp ) {
 220              while( !feof( $fp ) )
 221              {
 222                  $htaccess .= fgets( $fp, 4096 );
 223              }
 224              fclose( $fp );
 225              $htaccess = str_replace( "BASE", $base, $htaccess );
 226              if( touch( $newfilename ) ) {
 227                  $fp = fopen( $newfilename, "w" );
 228                  if( $fp ) {
 229                      fwrite( $fp, $htaccess );
 230                      fclose( $fp );
 231                  } else {
 232                      $err = "could not open $newfilename for writing";
 233                  }
 234              } else {
 235                  $err = "could not open $newfilename for writing";
 236              }
 237          } else {
 238              $err = "could not open $oldfilename for reading";
 239          }
 240      } else {
 241          $err = "$oldfilename not found";
 242      }
 243  
 244      if( $err != '' ) {
 245          print "<h2>Warning!</h2>";
 246          print "<p><strong>There was a problem creating the .htaccess file.</strong> </p>";
 247          print "<p style='color: #900'>Error: ";
 248          if( $err == "could not open $newfilename for writing" ) {
 249              print "Could Not Write To $newfilename.";
 250          } elseif( $err == "could not open $oldfilename for reading" ) {
 251              print "I could not read from $oldfilename. ";
 252          } elseif( $err == "$oldfilename not found" ) {
 253              print "The file, $oldfilename, is missing.";
 254          }
 255          print "</p>";
 256          filestats( $err );
 257  
 258          print "<p>Please ensure that the webserver can write to this directory.</p>";
 259          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>";
 260          print "<p>If all else fails then you'll have to create it by hand:";
 261          print "<ul>
 262              <li> Download htaccess.dist to your computer and open it in your favourite text editor.</li>
 263              <li> Replace the following text:
 264              <ul>
 265              <li>BASE by '$base'</li>
 266              <li>HOST by '$url'</li>
 267              </ul>
 268              </li>
 269              <li> Rename htaccess.dist to .htaccess and upload it back to the same directory.</li>
 270              </ul>";
 271          die( "Installation Aborted!" );
 272      }
 273  }
 274  
 275  function checkdirs() {
 276      global $dirs;
 277      $return = true;
 278  
 279      $errors = array();
 280      foreach( (array) $dirs as $dir ) {
 281          if( false == is_writeable( $dir ) ) {
 282              $errors[] = $dir;
 283          }
 284      }
 285  
 286      if( !empty( $errors ) ) {
 287          ?>
 288          <h2>Warning!</h2>
 289          <div style='border: 1px solid #ccc'>
 290              <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 />
 291                  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 />
 292                  Refresh this page when you're done!<br /></p>
 293          </div>
 294          <p>Quick fix:<br /> <code>chmod&nbsp;777&nbsp;<?php
 295          foreach( $errors as $dir ) {
 296              echo "$dir&nbsp;";
 297          }
 298          ?></code>
 299          </p>
 300          </div>
 301          <?php
 302          $return = false;
 303      }
 304      
 305      if( file_exists( "./.htaccess" ) && is_writeable( "./.htaccess" ) == false ) {
 306          ?>
 307          <h2>Warning! .htaccess already exists.</h2>
 308          <div style='border: 1px solid #ccc'>
 309              <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 />Offending file: <?php echo realpath( '.htaccess' ); ?></p>
 310          </div>
 311          <?php
 312          $return = false;
 313      }
 314      
 315      return $return;
 316  }
 317  
 318  function step1() {
 319      ?>
 320      <h2>Installing WordPress &micro;</h2>
 321      <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>
 322      <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 yourself may result in a broken site. It's much easier to use this installer to get the job done.</p>
 323      
 324      <h2>What do I need?</h2>
 325      <ul>
 326          <li>Access to your server to change directory permissions. This can be done through ssh or ftp for example.</li>
 327          <li>A valid email where your password and administrative emails will be sent.</li>
 328          <li>An empty MySQL database.Tables are prefixed with <code>wp_</code> which may conflict with an existing WordPress install.</li>
 329          <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>
 330      </ul>
 331      <?php
 332      $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>";
 333      
 334      if( function_exists( "apache_get_modules" ) ) {
 335          $modules = apache_get_modules();
 336          if( in_array( "mod_rewrite", $modules ) == false ) {
 337              echo "<p><strong>Warning!</strong> It looks like mod_rewrite is not installed.</p>" . $mod_rewrite_msg;
 338          }
 339      } else {
 340          ?><p>Please make sure <code>mod_rewrite</code> is installed as it will be activated at the end of this install.</p><?php
 341          echo $mod_rewrite_msg;
 342      }
 343      
 344      if( checkdirs() == false ) {
 345          return false;
 346      }
 347  
 348      // Create Blogs living area.
 349      @mkdir( dirname(__FILE__) . "/wp-content/blogs.dir", 0777 );
 350  
 351      $url = stripslashes( "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] ) );
 352      if( substr( $url, -1 ) == '/' )
 353          $url = substr( $url, 0, -1 );
 354      $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) );
 355      if( $base != "/") {
 356          $base .= "/";
 357      } 
 358  
 359      return true;
 360  }
 361  
 362  function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'password', $dbhost = 'localhost', $vhost = 'yes', $prefix = 'wp_' ) {
 363      $weblog_title = ucfirst( $_SERVER[ 'HTTP_HOST' ] ) . ' Blogs';
 364      $email = '';
 365      $hostname = $_SERVER[ 'HTTP_HOST' ];
 366      if( substr( $_SERVER[ 'HTTP_HOST' ], 0, 4 ) == 'www.' )
 367          $hostname = str_replace( "www.", "", $_SERVER[ 'HTTP_HOST' ] );
 368      ?>
 369      <form method='post' action='index.php'> 
 370          <input type='hidden' name='action' value='step2' />
 371          <h2>Blog Addresses</h2>
 372          <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>
 373          <p class="blog-address">
 374              <label><input type='radio' name='vhost' value='yes' <?php if( $vhost == 'yes' ) echo 'checked="checked"'; ?> /> Sub-domains (like <code>blog1.example.com</code>)</label><br />
 375              <label><input type='radio' name='vhost' value='no' <?php if( $vhost == 'no' ) echo 'checked="checked"'; ?> /> Sub-directories (like <code>example.com/blog1</code>)</label>
 376          </p>
 377  
 378          <h2>Database</h2>
 379  
 380          <p>Below you should enter your database connection details. If you're not sure about these, contact your host.</p>
 381          <table class="form-table"> 
 382              <tr> 
 383                  <th scope='row' width='33%'>Database Name</th> 
 384                  <td><input name='dbname' type='text' size='45' value='<?php echo $dbname ?>' /></td>  
 385              </tr> 
 386              <tr> 
 387                  <th scope='row'>User Name</th> 
 388                  <td><input name='uname' type='text' size='45' value='<?php echo $uname ?>' /></td> 
 389              </tr> 
 390              <tr> 
 391                  <th scope='row'>Password</th> 
 392                  <td><input name='pwd' type='text' size='45' value='<?php echo $pwd ?>' /></td> 
 393              </tr> 
 394              <tr> 
 395                  <th scope='row'>Database Host</th> 
 396                  <td><input name='dbhost' type='text' size='45' value='<?php echo $dbhost ?>' /></td> 
 397              </tr>
 398          </table> 
 399  
 400          <h2>Server Address</h2>
 401          <table class="form-table">  
 402              <tr> 
 403                  <th scope='row'>Server Address</th> 
 404                  <td>
 405                      <input type='text' name='basedomain' value='<?php echo $hostname ?>' />
 406                      <p>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.</p>
 407                      <p>Do not use an IP address (like 127.0.0.1) as your server address. Do not use a single word hostname like <q>localhost</q>, use <q>localhost.localdomain</q> instead.</p>
 408                  </td> 
 409              </tr>
 410          </table>
 411  
 412          <h2>Site Details</h2>
 413          <table class="form-table">  
 414              <tr> 
 415                  <th scope='row'>Site&nbsp;Title</th> 
 416                  <td>
 417                      <input name='weblog_title' type='text' size='45' value='<?php echo $weblog_title ?>' />
 418                      <br />What would you like to call your site?
 419                  </td> 
 420              </tr> 
 421              <tr> 
 422                  <th scope='row'>Email</th> 
 423                  <td>
 424                      <input name='email' type='text' size='45' value='<?php echo $email ?>' /> 
 425                      <br />Your email address.
 426                  </td> 
 427              </tr> 
 428          </table> 
 429          <p class='submit'><input class="button" name='submit' type='submit' value='Submit' /></p>
 430      </form> 
 431      <?php
 432  }
 433  
 434  function step2() {
 435      global $base, $wpdb;
 436  
 437      $dbname  = stripslashes($_POST['dbname']);
 438      $uname   = stripslashes($_POST['uname']);
 439      $passwrd = stripslashes($_POST['pwd']);
 440      $dbhost  = stripslashes($_POST['dbhost']);
 441      $vhost   = stripslashes($_POST['vhost' ]);
 442      $prefix  = 'wp_'; // Hardcoded
 443  
 444      $base = stripslashes( dirname($_SERVER["SCRIPT_NAME"]) );
 445      if( $base != "/")
 446          $base .= "/";
 447  
 448      // Test the db connection.
 449      define('DB_NAME', $dbname);
 450      define('DB_USER', $uname);
 451      define('DB_PASSWORD', $passwrd);
 452      define('DB_HOST', $dbhost);
 453  
 454      if ( !file_exists( 'wp-config-sample.php' ) )
 455          die( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.' );
 456  
 457      if ( file_exists( 'wp-config.php' ) )
 458          die( 'Sorry, the file wp-config.php already exists. Please delete it and reload this page.' );
 459  
 460      if ( file_exists( '.htaccess' ) )
 461          die( 'Sorry, the file .htaccess already exists. Please delete it and reload this page.' );
 462  
 463      $wp_config_file = file('wp-config-sample.php');
 464      // We'll fail here if the values are no good.
 465      require_once ('wp-includes/wp-db.php');
 466      printheader();
 467  
 468      $handle = fopen('wp-config.php', 'w');
 469  
 470      foreach ($wp_config_file as $line) {
 471          switch ( trim( substr($line,0,16) ) ) {
 472              case "define('DB_NAME'":
 473                  fwrite($handle, str_replace("wordpress", $dbname, $line));
 474                  break;
 475              case "define('DB_USER'":
 476                  fwrite($handle, str_replace("'username'", "'$uname'", $line));
 477                  break;
 478              case "define('DB_PASSW":
 479                  fwrite($handle, str_replace("'password'", "'$passwrd'", $line));
 480                  break;
 481              case "define('DB_HOST'":
 482                  fwrite($handle, str_replace("localhost", $dbhost, $line));
 483                  break;
 484              case "define('VHOST',":
 485                  fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line));
 486                  break;
 487              case '$table_prefix  =':
 488                  fwrite($handle, str_replace('wp_', $prefix, $line));
 489                  break;
 490              case '$base = \'BASE\';':
 491                  fwrite($handle, str_replace('BASE', $base, $line));
 492                  break;
 493              case "define('DOMAIN_C":
 494                  $domain = get_clean_basedomain();
 495                  fwrite($handle, str_replace("current_site_domain", $domain, $line));
 496                  break;
 497              case "define('PATH_CUR":
 498                  fwrite($handle, str_replace("current_site_path", str_replace( 'index.php', '', $_SERVER[ 'REQUEST_URI' ] ), $line));
 499                  break;
 500              case "define('AUTH_KEY":
 501              case "define('AUTH_SAL":
 502              case "define('LOGGED_I":
 503              case "define('SECURE_A":
 504              case "define('NONCE_KE":
 505                  fwrite($handle, str_replace('put your unique phrase here', md5( mt_rand() ) . md5( mt_rand() ), $line));
 506                  break;
 507              default:
 508                  fwrite($handle, $line);
 509                  break;
 510          }
 511      }
 512      fclose($handle);
 513      chmod('wp-config.php', 0644);
 514      define( 'VHOST', $vhost );
 515  }
 516  
 517  function get_clean_basedomain() {
 518      global $wpdb;
 519      $domain =   $wpdb->escape( $_POST[ 'basedomain' ] );
 520      $domain = str_replace( 'http://', '', $domain );
 521      if( substr( $domain, 0, 4 ) == 'www.' )
 522          $domain = substr( $domain, 4 );
 523      if( strpos( $domain, '/' ) )
 524          $domain = substr( $domain, 0, strpos( $domain, '/' ) );
 525      return $domain;
 526  }
 527  
 528  function step3() {
 529      global $wpdb, $current_site, $dirs, $wpmu_version, $wp_db_version;
 530      $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) );
 531      if( $base != "/") {
 532          $base .= "/";
 533      } 
 534      $domain = get_clean_basedomain();
 535      $email = $wpdb->escape( $_POST[ 'email' ] );
 536      if( $email == '' )
 537          die( 'You must enter an email address!' );
 538  
 539      // set up site tables
 540      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_name', '" . $wpdb->escape( $_POST[ 'weblog_title' ] ) . "')" );
 541      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_email', '".$email."')" );
 542      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_user_id', '1')" );
 543      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'registration', 'none')" );
 544      $wpdb->query( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( NULL, '$domain', '$base' )" );
 545      $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (1, 'Uncategorized', 'uncategorized', NOW())" );
 546      $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (2, 'Blogroll', 'blogroll', NOW())" );
 547      $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' )" );
 548      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'blog_upload_space', '10' )" );
 549      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'fileupload_maxk', '1500' )" );
 550      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_admins', '" . serialize( array( 'admin' ) ) . "' )" );
 551      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'allowedthemes', '" . serialize( array( 'classic' => 1, 'default' => 1 ) ) . "' )" );
 552      $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" ) ) . "' )" );
 553      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'wpmu_upgrade_site', '{$wp_db_version}')" );
 554      $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'welcome_email', 'Dear User,
 555  
 556  Your new SITE_NAME blog has been successfully set up at:
 557  BLOG_URL
 558  
 559  You can log in to the administrator account with the following information:
 560  Username: USERNAME
 561  Password: PASSWORD
 562  Login Here: BLOG_URLwp-login.php
 563  
 564  We hope you enjoy your new blog.
 565  Thanks!
 566  
 567  --The Team @ SITE_NAME')" );
 568      $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!' )" );
 569      $weblog_title = stripslashes( $_POST[ 'weblog_title' ] );
 570  
 571      $pass = substr( md5( rand() ), 5, 12 );
 572      $user_id = wpmu_create_user( 'admin', $pass, $email);
 573  
 574      $current_site->domain = $domain;
 575      $current_site->path = $base;
 576      $current_site->site_name = ucfirst( $domain );
 577  
 578      wpmu_create_blog( $domain, $base, $weblog_title, $user_id, array( 'blog_public' => 1, 'public' => 1 ) );
 579      update_blog_option( 1, 'template', 'home');
 580      update_blog_option( 1, 'stylesheet', 'home');
 581      
 582      if( constant( 'VHOST' ) == 'yes' ) {
 583          update_blog_option( 1, 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
 584      } else {
 585          update_blog_option( 1, 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');
 586      }
 587      update_blog_option( 1, 'rewrite_rules', false );
 588      
 589      $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";
 590      wp_mail( $email, "Your new WordPress MU site is ready!", $msg, "From: wordpress@" . $_SERVER[ 'HTTP_HOST' ]  );
 591      ?>
 592      <h2>Installation Finished!</h2>
 593      <p>Congratulations! <br />Your <a href='http://<?php echo $domain . $base; ?>'>WordPress &micro; site</a> has been configured.</p>
 594      <p>You can <a class="button" href='wp-login.php'>log in</a> using the username "admin" and password <?php echo $pass; ?></p>
 595  
 596      <?php
 597      
 598      if ( $_POST['vhost' ] == 'yes' ) {
 599          $vhost_ok = false;
 600          $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
 601          if( include_once ( 'wp-includes/http.php' ) ) {
 602              $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) );
 603              if( is_object( $page ) && is_wp_error( $page ) ) {
 604                  foreach ( $page->get_error_messages() as $err )
 605                      $errstr = $err;
 606              } elseif( $page[ 'response' ][ 'code' ] == 200 ) {
 607                      $vhost_ok = true;    
 608              }
 609          } else {
 610              $fp = fsockopen( $hostname, 80, $errno, $errstr, 5 ); // Very random hostname!
 611              if( $fp ) {
 612                  $vhost_ok = true;
 613                  fclose( $fp );
 614              }
 615          }
 616          if( !$vhost_ok ) {
 617              echo "<h2>Warning! Wildcard DNS may not be configured correctly!</h2>";
 618              echo "<p>To use the subdomain feature of WordPress MU you must have a wildcard entry in your dns. The installer attempted to contact a random hostname ($hostname) on your domain but failed. It returned this error message:<br /> <strong>$errstr</strong></p><p>From the README.txt:</p>";
 619              echo "<p><blockquote> If you want to host blogs of the form http://blog.domain.tld/ where domain.tld is the domain name of your machine then you must add a wildcard record to your DNS records.<br />
 620  This usually means adding a '*' hostname record pointing at your webserver in your DNS configuration tool.  Matt has a more detailed <a href='http://ma.tt/2003/10/10/wildcard-dns-and-sub-domains/'>explanation</a> on his blog. If you still have problems, these <a href='http://mu.wordpress.org/forums/tags/wildcard'>forum messages</a> may help.</blockquote></p>";
 621              echo "<p>You can still use your site but any subdomain you create may not be accessible. This check is not foolproof so ignore if you know your dns is correct.</p>";
 622          }
 623      }
 624  
 625      ?>
 626      
 627      <h3>Directory Permissions</h3>
 628      <p>Please remember to reset the permissions on the following directories:
 629          <ul>
 630          <?php
 631          reset( $dirs );
 632          foreach( (array) $dirs as $dir ) {
 633              echo "<li>$dir</li>";
 634          }
 635          ?>
 636          </ul>
 637      </p>
 638      <p>You can probably use the following command to fix the permissions but check with your host if it doubt:
 639          <br />
 640          <code>chmod&nbsp;755&nbsp;
 641              <?php
 642              reset( $dirs );
 643              foreach( (array) $dirs as $dir ) {
 644                  echo "$dir&nbsp;";
 645              }
 646              ?>
 647          </code>
 648      </p>
 649      <h3>Delete the Installer</h3>
 650      <p>Now that you've installed WordPress &micro;, you don't need the installer any more. You can safely delete <em>index-install.php</em> now. It's always a good idea to remove code and scripts you don't need.</p>
 651      
 652      <h3>Further reading</h3>
 653      <p>
 654          <ul>
 655              <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>
 656              <li>There is also the <a href='http://trac.mu.wordpress.org/'>WordPress &micro; Trac</a>. That's our bug tracker.</li>
 657          </ul>
 658      </p>
 659      <p>Thanks for installing WordPress &micro;!<br /><br />Donncha<br /><code>wpmu version: <?php echo $wpmu_version ?></code></p>
 660      <?php
 661  }
 662  
 663  function nowww() {
 664      $nowww = str_replace( 'www.', '', $_POST[ 'basedomain' ] );
 665      ?>
 666      <h2>No-www</h2>
 667      <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>
 668      <p>The preferred method of hosting blogs is without the "www" prefix as it's more compact and simple.</p>
 669      <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>
 670  
 671      <p><a href="http://no-www.org/">www. is depreciated</a> has a lot more information on why 'www.' isn't needed any more.</p>
 672      <p>
 673          <form method='post'>
 674              <input type='hidden' name='dbname' value='<?php echo $_POST[ 'dbname' ]; ?>' />
 675              <input type='hidden' name='uname' value='<?php echo $_POST[ 'uname' ]; ?>' />
 676              <input type='hidden' name='pwd' value='<?php echo $_POST[ 'pwd' ]; ?>' />
 677              <input type='hidden' name='dbhost' value='<?php echo $_POST[ 'dbhost' ]; ?>' />
 678              <input type='hidden' name='vhost' value='<?php echo $_POST[ 'vhost' ]; ?>' />
 679              <input type='hidden' name='weblog_title' value='<?php echo $_POST[ 'weblog_title' ]; ?>' />
 680              <input type='hidden' name='email' value='<?php echo $_POST[ 'email' ]; ?>' />
 681              <input type='hidden' name='action' value='step2' />
 682              <input type='hidden' name='basedomain' value='<?echo $nowww ?>' />
 683              <input class="button" type='submit' value='Continue' />
 684          </form>
 685      </p>
 686      <?php
 687  }
 688  
 689  $action = isset($_POST[ 'action' ]) ? $_POST[ 'action' ] : null; 
 690  switch($action) {
 691      case "step2":
 692          if( substr( $_POST[ 'basedomain' ], 0, 4 ) == 'www.' ) {
 693              printheader();
 694              nowww();
 695              continue;
 696          }
 697          
 698          // get blog username, create wp-config.php 
 699          step2();
 700  
 701          // Install Blog!
 702          include_once('./wp-config.php');
 703          include_once ('./wp-admin/includes/upgrade.php');
 704          
 705          $_SERVER[ 'HTTP_HOST' ] = str_replace( 'www.', '', $_SERVER[ 'HTTP_HOST' ] ); // normalise hostname - no www.
 706          make_db_current_silent();
 707          populate_options();
 708          global $base;
 709          do_htaccess( 'htaccess.dist', '.htaccess', $base, '');
 710          
 711          step3();
 712      break;
 713      default:
 714          // check that directories are writeable, create wpmu-settings.php and get db auth info
 715          printheader();
 716          if( step1() ) {
 717              printstep1form();
 718          }
 719      break;
 720  }
 721  ?>
 722  <br /><br />
 723  <div style="text-align:center;">
 724      <a href="http://mu.wordpress.org/">WordPress &micro;</a> | <a href="http://mu.wordpress.org/forums/">Support Forums</a>
 725  </div>
 726  </body>
 727  </html>


Generated: Mon May 3 12:25:32 2010 Cross-referenced by PHPXref 0.7