[ Index ]

PHP Cross Reference of Wordpress MU 2.7

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


Generated: Thu Mar 5 12:05:07 2009 Cross-referenced by PHPXref 0.7